// 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 <jlhamm@acm.org>
//
// Who When What
// --- ---------- -----------------------------------------------------------
// JLH 06/03/2010 Added this text. :-)
+// JLH 09/11/2010 Fixed preview/snapper rendering.
//
#include "actiondrawcircle3p.h"
-#include "rs_commandevent.h"
-#include "rs_dialogfactory.h"
+#include "commandevent.h"
+#include "dialogfactory.h"
#include "graphicview.h"
-#include "rs_preview.h"
+#include "preview.h"
-ActionDrawCircle3P::ActionDrawCircle3P(RS_EntityContainer & container,
- GraphicView & graphicView): ActionInterface("Draw circles",
- container, graphicView)
+ActionDrawCircle3P::ActionDrawCircle3P(EntityContainer & container,
+ GraphicView & graphicView):
+ ActionInterface("Draw circles", container, graphicView)
{
reset();
}
void ActionDrawCircle3P::trigger()
{
ActionInterface::trigger();
-
preparePreview();
if (data.isValid())
{
- RS_Circle * circle = new RS_Circle(container, data);
+ Circle * circle = new Circle(container, data);
circle->setLayerToActive();
circle->setPenToActive();
container->addEntity(circle);
document->endUndoCycle();
}
- deleteSnapper();
- Vector rz = graphicView->getRelativeZero();
- graphicView->moveRelativeZero(Vector(0.0, 0.0));
- graphicView->drawEntity(circle);
- graphicView->moveRelativeZero(rz);
- drawSnapper();
+// deleteSnapper();
+// Vector rz = graphicView->getRelativeZero();
+// graphicView->moveRelativeZero(Vector(0.0, 0.0));
+// graphicView->drawEntity(circle);
+// graphicView->moveRelativeZero(rz);
+// drawSnapper();
+ graphicView->preview.clear(); // hm.
+ graphicView->redraw();
setStatus(SetPoint1);
reset();
}
else
- RS_DIALOGFACTORY->requestWarningDialog(tr("Invalid circle data."));
+ DIALOGFACTORY->requestWarningDialog(tr("Invalid circle data."));
}
void ActionDrawCircle3P::preparePreview()
if (point1.valid && point2.valid && point3.valid)
{
- RS_Circle circle(NULL, data);
+ Circle circle(NULL, data);
bool success = circle.createFrom3P(point1, point2, point3);
if (success)
if (data.isValid())
{
-// RS_Circle * circle = new RS_Circle(preview, data);
-//
+// Circle * circle = new Circle(preview, data);
// deletePreview();
// clearPreview();
// preview->addEntity(circle);
// drawPreview();
+ graphicView->preview.clear();
+ graphicView->preview.addEntity(new Circle(&(graphicView->preview), data));
}
+
break;
}
+
+ graphicView->redraw();
}
void ActionDrawCircle3P::mouseReleaseEvent(QMouseEvent * e)
}
else if (e->button() == Qt::RightButton)
{
- deletePreview();
- deleteSnapper();
+// deletePreview();
+// deleteSnapper();
init(getStatus() - 1);
+ graphicView->redraw(); // hm.
}
}
}
}
-void ActionDrawCircle3P::commandEvent(RS_CommandEvent * e)
+void ActionDrawCircle3P::commandEvent(CommandEvent * e)
{
QString c = e->getCommand().toLower();
if (checkCommand("help", c))
{
- RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ getAvailableCommands().join(", "));
return;
}
switch (getStatus())
{
case SetPoint1:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel"));
+ DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel"));
break;
case SetPoint2:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second point"), tr("Back"));
+ DIALOGFACTORY->updateMouseWidget(tr("Specify second point"), tr("Back"));
break;
case SetPoint3:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify third point"), tr("Back"));
+ DIALOGFACTORY->updateMouseWidget(tr("Specify third point"), tr("Back"));
break;
default:
- RS_DIALOGFACTORY->updateMouseWidget("", "");
+ DIALOGFACTORY->updateMouseWidget("", "");
break;
}
}
void ActionDrawCircle3P::updateToolBar()
{
if (!isFinished())
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+ DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
else
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
+ DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
}