]> Creatis software - clitk.git/commitdiff
- display binary image as overlay
authordsarrut <dsarrut>
Mon, 26 Apr 2010 09:25:54 +0000 (09:25 +0000)
committerdsarrut <dsarrut>
Mon, 26 Apr 2010 09:25:54 +0000 (09:25 +0000)
14 files changed:
common/clitkDicomRT_ROI.cxx
common/clitkDicomRT_ROI.h
common/clitkImageCommon.cxx
common/clitkImageCommon.txx
vv/CMakeLists.txt
vv/qt_ui/vvToolStructureSetManager.ui
vv/vvBinaryImageOverlayActor.cxx
vv/vvBinaryImageOverlayActor.h
vv/vvMainWindow.cxx
vv/vvROIActor.cxx
vv/vvStructureSetActor.cxx
vv/vvStructureSetActor.h
vv/vvToolStructureSetManager.cxx
vv/vvToolStructureSetManager.h

index 7aca4be0ae911cb65d3d92c68b52dada4b0dc4ea..72f8273f507e167f6fe9850db1ad2235af3c9883 100644 (file)
@@ -69,7 +69,6 @@ const std::vector<double> & clitk::DicomRT_ROI::GetDisplayColor() const {
 }
 //--------------------------------------------------------------------
 
-
  
 //--------------------------------------------------------------------
 void clitk::DicomRT_ROI::Print(std::ostream & os) const {
@@ -80,6 +79,20 @@ void clitk::DicomRT_ROI::Print(std::ostream & os) const {
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+void clitk::DicomRT_ROI::SetBackgroundValueLabelImage(double bg){
+  mBackgroundValue = bg;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+double clitk::DicomRT_ROI::GetBackgroundValueLabelImage() const {
+  return mBackgroundValue;
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 void clitk::DicomRT_ROI::Read(std::map<int, std::string> & rois, gdcm::SQItem * item) {
   
index e7aaa28af297e3ffe464ca60c452d3ce6da6e2c0..8ec0404b119aef459f9a663e480663ed9968d880 100644 (file)
@@ -46,6 +46,9 @@ namespace clitk {
 
     void SetDisplayColor(double r, double v, double b);
     
+    double GetBackgroundValueLabelImage() const;
+    void SetBackgroundValueLabelImage(double bg);
+    
   protected:
     void ComputeMesh();
     std::string mName;
@@ -55,6 +58,7 @@ namespace clitk {
     vtkPolyData * mMesh;
     bool mMeshIsUpToDate;
     vvImage::Pointer mImage;
+    double mBackgroundValue;
   };
   //--------------------------------------------------------------------
 
index 45dfa0d319909fa6dae98f6d287c098059cf5bf2..c9085c66a3d38d93109f0d29b9c8c6f31a7ba53f 100644 (file)
@@ -129,7 +129,11 @@ void clitk::printImageHeader(itk::ImageIOBase::Pointer header, std::ostream & os
        << "  ";
     for(unsigned int i=0; i< dim-1; i++)
       os << inputSpacing[i] << "x";
-    os << inputSpacing[dim-1];
+    os << inputSpacing[dim-1] 
+       << "  ";
+    for(unsigned int i=0; i< dim-1; i++)
+      os << inputOrigin[i] << "x";
+    os << inputOrigin[dim-1] << " ";
   }
   else {
     os << "Dim       = " << dim << "D" << std::endl;
index 547c2c7b94d4f67ba5e3b1587a2547768fbf8f4d..e682593751cafc87e6421963e7e8082e0da4da5b 100644 (file)
 ======================================================================-====*/
 #ifndef CLITKIMAGECOMMON_TXX
 #define CLITKIMAGECOMMON_TXX
-/**
-   -------------------------------------------------
-   * @file   clitkImageCommon.txx
-   * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
-   * @date   07 Sep 2007 11:34:19
-   * 
-   * @brief  
-   * 
-   * 
-   -------------------------------------------------*/
+
 
 //--------------------------------------------------------------------
 template<class PixelType>
@@ -101,9 +92,8 @@ typename itk::Image<PixelType,4>::Pointer NewImage4D(int sx, int sy, int sz, int
 template<class ImageType>
 typename ImageType::Pointer NewImageLike(const typename ImageType::Pointer input, bool allocate) {
   typename ImageType::Pointer output = ImageType::New();
-  output->SetRegions(input->GetLargestPossibleRegion());
-  output->SetOrigin(input->GetOrigin());
-  output->SetSpacing(input->GetSpacing());
+  output->CopyInformation(input);
+  output->SetRegions(input->GetLargestPossibleRegion());  
   if (allocate) output->Allocate();
   return output;
 }
index 18347c28efae755e3e905c6cd0dca8b6ba62aad1..1094b6cda6b8084f6ceb5136c221910973f72d66 100644 (file)
@@ -60,7 +60,7 @@ LINK_DIRECTORIES(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} )
 
 #=========================================================
 
-OPTION(CLITK_VV_USE_BDCM "Build vv with Dicom selector bdcm" OFF)
+OPTION(CLITK_VV_USE_BDCM "Build vv with Dicom selector bdcm" OFF)
 
 SET(vv_SRCS
   vvInfoPanel.cxx
@@ -194,26 +194,26 @@ ENDIF(CMAKE_COMPILER_IS_GNUCC)
 ENDIF(NOT __APPLE__)
 #=========================================================
 
-IF (CLITK_VV_USE_BDCM)
-  FIND_PACKAGE(bdcm)
-  IF(bdcm_FOUND)
-    INCLUDE(${bdcm_USE_FILE})
-  ELSE(bdcm_FOUND)
-    MESSAGE(FATAL_ERROR
-      "Cannot build without BDCM.  Please set BDCM_DIR.")
-  ENDIF(bdcm_FOUND)
-  #LINK_DIRECTORIES(/home/dsarrut/src/bdcm/build/)
-  #INCLUDE_DIRECTORIES(/home/dsarrut/src/bdcm/src2/)
+IF (CLITK_VV_USE_BDCM)
+  FIND_PACKAGE(bdcm)
+  IF(bdcm_FOUND)
+    INCLUDE(${bdcm_USE_FILE})
+  ELSE(bdcm_FOUND)
+    MESSAGE(FATAL_ERROR
+      "Cannot build without BDCM.  Please set BDCM_DIR.")
+  ENDIF(bdcm_FOUND)
+  #LINK_DIRECTORIES(/home/dsarrut/src/bdcm/build/)
+  #INCLUDE_DIRECTORIES(/home/dsarrut/src/bdcm/src2/)
 
-  FIND_PACKAGE(GDCM)
-  IF(GDCM_FOUND)
-    INCLUDE(${GDCM_USE_FILE})
-  ELSE(GDCM_FOUND)
-    MESSAGE(FATAL_ERROR
-      "Cannot build without GDCM.  Please set GDCM_DIR.")
-  ENDIF(GDCM_FOUND)
+  FIND_PACKAGE(GDCM)
+  IF(GDCM_FOUND)
+    INCLUDE(${GDCM_USE_FILE})
+  ELSE(GDCM_FOUND)
+    MESSAGE(FATAL_ERROR
+      "Cannot build without GDCM.  Please set GDCM_DIR.")
+  ENDIF(GDCM_FOUND)
 
-ENDIF (CLITK_VV_USE_BDCM)
+ENDIF (CLITK_VV_USE_BDCM)
 
 IF(WIN32)
   SET(EXE_ICON vvIcon.rc)
index a9c7af661aa92c139b1a2604e0c96cc87dcd0ebd..126bf791b9da2ced3b860c4a67c68ab544ae714d 100644 (file)
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>601</width>
-    <height>414</height>
+    <width>483</width>
+    <height>519</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_3">
+  <layout class="QVBoxLayout" name="verticalLayout_4">
    <item>
-    <widget class="QComboBox" name="mOpenComboBox">
-     <property name="currentIndex">
-      <number>0</number>
-     </property>
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
      <item>
-      <property name="text">
-       <string>Open binary image</string>
-      </property>
+      <widget class="QGroupBox" name="groupBox_3">
+       <property name="title">
+        <string>Add Label Image from file</string>
+       </property>
+       <layout class="QHBoxLayout" name="horizontalLayout_3">
+        <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>
+         <layout class="QVBoxLayout" name="verticalLayout_3">
+          <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>&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:10pt; 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:9pt;&quot;&gt;Background value :&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QSpinBox" name="mBackgroundValueSpinBox"/>
+          </item>
+         </layout>
+        </item>
+       </layout>
+      </widget>
      </item>
      <item>
-      <property name="text">
-       <string>Open DICOM RT StructureSet</string>
-      </property>
+      <widget class="QGroupBox" name="groupBox_4">
+       <property name="title">
+        <string>Add DICOM RT contours</string>
+       </property>
+       <layout class="QGridLayout" name="gridLayout">
+        <item row="0" column="0">
+         <widget class="QPushButton" name="mOpenBinaryButton_3">
+          <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 DICOM  RT Struct</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>
+       </layout>
+      </widget>
      </item>
      <item>
-      <property name="text">
-       <string>Open VTK mesh</string>
-      </property>
+      <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>
-    </widget>
+    </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout">
        <string>Name</string>
       </property>
      </column>
-     <column>
-      <property name="text">
-       <string>Show</string>
-      </property>
-     </column>
-     <column>
-      <property name="text">
-       <string>Refresh</string>
-      </property>
-     </column>
      <item>
       <property name="text">
        <string>1</string>
       <property name="text">
        <string>Default</string>
       </property>
-      <property name="text">
-       <string/>
-      </property>
-      <property name="icon">
-       <iconset resource="../vvIcons.qrc">
-        <normaloff>:/common/icons/standardbutton-cancel-16.png</normaloff>
-        <normalon>:/common/icons/standardbutton-apply-16.png</normalon>:/common/icons/standardbutton-cancel-16.png</iconset>
-      </property>
       <property name="flags">
        <set>ItemIsSelectable|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate</set>
       </property>
        <property name="text">
         <string>2</string>
        </property>
+       <property name="text">
+        <string/>
+       </property>
       </item>
      </item>
      <item>
        <property name="text">
         <string>1</string>
        </property>
+       <property name="text">
+        <string/>
+       </property>
       </item>
       <item>
        <property name="text">
         <string>2</string>
        </property>
+       <property name="text">
+        <string/>
+       </property>
       </item>
      </item>
     </widget>
         <string>Current ROI</string>
        </property>
        <layout class="QVBoxLayout" name="verticalLayout">
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_6">
+          <item>
+           <widget class="QCheckBox" name="mCheckBoxShow">
+            <property name="text">
+             <string>Show</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="mChangeColorButton_2">
+            <property name="toolTip">
+             <string/>
+            </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="horizontalSlider">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QSpinBox" name="spinBox"/>
+          </item>
+         </layout>
+        </item>
         <item>
          <widget class="QLabel" name="vectorFieldNameLabel_5">
           <property name="sizePolicy">
  <resources>
   <include location="../vvIcons.qrc"/>
  </resources>
- <connections/>
+ <connections>
+  <connection>
+   <sender>horizontalSlider</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>spinBox</receiver>
+   <slot>setValue(int)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>344</x>
+     <y>416</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>426</x>
+     <y>416</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>spinBox</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>horizontalSlider</receiver>
+   <slot>setValue(int)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>432</x>
+     <y>421</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>351</x>
+     <y>421</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
 </ui>
index f54b743e1b8455196043c4145a0632dc23ac9096..1ea3c6f40b2f54d791eac41d7859cdf6549be421 100644 (file)
@@ -61,7 +61,6 @@ void vvBinaryImageOverlayActor::setColor(double r, double g, double b) {
 //------------------------------------------------------------------------------
 
 
-
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::setSlicer(vvSlicer * slicer) {
   mSlicer = slicer;
@@ -83,13 +82,17 @@ void vvBinaryImageOverlayActor::initialize() {
   // Create an actor for each time slice
   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
     DD(numImage);
+
+    // how many intensity ? 
+    
+
     vtkImageMapToRGBA * mOverlayMapper = vtkImageMapToRGBA::New();
     mOverlayMapper->SetInput(mImage->GetVTKImages()[0]); // DS TODO : to change if it is 4D !!!
     vtkLookupTable * lut = vtkLookupTable::New();
     DD(lut->IsOpaque ());
     lut->SetRange(0,1);
     lut->SetNumberOfTableValues(2);
-    lut->SetTableValue(0, 0, 0, 0, 0.0);   // BG
+    lut->SetTableValue(mBackgroundValue, 0, 0, 0, 0.0);   // BG
     lut->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
     DD(mColor[0]);
     mOverlayMapper->SetLookupTable(lut);
@@ -109,8 +112,9 @@ void vvBinaryImageOverlayActor::initialize() {
 
 
 //------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image) {
+void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image, double bg) {
   mImage = image;
+  mBackgroundValue = bg;
 }
 //------------------------------------------------------------------------------
 
@@ -141,16 +145,11 @@ void vvBinaryImageOverlayActor::showActors() {
   
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::update(int slicer, int slice) {
-  // DD("update");
-  // DD(slicer);
-  // DD(slice);
   if (!mSlicer) return;
-  // DD(mSlicer->GetSlice());
-  // DD(mSlicer->GetTSlice());
 
   if (mPreviousSlice == mSlicer->GetSlice()) {
     if (mPreviousTSlice == mSlicer->GetTSlice()) {
-      DD("=========== NOTHING");
+      //DD("=========== NOTHING");
       return; // Nothing to do
     }
   }
@@ -160,18 +159,6 @@ void vvBinaryImageOverlayActor::update(int slicer, int slice) {
   mTSlice = mSlicer->GetTSlice();
 
   // Update extent
-  //  DD("Update extent");
-
-  /*
-1 - get extent
-2 - orientation
-3 - compute new extent : ComputeImageDisplayedExtent
-4 - ClipDisplayedExtent
-5 - actor SetDisplayExtent
-
-==> à mettre dans slicer.
-  ==> fct (image input, image à overl)
-  */
   int * imageExtent = mSlicer->GetExtent();
   int orientation = mSlicer->GetOrientation();
   int maskExtent[6];
@@ -185,10 +172,7 @@ void vvBinaryImageOverlayActor::update(int slicer, int slice) {
   //       << maskExtent[3] << " " << maskExtent[4] << " " << maskExtent[5] << std::endl;
   SetDisplayExtentAndCameraPosition(orientation, mSlice, maskExtent, mImageActorList[mTSlice], 0.0);
   
-  // TOO SLOW ? 
-  //mSlicer->Render();
-
-  //
+  // set previous slice
   mPreviousTSlice = mSlicer->GetTSlice();
   mPreviousSlice  = mSlicer->GetSlice();
 }
@@ -249,12 +233,9 @@ void vvBinaryImageOverlayActor::SetDisplayExtentAndCameraPosition(int orientatio
                                                                  int * extent, 
                                                                  vtkImageActor * actor, 
                                                                  double position) {
-  //  DD("SetDisplayExtentAndCameraPosition");
-  //DD(orientation);
-  //DD(slice);
   actor->SetDisplayExtent(extent);
   
-
+  // Set position
   if (orientation == vtkImageViewer2::SLICE_ORIENTATION_XY) {
     if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice)
       actor->SetPosition(0,0, position);
index e4e3be9be351d4f3533741e178dd0e0fdfdc29fc..f33014ddd6c8426c1f5e1cfaccc3f554e4859ab2 100644 (file)
@@ -41,7 +41,7 @@ class vvBinaryImageOverlayActor
   void hideActors();
   void showActors();
   void setColor(double r, double g, double b);
-  void setImage(vvImage::Pointer image);
+  void setImage(vvImage::Pointer image, double bg);
   void initialize();
 
  protected:
@@ -53,6 +53,7 @@ class vvBinaryImageOverlayActor
   vvImage::Pointer mImage;
   std::vector<double> mColor;
   double mAlpha;
+  double mBackgroundValue;
   
   std::vector<vtkImageMapToRGBA *> mMapperList;
   std::vector<vtkImageActor*> mImageActorList;
index 9fa632988335b450205d03bc1d89f4f1ad80c04d..abf38e98fe2d55f4533cef82e3c58a7922948ad9 100644 (file)
@@ -2445,8 +2445,8 @@ void vvMainWindow::NOVerticalSliderChanged() {
         {
           mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
           mSlicerManagers[i]->VerticalSliderHasChanged(0, value);
-          // mSlicerManagers[i]->UpdateSlice(0);
-          // <-- DS add this. Not too much update ? YES.
+          // mSlicerManagers[i]->UpdateSlice(0);  // <-- DS add this. Not too much update ? YES.
+         mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? 
           break;
         }
     }
@@ -2462,6 +2462,8 @@ void vvMainWindow::NEVerticalSliderChanged() {
       if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1)
         {
           mSlicerManagers[i]->GetSlicer(1)->SetSlice(value);
+          mSlicerManagers[i]->VerticalSliderHasChanged(1, value);
+         mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? 
           break;
         }
     }
@@ -2477,6 +2479,8 @@ void vvMainWindow::SOVerticalSliderChanged() {
       if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1)
         {
           mSlicerManagers[i]->GetSlicer(2)->SetSlice(value);
+          mSlicerManagers[i]->VerticalSliderHasChanged(2, value);
+         mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? 
           break;
         }
     }
@@ -2492,6 +2496,8 @@ void vvMainWindow::SEVerticalSliderChanged() {
       if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1)
         {
           mSlicerManagers[i]->GetSlicer(3)->SetSlice(value);
+          mSlicerManagers[i]->VerticalSliderHasChanged(3, value);
+         mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? 
           break;
         }
     }
index f4db30b67d6111a1c2286734d5400c4c4a120cdf..f1eb222539b2c86059cb493e3709d39dc10151ea 100644 (file)
@@ -23,6 +23,7 @@
 #include <vtkImageActor.h>
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
+//#include <vtkRenderWindow.h>
 #include <vtkMarchingSquares.h>
 #include <vtkImageClip.h>
 #include <vtkImageData.h>
@@ -62,7 +63,6 @@ void vvROIActor::Initialize() {
   if (mROI->GetImage()) {
     mImageContour.clear();
     mOverlayActors.clear();
-    DD(mSlicerManager->NumberOfSlicers());
     for(int i=0;i<mSlicerManager->NumberOfSlicers(); i++) {
       mImageContour.push_back(new vvImageContour);
       mImageContour[i]->setSlicer(mSlicerManager->GetSlicer(i));
@@ -74,7 +74,7 @@ void vvROIActor::Initialize() {
       mImageContour[i]->setPreserveMemoryModeEnabled(false);        
       
       mOverlayActors.push_back(new vvBinaryImageOverlayActor);
-      mOverlayActors[i]->setImage(mROI->GetImage());
+      mOverlayActors[i]->setImage(mROI->GetImage(), mROI->GetBackgroundValueLabelImage());
       mOverlayActors[i]->setColor(mROI->GetDisplayColor()[0], 
                                  mROI->GetDisplayColor()[1], 
                                  mROI->GetDisplayColor()[2]);
@@ -92,7 +92,6 @@ void vvROIActor::Initialize() {
 
 //------------------------------------------------------------------------------
 void vvROIActor::Update() {
-  DD("vvROIActor::Update");
   for(int i=0; i<mSlicerManager->NumberOfSlicers(); i++) {
     UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice());
   }
@@ -102,9 +101,6 @@ void vvROIActor::Update() {
 
 //------------------------------------------------------------------------------
 void vvROIActor::UpdateSlice(int slicer, int slices) {
-  // DD("UpdateSlice");
-  // DD(slicer);
-  // DD(slices);
    if (!mROI->GetImage())  return;
 
   if (!mSlicerManager) {
@@ -115,10 +111,10 @@ void vvROIActor::UpdateSlice(int slicer, int slices) {
   // CONTOUR HERE 
   // mImageContour[slicer]->update(1.0); 
 
-
+  // Refresh overlays
   mOverlayActors[slicer]->update(slicer, slices);
 
-  // TOO SLOW !!!!!
-  //  mSlicerManager->GetSlicer(slicer)->Render(); 
+  // Do not used the following line : TOO SLOW.
+  // mSlicerManager->GetSlicer(slicer)->GetRenderWindow()->Render(); 
 }
 //------------------------------------------------------------------------------
index 6473a7de7748826bb5475e0d778e0519311c2ead..819a65364a93d41cf2e2da7a3b26cfd6a66a0431 100644 (file)
@@ -46,6 +46,17 @@ void vvStructureSetActor::SetSlicerManager(vvSlicerManager * s) {
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+vvROIActor * vvStructureSetActor::GetROIActor(int n) {
+  if (mMapROIIndex.find(n) == mMapROIIndex.end()) {
+    std::cerr << "No ROI number " << n << std::endl;
+    return NULL;    
+  }
+  return mROIActors[mMapROIIndex[n]];
+}
+//------------------------------------------------------------------------------
+
+
 //------------------------------------------------------------------------------
 void vvStructureSetActor::CreateNewROIActor(int n) {
   DD("AddROIActor");
@@ -64,9 +75,9 @@ void vvStructureSetActor::CreateNewROIActor(int n) {
   actor->SetROI(roi);
   actor->SetSlicerManager(mSlicerManager);
   actor->Initialize();
-  // 
+  mMapROIIndex[n] = mROIActors.size()-1;
 
-  actor->Update();
+  //  actor->Update();
 }
 //------------------------------------------------------------------------------
 
index 91c105867d0d688c8bdf76bd8a6670179ecc8033..119169d95a7d9c4a95acfd9cf722221dc03d95af 100644 (file)
@@ -35,11 +35,13 @@ class vvStructureSetActor: public QObject {
   void SetStructureSet(clitk::DicomRT_StructureSet * s);
   void SetSlicerManager(vvSlicerManager * s);
   void CreateNewROIActor(int n);
+  vvROIActor* GetROIActor(int n);
 
  protected:
   clitk::DicomRT_StructureSet * mStructureSet;
   vvSlicerManager * mSlicerManager;
   std::vector<vvROIActor*> mROIActors;
+  std::map<int, int> mMapROIIndex;
 
 }; // end class vvStructureSetActor
 //------------------------------------------------------------------------------
index 0b0d661da1b9f1ccf9a212aec8559a94911782c5..ac53fb53c3060f7be98ee27c4b2b3e9437d3d29f 100644 (file)
@@ -20,6 +20,7 @@
 #include "vvImageReader.h"
 #include "vvStructureSetActor.h"
 #include "vvSlicer.h"
+#include "vvROIActor.h"
 #include <QFileDialog>
 #include <QMessageBox>
 #include <vtkLookupTable.h>
@@ -83,14 +84,38 @@ void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m) {
   s.push_back(1);
   splitter->setSizes(s);
   // Connect open menus
-  connect(mOpenComboBox, SIGNAL(activated(int)), this, SLOT(open(int)));
+  //  connect(mOpenComboBox, SIGNAL(activated(int)), this, SLOT(open(int)));
+  
+  connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(openBinaryImage()));
+
   DD(mCurrentImage->GetNumberOfDimensions());
 
-  // To trigger the Render ??
-  //  connect(m,SIGNAL(releasemouse()),this,SLOT(Render()));
-  
-  //  connect(m, SIGNAL(UpdateSlice(int, int)), SLOT(UpdateSlice(int, int)));
-  connect(m, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
+  // Seems that the following is not needed to refresh ...
+  //  connect(m, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
+
+  connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(selectedItemChangedInTree()));
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::selectedItemChangedInTree() {
+  DD("selectedItemChangedInTree");
+  QList<QTreeWidgetItem *> l = mTree->selectedItems();
+  DD(l.size());
+  QTreeWidgetItem * w = l[0];
+  if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) return; // Search for SS (first)
+  clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w];
+  DD(roi->GetName());
+  setCurrentSelectedROI(roi);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::setCurrentSelectedROI(clitk::DicomRT_ROI * roi) {
+  //  mCheckBoxShow = // get roi actor .../
+
 }
 //------------------------------------------------------------------------------
 
@@ -132,30 +157,37 @@ void vvToolStructureSetManager::addRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTr
   for(int i=0; i<w->columnCount (); i++) {
     w->setBackground(i, brush);
   }
+  mMapROIToTreeWidget[roi] = w;
+  mMapTreeWidgetToROI[w] = roi;
+  // Connect ROI TreeWidget
+  // TODO
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::addStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) {
-  // Main row item
-  QTreeWidgetItem * ss = new QTreeWidgetItem(mTree);
-  //  ss->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
-  ss->setText(0, QString("S%1").arg(index));
-  ss->setText(1, QString("%1").arg(s->GetLabel().c_str()));
+void vvToolStructureSetManager::updateStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) {
+  QTreeWidgetItem * ss;
+  if (mMapStructureSetIndexToTreeWidget.find(index) == mMapStructureSetIndexToTreeWidget.end()) {
+    // Main row item
+    ss = new QTreeWidgetItem(mTree);
+    //  ss->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
+    ss->setText(0, QString("S%1").arg(index));
+    ss->setText(1, QString("%1").arg(s->GetLabel().c_str()));
+    // Insert in list
+    mMapStructureSetIndexToTreeWidget[index] = ss;
+    
+    // Connect Structure TreeWidget
+    // TODO
+  }
+  else ss = mMapStructureSetIndexToTreeWidget[index];
 
   // Insert ROI
   const std::vector<clitk::DicomRT_ROI*> & rois = s->GetListOfROI();
   for(unsigned int i=0; i<rois.size(); i++) {
-    DD(i);
-    addRoiInTreeWidget(rois[i], ss);
+    if (mMapROIToTreeWidget.find(rois[i]) == mMapROIToTreeWidget.end())
+      addRoiInTreeWidget(rois[i], ss);
   }
-  
-  // Insert in list
-  mStructureSetItemsList[index] = ss;
-  
-  // Connect
-  //  TODO
 }
 //------------------------------------------------------------------------------
 
@@ -184,6 +216,7 @@ void vvToolStructureSetManager::openBinaryImage() {
   DD("openBinaryImage");
   // Select current StructureSet (or create)
   int index;
+  DD(mCurrentStructureSetIndex);
   if (mCurrentStructureSet == NULL) {
     if (mStructureSetsList.size() == 0) { // Create a default SS
       clitk::DicomRT_StructureSet * mStructureSet = new clitk::DicomRT_StructureSet;
@@ -193,13 +226,15 @@ void vvToolStructureSetManager::openBinaryImage() {
     else { // Get first SS
       index = 0;
     }
-    // TODO -> SET THIS SS AS CURRENT
-    mCurrentStructureSet = mStructureSetsList[index];
-    mCurrentStructureSetActor = mStructureSetActorsList[index];
   }
   else {
     index = mCurrentStructureSetIndex;
   }
+  DD(index);
+  // TODO -> SET THIS SS AS CURRENT
+  mCurrentStructureSet = mStructureSetsList[index];
+  mCurrentStructureSetActor = mStructureSetActorsList[index];
+  mCurrentStructureSetIndex = index;
   DD(mCurrentStructureSet->GetName());
 
   // Open images
@@ -210,6 +245,7 @@ void vvToolStructureSetManager::openBinaryImage() {
                                 mMainWindowBase->GetInputPathName(),Extensions);
   if (filename.size() == 0) return;
 
+  std::vector<int> mLoadedROIIndex;
   for(int i=0; i<filename.size(); i++) {
     DD(filename[i].toStdString());
 
@@ -232,41 +268,52 @@ void vvToolStructureSetManager::openBinaryImage() {
       return;
     }
     vvImage::Pointer binaryImage = mReader->GetOutput();
-  //  delete mReader;
-
-  // Check Dimension
-  int dim = mCurrentImage->GetNumberOfDimensions();
-  DD(dim);
-  int bin_dim = binaryImage->GetNumberOfDimensions();
-  DD(bin_dim);
-  if (dim < bin_dim) {  ////////// TO CHANGE FOR 3D/4D
-    std::ostringstream os;
-    os << "Error. Loaded binary image is " << bin_dim 
-             << "D while selected image is " << dim << "D" << std::endl;
-    QMessageBox::information(this,tr("Reading problem"),os.str().c_str());
-    return;
-  }
+    //  delete mReader;
+
+    // Check Dimension
+    int dim = mCurrentImage->GetNumberOfDimensions();
+    DD(dim);
+    int bin_dim = binaryImage->GetNumberOfDimensions();
+    DD(bin_dim);
+    if (dim < bin_dim) {  ////////// TO CHANGE FOR 3D/4D
+      std::ostringstream os;
+      os << "Error. Loaded binary image is " << bin_dim 
+        << "D while selected image is " << dim << "D" << std::endl;
+      QMessageBox::information(this,tr("Reading problem"),os.str().c_str());
+      return;
+    }
+    
+    // Add a new roi to the structure
+    int n = mCurrentStructureSet->AddBinaryImageAsNewROI(binaryImage, filename[i].toStdString());
+    //DD(n);
+    mLoadedROIIndex.push_back(n);
+
+    mCurrentStructureSet->GetROI(n)->SetBackgroundValueLabelImage(mBackgroundValueSpinBox->value());
+    
+    // Change color NEED DEFAULT COLOR LIST
+    DD(mDefaultLUTColor->GetNumberOfTableValues ());
+    if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
+      double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ());
+      DD(color[0]);
+      DD(color[1]);
+      DD(color[2]);
+      mCurrentStructureSet->GetROI(n)->SetDisplayColor(color[0], color[1], color[2]);
+    }
+    
+    // Add a new roi actor
+    mCurrentStructureSetActor->CreateNewROIActor(n);
+  } // end loop on n selected filenames
 
-  // Add a new roi to the structure
-  int n = mCurrentStructureSet->AddBinaryImageAsNewROI(binaryImage, filename[i].toStdString());
-  DD(n);
+  // Update the TreeWidget
+  updateStructureSetInTreeWidget(index, mCurrentStructureSet);
   
-  // Change color NEED DEFAULT COLOR LIST
-  DD(mDefaultLUTColor->GetNumberOfTableValues ());
-  if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
-    double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ());
-    DD(color[0]);
-    DD(color[1]);
-    DD(color[2]);
-    mCurrentStructureSet->GetROI(n)->SetDisplayColor(color[0], color[1], color[2]);
+  // Render loaded ROIs (the first is sufficient)
+  for(unsigned int i=0; i<mLoadedROIIndex.size(); i++) {
+    mCurrentStructureSetActor->GetROIActor(mLoadedROIIndex[i])->Update();
   }
-  
-  // Add a new roi actor
-  mCurrentStructureSetActor->CreateNewROIActor(n);
+  for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
+    mCurrentSlicerManager->GetSlicer(i)->Render(); 
   }
-
-  // Update the TreeWidget
-  addStructureSetInTreeWidget(index, mCurrentStructureSet);
 }
 //------------------------------------------------------------------------------
 
index e46bf5c31fa1060b85ab6614101857918b9d4a67..0295513f2ecd9ed61e8e46897d431cc543b0d334 100644 (file)
@@ -42,25 +42,30 @@ class vvToolStructureSetManager:
   virtual void InputIsSelected(vvSlicerManager *m);
 
   int addStructureSet(clitk::DicomRT_StructureSet * mStructureSet);
-  void addStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s);
+  void updateStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s);
   void addRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTreeWidgetItem * w);
 
 public slots:
   virtual void apply();
   void open(int type);
   void LeftButtonReleaseEvent(int slicer);
+  void openBinaryImage();
+  void selectedItemChangedInTree();
 
  protected:
   Ui::vvToolStructureSetManager ui;
-  void openBinaryImage();
   clitk::DicomRT_StructureSet * mCurrentStructureSet;
   vvStructureSetActor * mCurrentStructureSetActor;
   int mCurrentStructureSetIndex;
   vtkLookupTable * mDefaultLUTColor;
-  
+  void setCurrentSelectedROI(clitk::DicomRT_ROI * roi);
   std::vector<clitk::DicomRT_StructureSet*> mStructureSetsList;
   std::vector<vvStructureSetActor *> mStructureSetActorsList;
-  std::map<int, QTreeWidgetItem *> mStructureSetItemsList;
+  std::map<int, QTreeWidgetItem *> mMapStructureSetIndexToTreeWidget;
+  std::map<clitk::DicomRT_ROI*, QTreeWidgetItem *> mMapROIToTreeWidget;
+  std::map<QTreeWidgetItem *, clitk::DicomRT_ROI*> mMapTreeWidgetToROI;
 
 }; // end class vvToolStructureSetManager
 //------------------------------------------------------------------------------