// rs_actiondrawline.cpp
//
+// 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
void RS_ActionDrawLine::init(int status)
{
RS_DEBUG->print("RS_ActionDrawLine::init");
- RS_PreviewActionInterface::init(status);
+// RS_PreviewActionInterface::init(status);
+ RS_ActionInterface::init(status);
reset();
RS_DEBUG->print("RS_ActionDrawLine::init: OK");
}
void RS_ActionDrawLine::trigger()
{
-#if 0
- RS_PreviewActionInterface::trigger(); // XOR off screen, delete entities in container
-#else
graphicView->preview.clear();
-// graphicView->redraw();
-#endif
RS_Line * line = new RS_Line(container, data);
line->setLayerToActive();
if (getStatus() == SetEndpoint && data.startpoint.valid)
{
RS_DEBUG->print("RS_ActionDrawLine::mouseMoveEvent: update preview");
-#if 0
-//not needed, but without this, it doesn't draw... strange...
-//obviously we haven't gotten our rendering path correct...
-// deletePreview(); // XOR off of screen
- clearPreview(); // Remove entities from the container
- preview->addEntity(new RS_Line(preview, RS_LineData(data.startpoint, mouse)));
- RS_DEBUG->print("RS_ActionDrawLine::mouseMoveEvent: draw preview");
-// drawPreview(); // XOR on screen
- xorPreview(); // XOR on screen
-#else
// 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));
-//wha? Even THIS doesn't work!!! It was the container...
-// line->setPen(RS_Pen(RS_Color(60, 255, 60), RS2::Width00, RS2::SolidLine));
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);
+
+ if (line)
+ {
+ line->setEndpoint(mouse);
+ }
+ else
+ {
+ line = new RS_Line(&(graphicView->preview), RS_LineData(data.startpoint, mouse));
+ graphicView->preview.addEntity(line);
+ }
#endif
}
{
if (e->button() == Qt::LeftButton)
{
- Vector ce(snapPoint(e));
+ Vector ce(graphicView->snapper.snapPoint(e));
coordinateEvent(&ce);
}
else if (e->button() == Qt::RightButton)
graphicView->preview.SetVisible(false);
}
-#if 0
- deletePreview(); // XOR off of screen
- clearPreview(); // Remove entities from the container
-#else
-#endif
init(getStatus() - 1);
}
else
RS_DIALOGFACTORY->updateMouseWidget(tr("Specify next point"), tr("Back"));
}
- break;
+ break;
default:
RS_DIALOGFACTORY->updateMouseWidget("", "");
if (history.count() > 1)
{
history.removeLast();
-// deletePreview(); // XOR off of screen
-// clearPreview(); // Delete entities in container
graphicView->setCurrentAction(new RS_ActionEditUndo(true, *container, *graphicView));
data.startpoint = *history.last();
graphicView->moveRelativeZero(data.startpoint);
-graphicView->preview.clear();
-graphicView->redraw();
+ graphicView->preview.clear();
+ graphicView->redraw();
}
else
RS_DIALOGFACTORY->commandMessage(tr("Cannot undo: Not enough entities defined yet."));