1 /**************************************************************************** 2 ** 3 ** This file is part of the LibreCAD project, a 2D CAD program 4 ** 5 ** Copyright (C) 2018 A. Stebich (librecad@mail.lordofbikes.de) 6 ** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl) 7 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. 8 ** 9 ** 10 ** This file may be distributed and/or modified under the terms of the 11 ** GNU General Public License version 2 as published by the Free Software 12 ** Foundation and appearing in the file gpl-2.0.txt included in the 13 ** packaging of this file. 14 ** 15 ** This program is distributed in the hope that it will be useful, 16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ** GNU General Public License for more details. 19 ** 20 ** You should have received a copy of the GNU General Public License 21 ** along with this program; if not, write to the Free Software 22 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 ** 24 ** This copyright notice MUST APPEAR in all copies of the script! 25 ** 26 **********************************************************************/ 27 28 #ifndef RS_DIMANGULAR_H 29 #define RS_DIMANGULAR_H 30 31 #include "rs_dimension.h" 32 #include "rs_constructionline.h" 33 34 /** 35 * Holds the data that defines a angular dimension entity. 36 */ 37 struct RS_DimAngularData 38 { 39 RS_DimAngularData(); 40 RS_DimAngularData(const RS_DimAngularData& ed); 41 42 /** 43 * Constructor with initialisation. 44 * 45 * @param definitionPoint Definition point of the angular dimension. 46 * @param leader Leader length. 47 */ 48 RS_DimAngularData(const RS_Vector& definitionPoint1, 49 const RS_Vector& definitionPoint2, 50 const RS_Vector& definitionPoint3, 51 const RS_Vector& definitionPoint4); 52 53 RS_Vector definitionPoint1; ///< 1st line start point, DXF codes 13,23,33 54 RS_Vector definitionPoint2; ///< 1st line end point, DXF codes 14,24,34 55 RS_Vector definitionPoint3; ///< 2nd line start point, DXF codes 15,25,35 56 ///< 2nd line end point is in common dim data, DXF codes 10,20,30 57 RS_Vector definitionPoint4; ///< dim arc radius point, DXF codes 16,26,36 58 }; 59 60 std::ostream& operator << (std::ostream& os, const RS_DimAngularData& dd); 61 62 /** 63 * Holds the DXF variables that defines a angular dimension entity. 64 */ 65 struct LC_DimAngularVars 66 { 67 explicit LC_DimAngularVars(const double _dimscale, 68 const double _dimexo, 69 const double _dimexe, 70 const double _dimtxt, 71 const double _dimgap, 72 const double _arrowSize); 73 explicit LC_DimAngularVars(const LC_DimAngularVars& av); 74 scaleLC_DimAngularVars75 double scale(void) const { 76 return dimscale; 77 } exoLC_DimAngularVars78 double exo(void) const { 79 return dimexo; 80 } exeLC_DimAngularVars81 double exe(void) const { 82 return dimexe; 83 } txtLC_DimAngularVars84 double txt(void) const { 85 return dimtxt; 86 } gapLC_DimAngularVars87 double gap(void) const { 88 return dimgap; 89 } arrowLC_DimAngularVars90 double arrow(void) const { 91 return arrowSize; 92 } 93 94 private: 95 double dimscale {1.0}; ///< general scale (DIMSCALE) 96 double dimexo {0.0}; ///< distance from entities (DIMEXO) 97 double dimexe {0.0}; ///< extension line extension (DIMEXE) 98 double dimtxt {0.0}; ///< text height (DIMTXT) 99 double dimgap {0.0}; ///< text distance to line (DIMGAP) 100 double arrowSize {0.0}; ///< arrow length 101 }; 102 103 std::ostream& operator << (std::ostream& os, const LC_DimAngularVars& dd); 104 105 /** 106 * Class for angular dimension entities. 107 * 108 * @author Andrew Mustun 109 */ 110 class RS_DimAngular : public RS_Dimension 111 { 112 friend std::ostream& operator << (std::ostream& os, const RS_DimAngular& d); 113 114 public: 115 RS_DimAngular(RS_EntityContainer* parent, 116 const RS_DimensionData& d, 117 const RS_DimAngularData& ed); 118 119 RS_Entity* clone() const override; 120 121 /** @return RS2::EntityDimAngular */ rtti()122 RS2::EntityType rtti() const override { 123 return RS2::EntityDimAngular; 124 } 125 126 /** 127 * @return Copy of data that defines the angular dimension. 128 * @see getData() 129 */ getEData()130 RS_DimAngularData getEData() const { 131 return edata; 132 } 133 134 QString getMeasuredLabel() override; 135 RS_Vector getCenter() const override; 136 137 void updateDim(bool autoText = false) override; 138 getDefinitionPoint1()139 RS_Vector getDefinitionPoint1() { 140 return edata.definitionPoint1; 141 } getDefinitionPoint2()142 RS_Vector getDefinitionPoint2() { 143 return edata.definitionPoint2; 144 } getDefinitionPoint3()145 RS_Vector getDefinitionPoint3() { 146 return edata.definitionPoint3; 147 } getDefinitionPoint4()148 RS_Vector getDefinitionPoint4() { 149 return edata.definitionPoint4; 150 } 151 152 void update() override; 153 void move(const RS_Vector& offset) override; 154 void rotate(const RS_Vector& center, const double& angle) override; 155 void rotate(const RS_Vector& center, const RS_Vector& angleVector) override; 156 void scale(const RS_Vector& center, const RS_Vector& factor) override; 157 void mirror(const RS_Vector& axisPoint1, const RS_Vector& axisPoint2) override; 158 159 protected: 160 /** Extended data. */ 161 RS_DimAngularData edata; 162 163 private: 164 void calcDimension(void); 165 void fixDimension(void); 166 void extensionLine(const RS_ConstructionLine& dimLine, 167 const RS_Vector& dimPoint, 168 const RS_Vector& dirStart, 169 const RS_Vector& dirEnd, 170 const LC_DimAngularVars& av, 171 const RS_Pen& pen); 172 void arrow(const RS_Vector& point, 173 const double angle, 174 const double direction, 175 const bool outsideArrows, 176 const LC_DimAngularVars& av, 177 const RS_Pen& pen); 178 179 RS_Vector dimDir1s; 180 RS_Vector dimDir1e; 181 RS_Vector dimDir2s; 182 RS_Vector dimDir2e; 183 RS_Vector dimDirRad; 184 RS_ConstructionLine dimLine1; 185 RS_ConstructionLine dimLine2; 186 double dimRadius {0.0}; 187 double dimAngleL1 {0.0}; 188 double dimAngleL2 {0.0}; 189 double dimAngle {0.0}; ///< angle to dimension in rad 190 RS_Vector dimCenter; ///< intersection point of the dimension lines 191 }; 192 193 #endif 194