X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawlinebisector.cpp;h=eb7172715d8e1e1b793e434c8a42b8281bed76ea;hb=f62cebc26c7c3af447f0e4e4c43331f8589dce22;hp=78b8581809bff58cad6cd55a5b24a3f26070bb7a;hpb=48105dec9198cf5a81dd9286010d0d45e28f70c3;p=architektonas diff --git a/src/actions/actiondrawlinebisector.cpp b/src/actions/actiondrawlinebisector.cpp index 78b8581..eb71727 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(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,50 +44,17 @@ 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 creation(container, graphicView); + creation.createBisector(coord1, coord2, length, number, line1, line2); + graphicView->redraw(); } void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e) { - RS_DEBUG->print("ActionDrawLineBisector::mouseMoveEvent begin"); + DEBUG->print("ActionDrawLineBisector::mouseMoveEvent begin"); Vector mouse = Vector(graphicView->toGraphX(e->x()), - graphicView->toGraphY(e->y())); + graphicView->toGraphY(e->y())); switch (getStatus()) { @@ -101,18 +64,14 @@ void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e) case SetLine2: { coord2 = mouse; - RS_Entity * en = catchEntity(e, RS2::ResolveAll); + Entity * en = catchEntity(e, RS2::ResolveAll); 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 = (Line *)en; + graphicView->preview.clear(); + Creation creation(&(graphicView->preview), NULL, false); + creation.createBisector(coord1, coord2, length, number, line1, line2); } } break; @@ -121,15 +80,16 @@ void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e) break; } - RS_DEBUG->print("ActionDrawLineBisector::mouseMoveEvent end"); + graphicView->redraw(); + DEBUG->print("ActionDrawLineBisector::mouseMoveEvent end"); } void ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent * e) { if (e->button() == Qt::RightButton) { - deletePreview(); - clearPreview(); +// deletePreview(); +// clearPreview(); init(getStatus() - 1); } else @@ -142,12 +102,14 @@ void ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent * e) case SetLine1: { coord1 = mouse; - RS_Entity * en = catchEntity(e, RS2::ResolveAll); + Entity * en = catchEntity(e, RS2::ResolveAll); - if (en != NULL && en->rtti() == RS2::EntityLine) - line1 = (RS_Line *)en; + if (en && en->rtti() == RS2::EntityLine) + { + line1 = (Line *)en; + setStatus(SetLine2); + } } - setStatus(SetLine2); break; case SetLine2: @@ -159,13 +121,13 @@ void ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent * e) } } -void ActionDrawLineBisector::commandEvent(RS_CommandEvent * e) +void ActionDrawLineBisector::commandEvent(CommandEvent * e) { QString c = e->getCommand().toLower(); if (checkCommand("help", c)) { - RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } @@ -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); + double l = 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); + DIALOGFACTORY->commandMessage(tr("Not a valid expression")); + + DIALOGFACTORY->requestOptions(this, true, true); setStatus(lastStatus); } - break; + break; - case SetNumber: { + case SetNumber: + { bool ok; - int n = (int)RS_Math::eval(c, &ok); + int n = (int)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); + DIALOGFACTORY->commandMessage(tr("Not a valid expression")); + + DIALOGFACTORY->requestOptions(this, true, true); setStatus(lastStatus); } - break; + break; default: break; @@ -247,27 +214,23 @@ void ActionDrawLineBisector::updateMouseButtonHints() switch (getStatus()) { case SetLine1: - RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"), - tr("Cancel")); + DIALOGFACTORY->updateMouseWidget(tr("Select first line"), tr("Cancel")); break; case SetLine2: - RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"), - tr("Back")); + DIALOGFACTORY->updateMouseWidget(tr("Select second line"), tr("Back")); break; case SetLength: - RS_DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"), - tr("Back")); + DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"), tr("Back")); break; case SetNumber: - RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"), - tr("Back")); + DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"), tr("Back")); break; default: - RS_DIALOGFACTORY->updateMouseWidget("", ""); + DIALOGFACTORY->updateMouseWidget("", ""); break; } } @@ -275,15 +238,13 @@ void ActionDrawLineBisector::updateMouseButtonHints() void ActionDrawLineBisector::showOptions() { ActionInterface::showOptions(); - - RS_DIALOGFACTORY->requestOptions(this, true); + DIALOGFACTORY->requestOptions(this, true); } void ActionDrawLineBisector::hideOptions() { ActionInterface::hideOptions(); - - RS_DIALOGFACTORY->requestOptions(this, false); + DIALOGFACTORY->requestOptions(this, false); } void ActionDrawLineBisector::updateMouseCursor() @@ -293,7 +254,7 @@ void ActionDrawLineBisector::updateMouseCursor() void ActionDrawLineBisector::updateToolBar() { - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines); + DIALOGFACTORY->requestToolBar(RS2::ToolBarLines); } void ActionDrawLineBisector::setLength(double l)