]> Shamusworld >> Repos - architektonas/blob - src/base/rs_atomicentity.cpp
0b70917dc356b05e5f0f1b82ebfee75a2203038c
[architektonas] / src / base / rs_atomicentity.cpp
1 // rs_atomicentity.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  05/08/2010  Moved implementation from header to this file. :-)
15 //
16
17 #include "rs_atomicentity.h"
18
19 /**
20  * Construtor.
21  */
22 RS_AtomicEntity::RS_AtomicEntity(RS_EntityContainer * parent/*= NULL*/): RS_Entity(parent)
23 {
24 }
25
26 /**
27  * Destrutor.
28  */
29 /*virtual*/ RS_AtomicEntity::~RS_AtomicEntity()
30 {
31 }
32
33 /**
34  * @return false because entities made from subclasses are
35  *  atomic entities.
36  */
37 /*virtual*/ bool RS_AtomicEntity::isContainer() const
38 {
39         return false;
40 }
41
42 /**
43  * @return true because entities made from subclasses are
44  *  atomic entities.
45  */
46 /*virtual*/ bool RS_AtomicEntity::isAtomic() const
47 {
48         return true;
49 }
50
51 /**
52  * @return Always 1 for atomic entities.
53  */
54 /*virtual*/ unsigned long int RS_AtomicEntity::count()
55 {
56         return 1;
57 }
58
59 /**
60  * @return Always 1 for atomic entities.
61  */
62 /*virtual*/ unsigned long int RS_AtomicEntity::countDeep()
63 {
64         return 1;
65 }
66
67 /**
68  * Implementation must return the endpoint of the entity or
69  * an invalid vector if the entity has no endpoint.
70  */
71 /*virtual*/ Vector RS_AtomicEntity::getEndpoint() const
72 {
73         return Vector(false);
74 }
75
76 /**
77  * Implementation must return the startpoint of the entity or
78  * an invalid vector if the entity has no startpoint.
79  */
80 /*virtual*/ Vector RS_AtomicEntity::getStartpoint() const
81 {
82         return Vector(false);
83 }
84
85 /**
86  * Implementation must return the angle in which direction the entity starts.
87  */
88 /*virtual*/ double RS_AtomicEntity::getDirection1() const
89 {
90         return 0.0;
91 }
92
93 /**
94  * Implementation must return the angle in which direction the entity starts the opposite way.
95  */
96 /*virtual*/ double RS_AtomicEntity::getDirection2() const
97 {
98         return 0.0;
99 }
100
101 /**
102  * (De-)selects startpoint.
103  */
104 /*virtual*/ void RS_AtomicEntity::setStartpointSelected(bool select)
105 {
106         if (select)
107                 setFlag(RS2::FlagSelected1);
108         else
109                 delFlag(RS2::FlagSelected1);
110 }
111
112 /**
113  * (De-)selects endpoint.
114  */
115 /*virtual*/ void RS_AtomicEntity::setEndpointSelected(bool select)
116 {
117         if (select)
118                 setFlag(RS2::FlagSelected2);
119         else
120                 delFlag(RS2::FlagSelected2);
121 }
122
123 /**
124  * @return True if the entities startpoint is selected.
125  */
126 bool RS_AtomicEntity::isStartpointSelected() const
127 {
128         return getFlag(RS2::FlagSelected1);
129 }
130
131 /**
132  * @return True if the entities endpoint is selected.
133  */
134 bool RS_AtomicEntity::isEndpointSelected() const
135 {
136         return getFlag(RS2::FlagSelected2);
137 }
138
139 /**
140  * Implementation must move the startpoint of the entity to
141  * the given position.
142  */
143 /*virtual*/ void RS_AtomicEntity::moveStartpoint(const Vector & /*pos*/)
144 {
145 }
146
147 /**
148  * Implementation must move the endpoint of the entity to
149  * the given position.
150  */
151 /*virtual*/ void RS_AtomicEntity::moveEndpoint(const Vector & /*pos*/)
152 {
153 }
154
155 /**
156  * Implementation must trim the startpoint of the entity to
157  * the given position.
158  */
159 /*virtual*/ void RS_AtomicEntity::trimStartpoint(const Vector & pos)
160 {
161         moveStartpoint(pos);
162 }
163
164 /**
165 * Implementation must trim the endpoint of the entity to
166 * the given position.
167 */
168 /*virtual*/ void RS_AtomicEntity::trimEndpoint(const Vector & pos)
169 {
170         moveEndpoint(pos);
171 }
172
173 /**
174 * Implementation must return which ending of the entity will
175 * be trimmed if 'coord' is the coordinate chosen to indicate the
176 * trim entity and 'trimPoint' is the point to which the entity will
177 * be trimmed.
178 */
179 /*virtual*/ RS2::Ending RS_AtomicEntity::getTrimPoint(const Vector & /*coord*/, const Vector & /*trimPoint*/)
180 {
181         return RS2::EndingNone;
182 }
183
184 /*virtual*/ void RS_AtomicEntity::reverse()
185 {
186 }
187
188 /*virtual*/ void RS_AtomicEntity::moveSelectedRef(const Vector & ref, const Vector & offset)
189 {
190         if (isSelected())
191                 moveRef(ref, offset);
192 }