#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_AttributeIntArray.h>
#include <ModuleBase_ResultPrs.h>
aContext->Display(anAISIO, false);
aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
- // Customization of presentation
- 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(theAIS);
- }
+
+ customizeObject(theObject);
if (aCanBeShaded) {
openLocalContext();
activateObjects(myActiveSelectionModes);
// Check that the visualized shape is the same and the redisplay is not necessary
// Redisplay of AIS object leads to this object selection compute and the selection
// in the browser is lost
- // become
+
+ // this check is not necessary anymore because the selection store/restore is realized
+ // before and after the values modification.
+ // Moreother, this check avoids customize and redisplay presentation if the presentable
+ // parameter is changed.
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (aResult.get() != NULL) {
Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
}
}
}
+ // Customization of presentation
+ customizeObject(theObject);
+
aContext->Redisplay(aAISIO, false);
if (isUpdateViewer)
updateViewer();
}
}
}
+
+void XGUI_Displayer::customizeObject(ObjectPtr theObject)
+{
+ 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);
+ }
+ }
+ else {
+ // Customization of presentation
+ 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);
+ }
+ }
+}