-
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate)
-{
- updateSelectionName();
-
- if (toActivate) {
- QIntList aList;
- foreach (QString aType, myShapeTypes) {
- aList.append(ModuleBase_Tools::shapeType(aType));
- }
- myWorkshop->activateSubShapesSelection(aList);
- } else {
- myWorkshop->deactivateSubShapesSelection();
- }
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::raisePanel() const
-{
- QWidget* aParent = this->parentWidget();
- QWidget* aLastPanel = 0;
- while (!aParent->inherits("QDockWidget")) {
- aLastPanel = aParent;
- aParent = aParent->parentWidget();
- if (!aParent)
- return;
- }
- if (aParent->inherits("QDockWidget")) {
- QDockWidget* aTabWgt = (QDockWidget*) aParent;
- aTabWgt->raise();
- }
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::activateCustom()
-{
- connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
- activateSelection(true);
-
- // Restore selection in the viewer by the attribute selection list
- myWorkshop->setSelected(getAttributeSelection());
-
- activateFilters(myWorkshop, true);
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::storeAttributeValue()
-{
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = myFeature->attribute(attributeID());
-
- myObject = GeomValidators_Tools::getObject(anAttribute);
- myShape = getShape();
- myRefAttribute = AttributePtr();
- myIsObject = false;
- AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
- if (aRefAttr) {
- myIsObject = aRefAttr->isObject();
- myRefAttribute = aRefAttr->attr();
- }
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::restoreAttributeValue(bool theValid)
-{
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = myFeature->attribute(attributeID());
-
- setObject(myObject, myShape);
- AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
- if (aRefAttr) {
- if (!myIsObject)
- aRefAttr->setAttr(myRefAttribute);
- }
-}
-
-//********************************************************************
-bool ModuleBase_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
-{
- 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);
- }
- if (aValid) {
- // In order to avoid selection of the same object
- ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
- FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aResult);
- aValid = aSelectedFeature != myFeature;
- }
- return aValid;
-}
-
-//********************************************************************
-bool ModuleBase_WidgetShapeSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
-{
- ObjectPtr anObject;
- GeomShapePtr aShape;
- getGeomSelection(thePrs, anObject, aShape);
-
- setObject(anObject, aShape);
- return true;
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::deactivate()
-{
- activateSelection(false);
- activateFilters(myWorkshop, false);
- disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-}