1 #ifndef RS_ENTITYCONTAINER_H
2 #define RS_ENTITYCONTAINER_H
7 #include "rs_ellipse.h"
13 * Class representing a tree of entities.
14 * Typical entity containers are graphics, polylines, groups, texts, ...)
16 * @author Andrew Mustun
18 class RS_EntityContainer: public RS_Entity
21 RS_EntityContainer(RS_EntityContainer * parent = NULL, bool owner = true);
22 //RS_EntityContainer(const RS_EntityContainer& ec);
23 virtual ~RS_EntityContainer();
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();
33 virtual void undoStateChanged(bool undone);
34 virtual void setVisible(bool v);
36 virtual bool setSelected(bool select = true);
37 virtual bool toggleSelected();
39 virtual void selectWindow(Vector v1, Vector v2, bool select = true, bool cross = false);
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);
55 // Q3PtrListIterator<RS_Entity> createIterator();
56 // QListIterator<RS_Entity *> createIterator();
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);
72 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
74 RS_Entity * getNearestEntity(const Vector & point, double * dist = NULL,
75 RS2::ResolveLevel level = RS2::ResolveAll);
77 virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true,
78 double * dist = NULL, RS_Entity ** entity = NULL);
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);
87 virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity,
88 RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
90 virtual bool optimizeContours();
92 virtual bool hasEndpointsWithinWindow(Vector v1, Vector v2);
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);
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);
104 friend std::ostream & operator<<(std::ostream & os, RS_EntityContainer & ec);
107 /** entities in the container */
108 // Q3PtrList<RS_Entity> entities;
109 QList<RS_Entity *> entities;
111 /** sub container used only temporarly for iteration. */
112 RS_EntityContainer * subContainer;
116 * Automatically update the borders of the container when entities
117 * are added or removed.
119 static bool autoUpdateBorders;
122 QListIterator<RS_Entity *> entityIterator;