PolygonUtils.h
Go to the documentation of this file.
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 
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;
51 } Calculation;
52 
53 typedef struct
54 {
58 
60 {
62  unsigned m_numVertices;
63  const unsigned short *mp_elements;
64  unsigned m_numElements;
71  unsigned m_coordWidth;
72  unsigned m_coordHeight;
74  unsigned m_numGluePoints;
75  unsigned char m_adjustShiftMask;
76 
77  Coordinate getTextRectangle(double x, double y, double width, double height, std::function<double(unsigned index)> calculator) const;
78 
79  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) :
80  mp_vertices(p_vertices), m_numVertices(numVertices),
81  mp_elements(p_elements), m_numElements(numElements),
82  mp_calculations(p_calculations), m_numCalculations(numCalculations),
83  mp_defaultAdjustValues(p_defaultAdjustValues), m_numDefaultAdjustValues(numDefaultAdjustValues),
84  mp_textRectangles(p_textRectangles), m_numTextRectangles(numTextRectangles),
85  m_coordWidth(coordWidth), m_coordHeight(coordHeight),
86  mp_gluePoints(p_gluePoints), m_numGluePoints(numGluePoints),
87  m_adjustShiftMask(adjustShiftMask)
88  {
89  }
90 };
91 
93 {
94  std::vector<Vertex> m_vertices;
95  std::vector<unsigned short> m_elements;
96  std::vector<Calculation> m_calculations;
97  std::vector<int> m_defaultAdjustValues;
98  std::vector<TextRectangle> m_textRectangles;
99  std::vector<Vertex> m_gluePoints;
100  unsigned m_coordWidth;
101  unsigned m_coordHeight;
102  unsigned char m_adjustShiftMask;
103 
104  DynamicCustomShape(unsigned coordWidth, unsigned coordHeight)
105  : m_vertices(), m_elements(),
108  m_coordWidth(coordWidth), m_coordHeight(coordHeight),
110  {
111  }
112 };
113 
114 std::shared_ptr<const CustomShape> getFromDynamicCustomShape(const DynamicCustomShape &dcs);
115 
116 const CustomShape *getCustomShape(ShapeType type);
118 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);
119 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);
120 
121 } // libmspub
122 #endif /* INCLUDED_POLYGONUTILS_H */
123 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
std::vector< Vertex > m_vertices
Definition: PolygonUtils.h:94
unsigned m_coordWidth
Definition: PolygonUtils.h:71
const int PROP_ADJUST_VAL_FIRST
Definition: PolygonUtils.h:24
Definition: MSPUBTypes.h:199
const int * mp_defaultAdjustValues
Definition: PolygonUtils.h:67
Definition: PolygonUtils.h:92
int m_argThree
Definition: PolygonUtils.h:50
std::vector< TextRectangle > m_textRectangles
Definition: PolygonUtils.h:98
const int PROP_GEO_RIGHT
Definition: PolygonUtils.h:28
int m_flags
Definition: PolygonUtils.h:47
const int OTHER_CALC_VAL
Definition: PolygonUtils.h:31
int m_argTwo
Definition: PolygonUtils.h:49
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)
Definition: PolygonUtils.h:79
unsigned m_coordWidth
Definition: PolygonUtils.h:100
unsigned m_numVertices
Definition: PolygonUtils.h:62
librevenge::RVNGPropertyList calcClipPath(const std::vector< Vertex > &verts, double x, double y, double height, double width, VectorTransformation2D transform, std::shared_ptr< const CustomShape > shape)
Definition: PolygonUtils.cpp:5883
unsigned m_numElements
Definition: PolygonUtils.h:64
std::vector< unsigned short > m_elements
Definition: PolygonUtils.h:95
bool isShapeTypeRectangle(ShapeType type)
Definition: PolygonUtils.cpp:6375
Vertex second
Definition: PolygonUtils.h:56
Vertex first
Definition: PolygonUtils.h:55
const int PROP_GEO_LEFT
Definition: PolygonUtils.h:26
Definition: Coordinate.h:17
const unsigned short * mp_elements
Definition: PolygonUtils.h:63
unsigned m_numTextRectangles
Definition: PolygonUtils.h:70
Definition: PolygonUtils.h:39
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)
Definition: PolygonUtils.cpp:5908
int m_x
Definition: PolygonUtils.h:41
int m_argOne
Definition: PolygonUtils.h:48
const int PROP_GEO_TOP
Definition: PolygonUtils.h:27
const Vertex * mp_gluePoints
Definition: PolygonUtils.h:73
std::shared_ptr< const CustomShape > getFromDynamicCustomShape(const DynamicCustomShape &dcs)
Definition: PolygonUtils.cpp:6381
unsigned m_numDefaultAdjustValues
Definition: PolygonUtils.h:68
unsigned char m_adjustShiftMask
Definition: PolygonUtils.h:75
Coordinate getTextRectangle(double x, double y, double width, double height, std::function< double(unsigned index)> calculator) const
Definition: PolygonUtils.cpp:5683
int m_y
Definition: PolygonUtils.h:42
unsigned m_coordHeight
Definition: PolygonUtils.h:101
const int ASPECT_RATIO
Definition: PolygonUtils.h:32
DynamicCustomShape(unsigned coordWidth, unsigned coordHeight)
Definition: PolygonUtils.h:104
Definition: PolygonUtils.h:45
const TextRectangle * mp_textRectangles
Definition: PolygonUtils.h:69
const int PROP_ADJUST_VAL_LAST
Definition: PolygonUtils.h:25
Definition: Arrow.h:13
Definition: PolygonUtils.h:59
std::vector< Vertex > m_gluePoints
Definition: PolygonUtils.h:99
Definition: VectorTransformation2D.h:25
const CustomShape * getCustomShape(ShapeType type)
Definition: PolygonUtils.cpp:5245
Definition: PolygonUtils.h:53
const Calculation * mp_calculations
Definition: PolygonUtils.h:65
unsigned char m_adjustShiftMask
Definition: PolygonUtils.h:102
std::vector< int > m_defaultAdjustValues
Definition: PolygonUtils.h:97
const int PROP_GEO_BOTTOM
Definition: PolygonUtils.h:29
const Vertex * mp_vertices
Definition: PolygonUtils.h:61
unsigned m_coordHeight
Definition: PolygonUtils.h:72
ShapeType
Definition: ShapeType.h:15
std::vector< Calculation > m_calculations
Definition: PolygonUtils.h:96
Definition: Line.h:20
unsigned m_numGluePoints
Definition: PolygonUtils.h:74
unsigned m_numCalculations
Definition: PolygonUtils.h:66

Generated for libmspub by doxygen 1.8.14