]> Shamusworld >> Repos - architektonas/blob - src/base/rs_modification.h.bak
Refactoring: Moved RS_GraphicView to GraphicView.
[architektonas] / src / base / rs_modification.h.bak
1 /****************************************************************************
2 ** $Id: rs_modification.h 1946 2004-12-24 19:27:43Z andrew $
3 **
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5 **
6 ** This file is part of the qcadlib Library project.
7 **
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.
12 **
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.
16 **
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.
19 **
20 ** See http://www.ribbonsoft.com for further details.
21 **
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
23 ** not clear to you.
24 **
25 **********************************************************************/
26
27 #ifndef RS_MODIFICATION_H
28 #define RS_MODIFICATION_H
29
30 #include "rs_entitycontainer.h"
31 #include "rs_graphicview.h"
32 #include "rs_line.h"
33
34
35
36 /**
37  * Holds the data needed for move modifications.
38  */
39 class RS_MoveData {
40 public:
41     int number;
42     bool useCurrentAttributes;
43     bool useCurrentLayer;
44     Vector offset;
45 };
46
47
48
49 /**
50  * Holds the data needed for rotation modifications.
51  */
52 class RS_RotateData {
53 public:
54     int number;
55     bool useCurrentAttributes;
56     bool useCurrentLayer;
57     Vector center;
58     double angle;
59 };
60
61
62
63 /**
64  * Holds the data needed for scale modifications.
65  */
66 class RS_ScaleData {
67 public:
68     int number;
69     bool useCurrentAttributes;
70     bool useCurrentLayer;
71     Vector referencePoint;
72     double factor;
73 };
74
75
76 /**
77  * Holds the data needed for mirror modifications.
78  */
79 class RS_MirrorData {
80 public:
81     bool copy;
82     bool useCurrentAttributes;
83     bool useCurrentLayer;
84     Vector axisPoint1;
85     Vector axisPoint2;
86 };
87
88
89 /**
90  * Holds the data needed for move/rotate modifications.
91  */
92 class RS_MoveRotateData {
93 public:
94     int number;
95     bool useCurrentAttributes;
96     bool useCurrentLayer;
97     Vector referencePoint;
98         Vector offset;
99         double angle;
100 };
101
102
103
104 /**
105  * Holds the data needed for rotation around two centers modifications.
106  */
107 class RS_Rotate2Data {
108 public:
109     int number;
110     bool useCurrentAttributes;
111     bool useCurrentLayer;
112     Vector center1;
113     Vector center2;
114     double angle1;
115     double angle2;
116 };
117
118
119
120 /**
121  * Holds the data needed for beveling modifications.
122  */
123 class RS_BevelData {
124 public:
125         double length1;
126         double length2;
127         bool trim;
128 };
129
130
131
132
133 /**
134  * Holds the data needed for rounding modifications.
135  */
136 class RS_RoundData {
137 public:
138         double radius;
139         bool trim;
140 };
141
142
143 /**
144  * Holds the data needed for moving reference points.
145  */
146 class RS_MoveRefData {
147 public:
148         Vector ref;
149     Vector offset;
150 };
151
152
153
154 /**
155  * Holds the data needed for changing attributes.
156  */
157 class RS_AttributesData {
158 public:
159         RS_String layer;
160         RS_Pen pen;
161         bool changeLayer;
162         bool changeColor;
163         bool changeLineType;
164         bool changeWidth;
165 };
166
167
168 /**
169  * Holds the data needed for pasting.
170  */
171 class RS_PasteData {
172 public:
173         RS_PasteData(Vector insertionPoint,
174                 double factor,
175                 double angle,
176                 bool asInsert,
177                 const RS_String& blockName) {
178
179                 this->insertionPoint = insertionPoint;
180                 this->factor = factor;
181                 this->angle = angle;
182                 this->asInsert = asInsert;
183                 this->blockName = blockName;
184         }
185         
186         //! Insertion point.
187         Vector insertionPoint;
188         //! Scale factor.
189         double factor;
190         //! Rotation angle.
191         double angle;
192         //! Paste as an insert rather than individual entities.
193         bool asInsert;
194         //! Name of the block to create or an empty string to assign a new auto name.
195         RS_String blockName;
196 };
197
198
199 /**
200  * API Class for manipulating entities. 
201  * There's no interaction handled in this class.
202  * 
203  * All modifications can be undone / redone if the container 
204  * is a RS_Graphic.
205  *
206  * This class is connected to an entity container and
207  * can be connected to a graphic view.
208  *
209  * @author Andrew Mustun
210  */
211 class RS_Modification {
212 public:
213     RS_Modification(RS_EntityContainer& entityContainer,
214                     RS_GraphicView* graphicView=NULL,
215                                         bool handleUndo=true);
216
217         void remove();
218     bool changeAttributes(RS_AttributesData& data);
219
220         void copy(const Vector& ref, const bool cut);
221 private:
222         void copyEntity(RS_Entity* e, const Vector& ref, const bool cut);
223 public:
224         void copyLayers(RS_Entity* e);
225         void copyBlocks(RS_Entity* e);
226         void paste(const RS_PasteData& data, RS_Graphic* source=NULL);
227
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);
234         
235     bool trim(const Vector& trimCoord, RS_AtomicEntity* trimEntity,
236               const Vector& limitCoord, RS_Entity* limitEntity,
237                           bool both);
238     bool trimAmount(const Vector& trimCoord, RS_AtomicEntity* trimEntity,
239                   double dist);
240
241     bool cut(const Vector& cutCoord, RS_AtomicEntity* cutEntity);
242     bool stretch(const Vector& firstCorner,
243                                 const Vector& secondCorner,
244                                 const Vector& offset);
245                                 
246     bool bevel(const Vector& coord1, RS_AtomicEntity* entity1,
247               const Vector& coord2, RS_AtomicEntity* entity2,
248                           RS_BevelData& data);
249     bool round(const Vector& coord, 
250                const Vector& coord1,
251                    RS_AtomicEntity* entity1,
252                const Vector& coord2,
253                RS_AtomicEntity* entity2,
254                            RS_RoundData& data);
255
256         bool explode();
257         bool explodeTextIntoLetters();
258         bool explodeTextIntoLetters(RS_Text* text, RS_PtrList<RS_Entity>& addList);
259     bool moveRef(RS_MoveRefData& data);
260
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,
268                                  const Vector& node);
269         RS_Polyline* deletePolylineNode(RS_Polyline& polyline, 
270                                 const Vector& node);
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);
276
277 private:
278     void deselectOriginals(bool remove);
279     void addNewEntities(RS_PtrList<RS_Entity>& addList);
280
281 protected:
282     RS_EntityContainer* container;
283     RS_Graphic* graphic;
284     RS_Document* document;
285     RS_GraphicView* graphicView;
286         bool handleUndo;
287 };
288
289 #endif