]> Shamusworld >> Repos - architektonas/blobdiff - src/widgets/qg_actionhandler.cpp
Fixed preview rendering for ActionDrawLine...
[architektonas] / src / widgets / qg_actionhandler.cpp
index 5e8627942363e2ff1b1bd4eab3e977331d3265a0..2ddc8eba284c1e3fb8c05b7391e62746707664d2 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "qg_actionhandler.h"
 
+#include "rs_commandevent.h"
 #include "commands.h"
 #include "rs_actionblocksadd.h"
 #include "rs_actionblocksattributes.h"
@@ -67,6 +68,7 @@
 #include "rs_actioninfodist2.h"
 #include "rs_actioninfoinside.h"
 #include "rs_actioninfototallength.h"
+#include "rs_actioninterface.h"
 #include "rs_actionlayersadd.h"
 #include "rs_actionlayersedit.h"
 #include "rs_actionlayersfreezeall.h"
@@ -172,9 +174,9 @@ QG_ActionHandler::~QG_ActionHandler()
  */
 void QG_ActionHandler::killSelectActions()
 {
-       RS_GraphicView * gv = mainWindow->getGraphicView();
+       GraphicView * gv = mainWindow->getGraphicView();
 
-       if (gv != NULL)
+       if (gv)
                gv->killSelectActions();
 }
 
@@ -183,7 +185,7 @@ void QG_ActionHandler::killSelectActions()
  */
 RS_ActionInterface * QG_ActionHandler::getCurrentAction()
 {
-       RS_GraphicView * gv = mainWindow->getGraphicView();
+       GraphicView * gv = mainWindow->getGraphicView();
 
        if (gv)
                return gv->getCurrentAction();
@@ -195,7 +197,7 @@ RS_ActionInterface * QG_ActionHandler::getCurrentAction()
 Instead of the following giant switch statement, you could something like the following:
 RS_ActionInterface * QG_ActionHandler::setCurrentAction(RS_ActionInterface * action)
 {
-       RS_GraphicView * gv = mainWindow->getGraphicView();
+       GraphicView * gv = mainWindow->getGraphicView();
        RS_Document * doc = mainWindow->getDocument();
 
        // only global options are allowed without a document:
@@ -204,7 +206,7 @@ RS_ActionInterface * QG_ActionHandler::setCurrentAction(RS_ActionInterface * act
                return NULL;
        }
 
-       if (action != NULL)
+       if (action)
                gv->setCurrentAction(action);
 
        return action;
@@ -231,7 +233,7 @@ RS_ActionInterface * QG_ActionHandler::setCurrentAction(RS2::ActionType id)
 {
        RS_DEBUG->print("QG_ActionHandler::setCurrentAction()");
 
-       RS_GraphicView * gv = mainWindow->getGraphicView();
+       GraphicView * gv = mainWindow->getGraphicView();
        RS_Document * doc = mainWindow->getDocument();
        RS_ActionInterface * a = NULL;
 
@@ -493,7 +495,7 @@ RS_ActionInterface * QG_ActionHandler::setCurrentAction(RS2::ActionType id)
                a = new RS_ActionDimLinear(*doc, *gv, 0.0, true);
                break;
        case RS2::ActionDimLinearVer:
-               a = new RS_ActionDimLinear(*doc, *gv, M_PI/2.0, true);
+               a = new RS_ActionDimLinear(*doc, *gv, M_PI / 2.0, true);
                break;
        case RS2::ActionDimRadial:
                a = new RS_ActionDimRadial(*doc, *gv);
@@ -776,7 +778,7 @@ RS_ActionInterface * QG_ActionHandler::setCurrentAction(RS2::ActionType id)
                break;
        }
 
-       if (a != NULL)
+       if (a)
                gv->setCurrentAction(a);
 
        RS_DEBUG->print("QG_ActionHandler::setCurrentAction(): OK");
@@ -791,7 +793,7 @@ QStringList QG_ActionHandler::getAvailableCommands()
 {
        RS_ActionInterface * currentAction = getCurrentAction();
 
-       if (currentAction != NULL)
+       if (currentAction)
                return currentAction->getAvailableCommands();
        else
        {
@@ -816,8 +818,8 @@ bool QG_ActionHandler::keycode(const QString & code)
        // pass keycode on to running action:
        //RS_keycodeEvent e(cmd);
 
-       //RS_GraphicView* gv = mainWindow->getGraphicView();
-       //if (gv!=NULL) {
+       //GraphicView* gv = mainWindow->getGraphicView();
+       //if (gv) {
        //    gv->keycodeEvent(&e);
        //}
 
@@ -897,9 +899,9 @@ bool QG_ActionHandler::command(const QString & cmd)
 
        if (c == "\n")
        {
-               RS_GraphicView * gv = mainWindow->getGraphicView();
+               GraphicView * gv = mainWindow->getGraphicView();
 
-               if (gv != NULL)
+               if (gv)
                        gv->back();
 
                RS_DEBUG->print("QG_ActionHandler::command: back");
@@ -909,9 +911,9 @@ bool QG_ActionHandler::command(const QString & cmd)
        // pass command on to running action:
        RS_CommandEvent e(cmd);
 
-       RS_GraphicView * gv = mainWindow->getGraphicView();
+       GraphicView * gv = mainWindow->getGraphicView();
 
-       if (gv != NULL)
+       if (gv)
        {
                RS_DEBUG->print("QG_ActionHandler::command: trigger command event in graphic view");
                gv->commandEvent(&e);
@@ -1416,12 +1418,12 @@ void QG_ActionHandler::slotSnapFree()
 {
        disableSnaps();
 
-       if (snapFree != NULL)
+       if (snapFree)
                snapFree->setChecked(true);
-
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapMode(RS2::SnapFree);
-
+#endif
        setCurrentAction(RS2::ActionSnapFree);
 }
 
@@ -1429,12 +1431,13 @@ void QG_ActionHandler::slotSnapGrid()
 {
        disableSnaps();
 
-       if (snapGrid != NULL)
+       if (snapGrid)
                snapGrid->setChecked(true);
 
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapMode(RS2::SnapGrid);
-
+#endif
        setCurrentAction(RS2::ActionSnapGrid);
 }
 
@@ -1442,26 +1445,25 @@ void QG_ActionHandler::slotSnapEndpoint()
 {
        disableSnaps();
 
-       if (snapEndpoint != NULL)
+       if (snapEndpoint)
                snapEndpoint->setChecked(true);
 
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapMode(RS2::SnapEndpoint);
-
+#endif
        setCurrentAction(RS2::ActionSnapEndpoint);
 }
 
 void QG_ActionHandler::slotSnapOnEntity()
 {
        disableSnaps();
-       if (snapOnEntity!=NULL) {
+       if (snapOnEntity)
                snapOnEntity->setChecked(true);
-       }
-//#if QT_VERSION>=0x030000
-       if (cadToolBarSnap!=NULL) {
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapMode(RS2::SnapOnEntity);
-       }
-//#endif
+#endif
        setCurrentAction(RS2::ActionSnapOnEntity);
 }
 
@@ -1469,13 +1471,13 @@ void QG_ActionHandler::slotSnapCenter()
 {
        disableSnaps();
 
-       if (snapCenter != NULL)
+       if (snapCenter)
                snapCenter->setChecked(true);
 
-//#if QT_VERSION>=0x030000
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapMode(RS2::SnapCenter);
-//#endif
+#endif
 
        setCurrentAction(RS2::ActionSnapCenter);
 }
@@ -1484,13 +1486,13 @@ void QG_ActionHandler::slotSnapMiddle()
 {
        disableSnaps();
 
-       if (snapMiddle != NULL)
+       if (snapMiddle)
                snapMiddle->setChecked(true);
 
-//#if QT_VERSION>=0x030000
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapMode(RS2::SnapMiddle);
-//#endif
+#endif
 
        setCurrentAction(RS2::ActionSnapMiddle);
 }
@@ -1499,13 +1501,13 @@ void QG_ActionHandler::slotSnapDist()
 {
        disableSnaps();
 
-       if (snapDist != NULL)
+       if (snapDist)
                snapDist->setChecked(true);
 
-//#if QT_VERSION>=0x030000
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapMode(RS2::SnapDist);
-//#endif
+#endif
 
        setCurrentAction(RS2::ActionSnapDist);
 }
@@ -1514,13 +1516,13 @@ void QG_ActionHandler::slotSnapIntersection()
 {
        disableSnaps();
 
-       if (snapIntersection != NULL)
+       if (snapIntersection)
                snapIntersection->setChecked(true);
 
-//#if QT_VERSION>=0x030000
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapMode(RS2::SnapIntersection);
-//#endif
+#endif
 
        setCurrentAction(RS2::ActionSnapIntersection);
 }
@@ -1528,10 +1530,10 @@ void QG_ActionHandler::slotSnapIntersection()
 void QG_ActionHandler::slotSnapIntersectionManual()
 {
        //disableSnaps();
-       /*if (snapIntersectionManual!=NULL) {
+       /*if (snapIntersectionManual) {
                snapIntersectionManual->setChecked(true);
 }*/
-       /*if (cadToolBarSnap!=NULL) {
+       /*if (cadToolBarSnap) {
                cadToolBarSnap->setSnapMode(RS2::SnapIntersectionManual);
 }*/
        setCurrentAction(RS2::ActionSnapIntersectionManual);
@@ -1539,47 +1541,50 @@ void QG_ActionHandler::slotSnapIntersectionManual()
 
 void QG_ActionHandler::disableSnaps()
 {
-       if (snapFree != NULL)
+       if (snapFree)
                snapFree->setChecked(false);
 
-       if (snapGrid != NULL)
+       if (snapGrid)
                snapGrid->setChecked(false);
 
-       if (snapEndpoint != NULL)
+       if (snapEndpoint)
                snapEndpoint->setChecked(false);
 
-       if (snapOnEntity != NULL)
+       if (snapOnEntity)
                snapOnEntity->setChecked(false);
 
-       if (snapCenter != NULL)
+       if (snapCenter)
                snapCenter->setChecked(false);
 
-       if (snapMiddle != NULL)
+       if (snapMiddle)
                snapMiddle->setChecked(false);
 
-       if (snapDist != NULL)
+       if (snapDist)
                snapDist->setChecked(false);
 
-       if (snapIntersection != NULL)
+       if (snapIntersection)
                snapIntersection->setChecked(false);
 
-       if (snapIntersectionManual != NULL)
+       if (snapIntersectionManual)
                snapIntersectionManual->setChecked(false);
 
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->disableSnaps();
+#endif
 }
 
 void QG_ActionHandler::slotRestrictNothing()
 {
        disableRestrictions();
 
-       if (restrictNothing != NULL)
+       if (restrictNothing)
                restrictNothing->setChecked(true);
 
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapRestriction(RS2::RestrictNothing);
-
+#endif
        setCurrentAction(RS2::ActionRestrictNothing);
 }
 
@@ -1587,12 +1592,13 @@ void QG_ActionHandler::slotRestrictOrthogonal()
 {
        disableRestrictions();
 
-       if (restrictOrthogonal != NULL)
+       if (restrictOrthogonal)
                restrictOrthogonal->setChecked(true);
 
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapRestriction(RS2::RestrictOrthogonal);
-
+#endif
        setCurrentAction(RS2::ActionRestrictOrthogonal);
 }
 
@@ -1600,11 +1606,13 @@ void QG_ActionHandler::slotRestrictHorizontal()
 {
        disableRestrictions();
 
-       if (restrictHorizontal != NULL)
+       if (restrictHorizontal)
                restrictHorizontal->setChecked(true);
 
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapRestriction(RS2::RestrictHorizontal);
+#endif
 
        setCurrentAction(RS2::ActionRestrictHorizontal);
 }
@@ -1613,31 +1621,34 @@ void QG_ActionHandler::slotRestrictVertical()
 {
        disableRestrictions();
 
-       if (restrictVertical != NULL)
+       if (restrictVertical)
                restrictVertical->setChecked(true);
 
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setSnapRestriction(RS2::RestrictVertical);
-
+#endif
        setCurrentAction(RS2::ActionRestrictVertical);
 }
 
 void QG_ActionHandler::disableRestrictions()
 {
-       if (restrictNothing != NULL)
+       if (restrictNothing)
                restrictNothing->setChecked(false);
 
-       if (restrictOrthogonal != NULL)
+       if (restrictOrthogonal)
                restrictOrthogonal->setChecked(false);
 
-       if (restrictHorizontal != NULL)
+       if (restrictHorizontal)
                restrictHorizontal->setChecked(false);
 
-       if (restrictVertical != NULL)
+       if (restrictVertical)
                restrictVertical->setChecked(false);
 
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->disableRestrictions();
+#endif
 }
 
 /**
@@ -1646,35 +1657,35 @@ void QG_ActionHandler::disableRestrictions()
  */
 void QG_ActionHandler::updateSnapMode()
 {
-       if (snapFree != NULL && snapFree->isChecked())
+       if (snapFree && snapFree->isChecked())
                slotSnapFree();
-       else if (snapGrid != NULL && snapGrid->isChecked())
+       else if (snapGrid && snapGrid->isChecked())
                slotSnapGrid();
-       else if (snapEndpoint != NULL && snapEndpoint->isChecked())
+       else if (snapEndpoint && snapEndpoint->isChecked())
                slotSnapEndpoint();
-       else if (snapOnEntity != NULL && snapOnEntity->isChecked())
+       else if (snapOnEntity && snapOnEntity->isChecked())
                slotSnapOnEntity();
-       else if (snapCenter != NULL && snapCenter->isChecked())
+       else if (snapCenter && snapCenter->isChecked())
                slotSnapCenter();
-       else if (snapMiddle != NULL && snapMiddle->isChecked())
+       else if (snapMiddle && snapMiddle->isChecked())
                slotSnapMiddle();
-       else if (snapDist != NULL && snapDist->isChecked())
+       else if (snapDist && snapDist->isChecked())
                slotSnapDist();
-       else if (snapIntersection != NULL && snapIntersection->isChecked())
+       else if (snapIntersection && snapIntersection->isChecked())
                slotSnapIntersection();
 
        // snap restricitons:
-       if (restrictNothing != NULL && restrictNothing->isChecked())
+       if (restrictNothing && restrictNothing->isChecked())
                slotRestrictNothing();
-       else if (restrictOrthogonal != NULL && restrictOrthogonal->isChecked())
+       else if (restrictOrthogonal && restrictOrthogonal->isChecked())
                slotRestrictOrthogonal();
-       else if (restrictHorizontal != NULL && restrictHorizontal->isChecked())
+       else if (restrictHorizontal && restrictHorizontal->isChecked())
                slotRestrictHorizontal();
-       else if (restrictVertical != NULL && restrictVertical->isChecked())
+       else if (restrictVertical && restrictVertical->isChecked())
                slotRestrictVertical();
 
        // lock of relative zero:
-       if (lockRelativeZero != NULL)
+       if (lockRelativeZero)
                slotLockRelativeZero(lockRelativeZero->isChecked());
 }
 
@@ -1685,7 +1696,7 @@ void QG_ActionHandler::slotSetRelativeZero()
 
 void QG_ActionHandler::slotLockRelativeZero(bool on)
 {
-       if (lockRelativeZero != NULL)
+       if (lockRelativeZero)
                lockRelativeZero->setChecked(on);
 
        if (on)
@@ -1693,8 +1704,10 @@ void QG_ActionHandler::slotLockRelativeZero(bool on)
        else
                setCurrentAction(RS2::ActionUnlockRelativeZero);
 
-       if (cadToolBarSnap != NULL)
+#if 0
+       if (cadToolBarSnap)
                cadToolBarSnap->setLockRelativeZero(on);
+#endif
 }
 
 void QG_ActionHandler::slotInfoInside()
@@ -1836,7 +1849,7 @@ void QG_ActionHandler::slotCamReorder()
 void QG_ActionHandler::slotFocusNormal()
 {
        //QG_GraphicView* gv = mainWindow->getGraphicView();
-       //if (gv!=NULL) {
+       //if (gv) {
                //gv->setFocus();
        mainWindow->setFocus2();
        //}