]> Shamusworld >> Repos - architektonas/blob - src/base/rs_hatch.h
Changed RS_Graphic to Drawing; this is less confusing as a drawing is
[architektonas] / src / base / rs_hatch.h
1 #ifndef RS_HATCH_H
2 #define RS_HATCH_H
3
4 #include "rs_entity.h"
5 #include "rs_entitycontainer.h"
6
7 /**
8  * Holds the data that defines a hatch entity.
9  */
10 class RS_HatchData
11 {
12         public:
13                 /**
14                  * Default constructor. Leaves the data object uninitialized.
15                  */
16                 RS_HatchData() {}
17
18                 /**
19                  * @param solid true: solid fill, false: pattern.
20                  * @param scale Pattern scale or spacing.
21                  * @param pattern Pattern name.
22                  */
23                 RS_HatchData(bool solid, double scale, double angle, const QString & pattern)
24                 {
25                         this->solid = solid;
26                         this->scale = scale;
27                         this->angle = angle;
28                         this->pattern = pattern;
29
30                         //std::cout << "RS_HatchData: " << pattern.latin1() << "\n";
31                 }
32
33                 friend std::ostream & operator<<(std::ostream & os, const RS_HatchData & td)
34                 {
35                         os << "(" << td.pattern.toLatin1().data() << ")";
36                         return os;
37                 }
38
39         public:
40                 bool solid;
41                 double scale;
42                 double angle;
43                 QString pattern;
44 };
45
46 /**
47  * Class for a hatch entity.
48  *
49  * @author Andrew Mustun
50  */
51 class RS_Hatch: public RS_EntityContainer
52 {
53         public:
54                 RS_Hatch(RS_EntityContainer * parent, const RS_HatchData & d);
55                 virtual ~RS_Hatch();
56
57                 virtual RS_Entity * clone();
58                 virtual RS2::EntityType rtti() const;
59                 virtual bool isContainer() const;
60                 RS_HatchData getData() const;
61                 bool validate();
62                 int countLoops();
63
64                 /** @return true if this is a solid fill. false if it is a pattern hatch. */
65                 bool isSolid() const;
66                 void setSolid(bool solid);
67                 QString getPattern();
68                 void setPattern(const QString & pattern);
69                 double getScale();
70                 void setScale(double scale);
71                 double getAngle();
72                 void setAngle(double angle);
73
74                 virtual void calculateBorders();
75                 void update();
76                 void activateContour(bool on);
77
78         //    virtual void draw(RS_Painter* painter, RS_GraphicView* view,
79                 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
80
81                 virtual double getLength();
82                 virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL,
83                         RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
84                 virtual void move(Vector offset);
85                 virtual void rotate(Vector center, double angle);
86                 virtual void scale(Vector center, Vector factor);
87                 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
88                 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
89
90                 friend std::ostream & operator<<(std::ostream & os, const RS_Hatch & p);
91
92         protected:
93                 RS_HatchData data;
94                 RS_EntityContainer * hatch;
95                 bool updateRunning;
96                 bool needOptimization;
97 };
98
99 #endif