1 /****************************************************************************
2 ** $Id: rs_insert.h 2367 2005-04-04 16:57:36Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
30 #include "rs_entitycontainer.h"
32 #include "rs_graphic.h"
35 * Holds the data that defines an insert.
41 * Default constructor.
46 * @param name The name of the block used as an identifier.
47 * @param insertionPoint Insertion point of the block.
48 * @param scaleFactor Scale factor in x / y.
49 * @param angle Rotation angle.
50 * @param cols Number of cols if we insert a whole array.
51 * @param rows Number of rows if we insert a whole array.
52 * @param spacing Spacing between rows and cols.
53 * @param blockSource Source for the block to insert if other than parent.
54 * Normally blocks are requested from the entity's parent but the
55 * block can also come from another resource. RS_Text uses that
56 * to share the blocks (letters) from a font.
57 * @param updateMode RS2::Update will update the insert entity instantly
58 * RS2::NoUpdate will not update the insert. You can update
59 * it later manually using the update() method. This is
60 * often the case since you might want to adjust attributes
61 * after creating an insert entity.
63 RS_InsertData(const QString & name, Vector insertionPoint, Vector scaleFactor,
64 double angle, int cols, int rows, Vector spacing, RS_BlockList * blockSource = NULL,
65 RS2::UpdateMode updateMode = RS2::Update)
68 this->insertionPoint = insertionPoint;
69 this->scaleFactor = scaleFactor;
73 this->spacing = spacing;
74 this->blockSource = blockSource;
75 this->updateMode = updateMode;
78 friend class RS_Insert;
80 friend std::ostream & operator<<(std::ostream & os, const RS_InsertData & d)
82 os << "(" << d.name.toLatin1().data() << ")";
87 Vector insertionPoint;
92 RS_BlockList * blockSource;
93 RS2::UpdateMode updateMode;
97 * An insert inserts a block into the drawing at a certain location
98 * with certain attributes (angle, scale, ...).
99 * Inserts don't really contain other entities internally. They just
100 * refer to a block. However, to the outside world they act exactly
101 * like EntityContainer.
103 * @author Andrew Mustun
105 class RS_Insert: public RS_EntityContainer
108 RS_Insert(RS_EntityContainer * parent, const RS_InsertData & d);
109 virtual ~RS_Insert();
111 virtual RS_Entity * clone();
112 virtual RS2::EntityType rtti() const;
113 RS_InsertData getData() const;
114 virtual void reparent(RS_EntityContainer * parent);
116 RS_Block * getBlockForInsert();
117 virtual void update();
119 QString getName() const;
120 void setName(const QString & newName);
121 Vector getInsertionPoint() const;
122 void setInsertionPoint(const Vector & i);
123 Vector getScale() const;
124 void setScale(const Vector & s);
125 double getAngle() const;
126 void setAngle(double a);
131 Vector getSpacing() const;
132 void setSpacing(const Vector & s);
133 virtual bool isVisible();
135 virtual VectorSolutions getRefPoints();
136 virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
138 virtual void move(Vector offset);
139 virtual void rotate(Vector center, double angle);
140 virtual void scale(Vector center, Vector factor);
141 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
143 friend std::ostream & operator<<(std::ostream & os, const RS_Insert & i);