// 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 "actiondrawcirclecr.h"
-#include "rs_commandevent.h"
-#include "rs_dialogfactory.h"
+#include "commandevent.h"
+#include "debug.h"
+#include "dialogfactory.h"
#include "graphicview.h"
-#include "rs_preview.h"
+#include "preview.h"
/**
* Constructor.
*/
-ActionDrawCircleCR::ActionDrawCircleCR(RS_EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw circles CR",
- container, graphicView)
+ActionDrawCircleCR::ActionDrawCircleCR(EntityContainer & container,
+ GraphicView & graphicView):
+ ActionInterface("Draw circles CR", container, graphicView)
{
reset();
}
void ActionDrawCircleCR::reset()
{
- data = RS_CircleData(Vector(false), 0.0);
+ data = CircleData(Vector(false), 0.0);
}
void ActionDrawCircleCR::init(int status)
{
ActionInterface::trigger();
- RS_Circle * circle = new RS_Circle(container, data);
+ Circle * circle = new Circle(container, data);
circle->setLayerToActive();
circle->setPenToActive();
container->addEntity(circle);
// upd. undo list:
- if (document != NULL)
+ if (document)
{
document->startUndoCycle();
document->addUndoable(circle);
document->endUndoCycle();
}
- deleteSnapper();
- Vector rz = graphicView->getRelativeZero();
- graphicView->moveRelativeZero(Vector(0.0, 0.0));
- graphicView->drawEntity(circle);
- graphicView->moveRelativeZero(circle->getCenter());
- drawSnapper();
+// deleteSnapper();
+// Vector rz = graphicView->getRelativeZero();
+// graphicView->moveRelativeZero(Vector(0.0, 0.0));
+// graphicView->drawEntity(circle);
+// graphicView->moveRelativeZero(circle->getCenter());
+// drawSnapper();
+ graphicView->preview.clear(); // hm.
+ graphicView->redraw();
setStatus(SetCenter);
- RS_DEBUG->print("ActionDrawCircleCR::trigger(): circle added: %d", circle->getId());
+ DEBUG->print("ActionDrawCircleCR::trigger(): circle added: %d", circle->getId());
}
void ActionDrawCircleCR::mouseMoveEvent(QMouseEvent * e)
{
- RS_DEBUG->print("ActionDrawCircleCR::mouseMoveEvent begin");
+ DEBUG->print("ActionDrawCircleCR::mouseMoveEvent begin");
Vector mouse = snapPoint(e);
switch (getStatus())
{
case SetCenter:
data.center = mouse;
- deletePreview();
- clearPreview();
-// preview->addEntity(new RS_Circle(preview, data));
- drawPreview();
+// deletePreview();
+// clearPreview();
+// preview->addEntity(new Circle(preview, data));
+// drawPreview();
+ graphicView->preview.clear();
+ graphicView->preview.addEntity(new Circle(&(graphicView->preview), data));
break;
}
- RS_DEBUG->print("ActionDrawCircleCR::mouseMoveEvent end");
+ graphicView->redraw();
+ DEBUG->print("ActionDrawCircleCR::mouseMoveEvent end");
}
void ActionDrawCircleCR::mouseReleaseEvent(QMouseEvent * e)
}
else if (e->button() == Qt::RightButton)
{
- deletePreview();
- deleteSnapper();
+// deletePreview();
+// deleteSnapper();
init(getStatus() - 1);
+ graphicView->redraw(); // hm.
}
}
}
}
-void ActionDrawCircleCR::commandEvent(RS_CommandEvent * e)
+void ActionDrawCircleCR::commandEvent(CommandEvent * e)
{
QString c = e->getCommand().toLower();
if (checkCommand("help", c))
{
- RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ getAvailableCommands().join(", "));
return;
}
case SetRadius:
{
bool ok;
- double r = RS_Math::eval(c, &ok);
+ double r = Math::eval(c, &ok);
if (ok == true)
data.radius = r;
else
- RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+ DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
- RS_DIALOGFACTORY->requestOptions(this, true, true);
+ DIALOGFACTORY->requestOptions(this, true, true);
setStatus(SetCenter);
}
break;
switch (getStatus())
{
case SetCenter:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify circle center"), tr("Cancel"));
+ DIALOGFACTORY->updateMouseWidget(tr("Specify circle center"), tr("Cancel"));
break;
case SetRadius:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify circle radius"), tr("Back"));
+ DIALOGFACTORY->updateMouseWidget(tr("Specify circle radius"), tr("Back"));
break;
default:
- RS_DIALOGFACTORY->updateMouseWidget("", "");
+ DIALOGFACTORY->updateMouseWidget("", "");
break;
}
}
{
ActionInterface::showOptions();
- RS_DIALOGFACTORY->requestOptions(this, true);
+ DIALOGFACTORY->requestOptions(this, true);
}
void ActionDrawCircleCR::hideOptions()
{
ActionInterface::hideOptions();
- RS_DIALOGFACTORY->requestOptions(this, false);
+ DIALOGFACTORY->requestOptions(this, false);
}
void ActionDrawCircleCR::updateMouseCursor()
void ActionDrawCircleCR::updateToolBar()
{
if (!isFinished())
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+ DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
else
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
+ DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles);
}
double ActionDrawCircleCR::getRadius()