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 "libwpd/libwpd.h"
40 # include "libmwaw_internal.hxx"
41 
42 class WPXPropertyList;
43 class MWAWGraphicStyle;
44 
47 {
48 public:
52  struct PathData {
54  PathData(char type, Vec2f const &x=Vec2f(), Vec2f const &x1=Vec2f(), Vec2f const &x2=Vec2f()):
55  m_type(type), m_x(x), m_x1(x1), m_x2(x2), m_r(), m_rotate(0), m_largeAngle(false), m_sweep(false) {
56  }
58  void translate(Vec2f const &delta);
60  void rotate(float angle, Vec2f const &delta);
62  bool get(WPXPropertyList &pList, Vec2f const &orig) const;
64  friend std::ostream &operator<<(std::ostream &o, PathData const &path);
66  int cmp(PathData const &a) const;
68  char m_type;
78  float m_rotate;
82  bool m_sweep;
83  };
84 
87  m_vertices(), m_path(), m_extra("") {
88  }
90  virtual ~MWAWGraphicShape() { }
92  static MWAWGraphicShape line(Vec2f const &orign, Vec2f const &dest);
94  static MWAWGraphicShape rectangle(Box2f const &box, Vec2f const &corners=Vec2f(0,0)) {
95  MWAWGraphicShape res;
96  res.m_type=Rectangle;
97  res.m_bdBox=res.m_formBox=box;
98  res.m_cornerWidth=corners;
99  return res;
100  }
102  static MWAWGraphicShape circle(Box2f const &box) {
103  MWAWGraphicShape res;
104  res.m_type=Circle;
105  res.m_bdBox=res.m_formBox=box;
106  return res;
107  }
109  static MWAWGraphicShape arc(Box2f const &box, Box2f const &circleBox, Vec2f const &angles) {
110  MWAWGraphicShape res;
111  res.m_type=Arc;
112  res.m_bdBox=box;
113  res.m_formBox=circleBox;
114  res.m_arcAngles=angles;
115  return res;
116  }
118  static MWAWGraphicShape pie(Box2f const &box, Box2f const &circleBox, Vec2f const &angles) {
119  MWAWGraphicShape res;
120  res.m_type=Pie;
121  res.m_bdBox=box;
122  res.m_formBox=circleBox;
123  res.m_arcAngles=angles;
124  return res;
125  }
127  static MWAWGraphicShape polygon(Box2f const &box) {
128  MWAWGraphicShape res;
129  res.m_type=Polygon;
130  res.m_bdBox=box;
131  return res;
132  }
134  static MWAWGraphicShape path(Box2f const &box) {
135  MWAWGraphicShape res;
136  res.m_type=Path;
137  res.m_bdBox=box;
138  return res;
139  }
140 
142  void translate(Vec2f const &delta);
146  MWAWGraphicShape rotate(float angle, Vec2f const &center) const;
148  Box2f getBdBox(MWAWGraphicStyle const &style, bool moveToO=false) const;
150  bool send(MWAWGraphicInterface &interface, MWAWGraphicStyle const &style, Vec2f const &orig) const;
152  friend std::ostream &operator<<(std::ostream &o, MWAWGraphicShape const &sh);
154  int cmp(MWAWGraphicShape const &a) const;
155 protected:
157  std::vector<PathData> getPath() const;
158 public:
170  std::vector<Vec2f> m_vertices;
172  std::vector<PathData> m_path;
174  std::string m_extra;
175 };
176 #endif
177 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
static MWAWGraphicShape circle(Box2f const &box)
static constructor to create a circle
Definition: MWAWGraphicShape.hxx:102
Vec2f m_r
the radius ( A command)
Definition: MWAWGraphicShape.hxx:76
std::vector< PathData > getPath() const
return a path corresponding to the shape
Definition: MWAWGraphicShape.cxx:474
MWAWGraphicShape()
constructor
Definition: MWAWGraphicShape.hxx:86
bool send(MWAWGraphicInterface &interface, MWAWGraphicStyle const &style, Vec2f const &orig) const
add shape to a graphic listener
Definition: MWAWGraphicShape.cxx:332
Vec2f m_cornerWidth
the rectangle round corner
Definition: MWAWGraphicShape.hxx:166
Definition: MWAWGraphicShape.hxx:50
void translate(Vec2f const &delta)
translate all the coordinate by delta
Definition: MWAWGraphicShape.cxx:297
Vec2< float > Vec2f
Vec2 of float.
Definition: libmwaw_internal.hxx:596
Box2f m_formBox
the internal shape bdbox ( used for arc, circle to store the circle bdbox )
Definition: MWAWGraphicShape.hxx:164
MWAWGraphicShape rotate(float angle, Vec2f const &center) const
return a new shape corresponding to a rotation from center.
Definition: MWAWGraphicShape.cxx:309
Definition: MWAWGraphicShape.hxx:50
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
Definition: MWAWGraphicShape.hxx:50
int cmp(MWAWGraphicShape const &a) const
compare two shapes
Definition: MWAWGraphicShape.cxx:255
Box2f m_bdBox
the shape bdbox
Definition: MWAWGraphicShape.hxx:162
Vec2f m_arcAngles
the start and end value which defines an arc
Definition: MWAWGraphicShape.hxx:168
Box2f getBdBox(MWAWGraphicStyle const &style, bool moveToO=false) const
returns the bdbox corresponding to a style
Definition: MWAWGraphicShape.cxx:282
bool m_sweep
sweep value ( A command)
Definition: MWAWGraphicShape.hxx:82
void rotate(float angle, Vec2f const &delta)
rotate all the coordinate by angle (origin rotation) then translate coordinate
Definition: MWAWGraphicShape.cxx:103
bool m_largeAngle
large angle ( A command)
Definition: MWAWGraphicShape.hxx:80
Type
an enum used to define the shape type
Definition: MWAWGraphicShape.hxx:50
Vec2f m_x
the main x value
Definition: MWAWGraphicShape.hxx:70
static MWAWGraphicShape pie(Box2f const &box, Box2f const &circleBox, Vec2f const &angles)
static constructor to create a pie
Definition: MWAWGraphicShape.hxx:118
Definition: MWAWGraphicShape.hxx:50
main class used to define the final interface to generate picture
Definition: MWAWGraphicInterface.hxx:52
static MWAWGraphicShape path(Box2f const &box)
static constructor to create a path
Definition: MWAWGraphicShape.hxx:134
float m_rotate
the rotate ( A command)
Definition: MWAWGraphicShape.hxx:78
Definition: MWAWGraphicShape.hxx:50
PathData(char type, Vec2f const &x=Vec2f(), Vec2f const &x1=Vec2f(), Vec2f const &x2=Vec2f())
constructor
Definition: MWAWGraphicShape.hxx:54
char m_type
the type: M, L, ...
Definition: MWAWGraphicShape.hxx:68
int cmp(PathData const &a) const
comparison function
Definition: MWAWGraphicShape.cxx:165
friend std::ostream & operator<<(std::ostream &o, PathData const &path)
a print operator
Definition: MWAWGraphicShape.cxx:57
std::string m_extra
extra data
Definition: MWAWGraphicShape.hxx:174
virtual ~MWAWGraphicShape()
virtual destructor
Definition: MWAWGraphicShape.hxx:90
Definition: MWAWGraphicShape.hxx:50
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:46
static MWAWGraphicShape arc(Box2f const &box, Box2f const &circleBox, Vec2f const &angles)
static constructor to create a arc
Definition: MWAWGraphicShape.hxx:109
std::vector< Vec2f > m_vertices
the list of vertices for lines or polygons
Definition: MWAWGraphicShape.hxx:170
std::vector< PathData > m_path
the list of path component
Definition: MWAWGraphicShape.hxx:172
Definition: MWAWGraphicShape.hxx:50
static MWAWGraphicShape line(Vec2f const &orign, Vec2f const &dest)
static constructor to create a line
Definition: MWAWGraphicShape.cxx:189
friend std::ostream & operator<<(std::ostream &o, MWAWGraphicShape const &sh)
a print operator
Definition: MWAWGraphicShape.cxx:207
Vec2f m_x1
x1 value
Definition: MWAWGraphicShape.hxx:72
a simple path component
Definition: MWAWGraphicShape.hxx:52
static MWAWGraphicShape rectangle(Box2f const &box, Vec2f const &corners=Vec2f(0, 0))
static constructor to create a rectangle
Definition: MWAWGraphicShape.hxx:94
Type m_type
the type
Definition: MWAWGraphicShape.hxx:160
void translate(Vec2f const &delta)
translate all the coordinate by delta
Definition: MWAWGraphicShape.cxx:90
Definition: MWAWGraphicShape.hxx:50
Vec2f m_x2
x2 value
Definition: MWAWGraphicShape.hxx:74
static MWAWGraphicShape polygon(Box2f const &box)
static constructor to create a polygon
Definition: MWAWGraphicShape.hxx:127

Generated on Tue Mar 10 2015 17:32:09 for libmwaw by doxygen 1.8.5