src/ldtypes.cc

Fri, 10 Jan 2014 15:48:40 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 10 Jan 2014 15:48:40 +0200
changeset 617
f5059d144438
parent 606
3dd6f343ec06
child 618
de0d51349f6c
permissions
-rw-r--r--

- added a type alias LDObjectList

557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
3 * Copyright (C) 2013, 2014 Santeri Piippo
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
8 * (at your option) any later version.
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include "main.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "ldtypes.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "document.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "misc.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "gui.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "history.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "gldraw.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 #include "colors.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
28 cfg (String, ld_defaultname, "");
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
29 cfg (String, ld_defaultuser, "");
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
30 cfg (Int, ld_defaultlicense, 0);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 // List of all LDObjects
617
f5059d144438 - added a type alias LDObjectList
Santeri Piippo <crimsondusk64@gmail.com>
parents: 606
diff changeset
33 static LDObjectList g_LDObjects;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 // LDObject constructors
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 LDObject::LDObject() :
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
39 m_Hidden (false),
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
40 m_Selected (false),
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
41 m_Parent (null),
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
42 m_File (null),
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
43 m_GLInit (false),
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
44 qObjListEntry (null)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
45 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
46 memset (m_coords, 0, sizeof m_coords);
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
47 chooseID();
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
48 g_LDObjects << this;
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
49 }
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
51 // =============================================================================
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
52 // -----------------------------------------------------------------------------
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
53 void LDObject::chooseID()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
54 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
55 int32 id = 1; // 0 shalt be null
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
57 for (LDObject* obj : g_LDObjects)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
58 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
59 assert (obj != this);
562
c4ff45e98551 - fixed: LDObject methods still used operator delete directly, causing *a very frustrating* crash to debug
Santeri Piippo <crimsondusk64@gmail.com>
parents: 560
diff changeset
60
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
61 if (obj->getID() >= id)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 id = obj->getID() + 1;
562
c4ff45e98551 - fixed: LDObject methods still used operator delete directly, causing *a very frustrating* crash to debug
Santeri Piippo <crimsondusk64@gmail.com>
parents: 560
diff changeset
63 }
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
65 setID (id);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 // Default implementations for LDObject's virtual methods. These should never be
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 // actually called, for a subclass-less LDObject should never come into existance.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 // These exist only to satisfy the linker.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 LDObject::Type LDObject::getType() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
74 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
75 return LDObject::EUnidentified;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 bool LDObject::hasMatrix() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
79 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
80 return false;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 bool LDObject::isColored() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
84 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
85 return false;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 bool LDObject::isScemantic() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
89 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
90 return false;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
93 QString LDObject::getTypeName() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
94 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
95 return "";
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 int LDObject::vertices() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
99 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
100 return 0;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
105 void LDObject::setVertexCoord (int i, Axis ax, double value)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
106 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
107 Vertex v = getVertex (i);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108 v[ax] = value;
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
109 setVertex (i, v);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 LDError::LDError() {}
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
116 QString LDComment::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
117 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
118 return fmt ("0 %1", text);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
123 QString LDSubfile::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
124 {
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
125 QString val = fmt ("1 %1 %2 ", getColor(), getPosition());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 val += getTransform().stringRep();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 val += ' ';
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 val += getFileInfo()->getName();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 return val;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
134 QString LDLine::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
135 {
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
136 QString val = fmt ("2 %1", getColor());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
138 for (int i = 0; i < 2; ++i)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
139 val += fmt (" %1", getVertex (i));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 return val;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
146 QString LDTriangle::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
147 {
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
148 QString val = fmt ("3 %1", getColor());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
150 for (int i = 0; i < 3; ++i)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
151 val += fmt (" %1", getVertex (i));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 return val;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
158 QString LDQuad::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
159 {
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
160 QString val = fmt ("4 %1", getColor());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
162 for (int i = 0; i < 4; ++i)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
163 val += fmt (" %1", getVertex (i));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 return val;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
170 QString LDCondLine::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
171 {
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
172 QString val = fmt ("5 %1", getColor());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 // Add the coordinates
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
175 for (int i = 0; i < 4; ++i)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
176 val += fmt (" %1", getVertex (i));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 return val;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
183 QString LDError::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
184 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
185 return contents;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
190 QString LDVertex::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
191 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
192 return fmt ("0 !LDFORGE VERTEX %1 %2", getColor(), pos);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
197 QString LDEmpty::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
198 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
199 return "";
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 const char* LDBFC::statements[] =
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
205 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
206 "CERTIFY CCW",
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 "CCW",
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 "CERTIFY CW",
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 "CW",
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 "NOCERTIFY",
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 "INVERTNEXT",
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 "CLIP",
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 "CLIP CCW",
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 "CLIP CW",
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215 "NOCLIP",
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 };
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
218 QString LDBFC::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
219 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
220 return fmt ("0 BFC %1", LDBFC::statements[type]);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 QList<LDTriangle*> LDQuad::splitToTriangles()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
226 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
227 // Create the two triangles based on this quadrilateral:
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 // 0---3 0---3 3
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 // | | | / /|
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
230 // | | ==> | / / |
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231 // | | |/ / |
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232 // 1---2 1 1---2
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
233 LDTriangle* tri1 = new LDTriangle (getVertex (0), getVertex (1), getVertex (3));
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
234 LDTriangle* tri2 = new LDTriangle (getVertex (1), getVertex (2), getVertex (3));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236 // The triangles also inherit the quad's color
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
237 tri1->setColor (getColor());
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
238 tri2->setColor (getColor());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 QList<LDTriangle*> triangles;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 triangles << tri1;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242 triangles << tri2;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 return triangles;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
248 void LDObject::replace (LDObject* other)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
249 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
250 long idx = getIndex();
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
251 assert (idx != -1);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 // Replace the instance of the old object with the new object
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
254 getFile()->setObject (idx, other);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256 // Remove the old object
562
c4ff45e98551 - fixed: LDObject methods still used operator delete directly, causing *a very frustrating* crash to debug
Santeri Piippo <crimsondusk64@gmail.com>
parents: 560
diff changeset
257 deleteSelf();
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
258 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
262 void LDObject::swap (LDObject* other)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
263 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
264 assert (getFile() == other->getFile());
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
265 getFile()->swapObjects (this, other);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
268 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
270 LDLine::LDLine (Vertex v1, Vertex v2)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
271 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
272 setVertex (0, v1);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
273 setVertex (1, v2);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
278 LDQuad::LDQuad (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
279 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
280 setVertex (0, v0);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
281 setVertex (1, v1);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
282 setVertex (2, v2);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
283 setVertex (3, v3);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287 // -----------------------------------------------------------------------------
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
288 LDObject::~LDObject() {}
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
289
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
290 // =============================================================================
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
291 // -----------------------------------------------------------------------------
583
4906c5c1670f - documents are now refcounted. This should seriously stabilize (and speed up!) the pruning of unused files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 565
diff changeset
292 LDSubfile::~LDSubfile() {}
564
79b23e02dcf1 - implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents: 562
diff changeset
293
79b23e02dcf1 - implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents: 562
diff changeset
294 // =============================================================================
79b23e02dcf1 - implicit documents are now auto-closed when rendered unused, in general, a LOT better document closing behavior
Santeri Piippo <crimsondusk64@gmail.com>
parents: 562
diff changeset
295 // -----------------------------------------------------------------------------
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
296 void LDObject::deleteSelf()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
297 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
298 // If this object was selected, unselect it now
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
299 if (isSelected())
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300 unselect();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302 // If this object was associated to a file, remove it off it now
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
303 if (getFile())
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
304 getFile()->forgetObject (this);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306 // Delete the GL lists
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
307 GL::deleteLists (this);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 // Remove this object from the list of LDObjects
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
310 g_LDObjects.removeOne (this);
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
311
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
312 delete this;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
317 static void transformObject (LDObject* obj, Matrix transform, Vertex pos, int parentcolor)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
318 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
319 switch (obj->getType())
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
320 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
321 case LDObject::ELine:
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
322 case LDObject::ECondLine:
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
323 case LDObject::ETriangle:
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
324 case LDObject::EQuad:
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
326 for (int i = 0; i < obj->vertices(); ++i)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
327 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
328 Vertex v = obj->getVertex (i);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
329 v.transform (transform, pos);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
330 obj->setVertex (i, v);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333 break;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
334
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
335 case LDObject::ESubfile:
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
336 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
337 LDSubfile* ref = static_cast<LDSubfile*> (obj);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
338 Matrix newMatrix = transform * ref->getTransform();
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
339 Vertex newpos = ref->getPosition();
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
340
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
341 newpos.transform (transform, pos);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
342 ref->setPosition (newpos);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
343 ref->setTransform (newMatrix);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345 break;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
347 default:
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
348 break;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
349 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
351 if (obj->getColor() == maincolor)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
352 obj->setColor (parentcolor);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
354
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 // -----------------------------------------------------------------------------
617
f5059d144438 - added a type alias LDObjectList
Santeri Piippo <crimsondusk64@gmail.com>
parents: 606
diff changeset
357 LDObjectList LDSubfile::inlineContents (InlineFlags flags)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
358 {
617
f5059d144438 - added a type alias LDObjectList
Santeri Piippo <crimsondusk64@gmail.com>
parents: 606
diff changeset
359 LDObjectList objs = getFileInfo()->inlineContents (flags);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 // Transform the objects
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
362 for (LDObject* obj : objs)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
363 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
364 // Set the parent now so we know what inlined the object.
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
365 obj->setParent (this);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
366 transformObject (obj, getTransform(), getPosition(), getColor());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
369 return objs;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 long LDObject::getIndex() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
375 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
376 assert (getFile() != null);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
378 for (int i = 0; i < getFile()->getObjectCount(); ++i)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
379 if (getFile()->getObject (i) == this)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380 return i;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
382 return -1;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
383 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 // -----------------------------------------------------------------------------
617
f5059d144438 - added a type alias LDObjectList
Santeri Piippo <crimsondusk64@gmail.com>
parents: 606
diff changeset
387 void LDObject::moveObjects (LDObjectList objs, const bool up)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
388 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
389 if (objs.isEmpty())
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
390 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
391
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392 // If we move down, we need to iterate the array in reverse order.
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
393 const long start = up ? 0 : (objs.size() - 1);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394 const long end = up ? objs.size() : -1;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395 const long incr = up ? 1 : -1;
617
f5059d144438 - added a type alias LDObjectList
Santeri Piippo <crimsondusk64@gmail.com>
parents: 606
diff changeset
396 LDObjectList objsToCompile;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 LDDocument* file = objs[0]->getFile();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
399 for (long i = start; i != end; i += incr)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
400 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
401 LDObject* obj = objs[i];
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 const long idx = obj->getIndex(),
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
404 target = idx + (up ? -1 : 1);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
405
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
406 if ( (up && idx == 0) || (!up && idx == (long) (file->getObjects().size() - 1)))
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
407 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
408 // One of the objects hit the extrema. If this happens, this should be the first
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409 // object to be iterated on. Thus, nothing has changed yet and it's safe to just
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410 // abort the entire operation.
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
411 assert (i == start);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
413 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
414
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415 objsToCompile << obj;
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
416 objsToCompile << file->getObject (target);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
417
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
418 obj->swap (file->getObject (target));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
420
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
421 removeDuplicates (objsToCompile);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
423 // The objects need to be recompiled, otherwise their pick lists are left with
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
424 // the wrong index colors which messes up selection.
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
425 for (LDObject* obj : objsToCompile)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
426 g_win->R()->compileObject (obj);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
430 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
431 QString LDObject::typeName (LDObject::Type type)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
432 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
433 LDObject* obj = LDObject::getDefault (type);
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
434 QString name = obj->getTypeName();
562
c4ff45e98551 - fixed: LDObject methods still used operator delete directly, causing *a very frustrating* crash to debug
Santeri Piippo <crimsondusk64@gmail.com>
parents: 560
diff changeset
435 obj->deleteSelf();
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
436 return name;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
437 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
438
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
439 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 // -----------------------------------------------------------------------------
617
f5059d144438 - added a type alias LDObjectList
Santeri Piippo <crimsondusk64@gmail.com>
parents: 606
diff changeset
441 QString LDObject::describeObjects (const LDObjectList& objs)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
442 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
443 bool firstDetails = true;
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
444 QString text = "";
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
445
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
446 if (objs.isEmpty())
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
447 return "nothing"; // :)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
449 for (long i = 0; i < ENumTypes; ++i)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
450 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
451 Type objType = (Type) i;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
452 int count = 0;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
453
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
454 for (LDObject * obj : objs)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
455 if (obj->getType() == objType)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
456 count++;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
457
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
458 if (count == 0)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
459 continue;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
460
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
461 if (!firstDetails)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
462 text += ", ";
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
463
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
464 QString noun = fmt ("%1%2", typeName (objType), plural (count));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
466 // Plural of "vertex" is "vertices", correct that
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
467 if (objType == EVertex && count != 1)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
468 noun = "vertices";
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
470 text += fmt ("%1 %2", count, noun);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
471 firstDetails = false;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
472 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
473
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474 return text;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
475 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
477 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
478 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
479 LDObject* LDObject::topLevelParent()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
480 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
481 if (!getParent())
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
482 return this;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
484 LDObject* it = this;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
485
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
486 while (it->getParent())
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
487 it = it->getParent();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
488
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
489 return it;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
490 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
491
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
492 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
493 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
494 LDObject* LDObject::next() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
495 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
496 long idx = getIndex();
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
497 assert (idx != -1);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
498
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
499 if (idx == (long) getFile()->getObjectCount() - 1)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
500 return null;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
501
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
502 return getFile()->getObject (idx + 1);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
503 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
504
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
505 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
506 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
507 LDObject* LDObject::prev() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
508 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
509 long idx = getIndex();
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
510 assert (idx != -1);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
511
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
512 if (idx == 0)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
513 return null;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
514
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
515 return getFile()->getObject (idx - 1);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
516 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
517
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
518 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
519 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
520 void LDObject::move (Vertex vect)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
521 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
522 if (hasMatrix())
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
523 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
524 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (this);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
525 mo->setPosition (mo->getPosition() + vect);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
526 }
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
527 elif (getType() == LDObject::EVertex)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
528 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
529 // ugh
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
530 static_cast<LDVertex*> (this)->pos += vect;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
531 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
532 else
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
533 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
534 for (int i = 0; i < vertices(); ++i)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
535 setVertex (i, getVertex (i) + vect);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
536 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
537 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
538
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
539 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
540 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
541 #define CHECK_FOR_OBJ(N) \
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
542 if (type == LDObject::E##N) \
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
543 return new LD##N;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
544
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
545 LDObject* LDObject::getDefault (const LDObject::Type type)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
546 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
547 CHECK_FOR_OBJ (Comment)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
548 CHECK_FOR_OBJ (BFC)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
549 CHECK_FOR_OBJ (Line)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
550 CHECK_FOR_OBJ (CondLine)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
551 CHECK_FOR_OBJ (Subfile)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
552 CHECK_FOR_OBJ (Triangle)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
553 CHECK_FOR_OBJ (Quad)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
554 CHECK_FOR_OBJ (Empty)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
555 CHECK_FOR_OBJ (BFC)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
556 CHECK_FOR_OBJ (Error)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
557 CHECK_FOR_OBJ (Vertex)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
558 CHECK_FOR_OBJ (Overlay)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
559 return null;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
560 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
561
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
562 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
563 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
564 void LDObject::invert() {}
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
565 void LDBFC::invert() {}
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
566 void LDEmpty::invert() {}
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
567 void LDComment::invert() {}
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
568 void LDError::invert() {}
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
569
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
570 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
571 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
572 void LDTriangle::invert()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
573 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
574 // Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1.
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
575 // Thus, we swap 1 and 2.
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
576 Vertex tmp = getVertex (1);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
577 setVertex (1, getVertex (2));
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
578 setVertex (2, tmp);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
579
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
580 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
581 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
582
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
583 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
584 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
585 void LDQuad::invert()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
586 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
587 // Quad: 0 -> 1 -> 2 -> 3
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
588 // rev: 0 -> 3 -> 2 -> 1
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
589 // Thus, we swap 1 and 3.
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
590 Vertex tmp = getVertex (1);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
591 setVertex (1, getVertex (3));
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
592 setVertex (3, tmp);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
593 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
594
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
595 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
596 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
597 void LDSubfile::invert()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
598 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
599 // Subfiles are inverted when they're prefixed with
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
600 // a BFC INVERTNEXT statement. Thus we need to toggle this status.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
601 // For flat primitives it's sufficient that the determinant is
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
602 // flipped but I don't have a method for checking flatness yet.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
603 // Food for thought...
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
604
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
605 int idx = getIndex();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
606
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
607 if (idx > 0)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
608 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
609 LDBFC* bfc = dynamic_cast<LDBFC*> (prev());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
610
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
611 if (bfc && bfc->type == LDBFC::InvertNext)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
612 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
613 // This is prefixed with an invertnext, thus remove it.
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
614 bfc->deleteSelf();
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
615 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
616 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
617 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
618
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
619 // Not inverted, thus prefix it with a new invertnext.
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
620 LDBFC* bfc = new LDBFC (LDBFC::InvertNext);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
621 getFile()->insertObj (idx, bfc);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
622 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
623
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
624 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
625 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
626 static void invertLine (LDObject* line)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
627 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
628 // For lines, we swap the vertices. I don't think that a
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
629 // cond-line's control points need to be swapped, do they?
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
630 Vertex tmp = line->getVertex (0);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
631 line->setVertex (0, line->getVertex (1));
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
632 line->setVertex (1, tmp);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
633 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
634
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
635 void LDLine::invert()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
636 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
637 invertLine (this);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
638 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
639
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
640 void LDCondLine::invert()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
641 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
642 invertLine (this);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
643 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
644
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
645 void LDVertex::invert() {}
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
646
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
647 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
648 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
649 LDLine* LDCondLine::demote()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
650 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
651 LDLine* repl = new LDLine;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
652
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
653 for (int i = 0; i < repl->vertices(); ++i)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
654 repl->setVertex (i, getVertex (i));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
655
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
656 repl->setColor (getColor());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
657
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
658 replace (repl);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
659 return repl;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
660 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
661
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
662 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
663 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
664 LDObject* LDObject::fromID (int id)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
665 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
666 for (LDObject* obj : g_LDObjects)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
667 if (obj->getID() == id)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
668 return obj;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
669
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
670 return null;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
671 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
672
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
673 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
674 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
675 QString LDOverlay::raw() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
676 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
677 return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6",
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
678 getFileName(), getCamera(), getX(), getY(), getWidth(), getHeight());
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
679 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
680
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
681 void LDOverlay::invert() {}
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
682
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
683 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
684 // Hook the set accessors of certain properties to this changeProperty function.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
685 // It takes care of history management so we can capture low-level changes, this
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
686 // makes history stuff work out of the box.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
687 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
688 template<class T> static void changeProperty (LDObject* obj, T* ptr, const T& val)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
689 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
690 long idx;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
691
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
692 if (*ptr == val)
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
693 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
694
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
695 if (obj->getFile() && (idx = obj->getIndex()) != -1)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
696 {
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
697 QString before = obj->raw();
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
698 *ptr = val;
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
699 QString after = obj->raw();
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
700
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
701 if (before != after)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
702 obj->getFile()->addToHistory (new EditHistory (idx, before, after));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
703 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
704 else
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
705 *ptr = val;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
706 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
707
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
708 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
709 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
710 void LDObject::setColor (const int& val)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
711 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
712 changeProperty (this, &m_Color, val);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
713 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
714
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
715 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
716 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
717 const Vertex& LDObject::getVertex (int i) const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
718 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
719 return m_coords[i]->data();
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
720 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
721
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
722 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
723 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
724 void LDObject::setVertex (int i, const Vertex& vert)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
725 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
726 changeProperty (this, &m_coords[i], LDSharedVertex::getSharedVertex (vert));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
727 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
728
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
729 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
730 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
731 void LDMatrixObject::setPosition (const Vertex& a)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
732 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
733 changeProperty (getLinkPointer(), &m_Position, LDSharedVertex::getSharedVertex (a));
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
734 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
735
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
736 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
737 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
738 void LDMatrixObject::setTransform (const Matrix& val)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
739 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
740 changeProperty (getLinkPointer(), &m_Transform, val);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
741 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
742
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
743 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
744 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
745 static QMap<Vertex, LDSharedVertex*> g_sharedVerts;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
746
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
747 LDSharedVertex* LDSharedVertex::getSharedVertex (const Vertex& a)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
748 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
749 auto it = g_sharedVerts.find (a);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
750
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
751 if (it == g_sharedVerts.end())
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
752 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
753 LDSharedVertex* v = new LDSharedVertex (a);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
754 g_sharedVerts[a] = v;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
755 return v;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
756 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
757
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
758 return *it;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
759 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
760
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
761 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
762 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
763 void LDSharedVertex::addRef (LDObject* a)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
764 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
765 m_refs << a;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
766 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
767
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
768 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
769 // -----------------------------------------------------------------------------
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
770 void LDSharedVertex::delRef (LDObject* a)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
771 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
772 m_refs.removeOne (a);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
773
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
774 if (m_refs.empty())
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
775 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
776 g_sharedVerts.remove (m_data);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
777 delete this;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
778 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
779 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
780
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
781 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
782 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
783 void LDObject::select()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
784 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
785 if (!getFile())
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
786 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
787 log ("Warning: Object #%1 cannot be selected as it is not assigned a file!\n", getID());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
788 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
789 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
790
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
791 getFile()->addToSelection (this);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
792 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
793
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
794 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
795 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
796 void LDObject::unselect()
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
797 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
798 if (!getFile())
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
799 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
800 log ("Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", getID());
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
801 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
802 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
803
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
804 getFile()->removeFromSelection (this);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
805 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
806
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
807 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
808 // -----------------------------------------------------------------------------
606
3dd6f343ec06 - removed the 'str' typedef, use QString directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 604
diff changeset
809 QString getLicenseText (int id)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
810 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
811 switch (id)
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
812 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
813 case 0:
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
814 return CALicense;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
815
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
816 case 1:
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
817 return NonCALicense;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
818
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
819 case 2:
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
820 return "";
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
821 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
822
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
823 assert (false);
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
824 return "";
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
825 }
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
826
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
827 // =============================================================================
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
828 // -----------------------------------------------------------------------------
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
829 LDObject* LDObject::createCopy() const
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
830 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
831 /*
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
832 LDObject* copy = clone();
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
833 copy->setFile (null);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
834 copy->setGLInit (false);
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
835 copy->chooseID();
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
836 copy->setSelected (false);
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
837 */
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
838
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
839 /*
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
840 LDObject* copy = getDefault (getType());
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
841 copy->setColor (getColor());
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
842
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
843 if (hasMatrix())
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
844 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
845 LDMatrixObject* copyMo = static_cast<LDMatrixObject*> (copy);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
846 const LDMatrixObject* mo = static_cast<const LDMatrixObject*> (this);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
847 copyMo->setPosition (mo->getPosition());
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
848 copyMo->setTransform (mo->getTransform());
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
849 }
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
850 else
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
851 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
852 for (int i = 0; i < vertices(); ++i)
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
853 copy->setVertex (getVertex (i));
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
854 }
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
855
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
856 switch (getType())
603
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
857 {
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
858 case Subfile:
47e7773c7841 - reformatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 600
diff changeset
859 {
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
860 LDSubfile* copyRef = static_cast<LDSubfile*> (copy);
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
861 const LDSubfile* ref = static_cast<const LDSubfile*> (this);
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
862
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
863 copyRef->setFileInfo (ref->getFileInfo());
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
864 }
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
865 }
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
866 */
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
867
604
01bdac75994a - some cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 603
diff changeset
868 LDObject* copy = parseLine (raw());
560
39085791128f - corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 557
diff changeset
869 return copy;
557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
870 }

mercurial