Go to the documentation of this file.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 "libwpd/libwpd.h"
00040 # include "libmwaw_internal.hxx"
00041
00042 class WPXPropertyList;
00043 class MWAWGraphicStyle;
00044
00046 class MWAWGraphicShape
00047 {
00048 public:
00050 enum Type { Arc, Circle, Line, Rectangle, Path, Pie, Polygon, ShapeUnknown };
00052 struct PathData {
00054 PathData(char type, Vec2f const &x=Vec2f(), Vec2f const &x1=Vec2f(), Vec2f const &x2=Vec2f()):
00055 m_type(type), m_x(x), m_x1(x1), m_x2(x2), m_r(), m_rotate(0), m_largeAngle(false), m_sweep(false) {
00056 }
00058 void translate(Vec2f const &delta);
00060 void rotate(float angle, Vec2f const &delta);
00062 bool get(WPXPropertyList &pList, Vec2f const &orig) const;
00064 friend std::ostream &operator<<(std::ostream &o, PathData const &path);
00066 int cmp(PathData const &a) const;
00068 char m_type;
00070 Vec2f m_x;
00072 Vec2f m_x1;
00074 Vec2f m_x2;
00076 Vec2f m_r;
00078 float m_rotate;
00080 bool m_largeAngle;
00082 bool m_sweep;
00083 };
00084
00086 MWAWGraphicShape() : m_type(ShapeUnknown), m_bdBox(), m_formBox(), m_cornerWidth(0,0), m_arcAngles(0,0),
00087 m_vertices(), m_path(), m_extra("") {
00088 }
00090 virtual ~MWAWGraphicShape() { }
00092 static MWAWGraphicShape line(Vec2f const &orign, Vec2f const &dest);
00094 static MWAWGraphicShape rectangle(Box2f const &box, Vec2f const &corners=Vec2f(0,0)) {
00095 MWAWGraphicShape res;
00096 res.m_type=Rectangle;
00097 res.m_bdBox=res.m_formBox=box;
00098 res.m_cornerWidth=corners;
00099 return res;
00100 }
00102 static MWAWGraphicShape circle(Box2f const &box) {
00103 MWAWGraphicShape res;
00104 res.m_type=Circle;
00105 res.m_bdBox=res.m_formBox=box;
00106 return res;
00107 }
00109 static MWAWGraphicShape arc(Box2f const &box, Box2f const &circleBox, Vec2f const &angles) {
00110 MWAWGraphicShape res;
00111 res.m_type=Arc;
00112 res.m_bdBox=box;
00113 res.m_formBox=circleBox;
00114 res.m_arcAngles=angles;
00115 return res;
00116 }
00118 static MWAWGraphicShape pie(Box2f const &box, Box2f const &circleBox, Vec2f const &angles) {
00119 MWAWGraphicShape res;
00120 res.m_type=Pie;
00121 res.m_bdBox=box;
00122 res.m_formBox=circleBox;
00123 res.m_arcAngles=angles;
00124 return res;
00125 }
00127 static MWAWGraphicShape polygon(Box2f const &box) {
00128 MWAWGraphicShape res;
00129 res.m_type=Polygon;
00130 res.m_bdBox=box;
00131 return res;
00132 }
00134 static MWAWGraphicShape path(Box2f const &box) {
00135 MWAWGraphicShape res;
00136 res.m_type=Path;
00137 res.m_bdBox=box;
00138 return res;
00139 }
00140
00142 void translate(Vec2f const &delta);
00146 MWAWGraphicShape rotate(float angle, Vec2f const ¢er) const;
00148 Box2f getBdBox(MWAWGraphicStyle const &style, bool moveToO=false) const;
00150 bool send(MWAWGraphicInterface &interface, MWAWGraphicStyle const &style, Vec2f const &orig) const;
00152 friend std::ostream &operator<<(std::ostream &o, MWAWGraphicShape const &sh);
00154 int cmp(MWAWGraphicShape const &a) const;
00155 protected:
00157 std::vector<PathData> getPath() const;
00158 public:
00160 Type m_type;
00162 Box2f m_bdBox;
00164 Box2f m_formBox;
00166 Vec2f m_cornerWidth;
00168 Vec2f m_arcAngles;
00170 std::vector<Vec2f> m_vertices;
00172 std::vector<PathData> m_path;
00174 std::string m_extra;
00175 };
00176 #endif
00177