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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/28/2010 Added this text. :-)
17 #include "dimdiametric.h"
27 * @para parent Parent Entity Container.
28 * @para d Common dimension geometrical data.
29 * @para ed Extended geometrical data for diametric dimension.
31 DimDiametric::DimDiametric(EntityContainer * parent, const DimensionData & d,
32 const DimDiametricData & ed): Dimension(parent, d), edata(ed)
37 /*virtual*/ DimDiametric::~DimDiametric()
41 /*virtual*/ Entity * DimDiametric::clone()
43 DimDiametric * d = new DimDiametric(*this);
44 #warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!"
45 // d->entities.setAutoDelete(entities.autoDelete());
51 /** @return RS2::EntityDimDiametric */
52 /*virtual*/ RS2::EntityType DimDiametric::rtti() const
54 return RS2::EntityDimDiametric;
58 * @return Copy of data that defines the diametric dimension.
61 DimDiametricData DimDiametric::getEData() const
67 * @return Automatically created label for the default
68 * measurement of this dimension.
70 QString DimDiametric::getMeasuredLabel()
72 // Definitive dimension line:
73 double dist = data.definitionPoint.distanceTo(edata.definitionPoint);
75 Drawing* graphic = getGraphic();
79 ret = Units::formatLinear(dist, graphic->getUnit(),
80 graphic->getLinearFormat(), graphic->getLinearPrecision());
83 ret = QString("%1").arg(dist);
89 VectorSolutions DimDiametric::getRefPoints()
91 VectorSolutions ret(edata.definitionPoint, data.definitionPoint, data.middleOfText);
96 * Updates the sub entities of this dimension. Called when the
97 * dimension or the position, alignment, .. changes.
99 * @param autoText Automatically reposition the text label
101 void DimDiametric::update(bool autoText)
103 DEBUG->print("DimDiametric::update");
110 updateCreateDimensionLine(data.definitionPoint, edata.definitionPoint, true, true, autoText);
114 Vector DimDiametric::getDefinitionPoint()
116 return edata.definitionPoint;
119 double DimDiametric::getLeader()
124 void DimDiametric::move(Vector offset)
126 Dimension::move(offset);
128 edata.definitionPoint.move(offset);
132 void DimDiametric::rotate(Vector center, double angle)
134 Dimension::rotate(center, angle);
136 edata.definitionPoint.rotate(center, angle);
140 void DimDiametric::scale(Vector center, Vector factor) {
141 Dimension::scale(center, factor);
143 edata.definitionPoint.scale(center, factor);
144 edata.leader*=factor.x;
148 void DimDiametric::mirror(Vector axisPoint1, Vector axisPoint2) {
149 Dimension::mirror(axisPoint1, axisPoint2);
151 edata.definitionPoint.mirror(axisPoint1, axisPoint2);
155 void DimDiametric::moveRef(const Vector& ref, const Vector& offset)
157 if (ref.distanceTo(edata.definitionPoint)<1.0e-4) {
158 Vector c = (edata.definitionPoint + data.definitionPoint)/2.0;
159 double d = c.distanceTo(edata.definitionPoint);
160 double a = c.angleTo(edata.definitionPoint + offset);
164 edata.definitionPoint = c + v;
165 data.definitionPoint = c - v;
168 else if (ref.distanceTo(data.definitionPoint)<1.0e-4) {
169 Vector c = (edata.definitionPoint + data.definitionPoint)/2.0;
170 double d = c.distanceTo(data.definitionPoint);
171 double a = c.angleTo(data.definitionPoint + offset);
175 data.definitionPoint = c + v;
176 edata.definitionPoint = c - v;
179 else if (ref.distanceTo(data.middleOfText)<1.0e-4) {
180 data.middleOfText.move(offset);
186 * Dumps the point's data to stdout.
188 std::ostream & operator<<(std::ostream & os, const DimDiametric & d)
190 os << " DimDiametric: " << d.getData() << "\n" << d.getEData() << "\n";