-
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate)
-{
- if (myIsActive == toActivate)
- return;
- myIsActive = toActivate;
- updateSelectionName();
-
- if (myIsActive) {
- QIntList aList;
- foreach (QString aType, myShapeTypes) {
- aList.append(shapeType(aType));
- }
- myWorkshop->activateSubShapesSelection(aList);
- } else {
- myWorkshop->deactivateSubShapesSelection();
- }
-
- activateFilters(myWorkshop, myIsActive);
-}
-
-//********************************************************************
-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);
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::backupAttributeValue(const bool isBackup)
-{
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = myFeature->attribute(attributeID());
-
- if (isBackup) {
- myObject = getObject(anAttribute);
- myShape = getShape();
- myRefAttribute = NULL;
- myIsObject = false;
- AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
- if (aRefAttr) {
- myIsObject = aRefAttr->isObject();
- myRefAttribute = aRefAttr->attr();
- }
- }
- else {
- storeAttributeValues(myObject, myShape);
- AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
- if (aRefAttr) {
- if (!myIsObject)
- aRefAttr->setAttr(myRefAttribute);
- }
- }
-}
-
-//********************************************************************
-bool ModuleBase_WidgetShapeSelector::setSelection(const Handle_SelectMgr_EntityOwner& theOwner)
-{
- bool isDone = false;
- //QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected();
- //if (aSelected.size() > 0) {
- ModuleBase_ViewerPrs aPrs;
- myWorkshop->selection()->fillPresentation(aPrs, theOwner);
- isDone = setSelectionPrs(aPrs);
- //}
- return isDone;
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::deactivate()
-{
- activateSelection(false);
- disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-}
-
-//********************************************************************
-/*bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape)
-{
- bool isValid = ModuleBase_WidgetValidated::isValid(theObj, theShape);
- if (!isValid)
- return false;
-
- SessionPtr aMgr = ModelAPI_Session::get();
- ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- std::list<ModelAPI_Validator*> aValidators;
- std::list<std::list<std::string> > anArguments;
- aFactory->validators(parentID(), attributeID(), aValidators, anArguments);
-
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = myFeature->attribute(attributeID());
-
- // 1. make a backup of the previous attribute values
- backupAttributeValue(true);
- // 2. store the current values, disable the model's update
- aData->blockSendAttributeUpdated(true);
-
- // 3. check the acceptability of the current values
- std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
- std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
- bool aValid = true;
- for (; aValidator != aValidators.end() && aValid; aValidator++, aArgs++) {
- const ModelAPI_AttributeValidator* aAttrValidator =
- dynamic_cast<const ModelAPI_AttributeValidator*>(*aValidator);
- if (aAttrValidator) {
- aValid = aAttrValidator->isValid(anAttribute, *aArgs);
- }
- }
-
- // 4. if the values are not valid, restore the previous values to the attribute
- backupAttributeValue(false);
-
- // 5. enable the model's update
- aData->blockSendAttributeUpdated(false);
- return aValid;
-}*/