-// rs_actiondrawlinerelangle.cpp
+// actiondrawlinerelangle.cpp
//
// Part of the Architektonas Project
// Originally part of QCad Community Edition by Andrew Mustun
// JLH 05/22/2010 Added this text. :-)
//
-#include "rs_actiondrawlinerelangle.h"
+#include "actiondrawlinerelangle.h"
#include "rs_commandevent.h"
#include "rs_creation.h"
#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLineRelAngle::RS_ActionDrawLineRelAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle):
- RS_PreviewActionInterface("Draw Lines with relative angles",
- container, graphicView)
+ActionDrawLineRelAngle::ActionDrawLineRelAngle(RS_EntityContainer & container,
+ GraphicView & graphicView, double angle, bool fixedAngle):
+ ActionInterface("Draw Lines with relative angles", container, graphicView)
{
entity = NULL;
this->angle = angle;
pos = Vector(false);
}
-RS_ActionDrawLineRelAngle::~RS_ActionDrawLineRelAngle()
+ActionDrawLineRelAngle::~ActionDrawLineRelAngle()
{
}
-/*virtual*/ RS2::ActionType RS_ActionDrawLineRelAngle::rtti()
+/*virtual*/ RS2::ActionType ActionDrawLineRelAngle::rtti()
{
return RS2::ActionDrawLineRelAngle;
}
-void RS_ActionDrawLineRelAngle::trigger()
+void ActionDrawLineRelAngle::trigger()
{
- RS_PreviewActionInterface::trigger();
+ ActionInterface::trigger();
deleteSnapper();
deletePreview();
clearPreview();
RS_Creation creation(container, graphicView);
- creation.createLineRelAngle(pos,
- entity,
- angle,
- length);
-
- /*
- if (line!=NULL) {
- RS_Entity* newEntity = NULL;
-
- newEntity = new RS_Line(container,
- line->getData());
-
- if (newEntity!=NULL) {
- newEntity->setLayerToActive();
- newEntity->setPenToActive();
- container->addEntity(newEntity);
-
- // upd. undo list:
- if (document!=NULL) {
- document->startUndoCycle();
- document->addUndoable(newEntity);
- document->endUndoCycle();
- }
- deleteSnapper();
- graphicView->drawEntity(newEntity);
- setStatus(SetEntity);
- }
- //reset();
- delete line;
- line = NULL;
- } else {
- RS_DEBUG->print("RS_ActionDrawLineRelAngle::trigger:"
- " Line is NULL\n");
- }
- */
+ creation.createLineRelAngle(pos, entity, angle, length);
}
-void RS_ActionDrawLineRelAngle::mouseMoveEvent(QMouseEvent * e)
+void ActionDrawLineRelAngle::mouseMoveEvent(QMouseEvent * e)
{
- RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent begin");
-
+ RS_DEBUG->print("ActionDrawLineRelAngle::mouseMoveEvent begin");
Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
switch (getStatus())
entity = catchEntity(e, RS2::ResolveAll);
break;
- case SetPos: {
- //length = graphicView->toGraphDX(graphicView->getWidth());
- //Vector mouse = snapPoint(e);
+ case SetPos:
+ {
pos = snapPoint(e);
- /*RS_Creation creation(NULL, NULL);
- RS_Line* l = creation.createLineRelAngle(mouse,
- entity,
- angle,
- length);*/
-
deletePreview();
clearPreview();
- RS_Creation creation(preview, NULL, false);
- creation.createLineRelAngle(pos,
- entity,
- angle,
- length);
+// RS_Creation creation(preview, NULL, false);
+// creation.createLineRelAngle(pos, entity, angle, length);
drawPreview();
-
- /*if (l!=NULL) {
- if (line!=NULL) {
- delete line;
- }
- line = (RS_Line*)l->clone();
-
- deletePreview();
- clearPreview();
- preview->addEntity(l);
- drawPreview();
- }*/
}
- break;
+ break;
default:
break;
}
- RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent end");
+ RS_DEBUG->print("ActionDrawLineRelAngle::mouseMoveEvent end");
}
-void RS_ActionDrawLineRelAngle::mouseReleaseEvent(QMouseEvent * e)
+void ActionDrawLineRelAngle::mouseReleaseEvent(QMouseEvent * e)
{
if (e->button() == Qt::LeftButton)
{
switch (getStatus())
{
- case SetEntity: {
+ case SetEntity:
+ {
RS_Entity * en = catchEntity(e, RS2::ResolveAll);
if (en != NULL
setStatus(SetPos);
}
}
- break;
+ break;
- case SetPos: {
+ case SetPos:
+ {
Vector ce(snapPoint(e));
coordinateEvent(&ce);
}
- break;
+ break;
default:
break;
deleteSnapper();
clearPreview();
- if (entity != NULL)
+ if (entity)
{
entity->setHighlighted(false);
graphicView->drawEntity(entity);
}
+
init(getStatus() - 1);
}
}
-void RS_ActionDrawLineRelAngle::coordinateEvent(Vector * e)
+void ActionDrawLineRelAngle::coordinateEvent(Vector * e)
{
if (e == NULL)
return;
}
}
-void RS_ActionDrawLineRelAngle::commandEvent(RS_CommandEvent * e)
+void ActionDrawLineRelAngle::commandEvent(RS_CommandEvent * e)
{
QString c = e->getCommand().toLower();
{
case SetEntity:
case SetPos:
-
if (!fixedAngle && checkCommand("angle", c))
{
deleteSnapper();
}
break;
- case SetAngle: {
+ case SetAngle:
+ {
bool ok;
double a = RS_Math::eval(c, &ok);
- if (ok == true)
+ if (ok)
angle = RS_Math::deg2rad(a);
- else if (RS_DIALOGFACTORY != NULL)
+ else if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, true, true);
+
setStatus(SetPos);
}
- break;
+ break;
- case SetLength: {
+ case SetLength:
+ {
bool ok;
double l = RS_Math::eval(c, &ok);
- if (ok == true)
+ if (ok)
length = l;
- else if (RS_DIALOGFACTORY != NULL)
+ else if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, true, true);
+
setStatus(SetPos);
}
- break;
+ break;
default:
break;
}
}
-QStringList RS_ActionDrawLineRelAngle::getAvailableCommands()
+QStringList ActionDrawLineRelAngle::getAvailableCommands()
{
QStringList cmd;
{
case SetPos:
case SetLength:
-
if (!fixedAngle)
cmd += command("angle");
cmd += command("length");
return cmd;
}
-void RS_ActionDrawLineRelAngle::updateMouseButtonHints()
+void ActionDrawLineRelAngle::updateMouseButtonHints()
{
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
{
switch (getStatus())
{
}
}
-void RS_ActionDrawLineRelAngle::showOptions()
+void ActionDrawLineRelAngle::showOptions()
{
- RS_ActionInterface::showOptions();
+ ActionInterface::showOptions();
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, true);
}
-void RS_ActionDrawLineRelAngle::hideOptions()
+void ActionDrawLineRelAngle::hideOptions()
{
- RS_ActionInterface::hideOptions();
+ ActionInterface::hideOptions();
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, false);
}
-void RS_ActionDrawLineRelAngle::updateMouseCursor()
+void ActionDrawLineRelAngle::updateMouseCursor()
{
graphicView->setMouseCursor(RS2::CadCursor);
}
-void RS_ActionDrawLineRelAngle::updateToolBar()
+void ActionDrawLineRelAngle::updateToolBar()
{
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
{
if (!isFinished())
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
}
}
-void RS_ActionDrawLineRelAngle::setAngle(double a)
+void ActionDrawLineRelAngle::setAngle(double a)
{
angle = a;
}
-double RS_ActionDrawLineRelAngle::getAngle()
+double ActionDrawLineRelAngle::getAngle()
{
return angle;
}
-void RS_ActionDrawLineRelAngle::setLength(double l)
+void ActionDrawLineRelAngle::setLength(double l)
{
length = l;
}
-double RS_ActionDrawLineRelAngle::getLength()
+double ActionDrawLineRelAngle::getLength()
{
return length;
}
-bool RS_ActionDrawLineRelAngle::hasFixedAngle()
+bool ActionDrawLineRelAngle::hasFixedAngle()
{
return fixedAngle;
}
-