X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetShapeSelector.cpp;h=bd5e54e707b51b445aeeaad5f50eb4cac305047b;hb=dcd54507eb794c21a02c95ad26c1779c36481274;hp=f07c339caa60e82bd6a68645d904559758b1d4d3;hpb=9d397846914c40af6ce803f4742bd6fa6b085e56;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index f07c339ca..bd5e54e70 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -46,8 +47,7 @@ #include #include -#include -#include +#include typedef QMap ShapeTypes; static ShapeTypes MyShapeTypes; @@ -129,9 +129,12 @@ bool ModuleBase_WidgetShapeSelector::storeValue() const boost::shared_ptr aSelect = boost::dynamic_pointer_cast(aData->attribute(attributeID())); - ResultBodyPtr aBody = boost::dynamic_pointer_cast(mySelectedObject); - if (aBody) + ResultPtr aBody = boost::dynamic_pointer_cast(mySelectedObject); + if (aBody) { aSelect->setValue(aBody, myShape); + updateObject(myFeature); + return true; + } } else { boost::shared_ptr aRef = boost::dynamic_pointer_cast(aData->attribute(attributeID())); @@ -140,9 +143,10 @@ bool ModuleBase_WidgetShapeSelector::storeValue() const if (!(aObject && aObject->isSame(mySelectedObject))) { aRef->setValue(mySelectedObject); updateObject(myFeature); + return true; } } - return true; + return false; } //******************************************************************** @@ -185,12 +189,20 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() return; if (mySelectedObject && aObject && mySelectedObject->isSame(aObject)) return; + // Check that the selected object is result (others can not be accepted) + ResultPtr aRes = boost::dynamic_pointer_cast(aObject); + if (!aRes) + return; + // Check that the result has a shape + GeomShapePtr aShape = ModelAPI_Tools::shape(aRes); + if (!aShape) + return; // Get sub-shapes from local selection - boost::shared_ptr aShape; if (myUseSubShapes) { NCollection_List aShapeList; - myWorkshop->selection()->selectedShapes(aShapeList); + std::list aOwners; + myWorkshop->selection()->selectedShapes(aShapeList, aOwners); if (aShapeList.Extent() > 0) { aShape = boost::shared_ptr(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(aShapeList.First())); @@ -222,7 +234,6 @@ void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj, boost::shared_p if (!myUseSubShapes) { static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TOHIDE); ModelAPI_EventCreator::get()->sendUpdated(mySelectedObject, anEvent); - Events_Loop::loop()->flush(anEvent); } } updateSelectionName();