]> Creatis software - bbtk.git/blobdiff - packages/kw/src/vtkKWSlicer.cxx
*** empty log message ***
[bbtk.git] / packages / kw / src / vtkKWSlicer.cxx
index adc9bf9d52f675ea2d12c82dc60fab074ebaa71f..3de69e8a74179658241b1a5b453d3499ba9c1d3c 100644 (file)
 #include "vtkRenderWindowInteractor.h"
 #include "vtkXMLImageDataReader.h"
 
+#include "vtkKWCornerAnnotationEditor.h"
+
 //#include "vtkKWWidgetsPaths.h" 
 #include "vtkToolkits.h"
 
 #include <vtksys/SystemTools.hxx>
 
+extern "C" int Bbkw_Init(Tcl_Interp *interp);
+
 //namespace bbkw {
 
 //----------------------------------------------------------------------------
 vtkStandardNewMacro( vtkKWSlicer );
-vtkCxxRevisionMacro(vtkKWSlicer, "$Revision: 1.2 $");
+vtkCxxRevisionMacro(vtkKWSlicer, "$Revision: 1.3 $");
 
 //----------------------------------------------------------------------------
 vtkKWSlicer::vtkKWSlicer()
 {
+
+  Bbkw_Init(vtkKWApplication::GetMainInterp ());
+
   this->Frame = NULL;
   this->RenderWidget = NULL;
   this->Image = NULL;
@@ -70,6 +77,10 @@ vtkKWSlicer::~vtkKWSlicer()
     {
     this->WindowLevelPresetSelector->Delete();
     }
+  if (this->AnnotationEditor)
+    {
+      this->AnnotationEditor->Delete();
+    }
   if (this->AnimationWidget)
     {
     this->AnimationWidget->Delete();
@@ -94,6 +105,7 @@ void vtkKWSlicer::CreateWidget()
   vtkKWApplication *app = this->GetApplication();
 
   // Add a SplitFrame
+  /*
   Frame =  vtkKWSplitFrame::New();
   Frame->SetFrame1MinimumSize(150);
   Frame->SetFrame2MinimumSize(250);    
@@ -104,12 +116,13 @@ void vtkKWSlicer::CreateWidget()
   app->Script("pack %s -side top -expand yes",// -fill both",
              this->Frame->GetWidgetName());
   // Add a render widget, attach it to the view frame, and pack
+  */
 
   if (!this->RenderWidget)
     {
     this->RenderWidget = vtkKWRenderWidget::New();
     }
-  this->RenderWidget->SetParent(Frame->GetFrame2());
+  this->RenderWidget->SetParent(this); //Frame->GetFrame2());
   this->RenderWidget->Create();
   this->RenderWidget->CornerAnnotationVisibilityOn();
 
@@ -120,20 +133,7 @@ void vtkKWSlicer::CreateWidget()
   //  this->Script("grid rowconfigure %s 1 -weight 1 -minsize 100",
   //               this->RenderWidget->GetWidgetName());
 
-  // Create a volume reader
-  /*
-  vtkXMLImageDataReader *reader = vtkXMLImageDataReader::New();
-
-  char data_path[2048];
-  sprintf(data_path, "%s/Data/head100x100x47.vti", KWWidgets_EXAMPLES_DIR);
-  if (!vtksys::SystemTools::FileExists(data_path))
-    {
-    sprintf(data_path,
-            "%s/..%s/Examples/Data/head100x100x47.vti",
-            app->GetInstallationDirectory(), KWWidgets_INSTALL_DATA_DIR);
-    }
-  reader->SetFileName(data_path);
-  */
   // Create an image viewer
   // Use the render window and renderer of the renderwidget
 
@@ -148,15 +148,6 @@ void vtkKWSlicer::CreateWidget()
     this->RenderWidget->GetRenderWindow()->GetInteractor());
 
 
-  // Reset the window/level and the camera
-  /*
-  reader->Update();
-  double *range = reader->GetOutput()->GetScalarRange();
-  this->ImageViewer->SetColorWindow(range[1] - range[0]);
-  this->ImageViewer->SetColorLevel(0.5 * (range[1] + range[0]));
-
-  this->RenderWidget->ResetCamera();
-  */
   // The corner annotation has the ability to parse "tags" and fill
   // them with information gathered from other objects.
   // For example, let's display the slice and window/level in one corner
@@ -169,13 +160,15 @@ void vtkKWSlicer::CreateWidget()
   ca->SetText(2, "<slice>");
   ca->SetText(3, "<window>\n<level>");
 
+
+
   // Create a scale to control the slice
 
   if (!this->SliceScale)
     {
     this->SliceScale = vtkKWScale::New();
     }
-  this->SliceScale->SetParent(Frame->GetFrame1());
+  this->SliceScale->SetParent(this); //Frame->GetFrame1());
   this->SliceScale->Create();
   //  this->SliceScale->SetCommand(this, "SetSliceFromScaleCallback");
 
@@ -192,7 +185,7 @@ void vtkKWSlicer::CreateWidget()
   vtkKWMenuButtonWithSpinButtonsWithLabel *orientation_menubutton =
     vtkKWMenuButtonWithSpinButtonsWithLabel::New();
 
-  orientation_menubutton->SetParent(Frame->GetFrame1());
+  orientation_menubutton->SetParent(this); //Frame->GetFrame1());
   orientation_menubutton->Create();
   orientation_menubutton->SetLabelText("Orientation:");
   orientation_menubutton->SetPadX(2);
@@ -221,12 +214,11 @@ void vtkKWSlicer::CreateWidget()
 
   
   // Create a window/level preset selector
-  /*
   vtkKWFrameWithLabel *wl_frame = vtkKWFrameWithLabel::New();
-  wl_frame->SetParent(this); //->GetMainPanelFrame());
+  wl_frame->SetParent(this); //Frame->GetFrame1());
   wl_frame->Create();
   wl_frame->SetLabelText("Window/Level Presets");
-
+  wl_frame->CollapseFrame ();
   app->Script("pack %s -side top -anchor nw -expand n -fill x -pady 2",
               wl_frame->GetWidgetName());
 
@@ -237,22 +229,24 @@ void vtkKWSlicer::CreateWidget()
   this->WindowLevelPresetSelector->SetParent(wl_frame->GetFrame());
   this->WindowLevelPresetSelector->Create();
   this->WindowLevelPresetSelector->ThumbnailColumnVisibilityOn();
-  
-  this->WindowLevelPresetSelector->SetPresetAddCommand(
-    this, "WindowLevelPresetAddCallback");
-  this->WindowLevelPresetSelector->SetPresetApplyCommand(
-    this, "WindowLevelPresetApplyCallback");
-  this->WindowLevelPresetSelector->SetPresetUpdateCommand(
-    this, "WindowLevelPresetUpdateCallback");
-  this->WindowLevelPresetSelector->SetPresetHasChangedCommand(
-    this, "WindowLevelPresetHasChangedCallback");
-
+    
 
   app->Script("pack %s -side top -anchor nw -expand n -fill x",
               this->WindowLevelPresetSelector->GetWidgetName());
 
-  // Create a simple animation widget
+  // Create a corner annotation editor
+  this->AnnotationEditor = vtkKWCornerAnnotationEditor::New();
+  this->AnnotationEditor->SetParent(this);
+  this->AnnotationEditor->Create();
+  this->AnnotationEditor->SetRenderWidget(this->RenderWidget);
+  this->AnnotationEditor->GetFrame()->CollapseFrame ();
+  app->Script("pack %s -side top -anchor nw -expand n -fill x", 
+              this->AnnotationEditor->GetWidgetName());
+
 
+  // Create a simple animation widget
+  /*
   vtkKWFrameWithLabel *animation_frame = vtkKWFrameWithLabel::New();
   animation_frame->SetParent(this); //->GetMainPanelFrame());
   animation_frame->Create();
@@ -275,6 +269,7 @@ void vtkKWSlicer::CreateWidget()
   app->Script("pack %s -side top -anchor nw -expand n -fill x",
               this->AnimationWidget->GetWidgetName());
   */
+
   this->UpdateSliceRanges();
 
   // Callbacks
@@ -283,6 +278,18 @@ void vtkKWSlicer::CreateWidget()
   this->AddCallbackCommandObserver( menu, 
                                    vtkKWMenu::MenuItemInvokedEvent);
 
+  //  this->AddCallbackCommandObserver( this->WindowLevelPresetSelector,
+  
+  this->WindowLevelPresetSelector->SetPresetAddCommand(this, 
+                                                      "WindowLevelPresetAddCallback");
+  this->WindowLevelPresetSelector->SetPresetApplyCommand(this,
+                                                        "WindowLevelPresetApplyCallback");
+  this->WindowLevelPresetSelector->SetPresetUpdateCommand(
+    this, "WindowLevelPresetUpdateCallback");
+  this->WindowLevelPresetSelector->SetPresetHasChangedCommand(
+    this, "WindowLevelPresetHasChangedCallback");
+
+
 
   // Deallocate local objects