+ #ifdef DEBUG_EMPTY_SHAPE
+ qDebug(QString("Empty shape in result, result: %1")
+ .arg(ModuleBase_Tools::objectInfo(theObject)).toStdString().c_str());
+ #endif
+ }
+ }
+}
+
+void PartSet_OperationPrs::getFeatureShapes(const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop,
+ QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
+{
+ theObjectShapes.clear();
+ if (!theFeature.get())
+ return;
+
+ ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+
+ QList<GeomShapePtr> aShapes;
+ std::list<AttributePtr> anAttributes = theFeature->data()->attributes("");
+ std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
+ for (; anIt != aLast; anIt++) {
+ AttributePtr anAttribute = *anIt;
+ if (!isSelectionAttribute(anAttribute))
+ continue;
+
+ if (!aValidators->isCase(theFeature, anAttribute->id()))
+ continue; // this attribute is not participated in the current case
+
+ std::string anAttrType = anAttribute->attributeType();
+
+ if (anAttrType == ModelAPI_AttributeSelectionList::typeId()) {
+ std::shared_ptr<ModelAPI_AttributeSelectionList> aCurSelList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
+ for(int i = 0; i < aCurSelList->size(); i++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
+ ResultPtr aResult = aSelAttribute->context();
+ GeomShapePtr aShape = aSelAttribute->value();
+ addValue(aResult, aShape, theFeature, theWorkshop, theObjectShapes);
+ }
+ }
+ if (anAttrType == ModelAPI_AttributeRefList::typeId()) {
+ std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
+ for (int i = 0; i < aCurSelList->size(); i++) {
+ ObjectPtr anObject = aCurSelList->object(i);
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+ // if a feature is stored in the attribute, we should obtain the feature results
+ // e.g. feature rectangle uses parameters feature lines in the attribute
+ if (aFeature.get()) {
+ getResultShapes(aFeature, theWorkshop, theObjectShapes, false);
+ }
+ else {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ if (aResult.get()) {
+ GeomShapePtr aShape = aResult->shape();
+ if (aShape.get())
+ addValue(aResult, aShape, theFeature, theWorkshop, theObjectShapes);
+ }
+ }
+ }
+ }
+ else {
+ ObjectPtr anObject;
+ GeomShapePtr aShape;
+ if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
+ AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttribute);
+ if (anAttr->isObject()) {
+ anObject = anAttr->object();
+ }
+ else {
+ AttributePtr anAttribute = anAttr->attr();
+ aShape = PartSet_Tools::findShapeBy2DPoint(anAttribute, theWorkshop);
+ // the distance point is not found if the point is selected in the 2nd time
+ // TODO: after debug, this check can be removed
+ if (!aShape.get())
+ continue;
+ anObject = anAttr->attr()->owner();
+ }
+ }
+ if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
+ AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
+ anObject = anAttr->context();
+ aShape = anAttr->value();
+ }
+ if (anAttrType == ModelAPI_AttributeReference::typeId()) {
+ AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(anAttribute);
+ anObject = anAttr->value();
+ }
+ addValue(anObject, aShape, theFeature, theWorkshop, theObjectShapes);
+ }
+ }
+}
+
+void PartSet_OperationPrs::getResultShapes(const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop,
+ QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
+ const bool theListShouldBeCleared)
+{
+ if (theListShouldBeCleared)
+ theObjectShapes.clear();
+
+ if (!theFeature.get())
+ return;
+
+ XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer();
+
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(theFeature, aResults);
+ std::list<ResultPtr>::const_iterator aRIt = aResults.begin(),
+ aRLast = aResults.end();
+ for (; aRIt != aRLast; aRIt++) {
+ ResultPtr aResult = *aRIt;
+ GeomShapePtr aGeomShape = aResult->shape();
+ appendShapeIfVisible(theWorkshop, aResult, aGeomShape, theObjectShapes);
+ }
+}
+
+void PartSet_OperationPrs::getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
+ QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
+{
+ theObjectShapes.clear();
+
+ QList<ModuleBase_ViewerPrsPtr> aValues;
+ ModuleBase_IPropertyPanel* aPanel = theWorkshop->propertyPanel();
+ if (aPanel) {
+ ModuleBase_ModelWidget* aWidget = aPanel->activeWidget();
+ if (aWidget) {
+ aWidget->getHighlighted(aValues);