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
,
Measure
,
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,
MWAWVec2f
const
&x=
MWAWVec2f
(),
MWAWVec2f
const
&x1=
MWAWVec2f
(),
MWAWVec2f
const
&x2=
MWAWVec2f
()):
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
(
MWAWVec2f
const
&delta);
62
void
scale
(
MWAWVec2f
const
&factor);
64
void
rotate
(
float
angle,
MWAWVec2f
const
&delta);
66
bool
get
(librevenge::RVNGPropertyList &pList,
MWAWVec2f
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
MWAWVec2f
m_x
;
76
MWAWVec2f
m_x1
;
78
MWAWVec2f
m_x2
;
80
MWAWVec2f
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
(
MWAWVec2f
const
&orign,
MWAWVec2f
const
&dest);
99
static
MWAWGraphicShape
measure
(
MWAWVec2f
const
&orign,
MWAWVec2f
const
&dest);
101
static
MWAWGraphicShape
rectangle
(
MWAWBox2f
const
&box,
MWAWVec2f
const
&corners=
MWAWVec2f
(0,0))
102
{
103
MWAWGraphicShape
res;
104
res.
m_type
=
Rectangle
;
105
res.
m_bdBox
=res.
m_formBox
=box;
106
res.
m_cornerWidth
=corners;
107
return
res;
108
}
110
static
MWAWGraphicShape
circle
(
MWAWBox2f
const
&box)
111
{
112
MWAWGraphicShape
res;
113
res.
m_type
=
Circle
;
114
res.
m_bdBox
=res.
m_formBox
=box;
115
return
res;
116
}
118
static
MWAWGraphicShape
arc
(
MWAWBox2f
const
&box,
MWAWBox2f
const
&circleBox,
MWAWVec2f
const
&angles)
119
{
120
MWAWGraphicShape
res;
121
res.
m_type
=
Arc
;
122
res.
m_bdBox
=box;
123
res.
m_formBox
=circleBox;
124
res.
m_arcAngles
=angles;
125
return
res;
126
}
128
static
MWAWGraphicShape
pie
(
MWAWBox2f
const
&box,
MWAWBox2f
const
&circleBox,
MWAWVec2f
const
&angles)
129
{
130
MWAWGraphicShape
res;
131
res.
m_type
=
Pie
;
132
res.
m_bdBox
=box;
133
res.
m_formBox
=circleBox;
134
res.
m_arcAngles
=angles;
135
return
res;
136
}
138
static
MWAWGraphicShape
polygon
(
MWAWBox2f
const
&box)
139
{
140
MWAWGraphicShape
res;
141
res.
m_type
=
Polygon
;
142
res.
m_bdBox
=box;
143
return
res;
144
}
146
static
MWAWGraphicShape
path
(
MWAWBox2f
const
&box)
147
{
148
MWAWGraphicShape
res;
149
res.
m_type
=
Path
;
150
res.
m_bdBox
=box;
151
return
res;
152
}
153
155
void
translate
(
MWAWVec2f
const
&delta);
157
void
scale
(
MWAWVec2f
const
&factor);
161
MWAWGraphicShape
rotate
(
float
angle,
MWAWVec2f
const
¢er)
const
;
163
Type
getType
()
const
164
{
165
return
m_type
;
166
}
168
MWAWBox2f
getBdBox
()
const
169
{
170
return
m_bdBox
;
171
}
173
MWAWBox2f
getBdBox
(
MWAWGraphicStyle
const
&style,
bool
moveToO=
false
)
const
;
175
Command
addTo
(
MWAWVec2f
const
&orig,
bool
asSurface, librevenge::RVNGPropertyList &propList)
const
;
177
bool
addPathTo
(
MWAWVec2f
const
&orig, librevenge::RVNGPropertyListVector &propList)
const
;
179
friend
std::ostream &
operator<<
(std::ostream &o,
MWAWGraphicShape
const
&sh);
181
int
cmp
(
MWAWGraphicShape
const
&a)
const
;
182
protected
:
184
std::vector<PathData>
getPath
()
const
;
185
public
:
187
Type
m_type
;
189
MWAWBox2f
m_bdBox
;
191
MWAWBox2f
m_formBox
;
193
MWAWVec2f
m_cornerWidth
;
195
MWAWVec2f
m_arcAngles
;
197
std::vector<MWAWVec2f>
m_vertices
;
199
std::vector<PathData>
m_path
;
201
std::string
m_extra
;
202
};
203
#endif
204
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Generated on Tue Mar 1 2016 23:42:50 for libmwaw by
doxygen
1.8.4