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 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);
137 
138 } // libmspub
139 #endif /* __POLYGONUTILS_H__ */
140 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libmspub by doxygen 1.8.3