]> Shamusworld >> Repos - architektonas/blobdiff - src/actions/rs_actiondrawtext.cpp
Major refactoring of actions: Moved implementation from header files
[architektonas] / src / actions / rs_actiondrawtext.cpp
index c4f2d24fa1097479bff58b8dea8a7f5039f1e03f..55b9ae64587c2760e3763b2523013e46fc3152c2 100644 (file)
 
 #include "rs_actiondrawtext.h"
 
+#include "rs_dialogfactory.h"
 #include "rs_graphicview.h"
-#include "rs_snapper.h"
+#include "rs_preview.h"
 
-RS_ActionDrawText::RS_ActionDrawText(RS_EntityContainer & container,
-       RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Text", container, graphicView)
+RS_ActionDrawText::RS_ActionDrawText(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw Text", container, graphicView)
 {
        pos = Vector(false);
        textChanged = true;
@@ -68,7 +68,7 @@ void RS_ActionDrawText::init(int status)
 
                graphicView->redraw();
        }
-               break;
+       break;
 
        case SetPos:
                RS_DIALOGFACTORY->requestOptions(this, true, true);
@@ -81,9 +81,9 @@ void RS_ActionDrawText::init(int status)
 
 void RS_ActionDrawText::reset()
 {
-    data = RS_TextData(Vector(0.0, 0.0), 1.0, 100.0, RS2::VAlignTop,
-               RS2::HAlignLeft, RS2::LeftToRight, RS2::Exact, 1.0, data.text,
-               "standard", 0.0, RS2::Update);
+       data = RS_TextData(Vector(0.0, 0.0), 1.0, 100.0, RS2::VAlignTop,
+                       RS2::HAlignLeft, RS2::LeftToRight, RS2::Exact, 1.0, data.text,
+                       "standard", 0.0, RS2::Update);
 }
 
 void RS_ActionDrawText::trigger()
@@ -158,7 +158,7 @@ void RS_ActionDrawText::mouseReleaseEvent(QMouseEvent * e)
 {
        if (e->button() == Qt::LeftButton)
        {
-               RS_CoordinateEvent ce(snapPoint(e));
+               Vector ce(snapPoint(e));
                coordinateEvent(&ce);
        }
        else if (e->button() == Qt::RightButton)
@@ -176,12 +176,12 @@ void RS_ActionDrawText::mouseReleaseEvent(QMouseEvent * e)
        }
 }
 
-void RS_ActionDrawText::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDrawText::coordinateEvent(Vector * e)
 {
        if (e == NULL)
                return;
 
-       Vector mouse = e->getCoordinate();
+       Vector mouse = *e;
 
        switch (getStatus())
        {
@@ -205,16 +205,15 @@ void RS_ActionDrawText::commandEvent(RS_CommandEvent * e)
        if (checkCommand("help", c))
        {
                if (RS_DIALOGFACTORY != NULL)
-               {
                        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
                                + getAvailableCommands().join(", "));
-               }
                return;
        }
 
        switch (getStatus())
        {
        case SetPos:
+
                if (checkCommand("text", c))
                {
                        deleteSnapper();
@@ -277,9 +276,11 @@ void RS_ActionDrawText::updateMouseButtonHints()
        case SetPos:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Specify insertion point"), tr("Cancel"));
                break;
+
        case SetText:
                RS_DIALOGFACTORY->updateMouseWidget(tr("Enter text:"), tr("Back"));
                break;
+
        default:
                RS_DIALOGFACTORY->updateMouseWidget("", "");
                break;
@@ -288,12 +289,12 @@ void RS_ActionDrawText::updateMouseButtonHints()
 
 void RS_ActionDrawText::updateMouseCursor()
 {
-    graphicView->setMouseCursor(RS2::CadCursor);
+       graphicView->setMouseCursor(RS2::CadCursor);
 }
 
 void RS_ActionDrawText::updateToolBar()
 {
-    if (RS_DIALOGFACTORY == NULL)
+       if (RS_DIALOGFACTORY == NULL)
                return;
 
        switch (getStatus())
@@ -301,6 +302,7 @@ void RS_ActionDrawText::updateToolBar()
        case SetPos:
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
                break;
+
        default:
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
                break;
@@ -309,22 +311,23 @@ void RS_ActionDrawText::updateToolBar()
 
 void RS_ActionDrawText::setText(const QString & t)
 {
-    data.text = t;
-    textChanged = true;
+       data.text = t;
+       textChanged = true;
 }
 
 QString RS_ActionDrawText::getText()
 {
-    return data.text;
+       return data.text;
 }
 
 void RS_ActionDrawText::setAngle(double a)
 {
-    data.angle = a;
-    textChanged = true;
+       data.angle = a;
+       textChanged = true;
 }
 
 double RS_ActionDrawText::getAngle()
 {
-    return data.angle;
+       return data.angle;
 }
+