-// rs_actiondrawlinetangent1.cpp
+// actiondrawlinetangent1.cpp
//
// Part of the Architektonas Project
// Originally part of QCad Community Edition by Andrew Mustun
// JLH 06/04/2010 Added this text. :-)
//
-#include "rs_actiondrawlinetangent1.h"
+#include "actiondrawlinetangent1.h"
#include "rs_creation.h"
#include "rs_dialogfactory.h"
#include "graphicview.h"
#include "rs_preview.h"
-RS_ActionDrawLineTangent1::RS_ActionDrawLineTangent1(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw Tangents 1",
+ActionDrawLineTangent1::ActionDrawLineTangent1(RS_EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw Tangents 1",
container, graphicView)
{
tangent = NULL;
circle = NULL;
}
-RS_ActionDrawLineTangent1::~RS_ActionDrawLineTangent1()
+ActionDrawLineTangent1::~ActionDrawLineTangent1()
{
}
-void RS_ActionDrawLineTangent1::trigger()
+void ActionDrawLineTangent1::trigger()
{
- RS_PreviewActionInterface::trigger();
+ ActionInterface::trigger();
- if (tangent != NULL)
+ if (tangent)
{
RS_Entity * newEntity = NULL;
newEntity = new RS_Line(container, tangent->getData());
- if (newEntity != NULL)
+ if (newEntity)
{
newEntity->setLayerToActive();
newEntity->setPenToActive();
container->addEntity(newEntity);
// upd. undo list:
- if (document != NULL)
+ if (document)
{
document->startUndoCycle();
document->addUndoable(newEntity);
tangent = NULL;
}
else
- RS_DEBUG->print("RS_ActionDrawLineTangent1::trigger:"
+ RS_DEBUG->print("ActionDrawLineTangent1::trigger:"
" Entity is NULL\n");
}
-void RS_ActionDrawLineTangent1::mouseMoveEvent(QMouseEvent * e)
+void ActionDrawLineTangent1::mouseMoveEvent(QMouseEvent * e)
{
- RS_DEBUG->print("RS_ActionDrawLineTangent1::mouseMoveEvent begin");
-
+ RS_DEBUG->print("ActionDrawLineTangent1::mouseMoveEvent begin");
Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
switch (getStatus())
point = snapPoint(e);
break;
- case SetCircle: {
+ case SetCircle:
+ {
RS_Entity * en = catchEntity(e, RS2::ResolveAll);
- if (en != NULL && (en->rtti() == RS2::EntityCircle
- || en->rtti() == RS2::EntityArc
- || en->rtti() == RS2::EntityEllipse))
+ if (en && (en->rtti() == RS2::EntityCircle
+ || en->rtti() == RS2::EntityArc
+ || en->rtti() == RS2::EntityEllipse))
{
circle = en;
-
RS_Creation creation(NULL, NULL);
- RS_Line * t = creation.createTangent1(mouse,
- point,
- circle);
+ RS_Line * t = creation.createTangent1(mouse, point, circle);
- if (t != NULL)
+ if (t)
{
- if (tangent != NULL)
+ if (tangent)
delete tangent;
+
tangent = (RS_Line *)t->clone();
deletePreview();
clearPreview();
- preview->addEntity(t);
+// preview->addEntity(t);
drawPreview();
}
}
}
- break;
+ break;
default:
break;
}
- RS_DEBUG->print("RS_ActionDrawLineTangent1::mouseMoveEvent end");
+ RS_DEBUG->print("ActionDrawLineTangent1::mouseMoveEvent end");
}
-void RS_ActionDrawLineTangent1::mouseReleaseEvent(QMouseEvent * e)
+void ActionDrawLineTangent1::mouseReleaseEvent(QMouseEvent * e)
{
if (e->button() == Qt::RightButton)
{
{
switch (getStatus())
{
- case SetPoint: {
+ case SetPoint:
+ {
Vector ce(snapPoint(e));
coordinateEvent(&ce);
}
- break;
+ break;
case SetCircle:
trigger();
}
}
-void RS_ActionDrawLineTangent1::coordinateEvent(Vector * e)
+void ActionDrawLineTangent1::coordinateEvent(Vector * e)
{
if (e == NULL)
return;
}
}
-void RS_ActionDrawLineTangent1::updateMouseButtonHints()
+void ActionDrawLineTangent1::updateMouseButtonHints()
{
if (RS_DIALOGFACTORY != NULL)
{
switch (getStatus())
{
case SetPoint:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"),
- tr("Cancel"));
+ RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Cancel"));
break;
case SetCircle:
}
}
-void RS_ActionDrawLineTangent1::updateMouseCursor()
+void ActionDrawLineTangent1::updateMouseCursor()
{
graphicView->setMouseCursor(RS2::CadCursor);
}
-void RS_ActionDrawLineTangent1::updateToolBar()
+void ActionDrawLineTangent1::updateToolBar()
{
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
{
if (!isFinished())
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
}
}
-
-// EOF