1 /**************************************************************************** 2 ** 3 ** This file is part of the LibreCAD project, a 2D CAD program 4 ** 5 ** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl) 6 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. 7 ** 8 ** 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. 13 ** 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. 18 ** 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 22 ** 23 ** This copyright notice MUST APPEAR in all copies of the script! 24 ** 25 **********************************************************************/ 26 27 28 #ifndef RS_DIMALIGNED_H 29 #define RS_DIMALIGNED_H 30 31 #include "rs_dimension.h" 32 33 /** 34 * Holds the data that defines an aligned dimension entity. 35 */ 36 struct RS_DimAlignedData { 37 /** 38 * Default constructor 39 */ 40 RS_DimAlignedData(); 41 /** 42 * Constructor with initialisation. 43 * 44 * @para extensionPoint1 Definition point. Startpoint of the 45 * first extension line. 46 * @para extensionPoint2 Definition point. Startpoint of the 47 * second extension line. 48 */ 49 RS_DimAlignedData(const RS_Vector& extensionPoint1, 50 const RS_Vector& extensionPoint2); 51 52 /** Definition point. Startpoint of the first extension line. */ 53 RS_Vector extensionPoint1; 54 /** Definition point. Startpoint of the second extension line. */ 55 RS_Vector extensionPoint2; 56 }; 57 58 std::ostream& operator << (std::ostream& os, const RS_DimAlignedData& dd); 59 60 /** 61 * Class for aligned dimension entities. 62 * 63 * @author Andrew Mustun 64 */ 65 class RS_DimAligned : public RS_Dimension { 66 public: 67 RS_DimAligned(RS_EntityContainer* parent, 68 const RS_DimensionData& d, 69 const RS_DimAlignedData& ed); 70 71 RS_Entity* clone() const override; 72 73 /** @return RS2::EntityDimAligned */ rtti()74 RS2::EntityType rtti() const override{ 75 return RS2::EntityDimAligned; 76 } 77 78 /** 79 * @return Copy of data that defines the aligned dimension. 80 * @see getData() 81 */ 82 RS_DimAlignedData const& getEData() const; 83 84 RS_VectorSolutions getRefPoints() const override; 85 86 QString getMeasuredLabel() override; 87 88 void updateDim(bool autoText=false) override; 89 90 RS_Vector const& getExtensionPoint1() const; 91 92 RS_Vector const& getExtensionPoint2() const; 93 94 /** 95 * Recalculate the original Dimension Point to remove Dim oblique angle. 96 * @author Rallaz 97 */ 98 void updateDimPoint(); 99 100 void move(const RS_Vector& offset) override; 101 void rotate(const RS_Vector& center, const double& angle) override; 102 void rotate(const RS_Vector& center, const RS_Vector& angleVector) override; 103 void scale(const RS_Vector& center, const RS_Vector& factor) override; 104 void mirror(const RS_Vector& axisPoint1, const RS_Vector& axisPoint2) override; 105 bool hasEndpointsWithinWindow(const RS_Vector& v1, const RS_Vector& v2) override; 106 void stretch(const RS_Vector& firstCorner, 107 const RS_Vector& secondCorner, 108 const RS_Vector& offset) override; 109 void moveRef(const RS_Vector& ref, const RS_Vector& offset) override; 110 111 friend std::ostream& operator << (std::ostream& os, 112 const RS_DimAligned& d); 113 114 protected: 115 /** Extended data. */ 116 RS_DimAlignedData edata; 117 }; 118 119 #endif 120