#include "qg_actionhandler.h"
+#include "rs_commandevent.h"
#include "commands.h"
#include "rs_actionblocksadd.h"
#include "rs_actionblocksattributes.h"
#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"
*/
void QG_ActionHandler::killSelectActions()
{
- RS_GraphicView * gv = mainWindow->getGraphicView();
+ GraphicView * gv = mainWindow->getGraphicView();
- if (gv != NULL)
+ if (gv)
gv->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:
return NULL;
}
- if (action != NULL)
+ if (action)
gv->setCurrentAction(action);
return action;
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
/**
{
RS_DEBUG->print("QG_ActionHandler::setCurrentAction()");
- RS_GraphicView * gv = mainWindow->getGraphicView();
+ GraphicView * gv = mainWindow->getGraphicView();
RS_Document * doc = mainWindow->getDocument();
RS_ActionInterface * a = NULL;
break;
}
- if (a != NULL)
+ if (a)
gv->setCurrentAction(a);
RS_DEBUG->print("QG_ActionHandler::setCurrentAction(): OK");
{
RS_ActionInterface * currentAction = getCurrentAction();
- if (currentAction != NULL)
+ if (currentAction)
return currentAction->getAvailableCommands();
else
{
// 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);
//}
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");
// 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);
{
disableSnaps();
- if (snapFree != NULL)
+ if (snapFree)
snapFree->setChecked(true);
-
- if (cadToolBarSnap != NULL)
+#if 0
+ if (cadToolBarSnap)
cadToolBarSnap->setSnapMode(RS2::SnapFree);
-
+#endif
setCurrentAction(RS2::ActionSnapFree);
}
{
disableSnaps();
- if (snapGrid != NULL)
+ if (snapGrid)
snapGrid->setChecked(true);
- if (cadToolBarSnap != NULL)
+#if 0
+ if (cadToolBarSnap)
cadToolBarSnap->setSnapMode(RS2::SnapGrid);
-
+#endif
setCurrentAction(RS2::ActionSnapGrid);
}
{
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);
}
{
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);
}
{
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);
}
{
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);
}
{
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);
}
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);
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);
}
{
disableRestrictions();
- if (restrictOrthogonal != NULL)
+ if (restrictOrthogonal)
restrictOrthogonal->setChecked(true);
- if (cadToolBarSnap != NULL)
+#if 0
+ if (cadToolBarSnap)
cadToolBarSnap->setSnapRestriction(RS2::RestrictOrthogonal);
-
+#endif
setCurrentAction(RS2::ActionRestrictOrthogonal);
}
{
disableRestrictions();
- if (restrictHorizontal != NULL)
+ if (restrictHorizontal)
restrictHorizontal->setChecked(true);
- if (cadToolBarSnap != NULL)
+#if 0
+ if (cadToolBarSnap)
cadToolBarSnap->setSnapRestriction(RS2::RestrictHorizontal);
+#endif
setCurrentAction(RS2::ActionRestrictHorizontal);
}
{
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
}
/**
*/
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());
}
void QG_ActionHandler::slotLockRelativeZero(bool on)
{
- if (lockRelativeZero != NULL)
+ if (lockRelativeZero)
lockRelativeZero->setChecked(on);
if (on)
else
setCurrentAction(RS2::ActionUnlockRelativeZero);
- if (cadToolBarSnap != NULL)
+#if 0
+ if (cadToolBarSnap)
cadToolBarSnap->setLockRelativeZero(on);
+#endif
}
void QG_ActionHandler::slotInfoInside()
void QG_ActionHandler::slotFocusNormal()
{
//QG_GraphicView* gv = mainWindow->getGraphicView();
- //if (gv!=NULL) {
+ //if (gv) {
//gv->setFocus();
mainWindow->setFocus2();
//}