X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetValidated.cpp;h=caadc6be7582cc17eb8121963161c657c171b058;hb=872ac5e3e0196ad70c2a01a79bd070c9a7d4a2e6;hp=8f410e56d50dee27bcdebaaf8e7da61101ab0033;hpb=c7ed89ce495c3b8ef952f4afd45da259618d80ca;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 8f410e56d..caadc6be7 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -3,10 +3,12 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -31,9 +33,8 @@ bool ModuleBase_WidgetValidated::setSelection(ModuleBase_ViewerPrs theValue) { bool isDone = false; - Handle(SelectMgr_EntityOwner) anOwner = theValue.owner(); - if (isValid(anOwner)) { - setSelection(anOwner); + if (isValidSelection(theValue)) { + isDone = setSelectionCustom(theValue); updateObject(myFeature); emit valuesChanged(); } @@ -41,7 +42,7 @@ bool ModuleBase_WidgetValidated::setSelection(ModuleBase_ViewerPrs theValue) } //******************************************************************** -bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& theOwner) +bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue) { DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); @@ -57,10 +58,11 @@ bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& the storeAttributeValue(); // saves the owner value to the widget attribute - setSelection(theOwner); + bool aValid = setSelectionCustom(theValue); - // checks the attribute validity - bool aValid = isValidAttribute(); + if (aValid) + // checks the attribute validity + aValid = isValidAttribute(); // restores the current values of the widget attribute restoreAttributeValue(aValid); @@ -68,6 +70,16 @@ bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& the anAttribute->blockSetInitialized(isAttributeBlocked); aLoop->activateFlushes(true); + // In particular case the results are deleted and called as redisplayed inside of this + // highlight-selection, to they must be flushed as soon as possible. + // Example: selection of group-vertices subshapes with shift pressend on body. Without + // these 4 lines below the application crashes because of left presentations on + // removed results still in the viewer. + static Events_ID aDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED); + static Events_ID aRedispEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); + aLoop->flush(aDeletedEvent); + aLoop->flush(aRedispEvent); + return aValid; } @@ -107,3 +119,25 @@ void ModuleBase_WidgetValidated::activateFilters(ModuleBase_IWorkshop* theWorksh else aViewer->removeSelectionFilter(aSelFilter); } + +QList ModuleBase_WidgetValidated::getSelectedEntitiesOrObjects( + ModuleBase_ISelection* theSelection) const +{ + QList aSelectedPrs; + + // find selected presentation either in the viewer or in OB + // the selection in OCC viewer - the selection of a sub-shapes in the viewer + aSelectedPrs = theSelection->getSelected(); + if (aSelectedPrs.empty()) { + // the selection in Object Browser + QObjectPtrList anObjects = theSelection->selectedObjects(); + QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end(); + for (; anIt != aLast; anIt++) { + ObjectPtr anObject = *anIt; + if (anObject.get() != NULL) { + aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL)); + } + } + } + return aSelectedPrs; +}