X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawline.cpp;h=a0be6db85b6a1812c2b6164fc4d61e61173e1c61;hb=2ee84c5948ede7fc2f7b4435c5edef42a030ac05;hp=e6ae87a68b0807ef233e398c7b6b3b84e82b6345;hpb=d774c2655ba2c3657a565f325411144452392277;p=architektonas diff --git a/src/actions/actiondrawline.cpp b/src/actions/actiondrawline.cpp index e6ae87a..a0be6db 100644 --- a/src/actions/actiondrawline.cpp +++ b/src/actions/actiondrawline.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 // @@ -15,23 +17,24 @@ #include "actiondrawline.h" #include "actioneditundo.h" -#include "rs_commandevent.h" +#include "commandevent.h" #include "commands.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"); +// graphicView.snapper.SetContainer(&container); +// graphicView.snapper.SetGraphicView(&graphicView); +// graphicView.snapper.SetVisible(); +// graphicView.preview.SetVisible(); + DEBUG->print("ActionDrawLine::ActionDrawLine: OK"); } ActionDrawLine::~ActionDrawLine() @@ -46,34 +49,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"); -// ActionInterface::init(status); + 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: @@ -87,29 +89,29 @@ 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"); + 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: 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) { @@ -117,7 +119,7 @@ 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 @@ -125,7 +127,7 @@ void ActionDrawLine::mouseMoveEvent(QMouseEvent * e) //hm. [ok, this works. :-D] graphicView->redraw(); - RS_DEBUG->print("ActionDrawLine::mouseMoveEvent end"); + DEBUG->print("ActionDrawLine::mouseMoveEvent end"); } void ActionDrawLine::mouseReleaseEvent(QMouseEvent * e) @@ -137,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); } @@ -153,11 +155,11 @@ void ActionDrawLine::mouseReleaseEvent(QMouseEvent * e) 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; } @@ -187,12 +189,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()) @@ -201,7 +203,7 @@ void ActionDrawLine::commandEvent(RS_CommandEvent * e) if (checkCommand("help", c)) { - RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } @@ -228,7 +230,7 @@ void ActionDrawLine::commandEvent(RS_CommandEvent * e) break; } - RS_DEBUG->print("ActionDrawLine::commandEvent: OK"); + DEBUG->print("ActionDrawLine::commandEvent: OK"); } QStringList ActionDrawLine::getAvailableCommands() @@ -262,7 +264,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: @@ -271,40 +273,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"); -// ActionInterface::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(); ActionInterface::hideOptions(); - RS_DIALOGFACTORY->requestOptions(this, false); + DIALOGFACTORY->requestOptions(this, false); } void ActionDrawLine::updateMouseCursor() @@ -315,9 +315,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 +332,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 +348,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)