#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_AttributeColor.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);
}
}
// 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(aAISObj);
- }
+ customizeObject(theObject);
aContext->Redisplay(aAISIO, false);
if (isUpdateViewer)
}
}
}
+
+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) {
+ int aRed, aGreen, aBlue;
+
+ AttributeColorPtr aColorAttr = std::dynamic_pointer_cast<ModelAPI_AttributeColor>(
+ aResult->data()->attribute(ModelAPI_Result::COLOR_ID()));
+ aColorAttr->values(aRed, aGreen, aBlue);
+ 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);
+ }
+ }
+}
/// Opens local context. Does nothing if it is already opened.
void openLocalContext();
+ /** Update the object presentable properties such as color, lines width and other
+ * If the object is result with the color attribute value set, it is used,
+ * otherwise the customize is applyed to the object's feature if it is a custom prs
+ * \param theObject an object instance
+ */
+ void customizeObject(ObjectPtr theObject);
+
protected:
/// Reference to workshop
XGUI_Workshop* myWorkshop;