- if (myIsActive) {
- connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
- QIntList aList;
- foreach (QString aType, myShapeTypes) {
- aList.append(shapeType(aType));
- }
- myWorkshop->activateSubShapesSelection(aList);
- if (!myObjectTypes.isEmpty()) {
- myObjTypeFilter = new ModuleBase_ObjectTypesFilter(myWorkshop, myObjectTypes);
- aViewer->clearSelectionFilters();
- aViewer->addSelectionFilter(myObjTypeFilter);
- }
- } else {
- disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
- if (!myObjTypeFilter.IsNull()) {
- aViewer->removeSelectionFilter(myObjTypeFilter);
- myObjTypeFilter.Nullify();
- }
- myWorkshop->deactivateSubShapesSelection();
- }
- // apply filters loaded from the XML definition of the widget
- ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters();
- SelectMgr_ListOfFilter aFilters;
- aFactory->filters(parentID(), attributeID(), aFilters);
- SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
- for (; aIt.More(); aIt.Next()) {
- Handle(SelectMgr_Filter) aSelFilter = aIt.Value();
- if (aSelFilter.IsNull())
- continue;
-
- //Handle(ModuleBase_Filter) aFilter = Handle(ModuleBase_Filter)::DownCast(aIt.Value());
- //if (aFilter.IsNull())
- // continue;
- if (myIsActive)
- aViewer->addSelectionFilter(aSelFilter);
- else
- aViewer->removeSelectionFilter(aSelFilter);
- }
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::raisePanel() const
-{
- QWidget* aParent = myContainer->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::activate()
-{
- activateSelection(true);
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::deactivate()
-{
- activateSelection(false);
-}
-
-//********************************************************************
-bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape)
-{
- 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);
-
- // Check the type of selected object
- std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
- bool isValid = true;
- for (; aValidator != aValidators.end(); aValidator++) {
- const ModelAPI_ResultValidator* aResValidator =
- dynamic_cast<const ModelAPI_ResultValidator*>(*aValidator);
- if (aResValidator) {
- isValid = false;
- if (aResValidator->isValid(theObj)) {
- isValid = true;
- break;
+ bool isNameUpdated = false;
+ AttributeSelectionPtr aSelect = aData->selection(attributeID());
+ if (aSelect) {
+ myTextLine->setText(QString::fromStdString(aSelect->namingName(getDefaultValue())));
+ isNameUpdated = true;
+ }
+ if (!isNameUpdated) {
+ ObjectPtr anObject = ModuleBase_Tools::getObject(myFeature->attribute(attributeID()));
+ if (anObject.get() != NULL) {
+ std::string aName = anObject->data()->name();
+ myTextLine->setText(QString::fromStdString(aName));
+ } else {
+ AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
+ if (aRefAttr && aRefAttr->attr().get() != NULL) {
+ //myIsObject = aRefAttr->isObject();
+ std::string anAttrName = generateName(aRefAttr->attr(), myWorkshop);
+ myTextLine->setText(QString::fromStdString(anAttrName));