Qt::UniqueConnection);
activateShapeSelection(true);
- QList<ModuleBase_ViewerPrs> aSelected;
+
// Restore selection in the viewer by the attribute selection list
- if(myFeature) {
- DataPtr aData = myFeature->data();
- AttributeSelectionListPtr aListAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
- if (aListAttr) {
- for (int i = 0; i < aListAttr->size(); i++) {
- AttributeSelectionPtr anAttr = aListAttr->value(i);
- ResultPtr anObject = anAttr->context();
- if (anObject.get()) {
- TopoDS_Shape aShape;
- std::shared_ptr<GeomAPI_Shape> aShapePtr = anAttr->value();
- if (aShapePtr.get()) {
- aShape = aShapePtr->impl<TopoDS_Shape>();
- }
- aSelected.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));
- }
- }
- }
- }
- myWorkshop->setSelected(aSelected);
+ myWorkshop->setSelected(getCurrentSelection());
activateFilters(myWorkshop, true);
}
}
}
+QList<ModuleBase_ViewerPrs> ModuleBase_WidgetMultiSelector::getCurrentSelection() const
+{
+ QList<ModuleBase_ViewerPrs> aSelected;
+ // Restore selection in the viewer by the attribute selection list
+ if(myFeature) {
+ DataPtr aData = myFeature->data();
+ AttributeSelectionListPtr aListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
+ if (aListAttr) {
+ for (int i = 0; i < aListAttr->size(); i++) {
+ AttributeSelectionPtr anAttr = aListAttr->value(i);
+ ResultPtr anObject = anAttr->context();
+ if (anObject.get()) {
+ TopoDS_Shape aShape;
+ std::shared_ptr<GeomAPI_Shape> aShapePtr = anAttr->value();
+ if (aShapePtr.get()) {
+ aShape = aShapePtr->impl<TopoDS_Shape>();
+ }
+ aSelected.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));
+ }
+ }
+ }
+ }
+ return aSelected;
+}
+
//********************************************************************
void ModuleBase_WidgetMultiSelector::updateSelectionList(AttributeSelectionListPtr theList)
{
/// \param isActivated a state whether the shape is activated or deactivated in selection
void activateShapeSelection(const bool isActivated);
+ /// Return the attribute values wrapped in a list of viewer presentations
+ /// \return a list of viewer presentations, which contains an attribute result and
+ /// a shape. If the attribute do not uses the shape, it is empty
+ QList<ModuleBase_ViewerPrs> getCurrentSelection() const;
+
protected:
/// Update selection list
void updateSelectionList(AttributeSelectionListPtr);
return isChanged;
}
+//********************************************************************
+QList<ModuleBase_ViewerPrs> ModuleBase_WidgetShapeSelector::getCurrentSelection() const
+{
+ QList<ModuleBase_ViewerPrs> aSelected;
+ if(myFeature) {
+ DataPtr aData = myFeature->data();
+ AttributePtr anAttribute = myFeature->attribute(attributeID());
+
+ ObjectPtr anObject = GeomValidators_Tools::getObject(anAttribute);
+ TopoDS_Shape aShape;
+ std::shared_ptr<GeomAPI_Shape> aShapePtr = getShape();
+ if (aShapePtr.get()) {
+ aShape = aShapePtr->impl<TopoDS_Shape>();
+ }
+ ModuleBase_ViewerPrs aPrs(anObject, aShape, NULL);
+ aSelected.append(aPrs);
+ }
+ return aSelected;
+}
+
//********************************************************************
void ModuleBase_WidgetShapeSelector::clearAttribute()
{
{
connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
activateSelection(true);
- // Restore selection in the viewer by the attribute selection list
- QList<ModuleBase_ViewerPrs> aSelected;
- if(myFeature) {
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = myFeature->attribute(attributeID());
- ObjectPtr anObject = GeomValidators_Tools::getObject(anAttribute);
- TopoDS_Shape aShape;
- std::shared_ptr<GeomAPI_Shape> aShapePtr = getShape();
- if (aShapePtr.get()) {
- aShape = aShapePtr->impl<TopoDS_Shape>();
- }
- ModuleBase_ViewerPrs aPrs(anObject, aShape, NULL);
- aSelected.append(aPrs);
- }
- myWorkshop->setSelected(aSelected);
+ // Restore selection in the viewer by the attribute selection list
+ myWorkshop->setSelected(getCurrentSelection());
activateFilters(myWorkshop, true);
}
/// \return true if it is succeed
virtual bool setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape);
+ /// Return the attribute values wrapped in a list of viewer presentations
+ /// \return a list of viewer presentations, which contains an attribute result and
+ /// a shape. If the attribute do not uses the shape, it is empty
+ QList<ModuleBase_ViewerPrs> getCurrentSelection() const;
+
//----------- Class members -------------
protected:
/// Label of the widget