std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
for (int i = 0; i < aCurSelList->size(); i++) {
- GeomShapePtr aShape;
- addValue(aCurSelList->object(i), aShape, theFeature, theObjectShapes);
+ ObjectPtr anObject = aCurSelList->object(i);
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+ // feature rectangle uses as parameters feature lines, so we should obtain line results
+ 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, theObjectShapes);
+ }
+ }
}
}
else {
anObject = anAttr->object();
}
else {
- aShape = PartSet_Tools::findShapeBy2DPoint(anAttr, theWorkshop);
+ 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())
void PartSet_OperationPrs::getResultShapes(const FeaturePtr& theFeature,
ModuleBase_IWorkshop* theWorkshop,
- QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
+ QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
+ const bool theListShouldBeCleared)
{
- theObjectShapes.clear();
+ if (theListShouldBeCleared)
+ theObjectShapes.clear();
if (!theFeature.get())
return;
}
GeomShapePtr PartSet_Tools::findShapeBy2DPoint(const AttributePtr& theAttribute,
- ModuleBase_IWorkshop* theWorkshop)
+ ModuleBase_IWorkshop* theWorkshop)
{
- // 1. find an attribute value in attribute reference attribute value
GeomShapePtr aShape;
- AttributeRefAttrPtr aRefAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (aRefAttr) {
- if (!aRefAttr->isObject()) {
- AttributePtr theAttribute = aRefAttr->attr();
- if (theAttribute.get()) {
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
- XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
-
- // 2. find visualized vertices of the attribute and if the attribute of the vertex is
- // the same, return it
- FeaturePtr anAttributeFeature = ModelAPI_Feature::feature(theAttribute->owner());
- // 2.1 get visualized results of the feature
- const std::list<ResultPtr>& aResList = anAttributeFeature->results();
- std::list<ResultPtr>::const_iterator anIt = aResList.begin(), aLast = aResList.end();
- for (; anIt != aLast; anIt++) {
- AISObjectPtr aAISObj = aDisplayer->getAISObject(*anIt);
- if (aAISObj.get() != NULL) {
- Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
- // 2.2 find selected owners of a visualizedd object
- SelectMgr_IndexedMapOfOwner aSelectedOwners;
- aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
- for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
- Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
- if (!anOwner.IsNull()) {
- Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
- if (!aBRepOwner.IsNull() && aBRepOwner->HasShape()) {
- const TopoDS_Shape& aBRepShape = aBRepOwner->Shape();
- if (aBRepShape.ShapeType() == TopAbs_VERTEX) {
- // 2.3 if the owner is vertex and an attribute of the vertex is equal to the initial
- // attribute, returns the shape
- PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(theWorkshop->module());
- PartSet_SketcherMgr* aSketchMgr = aModule->sketchMgr();
- AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(anAttributeFeature,
- aBRepShape, aSketchMgr->activeSketch());
- if (aPntAttr.get() != NULL && aPntAttr == theAttribute) {
- aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
- aShape->setImpl(new TopoDS_Shape(aBRepShape));
- break;
- }
- }
- }
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+ // 2. find visualized vertices of the attribute and if the attribute of the vertex is
+ // the same, return it
+ FeaturePtr anAttributeFeature = ModelAPI_Feature::feature(theAttribute->owner());
+ // 2.1 get visualized results of the feature
+ const std::list<ResultPtr>& aResList = anAttributeFeature->results();
+ std::list<ResultPtr>::const_iterator anIt = aResList.begin(), aLast = aResList.end();
+ for (; anIt != aLast; anIt++) {
+ AISObjectPtr aAISObj = aDisplayer->getAISObject(*anIt);
+ if (aAISObj.get() != NULL) {
+ Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ // 2.2 find selected owners of a visualizedd object
+ SelectMgr_IndexedMapOfOwner aSelectedOwners;
+ aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
+ for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
+ Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
+ if (!anOwner.IsNull()) {
+ Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
+ if (!aBRepOwner.IsNull() && aBRepOwner->HasShape()) {
+ const TopoDS_Shape& aBRepShape = aBRepOwner->Shape();
+ if (aBRepShape.ShapeType() == TopAbs_VERTEX) {
+ // 2.3 if the owner is vertex and an attribute of the vertex is equal to the initial
+ // attribute, returns the shape
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(theWorkshop->module());
+ PartSet_SketcherMgr* aSketchMgr = aModule->sketchMgr();
+ AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(anAttributeFeature,
+ aBRepShape, aSketchMgr->activeSketch());
+ if (aPntAttr.get() != NULL && aPntAttr == theAttribute) {
+ aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
+ aShape->setImpl(new TopoDS_Shape(aBRepShape));
+ break;
}
}
}