WPSGraphicShape.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
3/* libwps
4 * Version: MPL 2.0 / LGPLv2.1+
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 *
10 * Major Contributor(s):
11 * Copyright (C) 2002, 2005 William Lachance (william.lachance@sympatico.ca)
12 * Copyright (C) 2002, 2004 Marc Maurer (uwog@uwog.net)
13 *
14 * For minor contributions see the git repository.
15 *
16 * Alternatively, the contents of this file may be used under the terms
17 * of the GNU Lesser General Public License Version 2.1 or later
18 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19 * applicable instead of those above.
20 *
21 * For further information visit http://libwps.sourceforge.net
22*/
23#ifndef WPS_GRAPHIC_SHAPE
24# define WPS_GRAPHIC_SHAPE
25# include <ostream>
26# include <string>
27# include <vector>
28
29# include "librevenge/librevenge.h"
30
31# include "libwps_internal.h"
32
35{
36public:
42 struct PathData
43 {
45 PathData(char type, Vec2f const &x=Vec2f(), Vec2f const &x1=Vec2f(), Vec2f const &x2=Vec2f()):
46 m_type(type), m_x(x), m_x1(x1), m_x2(x2), m_r(), m_rotate(0), m_largeAngle(false), m_sweep(false)
47 {
48 }
50 void translate(Vec2f const &delta);
52 void scale(Vec2f const &factor);
54 void rotate(float angle, Vec2f const &delta);
56 void transform(WPSTransformation const &matrix, float rotation);
58 bool get(librevenge::RVNGPropertyList &pList, Vec2f const &orig) const;
60 friend std::ostream &operator<<(std::ostream &o, PathData const &path);
62 int cmp(PathData const &a) const;
64 char m_type;
74 float m_rotate;
78 bool m_sweep;
79 };
80
89 static WPSGraphicShape line(Vec2f const &orign, Vec2f const &dest);
91 static WPSGraphicShape rectangle(WPSBox2f const &box, Vec2f const &corners=Vec2f(0,0))
92 {
94 res.m_type=Rectangle;
95 res.m_bdBox=res.m_formBox=box;
96 res.m_cornerWidth=corners;
97 return res;
98 }
100 static WPSGraphicShape circle(WPSBox2f const &box)
101 {
102 WPSGraphicShape res;
103 res.m_type=Circle;
104 res.m_bdBox=res.m_formBox=box;
105 return res;
106 }
108 static WPSGraphicShape arc(WPSBox2f const &box, WPSBox2f const &circleWPSBox, Vec2f const &angles)
109 {
110 WPSGraphicShape res;
111 res.m_type=Arc;
112 res.m_bdBox=box;
113 res.m_formBox=circleWPSBox;
114 res.m_arcAngles=angles;
115 return res;
116 }
118 static WPSGraphicShape pie(WPSBox2f const &box, WPSBox2f const &circleWPSBox, Vec2f const &angles)
119 {
120 WPSGraphicShape res;
121 res.m_type=Pie;
122 res.m_bdBox=box;
123 res.m_formBox=circleWPSBox;
124 res.m_arcAngles=angles;
125 return res;
126 }
129 {
130 WPSGraphicShape res;
131 res.m_type=Polygon;
132 res.m_bdBox=box;
133 return res;
134 }
136 static WPSGraphicShape path(WPSBox2f const &box)
137 {
138 WPSGraphicShape res;
139 res.m_type=Path;
140 res.m_bdBox=box;
141 return res;
142 }
143
145 void translate(Vec2f const &delta);
147 void scale(Vec2f const &factor);
151 WPSGraphicShape rotate(float angle, Vec2f const &center) const;
153 WPSGraphicShape transform(WPSTransformation const &matrix) const;
155 Type getType() const
156 {
157 return m_type;
158 }
161 {
162 return m_bdBox;
163 }
165 Command addTo(Vec2f const &orig, bool asSurface, librevenge::RVNGPropertyList &propList) const;
167 friend std::ostream &operator<<(std::ostream &o, WPSGraphicShape const &sh);
169 int cmp(WPSGraphicShape const &a) const;
170protected:
172 std::vector<PathData> getPath(bool forTransformation) const;
173public:
185 std::vector<Vec2f> m_vertices;
187 std::vector<PathData> m_path;
189 std::string m_extra;
190};
191#endif
192/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
a structure used to define a picture shape
Definition WPSGraphicShape.h:35
void scale(Vec2f const &factor)
rescale all the coordinate
Definition WPSGraphicShape.cpp:320
Vec2f m_cornerWidth
the rectangle round corner
Definition WPSGraphicShape.h:181
WPSGraphicShape transform(WPSTransformation const &matrix) const
returns a new shape corresponding to a matrix transformation
Definition WPSGraphicShape.cpp:357
void translate(Vec2f const &delta)
translate all the coordinate by delta
Definition WPSGraphicShape.cpp:308
Command addTo(Vec2f const &orig, bool asSurface, librevenge::RVNGPropertyList &propList) const
updates the propList to send to an interface
Definition WPSGraphicShape.cpp:389
std::vector< PathData > getPath(bool forTransformation) const
return a path corresponding to the shape
Definition WPSGraphicShape.cpp:534
WPSBox2f m_bdBox
the shape bdbox
Definition WPSGraphicShape.h:177
Type getType() const
returns the type corresponding to a shape
Definition WPSGraphicShape.h:155
Command
an enum used to define the interface command
Definition WPSGraphicShape.h:40
@ C_Bad
Definition WPSGraphicShape.h:40
@ C_Path
Definition WPSGraphicShape.h:40
@ C_Polyline
Definition WPSGraphicShape.h:40
@ C_Ellipse
Definition WPSGraphicShape.h:40
@ C_Rectangle
Definition WPSGraphicShape.h:40
@ C_Polygon
Definition WPSGraphicShape.h:40
WPSBox2f m_formBox
the internal shape bdbox ( used for arc, circle to store the circle bdbox )
Definition WPSGraphicShape.h:179
Type
an enum used to define the shape type
Definition WPSGraphicShape.h:38
@ Pie
Definition WPSGraphicShape.h:38
@ Line
Definition WPSGraphicShape.h:38
@ Polygon
Definition WPSGraphicShape.h:38
@ ShapeUnknown
Definition WPSGraphicShape.h:38
@ Arc
Definition WPSGraphicShape.h:38
@ Rectangle
Definition WPSGraphicShape.h:38
@ Circle
Definition WPSGraphicShape.h:38
@ Path
Definition WPSGraphicShape.h:38
static WPSGraphicShape circle(WPSBox2f const &box)
static constructor to create a circle
Definition WPSGraphicShape.h:100
static WPSGraphicShape arc(WPSBox2f const &box, WPSBox2f const &circleWPSBox, Vec2f const &angles)
static constructor to create a arc
Definition WPSGraphicShape.h:108
friend std::ostream & operator<<(std::ostream &o, WPSGraphicShape const &sh)
a print operator
Definition WPSGraphicShape.cpp:230
std::vector< PathData > m_path
the list of path component
Definition WPSGraphicShape.h:187
std::string m_extra
extra data
Definition WPSGraphicShape.h:189
static WPSGraphicShape polygon(WPSBox2f const &box)
static constructor to create a polygon
Definition WPSGraphicShape.h:128
static WPSGraphicShape line(Vec2f const &orign, Vec2f const &dest)
static constructor to create a line
Definition WPSGraphicShape.cpp:211
WPSBox2f getBdBox() const
returns the basic bdbox
Definition WPSGraphicShape.h:160
int cmp(WPSGraphicShape const &a) const
compare two shapes
Definition WPSGraphicShape.cpp:279
WPSGraphicShape()
constructor
Definition WPSGraphicShape.h:82
static WPSGraphicShape path(WPSBox2f const &box)
static constructor to create a path
Definition WPSGraphicShape.h:136
std::vector< Vec2f > m_vertices
the list of vertices for lines or polygons
Definition WPSGraphicShape.h:185
Type m_type
the type
Definition WPSGraphicShape.h:175
static WPSGraphicShape pie(WPSBox2f const &box, WPSBox2f const &circleWPSBox, Vec2f const &angles)
static constructor to create a pie
Definition WPSGraphicShape.h:118
static WPSGraphicShape rectangle(WPSBox2f const &box, Vec2f const &corners=Vec2f(0, 0))
static constructor to create a rectangle
Definition WPSGraphicShape.h:91
WPSGraphicShape rotate(float angle, Vec2f const &center) const
return a new shape corresponding to a rotation from center.
Definition WPSGraphicShape.cpp:333
Vec2f m_arcAngles
the start and end value which defines an arc
Definition WPSGraphicShape.h:183
~WPSGraphicShape()
destructor
Definition WPSGraphicShape.h:87
a transformation which stored the first row of a 3x3 perspective matrix
Definition libwps_internal.h:1090
Vec2< float > Vec2f
Vec2 of float.
Definition libwps_internal.h:721
a simple path component
Definition WPSGraphicShape.h:43
friend std::ostream & operator<<(std::ostream &o, PathData const &path)
a print operator
Definition WPSGraphicShape.cpp:41
Vec2f m_r
the radius ( A command)
Definition WPSGraphicShape.h:72
Vec2f m_x2
x2 value
Definition WPSGraphicShape.h:70
int cmp(PathData const &a) const
comparison function
Definition WPSGraphicShape.cpp:187
char m_type
the type: M, L, ...
Definition WPSGraphicShape.h:64
void scale(Vec2f const &factor)
scale all the coordinate by a factor
Definition WPSGraphicShape.cpp:90
Vec2f m_x
the main x value
Definition WPSGraphicShape.h:66
void translate(Vec2f const &delta)
translate all the coordinate by delta
Definition WPSGraphicShape.cpp:77
bool get(librevenge::RVNGPropertyList &pList, Vec2f const &orig) const
update the property list to correspond to a command
Definition WPSGraphicShape.cpp:143
void rotate(float angle, Vec2f const &delta)
rotate all the coordinate by angle (origin rotation) then translate coordinate
Definition WPSGraphicShape.cpp:103
bool m_largeAngle
large angle ( A command)
Definition WPSGraphicShape.h:76
Vec2f m_x1
x1 value
Definition WPSGraphicShape.h:68
float m_rotate
the rotate ( A command)
Definition WPSGraphicShape.h:74
void transform(WPSTransformation const &matrix, float rotation)
multiply all the coordinate by a matrix
Definition WPSGraphicShape.cpp:125
bool m_sweep
sweep value ( A command)
Definition WPSGraphicShape.h:78
PathData(char type, Vec2f const &x=Vec2f(), Vec2f const &x1=Vec2f(), Vec2f const &x2=Vec2f())
constructor
Definition WPSGraphicShape.h:45

Generated on Wed Nov 29 2023 19:00:10 for libwps by doxygen 1.9.8