]> Creatis software - clitk.git/commitdiff
First version of new ROI tool (the goal is to put it into the main tab and allow...
authorDavid Sarrut <david.sarrut@gmail.com>
Thu, 2 Feb 2012 08:38:45 +0000 (09:38 +0100)
committerDavid Sarrut <david.sarrut@gmail.com>
Thu, 2 Feb 2012 08:38:45 +0000 (09:38 +0100)
vv/qt_ui/vvToolROIManager.ui [new file with mode: 0644]
vv/vvToolROIManager.cxx [new file with mode: 0644]
vv/vvToolROIManager.h [new file with mode: 0644]

diff --git a/vv/qt_ui/vvToolROIManager.ui b/vv/qt_ui/vvToolROIManager.ui
new file mode 100644 (file)
index 0000000..60c247d
--- /dev/null
@@ -0,0 +1,542 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolROIManager</class>
+ <widget class="QWidget" name="vvToolROIManager">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>411</width>
+    <height>534</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>16777215</width>
+    <height>16777215</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_3">
+   <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="QLabel" name="mLabelInputInfo">
+       <property name="font">
+        <font>
+         <pointsize>11</pointsize>
+         <weight>75</weight>
+         <bold>true</bold>
+        </font>
+       </property>
+       <property name="frameShape">
+        <enum>QFrame::NoFrame</enum>
+       </property>
+       <property name="text">
+        <string>No selected image</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignCenter</set>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_3">
+       <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="QPushButton" name="mCloseButton">
+       <property name="toolTip">
+        <string/>
+       </property>
+       <property name="autoFillBackground">
+        <bool>false</bool>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../vvIcons.qrc">
+         <normaloff>:/common/icons/exit.png</normaloff>:/common/icons/exit.png</iconset>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="vectorFieldNameLabel_4">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Load ROI from image</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="mOpenBinaryButton">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>24</width>
+         <height>24</height>
+        </size>
+       </property>
+       <property name="toolTip">
+        <string>Open label image</string>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../vvIcons.qrc">
+         <normaloff>:/common/icons/fileopen.png</normaloff>:/common/icons/fileopen.png</iconset>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_4">
+       <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="QLabel" name="dimensionStaticLabel">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>BG</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSpinBox" name="mBackgroundValueSpinBox"/>
+     </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>
+    <widget class="QTreeWidget" name="mTree">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="editTriggers">
+      <set>QAbstractItemView::AllEditTriggers</set>
+     </property>
+     <property name="tabKeyNavigation">
+      <bool>true</bool>
+     </property>
+     <property name="alternatingRowColors">
+      <bool>true</bool>
+     </property>
+     <property name="selectionMode">
+      <enum>QAbstractItemView::SingleSelection</enum>
+     </property>
+     <property name="selectionBehavior">
+      <enum>QAbstractItemView::SelectRows</enum>
+     </property>
+     <property name="animated">
+      <bool>true</bool>
+     </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
+     <column>
+      <property name="text">
+       <string>ID</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Name</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Color</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Depth</string>
+      </property>
+     </column>
+     <item>
+      <property name="text">
+       <string>10</string>
+      </property>
+      <property name="text">
+       <string>Toto.mhd.toiefkjhfdjvhjhf</string>
+      </property>
+      <property name="text">
+       <string>Red</string>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </item>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="mGroupBoxROI">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title">
+      <string>Selected ROI</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_8">
+        <item>
+         <widget class="QCheckBox" name="mCheckBoxShow">
+          <property name="text">
+           <string>Visible</string>
+          </property>
+          <property name="checked">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="mChangeColorButton">
+          <property name="toolTip">
+           <string/>
+          </property>
+          <property name="autoFillBackground">
+           <bool>false</bool>
+          </property>
+          <property name="text">
+           <string>Color</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="mReloadButton">
+          <property name="toolTip">
+           <string>Reload image</string>
+          </property>
+          <property name="autoFillBackground">
+           <bool>false</bool>
+          </property>
+          <property name="text">
+           <string/>
+          </property>
+          <property name="icon">
+           <iconset resource="../vvIcons.qrc">
+            <normaloff>:/common/icons/rotateright.png</normaloff>:/common/icons/rotateright.png</iconset>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_5">
+        <item>
+         <widget class="QLabel" name="vectorFieldNameLabel_7">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string>Opacity</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSlider" name="mOpacitySlider">
+          <property name="maximum">
+           <number>100</number>
+          </property>
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="mOpacitySpinBox">
+          <property name="maximum">
+           <number>100</number>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_9">
+        <item>
+         <widget class="QCheckBox" name="mContourCheckBoxShow">
+          <property name="text">
+           <string>Contour</string>
+          </property>
+          <property name="checked">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="mChangeContourColorButton">
+          <property name="toolTip">
+           <string/>
+          </property>
+          <property name="autoFillBackground">
+           <bool>false</bool>
+          </property>
+          <property name="text">
+           <string>Color</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_6">
+          <item>
+           <widget class="QLabel" name="mROInameLabel_2">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="text">
+             <string>Width</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QSpinBox" name="mContourWidthSpinBox">
+            <property name="minimum">
+             <number>1</number>
+            </property>
+            <property name="maximum">
+             <number>10</number>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_3">
+        <item>
+         <widget class="QLabel" name="mROInameLabel">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string>Name : Lung</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_5">
+          <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="QLabel" name="mROInameLabel_3">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string>Depth</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="mDepthSpinBox">
+          <property name="minimum">
+           <number>1</number>
+          </property>
+          <property name="maximum">
+           <number>999999</number>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title">
+      <string>All ROI</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <property name="spacing">
+       <number>1</number>
+      </property>
+      <property name="margin">
+       <number>1</number>
+      </property>
+      <item>
+       <layout class="QVBoxLayout" name="verticalLayout_4">
+        <property name="spacing">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>1</number>
+        </property>
+        <item>
+         <widget class="QCheckBox" name="mCheckBoxShowAll">
+          <property name="text">
+           <string>Set all ROI visible</string>
+          </property>
+          <property name="checked">
+           <bool>false</bool>
+          </property>
+          <property name="tristate">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="mContourCheckBoxShowAll">
+          <property name="text">
+           <string>Set all contours visible</string>
+          </property>
+          <property name="checked">
+           <bool>false</bool>
+          </property>
+          <property name="tristate">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="../vvIcons.qrc"/>
+ </resources>
+ <connections>
+  <connection>
+   <sender>mOpacitySlider</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>mOpacitySpinBox</receiver>
+   <slot>setValue(int)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>219</x>
+     <y>385</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>376</x>
+     <y>376</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>mOpacitySpinBox</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>mOpacitySlider</receiver>
+   <slot>setValue(int)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>376</x>
+     <y>367</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>222</x>
+     <y>373</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/vv/vvToolROIManager.cxx b/vv/vvToolROIManager.cxx
new file mode 100644 (file)
index 0000000..77a65d3
--- /dev/null
@@ -0,0 +1,122 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+  ===========================================================================**/
+
+// vv
+#include "vvToolROIManager.h"
+#include "vvImageReader.h"
+#include "vvROIActor.h"
+#include "vvSlicer.h"
+#include "vvROIActor.h"
+
+// Qt
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QColorDialog>
+#include <QAbstractEventDispatcher>
+// vtk
+#include <vtkLookupTable.h>
+#include <vtkRenderWindow.h>
+
+//------------------------------------------------------------------------------
+// Create the tool and automagically (I like this word) insert it in
+// the main window menu.
+ADD_TOOL(vvToolROIManager);
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f):
+  // vvToolWidgetBase(parent, f), 
+  // if Qt::Widget -> No dialog in this case (in tab) ; PB = "invisible widget on menu" !
+  // if "f" normal widget
+  QWidget(parent->GetTab()->widget(4)), 
+  vvToolBase<vvToolROIManager>(parent),
+  Ui::vvToolROIManager()
+{
+  //  Insert the current QWidget into the tab layout (required)
+  QWidget * mother = qFindChild<QWidget*>(parent->GetTab(), "ROItab");
+  mother->layout()->addWidget(this);
+  
+  // Build the UI
+  Ui_vvToolROIManager::setupUi(this);
+  setAttribute(Qt::WA_DeleteOnClose);
+
+  // Select the current image as the target
+  int i = parent->GetSlicerManagerCurrentIndex();
+  InputIsSelected(parent->GetSlicerManagers()[i]);
+
+  // Connect event from mainwindow to this widget
+  connect(parent, SIGNAL(AnImageIsBeingClosed(vvSlicerManager *)), 
+          this, SLOT(AnImageIsBeingClosed(vvSlicerManager *)));
+  connect(parent, SIGNAL(SelectedImageHasChanged(vvSlicerManager *)), 
+          this, SLOT(SelectedImageHasChanged(vvSlicerManager *)));
+
+  // mMainWindowBase->GetTab()->setTabIcon(mTabNumber, GetToolIcon());
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolROIManager::~vvToolROIManager()
+{
+  std::cout << "vvToolROIManager::~vvToolROIManager()" << std::endl;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+// STATIC
+void vvToolROIManager::Initialize() {
+  SetToolName("ROIManager");
+  SetToolMenuName("Display ROI (binary image)");
+  SetToolIconFilename(":/common/icons/tool-roi.png");
+  SetToolTip("Display ROI from a binary image.");
+  SetToolExperimental(true);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
+{
+  std::cout << "vvToolROIManager::InputIsSelected()" << std::endl;
+  mSlicerManager = m;
+
+  // Signal/slot
+  connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()));
+
+  // Initialization
+
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m)
+{
+  if (m == mSlicerManager) close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
+  if (m != mSlicerManager) hide();
+  else show();
+}
+//------------------------------------------------------------------------------
diff --git a/vv/vvToolROIManager.h b/vv/vvToolROIManager.h
new file mode 100644 (file)
index 0000000..2d91264
--- /dev/null
@@ -0,0 +1,58 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to: 
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+  ===========================================================================**/
+
+#ifndef VVTOOLROIMANAGER_H
+#define VVTOOLROIMANAGER_H
+
+#include <QtDesigner/QDesignerExportWidget>
+#include <QSharedPointer>
+
+#include "vvToolBase.h"
+#include "vvROIActor.h"
+#include "clitkDicomRT_ROI.h"
+#include "ui_vvToolROIManager.h"
+
+class vvROIActor;
+
+//------------------------------------------------------------------------------
+class vvToolROIManager:
+  public QWidget, 
+  public vvToolBase<vvToolROIManager>, 
+  public Ui::vvToolROIManager
+{
+  Q_OBJECT
+  public:
+  vvToolROIManager(vvMainWindowBase* parent=0, Qt::WindowFlags f=Qt::Dialog);
+  virtual ~vvToolROIManager();
+
+  static void Initialize();
+  virtual void InputIsSelected(vvSlicerManager *m);
+
+  public slots:
+  void AnImageIsBeingClosed(vvSlicerManager *);
+  void SelectedImageHasChanged(vvSlicerManager *);
+
+protected:
+  Ui::vvToolROIManager ui;
+  vvSlicerManager * mSlicerManager;
+}; // end class vvToolROIManager
+//------------------------------------------------------------------------------
+
+#endif
+