AISObjectPtr thePrs,
GeomCustomPrsPtr theCustomPrs) { return false; };
+ /// Modifies the given presentation in the custom way after usual customize is performed.
+ virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+ AISObjectPtr thePrs,
+ GeomCustomPrsPtr theCustomPrs) { return false; };
+
/// 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
return aCustomized;
std::vector<int> aColor;
- bool aCustomColor = myOverconstraintListener->hasCustomColor(anObject, aColor);
+ //bool aCustomColor = myOverconstraintListener->hasCustomColor(anObject, aColor);
if (!theResult.get()) {
- // customize sketch symbol presentation
+ /*// customize sketch symbol presentation
if (thePrs.get()) {
Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
}
}
}
+ }*/
+ // customize sketch dimension constraint presentation
+ //if (!aCustomized) {
+ // if (!aCustomColor)
+ XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
+ if (!aColor.empty()) {
+ aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+ // }
}
+ }
+ // customize dimentional constrains
+ sketchMgr()->customizePresentation(anObject);
+
+ return aCustomized;
+}
+
+bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+ AISObjectPtr thePrs,
+ GeomCustomPrsPtr theCustomPrs)
+{
+ bool aCustomized = false;
+
+ XGUI_Workshop* aWorkshop = getWorkshop();
+ XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+ ObjectPtr anObject = aDisplayer->getObject(thePrs);
+ if (!anObject)
+ return aCustomized;
+
+ std::vector<int> aColor;
+ bool aCustomColorChanged = myOverconstraintListener->isNeedUpdateCustomColor();
+ if (aCustomColorChanged) {
+ bool aUseCustomColor = true;
+ // do not use fully constrained color if create operation is started
+ /*if (aWorkshop->operationMgr()->hasOperation()) {
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (aWorkshop->operationMgr()->currentOperation());
+ if (aFOperation && !aFOperation->isEditOperation())
+ aUseCustomColor = false;
+ }*/
+ if (aUseCustomColor)
+ myOverconstraintListener->getCustomColor(anObject, aColor);
+ //if (!theResult.get()) {
+ // customize sketch symbol presentation
+ //if (thePrs.get()) {
+ Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
+ if (!anAISIO.IsNull()) {
+ if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
+ Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
+ if (!aPrs.IsNull()) {
+ aPrs->SetCustomColor(aColor);
+ aCustomized = true;
+ }
+ } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
+ Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
+ if (!aPrs.IsNull()) {
+ aPrs->SetCustomColor(aColor);
+ aCustomized = true;
+ }
+ }
+ }
+ //}
// customize sketch dimension constraint presentation
if (!aCustomized) {
- if (!aCustomColor)
- XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
- if (!aColor.empty()) {
+ //if (!aCustomColor)
+ // XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
+ if (!aColor.empty()) { // otherwise presentation has the default color
aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
}
}
}
- // customize dimentional constrains
- sketchMgr()->customizePresentation(anObject);
-
return aCustomized;
}
AISObjectPtr thePrs,
std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
+ /// Modifies the given presentation in the custom way after usual customize is performed.
+ virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+ AISObjectPtr thePrs,
+ GeomCustomPrsPtr theCustomPrs);
+
/// 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
//#define DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
PartSet_OverconstraintListener::PartSet_OverconstraintListener(ModuleBase_IWorkshop* theWorkshop)
-: myWorkshop(theWorkshop), myIsFullyConstrained(false)
+: myWorkshop(theWorkshop), myIsFullyConstrained(false), myIsNeedUpdateCustomColor(false)
{
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SKETCH_FULLY_CONSTRAINED));
}
-bool PartSet_OverconstraintListener::hasCustomColor(const ObjectPtr& theObject,
+void PartSet_OverconstraintListener::getCustomColor(const ObjectPtr& theObject,
std::vector<int>& theColor)
{
if (myConflictingObjects.find(theObject) != myConflictingObjects.end()) {
theColor.push_back(aColor.Red()*255.);
theColor.push_back(aColor.Green()*255.);
theColor.push_back(aColor.Blue()*255.);
- return true;
}
if (myIsFullyConstrained) {
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
if (ModelAPI_Tools::compositeOwner(aFeature) == aCompositeFeature) {
Quantity_Color aColor = ModuleBase_Tools::color("Visualization",
"sketch_fully_constrained_color");
- theColor.push_back(aColor.Red()*255.);
+ theColor.push_back(aColor.Red()*0.);
theColor.push_back(aColor.Green()*255.);
- theColor.push_back(aColor.Blue()*255.);
- return true;
+ theColor.push_back(aColor.Blue()*0.);
}
}
}
- return false;
}
void PartSet_OverconstraintListener::processEvent(
myIsFullyConstrained = anEventID == Events_Loop::eventByName(EVENT_SKETCH_FULLY_CONSTRAINED);
if (aPrevFullyConstrained != myIsFullyConstrained) {
+ myIsNeedUpdateCustomColor = true;
std::set<ObjectPtr> aModifiedObjects;
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch();
}
}
redisplayObjects(aModifiedObjects);
+ myIsNeedUpdateCustomColor = false;
}
}
/// \param theObject an object to be checked
/// \param theColor the output container to be filled in [red, green, blue] values
/// \return boolean result
- bool hasCustomColor(const ObjectPtr& theObject, std::vector<int>& theColor);
+ void getCustomColor(const ObjectPtr& theObject, std::vector<int>& theColor);
+
+ /// Returns true if custom color of presentations is changed and it should be redisplayed
+ /// \return boolean value
+ bool isNeedUpdateCustomColor() const { return true;/*myIsNeedUpdateCustomColor;*/ }
/// Redefinition of Events_Listener method
virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
std::set<ObjectPtr> myConflictingObjects;
ModuleBase_IWorkshop* myWorkshop;
bool myIsFullyConstrained; /// state if Solver is fully constrained, DOF = 0
+ bool myIsNeedUpdateCustomColor;
};
#endif
return isActivationChanged;
}
+//#define DEBUG_FULLY_CONSTRAINED
bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
{
AISObjectPtr anAISObj = getAISObject(theObject);
}
bool isCustomized = aCustomPrs.get() &&
aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
+#ifdef DEBUG_FULLY_CONSTRAINED
+ isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs) || isCustomized;
+#endif
return isCustomized;
}