]> Shamusworld >> Repos - architektonas/blob - src/base/entitycontainer.h
Fixed thumbnail rendering in LibraryWidget and DXF detection.
[architektonas] / src / base / entitycontainer.h
1 #ifndef __ENTITYCONTAINER_H__
2 #define __ENTITYCONTAINER_H__
3
4 #include <QtCore>
5 #include "arc.h"
6 #include "circle.h"
7 #include "ellipse.h"
8 #include "entity.h"
9 #include "line.h"
10 #include "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                 virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
103
104                 friend std::ostream & operator<<(std::ostream & os, RS_EntityContainer & ec);
105
106         protected:
107                 /** entities in the container */
108                 QList<RS_Entity *> entities;
109
110                 /** sub container used only temporarly for iteration. */
111                 RS_EntityContainer * subContainer;
112
113                 /**
114                  * Class variable:
115                  * Automatically update the borders of the container when entities
116                  * are added or removed.
117                  */
118                 static bool autoUpdateBorders;
119
120         private:
121                 QListIterator<RS_Entity *> entityIterator;
122 };
123
124 #endif  // __ENTITYCONTAINER_H__