]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To provide correct vtkObservers management
authorapo <apo@opencascade.com>
Wed, 28 Sep 2005 13:13:25 +0000 (13:13 +0000)
committerapo <apo@opencascade.com>
Wed, 28 Sep 2005 13:13:25 +0000 (13:13 +0000)
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsDeviceActor.cxx

index aa7c737def8fee097dbd577bd045b3efa21a5543..c986c59f26ba7388c572471672efa47663298296 100644 (file)
@@ -182,6 +182,8 @@ VISU_GaussPtsAct
 ::~VISU_GaussPtsAct()
 {
   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::~VISU_GaussPtsAct - this = "<<this);
+  SetImplicitFunctionWidget(NULL);
+  SetInteractor(NULL);
 }
 
 
@@ -307,14 +309,22 @@ VISU_GaussPtsAct
 ::SetImplicitFunctionWidget(VISU_ImplicitFunctionWidget* theWidget)
 {
   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::SetImplicitFunctionWidget - this = "<<this);
+  if(myWidget == theWidget)
+    return;
+
+  if(myWidget)
+    myWidget->RemoveObserver(myEventCallbackCommand.GetPointer());
+
+  if(theWidget){
+    theWidget->AddObserver(vtkCommand::EnableEvent, 
+                          myEventCallbackCommand.GetPointer(), 
+                          myPriority);
+    theWidget->AddObserver(vtkCommand::DisableEvent, 
+                          myEventCallbackCommand.GetPointer(), 
+                          myPriority);
+  }
 
   myWidget = theWidget;
-  theWidget->AddObserver(vtkCommand::EnableEvent, 
-                        myEventCallbackCommand.GetPointer(), 
-                        myPriority);
-  theWidget->AddObserver(vtkCommand::DisableEvent, 
-                        myEventCallbackCommand.GetPointer(), 
-                        myPriority);
 }
 
 bool
@@ -879,13 +889,26 @@ VISU_GaussPtsAct1
 {
   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetImplicitFunctionWidget - this = "<<this);
 
-  Superclass::SetImplicitFunctionWidget(theWidget);
+  if(myWidget == theWidget)
+    return;
 
-  myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction());
-  myInsideDeviceActor->SetVisibility(GetVisibility() && theWidget->IsEnabled());
+  if(myWidget){
+    myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
+    myInsideDeviceActor->SetVisibility(false);
+
+    myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);  
+    myOutsideDeviceActor->SetVisibility(false);
+  }
 
-  myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction());  
-  myOutsideDeviceActor->SetVisibility(GetVisibility() && theWidget->IsEnabled());
+  if(theWidget){
+    myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction());
+    myInsideDeviceActor->SetVisibility(GetVisibility() && theWidget->IsEnabled());
+
+    myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction());  
+    myOutsideDeviceActor->SetVisibility(GetVisibility() && theWidget->IsEnabled());
+  }
+
+  Superclass::SetImplicitFunctionWidget(theWidget);
 }
 
 
@@ -901,6 +924,7 @@ VISU_GaussPtsAct1
   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
     myInsideDeviceActor->SetPipeLine(aPipeLine);
   }
+
   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
     myOutsideDeviceActor->SetPipeLine(aPipeLine);
 
@@ -1007,14 +1031,24 @@ VISU_GaussPtsAct2
 {
   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetImplicitFunctionWidget - this = "<<this);
 
-  Superclass::SetImplicitFunctionWidget(theWidget);
+  if(myWidget == theWidget)
+    return;
 
-  theWidget->AddObserver(vtkCommand::EndInteractionEvent, 
-                        myEventCallbackCommand.GetPointer(), 
-                        myPriority);
+  if(myWidget){
+    theWidget->RemoveObserver(myEventCallbackCommand.GetPointer());
+    myDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
+    myDeviceActor->SetVisibility(false);
+  }
 
-  myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction());
-  myDeviceActor->SetVisibility(GetVisibility() && theWidget->IsEnabled());
+  if(theWidget){
+    theWidget->AddObserver(vtkCommand::EndInteractionEvent, 
+                          myEventCallbackCommand.GetPointer(), 
+                          myPriority);
+    myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction());
+    myDeviceActor->SetVisibility(GetVisibility() && theWidget->IsEnabled());
+  }
+
+  Superclass::SetImplicitFunctionWidget(theWidget);
 }
 
 
index 2d66709a07f1fdd2e7e24e91ffea61afa05caa20..cea0f5142157ef946416f2bc10be722f86c44a65 100644 (file)
@@ -43,7 +43,7 @@
 #include "utilities.h"
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
 #endif