]> Creatis software - clitk.git/commitdiff
- binarize tool
authordsarrut <dsarrut>
Fri, 29 Jan 2010 13:53:49 +0000 (13:53 +0000)
committerdsarrut <dsarrut>
Fri, 29 Jan 2010 13:53:49 +0000 (13:53 +0000)
26 files changed:
vv/CMakeLists.txt
vv/qt_ui/vvIntensityValueSlider.ui [new file with mode: 0644]
vv/qt_ui/vvToolBinarize.ui [new file with mode: 0644]
vv/qt_ui/vvToolConnectedComponentLabeling.ui [new file with mode: 0644]
vv/qt_ui/vvToolCrop.ui [new file with mode: 0644]
vv/qt_ui/vvToolInputSelectorWidget.ui [new file with mode: 0644]
vv/qt_ui/vvToolMorphoMath.ui [new file with mode: 0644]
vv/qt_ui/vvTools.ui [new file with mode: 0644]
vv/vv.cxx
vv/vvIcons.qrc
vv/vvIntensityValueSlider.cxx [new file with mode: 0644]
vv/vvIntensityValueSlider.h [new file with mode: 0644]
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvMainWindow.txx [new file with mode: 0644]
vv/vvToolBase.cxx [new file with mode: 0644]
vv/vvToolBase.h [new file with mode: 0644]
vv/vvToolBinarize.cxx [new file with mode: 0644]
vv/vvToolBinarize.h [new file with mode: 0644]
vv/vvToolCreatorBase.cxx [new file with mode: 0644]
vv/vvToolCreatorBase.h [new file with mode: 0644]
vv/vvToolCreatorBase.txx [new file with mode: 0644]
vv/vvToolInputSelectorWidget.cxx [new file with mode: 0644]
vv/vvToolInputSelectorWidget.h [new file with mode: 0644]
vv/vvToolManager.cxx [new file with mode: 0644]
vv/vvToolManager.h [new file with mode: 0644]

index b68ceaa2a3abeace304a87406a129a9050620611..7fe306ccea4ace2b752215299a176dbc77d171a4 100644 (file)
@@ -33,9 +33,14 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_BINARY_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}
   ../common
+  ../tools
   )
 
 #=========================================================
+# To avoid warning with some version
+if(COMMAND cmake_policy)
+  cmake_policy(SET CMP0003 NEW)
+endif(COMMAND cmake_policy)
 
 #SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
 #SET(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}/../lib)
@@ -44,6 +49,7 @@ INCLUDE_DIRECTORIES(
 LINK_LIBRARIES (
   #ITKIO
   clitkCommon
+  clitkGGO
   clitkFilters
   ${QT_QTCORE_LIBRARY}
   ${QT_QTGUI_LIBRARY}
@@ -103,6 +109,12 @@ SET(vv_SRCS
   vvCropDialog.cxx
   vvMidPosition.cxx
   vvImageMapToWLColors.cxx
+  vvIntensityValueSlider.cxx
+  vvToolManager.cxx
+  vvToolCreatorBase.cxx
+  vvToolBinarize.cxx
+  ../tools/clitkBinarizeImage_ggo.c
+  vvToolInputSelectorWidget.cxx
   )
 
 QT4_WRAP_CPP(vv_SRCS 
@@ -124,6 +136,10 @@ QT4_WRAP_CPP(vv_SRCS
   vvSlicerManager.h
   vvStructSelector.h
   vvCropDialog.h
+  vvIntensityValueSlider.h
+  vvToolCreatorBase.h
+  vvToolBinarize.h
+  vvToolInputSelectorWidget.h
   )
 
 QT4_WRAP_UI(vv_UI_CXX 
@@ -143,6 +159,9 @@ QT4_WRAP_UI(vv_UI_CXX
   qt_ui/vvStructSelector.ui
   qt_ui/vvCropDialog.ui
   qt_ui/vvDummyWindow.ui #For testing
+  qt_ui/vvIntensityValueSlider.ui
+  qt_ui/vvToolBinarize.ui
+  qt_ui/vvToolInputSelectorWidget.ui
   )
 
 SET(vvUI_RCCS vvIcons.qrc)
diff --git a/vv/qt_ui/vvIntensityValueSlider.ui b/vv/qt_ui/vvIntensityValueSlider.ui
new file mode 100644 (file)
index 0000000..ae0c459
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvIntensityValueSlider</class>
+ <widget class="QWidget" name="vvIntensityValueSlider">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>222</width>
+    <height>39</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <property name="leftMargin">
+    <number>2</number>
+   </property>
+   <property name="topMargin">
+    <number>2</number>
+   </property>
+   <property name="rightMargin">
+    <number>2</number>
+   </property>
+   <item row="0" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="mLabel">
+       <property name="text">
+        <string>Value 1</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="mSlider">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDoubleSpinBox" name="mSpinBox">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>0</height>
+        </size>
+       </property>
+       <property name="decimals">
+        <number>2</number>
+       </property>
+       <property name="minimum">
+        <double>-9999.000000000000000</double>
+       </property>
+       <property name="maximum">
+        <double>99999.000000000000000</double>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/vv/qt_ui/vvToolBinarize.ui b/vv/qt_ui/vvToolBinarize.ui
new file mode 100644 (file)
index 0000000..154f977
--- /dev/null
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolBinarize</class>
+ <widget class="QWidget" name="vvToolBinarize">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>388</width>
+    <height>318</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Binarize image</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QSplitter" name="splitter">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <widget class="vvToolInputSelectorWidget" name="mToolInputSelectionWidget" native="true"/>
+     <widget class="QWidget" name="toolMainWidget" native="true">
+      <layout class="QVBoxLayout" name="verticalLayout_4">
+       <property name="margin">
+        <number>3</number>
+       </property>
+       <item>
+        <layout class="QVBoxLayout" name="verticalLayout_3">
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout">
+           <item>
+            <layout class="QVBoxLayout" name="verticalLayout">
+             <item>
+              <widget class="QFrame" name="frame">
+               <property name="frameShape">
+                <enum>QFrame::StyledPanel</enum>
+               </property>
+               <property name="frameShadow">
+                <enum>QFrame::Raised</enum>
+               </property>
+               <layout class="QVBoxLayout" name="verticalLayout_5">
+                <item>
+                 <widget class="QRadioButton" name="mRadioButtonGreaterThan">
+                  <property name="text">
+                   <string>Greater than</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QRadioButton" name="mRadioButtonEqualThan">
+                  <property name="text">
+                   <string>Equal</string>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QRadioButton" name="radioButton_3">
+                  <property name="text">
+                   <string>Not equal</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+            </layout>
+           </item>
+           <item>
+            <widget class="vvIntensityValueSlider" name="mThresholdSlider1" native="true"/>
+           </item>
+          </layout>
+         </item>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_2">
+           <item>
+            <widget class="QRadioButton" name="mRadioButtonLowerThan">
+             <property name="text">
+              <string>Lower than</string>
+             </property>
+             <property name="autoExclusive">
+              <bool>false</bool>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="vvIntensityValueSlider" name="mThresholdSlider2" native="true">
+             <property name="enabled">
+              <bool>false</bool>
+             </property>
+            </widget>
+           </item>
+          </layout>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <layout class="QVBoxLayout" name="verticalLayout_2">
+         <item>
+          <widget class="Line" name="line_2">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QLabel" name="label">
+           <property name="text">
+            <string>Resulting binary image:</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_4">
+           <item>
+            <widget class="vvIntensityValueSlider" name="mFGSlider" native="true"/>
+           </item>
+          </layout>
+         </item>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_5">
+           <item>
+            <widget class="vvIntensityValueSlider" name="mBGSlider" native="true"/>
+           </item>
+          </layout>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <widget class="Line" name="line_3">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QCheckBox" name="checkBox_2">
+         <property name="text">
+          <string>Interactive (unchek to disable on the fly contours drawing)</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QDialogButtonBox" name="buttonBox">
+         <property name="standardButtons">
+          <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>vvIntensityValueSlider</class>
+   <extends>QWidget</extends>
+   <header>vvIntensityValueSlider.h</header>
+   <container>1</container>
+  </customwidget>
+  <customwidget>
+   <class>vvToolInputSelectorWidget</class>
+   <extends>QWidget</extends>
+   <header location="global">vvToolInputSelectorWidget.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>mRadioButtonLowerThan</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>mThresholdSlider2</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>85</x>
+     <y>191</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>601</x>
+     <y>203</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>mRadioButtonEqualThan</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>mRadioButtonLowerThan</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>82</x>
+     <y>121</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>88</x>
+     <y>191</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>radioButton_3</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>mRadioButtonLowerThan</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>73</x>
+     <y>141</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>137</x>
+     <y>191</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/vv/qt_ui/vvToolConnectedComponentLabeling.ui b/vv/qt_ui/vvToolConnectedComponentLabeling.ui
new file mode 100644 (file)
index 0000000..a12ccf4
--- /dev/null
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <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>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>20</y>
+     <width>191</width>
+     <height>16</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Connected component labeling</string>
+   </property>
+  </widget>
+  <widget class="QRadioButton" name="radioButton_5">
+   <property name="geometry">
+    <rect>
+     <x>200</x>
+     <y>80</y>
+     <width>131</width>
+     <height>19</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Sort label by size</string>
+   </property>
+  </widget>
+  <widget class="QWidget" name="">
+   <property name="geometry">
+    <rect>
+     <x>60</x>
+     <y>50</y>
+     <width>93</width>
+     <height>81</height>
+    </rect>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <item>
+     <widget class="QRadioButton" name="radioButton">
+      <property name="text">
+       <string>6 connectivity</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QRadioButton" name="radioButton_2">
+      <property name="text">
+       <string>18 connexity</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QRadioButton" name="radioButton_3">
+      <property name="text">
+       <string>26 connexity</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QRadioButton" name="radioButton_4">
+      <property name="text">
+       <string>26 connexity</string>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QLabel" name="label_7">
+   <property name="geometry">
+    <rect>
+     <x>32</x>
+     <y>247</y>
+     <width>16</width>
+     <height>16</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string/>
+   </property>
+  </widget>
+  <widget class="QWidget" name="">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>160</y>
+     <width>321</width>
+     <height>51</height>
+    </rect>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout_2">
+    <item>
+     <layout class="QHBoxLayout" name="horizontalLayout_2">
+      <item>
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="radioButton_6">
+        <property name="layoutDirection">
+         <enum>Qt::LeftToRight</enum>
+        </property>
+        <property name="text">
+         <string>Keep n first greater labels</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <spacer name="horizontalSpacer_2">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </item>
+    <item>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <item>
+       <widget class="QLabel" name="label_6">
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QSlider" name="horizontalSlider">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QSpinBox" name="spinBox"/>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>spinBox</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>horizontalSlider</receiver>
+   <slot>setValue(int)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>319</x>
+     <y>197</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>246</x>
+     <y>199</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>horizontalSlider</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>spinBox</receiver>
+   <slot>setValue(int)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>207</x>
+     <y>202</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>332</x>
+     <y>201</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/vv/qt_ui/vvToolCrop.ui b/vv/qt_ui/vvToolCrop.ui
new file mode 100644 (file)
index 0000000..9a4fa74
--- /dev/null
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>192</width>
+    <height>169</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/vvToolInputSelectorWidget.ui b/vv/qt_ui/vvToolInputSelectorWidget.ui
new file mode 100644 (file)
index 0000000..775591a
--- /dev/null
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolInputSelectorWidget</class>
+ <widget class="QWidget" name="vvToolInputSelectorWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>276</width>
+    <height>98</height>
+   </rect>
+  </property>
+  <property name="font">
+   <font>
+    <pointsize>8</pointsize>
+   </font>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <property name="autoFillBackground">
+   <bool>false</bool>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <property name="margin">
+    <number>2</number>
+   </property>
+   <item row="0" column="0">
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Select input image</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_2">
+      <property name="margin">
+       <number>2</number>
+      </property>
+      <item row="0" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <item>
+         <widget class="QComboBox" name="mInputSequenceBox">
+          <property name="font">
+           <font>
+            <pointsize>11</pointsize>
+           </font>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item row="1" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <widget class="QLabel" name="mLabelInputInfo">
+          <property name="font">
+           <font>
+            <pointsize>11</pointsize>
+           </font>
+          </property>
+          <property name="frameShape">
+           <enum>QFrame::NoFrame</enum>
+          </property>
+          <property name="text">
+           <string>3D image
+Pixel type short
+bla bla</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QDialogButtonBox" name="mInputSelectionButtonBox">
+          <property name="standardButtons">
+           <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/vv/qt_ui/vvToolMorphoMath.ui b/vv/qt_ui/vvToolMorphoMath.ui
new file mode 100644 (file)
index 0000000..5768e33
--- /dev/null
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>468</width>
+    <height>120</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <layout class="QVBoxLayout" name="verticalLayout_3">
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout">
+         <item>
+          <widget class="QLabel" name="label_6">
+           <property name="text">
+            <string>Kernel size</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QSlider" name="horizontalSlider">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QDoubleSpinBox" name="doubleSpinBox"/>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_3">
+         <item>
+          <layout class="QVBoxLayout" name="verticalLayout">
+           <item>
+            <widget class="QRadioButton" name="radioButton">
+             <property name="text">
+              <string>Apply</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QRadioButton" name="radioButton_2">
+             <property name="text">
+              <string>Add to sequence</string>
+             </property>
+            </widget>
+           </item>
+          </layout>
+         </item>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_2">
+           <item>
+            <widget class="QPushButton" name="pushButton">
+             <property name="text">
+              <string>Erode</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QPushButton" name="pushButton_2">
+             <property name="text">
+              <string>Dilate</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QPushButton" name="pushButton_3">
+             <property name="text">
+              <string>Openning</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QPushButton" name="pushButton_4">
+             <property name="text">
+              <string>Closing</string>
+             </property>
+            </widget>
+           </item>
+          </layout>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout_4">
+       <item>
+        <widget class="QLabel" name="label">
+         <property name="text">
+          <string>Sequence of operations</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLineEdit" name="lineEdit">
+         <property name="text">
+          <string>EEDOCDD</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/vv/qt_ui/vvTools.ui b/vv/qt_ui/vvTools.ui
new file mode 100644 (file)
index 0000000..90d9276
--- /dev/null
@@ -0,0 +1,371 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>803</width>
+    <height>729</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <property name="locale">
+   <locale language="English" country="UnitedKingdom"/>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="1" column="0">
+    <widget class="QSplitter" name="splitter">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <widget class="QFrame" name="frame_3">
+      <property name="frameShape">
+       <enum>QFrame::StyledPanel</enum>
+      </property>
+      <property name="frameShadow">
+       <enum>QFrame::Raised</enum>
+      </property>
+      <widget class="QFrame" name="frame_2">
+       <property name="geometry">
+        <rect>
+         <x>11</x>
+         <y>48</y>
+         <width>172</width>
+         <height>72</height>
+        </rect>
+       </property>
+       <property name="frameShape">
+        <enum>QFrame::StyledPanel</enum>
+       </property>
+       <property name="frameShadow">
+        <enum>QFrame::Raised</enum>
+       </property>
+       <layout class="QGridLayout" name="gridLayout_4">
+        <item row="0" column="0">
+         <widget class="QLabel" name="label_8">
+          <property name="text">
+           <string>Input Image</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="2">
+         <widget class="QComboBox" name="inputSequenceBox"/>
+        </item>
+        <item row="1" column="1" colspan="2">
+         <widget class="Line" name="line_2">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="0" colspan="2">
+         <widget class="QLabel" name="label_9">
+          <property name="text">
+           <string>Info input image</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+      <widget class="QFrame" name="frame">
+       <property name="geometry">
+        <rect>
+         <x>10</x>
+         <y>140</y>
+         <width>321</width>
+         <height>151</height>
+        </rect>
+       </property>
+       <property name="frameShape">
+        <enum>QFrame::StyledPanel</enum>
+       </property>
+       <property name="frameShadow">
+        <enum>QFrame::Raised</enum>
+       </property>
+       <widget class="QLabel" name="label">
+        <property name="geometry">
+         <rect>
+          <x>8</x>
+          <y>70</y>
+          <width>73</width>
+          <height>16</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>Script filename</string>
+        </property>
+       </widget>
+       <widget class="QLineEdit" name="lineEdit">
+        <property name="geometry">
+         <rect>
+          <x>86</x>
+          <y>73</y>
+          <width>131</width>
+          <height>20</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>/home/toto/a.config</string>
+        </property>
+       </widget>
+       <widget class="QDialogButtonBox" name="buttonBox_2">
+        <property name="geometry">
+         <rect>
+          <x>8</x>
+          <y>107</y>
+          <width>80</width>
+          <height>26</height>
+         </rect>
+        </property>
+        <property name="locale">
+         <locale language="English" country="UnitedKingdom"/>
+        </property>
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="standardButtons">
+         <set>QDialogButtonBox::Save</set>
+        </property>
+        <property name="centerButtons">
+         <bool>true</bool>
+        </property>
+       </widget>
+       <widget class="QLabel" name="label_2">
+        <property name="geometry">
+         <rect>
+          <x>138</x>
+          <y>107</y>
+          <width>96</width>
+          <height>16</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Status : &lt;span style=&quot; font-size:10pt; font-weight:600;&quot;&gt;*not save*&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+        </property>
+       </widget>
+       <widget class="QComboBox" name="comboBox">
+        <property name="geometry">
+         <rect>
+          <x>86</x>
+          <y>39</y>
+          <width>65</width>
+          <height>20</height>
+         </rect>
+        </property>
+       </widget>
+       <widget class="QLabel" name="label_5">
+        <property name="geometry">
+         <rect>
+          <x>8</x>
+          <y>39</y>
+          <width>33</width>
+          <height>16</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>Presets</string>
+        </property>
+       </widget>
+       <widget class="QDialogButtonBox" name="buttonBox_4">
+        <property name="geometry">
+         <rect>
+          <x>230</x>
+          <y>50</y>
+          <width>75</width>
+          <height>26</height>
+         </rect>
+        </property>
+        <property name="locale">
+         <locale language="English" country="UnitedKingdom"/>
+        </property>
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="standardButtons">
+         <set>QDialogButtonBox::Open</set>
+        </property>
+        <property name="centerButtons">
+         <bool>true</bool>
+        </property>
+       </widget>
+       <widget class="QLabel" name="label_10">
+        <property name="geometry">
+         <rect>
+          <x>11</x>
+          <y>11</y>
+          <width>49</width>
+          <height>16</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>Script info</string>
+        </property>
+       </widget>
+       <widget class="Line" name="line">
+        <property name="geometry">
+         <rect>
+          <x>8</x>
+          <y>29</y>
+          <width>291</width>
+          <height>16</height>
+         </rect>
+        </property>
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+       </widget>
+      </widget>
+      <widget class="QPushButton" name="pushButton">
+       <property name="geometry">
+        <rect>
+         <x>692</x>
+         <y>11</y>
+         <width>82</width>
+         <height>26</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>Hide panel</string>
+       </property>
+       <property name="icon">
+        <iconset resource="../vvIcons.qrc">
+         <normaloff>:/new/prefix1/icons/standardbutton-apply-16.png</normaloff>:/new/prefix1/icons/standardbutton-apply-16.png</iconset>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_11">
+       <property name="geometry">
+        <rect>
+         <x>11</x>
+         <y>11</y>
+         <width>71</width>
+         <height>16</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;Tool name&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+       </property>
+      </widget>
+      <widget class="QFrame" name="frame_5">
+       <property name="geometry">
+        <rect>
+         <x>360</x>
+         <y>70</y>
+         <width>391</width>
+         <height>241</height>
+        </rect>
+       </property>
+       <property name="frameShape">
+        <enum>QFrame::StyledPanel</enum>
+       </property>
+       <property name="frameShadow">
+        <enum>QFrame::Raised</enum>
+       </property>
+       <widget class="QLabel" name="label_12">
+        <property name="geometry">
+         <rect>
+          <x>23</x>
+          <y>22</y>
+          <width>49</width>
+          <height>16</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>Script steps</string>
+        </property>
+       </widget>
+       <widget class="Line" name="line_3">
+        <property name="geometry">
+         <rect>
+          <x>20</x>
+          <y>40</y>
+          <width>291</width>
+          <height>16</height>
+         </rect>
+        </property>
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+       </widget>
+      </widget>
+     </widget>
+     <widget class="QFrame" name="frame_4">
+      <property name="frameShape">
+       <enum>QFrame::StyledPanel</enum>
+      </property>
+      <property name="frameShadow">
+       <enum>QFrame::Raised</enum>
+      </property>
+      <layout class="QGridLayout" name="gridLayout_2">
+       <item row="0" column="0">
+        <layout class="QVBoxLayout" name="verticalLayout">
+         <item>
+          <widget class="QWidget" name="widget" native="true"/>
+         </item>
+         <item>
+          <widget class="QDialogButtonBox" name="buttonBox">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="standardButtons">
+            <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel</set>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="../vvIcons.qrc"/>
+ </resources>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>Dialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>300</x>
+     <y>683</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>Dialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>300</x>
+     <y>683</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index 1f0f13adb382a217e79b87e59de4779127fcc3d6..fde6e992627cdebfa2759319011039ae57c13a44 100644 (file)
--- a/vv/vv.cxx
+++ b/vv/vv.cxx
@@ -32,9 +32,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "clitkCommon.h"
 #include "vvMainWindow.h"
 #include "vvInit.h"
-
 #include "vvConstants.h"
 
+//------------------------------------------------------------------------------
+// (*NEEDED HERE*) Static instances initialization for ToolManager
+TOOL_MANAGER_INITIALIZATION;
+
+//------------------------------------------------------------------------------
 int main( int argc, char** argv )
 {
     initialize_IO();
@@ -44,7 +48,7 @@ int main( int argc, char** argv )
     //QPixmap pixmap(":/splashscreen.PNG");
     QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/new/prefix1/splashscreen.PNG")));
     /*splash->showMessage("VV 1.0 developped by Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr and CREATIS-LRMN http://www.creatis.insa-lyon.fr",(Qt::AlignRight | Qt::AlignBottom));*/
-//  splash->show();
+    //  splash->show();
     QTimer::singleShot(2000, splash, SLOT(close()));
     while (!splash->isHidden())
         app.processEvents();
index f3ac659ebbe3795b9857bc82568e691ee72c8e45..98a90b77f8474606d3df3b1b9647737eb12d4611 100644 (file)
@@ -1,5 +1,6 @@
 <RCC>
-  <qresource prefix="/new/prefix1" >
+  <qresource prefix="/new/prefix1">
+    <file>icons/binarize.png</file>
     <file>icons/crop.png</file>
     <file>icons/splashscreen2.png</file>
     <file>icons/splashscreen.PNG</file>
diff --git a/vv/vvIntensityValueSlider.cxx b/vv/vvIntensityValueSlider.cxx
new file mode 100644 (file)
index 0000000..11a5f58
--- /dev/null
@@ -0,0 +1,153 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvIntensityValueSlider.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 "vvIntensityValueSlider.h"
+#include "clitkCommon.h"
+
+//------------------------------------------------------------------------------
+vvIntensityValueSlider::vvIntensityValueSlider(QWidget * parent, Qt::WindowFlags f)
+  :QWidget(parent,f),  Ui::vvIntensityValueSlider() 
+{
+  // GUI Initialization
+  setupUi(this);
+  
+  // Connect signals & slots
+  connect(mSpinBox, SIGNAL(valueChanged(double)), this, SLOT(valueChangedFromSpinBox(double)));
+  connect(mSlider, SIGNAL(valueChanged(int)), this, SLOT(valueChangedFromSlider(int)));
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvIntensityValueSlider::~vvIntensityValueSlider() {
+  // DD("Delete vvIntensityValueSlider");
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvIntensityValueSlider::valueChangedFromSpinBox(double v) {
+  //  DD("valueChangedFromSpinBox");
+  //   DD(v);
+  mSlider->setValue(v);
+  mValue = v;
+  emit valueChanged(v);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvIntensityValueSlider::valueChangedFromSlider(int v) {
+  //   DD("valueChangedFromSlider");
+  //   DD(v);
+  //   DD(v*mSliderFactor);
+  mSpinBox->setValue(v*mSliderFactor);
+  //  emit valueChanged(v*mSliderFactor);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvIntensityValueSlider::SetText(QString t) {
+  mLabel->setText(t);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvIntensityValueSlider::SetImage(vvImage * im) { 
+  mImage = im; 
+  Update(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvIntensityValueSlider::SetValue(double d) { 
+  mSpinBox->setValue(d);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvIntensityValueSlider::SetMaximum(double max) {
+  mSlider->setMaximum(max);
+  mSpinBox->setMaximum(max);
+  if (mValue > max) { SetValue(max); }
+  QString tip = QString("Min = %1    Max = %2").arg(mSpinBox->minimum()).arg(max);
+  setToolTip(tip);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvIntensityValueSlider::SetMinimum(double min) {
+  mSlider->setMinimum(min);
+  mSpinBox->setMinimum(min);
+  if (mValue < min) { SetValue(min); }
+  QString tip = QString("Min = %1    Max = %2").arg(min).arg(mSpinBox->maximum());
+  setToolTip(tip);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvIntensityValueSlider::Update() {
+  DD(mImage->GetScalarTypeAsString());
+  DD(mImage->GetFirstVTKImageData()->GetScalarTypeMax());
+  DD(mImage->GetFirstVTKImageData()->GetScalarTypeMin());
+
+  // double max = mImage->GetFirstVTKImageData()->GetScalarTypeMax();
+//   double min = mImage->GetFirstVTKImageData()->GetScalarTypeMin();
+    
+  if (mImage->IsScalarTypeInteger()) {
+
+    mSpinBox->setSingleStep(1.0);
+    mSpinBox->setDecimals(0);
+    mSliderFactor = 1.0;
+
+    double range[2];
+    mImage->GetFirstVTKImageData()->GetScalarRange(range);
+    mMin = range[0];
+    mMax = range[1];
+    DD(mMax);
+    DD(mMin);
+    mSlider->setMaximum(mMax);
+    mSlider->setMinimum(mMin);
+    mSpinBox->setMaximum(mMax);
+    mSpinBox->setMinimum(mMin);
+
+    QString tip = QString("Min = %1    Max = %2").arg(mMin).arg(mMax);
+    setToolTip(tip);
+  }
+  else {
+    std::cerr << "NO floating point image yet !!" << std::endl;
+    exit(0);
+  }
+}
+
+//------------------------------------------------------------------------------
diff --git a/vv/vvIntensityValueSlider.h b/vv/vvIntensityValueSlider.h
new file mode 100644 (file)
index 0000000..831d29b
--- /dev/null
@@ -0,0 +1,76 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvIntensityValueSlider.h,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 VVINTENSITYVALUESLIDER_H
+#define VVINTENSITYVALUESLIDER_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include <QDialog>
+
+#include "ui_vvIntensityValueSlider.h"
+#include "clitkCommon.h"
+#include "vvImage.h"
+#include "vtkImageData.h"
+
+//------------------------------------------------------------------------------
+class QDESIGNER_WIDGET_EXPORT vvIntensityValueSlider: 
+  public QWidget, private Ui::vvIntensityValueSlider {
+  Q_OBJECT
+    public:
+  vvIntensityValueSlider(QWidget * parent=0, Qt::WindowFlags f=0);
+  ~vvIntensityValueSlider();
+
+  void SetText(QString t);
+  void SetImage(vvImage * im);
+  void Update();
+  double GetValue() const { return mValue; }
+  void SetValue(double d);
+  void SetMaximum(double max);
+  void SetMinimum(double min);                         
+  void resetMinimum() { SetMinimum(mMin); }
+  void resetMaximum() { SetMaximum(mMax); }
+
+ public slots:
+  void valueChangedFromSpinBox(double v);
+  void valueChangedFromSlider(int v);
+
+ signals:
+  void valueChanged(double);
+
+ protected:
+  Ui::vvIntensityValueSlider ui;
+  vvImage * mImage;
+  double mSliderFactor;
+  double mValue;
+  double mMax;
+  double mMin;
+
+}; // end class vvIntensityValueSlider
+//------------------------------------------------------------------------------
+
+#endif
+
index 01501622b85e983d75bd5a386ffcf65ef3cd362f..30005ac931e0d7927e0fda5e39022155c0c1b453 100644 (file)
@@ -1,31 +1,38 @@
 /*=========================================================================
 
-Program:   vv
-Language:  C++
-Author :   Pierre Seroul (pierre.seroul@gmail.com)
+  Program:   vv
+  Module:    $RCSfile: vvMainWindow.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:53:49 $
+  Version:   $Revision: 1.5 $
+  Author :   Pierre Seroul (pierre.seroul@gmail.com)
 
-Copyright (C) 200COLUMN_IMAGE_NAME
-Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
-CREATIS-LRMN http://www.creatis.insa-lyon.fr
+  Copyright (C) 200COLUMN_IMAGE_NAME
+  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/>.
 
-=========================================================================*/
+  =========================================================================*/
+
+// QT include
 #include <algorithm>
 #include <QMessageBox>
 #include <QInputDialog>
 #include <QTimer>
+#include "QTreePushButton.h"
 
+// VV include
 #include "vvMainWindow.h"
 #include "vvHelpDialog.h"
 #include "vvDocumentation.h"
@@ -48,18 +55,19 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "vvStructSelector.h"
 #include "vvMeshReader.h"
 #include "vvCropDialog.h"
-#include "QTreePushButton.h"
-
+#include "vvConstants.h"
 #ifdef CLITK_VV_USE_BDCM
 #include <bdcmDicomFilesSelectorDialog.h>
 #endif
 
+// ITK include
 #include "itkImage.h"
 #include "itkImageFileReader.h"
 #include "itkByteSwapper.h"
 #include "itkCommand.h"
 #include "itkNumericSeriesFileNames.h"
 
+// VTK include
 #include "vtkImageData.h"
 #include "vtkImageActor.h"
 #include "vtkCornerAnnotation.h"
@@ -67,7 +75,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "vtkRenderWindowInteractor.h"
 #include "vtkRenderer.h"
 #include "vtkRendererCollection.h"
-
 #include "vtkWindowToImageFilter.h"
 #include "vtkBMPWriter.h"
 #include "vtkTIFFWriter.h"
@@ -78,8 +85,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 // Standard includes
 #include <iostream>
 
-#include "vvConstants.h"
-
 #define COLUMN_TREE 0
 #define COLUMN_UL_VIEW 1
 #define COLUMN_UR_VIEW 2
@@ -99,932 +104,975 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
   5,0  short filename
   5,Qt::UserRole mSlicerManager id*/
 
-//====================================================================
+//------------------------------------------------------------------------------
 vvMainWindow::vvMainWindow() {
-    setupUi(this); // this sets up the GUI
-
-    mInputPathName = "";
-
-    //Init the contextMenu
-    this->setContextMenuPolicy(Qt::CustomContextMenu);
-    contextActions.resize(0);
-    QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/fileopen.png")),
-                                    tr("Open new Image"));
-    connect(actionOpen_new_image,SIGNAL(triggered()),this,SLOT(OpenImages()));
-    contextActions.push_back(actionOpen_new_image);
-
-    contextMenu.addSeparator();
-
-    QAction* actionClose_Image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")),
-                                 tr("Close Current Image"));
-    connect(actionClose_Image,SIGNAL(triggered()),this,SLOT(CloseImage()));
-    contextActions.push_back(actionClose_Image);
-
-    QAction* actionReload_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")),
-                                  tr("Reload Current Image"));
-    connect(actionReload_image,SIGNAL(triggered()),this,SLOT(ReloadImage()));
-    contextActions.push_back(actionReload_image);
-
-    QAction* actionSave_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/filesave.png")),
-                                tr("Save Current Image"));
-    connect(actionSave_image,SIGNAL(triggered()),this,SLOT(SaveAs()));
-    contextActions.push_back(actionSave_image);
-
-    contextMenu.addSeparator();
-
-    QAction* actionCrop_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/crop.png")),
-                                 tr("Crop Current Image"));
-    connect(actionCrop_image,SIGNAL(triggered()),this,SLOT(CropImage()));
-    contextActions.push_back(actionCrop_image);
-
-    QAction* actionSplit_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/cut.png")),
-                                 tr("Split Current Image"));
-    connect(actionSplit_image,SIGNAL(triggered()),this,SLOT(SplitImage()));
-    contextActions.push_back(actionSplit_image);
-
-    contextMenu.addSeparator();
-
-    contextMenu.addAction(actionAdd_VF_to_current_Image);
-    contextActions.push_back(actionAdd_VF_to_current_Image);
-
-    QAction* actionAdd_Overlay_to_current_Image = menuOverlay->addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/GPSup.png")),
-            tr("Add overlay image to current image"));
-    contextMenu.addAction(actionAdd_Overlay_to_current_Image);
-    contextActions.push_back(actionAdd_Overlay_to_current_Image);
-
-    connect(actionAdd_Overlay_to_current_Image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage()));
-
-    contextMenu.addAction(actionAdd_fusion_image);
-    connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
-    contextActions.push_back(actionAdd_fusion_image);
-
-
-    //init the DataTree
-    mSlicerManagers.resize(0);
-
-    QStringList header;
-    header.append("");
-    header.append("TL");
-    header.append("TR");
-    header.append("BL");
-    header.append("BR");
-    header.append("");
-    header.append("");
-    header.append("Name");
-
-    DataTree->setHeaderLabels(header);
-    DataTree->resizeColumnToContents(COLUMN_TREE);
-    DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
-    DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
-    DataTree->resizeColumnToContents(COLUMN_DL_VIEW);
-    DataTree->resizeColumnToContents(COLUMN_DR_VIEW);
-    DataTree->resizeColumnToContents(COLUMN_CLOSE_IMAGE);
-    DataTree->resizeColumnToContents(COLUMN_RELOAD_IMAGE);
-    DataTree->resizeColumnToContents(COLUMN_IMAGE_NAME);
-
-    viewMode = 1;
-    documentation = new vvDocumentation();
-    help_dialog = new vvHelpDialog();
-    dicomSeriesSelector = new vvDicomSeriesSelector();
-
-    inverseButton->setEnabled(0);
-    actionAdd_Overlay_to_current_Image->setEnabled(0);
-    actionSave_As->setEnabled(0);
-    actionAdd_VF_to_current_Image->setEnabled(0);
-    actionAdd_fusion_image->setEnabled(0);
-
-    //init the sliders
-    verticalSliders.push_back(NOVerticalSlider);
-    verticalSliders.push_back(NEVerticalSlider);
-    verticalSliders.push_back(SOVerticalSlider);
-    verticalSliders.push_back(SEVerticalSlider);
-
-    for (int i =0; i < 4; i++)
-        verticalSliders[i]->hide();
-
-    horizontalSliders.push_back(NOHorizontalSlider);
-    horizontalSliders.push_back(NEHorizontalSlider);
-    horizontalSliders.push_back(SOHorizontalSlider);
-    horizontalSliders.push_back(SEHorizontalSlider);
-
-    for (int i =0; i < 4; i++)
-        horizontalSliders[i]->hide();
-
-
-    connect(NOVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(NOVerticalSliderChanged()));
-    connect(NEVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(NEVerticalSliderChanged()));
-    connect(SOVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(SOVerticalSliderChanged()));
-    connect(SEVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(SEVerticalSliderChanged()));
-
-    connect(NOHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(NOHorizontalSliderMoved()));
-    connect(NEHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(NEHorizontalSliderMoved()));
-    connect(SOHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(SOHorizontalSliderMoved()));
-    connect(SEHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(SEHorizontalSliderMoved()));
-
-    //connect everything
-    connect(actionMaximum_Intensity_Projection,SIGNAL(triggered()),this,SLOT(ComputeMIP()));
-    connect(actionCompute_mid_position_image,SIGNAL(triggered()),this,SLOT(ComputeMidPosition()));
-    connect(actionDeformable_Registration,SIGNAL(triggered()),this,SLOT(ComputeDeformableRegistration()));
-    connect(actionWarp_image_with_vector_field,SIGNAL(triggered()),this,SLOT(WarpImage()));
-    connect(actionLoad_images,SIGNAL(triggered()),this,SLOT(OpenImages()));
-    connect(actionOpen_Dicom,SIGNAL(triggered()),this,SLOT(OpenDicom()));
-    connect(actionOpen_Dicom_Struct,SIGNAL(triggered()),this,SLOT(OpenDCStructContour()));
-    connect(actionOpen_VTK_contour,SIGNAL(triggered()),this,SLOT(OpenVTKContour()));
-    connect(actionOpen_Multiple_Images_As_One,SIGNAL(triggered()),this,SLOT(MergeImages()));
-    connect(actionOpen_Image_With_Time,SIGNAL(triggered()),this,SLOT(OpenImageWithTime()));
-    connect(actionMerge_images_as_n_dim_t, SIGNAL(triggered()), this, SLOT(MergeImagesWithTime()));
-    connect(actionSave_As,SIGNAL(triggered()),this,SLOT(SaveAs()));
-    connect(actionExit,SIGNAL(triggered()),this,SLOT(close()));
-    connect(actionAdd_VF_to_current_Image,SIGNAL(triggered()),this,SLOT(OpenField()));
-    connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
-    connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
-
-    ///////////////////////////////////////////////
-    contextMenu.addAction(actionResampler);
-    connect(actionResampler,SIGNAL(triggered()),this,SLOT(ResampleCurrentImage()));
-    connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage()));
-    connect(actionSurface_Viewer,SIGNAL(triggered()),this,SLOT(SurfaceViewerLaunch()));
-    ///////////////////////////////////////////////
-
-    actionNorth_East_Window->setEnabled(0);
-    actionNorth_West_Window->setEnabled(0);
-    actionSouth_East_Window->setEnabled(0);
-    actionSouth_West_Window->setEnabled(0);
-
-    connect(actionNorth_East_Window,SIGNAL(triggered()),this,SLOT(SaveNEScreenshot()));
-    connect(actionNorth_West_Window,SIGNAL(triggered()),this,SLOT(SaveNOScreenshot()));
-    connect(actionSouth_East_Window,SIGNAL(triggered()),this,SLOT(SaveSEScreenshot()));
-    connect(actionSouth_West_Window,SIGNAL(triggered()),this,SLOT(SaveSOScreenshot()));
-
-    connect(DataTree,SIGNAL(itemSelectionChanged()),this,SLOT(ImageInfoChanged()));
-    connect(DataTree,SIGNAL(itemClicked(QTreeWidgetItem*, int)),this,
-            SLOT(DisplayChanged(QTreeWidgetItem*, int)));
-
-    connect(viewButton,SIGNAL(clicked()),this, SLOT(ChangeViewMode()) );
-    connect(windowSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
-    connect(levelSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
-    connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap()));
-    connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel()));
-    connect(inverseButton,SIGNAL(clicked()),this,SLOT(SwitchWindowLevel()));
-
-
-    connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint)));
-
-    connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString)));
-    connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString)));
-    connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int)),this,SLOT(SetVFProperty(int,int,int)));
-    connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int)));
-    connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,double,double)),
-            this,SLOT(SetFusionProperty(int,int,double,double)));
-    connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows()));
-
-    playMode = 0;//pause
-    mFrameRate = 10;
-    playButton->setEnabled(0);
-    frameRateLabel->setEnabled(0);
-    frameRateSpinBox->setEnabled(0);
-    connect(playButton, SIGNAL(clicked()),this,SLOT(PlayPause()));
-    connect(frameRateSpinBox, SIGNAL(valueChanged(int)),this,SLOT(ChangeFrameRate(int)));
-
-    goToCursorPushButton->setEnabled(0);
-    connect(goToCursorPushButton, SIGNAL(clicked()),this,SLOT(GoToCursor()));
-
-    NOViewWidget->hide();
-    NEViewWidget->hide();
-    SOViewWidget->hide();
-    SEViewWidget->hide();
-
-    //Recently opened files
-    std::list<std::string> recent_files = GetRecentlyOpenedImages();
-    if ( not recent_files.empty() )
-    {
-        QMenu * rmenu = new QMenu("Recently opened files...");
-        rmenu->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/open.png")));
-        menuFile->insertMenu(actionOpen_Image_With_Time,rmenu);
-        for (std::list<std::string>::iterator i = recent_files.begin();i!=recent_files.end();i++)
-        {
-            QAction* current=new QAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/open.png")),
-                    (*i).c_str(),this);
-            rmenu->addAction(current);
-            connect(current,SIGNAL(triggered()),this,SLOT(OpenRecentImage()));
-        }
-    }
-}
-//====================================================================
+  setupUi(this); // this sets up the GUI
+
+  mInputPathName = "";
+  mCurrentToolInfo = 0;
+
+  //Init the contextMenu
+  this->setContextMenuPolicy(Qt::CustomContextMenu);
+  contextActions.resize(0);
+  QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/fileopen.png")),
+                                                        tr("Open new Image"));
+  connect(actionOpen_new_image,SIGNAL(triggered()),this,SLOT(OpenImages()));
+  contextActions.push_back(actionOpen_new_image);
+
+  contextMenu.addSeparator();
+
+  QAction* actionClose_Image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")),
+                                                     tr("Close Current Image"));
+  connect(actionClose_Image,SIGNAL(triggered()),this,SLOT(CloseImage()));
+  contextActions.push_back(actionClose_Image);
+
+  QAction* actionReload_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")),
+                                                      tr("Reload Current Image"));
+  connect(actionReload_image,SIGNAL(triggered()),this,SLOT(ReloadImage()));
+  contextActions.push_back(actionReload_image);
+
+  QAction* actionSave_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/filesave.png")),
+                                                    tr("Save Current Image"));
+  connect(actionSave_image,SIGNAL(triggered()),this,SLOT(SaveAs()));
+  contextActions.push_back(actionSave_image);
+
+  contextMenu.addSeparator();
+
+  QAction* actionCrop_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/crop.png")),
+                                                    tr("Crop Current Image"));
+  connect(actionCrop_image,SIGNAL(triggered()),this,SLOT(CropImage()));
+  contextActions.push_back(actionCrop_image);
+
+  QAction* actionSplit_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/cut.png")),
+                                                     tr("Split Current Image"));
+  connect(actionSplit_image,SIGNAL(triggered()),this,SLOT(SplitImage()));
+  contextActions.push_back(actionSplit_image);
+
+  contextMenu.addSeparator();
+
+  contextMenu.addAction(actionAdd_VF_to_current_Image);
+  contextActions.push_back(actionAdd_VF_to_current_Image);
+
+  QAction* actionAdd_Overlay_to_current_Image = menuOverlay->addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/GPSup.png")),
+                                                                       tr("Add overlay image to current image"));
+  contextMenu.addAction(actionAdd_Overlay_to_current_Image);
+  contextActions.push_back(actionAdd_Overlay_to_current_Image);
+
+  connect(actionAdd_Overlay_to_current_Image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage()));
+
+  contextMenu.addAction(actionAdd_fusion_image);
+  connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
+  contextActions.push_back(actionAdd_fusion_image);
+
+
+  //init the DataTree
+  mSlicerManagers.resize(0);
+
+  QStringList header;
+  header.append("");
+  header.append("TL");
+  header.append("TR");
+  header.append("BL");
+  header.append("BR");
+  header.append("");
+  header.append("");
+  header.append("Name");
+
+  DataTree->setHeaderLabels(header);
+  DataTree->resizeColumnToContents(COLUMN_TREE);
+  DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
+  DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
+  DataTree->resizeColumnToContents(COLUMN_DL_VIEW);
+  DataTree->resizeColumnToContents(COLUMN_DR_VIEW);
+  DataTree->resizeColumnToContents(COLUMN_CLOSE_IMAGE);
+  DataTree->resizeColumnToContents(COLUMN_RELOAD_IMAGE);
+  DataTree->resizeColumnToContents(COLUMN_IMAGE_NAME);
+
+  viewMode = 1;
+  documentation = new vvDocumentation();
+  help_dialog = new vvHelpDialog();
+  dicomSeriesSelector = new vvDicomSeriesSelector();
+
+  inverseButton->setEnabled(0);
+  actionAdd_Overlay_to_current_Image->setEnabled(0);
+  actionSave_As->setEnabled(0);
+  actionAdd_VF_to_current_Image->setEnabled(0);
+  actionAdd_fusion_image->setEnabled(0);
+
+  //init the sliders
+  verticalSliders.push_back(NOVerticalSlider);
+  verticalSliders.push_back(NEVerticalSlider);
+  verticalSliders.push_back(SOVerticalSlider);
+  verticalSliders.push_back(SEVerticalSlider);
+
+  for (int i =0; i < 4; i++)
+    verticalSliders[i]->hide();
+
+  horizontalSliders.push_back(NOHorizontalSlider);
+  horizontalSliders.push_back(NEHorizontalSlider);
+  horizontalSliders.push_back(SOHorizontalSlider);
+  horizontalSliders.push_back(SEHorizontalSlider);
+
+  for (int i =0; i < 4; i++)
+    horizontalSliders[i]->hide();
+
+
+  connect(NOVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(NOVerticalSliderChanged()));
+  connect(NEVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(NEVerticalSliderChanged()));
+  connect(SOVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(SOVerticalSliderChanged()));
+  connect(SEVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(SEVerticalSliderChanged()));
+
+  connect(NOHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(NOHorizontalSliderMoved()));
+  connect(NEHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(NEHorizontalSliderMoved()));
+  connect(SOHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(SOHorizontalSliderMoved()));
+  connect(SEHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(SEHorizontalSliderMoved()));
+
+  //connect everything
+  connect(actionMaximum_Intensity_Projection,SIGNAL(triggered()),this,SLOT(ComputeMIP()));
+  connect(actionCompute_mid_position_image,SIGNAL(triggered()),this,SLOT(ComputeMidPosition()));
+  connect(actionDeformable_Registration,SIGNAL(triggered()),this,SLOT(ComputeDeformableRegistration()));
+  connect(actionWarp_image_with_vector_field,SIGNAL(triggered()),this,SLOT(WarpImage()));
+  connect(actionLoad_images,SIGNAL(triggered()),this,SLOT(OpenImages()));
+  connect(actionOpen_Dicom,SIGNAL(triggered()),this,SLOT(OpenDicom()));
+  connect(actionOpen_Dicom_Struct,SIGNAL(triggered()),this,SLOT(OpenDCStructContour()));
+  connect(actionOpen_VTK_contour,SIGNAL(triggered()),this,SLOT(OpenVTKContour()));
+  connect(actionOpen_Multiple_Images_As_One,SIGNAL(triggered()),this,SLOT(MergeImages()));
+  connect(actionOpen_Image_With_Time,SIGNAL(triggered()),this,SLOT(OpenImageWithTime()));
+  connect(actionMerge_images_as_n_dim_t, SIGNAL(triggered()), this, SLOT(MergeImagesWithTime()));
+  connect(actionSave_As,SIGNAL(triggered()),this,SLOT(SaveAs()));
+  connect(actionExit,SIGNAL(triggered()),this,SLOT(close()));
+  connect(actionAdd_VF_to_current_Image,SIGNAL(triggered()),this,SLOT(OpenField()));
+  connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
+  connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
+
+  ///////////////////////////////////////////////
+  contextMenu.addAction(actionResampler);
+  connect(actionResampler,SIGNAL(triggered()),this,SLOT(ResampleCurrentImage()));
+  connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage()));
+  connect(actionSurface_Viewer,SIGNAL(triggered()),this,SLOT(SurfaceViewerLaunch()));
+  ///////////////////////////////////////////////
+
+  actionNorth_East_Window->setEnabled(0);
+  actionNorth_West_Window->setEnabled(0);
+  actionSouth_East_Window->setEnabled(0);
+  actionSouth_West_Window->setEnabled(0);
+
+  connect(actionNorth_East_Window,SIGNAL(triggered()),this,SLOT(SaveNEScreenshot()));
+  connect(actionNorth_West_Window,SIGNAL(triggered()),this,SLOT(SaveNOScreenshot()));
+  connect(actionSouth_East_Window,SIGNAL(triggered()),this,SLOT(SaveSEScreenshot()));
+  connect(actionSouth_West_Window,SIGNAL(triggered()),this,SLOT(SaveSOScreenshot()));
+
+  connect(DataTree,SIGNAL(itemSelectionChanged()),this,SLOT(ImageInfoChanged()));
+  connect(DataTree,SIGNAL(itemClicked(QTreeWidgetItem*, int)),this,
+          SLOT(DisplayChanged(QTreeWidgetItem*, int)));
+
+  connect(viewButton,SIGNAL(clicked()),this, SLOT(ChangeViewMode()) );
+  connect(windowSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
+  connect(levelSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
+  connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap()));
+  connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel()));
+  connect(inverseButton,SIGNAL(clicked()),this,SLOT(SwitchWindowLevel()));
+
+
+  connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint)));
+
+  connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString)));
+  connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString)));
+  connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int)),this,SLOT(SetVFProperty(int,int,int)));
+  connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int)));
+  connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,double,double)),
+          this,SLOT(SetFusionProperty(int,int,double,double)));
+  connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows()));
+
+  playMode = 0;//pause
+  mFrameRate = 10;
+  playButton->setEnabled(0);
+  frameRateLabel->setEnabled(0);
+  frameRateSpinBox->setEnabled(0);
+  connect(playButton, SIGNAL(clicked()),this,SLOT(PlayPause()));
+  connect(frameRateSpinBox, SIGNAL(valueChanged(int)),this,SLOT(ChangeFrameRate(int)));
+
+  goToCursorPushButton->setEnabled(0);
+  connect(goToCursorPushButton, SIGNAL(clicked()),this,SLOT(GoToCursor()));
+
+  NOViewWidget->hide();
+  NEViewWidget->hide();
+  SOViewWidget->hide();
+  SEViewWidget->hide();
+
+  //Recently opened files
+  std::list<std::string> recent_files = GetRecentlyOpenedImages();
+  if ( not recent_files.empty() )
+    {
+      QMenu * rmenu = new QMenu("Recently opened files...");
+      rmenu->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/open.png")));
+      menuFile->insertMenu(actionOpen_Image_With_Time,rmenu);
+      for (std::list<std::string>::iterator i = recent_files.begin();i!=recent_files.end();i++)
+        {
+          QAction* current=new QAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/open.png")),
+                                       (*i).c_str(),this);
+          rmenu->addAction(current);
+          connect(current,SIGNAL(triggered()),this,SLOT(OpenRecentImage()));
+        }
+    }
+
+  // Adding all new tools (insertion in the menu)
+  vvToolManager::GetInstance()->Initialize(this);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
 void vvMainWindow::ComputeMIP()
 {
-    vvMaximumIntensityProjection mip;
-    vvSlicerManager* selected_slicer = mSlicerManagers[GetSlicerIndexFromItem(DataTree->selectedItems()[0])];
-    QFileInfo info(selected_slicer->GetFileName().c_str());
-    mip.Compute(selected_slicer);
-    AddImage(mip.GetOutput(),info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_mip.mhd");
+  vvMaximumIntensityProjection mip;
+  vvSlicerManager* selected_slicer = mSlicerManagers[GetSlicerIndexFromItem(DataTree->selectedItems()[0])];
+  QFileInfo info(selected_slicer->GetFileName().c_str());
+  mip.Compute(selected_slicer);
+  AddImage(mip.GetOutput(),info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_mip.mhd");
 }
+//------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
 void vvMainWindow::ComputeMidPosition()
 {
-    bool ok;
-    int index=GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
-            mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
-    if (ok)
-    {
-        vvMidPosition midp;
-        midp.slicer_manager = mSlicerManagers[index];
-        midp.reference_image_index = ref;
-        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-        midp.Update();
-        if (midp.error)
-            QMessageBox::warning(this, "Error computing midposition image",midp.error_message.c_str());
-        else
+  bool ok;
+  int index=GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
+                                     mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
+  if (ok)
+    {
+      vvMidPosition midp;
+      midp.slicer_manager = mSlicerManagers[index];
+      midp.reference_image_index = ref;
+      QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+      midp.Update();
+      if (midp.error)
+        QMessageBox::warning(this, "Error computing midposition image",midp.error_message.c_str());
+      else
         {
-            QFileInfo info(midp.slicer_manager->GetFileName().c_str());
-            AddImage(midp.output,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_midposition.mhd");
+          QFileInfo info(midp.slicer_manager->GetFileName().c_str());
+          AddImage(midp.output,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_midposition.mhd");
         }
-        QApplication::restoreOverrideCursor();
+      QApplication::restoreOverrideCursor();
     }
 }
 
 void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool propagation)
 {
-    QTreeWidgetItem *item = new QTreeWidgetItem();
-    item->setData(0,Qt::UserRole,"filename.vtk");
-    item->setData(1,Qt::UserRole,tr("contour"));
-    QBrush brush;
-    brush.setColor(QColor(contour->r*255,contour->g*255,contour->b*255));
-    brush.setStyle(Qt::SolidPattern);
-    item->setData(COLUMN_IMAGE_NAME,Qt::BackgroundRole,brush);
-    item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,contour->structure_name.c_str());
-
-    for (int j = 1; j <= 4; j++)
-        item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(image_index)->data(j,Qt::CheckStateRole));
-
-    QTreePushButton* cButton = new QTreePushButton;
-    cButton->setItem(item);
-    cButton->setColumn(COLUMN_CLOSE_IMAGE);
-    cButton->setToolTip(tr("close image"));
-    cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
-    connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-            this,SLOT(CloseImage(QTreeWidgetItem*, int)));
-
-    QTreePushButton* rButton = new QTreePushButton;
-    rButton->setItem(item);
-    rButton->setColumn(COLUMN_RELOAD_IMAGE);
-    rButton->setToolTip(tr("reload image"));
-    rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
-    rButton->setEnabled(false);
-    //Not implemented
-    //connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-            //this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
-
-    DataTree->topLevelItem(image_index)->setExpanded(1);
-    DataTree->topLevelItem(image_index)->addChild(item);
-    DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
-    DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
-    QString id = DataTree->topLevelItem(image_index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
-    item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
-
-    UpdateTree();
-    mSlicerManagers[image_index]->AddContour(contour,propagation);
-    mSlicerManagers[image_index]->Render();
-}
-
-//====================================================================
+  QTreeWidgetItem *item = new QTreeWidgetItem();
+  item->setData(0,Qt::UserRole,"filename.vtk");
+  item->setData(1,Qt::UserRole,tr("contour"));
+  QBrush brush;
+  brush.setColor(QColor(contour->r*255,contour->g*255,contour->b*255));
+  brush.setStyle(Qt::SolidPattern);
+  item->setData(COLUMN_IMAGE_NAME,Qt::BackgroundRole,brush);
+  item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,contour->structure_name.c_str());
+
+  for (int j = 1; j <= 4; j++)
+    item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(image_index)->data(j,Qt::CheckStateRole));
+
+  QTreePushButton* cButton = new QTreePushButton;
+  cButton->setItem(item);
+  cButton->setColumn(COLUMN_CLOSE_IMAGE);
+  cButton->setToolTip(tr("close image"));
+  cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
+  connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+          this,SLOT(CloseImage(QTreeWidgetItem*, int)));
+
+  QTreePushButton* rButton = new QTreePushButton;
+  rButton->setItem(item);
+  rButton->setColumn(COLUMN_RELOAD_IMAGE);
+  rButton->setToolTip(tr("reload image"));
+  rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
+  rButton->setEnabled(false);
+  //Not implemented
+  //connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+  //this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
+
+  DataTree->topLevelItem(image_index)->setExpanded(1);
+  DataTree->topLevelItem(image_index)->addChild(item);
+  DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
+  DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
+  QString id = DataTree->topLevelItem(image_index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
+  item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
+
+  UpdateTree();
+  mSlicerManagers[image_index]->AddContour(contour,propagation);
+  mSlicerManagers[image_index]->Render();
+}
+
+//------------------------------------------------------------------------------
 void vvMainWindow::OpenVTKContour()
 {
-    if (mSlicerManagers.size() > 0)
-    {
-        QString Extensions = "Images ( *.vtk)";
-        Extensions += ";;All Files (*)";
-        QString file = QFileDialog::getOpenFileName(this,tr("Open vtkPolyData"),mInputPathName,Extensions);
-        if (file.isNull())
-            return;
-        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-        int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-        vvMeshReader reader;
-        reader.SetModeToVTK();
-        reader.SetFilename(file.toStdString());
-        reader.Update();
-        AddContour(index,reader.GetOutput()[0],false);
-        QApplication::restoreOverrideCursor();
+  if (mSlicerManagers.size() > 0)
+    {
+      QString Extensions = "Images ( *.vtk)";
+      Extensions += ";;All Files (*)";
+      QString file = QFileDialog::getOpenFileName(this,tr("Open vtkPolyData"),mInputPathName,Extensions);
+      if (file.isNull())
+        return;
+      QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+      int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+      vvMeshReader reader;
+      reader.SetModeToVTK();
+      reader.SetFilename(file.toStdString());
+      reader.Update();
+      AddContour(index,reader.GetOutput()[0],false);
+      QApplication::restoreOverrideCursor();
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::OpenDCStructContour()
 {
-    if (mSlicerManagers.size() > 0)
-    {
-        QString Extensions = "Dicom Files ( *.dcm)";
-        Extensions += ";;All Files (*)";
-        QString file = QFileDialog::getOpenFileName(this,tr("Merge Images"),mInputPathName,Extensions);
-        if (file.isNull())
-            return;
-        int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-        vvMeshReader reader;
-        reader.SetFilename(file.toStdString());
-        vvStructSelector selector;
-        selector.SetStructures(reader.GetROINames());
-        if (!mSlicerManagers[index]->GetVF().IsNull())
-            selector.EnablePropagationCheckBox();
-        if (selector.exec())
-        {
-            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-            reader.SetSelectedItems(selector.getSelectedItems());
-            reader.SetImage(mSlicerManagers[index]->GetImage());
-            if (selector.PropagationEnabled())
-                reader.SetPropagationVF(mSlicerManagers[index]->GetVF());
-            reader.Update();
-            std::vector<vvMesh::Pointer> contours=reader.GetOutput();
-            for (std::vector<vvMesh::Pointer>::iterator i=contours.begin();
-                    i!=contours.end();i++)
-                AddContour(index,*i,selector.PropagationEnabled());
-            QApplication::restoreOverrideCursor();
-        }
-    }
-}
-
-//====================================================================
+  if (mSlicerManagers.size() > 0)
+    {
+      QString Extensions = "Dicom Files ( *.dcm)";
+      Extensions += ";;All Files (*)";
+      QString file = QFileDialog::getOpenFileName(this,tr("Merge Images"),mInputPathName,Extensions);
+      if (file.isNull())
+        return;
+      int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+      vvMeshReader reader;
+      reader.SetFilename(file.toStdString());
+      vvStructSelector selector;
+      selector.SetStructures(reader.GetROINames());
+      if (!mSlicerManagers[index]->GetVF().IsNull())
+        selector.EnablePropagationCheckBox();
+      if (selector.exec())
+        {
+          QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+          reader.SetSelectedItems(selector.getSelectedItems());
+          reader.SetImage(mSlicerManagers[index]->GetImage());
+          if (selector.PropagationEnabled())
+            reader.SetPropagationVF(mSlicerManagers[index]->GetVF());
+          reader.Update();
+          std::vector<vvMesh::Pointer> contours=reader.GetOutput();
+          for (std::vector<vvMesh::Pointer>::iterator i=contours.begin();
+               i!=contours.end();i++)
+            AddContour(index,*i,selector.PropagationEnabled());
+          QApplication::restoreOverrideCursor();
+        }
+    }
+}
+
+//------------------------------------------------------------------------------
 void vvMainWindow::ComputeDeformableRegistration()
 {
-    if (mSlicerManagers.size() > 0)
+  if (mSlicerManagers.size() > 0)
     {
-        int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-        vvDeformationDialog dialog(index,mSlicerManagers);
-        if (dialog.exec())
+      int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+      vvDeformationDialog dialog(index,mSlicerManagers);
+      if (dialog.exec())
         {
-            std::string base_name=itksys::SystemTools::GetFilenameWithoutExtension(mSlicerManagers[dialog.GetInputFileIndex()]->GetFileName());
-            AddField(dialog.GetOutput(),dialog.getFieldFile(),dialog.GetInputFileIndex());
-            WarpImage(dialog.GetSelectedSlicer(),dialog.GetReferenceFrameIndex());
+          std::string base_name=itksys::SystemTools::GetFilenameWithoutExtension(mSlicerManagers[dialog.GetInputFileIndex()]->GetFileName());
+          AddField(dialog.GetOutput(),dialog.getFieldFile(),dialog.GetInputFileIndex());
+          WarpImage(dialog.GetSelectedSlicer(),dialog.GetReferenceFrameIndex());
         }
-        else
-            std::cout << "Error or user cancellation while computing deformation field..." << std::endl;
+      else
+        std::cout << "Error or user cancellation while computing deformation field..." << std::endl;
     }
-    else QMessageBox::information(this, "Need to open image","You must open an image first.");
+  else QMessageBox::information(this, "Need to open image","You must open an image first.");
 }
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::WarpImage()
 {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    if (!mSlicerManagers[index]->GetVF().IsNull())
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  if (!mSlicerManagers[index]->GetVF().IsNull())
     {
-        bool ok;
-        int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
-                                           mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
-        if (ok)
+      bool ok;
+      int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
+                                         mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
+      if (ok)
         {
-            WarpImage(mSlicerManagers[index],ref);
+          WarpImage(mSlicerManagers[index],ref);
         }
     }
-    else
-        QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field"));
+  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)
 {
-    if (!selected_slicer->GetVF().IsNull())
+  if (!selected_slicer->GetVF().IsNull())
     {
-        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-        QFileInfo info(selected_slicer->GetFileName().c_str());
-        vvImageWarp warp(selected_slicer->GetImage(),selected_slicer->GetVF(),
-                reference_phase,this);
-        if (warp.ComputeWarpedImage())
+      QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+      QFileInfo info(selected_slicer->GetFileName().c_str());
+      vvImageWarp warp(selected_slicer->GetImage(),selected_slicer->GetVF(),
+                       reference_phase,this);
+      if (warp.ComputeWarpedImage())
         {
-            AddImage(warp.GetWarpedImage(),info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_warped.mhd");
-            AddImage(warp.GetDiffImage()  ,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_diff.mhd");
-            AddImage(warp.GetJacobianImage()  ,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_jacobian.mhd");
-            QApplication::restoreOverrideCursor();
+          AddImage(warp.GetWarpedImage(),info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_warped.mhd");
+          AddImage(warp.GetDiffImage()  ,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_diff.mhd");
+          AddImage(warp.GetJacobianImage()  ,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_jacobian.mhd");
+          QApplication::restoreOverrideCursor();
         }
-        else
+      else
         {
-            QApplication::restoreOverrideCursor();
-            QMessageBox::warning(this,tr("Different spacings"),tr("The vector field and image spacings must be the same in order to warp."));
+          QApplication::restoreOverrideCursor();
+          QMessageBox::warning(this,tr("Different spacings"),tr("The vector field and image spacings must be the same in order to warp."));
         }
     }
-    else
-        QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field."));
+  else
+    QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field."));
 }
 
-//====================================================================
+//------------------------------------------------------------------------------
 vvMainWindow::~vvMainWindow() {
-    for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
     {
-        if (mSlicerManagers[i] != NULL)
-            delete mSlicerManagers[i];
+      if (mSlicerManagers[i] != NULL)
+        delete mSlicerManagers[i];
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::MergeImages() {
-    QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
-    Extensions += ";;All Files (*)";
-    QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images"),mInputPathName,Extensions);
-    if (files.isEmpty())
-        return;
-    mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
-    std::vector<std::string> vector;
-
-    unsigned int currentDim = 0;
-    std::vector<double> currentSpacing;
-    std::vector<int> currentSize;
-    std::vector<double> currentOrigin;
-
-    for (int i = 0; i < files.size(); i++)
-    {
-        itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
-                                               files[i].toStdString().c_str(), itk::ImageIOFactory::ReadMode);
-        reader->SetFileName(files[i].toStdString().c_str());
-        reader->ReadImageInformation();
-        if (reader)  NOViewWidget->hide();
-        NEViewWidget->hide();
-        SOViewWidget->hide();
-        SEViewWidget->hide();
-        {
+  QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
+  Extensions += ";;All Files (*)";
+  QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images"),mInputPathName,Extensions);
+  if (files.isEmpty())
+    return;
+  mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
+  std::vector<std::string> vector;
+
+  unsigned int currentDim = 0;
+  std::vector<double> currentSpacing;
+  std::vector<int> currentSize;
+  std::vector<double> currentOrigin;
+
+  for (int i = 0; i < files.size(); i++)
+    {
+      itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
+                                                                            files[i].toStdString().c_str(), itk::ImageIOFactory::ReadMode);
+      reader->SetFileName(files[i].toStdString().c_str());
+      reader->ReadImageInformation();
+      if (reader)  NOViewWidget->hide();
+      NEViewWidget->hide();
+      SOViewWidget->hide();
+      SEViewWidget->hide();
+      {
+        if (i == 0)
+          currentDim = reader->GetNumberOfDimensions();
+        bool IsOk = true;
+        for (unsigned int j = 0;j < currentDim; j++)
+          {
             if (i == 0)
-                currentDim = reader->GetNumberOfDimensions();
-            bool IsOk = true;
-            for (unsigned int j = 0;j < currentDim; j++)
-            {
-                if (i == 0)
-                {
-                    if (j == 0)
-                    {
-                        currentSpacing.resize(currentDim);
-                        currentSize.resize(currentDim);
-                        currentOrigin.resize(currentDim);
-                    }
-                    currentOrigin[j] = reader->GetOrigin(j);
-                    currentSpacing[j] = reader->GetSpacing(j);
-                    currentSize[j] = reader->GetDimensions(j);
-                }
-                else if (currentDim != reader->GetNumberOfDimensions()
-                         || currentSpacing[j] != reader->GetSpacing(j)
-                         || currentSize[j] != (int)reader->GetDimensions(j)
-                         || currentOrigin[j] != reader->GetOrigin(j))
-                {
-                    QString error = "Cannot read file (too different from others ";
-                    error += files[i].toStdString().c_str();
-                    QMessageBox::information(this,tr("Reading problem"),error);
-                    IsOk = false;
-                    break;
-                }
-            }
-            if (IsOk)
-                vector.push_back(files[i].toStdString());
-        }
+              {
+                if (j == 0)
+                  {
+                    currentSpacing.resize(currentDim);
+                    currentSize.resize(currentDim);
+                    currentOrigin.resize(currentDim);
+                  }
+                currentOrigin[j] = reader->GetOrigin(j);
+                currentSpacing[j] = reader->GetSpacing(j);
+                currentSize[j] = reader->GetDimensions(j);
+              }
+            else if (currentDim != reader->GetNumberOfDimensions()
+                     || currentSpacing[j] != reader->GetSpacing(j)
+                     || currentSize[j] != (int)reader->GetDimensions(j)
+                     || currentOrigin[j] != reader->GetOrigin(j))
+              {
+                QString error = "Cannot read file (too different from others ";
+                error += files[i].toStdString().c_str();
+                QMessageBox::information(this,tr("Reading problem"),error);
+                IsOk = false;
+                break;
+              }
+          }
+        if (IsOk)
+          vector.push_back(files[i].toStdString());
+      }
     }
-    if (vector.size() > 0)
-        LoadImages(vector, MERGED);
+  if (vector.size() > 0)
+    LoadImages(vector, MERGED);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::MergeImagesWithTime() {
-    QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
-    Extensions += ";;All Files (*)";
-    QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images With Time"),mInputPathName,Extensions);
-    if (files.isEmpty())
-        return;
-    mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
-    std::vector<std::string> vector;
-
-    unsigned int currentDim = 0;
-    std::vector<double> currentSpacing;
-    std::vector<int> currentSize;
-    std::vector<double> currentOrigin;
-
-    for (int i = 0; i < files.size(); i++)
-    {
-        itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
-                                               files[i].toStdString().c_str(), itk::ImageIOFactory::ReadMode);
-        if (reader)
-        {
-            reader->SetFileName(files[i].toStdString().c_str());
-            reader->ReadImageInformation();
-            if (i == 0)
-                currentDim = reader->GetNumberOfDimensions();
-            bool IsOk = true;
-            for (unsigned int j = 0;j < currentDim; j++)
+  QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
+  Extensions += ";;All Files (*)";
+  QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images With Time"),mInputPathName,Extensions);
+  if (files.isEmpty())
+    return;
+  mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
+  std::vector<std::string> vector;
+
+  unsigned int currentDim = 0;
+  std::vector<double> currentSpacing;
+  std::vector<int> currentSize;
+  std::vector<double> currentOrigin;
+
+  for (int i = 0; i < files.size(); i++)
+    {
+      itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
+                                                                            files[i].toStdString().c_str(), itk::ImageIOFactory::ReadMode);
+      if (reader)
+        {
+          reader->SetFileName(files[i].toStdString().c_str());
+          reader->ReadImageInformation();
+          if (i == 0)
+            currentDim = reader->GetNumberOfDimensions();
+          bool IsOk = true;
+          for (unsigned int j = 0;j < currentDim; j++)
             {
-                if (i == 0)
+              if (i == 0)
                 {
-                    if (j == 0)
+                  if (j == 0)
                     {
-                        currentSpacing.resize(currentDim);
-                        currentSize.resize(currentDim);
-                        currentOrigin.resize(currentDim);
+                      currentSpacing.resize(currentDim);
+                      currentSize.resize(currentDim);
+                      currentOrigin.resize(currentDim);
                     }
-                    currentOrigin[j] = reader->GetOrigin(j);
-                    currentSpacing[j] = reader->GetSpacing(j);
-                    currentSize[j] = reader->GetDimensions(j);
+                  currentOrigin[j] = reader->GetOrigin(j);
+                  currentSpacing[j] = reader->GetSpacing(j);
+                  currentSize[j] = reader->GetDimensions(j);
                 }
-                else if (currentDim != reader->GetNumberOfDimensions()
-                         || currentSpacing[j] != reader->GetSpacing(j)
-                         || currentSize[j] != (int)reader->GetDimensions(j)
-                         || currentOrigin[j] != reader->GetOrigin(j))
+              else if (currentDim != reader->GetNumberOfDimensions()
+                       || currentSpacing[j] != reader->GetSpacing(j)
+                       || currentSize[j] != (int)reader->GetDimensions(j)
+                       || currentOrigin[j] != reader->GetOrigin(j))
                 {
-                    QString error = "Cannot read file (too different from others ";
-                    error += files[i].toStdString().c_str();
-                    QMessageBox::information(this,tr("Reading problem"),error);
-                    IsOk = false;
-                    break;
+                  QString error = "Cannot read file (too different from others ";
+                  error += files[i].toStdString().c_str();
+                  QMessageBox::information(this,tr("Reading problem"),error);
+                  IsOk = false;
+                  break;
                 }
             }
-            if (IsOk)
-                vector.push_back(files[i].toStdString());
+          if (IsOk)
+            vector.push_back(files[i].toStdString());
         }
-        else
+      else
         {
-            QString error = "Cannot read file info for ";
-            error += files[i].toStdString().c_str();
-            error += "\n";
-            error += "Maybe you're trying to open an image in an unsupported format?\n";
-            QMessageBox::information(this,tr("Reading problem"),error);
+          QString error = "Cannot read file info for ";
+          error += files[i].toStdString().c_str();
+          error += "\n";
+          error += "Maybe you're trying to open an image in an unsupported format?\n";
+          QMessageBox::information(this,tr("Reading problem"),error);
         }
     }
-    sort(vector.begin(),vector.end());
-    if (vector.size() > 1)
-        LoadImages(vector, MERGEDWITHTIME);
-    else
-        QMessageBox::warning(this,tr("Reading problem"),"You need to select at least two images to merge images with time.\nIf you only want to open one image, please use the \"Open Image\" function.");
+  sort(vector.begin(),vector.end());
+  if (vector.size() > 1)
+    LoadImages(vector, MERGEDWITHTIME);
+  else
+    QMessageBox::warning(this,tr("Reading problem"),"You need to select at least two images to merge images with time.\nIf you only want to open one image, please use the \"Open Image\" function.");
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::OpenDicom() {
-    std::vector<std::string> files;
+  std::vector<std::string> files;
 
 #ifdef CLITK_VV_USE_BDCM
-    bool r = bdcm::OpenDicomFilesSelectorDialog(files,
-             "DicomFilesSelectorDialog test",
-             0,0,800,800,1);
-
-    if (r) {
-        std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
-        std::cout << "$$$$ selected files : "<<std::endl;
-        std::vector<std::string>::iterator i;
-        for (i=files.begin();i!=files.end();++i) {
-            std::cout << *i << std::endl;
-        }
-        std::cout << "$$$$ "<<std::endl;
-
-        LoadImages(files,DICOM);
-    }
-    else {
-        std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
-    }
+  bool r = bdcm::OpenDicomFilesSelectorDialog(files,
+                                              "DicomFilesSelectorDialog test",
+                                              0,0,800,800,1);
+
+  if (r) {
+    std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
+    std::cout << "$$$$ selected files : "<<std::endl;
+    std::vector<std::string>::iterator i;
+    for (i=files.begin();i!=files.end();++i) {
+      std::cout << *i << std::endl;
+    }
+    std::cout << "$$$$ "<<std::endl;
+
+    LoadImages(files,DICOM);
+  }
+  else {
+    std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
+  }
 #else
-    std::cout << "dicomSeriesSelector " << std::endl;
-    if (dicomSeriesSelector->exec() == QDialog::Accepted) {
-        files = *(dicomSeriesSelector->GetFilenames());
-        LoadImages(files,DICOM);
-    }
+  std::cout << "dicomSeriesSelector " << std::endl;
+  if (dicomSeriesSelector->exec() == QDialog::Accepted) {
+    files = *(dicomSeriesSelector->GetFilenames());
+    LoadImages(files,DICOM);
+  }
 #endif
 
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::OpenImages() {
-    QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
-    Extensions += ";;All Files (*)";
-
-    QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Images"),mInputPathName,Extensions);
-    if (files.isEmpty())
-        return;
-    mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
-    std::vector<std::string> vector;
-    for (int i = 0; i < files.size(); i++)
-        vector.push_back(files[i].toStdString());
-    LoadImages(vector, IMAGE);
-}
-//====================================================================
+  QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
+  Extensions += ";;All Files (*)";
+
+  QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Images"),mInputPathName,Extensions);
+  if (files.isEmpty())
+    return;
+  mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
+  std::vector<std::string> vector;
+  for (int i = 0; i < files.size(); i++)
+    vector.push_back(files[i].toStdString());
+  LoadImages(vector, IMAGE);
+}
+//------------------------------------------------------------------------------
 void vvMainWindow::OpenRecentImage()
 {
-    QAction * caller = qobject_cast<QAction*>(sender());
-    std::vector<std::string> images;
-    images.push_back(caller->text().toStdString());
-    mInputPathName = itksys::SystemTools::GetFilenamePath(images[0]).c_str();
-    LoadImages(images,IMAGE);
+  QAction * caller = qobject_cast<QAction*>(sender());
+  std::vector<std::string> images;
+  images.push_back(caller->text().toStdString());
+  mInputPathName = itksys::SystemTools::GetFilenamePath(images[0]).c_str();
+  LoadImages(images,IMAGE);
 }
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::OpenImageWithTime() {
-    QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
-    Extensions += ";;All Files (*)";
+  QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
+  Extensions += ";;All Files (*)";
 
-    QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Images With Time"),mInputPathName,Extensions);
-    if (files.isEmpty())
-        return;
-    mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
-    std::vector<std::string> vector;
-    for (int i = 0; i < files.size(); i++)
+  QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Images With Time"),mInputPathName,Extensions);
+  if (files.isEmpty())
+    return;
+  mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
+  std::vector<std::string> vector;
+  for (int i = 0; i < files.size(); i++)
     {
-        vector.push_back(files[i].toStdString());
+      vector.push_back(files[i].toStdString());
     }
-    LoadImages(vector, IMAGEWITHTIME);
+  LoadImages(vector, IMAGEWITHTIME);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::LoadImages(std::vector<std::string> files, LoadedImageType filetype) {
-    //Separate the way to open images and dicoms
-    int fileSize;
-    if (filetype == IMAGE || filetype == IMAGEWITHTIME)
-        fileSize = files.size();
-    else
-        fileSize = 1;
+  //Separate the way to open images and dicoms
+  int fileSize;
+  if (filetype == IMAGE || filetype == IMAGEWITHTIME)
+    fileSize = files.size();
+  else
+    fileSize = 1;
+
+  //Only add to the list of recently opened files when a single file is opened,
+  //to avoid polluting the list of recently opened files
+  if (files.size() == 1)
+    {
+      QFileInfo finfo=tr(files[0].c_str());
+      AddToRecentlyOpenedImages(finfo.absoluteFilePath().toStdString());
+    }
+  //init the progress events
+  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+  vvProgressDialog progress("Opening " + files[0],fileSize>1);
+  qApp->processEvents();
+
+  int numberofsuccesulreads=0;
+  //open images as 1 or multiples
+  for (int i = 0; i < fileSize; i++) {
+
+    progress.Update("Opening " + files[i]);
+    progress.SetProgress(i,fileSize);
+    qApp->processEvents();
 
-    //Only add to the list of recently opened files when a single file is opened,
-    //to avoid polluting the list of recently opened files
-    if (files.size() == 1)
-    {
-        QFileInfo finfo=tr(files[0].c_str());
-        AddToRecentlyOpenedImages(finfo.absoluteFilePath().toStdString());
-    }
-    //init the progress events
-    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-    vvProgressDialog progress("Opening " + files[0],fileSize>1);
+    //read the image and put it in mSlicerManagers
+    vvSlicerManager* imageManager = new vvSlicerManager(4);
     qApp->processEvents();
 
-    int numberofsuccesulreads=0;
-    //open images as 1 or multiples
-    for (int i = 0; i < fileSize; i++) {
+    bool SetImageSucceed=false;
 
-        progress.Update("Opening " + files[i]);
-        progress.SetProgress(i,fileSize);
+    if (filetype == IMAGE || filetype == IMAGEWITHTIME)
+      SetImageSucceed = imageManager->SetImage(files[i],filetype);
+    else
+      {
+        SetImageSucceed = imageManager->SetImages(files,filetype);
+      }
+    if (SetImageSucceed == false)
+      {
+        QApplication::restoreOverrideCursor();
+        QString error = "Cannot open file \n";
+        error += imageManager->GetLastError().c_str();
+        QMessageBox::information(this,tr("Reading problem"),error);
+        delete imageManager;
+      }
+    else
+      {
+        mSlicerManagers.push_back(imageManager);
+
+        //create an item in the tree with good settings
+        QTreeWidgetItem *item = new QTreeWidgetItem();
+        item->setData(0,Qt::UserRole,files[i].c_str());
+        QFileInfo fileinfo(imageManager->GetFileName().c_str()); //Do not show the path
+        item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
         qApp->processEvents();
 
-        //read the image and put it in mSlicerManagers
-        vvSlicerManager* imageManager = new vvSlicerManager(4);
+        //Create the buttons for reload and close
         qApp->processEvents();
+        QTreePushButton* cButton = new QTreePushButton;
+        cButton->setItem(item);
+        cButton->setColumn(COLUMN_CLOSE_IMAGE);
+        cButton->setToolTip(tr("close image"));
+        cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
+        connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+                this,SLOT(CloseImage(QTreeWidgetItem*, int)));
 
-        bool SetImageSucceed=false;
+        QTreePushButton* rButton = new QTreePushButton;
+        rButton->setItem(item);
+        rButton->setColumn(COLUMN_RELOAD_IMAGE);
+        rButton->setToolTip(tr("reload image"));
+        rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
+        connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+                this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
 
-        if (filetype == IMAGE || filetype == IMAGEWITHTIME)
-            SetImageSucceed = imageManager->SetImage(files[i],filetype);
-        else
-        {
-            SetImageSucceed = imageManager->SetImages(files,filetype);
-        }
-        if (SetImageSucceed == false)
-        {
-            QApplication::restoreOverrideCursor();
-            QString error = "Cannot open file \n";
-            error += imageManager->GetLastError().c_str();
-            QMessageBox::information(this,tr("Reading problem"),error);
-            delete imageManager;
-        }
-        else
-        {
-            mSlicerManagers.push_back(imageManager);
-
-            //create an item in the tree with good settings
-            QTreeWidgetItem *item = new QTreeWidgetItem();
-            item->setData(0,Qt::UserRole,files[i].c_str());
-            QFileInfo fileinfo(imageManager->GetFileName().c_str()); //Do not show the path
-            item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
-            qApp->processEvents();
-
-            //Create the buttons for reload and close
-            qApp->processEvents();
-            QTreePushButton* cButton = new QTreePushButton;
-            cButton->setItem(item);
-            cButton->setColumn(COLUMN_CLOSE_IMAGE);
-            cButton->setToolTip(tr("close image"));
-            cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
-            connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-                    this,SLOT(CloseImage(QTreeWidgetItem*, int)));
-
-            QTreePushButton* rButton = new QTreePushButton;
-            rButton->setItem(item);
-            rButton->setColumn(COLUMN_RELOAD_IMAGE);
-            rButton->setToolTip(tr("reload image"));
-            rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
-            connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-                    this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
-
-            DataTree->addTopLevelItem(item);
-            DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
-            DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
-
-            //set the id of the image
-            QString id = files[i].c_str() + QString::number(mSlicerManagers.size()-1);
-            item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
-            mSlicerManagers.back()->SetId(id.toStdString());
-
-            linkPanel->addImage(imageManager->GetFileName(), id.toStdString());
-
-            connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
-                    this,SLOT(CurrentImageChanged(std::string)));
-            connect(mSlicerManagers.back(),SIGNAL(
-                        UpdatePosition(int, double, double, double, double, double, double, double)),this,
-                    SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
-            connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)),
-                    this, SLOT(VectorChanged(int,double,double,double, double)));
-            connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
-                    this, SLOT(OverlayChanged(int,double,double)));
-            connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
-                    this, SLOT(FusionChanged(int,double)));
-            connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
-                    this,SLOT(WindowsChanged(int, int, int)));
-            connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
-                    this,SLOT(WindowLevelChanged(double, double, int, int)));
-            connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
-                    this,SLOT(UpdateSlice(int,int)));
-            connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
-                    this,SLOT(UpdateTSlice(int, int)));
-            connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
-                    this,SLOT(UpdateSliceRange(int,int,int,int,int)));
-            connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
-                    this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
-            connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
-            InitSlicers();
-            numberofsuccesulreads++;
-        }
-    }
-    if (numberofsuccesulreads)
-    {
-        NOViewWidget->show();
-        NEViewWidget->show();
-        SOViewWidget->show();
-        SEViewWidget->show();
-        UpdateTree();
-        InitDisplay();
-        ShowLastImage();
-    }
-    QApplication::restoreOverrideCursor();
-}
-//====================================================================
+        DataTree->addTopLevelItem(item);
+        DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
+        DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
 
-//====================================================================
+        //set the id of the image
+        QString id = files[i].c_str() + QString::number(mSlicerManagers.size()-1);
+        item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
+        mSlicerManagers.back()->SetId(id.toStdString());
+
+        linkPanel->addImage(imageManager->GetFileName(), id.toStdString());
+
+        connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
+                this,SLOT(CurrentImageChanged(std::string)));
+        connect(mSlicerManagers.back(),SIGNAL(
+                                              UpdatePosition(int, double, double, double, double, double, double, double)),this,
+                SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
+        connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)),
+                this, SLOT(VectorChanged(int,double,double,double, double)));
+        connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
+                this, SLOT(OverlayChanged(int,double,double)));
+        connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
+                this, SLOT(FusionChanged(int,double)));
+        connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
+                this,SLOT(WindowsChanged(int, int, int)));
+        connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
+                this,SLOT(WindowLevelChanged(double, double, int, int)));
+        connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
+                this,SLOT(UpdateSlice(int,int)));
+        connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
+                this,SLOT(UpdateTSlice(int, int)));
+        connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
+                this,SLOT(UpdateSliceRange(int,int,int,int,int)));
+        connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
+                this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
+        connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
+        InitSlicers();
+        numberofsuccesulreads++;
+      }
+  }
+  if (numberofsuccesulreads)
+    {
+      NOViewWidget->show();
+      NEViewWidget->show();
+      SOViewWidget->show();
+      SEViewWidget->show();
+      UpdateTree();
+      InitDisplay();
+      ShowLastImage();
+    }
+  QApplication::restoreOverrideCursor();
+
+
+  // vvToolManager::GetInstance()->UpdateEnabledTool();
+  // emit SlicerManagersHasChanged();
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
 void vvMainWindow::UpdateTree() {
-    DataTree->resizeColumnToContents(COLUMN_TREE);
-    DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
-    DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
-    DataTree->resizeColumnToContents(COLUMN_DL_VIEW);
-    DataTree->resizeColumnToContents(COLUMN_DR_VIEW);
-    DataTree->resizeColumnToContents(COLUMN_IMAGE_NAME);
-    DataTree->resizeColumnToContents(COLUMN_CLOSE_IMAGE);
-    DataTree->resizeColumnToContents(COLUMN_RELOAD_IMAGE);
-}
-//====================================================================
-
-//====================================================================
+  DataTree->resizeColumnToContents(COLUMN_TREE);
+  DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
+  DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
+  DataTree->resizeColumnToContents(COLUMN_DL_VIEW);
+  DataTree->resizeColumnToContents(COLUMN_DR_VIEW);
+  DataTree->resizeColumnToContents(COLUMN_IMAGE_NAME);
+  DataTree->resizeColumnToContents(COLUMN_CLOSE_IMAGE);
+  DataTree->resizeColumnToContents(COLUMN_RELOAD_IMAGE);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
 void vvMainWindow::CurrentImageChanged(std::string id) {
-    int selected = 0;
-    for (int i = 0; i < DataTree->topLevelItemCount(); i++)
+  int selected = 0;
+  for (int i = 0; i < DataTree->topLevelItemCount(); i++)
     {
-        if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString().toStdString() == id)
+      if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString().toStdString() == id)
         {
-            selected = i;
+          selected = i;
         }
-        else
+      else
         {
-            DataTree->topLevelItem(i)->setSelected(0);
+          DataTree->topLevelItem(i)->setSelected(0);
         }
-        for (int child = 0; child < DataTree->topLevelItem(i)->childCount();child++)
-            DataTree->topLevelItem(i)->child(child)->setSelected(0);
+      for (int child = 0; child < DataTree->topLevelItem(i)->childCount();child++)
+        DataTree->topLevelItem(i)->child(child)->setSelected(0);
 
     }
-    DataTree->topLevelItem(selected)->setSelected(1);
+  DataTree->topLevelItem(selected)->setSelected(1);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::ImageInfoChanged() {
-    contextActions[7]->setEnabled(1);
-    contextActions[6]->setEnabled(1);
-    actionSave_As->setEnabled(1);
-    actionAdd_VF_to_current_Image->setEnabled(1);
-    actionAdd_fusion_image->setEnabled(1);
-    actionNorth_East_Window->setEnabled(1);
-    actionNorth_West_Window->setEnabled(1);
-    actionSouth_East_Window->setEnabled(1);
-    actionSouth_West_Window->setEnabled(1);
-    inverseButton->setEnabled(1);
-
-    goToCursorPushButton->setEnabled(1);
-
-    if (DataTree->selectedItems().size()) {
-        int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-
-        colorMapComboBox->setEnabled(1);
-        for (int i = 0; i < DataTree->topLevelItem(index)->childCount();i++)
-        {
-            if (DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "overlay" ||
-                    DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusion")
-            {
-                colorMapComboBox->setEnabled(0);
-                break;
-            }
-        }
-
-        std::vector<double> origin;
-        std::vector<double> inputSpacing;
-        std::vector<int> inputSize;
-        std::vector<double> sizeMM;
-        int dimension=0;
-        QString pixelType;
-        QString inputSizeInBytes;
-        QString image = DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-
-        if (mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size() > 1 || playMode == 1)
-        {
-            playButton->setEnabled(1);
-            frameRateLabel->setEnabled(1);
-            frameRateSpinBox->setEnabled(1);
-        }
-        else
-        {
-            playButton->setEnabled(0);
-            frameRateLabel->setEnabled(0);
-            frameRateSpinBox->setEnabled(0);
-        }
-
-        //read image header
-        int NPixel = 1;
-
-        if (DataTree->topLevelItem(index) == DataTree->selectedItems()[0])
-        {
-            vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
-            dimension = imageSelected->GetNumberOfDimensions();
-            origin.resize(dimension);
-            inputSpacing.resize(dimension);
-            inputSize.resize(dimension);
-            sizeMM.resize(dimension);
-            pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsString().c_str();
-            for (int i = 0;i < dimension;i++)
-            {
-                origin[i] = imageSelected->GetOrigin()[i];
-                inputSpacing[i] = imageSelected->GetSpacing()[i];
-                inputSize[i] = imageSelected->GetSize()[i];
-                sizeMM[i] = inputSize[i]*inputSpacing[i];
-                NPixel *= inputSize[i];
-            }
-            inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
-        }
-        else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector")
-        {
-            vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetVF();
-            dimension = imageSelected->GetNumberOfDimensions();
-            origin.resize(dimension);
-            inputSpacing.resize(dimension);
-            inputSize.resize(dimension);
-            sizeMM.resize(dimension);
-            pixelType = mSlicerManagers[index]->GetVF()->GetScalarTypeAsString().c_str();
-            for (int i = 0;i < dimension;i++)
-            {
-                origin[i] = imageSelected->GetOrigin()[i];
-                inputSpacing[i] = imageSelected->GetSpacing()[i];
-                inputSize[i] = imageSelected->GetSize()[i];
-                sizeMM[i] = inputSize[i]*inputSpacing[i];
-                NPixel *= inputSize[i];
-            }
-            inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
-        }
-        else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "overlay")
-        {
-            vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetOverlay();
-            dimension = imageSelected->GetNumberOfDimensions();
-            origin.resize(dimension);
-            inputSpacing.resize(dimension);
-            inputSize.resize(dimension);
-            sizeMM.resize(dimension);
-            pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsString().c_str();
-            for (int i = 0;i < dimension;i++)
-            {
-                origin[i] = imageSelected->GetOrigin()[i];
-                inputSpacing[i] = imageSelected->GetSpacing()[i];
-                inputSize[i] = imageSelected->GetSize()[i];
-                sizeMM[i] = inputSize[i]*inputSpacing[i];
-                NPixel *= inputSize[i];
-            }
-            inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
-        }
-        else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "fusion")
-        {
-            vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion();
-            dimension = imageSelected->GetNumberOfDimensions();
-            origin.resize(dimension);
-            inputSpacing.resize(dimension);
-            inputSize.resize(dimension);
-            sizeMM.resize(dimension);
-            pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsString().c_str();
-            for (int i = 0;i < dimension;i++)
-            {
-                origin[i] = imageSelected->GetOrigin()[i];
-                inputSpacing[i] = imageSelected->GetSpacing()[i];
-                inputSize[i] = imageSelected->GetSize()[i];
-                sizeMM[i] = inputSize[i]*inputSpacing[i];
-                NPixel *= inputSize[i];
-            }
-            inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
-        }
+  contextActions[7]->setEnabled(1);
+  contextActions[6]->setEnabled(1);
+  actionSave_As->setEnabled(1);
+  actionAdd_VF_to_current_Image->setEnabled(1);
+  actionAdd_fusion_image->setEnabled(1);
+  actionNorth_East_Window->setEnabled(1);
+  actionNorth_West_Window->setEnabled(1);
+  actionSouth_East_Window->setEnabled(1);
+  actionSouth_West_Window->setEnabled(1);
+  inverseButton->setEnabled(1);
+
+  goToCursorPushButton->setEnabled(1);
+
+  if (DataTree->selectedItems().size()) {
+    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
-        QString dim = QString::number(dimension) + " (";
-        dim += pixelType + ")";
+    colorMapComboBox->setEnabled(1);
+    for (int i = 0; i < DataTree->topLevelItem(index)->childCount();i++)
+      {
+        if (DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "overlay" ||
+            DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusion")
+          {
+            colorMapComboBox->setEnabled(0);
+            break;
+          }
+      }
+
+    std::vector<double> origin;
+    std::vector<double> inputSpacing;
+    std::vector<int> inputSize;
+    std::vector<double> sizeMM;
+    int dimension=0;
+    QString pixelType;
+    QString inputSizeInBytes;
+    QString image = DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
+
+    if (mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size() > 1 || playMode == 1)
+      {
+        playButton->setEnabled(1);
+        frameRateLabel->setEnabled(1);
+        frameRateSpinBox->setEnabled(1);
+      }
+    else
+      {
+        playButton->setEnabled(0);
+        frameRateLabel->setEnabled(0);
+        frameRateSpinBox->setEnabled(0);
+      }
+
+    //read image header
+    int NPixel = 1;
+
+    if (DataTree->topLevelItem(index) == DataTree->selectedItems()[0])
+      {
+        vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
+        dimension = imageSelected->GetNumberOfDimensions();
+        origin.resize(dimension);
+        inputSpacing.resize(dimension);
+        inputSize.resize(dimension);
+        sizeMM.resize(dimension);
+        pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsString().c_str();
+        for (int i = 0;i < dimension;i++)
+          {
+            origin[i] = imageSelected->GetOrigin()[i];
+            inputSpacing[i] = imageSelected->GetSpacing()[i];
+            inputSize[i] = imageSelected->GetSize()[i];
+            sizeMM[i] = inputSize[i]*inputSpacing[i];
+            NPixel *= inputSize[i];
+          }
+        inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
+      }
+    else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector")
+      {
+        vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetVF();
+        dimension = imageSelected->GetNumberOfDimensions();
+        origin.resize(dimension);
+        inputSpacing.resize(dimension);
+        inputSize.resize(dimension);
+        sizeMM.resize(dimension);
+        pixelType = mSlicerManagers[index]->GetVF()->GetScalarTypeAsString().c_str();
+        for (int i = 0;i < dimension;i++)
+          {
+            origin[i] = imageSelected->GetOrigin()[i];
+            inputSpacing[i] = imageSelected->GetSpacing()[i];
+            inputSize[i] = imageSelected->GetSize()[i];
+            sizeMM[i] = inputSize[i]*inputSpacing[i];
+            NPixel *= inputSize[i];
+          }
+        inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
+      }
+    else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "overlay")
+      {
+        vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetOverlay();
+        dimension = imageSelected->GetNumberOfDimensions();
+        origin.resize(dimension);
+        inputSpacing.resize(dimension);
+        inputSize.resize(dimension);
+        sizeMM.resize(dimension);
+        pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsString().c_str();
+        for (int i = 0;i < dimension;i++)
+          {
+            origin[i] = imageSelected->GetOrigin()[i];
+            inputSpacing[i] = imageSelected->GetSpacing()[i];
+            inputSize[i] = imageSelected->GetSize()[i];
+            sizeMM[i] = inputSize[i]*inputSpacing[i];
+            NPixel *= inputSize[i];
+          }
+        inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
+      }
+    else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "fusion")
+      {
+        vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion();
+        dimension = imageSelected->GetNumberOfDimensions();
+        origin.resize(dimension);
+        inputSpacing.resize(dimension);
+        inputSize.resize(dimension);
+        sizeMM.resize(dimension);
+        pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsString().c_str();
+        for (int i = 0;i < dimension;i++)
+          {
+            origin[i] = imageSelected->GetOrigin()[i];
+            inputSpacing[i] = imageSelected->GetSpacing()[i];
+            inputSize[i] = imageSelected->GetSize()[i];
+            sizeMM[i] = inputSize[i]*inputSpacing[i];
+            NPixel *= inputSize[i];
+          }
+        inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
+      }
+
+    QString dim = QString::number(dimension) + " (";
+    dim += pixelType + ")";
+
+    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());
+    DD(mSlicerManagers[index]->GetColorMap());
+    DD(mSlicerManagers[index]->GetPreset());
+    presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
+    colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
 
         infoPanel->setFileName(image);
         infoPanel->setDimension(dim);
@@ -1090,846 +1138,858 @@ void vvMainWindow::ImageInfoChanged() {
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::ShowDocumentation() {
-    documentation->show();
+  documentation->show();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::ShowHelpDialog() {
-    help_dialog->show();
+  help_dialog->show();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::ChangeViewMode() {
-    QListIterator<int> it0(splitter_3->sizes());
-    QListIterator<int> it1(splitter_3->sizes());
-    int max0 = 0;
-    int max1 = 1;
-    while (it0.hasNext())
-    {
-        max0 += it0.next();
-    }
-    while (it1.hasNext())
-    {
-        max1 += it1.next();
-    }
-    QList<int> size0;
-    QList<int> size1;
-    if (viewMode == 1)
-    {
-        viewMode = 0;
-        size0.push_back(max0);
-        size0.push_back(0);
-        size1.push_back(max1);
-        size1.push_back(0);
-        splitter_3->setSizes(size0);
-        OSplitter->setSizes(size1);
-        DataTree->setColumnHidden(2,1);
-        DataTree->setColumnHidden(3,1);
-        DataTree->setColumnHidden(4,1);
-    }
-    else
-    {
-        viewMode = 1;
-        size0.push_back(int(max0/2));
-        size0.push_back(int(max0/2));
-        size1.push_back(int(max1/2));
-        size1.push_back(int(max1/2));
-        splitter_3->setSizes(size0);
-        OSplitter->setSizes(size1);
-        DataTree->setColumnHidden(2,0);
-        DataTree->setColumnHidden(3,0);
-        DataTree->setColumnHidden(4,0);
-    }
-}
-//====================================================================
-
-//====================================================================
+  QListIterator<int> it0(splitter_3->sizes());
+  QListIterator<int> it1(splitter_3->sizes());
+  int max0 = 0;
+  int max1 = 1;
+  while (it0.hasNext())
+    {
+      max0 += it0.next();
+    }
+  while (it1.hasNext())
+    {
+      max1 += it1.next();
+    }
+  QList<int> size0;
+  QList<int> size1;
+  if (viewMode == 1)
+    {
+      viewMode = 0;
+      size0.push_back(max0);
+      size0.push_back(0);
+      size1.push_back(max1);
+      size1.push_back(0);
+      splitter_3->setSizes(size0);
+      OSplitter->setSizes(size1);
+      DataTree->setColumnHidden(2,1);
+      DataTree->setColumnHidden(3,1);
+      DataTree->setColumnHidden(4,1);
+    }
+  else
+    {
+      viewMode = 1;
+      size0.push_back(int(max0/2));
+      size0.push_back(int(max0/2));
+      size1.push_back(int(max1/2));
+      size1.push_back(int(max1/2));
+      splitter_3->setSizes(size0);
+      OSplitter->setSizes(size1);
+      DataTree->setColumnHidden(2,0);
+      DataTree->setColumnHidden(3,0);
+      DataTree->setColumnHidden(4,0);
+    }
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
 QString vvMainWindow::GetSizeInBytes(unsigned long size) {
-    QString result = "";// QString::number(size);
-    //result += " bytes (";
-    if (size > 1000000000)
+  QString result = "";// QString::number(size);
+  //result += " bytes (";
+  if (size > 1000000000)
     {
-        size /= 1000000000;
-        result += QString::number(size);
-        result += "Gb";//)";
+      size /= 1000000000;
+      result += QString::number(size);
+      result += "Gb";//)";
     }
-    else if (size > 1000000)
+  else if (size > 1000000)
     {
-        size /= 1000000;
-        result += QString::number(size);
-        result += "Mb";//)";
+      size /= 1000000;
+      result += QString::number(size);
+      result += "Mb";//)";
     }
-    else if (size > 1000)
+  else if (size > 1000)
     {
-        size /= 1000;
-        result += QString::number(size);
-        result += "kb";//)";
+      size /= 1000;
+      result += QString::number(size);
+      result += "kb";//)";
     }
-    return result;
+  return result;
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 QString vvMainWindow::GetVectorDoubleAsString(std::vector<double> vectorDouble) {
-    QString result;
-    for (unsigned int i= 0; i < vectorDouble.size(); i++)
+  QString result;
+  for (unsigned int i= 0; i < vectorDouble.size(); i++)
     {
-        if (i != 0)
-            result += " ";
-        result += QString::number(vectorDouble[i]);
+      if (i != 0)
+        result += " ";
+      result += QString::number(vectorDouble[i]);
     }
-    return result;
+  return result;
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 QString vvMainWindow::GetVectorIntAsString(std::vector<int> vectorInt) {
-    QString result;
-    for (unsigned int i= 0; i < vectorInt.size(); i++)
+  QString result;
+  for (unsigned int i= 0; i < vectorInt.size(); i++)
     {
-        if (i != 0)
-            result += " ";
-        result += QString::number(vectorInt[i]);
+      if (i != 0)
+        result += " ";
+      result += QString::number(vectorInt[i]);
     }
-    return result;
+  return result;
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 int vvMainWindow::GetSlicerIndexFromItem(QTreeWidgetItem* item) {
-    QString id = item->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
-    for (int i = 0; i < DataTree->topLevelItemCount(); i++)
+  QString id = item->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
+  for (int i = 0; i < DataTree->topLevelItemCount(); i++)
     {
-        if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
-            return i;
+      if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
+        return i;
     }
-    return -1;
+  return -1;
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::DisplayChanged(QTreeWidgetItem *clicked_item, int column) {
-    int index = GetSlicerIndexFromItem(clicked_item);
-    if ( column >= COLUMN_CLOSE_IMAGE or column <= 0)
-        return;
-    for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
+  int index = GetSlicerIndexFromItem(clicked_item);
+  if ( column >= COLUMN_CLOSE_IMAGE or column <= 0)
+    return;
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
     {
-        QTreeWidgetItem* current_row=DataTree->topLevelItem(i);
-        if (DataTree->topLevelItem(index) == current_row)
+      QTreeWidgetItem* current_row=DataTree->topLevelItem(i);
+      if (DataTree->topLevelItem(index) == current_row)
         {
-            vvSlicer* clicked_slicer=mSlicerManagers[i]->GetSlicer(column-1);
-            if (current_row == clicked_item) 
+          vvSlicer* clicked_slicer=mSlicerManagers[i]->GetSlicer(column-1);
+          if (current_row == clicked_item) 
             {
-                //If we just activated a slicer
-                if (current_row->data(column,Qt::CheckStateRole).toInt() > 0)
+              //If we just activated a slicer
+              if (current_row->data(column,Qt::CheckStateRole).toInt() > 0)
                 {
-                    mSlicerManagers[i]->UpdateSlicer(column-1,clicked_item->data(column,Qt::CheckStateRole).toInt());
-                    mSlicerManagers[i]->UpdateInfoOnCursorPosition(column-1);
-                    DisplaySliders(i,column-1);
-                    std::map<std::string,int> overlay_counts;
-                    for (int child = 0; child < current_row->childCount(); child++)
+                  mSlicerManagers[i]->UpdateSlicer(column-1,clicked_item->data(column,Qt::CheckStateRole).toInt());
+                  mSlicerManagers[i]->UpdateInfoOnCursorPosition(column-1);
+                  DisplaySliders(i,column-1);
+                  std::map<std::string,int> overlay_counts;
+                  for (int child = 0; child < current_row->childCount(); child++)
                     {
-                        std::string overlay_type = 
-                            current_row->child(child)->data(1,Qt::UserRole).toString().toStdString();
-                        overlay_counts[overlay_type]++;
-                        current_row->child(child)->setData(column,Qt::CheckStateRole,
-                                current_row->data(column,Qt::CheckStateRole));
-                        clicked_slicer->SetActorVisibility(overlay_type,overlay_counts[overlay_type]-1,true);
+                      std::string overlay_type = 
+                        current_row->child(child)->data(1,Qt::UserRole).toString().toStdString();
+                      overlay_counts[overlay_type]++;
+                      current_row->child(child)->setData(column,Qt::CheckStateRole,
+                                                         current_row->data(column,Qt::CheckStateRole));
+                      clicked_slicer->SetActorVisibility(overlay_type,overlay_counts[overlay_type]-1,true);
                     }
                 }
-                else //We don't allow simply desactivating a slicer
+              else //We don't allow simply desactivating a slicer
                 {
-                    clicked_item->setData(column,Qt::CheckStateRole,2);
-                    return;
+                  clicked_item->setData(column,Qt::CheckStateRole,2);
+                  return;
                 }
             }
-            //if we clicked on the vector(or overlay) and not the image
-            else
+          //if we clicked on the vector(or overlay) and not the image
+          else
             {
-                if (clicked_item->data(column,Qt::CheckStateRole).toInt())
+              if (clicked_item->data(column,Qt::CheckStateRole).toInt())
                 {
-                    current_row->setData(column,Qt::CheckStateRole,2);
-                    mSlicerManagers[i]->UpdateSlicer(column-1,2);
-                    mSlicerManagers[i]->UpdateInfoOnCursorPosition(column-1);
-                    DisplaySliders(i,column-1);
+                  current_row->setData(column,Qt::CheckStateRole,2);
+                  mSlicerManagers[i]->UpdateSlicer(column-1,2);
+                  mSlicerManagers[i]->UpdateInfoOnCursorPosition(column-1);
+                  DisplaySliders(i,column-1);
                 }
-                int vis = clicked_item->data(column,Qt::CheckStateRole).toInt();
-                std::string overlay_type = clicked_item->data(1,Qt::UserRole).toString().toStdString();
-                int overlay_index=0;
-                for (int child = 0; child < current_row->childCount(); child++)
+              int vis = clicked_item->data(column,Qt::CheckStateRole).toInt();
+              std::string overlay_type = clicked_item->data(1,Qt::UserRole).toString().toStdString();
+              int overlay_index=0;
+              for (int child = 0; child < current_row->childCount(); child++)
                 {
-                    if (current_row->child(child)->data(1,Qt::UserRole).toString().toStdString() == overlay_type)
-                        overlay_index++;
-                    if (current_row->child(child) == clicked_item) break;
+                  if (current_row->child(child)->data(1,Qt::UserRole).toString().toStdString() == overlay_type)
+                    overlay_index++;
+                  if (current_row->child(child) == clicked_item) break;
                 }
-                clicked_slicer->SetActorVisibility(
-                        clicked_item->data(1,Qt::UserRole).toString().toStdString(), overlay_index-1,vis);
+              clicked_slicer->SetActorVisibility(
+                                                 clicked_item->data(1,Qt::UserRole).toString().toStdString(), overlay_index-1,vis);
             }
         }
-        else if (current_row->data(column,Qt::CheckStateRole).toInt() > 0)
+      else if (current_row->data(column,Qt::CheckStateRole).toInt() > 0)
         {
-            current_row->setData(column,Qt::CheckStateRole,0);
-            mSlicerManagers[i]->UpdateSlicer(column-1,0);
-            std::map<std::string,int> overlay_counts;
-            for (int child = 0; child < current_row->childCount(); child++)
+          current_row->setData(column,Qt::CheckStateRole,0);
+          mSlicerManagers[i]->UpdateSlicer(column-1,0);
+          std::map<std::string,int> overlay_counts;
+          for (int child = 0; child < current_row->childCount(); child++)
             {
-                std::string overlay_type = 
-                    current_row->child(child)->data(1,Qt::UserRole).toString().toStdString();
-                overlay_counts[overlay_type]++;
-                current_row->child(child)->setData(column,Qt::CheckStateRole,0);
-                vvSlicer * current_slicer=mSlicerManagers[i]->GetSlicer(column-1);
-                current_slicer->SetActorVisibility(overlay_type,overlay_counts[overlay_type]-1,false);
+              std::string overlay_type = 
+                current_row->child(child)->data(1,Qt::UserRole).toString().toStdString();
+              overlay_counts[overlay_type]++;
+              current_row->child(child)->setData(column,Qt::CheckStateRole,0);
+              vvSlicer * current_slicer=mSlicerManagers[i]->GetSlicer(column-1);
+              current_slicer->SetActorVisibility(overlay_type,overlay_counts[overlay_type]-1,false);
             }
         }
-        mSlicerManagers[i]->SetColorMap();
+      //mSlicerManagers[i]->SetColorMap(-1);
+      mSlicerManagers[i]->SetColorMap();
     }
-    mSlicerManagers[index]->GetSlicer(column-1)->Render();
+  mSlicerManagers[index]->GetSlicer(column-1)->Render();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
 void vvMainWindow::InitSlicers()
 {
-    if (mSlicerManagers.size())
+  if (mSlicerManagers.size())
     {
-        mSlicerManagers.back()->GenerateDefaultLookupTable();
+      mSlicerManagers.back()->GenerateDefaultLookupTable();
 
-        mSlicerManagers.back()->SetSlicerWindow(0,NOViewWidget->GetRenderWindow());
-        mSlicerManagers.back()->SetSlicerWindow(1,NEViewWidget->GetRenderWindow());
-        mSlicerManagers.back()->SetSlicerWindow(2,SOViewWidget->GetRenderWindow());
-        mSlicerManagers.back()->SetSlicerWindow(3,SEViewWidget->GetRenderWindow());
+      mSlicerManagers.back()->SetSlicerWindow(0,NOViewWidget->GetRenderWindow());
+      mSlicerManagers.back()->SetSlicerWindow(1,NEViewWidget->GetRenderWindow());
+      mSlicerManagers.back()->SetSlicerWindow(2,SOViewWidget->GetRenderWindow());
+      mSlicerManagers.back()->SetSlicerWindow(3,SEViewWidget->GetRenderWindow());
     }
 }
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::InitDisplay() {
-    if (mSlicerManagers.size())
+  if (mSlicerManagers.size())
     {
-        //BE CAREFUL : this is absolutely necessary to set the interactor style
-        //in order to have the same style instanciation for all SlicerManagers in
-        // a same window
-        for (int j = 0; j < 4; j++)
+      //BE CAREFUL : this is absolutely necessary to set the interactor style
+      //in order to have the same style instanciation for all SlicerManagers in
+      // a same window
+      for (int j = 0; j < 4; j++)
         {
-            vvInteractorStyleNavigator* style = vvInteractorStyleNavigator::New();
-            style->SetAutoAdjustCameraClippingRange(1);
-            bool AlreadySelected = false;
-            for (int i = 0; i < DataTree->topLevelItemCount(); i++)
+          vvInteractorStyleNavigator* style = vvInteractorStyleNavigator::New();
+          style->SetAutoAdjustCameraClippingRange(1);
+          bool AlreadySelected = false;
+          for (int i = 0; i < DataTree->topLevelItemCount(); i++)
             {
-                mSlicerManagers[i]->SetInteractorStyleNavigator(j,style);
+              mSlicerManagers[i]->SetInteractorStyleNavigator(j,style);
 
-                //select the image only if previous are not selected
-                if (DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 1)
+              //select the image only if previous are not selected
+              if (DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 1)
                 {
-                    mSlicerManagers[i]->UpdateSlicer(j,1);
-                    AlreadySelected = true;
+                  mSlicerManagers[i]->UpdateSlicer(j,1);
+                  AlreadySelected = true;
                 }
-                else if (i == DataTree->topLevelItemCount()-1 && !AlreadySelected)
+              else if (i == DataTree->topLevelItemCount()-1 && !AlreadySelected)
                 {
-                    if (DataTree->selectedItems().size() == 0)
-                        DataTree->topLevelItem(i)->setSelected(1);
-                    DataTree->topLevelItem(i)->setData(j+1,Qt::CheckStateRole,2);
-                    mSlicerManagers[i]->UpdateSlicer(j,1);
-                    DisplaySliders(i,j);
+                  if (DataTree->selectedItems().size() == 0)
+                    DataTree->topLevelItem(i)->setSelected(1);
+                  DataTree->topLevelItem(i)->setData(j+1,Qt::CheckStateRole,2);
+                  mSlicerManagers[i]->UpdateSlicer(j,1);
+                  DisplaySliders(i,j);
                 }
-                else
+              else
                 {
-                    DataTree->topLevelItem(i)->setData(j+1,Qt::CheckStateRole,0);
-                    mSlicerManagers[i]->UpdateSlicer(j,0);
+                  DataTree->topLevelItem(i)->setData(j+1,Qt::CheckStateRole,0);
+                  mSlicerManagers[i]->UpdateSlicer(j,0);
                 }
             }
-            style->Delete();
+          style->Delete();
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::DisplaySliders(int slicer, int window) {
-    int range[2];
-    mSlicerManagers[slicer]->GetSlicer(window)->GetSliceRange(range);
-    int position = mSlicerManagers[slicer]->GetSlicer(window)->GetSlice();
-
-    int tRange[2];
-    tRange[0] = 0;
-    tRange[1] = mSlicerManagers[slicer]->GetSlicer(window)->GetTMax();
-    int tPosition = mSlicerManagers[slicer]->GetSlicer(window)->GetTSlice();
-    bool showHorizontal = false;
-    bool showVertical = false;
-    if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3
-            || (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 2
-                && mSlicerManagers[slicer]->GetType() != IMAGEWITHTIME
-                && mSlicerManagers[slicer]->GetType() != MERGEDWITHTIME))
-        showVertical = true;
-    if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3
-            || mSlicerManagers[slicer]->GetType() == IMAGEWITHTIME
-            || mSlicerManagers[slicer]->GetType() == MERGEDWITHTIME)
-        showHorizontal = true;
-
-    if (showVertical)
-        verticalSliders[window]->show();
-    else
-        verticalSliders[window]->hide();
-    verticalSliders[window]->setRange(range[0],range[1]);
-    verticalSliders[window]->setValue(position);
-
-    if (showHorizontal)
-        horizontalSliders[window]->show();
-    else
-        horizontalSliders[window]->hide();
-    horizontalSliders[window]->setRange(tRange[0],tRange[1]);
-    horizontalSliders[window]->setValue(tPosition);
-}
-//====================================================================
-
-//====================================================================
+  int range[2];
+  mSlicerManagers[slicer]->GetSlicer(window)->GetSliceRange(range);
+  int position = mSlicerManagers[slicer]->GetSlicer(window)->GetSlice();
+
+  int tRange[2];
+  tRange[0] = 0;
+  tRange[1] = mSlicerManagers[slicer]->GetSlicer(window)->GetTMax();
+  int tPosition = mSlicerManagers[slicer]->GetSlicer(window)->GetTSlice();
+  bool showHorizontal = false;
+  bool showVertical = false;
+  if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3
+      || (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 2
+          && mSlicerManagers[slicer]->GetType() != IMAGEWITHTIME
+          && mSlicerManagers[slicer]->GetType() != MERGEDWITHTIME))
+    showVertical = true;
+  if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3
+      || mSlicerManagers[slicer]->GetType() == IMAGEWITHTIME
+      || mSlicerManagers[slicer]->GetType() == MERGEDWITHTIME)
+    showHorizontal = true;
+
+  if (showVertical)
+    verticalSliders[window]->show();
+  else
+    verticalSliders[window]->hide();
+  verticalSliders[window]->setRange(range[0],range[1]);
+  verticalSliders[window]->setValue(position);
+
+  if (showHorizontal)
+    horizontalSliders[window]->show();
+  else
+    horizontalSliders[window]->hide();
+  horizontalSliders[window]->setRange(tRange[0],tRange[1]);
+  horizontalSliders[window]->setValue(tPosition);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
 void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) {
-    int index = GetSlicerIndexFromItem(item);
+  int index = GetSlicerIndexFromItem(item);
 
-    if (DataTree->topLevelItem(index) != item)
+  if (DataTree->topLevelItem(index) != item)
     {
-        QString warning = "Do you really want to close the overlay : ";
-        warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-        QMessageBox msgBox(QMessageBox::Warning, tr("Close Overlay"),
-                           warning, 0, this);
-        msgBox.addButton(tr("Close"), QMessageBox::AcceptRole);
-        msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
-        if (msgBox.exec() == QMessageBox::AcceptRole)
+      QString warning = "Do you really want to close the overlay : ";
+      warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
+      QMessageBox msgBox(QMessageBox::Warning, tr("Close Overlay"),
+                         warning, 0, this);
+      msgBox.addButton(tr("Close"), QMessageBox::AcceptRole);
+      msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
+      if (msgBox.exec() == QMessageBox::AcceptRole)
         {
-            std::string overlay_type=item->data(1,Qt::UserRole).toString().toStdString();
-            int overlay_index=0;
-            for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
+          std::string overlay_type=item->data(1,Qt::UserRole).toString().toStdString();
+          int overlay_index=0;
+          for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
             {
-                if (DataTree->topLevelItem(index)->\
-                        child(child)->data(1,Qt::UserRole).toString().toStdString() == overlay_type)
-                    overlay_index++;
-                if (DataTree->topLevelItem(index)->child(child) == item) break;
+              if (DataTree->topLevelItem(index)->\
+                  child(child)->data(1,Qt::UserRole).toString().toStdString() == overlay_type)
+                overlay_index++;
+              if (DataTree->topLevelItem(index)->child(child) == item) break;
             }
-            mSlicerManagers[index]->RemoveActor(overlay_type, overlay_index-1);
-            mSlicerManagers[index]->SetColorMap(0);
-            DataTree->topLevelItem(index)->takeChild(DataTree->topLevelItem(index)->indexOfChild(item));
-            mSlicerManagers[index]->Render();
+          mSlicerManagers[index]->RemoveActor(overlay_type, overlay_index-1);
+          mSlicerManagers[index]->SetColorMap(0);
+          DataTree->topLevelItem(index)->takeChild(DataTree->topLevelItem(index)->indexOfChild(item));
+          mSlicerManagers[index]->Render();
         }
     }
-    else if (DataTree->topLevelItemCount() <= 1)
+  else if (DataTree->topLevelItemCount() <= 1)
     {
-        QString warning = "Do you really want to close the image : ";
-        warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-        warning += "\nThis is the last image, you're about to close vv !!!";
-        QMessageBox msgBox(QMessageBox::Warning, tr("Close Image"),
-                           warning, 0, this);
-        msgBox.addButton(tr("Close vv"), QMessageBox::AcceptRole);
-        msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
-        if (msgBox.exec() == QMessageBox::AcceptRole)
+      QString warning = "Do you really want to close the image : ";
+      warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
+      warning += "\nThis is the last image, you're about to close vv !!!";
+      QMessageBox msgBox(QMessageBox::Warning, tr("Close Image"),
+                         warning, 0, this);
+      msgBox.addButton(tr("Close vv"), QMessageBox::AcceptRole);
+      msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
+      if (msgBox.exec() == QMessageBox::AcceptRole)
         {
-            this->close();
+          this->close();
         }
     }
-    else
+  else
     {
-        QString warning = "Do you really want to close the image : ";
-        warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-        QMessageBox msgBox(QMessageBox::Warning, tr("Close Image"),
-                           warning, 0, this);
-        msgBox.addButton(tr("Close"), QMessageBox::AcceptRole);
-        msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
-        if (msgBox.exec() == QMessageBox::AcceptRole)
+      QString warning = "Do you really want to close the image : ";
+      warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
+      QMessageBox msgBox(QMessageBox::Warning, tr("Close Image"),
+                         warning, 0, this);
+      msgBox.addButton(tr("Close"), QMessageBox::AcceptRole);
+      msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
+      if (msgBox.exec() == QMessageBox::AcceptRole)
         {
-            std::vector<vvSlicerManager*>::iterator Manageriter = mSlicerManagers.begin();
-            DataTree->takeTopLevelItem(index);
-            for (int i = 0; i < index; i++)
+          std::vector<vvSlicerManager*>::iterator Manageriter = mSlicerManagers.begin();
+          DataTree->takeTopLevelItem(index);
+          for (int i = 0; i < index; i++)
             {
-                Manageriter++;
+              Manageriter++;
             }
-            linkPanel->removeImage(index);
-            mSlicerManagers[index]->RemoveActors();
-            delete mSlicerManagers[index];
-            mSlicerManagers.erase(Manageriter);
-            InitDisplay();
+          linkPanel->removeImage(index);
+          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));
-    QString role=item->data(1,Qt::UserRole).toString();
-    if ( role == "vector")
-        mSlicerManagers[index]->ReloadVF();
-    else if (role == "overlay")
-        mSlicerManagers[index]->ReloadOverlay();
-    else if (role == "fusion")
-        mSlicerManagers[index]->ReloadFusion();
-    else
-        mSlicerManagers[index]->Reload();
-    QApplication::restoreOverrideCursor();
-}
-//====================================================================
+  // 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::restoreOverrideCursor();
+  int index = GetSlicerIndexFromItem(item);
+  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+  QString role=item->data(1,Qt::UserRole).toString();
+  if ( role == "vector")
+    mSlicerManagers[index]->ReloadVF();
+  else if (role == "overlay")
+    mSlicerManagers[index]->ReloadOverlay();
+  else if (role == "fusion")
+    mSlicerManagers[index]->ReloadFusion();
+  else
+    mSlicerManagers[index]->Reload();
+  QApplication::restoreOverrideCursor();  
+}
+//------------------------------------------------------------------------------
 
 void vvMainWindow::CropImage()
 {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    vvCropDialog crop(mSlicerManagers,index);
-    if(crop.exec())
-        AddImage(crop.GetOutput(),"cropped.mhd");
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  vvCropDialog crop(mSlicerManagers,index);
+  if(crop.exec())
+    AddImage(crop.GetOutput(),"cropped.mhd");
 }
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SplitImage() {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    int dim = mSlicerManagers[index]->GetDimension();
-    QString warning = "Do you really want to split the ";
-    warning += QString::number(dim) + "D image ";
-    warning += DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString() + " into ";
-    warning += QString::number(mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetSize()[dim-1]) + " ";
-    warning += QString::number(dim-1) + "D images.";
-    QMessageBox msgBox(QMessageBox::Warning, tr("Split Image"),
-                       warning, 0, this);
-    msgBox.addButton(tr("Split"), QMessageBox::AcceptRole);
-    msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
-    if (msgBox.exec() == QMessageBox::AcceptRole)
-    {
-        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-        if (dim > 2)
-        {
-            std::string filename = DataTree->selectedItems()[0]->data(0,Qt::UserRole).toString().toStdString();
-            int numberOfSlice = mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetSize()[dim-1];
-            std::string path = itksys::SystemTools::GetFilenamePath(
-                                   filename);
-            path += "/";
-            path += DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString().toStdString();
-            path += "%03d";
-            path += itksys::SystemTools::GetFilenameLastExtension(
-                        filename).c_str();
-
-            typedef itk::NumericSeriesFileNames NameGeneratorType;
-            NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
-            nameGenerator->SetSeriesFormat(path.c_str());
-            nameGenerator->SetStartIndex(0);
-            nameGenerator->SetEndIndex(numberOfSlice-1);
-            nameGenerator->SetIncrementIndex(1);
-
-            for (int i = 0; i < numberOfSlice; i++)
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  int dim = mSlicerManagers[index]->GetDimension();
+  QString warning = "Do you really want to split the ";
+  warning += QString::number(dim) + "D image ";
+  warning += DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString() + " into ";
+  warning += QString::number(mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetSize()[dim-1]) + " ";
+  warning += QString::number(dim-1) + "D images.";
+  QMessageBox msgBox(QMessageBox::Warning, tr("Split Image"),
+                     warning, 0, this);
+  msgBox.addButton(tr("Split"), QMessageBox::AcceptRole);
+  msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
+  if (msgBox.exec() == QMessageBox::AcceptRole)
+    {
+      QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+      if (dim > 2)
+        {
+          std::string filename = DataTree->selectedItems()[0]->data(0,Qt::UserRole).toString().toStdString();
+          int numberOfSlice = mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetSize()[dim-1];
+          std::string path = itksys::SystemTools::GetFilenamePath(
+                                                                  filename);
+          path += "/";
+          path += DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString().toStdString();
+          path += "%03d";
+          path += itksys::SystemTools::GetFilenameLastExtension(
+                                                                filename).c_str();
+
+          typedef itk::NumericSeriesFileNames NameGeneratorType;
+          NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
+          nameGenerator->SetSeriesFormat(path.c_str());
+          nameGenerator->SetStartIndex(0);
+          nameGenerator->SetEndIndex(numberOfSlice-1);
+          nameGenerator->SetIncrementIndex(1);
+
+          for (int i = 0; i < numberOfSlice; i++)
             {
-                vvSlicerManager* imageManager = new vvSlicerManager(4);
-                imageManager->SetExtractedImage(nameGenerator->GetFileNames()[i],
-                                                mSlicerManagers[index]->GetSlicer(0)->GetImage(), i);
-                mSlicerManagers.push_back(imageManager);
-
-                //create an item in the tree with good settings
-                QTreeWidgetItem *item = new QTreeWidgetItem();
-                item->setData(0,Qt::UserRole,nameGenerator->GetFileNames()[i].c_str());
-                std::string fileI = itksys::SystemTools::GetFilenameWithoutLastExtension(
-                                        nameGenerator->GetFileNames()[i]).c_str();
-                item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileI.c_str());
-                for (int j = 1; j <= 4; j++)
+              vvSlicerManager* imageManager = new vvSlicerManager(4);
+              imageManager->SetExtractedImage(nameGenerator->GetFileNames()[i],
+                                              mSlicerManagers[index]->GetSlicer(0)->GetImage(), i);
+              mSlicerManagers.push_back(imageManager);
+
+              //create an item in the tree with good settings
+              QTreeWidgetItem *item = new QTreeWidgetItem();
+              item->setData(0,Qt::UserRole,nameGenerator->GetFileNames()[i].c_str());
+              std::string fileI = itksys::SystemTools::GetFilenameWithoutLastExtension(
+                                                                                       nameGenerator->GetFileNames()[i]).c_str();
+              item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileI.c_str());
+              for (int j = 1; j <= 4; j++)
                 {
-                    for (int i = 0; i < DataTree->topLevelItemCount(); i++)
+                  for (int i = 0; i < DataTree->topLevelItemCount(); i++)
                     {
-                        DataTree->topLevelItem(i)->setData(j,Qt::CheckStateRole,0);
+                      DataTree->topLevelItem(i)->setData(j,Qt::CheckStateRole,0);
                     }
-                    item->setData(j,Qt::CheckStateRole,2);
+                  item->setData(j,Qt::CheckStateRole,2);
                 }
 
-                //Create the buttons for reload and close
-                QTreePushButton* cButton = new QTreePushButton;
-                cButton->setItem(item);
-                cButton->setColumn(COLUMN_CLOSE_IMAGE);
-                cButton->setToolTip(tr("close image"));
-                cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
-                connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-                        this,SLOT(CloseImage(QTreeWidgetItem*, int)));
-
-                QTreePushButton* rButton = new QTreePushButton;
-                rButton->setItem(item);
-                rButton->setColumn(COLUMN_RELOAD_IMAGE);
-                rButton->setToolTip(tr("reload image"));
-                rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
-                rButton->setEnabled(false);
-                connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-                        this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
-
-                DataTree->addTopLevelItem(item);
-                DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
-                DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
-
-                //set the id of the image
-                QString id = nameGenerator->GetFileNames()[i].c_str() + QString::number(mSlicerManagers.size()-1);
-                item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
-                mSlicerManagers.back()->SetId(id.toStdString());
-                linkPanel->addImage(fileI, id.toStdString());
-                connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
-                        this,SLOT(CurrentImageChanged(std::string)));
-                connect(mSlicerManagers.back(),SIGNAL(
-                            UpdatePosition(int, double, double, double, double, double, double, double)),this,
-                        SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
-                connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)),
-                        this, SLOT(VectorChanged(int,double,double,double, double)));
-                connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
-                        this, SLOT(OverlayChanged(int,double,double)));
-                connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
-                        this, SLOT(FusionChanged(int,double)));
-                connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
-                        this,SLOT(WindowsChanged(int, int, int)));
-                connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
-                        this,SLOT(WindowLevelChanged(double, double, int, int)));
-                connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
-                        this,SLOT(UpdateSlice(int,int)));
-                connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
-                        this,SLOT(UpdateTSlice(int, int)));
-                connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
-                        this,SLOT(UpdateSliceRange(int,int,int,int,int)));
-                connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
-                        this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
-                connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
-                UpdateTree();
-                qApp->processEvents();
-                InitSlicers();
-                InitDisplay();
-                qApp->processEvents();
+              //Create the buttons for reload and close
+              QTreePushButton* cButton = new QTreePushButton;
+              cButton->setItem(item);
+              cButton->setColumn(COLUMN_CLOSE_IMAGE);
+              cButton->setToolTip(tr("close image"));
+              cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
+              connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+                      this,SLOT(CloseImage(QTreeWidgetItem*, int)));
+
+              QTreePushButton* rButton = new QTreePushButton;
+              rButton->setItem(item);
+              rButton->setColumn(COLUMN_RELOAD_IMAGE);
+              rButton->setToolTip(tr("reload image"));
+              rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
+              rButton->setEnabled(false);
+              connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+                      this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
+
+              DataTree->addTopLevelItem(item);
+              DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
+              DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
+
+              //set the id of the image
+              QString id = nameGenerator->GetFileNames()[i].c_str() + QString::number(mSlicerManagers.size()-1);
+              item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
+              mSlicerManagers.back()->SetId(id.toStdString());
+              linkPanel->addImage(fileI, id.toStdString());
+              connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
+                      this,SLOT(CurrentImageChanged(std::string)));
+              connect(mSlicerManagers.back(),SIGNAL(
+                                                    UpdatePosition(int, double, double, double, double, double, double, double)),this,
+                      SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
+              connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)),
+                      this, SLOT(VectorChanged(int,double,double,double, double)));
+              connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
+                      this, SLOT(OverlayChanged(int,double,double)));
+              connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
+                      this, SLOT(FusionChanged(int,double)));
+              connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
+                      this,SLOT(WindowsChanged(int, int, int)));
+              connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
+                      this,SLOT(WindowLevelChanged(double, double, int, int)));
+              connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
+                      this,SLOT(UpdateSlice(int,int)));
+              connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
+                      this,SLOT(UpdateTSlice(int, int)));
+              connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
+                      this,SLOT(UpdateSliceRange(int,int,int,int,int)));
+              connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
+                      this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
+              connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
+              UpdateTree();
+              qApp->processEvents();
+              InitSlicers();
+              InitDisplay();
+              qApp->processEvents();
             }
-            QApplication::restoreOverrideCursor();
+          QApplication::restoreOverrideCursor();
         }
-        else
+      else
         {
-            QApplication::restoreOverrideCursor();
-            QString error = "Cannot split file (dimensions must be greater than 2) ";
-            QMessageBox::information(this,tr("Splitting problem"),error);
+          QApplication::restoreOverrideCursor();
+          QString error = "Cannot split file (dimensions must be greater than 2) ";
+          QMessageBox::information(this,tr("Splitting problem"),error);
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::MousePositionChanged(int visibility,double x, double y, double z, double X, double Y, double Z , double value) {
-    infoPanel->setCurrentInfo(visibility,x,y,z,X,Y,Z,value);
+  infoPanel->setCurrentInfo(visibility,x,y,z,X,Y,Z,value);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::VectorChanged(int visibility,double x, double y, double z, double value) {
-    overlayPanel->getCurrentVectorInfo(visibility,x,y,z,value);
+  overlayPanel->getCurrentVectorInfo(visibility,x,y,z,value);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::OverlayChanged(int visibility, double valueOver, double valueRef) {
-    overlayPanel->getCurrentOverlayInfo(visibility,valueOver, valueRef);
+  overlayPanel->getCurrentOverlayInfo(visibility,valueOver, valueRef);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::FusionChanged(int visibility, double value) {
-    overlayPanel->getCurrentFusionInfo(visibility,value);
+  overlayPanel->getCurrentFusionInfo(visibility,value);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::WindowsChanged(int window, int view, int slice) {
-    infoPanel->setViews(window, view, slice);
+  infoPanel->setViews(window, view, slice);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::WindowLevelChanged(double window, double level,int preset,int colormap) {
-    windowSpinBox->setValue(window);
-    levelSpinBox->setValue(level);
-    colorMapComboBox->setCurrentIndex(colormap);
-    presetComboBox->setCurrentIndex(preset);
+  windowSpinBox->setValue(window);
+  levelSpinBox->setValue(level);
+  colorMapComboBox->setCurrentIndex(colormap);
+  presetComboBox->setCurrentIndex(preset);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::WindowLevelEdited() {
-    presetComboBox->setCurrentIndex(6);
-    UpdateWindowLevel();
+  presetComboBox->setCurrentIndex(6);
+  UpdateWindowLevel();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::UpdateWindowLevel() {
-    if (DataTree->selectedItems().size())
+  if (DataTree->selectedItems().size())
     {
-        if (presetComboBox->currentIndex() == 7) //For ventilation
-            colorMapComboBox->setCurrentIndex(5);
-        int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-        mSlicerManagers[index]->SetColorWindow(windowSpinBox->value());
-        mSlicerManagers[index]->SetColorLevel(levelSpinBox->value());
-        mSlicerManagers[index]->SetPreset(presetComboBox->currentIndex());
-        mSlicerManagers[index]->Render();
+      if (presetComboBox->currentIndex() == 7) //For ventilation
+        colorMapComboBox->setCurrentIndex(5);
+      int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+      mSlicerManagers[index]->SetColorWindow(windowSpinBox->value());
+      mSlicerManagers[index]->SetColorLevel(levelSpinBox->value());
+      mSlicerManagers[index]->SetPreset(presetComboBox->currentIndex());
+      mSlicerManagers[index]->Render();
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::UpdateColorMap() {
-    if (DataTree->selectedItems().size())
+  if (DataTree->selectedItems().size())
     {
-        int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-        mSlicerManagers[index]->SetColorMap(colorMapComboBox->currentIndex());
-        mSlicerManagers[index]->Render();
+      int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+      mSlicerManagers[index]->SetColorMap(colorMapComboBox->currentIndex());
+      mSlicerManagers[index]->Render();
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SwitchWindowLevel() {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    int window = mSlicerManagers[index]->GetColorWindow();
-    presetComboBox->setCurrentIndex(6);
-    windowSpinBox->setValue(-window);
-    UpdateWindowLevel();
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  int window = mSlicerManagers[index]->GetColorWindow();
+  presetComboBox->setCurrentIndex(6);
+  windowSpinBox->setValue(-window);
+  UpdateWindowLevel();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps) {
-    for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
     {
-        if (mSlicerManagers[i]->GetId() == id)
+      if (mSlicerManagers[i]->GetId() == id)
         {
-            //mSlicerManagers[i]->SetTSlice(temps);
-            mSlicerManagers[i]->GetSlicer(slicer)->SetCurrentPosition(x,y,z,temps);
-            mSlicerManagers[i]->UpdateViews(0,slicer);
-            break;
+          //mSlicerManagers[i]->SetTSlice(temps);
+          mSlicerManagers[i]->GetSlicer(slicer)->SetCurrentPosition(x,y,z,temps);
+          mSlicerManagers[i]->UpdateViews(0,slicer);
+          break;
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::ShowContextMenu(QPoint point) {
-    if (!DataTree->selectedItems().size())
-    {
-        contextActions[1]->setEnabled(0);
-        contextActions[2]->setEnabled(0);
-        contextActions[3]->setEnabled(0);
+  if (!DataTree->selectedItems().size())
+    {
+      contextActions[1]->setEnabled(0);
+      contextActions[2]->setEnabled(0);
+      contextActions[3]->setEnabled(0);
+      contextActions[4]->setEnabled(0);
+      contextActions[5]->setEnabled(0);
+      contextActions[6]->setEnabled(0);
+      contextActions[7]->setEnabled(0);
+    }
+  else
+    {
+      int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+      contextActions[1]->setEnabled(1);
+      contextActions[2]->setEnabled(
+                                    DataTree->itemWidget(DataTree->selectedItems()[0],
+                                                         COLUMN_RELOAD_IMAGE)->isEnabled());
+      contextActions[3]->setEnabled(1);
+      contextActions[5]->setEnabled(1);
+      contextActions[6]->setEnabled(1);
+      contextActions[7]->setEnabled(1);
+
+      if (mSlicerManagers[index]->GetDimension() < 3)
         contextActions[4]->setEnabled(0);
-        contextActions[5]->setEnabled(0);
-        contextActions[6]->setEnabled(0);
-        contextActions[7]->setEnabled(0);
-    }
-    else
-    {
-        int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-        contextActions[1]->setEnabled(1);
-        contextActions[2]->setEnabled(
-            DataTree->itemWidget(DataTree->selectedItems()[0],
-                                 COLUMN_RELOAD_IMAGE)->isEnabled());
-        contextActions[3]->setEnabled(1);
-        contextActions[5]->setEnabled(1);
-        contextActions[6]->setEnabled(1);
-        contextActions[7]->setEnabled(1);
-
-        if (mSlicerManagers[index]->GetDimension() < 3)
-            contextActions[4]->setEnabled(0);
-        else
-            contextActions[4]->setEnabled(1);
+      else
+        contextActions[4]->setEnabled(1);
     }
-    contextMenu.exec(QCursor::pos());
+  contextMenu.exec(QCursor::pos());
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::CloseImage() {
-    CloseImage(DataTree->selectedItems()[0],0);
+  CloseImage(DataTree->selectedItems()[0],0);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::ReloadImage() {
-    ReloadImage(DataTree->selectedItems()[0],0);
+  ReloadImage(DataTree->selectedItems()[0],0);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SelectOverlayImage() {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-
-    //check if one overlay image is added
-    for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-        if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "overlay")
-        {
-            QString error = "Cannot add more than one compared image\n";
-            error += "Please remove first ";
-            error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-            QMessageBox::information(this,tr("Problem adding compared image !"),error);
-            return;
-        }
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+
+  //check if one overlay image is added
+  for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
+    if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "overlay")
+      {
+        QString error = "Cannot add more than one compared image\n";
+        error += "Please remove first ";
+        error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
+        QMessageBox::information(this,tr("Problem adding compared image !"),error);
+        return;
+      }
 
-    QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
-    Extensions += ";;All Files (*)";
-    QString file = QFileDialog::getOpenFileName(this,tr("Load Overlay image"),mInputPathName,Extensions);
-    if (!file.isEmpty())
-        AddOverlayImage(index,file);
+  QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
+  Extensions += ";;All Files (*)";
+  QString file = QFileDialog::getOpenFileName(this,tr("Load Overlay image"),mInputPathName,Extensions);
+  if (!file.isEmpty())
+    AddOverlayImage(index,file);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::AddOverlayImage(int index, QString file) {
-    mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
-    itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
-                                           file.toStdString().c_str(), itk::ImageIOFactory::ReadMode);
-    reader->SetFileName(file.toStdString().c_str());
-    reader->ReadImageInformation();
-    std::string component = reader->GetComponentTypeAsString(reader->GetComponentType());
-    int dimension = reader->GetNumberOfDimensions();
-    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-    vvProgressDialog progress("Opening " + file.toStdString());
-    qApp->processEvents();
-
-    std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
-    if (mSlicerManagers[index]->SetOverlay(file.toStdString(),dimension, component))
-    {
-        //create an item in the tree with good settings
-        QTreeWidgetItem *item = new QTreeWidgetItem();
-        item->setData(0,Qt::UserRole,file.toStdString().c_str());
-        item->setData(1,Qt::UserRole,tr("overlay"));
-        item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename.c_str());
-        qApp->processEvents();
-
-        for (int j = 1; j <= 4; j++)
-        {
-            item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
-            mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("overlay",0,
-                DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
-        }
-
-        //Create the buttons for reload and close
-        qApp->processEvents();
-        QTreePushButton* cButton = new QTreePushButton;
-        cButton->setItem(item);
-        cButton->setColumn(COLUMN_CLOSE_IMAGE);
-        cButton->setToolTip(tr("close image"));
-        cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
-        connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-                this,SLOT(CloseImage(QTreeWidgetItem*, int)));
-
-        QTreePushButton* rButton = new QTreePushButton;
-        rButton->setItem(item);
-        rButton->setColumn(COLUMN_RELOAD_IMAGE);
-        rButton->setToolTip(tr("reload image"));
-        rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
-        connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-                this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
-
-        DataTree->topLevelItem(index)->setExpanded(1);
-        DataTree->topLevelItem(index)->addChild(item);
-        DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
-        DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
-
-        //set the id of the image
-        QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
-        item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
-        UpdateTree();
-        qApp->processEvents();
-        ImageInfoChanged();
-        QApplication::restoreOverrideCursor();
-    }
-    else
-    {
-        QApplication::restoreOverrideCursor();
-        QString error = "Cannot import the new image.\n";
-        error += mSlicerManagers[index]->GetLastError().c_str();
-        QMessageBox::information(this,tr("Problem reading image !"),error);
+  mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
+  itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
+                                                                        file.toStdString().c_str(), itk::ImageIOFactory::ReadMode);
+  reader->SetFileName(file.toStdString().c_str());
+  reader->ReadImageInformation();
+  std::string component = reader->GetComponentTypeAsString(reader->GetComponentType());
+  int dimension = reader->GetNumberOfDimensions();
+  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+  vvProgressDialog progress("Opening " + file.toStdString());
+  qApp->processEvents();
+
+  std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
+  if (mSlicerManagers[index]->SetOverlay(file.toStdString(),dimension, component))
+    {
+      //create an item in the tree with good settings
+      QTreeWidgetItem *item = new QTreeWidgetItem();
+      item->setData(0,Qt::UserRole,file.toStdString().c_str());
+      item->setData(1,Qt::UserRole,tr("overlay"));
+      item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename.c_str());
+      qApp->processEvents();
+
+      for (int j = 1; j <= 4; j++)
+        {
+          item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
+          mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("overlay",0,
+                                                                     DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
+        }
+
+      //Create the buttons for reload and close
+      qApp->processEvents();
+      QTreePushButton* cButton = new QTreePushButton;
+      cButton->setItem(item);
+      cButton->setColumn(COLUMN_CLOSE_IMAGE);
+      cButton->setToolTip(tr("close image"));
+      cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
+      connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+              this,SLOT(CloseImage(QTreeWidgetItem*, int)));
+
+      QTreePushButton* rButton = new QTreePushButton;
+      rButton->setItem(item);
+      rButton->setColumn(COLUMN_RELOAD_IMAGE);
+      rButton->setToolTip(tr("reload image"));
+      rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
+      connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+              this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
+
+      DataTree->topLevelItem(index)->setExpanded(1);
+      DataTree->topLevelItem(index)->addChild(item);
+      DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
+      DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
+
+      //set the id of the image
+      QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
+      item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
+      UpdateTree();
+      qApp->processEvents();
+      ImageInfoChanged();
+      QApplication::restoreOverrideCursor();
+    }
+  else
+    {
+      QApplication::restoreOverrideCursor();
+      QString error = "Cannot import the new image.\n";
+      error += mSlicerManagers[index]->GetLastError().c_str();
+      QMessageBox::information(this,tr("Problem reading image !"),error);
     }
 }
 
 void vvMainWindow::AddFusionImage()
 {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-
-    //check if one fusion image is added
-    for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-        if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion")
-        {
-            QString error = "Cannot add more than one fusion image\n";
-            error += "Please remove first ";
-            error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-            QMessageBox::information(this,tr("Problem adding fusion image !"),error);
-            return;
-        }
-
-    QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
-    Extensions += ";;All Files (*)";
-    QString file = QFileDialog::getOpenFileName(this,tr("Load Fusion image"),mInputPathName,Extensions);
-    if (!file.isEmpty())
-    {
-        mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
-        itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
-                                               file.toStdString().c_str(), itk::ImageIOFactory::ReadMode);
-        reader->SetFileName(file.toStdString().c_str());
-        reader->ReadImageInformation();
-        std::string component = reader->GetComponentTypeAsString(reader->GetComponentType());
-        if (reader)
-        {
-            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-            vvProgressDialog progress("Opening fusion");
-            qApp->processEvents();
-
-            std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
-            if (mSlicerManagers[index]->SetFusion(file.toStdString(),
-                                                   reader->GetNumberOfDimensions(), component))
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+
+  //check if one fusion image is added
+  for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
+    if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion")
+      {
+        QString error = "Cannot add more than one fusion image\n";
+        error += "Please remove first ";
+        error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
+        QMessageBox::information(this,tr("Problem adding fusion image !"),error);
+        return;
+      }
+
+  QString Extensions = "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox)";
+  Extensions += ";;All Files (*)";
+  QString file = QFileDialog::getOpenFileName(this,tr("Load Fusion image"),mInputPathName,Extensions);
+  if (!file.isEmpty())
+    {
+      mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
+      itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
+                                                                            file.toStdString().c_str(), itk::ImageIOFactory::ReadMode);
+      reader->SetFileName(file.toStdString().c_str());
+      reader->ReadImageInformation();
+      std::string component = reader->GetComponentTypeAsString(reader->GetComponentType());
+      if (reader)
+        {
+          QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+          vvProgressDialog progress("Opening fusion");
+          qApp->processEvents();
+
+          std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
+          if (mSlicerManagers[index]->SetFusion(file.toStdString(),
+                                                reader->GetNumberOfDimensions(), component))
             {
-                //create an item in the tree with good settings
-                QTreeWidgetItem *item = new QTreeWidgetItem();
-                item->setData(0,Qt::UserRole,file.toStdString().c_str());
-                item->setData(1,Qt::UserRole,tr("fusion"));
-                item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename.c_str());
-                qApp->processEvents();
-
-                for (int j = 1; j <= 4; j++)
+              //create an item in the tree with good settings
+              QTreeWidgetItem *item = new QTreeWidgetItem();
+              item->setData(0,Qt::UserRole,file.toStdString().c_str());
+              item->setData(1,Qt::UserRole,tr("fusion"));
+              item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename.c_str());
+              qApp->processEvents();
+
+              for (int j = 1; j <= 4; j++)
                 {
-                    item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
-                    mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("fusion",0,
-                        DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
+                  item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
+                  mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("fusion",0,
+                                                                             DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
                 }
 
-                //Create the buttons for reload and close
-                qApp->processEvents();
-                QTreePushButton* cButton = new QTreePushButton;
-                cButton->setItem(item);
-                cButton->setColumn(COLUMN_CLOSE_IMAGE);
-                cButton->setToolTip(tr("close image"));
-                cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
-                connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-                        this,SLOT(CloseImage(QTreeWidgetItem*, int)));
-
-                QTreePushButton* rButton = new QTreePushButton;
-                rButton->setItem(item);
-                rButton->setColumn(COLUMN_RELOAD_IMAGE);
-                rButton->setToolTip(tr("reload image"));
-                rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
-                connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-                        this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
-
-                DataTree->topLevelItem(index)->setExpanded(1);
-                DataTree->topLevelItem(index)->addChild(item);
-                DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
-                DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
-
-                //set the id of the image
-                QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
-                item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
-                UpdateTree();
-                qApp->processEvents();
-                ImageInfoChanged();
-                QApplication::restoreOverrideCursor();
+              //Create the buttons for reload and close
+              qApp->processEvents();
+              QTreePushButton* cButton = new QTreePushButton;
+              cButton->setItem(item);
+              cButton->setColumn(COLUMN_CLOSE_IMAGE);
+              cButton->setToolTip(tr("close image"));
+              cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
+              connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+                      this,SLOT(CloseImage(QTreeWidgetItem*, int)));
+
+              QTreePushButton* rButton = new QTreePushButton;
+              rButton->setItem(item);
+              rButton->setColumn(COLUMN_RELOAD_IMAGE);
+              rButton->setToolTip(tr("reload image"));
+              rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
+              connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+                      this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
+
+              DataTree->topLevelItem(index)->setExpanded(1);
+              DataTree->topLevelItem(index)->addChild(item);
+              DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
+              DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
+
+              //set the id of the image
+              QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
+              item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
+              UpdateTree();
+              qApp->processEvents();
+              ImageInfoChanged();
+              QApplication::restoreOverrideCursor();
             }
-            else
+          else
             {
-                QApplication::restoreOverrideCursor();
-                QString error = "Cannot import the new image.\n";
-                error += mSlicerManagers[index]->GetLastError().c_str();
-                QMessageBox::information(this,tr("Problem reading image !"),error);
+              QApplication::restoreOverrideCursor();
+              QString error = "Cannot import the new image.\n";
+              error += mSlicerManagers[index]->GetLastError().c_str();
+              QMessageBox::information(this,tr("Problem reading image !"),error);
             }
         }
-        else
+      else
         {
-            QString error = "Cannot import the new image.\n";
-            QMessageBox::information(this,tr("Problem reading image !"),error);
+          QString error = "Cannot import the new image.\n";
+          QMessageBox::information(this,tr("Problem reading image !"),error);
         }
     }
 }
@@ -1937,750 +1997,775 @@ void vvMainWindow::AddFusionImage()
 
 void vvMainWindow::OpenField()
 {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    //check if a vector field has already been added
-    for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-        if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "vector")
-        {
-            QString error = "Cannot add more than one vector field\n";
-            error += "Please remove first ";
-            error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-            QMessageBox::information(this,tr("Problem adding vector field!"),error);
-            return;
-        }
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  //check if a vector field has already been added
+  for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
+    if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "vector")
+      {
+        QString error = "Cannot add more than one vector field\n";
+        error += "Please remove first ";
+        error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
+        QMessageBox::information(this,tr("Problem adding vector field!"),error);
+        return;
+      }
 
-    QString Extensions = "Images ( *.mhd)";
-    Extensions += ";;Images ( *.vf)";
-    QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
-    if (!file.isEmpty())
-        AddField(file,index);
+  QString Extensions = "Images ( *.mhd)";
+  Extensions += ";;Images ( *.vf)";
+  QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
+  if (!file.isEmpty())
+    AddField(file,index);
 }
 
 void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk)
 {
-    //create an item in the tree with good settings
-    QTreeWidgetItem *item = new QTreeWidgetItem();
-    item->setData(0,Qt::UserRole,filename.toStdString().c_str());
-    item->setData(1,Qt::UserRole,tr("vector"));
-    item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename);
-    qApp->processEvents();
-
-    for (int j = 1; j <= 4; j++)
-    {
-        item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
-        mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("vector",0,
-            DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
-    }
-
-    //Create the buttons for reload and close
-    qApp->processEvents();
-    QTreePushButton* cButton = new QTreePushButton;
-    cButton->setItem(item);
-    cButton->setColumn(COLUMN_CLOSE_IMAGE);
-    cButton->setToolTip(tr("close vector field"));
-    cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
-    connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-            this,SLOT(CloseImage(QTreeWidgetItem*, int)));
-
-    QTreePushButton* rButton = new QTreePushButton;
-    rButton->setItem(item);
-    rButton->setColumn(COLUMN_RELOAD_IMAGE);
-    rButton->setToolTip(tr("reload vector field"));
-    rButton->setEnabled(from_disk);
-    rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
-    connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-            this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
-
-    DataTree->topLevelItem(index)->setExpanded(1);
-    DataTree->topLevelItem(index)->addChild(item);
-    DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
-    DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
-
-    //set the id of the image
-    QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
-    item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
-    UpdateTree();
-    qApp->processEvents();
-    ImageInfoChanged();
-    QApplication::restoreOverrideCursor();
+  //create an item in the tree with good settings
+  QTreeWidgetItem *item = new QTreeWidgetItem();
+  item->setData(0,Qt::UserRole,filename.toStdString().c_str());
+  item->setData(1,Qt::UserRole,tr("vector"));
+  item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename);
+  qApp->processEvents();
+
+  for (int j = 1; j <= 4; j++)
+    {
+      item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
+      mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("vector",0,
+                                                                 DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
+    }
+
+  //Create the buttons for reload and close
+  qApp->processEvents();
+  QTreePushButton* cButton = new QTreePushButton;
+  cButton->setItem(item);
+  cButton->setColumn(COLUMN_CLOSE_IMAGE);
+  cButton->setToolTip(tr("close vector field"));
+  cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
+  connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+          this,SLOT(CloseImage(QTreeWidgetItem*, int)));
+
+  QTreePushButton* rButton = new QTreePushButton;
+  rButton->setItem(item);
+  rButton->setColumn(COLUMN_RELOAD_IMAGE);
+  rButton->setToolTip(tr("reload vector field"));
+  rButton->setEnabled(from_disk);
+  rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
+  connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+          this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
+
+  DataTree->topLevelItem(index)->setExpanded(1);
+  DataTree->topLevelItem(index)->addChild(item);
+  DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
+  DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
+
+  //set the id of the image
+  QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
+  item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
+  UpdateTree();
+  qApp->processEvents();
+  ImageInfoChanged();
+  QApplication::restoreOverrideCursor();
 }
 
 void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index)
 {
-    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-    vvSlicerManager* imageManager = mSlicerManagers[index];
-    if (imageManager->SetVF(vf,file.toStdString()))
+  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+  vvSlicerManager* imageManager = mSlicerManagers[index];
+  if (imageManager->SetVF(vf,file.toStdString()))
     {
-        AddFieldEntry(file,index,false);
+      AddFieldEntry(file,index,false);
     }
-    else
+  else
     {
-        QString error = "Cannot import the vector field for this image.\n";
-        error += imageManager->GetLastError().c_str();
-        QMessageBox::information(this,tr("Problem reading VF !"),error);
+      QString error = "Cannot import the vector field for this image.\n";
+      error += imageManager->GetLastError().c_str();
+      QMessageBox::information(this,tr("Problem reading VF !"),error);
     }
-    QApplication::restoreOverrideCursor();
+  QApplication::restoreOverrideCursor();
 }
 
 void vvMainWindow::AddField(QString file,int index)
 {
-    if (QFile::exists(file))
+  if (QFile::exists(file))
     {
-        mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
+      mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
 
-        //init the progress events
-        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-        vvProgressDialog progress("Opening " + file.toStdString());
-        qApp->processEvents();
+      //init the progress events
+      QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+      vvProgressDialog progress("Opening " + file.toStdString());
+      qApp->processEvents();
 
-        //read the vector and put it in the current mSlicerManager
-        vvSlicerManager* imageManager = mSlicerManagers[index];
-        qApp->processEvents();
+      //read the vector and put it in the current mSlicerManager
+      vvSlicerManager* imageManager = mSlicerManagers[index];
+      qApp->processEvents();
 
-        std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
-        if (imageManager->SetVF(file.toStdString()))
+      std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
+      if (imageManager->SetVF(file.toStdString()))
         {
-            imageManager->Render();
-            AddFieldEntry(file,index,true);
+          imageManager->Render();
+          AddFieldEntry(file,index,true);
         }
-        else
+      else
         {
-            QApplication::restoreOverrideCursor();
-            QString error = "Cannot import the vector field for this image.\n";
-            error += imageManager->GetLastError().c_str();
-            QMessageBox::information(this,tr("Problem reading VF !"),error);
+          QApplication::restoreOverrideCursor();
+          QString error = "Cannot import the vector field for this image.\n";
+          error += imageManager->GetLastError().c_str();
+          QMessageBox::information(this,tr("Problem reading VF !"),error);
         }
     }
-    else
-        QMessageBox::information(this,tr("Problem reading VF !"),"File doesn't exist!");
+  else
+    QMessageBox::information(this,tr("Problem reading VF !"),"File doesn't exist!");
 
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    if (mSlicerManagers[index]->GetSlicer(0)->GetVF())
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  if (mSlicerManagers[index]->GetSlicer(0)->GetVF())
     {
-        for (int i = 0; i < 4; i++)
+      for (int i = 0; i < 4; i++)
         {
-            mSlicerManagers[index]->GetSlicer(i)->SetVFSubSampling(subsampling);
-            mSlicerManagers[index]->GetSlicer(i)->SetVFScale(scale);
-            if (log > 0)
-                mSlicerManagers[index]->GetSlicer(i)->SetVFLog(1);
-            else
-                mSlicerManagers[index]->GetSlicer(i)->SetVFLog(0);
+          mSlicerManagers[index]->GetSlicer(i)->SetVFSubSampling(subsampling);
+          mSlicerManagers[index]->GetSlicer(i)->SetVFScale(scale);
+          if (log > 0)
+            mSlicerManagers[index]->GetSlicer(i)->SetVFLog(1);
+          else
+            mSlicerManagers[index]->GetSlicer(i)->SetVFLog(0);
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SetOverlayProperty(int color) {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay())
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay())
     {
-        mSlicerManagers[index]->SetOverlayColor(color);
-        mSlicerManagers[index]->SetColorMap(0);
-        mSlicerManagers[index]->Render();
+      mSlicerManagers[index]->SetOverlayColor(color);
+      mSlicerManagers[index]->SetColorMap(0);
+      mSlicerManagers[index]->Render();
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SetFusionProperty(int opacity, int colormap,double window, double level) {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    if (mSlicerManagers[index]->GetSlicer(0)->GetFusion())
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  if (mSlicerManagers[index]->GetSlicer(0)->GetFusion())
     {
-        mSlicerManagers[index]->SetFusionOpacity(opacity);
-        mSlicerManagers[index]->SetFusionColorMap(colormap);
-        mSlicerManagers[index]->SetFusionWindow(window);
-        mSlicerManagers[index]->SetFusionLevel(level);
-        mSlicerManagers[index]->SetColorMap(0);
-        mSlicerManagers[index]->Render();
+      mSlicerManagers[index]->SetFusionOpacity(opacity);
+      mSlicerManagers[index]->SetFusionColorMap(colormap);
+      mSlicerManagers[index]->SetFusionWindow(window);
+      mSlicerManagers[index]->SetFusionLevel(level);
+      mSlicerManagers[index]->SetColorMap(0);
+      mSlicerManagers[index]->Render();
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SaveAs() {
-    if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector")
+  if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector")
     {
-        QMessageBox::warning(this,tr("Unsupported type"),tr("Sorry, saving a vector field is unsupported for the moment"));
-        return;
+      QMessageBox::warning(this,tr("Unsupported type"),tr("Sorry, saving a vector field is unsupported for the moment"));
+      return;
     }
 
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    int dimension = mSlicerManagers[index]->GetDimension();
-    QStringList OutputListeFormat;
-    OutputListeFormat.clear();
-    if (dimension == 1)
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  int dimension = mSlicerManagers[index]->GetDimension();
+  QStringList OutputListeFormat;
+  OutputListeFormat.clear();
+  if (dimension == 1)
     {
-        OutputListeFormat.push_back(".mhd");
+      OutputListeFormat.push_back(".mhd");
     }
-    if (dimension == 2)
+  if (dimension == 2)
     {
-        OutputListeFormat.push_back(".bmp");
-        OutputListeFormat.push_back(".png");
-        OutputListeFormat.push_back(".jpeg");
-        OutputListeFormat.push_back(".tif");
-        OutputListeFormat.push_back(".mhd");
-        OutputListeFormat.push_back(".hdr");
-        OutputListeFormat.push_back(".vox");
+      OutputListeFormat.push_back(".bmp");
+      OutputListeFormat.push_back(".png");
+      OutputListeFormat.push_back(".jpeg");
+      OutputListeFormat.push_back(".tif");
+      OutputListeFormat.push_back(".mhd");
+      OutputListeFormat.push_back(".hdr");
+      OutputListeFormat.push_back(".vox");
     }
-    else if (dimension == 3)
+  else if (dimension == 3)
     {
-        OutputListeFormat.push_back(".mhd");
-        OutputListeFormat.push_back(".hdr");
-        OutputListeFormat.push_back(".vox");
+      OutputListeFormat.push_back(".mhd");
+      OutputListeFormat.push_back(".hdr");
+      OutputListeFormat.push_back(".vox");
     }
-    else if (dimension == 4)
+  else if (dimension == 4)
     {
-        OutputListeFormat.push_back(".mhd");
+      OutputListeFormat.push_back(".mhd");
     }
-    QString Extensions = "AllFiles(*.*)";
-    for (int i = 0; i < OutputListeFormat.count(); i++)
+  QString Extensions = "AllFiles(*.*)";
+  for (int i = 0; i < OutputListeFormat.count(); i++)
     {
-        Extensions += ";;Images ( *";
-        Extensions += OutputListeFormat[i];
-        Extensions += ")";
+      Extensions += ";;Images ( *";
+      Extensions += OutputListeFormat[i];
+      Extensions += ")";
     }
-    QString fileName = QFileDialog::getSaveFileName(this,
-                       tr("Save As"),
-                       mSlicerManagers[index]->GetFileName().c_str(),
-                       Extensions);
-    if (!fileName.isEmpty())
+  QString fileName = QFileDialog::getSaveFileName(this,
+                                                  tr("Save As"),
+                                                  mSlicerManagers[index]->GetFileName().c_str(),
+                                                  Extensions);
+  if (!fileName.isEmpty())
     {
-        std::string fileformat = itksys::SystemTools::GetFilenameLastExtension(fileName.toStdString());
-        if (OutputListeFormat.contains(
-                    fileformat.c_str()))
+      std::string fileformat = itksys::SystemTools::GetFilenameLastExtension(fileName.toStdString());
+      if (OutputListeFormat.contains(
+                                     fileformat.c_str()))
         {
-            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-            std::string action = "Saving";
-            vvProgressDialog progress("Saving "+fileName.toStdString());
-            qApp->processEvents();
-            vvImageWriter *writer = new vvImageWriter;
-            writer->SetOutputFileName(fileName.toStdString());
-            writer->SetInput(mSlicerManagers[index]->GetImage());
-            writer->Update();
-            QApplication::restoreOverrideCursor();
-            if (writer->GetLastError().size())
+          QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+          std::string action = "Saving";
+          vvProgressDialog progress("Saving "+fileName.toStdString());
+          qApp->processEvents();
+          vvImageWriter *writer = new vvImageWriter;
+          writer->SetOutputFileName(fileName.toStdString());
+          writer->SetInput(mSlicerManagers[index]->GetImage());
+          writer->Update();
+          QApplication::restoreOverrideCursor();
+          if (writer->GetLastError().size())
             {
-                QString error = "Saving did not succeed\n";
-                error += writer->GetLastError().c_str();
-                QMessageBox::information(this,tr("Saving Problem"),error);
-                SaveAs();
+              QString error = "Saving did not succeed\n";
+              error += writer->GetLastError().c_str();
+              QMessageBox::information(this,tr("Saving Problem"),error);
+              SaveAs();
             }
         }
-        else
+      else
         {
-            QString error = fileformat.c_str();
-            if (error.isEmpty())
-                error += "no file format specified !";
-            else
-                error += " format unknown !!!\n";
-            QMessageBox::information(this,tr("Saving Problem"),error);
-            SaveAs();
+          QString error = fileformat.c_str();
+          if (error.isEmpty())
+            error += "no file format specified !";
+          else
+            error += " format unknown !!!\n";
+          QMessageBox::information(this,tr("Saving Problem"),error);
+          SaveAs();
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::AddLink(QString image1,QString image2) {
-    for (unsigned int i = 0; i < mSlicerManagers.size();i++)
+  for (unsigned int i = 0; i < mSlicerManagers.size();i++)
     {
-        if (image1.toStdString() == mSlicerManagers[i]->GetId())
+      if (image1.toStdString() == mSlicerManagers[i]->GetId())
         {
-            mSlicerManagers[i]->AddLink(image2.toStdString());
+          mSlicerManagers[i]->AddLink(image2.toStdString());
         }
-        if (image2.toStdString() == mSlicerManagers[i]->GetId())
+      if (image2.toStdString() == mSlicerManagers[i]->GetId())
         {
-            mSlicerManagers[i]->AddLink(image1.toStdString());
+          mSlicerManagers[i]->AddLink(image1.toStdString());
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::RemoveLink(QString image1,QString image2) {
-    for (unsigned int i = 0; i < mSlicerManagers.size();i++)
+  for (unsigned int i = 0; i < mSlicerManagers.size();i++)
     {
-        if (image1.toStdString() == mSlicerManagers[i]->GetId())
+      if (image1.toStdString() == mSlicerManagers[i]->GetId())
         {
-            mSlicerManagers[i]->RemoveLink(image2.toStdString());
+          mSlicerManagers[i]->RemoveLink(image2.toStdString());
         }
-        if (image2.toStdString() == mSlicerManagers[i]->GetId())
+      if (image2.toStdString() == mSlicerManagers[i]->GetId())
         {
-            mSlicerManagers[i]->RemoveLink(image1.toStdString());
+          mSlicerManagers[i]->RemoveLink(image1.toStdString());
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
 void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
 {
-    for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
     {
-        if (DataTree->topLevelItem(i)->data(column,Qt::CheckStateRole).toInt() > 1)
+      if (DataTree->topLevelItem(i)->data(column,Qt::CheckStateRole).toInt() > 1)
         {
-            for (int j = 0; j < 4; j++)
+          for (int j = 0; j < 4; j++)
             {
-                mSlicerManagers[i]->SetTSliceInSlicer(value,j);
-                //if (mSlicerManagers[i]->GetSlicer(j)->GetImageActor()->GetVisibility())
-                    //UpdateTSlice(j,value);
+              mSlicerManagers[i]->SetTSliceInSlicer(value,j);
+              //if (mSlicerManagers[i]->GetSlicer(j)->GetImageActor()->GetVisibility())
+              //UpdateTSlice(j,value);
             }
-            mSlicerManagers[i]->GetSlicer(slicer_index)->Render();
-            break;
+          mSlicerManagers[i]->GetSlicer(slicer_index)->Render();
+          break;
         }
     }
 }
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::NOHorizontalSliderMoved() {
-    HorizontalSliderMoved(NOHorizontalSlider->value(),COLUMN_UL_VIEW,0);
+  HorizontalSliderMoved(NOHorizontalSlider->value(),COLUMN_UL_VIEW,0);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::NEHorizontalSliderMoved() {
-    HorizontalSliderMoved(NEHorizontalSlider->value(),COLUMN_UR_VIEW,1);
+  HorizontalSliderMoved(NEHorizontalSlider->value(),COLUMN_UR_VIEW,1);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SOHorizontalSliderMoved() {
-    HorizontalSliderMoved(SOHorizontalSlider->value(),COLUMN_DL_VIEW,2);
+  HorizontalSliderMoved(SOHorizontalSlider->value(),COLUMN_DL_VIEW,2);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SEHorizontalSliderMoved() {
-    HorizontalSliderMoved(SEHorizontalSlider->value(),COLUMN_DR_VIEW,3);
+  HorizontalSliderMoved(SEHorizontalSlider->value(),COLUMN_DR_VIEW,3);
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::NOVerticalSliderChanged() {
-    int value = NOVerticalSlider->value();
-    for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
+  int value = NOVerticalSlider->value();
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
     {
-        if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1)
+      if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1)
         {
-            mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
-            break;
+          mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
+          break;
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::NEVerticalSliderChanged() {
-    int value = NEVerticalSlider->value();
-    for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
+  int value = NEVerticalSlider->value();
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
     {
-        if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1)
+      if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1)
         {
-            mSlicerManagers[i]->GetSlicer(1)->SetSlice(value);
-            break;
+          mSlicerManagers[i]->GetSlicer(1)->SetSlice(value);
+          break;
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SOVerticalSliderChanged() {
-    int value = SOVerticalSlider->value();
-    for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
+  int value = SOVerticalSlider->value();
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
     {
-        if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1)
+      if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1)
         {
-            mSlicerManagers[i]->GetSlicer(2)->SetSlice(value);
-            break;
+          mSlicerManagers[i]->GetSlicer(2)->SetSlice(value);
+          break;
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SEVerticalSliderChanged() {
-    int value = SEVerticalSlider->value();
-    for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
+  int value = SEVerticalSlider->value();
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
     {
-        if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1)
+      if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1)
         {
-            mSlicerManagers[i]->GetSlicer(3)->SetSlice(value);
-            break;
+          mSlicerManagers[i]->GetSlicer(3)->SetSlice(value);
+          break;
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::UpdateSlice(int slicer, int slice) {
-    if (slicer == 0)
-        NOVerticalSlider->setValue(slice);
-    else if (slicer == 1)
-        NEVerticalSlider->setValue(slice);
-    else if (slicer == 2)
-        SOVerticalSlider->setValue(slice);
-    else if (slicer == 3)
-        SEVerticalSlider->setValue(slice);
-}
-//====================================================================
-
-//====================================================================
+  if (slicer == 0)
+    NOVerticalSlider->setValue(slice);
+  else if (slicer == 1)
+    NEVerticalSlider->setValue(slice);
+  else if (slicer == 2)
+    SOVerticalSlider->setValue(slice);
+  else if (slicer == 3)
+    SEVerticalSlider->setValue(slice);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
 void vvMainWindow::UpdateTSlice(int slicer, int slice) {
-    switch (slicer)
+  switch (slicer)
     {
     case 0:
-        NOHorizontalSlider->setValue(slice);
-        break;
+      NOHorizontalSlider->setValue(slice);
+      break;
     case 1:
-        NEHorizontalSlider->setValue(slice);
-        break;
+      NEHorizontalSlider->setValue(slice);
+      break;
     case 2:
-        SOHorizontalSlider->setValue(slice);
-        break;
+      SOHorizontalSlider->setValue(slice);
+      break;
     case 3:
-        SEHorizontalSlider->setValue(slice);
-        break;
+      SEHorizontalSlider->setValue(slice);
+      break;
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax) {
-    int position = int((min+max)/2);
-    int tPosition = int((tmin+tmax)/2);
-    if (slicer == 0)
+  int position = int((min+max)/2);
+  int tPosition = int((tmin+tmax)/2);
+  if (slicer == 0)
     {
-        NOVerticalSlider->setValue(position);
-        NOVerticalSlider->setRange(min,max);
-        NOHorizontalSlider->setRange(tmin,tmax);
-        NOHorizontalSlider->setValue(tPosition);
+      NOVerticalSlider->setValue(position);
+      NOVerticalSlider->setRange(min,max);
+      NOHorizontalSlider->setRange(tmin,tmax);
+      NOHorizontalSlider->setValue(tPosition);
     }
-    else if (slicer == 1)
+  else if (slicer == 1)
     {
-        NEVerticalSlider->setValue(position);
-        NEVerticalSlider->setRange(min,max);
-        NEHorizontalSlider->setRange(tmin,tmax);
-        NEHorizontalSlider->setValue(tPosition);
+      NEVerticalSlider->setValue(position);
+      NEVerticalSlider->setRange(min,max);
+      NEHorizontalSlider->setRange(tmin,tmax);
+      NEHorizontalSlider->setValue(tPosition);
     }
-    else if (slicer == 2)
+  else if (slicer == 2)
     {
-        SOVerticalSlider->setValue(position);
-        SOVerticalSlider->setRange(min,max);
-        SOHorizontalSlider->setRange(tmin,tmax);
-        SOHorizontalSlider->setValue(tPosition);
+      SOVerticalSlider->setValue(position);
+      SOVerticalSlider->setRange(min,max);
+      SOHorizontalSlider->setRange(tmin,tmax);
+      SOHorizontalSlider->setValue(tPosition);
     }
-    else if (slicer == 3)
+  else if (slicer == 3)
     {
-        SEVerticalSlider->setValue(position);
-        SEVerticalSlider->setRange(min,max);
-        SEHorizontalSlider->setRange(tmin,tmax);
-        SEHorizontalSlider->setValue(tPosition);
+      SEVerticalSlider->setValue(position);
+      SEVerticalSlider->setRange(min,max);
+      SEHorizontalSlider->setRange(tmin,tmax);
+      SEHorizontalSlider->setValue(tPosition);
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SaveNOScreenshot() {
-    vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
-    w2i->SetInput(NOViewWidget->GetRenderWindow());
-    w2i->Update();
-    SaveScreenshot(w2i->GetOutput());
-    w2i->Delete();
+  vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
+  w2i->SetInput(NOViewWidget->GetRenderWindow());
+  w2i->Update();
+  SaveScreenshot(w2i->GetOutput());
+  w2i->Delete();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SaveNEScreenshot() {
-    vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
-    w2i->SetInput(NEViewWidget->GetRenderWindow());
-    w2i->Update();
-    SaveScreenshot(w2i->GetOutput());
-    w2i->Delete();
+  vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
+  w2i->SetInput(NEViewWidget->GetRenderWindow());
+  w2i->Update();
+  SaveScreenshot(w2i->GetOutput());
+  w2i->Delete();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SaveSOScreenshot() {
-    vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
-    w2i->SetInput(SOViewWidget->GetRenderWindow());
-    w2i->Update();
-    SaveScreenshot(w2i->GetOutput());
-    w2i->Delete();
+  vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
+  w2i->SetInput(SOViewWidget->GetRenderWindow());
+  w2i->Update();
+  SaveScreenshot(w2i->GetOutput());
+  w2i->Delete();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SaveSEScreenshot() {
-    vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
-    w2i->SetInput(SEViewWidget->GetRenderWindow());
-    w2i->Update();
-    SaveScreenshot(w2i->GetOutput());
-    w2i->Delete();
+  vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
+  w2i->SetInput(SEViewWidget->GetRenderWindow());
+  w2i->Update();
+  SaveScreenshot(w2i->GetOutput());
+  w2i->Delete();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SaveScreenshot(vtkImageData* image) {
-    QString Extensions = "Images( *.png);;";
-    Extensions += "Images( *.jpg);;";
-    Extensions += "Images( *.bmp);;";
-    Extensions += "Images( *.tif);;";
-    Extensions += "Images( *.ppm)";
-    QString fileName = QFileDialog::getSaveFileName(this,
-                       tr("Save As"),
-                       itksys::SystemTools::GetFilenamePath(
-                           mSlicerManagers[0]->GetFileName()).c_str(),
-                       Extensions);
-    if (!fileName.isEmpty())
-    {
-        const char *ext = fileName.toStdString().c_str() + strlen(fileName.toStdString().c_str()) - 4;
-        if (!strcmp(ext, ".bmp"))
+  QString Extensions = "Images( *.png);;";
+  Extensions += "Images( *.jpg);;";
+  Extensions += "Images( *.bmp);;";
+  Extensions += "Images( *.tif);;";
+  Extensions += "Images( *.ppm)";
+  QString fileName = QFileDialog::getSaveFileName(this,
+                                                  tr("Save As"),
+                                                  itksys::SystemTools::GetFilenamePath(
+                                                                                       mSlicerManagers[0]->GetFileName()).c_str(),
+                                                  Extensions);
+  if (!fileName.isEmpty())
+    {
+      const char *ext = fileName.toStdString().c_str() + strlen(fileName.toStdString().c_str()) - 4;
+      if (!strcmp(ext, ".bmp"))
         {
-            vtkBMPWriter *bmp = vtkBMPWriter::New();
-            bmp->SetInput(image);
-            bmp->SetFileName(fileName.toStdString().c_str());
-            bmp->Write();
-            bmp->Delete();
+          vtkBMPWriter *bmp = vtkBMPWriter::New();
+          bmp->SetInput(image);
+          bmp->SetFileName(fileName.toStdString().c_str());
+          bmp->Write();
+          bmp->Delete();
         }
-        else if (!strcmp(ext, ".tif"))
+      else if (!strcmp(ext, ".tif"))
         {
-            vtkTIFFWriter *tif = vtkTIFFWriter::New();
-            tif->SetInput(image);
-            tif->SetFileName(fileName.toStdString().c_str());
-            tif->Write();
-            tif->Delete();
+          vtkTIFFWriter *tif = vtkTIFFWriter::New();
+          tif->SetInput(image);
+          tif->SetFileName(fileName.toStdString().c_str());
+          tif->Write();
+          tif->Delete();
         }
-        else if (!strcmp(ext, ".ppm"))
+      else if (!strcmp(ext, ".ppm"))
         {
-            vtkPNMWriter *pnm = vtkPNMWriter::New();
-            pnm->SetInput(image);
-            pnm->SetFileName(fileName.toStdString().c_str());
-            pnm->Write();
-            pnm->Delete();
+          vtkPNMWriter *pnm = vtkPNMWriter::New();
+          pnm->SetInput(image);
+          pnm->SetFileName(fileName.toStdString().c_str());
+          pnm->Write();
+          pnm->Delete();
         }
-        else if (!strcmp(ext, ".png"))
+      else if (!strcmp(ext, ".png"))
         {
-            vtkPNGWriter *png = vtkPNGWriter::New();
-            png->SetInput(image);
-            png->SetFileName(fileName.toStdString().c_str());
-            png->Write();
-            png->Delete();
+          vtkPNGWriter *png = vtkPNGWriter::New();
+          png->SetInput(image);
+          png->SetFileName(fileName.toStdString().c_str());
+          png->Write();
+          png->Delete();
         }
-        else if (!strcmp(ext, ".jpg"))
+      else if (!strcmp(ext, ".jpg"))
         {
-            vtkJPEGWriter *jpg = vtkJPEGWriter::New();
-            jpg->SetInput(image);
-            jpg->SetFileName(fileName.toStdString().c_str());
-            jpg->Write();
-            jpg->Delete();
+          vtkJPEGWriter *jpg = vtkJPEGWriter::New();
+          jpg->SetInput(image);
+          jpg->SetFileName(fileName.toStdString().c_str());
+          jpg->Write();
+          jpg->Delete();
         }
-        else
+      else
         {
-            QMessageBox::information(this,tr("Problem saving screenshot !"),tr("Cannot save image.\nPlease set a file extension !!!"));
+          QMessageBox::information(this,tr("Problem saving screenshot !"),tr("Cannot save image.\nPlease set a file extension !!!"));
         }
     }
 
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::GoToCursor() {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    for (int column = 1; column < 5; column++)
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  for (int column = 1; column < 5; column++)
     {
-        if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1)
+      if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1)
         {
-            double* cursorPos = mSlicerManagers[index]->GetSlicer(column-1)->GetCursorPosition();
-            mSlicerManagers[index]->GetSlicer(column-1)->SetCurrentPosition(
-                cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
-            mSlicerManagers[index]->UpdateViews(1,column-1);
-            mSlicerManagers[index]->UpdateLinked(column-1);
-            break;
+          double* cursorPos = mSlicerManagers[index]->GetSlicer(column-1)->GetCursorPosition();
+          mSlicerManagers[index]->GetSlicer(column-1)->SetCurrentPosition(
+                                                                          cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
+          mSlicerManagers[index]->UpdateViews(1,column-1);
+          mSlicerManagers[index]->UpdateLinked(column-1);
+          break;
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::PlayPause() {
-    if (playMode)
+  if (playMode)
     {
-        playMode = 0;
-        playButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/player_play.png")));
-        ImageInfoChanged();
-        return;
+      playMode = 0;
+      playButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/player_play.png")));
+      ImageInfoChanged();
+      return;
     }
-    else
+  else
     {
-        int image_number=DataTree->topLevelItemCount();
-        bool has_temporal;
-        for (int i=0;i<image_number;i++)
-            if (mSlicerManagers[i]->GetImage()->GetVTKImages().size() > 1)
-            {
-                has_temporal=true;
-                break;
-            }
-        if (has_temporal)
+      int image_number=DataTree->topLevelItemCount();
+      bool has_temporal;
+      for (int i=0;i<image_number;i++)
+        if (mSlicerManagers[i]->GetImage()->GetVTKImages().size() > 1)
+          {
+            has_temporal=true;
+            break;
+          }
+      if (has_temporal)
         {
-            playMode = 1;
-            playButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/player_pause.png")));
-            QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext()));
+          playMode = 1;
+          playButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/player_pause.png")));
+          QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext()));
         }
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::PlayNext() {
-    if (playMode && !this->isHidden())
-    {
-        int image_number=DataTree->topLevelItemCount();
-        ///Only play one slicer per SM, and only if the SM is being displayed
-        for (int i=0;i<image_number;i++)
-            for (int j=0;j<4;j++)
-                if (mSlicerManagers[i]->GetImage()->GetVTKImages().size() > 1 and
-                        DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 0)
-                {
-                    mSlicerManagers[i]->SetNextTSlice(j);
-                    break;
-                }
-        QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext()));
+  if (playMode && !this->isHidden())
+    {
+      int image_number=DataTree->topLevelItemCount();
+      ///Only play one slicer per SM, and only if the SM is being displayed
+      for (int i=0;i<image_number;i++)
+        for (int j=0;j<4;j++)
+          if (mSlicerManagers[i]->GetImage()->GetVTKImages().size() > 1 and
+              DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 0)
+            {
+              mSlicerManagers[i]->SetNextTSlice(j);
+              break;
+            }
+      QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext()));
     }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
 void vvMainWindow::ShowLastImage()
 {
-    if (mSlicerManagers.size() > 1)
+  if (mSlicerManagers.size() > 1)
     {
-        QTreeWidgetItem * item=DataTree->topLevelItem(DataTree->topLevelItemCount()-1);
-        CurrentImageChanged(mSlicerManagers.back()->GetId()); //select new image
-        item->setData(1,Qt::CheckStateRole,2); //show the new image in the first panel
-        DisplayChanged(item,1);
+      QTreeWidgetItem * item=DataTree->topLevelItem(DataTree->topLevelItemCount()-1);
+      CurrentImageChanged(mSlicerManagers.back()->GetId()); //select new image
+      item->setData(1,Qt::CheckStateRole,2); //show the new image in the first panel
+      DisplayChanged(item,1);
     }
 }
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::UpdateRenderWindows() {
-    if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render();
-    if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render();
-    if (SOViewWidget->GetRenderWindow()) SOViewWidget->GetRenderWindow()->Render();
-    if (SEViewWidget->GetRenderWindow()) SEViewWidget->GetRenderWindow()->Render();
+  if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render();
+  if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render();
+  if (SOViewWidget->GetRenderWindow()) SOViewWidget->GetRenderWindow()->Render();
+  if (SEViewWidget->GetRenderWindow()) SEViewWidget->GetRenderWindow()->Render();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::ResampleCurrentImage() {
-    vvResamplerDialog resampler;
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    resampler.SetSlicerManagers(mSlicerManagers,index);
-    if (resampler.exec()) 
-        AddImage(resampler.GetOutput(),resampler.GetOutputFileName());
+  vvResamplerDialog resampler;
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  resampler.SetSlicerManagers(mSlicerManagers,index);
+  if (resampler.exec()) 
+    AddImage(resampler.GetOutput(),resampler.GetOutputFileName());
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::SegmentationOnCurrentImage() {
-    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
-    vvSegmentationDialog segmentation;
-    segmentation.SetImage(mSlicerManagers[index]->GetSlicer(0)->GetImage());
-    segmentation.exec();
+  vvSegmentationDialog segmentation;
+  segmentation.SetImage(mSlicerManagers[index]->GetSlicer(0)->GetImage());
+  segmentation.exec();
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
 void vvMainWindow::SurfaceViewerLaunch()
 {
-    vvSurfaceViewerDialog surfaceViewer;
-    surfaceViewer.exec();
+  vvSurfaceViewerDialog surfaceViewer;
+  surfaceViewer.exec();
 }
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::AddImage(vvImage::Pointer image,std::string filename)
 {
-    vvSlicerManager* m = new vvSlicerManager(4);
-    m->SetImage(image);
-    m->SetFilename(filename);
-    AddImage(m);
+  vvSlicerManager* m = new vvSlicerManager(4);
+  m->SetImage(image);
+  m->SetFilename(filename);
+  AddImage(m);
 }
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvMainWindow::AddImage(vvSlicerManager * slicer_manager) {
-    mSlicerManagers.push_back(slicer_manager);
+  mSlicerManagers.push_back(slicer_manager);
+
+  std::string filename = slicer_manager->GetFileName();
+
+  //create an item in the tree with good settings
+  QTreeWidgetItem *item = new QTreeWidgetItem();
+  item->setData(0,Qt::UserRole,slicer_manager->GetFileName().c_str());//files[i].c_str());
+  item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename.c_str());
+  qApp->processEvents();
+
+  for (int j = 1; j <= 4; j++) item->setData(j,Qt::CheckStateRole,1);
+
+  //Create the buttons for reload and close
+  qApp->processEvents();
+  QTreePushButton* cButton = new QTreePushButton;
+  cButton->setItem(item);
+  cButton->setColumn(COLUMN_CLOSE_IMAGE);
+  cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
+  connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+          this,SLOT(CloseImage(QTreeWidgetItem*, int)));
+
+  QTreePushButton* rButton = new QTreePushButton;
+  rButton->setItem(item);
+  rButton->setColumn(COLUMN_RELOAD_IMAGE);
+  rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
+  rButton->setEnabled(0);
+  connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
+          this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
+
+  DataTree->addTopLevelItem(item);
+  DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
+  DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
+
+  //set the id of the image
+  QString id = slicer_manager->GetFileName().c_str() + QString::number(mSlicerManagers.size()-1);
+  item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
+  mSlicerManagers.back()->SetId(id.toStdString());
+
+  linkPanel->addImage(filename, id.toStdString());
+
+  connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
+          this,SLOT(CurrentImageChanged(std::string)));
+  connect(mSlicerManagers.back(),SIGNAL(
+                                        UpdatePosition(int, double, double, double, double, double, double, double)),this,
+          SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
+  connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)),
+          this, SLOT(VectorChanged(int,double,double,double, double)));
+  connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
+          this, SLOT(OverlayChanged(int,double,double)));
+  connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
+          this, SLOT(FusionChanged(int,double)));
+  connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
+          this,SLOT(WindowsChanged(int, int, int)));
+  connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
+          this,SLOT(WindowLevelChanged(double, double, int, int)));
+  connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
+          this,SLOT(UpdateSlice(int,int)));
+  connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
+          this,SLOT(UpdateTSlice(int, int)));
+  connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
+          this,SLOT(UpdateSliceRange(int,int,int,int,int)));
+  connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
+          this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
+  connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
+  UpdateTree();
+  qApp->processEvents();
+  InitSlicers();
+  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;
+  int index = -1;
+  DD(DataTree->selectedItems().size());
+  if (DataTree->selectedItems().size() > 0) {
+    index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+    DD(DataTree->selectedItems()[0]);
+    DD(index);
+  }
+  mCurrentToolInfo->mSlicerManagerCurrentIndex = index;    
+
+  return mCurrentToolInfo;
+}
+//------------------------------------------------------------------------------
 
-    std::string filename = slicer_manager->GetFileName();
 
-    //create an item in the tree with good settings
-    QTreeWidgetItem *item = new QTreeWidgetItem();
-    item->setData(0,Qt::UserRole,slicer_manager->GetFileName().c_str());//files[i].c_str());
-    item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename.c_str());
-    qApp->processEvents();
-
-    for (int j = 1; j <= 4; j++) item->setData(j,Qt::CheckStateRole,1);
-
-    //Create the buttons for reload and close
-    qApp->processEvents();
-    QTreePushButton* cButton = new QTreePushButton;
-    cButton->setItem(item);
-    cButton->setColumn(COLUMN_CLOSE_IMAGE);
-    cButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")));
-    connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-            this,SLOT(CloseImage(QTreeWidgetItem*, int)));
-
-    QTreePushButton* rButton = new QTreePushButton;
-    rButton->setItem(item);
-    rButton->setColumn(COLUMN_RELOAD_IMAGE);
-    rButton->setIcon(QIcon(QString::fromUtf8(":/new/prefix1/icons/rotateright.png")));
-    rButton->setEnabled(0);
-    connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
-            this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
-
-    DataTree->addTopLevelItem(item);
-    DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
-    DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
-
-    //set the id of the image
-    QString id = slicer_manager->GetFileName().c_str() + QString::number(mSlicerManagers.size()-1);
-    item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
-    mSlicerManagers.back()->SetId(id.toStdString());
-
-    linkPanel->addImage(filename, id.toStdString());
-
-    connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
-            this,SLOT(CurrentImageChanged(std::string)));
-    connect(mSlicerManagers.back(),SIGNAL(
-                UpdatePosition(int, double, double, double, double, double, double, double)),this,
-            SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
-    connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)),
-            this, SLOT(VectorChanged(int,double,double,double, double)));
-    connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
-            this, SLOT(OverlayChanged(int,double,double)));
-    connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
-            this, SLOT(FusionChanged(int,double)));
-    connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
-            this,SLOT(WindowsChanged(int, int, int)));
-    connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
-            this,SLOT(WindowLevelChanged(double, double, int, int)));
-    connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
-            this,SLOT(UpdateSlice(int,int)));
-    connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
-            this,SLOT(UpdateTSlice(int, int)));
-    connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
-            this,SLOT(UpdateSliceRange(int,int,int,int,int)));
-    connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
-            this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
-    connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
-    UpdateTree();
-    qApp->processEvents();
-    InitSlicers();
-    ShowLastImage();
-    InitDisplay();
-    qApp->processEvents();
-
-}
-//====================================================================
index dfc2fc6116f96934cb53756ebc2112b00b0a540f..b3d60313ffa09a5b070231543ae2a01e2d4027e3 100644 (file)
@@ -17,10 +17,10 @@ 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/>.
 
-=========================================================================*/
+  =========================================================================*/
 
 #ifndef vvMainWindow_h
 #define vvMainWindow_h
@@ -33,6 +33,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "vvConstants.h"
 #include "vvImage.h"
 #include "vvMesh.h"
+#include "vvToolManager.h"
+#include "clitkCommon.h"
 
 class vvSlicerManager;
 class vvHelpDialog;
@@ -42,144 +44,164 @@ class vtkImageData;
 class vtkRenderer;
 class vvDicomSeriesSelector;
 
+//------------------------------------------------------------------------------
+struct vvMainWindowToolInfo {
+  QMenu * mMenuTools;
+  std::vector<vvSlicerManager*> * mSlicerManagers;
+  int mSlicerManagerCurrentIndex;
+};
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
 class vvMainWindow : public QMainWindow, private Ui::vvMainWindow
 {
-    Q_OBJECT
-
-public:
-    vvMainWindow();
-    ~vvMainWindow();
-    void LoadImages(std::vector<std::string> filenames, LoadedImageType type);
-    void AddImage(vvImage::Pointer image,std::string filename);
-    void AddImage(vvSlicerManager * m);
-    void AddField(QString file,int index);
-    void AddOverlayImage(int index, QString filename);
-    ///Adds a mesh to a SlicerManager, with optional warping by vector field
-    void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
-    ///This is used to show an image when opened or computed
-    void ShowLastImage();
+  Q_OBJECT
+
+  public:
+  vvMainWindow();
+  ~vvMainWindow();
+  void LoadImages(std::vector<std::string> filenames, LoadedImageType type);
+  void AddImage(vvImage::Pointer image,std::string filename);
+  void AddImage(vvSlicerManager * m);
+  void AddField(QString file,int index);
+  void AddOverlayImage(int index, QString filename);
+  ///Adds a mesh to a SlicerManager, with optional warping by vector field
+  void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
+  ///This is used to show an image when opened or computed
+  void ShowLastImage();
+
+  vvMainWindowToolInfo * GetInfoForTool();
 
 public slots:
-    ///Allows the user to open and select various surfaces contained in a dicom-struct file
-    void OpenDCStructContour();
-    ///Computes the MIP of the currently selected image and displays it
-    void ComputeMIP();
-    ///Computes the midposition image of a 4D sequence with a VF and displays it
-    void ComputeMidPosition();
-    void OpenImages();
-    ///Slot triggered by the dynamically-generated recent file menu actions
-    void OpenRecentImage();
-    void OpenImageWithTime();
-    void MergeImages();
-    void MergeImagesWithTime();
-    void OpenDicom();
-    ///Open a vtkPolyData surface mesh and display it over the current image
-    void OpenVTKContour();
-    void SaveAs();
-    void CurrentImageChanged(std::string id);
-    void ImageInfoChanged();
-    void ShowHelpDialog();
-    void ShowDocumentation();
-    void ComputeDeformableRegistration();
-    void WarpImage();
-    void ChangeViewMode();
-    void DisplayChanged(QTreeWidgetItem *item, int column);
-    void CloseImage(QTreeWidgetItem* item, int column);
-    void ReloadImage(QTreeWidgetItem* item, int column);
-    void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
-    void VectorChanged(int visibility, double x, double y, double z, double value);
-    void OverlayChanged(int visibility, double valueOver, double valueRef);
-    void FusionChanged(int visibility, double value);
-    void ResampleCurrentImage();
-    void SegmentationOnCurrentImage();
-    void SurfaceViewerLaunch();
-
-    void WindowsChanged(int window, int view, int slice);
-    void WindowLevelChanged(double window, double level,int preset, int colormap);
-    void UpdateSlice(int slicer, int slice);
-    void UpdateTSlice(int slicer, int slice);
-    void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
-    void WindowLevelEdited();
-    void UpdateColorMap();
-    void UpdateWindowLevel();
-    void SwitchWindowLevel();
-    void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
-    void AddLink(QString image1,QString image2);
-    void RemoveLink(QString image1,QString image2);
-
-    ///Generic method called when any one of the horizontal sliders is moved
-    void HorizontalSliderMoved(int value,int column, int slicer_index);
-    void NOHorizontalSliderMoved();
-    void NEHorizontalSliderMoved();
-    void SOHorizontalSliderMoved();
-    void SEHorizontalSliderMoved();
-
-    void NOVerticalSliderChanged();
-    void NEVerticalSliderChanged();
-    void SOVerticalSliderChanged();
-    void SEVerticalSliderChanged();
-
-    void SaveNEScreenshot();
-    void SaveNOScreenshot();
-    void SaveSEScreenshot();
-    void SaveSOScreenshot();
-
-    void ShowContextMenu(QPoint point);
-    void CropImage();
-    void SplitImage();
-    void CloseImage();
-    void ReloadImage();
-    void OpenField();
-    void SelectOverlayImage();
-    void AddFusionImage();
-
-    void SetVFProperty(int subsampling,int scale,int lut);
-    void SetOverlayProperty(int color);
-    void SetFusionProperty(int opacity,int colormap,double window,double level);
-
-    void GoToCursor();
-    void PlayPause();
-    void PlayNext();
-    void ChangeFrameRate(int rate) {
-        mFrameRate = rate;
-    }
-
-    void UpdateRenderWindows();
+  ///Allows the user to open and select various surfaces contained in a dicom-struct file
+  void OpenDCStructContour();
+  ///Computes the MIP of the currently selected image and displays it
+  void ComputeMIP();
+  ///Computes the midposition image of a 4D sequence with a VF and displays it
+  void ComputeMidPosition();
+  void OpenImages();
+  ///Slot triggered by the dynamically-generated recent file menu actions
+  void OpenRecentImage();
+  void OpenImageWithTime();
+  void MergeImages();
+  void MergeImagesWithTime();
+  void OpenDicom();
+  ///Open a vtkPolyData surface mesh and display it over the current image
+  void OpenVTKContour();
+  void SaveAs();
+  void CurrentImageChanged(std::string id);
+  void ImageInfoChanged();
+  void ShowHelpDialog();
+  void ShowDocumentation();
+  void ComputeDeformableRegistration();
+  void WarpImage();
+  void ChangeViewMode();
+  void DisplayChanged(QTreeWidgetItem *item, int column);
+  void CloseImage(QTreeWidgetItem* item, int column);
+  void ReloadImage(QTreeWidgetItem* item, int column);
+  void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
+  void VectorChanged(int visibility, double x, double y, double z, double value);
+  void OverlayChanged(int visibility, double valueOver, double valueRef);
+  void FusionChanged(int visibility, double value);
+  void ResampleCurrentImage();
+  void SegmentationOnCurrentImage();
+  void SurfaceViewerLaunch();
+
+  void WindowsChanged(int window, int view, int slice);
+  void WindowLevelChanged(double window, double level,int preset, int colormap);
+  void UpdateSlice(int slicer, int slice);
+  void UpdateTSlice(int slicer, int slice);
+  void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
+  void WindowLevelEdited();
+  void UpdateColorMap();
+  void UpdateWindowLevel();
+  void SwitchWindowLevel();
+  void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
+  void AddLink(QString image1,QString image2);
+  void RemoveLink(QString image1,QString image2);
+
+  ///Generic method called when any one of the horizontal sliders is moved
+  void HorizontalSliderMoved(int value,int column, int slicer_index);
+  void NOHorizontalSliderMoved();
+  void NEHorizontalSliderMoved();
+  void SOHorizontalSliderMoved();
+  void SEHorizontalSliderMoved();
+
+  void NOVerticalSliderChanged();
+  void NEVerticalSliderChanged();
+  void SOVerticalSliderChanged();
+  void SEVerticalSliderChanged();
+
+  void SaveNEScreenshot();
+  void SaveNOScreenshot();
+  void SaveSEScreenshot();
+  void SaveSOScreenshot();
+
+  void ShowContextMenu(QPoint point);
+  void CropImage();
+  void SplitImage();
+  void CloseImage();
+  void ReloadImage();
+  void OpenField();
+  void SelectOverlayImage();
+  void AddFusionImage();
+
+  void SetVFProperty(int subsampling,int scale,int lut);
+  void SetOverlayProperty(int color);
+  void SetFusionProperty(int opacity,int colormap,double window,double level);
+
+  void GoToCursor();
+  void PlayPause();
+  void PlayNext();
+  void ChangeFrameRate(int rate) {
+    mFrameRate = rate;
+  }
+  void UpdateRenderWindows();
+
+// signals:
+//   void SlicerManagersHasChanged();
 
 private:
 
-    //variables
-    std::vector<vvSlicerManager*> mSlicerManagers;
-    vvHelpDialog *help_dialog;
-    vvDocumentation *documentation;
-    vvDicomSeriesSelector *dicomSeriesSelector;
-
-    QString mInputPathName;
-    bool viewMode;
-    bool playMode;
-
-    //functions
-    void UpdateTree();
-    ///Adds a vector field to slicer manager index
-    void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
-    void AddFieldEntry(QString filename,int index,bool from_disk);
-    void AddField(vvImage::Pointer vf,QString file,int index);
-    void InitDisplay();
-    ///Sets the render window and LUT for the last SlicerManager
-    void InitSlicers();
-    void DisplaySliders(int slicer, int window);
-    QString GetSizeInBytes(unsigned long size);
-    QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
-    QString GetVectorIntAsString(std::vector<int> vectorInt);
-    int GetSlicerIndexFromItem(QTreeWidgetItem* item);
-    void SaveScreenshot(vtkImageData* image);
-
-    QMenu contextMenu;
-    //QMenu *AddSubImageMenu;
-    std::vector<QAction*> contextActions;
-    std::vector<QSlider*> horizontalSliders;
-    std::vector<QSlider*> verticalSliders;
-    int mFrameRate;
+  //variables
+  std::vector<vvSlicerManager*> mSlicerManagers;
+  vvHelpDialog *help_dialog;
+  vvDocumentation *documentation;
+  vvDicomSeriesSelector *dicomSeriesSelector;
+
+  QString mInputPathName;
+  bool viewMode;
+  bool playMode;
+
+  //functions
+  void UpdateTree();
+  ///Adds a vector field to slicer manager index
+  void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
+  void AddFieldEntry(QString filename,int index,bool from_disk);
+  void AddField(vvImage::Pointer vf,QString file,int index);
+  void InitDisplay();
+  ///Sets the render window and LUT for the last SlicerManager
+  void InitSlicers();
+  void DisplaySliders(int slicer, int window);
+  QString GetSizeInBytes(unsigned long size);
+  QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
+  QString GetVectorIntAsString(std::vector<int> vectorInt);
+  int GetSlicerIndexFromItem(QTreeWidgetItem* item);
+  void SaveScreenshot(vtkImageData* image);
+
+  QMenu contextMenu;
+  //QMenu *AddSubImageMenu;
+  std::vector<QAction*> contextActions;
+  std::vector<QSlider*> horizontalSliders;
+  std::vector<QSlider*> verticalSliders;
+  int mFrameRate;
+
+  vvMainWindowToolInfo * mCurrentToolInfo;
+
+  static vvMainWindow * mSingleton;
 };
 
+#include "vvMainWindow.txx"
+
 #endif
diff --git a/vv/vvMainWindow.txx b/vv/vvMainWindow.txx
new file mode 100644 (file)
index 0000000..c8227e5
--- /dev/null
@@ -0,0 +1,42 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvMainWindow.txx,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54:37 $
+  Version:   $Revision: 1.1 $
+  Author :   Pierre Seroul (pierre.seroul@gmail.com)
+
+  Copyright (C) 200COLUMN_IMAGE_NAME
+  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/>.
+
+  =========================================================================*/
+
+//------------------------------------------------------------------------------
+// #define CREATE_TOOL_CALLBACK(TOOL_NAME) 
+//   void vvMainWindow::bidon();
+
+//------------------------------------------------------------------------------
+// template<class ToolType>
+// void vvMainWindow::addNewToolInMenu() {
+//   QAction * binarizeAction = new QAction(QIcon(":/new/prefix1/icons/binarize.png"), tr("&Binarize..."), this);
+//   binarizeAction->setStatusTip(tr("Binarization of an image by thresholding."));
+
+//   // CREATE_TOOL_CALLBACK(toto);
+
+//   connect(binarizeAction, SIGNAL(triggered()), this, SLOT(commonToolAction()));
+//   menuTools->addAction(binarizeAction);
+// }
diff --git a/vv/vvToolBase.cxx b/vv/vvToolBase.cxx
new file mode 100644 (file)
index 0000000..9919227
--- /dev/null
@@ -0,0 +1,41 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolBase.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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/>.
+
+  =========================================================================*/
+
+#ifndef VVTOOLBASE_CXX
+#define VVTOOLBASE_CXX
+
+#include "vvToolBase.h"
+
+// //------------------------------------------------------------------------------
+// void vvToolBaseBase::initializeListOfInputImages() {
+
+// }
+
+
+
+#endif
+
diff --git a/vv/vvToolBase.h b/vv/vvToolBase.h
new file mode 100644 (file)
index 0000000..dc62849
--- /dev/null
@@ -0,0 +1,139 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolBase.h,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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/>.
+
+  =========================================================================*/
+
+#ifndef VVTOOLBASE_H
+#define VVTOOLBASE_H
+
+#include "vvToolCreatorBase.h"
+#include "vvToolInputSelectorWidget.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//------------------------------------------------------------------------------
+template<class ToolType>
+class vvToolBase {
+public:
+  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->CheckDimension(image->GetNumberOfDimensions()) && 
+         mFilter->CheckPixelType(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;
+      }
+    }
+  }  
+}
+//------------------------------------------------------------------------------
+
+
+#endif
+
diff --git a/vv/vvToolBinarize.cxx b/vv/vvToolBinarize.cxx
new file mode 100644 (file)
index 0000000..a7579d8
--- /dev/null
@@ -0,0 +1,394 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolBinarize.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 "vvToolBinarize.h"
+#include "vvSlicerManager.h"
+#include "vvSlicer.h"
+#include "vvToolInputSelectorWidget.h"
+
+#include "clitkBinarizeImageGenericFilter.h"
+
+#include "vtkImageActor.h"
+#include "vtkCamera.h"
+
+//------------------------------------------------------------------------------
+// Create the tool and automagically (I like this word) insert it in
+// the main window menu.
+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);
+
+  // GUI Initialization
+  setupUi(this);
+
+  // 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)));
+
+  // VTK objects
+  mClipper = vtkImageClip::New();
+  mSquares1 = vtkMarchingSquares::New();
+  mSquaresMapper1 = vtkPolyDataMapper::New();
+  mSquaresActor1 = vtkActor::New();
+
+  // 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() {
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::enableLowerThan(bool b) {
+  if (!b) {
+    mThresholdSlider1->resetMaximum();
+  }
+  else {
+    valueChangedT1(mThresholdSlider1->GetValue());
+  }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::InputIsSelected() {
+
+  // Common
+  int index = mToolInputSelectionWidget->GetSelectedInputIndex();
+  mCurrentSliceManager = mSlicerManagersCompatible[index];
+  mCurrentImage = mCurrentSliceManager->GetImage();
+  toolMainWidget->setEnabled(true);
+
+  // Specific for this gui
+  mThresholdSlider1->SetImage(mCurrentImage);
+  mThresholdSlider2->SetImage(mCurrentImage);
+  mFGSlider->SetImage(mCurrentImage);
+  mBGSlider->SetImage(mCurrentImage);
+  mFGSlider->SetValue(1);
+  mBGSlider->SetValue(0);
+  DD(mCurrentSliceManager->GetFileName().c_str());
+  
+  DD("VTK");
+  DD(mCurrentSliceManager->NumberOfSlicers());
+  //    mClipper->SetInput(mCurrentSliceManager->GetSlicer(0)->GetInput());
+  DD(mCurrentImage->GetFirstVTKImageData());
+  DD(mClipper);
+  DD(mCurrentSliceManager->GetSlicer(0));
+  mClipper->SetInput(mCurrentImage->GetFirstVTKImageData());
+  
+  mSquares1->SetInput(mClipper->GetOutput());
+  mSquaresMapper1->SetInput(mSquares1->GetOutput());
+  mSquaresActor1->SetMapper(mSquaresMapper1);
+  mSquaresActor1->GetProperty()->SetColor(1.0,0,0);
+  mSquaresActor1->SetPickable(0);
+  mCurrentSliceManager->GetSlicer(0)->GetRenderer()->AddActor(mSquaresActor1);
+  mSquares1->Update();
+  
+  
+  DD("VTK end");
+  
+  //    connect(mCurrentSliceManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
+  connect(mCurrentSliceManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
+  //connect(mCurrentSliceManager,SIGNAL(UpdateSliceRange(int,int,int,int,int)),this,SLOT(UpdateSlice(int, int)));
+  //    connect(mCurrentSliceManager,SIGNAL(LandmarkAdded()),this,SLOT(InsertSeed()));
+  
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::UpdateSlice(int slicer,int slices) {
+  // A METTRE SUR TOUT LES SLICES ! PAS QUE 0
+
+  // !! signal update slice pas tjs quand move slicer ???
+
+
+   int slice = mCurrentSliceManager->GetSlicer(0)->GetSlice();
+    int tslice = mCurrentSliceManager->GetSlicer(0)->GetTSlice();
+    mClipper->SetInput(mCurrentSliceManager->GetSlicer(0)->GetInput());
+    int* extent = mCurrentSliceManager->GetSlicer(0)->GetImageActor()->GetDisplayExtent();
+    mClipper->SetOutputWholeExtent(extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]);
+    int i;
+    for (i = 0; i < 6;i = i+2)
+    {
+        if (extent[i] == extent[i+1])
+        {
+            break;
+        }
+    }
+
+    switch (i)
+    {
+    case 0:
+        if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice)
+        {
+            mSquaresActor1->SetPosition(1,0,0);
+            // mSquaresActor2->SetPosition(1,0,0);
+        }
+        else
+        {
+            mSquaresActor1->SetPosition(-1,0,0);
+            // mSquaresActor2->SetPosition(-1,0,0);
+        }
+        break;
+    case 2:
+        if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice)
+        {
+            mSquaresActor1->SetPosition(0,1,0);
+          //   mSquaresActor2->SetPosition(0,1,0);
+        }
+        else
+        {
+            mSquaresActor1->SetPosition(0,-1,0);
+            // mSquaresActor2->SetPosition(0,-1,0);
+        }
+        break;
+    case 4:
+        if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice)
+        {
+            mSquaresActor1->SetPosition(0,0,1);
+            // mSquaresActor2->SetPosition(0,0,1);
+        }
+        else
+        {
+            mSquaresActor1->SetPosition(0,0,-1);
+            // mSquaresActor2->SetPosition(0,0,-1);
+        }
+        break;
+    }
+    mSquares1->Update();
+   //  mSquares2->Update();
+
+    mCurrentSliceManager->Render(); 
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::GetArgsInfoFromGUI() {
+
+  /* //KEEP THIS FOR READING GGO FROM FILE
+    int argc=1;
+    std::string a = "toto";
+    char * const* argv = new char*;
+    //a.c_str();
+    struct cmdline_parser_params p;
+    p.check_required = 0;
+    int good = cmdline_parser_ext(argc, argv, &args_info, &p);
+  DD(good);
+  */
+
+  mArgsInfo.upper_given = 0;
+  mArgsInfo.lower_given = 0;
+  bool inverseBGandFG = false;
+
+  if (mRadioButtonGreaterThan->isChecked()) { // Greater Than (and Lower Than)
+    mArgsInfo.lower_given = 1;
+    mArgsInfo.lower_arg = mThresholdSlider1->GetValue();
+    DD(mArgsInfo.lower_arg);
+    if (mRadioButtonLowerThan->isChecked()) {
+      mArgsInfo.upper_given = 1;
+      mArgsInfo.upper_arg = mThresholdSlider2->GetValue();
+      if (mArgsInfo.upper_arg<mArgsInfo.lower_arg) {
+        mArgsInfo.upper_given = 0;
+        DD("TODO : lower thres greater than greater thres ! Ignoring ");
+      }
+    }
+  }
+  else {
+    if (mRadioButtonEqualThan->isChecked()) {
+      mArgsInfo.lower_given = 1;
+      mArgsInfo.upper_given = 1;
+      mArgsInfo.lower_arg = mThresholdSlider1->GetValue();
+      mArgsInfo.upper_arg = mThresholdSlider1->GetValue();
+    }
+    else {
+      mArgsInfo.lower_given = 1;
+      mArgsInfo.upper_given = 1;
+      mArgsInfo.lower_arg = mThresholdSlider1->GetValue();
+      mArgsInfo.upper_arg = mThresholdSlider1->GetValue();
+      inverseBGandFG = true;
+    }
+  }
+
+  mArgsInfo.inside_arg = mFGSlider->GetValue();
+  mArgsInfo.outside_arg = mBGSlider->GetValue();
+  if (inverseBGandFG) {
+    mArgsInfo.inside_arg = mBGSlider->GetValue();
+    mArgsInfo.outside_arg = mFGSlider->GetValue();
+  }
+  mArgsInfo.inside_given = 1;
+  mArgsInfo.outside_given = 1;
+
+  mArgsInfo.verbose_flag = true;
+
+  // Required (even if not used)
+  mArgsInfo.input_given = 0;
+  mArgsInfo.output_given = 0;
+  
+  mArgsInfo.input_arg = new char;
+  mArgsInfo.output_arg = new char;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::apply() {
+  DD("Apply");
+
+  GetArgsInfoFromGUI();
+
+  DD(mArgsInfo.lower_arg);
+  // cmdline_parser2(argc, argv, &args_info, 1, 1, 0);                 
+  //   if (args_info.config_given)     
+  // cmdline_parser_configfile ("toto.config", &args_info, 0, 0, 1);
+  //   else cmdline_parser(argc, argv, &args_info);
+
+  // Main filter
+  clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>::Pointer filter = 
+    clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>::New();
+  filter->SetArgsInfo(mArgsInfo);
+  filter->SetInputVVImage(mCurrentImage);
+  filter->Update();
+
+  // Output ???
+  vvImage::Pointer output = filter->GetOutputVVImage();
+  DD(output->GetScalarTypeAsString());
+  CREATOR(vvToolBinarize)->mMainWindow->AddImage(output,"toto.mhd"); 
+  close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::valueChangedT2(double v) {
+  if (mRadioButtonLowerThan->isChecked()) mThresholdSlider1->SetMaximum(v);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::valueChangedT1(double v) {
+  mThresholdSlider2->SetMinimum(v);
+  DD(v);
+  int m1 = (int)lrint(v);
+  DD(m1);  
+  int* extent = mCurrentSliceManager->GetSlicer(0)->GetImageActor()->GetDisplayExtent();
+  mClipper->SetOutputWholeExtent(extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]);
+
+
+int slice = mCurrentSliceManager->GetSlicer(0)->GetSlice();
+
+ int i;
+for (i = 0; i < 6;i = i+2)
+    {
+        if (extent[i] == extent[i+1])
+        {
+            break;
+        }
+    }
+
+    switch (i)
+    {
+    case 0:
+        if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice)
+        {
+            mSquaresActor1->SetPosition(1,0,0);
+            // mSquaresActor2->SetPosition(1,0,0);
+        }
+        else
+        {
+            mSquaresActor1->SetPosition(-1,0,0);
+            // mSquaresActor2->SetPosition(-1,0,0);
+        }
+        break;
+    case 2:
+        if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice)
+        {
+            mSquaresActor1->SetPosition(0,1,0);
+           //  mSquaresActor2->SetPosition(0,1,0);
+        }
+        else
+        {
+            mSquaresActor1->SetPosition(0,-1,0);
+            // mSquaresActor2->SetPosition(0,-1,0);
+        }
+        break;
+    case 4:
+        if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice)
+        {
+            mSquaresActor1->SetPosition(0,0,1);
+            // mSquaresActor2->SetPosition(0,0,1);
+        }
+        else
+        {
+            mSquaresActor1->SetPosition(0,0,-1);
+            // mSquaresActor2->SetPosition(0,0,-1);
+        }
+        break;
+    }
+
+
+
+
+  mSquares1->SetValue(0,m1);
+  mSquares1->Update();
+  mCurrentSliceManager->Render();
+}
+//------------------------------------------------------------------------------
diff --git a/vv/vvToolBinarize.h b/vv/vvToolBinarize.h
new file mode 100644 (file)
index 0000000..323514b
--- /dev/null
@@ -0,0 +1,100 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolBinarize.h,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 VVTOOLBINARIZE_H
+#define VVTOOLBINARIZE_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include <QDialog>
+
+#include "vvToolBase.h"
+#include "ui_vvToolBinarize.h"
+#include "clitkBinarizeImage_ggo.h"
+
+#include "vtkMarchingSquares.h"
+#include "vtkImageClip.h"
+#include "vtkMarchingCubes.h"
+#include "vtkPolyData.h"
+#include "vtkPolyDataMapper.h"
+#include "vtkActor.h"
+#include "vtkProperty.h"
+#include "vtkRenderer.h"
+
+//------------------------------------------------------------------------------
+class QDESIGNER_WIDGET_EXPORT vvToolBinarize: 
+  public QDialog, public vvToolBase<vvToolBinarize>, private Ui::vvToolBinarize 
+{
+  Q_OBJECT
+    public:
+  vvToolBinarize(QWidget * 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.");
+  }
+
+  void InputIsSet(bool b);
+  void GetArgsInfoFromGUI();
+
+  //-----------------------------------------------------
+ // public slots:
+//   void InputUpdate();
+
+  public slots:
+  void apply();
+  // void InputChange(int index);
+  void valueChangedT1(double v);
+  void valueChangedT2(double v);
+  void UpdateSlice(int slicer,int slices);
+  void InputIsSelected();
+  void enableLowerThan(bool b);
+
+ protected:
+  Ui::vvToolBinarize ui;
+  // std::vector<vvSlicerManager*> mSlicerManagers;
+//   std::vector<vvSlicerManager*> mSlicerManagersCompatible;
+//   vvImage::Pointer mCurrentImage;
+//   vvSlicerManager * mCurrentSliceManager;
+  args_info_clitkBinarizeImage mArgsInfo;
+
+  vtkImageClip* mClipper;
+  vtkMarchingSquares* mSquares1;
+  vtkPolyDataMapper* mSquaresMapper1;
+  vtkActor* mSquaresActor1;
+
+}; // end class vvToolBinarize
+//------------------------------------------------------------------------------
+
+#endif
+
diff --git a/vv/vvToolCreatorBase.cxx b/vv/vvToolCreatorBase.cxx
new file mode 100644 (file)
index 0000000..e47fa14
--- /dev/null
@@ -0,0 +1,68 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolCreatorBase.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 "vvToolCreatorBase.h"
+#include "vvSlicerManager.h"
+#include "vvToolManager.h"
+#include <QAction>
+
+//------------------------------------------------------------------------------
+vvToolCreatorBase::vvToolCreatorBase(QString name) { 
+  mToolName = name;
+  vvToolManager::GetInstance()->AddTool(this); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolCreatorBase::Initialize(vvMainWindow * 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(mAction, SIGNAL(triggered()), this, SLOT(MenuToolSlot()));
+  mMainWindow->GetInfoForTool()->mMenuTools->addAction(mAction);
+  //UpdateEnabledTool();
+} 
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+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);
+}
+//------------------------------------------------------------------------------
diff --git a/vv/vvToolCreatorBase.h b/vv/vvToolCreatorBase.h
new file mode 100644 (file)
index 0000000..4f7538b
--- /dev/null
@@ -0,0 +1,93 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolCreatorBase.h,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 VVTOOLCREATORBASE_H
+#define VVTOOLCREATORBASE_H
+
+#include "clitkCommon.h"
+#include <QObject>
+
+// For vvMainWindowToolInfo
+#include "vvMainWindow.h"
+class vvMainWindow;
+// struct vvMainWindowToolInfo;
+class QAction;
+
+//------------------------------------------------------------------------------
+class vvToolCreatorBase: public QObject {
+  Q_OBJECT
+  public:
+
+  vvToolCreatorBase(QString name);
+  virtual ~vvToolCreatorBase() {;}
+  
+  virtual void Initialize(vvMainWindow * m);
+  virtual void UpdateEnabledTool();
+  template<class ToolType> void CreateTool();
+  virtual void MenuSpecificToolSlot() = 0;
+  
+  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>(); }
+};
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+#define CREATOR(CLASSNAME) vvToolCreator<CLASSNAME>::mSingleton
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+#define ADD_TOOL(NAME)                                          \
+  template<>                                                    \
+  vvToolCreator<NAME> * vvToolCreator<NAME>::mSingleton =       \
+    new vvToolCreator<NAME>(#NAME);
+//------------------------------------------------------------------------------
+
+#include "vvToolCreatorBase.txx"
+
+#endif
+
diff --git a/vv/vvToolCreatorBase.txx b/vv/vvToolCreatorBase.txx
new file mode 100644 (file)
index 0000000..1548266
--- /dev/null
@@ -0,0 +1,60 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolCreatorBase.txx,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 "vvMainWindow.h"
+#include "vvSlicerManager.h"
+
+//------------------------------------------------------------------------------
+template<class ToolType>
+void vvToolCreatorBase::CreateTool() {
+  DD("Create new tool ");
+  ToolType * tool = new ToolType(mMainWindow);
+  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/vvToolInputSelectorWidget.cxx b/vv/vvToolInputSelectorWidget.cxx
new file mode 100644 (file)
index 0000000..0cb8c01
--- /dev/null
@@ -0,0 +1,120 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolInputSelectorWidget.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 VVTOOLINPUTSELECTORWIDGET_CXX
+#define VVTOOLINPUTSELECTORWIDGET_CXX
+
+#include "vvToolInputSelectorWidget.h"
+#include "vvSlicerManager.h"
+
+//------------------------------------------------------------------------------
+vvToolInputSelectorWidget::vvToolInputSelectorWidget(QWidget * parent, Qt::WindowFlags f):
+  QWidget(parent, f) {
+  setupUi(this);  
+
+  setEnabled(true);
+
+  // Connect signals & slots  
+  connect(mInputSelectionButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
+  connect(mInputSelectionButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
+  connect(mInputSequenceBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeInput(int)));  
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolInputSelectorWidget::Initialize(std::vector<vvSlicerManager*> l, int index) {
+  DD("Initialize"); DD(index);
+  mInputSequenceBox->clear();
+  mSlicerManagerList = l;
+  mCurrentIndex = index;
+  for (unsigned int i = 0; i < mSlicerManagerList.size(); i++) {
+    mInputSequenceBox->addItem(mSlicerManagerList[i]->GetFileName().c_str());
+  }
+  mInputSequenceBox->setCurrentIndex(mCurrentIndex);
+  if (mSlicerManagerList.size() == 0) {
+    // TODO !!!
+    DD("no input > error message");
+    reject();
+  }
+  if (mSlicerManagerList.size() == 1) {
+    accept();
+  }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolInputSelectorWidget::SetToolTip(QString s) {
+  //  mLabelSelection->setToolTip(s);
+  //mInputSequenceBox->setToolTip(s);
+  setToolTip(s);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolInputSelectorWidget::accept() {
+  mInputSelectionButtonBox->setEnabled(false);
+  mInputSequenceBox->setEnabled(false);
+  emit accepted();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolInputSelectorWidget::reject() {
+  emit rejected();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolInputSelectorWidget::changeInput(int index) {
+  mCurrentIndex = index;
+  vvImage * mCurrentImage = mSlicerManagerList[index]->GetImage();
+  unsigned int d = mCurrentImage->GetNumberOfDimensions();
+  QString size;
+  QString spacing;
+  for(unsigned int i=0; i<d-1; i++) {
+    size.append(QString("%1").arg(mCurrentImage->GetSize()[i]));
+    size.append("x");
+    spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[i]));
+    spacing.append("x");
+  }
+  size.append(QString("%1").arg(mCurrentImage->GetSize()[d-1]));
+  spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[d-1]));
+  mLabelInputInfo->setText(QString("Image: %1D %2   %3    %4")
+                           .arg(d)
+                           .arg(mCurrentImage->GetScalarTypeAsString().c_str())
+                           .arg(size)
+                           .arg(spacing));
+}
+//------------------------------------------------------------------------------
+
+#endif
+
diff --git a/vv/vvToolInputSelectorWidget.h b/vv/vvToolInputSelectorWidget.h
new file mode 100644 (file)
index 0000000..d84673f
--- /dev/null
@@ -0,0 +1,69 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolInputSelectorWidget.h,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 VVTOOLINPUTSELECTORWIDGET_H
+#define VVTOOLINPUTSELECTORWIDGET_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include <QDialog>
+
+#include "ui_vvToolInputSelectorWidget.h"
+
+class vvSlicerManager;
+
+//------------------------------------------------------------------------------
+class QDESIGNER_WIDGET_EXPORT vvToolInputSelectorWidget:
+  public QWidget, private Ui::vvToolInputSelectorWidget 
+{
+  Q_OBJECT
+    public:
+  vvToolInputSelectorWidget(QWidget * parent=0, Qt::WindowFlags f=0);
+  ~vvToolInputSelectorWidget() {}
+  
+  void Initialize(std::vector<vvSlicerManager*> l, int index);
+  int GetSelectedInputIndex() { return mCurrentIndex; }
+  void SetToolTip(QString s);
+
+ public slots:
+  void accept();
+  void reject();
+  void changeInput(int i);
+
+ signals:
+  void accepted();
+  void rejected();
+
+ protected:
+  Ui::vvToolInputSelectorWidget ui;
+  std::vector<vvSlicerManager*> mSlicerManagerList;
+  int mCurrentIndex;
+
+}; // end class vvToolInputSelectorWidget
+//------------------------------------------------------------------------------
+
+#endif
+
diff --git a/vv/vvToolManager.cxx b/vv/vvToolManager.cxx
new file mode 100644 (file)
index 0000000..0a80a47
--- /dev/null
@@ -0,0 +1,64 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolManager.cxx,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 "vvToolManager.h"
+#include "vvMainWindow.h"
+
+//------------------------------------------------------------------------------
+vvToolManager * vvToolManager::GetInstance() {
+  if (mSingleton == 0) {
+    mSingleton = new vvToolManager;
+  }
+  return mSingleton;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolManager::AddTool(vvToolCreatorBase * v)  {
+  std::cout << "Adding the tool <" << v->mToolName.toStdString() << ">." << std::endl;
+  mListOfTools.push_back(v);
+}  
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolManager::Initialize(vvMainWindow * m) {
+  for(unsigned int i=0; i<mListOfTools.size(); i++) {
+    mListOfTools[i]->Initialize(m);
+  }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolManager::UpdateEnabledTool() {
+  for(unsigned int i=0; i<mListOfTools.size(); i++) {
+    mListOfTools[i]->UpdateEnabledTool();
+  }
+}
+//------------------------------------------------------------------------------
diff --git a/vv/vvToolManager.h b/vv/vvToolManager.h
new file mode 100644 (file)
index 0000000..afd5936
--- /dev/null
@@ -0,0 +1,64 @@
+/*=========================================================================
+
+  Program:   vv
+  Module:    $RCSfile: vvToolManager.h,v $
+  Language:  C++
+  Date:      $Date: 2010/01/29 13:54: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 VVTOOLMANAGER_H
+#define VVTOOLMANAGER_H
+
+#include "vvToolCreatorBase.h"
+#include "clitkCommon.h"
+
+class vvToolCreatorBase;
+class vvMainWindow;
+
+//------------------------------------------------------------------------------
+// Manage a list of ToolCreator. Each tool will be automagically
+// inserted into a list at construction time, before main. Then the
+// MainWindow will call the 'Initialize' to insert the tool in the
+// menu bar.
+class vvToolManager {
+public:
+  // Functions
+  static vvToolManager * GetInstance();  
+  static void AddTool(vvToolCreatorBase * v);
+  static void Initialize(vvMainWindow * m);
+  static void UpdateEnabledTool();
+  // Variables
+  static std::vector<vvToolCreatorBase *> mListOfTools;
+  static vvToolManager * mSingleton;
+};
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Static instances initialization (to put in main)
+#define TOOL_MANAGER_INITIALIZATION                                     \
+  vvToolManager* vvToolManager::mSingleton=0;                           \
+  std::vector<vvToolCreatorBase *> vvToolManager::mListOfTools;
+//------------------------------------------------------------------------------
+
+
+#endif
+