Salome HOME
"2.11 Constraint with a point from the intersection between an outer edge and plane...
[modules/shaper.git] / src / PartSet / PartSet_CustomPrs.cpp
index 54298f76d26bac7ab30faf396e433f216f7c93b8..3a0a054c76cd526a22ae881363ef56a8b7a65120 100755 (executable)
@@ -7,6 +7,7 @@
 #include <PartSet_CustomPrs.h>
 #include <PartSet_Module.h>
 #include "PartSet_OperationPrs.h"
+#include "PartSet_OverconstraintListener.h"
 
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_Workshop.h>
 //#define DO_NOT_VISUALIZE_CUSTOM_PRESENTATION
 
 PartSet_CustomPrs::PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop)
-  : myWorkshop(theWorkshop), myIsActive(false), myFeature(FeaturePtr())
+  : myWorkshop(theWorkshop), myFeature(FeaturePtr())
 {
   initPresentation(ModuleBase_IModule::CustomizeArguments);
   initPresentation(ModuleBase_IModule::CustomizeResults);
   initPresentation(ModuleBase_IModule::CustomizeHighlightedObjects);
+
+  myIsActive[ModuleBase_IModule::CustomizeArguments] = false;
+  myIsActive[ModuleBase_IModule::CustomizeResults] = false;
+  myIsActive[ModuleBase_IModule::CustomizeHighlightedObjects] = false;
 }
 
-bool PartSet_CustomPrs::isActive()
+bool PartSet_CustomPrs::isActive(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag)
 {
-  return myIsActive;
+  return myIsActive[theFlag];
 }
 
-bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpdateViewer)
+bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature,
+                                 const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                                 const bool theUpdateViewer)
 {
 #ifdef DO_NOT_VISUALIZE_CUSTOM_PRESENTATION
   return false;
 #endif
 
-  myIsActive = true;
+  myIsActive[theFlag] = true;
   myFeature = theFeature;
 
   bool isModified = false;
@@ -56,9 +63,10 @@ bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpd
   return isModified;
 }
 
-bool PartSet_CustomPrs::deactivate(const bool theUpdateViewer)
+bool PartSet_CustomPrs::deactivate(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                                   const bool theUpdateViewer)
 {
-  myIsActive = false;
+  myIsActive[theFlag] = false;
   bool isModified = false;
 
   erasePresentation(ModuleBase_IModule::CustomizeArguments, theUpdateViewer);
@@ -78,7 +86,7 @@ bool PartSet_CustomPrs::displayPresentation(
   // update the AIS objects content
   Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(theFlag);
   // do nothing if the feature can not be displayed [is moved from presentation, to be checked]
-  if (!myFeature.get() || !myWorkshop->module()->canDisplayObject(myFeature))
+  if (!myFeature.get())
     return isModified;
 
   switch (theFlag) {
@@ -98,7 +106,9 @@ bool PartSet_CustomPrs::displayPresentation(
   // redisplay AIS objects
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if (!aContext.IsNull() && !aContext->IsDisplayed(anOperationPrs)) {
-    if (anOperationPrs->hasShapes()) {
+    // when the feature can not be visualized in the module, the operation preview should not
+    // be visualized also
+    if (anOperationPrs->hasShapes() && myWorkshop->module()->canDisplayObject(myFeature)) {
       // set color here because it can be changed in preferences
       Quantity_Color aShapeColor = getShapeColor(theFlag);
       anOperationPrs->setShapeColor(aShapeColor);
@@ -112,7 +122,9 @@ bool PartSet_CustomPrs::displayPresentation(
     }
   }
   else {
-    if (!anOperationPrs->hasShapes()) {
+    // when the feature can not be visualized in the module, the operation preview should not
+    // be visualized also
+    if (!anOperationPrs->hasShapes() || !myWorkshop->module()->canDisplayObject(myFeature)) {
       erasePresentation(theFlag, theUpdateViewer);
       isModified = true;
     }
@@ -162,7 +174,9 @@ bool PartSet_CustomPrs::redisplay(const ObjectPtr& theObject,
 #ifdef DO_NOT_VISUALIZE_CUSTOM_PRESENTATION
   return false;
 #endif
-  return displayPresentation(theFlag, theUpdateViewer);
+  bool aRedisplayed = displayPresentation(theFlag, theUpdateViewer);
+
+  return aRedisplayed;
 }
 
 void PartSet_CustomPrs::clearPrs()