#include "graphicview.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()
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:
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)
{
}
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;
}
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())
if (checkCommand("help", c))
{
- RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ getAvailableCommands().join(", "));
return;
}
break;
}
- RS_DEBUG->print("ActionDrawLine::commandEvent: OK");
+ DEBUG->print("ActionDrawLine::commandEvent: OK");
}
QStringList ActionDrawLine::getAvailableCommands()
switch (getStatus())
{
case SetStartpoint:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel"));
+ DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel"));
break;
case SetEndpoint:
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()
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()
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()
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)