#include <QtGui>
#include "rs_actioninterface.h"
-#include "rs_coordinateevent.h"
+#include "rs_commandevent.h"
+#include "rs_debug.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_math.h"
/**
* Constructor.
/**
* Called by RS_GraphicView
*/
-void RS_EventHandler::keyReleaseEvent(QKeyEvent* e)
+void RS_EventHandler::keyReleaseEvent(QKeyEvent * e)
{
- if (actionIndex>=0 && currentActions[actionIndex]!=NULL &&
- !currentActions[actionIndex]->isFinished()) {
- currentActions[actionIndex]->keyReleaseEvent(e);
- } else {
- if (defaultAction!=NULL) {
- defaultAction->keyReleaseEvent(e);
- }
- else {
+ if (actionIndex >= 0 && currentActions[actionIndex] != NULL
+ && !currentActions[actionIndex]->isFinished())
+ {
+ currentActions[actionIndex]->keyReleaseEvent(e);
+ }
+ else
+ {
+ if (defaultAction != NULL)
+ defaultAction->keyReleaseEvent(e);
+ else
e->ignore();
- }
- //RS_DEBUG->print("currently no action defined");
- }
+
+ //RS_DEBUG->print("currently no action defined");
+ }
}
/**
if (actionIndex >= 0 && currentActions[actionIndex] != NULL
&& !currentActions[actionIndex]->isFinished())
{
-// int commaPos = cmd.find(',');
int commaPos = cmd.indexOf(',');
RS_DEBUG->print("RS_EventHandler::commandEvent: 001");
bool ok1, ok2;
if (ok1 && ok2)
{
- RS_DEBUG->print("RS_EventHandler::commandEvent: 005");
- RS_CoordinateEvent ce(Vector(x, y));
+// RS_DEBUG->print("RS_EventHandler::commandEvent: 005");
+// RS_CoordinateEvent ce(Vector(x, y));
RS_DEBUG->print("RS_EventHandler::commandEvent: 006");
+// currentActions[actionIndex]->coordinateEvent(&ce);
+ Vector ce(x, y);
currentActions[actionIndex]->coordinateEvent(&ce);
}
else
if (actionIndex >= 0 && currentActions[actionIndex] != NULL
&& !currentActions[actionIndex]->isFinished())
{
-// int commaPos = cmd.find(',');
int commaPos = cmd.indexOf(',');
bool ok1, ok2;
double x = RS_Math::eval(cmd.mid(1, commaPos - 1), &ok1);
if (ok1 && ok2)
{
- RS_CoordinateEvent ce(Vector(x,y) +
- graphicView->getRelativeZero());
+// RS_CoordinateEvent ce(Vector(x,y) + graphicView->getRelativeZero());
+// currentActions[actionIndex]->coordinateEvent(&ce);
+ Vector ce(Vector(x,y) + graphicView->getRelativeZero());
currentActions[actionIndex]->coordinateEvent(&ce);
}
else
if (actionIndex >= 0 && currentActions[actionIndex] != NULL
&& !currentActions[actionIndex]->isFinished())
{
-// int commaPos = cmd.find('<');
int commaPos = cmd.indexOf('<');
bool ok1, ok2;
double r = RS_Math::eval(cmd.left(commaPos), &ok1);
{
Vector pos;
pos.setPolar(r,RS_Math::deg2rad(a));
- RS_CoordinateEvent ce(pos);
- currentActions[actionIndex]->coordinateEvent(&ce);
+// RS_CoordinateEvent ce(pos);
+// currentActions[actionIndex]->coordinateEvent(&ce);
+ currentActions[actionIndex]->coordinateEvent(&pos);
}
else
{
{
Vector pos;
pos.setPolar(r,RS_Math::deg2rad(a));
- RS_CoordinateEvent ce(pos +
- graphicView->getRelativeZero());
+// RS_CoordinateEvent ce(pos + graphicView->getRelativeZero());
+// currentActions[actionIndex]->coordinateEvent(&ce);
+ Vector ce(pos + graphicView->getRelativeZero());
currentActions[actionIndex]->coordinateEvent(&ce);
}
else
else
{
if (defaultAction != NULL)
- {
defaultAction->commandEvent(e);
- //e->accept();
- }
}
}
return;
// Predecessor of the new action or NULL:
- RS_ActionInterface* predecessor = NULL;
+ RS_ActionInterface * predecessor = NULL;
// Suspend current action:
if (actionIndex >= 0 && currentActions[actionIndex] != NULL
// Move up actionstack (optimize):
for(int i=0; i<RS_MAXACTIONS-1; ++i)
- {
currentActions[i] = currentActions[i + 1];
- }
}
else if (actionIndex < RS_MAXACTIONS - 1)
- {
actionIndex++;
- }
// Set current action:
currentActions[actionIndex] = action;
*/
void RS_EventHandler::cleanUp()
{
- RS_DEBUG->print("RS_EventHandler::cleanUp");
-
- int o=0; // old index
- int n=0; // new index
- int resume=0; // index of action to resume
- bool doResume=false; // do we need to resume an action
- actionIndex = -1;
-
- debugActions();
- do {
- // search first used action (o)
- while (currentActions[o]==NULL && o<RS_MAXACTIONS) {
- o++;
- }
+ RS_DEBUG->print("RS_EventHandler::cleanUp");
- // delete action if it is finished
- if (o<RS_MAXACTIONS && currentActions[o]!=NULL &&
- currentActions[o]->isFinished()) {
- delete currentActions[o];
- currentActions[o] = NULL;
+ int o = 0; // old index
+ int n = 0; // new index
+ int resume = 0; // index of action to resume
+ bool doResume = false; // do we need to resume an action
+ actionIndex = -1;
- doResume = true;
- }
+ debugActions();
- // move a running action up in the stack
- if (o<RS_MAXACTIONS && currentActions[o]!=NULL) {
- if (n!=o) {
- currentActions[n] = currentActions[o];
- resume = n;
- currentActions[o] = NULL;
- } else {
- if (o<RS_MAXACTIONS) {
- o++;
- }
- }
- actionIndex = n;
- if (n<RS_MAXACTIONS-1) {
- n++;
- }
- }
- } while (o<RS_MAXACTIONS);
-
- debugActions();
-
- // Resume last used action:
- if (doResume) {
- if (currentActions[resume]!=NULL &&
- !currentActions[resume]->isFinished()) {
-
- currentActions[resume]->resume();
- currentActions[resume]->showOptions();
- } else {
- if (defaultAction!=NULL) {
- defaultAction->resume();
- defaultAction->showOptions();
- }
- }
- }
- RS_DEBUG->print("RS_EventHandler::cleanUp: OK");
+ do
+ {
+ // search first used action (o)
+ while (currentActions[o] == NULL && o < RS_MAXACTIONS)
+ o++;
+
+ // delete action if it is finished
+ if (o < RS_MAXACTIONS && currentActions[o] != NULL
+ && currentActions[o]->isFinished())
+ {
+ delete currentActions[o];
+ currentActions[o] = NULL;
+ doResume = true;
+ }
+
+ // move a running action up in the stack
+ if (o < RS_MAXACTIONS && currentActions[o] != NULL)
+ {
+ if (n != o)
+ {
+ currentActions[n] = currentActions[o];
+ resume = n;
+ currentActions[o] = NULL;
+ }
+ else
+ {
+ if (o < RS_MAXACTIONS)
+ o++;
+ }
+
+ actionIndex = n;
+
+ if (n < RS_MAXACTIONS - 1)
+ n++;
+ }
+ }
+ while (o < RS_MAXACTIONS);
+
+ debugActions();
+
+ // Resume last used action:
+ if (doResume)
+ {
+ if (currentActions[resume] != NULL && !currentActions[resume]->isFinished())
+ {
+ currentActions[resume]->resume();
+ currentActions[resume]->showOptions();
+ }
+ else
+ {
+ if (defaultAction != NULL)
+ {
+ defaultAction->resume();
+ defaultAction->showOptions();
+ }
+ }
+ }
+
+ RS_DEBUG->print("RS_EventHandler::cleanUp: OK");
}
/**