From b5b6d49d2e7c0f3fefef3e368cb0b9edd043d757 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 5 Apr 2014 19:57:40 +0200 Subject: [PATCH] + restore arrow cursor when mouse moves into empty area in 3d view --- src/Gui/SoFCUnifiedSelection.cpp | 34 ++++++++++++++++++++++++++++++++ src/Gui/SoFCUnifiedSelection.h | 4 +++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index 03b09a5be632..23e7bf01ae27 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -103,6 +103,7 @@ SoFCUnifiedSelection::SoFCUnifiedSelection() : pcDocument(0) SO_NODE_SET_SF_ENUM_TYPE (highlightMode, HighlightModes); highlighted = FALSE; + preSelection = -1; } /*! @@ -360,6 +361,7 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) std::string objectName = vpd->getObject()->getNameInDocument(); std::string subElementName = vpd->getElement(pp ? pp->getDetail() : 0); + this->preSelection = 1; static char buf[513]; snprintf(buf,512,"Preselected: %s.%s.%s (%f,%f,%f)",documentName.c_str() ,objectName.c_str() @@ -396,6 +398,15 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) } } } + // nothing picked + else if (!pp) { + if (this->preSelection > 0) { + this->preSelection = 0; + // touch() makes sure to call GLRenderBelowPath so that the cursor can be updated + // because only from there the SoGLWidgetElement delivers the OpenGL window + this->touch(); + } + } if (currenthighlight/* && old_state != highlighted*/) { SoHighlightElementAction action; @@ -513,6 +524,29 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) inherited::handleEvent(action); } +void SoFCUnifiedSelection::GLRenderBelowPath(SoGLRenderAction * action) +{ + inherited::GLRenderBelowPath(action); + + // nothing picked, so restore the arrow cursor if needed + if (this->preSelection == 0) { + // this is called when a selection gate forbad to select an object + // and the user moved the mouse to an empty area + this->preSelection = -1; + QGLWidget* window; + SoState *state = action->getState(); + SoGLWidgetElement::get(state, window); + QWidget* parent = window ? window->parentWidget() : 0; + if (parent) { + QCursor c = parent->cursor(); + if (c.shape() == Qt::ForbiddenCursor) { + c.setShape(Qt::ArrowCursor); + parent->setCursor(c); + } + } + } +} + // --------------------------------------------------------------- SO_ACTION_SOURCE(SoHighlightElementAction); diff --git a/src/Gui/SoFCUnifiedSelection.h b/src/Gui/SoFCUnifiedSelection.h index c9914f5ca41b..1a9374e67d48 100644 --- a/src/Gui/SoFCUnifiedSelection.h +++ b/src/Gui/SoFCUnifiedSelection.h @@ -85,7 +85,7 @@ class GuiExport SoFCUnifiedSelection : public SoSeparator { //virtual void GLRender(SoGLRenderAction * action); virtual void handleEvent(SoHandleEventAction * action); - //virtual void GLRenderBelowPath(SoGLRenderAction * action); + virtual void GLRenderBelowPath(SoGLRenderAction * action); //virtual void GLRenderInPath(SoGLRenderAction * action); //static void turnOffCurrentHighlight(SoGLRenderAction * action); @@ -107,6 +107,8 @@ class GuiExport SoFCUnifiedSelection : public SoSeparator { static SoFullPath * currenthighlight; SbBool highlighted; + // -1 = not handled, 0 = not selected, 1 = selected + int32_t preSelection; SoColorPacker colorpacker; };