]> Shamusworld >> Repos - architektonas/blob - src/base/dimlinear.h
Fixed thumbnail rendering in LibraryWidget and DXF detection.
[architektonas] / src / base / dimlinear.h
1 #ifndef __DIMLINEAR_H__
2 #define __DIMLINEAR_H__
3
4 #include "dimension.h"
5
6 /**
7  * Holds the data that defines a linear dimension entity.
8  */
9 class RS_DimLinearData
10 {
11         public:
12                 /**
13                  * Default constructor. Leaves the data object uninitialized.
14                  */
15                 RS_DimLinearData() {}
16
17                 /**
18                  * Constructor with initialisation.
19                  *
20                  * @para extensionPoint1 Startpoint of the first extension line.
21                  * @para extensionPoint2 Startpoint of the second extension line.
22                  * @param angle Rotation angle in rad.
23                  * @param oblique Oblique angle in rad.
24                  */
25                 RS_DimLinearData(const Vector & extensionPoint1,
26                         const Vector & extensionPoint2,
27                         double angle, double oblique)
28                 {
29                         this->extensionPoint1 = extensionPoint1;
30                         this->extensionPoint2 = extensionPoint2;
31                         this->angle = angle;
32                         this->oblique = oblique;
33                 }
34
35                 friend class RS_DimLinear;
36                 friend class RS_ActionDimLinear;
37
38                 friend std::ostream & operator<<(std::ostream & os, const RS_DimLinearData & dd)
39                 {
40                         os << "(" << dd.extensionPoint1 << "/" << dd.extensionPoint1 << ")";
41                         return os;
42                 }
43
44         public:
45                 /** Definition point. Startpoint of the first definition line. */
46                 Vector extensionPoint1;
47                 /** Definition point. Startpoint of the second definition line. */
48                 Vector extensionPoint2;
49                 /** Rotation angle in rad. */
50                 double angle;
51                 /** Oblique angle in rad. */
52                 double oblique;
53 };
54
55 /**
56  * Class for aligned dimension entities.
57  *
58  * @author Andrew Mustun
59  */
60 class RS_DimLinear: public RS_Dimension
61 {
62         public:
63                 RS_DimLinear(RS_EntityContainer * parent, const RS_DimensionData & d, const RS_DimLinearData & ed);
64                 virtual ~RS_DimLinear();
65
66                 virtual RS_Entity * clone();
67                 virtual RS2::EntityType rtti() const;
68                 RS_DimLinearData getEData() const;
69                 virtual VectorSolutions getRefPoints();
70                 virtual QString getMeasuredLabel();
71                 virtual void update(bool autoText = false);
72                 Vector getExtensionPoint1();
73                 Vector getExtensionPoint2();
74                 double getAngle();
75                 void setAngle(double a);
76                 double getOblique();
77                 virtual bool hasEndpointsWithinWindow(Vector v1, Vector v2);
78                 virtual void move(Vector offset);
79                 virtual void rotate(Vector center, double angle);
80                 virtual void scale(Vector center, Vector factor);
81                 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
82                 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
83                 virtual void moveRef(const Vector & ref, const Vector & offset);
84
85                 friend std::ostream & operator<<(std::ostream & os, const RS_DimLinear & d);
86
87         protected:
88                 /** Extended data. */
89                 RS_DimLinearData edata;
90 };
91
92 #endif