#include "PartSet_OperationPrs.h"
#include "PartSet_Tools.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_ModuleConnector.h"
+#include "XGUI_Displayer.h"
+
+#include "ModuleBase_Tools.h"
+
#include <ModelAPI_Result.h>
#include <ModelAPI_Attribute.h>
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeRefList.h>
+
+
#include <GeomValidators_Tools.h>
+#include <GeomAPI_IPresentable.h>
+
#include <StdPrs_WFDeflectionShape.hxx>
#include <QList>
const Standard_Integer theMode)
{
thePresentation->Clear();
+ XGUI_Displayer* aDisplayer = workshop()->displayer();
// create presentations on the base of the shapes
Handle(Prs3d_Drawer) aDrawer = Attributes();
QMap<ObjectPtr, QList<GeomShapePtr> >::const_iterator anIt = myFeatureShapes.begin(),
aLast = myFeatureShapes.end();
for (; anIt != aLast; anIt++) {
+ ObjectPtr anObject = anIt.key();
+ if (!isVisible(aDisplayer, anObject))
+ continue;
QList<GeomShapePtr> aShapes = anIt.value();
QList<GeomShapePtr>::const_iterator aShIt = aShapes.begin(), aShLast = aShapes.end();
for (; aShIt != aShLast; aShIt++) {
GeomShapePtr aGeomShape = *aShIt;
+ if (!aGeomShape.get())
+ continue;
TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
+ // change deviation coefficient to provide more precise circle
+ ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
}
}
// the presentation is not used in the selection
}
+bool PartSet_OperationPrs::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject)
+{
+ bool aVisible = false;
+ GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aPrs.get() || aResult.get())
+ aVisible = theDisplayer->isVisible(theObject);
+ else {
+ // check if all results of the feature are visible
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ aVisible = !aResults.empty();
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ aVisible = aVisible && theDisplayer->isVisible(*aIt);
+ }
+ }
+ return aVisible;
+}
+
+bool isSubObject(const ObjectPtr& theObject, const FeaturePtr& theFeature)
+{
+ bool isSub = false;
+ CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
+ if (aComposite.get())
+ isSub = aComposite->isSub(theObject);
+
+ return isSub;
+}
+
void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
+ const FeaturePtr& theFeature,
QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
{
- if (theObjectShapes.contains(theObject))
- theObjectShapes[theObject].append(theShape);
- else {
- QList<GeomShapePtr> aShapes;
- aShapes.append(theShape);
- theObjectShapes[theObject] = aShapes;
+ if (theObject.get()) {
+ GeomShapePtr aShape = theShape;
+ if (!aShape.get()) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get())
+ aShape = aResult->shape();
+ }
+ if (!isSubObject(theObject, theFeature)) {
+ if (theObjectShapes.contains(theObject))
+ theObjectShapes[theObject].append(aShape);
+ else {
+ QList<GeomShapePtr> aShapes;
+ aShapes.append(aShape);
+ theObjectShapes[theObject] = aShapes;
+ }
+ }
}
}
std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
ResultPtr aResult = aSelAttribute->context();
GeomShapePtr aShape = aSelAttribute->value();
- if (!aShape.get())
- aShape = aResult->shape();
- addValue(aResult, aShape, theObjectShapes);
+ addValue(aResult, aShape, myFeature, 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++) {
+ GeomShapePtr aShape;
+ addValue(aCurSelList->object(i), aShape, myFeature, theObjectShapes);
}
}
else {
AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(anAttribute);
anObject = anAttr->value();
}
-
- if (anObject.get()) {
- if (!aShape.get()) {
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
- if (aResult.get())
- aShape = aResult->shape();
- }
- addValue(anObject, aShape, theObjectShapes);
- }
+ addValue(anObject, aShape, myFeature, theObjectShapes);
}
}
}
std::string anAttrType = theAttribute->attributeType();
return anAttrType == ModelAPI_AttributeSelectionList::typeId() ||
+ anAttrType == ModelAPI_AttributeRefList::typeId() ||
anAttrType == ModelAPI_AttributeRefAttr::typeId() ||
anAttrType == ModelAPI_AttributeSelection::typeId() ||
anAttrType == ModelAPI_AttributeReference::typeId();
}
+
+XGUI_Workshop* PartSet_OperationPrs::workshop() const
+{
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+ return aConnector->workshop();
+}