1 #ifndef __ENTITYCONTAINER_H__
2 #define __ENTITYCONTAINER_H__
13 * Class representing a tree of entities.
14 * Typical entity containers are graphics, polylines, groups, texts, ...)
16 * @author Andrew Mustun
18 class EntityContainer: public Entity
21 EntityContainer(EntityContainer * parent = NULL, bool owner = true);
22 //EntityContainer(const EntityContainer& ec);
23 virtual ~EntityContainer();
25 virtual Entity * clone();
26 virtual void detach();
27 virtual RS2::EntityType rtti() const;
28 void reparent(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(Entity * entity);
42 virtual void insertEntity(int index, Entity * entity);
43 virtual void replaceEntity(int index, Entity * entity);
44 virtual bool removeEntity(Entity * entity);
45 virtual Entity * firstEntity(RS2::ResolveLevel level = RS2::ResolveNone);
46 virtual Entity * lastEntity(RS2::ResolveLevel level = RS2::ResolveNone);
47 virtual Entity * nextEntity(RS2::ResolveLevel level = RS2::ResolveNone);
48 virtual Entity * prevEntity(RS2::ResolveLevel level = RS2::ResolveNone);
49 virtual Entity * entityAt(uint index);
50 virtual Entity * currentEntity();
51 virtual int entityAt();
52 virtual int findEntity(Entity * entity);
55 // Q3PtrListIterator<Entity> createIterator();
56 // QListIterator<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(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 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, 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, 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, EntityContainer & ec);
107 /** entities in the container */
108 QList<Entity *> entities;
110 /** sub container used only temporarly for iteration. */
111 EntityContainer * subContainer;
115 * Automatically update the borders of the container when entities
116 * are added or removed.
118 static bool autoUpdateBorders;
121 QListIterator<Entity *> entityIterator;
124 #endif // __ENTITYCONTAINER_H__