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