]> Shamusworld >> Repos - architektonas/blob - src/base/rs_entitycontainer.h
Initial import
[architektonas] / src / base / rs_entitycontainer.h
1 #ifndef RS_ENTITYCONTAINER_H
2 #define RS_ENTITYCONTAINER_H
3
4 #include <QtCore>
5 #include "rs_arc.h"
6 #include "rs_circle.h"
7 #include "rs_ellipse.h"
8 #include "rs_entity.h"
9 #include "rs_line.h"
10 #include "rs_point.h"
11
12 /**
13  * Class representing a tree of entities.
14  * Typical entity containers are graphics, polylines, groups, texts, ...)
15  *
16  * @author Andrew Mustun
17  */
18 class RS_EntityContainer: public RS_Entity
19 {
20         public:
21                 RS_EntityContainer(RS_EntityContainer * parent = NULL, bool owner = true);
22                 //RS_EntityContainer(const RS_EntityContainer& ec);
23                 virtual ~RS_EntityContainer();
24
25                 virtual RS_Entity * clone();
26                 virtual void detach();
27                 virtual RS2::EntityType rtti() const;
28                 void reparent(RS_EntityContainer * parent);
29                 virtual bool isContainer() const;
30                 virtual bool isAtomic() const;
31                 virtual double getLength();
32
33                 virtual void undoStateChanged(bool undone);
34                 virtual void setVisible(bool v);
35
36                 virtual bool setSelected(bool select = true);
37                 virtual bool toggleSelected();
38
39                 virtual void selectWindow(Vector v1, Vector v2, bool select = true, bool cross = false);
40
41                 virtual void addEntity(RS_Entity * entity);
42                 virtual void insertEntity(int index, RS_Entity * entity);
43                 virtual void replaceEntity(int index, RS_Entity * entity);
44                 virtual bool removeEntity(RS_Entity * entity);
45                 virtual RS_Entity * firstEntity(RS2::ResolveLevel level = RS2::ResolveNone);
46                 virtual RS_Entity * lastEntity(RS2::ResolveLevel level = RS2::ResolveNone);
47                 virtual RS_Entity * nextEntity(RS2::ResolveLevel level = RS2::ResolveNone);
48                 virtual RS_Entity * prevEntity(RS2::ResolveLevel level = RS2::ResolveNone);
49                 virtual RS_Entity * entityAt(uint index);
50                 virtual RS_Entity * currentEntity();
51                 virtual int entityAt();
52                 virtual int findEntity(RS_Entity * entity);
53                 virtual void clear();
54
55         //      Q3PtrListIterator<RS_Entity> createIterator();
56 //              QListIterator<RS_Entity *> createIterator();
57
58                 virtual bool isEmpty();
59                 virtual unsigned long int count();
60                 virtual unsigned long int countDeep();
61                 virtual unsigned long int countSelected();
62                 virtual void setAutoUpdateBorders(bool enable);
63                 virtual void adjustBorders(RS_Entity * entity);
64                 virtual void calculateBorders();
65                 virtual void forcedCalculateBorders();
66                 virtual void updateDimensions();
67                 virtual void updateInserts();
68                 virtual void updateSplines();
69                 virtual void update();
70                 virtual void renameInserts(const QString & oldName, const QString & newName);
71
72                 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
73
74                 RS_Entity * getNearestEntity(const Vector & point, double * dist = NULL,
75                         RS2::ResolveLevel level = RS2::ResolveAll);
76
77                 virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true,
78                         double * dist = NULL, RS_Entity ** entity = NULL);
79
80                 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
81                 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
82                 virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
83                 virtual Vector getNearestIntersection(const Vector & coord, double * dist = NULL);
84                 virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
85                 virtual Vector getNearestSelectedRef(const Vector & coord, double * dist = NULL);
86
87                 virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity,
88                         RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
89
90                 virtual bool optimizeContours();
91
92                 virtual bool hasEndpointsWithinWindow(Vector v1, Vector v2);
93
94                 virtual void move(Vector offset);
95                 virtual void rotate(Vector center, double angle);
96                 virtual void scale(Vector center, Vector factor);
97                 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
98
99                 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
100                 virtual void moveRef(const Vector & ref, const Vector & offset);
101                 virtual void moveSelectedRef(const Vector & ref, const Vector & offset);
102
103 //              virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
104                 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
105
106                 friend std::ostream & operator<<(std::ostream & os, RS_EntityContainer & ec);
107
108         protected:
109                 /** entities in the container */
110 //              Q3PtrList<RS_Entity> entities;
111                 QList<RS_Entity *> entities;
112
113                 /** sub container used only temporarly for iteration. */
114                 RS_EntityContainer * subContainer;
115
116                 /**
117                  * Class variable:
118                  * Automatically update the borders of the container when entities
119                  * are added or removed.
120                  */
121                 static bool autoUpdateBorders;
122
123         private:
124                 QListIterator<RS_Entity *> entityIterator;
125 };
126
127 #endif