1
/****************************************************************************
3
** This file is part of the LibreCAD project, a 2D CAD program
5
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
6
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
9
** This file may be distributed and/or modified under the terms of the
10
** GNU General Public License version 2 as published by the Free Software
11
** Foundation and appearing in the file gpl-2.0.txt included in the
12
** packaging of this file.
14
** This program is distributed in the hope that it will be useful,
15
** but WITHOUT ANY WARRANTY; without even the implied warranty of
16
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
** GNU General Public License for more details.
19
** You should have received a copy of the GNU General Public License
20
** along with this program; if not, write to the Free Software
21
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
** This copyright notice MUST APPEAR in all copies of the script!
25
**********************************************************************/
28
#ifndef RS_ATOMICENTITY_H
29
#define RS_ATOMICENTITY_H
31
#include "rs_entity.h"
36
* Class representing an atomic entity
37
* Typical atomic entities: RS_Line, RS_Arc, RS_Circle, RS_Ellipse
39
* @author Andrew Mustun
41
class RS_AtomicEntity : public RS_Entity {
47
RS_AtomicEntity(RS_EntityContainer* parent=NULL) : RS_Entity(parent) {}
51
virtual ~RS_AtomicEntity() {}
54
* @return false because entities made from subclasses are
57
virtual bool isContainer() const {
62
* @return true because entities made from subclasses are
65
virtual bool isAtomic() const {
70
* @return Always 1 for atomic entities.
72
virtual unsigned int count() {
77
* @return Always 1 for atomic entities.
79
virtual unsigned int countDeep() {
84
* Implementation must return the endpoint of the entity or
85
* an invalid vector if the entity has no endpoint.
87
virtual RS_Vector getEndpoint() const {
88
return RS_Vector(false);
92
* Implementation must return the startpoint of the entity or
93
* an invalid vector if the entity has no startpoint.
95
virtual RS_Vector getStartpoint() const {
96
return RS_Vector(false);
100
* Implementation must return the angle in which direction the entity starts.
102
virtual double getDirection1() const {
107
* Implementation must return the angle in which direction the entity starts the opposite way.
109
virtual double getDirection2() const {
112
virtual RS_Vector getCenter() const {
113
return RS_Vector(false);
115
virtual double getRadius() const {
119
* return the nearest center for snapping
120
* @param coord Coordinate (typically a mouse coordinate)
121
* @param dist Pointer to a value which will contain the measured
122
* distance between 'coord' and the closest center point. The passed
123
* pointer can also be NULL in which case the distance will be
126
* @return The closest center point.
128
virtual RS_Vector getNearestCenter(const RS_Vector& /*coord*/,
130
return RS_Vector(false);
134
* (De-)selects startpoint.
136
virtual void setStartpointSelected(bool select) {
138
setFlag(RS2::FlagSelected1);
140
delFlag(RS2::FlagSelected1);
145
* (De-)selects endpoint.
147
virtual void setEndpointSelected(bool select) {
149
setFlag(RS2::FlagSelected2);
151
delFlag(RS2::FlagSelected2);
154
virtual bool isTangent(const RS_CircleData& /* circleData */) {
159
* @return True if the entities startpoint is selected.
161
bool isStartpointSelected() const {
162
return getFlag(RS2::FlagSelected1);
166
* @return True if the entities endpoint is selected.
168
bool isEndpointSelected() const {
169
return getFlag(RS2::FlagSelected2);
172
virtual void revertDirection(){}
175
* Implementation must create offset of the entity to
176
* the given direction and distance
178
virtual bool offset(const RS_Vector& /*position*/, const double& /*distance*/) {return false;}
181
* Implementation must move the startpoint of the entity to
182
* the given position.
184
virtual void moveStartpoint(const RS_Vector& /*pos*/) {}
187
* Implementation must move the endpoint of the entity to
188
* the given position.
190
virtual void moveEndpoint(const RS_Vector& /*pos*/) {}
193
* Implementation must trim the startpoint of the entity to
194
* the given position.
196
virtual void trimStartpoint(const RS_Vector& pos) {
201
* Implementation must trim the endpoint of the entity to
202
* the given position.
204
virtual void trimEndpoint(const RS_Vector& pos) {
209
* Implementation must return which ending of the entity will
210
* be trimmed if 'coord' is the coordinate chosen to indicate the
211
* trim entity and 'trimPoint' is the point to which the entity will
214
virtual RS2::Ending getTrimPoint(const RS_Vector& /*coord*/,
215
const RS_Vector& /*trimPoint*/) {
216
return RS2::EndingNone;
220
* Implementation must trim the entity in the case of multiple
221
* intersections and return the trimPoint
222
* trimCoord indicts the trigger trim position
223
* trimSol contains intersections
225
virtual RS_Vector prepareTrim(const RS_Vector& /*trimCoord*/,
226
const RS_VectorSolutions& /*trimSol*/) {
227
return RS_Vector(false);
230
virtual void reverse() { }
232
virtual void moveSelectedRef(const RS_Vector& ref, const RS_Vector& offset) {
234
moveRef(ref, offset);