PolygonUtils.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libmspub
3  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License or as specified alternatively below. You may obtain a copy of
8  * the License at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * Major Contributor(s):
16  * Copyright (C) 2012 Brennan Vincent <brennanv@email.arizona.edu>
17  *
18  * All Rights Reserved.
19  *
20  * For minor contributions see the git repository.
21  *
22  * Alternatively, the contents of this file may be used under the terms of
23  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
24  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
25  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
26  * instead of those above.
27  */
28 
29 #ifndef __POLYGONUTILS_H__
30 #define __POLYGONUTILS_H__
31 
32 #include <vector>
33 
34 #include <libwpg/libwpg.h>
35 #include <boost/function.hpp>
36 #include <boost/shared_ptr.hpp>
37 
38 #include "ShapeType.h"
39 #include "VectorTransformation2D.h"
40 #include "Coordinate.h"
41 #include "Line.h"
42 
43 namespace libmspub
44 {
45 const int PROP_ADJUST_VAL_FIRST = 327;
46 const int PROP_ADJUST_VAL_LAST = 336;
47 const int PROP_GEO_LEFT = 320;
48 const int PROP_GEO_TOP = 321;
49 const int PROP_GEO_RIGHT = 322;
50 const int PROP_GEO_BOTTOM = 323;
51 
52 const int OTHER_CALC_VAL = 0x400;
53 const int ASPECT_RATIO = 0x600;
54 
55 class MSPUBCollector;
56 
57 typedef struct
58 {
59  int m_x;
60  int m_y;
61 } Vertex;
62 
63 typedef struct
64 {
65  int m_flags;
66  int m_argOne;
67  int m_argTwo;
69 } Calculation;
70 
71 typedef struct
72 {
76 
78 {
80  unsigned m_numVertices;
81  const unsigned short *mp_elements;
82  unsigned m_numElements;
89  unsigned m_coordWidth;
90  unsigned m_coordHeight;
92  unsigned m_numGluePoints;
93  unsigned char m_adjustShiftMask;
94 
95  Coordinate getTextRectangle(double x, double y, double width, double height, boost::function<double (unsigned index)> calculator) const;
96 
97  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) :
98  mp_vertices(p_vertices), m_numVertices(numVertices),
99  mp_elements(p_elements), m_numElements(numElements),
100  mp_calculations(p_calculations), m_numCalculations(numCalculations),
101  mp_defaultAdjustValues(p_defaultAdjustValues), m_numDefaultAdjustValues(numDefaultAdjustValues),
102  mp_textRectangles(p_textRectangles), m_numTextRectangles(numTextRectangles),
103  m_coordWidth(coordWidth), m_coordHeight(coordHeight),
104  mp_gluePoints(p_gluePoints), m_numGluePoints(numGluePoints),
105  m_adjustShiftMask(adjustShiftMask)
106  {
107  }
108 };
109 
111 {
112  std::vector<Vertex> m_vertices;
113  std::vector<unsigned short> m_elements;
114  std::vector<Calculation> m_calculations;
115  std::vector<int> m_defaultAdjustValues;
116  std::vector<TextRectangle> m_textRectangles;
117  std::vector<Vertex> m_gluePoints;
118  unsigned m_coordWidth;
119  unsigned m_coordHeight;
120  unsigned char m_adjustShiftMask;
121 
122  DynamicCustomShape(unsigned coordWidth, unsigned coordHeight)
123  : m_vertices(), m_elements(),
126  m_coordWidth(coordWidth), m_coordHeight(coordHeight),
128  {
129  }
130 };
131 
132 boost::shared_ptr<const CustomShape> getFromDynamicCustomShape(const DynamicCustomShape &dcs);
133 
134 const CustomShape *getCustomShape(ShapeType type);
136 WPXPropertyList calcClipPath(const std::vector<libmspub::Vertex> &verts, double x, double y, double height, double width, VectorTransformation2D transform, boost::shared_ptr<const CustomShape> shape);
137 void writeCustomShape(ShapeType shapeType, WPXPropertyList &graphicsProps, libwpg::WPGPaintInterface *painter, double x, double y, double height, double width, bool closeEverything, VectorTransformation2D transform, std::vector<Line> lines, boost::function<double(unsigned index)> calculator, const std::vector<Color> &palette, boost::shared_ptr<const CustomShape> shape);
138 
139 } // libmspub
140 #endif /* __POLYGONUTILS_H__ */
141 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
std::vector< Vertex > m_vertices
Definition: PolygonUtils.h:112
unsigned m_coordWidth
Definition: PolygonUtils.h:89
const int PROP_ADJUST_VAL_FIRST
Definition: PolygonUtils.h:45
const int * mp_defaultAdjustValues
Definition: PolygonUtils.h:85
Definition: PolygonUtils.h:110
int m_argThree
Definition: PolygonUtils.h:68
std::vector< TextRectangle > m_textRectangles
Definition: PolygonUtils.h:116
boost::shared_ptr< const CustomShape > getFromDynamicCustomShape(const DynamicCustomShape &dcs)
Definition: PolygonUtils.cpp:6398
const int PROP_GEO_RIGHT
Definition: PolygonUtils.h:49
int m_flags
Definition: PolygonUtils.h:65
const int OTHER_CALC_VAL
Definition: PolygonUtils.h:52
void writeCustomShape(ShapeType shapeType, WPXPropertyList &graphicsProps, libwpg::WPGPaintInterface *painter, double x, double y, double height, double width, bool closeEverything, VectorTransformation2D transform, std::vector< Line > lines, boost::function< double(unsigned index)> calculator, const std::vector< Color > &palette, boost::shared_ptr< const CustomShape > shape)
Definition: PolygonUtils.cpp:5929
int m_argTwo
Definition: PolygonUtils.h:67
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:97
unsigned m_coordWidth
Definition: PolygonUtils.h:118
unsigned m_numVertices
Definition: PolygonUtils.h:80
Coordinate getTextRectangle(double x, double y, double width, double height, boost::function< double(unsigned index)> calculator) const
Definition: PolygonUtils.cpp:5706
unsigned m_numElements
Definition: PolygonUtils.h:82
std::vector< unsigned short > m_elements
Definition: PolygonUtils.h:113
bool isShapeTypeRectangle(ShapeType type)
Definition: PolygonUtils.cpp:6392
Vertex second
Definition: PolygonUtils.h:74
Vertex first
Definition: PolygonUtils.h:73
const int PROP_GEO_LEFT
Definition: PolygonUtils.h:47
Definition: Coordinate.h:34
const unsigned short * mp_elements
Definition: PolygonUtils.h:81
unsigned m_numTextRectangles
Definition: PolygonUtils.h:88
Definition: PolygonUtils.h:57
int m_x
Definition: PolygonUtils.h:59
int m_argOne
Definition: PolygonUtils.h:66
const int PROP_GEO_TOP
Definition: PolygonUtils.h:48
const Vertex * mp_gluePoints
Definition: PolygonUtils.h:91
unsigned m_numDefaultAdjustValues
Definition: PolygonUtils.h:86
unsigned char m_adjustShiftMask
Definition: PolygonUtils.h:93
int m_y
Definition: PolygonUtils.h:60
unsigned m_coordHeight
Definition: PolygonUtils.h:119
const int ASPECT_RATIO
Definition: PolygonUtils.h:53
DynamicCustomShape(unsigned coordWidth, unsigned coordHeight)
Definition: PolygonUtils.h:122
Definition: PolygonUtils.h:63
const TextRectangle * mp_textRectangles
Definition: PolygonUtils.h:87
const int PROP_ADJUST_VAL_LAST
Definition: PolygonUtils.h:46
Definition: PolygonUtils.h:77
WPXPropertyList calcClipPath(const std::vector< libmspub::Vertex > &verts, double x, double y, double height, double width, VectorTransformation2D transform, boost::shared_ptr< const CustomShape > shape)
Definition: PolygonUtils.cpp:5904
std::vector< Vertex > m_gluePoints
Definition: PolygonUtils.h:117
const CustomShape * getCustomShape(ShapeType type)
Definition: PolygonUtils.cpp:5268
Definition: PolygonUtils.h:71
Definition: MSPUBCollector.h:66
const Calculation * mp_calculations
Definition: PolygonUtils.h:83
unsigned char m_adjustShiftMask
Definition: PolygonUtils.h:120
std::vector< int > m_defaultAdjustValues
Definition: PolygonUtils.h:115
const int PROP_GEO_BOTTOM
Definition: PolygonUtils.h:50
const Vertex * mp_vertices
Definition: PolygonUtils.h:79
unsigned m_coordHeight
Definition: PolygonUtils.h:90
ShapeType
Definition: ShapeType.h:34
std::vector< Calculation > m_calculations
Definition: PolygonUtils.h:114
unsigned m_numGluePoints
Definition: PolygonUtils.h:92
unsigned m_numCalculations
Definition: PolygonUtils.h:84

Generated for libmspub by doxygen 1.8.6