/src/libmspub/src/lib/PolygonUtils.h
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* |
3 | | * This file is part of the libmspub project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #ifndef INCLUDED_POLYGONUTILS_H |
11 | | #define INCLUDED_POLYGONUTILS_H |
12 | | |
13 | | #include <functional> |
14 | | #include <memory> |
15 | | #include <vector> |
16 | | |
17 | | #include <librevenge/librevenge.h> |
18 | | |
19 | | #include "Coordinate.h" |
20 | | #include "ShapeType.h" |
21 | | |
22 | | namespace libmspub |
23 | | { |
24 | | const int PROP_ADJUST_VAL_FIRST = 327; |
25 | | const int PROP_ADJUST_VAL_LAST = 336; |
26 | | const int PROP_GEO_LEFT = 320; |
27 | | const int PROP_GEO_TOP = 321; |
28 | | const int PROP_GEO_RIGHT = 322; |
29 | | const int PROP_GEO_BOTTOM = 323; |
30 | | |
31 | | const int OTHER_CALC_VAL = 0x400; |
32 | | const int ASPECT_RATIO = 0x600; |
33 | | |
34 | | class VectorTransformation2D; |
35 | | |
36 | | struct Color; |
37 | | struct Line; |
38 | | |
39 | | typedef struct |
40 | | { |
41 | | int m_x; |
42 | | int m_y; |
43 | | } Vertex; |
44 | | |
45 | | typedef struct |
46 | | { |
47 | | int m_flags; |
48 | | int m_argOne; |
49 | | int m_argTwo; |
50 | | int m_argThree; |
51 | | } Calculation; |
52 | | |
53 | | typedef struct |
54 | | { |
55 | | Vertex first; |
56 | | Vertex second; |
57 | | } TextRectangle; |
58 | | |
59 | | struct CustomShape |
60 | | { |
61 | | const Vertex *mp_vertices; |
62 | | unsigned m_numVertices; |
63 | | const unsigned short *mp_elements; |
64 | | unsigned m_numElements; |
65 | | const Calculation *mp_calculations; |
66 | | unsigned m_numCalculations; |
67 | | const int *mp_defaultAdjustValues; |
68 | | unsigned m_numDefaultAdjustValues; |
69 | | const TextRectangle *mp_textRectangles; |
70 | | unsigned m_numTextRectangles; |
71 | | unsigned m_coordWidth; |
72 | | unsigned m_coordHeight; |
73 | | const Vertex *mp_gluePoints; |
74 | | unsigned m_numGluePoints; |
75 | | unsigned char m_adjustShiftMask; |
76 | | |
77 | | CustomShape(const Vertex *p_vertices, unsigned numVertices, const unsigned short *p_elements, unsigned numElements, const Calculation *p_calculations, unsigned numCalculations, const int *p_defaultAdjustValues, unsigned numDefaultAdjustValues, const TextRectangle *p_textRectangles, unsigned numTextRectangles, unsigned coordWidth, unsigned coordHeight, const Vertex *p_gluePoints, unsigned numGluePoints, unsigned char adjustShiftMask = 0) : |
78 | 12.4k | mp_vertices(p_vertices), m_numVertices(numVertices), |
79 | 12.4k | mp_elements(p_elements), m_numElements(numElements), |
80 | 12.4k | mp_calculations(p_calculations), m_numCalculations(numCalculations), |
81 | 12.4k | mp_defaultAdjustValues(p_defaultAdjustValues), m_numDefaultAdjustValues(numDefaultAdjustValues), |
82 | 12.4k | mp_textRectangles(p_textRectangles), m_numTextRectangles(numTextRectangles), |
83 | 12.4k | m_coordWidth(coordWidth), m_coordHeight(coordHeight), |
84 | 12.4k | mp_gluePoints(p_gluePoints), m_numGluePoints(numGluePoints), |
85 | 12.4k | m_adjustShiftMask(adjustShiftMask) |
86 | 12.4k | { |
87 | 12.4k | } |
88 | | }; |
89 | | |
90 | | struct DynamicCustomShape |
91 | | { |
92 | | std::vector<Vertex> m_vertices; |
93 | | std::vector<unsigned short> m_elements; |
94 | | std::vector<Calculation> m_calculations; |
95 | | std::vector<int> m_defaultAdjustValues; |
96 | | std::vector<TextRectangle> m_textRectangles; |
97 | | std::vector<Vertex> m_gluePoints; |
98 | | unsigned m_coordWidth; |
99 | | unsigned m_coordHeight; |
100 | | unsigned char m_adjustShiftMask; |
101 | | |
102 | | DynamicCustomShape(unsigned coordWidth, unsigned coordHeight) |
103 | 628 | : m_vertices(), m_elements(), |
104 | 628 | m_calculations(), m_defaultAdjustValues(), |
105 | 628 | m_textRectangles(), m_gluePoints(), |
106 | 628 | m_coordWidth(coordWidth), m_coordHeight(coordHeight), |
107 | 628 | m_adjustShiftMask(0) |
108 | 628 | { |
109 | 628 | } |
110 | | }; |
111 | | |
112 | | std::shared_ptr<const CustomShape> getFromDynamicCustomShape(const DynamicCustomShape &dcs); |
113 | | |
114 | | const CustomShape *getCustomShape(ShapeType type); |
115 | | bool isShapeTypeRectangle(ShapeType type); |
116 | | librevenge::RVNGPropertyList calcClipPath(const std::vector<libmspub::Vertex> &verts, double x, double y, double height, double width, VectorTransformation2D transform, std::shared_ptr<const CustomShape> shape); |
117 | | void writeCustomShape(ShapeType shapeType, librevenge::RVNGPropertyList &graphicsProps, librevenge::RVNGDrawingInterface *painter, double x, double y, double height, double width, bool closeEverything, VectorTransformation2D transform, std::vector<Line> lines, std::function<double(unsigned index)> calculator, const std::vector<Color> &palette, std::shared_ptr<const CustomShape> shape); |
118 | | |
119 | | } // libmspub |
120 | | #endif /* INCLUDED_POLYGONUTILS_H */ |
121 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |