#include "PartSet_OperationPrs.h"
#include "PartSet_Tools.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_ModuleConnector.h"
+#include "XGUI_Displayer.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 <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++) {
// 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;
+}
+
void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
{
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();
+}
DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape)
+class XGUI_Workshop;
+class XGUI_Displayer;
+
/**
* \ingroup GUI
* A redefinition of standard AIS Interactive Object in order to provide colored presentation of
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode) ;
private:
+ /// Return true if the object is visible. If the object is feature, it returns true
+ /// if all results of the feature are shown
+ /// \param theDisplayer a displayer
+ /// \param theObject an object
+ /// \return a boolean value
+ bool isVisible(XGUI_Displayer* theDislayer, const ObjectPtr& theObject);
+
/// Fills the map by the feature object and shapes, which should be visuaziled
/// Gets the feature attribute, collect objects to whom the attribute refers
/// \param theObjectShape an output map of objects
/// \return a boolean value
static bool isSelectionAttribute(const AttributePtr& theAttribute);
+ /// Converts the current workshop to XGUI workshop
+ /// \return a workshop instance
+ XGUI_Workshop* workshop() const;
+
private:
ModuleBase_IWorkshop* myWorkshop;
FeaturePtr myFeature; /// Reference to a feature object