1 /****************************************************************************
2 ** $Id: rs_modification.h 1946 2004-12-24 19:27:43Z 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 **********************************************************************/
27 #ifndef RS_MODIFICATION_H
28 #define RS_MODIFICATION_H
30 #include "rs_entitycontainer.h"
31 #include "rs_graphicview.h"
37 * Holds the data needed for move modifications.
42 bool useCurrentAttributes;
50 * Holds the data needed for rotation modifications.
55 bool useCurrentAttributes;
64 * Holds the data needed for scale modifications.
69 bool useCurrentAttributes;
71 Vector referencePoint;
77 * Holds the data needed for mirror modifications.
82 bool useCurrentAttributes;
90 * Holds the data needed for move/rotate modifications.
92 class RS_MoveRotateData {
95 bool useCurrentAttributes;
97 Vector referencePoint;
105 * Holds the data needed for rotation around two centers modifications.
107 class RS_Rotate2Data {
110 bool useCurrentAttributes;
111 bool useCurrentLayer;
121 * Holds the data needed for beveling modifications.
134 * Holds the data needed for rounding modifications.
144 * Holds the data needed for moving reference points.
146 class RS_MoveRefData {
155 * Holds the data needed for changing attributes.
157 class RS_AttributesData {
169 * Holds the data needed for pasting.
173 RS_PasteData(Vector insertionPoint,
177 const RS_String& blockName) {
179 this->insertionPoint = insertionPoint;
180 this->factor = factor;
182 this->asInsert = asInsert;
183 this->blockName = blockName;
187 Vector insertionPoint;
192 //! Paste as an insert rather than individual entities.
194 //! Name of the block to create or an empty string to assign a new auto name.
200 * API Class for manipulating entities.
201 * There's no interaction handled in this class.
203 * All modifications can be undone / redone if the container
206 * This class is connected to an entity container and
207 * can be connected to a graphic view.
209 * @author Andrew Mustun
211 class RS_Modification {
213 RS_Modification(RS_EntityContainer& entityContainer,
214 RS_GraphicView* graphicView=NULL,
215 bool handleUndo=true);
218 bool changeAttributes(RS_AttributesData& data);
220 void copy(const Vector& ref, const bool cut);
222 void copyEntity(RS_Entity* e, const Vector& ref, const bool cut);
224 void copyLayers(RS_Entity* e);
225 void copyBlocks(RS_Entity* e);
226 void paste(const RS_PasteData& data, RS_Graphic* source=NULL);
228 bool move(RS_MoveData& data);
229 bool rotate(RS_RotateData& data);
230 bool scale(RS_ScaleData& data);
231 bool mirror(RS_MirrorData& data);
232 bool moveRotate(RS_MoveRotateData& data);
233 bool rotate2(RS_Rotate2Data& data);
235 bool trim(const Vector& trimCoord, RS_AtomicEntity* trimEntity,
236 const Vector& limitCoord, RS_Entity* limitEntity,
238 bool trimAmount(const Vector& trimCoord, RS_AtomicEntity* trimEntity,
241 bool cut(const Vector& cutCoord, RS_AtomicEntity* cutEntity);
242 bool stretch(const Vector& firstCorner,
243 const Vector& secondCorner,
244 const Vector& offset);
246 bool bevel(const Vector& coord1, RS_AtomicEntity* entity1,
247 const Vector& coord2, RS_AtomicEntity* entity2,
249 bool round(const Vector& coord,
250 const Vector& coord1,
251 RS_AtomicEntity* entity1,
252 const Vector& coord2,
253 RS_AtomicEntity* entity2,
257 bool explodeTextIntoLetters();
258 bool explodeTextIntoLetters(RS_Text* text, RS_PtrList<RS_Entity>& addList);
259 bool moveRef(RS_MoveRefData& data);
261 bool splitPolyline(RS_Polyline& polyline,
262 RS_Entity& e1, Vector v1,
263 RS_Entity& e2, Vector v2,
264 RS_Polyline** polyline1,
265 RS_Polyline** polyline2) const;
266 RS_Polyline* addPolylineNode(RS_Polyline& polyline,
267 const RS_AtomicEntity& segment,
269 RS_Polyline* deletePolylineNode(RS_Polyline& polyline,
271 RS_Polyline* deletePolylineNodesBetween(RS_Polyline& polyline, RS_AtomicEntity& segment,
272 const Vector& node1, const Vector& node2);
273 RS_Polyline* polylineTrim(RS_Polyline& polyline,
274 RS_AtomicEntity& segment1,
275 RS_AtomicEntity& segment2);
278 void deselectOriginals(bool remove);
279 void addNewEntities(RS_PtrList<RS_Entity>& addList);
282 RS_EntityContainer* container;
284 RS_Document* document;
285 RS_GraphicView* graphicView;