]> Creatis software - bbtk.git/blobdiff - packages/wxvtk/src/bbwxvtkViewer3D.cxx
compile under linux ok
[bbtk.git] / packages / wxvtk / src / bbwxvtkViewer3D.cxx
index fe71dd7b82cc961c5d2dd0da1e7e232703c3357d..67df2857932a885a202ca5e5bb518460bdab53f6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxvtkViewer3D.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/03/23 12:55:54 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2009/07/08 15:18:25 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -87,6 +87,8 @@ namespace bbwxvtk
   //-------------------------------------------------------------------------
   Viewer3DWidget::~Viewer3DWidget()
   {
+    mBox->DisableObservers();
+    mBox->bbSetOutputWidget(NULL);
     renderwindow->Delete();
     renderer->Delete();
     interactorstyle->Delete();
@@ -132,30 +134,83 @@ void Viewer3DWidget::Refresh(bool eraseBackground , const wxRect* rect )
 
   BBTK_BLACK_BOX_IMPLEMENTATION(Viewer3D,bbtk::WxBlackBox);
 
-  void Viewer3D::bbUserConstructor() 
-  { 
-         firsttime=true;
-    bbSetInputIn1(NULL);
-    bbSetInputIn2(NULL);
-    bbSetInputIn3(NULL);
-    bbSetInputIn4(NULL);
-    bbSetInputIn5(NULL);
-    bbSetInputObs1(NULL);
-    bbSetInputObs2(NULL);
-    bbSetInputObs3(NULL);
-    bbSetInputObs4(NULL);
-    bbSetInputObs5(NULL);
-    bbSetInputStereo(false);
-    bbSetOutputRenderer( NULL );
-    bbSetOutputInteractor( NULL );
-    bbSetOutputWidget(NULL);
-  }
-
-
+       
+       //-----------------------------------------------------------------     
+       void Viewer3D::bbUserSetDefaultValues()
+       { 
+               firsttime=true;
+               bbSetInputIn1(NULL);
+               bbSetInputIn2(NULL);
+               bbSetInputIn3(NULL);
+               bbSetInputIn4(NULL);
+               bbSetInputIn5(NULL);
+               bbSetInputObs1(NULL);
+               bbSetInputObs2(NULL);
+               bbSetInputObs3(NULL);
+               bbSetInputObs4(NULL);
+               bbSetInputObs5(NULL);
+               bbSetInputStereo(false);
+               bbSetOutputRenderer( NULL );
+               bbSetOutputInteractor( NULL );
+               bbSetOutputWidget(NULL);
+       }
+       
+       //-----------------------------------------------------------------     
+       void Viewer3D::bbUserInitializeProcessing()
+       {
+       }
+       
+       //-----------------------------------------------------------------     
+       void Viewer3D::bbUserFinalizeProcessing()
+       {  
+         DisableObservers();
+       }
+
+       void Viewer3D::DisableObservers()
+       {  
+         Viewer3DWidget* w = (Viewer3DWidget*)bbGetOutputWidget();
+         if (w!=NULL)
+           { 
+             vtkRenderWindowInteractor *interactor = w->GetInteractor();
+             if (interactor!=NULL)
+               {
+                 if (bbGetInputObs1()!=NULL) 
+                   {
+                     if (bbGetInputObs1()->GetInteractor()!=NULL)
+                       bbGetInputObs1()->EnabledOff();
+                   }
+                 if (bbGetInputObs2()!=NULL) 
+                   {
+                     if (bbGetInputObs2()->GetInteractor()!=NULL)
+                 //bbGetInputObs2()->SetInteractor(NULL);
+                     bbGetInputObs2()->EnabledOff();
+                   }
+                 if (bbGetInputObs3()!=NULL) 
+                   {
+                    if (bbGetInputObs3()->GetInteractor()!=NULL)
+                  //bbGetInputObs3()->SetInteractor(NULL);
+                     bbGetInputObs3()->EnabledOff();
+                   }
+                 if (bbGetInputObs4()!=NULL) 
+                   {
+                    if (bbGetInputObs4()->GetInteractor()!=NULL)
+                  //bbGetInputObs4()->SetInteractor(NULL);
+                     bbGetInputObs4()->EnabledOff();
+                   }
+                 if (bbGetInputObs5()!=NULL) 
+                   {
+                  if (bbGetInputObs5()->GetInteractor()!=NULL)
+                    //bbGetInputObs5()->SetInteractor(NULL);
+                     bbGetInputObs5()->EnabledOff();
+                   }
+               }       
+           }
+       }
+       
+       //--------------------------------------------------------------------------
   void Viewer3D::Process() 
   { 
-         printf("EED Viewer3D::Process() 0\n"); 
-         
+    if (!bbIsShown()) return;
 //EED    
 //       Viewer3DWidget* w = (Viewer3DWidget*)bbGetOutputWidget();
 //       if (w)   w->Update();
@@ -165,11 +220,11 @@ void Viewer3DWidget::Refresh(bool eraseBackground , const wxRect* rect )
     Viewer3DWidget* w = (Viewer3DWidget*)bbGetOutputWidget();
          if ((firsttime==true) && (w!=NULL)){ 
                  firsttime=false;
-                 printf("EED Viewer3D::Process() 1\n"); 
                  
                  vtkRenderWindowInteractor *interactor = w->GetInteractor();
                  if (interactor!=NULL)
                  {
+
                          if (bbGetInputObs1()!=NULL) 
                          {
                                  bbGetInputObs1()->SetInteractor(interactor);
@@ -230,15 +285,15 @@ void Viewer3DWidget::Refresh(bool eraseBackground , const wxRect* rect )
    */ 
   void Viewer3D::CreateWidget(wxWindow* parent)
   {
-         printf("EED Viewer3D::CreateWidget() 0\n"); 
  
     bbtkDebugMessageInc("Core",9,"Viewer3D::CreateWidget()"<<std::endl);
 
-    Viewer3DWidget* w = new Viewer3DWidget(this,parent,
-                                                                                  //bbGetWxParent(),
-                                                                                  bbGetInputStereo());
-  //EED  w->Update();
-  //...
+    Viewer3DWidget* w = new Viewer3DWidget(this,
+                                          parent,
+                                          //bbGetWxParent(),
+                                          bbGetInputStereo());
+    //EED  w->Update();
+    //...
          
     bbSetOutputWidget(w);
     
@@ -250,8 +305,7 @@ void Viewer3DWidget::Refresh(bool eraseBackground , const wxRect* rect )
   // when window is shown
   void  Viewer3D::OnShowWidget()
   {
-          printf("EED Viewer3D::OnShowWidget() 0\n"); 
-         
+    Process();
        //    Viewer3DWidget* w = (Viewer3DWidget*)bbGetOutputWidget();
     //    if (w) w->Update();
   }