00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef MWAW_GRAPHIC_SHAPE
00034 # define MWAW_GRAPHIC_SHAPE
00035 # include <ostream>
00036 # include <string>
00037 # include <vector>
00038
00039 # include "librevenge/librevenge.h"
00040 # include "libmwaw_internal.hxx"
00041
00042 class MWAWGraphicStyle;
00043
00045 class MWAWGraphicShape
00046 {
00047 public:
00049 enum Type { Arc, Circle, Line, Rectangle, Path, Pie, Polygon, ShapeUnknown };
00051 enum Command { C_Ellipse, C_Polyline, C_Rectangle, C_Path, C_Polygon, C_Bad };
00053 struct PathData {
00055 PathData(char type, MWAWVec2f const &x=MWAWVec2f(), MWAWVec2f const &x1=MWAWVec2f(), MWAWVec2f const &x2=MWAWVec2f()):
00056 m_type(type), m_x(x), m_x1(x1), m_x2(x2), m_r(), m_rotate(0), m_largeAngle(false), m_sweep(false)
00057 {
00058 }
00060 void translate(MWAWVec2f const &delta);
00062 void scale(MWAWVec2f const &factor);
00064 void rotate(float angle, MWAWVec2f const &delta);
00066 bool get(librevenge::RVNGPropertyList &pList, MWAWVec2f const &orig) const;
00068 friend std::ostream &operator<<(std::ostream &o, PathData const &path);
00070 int cmp(PathData const &a) const;
00072 char m_type;
00074 MWAWVec2f m_x;
00076 MWAWVec2f m_x1;
00078 MWAWVec2f m_x2;
00080 MWAWVec2f m_r;
00082 float m_rotate;
00084 bool m_largeAngle;
00086 bool m_sweep;
00087 };
00088
00090 MWAWGraphicShape() : m_type(ShapeUnknown), m_bdBox(), m_formBox(), m_cornerWidth(0,0), m_arcAngles(0,0),
00091 m_vertices(), m_path(), m_extra("")
00092 {
00093 }
00095 virtual ~MWAWGraphicShape() { }
00097 static MWAWGraphicShape line(MWAWVec2f const &orign, MWAWVec2f const &dest);
00099 static MWAWGraphicShape rectangle(MWAWBox2f const &box, MWAWVec2f const &corners=MWAWVec2f(0,0))
00100 {
00101 MWAWGraphicShape res;
00102 res.m_type=Rectangle;
00103 res.m_bdBox=res.m_formBox=box;
00104 res.m_cornerWidth=corners;
00105 return res;
00106 }
00108 static MWAWGraphicShape circle(MWAWBox2f const &box)
00109 {
00110 MWAWGraphicShape res;
00111 res.m_type=Circle;
00112 res.m_bdBox=res.m_formBox=box;
00113 return res;
00114 }
00116 static MWAWGraphicShape arc(MWAWBox2f const &box, MWAWBox2f const &circleBox, MWAWVec2f const &angles)
00117 {
00118 MWAWGraphicShape res;
00119 res.m_type=Arc;
00120 res.m_bdBox=box;
00121 res.m_formBox=circleBox;
00122 res.m_arcAngles=angles;
00123 return res;
00124 }
00126 static MWAWGraphicShape pie(MWAWBox2f const &box, MWAWBox2f const &circleBox, MWAWVec2f const &angles)
00127 {
00128 MWAWGraphicShape res;
00129 res.m_type=Pie;
00130 res.m_bdBox=box;
00131 res.m_formBox=circleBox;
00132 res.m_arcAngles=angles;
00133 return res;
00134 }
00136 static MWAWGraphicShape polygon(MWAWBox2f const &box)
00137 {
00138 MWAWGraphicShape res;
00139 res.m_type=Polygon;
00140 res.m_bdBox=box;
00141 return res;
00142 }
00144 static MWAWGraphicShape path(MWAWBox2f const &box)
00145 {
00146 MWAWGraphicShape res;
00147 res.m_type=Path;
00148 res.m_bdBox=box;
00149 return res;
00150 }
00151
00153 void translate(MWAWVec2f const &delta);
00155 void scale(MWAWVec2f const &factor);
00159 MWAWGraphicShape rotate(float angle, MWAWVec2f const ¢er) const;
00161 Type getType() const
00162 {
00163 return m_type;
00164 }
00166 MWAWBox2f getBdBox() const
00167 {
00168 return m_bdBox;
00169 }
00171 MWAWBox2f getBdBox(MWAWGraphicStyle const &style, bool moveToO=false) const;
00173 Command addTo(MWAWVec2f const &orig, bool asSurface, librevenge::RVNGPropertyList &propList) const;
00175 friend std::ostream &operator<<(std::ostream &o, MWAWGraphicShape const &sh);
00177 int cmp(MWAWGraphicShape const &a) const;
00178 protected:
00180 std::vector<PathData> getPath() const;
00181 public:
00183 Type m_type;
00185 MWAWBox2f m_bdBox;
00187 MWAWBox2f m_formBox;
00189 MWAWVec2f m_cornerWidth;
00191 MWAWVec2f m_arcAngles;
00193 std::vector<MWAWVec2f> m_vertices;
00195 std::vector<PathData> m_path;
00197 std::string m_extra;
00198 };
00199 #endif
00200