]> Shamusworld >> Repos - architektonas/blob - src/base/rs_hatch.h
Fixed thumbnail rendering in LibraryWidget and DXF detection.
[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                 virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
78                 virtual double getLength();
79                 virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL,
80                         RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
81                 virtual void move(Vector offset);
82                 virtual void rotate(Vector center, double angle);
83                 virtual void scale(Vector center, Vector factor);
84                 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
85                 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
86
87                 friend std::ostream & operator<<(std::ostream & os, const RS_Hatch & p);
88
89         protected:
90                 RS_HatchData data;
91                 RS_EntityContainer * hatch;
92                 bool updateRunning;
93                 bool needOptimization;
94 };
95
96 #endif