]> Creatis software - clitk.git/commitdiff
- toolbase
authordsarrut <dsarrut>
Wed, 24 Feb 2010 11:42:40 +0000 (11:42 +0000)
committerdsarrut <dsarrut>
Wed, 24 Feb 2010 11:42:40 +0000 (11:42 +0000)
32 files changed:
CMakeLists.txt
vv/CMakeLists.txt
vv/qt_ui/vvToolCropImage.ui [new file with mode: 0644]
vv/qt_ui/vvToolFoo.ui [new file with mode: 0644]
vv/qt_ui/vvToolWidgetBase.ui [new file with mode: 0644]
vv/vvImageContour.cxx
vv/vvImageContour.h
vv/vvIntensityValueSlider.cxx
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvMainWindowBase.cxx [new file with mode: 0644]
vv/vvMainWindowBase.h [new file with mode: 0644]
vv/vvSlicerManagerCommand.cxx
vv/vvToolBase.h
vv/vvToolBase.txx [new file with mode: 0644]
vv/vvToolBinarize.cxx
vv/vvToolBinarize.h
vv/vvToolCreator.h [new file with mode: 0644]
vv/vvToolCreator.txx [new file with mode: 0644]
vv/vvToolCreatorBase.cxx
vv/vvToolCreatorBase.h
vv/vvToolCreatorBase.txx
vv/vvToolCropImage.cxx [new file with mode: 0644]
vv/vvToolCropImage.h [new file with mode: 0644]
vv/vvToolFoo.cxx [new file with mode: 0644]
vv/vvToolFoo.h [new file with mode: 0644]
vv/vvToolInputSelectorWidget.cxx
vv/vvToolInputSelectorWidget.h
vv/vvToolManager.cxx
vv/vvToolManager.h
vv/vvToolWidgetBase.cxx [new file with mode: 0644]
vv/vvToolWidgetBase.h [new file with mode: 0644]

index 164b7d7a82ec2d9e7143880a1f0828cb96599b75..2e121c6a8889ae8fae71e80328082705f5e2dd5c 100644 (file)
@@ -7,9 +7,10 @@ if(COMMAND cmake_policy)
 endif(COMMAND cmake_policy)
 PROJECT(clitk)
 #=========================================================
-IF(CMAKE_COMPILER_IS_GNUCXX)
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
-ENDIF(CMAKE_COMPILER_IS_GNUCXX)
+#IF(CMAKE_COMPILER_IS_GNUCXX)
+#  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
+#  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")
+#ENDIF(CMAKE_COMPILER_IS_GNUCXX)
 IF(MSVC)
   ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
 ENDIF(MSVC)
index 8404ae275d910e11f4fece41b1f92a9d9f5b4248..8797f8cc1f363fe903504a0a43c31df21aac8549 100644 (file)
@@ -73,6 +73,7 @@ SET(vv_SRCS
   vvResamplerDialog.cxx
   vvSegmentationDialog.cxx
   vvSurfaceViewerDialog.cxx
+  vvMainWindowBase.cxx
   vvMainWindow.cxx
   vvDeformationDialog.cxx
   vvImageWarp.cxx
@@ -102,12 +103,16 @@ SET(vv_SRCS
   vvIntensityValueSlider.cxx
   vvToolManager.cxx
   vvToolCreatorBase.cxx
+  vvToolWidgetBase.cxx
+  vvToolFoo.cxx
+  vvToolCropImage.cxx
   vvToolBinarize.cxx
   vvToolInputSelectorWidget.cxx
   vvImageContour.cxx
   )
 
 QT4_WRAP_CPP(vv_SRCS 
+  vvMainWindowBase.h 
   vvMainWindow.h 
   QTreePushButton.h 
   vvInfoPanel.h 
@@ -127,8 +132,11 @@ QT4_WRAP_CPP(vv_SRCS
   vvCropDialog.h
   vvIntensityValueSlider.h
   vvToolCreatorBase.h
+  vvToolFoo.h
   vvToolBinarize.h
   vvToolInputSelectorWidget.h
+  vvToolWidgetBase.h
+  vvToolCropImage.h
   )
 
 QT4_WRAP_UI(vv_UI_CXX 
@@ -149,6 +157,9 @@ QT4_WRAP_UI(vv_UI_CXX
   qt_ui/vvCropDialog.ui
   qt_ui/vvDummyWindow.ui #For testing
   qt_ui/vvIntensityValueSlider.ui
+  qt_ui/vvToolWidgetBase.ui
+  qt_ui/vvToolFoo.ui
+  qt_ui/vvToolCropImage.ui
   qt_ui/vvToolBinarize.ui
   qt_ui/vvToolInputSelectorWidget.ui
   )
diff --git a/vv/qt_ui/vvToolCropImage.ui b/vv/qt_ui/vvToolCropImage.ui
new file mode 100644 (file)
index 0000000..e7c0619
--- /dev/null
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolCropImage</class>
+ <widget class="QWidget" name="vvToolCropImage">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout_2">
+   <item row="0" column="0">
+    <layout class="QGridLayout" name="gridLayout">
+     <item row="0" column="0">
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>X min</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QSlider" name="xminSlider">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>X max</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QSlider" name="xmaxSlider">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="label_3">
+       <property name="text">
+        <string>Y min</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QSlider" name="yminSlider">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="0">
+      <widget class="QLabel" name="label_4">
+       <property name="text">
+        <string>Y max</string>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="1">
+      <widget class="QSlider" name="ymaxSlider">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="0">
+      <widget class="QLabel" name="label_5">
+       <property name="text">
+        <string>Z min</string>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="1">
+      <widget class="QSlider" name="zminSlider">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="5" column="0">
+      <widget class="QLabel" name="label_6">
+       <property name="text">
+        <string>Z max</string>
+       </property>
+      </widget>
+     </item>
+     <item row="5" column="1">
+      <widget class="QSlider" name="zmaxSlider">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="2">
+      <widget class="QSpinBox" name="spin_xmin"/>
+     </item>
+     <item row="1" column="2">
+      <widget class="QSpinBox" name="spin_xmax"/>
+     </item>
+     <item row="2" column="2">
+      <widget class="QSpinBox" name="spin_ymin"/>
+     </item>
+     <item row="3" column="2">
+      <widget class="QSpinBox" name="spin_ymax"/>
+     </item>
+     <item row="4" column="2">
+      <widget class="QSpinBox" name="spin_zmin"/>
+     </item>
+     <item row="5" column="2">
+      <widget class="QSpinBox" name="spin_zmax"/>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/vv/qt_ui/vvToolFoo.ui b/vv/qt_ui/vvToolFoo.ui
new file mode 100644 (file)
index 0000000..9748f2b
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolFoo</class>
+ <widget class="QWidget" name="vvToolFoo">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>358</width>
+    <height>213</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>150</x>
+     <y>90</y>
+     <width>75</width>
+     <height>23</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Foo !</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>pushButton</sender>
+   <signal>clicked()</signal>
+   <receiver>vvToolFoo</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>220</x>
+     <y>135</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>100</x>
+     <y>-18</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/vv/qt_ui/vvToolWidgetBase.ui b/vv/qt_ui/vvToolWidgetBase.ui
new file mode 100644 (file)
index 0000000..0effdb5
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolWidgetBase</class>
+ <widget class="QWidget" name="vvToolWidgetBase">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>615</width>
+    <height>372</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QSplitter" name="splitter">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <widget class="vvToolInputSelectorWidget" name="mToolInputSelectionWidget" native="true"/>
+     <widget class="QWidget" name="mToolWidget" native="true"/>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+  <zorder>splitter</zorder>
+  <zorder>buttonBox</zorder>
+  <zorder>mToolInputSelectionWidget</zorder>
+  <zorder>groupBox</zorder>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>vvToolInputSelectorWidget</class>
+   <extends>QWidget</extends>
+   <header location="global">vvToolInputSelectorWidget.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
index 63df2cb784c3dcc9aa66d7a56cf81d9597f0530a..85a9f2bb05767de4d46f7931dfcc4460a2d873bd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvImageContour.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/02/07 12:00:59 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.3 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2010
@@ -76,15 +76,30 @@ void vvImageContour::setSlicer(vvSlicer * slicer) {
     mSquaresActorList.push_back(mSquaresActor);
     mSquaresList.push_back(mSquares);
     mClipperList.push_back(mClipper);
-
   }
   //mSquares->Update();
 }
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+void vvImageContour::removeActors() {
+ //  DD("removeActors");
+  if (!mSlicer) return;
+  mSlice = mSlicer->GetSlice();
+ //  DD(mSlice);
+  for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
+    mSquaresActorList[i]->VisibilityOff();
+    //mSquaresActorList[i]->Update();
+  }
+}
+//------------------------------------------------------------------------------
+
+  
 //------------------------------------------------------------------------------
 void vvImageContour::update(int value) {
+  //  DD(value);
+  if (!mSlicer) return;
   mSlice = mSlicer->GetSlice();
 
   // Only change actor visibility if tslice change
index 0e9a9436f91fe0647f32747b08b7444e05dde35f..be96b05e8665a26d383d0ed16632274663636427 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvImageContour.h,v $
   Language:  C++
-  Date:      $Date: 2010/02/07 12:00:59 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.3 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2010
@@ -50,6 +50,7 @@ class vvImageContour
   void setSlicer(vvSlicer * slicer);
   // vtkActor * getActor() { return mSquaresActor;}
   void update(int value);
+  void removeActors();
 
  protected:
   vvSlicer * mSlicer;
index 82d9258a853617455fd1cb5ba7168320b42e765b..55ae8f23243cfd1015ebdba4a042365da3d40358 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvIntensityValueSlider.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/02/07 12:00:59 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.3 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
@@ -120,9 +120,9 @@ void vvIntensityValueSlider::SetMinimum(double min) {
 
 //------------------------------------------------------------------------------
 void vvIntensityValueSlider::Update() {
-  DD(mImage->GetScalarTypeAsString());
-  DD(mImage->GetFirstVTKImageData()->GetScalarTypeMax());
-  DD(mImage->GetFirstVTKImageData()->GetScalarTypeMin());
//  DD(mImage->GetScalarTypeAsString());
+//   DD(mImage->GetFirstVTKImageData()->GetScalarTypeMax());
+//   DD(mImage->GetFirstVTKImageData()->GetScalarTypeMin());
 
   // double max = mImage->GetFirstVTKImageData()->GetScalarTypeMax();
 //   double min = mImage->GetFirstVTKImageData()->GetScalarTypeMin();
@@ -137,8 +137,8 @@ void vvIntensityValueSlider::Update() {
     mImage->GetFirstVTKImageData()->GetScalarRange(range);
     mMin = range[0];
     mMax = range[1];
-    DD(mMax);
-    DD(mMin);
+   //  DD(mMax);
+//     DD(mMin);
     mSlider->setMaximum(mMax);
     mSlider->setMinimum(mMin);
     mSpinBox->setMaximum(mMax);
index f55ebea2d2ff05b344270572e4bc3575dc7b1e13..924bf19b534c8534a15323e27ed94693e9797cf1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvMainWindow.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/02/17 20:52:39 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.12 $
   Author :   Pierre Seroul (pierre.seroul@gmail.com)
 
   Copyright (C) 200COLUMN_IMAGE_NAME
@@ -56,6 +56,7 @@
 #include "vvMeshReader.h"
 #include "vvCropDialog.h"
 #include "vvConstants.h"
+
 #ifdef CLITK_VV_USE_BDCM
 #include <bdcmDicomFilesSelectorDialog.h>
 #endif
   5,Qt::UserRole mSlicerManager id*/
 
 //------------------------------------------------------------------------------
-vvMainWindow::vvMainWindow() {
+vvMainWindow::vvMainWindow():vvMainWindowBase() {
   setupUi(this); // this sets up the GUI
 
   mInputPathName = "";
-  mCurrentToolInfo = 0;
+  mMenuTools = menuTools;
+  mMainWidget = this;
 
   //Init the contextMenu
   this->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -166,7 +168,6 @@ vvMainWindow::vvMainWindow() {
   connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
   contextActions.push_back(actionAdd_fusion_image);
 
-
   //init the DataTree
   mSlicerManagers.resize(0);
 
@@ -319,7 +320,7 @@ vvMainWindow::vvMainWindow() {
     }
 
   // Adding all new tools (insertion in the menu)
-  vvToolManager::GetInstance()->Initialize(this);
+  vvToolManager::GetInstance()->InsertToolsInMenu(this);
 }
 //------------------------------------------------------------------------------
 
@@ -360,7 +361,10 @@ void vvMainWindow::ComputeMidPosition()
       QApplication::restoreOverrideCursor();
     }
 }
+//------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
 void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool propagation)
 {
   QTreeWidgetItem *item = new QTreeWidgetItem();
@@ -404,6 +408,8 @@ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool pro
   mSlicerManagers[image_index]->AddContour(contour,propagation);
   mSlicerManagers[image_index]->Render();
 }
+//------------------------------------------------------------------------------
+
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenVTKContour()
@@ -425,6 +431,9 @@ void vvMainWindow::OpenVTKContour()
       QApplication::restoreOverrideCursor();
     }
 }
+//------------------------------------------------------------------------------
+
+
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenDCStructContour()
 {
@@ -458,6 +467,8 @@ void vvMainWindow::OpenDCStructContour()
         }
     }
 }
+//------------------------------------------------------------------------------
+
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ComputeDeformableRegistration()
@@ -477,6 +488,8 @@ void vvMainWindow::ComputeDeformableRegistration()
     }
   else QMessageBox::information(this, "Need to open image","You must open an image first.");
 }
+//------------------------------------------------------------------------------
+
 
 //------------------------------------------------------------------------------
 void vvMainWindow::WarpImage()
@@ -495,6 +508,8 @@ void vvMainWindow::WarpImage()
   else
     QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field"));
 }
+//------------------------------------------------------------------------------
+
 
 //------------------------------------------------------------------------------
 void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phase)
@@ -521,6 +536,8 @@ void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phas
   else
     QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field."));
 }
+//------------------------------------------------------------------------------
+
 
 //------------------------------------------------------------------------------
 vvMainWindow::~vvMainWindow() {
@@ -532,6 +549,7 @@ vvMainWindow::~vvMainWindow() {
 }
 //------------------------------------------------------------------------------
 
+
 //------------------------------------------------------------------------------
 void vvMainWindow::MergeImages() {
   QString Extensions = EXTENSIONS;
@@ -596,6 +614,7 @@ void vvMainWindow::MergeImages() {
 }
 //------------------------------------------------------------------------------
 
+
 //------------------------------------------------------------------------------
 void vvMainWindow::MergeImagesWithTime() {
   QString Extensions = EXTENSIONS;
@@ -668,6 +687,7 @@ void vvMainWindow::MergeImagesWithTime() {
 }
 //------------------------------------------------------------------------------
 
+
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenDicom() {
   std::vector<std::string> files;
@@ -873,9 +893,6 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, LoadedImageType fi
     }
   QApplication::restoreOverrideCursor();
 
-
-  // vvToolManager::GetInstance()->UpdateEnabledTool();
-  // emit SlicerManagersHasChanged();
 }
 //------------------------------------------------------------------------------
 
@@ -1076,69 +1093,69 @@ void vvMainWindow::ImageInfoChanged() {
     presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
     colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
 
-        infoPanel->setFileName(image);
-        infoPanel->setDimension(dim);
-        infoPanel->setSizePixel(GetVectorIntAsString(inputSize));
-        infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM));
-        infoPanel->setOrigin(GetVectorDoubleAsString(origin));
-        infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
-        infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
-
-        landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
-                                            mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size());
-        landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
-        landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
-
-        overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str());
-        for (int i = 0; i < 4;i++)
-        {
-            if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3)
-            {
-                mSlicerManagers[index]->UpdateInfoOnCursorPosition(i);
-                break;
-            }
-        }
-        windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
-        levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
-        presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
-        colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
+    infoPanel->setFileName(image);
+    infoPanel->setDimension(dim);
+    infoPanel->setSizePixel(GetVectorIntAsString(inputSize));
+    infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM));
+    infoPanel->setOrigin(GetVectorDoubleAsString(origin));
+    infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
+    infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
 
-        if (mSlicerManagers[index]->GetSlicer(0)->GetVF())
-        {
-            overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
-            overlayPanel->getVFProperty(mSlicerManagers[index]->GetSlicer(0)->GetVFSubSampling(),
-                                        mSlicerManagers[index]->GetSlicer(0)->GetVFScale(),
-                                        mSlicerManagers[index]->GetSlicer(0)->GetVFLog());
-        }
-        else
-        {
-            overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
-            overlayPanel->getVFProperty(-1,-1,-1);
-        }
-        if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay())
-        {
-            overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
-            overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor());
-        }
-        else
-        {
-            overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
-            overlayPanel->getOverlayProperty(-1);
-        }
-        if (mSlicerManagers[index]->GetSlicer(0)->GetFusion())
-        {
-            overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
-            overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
-                                            mSlicerManagers[index]->GetFusionColorMap(),
-                                            mSlicerManagers[index]->GetFusionWindow(),
-                                            mSlicerManagers[index]->GetFusionLevel());
-        }
-        else
-        {
-            overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
-            overlayPanel->getFusionProperty(-1, -1,-1,-1);
-        }
-    }
+    landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
+                                        mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size());
+    landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
+    landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
+
+    overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str());
+    for (int i = 0; i < 4;i++)
+      {
+        if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3)
+          {
+            mSlicerManagers[index]->UpdateInfoOnCursorPosition(i);
+            break;
+          }
+      }
+    windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
+    levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
+    presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
+    colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
+
+    if (mSlicerManagers[index]->GetSlicer(0)->GetVF())
+      {
+        overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
+        overlayPanel->getVFProperty(mSlicerManagers[index]->GetSlicer(0)->GetVFSubSampling(),
+                                    mSlicerManagers[index]->GetSlicer(0)->GetVFScale(),
+                                    mSlicerManagers[index]->GetSlicer(0)->GetVFLog());
+      }
+    else
+      {
+        overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
+        overlayPanel->getVFProperty(-1,-1,-1);
+      }
+    if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay())
+      {
+        overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
+        overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor());
+      }
+    else
+      {
+        overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
+        overlayPanel->getOverlayProperty(-1);
+      }
+    if (mSlicerManagers[index]->GetSlicer(0)->GetFusion())
+      {
+        overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
+        overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
+                                        mSlicerManagers[index]->GetFusionColorMap(),
+                                        mSlicerManagers[index]->GetFusionWindow(),
+                                        mSlicerManagers[index]->GetFusionLevel());
+      }
+    else
+      {
+        overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
+        overlayPanel->getFusionProperty(-1, -1,-1,-1);
+      }
+  }
 }
 //------------------------------------------------------------------------------
 
@@ -1488,6 +1505,10 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) {
       msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
       if (msgBox.exec() == QMessageBox::AcceptRole)
         {
+
+          // Tell tools that we close an image
+          emit AnImageIsBeingClosed(mSlicerManagers[index]);
+
           std::vector<vvSlicerManager*>::iterator Manageriter = mSlicerManagers.begin();
           DataTree->takeTopLevelItem(index);
           for (int i = 0; i < index; i++)
@@ -1498,25 +1519,24 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) {
           mSlicerManagers[index]->RemoveActors();
           delete mSlicerManagers[index];
           mSlicerManagers.erase(Manageriter);
+          
+          //
           InitDisplay();
         }
     }
-
-  // vvToolManager::GetInstance()->UpdateEnabledTool();
-  // emit SlicerManagersHasChanged();
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column) {
   // int index = GetSlicerIndexFromItem(item);
-//   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-//   if (item->data(1,Qt::UserRole).toString() == "vector")
-//     mSlicerManagers[index]->ReloadVF();
-//   else
-//     mSlicerManagers[index]->Reload();
+  //   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+  //   if (item->data(1,Qt::UserRole).toString() == "vector")
+  //     mSlicerManagers[index]->ReloadVF();
+  //   else
+  //     mSlicerManagers[index]->Reload();
 
-//   QApplication::restoreOverrideCursor();
+  //   QApplication::restoreOverrideCursor();
   int index = GetSlicerIndexFromItem(item);
   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
   QString role=item->data(1,Qt::UserRole).toString();
@@ -2330,7 +2350,7 @@ void vvMainWindow::NOVerticalSliderChanged() {
       if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1)
         {
           mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
-          // mSlicerManagers[i]->UpdateSlice(0); // <-- too much update...
+          //mSlicerManagers[i]->UpdateSlice(0); // <-- NO ! too much update...
           break;
         }
     }
@@ -2381,8 +2401,10 @@ void vvMainWindow::SEVerticalSliderChanged() {
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateSlice(int slicer, int slice) {
-  if (slicer == 0)
-    NOVerticalSlider->setValue(slice);
+  if (slicer == 0) {
+    if (slice != NOVerticalSlider->value())
+      NOVerticalSlider->setValue(slice);
+  }
   else if (slicer == 1)
     NEVerticalSlider->setValue(slice);
   else if (slicer == 2)
@@ -2744,20 +2766,13 @@ void vvMainWindow::AddImage(vvSlicerManager * slicer_manager) {
   ShowLastImage();
   InitDisplay();
   qApp->processEvents();
-
-  // vvToolManager::GetInstance()->UpdateEnabledTool();
-  // emit SlicerManagersHasChanged();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-vvMainWindowToolInfo * vvMainWindow::GetInfoForTool() {
-  DD("GetInfoForTool");
-  if (mCurrentToolInfo ==0) mCurrentToolInfo = new vvMainWindowToolInfo;
-
-  mCurrentToolInfo->mMenuTools = menuTools;
-  mCurrentToolInfo->mSlicerManagers = &mSlicerManagers;
+void vvMainWindow::UpdateCurrentSlicer() {
+  DD("UpdateCurrentSlicer");
   int index = -1;
   DD(DataTree->selectedItems().size());
   if (DataTree->selectedItems().size() > 0) {
@@ -2765,10 +2780,7 @@ vvMainWindowToolInfo * vvMainWindow::GetInfoForTool() {
     DD(DataTree->selectedItems()[0]);
     DD(index);
   }
-  mCurrentToolInfo->mSlicerManagerCurrentIndex = index;    
-
-  return mCurrentToolInfo;
+  mSlicerManagerCurrentIndex = index;    
 }
 //------------------------------------------------------------------------------
 
-
index b3d60313ffa09a5b070231543ae2a01e2d4027e3..d92937408231ce15e2dc9f0c77d3bdf6ebd56125 100644 (file)
@@ -29,12 +29,10 @@ GNU General Public License for more details.
 #include <vector>
 
 #include "ui_vvMainWindow.h"
-
+#include "vvMainWindowBase.h"
+#include "vvToolManager.h"
 #include "vvConstants.h"
-#include "vvImage.h"
 #include "vvMesh.h"
-#include "vvToolManager.h"
-#include "clitkCommon.h"
 
 class vvSlicerManager;
 class vvHelpDialog;
@@ -45,16 +43,8 @@ class vtkRenderer;
 class vvDicomSeriesSelector;
 
 //------------------------------------------------------------------------------
-struct vvMainWindowToolInfo {
-  QMenu * mMenuTools;
-  std::vector<vvSlicerManager*> * mSlicerManagers;
-  int mSlicerManagerCurrentIndex;
-};
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-class vvMainWindow : public QMainWindow, private Ui::vvMainWindow
+class vvMainWindow: public vvMainWindowBase,
+                    private Ui::vvMainWindow
 {
   Q_OBJECT
 
@@ -71,7 +61,9 @@ class vvMainWindow : public QMainWindow, private Ui::vvMainWindow
   ///This is used to show an image when opened or computed
   void ShowLastImage();
 
-  vvMainWindowToolInfo * GetInfoForTool();
+  virtual void UpdateCurrentSlicer();
+  //vvMainWindowToolInfo * GetInfoForTool();
+//   void AddRunningTool(vvToolCreatorBase * tool);
 
 public slots:
   ///Allows the user to open and select various surfaces contained in a dicom-struct file
@@ -165,7 +157,7 @@ public slots:
 private:
 
   //variables
-  std::vector<vvSlicerManager*> mSlicerManagers;
+  // std::vector<vvSlicerManager*> mSlicerManagers;
   vvHelpDialog *help_dialog;
   vvDocumentation *documentation;
   vvDicomSeriesSelector *dicomSeriesSelector;
@@ -197,7 +189,8 @@ private:
   std::vector<QSlider*> verticalSliders;
   int mFrameRate;
 
-  vvMainWindowToolInfo * mCurrentToolInfo;
+  // vvMainWindowToolInfo * mCurrentToolInfo;
+  // std::vector<vvToolCreatorBase*> mListOfRunningTool;
 
   static vvMainWindow * mSingleton;
 };
diff --git a/vv/vvMainWindowBase.cxx b/vv/vvMainWindowBase.cxx
new file mode 100644 (file)
index 0000000..c7b58f7
--- /dev/null
@@ -0,0 +1,30 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvMainWindowBase.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2010
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#include "vvMainWindowBase.h"
+
+
diff --git a/vv/vvMainWindowBase.h b/vv/vvMainWindowBase.h
new file mode 100644 (file)
index 0000000..1c10d5e
--- /dev/null
@@ -0,0 +1,63 @@
+/*=========================================================================
+
+ Program:   vv
+  Module:   $RCSfile: vvMainWindowBase.h,v $
+ Language:  C++
+ Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+Copyright (C) 2010
+Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 3 of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#ifndef VVMAINWINDOWBASE_H
+#define VVMAINWINDOWBASE_H
+
+#include "clitkCommon.h"
+#include "vvImage.h"
+#include <qmainwindow.h>
+
+class vvSlicerManager;
+class QMenu;
+
+//------------------------------------------------------------------------------
+class vvMainWindowBase : public QMainWindow
+{
+   Q_OBJECT
+
+public:
+  vvMainWindowBase() { mSlicerManagerCurrentIndex = -1; }
+  ~vvMainWindowBase() { }
+
+  virtual void AddImage(vvImage::Pointer image,std::string filename) = 0;
+  virtual void UpdateCurrentSlicer() = 0;
+  const std::vector<vvSlicerManager*> & GetSlicerManagers() const { return mSlicerManagers; }
+  QMenu * GetMenu() const { return mMenuTools; }
+  int GetSlicerManagerCurrentIndex() const { return mSlicerManagerCurrentIndex; }
+  QWidget * GetMainWidget() { return mMainWidget; }
+
+signals:
+  void AnImageIsBeingClosed(vvSlicerManager *);
+
+protected:
+  std::vector<vvSlicerManager*> mSlicerManagers;
+  QMenu * mMenuTools;
+  int mSlicerManagerCurrentIndex;
+  QWidget* mMainWidget;
+};
+//------------------------------------------------------------------------------
+
+#endif
index f42ab2861ae00f057780f25f85d1ffeec8ff9796..6e3298b792cff082320e4440123b9bbfed087cd4 100644 (file)
@@ -1,26 +1,26 @@
 /*=========================================================================
 
-Program:   vv
-Language:  C++
-Author :   Pierre Seroul (pierre.seroul@gmail.com)
+  Program:   vv
+  Language:  C++
+  Author :   Pierre Seroul (pierre.seroul@gmail.com)
 
-Copyright (C) 2008
-Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
-CREATIS-LRMN http://www.creatis.insa-lyon.fr
+  Copyright (C) 2008
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS-LRMN http://www.creatis.insa-lyon.fr
 
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-=========================================================================*/
+  =========================================================================*/
 #include "vvSlicerManagerCommand.h"
 #include "vvSlicerManager.h"
 
@@ -43,523 +43,533 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <cmath>
 
+//------------------------------------------------------------------------------
 vvSlicerManagerCallback::vvSlicerManagerCallback()
 {
-    mStartSlicer = -1;
+  mStartSlicer = -1;
 }
+//------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
 //return the num of the current slicer if visible (-1 else)
 int vvSlicerManagerCallback::FindSlicerNumber(vtkRenderWindow* renwin)
 {
-    int result=-1;
-    for (int i = 0; i < SM->NumberOfSlicers(); i++)
+  int result=-1;
+  for (int i = 0; i < SM->NumberOfSlicers(); i++)
     {
-        if (SM->GetSlicer(i)->GetRenderWindow() == renwin
-                && SM->GetSlicer(i)->GetRenderer()->GetDraw())
+      if (SM->GetSlicer(i)->GetRenderWindow() == renwin
+         && SM->GetSlicer(i)->GetRenderer()->GetDraw())
         {
-            DD(i);
-            result=i;
+         //            DD(i);
+         result=i;
         }
     }
-    return result;
+  return result;
 }
+//------------------------------------------------------------------------------
+
 
+//------------------------------------------------------------------------------
 void vvSlicerManagerCallback::Execute(vtkObject *caller,
-                                       unsigned long event,
-                                       void *vtkNotUsed(callData))
+                                     unsigned long event,
+                                     void *vtkNotUsed(callData))
 {
-    //KeyPress event
-    vvInteractorStyleNavigator *isi =
-        dynamic_cast<vvInteractorStyleNavigator *>(caller);
-    if (isi)
+  //KeyPress event
+  vvInteractorStyleNavigator *isi =
+    dynamic_cast<vvInteractorStyleNavigator *>(caller);
+  if (isi)
     {
-        double x = isi->GetInteractor()->GetEventPosition()[0];
-        double y = isi->GetInteractor()->GetEventPosition()[1];
-        double z;
+      double x = isi->GetInteractor()->GetEventPosition()[0];
+      double y = isi->GetInteractor()->GetEventPosition()[1];
+      double z;
 
-        int VisibleInWindow = this->FindSlicerNumber(isi->GetInteractor()->GetRenderWindow());
-        vtkRenderer* renderer=NULL;
-        if (VisibleInWindow>-1) 
-            renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
-        newLandmark = false;
+      int VisibleInWindow = this->FindSlicerNumber(isi->GetInteractor()->GetRenderWindow());
+      vtkRenderer* renderer=NULL;
+      if (VisibleInWindow>-1) 
+       renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
+      newLandmark = false;
 
-        if (event == vtkCommand::StartPickEvent && VisibleInWindow == -1)
+      if (event == vtkCommand::StartPickEvent && VisibleInWindow == -1)
         {
-            for (int i = 0; i < this->SM->NumberOfSlicers(); i++)
+         for (int i = 0; i < this->SM->NumberOfSlicers(); i++)
             {
-                if (this->SM->GetSlicer(i)->GetCursorVisibility())
+             if (this->SM->GetSlicer(i)->GetCursorVisibility())
                 {
-                    this->SM->GetSlicer(i)->SetCursorVisibility(0);
-                    this->SM->GetSlicer(i)->Render();
+                 this->SM->GetSlicer(i)->SetCursorVisibility(0);
+                 this->SM->GetSlicer(i)->Render();
                 }
             }
         }
-        if ( VisibleInWindow > -1 )
+      if ( VisibleInWindow > -1 )
         {
-            if (event == vtkCommand::KeyPressEvent)
+         if (event == vtkCommand::KeyPressEvent)
             {
-                std::string KeyPress = isi->GetInteractor()->GetKeySym();
-                if (KeyPress == "f" || KeyPress == "F")
+             std::string KeyPress = isi->GetInteractor()->GetKeySym();
+             if (KeyPress == "f" || KeyPress == "F")
                 {
-                    FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
+                 FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
                 }
-                if (KeyPress == "0")
+             if (KeyPress == "0")
                 {
-                    this->SM->SetPreset(0);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetPreset(0);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "1")
+             if (KeyPress == "1")
                 {
-                    this->SM->SetPreset(1);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetPreset(1);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "2")
+             if (KeyPress == "2")
                 {
-                    this->SM->SetPreset(2);
-                    this->SM->UpdateWindowLevel();
+                 this->SM->SetPreset(2);
+                 this->SM->UpdateWindowLevel();
 
-                    return;
+                 return;
                 }
-                if (KeyPress == "3")
+             if (KeyPress == "3")
                 {
-                    this->SM->SetPreset(3);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetPreset(3);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "4")
+             if (KeyPress == "4")
                 {
-                    this->SM->SetPreset(4);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetPreset(4);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "5")
+             if (KeyPress == "5")
                 {
-                    this->SM->SetPreset(5);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetPreset(5);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "6")
+             if (KeyPress == "6")
                 {
-                    this->SM->SetColorMap(0);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetColorMap(0);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "7")
+             if (KeyPress == "7")
                 {
-                    this->SM->SetColorMap(1);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetColorMap(1);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "8")
+             if (KeyPress == "8")
                 {
-                    this->SM->SetColorMap(2);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetColorMap(2);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "9")
+             if (KeyPress == "9")
                 {
-                    this->SM->SetColorMap(3);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetColorMap(3);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "equal") //keycodes are in vtkWin32RenderWindowInteractor
+             if (KeyPress == "equal") //keycodes are in vtkWin32RenderWindowInteractor
                 {
-                    this->SM->SetPreset(7);
-                    //this->SM->SetColorMap(1);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 this->SM->SetPreset(7);
+                 //this->SM->SetColorMap(1);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "minus")
+             if (KeyPress == "minus")
                 {
-                    std::cout << "KeyPress : - " << std::endl;
-                    this->SM->SetColorWindow(-this->SM->GetColorWindow());
-                    this->SM->SetColorMap(-1);
-                    this->SM->UpdateWindowLevel();
-                    return;
+                 std::cout << "KeyPress : - " << std::endl;
+                 this->SM->SetColorWindow(-this->SM->GetColorWindow());
+                 this->SM->SetColorMap(-1);
+                 this->SM->UpdateWindowLevel();
+                 return;
                 }
-                if (KeyPress == "u")
+             if (KeyPress == "u")
                 {
-                    this->SM->ToggleContourSuperposition();
-                    this->SM->Render();
-                    return;
+                 this->SM->ToggleContourSuperposition();
+                 this->SM->Render();
+                 return;
                 }
-                if (KeyPress == "i")
+             if (KeyPress == "i")
                 {
-                    this->SM->ToggleInterpolation();
-                    this->SM->Render();
-                    return;
+                 this->SM->ToggleInterpolation();
+                 this->SM->Render();
+                 return;
                 }
-                if (KeyPress == "h")
+             if (KeyPress == "h")
                 {
-                    this->SM->SetCursorVisibility(0);
-                    this->SM->Render();
-                    return;
+                 this->SM->SetCursorVisibility(0);
+                 this->SM->Render();
+                 return;
                 }
-                if (KeyPress == "l")
+             if (KeyPress == "l")
                 {
-                    this->SM->Reload();
-                    this->SM->Render();
-                    return;
+                 this->SM->Reload();
+                 this->SM->Render();
+                 return;
                 }
-                if (KeyPress == "r" || KeyPress=="R")
+             if (KeyPress == "r" || KeyPress=="R")
                 {
-                    this->SM->GetSlicer(VisibleInWindow)->ResetCamera();
-                    this->SM->GetSlicer(VisibleInWindow)->Render();
-                    return;
+                 this->SM->GetSlicer(VisibleInWindow)->ResetCamera();
+                 this->SM->GetSlicer(VisibleInWindow)->Render();
+                 return;
                 }
-                if (KeyPress == "g")
+             if (KeyPress == "g")
                 {
-                    double* cursorPos = this->SM->GetSlicer(VisibleInWindow)->GetCursorPosition();
-                    this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(
-                            cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
-                    this->SM->UpdateViews(1,VisibleInWindow);
-                    this->SM->UpdateLinked(VisibleInWindow);
-                    return;
+                 double* cursorPos = this->SM->GetSlicer(VisibleInWindow)->GetCursorPosition();
+                 this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(
+                                                                          cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
+                 this->SM->UpdateViews(1,VisibleInWindow);
+                 this->SM->UpdateLinked(VisibleInWindow);
+                 return;
                 }
-                if (KeyPress == "F5")
+             if (KeyPress == "F5")
                 {
-                    this->SM->GetSlicer(VisibleInWindow)->FlipHorizontalView();
-                    this->SM->GetSlicer(VisibleInWindow)->Render();
-                    return;
+                 this->SM->GetSlicer(VisibleInWindow)->FlipHorizontalView();
+                 this->SM->GetSlicer(VisibleInWindow)->Render();
+                 return;
                 }
-                if (KeyPress == "F6")
+             if (KeyPress == "F6")
                 {
-                    this->SM->GetSlicer(VisibleInWindow)->FlipVerticalView();
-                    this->SM->GetSlicer(VisibleInWindow)->Render();
-                    return;
+                 this->SM->GetSlicer(VisibleInWindow)->FlipVerticalView();
+                 this->SM->GetSlicer(VisibleInWindow)->Render();
+                 return;
                 }
-                if (KeyPress == "Up")
+             if (KeyPress == "Up")
                 {
-                    this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
-                    this->SM->UpdateSlice(VisibleInWindow);
-                    this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+                 this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
+                 this->SM->UpdateSlice(VisibleInWindow);
+                 this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
                 }
-                if (KeyPress == "Down")
+             if (KeyPress == "Down")
                 {
-                    this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
-                    this->SM->UpdateSlice(VisibleInWindow);
-                    this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+                 this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
+                 this->SM->UpdateSlice(VisibleInWindow);
+                 this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
                 }
-                if (KeyPress == "space")
+             if (KeyPress == "space")
                 {
-                    newLandmark = true;
+                 newLandmark = true;
                 }
-                if (KeyPress == "Left")
-                    this->SM->SetPreviousTSlice(VisibleInWindow);
-                if (KeyPress == "Right")
-                    this->SM->SetNextTSlice(VisibleInWindow);
+             if (KeyPress == "Left")
+               this->SM->SetPreviousTSlice(VisibleInWindow);
+             if (KeyPress == "Right")
+               this->SM->SetNextTSlice(VisibleInWindow);
 
-                if (KeyPress == "F1")
+             if (KeyPress == "F1")
                 {
-                    this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Sagital\n<slice>");
-                    this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(0);
-                    this->SM->UpdateSliceRange(VisibleInWindow);
-                    this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+                 this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Sagital\n<slice>");
+                 this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(0);
+                 this->SM->UpdateSliceRange(VisibleInWindow);
+                 this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
                 }
-                if (KeyPress == "F2")
+             if (KeyPress == "F2")
                 {
-                    this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Coronal\n<slice>");
-                    this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(1);
-                    this->SM->UpdateSliceRange(VisibleInWindow);
-                    this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+                 this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Coronal\n<slice>");
+                 this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(1);
+                 this->SM->UpdateSliceRange(VisibleInWindow);
+                 this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
                 }
-                if (KeyPress == "F3")
+             if (KeyPress == "F3")
                 {
-                    this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Axial\n<slice>");
-                    this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(2);
-                    this->SM->UpdateSliceRange(VisibleInWindow);
-                    this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+                 this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Axial\n<slice>");
+                 this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(2);
+                 this->SM->UpdateSliceRange(VisibleInWindow);
+                 this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
                 }
             }
 
-            //All type of mouse events
-            if (event == vtkCommand::LeaveEvent)
+         //All type of mouse events
+         if (event == vtkCommand::LeaveEvent)
             {
-                this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
-                        -VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
-                this->SM->GetSlicer(VisibleInWindow)->Render();
-                return;
+             this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
+                                                                      -VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+             this->SM->GetSlicer(VisibleInWindow)->Render();
+             return;
             }
 
-            if (event == vtkCommand::StartWindowLevelEvent)
+         if (event == vtkCommand::StartWindowLevelEvent)
             {
-                mStartSlicer = -1;
-                this->InitialWindow = this->SM->GetColorWindow();
-                this->InitialLevel = this->SM->GetColorLevel();
+             mStartSlicer = -1;
+             this->InitialWindow = this->SM->GetColorWindow();
+             this->InitialLevel = this->SM->GetColorLevel();
 
-                if (VisibleInWindow > -1)
+             if (VisibleInWindow > -1)
                 {
-                    mStartSlicer = VisibleInWindow;
+                 mStartSlicer = VisibleInWindow;
                 }
-                return;
+             return;
             }
 
-            if (event == vtkCommand::EndWindowLevelEvent)
+         if (event == vtkCommand::EndWindowLevelEvent)
             {
-                mStartSlicer = -1;
+             mStartSlicer = -1;
             }
 
         }
-        if (VisibleInWindow > -1)
+      if (VisibleInWindow > -1)
         {
-            this->SM->Activated();
-            //if(!this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->GetVisibility())
-            this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetVisibility(1);
+         this->SM->Activated();
+         //if(!this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->GetVisibility())
+         this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetVisibility(1);
 
-            if (event == vtkCommand::MouseWheelForwardEvent && !isi->GetInteractor()->GetControlKey())
+         if (event == vtkCommand::MouseWheelForwardEvent && !isi->GetInteractor()->GetControlKey())
             {
-                this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
-                this->SM->UpdateSlice(VisibleInWindow);
-                this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+             this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
+             this->SM->UpdateSlice(VisibleInWindow);
+             this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
             }
-            else if (event == vtkCommand::MouseWheelForwardEvent && isi->GetInteractor()->GetControlKey())
+         else if (event == vtkCommand::MouseWheelForwardEvent && isi->GetInteractor()->GetControlKey())
             {
-                double factor = 2;
-                this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
+             double factor = 2;
+             this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
             }
-            else if (event == vtkCommand::MouseWheelBackwardEvent && !isi->GetInteractor()->GetControlKey())
+         else if (event == vtkCommand::MouseWheelBackwardEvent && !isi->GetInteractor()->GetControlKey())
             {
-                this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
-                this->SM->UpdateSlice(VisibleInWindow);
-                this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+             this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
+             this->SM->UpdateSlice(VisibleInWindow);
+             this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
             }
-            else if (event == vtkCommand::MouseWheelBackwardEvent && isi->GetInteractor()->GetControlKey())
+         else if (event == vtkCommand::MouseWheelBackwardEvent && isi->GetInteractor()->GetControlKey())
             {
-                double factor = -2;
-                this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
+             double factor = -2;
+             this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
             }
-            double xWorld=0; double yWorld=0; double zWorld=0;
-
-            //Move into World Coordinate
-            renderer->DisplayToNormalizedDisplay(x,y);
-            renderer->NormalizedDisplayToViewport(x,y);
-            renderer->ViewportToNormalizedViewport(x,y);
-            renderer->NormalizedViewportToView(x,y,z);
-            renderer->ViewToWorld(x,y,z);
-            switch (this->SM->GetSlicer(VisibleInWindow)->GetSliceOrientation())
+         double xWorld=0; double yWorld=0; double zWorld=0;
+
+         //Move into World Coordinate
+         renderer->DisplayToNormalizedDisplay(x,y);
+         renderer->NormalizedDisplayToViewport(x,y);
+         renderer->ViewportToNormalizedViewport(x,y);
+         renderer->NormalizedViewportToView(x,y,z);
+         renderer->ViewToWorld(x,y,z);
+         switch (this->SM->GetSlicer(VisibleInWindow)->GetSliceOrientation())
             {
             case vtkImageViewer2::SLICE_ORIENTATION_XY:
-                xWorld = x;
-                yWorld = y;
-                zWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[2] +
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[2];
-                break;
+             xWorld = x;
+             yWorld = y;
+             zWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
+               this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[2] +
+               this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[2];
+             break;
 
             case vtkImageViewer2::SLICE_ORIENTATION_XZ:
-                xWorld = x;
-                yWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[1] +
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[1];
-                zWorld = z;
-                break;
+             xWorld = x;
+             yWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
+               this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[1] +
+               this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[1];
+             zWorld = z;
+             break;
 
             case vtkImageViewer2::SLICE_ORIENTATION_YZ:
-                xWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[0] +
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[0];
-                yWorld = y;
-                zWorld = z;
-                break;
+             xWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
+               this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[0] +
+               this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[0];
+             yWorld = y;
+             zWorld = z;
+             break;
             }
-            this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld,
-                    this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
-            if (newLandmark)
+         this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld,
+                                                                  this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+         if (newLandmark)
             {
-                this->SM->AddLandmark(xWorld,yWorld,zWorld,
-                                      this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
-                this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks();
-                this->SM->Render();
+             this->SM->AddLandmark(xWorld,yWorld,zWorld,
+                                   this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+             this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks();
+             this->SM->Render();
             }
-            if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent)
+         if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent)
             {
-                this->SM->UpdateViews(1,VisibleInWindow);
-                this->SM->UpdateLinked(VisibleInWindow);
-                this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
+             this->SM->UpdateViews(1,VisibleInWindow);
+             this->SM->UpdateLinked(VisibleInWindow);
+             this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
             }
-            else
+         else
             {
-                this->SM->GetSlicer(VisibleInWindow)->Render();
+             this->SM->GetSlicer(VisibleInWindow)->Render();
             }
-            //this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
-                    //-VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
-            //this->SM->GetSlicer(VisibleInWindow)->Render();
+         //this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
+         //-VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+         //this->SM->GetSlicer(VisibleInWindow)->Render();
         }
 
-        if (event == vtkCommand::WindowLevelEvent && mStartSlicer > -1)
+      if (event == vtkCommand::WindowLevelEvent && mStartSlicer > -1)
         {
-            this->SM->GetSlicer(mStartSlicer)->GetAnnotation()->SetVisibility(1);
-            // Adjust the window level here
-            int *size = isi->GetInteractor()->GetRenderWindow()->GetSize();
-            double window = this->InitialWindow;
-            double level = this->InitialLevel;
-            double range[2];
-            this->SM->GetImage()->GetScalarRange(range);
-
-            // Compute normalized delta
-            double dx = static_cast<double>(isi->GetWindowLevelCurrentPosition()[0] -
-                         isi->GetWindowLevelStartPosition()[0]) / size[0];
-            double dy = static_cast<double>(isi->GetWindowLevelStartPosition()[1] -
-                         isi->GetWindowLevelCurrentPosition()[1]) / size[1];
-            //Window is exponential in nature, use exponential to avoid falling into negative numbers
-            dx = std::exp(1.0 * (dx*fabs(dx) + dx)) ; //Quadratic behavior for more reactive interface
-            dy = 0.15 * (dy*fabs(dy) + dy) * (range[1]-range[0]);//Quadratic behavior for more reactive interface
-
-            this->SM->SetColorWindow(window*dx);
-            this->SM->SetColorLevel(level-dy);
-            this->SM->SetPreset(6);
-            this->SM->UpdateWindowLevel();
-            this->SM->Render();
-            return;
+         this->SM->GetSlicer(mStartSlicer)->GetAnnotation()->SetVisibility(1);
+         // Adjust the window level here
+         int *size = isi->GetInteractor()->GetRenderWindow()->GetSize();
+         double window = this->InitialWindow;
+         double level = this->InitialLevel;
+         double range[2];
+         this->SM->GetImage()->GetScalarRange(range);
+
+         // Compute normalized delta
+         double dx = static_cast<double>(isi->GetWindowLevelCurrentPosition()[0] -
+                                         isi->GetWindowLevelStartPosition()[0]) / size[0];
+         double dy = static_cast<double>(isi->GetWindowLevelStartPosition()[1] -
+                                         isi->GetWindowLevelCurrentPosition()[1]) / size[1];
+         //Window is exponential in nature, use exponential to avoid falling into negative numbers
+         dx = std::exp(1.0 * (dx*fabs(dx) + dx)) ; //Quadratic behavior for more reactive interface
+         dy = 0.15 * (dy*fabs(dy) + dy) * (range[1]-range[0]);//Quadratic behavior for more reactive interface
+
+         this->SM->SetColorWindow(window*dx);
+         this->SM->SetColorLevel(level-dy);
+         this->SM->SetPreset(6);
+         this->SM->UpdateWindowLevel();
+         this->SM->Render();
+         return;
         }
     }
 }
+//------------------------------------------------------------------------------
+
 
+//------------------------------------------------------------------------------
 void vvSlicerManagerCallback::Dolly(double factor, vtkRenderWindowInteractor *interactor)
 {
-    int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
-    vtkRenderer* renderer;
-    if (VisibleInWindow>-1) 
-        renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
-    else
+  int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
+  vtkRenderer* renderer;
+  if (VisibleInWindow>-1) 
+    renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
+  else
     {
-        return;
+      return;
     }
 
-    double viewFocus[4],viewPoint[4],motionVector[3], focalDepth;
-    double oldPos[3], newPos[3], distance[2];
-    vtkCamera *camera = renderer->GetActiveCamera();
-    camera->GetFocalPoint(viewFocus);
-
-    renderer->SetWorldPoint(viewFocus[0], viewFocus[0], viewFocus[0], 1.0);
-    renderer->WorldToDisplay();
-    renderer->GetDisplayPoint(viewFocus);
-
-    focalDepth = viewFocus[2];
-
-    oldPos[0] = renderer->GetCenter()[0];
-    oldPos[1] = renderer->GetCenter()[1];
-    oldPos[2] = focalDepth;
-
-    distance[0] = 1/factor*
-                  (interactor->GetEventPosition()[0]-renderer->GetCenter()[0]);
-    distance[1] = 1/factor*
-                  (interactor->GetEventPosition()[1]-renderer->GetCenter()[1]);
-
-    newPos[0] = interactor->GetEventPosition()[0] - distance[0];
-    newPos[1] = interactor->GetEventPosition()[1] - distance[1];
-    newPos[2] = focalDepth;
-
-    renderer->DisplayToNormalizedDisplay(oldPos[0],oldPos[1]);
-    renderer->NormalizedDisplayToViewport(oldPos[0],oldPos[1]);
-    renderer->ViewportToNormalizedViewport(oldPos[0],oldPos[1]);
-    renderer->NormalizedViewportToView(oldPos[0],oldPos[1],oldPos[2]);
-    renderer->ViewToWorld(oldPos[0],oldPos[1],oldPos[2]);
-
-    renderer->DisplayToNormalizedDisplay(newPos[0],newPos[1]);
-    renderer->NormalizedDisplayToViewport(newPos[0],newPos[1]);
-    renderer->ViewportToNormalizedViewport(newPos[0],newPos[1]);
-    renderer->NormalizedViewportToView(newPos[0],newPos[1],newPos[2]);
-    renderer->ViewToWorld(newPos[0],newPos[1],newPos[2]);
-
-    motionVector[0] = newPos[0] - oldPos[0];
-    motionVector[1] = newPos[1] - oldPos[1];
-    motionVector[2] = newPos[2] - oldPos[2];
-
-    camera->GetFocalPoint(viewFocus);
-    camera->GetPosition(viewPoint);
-    camera->SetFocalPoint(motionVector[0] + viewFocus[0],
-                          motionVector[1] + viewFocus[1],
-                          motionVector[2] + viewFocus[2]);
-
-    camera->SetPosition(motionVector[0] + viewPoint[0],
-                        motionVector[1] + viewPoint[1],
-                        motionVector[2] + viewPoint[2]);
-
-    if (camera->GetParallelProjection())
+  double viewFocus[4],viewPoint[4],motionVector[3], focalDepth;
+  double oldPos[3], newPos[3], distance[2];
+  vtkCamera *camera = renderer->GetActiveCamera();
+  camera->GetFocalPoint(viewFocus);
+
+  renderer->SetWorldPoint(viewFocus[0], viewFocus[0], viewFocus[0], 1.0);
+  renderer->WorldToDisplay();
+  renderer->GetDisplayPoint(viewFocus);
+
+  focalDepth = viewFocus[2];
+
+  oldPos[0] = renderer->GetCenter()[0];
+  oldPos[1] = renderer->GetCenter()[1];
+  oldPos[2] = focalDepth;
+
+  distance[0] = 1/factor*
+    (interactor->GetEventPosition()[0]-renderer->GetCenter()[0]);
+  distance[1] = 1/factor*
+    (interactor->GetEventPosition()[1]-renderer->GetCenter()[1]);
+
+  newPos[0] = interactor->GetEventPosition()[0] - distance[0];
+  newPos[1] = interactor->GetEventPosition()[1] - distance[1];
+  newPos[2] = focalDepth;
+
+  renderer->DisplayToNormalizedDisplay(oldPos[0],oldPos[1]);
+  renderer->NormalizedDisplayToViewport(oldPos[0],oldPos[1]);
+  renderer->ViewportToNormalizedViewport(oldPos[0],oldPos[1]);
+  renderer->NormalizedViewportToView(oldPos[0],oldPos[1],oldPos[2]);
+  renderer->ViewToWorld(oldPos[0],oldPos[1],oldPos[2]);
+
+  renderer->DisplayToNormalizedDisplay(newPos[0],newPos[1]);
+  renderer->NormalizedDisplayToViewport(newPos[0],newPos[1]);
+  renderer->ViewportToNormalizedViewport(newPos[0],newPos[1]);
+  renderer->NormalizedViewportToView(newPos[0],newPos[1],newPos[2]);
+  renderer->ViewToWorld(newPos[0],newPos[1],newPos[2]);
+
+  motionVector[0] = newPos[0] - oldPos[0];
+  motionVector[1] = newPos[1] - oldPos[1];
+  motionVector[2] = newPos[2] - oldPos[2];
+
+  camera->GetFocalPoint(viewFocus);
+  camera->GetPosition(viewPoint);
+  camera->SetFocalPoint(motionVector[0] + viewFocus[0],
+                       motionVector[1] + viewFocus[1],
+                       motionVector[2] + viewFocus[2]);
+
+  camera->SetPosition(motionVector[0] + viewPoint[0],
+                     motionVector[1] + viewPoint[1],
+                     motionVector[2] + viewPoint[2]);
+
+  if (camera->GetParallelProjection())
     {
-        camera->SetParallelScale(camera->GetParallelScale() / factor);
+      camera->SetParallelScale(camera->GetParallelScale() / factor);
     }
-    else
+  else
     {
-        camera->Dolly(factor);
+      camera->Dolly(factor);
     }
 
-    if (interactor->GetLightFollowCamera())
+  if (interactor->GetLightFollowCamera())
     {
-        renderer->UpdateLightsGeometryToFollowCamera();
+      renderer->UpdateLightsGeometryToFollowCamera();
     }
-    renderer->ResetCameraClippingRange();
-    //interactor->Render();
+  renderer->ResetCameraClippingRange();
+  //interactor->Render();
 }
 
 void vvSlicerManagerCallback::FlyToPosition(vtkRenderWindowInteractor *interactor,vvSlicer* slicer)
 {
-    double flyFrom[3], flyTo[3];
-    double d[3], focalPt[3], position[3], positionFrom[3];
-    int i, j;
-    int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
-    vtkRenderer* renderer=NULL;
-    if (VisibleInWindow>-1) 
-        renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
-    else
-        return;
-
-    interactor->GetPicker()->Pick(interactor->GetEventPosition()[0],
-                                  interactor->GetEventPosition()[1], 0.0,
-                                  renderer);
-
-    vtkAssemblyPath *path=NULL;
-    vtkAbstractPropPicker *picker;
-    if ( (picker=vtkAbstractPropPicker::SafeDownCast(interactor->GetPicker())))
+  double flyFrom[3], flyTo[3];
+  double d[3], focalPt[3], position[3], positionFrom[3];
+  int i, j;
+  int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
+  vtkRenderer* renderer=NULL;
+  if (VisibleInWindow>-1) 
+    renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
+  else
+    return;
+
+  interactor->GetPicker()->Pick(interactor->GetEventPosition()[0],
+                               interactor->GetEventPosition()[1], 0.0,
+                               renderer);
+
+  vtkAssemblyPath *path=NULL;
+  vtkAbstractPropPicker *picker;
+  if ( (picker=vtkAbstractPropPicker::SafeDownCast(interactor->GetPicker())))
     {
-        path = picker->GetPath();
+      path = picker->GetPath();
     }
-    if ( path != NULL )
+  if ( path != NULL )
     {
-        flyTo[0] = picker->GetPickPosition()[0];
-        flyTo[1] = picker->GetPickPosition()[1];
-        flyTo[2] = picker->GetPickPosition()[2];
-        renderer->GetActiveCamera()->GetFocalPoint(flyFrom);
-        renderer->GetActiveCamera()->GetPosition(positionFrom);
+      flyTo[0] = picker->GetPickPosition()[0];
+      flyTo[1] = picker->GetPickPosition()[1];
+      flyTo[2] = picker->GetPickPosition()[2];
+      renderer->GetActiveCamera()->GetFocalPoint(flyFrom);
+      renderer->GetActiveCamera()->GetPosition(positionFrom);
 
-        switch (slicer->GetSliceOrientation())
+      switch (slicer->GetSliceOrientation())
         {
         case vtkImageViewer2::SLICE_ORIENTATION_XY:
-            flyTo[2] = flyFrom[2];
-            break;
+         flyTo[2] = flyFrom[2];
+         break;
 
         case vtkImageViewer2::SLICE_ORIENTATION_XZ:
-            flyTo[1] = flyFrom[1];
-            break;
+         flyTo[1] = flyFrom[1];
+         break;
 
         case vtkImageViewer2::SLICE_ORIENTATION_YZ:
-            flyTo[0] = flyFrom[0];
-            break;
+         flyTo[0] = flyFrom[0];
+         break;
         }
 
 
-        for (i=0; i<3; i++)
+      for (i=0; i<3; i++)
         {
-            d[i] = flyTo[i] - flyFrom[i];
+         d[i] = flyTo[i] - flyFrom[i];
         }
-        double distance = vtkMath::Normalize(d);
-        double delta = distance/15;
+      double distance = vtkMath::Normalize(d);
+      double delta = distance/15;
 
-        for (i=1; i<=15; i++)
+      for (i=1; i<=15; i++)
         {
-            for (j=0; j<3; j++)
+         for (j=0; j<3; j++)
             {
-                focalPt[j] = flyFrom[j] + d[j]*i*delta;
-                position[j] = positionFrom[j] + d[j]*i*delta;
+             focalPt[j] = flyFrom[j] + d[j]*i*delta;
+             position[j] = positionFrom[j] + d[j]*i*delta;
             }
-            renderer->GetActiveCamera()->SetFocalPoint(focalPt);
-            renderer->GetActiveCamera()->SetPosition(position);
-            renderer->GetActiveCamera()->Dolly(0.3/15 + 1.0);
-            renderer->ResetCameraClippingRange();
-            interactor->Render();
+         renderer->GetActiveCamera()->SetFocalPoint(focalPt);
+         renderer->GetActiveCamera()->SetPosition(position);
+         renderer->GetActiveCamera()->Dolly(0.3/15 + 1.0);
+         renderer->ResetCameraClippingRange();
+         interactor->Render();
         }
     }
 }
index 9e371f5172b1eabcc86bc52f8d1a15f22eda037d..005217fb30be94ad0fa8513fc332b2f5e3dd7663 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolBase.h,v $
   Language:  C++
-  Date:      $Date: 2010/02/09 14:19:32 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.3 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
 #ifndef VVTOOLBASE_H
 #define VVTOOLBASE_H
 
-#include "vvToolCreatorBase.h"
-#include "vvToolInputSelectorWidget.h"
-#include "clitkImageToImageGenericFilter.h"
+#include "vvToolBaseBase.h"
+#include "vvToolCreator.h"
 
 //------------------------------------------------------------------------------
 template<class ToolType>
-class vvToolBase {
+class vvToolBase : public vvToolBaseBase {
 public:
+  vvToolBase(vvMainWindowBase * m);
   static void Initialize();  // can't be virtual, must be overwritten
-  void UpdateInfoFromMainWindow();
-  vvMainWindowToolInfo * mMainWindowToolInfo;
 
   static void SetToolName(QString n) { vvToolCreator<ToolType>::mSingleton->mToolName = n; }
   static void SetToolMenuName(QString n) { vvToolCreator<ToolType>::mSingleton->mToolMenuName = n; }
   static void SetToolIconFilename(QString n) { vvToolCreator<ToolType>::mSingleton->mToolIconFilename = n; }
   static void SetToolTip(QString n) { vvToolCreator<ToolType>::mSingleton->mToolTip = n; }
 
-  void InitializeListOfInputImages();
-  void InitializeListOfInputImages(vvToolInputSelectorWidget * w, 
-                                   clitk::ImageToImageGenericFilterBase * f);
-  std::vector<vvSlicerManager*> mSlicerManagersCompatible;
-  unsigned int mCurrentIndex;
-
-  vvImage::Pointer mCurrentImage;
-  vvSlicerManager * mCurrentSliceManager;
-  clitk::ImageToImageGenericFilterBase * mFilter;
-
 };
 //------------------------------------------------------------------------------
 
-
-//------------------------------------------------------------------------------
-template<class ToolType>
-void vvToolBase<ToolType>::UpdateInfoFromMainWindow() { 
-  mMainWindowToolInfo = vvToolCreator<ToolType>::mSingleton->mMainWindow->GetInfoForTool(); 
-}
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------  
-template<class ToolType>
-void vvToolBase<ToolType>::Initialize() {
-  SetToolName("Unnamed tool");
-  SetToolMenuName("Unnamed tool");
-  SetToolIconFilename("");
-  SetToolTip("Unamed tool.");
-}
-//------------------------------------------------------------------------------    
-
-
-//------------------------------------------------------------------------------
-template<class ToolType>
-void vvToolBase<ToolType>::InitializeListOfInputImages(vvToolInputSelectorWidget * w, 
-                                                       clitk::ImageToImageGenericFilterBase * f) {
-  mFilter = f;
-  InitializeListOfInputImages();
-  w->Initialize(mSlicerManagersCompatible, mCurrentIndex);
-  w->SetToolTip(mFilter->GetAvailableImageTypes().c_str());
-}
-//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-template<class ToolType>
-void vvToolBase<ToolType>::InitializeListOfInputImages() {
-  UpdateInfoFromMainWindow();
-
-  std::vector<vvSlicerManager*> & mSlicerManagers = *mMainWindowToolInfo->mSlicerManagers;
-  mCurrentIndex = mMainWindowToolInfo->mSlicerManagerCurrentIndex;
-  DD("InputUpdate");
-  DD(mCurrentIndex);
-  // HERE : Check if image is ok (dimension, type etc ...)
-
-  if (mFilter) {
-    mFilter->PrintAvailableImageTypes();
-    
-  }
-  else {
-    /// if not set, do not check filter type
-    std::cerr << "*** ERROR, set mFilter member in the vvTool class before calling InitializeListOfInputImages" << std::endl;
-    exit(0);
-  }
-
-  //unsigned int previousIndex = mInputSequenceBox->mCurrentIndex();
-  mSlicerManagersCompatible.clear();
-  // mInputSequenceBox->clear();
-  for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
-    
-    vvImage * image = mSlicerManagers[i]->GetImage();
-    
-    if (mFilter->CheckImageType(image->GetNumberOfDimensions(),
-                image->GetNumberOfScalarComponents(),
-                image->GetScalarTypeAsString())) {
-      mSlicerManagersCompatible.push_back(mSlicerManagers[i]);
-      if (mCurrentIndex == i) {
-        mCurrentIndex = mSlicerManagersCompatible.size()-1;
-      }
-    }
-    else {
-      std::cerr << mSlicerManagers[i]->GetFileName().c_str() << " not compatible image" << std::endl;
-      if (mCurrentIndex == i) {
-        mCurrentIndex = 0;
-      }
-    }
-  }  
-}
-//------------------------------------------------------------------------------
-
+#include "vvToolBase.txx"
 
 #endif
 
diff --git a/vv/vvToolBase.txx b/vv/vvToolBase.txx
new file mode 100644 (file)
index 0000000..661a423
--- /dev/null
@@ -0,0 +1,45 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolBase.txx,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2008
+  Léon Bérard cancer center  http://oncora1.lyon.fnclcc.fr
+  CREATIS                    http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+//------------------------------------------------------------------------------
+template<class ToolType>
+vvToolBase<ToolType>::vvToolBase(vvMainWindowBase * m) { 
+  mMainWindowBase = m; 
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------  
+// Default value (to be overwritten)
+template<class ToolType>
+void vvToolBase<ToolType>::Initialize() {
+  SetToolName("Unnamed tool (use SetToolName in Initialize())");
+  SetToolMenuName("Unnamed tool");
+  SetToolIconFilename("");
+  SetToolTip("Unamed tool.");
+}
+//------------------------------------------------------------------------------    
+
index d8fb488a0235e5292b2d2edfd2e953ee39067bfd..bccf02151d761b807c9240d93e4fb2a19f8873e4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolBinarize.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/02/07 12:00:59 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.8 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
@@ -44,54 +44,45 @@ ADD_TOOL(vvToolBinarize);
 
 
 //------------------------------------------------------------------------------
-vvToolBinarize::vvToolBinarize(QWidget * parent, Qt::WindowFlags f)
-  :QDialog(parent,f), vvToolBase<vvToolBinarize>(), Ui::vvToolBinarize() 
-{
-  // Set Modality : dialog is not modal but stay always on top because
-  // parent is set at construction
-  setModal(false);
-  setAttribute(Qt::WA_DeleteOnClose);
+void vvToolBinarize::Initialize() {
+  SetToolName("Binarize");
+  SetToolMenuName("Binarize");
+  SetToolIconFilename(":/new/prefix1/icons/binarize.png");
+  SetToolTip("Image interactive binarization with thresholds.");
+}
+//------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
+vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f)
+  :vvToolWidgetBase(parent,f), 
+   vvToolBase<vvToolBinarize>(parent), 
+   Ui::vvToolBinarize() 
+{
   // GUI Initialization
-  setupUi(this);
+  Ui_vvToolBinarize::setupUi(mToolWidget);
 
   // Connect signals & slots  
-  connect(mToolInputSelectionWidget, SIGNAL(accepted()), this, SLOT(InputIsSelected()));
-  connect(mToolInputSelectionWidget, SIGNAL(rejected()), this, SLOT(close()));
-  connect(buttonBox, SIGNAL(accepted()), this, SLOT(apply()));
-  connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
   connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1(double)));
   connect(mThresholdSlider2, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT2(double)));
   connect(mRadioButtonLowerThan, SIGNAL(toggled(bool)), this, SLOT(enableLowerThan(bool)));
   connect(mCheckBoxUseFG, SIGNAL(toggled(bool)), this, SLOT(useFGBGtoggled(bool)));
   connect(mCheckBoxUseBG, SIGNAL(toggled(bool)), this, SLOT(useFGBGtoggled(bool)));
 
-  // VTK objects
-  //mImageContour = new vvImageContour;
-
-  //new vector of contours
-
   // Initialize some widget
   mThresholdSlider1->SetText("");
   mThresholdSlider2->SetText("");
   mFGSlider->SetText("Foreground value");
   mBGSlider->SetText("Background value");
 
-  // Disable main widget while input image is not selected
-  toolMainWidget->setEnabled(false);
-
   // Main filter 
   mFilter = new clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>; //DS PUT IN BASECLASS ?
-
-  // Initialize the input selection (mFilter should be create before !)
-  InitializeListOfInputImages(mToolInputSelectionWidget, mFilter);
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 vvToolBinarize::~vvToolBinarize() {
-  //delete mImageContour;
 }
 //------------------------------------------------------------------------------
 
@@ -117,13 +108,10 @@ void vvToolBinarize::useFGBGtoggled(bool) {
 
 
 //------------------------------------------------------------------------------
-void vvToolBinarize::InputIsSelected() {
-
+void vvToolBinarize::InputIsSelected(vvSlicerManager * m) {
+  mCurrentSlicerManager = m;
   // Common
-  int index = mToolInputSelectionWidget->GetSelectedInputIndex();
-  mCurrentSliceManager = mSlicerManagersCompatible[index];
-  mCurrentImage = mCurrentSliceManager->GetImage();
-  toolMainWidget->setEnabled(true);
+  mCurrentImage = mCurrentSlicerManager->GetImage();
 
   // Specific for this gui
   mThresholdSlider1->SetValue(0);
@@ -132,7 +120,7 @@ void vvToolBinarize::InputIsSelected() {
   mThresholdSlider2->SetImage(mCurrentImage);
   mFGSlider->SetImage(mCurrentImage);
   mBGSlider->SetImage(mCurrentImage);
-  DD(mCurrentSliceManager->GetFileName().c_str());
+  //  DD(mCurrentSlicerManager->GetFileName().c_str());
   mFGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax());
   mFGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin());
   mBGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax());
@@ -141,13 +129,13 @@ void vvToolBinarize::InputIsSelected() {
   mBGSlider->SetValue(0);
   
   // VTK objects for interactive display
-  for(int i=0;i<mCurrentSliceManager->NumberOfSlicers(); i++) {
+  for(int i=0;i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
     mImageContour.push_back(new vvImageContour);
-    mImageContour[i]->setSlicer(mCurrentSliceManager->GetSlicer(i));
+    mImageContour[i]->setSlicer(mCurrentSlicerManager->GetSlicer(i));
   }
   valueChangedT1(mThresholdSlider1->GetValue());
-  connect(mCurrentSliceManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
-  connect(mCurrentSliceManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
+  connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
+  connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
 
 }
 //------------------------------------------------------------------------------
@@ -155,11 +143,11 @@ void vvToolBinarize::InputIsSelected() {
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::UpdateSlice(int slicer,int slices) {
-  DD(slicer);
-  for(int i=0;i<mCurrentSliceManager->NumberOfSlicers(); i++) {
+  if (!mCurrentSlicerManager) close();
+  for(int i=0;i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
     mImageContour[i]->update(mThresholdSlider1->GetValue());
   }
-  mCurrentSliceManager->Render(); 
+  mCurrentSlicerManager->Render(); 
 }
 //------------------------------------------------------------------------------
 
@@ -183,7 +171,7 @@ void vvToolBinarize::GetArgsInfoFromGUI() {
 
   mArgsInfo.lower_given = 1;
   mArgsInfo.lower_arg = mThresholdSlider1->GetValue();
-  DD(mArgsInfo.lower_arg);
+  // DD(mArgsInfo.lower_arg);
   if (mRadioButtonLowerThan->isChecked()) {
     mArgsInfo.upper_given = 1;
     mArgsInfo.upper_arg = mThresholdSlider2->GetValue();
@@ -196,7 +184,7 @@ void vvToolBinarize::GetArgsInfoFromGUI() {
   mArgsInfo.fg_arg = mFGSlider->GetValue();
   mArgsInfo.bg_arg = mBGSlider->GetValue();
 
-  DD(inverseBGandFG);
+  // DD(inverseBGandFG);
   if (inverseBGandFG) {
     mArgsInfo.fg_arg = mFGSlider->GetValue();
     mArgsInfo.bg_arg = mBGSlider->GetValue();
@@ -224,6 +212,7 @@ void vvToolBinarize::GetArgsInfoFromGUI() {
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::apply() {
+  if (!mCurrentSlicerManager) close();
   GetArgsInfoFromGUI();
 
   // Main filter
@@ -236,8 +225,8 @@ void vvToolBinarize::apply() {
   // Output ???
   vvImage::Pointer output = filter->GetOutputVVImage();
   std::ostringstream osstream;
-  osstream << "Binarized_" << mCurrentSliceManager->GetSlicer(0)->GetFileName();
-  CREATOR(vvToolBinarize)->mMainWindow->AddImage(output,osstream.str()); 
+  osstream << "Binarized_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName();
+  CREATOR(vvToolBinarize)->GetMainWindow()->AddImage(output,osstream.str()); 
   close();
 }
 //------------------------------------------------------------------------------
@@ -252,12 +241,15 @@ void vvToolBinarize::valueChangedT2(double v) {
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::valueChangedT1(double v) {
+  // DD(v);
+  if (!mCurrentSlicerManager) close();
+//   DD(mCurrentSlicerManager->GetSlicer(0));
   mThresholdSlider2->SetMinimum(v);
   int m1 = (int)lrint(v);
 
-  for(int i=0;i<mCurrentSliceManager->NumberOfSlicers(); i++) {
+  for(int i=0;i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
     mImageContour[i]->update(m1);
   }
-  mCurrentSliceManager->Render();
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
index a1bd7d52d1067b39c24f96861458f7909599afa5..f29d1190367a797b46e1f5fdd53a366135f33843 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolBinarize.h,v $
   Language:  C++
-  Date:      $Date: 2010/02/07 12:00:59 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.6 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2010
 #define VVTOOLBINARIZE_H
 
 #include <QtDesigner/QDesignerExportWidget>
-#include <QDialog>
+//#include <QDialog>
 
 #include "vvToolBase.h"
+#include "vvToolWidgetBase.h"
 #include "vvImageContour.h"
 #include "ui_vvToolBinarize.h"
 #include "clitkBinarizeImage_ggo.h"
 
 //------------------------------------------------------------------------------
 class vvToolBinarize:
-  public QDialog, public vvToolBase<vvToolBinarize>, private Ui::vvToolBinarize 
+  public vvToolWidgetBase,
+  public vvToolBase<vvToolBinarize>, 
+  private Ui::vvToolBinarize 
 {
   Q_OBJECT
     public:
-  vvToolBinarize(QWidget * parent=0, Qt::WindowFlags f=0);
+  vvToolBinarize(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
   ~vvToolBinarize();
 
   //-----------------------------------------------------
-  typedef vvToolBinarize Self;
-
-  //-----------------------------------------------------
-  static void Initialize() {
-    SetToolName("Binarize");
-    SetToolMenuName("Binarize");
-    SetToolIconFilename(":/new/prefix1/icons/binarize.png");
-    SetToolTip("Image interactive binarization with thresholds.");
-  }
-
+  static void Initialize();
   void InputIsSet(bool b);
   void GetArgsInfoFromGUI();
 
@@ -74,9 +68,23 @@ class vvToolBinarize:
   void valueChangedT1(double v);
   void valueChangedT2(double v);
   void UpdateSlice(int slicer,int slices);
-  void InputIsSelected();
+  void InputIsSelected(vvSlicerManager * m);
   void enableLowerThan(bool b);
   void useFGBGtoggled(bool);
+  virtual bool close() { DD("vvToolBinarize::close"); 
+    for(unsigned int i=0; i<mImageContour.size(); i++)
+      mImageContour[i]->removeActors();
+    if (mCurrentSlicerManager)
+      mCurrentSlicerManager->Render();
+    return vvToolWidgetBase::close(); }
+
+  virtual void reject() { DD("vvToolBinarize::reject"); 
+    for(unsigned int i=0; i<mImageContour.size(); i++)
+      mImageContour[i]->removeActors();
+    if (mCurrentSlicerManager)
+      mCurrentSlicerManager->Render();
+    return vvToolWidgetBase::reject(); }
+
 
  protected:
   Ui::vvToolBinarize ui;
diff --git a/vv/vvToolCreator.h b/vv/vvToolCreator.h
new file mode 100644 (file)
index 0000000..e2d108a
--- /dev/null
@@ -0,0 +1,60 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolCreator.h,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2008
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#ifndef VVTOOLCREATOR_H
+#define VVTOOLCREATOR_H
+
+#include "vvToolCreatorBase.h"
+
+//------------------------------------------------------------------------------
+template<class ToolType>
+class vvToolCreator: public vvToolCreatorBase {
+public:
+  vvToolCreator(QString name):vvToolCreatorBase(name) {;}
+  virtual void InsertToolInMenu(vvMainWindowBase * m);
+  virtual void MenuSpecificToolSlot() { CreateTool<ToolType>(); }
+  static vvToolCreator<ToolType> * mSingleton;
+};
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+#define CREATOR(CLASSNAME) vvToolCreator<CLASSNAME>::mSingleton
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+#define ADD_TOOL(NAME)                                          \
+  template<>                                                    \
+  vvToolCreator<NAME> * vvToolCreator<NAME>::mSingleton =       \
+    new vvToolCreator<NAME>(#NAME);
+//------------------------------------------------------------------------------
+
+#include "vvToolCreator.txx"
+
+#endif
+
diff --git a/vv/vvToolCreator.txx b/vv/vvToolCreator.txx
new file mode 100644 (file)
index 0000000..bee8cbb
--- /dev/null
@@ -0,0 +1,45 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolCreator.txx,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2008
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+//------------------------------------------------------------------------------
+// Call when the ToolType is inserted into the menu
+template<class ToolType>
+void vvToolCreator<ToolType>::InsertToolInMenu(vvMainWindowBase * m) { 
+  mMainWindow = m;
+
+  // Default Initialization
+  mToolMenuName = mToolName;
+  mToolIconFilename = "noicon";
+  mToolTip = mToolName;
+
+  // User Tool Initialization
+  ToolType::Initialize();
+
+  // Common Initialization (insertion into menu)
+  vvToolCreatorBase::InsertToolInMenu(mMainWindow); 
+}
+//------------------------------------------------------------------------------
index e47fa142deb9c61e7d21c01194d89e581bf8e36a..57a1d9f24b358c2584cf06ff7a31cb27fab3ed4d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolCreatorBase.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/01/29 13:54:37 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.2 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
@@ -26,9 +26,9 @@
   =========================================================================*/
 
 #include "vvToolCreatorBase.h"
-#include "vvSlicerManager.h"
 #include "vvToolManager.h"
 #include <QAction>
+#include <QMenu>
 
 //------------------------------------------------------------------------------
 vvToolCreatorBase::vvToolCreatorBase(QString name) { 
@@ -39,30 +39,18 @@ vvToolCreatorBase::vvToolCreatorBase(QString name) {
 
 
 //------------------------------------------------------------------------------
-void vvToolCreatorBase::Initialize(vvMainWindow * m) { 
-  mMainWindow = m;
-  // Create main Action
+void vvToolCreatorBase::InsertToolInMenu(vvMainWindowBase * m) { 
+  mMainWindow = m; 
+  // Create main action
   if (mToolIconFilename == "noicon") 
     mAction = new QAction(QString("&").append(mToolMenuName), this);
   else 
     mAction = new QAction(QIcon(mToolIconFilename), 
                           QString("&").append(mToolMenuName), this);
   mAction->setStatusTip(mToolTip);
+  // Connect the action
   connect(mAction, SIGNAL(triggered()), this, SLOT(MenuToolSlot()));
-  mMainWindow->GetInfoForTool()->mMenuTools->addAction(mAction);
-  //UpdateEnabledTool();
+  mMainWindow->GetMenu()->addAction(mAction);
 } 
 //------------------------------------------------------------------------------
 
-
-//------------------------------------------------------------------------------
-void vvToolCreatorBase::UpdateEnabledTool() { 
-  DD("Update enabled tool"); 
-  
-  DD(mMainWindow->GetInfoForTool()->mSlicerManagers->size());
-  if (mMainWindow->GetInfoForTool()->mSlicerManagers->size() < 1)
-    mAction->setEnabled(false);
-  else mAction->setEnabled(true);
-}
-//------------------------------------------------------------------------------
index 4f7538b4a5aee11909b6dedfaed5356907cba4c9..2143239f57d991f25e86a8c98379254da0cc46e1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolCreatorBase.h,v $
   Language:  C++
-  Date:      $Date: 2010/01/29 13:54:37 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.2 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
 #ifndef VVTOOLCREATORBASE_H
 #define VVTOOLCREATORBASE_H
 
-#include "clitkCommon.h"
 #include <QObject>
+#include "vvSlicerManager.h"
+#include "vvMainWindowBase.h"
 
-// For vvMainWindowToolInfo
-#include "vvMainWindow.h"
-class vvMainWindow;
-// struct vvMainWindowToolInfo;
 class QAction;
+class vvToolBaseBase;
 
 //------------------------------------------------------------------------------
 class vvToolCreatorBase: public QObject {
@@ -43,50 +41,27 @@ class vvToolCreatorBase: public QObject {
   public:
 
   vvToolCreatorBase(QString name);
-  virtual ~vvToolCreatorBase() {;}
-  
-  virtual void Initialize(vvMainWindow * m);
-  virtual void UpdateEnabledTool();
+  virtual ~vvToolCreatorBase() {;}  
+  virtual void InsertToolInMenu(vvMainWindowBase * m);
   template<class ToolType> void CreateTool();
   virtual void MenuSpecificToolSlot() = 0;
-  
+  vvMainWindowBase * GetMainWindow() const { return mMainWindow; }
+
   QString mToolName;
   QString mToolMenuName;
   QString mToolIconFilename;
   QString mToolTip;
   QAction * mAction;
 
-  vvMainWindow * mMainWindow;
-
 public slots:
   virtual void MenuToolSlot() { MenuSpecificToolSlot(); }
-};
-//------------------------------------------------------------------------------
 
-//------------------------------------------------------------------------------
-template<class ToolType>
-class vvToolCreator: public vvToolCreatorBase {
-public:
-  vvToolCreator(QString name):vvToolCreatorBase(name) {;}
-  virtual void Initialize(vvMainWindow * m);
-  static vvToolCreator<ToolType> * mSingleton;
-  virtual void MenuSpecificToolSlot() { CreateTool<ToolType>(); }
+protected:
+  vvMainWindowBase * mMainWindow;
+  std::vector<vvToolBaseBase*> mListOfTool;
 };
 //------------------------------------------------------------------------------
 
-
-//------------------------------------------------------------------------------
-#define CREATOR(CLASSNAME) vvToolCreator<CLASSNAME>::mSingleton
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-#define ADD_TOOL(NAME)                                          \
-  template<>                                                    \
-  vvToolCreator<NAME> * vvToolCreator<NAME>::mSingleton =       \
-    new vvToolCreator<NAME>(#NAME);
-//------------------------------------------------------------------------------
-
 #include "vvToolCreatorBase.txx"
 
 #endif
index 1548266c480785abf0aa60debf2afa8081b8cfef..334771e65713a2586251d28a83ca5ad908050205 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolCreatorBase.txx,v $
   Language:  C++
-  Date:      $Date: 2010/01/29 13:54:37 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.2 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
 
   =========================================================================*/
 
-#include "vvMainWindow.h"
-#include "vvSlicerManager.h"
-
 //------------------------------------------------------------------------------
+// Called when the tool is created
 template<class ToolType>
 void vvToolCreatorBase::CreateTool() {
-  DD("Create new tool ");
+  // Get information on the current image
+  mMainWindow->UpdateCurrentSlicer();
+  // Create the tool
   ToolType * tool = new ToolType(mMainWindow);
+  // Put it in the list of open tools
+  mListOfTool.push_back(tool);
+  // Go !
   tool->show();
 }
 //------------------------------------------------------------------------------
 
-//------------------------------------------------------------------------------
-template<class ToolType>
-void vvToolCreator<ToolType>::Initialize(vvMainWindow * m) { 
-  // Set MainWindow pointer
-  mMainWindow = m;
-  
-  // Default Initialization
-  mToolMenuName = mToolName;
-  mToolIconFilename = "noicon";
-  mToolTip = mToolName;
-
-  // User Tool Initialization
-  ToolType::Initialize();
-
-  // Common Initialization (insertion into menu)
-  vvToolCreatorBase::Initialize(mMainWindow); 
-}
-//------------------------------------------------------------------------------
-
-// template<class ToolType>
-//   void vvToolCreator<ToolType>::UpdateInfoFromMainWindow() { mMainWindowToolInfo = CREATOR(ToolType)->mMainWindow->GetInfoForTool(); }
diff --git a/vv/vvToolCropImage.cxx b/vv/vvToolCropImage.cxx
new file mode 100644 (file)
index 0000000..126a46f
--- /dev/null
@@ -0,0 +1,64 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolCropImage.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2008
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#include "vvToolCropImage.h"
+
+//------------------------------------------------------------------------------
+// Create the tool and automagically (I like this word) insert it in
+// the main window menu.
+ADD_TOOL(vvToolCropImage);
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolCropImage::vvToolCropImage(vvMainWindowBase * parent, Qt::WindowFlags f):
+  vvToolWidgetBase(parent, f), 
+  vvToolBase<vvToolCropImage>(parent), 
+  Ui::vvToolCropImage() {
+  // GUI Initialization
+  Ui_vvToolCropImage::setupUi(mToolWidget);
+
+  // Initialize the input selection
+  //UpdateInfoFromMainWindow();
+ //  InitializeListOfInputImages(*mMainWindowToolInfo->mSlicerManagers, 
+//                           mMainWindowToolInfo->mSlicerManagerCurrentIndex); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolCropImage::~vvToolCropImage() {
+
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) {
+  DD("InputIsSelected");
+}
+//------------------------------------------------------------------------------
diff --git a/vv/vvToolCropImage.h b/vv/vvToolCropImage.h
new file mode 100644 (file)
index 0000000..c039653
--- /dev/null
@@ -0,0 +1,78 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolCropImage.h,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2010
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS                   http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#ifndef VVTOOLCROPIMAGE_H
+#define VVTOOLCROPIMAGE_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include <QDialog>
+
+#include "vvToolBase.h"
+#include "vvToolWidgetBase.h"
+#include "vvMainWindowBase.h"
+#include "ui_vvToolCropImage.h"
+
+//------------------------------------------------------------------------------
+class vvToolCropImage:
+  public vvToolWidgetBase,
+  public vvToolBase<vvToolCropImage>, 
+  private Ui::vvToolCropImage 
+{
+  Q_OBJECT
+    public:
+  vvToolCropImage(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
+  ~vvToolCropImage();
+
+  //-----------------------------------------------------
+  typedef vvToolCropImage Self;
+  bool close() { return QWidget::close(); }
+  virtual void InputIsSelected(vvSlicerManager *m);
+  //void AnImageIsBeingClosed(vvSlicerManager * m) { vvToolWidgetBase::TTAnImageIsBeingClosed(m); }
+
+  void bar() { DD("crop::bar"); }
+
+
+public slots:
+  void apply() { DD("Apply"); }
+
+  //-----------------------------------------------------
+  static void Initialize() {
+    SetToolName("Crop");
+    SetToolMenuName("Crop");
+    SetToolIconFilename(":/new/prefix1/icons/binarize.png");
+    SetToolTip("Crop image.");
+  }
+
+ protected:
+  Ui::vvToolCropImage ui;
+
+
+}; // end class vvToolCropImage
+//------------------------------------------------------------------------------
+
+#endif
+
diff --git a/vv/vvToolFoo.cxx b/vv/vvToolFoo.cxx
new file mode 100644 (file)
index 0000000..4976654
--- /dev/null
@@ -0,0 +1,63 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolFoo.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2010
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS                   http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#include "vvToolFoo.h"
+
+//------------------------------------------------------------------------------
+// Create the tool and automagically (I like this word) insert it in
+// the main window menu.
+ADD_TOOL(vvToolFoo);
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+vvToolFoo::vvToolFoo(vvMainWindowBase * parent, Qt::WindowFlags f)
+  :QDialog(parent), 
+   vvToolBase<vvToolFoo>(parent), 
+   Ui::vvToolFoo() {
+  // Setup the UI
+  Ui_vvToolFoo::setupUi(this);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolFoo::~vvToolFoo() {
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolFoo::Initialize() {
+  SetToolName("Foo");
+  SetToolMenuName("Foo");
+  SetToolIconFilename(":/new/prefix1/icons/ducky.png");
+  SetToolTip("Make 'foo' on an image.");
+}
+//------------------------------------------------------------------------------
+
+
+
diff --git a/vv/vvToolFoo.h b/vv/vvToolFoo.h
new file mode 100644 (file)
index 0000000..2e2b221
--- /dev/null
@@ -0,0 +1,57 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolFoo.h,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2010
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS                   http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#ifndef VVTOOLFOO_H
+#define VVTOOLFOO_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include <QDialog>
+
+#include "vvToolBase.h"
+#include "ui_vvToolFoo.h"
+
+//------------------------------------------------------------------------------
+class vvToolFoo:
+  public QDialog,
+  public vvToolBase<vvToolFoo>, 
+  private Ui::vvToolFoo
+{
+  Q_OBJECT
+    public:
+  vvToolFoo(vvMainWindowBase* parent=0, Qt::WindowFlags f=0);
+  ~vvToolFoo();
+
+  static void Initialize();
+
+ protected:
+  Ui::vvToolFoo ui;
+
+}; // end class vvToolFoo
+//------------------------------------------------------------------------------
+
+#endif
+
index 0cb8c01f528a700e653d308f12e99da3a96aeacc..217b53be2340c3f615f00eab5ea07673dca06829 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolInputSelectorWidget.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/01/29 13:54:37 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.2 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2010
@@ -48,7 +48,6 @@ vvToolInputSelectorWidget::vvToolInputSelectorWidget(QWidget * parent, Qt::Windo
 
 //------------------------------------------------------------------------------
 void vvToolInputSelectorWidget::Initialize(std::vector<vvSlicerManager*> l, int index) {
-  DD("Initialize"); DD(index);
   mInputSequenceBox->clear();
   mSlicerManagerList = l;
   mCurrentIndex = index;
@@ -70,8 +69,6 @@ void vvToolInputSelectorWidget::Initialize(std::vector<vvSlicerManager*> l, int
 
 //------------------------------------------------------------------------------
 void vvToolInputSelectorWidget::SetToolTip(QString s) {
-  //  mLabelSelection->setToolTip(s);
-  //mInputSequenceBox->setToolTip(s);
   setToolTip(s);
 }
 //------------------------------------------------------------------------------
index 4940c44dc696b862f2c37a9b0a936d2fabed76f2..0c02651c9a65cbedc832d4fd00d7ea28643da3ad 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolInputSelectorWidget.h,v $
   Language:  C++
-  Date:      $Date: 2010/02/05 09:06:46 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.3 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2010
@@ -30,8 +30,8 @@
 
 #include <QtDesigner/QDesignerExportWidget>
 #include <QDialog>
-
 #include "ui_vvToolInputSelectorWidget.h"
+#include "vvImage.h"
 
 class vvSlicerManager;
 
@@ -60,6 +60,7 @@ class vvToolInputSelectorWidget: public QWidget, private Ui::vvToolInputSelector
   Ui::vvToolInputSelectorWidget ui;
   std::vector<vvSlicerManager*> mSlicerManagerList;
   int mCurrentIndex;
+  vvSlicerManager * mCurrentSliceManager;
 
 }; // end class vvToolInputSelectorWidget
 //------------------------------------------------------------------------------
index e66fa065e9428952f6f43cc9c9357ad4f1287c9d..9ff504f759b28daefde2b59c1e43ee19f6d7e4f1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolManager.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/02/03 10:54:08 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.3 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
   =========================================================================*/
 
 #include "vvToolManager.h"
-#include "vvMainWindow.h"
+#include "vvToolCreatorBase.h"
+#include "vvMainWindowBase.h"
 
+//------------------------------------------------------------------------------
+/// Unique static instance 
 vvToolManager* vvToolManager::mSingleton=0; 
+//------------------------------------------------------------------------------
+
 
 //------------------------------------------------------------------------------
 vvToolManager * vvToolManager::GetInstance() {
@@ -49,18 +54,10 @@ void vvToolManager::AddTool(vvToolCreatorBase * v)  {
 
 
 //------------------------------------------------------------------------------
-void vvToolManager::Initialize(vvMainWindow * m) {
+void vvToolManager::InsertToolsInMenu(vvMainWindowBase * m) {
   for(unsigned int i=0; i<GetInstance()->mListOfTools.size(); i++) {
-    GetInstance()->mListOfTools[i]->Initialize(m);
+    GetInstance()->mListOfTools[i]->InsertToolInMenu(m);
   }
 }
 //------------------------------------------------------------------------------
 
-
-//------------------------------------------------------------------------------
-void vvToolManager::UpdateEnabledTool() {
-  for(unsigned int i=0; i<GetInstance()->mListOfTools.size(); i++) {
-    GetInstance()->mListOfTools[i]->UpdateEnabledTool();
-  }
-}
-//------------------------------------------------------------------------------
index 8d8c1da9a50bf05812044520bf783ee9b5901e08..01f1e819f5856f927cf561ee78155f6e58561e27 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolManager.h,v $
   Language:  C++
-  Date:      $Date: 2010/02/03 10:54:08 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/02/24 11:42:42 $
+  Version:   $Revision: 1.3 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
 #ifndef VVTOOLMANAGER_H
 #define VVTOOLMANAGER_H
 
-#include "vvToolCreatorBase.h"
 #include "clitkCommon.h"
 
 class vvToolCreatorBase;
-class vvMainWindow;
+class vvMainWindowBase;
 
 //------------------------------------------------------------------------------
 // Manage a list of ToolCreator. Each tool will be automagically
@@ -40,15 +39,25 @@ class vvMainWindow;
 // MainWindow will call the 'Initialize' to insert the tool in the
 // menu bar.
 class vvToolManager {
+
 public:
-  // Functions
+
+  /// Get or build unique instance with this method
   static vvToolManager * GetInstance();  
+
+  /// Add a tool creator in the list (called before main, via static member initialization)
   static void AddTool(vvToolCreatorBase * v);
-  static void Initialize(vvMainWindow * m);
-  static void UpdateEnabledTool();
-  // Variables
-   std::vector<vvToolCreatorBase *> mListOfTools;
+
+  /// Called in MainWindow, insert all tools into the menu
+  static void InsertToolsInMenu(vvMainWindowBase * m);
+  
+protected:
+
+  /// Singleton object pointer
   static vvToolManager * mSingleton;
+
+  /// list of all tool creators
+  std::vector<vvToolCreatorBase *> mListOfTools;
 };
 //------------------------------------------------------------------------------
 
diff --git a/vv/vvToolWidgetBase.cxx b/vv/vvToolWidgetBase.cxx
new file mode 100644 (file)
index 0000000..c853c75
--- /dev/null
@@ -0,0 +1,132 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolWidgetBase.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2008
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS-LRMN http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#include "vvToolWidgetBase.h"
+#include "vvMainWindowBase.h"
+#include "vvSlicerManager.h"
+
+//------------------------------------------------------------------------------
+vvToolWidgetBase::vvToolWidgetBase(vvMainWindowBase * parent, Qt::WindowFlags f)
+  :QDialog(parent, f), 
+   Ui::vvToolWidgetBase() {
+
+  // Set Modality : dialog is not modal but stay always on top because
+  // parent is set at construction
+  mIsInitialized = false;
+  mFilter = 0;
+  mMainWindowBase = parent;
+  setModal(false);
+  setAttribute(Qt::WA_DeleteOnClose);
+  
+  // GUI Initialization
+  setupUi(this);
+
+  // Connect signals & slots  
+  connect(mMainWindowBase, SIGNAL(AnImageIsBeingClosed(vvSlicerManager*)), 
+          this, SLOT(AnImageIsBeingClosed(vvSlicerManager*)));
+  connect(mToolInputSelectionWidget, SIGNAL(accepted()), this, SLOT(InputIsSelected()));
+  connect(mToolInputSelectionWidget, SIGNAL(rejected()), this, SLOT(close()));
+  connect(buttonBox, SIGNAL(accepted()), this, SLOT(apply()));
+  connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
+
+  // Disable main widget while input image is not selected
+  mToolWidget->setEnabled(false);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolWidgetBase::~vvToolWidgetBase() {
+  
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::show() {
+ if (!mIsInitialized) {
+   InitializeInputs();
+ }
+ QDialog::show();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+bool vvToolWidgetBase::close() {
+  return QDialog::close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m) {
+  if (m == mCurrentSlicerManager) {
+    close();
+  }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::InitializeInputs() {
+  if (mFilter) {
+    int j=0;
+    mToolInputSelectionWidget->SetToolTip(QString("%1").arg(mFilter->GetAvailableImageTypes().c_str()));
+    for(unsigned int i=0; i<mMainWindowBase->GetSlicerManagers().size(); i++) {
+      vvImage * s = mMainWindowBase->GetSlicerManagers()[i]->GetImage();
+      if (mFilter->CheckImageType(s->GetNumberOfDimensions(), 
+                                  s->GetNumberOfScalarComponents(), 
+                                  s->GetScalarTypeAsString())) {
+        mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
+        if ((int)i == mMainWindowBase->GetSlicerManagerCurrentIndex()) mCurrentCompatibleIndex = j;
+        j++;
+      }
+    }
+  }
+  else {
+    mSlicerManagersCompatible = mMainWindowBase->GetSlicerManagers();
+    mCurrentCompatibleIndex = mMainWindowBase->GetSlicerManagerCurrentIndex();
+  }
+  mToolInputSelectionWidget->Initialize(mSlicerManagersCompatible, 
+                                        mCurrentCompatibleIndex);
+  mIsInitialized = true;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::InputIsSelected() {
+  // Common
+  int index = mToolInputSelectionWidget->GetSelectedInputIndex();
+  mCurrentSlicerManager = mSlicerManagersCompatible[index];
+  mToolWidget->setEnabled(true);
+  if (!mCurrentSlicerManager) close();
+  InputIsSelected(mCurrentSlicerManager);
+}
+//------------------------------------------------------------------------------
+
diff --git a/vv/vvToolWidgetBase.h b/vv/vvToolWidgetBase.h
new file mode 100644 (file)
index 0000000..225b5f2
--- /dev/null
@@ -0,0 +1,71 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolWidgetBase.h,v $
+  Language:  C++
+  Date:      $Date: 2010/02/24 11:43:37 $
+  Version:   $Revision: 1.1 $
+  Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
+
+  Copyright (C) 2010
+  Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+  CREATIS                   http://www.creatis.insa-lyon.fr
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, version 3 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#ifndef VVTOOLWIDGETBASE_H
+#define VVTOOLWIDGETBASE_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include "ui_vvToolWidgetBase.h"
+#include "clitkImageToImageGenericFilter.h"
+class vvMainWindowBase;
+
+//------------------------------------------------------------------------------
+class vvToolWidgetBase:
+  public QDialog, 
+  public Ui::vvToolWidgetBase 
+{
+  Q_OBJECT
+  public:
+
+  vvToolWidgetBase(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
+  ~vvToolWidgetBase();
+
+  virtual void InputIsSelected(vvSlicerManager *m) = 0;
+
+public slots:
+  virtual void apply() = 0;
+  void InputIsSelected();
+  void AnImageIsBeingClosed(vvSlicerManager * m);
+  void show();
+  virtual bool close();
+
+protected:
+  void InitializeInputs();
+  Ui::vvToolWidgetBase ui;
+  clitk::ImageToImageGenericFilterBase * mFilter;
+  vvMainWindowBase * mMainWindowBase;
+  std::vector<vvSlicerManager*> mSlicerManagersCompatible;
+  vvSlicerManager * mCurrentSlicerManager;
+  int mCurrentCompatibleIndex;
+  vvImage * mCurrentImage;
+  bool mIsInitialized;
+
+}; // end class vvToolWidgetBase
+//------------------------------------------------------------------------------
+
+#endif
+