#include "XGUI_ViewerProxy.h"
#include "XGUI_SelectionMgr.h"
#include "XGUI_Selection.h"
+#include "XGUI_CustomPrs.h"
#include <AppElements_Viewer.h>
: myWorkshop(theWorkshop)
{
enableUpdateViewer(true);
+ myCustomPrs = std::shared_ptr<GeomAPI_ICustomPrs>(new XGUI_CustomPrs());
}
XGUI_Displayer::~XGUI_Displayer()
aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
- customizeObject(theObject);
+ bool isCustomized = customizeObject(theObject);
+ if (isCustomized)
+ aContext->Redisplay(anAISIO, false);
+
if (aCanBeShaded) {
openLocalContext();
activateObjects(myActiveSelectionModes);
// before and after the values modification.
// Moreother, this check avoids customize and redisplay presentation if the presentable
// parameter is changed.
+ bool isEqualShapes = false;
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (aResult.get() != NULL) {
Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
std::shared_ptr<GeomAPI_Shape> anAISShapePtr(new GeomAPI_Shape());
anAISShapePtr->setImpl(new TopoDS_Shape(aShape));
- if (aShapePtr->isEqual(anAISShapePtr))
- return;
+ isEqualShapes = aShapePtr->isEqual(anAISShapePtr);
}
}
}
// Customization of presentation
- customizeObject(theObject);
-
- aContext->Redisplay(aAISIO, false);
- if (isUpdateViewer)
- updateViewer();
+ bool isCustomized = customizeObject(theObject);
+ if (!isEqualShapes || isCustomized) {
+ aContext->Redisplay(aAISIO, false);
+ if (isUpdateViewer)
+ updateViewer();
+ }
}
}
}
}
-void XGUI_Displayer::customizeObject(ObjectPtr theObject)
+bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
{
+ // we need not customize presentable objects
+ GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+ if (aPrs.get() != NULL)
+ return false;
+
AISObjectPtr anAISObj = getAISObject(theObject);
// correct the result's color it it has the attribute
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult.get() != NULL && aResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
- AttributeIntArrayPtr aColorAttr = aResult->data()->intArray(ModelAPI_Result::COLOR_ID());
- if (aColorAttr.get() && aColorAttr->size()) {
- int aRed = aColorAttr->value(0);
- int aGreen = aColorAttr->value(1);
- int aBlue = aColorAttr->value(2);
- anAISObj->setColor(aRed, aGreen, aBlue);
- }
- }
+
// Customization of presentation
+ GeomCustomPrsPtr aCustomPrs = myCustomPrs;
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
if (aFeature.get() != NULL) {
GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
if (aCustPrs.get() != NULL)
- aCustPrs->customisePresentation(anAISObj);
+ aCustomPrs = aCustPrs;
}
+ return aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
}