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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/28/2010 Added this text. :-)
15 #include "rs_dimdiametric.h"
25 * @para parent Parent Entity Container.
26 * @para d Common dimension geometrical data.
27 * @para ed Extended geometrical data for diametric dimension.
29 RS_DimDiametric::RS_DimDiametric(RS_EntityContainer * parent, const RS_DimensionData & d,
30 const RS_DimDiametricData & ed): RS_Dimension(parent, d), edata(ed)
35 /*virtual*/ RS_DimDiametric::~RS_DimDiametric()
39 /*virtual*/ RS_Entity * RS_DimDiametric::clone()
41 RS_DimDiametric * d = new RS_DimDiametric(*this);
42 #warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!"
43 // d->entities.setAutoDelete(entities.autoDelete());
49 /** @return RS2::EntityDimDiametric */
50 /*virtual*/ RS2::EntityType RS_DimDiametric::rtti() const
52 return RS2::EntityDimDiametric;
56 * @return Copy of data that defines the diametric dimension.
59 RS_DimDiametricData RS_DimDiametric::getEData() const
65 * @return Automatically created label for the default
66 * measurement of this dimension.
68 QString RS_DimDiametric::getMeasuredLabel()
70 // Definitive dimension line:
71 double dist = data.definitionPoint.distanceTo(edata.definitionPoint);
73 Drawing* graphic = getGraphic();
77 ret = RS_Units::formatLinear(dist, graphic->getUnit(),
78 graphic->getLinearFormat(), graphic->getLinearPrecision());
81 ret = QString("%1").arg(dist);
87 VectorSolutions RS_DimDiametric::getRefPoints()
89 VectorSolutions ret(edata.definitionPoint, data.definitionPoint, data.middleOfText);
94 * Updates the sub entities of this dimension. Called when the
95 * dimension or the position, alignment, .. changes.
97 * @param autoText Automatically reposition the text label
99 void RS_DimDiametric::update(bool autoText)
101 RS_DEBUG->print("RS_DimDiametric::update");
108 updateCreateDimensionLine(data.definitionPoint, edata.definitionPoint, true, true, autoText);
112 Vector RS_DimDiametric::getDefinitionPoint()
114 return edata.definitionPoint;
117 double RS_DimDiametric::getLeader()
122 void RS_DimDiametric::move(Vector offset)
124 RS_Dimension::move(offset);
126 edata.definitionPoint.move(offset);
130 void RS_DimDiametric::rotate(Vector center, double angle)
132 RS_Dimension::rotate(center, angle);
134 edata.definitionPoint.rotate(center, angle);
138 void RS_DimDiametric::scale(Vector center, Vector factor) {
139 RS_Dimension::scale(center, factor);
141 edata.definitionPoint.scale(center, factor);
142 edata.leader*=factor.x;
146 void RS_DimDiametric::mirror(Vector axisPoint1, Vector axisPoint2) {
147 RS_Dimension::mirror(axisPoint1, axisPoint2);
149 edata.definitionPoint.mirror(axisPoint1, axisPoint2);
153 void RS_DimDiametric::moveRef(const Vector& ref, const Vector& offset)
155 if (ref.distanceTo(edata.definitionPoint)<1.0e-4) {
156 Vector c = (edata.definitionPoint + data.definitionPoint)/2.0;
157 double d = c.distanceTo(edata.definitionPoint);
158 double a = c.angleTo(edata.definitionPoint + offset);
162 edata.definitionPoint = c + v;
163 data.definitionPoint = c - v;
166 else if (ref.distanceTo(data.definitionPoint)<1.0e-4) {
167 Vector c = (edata.definitionPoint + data.definitionPoint)/2.0;
168 double d = c.distanceTo(data.definitionPoint);
169 double a = c.angleTo(data.definitionPoint + offset);
173 data.definitionPoint = c + v;
174 edata.definitionPoint = c - v;
177 else if (ref.distanceTo(data.middleOfText)<1.0e-4) {
178 data.middleOfText.move(offset);
184 * Dumps the point's data to stdout.
186 std::ostream & operator<<(std::ostream & os, const RS_DimDiametric & d)
188 os << " DimDiametric: " << d.getData() << "\n" << d.getEData() << "\n";