+ restore arrow cursor when mouse moves into empty area in 3d view
This commit is contained in:
parent
a1e049bc8a
commit
b5b6d49d2e
|
@ -103,6 +103,7 @@ SoFCUnifiedSelection::SoFCUnifiedSelection() : pcDocument(0)
|
||||||
SO_NODE_SET_SF_ENUM_TYPE (highlightMode, HighlightModes);
|
SO_NODE_SET_SF_ENUM_TYPE (highlightMode, HighlightModes);
|
||||||
|
|
||||||
highlighted = FALSE;
|
highlighted = FALSE;
|
||||||
|
preSelection = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -360,6 +361,7 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action)
|
||||||
std::string objectName = vpd->getObject()->getNameInDocument();
|
std::string objectName = vpd->getObject()->getNameInDocument();
|
||||||
std::string subElementName = vpd->getElement(pp ? pp->getDetail() : 0);
|
std::string subElementName = vpd->getElement(pp ? pp->getDetail() : 0);
|
||||||
|
|
||||||
|
this->preSelection = 1;
|
||||||
static char buf[513];
|
static char buf[513];
|
||||||
snprintf(buf,512,"Preselected: %s.%s.%s (%f,%f,%f)",documentName.c_str()
|
snprintf(buf,512,"Preselected: %s.%s.%s (%f,%f,%f)",documentName.c_str()
|
||||||
,objectName.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*/) {
|
if (currenthighlight/* && old_state != highlighted*/) {
|
||||||
SoHighlightElementAction action;
|
SoHighlightElementAction action;
|
||||||
|
@ -513,6 +524,29 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action)
|
||||||
inherited::handleEvent(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);
|
SO_ACTION_SOURCE(SoHighlightElementAction);
|
||||||
|
|
|
@ -85,7 +85,7 @@ public:
|
||||||
//virtual void GLRender(SoGLRenderAction * action);
|
//virtual void GLRender(SoGLRenderAction * action);
|
||||||
|
|
||||||
virtual void handleEvent(SoHandleEventAction * action);
|
virtual void handleEvent(SoHandleEventAction * action);
|
||||||
//virtual void GLRenderBelowPath(SoGLRenderAction * action);
|
virtual void GLRenderBelowPath(SoGLRenderAction * action);
|
||||||
//virtual void GLRenderInPath(SoGLRenderAction * action);
|
//virtual void GLRenderInPath(SoGLRenderAction * action);
|
||||||
//static void turnOffCurrentHighlight(SoGLRenderAction * action);
|
//static void turnOffCurrentHighlight(SoGLRenderAction * action);
|
||||||
|
|
||||||
|
@ -107,6 +107,8 @@ private:
|
||||||
static SoFullPath * currenthighlight;
|
static SoFullPath * currenthighlight;
|
||||||
|
|
||||||
SbBool highlighted;
|
SbBool highlighted;
|
||||||
|
// -1 = not handled, 0 = not selected, 1 = selected
|
||||||
|
int32_t preSelection;
|
||||||
SoColorPacker colorpacker;
|
SoColorPacker colorpacker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user