if (!anObject)
return aCustomized;
- std::vector<int> aColor;
- //bool aCustomColor = myOverconstraintListener->hasCustomColor(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)
+ std::vector<int> aColor;
XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
if (!aColor.empty()) {
aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
- // }
}
}
// customize dimentional constrains
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;
- }
- }
+ bool aUseCustomColor = true;
+ if (aUseCustomColor)
+ myOverconstraintListener->getCustomColor(anObject, aColor);
+ // customize sketch symbol presentation
+ 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;
}
- //}
- // customize sketch dimension constraint presentation
- if (!aCustomized) {
- //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]);
+ } 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 (!aColor.empty()) { // otherwise presentation has the default color
+ aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+ }
+ }
return aCustomized;
}
//#define DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
PartSet_OverconstraintListener::PartSet_OverconstraintListener(ModuleBase_IWorkshop* theWorkshop)
-: myWorkshop(theWorkshop), myIsFullyConstrained(false)//, myIsNeedUpdateCustomColor(false)
+: myWorkshop(theWorkshop), myIsFullyConstrained(false)
{
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED));
}
if (myIsFullyConstrained) {
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
- if (aFeature.get()) {
+ // only entity features has custom color when sketch is fully constrained
+ if (aFeature.get() && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
CompositeFeaturePtr aCompositeFeature = aModule->sketchMgr()->activeSketch();
// the given object is sub feature of the current sketch(created or edited)
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;
}
}
else if (anEventID == Events_Loop::eventByName(EVENT_OBJECT_CREATED)) {
/// \return boolean result
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