X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawline.cpp;h=8bc0bb13401dca28548f90df534bed0bca53addf;hb=5adb444f3e523d3fd028617ced72d1ea6661db21;hp=b387ee93501d197013f179b4a99c073f3c9cae65;hpb=1f0d096a7fc370ff02477f3860beae2669bf8903;p=architektonas diff --git a/src/actions/actiondrawline.cpp b/src/actions/actiondrawline.cpp index b387ee9..8bc0bb1 100644 --- a/src/actions/actiondrawline.cpp +++ b/src/actions/actiondrawline.cpp @@ -17,24 +17,20 @@ #include "actiondrawline.h" #include "actioneditundo.h" -#include "rs_commandevent.h" +#include "commandevent.h" #include "commands.h" -#include "rs_debug.h" -#include "rs_dialogfactory.h" +#include "debug.h" +#include "dialogfactory.h" #include "graphicview.h" -#include "rs_preview.h" +#include "preview.h" -ActionDrawLine::ActionDrawLine(RS_EntityContainer & container, GraphicView & graphicView): +ActionDrawLine::ActionDrawLine(EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw lines", container, graphicView) { - RS_DEBUG->print("ActionDrawLine::ActionDrawLine"); + DEBUG->print("ActionDrawLine::ActionDrawLine"); reset(); - //hm. -// graphicView.snapper.SetContainer(&container); -// graphicView.snapper.SetGraphicView(&graphicView); -// graphicView.snapper.SetVisible(); -// graphicView.preview.SetVisible(); - RS_DEBUG->print("ActionDrawLine::ActionDrawLine: OK"); + DEBUG->print("ActionDrawLine::ActionDrawLine: OK"); +//printf("ActionDrawLine(): preview is%s visible, snapper is%s visible...\n", (graphicView.preview.Visible() ? "" : " NOT"), (graphicView.snapper.Visible() ? "" : " NOT")); } ActionDrawLine::~ActionDrawLine() @@ -49,33 +45,33 @@ ActionDrawLine::~ActionDrawLine() void ActionDrawLine::reset() { - RS_DEBUG->print("ActionDrawLine::reset"); - data = RS_LineData(Vector(false), Vector(false)); + DEBUG->print("ActionDrawLine::reset"); + data = LineData(Vector(false), Vector(false)); start = Vector(false); ClearHistory(); - RS_DEBUG->print("ActionDrawLine::reset: OK"); + DEBUG->print("ActionDrawLine::reset: OK"); } void ActionDrawLine::init(int status) { - RS_DEBUG->print("ActionDrawLine::init"); + DEBUG->print("ActionDrawLine::init"); ActionInterface::init(status); reset(); - RS_DEBUG->print("ActionDrawLine::init: OK"); + DEBUG->print("ActionDrawLine::init: OK"); } void ActionDrawLine::trigger() { graphicView->preview.clear(); - RS_Line * line = new RS_Line(container, data); + Line * line = new Line(container, data); line->setLayerToActive(); line->setPenToActive(); container->addEntity(line); //std::cout << container; //printf("ActionDrawLine::trigger(): new line is %f,%f to %f,%f\n", data.startpoint.x, data.startpoint.y, data.endpoint.x, data.endpoint.y); //This makes it come back as "Unknown Entity" -//std::cout << *((RS_Entity *)container); +//std::cout << *((Entity *)container); //std::cout << *container; // Update undo list: @@ -89,29 +85,30 @@ void ActionDrawLine::trigger() graphicView->moveRelativeZero(line->getEndpoint()); //hm. [OK, it just moves the relative zero tho. Overkill. And remove preview, so OK.] graphicView->redraw(); - RS_DEBUG->print("ActionDrawLine::trigger(): line added: %d", line->getId()); + DEBUG->print("ActionDrawLine::trigger(): line added: %d", line->getId()); } void ActionDrawLine::mouseMoveEvent(QMouseEvent * e) { - RS_DEBUG->print("ActionDrawLine::mouseMoveEvent begin"); + DEBUG->print("ActionDrawLine::mouseMoveEvent begin"); - RS_DEBUG->print("ActionDrawLine::mouseMoveEvent: snap point"); - Vector mouse = graphicView->snapper.snapPoint(e); - RS_DEBUG->print("ActionDrawLine::mouseMoveEvent: snap point: OK"); + DEBUG->print("ActionDrawLine::mouseMoveEvent: snap point"); +// Vector mouse = graphicView->snapper.snapPoint(e); + Vector mouse = graphicView->SnapPoint(e); + DEBUG->print("ActionDrawLine::mouseMoveEvent: snap point: OK"); if (getStatus() == SetEndpoint && data.startpoint.valid) { - RS_DEBUG->print("ActionDrawLine::mouseMoveEvent: update preview"); + DEBUG->print("ActionDrawLine::mouseMoveEvent: update preview"); // This is lame. Creating a new Line every time the endpoint moves. // Surely we can alter the line entity inside the preview, no? #if 0 graphicView->preview.clear(); // Remove entities from the container - RS_Line * line = new RS_Line(&(graphicView->preview), RS_LineData(data.startpoint, mouse)); + Line * line = new Line(&(graphicView->preview), LineData(data.startpoint, mouse)); graphicView->preview.addEntity(line); #else // We can assume there's only one line in there, can't we? - RS_Line * line = (RS_Line *)graphicView->preview.firstEntity(RS2::ResolveNone); + Line * line = (Line *)graphicView->preview.firstEntity(RS2::ResolveNone); if (line) { @@ -119,47 +116,47 @@ void ActionDrawLine::mouseMoveEvent(QMouseEvent * e) } else { - line = new RS_Line(&(graphicView->preview), RS_LineData(data.startpoint, mouse)); + line = new Line(&(graphicView->preview), LineData(data.startpoint, mouse)); graphicView->preview.addEntity(line); } #endif } +//OK, snapper & preview are set as NOT visible... why??? +//becuz other things are created in the meantime which turn this stuff off, treating +//it like it isn't a shared resource which it is... +//printf("ActionDrawLine::mouseMoveEvent(): preview is%s visible, snapper is%s visible...\n", (graphicView->preview.Visible() ? "" : " NOT"), (graphicView->snapper.Visible() ? "" : " NOT")); //hm. [ok, this works. :-D] graphicView->redraw(); - RS_DEBUG->print("ActionDrawLine::mouseMoveEvent end"); + DEBUG->print("ActionDrawLine::mouseMoveEvent end"); } void ActionDrawLine::mouseReleaseEvent(QMouseEvent * e) { if (e->button() == Qt::LeftButton) { - Vector ce(graphicView->snapper.snapPoint(e)); +// Vector ce(graphicView->snapper.snapPoint(e)); + Vector ce(graphicView->SnapPoint(e)); coordinateEvent(&ce); } else if (e->button() == Qt::RightButton) { -// if (getStatus() == 0) -// { -// graphicView->snapper.SetVisible(false); -// graphicView->preview.SetVisible(false); -// } - init(getStatus() - 1); } //hm. [Seems to work OK.] - graphicView->preview.clear(); // Remove entities from container - graphicView->redraw(); + //shouldn't need this... +// graphicView->preview.clear(); // Remove entities from container +// graphicView->redraw(); } void ActionDrawLine::coordinateEvent(Vector * e) { - RS_DEBUG->print("ActionDrawLine::coordinateEvent"); + DEBUG->print("ActionDrawLine::coordinateEvent"); if (!e) { - RS_DEBUG->print("ActionDrawLine::coordinateEvent: event was NULL"); + DEBUG->print("ActionDrawLine::coordinateEvent: event was NULL"); return; } @@ -189,12 +186,12 @@ void ActionDrawLine::coordinateEvent(Vector * e) break; } - RS_DEBUG->print("ActionDrawLine::coordinateEvent: OK"); + DEBUG->print("ActionDrawLine::coordinateEvent: OK"); } -void ActionDrawLine::commandEvent(RS_CommandEvent * e) +void ActionDrawLine::commandEvent(CommandEvent * e) { - RS_DEBUG->print("ActionDrawLine::commandEvent"); + DEBUG->print("ActionDrawLine::commandEvent"); QString c = e->getCommand().toLower(); switch (getStatus()) @@ -203,7 +200,7 @@ void ActionDrawLine::commandEvent(RS_CommandEvent * e) if (checkCommand("help", c)) { - RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } @@ -230,7 +227,7 @@ void ActionDrawLine::commandEvent(RS_CommandEvent * e) break; } - RS_DEBUG->print("ActionDrawLine::commandEvent: OK"); + DEBUG->print("ActionDrawLine::commandEvent: OK"); } QStringList ActionDrawLine::getAvailableCommands() @@ -264,7 +261,7 @@ void ActionDrawLine::updateMouseButtonHints() switch (getStatus()) { case SetStartpoint: - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel")); + DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel")); break; case SetEndpoint: @@ -273,38 +270,38 @@ void ActionDrawLine::updateMouseButtonHints() if (history.count() >= 3) { - msg += RS_COMMANDS->command("close"); + msg += COMMANDS->command("close"); msg += "/"; } if (history.count() >= 2) - msg += RS_COMMANDS->command("undo"); + msg += COMMANDS->command("undo"); if (history.count() >= 2) - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify next point or [%1]").arg(msg), tr("Back")); + DIALOGFACTORY->updateMouseWidget(tr("Specify next point or [%1]").arg(msg), tr("Back")); else - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify next point"), tr("Back")); + DIALOGFACTORY->updateMouseWidget(tr("Specify next point"), tr("Back")); } break; default: - RS_DIALOGFACTORY->updateMouseWidget("", ""); + DIALOGFACTORY->updateMouseWidget("", ""); break; } } void ActionDrawLine::showOptions() { - RS_DEBUG->print("ActionDrawLine::showOptions"); + DEBUG->print("ActionDrawLine::showOptions"); ActionInterface::showOptions(); - RS_DIALOGFACTORY->requestOptions(this, true); - RS_DEBUG->print("ActionDrawLine::showOptions: OK"); + DIALOGFACTORY->requestOptions(this, true); + DEBUG->print("ActionDrawLine::showOptions: OK"); } void ActionDrawLine::hideOptions() { ActionInterface::hideOptions(); - RS_DIALOGFACTORY->requestOptions(this, false); + DIALOGFACTORY->requestOptions(this, false); } void ActionDrawLine::updateMouseCursor() @@ -315,9 +312,9 @@ void ActionDrawLine::updateMouseCursor() void ActionDrawLine::updateToolBar() { if (!isFinished()) - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); + DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); else - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines); + DIALOGFACTORY->requestToolBar(RS2::ToolBarLines); } void ActionDrawLine::close() @@ -332,7 +329,7 @@ void ActionDrawLine::close() graphicView->moveRelativeZero(start); } else - RS_DIALOGFACTORY->commandMessage(tr("Cannot close sequence of lines: Not enough entities defined yet.")); + DIALOGFACTORY->commandMessage(tr("Cannot close sequence of lines: Not enough entities defined yet.")); } void ActionDrawLine::undo() @@ -348,7 +345,7 @@ void ActionDrawLine::undo() graphicView->redraw(); } else - RS_DIALOGFACTORY->commandMessage(tr("Cannot undo: Not enough entities defined yet.")); + DIALOGFACTORY->commandMessage(tr("Cannot undo: Not enough entities defined yet.")); } void ActionDrawLine::ClearHistory(void)