1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * ModuleBase_WidgetMultiSelector.cpp
6 * Created on: Aug 28, 2014
10 #include <ModuleBase_WidgetMultiSelector.h>
11 #include <ModuleBase_WidgetShapeSelector.h>
12 #include <ModuleBase_ISelection.h>
13 #include <ModuleBase_IWorkshop.h>
14 #include <ModuleBase_IViewer.h>
15 #include <ModuleBase_Tools.h>
16 #include <ModuleBase_Definitions.h>
17 #include <ModuleBase_IModule.h>
19 #include <ModelAPI_Data.h>
20 #include <ModelAPI_Object.h>
21 #include <ModelAPI_AttributeSelectionList.h>
22 #include <ModelAPI_AttributeRefList.h>
23 #include <ModelAPI_AttributeRefAttrList.h>
25 #include <Config_WidgetAPI.h>
27 #include <QGridLayout>
29 #include <QListWidget>
35 #include <QApplication>
42 const int ATTRIBUTE_SELECTION_INDEX_ROLE = Qt::UserRole + 1;
45 * Customization of a List Widget to make it to be placed on full width of container
47 class CustomListWidget : public QListWidget
51 /// \param theParent a parent widget
52 CustomListWidget( QWidget* theParent )
53 : QListWidget( theParent )
57 /// Redefinition of virtual method
58 virtual QSize sizeHint() const
60 int aHeight = 2*QFontMetrics( font() ).height();
61 QSize aSize = QListWidget::sizeHint();
62 return QSize( aSize.width(), aHeight );
65 /// Redefinition of virtual method
66 virtual QSize minimumSizeHint() const
68 int aHeight = 4/*2*/*QFontMetrics( font() ).height();
69 QSize aSize = QListWidget::minimumSizeHint();
70 return QSize( aSize.width(), aHeight );
74 // The code is necessary only for Linux because
75 //it can not update viewport on widget resize
77 void resizeEvent(QResizeEvent* theEvent)
79 QListWidget::resizeEvent(theEvent);
80 QTimer::singleShot(5, viewport(), SLOT(repaint()));
85 ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParent,
86 ModuleBase_IWorkshop* theWorkshop,
87 const Config_WidgetAPI* theData,
88 const std::string& theParentId)
89 : ModuleBase_WidgetSelector(theParent, theWorkshop, theData, theParentId),
92 QGridLayout* aMainLay = new QGridLayout(this);
93 ModuleBase_Tools::adjustMargins(aMainLay);
95 QLabel* aTypeLabel = new QLabel(tr("Type"), this);
96 aMainLay->addWidget(aTypeLabel, 0, 0);
98 myTypeCombo = new QComboBox(this);
99 // There is no sense to parameterize list of types while we can not parameterize selection mode
101 std::string aPropertyTypes = theData->getProperty("type_choice");
102 QString aTypesStr = aPropertyTypes.c_str();
103 QStringList aShapeTypes = aTypesStr.split(' ', QString::SkipEmptyParts);
105 myIsUseChoice = theData->getBooleanAttribute("use_choice", true);
107 if (!aShapeTypes.empty())
108 myTypeCombo->addItems(aShapeTypes);
109 aMainLay->addWidget(myTypeCombo, 0, 1);
110 // if the xml definition contains one type, the controls to select a type should not be shown
111 if (aShapeTypes.size() <= 1 || !myIsUseChoice) {
112 aTypeLabel->setVisible(false);
113 myTypeCombo->setVisible(false);
116 std::string aLabelText = theData->getProperty("label");
117 QLabel* aListLabel = new QLabel(!aLabelText.empty() ? aLabelText.c_str()
118 : tr("Selected objects:"), this);
119 aMainLay->addWidget(aListLabel, 1, 0);
120 // if the xml definition contains one type, an information label should be shown near to the latest
121 if (aShapeTypes.size() <= 1) {
122 QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
123 if (!aLabelIcon.isEmpty()) {
124 QLabel* aSelectedLabel = new QLabel("", this);
125 aSelectedLabel->setPixmap(QPixmap(aLabelIcon));
126 aMainLay->addWidget(aSelectedLabel, 1, 1);
128 aMainLay->setColumnStretch(2, 1);
131 QString aToolTip = QString::fromStdString(theData->widgetTooltip());
132 myListControl = new CustomListWidget(this);
133 QString anObjName = QString::fromStdString(attributeID());
134 myListControl->setObjectName(anObjName);
135 myListControl->setToolTip(aToolTip);
136 myListControl->setSelectionMode(QAbstractItemView::ExtendedSelection);
138 aMainLay->addWidget(myListControl, 2, 0, 1, -1);
139 aMainLay->setRowStretch(2, 1);
140 //aMainLay->addWidget(new QLabel(this)); //FIXME(sbh)???
141 //aMainLay->setRowMinimumHeight(3, 20);
142 //this->setLayout(aMainLay);
143 connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged()));
145 myCopyAction = new QAction(QIcon(":pictures/copy.png"), tr("Copy"), this);
146 myCopyAction->setShortcut(QKeySequence::Copy);
147 myCopyAction->setEnabled(false);
148 connect(myCopyAction, SIGNAL(triggered(bool)), SLOT(onCopyItem()));
149 myListControl->addAction(myCopyAction);
151 myDeleteAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
152 myDeleteAction->setEnabled(false);
153 connect(myDeleteAction, SIGNAL(triggered(bool)), SLOT(onDeleteItem()));
154 myListControl->addAction(myDeleteAction);
156 myListControl->setContextMenuPolicy(Qt::ActionsContextMenu);
157 connect(myListControl, SIGNAL(itemSelectionChanged()), SLOT(onListSelection()));
160 ModuleBase_WidgetMultiSelector::~ModuleBase_WidgetMultiSelector()
164 //********************************************************************
165 void ModuleBase_WidgetMultiSelector::activateCustom()
167 ModuleBase_WidgetSelector::activateCustom();
169 myWorkshop->module()->activateCustomPrs(myFeature,
170 ModuleBase_IModule::CustomizeHighlightedObjects, true);
173 //********************************************************************
174 void ModuleBase_WidgetMultiSelector::deactivate()
176 ModuleBase_WidgetSelector::deactivate();
178 myWorkshop->module()->deactivateCustomPrs(ModuleBase_IModule::CustomizeHighlightedObjects, true);
181 //********************************************************************
182 bool ModuleBase_WidgetMultiSelector::storeValueCustom() const
184 // the value is stored on the selection changed signal processing
185 // A rare case when plugin was not loaded.
189 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
190 std::string aType = anAttribute->attributeType();
191 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
192 AttributeSelectionListPtr aSelectionListAttr =
193 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
194 aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString());
199 //********************************************************************
200 bool ModuleBase_WidgetMultiSelector::restoreValueCustom()
202 // A rare case when plugin was not loaded.
206 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
207 std::string aType = anAttribute->attributeType();
208 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
209 AttributeSelectionListPtr aSelectionListAttr =
210 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
211 // Restore shape type
212 setCurrentShapeType(ModuleBase_Tools::shapeType(aSelectionListAttr->selectionType().c_str()));
214 updateSelectionList();
218 //********************************************************************
219 void ModuleBase_WidgetMultiSelector::storeAttributeValue()
221 ModuleBase_WidgetValidated::storeAttributeValue();
223 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
224 std::string aType = anAttribute->attributeType();
226 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
227 AttributeSelectionListPtr aSelectionListAttr =
228 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
229 mySelectionType = aSelectionListAttr->selectionType();
230 mySelectionCount = aSelectionListAttr->size();
232 else if (aType == ModelAPI_AttributeRefList::typeId()) {
233 AttributeRefListPtr aRefListAttr =
234 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
235 mySelectionCount = aRefListAttr->size();
237 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
238 AttributeRefAttrListPtr aRefAttrListAttr =
239 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(anAttribute);
240 mySelectionCount = aRefAttrListAttr->size();
244 //********************************************************************
245 void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool theValid)
247 ModuleBase_WidgetValidated::restoreAttributeValue(theValid);
249 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
250 std::string aType = anAttribute->attributeType();
251 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
252 AttributeSelectionListPtr aSelectionListAttr =
253 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
254 aSelectionListAttr->setSelectionType(mySelectionType);
256 // restore selection in the attribute. Indeed there is only one stored object
257 int aCountAppened = aSelectionListAttr->size() - mySelectionCount;
258 for (int i = 0; i < aCountAppened; i++)
259 aSelectionListAttr->removeLast();
261 else if (aType == ModelAPI_AttributeRefList::typeId()) {
262 AttributeRefListPtr aRefListAttr =
263 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
264 // restore objects in the attribute. Indeed there is only one stored object
265 int aCountAppened = aRefListAttr->size() - mySelectionCount;
266 for (int i = 0; i < aCountAppened; i++)
267 aRefListAttr->removeLast();
269 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
270 AttributeRefAttrListPtr aRefAttrListAttr =
271 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(anAttribute);
272 // restore objects in the attribute. Indeed there is only one stored object
273 int aCountAppened = aRefAttrListAttr->size() - mySelectionCount;
274 for (int i = 0; i < aCountAppened; i++)
275 aRefAttrListAttr->removeLast();
279 //********************************************************************
280 void ModuleBase_WidgetMultiSelector::clearAttribute()
282 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
283 std::string aType = anAttribute->attributeType();
284 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
285 AttributeSelectionListPtr aSelectionListAttr =
286 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
287 aSelectionListAttr->clear();
289 else if (aType == ModelAPI_AttributeRefList::typeId()) {
290 AttributeRefListPtr aRefListAttr =
291 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
292 aRefListAttr->clear();
294 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
295 AttributeRefAttrListPtr aRefAttrListAttr =
296 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(anAttribute);
297 aRefAttrListAttr->clear();
301 //********************************************************************
302 void ModuleBase_WidgetMultiSelector::setObject(ObjectPtr theSelectedObject,
303 GeomShapePtr theShape)
305 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
306 std::string aType = anAttribute->attributeType();
307 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
308 AttributeSelectionListPtr aSelectionListAttr =
309 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
310 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
311 aSelectionListAttr->append(aResult, theShape, myIsInValidate);
313 else if (aType == ModelAPI_AttributeRefList::typeId()) {
314 AttributeRefListPtr aRefListAttr =
315 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
316 aRefListAttr->append(theSelectedObject);
318 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
319 AttributeRefAttrListPtr aRefAttrListAttr =
320 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(anAttribute);
322 AttributePtr anAttribute = myWorkshop->module()->findAttribute(theSelectedObject, theShape);
323 if (anAttribute.get())
324 aRefAttrListAttr->append(anAttribute);
326 aRefAttrListAttr->append(theSelectedObject);
330 //********************************************************************
331 bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
332 const bool theToValidate)
334 QList<ModuleBase_ViewerPrs> aSkippedValues;
336 QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
338 for (; anIt != aLast; anIt++) {
339 ModuleBase_ViewerPrs aValue = *anIt;
340 bool aProcessed = false;
341 if (!theToValidate || isValidInFilters(aValue)) {
342 aProcessed = setSelectionCustom(aValue);
345 aSkippedValues.append(aValue);
346 // if there is at least one set, the result is true
347 isDone = isDone || aProcessed;
349 // updateObject - to update/redisplay feature
350 // it is commented in order to perfom it outside the method
352 //updateObject(myFeature);
353 // this emit is necessary to call store/restore method an restore type of selection
354 //emit valuesChanged();
357 if (!aSkippedValues.empty())
358 theValues.append(aSkippedValues);
363 //********************************************************************
364 void ModuleBase_WidgetMultiSelector::getHighlighted(QList<ModuleBase_ViewerPrs>& theValues)
366 std::set<int> anAttributeIds;
367 getSelectedAttributeIndices(anAttributeIds);
368 if (!anAttributeIds.empty())
369 convertIndicesToViewerSelection(anAttributeIds, theValues);
372 //********************************************************************
373 bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
375 bool aValid = ModuleBase_WidgetSelector::isValidSelectionCustom(thePrs);
377 ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
378 aValid = aResult.get() != NULL;
381 // We can not select a result of our feature
382 const std::list<ResultPtr>& aResList = myFeature->results();
383 std::list<ResultPtr>::const_iterator aIt;
384 bool isSkipSelf = false;
385 for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
386 if ((*aIt) == aResult) {
399 //********************************************************************
400 bool ModuleBase_WidgetMultiSelector::processDelete()
402 // find attribute indices to delete
403 std::set<int> anAttributeIds;
404 getSelectedAttributeIndices(anAttributeIds);
406 // refill attribute by the items which indices are not in the list of ids
408 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
409 std::string aType = anAttribute->attributeType();
410 aDone = !anAttributeIds.empty();
411 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
412 AttributeSelectionListPtr aSelectionListAttr =
413 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
414 aSelectionListAttr->remove(anAttributeIds);
417 else if (aType == ModelAPI_AttributeRefList::typeId()) {
418 AttributeRefListPtr aRefListAttr =
419 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
420 aRefListAttr->remove(anAttributeIds);
422 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
423 AttributeRefAttrListPtr aRefAttrListAttr =
424 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(anAttribute);
425 aRefAttrListAttr->remove(anAttributeIds);
429 // update object is necessary to flush update signal. It leads to objects references map update
430 // and the operation presentation will not contain deleted items visualized as parameters of
432 updateObject(myFeature);
435 myWorkshop->setSelected(getAttributeSelection());
440 //********************************************************************
441 QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
443 QList<QWidget*> result;
444 //result << myTypeCombo;
445 result << myListControl;
449 //********************************************************************
450 void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
452 activateSelectionAndFilters(true);
453 QList<ModuleBase_ViewerPrs> anEmptyList;
454 // This method will call Selection changed event which will call onSelectionChanged
455 // To clear mySelection, myListControl and storeValue()
456 // So, we don't need to call it
457 myWorkshop->setSelected(anEmptyList);
460 void ModuleBase_WidgetMultiSelector::updateFocus()
462 // Set focus to List control in order to make possible
463 // to use Tab key for transfer the focus to next widgets
464 myListControl->setCurrentRow(myListControl->model()->rowCount() - 1);
465 ModuleBase_Tools::setFocus(myListControl,
466 "ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()");
469 //********************************************************************
470 void ModuleBase_WidgetMultiSelector::updateSelectionName()
474 //********************************************************************
475 QIntList ModuleBase_WidgetMultiSelector::getShapeTypes() const
477 QIntList aShapeTypes;
479 if (myTypeCombo->count() > 1 && myIsUseChoice) {
480 aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCombo->currentText()));
483 for (int i = 0, aCount = myTypeCombo->count(); i < aCount; i++) {
484 TopAbs_ShapeEnum aType = ModuleBase_Tools::shapeType(myTypeCombo->itemText(i));
485 aShapeTypes.append(aType);
486 if (aType == TopAbs_SOLID)
487 aShapeTypes.append(TopAbs_COMPSOLID);
493 //********************************************************************
494 void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const TopAbs_ShapeEnum theShapeType)
496 QString aShapeTypeName;
498 for (int idx = 0; idx < myTypeCombo->count(); ++idx) {
499 aShapeTypeName = myTypeCombo->itemText(idx);
500 TopAbs_ShapeEnum aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
501 if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
502 activateSelectionAndFilters(false);
503 bool isBlocked = myTypeCombo->blockSignals(true);
504 myTypeCombo->setCurrentIndex(idx);
505 myTypeCombo->blockSignals(isBlocked);
507 activateSelectionAndFilters(true);
513 QList<ModuleBase_ViewerPrs> ModuleBase_WidgetMultiSelector::getAttributeSelection() const
515 QList<ModuleBase_ViewerPrs> aSelected;
516 convertIndicesToViewerSelection(std::set<int>(), aSelected);
520 //********************************************************************
521 void ModuleBase_WidgetMultiSelector::updateSelectionList()
523 myListControl->clear();
525 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
526 std::string aType = anAttribute->attributeType();
527 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
528 AttributeSelectionListPtr aSelectionListAttr =
529 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
530 for (int i = 0; i < aSelectionListAttr->size(); i++) {
531 AttributeSelectionPtr aAttr = aSelectionListAttr->value(i);
532 QListWidgetItem* anItem = new QListWidgetItem(aAttr->namingName().c_str(), myListControl);
533 anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, i);
534 myListControl->addItem(anItem);
537 else if (aType == ModelAPI_AttributeRefList::typeId()) {
538 AttributeRefListPtr aRefListAttr =
539 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
540 for (int i = 0; i < aRefListAttr->size(); i++) {
541 ObjectPtr anObject = aRefListAttr->object(i);
542 if (anObject.get()) {
543 QListWidgetItem* anItem = new QListWidgetItem(anObject->data()->name().c_str(),
545 anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, i);
546 myListControl->addItem(anItem);
550 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
551 AttributeRefAttrListPtr aRefAttrListAttr =
552 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(anAttribute);
553 for (int i = 0; i < aRefAttrListAttr->size(); i++) {
554 AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
556 if (anAttribute.get()) {
557 std::string anAttrName = generateName(anAttribute);
558 aName = QString::fromStdString(anAttrName);
561 ObjectPtr anObject = aRefAttrListAttr->object(i);
562 if (anObject.get()) {
563 aName = anObject->data()->name().c_str();
566 QListWidgetItem* anItem = new QListWidgetItem(aName, myListControl);
567 anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, i);
568 myListControl->addItem(anItem);
572 // We have to call repaint because sometimes the List control is not updated
573 myListControl->repaint();
576 //********************************************************************
577 std::string ModuleBase_WidgetMultiSelector::validatorType(const QString& theType) const
581 if (theType == "Vertices")
583 else if (theType == "Edges")
585 else if (theType == "Faces")
587 else if (theType == "Solids")
593 //********************************************************************
594 void ModuleBase_WidgetMultiSelector::onCopyItem()
596 QList<QListWidgetItem*> aItems = myListControl->selectedItems();
598 foreach(QListWidgetItem* aItem, aItems) {
601 aRes += aItem->text();
603 if (!aRes.isEmpty()) {
604 QClipboard *clipboard = QApplication::clipboard();
605 clipboard->setText(aRes);
609 //********************************************************************
610 void ModuleBase_WidgetMultiSelector::onDeleteItem()
615 //********************************************************************
616 void ModuleBase_WidgetMultiSelector::onListSelection()
618 QList<QListWidgetItem*> aItems = myListControl->selectedItems();
619 myCopyAction->setEnabled(!aItems.isEmpty());
620 myDeleteAction->setEnabled(!aItems.isEmpty());
622 myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
626 //********************************************************************
627 void ModuleBase_WidgetMultiSelector::getSelectedAttributeIndices(std::set<int>& theAttributeIds)
629 QList<QListWidgetItem*> aItems = myListControl->selectedItems();
630 foreach(QListWidgetItem* anItem, aItems) {
631 int anIndex = anItem->data(ATTRIBUTE_SELECTION_INDEX_ROLE).toInt();
632 if (theAttributeIds.find(anIndex) == theAttributeIds.end())
633 theAttributeIds.insert(anIndex);
637 void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<int> theAttributeIds,
638 QList<ModuleBase_ViewerPrs>& theValues) const
640 if(myFeature.get() == NULL)
643 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
644 std::string aType = anAttribute->attributeType();
645 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
646 AttributeSelectionListPtr aSelectionListAttr =
647 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
648 for (int i = 0; i < aSelectionListAttr->size(); i++) {
649 // filter by attribute indices only if the container is not empty otherwise return all items
650 if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end())
652 AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
653 ResultPtr anObject = anAttr->context();
654 if (anObject.get()) {
656 std::shared_ptr<GeomAPI_Shape> aShapePtr = anAttr->value();
657 if (aShapePtr.get()) {
658 aShape = aShapePtr->impl<TopoDS_Shape>();
660 theValues.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));
664 else if (aType == ModelAPI_AttributeRefList::typeId()) {
665 AttributeRefListPtr aRefListAttr =
666 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
667 for (int i = 0; i < aRefListAttr->size(); i++) {
668 // filter by attribute indices only if the container is not empty otherwise return all items
669 if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end())
671 ObjectPtr anObject = aRefListAttr->object(i);
672 if (anObject.get()) {
673 theValues.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
677 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
678 AttributeRefAttrListPtr aRefAttrListAttr =
679 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(anAttribute);
680 for (int i = 0; i < aRefAttrListAttr->size(); i++) {
681 // filter by attribute indices only if the container is not empty otherwise return all items
682 if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end())
684 ObjectPtr anObject = aRefAttrListAttr->object(i);
688 AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
689 if (anAttribute.get()) {
690 GeomShapePtr aGeomShape = myWorkshop->module()->findShape(anAttribute);
691 if (aGeomShape.get()) {
692 aShape = aGeomShape->impl<TopoDS_Shape>();
694 theValues.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));