4 #include "entitycontainer.h"
9 * Holds the data that defines an insert.
15 * Default constructor.
20 * @param name The name of the block used as an identifier.
21 * @param insertionPoint Insertion point of the block.
22 * @param scaleFactor Scale factor in x / y.
23 * @param angle Rotation angle.
24 * @param cols Number of cols if we insert a whole array.
25 * @param rows Number of rows if we insert a whole array.
26 * @param spacing Spacing between rows and cols.
27 * @param blockSource Source for the block to insert if other than parent.
28 * Normally blocks are requested from the entity's parent but the
29 * block can also come from another resource. Text uses that
30 * to share the blocks (letters) from a font.
31 * @param updateMode RS2::Update will update the insert entity instantly
32 * RS2::NoUpdate will not update the insert. You can update
33 * it later manually using the update() method. This is
34 * often the case since you might want to adjust attributes
35 * after creating an insert entity.
37 InsertData(const QString & name, Vector insertionPoint, Vector scaleFactor,
38 double angle, int cols, int rows, Vector spacing, BlockList * blockSource = NULL,
39 RS2::UpdateMode updateMode = RS2::Update)
42 this->insertionPoint = insertionPoint;
43 this->scaleFactor = scaleFactor;
47 this->spacing = spacing;
48 this->blockSource = blockSource;
49 this->updateMode = updateMode;
54 friend std::ostream & operator<<(std::ostream & os, const InsertData & d)
56 os << "(" << d.name.toLatin1().data() << ")";
61 Vector insertionPoint;
66 BlockList * blockSource;
67 RS2::UpdateMode updateMode;
71 * An insert inserts a block into the drawing at a certain location
72 * with certain attributes (angle, scale, ...).
73 * Inserts don't really contain other entities internally. They just
74 * refer to a block. However, to the outside world they act exactly
75 * like EntityContainer.
77 * @author Andrew Mustun
79 class Insert: public EntityContainer
82 Insert(EntityContainer * parent, const InsertData & d);
85 virtual Entity * clone();
86 virtual RS2::EntityType rtti() const;
87 InsertData getData() const;
88 virtual void reparent(EntityContainer * parent);
90 Block * getBlockForInsert();
91 virtual void update();
93 QString getName() const;
94 void setName(const QString & newName);
95 Vector getInsertionPoint() const;
96 void setInsertionPoint(const Vector & i);
97 Vector getScale() const;
98 void setScale(const Vector & s);
99 double getAngle() const;
100 void setAngle(double a);
105 Vector getSpacing() const;
106 void setSpacing(const Vector & s);
107 virtual bool isVisible();
109 virtual VectorSolutions getRefPoints();
110 virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
112 virtual void move(Vector offset);
113 virtual void rotate(Vector center, double angle);
114 virtual void scale(Vector center, Vector factor);
115 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
117 friend std::ostream & operator<<(std::ostream & os, const Insert & i);