+++ /dev/null
-// dimdiametric.cpp
-//
-// Part of the Architektonas Project
-// Originally part of QCad Community Edition by Andrew Mustun
-// Extensively rewritten and refactored by James L. Hammons
-// Portions copyright (C) 2001-2003 RibbonSoft
-// Copyright (C) 2010 Underground Software
-// See the README and GPLv2 files for licensing and warranty information
-//
-// JLH = James L. Hammons <jlhamm@acm.org>
-//
-// Who When What
-// --- ---------- -----------------------------------------------------------
-// JLH 05/28/2010 Added this text. :-)
-//
-
-#include "dimdiametric.h"
-
-#include "text.h"
-#include "solid.h"
-#include "drawing.h"
-#include "units.h"
-
-/**
- * Constructor.
- *
- * @para parent Parent Entity Container.
- * @para d Common dimension geometrical data.
- * @para ed Extended geometrical data for diametric dimension.
- */
-DimDiametric::DimDiametric(EntityContainer * parent, const DimensionData & d,
- const DimDiametricData & ed): Dimension(parent, d), edata(ed)
-{
- calculateBorders();
-}
-
-/*virtual*/ DimDiametric::~DimDiametric()
-{
-}
-
-/*virtual*/ Entity * DimDiametric::clone()
-{
- DimDiametric * d = new DimDiametric(*this);
-#warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!"
-// d->entities.setAutoDelete(entities.autoDelete());
- d->initId();
- d->detach();
- return d;
-}
-
-/** @return RS2::EntityDimDiametric */
-/*virtual*/ RS2::EntityType DimDiametric::rtti() const
-{
- return RS2::EntityDimDiametric;
-}
-
-/**
- * @return Copy of data that defines the diametric dimension.
- * @see getData()
- */
-DimDiametricData DimDiametric::getEData() const
-{
- return edata;
-}
-
-/**
- * @return Automatically created label for the default
- * measurement of this dimension.
- */
-QString DimDiametric::getMeasuredLabel()
-{
- // Definitive dimension line:
- double dist = data.definitionPoint.distanceTo(edata.definitionPoint);
- Drawing * drawing = GetDrawing();
-
- if (drawing)
- return Units::formatLinear(dist, drawing->getUnit(),
- drawing->getLinearFormat(), drawing->getLinearPrecision());
-
- return QString("%1").arg(dist);
-}
-
-VectorSolutions DimDiametric::getRefPoints()
-{
- VectorSolutions ret(edata.definitionPoint, data.definitionPoint, data.middleOfText);
- return ret;
-}
-
-/**
- * Updates the sub entities of this dimension. Called when the
- * dimension or the position, alignment, .. changes.
- *
- * @param autoText Automatically reposition the text label
- */
-void DimDiametric::update(bool autoText)
-{
- DEBUG->print("DimDiametric::update");
- clear();
-
- if (isUndone())
- return;
-
- // dimension line:
- updateCreateDimensionLine(data.definitionPoint, edata.definitionPoint, true, true, autoText);
- calculateBorders();
-}
-
-Vector DimDiametric::getDefinitionPoint()
-{
- return edata.definitionPoint;
-}
-
-double DimDiametric::getLeader()
-{
- return edata.leader;
-}
-
-void DimDiametric::move(Vector offset)
-{
- Dimension::move(offset);
-
- edata.definitionPoint.move(offset);
- update();
-}
-
-void DimDiametric::rotate(Vector center, double angle)
-{
- Dimension::rotate(center, angle);
-
- edata.definitionPoint.rotate(center, angle);
- update();
-}
-
-void DimDiametric::scale(Vector center, Vector factor) {
- Dimension::scale(center, factor);
-
- edata.definitionPoint.scale(center, factor);
- edata.leader*=factor.x;
- update();
-}
-
-void DimDiametric::mirror(Vector axisPoint1, Vector axisPoint2) {
- Dimension::mirror(axisPoint1, axisPoint2);
-
- edata.definitionPoint.mirror(axisPoint1, axisPoint2);
- update();
-}
-
-void DimDiametric::moveRef(const Vector& ref, const Vector& offset)
-{
- if (ref.distanceTo(edata.definitionPoint)<1.0e-4) {
- Vector c = (edata.definitionPoint + data.definitionPoint)/2.0;
- double d = c.distanceTo(edata.definitionPoint);
- double a = c.angleTo(edata.definitionPoint + offset);
-
- Vector v;
- v.setPolar(d, a);
- edata.definitionPoint = c + v;
- data.definitionPoint = c - v;
- update(true);
- }
- else if (ref.distanceTo(data.definitionPoint)<1.0e-4) {
- Vector c = (edata.definitionPoint + data.definitionPoint)/2.0;
- double d = c.distanceTo(data.definitionPoint);
- double a = c.angleTo(data.definitionPoint + offset);
-
- Vector v;
- v.setPolar(d, a);
- data.definitionPoint = c + v;
- edata.definitionPoint = c - v;
- update(true);
- }
- else if (ref.distanceTo(data.middleOfText)<1.0e-4) {
- data.middleOfText.move(offset);
- update(false);
- }
-}
-
-/**
- * Dumps the point's data to stdout.
- */
-std::ostream & operator<<(std::ostream & os, const DimDiametric & d)
-{
- os << " DimDiametric: " << d.getData() << "\n" << d.getEData() << "\n";
- return os;
-}