-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::customValidators(
- std::list<ModelAPI_Validator*>& theValidators,
- std::list<std::list<std::string> >& theArguments) const
-{
- return;
- theValidators.push_back(myShapeValidator);
-
- std::list<std::string> anArguments;
- foreach(QString aType, myShapeTypes) {
- anArguments.push_back(aType.toStdString().c_str());
- }
- theArguments.push_back(anArguments);
-}
-
-//********************************************************************
-bool ModuleBase_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
-{
-#ifdef DEBUG_SHAPE_VALIDATION_PREVIOUS
- return true;
-#endif
-
- GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs);
- bool aValid;
- // if there is no selected shape, the method returns true
- if (!aShape.get())
- aValid = true;
- else {
- // Check that the selection corresponds to selection type
- TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
- aValid = acceptSubShape(aTopoShape);
- }
- return aValid;
-}
-
-//********************************************************************
-bool ModuleBase_WidgetShapeSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
-{
- bool isDone = false;
-
- ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
-
- // It should be checked by corresponded validator
- //ObjectPtr aObject = thePrs.object();
- //ObjectPtr aCurrentObject = GeomValidators_Tools::getObject(myFeature->attribute(attributeID()));
- /*
- if ((!aCurrentObject) && (!aObject))
- return false;*/
-
- // It should be checked by corresponded validator
- // Check that the selected object is result (others can not be accepted)
- //ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
- //if (!aRes)
- // return false;
- /*if (myFeature) {
- // We can not select a result of our feature
- const std::list<std::shared_ptr<ModelAPI_Result>>& aResList = myFeature->results();
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
- for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
- if ((*aIt) == aRes)
- return false;
- }
- }
- */
- // It should be checked by corresponded validator
- /*
- // 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 false;*/
-
-#ifdef DEBUG_SHAPE_VALIDATION_PREVIOUS
- // It should be checked by corresponded validator
- // Check that the result has a shape
- GeomShapePtr aShape = ModelAPI_Tools::shape(aRes);
- if (!aShape)
- return false;
-
- // Get sub-shapes from local selection
- if (!thePrs.shape().IsNull()) {
- aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(thePrs.shape()));
- }
-
- // Check that the selection corresponds to selection type
- TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
- if (!acceptSubShape(aTopoShape))
- return false;
-#else
- // the difference is that the next method returns an empty shape if the result has the same shape
- // to be checked for all cases and uncommented
- GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs);
-#endif
-
- setObject(aResult, aShape);
- return true;
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::deactivate()
-{
- activateSelection(false);
- activateFilters(myWorkshop, false);
- disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-}