/**
* Constructor.
*/
-RS_EventHandler::RS_EventHandler(GraphicView * graphicView)
+EventHandler::EventHandler(GraphicView * graphicView)
{
this->graphicView = graphicView;
actionIndex = -1;
/**
* Destructor.
*/
-RS_EventHandler::~RS_EventHandler()
+EventHandler::~EventHandler()
{
- RS_DEBUG->print("RS_EventHandler::~RS_EventHandler");
+ DEBUG->print("EventHandler::~EventHandler");
if (defaultAction != NULL)
{
killAllActions();
- RS_DEBUG->print("RS_EventHandler::~RS_EventHandler: Deleting all actions..");
+ DEBUG->print("EventHandler::~EventHandler: Deleting all actions..");
for(int i=0; i<RS_MAXACTIONS; ++i)
{
}
cleanUp();
- RS_DEBUG->print("RS_EventHandler::~RS_EventHandler: Deleting all actions..: OK");
- RS_DEBUG->print("RS_EventHandler::~RS_EventHandler: OK");
+ DEBUG->print("EventHandler::~EventHandler: Deleting all actions..: OK");
+ DEBUG->print("EventHandler::~EventHandler: OK");
}
/**
* Go back in current action.
*/
-void RS_EventHandler::back()
+void EventHandler::back()
{
QMouseEvent e(QEvent::MouseButtonRelease, QPoint(0, 0), Qt::RightButton, Qt::RightButton,
Qt::NoModifier);
/**
* Go enter pressed event for current action.
*/
-void RS_EventHandler::enter()
+void EventHandler::enter()
{
// QKeyEvent e(QEvent::KeyPress, Qt::Key_Enter, '\n', 0);
QKeyEvent e(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier, "\n", false, 0);
/**
* Called by GraphicView
*/
-void RS_EventHandler::mousePressEvent(QMouseEvent * e)
+void EventHandler::mousePressEvent(QMouseEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex] != NULL)
{
}
else
{
- RS_DEBUG->print("currently no action defined");
+ DEBUG->print("currently no action defined");
e->ignore();
}
}
/**
* Called by GraphicView
*/
-void RS_EventHandler::mouseReleaseEvent(QMouseEvent * e)
+void EventHandler::mouseReleaseEvent(QMouseEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex] != NULL
&& !currentActions[actionIndex]->isFinished())
{
- RS_DEBUG->print("call action %s", currentActions[actionIndex]->getName().toLatin1().data());
+ DEBUG->print("call action %s", currentActions[actionIndex]->getName().toLatin1().data());
currentActions[actionIndex]->mouseReleaseEvent(e);
// Clean up actions - one might be finished now
/**
* Called by GraphicView
*/
-void RS_EventHandler::mouseMoveEvent(QMouseEvent * e)
+void EventHandler::mouseMoveEvent(QMouseEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
}
else
e->ignore();
- //RS_DEBUG->print("currently no action defined");
+ //DEBUG->print("currently no action defined");
}
}
/**
* Called by GraphicView
*/
-void RS_EventHandler::mouseLeaveEvent()
+void EventHandler::mouseLeaveEvent()
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
{
if (defaultAction)
defaultAction->suspend();
- //RS_DEBUG->print("currently no action defined");
+ //DEBUG->print("currently no action defined");
}
}
/**
* Called by GraphicView
*/
-void RS_EventHandler::mouseEnterEvent()
+void EventHandler::mouseEnterEvent()
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
/**
* Called by GraphicView
*/
-void RS_EventHandler::keyPressEvent(QKeyEvent * e)
+void EventHandler::keyPressEvent(QKeyEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
else
e->ignore();
- //RS_DEBUG->print("currently no action defined");
+ //DEBUG->print("currently no action defined");
}
}
/**
* Called by GraphicView
*/
-void RS_EventHandler::keyReleaseEvent(QKeyEvent * e)
+void EventHandler::keyReleaseEvent(QKeyEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
else
e->ignore();
- //RS_DEBUG->print("currently no action defined");
+ //DEBUG->print("currently no action defined");
}
}
/**
* Handles command line events.
*/
-void RS_EventHandler::commandEvent(RS_CommandEvent * e)
+void EventHandler::commandEvent(CommandEvent * e)
{
- RS_DEBUG->print("RS_EventHandler::commandEvent");
+ DEBUG->print("EventHandler::commandEvent");
QString cmd = e->getCommand();
if (coordinateInputEnabled)
&& !currentActions[actionIndex]->isFinished())
{
int commaPos = cmd.indexOf(',');
- RS_DEBUG->print("RS_EventHandler::commandEvent: 001");
+ DEBUG->print("EventHandler::commandEvent: 001");
bool ok1, ok2;
- RS_DEBUG->print("RS_EventHandler::commandEvent: 002");
- double x = RS_Math::eval(cmd.left(commaPos), &ok1);
- RS_DEBUG->print("RS_EventHandler::commandEvent: 003a");
- double y = RS_Math::eval(cmd.mid(commaPos + 1), &ok2);
- RS_DEBUG->print("RS_EventHandler::commandEvent: 004");
+ DEBUG->print("EventHandler::commandEvent: 002");
+ double x = Math::eval(cmd.left(commaPos), &ok1);
+ DEBUG->print("EventHandler::commandEvent: 003a");
+ double y = Math::eval(cmd.mid(commaPos + 1), &ok2);
+ DEBUG->print("EventHandler::commandEvent: 004");
if (ok1 && ok2)
{
-// RS_DEBUG->print("RS_EventHandler::commandEvent: 005");
-// RS_CoordinateEvent ce(Vector(x, y));
- RS_DEBUG->print("RS_EventHandler::commandEvent: 006");
+// DEBUG->print("EventHandler::commandEvent: 005");
+// CoordinateEvent ce(Vector(x, y));
+ DEBUG->print("EventHandler::commandEvent: 006");
// currentActions[actionIndex]->coordinateEvent(&ce);
Vector ce(x, y);
currentActions[actionIndex]->coordinateEvent(&ce);
}
else
{
- if (RS_DIALOGFACTORY != NULL)
- RS_DIALOGFACTORY->commandMessage("Expression Syntax Error");
+ if (DIALOGFACTORY != NULL)
+ DIALOGFACTORY->commandMessage("Expression Syntax Error");
}
e->accept();
{
int commaPos = cmd.indexOf(',');
bool ok1, ok2;
- double x = RS_Math::eval(cmd.mid(1, commaPos - 1), &ok1);
- double y = RS_Math::eval(cmd.mid(commaPos + 1), &ok2);
+ double x = Math::eval(cmd.mid(1, commaPos - 1), &ok1);
+ double y = Math::eval(cmd.mid(commaPos + 1), &ok2);
if (ok1 && ok2)
{
-// RS_CoordinateEvent ce(Vector(x,y) + graphicView->getRelativeZero());
+// CoordinateEvent ce(Vector(x,y) + graphicView->getRelativeZero());
// currentActions[actionIndex]->coordinateEvent(&ce);
Vector ce(Vector(x,y) + graphicView->getRelativeZero());
currentActions[actionIndex]->coordinateEvent(&ce);
}
else
{
- if (RS_DIALOGFACTORY != NULL)
- RS_DIALOGFACTORY->commandMessage("Expression Syntax Error");
+ if (DIALOGFACTORY != NULL)
+ DIALOGFACTORY->commandMessage("Expression Syntax Error");
}
e->accept();
{
int commaPos = cmd.indexOf('<');
bool ok1, ok2;
- double r = RS_Math::eval(cmd.left(commaPos), &ok1);
- double a = RS_Math::eval(cmd.mid(commaPos + 1), &ok2);
+ double r = Math::eval(cmd.left(commaPos), &ok1);
+ double a = Math::eval(cmd.mid(commaPos + 1), &ok2);
if (ok1 && ok2)
{
Vector pos;
- pos.setPolar(r,RS_Math::deg2rad(a));
-// RS_CoordinateEvent ce(pos);
+ pos.setPolar(r,Math::deg2rad(a));
+// CoordinateEvent ce(pos);
// currentActions[actionIndex]->coordinateEvent(&ce);
currentActions[actionIndex]->coordinateEvent(&pos);
}
else
{
- if (RS_DIALOGFACTORY != NULL)
- RS_DIALOGFACTORY->commandMessage("Expression Syntax Error");
+ if (DIALOGFACTORY != NULL)
+ DIALOGFACTORY->commandMessage("Expression Syntax Error");
}
e->accept();
// int commaPos = cmd.find('<');
int commaPos = cmd.indexOf('<');
bool ok1, ok2;
- double r = RS_Math::eval(cmd.mid(1, commaPos - 1), &ok1);
- double a = RS_Math::eval(cmd.mid(commaPos + 1), &ok2);
+ double r = Math::eval(cmd.mid(1, commaPos - 1), &ok1);
+ double a = Math::eval(cmd.mid(commaPos + 1), &ok2);
if (ok1 && ok2)
{
Vector pos;
- pos.setPolar(r,RS_Math::deg2rad(a));
-// RS_CoordinateEvent ce(pos + graphicView->getRelativeZero());
+ pos.setPolar(r,Math::deg2rad(a));
+// CoordinateEvent ce(pos + graphicView->getRelativeZero());
// currentActions[actionIndex]->coordinateEvent(&ce);
Vector ce(pos + graphicView->getRelativeZero());
currentActions[actionIndex]->coordinateEvent(&ce);
}
else
{
- if (RS_DIALOGFACTORY)
- RS_DIALOGFACTORY->commandMessage("Expression Syntax Error");
+ if (DIALOGFACTORY)
+ DIALOGFACTORY->commandMessage("Expression Syntax Error");
}
e->accept();
}
}
- RS_DEBUG->print("RS_EventHandler::commandEvent: OK");
+ DEBUG->print("EventHandler::commandEvent: OK");
}
/**
* Enables coordinate input in the command line.
*/
-void RS_EventHandler::enableCoordinateInput()
+void EventHandler::enableCoordinateInput()
{
coordinateInputEnabled = true;
}
/**
* Enables coordinate input in the command line.
*/
-void RS_EventHandler::disableCoordinateInput()
+void EventHandler::disableCoordinateInput()
{
coordinateInputEnabled = false;
}
/**
* @return Current action.
*/
-ActionInterface * RS_EventHandler::getCurrentAction()
+ActionInterface * EventHandler::getCurrentAction()
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
/**
* @return The current default action.
*/
-ActionInterface * RS_EventHandler::getDefaultAction()
+ActionInterface * EventHandler::getDefaultAction()
{
return defaultAction;
}
/**
* Sets the default action.
*/
-void RS_EventHandler::setDefaultAction(ActionInterface * action)
+void EventHandler::setDefaultAction(ActionInterface * action)
{
if (defaultAction)
{
/**
* Sets the current action.
*/
-void RS_EventHandler::setCurrentAction(ActionInterface * action)
+void EventHandler::setCurrentAction(ActionInterface * action)
{
- RS_DEBUG->print("RS_EventHandler::setCurrentAction");
+ DEBUG->print("EventHandler::setCurrentAction");
if (!action)
return;
// Set current action:
currentActions[actionIndex] = action;
- RS_DEBUG->print("RS_EventHandler::setCurrentAction: current action is: %s",
+ DEBUG->print("EventHandler::setCurrentAction: current action is: %s",
currentActions[actionIndex]->getName().toLatin1().data());
// Initialisation of our new action:
- RS_DEBUG->print("RS_EventHandler::setCurrentAction: init current action");
+ DEBUG->print("EventHandler::setCurrentAction: init current action");
action->init();
// ## new:
if (action->isFinished() == false)
{
- RS_DEBUG->print("RS_EventHandler::setCurrentAction: show options");
+ DEBUG->print("EventHandler::setCurrentAction: show options");
currentActions[actionIndex]->showOptions();
- RS_DEBUG->print("RS_EventHandler::setCurrentAction: set predecessor");
+ DEBUG->print("EventHandler::setCurrentAction: set predecessor");
action->setPredecessor(predecessor);
}
- RS_DEBUG->print("RS_EventHandler::setCurrentAction: cleaning up..");
+ DEBUG->print("EventHandler::setCurrentAction: cleaning up..");
cleanUp();
- RS_DEBUG->print("RS_EventHandler::setCurrentAction: debugging actions");
+ DEBUG->print("EventHandler::setCurrentAction: debugging actions");
debugActions();
- RS_DEBUG->print("GraphicView::setCurrentAction: OK");
+ DEBUG->print("GraphicView::setCurrentAction: OK");
}
/**
* Kills all running selection actions. Called when a selection action
* is launched to reduce confusion.
*/
-void RS_EventHandler::killSelectActions()
+void EventHandler::killSelectActions()
{
for(int c=0; c<RS_MAXACTIONS; ++c)
{
/**
* Kills all running actions. Called when a window is closed.
*/
-void RS_EventHandler::killAllActions()
+void EventHandler::killAllActions()
{
/*
for (int c=0; c<RS_MAXACTIONS; ++c) {
/**
* @return true if there is at least one action in the action stack.
*/
-bool RS_EventHandler::hasAction()
+bool EventHandler::hasAction()
{
if (actionIndex != -1 || defaultAction)
return true;
/**
* Garbage collector for actions.
*/
-void RS_EventHandler::cleanUp()
+void EventHandler::cleanUp()
{
- RS_DEBUG->print("RS_EventHandler::cleanUp");
+ DEBUG->print("EventHandler::cleanUp");
int o = 0; // old index
int n = 0; // new index
}
}
- RS_DEBUG->print("RS_EventHandler::cleanUp: OK");
+ DEBUG->print("EventHandler::cleanUp: OK");
}
/**
* Sets the snap mode for all currently active actions.
*/
-void RS_EventHandler::setSnapMode(RS2::SnapMode sm)
+void EventHandler::setSnapMode(RS2::SnapMode sm)
{
#if 0
for(int c=0; c<RS_MAXACTIONS; ++c)
/**
* Sets the snap restriction for all currently active actions.
*/
-void RS_EventHandler::setSnapRestriction(RS2::SnapRestriction sr)
+void EventHandler::setSnapRestriction(RS2::SnapRestriction sr)
{
#if 0
for(int c=0; c<RS_MAXACTIONS; ++c)
#endif
}
-void RS_EventHandler::debugActions()
+void EventHandler::debugActions()
{
- RS_DEBUG->print("---");
+ DEBUG->print("---");
for(int c=0; c<RS_MAXACTIONS; ++c)
{
if (c == actionIndex)
- RS_DEBUG->print("Current");
+ DEBUG->print("Current");
if (currentActions[c])
- RS_DEBUG->print("Action %03d: %s [%s]",
+ DEBUG->print("Action %03d: %s [%s]",
c, currentActions[c]->getName().toLatin1().data(),
currentActions[c]->isFinished() ? "finished" : "active");
else
- RS_DEBUG->print("Action %03d: NULL", c);
+ DEBUG->print("Action %03d: NULL", c);
}
}