From: vsv Date: Wed, 5 Nov 2014 10:05:58 +0000 (+0300) Subject: Avoid selection of the same object in extrusion X-Git-Tag: V_0.5~37^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=559bc6fa26f2d013d774f36f2727d625be99894a;p=modules%2Fshaper.git Avoid selection of the same object in extrusion --- diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index bd5e54e70..65e2bb1a5 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -187,12 +187,29 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() ObjectPtr aObject = aObjects.first(); if ((!mySelectedObject) && (!aObject)) return; + // Check that object is not already selected 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; + + if (myFeature) { + // We can not select a result of our feature + const std::list>& aResList = myFeature->results(); + std::list >::const_iterator aIt; + for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) { + if ((*aIt) == aRes) + return; + } + } + // Check that object belongs to active document or PartSet + DocumentPtr aDoc = aRes->document(); + SessionPtr aMgr = ModelAPI_Session::get(); + if (!(aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument())) + return; + // Check that the result has a shape GeomShapePtr aShape = ModelAPI_Tools::shape(aRes); if (!aShape) @@ -218,6 +235,7 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() return; } setObject(aObject, aShape); + activateSelection(false); emit focusOutWidget(this); } } @@ -245,20 +263,6 @@ void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj, boost::shared_p bool ModuleBase_WidgetShapeSelector::isAccepted(const ObjectPtr theResult) const { ResultPtr aResult = boost::dynamic_pointer_cast(theResult); - if (myFeature) { - // We can not select a result of our feature - const std::list>& aRes = myFeature->results(); - std::list >::const_iterator aIt; - for (aIt = aRes.cbegin(); aIt != aRes.cend(); ++aIt) { - if ((*aIt) == aResult) - return false; - } - } - // Check that object belongs to active document or PartSet - DocumentPtr aDoc = aResult->document(); - SessionPtr aMgr = ModelAPI_Session::get(); - if (!(aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument())) - return false; // Check that the shape of necessary type boost::shared_ptr aShapePtr = ModelAPI_Tools::shape(aResult);