X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fwidgets%2Fqg_actionhandler.cpp;h=2ddc8eba284c1e3fb8c05b7391e62746707664d2;hb=c715d05d11ffe2913fe3465ec43d456ee9b85964;hp=11d4b3f3440cc8799327ce12f631c406483a033e;hpb=16ce54abf01ca3032e42a5bb11a4afcf9014dcca;p=architektonas diff --git a/src/widgets/qg_actionhandler.cpp b/src/widgets/qg_actionhandler.cpp index 11d4b3f..2ddc8eb 100644 --- a/src/widgets/qg_actionhandler.cpp +++ b/src/widgets/qg_actionhandler.cpp @@ -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,19 +185,19 @@ void QG_ActionHandler::killSelectActions() */ RS_ActionInterface * QG_ActionHandler::getCurrentAction() { - RS_GraphicView * gv = mainWindow->getGraphicView(); + GraphicView * gv = mainWindow->getGraphicView(); - if (gv != NULL) + if (gv) return gv->getCurrentAction(); - else - return NULL; + + return NULL; } #if 0 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; @@ -214,6 +216,12 @@ Then you'd call it with: Hmmm.... We need gv & doc *before* we call this... +What you'd do then is have the form of the thing worked ahead of time and the function +itself would create the gv & doc. So for the EditUndo, we'd have: + FunctionCreateAction(bool); + FunctionCreateAction(void); + +Well... The problem is the action, they're all different... #endif /** @@ -225,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; @@ -487,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); @@ -770,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"); @@ -785,7 +793,7 @@ QStringList QG_ActionHandler::getAvailableCommands() { RS_ActionInterface * currentAction = getCurrentAction(); - if (currentAction != NULL) + if (currentAction) return currentAction->getAvailableCommands(); else { @@ -810,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); //} @@ -891,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"); @@ -903,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); @@ -1410,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); } @@ -1423,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); } @@ -1436,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); } @@ -1463,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); } @@ -1478,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); } @@ -1493,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); } @@ -1508,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); } @@ -1522,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); @@ -1533,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); } @@ -1581,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); } @@ -1594,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); } @@ -1607,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 } /** @@ -1640,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()); } @@ -1679,7 +1696,7 @@ void QG_ActionHandler::slotSetRelativeZero() void QG_ActionHandler::slotLockRelativeZero(bool on) { - if (lockRelativeZero != NULL) + if (lockRelativeZero) lockRelativeZero->setChecked(on); if (on) @@ -1687,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() @@ -1830,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(); //}