MWAWGraphicShape.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MWAWGraphicShape.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33 #ifndef MWAW_GRAPHIC_SHAPE
34 # define MWAW_GRAPHIC_SHAPE
35 # include <ostream>
36 # include <string>
37 # include <vector>
38
39 # include "librevenge/librevenge.h"
40 # include "libmwaw_internal.hxx"
41
42 class MWAWGraphicStyle;
43
45 class MWAWGraphicShape
46 {
47 public:
49 enum Type { Arc, Circle, Line, Rectangle, Path, Pie, Polygon, ShapeUnknown };
51 enum Command { C_Ellipse, C_Polyline, C_Rectangle, C_Path, C_Polygon, C_Bad };
53 struct PathData {
55 PathData(char type, Vec2f const &x=Vec2f(), Vec2f const &x1=Vec2f(), Vec2f const &x2=Vec2f()):
56 m_type(type), m_x(x), m_x1(x1), m_x2(x2), m_r(), m_rotate(0), m_largeAngle(false), m_sweep(false)
57 {
58 }
60 void translate(Vec2f const &delta);
62 void scale(Vec2f const &factor);
64 void rotate(float angle, Vec2f const &delta);
66 bool get(librevenge::RVNGPropertyList &pList, Vec2f const &orig) const;
68 friend std::ostream &operator<<(std::ostream &o, PathData const &path);
70 int cmp(PathData const &a) const;
72 char m_type;
74 Vec2f m_x;
76 Vec2f m_x1;
78 Vec2f m_x2;
80 Vec2f m_r;
82 float m_rotate;
84 bool m_largeAngle;
86 bool m_sweep;
87 };
88
90 MWAWGraphicShape() : m_type(ShapeUnknown), m_bdBox(), m_formBox(), m_cornerWidth(0,0), m_arcAngles(0,0),
91 m_vertices(), m_path(), m_extra("")
92 {
93 }
95 virtual ~MWAWGraphicShape() { }
97 static MWAWGraphicShape line(Vec2f const &orign, Vec2f const &dest);
99 static MWAWGraphicShape rectangle(Box2f const &box, Vec2f const &corners=Vec2f(0,0))
100 {
101 MWAWGraphicShape res;
102 res.m_type=Rectangle;
103 res.m_bdBox=res.m_formBox=box;
104 res.m_cornerWidth=corners;
105 return res;
106 }
108 static MWAWGraphicShape circle(Box2f const &box)
109 {
110 MWAWGraphicShape res;
111 res.m_type=Circle;
112 res.m_bdBox=res.m_formBox=box;
113 return res;
114 }
116 static MWAWGraphicShape arc(Box2f const &box, Box2f const &circleBox, Vec2f const &angles)
117 {
118 MWAWGraphicShape res;
119 res.m_type=Arc;
120 res.m_bdBox=box;
121 res.m_formBox=circleBox;
122 res.m_arcAngles=angles;
123 return res;
124 }
126 static MWAWGraphicShape pie(Box2f const &box, Box2f const &circleBox, Vec2f const &angles)
127 {
128 MWAWGraphicShape res;
129 res.m_type=Pie;
130 res.m_bdBox=box;
131 res.m_formBox=circleBox;
132 res.m_arcAngles=angles;
133 return res;
134 }
136 static MWAWGraphicShape polygon(Box2f const &box)
137 {
138 MWAWGraphicShape res;
139 res.m_type=Polygon;
140 res.m_bdBox=box;
141 return res;
142 }
144 static MWAWGraphicShape path(Box2f const &box)
145 {
146 MWAWGraphicShape res;
147 res.m_type=Path;
148 res.m_bdBox=box;
149 return res;
150 }
151
153 void translate(Vec2f const &delta);
155 void scale(Vec2f const &factor);
159 MWAWGraphicShape rotate(float angle, Vec2f const &center) const;
161 Type getType() const
162 {
163 return m_type;
164 }
166 Box2f getBdBox() const
167 {
168 return m_bdBox;
169 }
171 Box2f getBdBox(MWAWGraphicStyle const &style, bool moveToO=false) const;
173 Command addTo(Vec2f const &orig, bool asSurface, librevenge::RVNGPropertyList &propList) const;
175 friend std::ostream &operator<<(std::ostream &o, MWAWGraphicShape const &sh);
177 int cmp(MWAWGraphicShape const &a) const;
178 protected:
180 std::vector<PathData> getPath() const;
181 public:
183 Type m_type;
185 Box2f m_bdBox;
187 Box2f m_formBox;
189 Vec2f m_cornerWidth;
191 Vec2f m_arcAngles;
193 std::vector<Vec2f> m_vertices;
195 std::vector<PathData> m_path;
197 std::string m_extra;
198 };
199 #endif
200 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWGraphicShape::circle
static MWAWGraphicShape circle(Box2f const &box)
static constructor to create a circle
Definition: MWAWGraphicShape.hxx:108
MWAWGraphicShape::PathData::m_r
Vec2f m_r
the radius ( A command)
Definition: MWAWGraphicShape.hxx:80
MWAWGraphicShape::getPath
std::vector< PathData > getPath() const
return a path corresponding to the shape
Definition: MWAWGraphicShape.cxx:493
MWAWGraphicShape::MWAWGraphicShape
MWAWGraphicShape()
constructor
Definition: MWAWGraphicShape.hxx:90
MWAWGraphicShape::m_cornerWidth
Vec2f m_cornerWidth
the rectangle round corner
Definition: MWAWGraphicShape.hxx:189
MWAWGraphicShape::Rectangle
Definition: MWAWGraphicShape.hxx:49
MWAWGraphicShape::translate
void translate(Vec2f const &delta)
translate all the coordinate by delta
Definition: MWAWGraphicShape.cxx:312
libmwaw_internal.hxx
Vec2f
Vec2< float > Vec2f
Vec2 of float.
Definition: libmwaw_internal.hxx:711
Box2< float >
MWAWGraphicShape::m_formBox
Box2f m_formBox
the internal shape bdbox ( used for arc, circle to store the circle bdbox )
Definition: MWAWGraphicShape.hxx:187
MWAWGraphicShape::C_Path
Definition: MWAWGraphicShape.hxx:51
MWAWGraphicShape::rotate
MWAWGraphicShape rotate(float angle, Vec2f const &center) const
return a new shape corresponding to a rotation from center.
Definition: MWAWGraphicShape.cxx:337
MWAWGraphicShape::ShapeUnknown
Definition: MWAWGraphicShape.hxx:49
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
MWAWGraphicShape::Command
Command
an enum used to define the interface command
Definition: MWAWGraphicShape.hxx:51
MWAWGraphicShape::Circle
Definition: MWAWGraphicShape.hxx:49
MWAWGraphicShape::cmp
int cmp(MWAWGraphicShape const &a) const
compare two shapes
Definition: MWAWGraphicShape.cxx:270
MWAWGraphicShape::C_Polygon
Definition: MWAWGraphicShape.hxx:51
MWAWGraphicShape::m_bdBox
Box2f m_bdBox
the shape bdbox
Definition: MWAWGraphicShape.hxx:185
MWAWGraphicShape::m_arcAngles
Vec2f m_arcAngles
the start and end value which defines an arc
Definition: MWAWGraphicShape.hxx:191
MWAWGraphicShape::PathData::m_sweep
bool m_sweep
sweep value ( A command)
Definition: MWAWGraphicShape.hxx:86
MWAWGraphicShape::PathData::rotate
void rotate(float angle, Vec2f const &delta)
rotate all the coordinate by angle (origin rotation) then translate coordinate
Definition: MWAWGraphicShape.cxx:118
MWAWGraphicShape::PathData::m_largeAngle
bool m_largeAngle
large angle ( A command)
Definition: MWAWGraphicShape.hxx:84
MWAWGraphicShape::Type
Type
an enum used to define the shape type
Definition: MWAWGraphicShape.hxx:49
MWAWGraphicShape::PathData::m_x
Vec2f m_x
the main x value
Definition: MWAWGraphicShape.hxx:74
MWAWGraphicShape::pie
static MWAWGraphicShape pie(Box2f const &box, Box2f const &circleBox, Vec2f const &angles)
static constructor to create a pie
Definition: MWAWGraphicShape.hxx:126
MWAWGraphicShape::Polygon
Definition: MWAWGraphicShape.hxx:49
MWAWGraphicShape::path
static MWAWGraphicShape path(Box2f const &box)
static constructor to create a path
Definition: MWAWGraphicShape.hxx:144
MWAWGraphicShape::PathData::m_rotate
float m_rotate
the rotate ( A command)
Definition: MWAWGraphicShape.hxx:82
MWAWGraphicShape::Arc
Definition: MWAWGraphicShape.hxx:49
MWAWGraphicShape::PathData::PathData
PathData(char type, Vec2f const &x=Vec2f(), Vec2f const &x1=Vec2f(), Vec2f const &x2=Vec2f())
constructor
Definition: MWAWGraphicShape.hxx:55
MWAWGraphicShape::PathData::m_type
char m_type
the type: M, L, ...
Definition: MWAWGraphicShape.hxx:72
MWAWGraphicShape::addTo
Command addTo(Vec2f const &orig, bool asSurface, librevenge::RVNGPropertyList &propList) const
updates the propList to send to an interface
Definition: MWAWGraphicShape.cxx:360
MWAWGraphicShape::C_Bad
Definition: MWAWGraphicShape.hxx:51
MWAWGraphicShape::scale
void scale(Vec2f const &factor)
rescale all the coordinate
Definition: MWAWGraphicShape.cxx:324
MWAWGraphicShape::PathData::cmp
int cmp(PathData const &a) const
comparison function
Definition: MWAWGraphicShape.cxx:180
MWAWGraphicShape::PathData::operator<<
friend std::ostream & operator<<(std::ostream &o, PathData const &path)
a print operator
Definition: MWAWGraphicShape.cxx:57
MWAWGraphicShape::m_extra
std::string m_extra
extra data
Definition: MWAWGraphicShape.hxx:197
MWAWGraphicShape::~MWAWGraphicShape
virtual ~MWAWGraphicShape()
virtual destructor
Definition: MWAWGraphicShape.hxx:95
MWAWGraphicShape::getBdBox
Box2f getBdBox() const
returns the basic bdbox
Definition: MWAWGraphicShape.hxx:166
MWAWGraphicShape::C_Polyline
Definition: MWAWGraphicShape.hxx:51
MWAWGraphicShape::C_Rectangle
Definition: MWAWGraphicShape.hxx:51
MWAWGraphicShape::Pie
Definition: MWAWGraphicShape.hxx:49
MWAWGraphicShape
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
MWAWGraphicShape::arc
static MWAWGraphicShape arc(Box2f const &box, Box2f const &circleBox, Vec2f const &angles)
static constructor to create a arc
Definition: MWAWGraphicShape.hxx:116
MWAWGraphicShape::m_vertices
std::vector< Vec2f > m_vertices
the list of vertices for lines or polygons
Definition: MWAWGraphicShape.hxx:193
MWAWGraphicShape::m_path
std::vector< PathData > m_path
the list of path component
Definition: MWAWGraphicShape.hxx:195
MWAWGraphicShape::Path
Definition: MWAWGraphicShape.hxx:49
MWAWGraphicShape::line
static MWAWGraphicShape line(Vec2f const &orign, Vec2f const &dest)
static constructor to create a line
Definition: MWAWGraphicShape.cxx:204
MWAWGraphicShape::C_Ellipse
Definition: MWAWGraphicShape.hxx:51
Vec2< float >
MWAWGraphicShape::operator<<
friend std::ostream & operator<<(std::ostream &o, MWAWGraphicShape const &sh)
a print operator
Definition: MWAWGraphicShape.cxx:222
MWAWGraphicShape::PathData::m_x1
Vec2f m_x1
x1 value
Definition: MWAWGraphicShape.hxx:76
MWAWGraphicShape::PathData::scale
void scale(Vec2f const &factor)
scale all the coordinate by a factor
Definition: MWAWGraphicShape.cxx:105
MWAWGraphicShape::PathData
a simple path component
Definition: MWAWGraphicShape.hxx:53
MWAWGraphicShape::rectangle
static MWAWGraphicShape rectangle(Box2f const &box, Vec2f const &corners=Vec2f(0, 0))
static constructor to create a rectangle
Definition: MWAWGraphicShape.hxx:99
MWAWGraphicShape::m_type
Type m_type
the type
Definition: MWAWGraphicShape.hxx:183
MWAWGraphicShape::getType
Type getType() const
returns the type corresponding to a shape
Definition: MWAWGraphicShape.hxx:161
MWAWGraphicShape::PathData::translate
void translate(Vec2f const &delta)
translate all the coordinate by delta
Definition: MWAWGraphicShape.cxx:92
MWAWGraphicShape::Line
Definition: MWAWGraphicShape.hxx:49
MWAWGraphicShape::PathData::m_x2
Vec2f m_x2
x2 value
Definition: MWAWGraphicShape.hxx:78
MWAWGraphicShape::polygon
static MWAWGraphicShape polygon(Box2f const &box)
static constructor to create a polygon
Definition: MWAWGraphicShape.hxx:136