From 1f0d096a7fc370ff02477f3860beae2669bf8903 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Mon, 9 Aug 2010 20:52:04 +0000 Subject: [PATCH] First steps in fixing/cleaning up preview/snapper rendering. --- architektonas.pro | 2 - src/actions/actiondefault.cpp | 11 +- src/actions/actiondrawline.cpp | 21 ++- src/actions/actiondrawlineangle.cpp | 90 +++++++------ src/actions/actiondrawlineangle.h | 27 ++-- src/actions/actiondrawlinebisector.cpp | 121 ++++++------------ src/actions/actiondrawlinerectangle.cpp | 48 ++++--- src/actions/actiondrawlinerectangle.h | 12 +- .../actiontoolregeneratedimensions.cpp | 71 ---------- src/actions/actiontoolregeneratedimensions.h | 22 ---- src/actions/actionzoompan.cpp | 14 +- src/base/actioninterface.cpp | 7 + src/base/rs_creation.cpp | 100 +++++++-------- src/base/rs_fileio.h | 3 - src/forms/lineangleoptions.cpp | 11 +- src/widgets/actionhandler.cpp | 8 +- 16 files changed, 212 insertions(+), 356 deletions(-) delete mode 100644 src/actions/actiontoolregeneratedimensions.cpp delete mode 100644 src/actions/actiontoolregeneratedimensions.h diff --git a/architektonas.pro b/architektonas.pro index 7d4bb33..ad5706f 100644 --- a/architektonas.pro +++ b/architektonas.pro @@ -281,7 +281,6 @@ HEADERS += \ src/actions/actionsetsnapmode.h \ src/actions/actionsetsnaprestriction.h \ src/actions/actionsnapintersectionmanual.h \ - src/actions/actiontoolregeneratedimensions.h \ src/actions/actionzoomauto.h \ src/actions/actionzoomautoy.h \ src/actions/actionzoomin.h \ @@ -389,7 +388,6 @@ SOURCES += \ src/actions/actionsetsnapmode.cpp \ src/actions/actionsetsnaprestriction.cpp \ src/actions/actionsnapintersectionmanual.cpp \ - src/actions/actiontoolregeneratedimensions.cpp \ src/actions/actionzoomauto.cpp \ src/actions/actionzoomautoy.cpp \ src/actions/actionzoomin.cpp \ diff --git a/src/actions/actiondefault.cpp b/src/actions/actiondefault.cpp index 19e0bc1..29940ba 100644 --- a/src/actions/actiondefault.cpp +++ b/src/actions/actiondefault.cpp @@ -30,13 +30,13 @@ * Constructor. */ ActionDefault::ActionDefault(RS_EntityContainer & container, - GraphicView & graphicView): ActionInterface("Default", - container, graphicView) + GraphicView & graphicView): + ActionInterface("Default", container, graphicView) { RS_DEBUG->print("ActionDefault::ActionDefault"); //hm. - graphicView.snapper.SetVisible(); - graphicView.preview.SetVisible(); +// graphicView.snapper.SetVisible(); +// graphicView.preview.SetVisible(); RS_DEBUG->print("ActionDefault::ActionDefault: OK"); } @@ -59,9 +59,6 @@ void ActionDefault::init(int status /*= 0*/) graphicView->snapper.setSnapRestriction(RS2::RestrictNothing); restrBak = RS2::RestrictNothing; RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain); -//hm. Nope. -// graphicView->snapper.SetVisible(); -// graphicView->preview.SetVisible(); RS_DEBUG->print("ActionDefault::init: OK"); } diff --git a/src/actions/actiondrawline.cpp b/src/actions/actiondrawline.cpp index 9817bba..b387ee9 100644 --- a/src/actions/actiondrawline.cpp +++ b/src/actions/actiondrawline.cpp @@ -30,10 +30,10 @@ ActionDrawLine::ActionDrawLine(RS_EntityContainer & container, GraphicView & gra RS_DEBUG->print("ActionDrawLine::ActionDrawLine"); reset(); //hm. - graphicView.snapper.SetContainer(&container); - graphicView.snapper.SetGraphicView(&graphicView); - graphicView.snapper.SetVisible(); - graphicView.preview.SetVisible(); +// graphicView.snapper.SetContainer(&container); +// graphicView.snapper.SetGraphicView(&graphicView); +// graphicView.snapper.SetVisible(); +// graphicView.preview.SetVisible(); RS_DEBUG->print("ActionDrawLine::ActionDrawLine: OK"); } @@ -59,7 +59,6 @@ void ActionDrawLine::reset() void ActionDrawLine::init(int status) { RS_DEBUG->print("ActionDrawLine::init"); -// ActionInterface::init(status); ActionInterface::init(status); reset(); RS_DEBUG->print("ActionDrawLine::init: OK"); @@ -140,11 +139,11 @@ void ActionDrawLine::mouseReleaseEvent(QMouseEvent * e) } else if (e->button() == Qt::RightButton) { - if (getStatus() == 0) - { - graphicView->snapper.SetVisible(false); - graphicView->preview.SetVisible(false); - } +// if (getStatus() == 0) +// { +// graphicView->snapper.SetVisible(false); +// graphicView->preview.SetVisible(false); +// } init(getStatus() - 1); } @@ -297,7 +296,6 @@ void ActionDrawLine::updateMouseButtonHints() void ActionDrawLine::showOptions() { RS_DEBUG->print("ActionDrawLine::showOptions"); -// ActionInterface::showOptions(); ActionInterface::showOptions(); RS_DIALOGFACTORY->requestOptions(this, true); RS_DEBUG->print("ActionDrawLine::showOptions: OK"); @@ -305,7 +303,6 @@ void ActionDrawLine::showOptions() void ActionDrawLine::hideOptions() { -// ActionInterface::hideOptions(); ActionInterface::hideOptions(); RS_DIALOGFACTORY->requestOptions(this, false); } diff --git a/src/actions/actiondrawlineangle.cpp b/src/actions/actiondrawlineangle.cpp index 0022d6f..e0c1d68 100644 --- a/src/actions/actiondrawlineangle.cpp +++ b/src/actions/actiondrawlineangle.cpp @@ -23,16 +23,17 @@ #include "graphicview.h" #include "rs_preview.h" -ActionDrawLineAngle::ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle): - ActionInterface("Draw lines with given angle", - container, graphicView) +ActionDrawLineAngle::ActionDrawLineAngle(RS_EntityContainer & container, + GraphicView & graphicView, double a, bool fa): + ActionInterface("Draw lines with given angle", container, graphicView), + pos(Vector(false)), angle(a), length(1.0), fixedAngle(fa), snpPoint(0) { - this->angle = angle; - length = 1.0; - snpPoint = 0; - this->fixedAngle = fixedAngle; - pos = Vector(false); reset(); + //hm. +// graphicView.snapper.SetContainer(&container); +// graphicView.snapper.SetGraphicView(&graphicView); +// graphicView.snapper.SetVisible(); +// graphicView.preview.SetVisible(); } ActionDrawLineAngle::~ActionDrawLineAngle() @@ -52,21 +53,19 @@ void ActionDrawLineAngle::reset() void ActionDrawLineAngle::init(int status) { ActionInterface::init(status); - reset(); } void ActionDrawLineAngle::trigger() { ActionInterface::trigger(); - preparePreview(); RS_Line * line = new RS_Line(container, data); line->setLayerToActive(); line->setPenToActive(); container->addEntity(line); - // upd. undo list: + // Update undo list: if (document) { document->startUndoCycle(); @@ -74,12 +73,12 @@ void ActionDrawLineAngle::trigger() document->endUndoCycle(); } - deleteSnapper(); +// deleteSnapper(); graphicView->moveRelativeZero(Vector(0.0, 0.0)); graphicView->drawEntity(line); graphicView->moveRelativeZero(data.startpoint); - RS_DEBUG->print("ActionDrawLineAngle::trigger(): line added: %d", - line->getId()); + graphicView->redraw(); + RS_DEBUG->print("ActionDrawLineAngle::trigger(): line added: %d", line->getId()); } void ActionDrawLineAngle::mouseMoveEvent(QMouseEvent * e) @@ -89,13 +88,17 @@ void ActionDrawLineAngle::mouseMoveEvent(QMouseEvent * e) if (getStatus() == SetPos) { pos = snapPoint(e); - deletePreview(); - clearPreview(); - preparePreview(); +// deletePreview(); +// clearPreview(); +// preparePreview(); // preview->addEntity(new RS_Line(preview, data)); - drawPreview(); +// drawPreview(); + preparePreview(); + graphicView->preview.clear(); + graphicView->preview.addEntity(new RS_Line(&(graphicView->preview), data)); } + graphicView->redraw(); RS_DEBUG->print("ActionDrawLineAngle::mouseMoveEvent end"); } @@ -105,16 +108,20 @@ void ActionDrawLineAngle::mouseReleaseEvent(QMouseEvent * e) { if (getStatus() == SetPos) { - Vector ce(snapPoint(e)); +// Vector ce(snapPoint(e)); + Vector ce(graphicView->snapper.snapPoint(e)); coordinateEvent(&ce); } } else if (e->button() == Qt::RightButton) { - deletePreview(); - deleteSnapper(); +// deletePreview(); +// deleteSnapper(); init(getStatus() - 1); } + + graphicView->preview.clear(); // Remove entities from container + graphicView->redraw(); } void ActionDrawLineAngle::preparePreview() @@ -139,7 +146,7 @@ void ActionDrawLineAngle::preparePreview() void ActionDrawLineAngle::coordinateEvent(Vector * e) { - if (e == NULL) + if (!e) return; switch (getStatus()) @@ -168,48 +175,51 @@ void ActionDrawLineAngle::commandEvent(RS_CommandEvent * e) switch (getStatus()) { case SetPos: - if (!fixedAngle && checkCommand("angle", c)) { - deleteSnapper(); - deletePreview(); - clearPreview(); +// deleteSnapper(); +// deletePreview(); +// clearPreview(); setStatus(SetAngle); } else if (checkCommand("length", c)) { - deleteSnapper(); - deletePreview(); - clearPreview(); +// deleteSnapper(); +// deletePreview(); +// clearPreview(); setStatus(SetLength); } break; - case SetAngle: { + case SetAngle: + { bool ok; double a = RS_Math::eval(c, &ok); - if (ok == true) + if (ok) angle = RS_Math::deg2rad(a); else RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression")); + RS_DIALOGFACTORY->requestOptions(this, true, true); setStatus(SetPos); } - break; + break; - case SetLength: { + case SetLength: + { bool ok; double l = RS_Math::eval(c, &ok); - if (ok == true) + if (ok) length = l; else RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression")); + RS_DIALOGFACTORY->requestOptions(this, true, true); setStatus(SetPos); } - break; + break; default: break; @@ -223,9 +233,9 @@ QStringList ActionDrawLineAngle::getAvailableCommands() switch (getStatus()) { case SetPos: - if (!fixedAngle) cmd += command("angle"); + cmd += command("length"); break; @@ -241,8 +251,7 @@ void ActionDrawLineAngle::updateMouseButtonHints() switch (getStatus()) { case SetPos: - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"), - tr("Cancel")); + RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"), tr("Cancel")); break; case SetAngle: @@ -261,14 +270,12 @@ void ActionDrawLineAngle::updateMouseButtonHints() void ActionDrawLineAngle::showOptions() { ActionInterface::showOptions(); - RS_DIALOGFACTORY->requestOptions(this, true); } void ActionDrawLineAngle::hideOptions() { ActionInterface::hideOptions(); - RS_DIALOGFACTORY->requestOptions(this, false); } @@ -288,6 +295,7 @@ void ActionDrawLineAngle::updateToolBar() void ActionDrawLineAngle::setSnapPoint(int sp) { snpPoint = sp; +// graphicView->redraw(); } int ActionDrawLineAngle::getSnapPoint() @@ -298,6 +306,7 @@ int ActionDrawLineAngle::getSnapPoint() void ActionDrawLineAngle::setAngle(double a) { angle = a; +// graphicView->redraw(); } double ActionDrawLineAngle::getAngle() @@ -308,6 +317,7 @@ double ActionDrawLineAngle::getAngle() void ActionDrawLineAngle::setLength(double l) { length = l; +// graphicView->redraw(); } double ActionDrawLineAngle::getLength() diff --git a/src/actions/actiondrawlineangle.h b/src/actions/actiondrawlineangle.h index 5282c66..3d49a6a 100644 --- a/src/actions/actiondrawlineangle.h +++ b/src/actions/actiondrawlineangle.h @@ -24,7 +24,8 @@ class ActionDrawLineAngle: public ActionInterface SetLength /**< Setting length in the command line. */ }; - ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false); + ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView, + double angle = 0.0, bool fixedAngle = false); ~ActionDrawLineAngle(); virtual RS2::ActionType rtti(); @@ -51,29 +52,17 @@ class ActionDrawLineAngle: public ActionInterface bool hasFixedAngle(); protected: - /** - * Line data defined so far. - */ + /** Line data defined so far. */ RS_LineData data; - /** - * Position. - */ + /** Position. */ Vector pos; - /** - * Line angle. - */ + /** Line angle. */ double angle; - /** - * Line length. - */ + /** Line length. */ double length; - /** - * Is the angle fixed? - */ + /** Is the angle fixed? */ bool fixedAngle; - /** - * Snap point (start, middle, end). - */ + /** Snap point (start, middle, end). */ int snpPoint; }; diff --git a/src/actions/actiondrawlinebisector.cpp b/src/actions/actiondrawlinebisector.cpp index 78b8581..b7dab13 100644 --- a/src/actions/actiondrawlinebisector.cpp +++ b/src/actions/actiondrawlinebisector.cpp @@ -23,17 +23,13 @@ #include "graphicview.h" #include "rs_preview.h" -ActionDrawLineBisector::ActionDrawLineBisector(RS_EntityContainer & container, GraphicView & graphicView): - ActionInterface("Draw Bisectors", container, graphicView) +ActionDrawLineBisector::ActionDrawLineBisector(RS_EntityContainer & container, + GraphicView & graphicView): + ActionInterface("Draw Bisectors", container, graphicView), + bisector(NULL), line1(NULL), line2(NULL), length(10.0), number(1), + coord1(Vector(false)), coord2(Vector(false)), lastStatus(SetLine1) { - bisector = NULL; - length = 10.0; - line1 = NULL; - line2 = NULL; - number = 1; - coord1 = Vector(false); - coord2 = Vector(false); - lastStatus = SetLine1; + graphicView.snapper.SetVisible(false); } ActionDrawLineBisector::~ActionDrawLineBisector() @@ -48,42 +44,9 @@ ActionDrawLineBisector::~ActionDrawLineBisector() void ActionDrawLineBisector::trigger() { ActionInterface::trigger(); - - //if (bisector!=NULL) { RS_Creation creation(container, graphicView); - creation.createBisector(coord1, - coord2, - length, - number, - line1, - line2); - /*RS_Entity* newEntity = NULL; - - newEntity = new RS_Line(container, - bisector->getData()); - - if (newEntity!=NULL) { - newEntity->setLayerToActive(); - newEntity->setPenToActive(); - container->addEntity(newEntity); - - // upd. undo list: - if (document!=NULL) { - document->startUndoCycle(); - document->addUndoable(newEntity); - document->endUndoCycle(); - } - graphicView->drawEntity(newEntity); - setStatus(SetLine1); - } - //reset(); - delete bisector; - bisector = NULL; - */ - /*} else { - RS_DEBUG->print("ActionDrawLineBisector::trigger:" - " Entity is NULL\n"); - }*/ + creation.createBisector(coord1, coord2, length, number, line1, line2); + graphicView->redraw(); } void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e) @@ -91,7 +54,7 @@ void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e) RS_DEBUG->print("ActionDrawLineBisector::mouseMoveEvent begin"); Vector mouse = Vector(graphicView->toGraphX(e->x()), - graphicView->toGraphY(e->y())); + graphicView->toGraphY(e->y())); switch (getStatus()) { @@ -105,14 +68,10 @@ void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e) if (en && en->rtti() == RS2::EntityLine) { -// line2 = (RS_Line *)en; -// -// deletePreview(); -// clearPreview(); -// -// RS_Creation creation(preview, NULL, false); -// creation.createBisector(coord1, coord2, length, number, line1, line2); -// drawPreview(); + line2 = (RS_Line *)en; + graphicView->preview.clear(); + RS_Creation creation(&(graphicView->preview), NULL, false); + creation.createBisector(coord1, coord2, length, number, line1, line2); } } break; @@ -121,6 +80,7 @@ void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e) break; } + graphicView->redraw(); RS_DEBUG->print("ActionDrawLineBisector::mouseMoveEvent end"); } @@ -128,8 +88,8 @@ void ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent * e) { if (e->button() == Qt::RightButton) { - deletePreview(); - clearPreview(); +// deletePreview(); +// clearPreview(); init(getStatus() - 1); } else @@ -144,10 +104,12 @@ void ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent * e) coord1 = mouse; RS_Entity * en = catchEntity(e, RS2::ResolveAll); - if (en != NULL && en->rtti() == RS2::EntityLine) + if (en && en->rtti() == RS2::EntityLine) + { line1 = (RS_Line *)en; + setStatus(SetLine2); + } } - setStatus(SetLine2); break; case SetLine2: @@ -178,45 +140,50 @@ void ActionDrawLineBisector::commandEvent(RS_CommandEvent * e) if (checkCommand("length", c)) { - deleteSnapper(); - deletePreview(); - clearPreview(); +// deleteSnapper(); +// deletePreview(); +// clearPreview(); setStatus(SetLength); } else if (checkCommand("number", c)) { - deleteSnapper(); - deletePreview(); - clearPreview(); +// deleteSnapper(); +// deletePreview(); +// clearPreview(); setStatus(SetNumber); } + break; - case SetLength: { + case SetLength: + { bool ok; double l = RS_Math::eval(c, &ok); - if (ok == true) + if (ok) length = l; else RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression")); + RS_DIALOGFACTORY->requestOptions(this, true, true); setStatus(lastStatus); } - break; + break; - case SetNumber: { + case SetNumber: + { bool ok; int n = (int)RS_Math::eval(c, &ok); - if (ok == true) + if (ok) number = n; else RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression")); + RS_DIALOGFACTORY->requestOptions(this, true, true); setStatus(lastStatus); } - break; + break; default: break; @@ -247,23 +214,19 @@ void ActionDrawLineBisector::updateMouseButtonHints() switch (getStatus()) { case SetLine1: - RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"), - tr("Cancel")); + RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"), tr("Cancel")); break; case SetLine2: - RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"), - tr("Back")); + RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"), tr("Back")); break; case SetLength: - RS_DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"), - tr("Back")); + RS_DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"), tr("Back")); break; case SetNumber: - RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"), - tr("Back")); + RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"), tr("Back")); break; default: @@ -275,14 +238,12 @@ void ActionDrawLineBisector::updateMouseButtonHints() void ActionDrawLineBisector::showOptions() { ActionInterface::showOptions(); - RS_DIALOGFACTORY->requestOptions(this, true); } void ActionDrawLineBisector::hideOptions() { ActionInterface::hideOptions(); - RS_DIALOGFACTORY->requestOptions(this, false); } diff --git a/src/actions/actiondrawlinerectangle.cpp b/src/actions/actiondrawlinerectangle.cpp index f3c4190..596f233 100644 --- a/src/actions/actiondrawlinerectangle.cpp +++ b/src/actions/actiondrawlinerectangle.cpp @@ -73,16 +73,17 @@ void ActionDrawLineRectangle::trigger() } // upd. view - deleteSnapper(); +// deleteSnapper(); graphicView->moveRelativeZero(Vector(0.0, 0.0)); for(int i=0; i<4; i++) { graphicView->drawEntity(line[i]); - RS_DEBUG->print("ActionDrawLineRectangle::trigger(): line added: %d", - line[i]->getId()); + RS_DEBUG->print("ActionDrawLineRectangle::trigger(): line added: %d", line[i]->getId()); } + graphicView->moveRelativeZero(corner2); + graphicView->redraw(); } void ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent * e) @@ -94,17 +95,22 @@ void ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent * e) if (getStatus() == SetCorner2 && corner1.valid) { corner2 = mouse; - deletePreview(); - clearPreview(); - - preparePreview(); +// deletePreview(); +// clearPreview(); +// preparePreview(); // for(int i=0; i<4; i++) // preview->addEntity(new RS_Line(preview, data[i])); - drawPreview(); +// drawPreview(); + preparePreview(); + graphicView->preview.clear(); + + for(int i=0; i<4; i++) + graphicView->preview.addEntity(new RS_Line(&(graphicView->preview), data[i])); } + graphicView->redraw(); RS_DEBUG->print("ActionDrawLineRectangle::mouseMoveEvent end"); } @@ -112,15 +118,19 @@ void ActionDrawLineRectangle::mouseReleaseEvent(QMouseEvent * e) { if (e->button() == Qt::LeftButton) { - Vector ce(snapPoint(e)); +// Vector ce(snapPoint(e)); + Vector ce(graphicView->snapper.snapPoint(e)); coordinateEvent(&ce); } else if (e->button() == Qt::RightButton) { - deletePreview(); - deleteSnapper(); +// deletePreview(); +// deleteSnapper(); init(getStatus() - 1); } + + graphicView->preview.clear(); // Remove entities from container + graphicView->redraw(); } void ActionDrawLineRectangle::preparePreview() @@ -133,7 +143,7 @@ void ActionDrawLineRectangle::preparePreview() void ActionDrawLineRectangle::coordinateEvent(Vector * e) { - if (e == NULL) + if (!e) return; Vector mouse = *e; @@ -163,7 +173,7 @@ void ActionDrawLineRectangle::commandEvent(RS_CommandEvent * e) if (checkCommand("help", c)) { - if (RS_DIALOGFACTORY != NULL) + if (RS_DIALOGFACTORY) RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; @@ -178,18 +188,16 @@ QStringList ActionDrawLineRectangle::getAvailableCommands() void ActionDrawLineRectangle::updateMouseButtonHints() { - if (RS_DIALOGFACTORY != NULL) + if (RS_DIALOGFACTORY) { switch (getStatus()) { case SetCorner1: - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"), - tr("Cancel")); + RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"), tr("Cancel")); break; case SetCorner2: - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"), - tr("Back")); + RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"), tr("Back")); break; default: @@ -206,7 +214,7 @@ void ActionDrawLineRectangle::updateMouseCursor() void ActionDrawLineRectangle::updateToolBar() { - if (RS_DIALOGFACTORY != NULL) + if (RS_DIALOGFACTORY) { if (!isFinished()) RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); @@ -214,5 +222,3 @@ void ActionDrawLineRectangle::updateToolBar() RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines); } } - - diff --git a/src/actions/actiondrawlinerectangle.h b/src/actions/actiondrawlinerectangle.h index 829ea2e..7e7fa92 100644 --- a/src/actions/actiondrawlinerectangle.h +++ b/src/actions/actiondrawlinerectangle.h @@ -41,17 +41,11 @@ class ActionDrawLineRectangle: public ActionInterface virtual void updateToolBar(); protected: - /** - * Line data for the 4 lines. - */ + /** Line data for the 4 lines. */ RS_LineData data[4]; - /** - * 1st corner. - */ + /** 1st corner. */ Vector corner1; - /** - * 2nd corner. - */ + /** 2nd corner. */ Vector corner2; }; diff --git a/src/actions/actiontoolregeneratedimensions.cpp b/src/actions/actiontoolregeneratedimensions.cpp deleted file mode 100644 index 0494e06..0000000 --- a/src/actions/actiontoolregeneratedimensions.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// actiontoolregeneratedimensions.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 -// -// Who When What -// --- ---------- ----------------------------------------------------------- -// JLH 06/05/2010 Added this text. :-) -// - -#include "actiontoolregeneratedimensions.h" - -#include "rs_debug.h" -#include "rs_dialogfactory.h" -#include "rs_dimension.h" -#include "graphicview.h" -#include "rs_information.h" - -ActionToolRegenerateDimensions::ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView): - ActionInterface("Tool Regen Dim", container, graphicView) -{ -} - -ActionToolRegenerateDimensions::~ActionToolRegenerateDimensions() -{ -} - -void ActionToolRegenerateDimensions::init(int status) -{ - ActionInterface::init(status); - trigger(); -} - -void ActionToolRegenerateDimensions::trigger() -{ - RS_DEBUG->print("ActionToolRegenerateDimensions::trigger()"); - - int num = 0; - - for(RS_Entity * e = container->firstEntity(RS2::ResolveNone); - e != NULL; e = container->nextEntity(RS2::ResolveNone)) - { - if (RS_Information::isDimension(e->rtti()) && e->isVisible()) - { - num++; - - if (((RS_Dimension *)e)->getLabel() == ";;") - ((RS_Dimension *)e)->setLabel(""); - - ((RS_Dimension *)e)->update(true); - } - } - - if (num > 0) - { - graphicView->redraw(); - RS_DIALOGFACTORY->commandMessage(tr("Regenerated %1 dimension entities").arg(num)); - } - else - RS_DIALOGFACTORY->commandMessage(tr("No dimension entities found")); - - finish(); -} - - diff --git a/src/actions/actiontoolregeneratedimensions.h b/src/actions/actiontoolregeneratedimensions.h deleted file mode 100644 index 9ca8d95..0000000 --- a/src/actions/actiontoolregeneratedimensions.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __ACTIONTOOLREGENERATEDIMENSIONS_H__ -#define __ACTIONTOOLREGENERATEDIMENSIONS_H__ - -#include "actioninterface.h" - -/** - * This action class can handle user events to regenerate dimensions. - * - * @author James Hammons - * @author Andrew Mustun - */ -class ActionToolRegenerateDimensions: public ActionInterface -{ - public: - ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView); - ~ActionToolRegenerateDimensions(); - - virtual void init(int status = 0); - virtual void trigger(); -}; - -#endif // __ACTIONTOOLREGENERATEDIMENSIONS_H__ diff --git a/src/actions/actionzoompan.cpp b/src/actions/actionzoompan.cpp index 7b8d3a8..7aa3a42 100644 --- a/src/actions/actionzoompan.cpp +++ b/src/actions/actionzoompan.cpp @@ -21,6 +21,8 @@ ActionZoomPan::ActionZoomPan(RS_EntityContainer & container, GraphicView & graphicView): ActionInterface("Zoom Pan", container, graphicView) { + graphicView.snapper.SetVisible(false); + graphicView.preview.SetVisible(false); } ActionZoomPan::~ActionZoomPan() @@ -61,7 +63,7 @@ void ActionZoomPan::mouseMoveEvent(QMouseEvent * e) void ActionZoomPan::mousePressEvent(QMouseEvent * e) { - if (e->button() == Qt::MidButton || e->button() == Qt::LeftButton) + if (e->button() == Qt::LeftButton || e->button() == Qt::MidButton) { x1 = e->x(); y1 = e->y(); @@ -71,12 +73,16 @@ void ActionZoomPan::mousePressEvent(QMouseEvent * e) void ActionZoomPan::mouseReleaseEvent(QMouseEvent * e) { - if (e->button() == Qt::RightButton) + // Right button? Why? + // Is this a regular tool? Is this why? (yup, it is. but lame nonetheless.) + // It doesn't revert the cursor correctly if this is not in... + // So... We need to fix this... [DONE] + /*if (e->button() == Qt::RightButton) init(getStatus() - 1); - else if (e->button() == Qt::MidButton) + else*/ if (e->button() == Qt::MidButton || e->button() == Qt::RightButton) init(-1); else - setStatus(0); + setStatus(0); // Qt::LeftButton } void ActionZoomPan::updateMouseCursor() diff --git a/src/base/actioninterface.cpp b/src/base/actioninterface.cpp index b62b578..9f38848 100644 --- a/src/base/actioninterface.cpp +++ b/src/base/actioninterface.cpp @@ -58,6 +58,8 @@ ActionInterface::ActionInterface(const char * name, RS_EntityContainer & c, // expunged, by Grabthar's Hammer! graphicView->snapper.SetContainer(container); graphicView->snapper.SetGraphicView(graphicView); // <-- THIS is what I mean! INSANE! + graphicView->snapper.SetVisible(); + graphicView->preview.SetVisible(); RS_DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\": OK", name); } @@ -109,6 +111,11 @@ void ActionInterface::init(int status/*= 0*/) updateMouseCursor(); updateToolBar(); } + else // status < 0, e.g. this action is finished + { + graphicView->snapper.SetVisible(false); + graphicView->preview.SetVisible(false); + } } /** diff --git a/src/base/rs_creation.cpp b/src/base/rs_creation.cpp index 39e5ee7..4fc2bc3 100644 --- a/src/base/rs_creation.cpp +++ b/src/base/rs_creation.cpp @@ -480,73 +480,61 @@ RS_Circle* RS_Creation::createParallelCircle(const Vector& coord, * @return Pointer to the first bisector created or NULL if no bisectors * were created. */ -RS_Line* RS_Creation::createBisector(const Vector& coord1, - const Vector& coord2, - double length, - int num, - RS_Line* l1, - RS_Line* l2) { +RS_Line * RS_Creation::createBisector(const Vector & coord1, const Vector & coord2, + double length, int num, RS_Line * l1, RS_Line * l2) +{ + // check given entities: + if (!l1 || !l2 || l1->rtti() != RS2::EntityLine || l2->rtti() != RS2::EntityLine) + return NULL; - VectorSolutions sol; + // intersection between entities: + VectorSolutions sol = RS_Information::getIntersection(l1, l2, false); + Vector inters = sol.get(0); - // check given entities: - if (l1==NULL || l2==NULL || - l1->rtti()!=RS2::EntityLine || l2->rtti()!=RS2::EntityLine) { - return NULL; - } + if (!inters.valid) + return NULL; - // intersection between entities: - sol = RS_Information::getIntersection(l1, l2, false); - Vector inters = sol.get(0); - if (inters.valid==false) { - return NULL; - } + double angle1 = inters.angleTo(l1->getNearestPointOnEntity(coord1)); + double angle2 = inters.angleTo(l2->getNearestPointOnEntity(coord2)); + double angleDiff = RS_Math::getAngleDifference(angle1, angle2); - double angle1 = inters.angleTo(l1->getNearestPointOnEntity(coord1)); - double angle2 = inters.angleTo(l2->getNearestPointOnEntity(coord2)); - double angleDiff = RS_Math::getAngleDifference(angle1, angle2); - if (angleDiff>M_PI) { - angleDiff = angleDiff - 2*M_PI; - } - RS_Line* ret = NULL; + if (angleDiff > M_PI) + angleDiff = angleDiff - 2 * M_PI; - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } + RS_Line * ret = NULL; - for (int n=1; n<=num; ++n) { + if (document && handleUndo) + document->startUndoCycle(); - double angle = angle1 + - (angleDiff / (num+1) * n); + for(int n=1; n<=num; n++) + { + double angle = angle1 + (angleDiff / (num + 1) * n); + Vector v; + v.setPolar(length, angle); + RS_LineData d = RS_LineData(inters, inters + v); + RS_Line * newLine = new RS_Line(container, d); - RS_LineData d; - Vector v; + if (container) + { + newLine->setLayerToActive(); + newLine->setPenToActive(); + container->addEntity(newLine); + } - Vector c; - v.setPolar(length, angle); - d = RS_LineData(inters, inters + v); + if (document && handleUndo) + document->addUndoable(newLine); - RS_Line* newLine = new RS_Line(container, d); - if (container!=NULL) { - newLine->setLayerToActive(); - newLine->setPenToActive(); - container->addEntity(newLine); - } - if (document!=NULL && handleUndo) { - document->addUndoable(newLine); - } - if (graphicView!=NULL) { - graphicView->drawEntity(newLine); - } - if (ret==NULL) { - ret = newLine; - } - } - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } + if (graphicView) + graphicView->drawEntity(newLine); - return ret; + if (!ret) + ret = newLine; + } + + if (document && handleUndo) + document->endUndoCycle(); + + return ret; } diff --git a/src/base/rs_fileio.h b/src/base/rs_fileio.h index 5359df3..fa0e8c3 100644 --- a/src/base/rs_fileio.h +++ b/src/base/rs_fileio.h @@ -25,13 +25,10 @@ class RS_FileIO QList getFilterList(); RS_FilterInterface * getImportFilter(RS2::FormatType t); RS_FilterInterface * getExportFilter(RS2::FormatType t); - bool fileImport(Drawing & graphic, const QString & file, RS2::FormatType type = RS2::FormatUnknown); - bool fileExport(Drawing & graphic, const QString & file, RS2::FormatType type = RS2::FormatUnknown); - RS2::FormatType detectFormat(const QString & file); protected: diff --git a/src/forms/lineangleoptions.cpp b/src/forms/lineangleoptions.cpp index dca00ae..626d0a4 100644 --- a/src/forms/lineangleoptions.cpp +++ b/src/forms/lineangleoptions.cpp @@ -73,7 +73,7 @@ LineAngleOptions::~LineAngleOptions() void LineAngleOptions::setAction(ActionInterface * a, bool update) { - if (a != NULL && a->rtti() == RS2::ActionDrawLineAngle) + if (a && a->rtti() == RS2::ActionDrawLineAngle) { action = (ActionDrawLineAngle *)a; @@ -83,8 +83,7 @@ void LineAngleOptions::setAction(ActionInterface * a, bool update) leAngle->hide(); } - QString sa; - QString sl; + QString sa, sl; int sp; // settings from action: @@ -123,18 +122,18 @@ void LineAngleOptions::setAction(ActionInterface * a, bool update) void LineAngleOptions::updateAngle(const QString & a) { - if (action != NULL && !action->hasFixedAngle()) + if (action && !action->hasFixedAngle()) action->setAngle(RS_Math::deg2rad(RS_Math::eval(a))); } void LineAngleOptions::updateLength(const QString & l) { - if (action != NULL) + if (action) action->setLength(RS_Math::eval(l)); } void LineAngleOptions::updateSnapPoint(int sp) { - if (action != NULL) + if (action) action->setSnapPoint(sp); } diff --git a/src/widgets/actionhandler.cpp b/src/widgets/actionhandler.cpp index 90731bb..689db38 100644 --- a/src/widgets/actionhandler.cpp +++ b/src/widgets/actionhandler.cpp @@ -110,7 +110,6 @@ #include "actionsetsnapmode.h" #include "actionsetsnaprestriction.h" #include "actionsnapintersectionmanual.h" -#include "actiontoolregeneratedimensions.h" #include "actionzoomauto.h" #include "actionzoomin.h" #include "actionzoompan.h" @@ -334,9 +333,10 @@ ActionInterface * ActionHandler::setCurrentAction(RS2::ActionType id) // Tool actions: // - case RS2::ActionToolRegenerateDimensions: - a = new ActionToolRegenerateDimensions(*doc, *gv); - break; +//no +// case RS2::ActionToolRegenerateDimensions: +// a = new ActionToolRegenerateDimensions(*doc, *gv); +// break; // Zooming actions: // -- 2.37.2