X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Factioninterface.cpp;fp=src%2Fbase%2Factioninterface.cpp;h=17d1da9f3ba958e95fdeeb77099f5936eb5bdf2a;hb=92c8661cef41f1109908bf645c0a171e34680183;hp=92b77452451cdb88ea7e26184701cced317fa340;hpb=806890f384b382a02675cadc33c15fdbcec7d432;p=architektonas diff --git a/src/base/actioninterface.cpp b/src/base/actioninterface.cpp index 92b7745..17d1da9 100644 --- a/src/base/actioninterface.cpp +++ b/src/base/actioninterface.cpp @@ -20,8 +20,17 @@ #include "commands.h" #include "debug.h" +#include "dialogfactory.h" #include "entitycontainer.h" #include "graphicview.h" +#include "grid.h" + +/* +I think what's needed here is for the constructor to save the state of the snapper +and to restore it in the destructor. This, of course, assumes that the actions are +created and used in a certain order, perhaps that needs enforcement? Dunno, but worth +a try as suspend() and resume() seem to fuck it up badly. +*/ /** * Constructor. @@ -35,7 +44,10 @@ * note that an action belongs to this view. */ ActionInterface::ActionInterface(const char * name, EntityContainer & ec, - GraphicView & gv): graphicView(&gv), container(&ec) + GraphicView & gv): graphicView(&gv), container(&ec), +// snapperVisibility(false), previewVisibility(false), suspendCount(0) +//hm. + snapperVisibility(true), previewVisibility(true), suspendCount(0) { DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\"", name); @@ -50,17 +62,20 @@ ActionInterface::ActionInterface(const char * name, EntityContainer & ec, // Document pointer will be used for undo / redo document = ec.getDocument(); + // \o/ \o/ \o/ BY GRABTHAR'S HAMMER, IT HAS BEEN EXPUNGED!!! \o/ \o/ \o/ // This is here until I can figure out a better way to contain all of this // circular referential nonsense that exists in this codebase. It will be // expunged, by Grabthar's Hammer! - graphicView->snapper.SetContainer(container); - graphicView->snapper.SetGraphicView(graphicView); // <-- THIS is what I mean! INSANE! +// graphicView->snapper.SetContainer(container); +// graphicView->snapper.SetGraphicView(graphicView); // <-- THIS is what I mean! INSANE! // Not all actions use these. Perhaps we need to pass params to the contructor // in order to set these? Setting the default to true for both? - graphicView->snapper.SetVisible(); +// graphicView->snapper.SetVisible(); + graphicView->SetSnapperVisible(); graphicView->preview.SetVisible(); DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\": OK", name); +printf("ActionInterface::ActionInterface() [%08X]\n", this); } /** @@ -71,6 +86,7 @@ ActionInterface::ActionInterface(const char * name, EntityContainer & ec, // would be pure virtual now: // hideOptions(); //JLH: Only it isn't pure virtual... +printf("ActionInterface::~ActionInterface() [%08X]\n", this); } /** @@ -112,9 +128,11 @@ void ActionInterface::init(int status/*= 0*/) } else // status < 0, e.g. this action is finished { - graphicView->snapper.SetVisible(false); +// graphicView->snapper.SetVisible(false); + graphicView->SetSnapperVisible(false); graphicView->preview.SetVisible(false); graphicView->preview.clear(); + graphicView->redraw(); //hm. } } @@ -208,9 +226,9 @@ QStringList ActionInterface::getAvailableCommands() * of progress and decreases when the user goes one * step back (i.e. presses the right mouse button). */ -void ActionInterface::setStatus(int status) +void ActionInterface::setStatus(int value) { - this->status = status; + status = value; if (status < 0) { @@ -295,6 +313,12 @@ void ActionInterface::finish() // Snapper::finish(); // Sets Snapper::finished = true // I think this is where we want to update the screen... // graphicView->redraw(); + // hm. +// graphicView->snapper.SetVisible(false); + graphicView->SetSnapperVisible(false); + graphicView->preview.SetVisible(false); +// graphicView->preview.clear(); + graphicView->redraw(); //hm. DEBUG->print("ActionInterface::finish: OK"); } @@ -307,15 +331,31 @@ void ActionInterface::setPredecessor(ActionInterface * p) predecessor = p; } +#if 0 +Here is a problem. suspend() and resume() don't do what they should: +The problem is that Actions are modifying a shared resource though it's acting +as if it were not. Case in point below: ActionZoomPan sets the snapper/preview +visibility to FALSE and then EventHandler calls suspend() here, which queries +the graphicView to see what its state is. We need to fix this...! + +This ties into the problem where we have GraphicView pointers scattered all +over the place. We need to fix that too! +#endif /** * Suspends this action while another action takes place. */ void ActionInterface::suspend() { +#if 0 +printf("ActionInterface::suspend(%i): [%08X] ", ++suspendCount, this); // Maybe this is where we need to save the state of the snapper // & preview objects??? // graphicView->setMouseCursor(RS2::ArrowCursor); // Snapper::suspend(); + snapperVisibility = graphicView->snapper.Visible(); + previewVisibility = graphicView->preview.Visible(); +printf("snapperVisibility = %s, previewVisibility = %s...\n", (snapperVisibility ? "true" : "FALSE"), (previewVisibility ? "true" : "FALSE")); +#endif } /** @@ -323,9 +363,17 @@ void ActionInterface::suspend() */ void ActionInterface::resume() { +#if 0 +if (suspendCount == 0) + printf("!!! RESUME BEFORE SUSPEND !!!\n"); +printf("ActionInterface::resume(%i): [%08X] ", suspendCount, this); updateMouseCursor(); updateToolBar(); // Snapper::resume(); + graphicView->snapper.SetVisible(snapperVisibility); + graphicView->preview.SetVisible(previewVisibility); +printf("snapperVisibility = %s, previewVisibility = %s...\n", (snapperVisibility ? "true" : "FALSE"), (previewVisibility ? "true" : "FALSE")); +#endif } /** @@ -373,17 +421,18 @@ QString ActionInterface::msgAvailableCommands() // this one. May go away in the future. Vector ActionInterface::snapPoint(QMouseEvent * e) { - return graphicView->snapper.snapPoint(e); +// return graphicView->snapper.snapPoint(e); + return graphicView->SnapPoint(e); } Entity * ActionInterface::catchEntity(QMouseEvent * e, RS2::ResolveLevel level/*= RS2::ResolveNone*/) { - return graphicView->snapper.catchEntity(e, level); + return graphicView->CatchEntity(e, level); } Entity * ActionInterface::catchEntity(Vector v, RS2::ResolveLevel level/*= RS2::ResolveNone*/) { - return graphicView->snapper.catchEntity(v, level); + return graphicView->CatchEntity(v, level); } #warning "!!! Dummy functions need to be deleted once all actions no longer use these !!!"