Would like to lock the selection while I process application events. The things is by processing application events I let the user change the selection and it gives error. I don't know which command deactivates selection in OpenCASCADE.
You don't necessarily have to deactivate the selection in OCC. Simply ignore the events from the GUI while a flag is set. Have a look at this snippet derived from view.cxx in Qt sample (note untested):
Mon, 08/03/2015 - 11:04
if (lockSelection) {
// Do nothing because we are processing the current information.
} else {
context->Select(true);
}
Does that work for you?
Thu, 08/06/2015 - 22:14
Would like to lock the selection while I process application events. The things is by processing application events I let the user change the selection and it gives error. I don't know which command deactivates selection in OpenCASCADE.
Fri, 08/07/2015 - 00:56
You don't necessarily have to deactivate the selection in OCC. Simply ignore the events from the GUI while a flag is set. Have a look at this snippet derived from view.cxx in Qt sample (note untested):
bool ignoreSelection = false;
void View::mousePressEvent( QMouseEvent* e )
{
if (ignoreSelection) {
e->ignore();
return;
}
if ( e->button() == Qt::LeftButton )
onLButtonDown( ( e->buttons() | e->modifiers() ), e->pos() );
else if ( e->button() == Qt::MidButton )
onMButtonDown( e->buttons() | e->modifiers(), e->pos() );
else if ( e->button() == Qt::RightButton )
onRButtonDown( e->buttons() | e->modifiers(), e->pos() );
}
void View::mouseReleaseEvent(QMouseEvent* e)
{
if (ignoreSelection) {
e->ignore();
return;
}
if ( e->button() == Qt::LeftButton )
onLButtonUp( e->buttons(), e->pos() );
else if ( e->button() == Qt::MidButton )
onMButtonUp( e->buttons(), e->pos() );
else if( e->button() == Qt::RightButton )
onRButtonUp( e->buttons(), e->pos() );
}
void View::mouseMoveEvent(QMouseEvent* e)
{
if (ignoreSelection) {
e->ignore();
return;
}
onMouseMove( e->buttons(), e->pos() );
}
void View::enableSelection(bool state)
{
ignoreSelection = state;
}
So you would use as follows:
view->enableSelection(false);
// process your application events
view->enableSelection(true);
Good luck