]> Shamusworld >> Repos - architektonas/blob - src/base/hatch.h
Removed unnecessary RS_ prefix from classes and whatnot.
[architektonas] / src / base / hatch.h
1 #ifndef __HATCH_H__
2 #define __HATCH_H__
3
4 #include "entity.h"
5 #include "entitycontainer.h"
6
7 /**
8  * Holds the data that defines a hatch entity.
9  */
10 class HatchData
11 {
12         public:
13                 /**
14                  * Default constructor. Leaves the data object uninitialized.
15                  */
16                 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                 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_H__atchData: " << pattern.latin1() << "\n";
31                 }
32
33                 friend std::ostream & operator<<(std::ostream & os, const HatchData & td)
34                 {
35                         os << "(" << td.pattern.toAscii().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 James Hammons
50  * @author Andrew Mustun
51  */
52 class Hatch: public EntityContainer
53 {
54         public:
55                 Hatch(EntityContainer * parent, const HatchData & d);
56                 virtual ~Hatch();
57
58                 virtual Entity * clone();
59                 virtual RS2::EntityType rtti() const;
60                 virtual bool isContainer() const;
61                 HatchData getData() const;
62                 bool validate();
63                 int countLoops();
64
65                 /** @return true if this is a solid fill. false if it is a pattern hatch. */
66                 bool isSolid() const;
67                 void setSolid(bool solid);
68                 QString getPattern();
69                 void setPattern(const QString & pattern);
70                 double getScale();
71                 void setScale(double scale);
72                 double getAngle();
73                 void setAngle(double angle);
74
75                 virtual void calculateBorders();
76                 void update();
77                 void activateContour(bool on);
78                 virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
79                 virtual double getLength();
80                 virtual double getDistanceToPoint(const Vector & coord, Entity ** entity = NULL,
81                         RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
82                 virtual void move(Vector offset);
83                 virtual void rotate(Vector center, double angle);
84                 virtual void scale(Vector center, Vector factor);
85                 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
86                 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
87
88                 friend std::ostream & operator<<(std::ostream & os, const Hatch & p);
89
90         protected:
91                 HatchData data;
92                 EntityContainer * hatch;
93                 bool updateRunning;
94                 bool needOptimization;
95 };
96
97 #endif  // __HATCH_H__