]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#968 parameter creation problem
authornds <nds@opencascade.com>
Fri, 18 Sep 2015 04:25:22 +0000 (07:25 +0300)
committernds <nds@opencascade.com>
Fri, 18 Sep 2015 04:25:53 +0000 (07:25 +0300)
do not display operation presentation if there are not shapes/result on it.

src/PartSet/PartSet_CustomPrs.cpp
src/PartSet/PartSet_CustomPrs.h
src/PartSet/PartSet_OperationPrs.cpp
src/PartSet/PartSet_OperationPrs.h

index 0ac8ee0c6f4cd5b6e84a4fbcd5735c95df93a53d..ab7a858fb6b8f93ce4663815cfee12a14dd66ad1 100755 (executable)
 #define OPERATION_PARAMETER_COLOR "255, 255, 0"
 
 PartSet_CustomPrs::PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop)
-  : myWorkshop(theWorkshop)
+  : myWorkshop(theWorkshop), myIsActive(false)
 {
   initPrs();
 }
 
 bool PartSet_CustomPrs::isActive()
 {
-  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
+  return myIsActive;
+  /*Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
 
-  return !aContext.IsNull() && aContext->IsDisplayed(anOperationPrs);
+  return !aContext.IsNull() && aContext->IsDisplayed(anOperationPrs);*/
 }
 
 bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpdateViewer)
@@ -45,6 +46,7 @@ bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpd
   Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
 
   if (anOperationPrs->canActivate(theFeature)) {
+    myIsActive = true;
     anOperationPrs->setFeature(theFeature);
     if (theFeature.get()) {
       displayPresentation(theUpdateViewer);
@@ -56,6 +58,7 @@ bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpd
 
 bool PartSet_CustomPrs::deactivate(const bool theUpdateViewer)
 {
+  myIsActive = false;
   bool isModified = false;
 
   Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
@@ -77,16 +80,21 @@ void PartSet_CustomPrs::displayPresentation(const bool theUpdateViewer)
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if (!aContext.IsNull() && !aContext->IsDisplayed(anOperationPrs)) {
-    PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
-
-    XGUI_Workshop* aWorkshop = workshop();
-    aWorkshop->displayer()->displayAIS(myOperationPrs, false/*load object in selection*/, theUpdateViewer);
-    aContext->SetZLayer(anOperationPrs, aModule->getVisualLayerId());
+    if (anOperationPrs->hasShapes()) {
+      PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+      XGUI_Workshop* aWorkshop = workshop();
+      aWorkshop->displayer()->displayAIS(myOperationPrs, false/*load object in selection*/, theUpdateViewer);
+      aContext->SetZLayer(anOperationPrs, aModule->getVisualLayerId());
+    }
   }
   else {
-    anOperationPrs->Redisplay();
-    if (theUpdateViewer)
-      workshop()->displayer()->updateViewer();
+    if (!anOperationPrs->hasShapes())
+      erasePresentation(theUpdateViewer);
+    else {
+      anOperationPrs->Redisplay();
+      if (theUpdateViewer)
+        workshop()->displayer()->updateViewer();
+    }
   }
 }
 
@@ -111,16 +119,22 @@ bool PartSet_CustomPrs::redisplay(const ObjectPtr& theObject, const bool theUpda
   // [it should be hiddend] or the new AIS depend on it [it should be visualized]
   Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  if (!aContext.IsNull() && aContext->IsDisplayed(anOperationPrs)) {
-    // if there are performance poblems, to improve them, the necessity of redisplay can be checked
-    //bool aChanged = anOperationPrs->dependOn(theObject);
-    anOperationPrs->updateShapes();
-    //aChanged = aChanged || anOperationPrs->dependOn(theObject);
-    //if (aChanged)
-    anOperationPrs->Redisplay();
-    isModified = true;
-    if (theUpdateViewer)
-      workshop()->displayer()->updateViewer();
+  if (!aContext.IsNull()) {
+    if (aContext->IsDisplayed(anOperationPrs)) {
+      // if there are performance poblems, to improve them, the necessity of redisplay can be checked
+      //bool aChanged = anOperationPrs->dependOn(theObject);
+      anOperationPrs->updateShapes();
+      //aChanged = aChanged || anOperationPrs->dependOn(theObject);
+      //if (aChanged)
+      anOperationPrs->Redisplay();
+      isModified = true;
+      if (theUpdateViewer)
+        workshop()->displayer()->updateViewer();
+    }
+    else {
+      anOperationPrs->updateShapes();
+      displayPresentation(theUpdateViewer);
+    }
   }
   return isModified;
 }
index aafb37887e14d43379d6551750136d2a0e4c824b..d21bdd0e3afe43e303da98caec158062aaba447d 100755 (executable)
@@ -80,6 +80,7 @@ private:
   void customizePresentation(const bool theUpdateViewer);
 
 private:
+  bool myIsActive;
   ModuleBase_IWorkshop* myWorkshop; /// current workshop
   AISObjectPtr myOperationPrs; /// the AIS presentation, which is displayed/erased in the viewer
 };
index 1466994594869ee530523855c2cb73c5ebb9dbd7..58b5a53f50a2d1d93972b8bb9adc0cc63b19a013 100755 (executable)
@@ -76,10 +76,17 @@ void PartSet_OperationPrs::updateShapes()
     myFeatureResults = myFeature->results();
 }
 
+bool PartSet_OperationPrs::hasShapes()
+{
+  return !myFeatureShapes.empty() || !myFeatureResults.empty();
+}
+
 void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                                    const Handle(Prs3d_Presentation)& thePresentation, 
                                    const Standard_Integer theMode)
 {
+  if (!hasShapes())
+    return;
   // when the feature can not be visualized in the module, the operation preview should not
   // be visualized also
   if (!myWorkshop->module()->canDisplayObject(myFeature))
index ca3eaa2dd36d99cedac7848b63b7b2e8271957fe..64d92151ad5dfaebb3b741135ecb344d6aba6fc8 100755 (executable)
@@ -62,6 +62,9 @@ public:
   // Recompute internal list of shaped dependent on the current feature
   void updateShapes();
 
+  /// Returns true if the feature contains shapes or results
+  bool hasShapes();
+
   DEFINE_STANDARD_RTTI(PartSet_OperationPrs)
 
 protected: