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>
18 #include <ModuleBase_ViewerPrs.h>
20 #include <ModelAPI_Data.h>
21 #include <ModelAPI_Object.h>
22 #include <ModelAPI_AttributeSelectionList.h>
23 #include <ModelAPI_AttributeRefList.h>
24 #include <ModelAPI_AttributeRefAttrList.h>
25 #include <ModelAPI_Tools.h>
27 #include <Config_WidgetAPI.h>
29 #include <QGridLayout>
31 #include <QListWidget>
37 #include <QApplication>
44 const int ATTRIBUTE_SELECTION_INDEX_ROLE = Qt::UserRole + 1;
47 * Customization of a List Widget to make it to be placed on full width of container
49 class CustomListWidget : public QListWidget
53 /// \param theParent a parent widget
54 CustomListWidget( QWidget* theParent )
55 : QListWidget( theParent )
59 /// Redefinition of virtual method
60 virtual QSize sizeHint() const
62 int aHeight = 2*QFontMetrics( font() ).height();
63 QSize aSize = QListWidget::sizeHint();
64 return QSize( aSize.width(), aHeight );
67 /// Redefinition of virtual method
68 virtual QSize minimumSizeHint() const
70 int aHeight = 4/*2*/*QFontMetrics( font() ).height();
71 QSize aSize = QListWidget::minimumSizeHint();
72 return QSize( aSize.width(), aHeight );
76 // The code is necessary only for Linux because
77 //it can not update viewport on widget resize
79 void resizeEvent(QResizeEvent* theEvent)
81 QListWidget::resizeEvent(theEvent);
82 QTimer::singleShot(5, viewport(), SLOT(repaint()));
87 ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParent,
88 ModuleBase_IWorkshop* theWorkshop,
89 const Config_WidgetAPI* theData)
90 : ModuleBase_WidgetSelector(theParent, theWorkshop, theData)
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", false);
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 = myFeature->data()->selectionList(attributeID());
193 aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString());
198 //********************************************************************
199 bool ModuleBase_WidgetMultiSelector::restoreValueCustom()
201 // A rare case when plugin was not loaded.
205 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
206 std::string aType = anAttribute->attributeType();
207 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
208 AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
209 // Restore shape type
210 std::string aSelectionType = aSelectionListAttr->selectionType().c_str();
211 if (!aSelectionType.empty())
212 setCurrentShapeType(ModuleBase_Tools::shapeType(aSelectionType.c_str()));
214 updateSelectionList();
218 //********************************************************************
219 bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
220 const bool theToValidate)
222 QList<ModuleBase_ViewerPrsPtr> aSkippedValues;
224 /// remove unused objects from the model attribute.
225 /// It should be performed before new attributes append.
226 removeUnusedAttributeObjects(theValues);
228 QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
230 for (; anIt != aLast; anIt++) {
231 ModuleBase_ViewerPrsPtr aValue = *anIt;
232 bool aProcessed = false;
233 if (!theToValidate || isValidInFilters(aValue)) {
234 aProcessed = setSelectionCustom(aValue);
237 aSkippedValues.append(aValue);
238 // if there is at least one set, the result is true
239 isDone = isDone || aProcessed;
241 // updateObject - to update/redisplay feature
242 // it is commented in order to perfom it outside the method
244 //updateObject(myFeature);
245 // this emit is necessary to call store/restore method an restore type of selection
246 //emit valuesChanged();
250 if (!aSkippedValues.empty())
251 theValues.append(aSkippedValues);
256 //********************************************************************
257 void ModuleBase_WidgetMultiSelector::getHighlighted(QList<ModuleBase_ViewerPrsPtr>& theValues)
259 std::set<int> anAttributeIds;
260 getSelectedAttributeIndices(anAttributeIds);
261 if (!anAttributeIds.empty())
262 convertIndicesToViewerSelection(anAttributeIds, theValues);
265 //********************************************************************
266 bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
268 bool aValid = ModuleBase_WidgetSelector::isValidSelectionCustom(thePrs);
270 ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
271 aValid = aResult.get() != NULL;
274 // We can not select a result of our feature
275 const std::list<ResultPtr>& aResList = myFeature->results();
276 std::list<ResultPtr>::const_iterator aIt;
277 bool isSkipSelf = false;
278 for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
279 if ((*aIt) == aResult) {
292 //********************************************************************
293 bool ModuleBase_WidgetMultiSelector::processDelete()
295 // find attribute indices to delete
296 std::set<int> anAttributeIds;
297 getSelectedAttributeIndices(anAttributeIds);
299 // refill attribute by the items which indices are not in the list of ids
301 DataPtr aData = myFeature->data();
302 AttributePtr anAttribute = aData->attribute(attributeID());
303 std::string aType = anAttribute->attributeType();
304 aDone = !anAttributeIds.empty();
305 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
306 AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
307 aSelectionListAttr->remove(anAttributeIds);
310 else if (aType == ModelAPI_AttributeRefList::typeId()) {
311 AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
312 aRefListAttr->remove(anAttributeIds);
314 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
315 AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
316 aRefAttrListAttr->remove(anAttributeIds);
320 // update object is necessary to flush update signal. It leads to objects references map update
321 // and the operation presentation will not contain deleted items visualized as parameters of
323 updateObject(myFeature);
326 myWorkshop->setSelected(getAttributeSelection());
331 //********************************************************************
332 QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
334 QList<QWidget*> result;
335 //result << myTypeCombo;
336 result << myListControl;
340 //********************************************************************
341 void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
343 activateSelectionAndFilters(true);
344 QList<ModuleBase_ViewerPrsPtr> anEmptyList;
345 // This method will call Selection changed event which will call onSelectionChanged
346 // To clear mySelection, myListControl and storeValue()
347 // So, we don't need to call it
348 myWorkshop->setSelected(anEmptyList);
351 void ModuleBase_WidgetMultiSelector::updateFocus()
353 // Set focus to List control in order to make possible
354 // to use Tab key for transfer the focus to next widgets
355 myListControl->setCurrentRow(myListControl->model()->rowCount() - 1);
356 ModuleBase_Tools::setFocus(myListControl,
357 "ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()");
360 //********************************************************************
361 void ModuleBase_WidgetMultiSelector::updateSelectionName()
365 //********************************************************************
366 QIntList ModuleBase_WidgetMultiSelector::getShapeTypes() const
368 QIntList aShapeTypes;
370 if (myTypeCombo->count() > 1 && myIsUseChoice) {
371 aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCombo->currentText()));
374 for (int i = 0, aCount = myTypeCombo->count(); i < aCount; i++) {
375 TopAbs_ShapeEnum aType = ModuleBase_Tools::shapeType(myTypeCombo->itemText(i));
376 aShapeTypes.append(aType);
377 if (aType == TopAbs_SOLID)
378 aShapeTypes.append(TopAbs_COMPSOLID);
384 //********************************************************************
385 void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const TopAbs_ShapeEnum theShapeType)
387 QString aShapeTypeName;
389 for (int idx = 0; idx < myTypeCombo->count(); ++idx) {
390 aShapeTypeName = myTypeCombo->itemText(idx);
391 TopAbs_ShapeEnum aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
392 if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
393 bool aWasActivated = activateSelectionAndFilters(false);
394 bool isBlocked = myTypeCombo->blockSignals(true);
395 myTypeCombo->setCurrentIndex(idx);
396 myTypeCombo->blockSignals(isBlocked);
398 activateSelectionAndFilters(true);
404 QList<ModuleBase_ViewerPrsPtr> ModuleBase_WidgetMultiSelector::getAttributeSelection() const
406 QList<ModuleBase_ViewerPrsPtr> aSelected;
407 convertIndicesToViewerSelection(std::set<int>(), aSelected);
411 //********************************************************************
412 void ModuleBase_WidgetMultiSelector::updateSelectionList()
414 myListControl->clear();
416 DataPtr aData = myFeature->data();
417 AttributePtr anAttribute = aData->attribute(attributeID());
418 std::string aType = anAttribute->attributeType();
419 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
420 AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
421 for (int i = 0; i < aSelectionListAttr->size(); i++) {
422 AttributeSelectionPtr aAttr = aSelectionListAttr->value(i);
423 QListWidgetItem* anItem = new QListWidgetItem(aAttr->namingName().c_str(), myListControl);
424 anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, i);
425 myListControl->addItem(anItem);
428 else if (aType == ModelAPI_AttributeRefList::typeId()) {
429 AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
430 for (int i = 0; i < aRefListAttr->size(); i++) {
431 ObjectPtr anObject = aRefListAttr->object(i);
432 if (anObject.get()) {
433 QListWidgetItem* anItem = new QListWidgetItem(anObject->data()->name().c_str(),
435 anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, i);
436 myListControl->addItem(anItem);
440 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
441 AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
442 for (int i = 0; i < aRefAttrListAttr->size(); i++) {
443 AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
445 if (anAttribute.get()) {
446 std::string anAttrName = generateName(anAttribute, myWorkshop);
447 aName = QString::fromStdString(anAttrName);
450 ObjectPtr anObject = aRefAttrListAttr->object(i);
451 if (anObject.get()) {
452 aName = anObject->data()->name().c_str();
455 QListWidgetItem* anItem = new QListWidgetItem(aName, myListControl);
456 anItem->setData(ATTRIBUTE_SELECTION_INDEX_ROLE, i);
457 myListControl->addItem(anItem);
461 // We have to call repaint because sometimes the List control is not updated
462 myListControl->repaint();
465 //********************************************************************
466 std::string ModuleBase_WidgetMultiSelector::validatorType(const QString& theType) const
470 if (theType == "Vertices")
472 else if (theType == "Edges")
474 else if (theType == "Faces")
476 else if (theType == "Solids")
482 //********************************************************************
483 void ModuleBase_WidgetMultiSelector::onCopyItem()
485 QList<QListWidgetItem*> aItems = myListControl->selectedItems();
487 foreach(QListWidgetItem* aItem, aItems) {
490 aRes += aItem->text();
492 if (!aRes.isEmpty()) {
493 QClipboard *clipboard = QApplication::clipboard();
494 clipboard->setText(aRes);
498 //********************************************************************
499 void ModuleBase_WidgetMultiSelector::onDeleteItem()
504 //********************************************************************
505 void ModuleBase_WidgetMultiSelector::onListSelection()
507 QList<QListWidgetItem*> aItems = myListControl->selectedItems();
508 myCopyAction->setEnabled(!aItems.isEmpty());
509 myDeleteAction->setEnabled(!aItems.isEmpty());
511 myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
515 //********************************************************************
516 void ModuleBase_WidgetMultiSelector::getSelectedAttributeIndices(std::set<int>& theAttributeIds)
518 QList<QListWidgetItem*> aItems = myListControl->selectedItems();
519 foreach(QListWidgetItem* anItem, aItems) {
520 int anIndex = anItem->data(ATTRIBUTE_SELECTION_INDEX_ROLE).toInt();
521 if (theAttributeIds.find(anIndex) == theAttributeIds.end())
522 theAttributeIds.insert(anIndex);
526 void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<int> theAttributeIds,
527 QList<ModuleBase_ViewerPrsPtr>& theValues) const
529 if(myFeature.get() == NULL)
532 DataPtr aData = myFeature->data();
533 AttributePtr anAttribute = aData->attribute(attributeID());
534 std::string aType = anAttribute->attributeType();
535 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
536 AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
537 for (int i = 0; i < aSelectionListAttr->size(); i++) {
538 // filter by attribute indices only if the container is not empty otherwise return all items
539 if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end())
541 AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
542 ResultPtr anObject = anAttr->context();
544 theValues.append(std::shared_ptr<ModuleBase_ViewerPrs>(
545 new ModuleBase_ViewerPrs(anObject, anAttr->value(), NULL)));
548 else if (aType == ModelAPI_AttributeRefList::typeId()) {
549 AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
550 for (int i = 0; i < aRefListAttr->size(); i++) {
551 // filter by attribute indices only if the container is not empty otherwise return all items
552 if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end())
554 ObjectPtr anObject = aRefListAttr->object(i);
555 if (anObject.get()) {
556 theValues.append(std::shared_ptr<ModuleBase_ViewerPrs>(
557 new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL)));
561 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
562 AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
563 for (int i = 0; i < aRefAttrListAttr->size(); i++) {
564 // filter by attribute indices only if the container is not empty otherwise return all items
565 if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end())
567 ObjectPtr anObject = aRefAttrListAttr->object(i);
571 AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
572 if (anAttribute.get()) {
573 GeomShapePtr aGeomShape = ModuleBase_Tools::getShape(anAttribute, myWorkshop);
574 theValues.append(std::shared_ptr<ModuleBase_ViewerPrs>(
575 new ModuleBase_ViewerPrs(anObject, aGeomShape, NULL)));
581 void ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects
582 (QList<ModuleBase_ViewerPrsPtr>& theValues)
584 std::map<ObjectPtr, std::set<GeomShapePtr> > aGeomSelection = convertSelection(theValues);
585 DataPtr aData = myFeature->data();
586 AttributePtr anAttribute = aData->attribute(attributeID());
587 std::string aType = anAttribute->attributeType();
588 std::set<GeomShapePtr> aShapes;
589 std::set<int> anIndicesToBeRemoved;
590 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
591 // iteration through data model to find not selected elements to remove them
592 AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
593 for (int i = 0; i < aSelectionListAttr->size(); i++) {
594 AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
595 bool aFound = findInSelection(anAttr->context(), anAttr->value(), aGeomSelection);
597 anIndicesToBeRemoved.insert(i);
599 aSelectionListAttr->remove(anIndicesToBeRemoved);
601 else if (aType == ModelAPI_AttributeRefList::typeId()) {
602 AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
603 for (int i = 0; i < aRefListAttr->size(); i++) {
604 ObjectPtr anObject = aRefListAttr->object(i);
605 if (anObject.get()) {
606 bool aFound = findInSelection(anObject, GeomShapePtr(), aGeomSelection);
608 anIndicesToBeRemoved.insert(i);
611 aRefListAttr->remove(anIndicesToBeRemoved);
613 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
614 std::set<AttributePtr> anAttributes;
615 QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
618 for (; anIt != aLast; anIt++) {
619 ModuleBase_ViewerPrsPtr aPrs = *anIt;
620 getGeomSelection(aPrs, anObject, aShape);
621 AttributePtr anAttr = myWorkshop->module()->findAttribute(anObject, aShape);
622 if (anAttr.get() && anAttributes.find(anAttr) == anAttributes.end())
623 anAttributes.insert(anAttr);
626 AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
627 for (int i = 0; i < aRefAttrListAttr->size(); i++) {
629 if (aRefAttrListAttr->isAttribute(i)) {
630 AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
631 aFound = anAttributes.find(anAttribute) != anAttributes.end();
634 aFound = findInSelection(aRefAttrListAttr->object(i), GeomShapePtr(), aGeomSelection);
637 anIndicesToBeRemoved.insert(i);
639 aRefAttrListAttr->remove(anIndicesToBeRemoved);
643 std::map<ObjectPtr, std::set<GeomShapePtr> > ModuleBase_WidgetMultiSelector::convertSelection
644 (QList<ModuleBase_ViewerPrsPtr>& theValues)
646 // convert prs list to objects map
647 std::map<ObjectPtr, std::set<GeomShapePtr> > aGeomSelection;
648 std::set<GeomShapePtr> aShapes;
649 QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
652 GeomShapePtr anEmptyShape(new GeomAPI_Shape());
653 for (; anIt != aLast; anIt++) {
654 ModuleBase_ViewerPrsPtr aPrs = *anIt;
655 getGeomSelection(aPrs, anObject, aShape);
657 if (aGeomSelection.find(anObject) != aGeomSelection.end()) // found
658 aShapes = aGeomSelection[anObject];
659 // we need to know if there was an empty shape in selection for the object
661 aShape = anEmptyShape;
662 if (aShape.get() && aShapes.find(aShape) == aShapes.end()) // not found
663 aShapes.insert(aShape);
664 aGeomSelection[anObject] = aShapes;
666 return aGeomSelection;
669 bool ModuleBase_WidgetMultiSelector::findInSelection(const ObjectPtr& theObject,
670 const GeomShapePtr& theShape,
671 const std::map<ObjectPtr, std::set<GeomShapePtr> >& theGeomSelection)
674 GeomShapePtr anEmptyShape(new GeomAPI_Shape());
675 GeomShapePtr aShape = theShape.get() ? theShape : anEmptyShape;
676 if (theGeomSelection.find(theObject) != theGeomSelection.end()) {// found
677 const std::set<GeomShapePtr>& aShapes = theGeomSelection.at(theObject);
678 std::set<GeomShapePtr>::const_iterator anIt = aShapes.begin(), aLast = aShapes.end();
679 for (; anIt != aLast && !aFound; anIt++) {
680 GeomShapePtr aCShape = *anIt;
682 aFound = aCShape->isEqual(aShape);