Drawings SDK provides the OdDbVisualStyle::trait() and OdDbVisualStyle::setTrait() methods to modify properties of visual styles.
The trait() method returns a value of a specified property. For example, to get the current value of the kFaceLightingModel property use this kind of code:
OdGiVariantPtr pGiVariant = pVStyle->trait(OdGiVisualStyleProperties::kFaceLightingModel);
if (pGiVariant->asInt() == OdGiVisualStyleProperties::kPhong)
odPrintConsoleString(L"\nFace Lighting Model = Phong");
The setTrait() method has realizations for each property type: boolean, color, double, integer, string, etc. It is convenient to use this one method for setting values of all visual styles properties. For example, to set the kEdgeModel property this kind of code can be used:
pVStyle->setTrait(OdGiVisualStyleProperties::kEdgeModel, (OdInt32)OdGiVisualStyleProperties::kFacetEdges, OdGiVisualStyleOperations::kSet);
Displaying some properties depends on whether an appropriate flag is set or not. For example, the kFaceOpacity property and the kFaceOpacity flag, the intersection edges properties and the kIntersection flag. To check whether a flag is enabled, the OdDbVisualStyle::traitFlag() method is used.
To set a flag, use the OdDbVisualStyle::setTraitFlag() method. Example below shows the usage of traitFlag() and setTraitFlag() methods, and demonstrates an editing of the kFaceOpacity property.
// Get the current value of the kFaceOpacityFlag
bool flag = pVStyle->traitFlag(OdGiVisualStyleProperties::kFaceModifiers, OdGiVisualStyleProperties::kFaceOpacityFlag);
// Check if the kFaceOpacityFlag is enabled. If not - set the kFaceOpacityFlag and enable displaying the kFaceOpacity property
if(!flag)
pVStyle->setTraitFlag(OdGiVisualStyleProperties::kFaceModifiers, OdGiVisualStyleProperties::kFaceOpacityFlag, true);
// Set a new double value of the kFaceOpacity property
pVStyle->setTrait(OdGiVisualStyleProperties::kFaceOpacity, 0.3, OdGiVisualStyleOperations::kSet);
See also
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|