1 /****************************************************************************
2 ** $Id: rs_solid.h 2371 2005-04-29 11:44:39Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
30 #include "rs_atomicentity.h"
34 * Holds the data that defines a solid.
40 * Default constructor. Leaves the data object uninitialized.
43 for (int i=0; i<4; ++i) {
44 corner[i] = Vector(false);
49 * Constructor for a solid with 3 corners.
51 RS_SolidData(const Vector& corner1,
52 const Vector& corner2,
53 const Vector& corner3) {
58 corner[3] = Vector(false);
62 * Constructor for a solid with 4 corners.
64 RS_SolidData(const Vector& corner1,
65 const Vector& corner2,
66 const Vector& corner3,
67 const Vector& corner4) {
75 friend class RS_Solid;
77 friend std::ostream& operator << (std::ostream& os,
78 const RS_SolidData& pd) {
80 for (int i=0; i<4; i++) {
92 * Class for a solid entity (e.g. dimension arrows).
94 * @author Andrew Mustun
96 class RS_Solid: public RS_AtomicEntity
99 RS_Solid(RS_EntityContainer* parent,
100 const RS_SolidData& d);
102 virtual RS_Entity* clone() {
103 RS_Solid* s = new RS_Solid(*this);
108 /** @return RS_ENTITY_POINT */
109 virtual RS2::EntityType rtti() const {
110 return RS2::EntitySolid;
114 * @return Start point of the entity.
116 virtual Vector getStartpoint() const {
117 return Vector(false);
120 * @return End point of the entity.
122 virtual Vector getEndpoint() const {
123 return Vector(false);
127 /** @return Copy of data that defines the point. */
128 RS_SolidData getData() const {
132 /** @return true if this is a triangle. */
134 return !data.corner[3].valid;
137 Vector getCorner(int num);
139 void shapeArrow(const Vector & point, double angle, double arrowSize);
141 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
142 virtual Vector getNearestPointOnEntity(const Vector & coord,
143 bool onEntity = true, double * dist = NULL, RS_Entity ** entity = NULL);
144 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
145 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
146 virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
148 virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL,
149 RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
151 virtual void move(Vector offset);
152 virtual void rotate(Vector center, double angle);
153 virtual void scale(Vector center, Vector factor);
154 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
156 // virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
157 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
159 friend std::ostream & operator<<(std::ostream & os, const RS_Solid & p);
161 /** Recalculates the borders of this entity. */
162 virtual void calculateBorders ();