X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawlinebisector.cpp;h=e4c8bdd94bf27d40c2f9e3d22f405567c6e40c86;hb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;hp=78b8581809bff58cad6cd55a5b24a3f26070bb7a;hpb=48105dec9198cf5a81dd9286010d0d45e28f70c3;p=architektonas diff --git a/src/actions/actiondrawlinebisector.cpp b/src/actions/actiondrawlinebisector.cpp index 78b8581..e4c8bdd 100644 --- a/src/actions/actiondrawlinebisector.cpp +++ b/src/actions/actiondrawlinebisector.cpp @@ -16,24 +16,20 @@ #include "actiondrawlinebisector.h" -#include "rs_commandevent.h" -#include "rs_creation.h" -#include "rs_debug.h" -#include "rs_dialogfactory.h" +#include "commandevent.h" +#include "creation.h" +#include "debug.h" +#include "dialogfactory.h" #include "graphicview.h" -#include "rs_preview.h" +#include "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); }