}
if (!aAISIO.IsNull()) {
- // 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
- // 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.
- //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);
- // if (!aShapePrs.IsNull()) {
- // std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
- // if (aShapePtr.get()) {
- // const TopoDS_Shape& aOldShape = aShapePrs->Shape();
- // if (!aOldShape.IsNull())
- // isEqualShapes = aOldShape.IsEqual(aShapePtr->impl<TopoDS_Shape>());
- // }
- // }
- //}
- // Customization of presentation
- //bool isCustomized = customizeObject(theObject);
- #ifdef DEBUG_FEATURE_REDISPLAY
- qDebug(QString("Redisplay: %1, isEqualShapes=%2").
- arg(!isEqualShapes/* || isCustomized*/).arg(isEqualShapes)
- .toStdString().c_str());
- #endif
- //if (!isEqualShapes/* || isCustomized*/) {
- // /// if shapes are equal and presentation are customized, selection should be restored
- // bool aNeedToRestoreSelection = isEqualShapes/* && isCustomized*/;
- // if (aNeedToRestoreSelection)
- if (aAISObj.get() && myWorkshop->facesPanel())
- myWorkshop->facesPanel()->customizeObject(theObject, aAISObj);
-
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get()) {
+ // Set color
+ std::vector<int> aColor;
+ ModelAPI_Tools::getColor(aResult, aColor);
+ if (aColor.size() > 0) {
+ aAISIO->SetColor(Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB));
+ }
+ // Set deflection
+ double aDeflection = ModelAPI_Tools::getDeflection(aResult);
+ if ((aDeflection >= 0) && (aDeflection != aAISObj->getDeflection()))
+ aAISObj->setDeflection(aDeflection);
+
+ // Set transparency
+ double aTransparency = ModelAPI_Tools::getTransparency(aResult);
+ if ((aTransparency >= 0) && (aTransparency != aAISObj->getTransparency()))
+ aAISObj->setTransparency(aTransparency);
+ }
myWorkshop->module()->storeSelection();
#ifdef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
myWorkshop->selector()->deselectPresentation(aAISIO);
#endif
+
if (aContext->IsDisplayed(aAISIO))
aContext->Redisplay(aAISIO, false);
else {
#include <ExchangePlugin_ImportPart.h>
#include <GeomAPI_Pnt.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <ModuleBase_IModule.h>
#include <ModuleBase_IViewer.h>
aColorAttr->setValue(1, theColor[1]);
aColorAttr->setValue(2, theColor[2]);
}
- static const Events_ID kRedisplayEvent =
- Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- ModelAPI_EventCreator::get()->sendUpdated(theResult, kRedisplayEvent);
+}
+
+//**************************************************************
+void getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
+ std::vector<int>& theColor)
+{
+ theColor.clear();
+ // get default color from the preferences manager for the given result
+ if (theColor.empty()) {
+ std::string aSection, aName, aDefault;
+ theObject->colorConfigInfo(aSection, aName, aDefault);
+ if (!aSection.empty() && !aName.empty()) {
+ theColor = Config_PropManager::color(aSection, aName);
+ }
+ }
+ if (!isEmptyColorValid && theColor.empty()) {
+ // all AIS objects, where the color is not set, are in black.
+ // The color should be defined in XML or set in the attribute
+ theColor = Config_PropManager::color("Visualization", "object_default_color");
+ Events_InfoMessage("XGUI_CustomPrs",
+ "A default color is not defined in the preferences for this kind of result").send();
+ }
}
//**************************************************************
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
ModelAPI_Tools::getColor(aResult, aColor);
+ if (aColor.empty())
+ getDefaultColor(aResult, false, aColor);
}
else {
// TODO: remove the obtaining a color from the AIS object
setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor());
}
}
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
aMgr->finishOperation();
updateCommandStatus();
+ myViewerProxy->update();
}
//**************************************************************
return;
AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
- if (aDeflectionAttr.get() != NULL)
+ if (aDeflectionAttr.get() != NULL) {
aDeflectionAttr->setValue(theDeflection);
- static const Events_ID kRedisplayEvent =
- Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- ModelAPI_EventCreator::get()->sendUpdated(theResult, kRedisplayEvent);
+ }
}
//**************************************************************
return;
AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
- if (anAttribute.get() != NULL)
+ if (anAttribute.get() != NULL) {
anAttribute->setValue(theTransparency);
- static const Events_ID kRedisplayEvent =
- Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- ModelAPI_EventCreator::get()->sendUpdated(theResult, kRedisplayEvent);
+ }
}
//**************************************************************
if (aBodyResult.get() != NULL) { // change property for all sub-solids
std::list<ResultPtr> allRes;
ModelAPI_Tools::allSubs(aBodyResult, allRes);
- for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ std::list<ResultPtr>::iterator aRes;
+ for(aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
setTransparency(*aRes, theTransparency);
}
}
}
}
+//**************************************************************
+double getDefaultDeflection(const ObjectPtr& theObject)
+{
+ double aDeflection = -1;
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get()) {
+ bool isConstruction = false;
+
+ std::string aResultGroup = aResult->groupName();
+ if (aResultGroup == ModelAPI_ResultConstruction::group())
+ isConstruction = true;
+ else if (aResultGroup == ModelAPI_ResultBody::group()) {
+ GeomShapePtr aGeomShape = aResult->shape();
+ if (aGeomShape.get()) {
+ // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
+ // correction of deviation for them should not influence to the application performance
+ GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
+ isConstruction = !anExp.more();
+ }
+ }
+ if (isConstruction)
+ aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
+ else
+ aDeflection = Config_PropManager::real("Visualization", "body_deflection");
+ }
+ return aDeflection;
+}
+
//**************************************************************
void XGUI_Workshop::changeDeflection(const QObjectPtrList& theObjects)
{
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
aDeflection = ModelAPI_Tools::getDeflection(aResult);
+ if (aDeflection < 0)
+ aDeflection = getDefaultDeflection(aResult);
}
else {
// TODO: remove the obtaining a property from the AIS object
setDeflection(aResult, aDeflection);
}
}
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
aMgr->finishOperation();
updateCommandStatus();
}
+//**************************************************************
+double getDefaultTransparency(const ResultPtr& theResult)
+{
+ return Config_PropManager::integer("Visualization", "shaper_default_transparency") / 100.;
+}
+
//**************************************************************
void XGUI_Workshop::changeTransparency(const QObjectPtrList& theObjects)
{
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
aCurrentValue = ModelAPI_Tools::getTransparency(aResult);
+ if (aCurrentValue < 0)
+ aCurrentValue = getDefaultTransparency(aResult);
}
if (aCurrentValue > 0)
break;
QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
setTransparency(aTransparencyWidget->getValue(), anObjects);
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ static const Events_ID kRedisplayEvent =
+ Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ Events_Loop::loop()->flush(kRedisplayEvent);
+
+ myViewerProxy->update();
}