X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondimlinear.cpp;h=1560ac7139e1a5b8772bbe1dba81abc8c39a08e1;hb=5adb444f3e523d3fd028617ced72d1ea6661db21;hp=0a37fe61c255f03e98ceb5e626d2e4754c2a6f32;hpb=97d3cdae07ec9788cf80e7905abfdb5d67a7747c;p=architektonas diff --git a/src/actions/actiondimlinear.cpp b/src/actions/actiondimlinear.cpp index 0a37fe6..1560ac7 100644 --- a/src/actions/actiondimlinear.cpp +++ b/src/actions/actiondimlinear.cpp @@ -3,7 +3,9 @@ // Part of the Architektonas Project // Originally part of QCad Community Edition by Andrew Mustun // Extensively rewritten and refactored by James L. Hammons -// (C) 2010 Underground Software +// 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 // @@ -14,11 +16,12 @@ #include "actiondimlinear.h" -#include "rs_commandevent.h" -#include "rs_constructionline.h" -#include "rs_dialogfactory.h" +#include "commandevent.h" +#include "constructionline.h" +#include "debug.h" +#include "dialogfactory.h" #include "graphicview.h" -#include "rs_preview.h" +#include "preview.h" /** * Constructor. @@ -27,7 +30,7 @@ * @param fixedAngle true: The user can't change the angle. * false: The user can change the angle in a option widget. */ -ActionDimLinear::ActionDimLinear(RS_EntityContainer & container, +ActionDimLinear::ActionDimLinear(EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle): ActionDimension("Draw linear dimensions", container, graphicView) { @@ -35,7 +38,8 @@ ActionDimLinear::ActionDimLinear(RS_EntityContainer & container, this->fixedAngle = fixedAngle; lastStatus = SetExtPoint1; //hm. doesn't work. - graphicView.snapper.SetVisible(); +// graphicView.snapper.SetVisible(); + graphicView.SetSnapperVisible(); reset(); } @@ -51,17 +55,17 @@ ActionDimLinear::~ActionDimLinear() void ActionDimLinear::reset() { ActionDimension::reset(); - edata = RS_DimLinearData(Vector(false), Vector(false), (fixedAngle ? edata.angle : 0.0), 0.0); + edata = DimLinearData(Vector(false), Vector(false), (fixedAngle ? edata.angle : 0.0), 0.0); - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->requestOptions(this, true, true); + if (DIALOGFACTORY) + DIALOGFACTORY->requestOptions(this, true, true); } void ActionDimLinear::trigger() { ActionDimension::trigger(); preparePreview(); - RS_DimLinear * dim = new RS_DimLinear(container, data, edata); + DimLinear * dim = new DimLinear(container, data, edata); dim->setLayerToActive(); dim->setPenToActive(); dim->update(); @@ -81,10 +85,10 @@ void ActionDimLinear::trigger() // graphicView->drawEntity(dim); // graphicView->moveRelativeZero(rz); // drawSnapper(); - graphicView->snapper.SetVisible(false); + graphicView->SetSnapperVisible(false); graphicView->redraw(); - RS_DEBUG->print("ActionDimLinear::trigger(): dim added: %d", dim->getId()); + DEBUG->print("ActionDimLinear::trigger(): dim added: %d", dim->getId()); } void ActionDimLinear::preparePreview() @@ -92,7 +96,7 @@ void ActionDimLinear::preparePreview() Vector dirV; dirV.setPolar(100.0, edata.angle + M_PI / 2.0); - RS_ConstructionLine cl(NULL, RS_ConstructionLineData(edata.extensionPoint2, + ConstructionLine cl(NULL, ConstructionLineData(edata.extensionPoint2, edata.extensionPoint2 + dirV)); data.definitionPoint = cl.getNearestPointOnEntity(data.definitionPoint); @@ -100,7 +104,7 @@ void ActionDimLinear::preparePreview() void ActionDimLinear::mouseMoveEvent(QMouseEvent * e) { - RS_DEBUG->print("ActionDimLinear::mouseMoveEvent begin"); + DEBUG->print("ActionDimLinear::mouseMoveEvent begin"); Vector mouse = snapPoint(e); @@ -117,12 +121,12 @@ void ActionDimLinear::mouseMoveEvent(QMouseEvent * e) { // deletePreview(); // clearPreview(); -// preview->addEntity(new RS_Line(preview, -// RS_LineData(edata.extensionPoint1, mouse))); +// preview->addEntity(new Line(preview, +// LineData(edata.extensionPoint1, mouse))); // drawPreview(); graphicView->preview.clear(); - graphicView->preview.addEntity(new RS_Line(&(graphicView->preview), - RS_LineData(edata.extensionPoint1, mouse))); + graphicView->preview.addEntity(new Line(&(graphicView->preview), + LineData(edata.extensionPoint1, mouse))); graphicView->preview.SetVisible(); graphicView->redraw(); } @@ -137,13 +141,13 @@ void ActionDimLinear::mouseMoveEvent(QMouseEvent * e) // clearPreview(); data.definitionPoint = mouse; // preparePreview(); -// RS_DimLinear * dim = new RS_DimLinear(preview, data, edata); +// DimLinear * dim = new DimLinear(preview, data, edata); // dim->update(); // preview->addEntity(dim); // drawPreview(); graphicView->preview.clear(); preparePreview(); - RS_DimLinear * dim = new RS_DimLinear(&(graphicView->preview), data, edata); + DimLinear * dim = new DimLinear(&(graphicView->preview), data, edata); dim->update(); graphicView->preview.addEntity(dim); graphicView->preview.SetVisible(); @@ -153,7 +157,7 @@ void ActionDimLinear::mouseMoveEvent(QMouseEvent * e) break; } - RS_DEBUG->print("ActionDimLinear::mouseMoveEvent end"); + DEBUG->print("ActionDimLinear::mouseMoveEvent end"); } void ActionDimLinear::mouseReleaseEvent(QMouseEvent * e) @@ -162,14 +166,16 @@ void ActionDimLinear::mouseReleaseEvent(QMouseEvent * e) { Vector ce(snapPoint(e)); coordinateEvent(&ce); - graphicView->snapper.SetVisible(); +// graphicView->snapper.SetVisible(); + graphicView->SetSnapperVisible(); } else if (e->button() == Qt::RightButton) { if (getStatus() == 0) { graphicView->preview.SetVisible(false); - graphicView->snapper.SetVisible(false); +// graphicView->snapper.SetVisible(false); + graphicView->SetSnapperVisible(false); } // deletePreview(); @@ -211,14 +217,14 @@ void ActionDimLinear::coordinateEvent(Vector * e) } } -void ActionDimLinear::commandEvent(RS_CommandEvent * e) +void ActionDimLinear::commandEvent(CommandEvent * e) { QString c = e->getCommand().toLower(); if (checkCommand("help", c)) { - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + if (DIALOGFACTORY) + DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } @@ -228,8 +234,8 @@ void ActionDimLinear::commandEvent(RS_CommandEvent * e) case SetText: setText(c); - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->requestOptions(this, true, true); + if (DIALOGFACTORY) + DIALOGFACTORY->requestOptions(this, true, true); graphicView->enableCoordinateInput(); setStatus(lastStatus); @@ -238,15 +244,15 @@ void ActionDimLinear::commandEvent(RS_CommandEvent * e) case SetAngle: { bool ok; - double a = RS_Math::eval(c, &ok); + double a = Math::eval(c, &ok); if (ok) - setAngle(RS_Math::deg2rad(a)); - else if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression")); + setAngle(Math::deg2rad(a)); + else if (DIALOGFACTORY) + DIALOGFACTORY->commandMessage(tr("Not a valid expression")); - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->requestOptions(this, true, true); + if (DIALOGFACTORY) + DIALOGFACTORY->requestOptions(this, true, true); setStatus(lastStatus); } @@ -296,35 +302,35 @@ QStringList ActionDimLinear::getAvailableCommands() void ActionDimLinear::updateMouseButtonHints() { - if (RS_DIALOGFACTORY) + if (DIALOGFACTORY) { switch (getStatus()) { case SetExtPoint1: - RS_DIALOGFACTORY->updateMouseWidget( + DIALOGFACTORY->updateMouseWidget( tr("Specify first extension line origin"), tr("Cancel")); break; case SetExtPoint2: - RS_DIALOGFACTORY->updateMouseWidget( + DIALOGFACTORY->updateMouseWidget( tr("Specify second extension line origin"), tr("Back")); break; case SetDefPoint: - RS_DIALOGFACTORY->updateMouseWidget( + DIALOGFACTORY->updateMouseWidget( tr("Specify dimension line location"), tr("Back")); break; case SetText: - RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), ""); + DIALOGFACTORY->updateMouseWidget(tr("Enter dimension text:"), ""); break; case SetAngle: - RS_DIALOGFACTORY->updateMouseWidget(tr("Enter dimension line angle:"), ""); + DIALOGFACTORY->updateMouseWidget(tr("Enter dimension line angle:"), ""); break; default: - RS_DIALOGFACTORY->updateMouseWidget("", ""); + DIALOGFACTORY->updateMouseWidget("", ""); break; } } @@ -334,16 +340,16 @@ void ActionDimLinear::showOptions() { ActionInterface::showOptions(); - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->requestOptions(this, true, true); + if (DIALOGFACTORY) + DIALOGFACTORY->requestOptions(this, true, true); } void ActionDimLinear::hideOptions() { ActionInterface::hideOptions(); - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->requestOptions(this, false); + if (DIALOGFACTORY) + DIALOGFACTORY->requestOptions(this, false); } double ActionDimLinear::getAngle()