]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorDavid Sarrut <david.sarrut@gmail.com>
Fri, 23 Mar 2012 06:42:40 +0000 (07:42 +0100)
committerDavid Sarrut <david.sarrut@gmail.com>
Fri, 23 Mar 2012 06:42:40 +0000 (07:42 +0100)
20 files changed:
cmake/dependencies.cmake
itk/RelativePositionPropImageFilter.txx
itk/clitkAddRelativePositionConstraintToLabelImageFilter.h
itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx
itk/clitkLabelImageOverlapMeasureFilter.h
itk/clitkLabelImageOverlapMeasureFilter.txx
itk/clitkMeshToBinaryImageFilter.h
itk/clitkMeshToBinaryImageFilter.txx
itk/clitkSliceBySliceRelativePositionFilter.txx
segmentation/clitkRelativePositionList.h
segmentation/clitkRelativePositionList.txx
segmentation/clitkStructuresExtractionFilter.h
segmentation/clitkStructuresExtractionFilter.txx
vv/CMakeLists.txt
vv/qt_ui/vvMainWindow.ui
vv/qt_ui/vvToolROIManager.ui
vv/vvMeshActor.cxx
vv/vvToolCreatorBase.cxx
vv/vvToolROIManager.cxx
vv/vvToolROIManager.h

index 75319ecf0790409273ddcd1bfc5917758b14426d..0ab0b6605fad348061c1beb10afe3af1e76f54f7 100644 (file)
@@ -23,7 +23,7 @@ IF(VTK_FOUND)
       vtkWidgets
       vtkImaging
       vtkHybrid
-      QVTK
+      vtkQVTK
       )
   ENDIF(VTK_VERSION VERSION_LESS 5.8.0)
 ELSE(VTK_FOUND)
index 15a5773cd802648533cc96343ddd0b29f04cd736..eee0f0a748c95a99e63def5712a0c166ee50dbb0 100644 (file)
@@ -86,8 +86,6 @@ namespace itk
   ::GenerateData()
   {
 
-    // std::cout <<"GenerateData" << std::endl;
-
     this->AllocateOutputs();
     computeDirection();
     typename InputImageType::ConstPointer input = this->GetInput();
@@ -131,7 +129,6 @@ namespace itk
   
     if(!m_Fast)
       {  
-        DD(m_Fast);
         for(int i=0;i<pow((double)2,(int)ImageDimension);i++)
           {
             int orient[ImageDimension];
index 00edd718b167f5d980dacd6941eeb7a587b951d2..99465547695d6403dea2c271e55ffba93da8c14b 100644 (file)
@@ -136,6 +136,13 @@ namespace clitk {
     itkSetMacro(FuzzyMapOnlyFlag, bool);
     itkBooleanMacro(FuzzyMapOnlyFlag);
 
+    itkGetConstMacro(FastFlag, bool);
+    itkSetMacro(FastFlag, bool);
+    itkBooleanMacro(FastFlag);
+
+    itkGetConstMacro(Radius, double);
+    itkSetMacro(Radius, double);
+
     typename FloatImageType::Pointer GetFuzzyMap() { return m_FuzzyMap; }
 
     // I dont want to verify inputs information
@@ -162,12 +169,15 @@ namespace clitk {
     bool m_RemoveObjectFlag;
     bool m_CombineWithOrFlag;
     bool m_FuzzyMapOnlyFlag;
+    bool m_FastFlag;
+    double m_Radius;
 
     virtual void GenerateOutputInformation();
     virtual void GenerateInputRequestedRegion();
     virtual void GenerateData();
 
     typedef itk::PasteImageFilter<ImageType,ImageType> PasteFilterType;
+    typedef itk::PasteImageFilter<FloatImageType,FloatImageType> PasteFloatFilterType;
     typename ImageType::Pointer working_image;
     typename ImageType::Pointer object_resampled;
     typename FloatImageType::Pointer relPos;
index e25f98b829fa3c65ed497f5fb5ffd73de863a066..6d536186fbf5084da969d0750e05a4cc8cd3c8fb 100644 (file)
@@ -63,6 +63,8 @@ AddRelativePositionConstraintToLabelImageFilter():
   VerboseStepFlagOff();
   WriteStepFlagOff();
   FuzzyMapOnlyFlagOff();
+  FastFlagOff();
+  SetRadius(2.0);
 }
 //--------------------------------------------------------------------
 
@@ -380,12 +382,16 @@ GenerateData()
   for(int i=0; i<GetNumberOfAngles(); i++) {
     // Compute fuzzy map
     relPosFilter = RelPosFilterType::New();
+    relPosFilter->SetFast(GetFastFlag());
+    relPosFilter->SetRadius(GetRadius());
     relPosFilter->SetInput(working_image);
     relPosFilter->SetAlpha1(m_Angle1[i]); // xy plane
     relPosFilter->SetAlpha2(m_Angle2[i]);
     relPosFilter->SetK1(M_PI/2.0); // Opening parameter, default = pi/2
-    relPosFilter->SetFast(true);
-    relPosFilter->SetRadius(1); // seems sufficient in this case
+
+    // relPosFilter->SetFast(true);
+    // relPosFilter->SetRadius(1); // seems sufficient in this case
+
     // relPosFilter->SetVerboseProgress(true);
     relPosFilter->Update();
     relPos = relPosFilter->GetOutput();
@@ -426,7 +432,43 @@ GenerateData()
 
   relPos = m_FuzzyMap;
   StopCurrentStep<FloatImageType>(relPos);
-  if (GetFuzzyMapOnlyFlag()) return;
+  if (GetFuzzyMapOnlyFlag()) {
+    // If the spacing is used, recompute fuzzy map with the input size/spacing
+    if (m_IntermediateSpacingFlag) {
+      StartNewStep("Resample FuzzyMap to come back to the same sampling than input");
+      typedef clitk::ResampleImageWithOptionsFilter<FloatImageType> ResampleFilterType;
+      typename ResampleFilterType::Pointer resampleFilter = ResampleFilterType::New();
+      resampleFilter->SetDefaultPixelValue(0.0); //Default fuzzymap value FIXME
+      resampleFilter->SetInput(relPos);
+      resampleFilter->SetOutputSpacing(input->GetSpacing());
+      resampleFilter->SetGaussianFilteringEnabled(false);
+      resampleFilter->Update();
+      relPos = m_FuzzyMap = resampleFilter->GetOutput();
+
+      // Need to put exactly the same size
+      if (relPos->GetLargestPossibleRegion() != input->GetLargestPossibleRegion()) {
+        StartNewStep("Pad to get the same size than input");
+        typename FloatImageType::Pointer temp = FloatImageType::New();
+        temp->CopyInformation(input);
+        temp->SetRegions(input->GetLargestPossibleRegion()); // Do not forget !!
+        temp->Allocate();
+        temp->FillBuffer(0.0); // Default fuzzymap value FIXME
+        typename PasteFloatFilterType::Pointer padFilter2 = PasteFloatFilterType::New();
+        padFilter2->SetSourceImage(relPos);
+        padFilter2->SetDestinationImage(temp);
+        padFilter2->SetDestinationIndex(input->GetLargestPossibleRegion().GetIndex());
+        padFilter2->SetSourceRegion(relPos->GetLargestPossibleRegion());
+        padFilter2->Update();
+        relPos = padFilter2->GetOutput();
+        StopCurrentStep<FloatImageType>(relPos);
+        m_FuzzyMap = relPos;
+      }     
+    }
+    else {
+      StopCurrentStep<FloatImageType>(relPos);
+    }
+    return;
+  }
                
   //--------------------------------------------------------------------
   //--------------------------------------------------------------------
index 9b4a45870992362bd5b02dfefc3f4a5b6152adea..17581f633ad9bb94d815b1e549ca19615dabaa58 100644 (file)
@@ -17,7 +17,7 @@
   ===========================================================================**/
 
 #ifndef CLITKLABELIMAGEOVERLAPMEASUREFILTER_H
-#define CLITKRELATIVEPOSITIONANALYZERFILTER_H
+#define CLITKLABELIMAGEOVERLAPMEASUREFILTER_H
 
 // clitk
 #include "clitkFilterBase.h"
index 11c1e42bca39d9a9aa6662c7e99ac0c08f1051fe..f4aabfc673647d28e66d25c3a05c81eb1e75da9d 100644 (file)
@@ -94,8 +94,8 @@ GenerateData()
   clitk::Or<ImageType>(image_union, input2, GetBackgroundValue());
   clitk::And<ImageType>(image_intersection, input2, GetBackgroundValue());
   
-  writeImage<ImageType>(image_union, "union.mha");
-  writeImage<ImageType>(image_intersection, "intersection.mha");
+  // writeImage<ImageType>(image_union, "union.mha");
+  // writeImage<ImageType>(image_intersection, "intersection.mha");
   
   // Compute size
   typedef itk::LabelStatisticsImageFilter<ImageType, ImageType> StatFilterType;
@@ -120,7 +120,7 @@ GenerateData()
   statFilter->Update();
   int in2 = statFilter->GetCount(GetLabel1());
 
-  std::cout << in1 << " " << in2 << " " << inter << " " << u << " " << (double)inter/(double)u << std::endl;
+  std::cout << in1 << " " << in2 << " " << inter << " " << u << " " << 2.0*(double)inter/(double)(in1+in2) << std::endl;
 }
 //--------------------------------------------------------------------
 
index acecc385558081696b5b5db039770c2edccbf313..1ff880b657c8fc78893f1aa1fff44b07bad2ebe3 100644 (file)
@@ -76,6 +76,7 @@ namespace clitk {
 
     itkSetMacro(Extrude, bool);
     itkGetMacro(Extrude, bool);
+    itkBooleanMacro(Extrude);    
 
   protected:
     MeshToBinaryImageFilter();
index 94424b8631ca4e9fa7d7e1f3c4af3fbf90bf1d70..cd9a3bafbbc2a421b780a7f837df371429345b98 100644 (file)
@@ -109,6 +109,13 @@ GenerateData()
     // We extrude in the -slice_spacing direction to respect the FOCAL convention 
     extrude->SetVector(0, 0, -m_LikeImage->GetSpacing()[2]);
     sts->SetInput(extrude->GetOutput());
+    
+    // When extrude ScaleFactor indicate the extrusion scaling (default = 1)
+    /*
+      extrude->SetScaleFactor(m_LikeImage->GetSpacing()[2]/2.0);
+      DD(extrude->GetScaleFactor());
+      DD(extrude->GetCapping());
+    */ 
   }
   else
     sts->SetInput(m_Mesh);
index a8d12ada76206a2ea10d79e0bf2d7a30b22d6341..eff331daa9e6d99269629f4ba6f112aca2fcec96 100644 (file)
@@ -95,7 +95,9 @@ PrintOptions(std::ostream & os)
      << "ObjectCCLSelectionFlag = " << this->GetObjectCCLSelectionFlag() << std::endl    
      << "ObjectCCLSelectionDimension = " << this->GetObjectCCLSelectionDimension() << std::endl    
      << "ObjectCCLSelectionIgnoreSingleCCLFlag = " << this->GetObjectCCLSelectionIgnoreSingleCCLFlag() << std::endl    
-     << "IgnoreEmptySliceObjectFlag = " << this->GetIgnoreEmptySliceObjectFlag() << std::endl;    
+     << "IgnoreEmptySliceObjectFlag = " << this->GetIgnoreEmptySliceObjectFlag() << std::endl
+     << "(RP) FastFlag              = " << this->GetFastFlag() << std::endl
+     << "(RP) Radius                = " << this->GetRadius() << std::endl;
 }
 //--------------------------------------------------------------------
 
@@ -179,6 +181,8 @@ GenerateOutputInformation()
     m_working_object = clitk::ResizeImageLike<ImageType>(m_working_object, 
                                                          m_working_input, 
                                                          this->GetObjectBackgroundValue());
+    
+    // End
     this->template StopCurrentStep<ImageType>(m_working_input);  
   }
   
@@ -221,7 +225,7 @@ GenerateOutputInformation()
 
   //--------------------------------------------------------------------
   // Perform slice by slice relative position
-  this->StartNewStep("Perform slice by slice relative position");
+  this->StartNewStep("Perform slice by slice relative position ("+toString(mInputSlices.size())+")");
   for(unsigned int i=0; i<mInputSlices.size(); i++) {
     
     // Count the number of CCL (allow to ignore empty slice)
@@ -281,17 +285,14 @@ GenerateOutputInformation()
         // Relative position
         typedef clitk::AddRelativePositionConstraintToLabelImageFilter<SliceType> RelPosFilterType;
         typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
-
         relPosFilter->VerboseStepFlagOff();
         relPosFilter->WriteStepFlagOff();
         // relPosFilter->VerboseMemoryFlagOn();
-        relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId()+"-"+toString(i));
-        
+        relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId()+"-"+toString(i));        
         relPosFilter->SetBackgroundValue(this->GetBackgroundValue());
         relPosFilter->SetInput(mInputSlices[i]); 
         relPosFilter->SetInputObject(mObjectSlices[i]); 
-        relPosFilter->SetRemoveObjectFlag(this->GetRemoveObjectFlag());
-        
+        relPosFilter->SetRemoveObjectFlag(this->GetRemoveObjectFlag());        
         // This flag (InverseOrientation) *must* be set before
         // AddOrientation because AddOrientation can change it.
         relPosFilter->SetInverseOrientationFlag(this->GetInverseOrientationFlag());
@@ -303,11 +304,12 @@ GenerateOutputInformation()
         relPosFilter->SetFuzzyThreshold(this->GetFuzzyThreshold());
         relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
         relPosFilter->SetCombineWithOrFlag(this->GetCombineWithOrFlag()); 
-
         // should we stop after fuzzy map ?
         relPosFilter->SetFuzzyMapOnlyFlag(this->GetFuzzyMapOnlyFlag());
-        //        relPosFilter->SetComputeFuzzyMapFlag(this->GetComputeFuzzyMapFlag());
-      
+        //        relPosFilter->SetComputeFuzzyMapFlag(this->GetComputeFuzzyMapFlag());      
+        relPosFilter->SetFastFlag(this->GetFastFlag());
+        relPosFilter->SetRadius(this->GetRadius());
+
         // Go !
         relPosFilter->Update();
 
index 20c6b777c503aa9e15b490a2e1c651bdade0de38..9628b400542cd65f1235fd50f58871a1dd6d89c4 100644 (file)
@@ -76,8 +76,13 @@ namespace clitk {
     itkSetMacro(InputName, std::string);
     itkGetConstMacro(InputName, std::string);
 
+    itkGetConstMacro(ComputeOverlapFlag, bool);
+    itkSetMacro(ComputeOverlapFlag, bool);
+    itkBooleanMacro(ComputeOverlapFlag);
+
     void Read(std::string filename);     
     void SetFilterOptions(typename RelPosFilterType::Pointer filter, ArgsInfoType & options);
+    void SetReferenceImageForOverlapMeasure(ImagePointer ref);
 
   protected:
     RelativePositionList();
@@ -97,6 +102,8 @@ namespace clitk {
     typename SliceRelPosFilterType::Pointer mFilter;
     std::vector<ArgsInfoType> mArgsInfoList;
     ImagePointer m_working_input;
+    ImagePointer m_reference;
+    bool m_ComputeOverlapFlag;
 
   }; // end class
   //--------------------------------------------------------------------
index e0258d5e71fb560e166c81d1a86a6608c6fe1bcb..39cc272cd1156253b4578efa45b30f1a0789d0b0 100644 (file)
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
   ======================================================================-====*/
 
+#include "clitkLabelImageOverlapMeasureFilter.h"
 
 //--------------------------------------------------------------------
 template <class TImageType>
 clitk::RelativePositionList<TImageType>::
 RelativePositionList() {
+  ComputeOverlapFlagOff();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class TImageType>
+void
+clitk::RelativePositionList<TImageType>::
+SetReferenceImageForOverlapMeasure(ImagePointer ref) {
+  m_reference = ref;
+  ComputeOverlapFlagOn();
 }
 //--------------------------------------------------------------------
 
@@ -87,6 +100,8 @@ Read(std::string filename) {
       std::ofstream os;
       openFileForWriting(os, tmpfilename);
       os << text;
+      os << "input = nothing" << std::endl;
+      os << "output = nothing" << std::endl;
       os.close();
 
       // Create a struct to store options. I use two step to allow to
@@ -97,14 +112,11 @@ Read(std::string filename) {
       std::copy(tmpfilename.begin(), tmpfilename.end(), writable.begin());
       char ** argv = new char*[1];
       argv[0] = new char[1];
-      cmdline_parser_clitkRelativePosition2(1, argv, &args_info, 1, 1, 0);
-      args_info.input_given = 1;
-      args_info.input_arg = new char[1];
-      args_info.output_given = 1;
-      args_info.output_arg = new char[1];
-      cmdline_parser_clitkRelativePosition_configfile(&writable[0], &args_info, 0, 0, 1);
-      
-      // Store the args
+      struct cmdline_parser_clitkRelativePosition_params params;
+      params.override = 0;
+      params.initialize = 1;
+      params.check_required = 0;
+      cmdline_parser_clitkRelativePosition_configfile(&writable[0], &args_info, 1, 1, 1);
       mArgsInfoList.push_back(args_info);
       
       // Delete the temporary file
@@ -157,6 +169,7 @@ GenerateOutputInformation() {
       text += " slice by slice";
     }
     else text += " 3D";
+    text += " spacing=" + toString(mArgsInfoList[i].spacing_arg);
 
     StartNewStep(text);  
     typename RelPosFilterType::Pointer relPosFilter;
@@ -191,7 +204,16 @@ GenerateOutputInformation() {
     relPosFilter->Update();
     m_working_input = relPosFilter->GetOutput();  
     StopCurrentStep<ImageType>(m_working_input);
-    // clitk::PrintMemory(true, "End"); 
+
+    // Compute overlap with reference if needed
+    if (GetComputeOverlapFlag()) {
+      typedef clitk::LabelImageOverlapMeasureFilter<ImageType> FilterType;
+      typename FilterType::Pointer filter = FilterType::New();
+      filter->SetInput(0, m_working_input);
+      filter->SetInput(1, m_reference);
+      filter->Update();
+    }
+    
   }
 }
 //--------------------------------------------------------------------
index 3e7d303fce076c7df5634a573f1d1a57db13f05a..9bf57d0dc6f69ae6e277385a57bb0e5c80899241 100644 (file)
@@ -88,7 +88,7 @@ namespace clitk {
     
     // RelativePositionList management 
     void AddRelativePositionListFilename(std::string s);    
-    MaskImagePointer ApplyRelativePositionList(std::string name, MaskImageType * input);
+    MaskImagePointer ApplyRelativePositionList(std::string name, MaskImageType * input, bool overlap=false);
     
    protected:
     StructuresExtractionFilter();
index 3a3e0ab7c7758cbb26306b5330c028cfdf1b9e79..9559d4c2702ab9fe7cbff3cf21d632460a6f0aff 100644 (file)
@@ -47,7 +47,7 @@ AddRelativePositionListFilename(std::string s) {
 template <class TImageType>
 typename clitk::StructuresExtractionFilter<TImageType>::MaskImagePointer
 clitk::StructuresExtractionFilter<TImageType>::
-ApplyRelativePositionList(std::string name, MaskImageType * input) 
+ApplyRelativePositionList(std::string name, MaskImageType * input, bool overlap
 { 
   // Create all RelativePositionList
   for(unsigned int i=0; i<mListOfRelativePositionListFilename.size(); i++) {
@@ -71,8 +71,14 @@ ApplyRelativePositionList(std::string name, MaskImageType * input)
     relpos->SetCurrentStepNumber(GetCurrentStepNumber());
     relpos->SetWriteStepFlag(GetWriteStepFlag());
     relpos->SetInput(input);
+    if (overlap) {
+      std::string n = name.substr(8,2);
+      MaskImagePointer ref = this->GetAFDB()->template GetImage <MaskImageType>("S"+n+"_Ref");
+      relpos->SetReferenceImageForOverlapMeasure(ref);
+    }
     relpos->Update();
     input = relpos->GetOutput();
+
     SetCurrentStepNumber(relpos->GetCurrentStepNumber());
   }
   return input;
index 6b0af0747dd31698426d9de01be68d32fc06098e..e1f5b080e4cd749f3dfaede837890824c1e93ac6 100644 (file)
@@ -22,7 +22,8 @@ SET(vv_TOOLS
   vvToolStructureSetManager
   vvToolMIP
   vvToolConvert ## with dummy vvToolConvert.ui
-  
+  vvToolROIManager
+
   ## these ones are for tests (not working)
   # vvToolFoo
   # vvToolFooWithWidgetBase
index da5e5e478dfdc353914f5732dad7065df977c986..789e59f3564050deb3418e0c1ba28f97b320ee8e 100644 (file)
    <property name="text">
     <string>Open image(s)</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionClose_image">
    <property name="text">
    <property name="text">
     <string>Exit</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionSave_screenshot">
    <property name="text">
    <property name="text">
     <string>About</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionReload_images">
    <property name="text">
    <property name="text">
     <string>Open Dicom</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionOpen_Multiple_Images_As_One">
    <property name="icon">
    <property name="text">
     <string>Merge several nD images into a single (n+1)D image</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionSlice_Image_As_Multiple_Images">
    <property name="icon">
    <property name="text">
     <string>Slice a nD image into several (n-1)D images</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionOpen_one_Image_as_Multiple">
    <property name="text">
    <property name="shortcut">
     <string>Ctrl+S</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionAdd_VF_to_current_Image">
    <property name="icon">
    <property name="text">
     <string>Save image in TL</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionNorth_East_Window">
    <property name="icon">
    <property name="text">
     <string>Save image in TR</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionSouth_West_Window">
    <property name="icon">
    <property name="text">
     <string>Save image in BL</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionSouth_East_Window">
    <property name="icon">
    <property name="text">
     <string>Save image in BR</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionOpen_Image_With_Time">
    <property name="icon">
    <property name="text">
     <string>Open a nD image as a (n-1)D + t image</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionMerge_images_as_n_dim_t">
    <property name="icon">
    <property name="text">
     <string>Open several nD images into a single nD+t image</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionAdd_fusion_image">
    <property name="icon">
    <property name="text">
     <string>Add fusion image to current image</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionSegmentation">
    <property name="text">
     <string>Segmentation</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionResampler">
    <property name="text">
    <property name="text">
     <string>Surface Viewer</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionDebug">
    <property name="text">
    <property name="text">
     <string>Deformable Registration</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionWarp_image_with_vector_field">
    <property name="text">
     <string>Verify Registration</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionMaximum_Intensity_Projection">
    <property name="text">
    <property name="text">
     <string>Open VTK or OBJ contour</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionNavigation_Help">
    <property name="text">
    <property name="shortcut">
     <string>F1</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionOpen_Dicom_Struct">
    <property name="icon">
    <property name="text">
     <string>Open Dicom-Struct</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionCompute_mid_position_image">
    <property name="text">
     <string>Compute mid-position image</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionExperimental">
    <property name="text">
    <property name="text">
     <string>Register vv</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionSave_all_slices">
    <property name="text">
    <property name="toolTip">
     <string>Save current window and file states</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionRead_saved_state">
    <property name="icon">
    <property name="text">
     <string>Read Saved State</string>
    </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionAdd_overlay_image_to_current_image">
    <property name="icon">
index 60c247d33f854920d53965f9777357421b6d6dcb..f4848dba1b53f0ae5688b3455835f86b2af38c8a 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>411</width>
-    <height>534</height>
+    <width>350</width>
+    <height>708</height>
    </rect>
   </property>
   <property name="sizePolicy">
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_3">
+  <layout class="QVBoxLayout" name="verticalLayout_5">
+   <property name="spacing">
+    <number>2</number>
+   </property>
+   <property name="margin">
+    <number>2</number>
+   </property>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_2">
      <item>
        </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>
+    <widget class="QFrame" name="frame_3">
+     <property name="frameShape">
+      <enum>QFrame::StyledPanel</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Raised</enum>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <property name="spacing">
+       <number>2</number>
+      </property>
+      <property name="margin">
+       <number>2</number>
+      </property>
+      <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>54</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>
+       <widget class="QCheckBox" name="mBGModeCheckBox">
+        <property name="toolTip">
+         <string>Tick if you want to consider FG mode instead of BG mode.</string>
+        </property>
+        <property name="text">
+         <string>FG ?</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QFrame" name="frame_4">
+     <property name="enabled">
+      <bool>true</bool>
+     </property>
+     <property name="frameShape">
+      <enum>QFrame::StyledPanel</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Raised</enum>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_10">
+      <property name="spacing">
+       <number>2</number>
+      </property>
+      <property name="margin">
+       <number>2</number>
+      </property>
+      <item>
+       <widget class="QLabel" name="vectorFieldNameLabel_5">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Load DICOM-RT-Struct</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="mOpenDicomButton">
+        <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_6">
+        <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>
+    </widget>
    </item>
    <item>
     <widget class="QTreeWidget" name="mTree">
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
+     <property name="minimumSize">
+      <size>
+       <width>0</width>
+       <height>0</height>
+      </size>
+     </property>
+     <property name="font">
+      <font>
+       <pointsize>9</pointsize>
+      </font>
+     </property>
      <property name="editTriggers">
       <set>QAbstractItemView::AllEditTriggers</set>
      </property>
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="mGroupBoxROI">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
+    <widget class="QFrame" name="frame">
+     <property name="frameShape">
+      <enum>QFrame::StyledPanel</enum>
      </property>
-     <property name="title">
-      <string>Selected ROI</string>
+     <property name="frameShadow">
+      <enum>QFrame::Raised</enum>
      </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>
+     <layout class="QGridLayout" name="gridLayout">
+      <property name="margin">
+       <number>2</number>
+      </property>
+      <property name="spacing">
+       <number>2</number>
+      </property>
+      <item row="0" column="0">
+       <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">
+         <property name="spacing">
+          <number>2</number>
+         </property>
+         <property name="margin">
+          <number>2</number>
+         </property>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_8">
+           <property name="spacing">
+            <number>1</number>
+           </property>
+           <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">
+           <property name="spacing">
+            <number>2</number>
+           </property>
+           <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">
+           <property name="spacing">
+            <number>2</number>
+           </property>
+           <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>
+            <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>
+           <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">
+           <property name="spacing">
+            <number>2</number>
+           </property>
+           <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>        </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>
-       <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>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_7">
+     <property name="spacing">
+      <number>2</number>
+     </property>
+     <item>
+      <widget class="QFrame" name="frame_2">
+       <property name="frameShape">
+        <enum>QFrame::StyledPanel</enum>
+       </property>
+       <property name="frameShadow">
+        <enum>QFrame::Raised</enum>
+       </property>
+       <layout class="QGridLayout" name="gridLayout_2">
+        <property name="margin">
+         <number>2</number>
+        </property>
+        <property name="spacing">
+         <number>2</number>
+        </property>
+        <item row="0" column="0">
+         <layout class="QHBoxLayout" name="horizontalLayout_4">
+          <property name="spacing">
+           <number>2</number>
           </property>
-         </widget>
-        </item>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_6">
           <item>
-           <widget class="QLabel" name="mROInameLabel_2">
+           <widget class="QGroupBox" name="groupBox">
             <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 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>
         </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>
+      </widget>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <item>
+        <widget class="QLabel" name="mROInameLabel_4">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Close tab</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </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>
+    </layout>
    </item>
   </layout>
  </widget>
+ <tabstops>
+  <tabstop>mOpenBinaryButton</tabstop>
+  <tabstop>mBackgroundValueSpinBox</tabstop>
+  <tabstop>mBGModeCheckBox</tabstop>
+  <tabstop>mOpenDicomButton</tabstop>
+  <tabstop>mTree</tabstop>
+  <tabstop>mCheckBoxShow</tabstop>
+  <tabstop>mChangeColorButton</tabstop>
+  <tabstop>mReloadButton</tabstop>
+  <tabstop>mOpacitySlider</tabstop>
+  <tabstop>mOpacitySpinBox</tabstop>
+  <tabstop>mContourCheckBoxShow</tabstop>
+  <tabstop>mChangeContourColorButton</tabstop>
+  <tabstop>mContourWidthSpinBox</tabstop>
+  <tabstop>mDepthSpinBox</tabstop>
+  <tabstop>mCheckBoxShowAll</tabstop>
+  <tabstop>mContourCheckBoxShowAll</tabstop>
+  <tabstop>mCloseButton</tabstop>
+ </tabstops>
  <resources>
   <include location="../vvIcons.qrc"/>
  </resources>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>219</x>
-     <y>385</y>
+     <x>289</x>
+     <y>371</y>
     </hint>
     <hint type="destinationlabel">
-     <x>376</x>
-     <y>376</y>
+     <x>413</x>
+     <y>374</y>
     </hint>
    </hints>
   </connection>
      <y>367</y>
     </hint>
     <hint type="destinationlabel">
-     <x>222</x>
-     <y>373</y>
+     <x>292</x>
+     <y>371</y>
     </hint>
    </hints>
   </connection>
index bfc5343f62484176c130c229e6a0491b910ea441..4ace9bb389239a1956477d035e51a8b7e8b48c95 100644 (file)
@@ -67,8 +67,8 @@ void vvMeshActor::Init(vvMesh::Pointer mesh,int time_slice,vvImage::Pointer vf)
 
 void vvMeshActor::SetCutSlice(double slice)
 {
-  DD("SetCutSlice");
-  DD(slice);
+  //DD("SetCutSlice");
+  //DD(slice);
   mCutSlice=slice;
   vtkImageData* mask;
   if (static_cast<unsigned int>(mTimeSlice)<mMesh->GetNumberOfMasks())
index 50a448941e8f524c0e567191f9356fa51264ff6b..f25926ca5d7f77cb23c72b9e8534167f9186f238 100644 (file)
@@ -51,9 +51,12 @@ void vvToolCreatorBase::InsertToolInMenu(vvMainWindowBase * m)
   // Create main action
   if (mToolIconFilename == "noicon")
     mAction = new QAction(QString("&").append(mToolMenuName), this);
-  else
+  else {
     mAction = new QAction(QIcon(mToolIconFilename),
                           QString("&").append(mToolMenuName), this);
+    mAction->setIconVisibleInMenu(true);
+  }
+
   mAction->setStatusTip(mToolTip);
   // Connect the action
   connect(mAction, SIGNAL(triggered()), this, SLOT(MenuToolSlot()));
index 77a65d3543c37ee3db2d4fac2e76b500ac24b4fa..7f544a5e31f8d1493b21fa080daa66ca1f4bc845 100644 (file)
@@ -22,6 +22,8 @@
 #include "vvROIActor.h"
 #include "vvSlicer.h"
 #include "vvROIActor.h"
+#include "vvMeshReader.h"
+#include "vvStructSelector.h"
 
 // Qt
 #include <QFileDialog>
@@ -41,20 +43,54 @@ 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)), 
+  QWidget(parent->GetTab()), 
   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);
+  // Store parent
+  mMainWindow = parent;
+  
+  // Assume the initial tab ROI index is 2
+  mIndexFirstTab = 2;
+
+  // Get the ROI Tab
+  QWidget * tab = qFindChild<QWidget*>(parent->GetTab(), "ROItab");
+  
+  // Set it as current
+  parent->GetTab()->setCurrentIndex(mIndexFirstTab);
+  
+  // Check if widget already used
+  if (tab->layout()->isEmpty()) {
+    tab->layout()->addWidget(this);
+  }
+  else {
+    close();
+    return;
+  }
   
   // Build the UI
   Ui_vvToolROIManager::setupUi(this);
   setAttribute(Qt::WA_DeleteOnClose);
+  mTree->clear();
+  mTree->header()->resizeSection(0, 30);
+  mGroupBoxROI->setEnabled(false);
+  
+  // Temporary disable "Load dicom" button
+  frame_4->hide();
+
+  // Set default LUT
+  mDefaultLUTColor = vtkSmartPointer<vtkLookupTable>::New();
+  for(int i=0; i<mDefaultLUTColor->GetNumberOfTableValues(); i++) {
+    double r = (rand()/(RAND_MAX+1.0));
+    double v = (rand()/(RAND_MAX+1.0));
+    double b = (rand()/(RAND_MAX+1.0));
+    mDefaultLUTColor->SetTableValue(i, r, v, b);
+  }
+#include "vvDefaultLut.h"
+
+  // Initialization
+  mNumberOfVisibleROI = 0;
+  mNumberOfVisibleContourROI = 0;
 
   // Select the current image as the target
   int i = parent->GetSlicerManagerCurrentIndex();
@@ -65,8 +101,20 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f)
           this, SLOT(AnImageIsBeingClosed(vvSlicerManager *)));
   connect(parent, SIGNAL(SelectedImageHasChanged(vvSlicerManager *)), 
           this, SLOT(SelectedImageHasChanged(vvSlicerManager *)));
-
-  // mMainWindowBase->GetTab()->setTabIcon(mTabNumber, GetToolIcon());
+  connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(OpenBinaryImage()));
+  connect(mOpenDicomButton, SIGNAL(clicked()), this, SLOT(OpenDicomImage()));
+  connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
+  connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
+  connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
+  connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
+  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
+  connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
+  connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
+  connect(mReloadButton, SIGNAL(clicked()), this, SLOT(ReloadCurrentROI()));
+  connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
+  connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
+  connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()));
 }
 //------------------------------------------------------------------------------
 
@@ -74,7 +122,6 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f)
 //------------------------------------------------------------------------------
 vvToolROIManager::~vvToolROIManager()
 {
-  std::cout << "vvToolROIManager::~vvToolROIManager()" << std::endl;
 }
 //------------------------------------------------------------------------------
 
@@ -94,14 +141,24 @@ void vvToolROIManager::Initialize() {
 //------------------------------------------------------------------------------
 void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
 {
-  std::cout << "vvToolROIManager::InputIsSelected()" << std::endl;
   mSlicerManager = m;
 
-  // Signal/slot
-  connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()));
-
   // Initialization
+  mSlicerManager = m;
+  mCurrentImage = mSlicerManager->GetImage();
+
+  // Refuse if 4D
+  if (mCurrentImage->GetNumberOfDimensions() != 3) {
+    QMessageBox::information(this,tr("Sorry only 3D yet"), tr("Sorry only 3D yet"));
+    close();
+    return;
+  }
 
+  // Change gui
+  mLabelInputInfo->setText(QString("%1").arg(m->GetFileName().c_str()));
+
+  // Auto display browser to select new contours 
+  OpenBinaryImage();
 }
 //------------------------------------------------------------------------------
 
@@ -109,14 +166,465 @@ void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
 //------------------------------------------------------------------------------
 void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m)
 {
-  if (m == mSlicerManager) close();
+  if (m == mSlicerManager) { 
+    close();
+    return;
+  }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::close()
+{
+  // Update to delete actors
+  UpdateAllContours();
+  QWidget::close();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
-  if (m != mSlicerManager) hide();
-  else show();
+  if (m != mSlicerManager) hide(); 
+  else {
+    show();
+  }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::OpenBinaryImage() 
+{
+  // Open images
+  QString Extensions = "Images files ( *.mha *.mhd *.hdr *.his)";
+  Extensions += ";;All Files (*)";
+  QStringList filename =
+    QFileDialog::getOpenFileNames(this,tr("Open binary image"),
+                                 mMainWindowBase->GetInputPathName(),Extensions);
+  if (filename.size() == 0) return;
+  
+  // For each selected file, open the image
+  for(int i=0; i<filename.size(); i++) {
+    // Open Image
+    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+    vvImageReader::Pointer reader = vvImageReader::New();
+    std::vector<std::string> filenames;
+    filenames.push_back(filename[i].toStdString());
+    reader->SetInputFilenames(filenames);
+    reader->Update(vvImageReader::IMAGE);
+    QApplication::restoreOverrideCursor();
+
+    if (reader->GetLastError().size() != 0) {
+      std::cerr << "Error while reading " << filename[i].toStdString() << std::endl;
+      QString error = "Cannot open file \n";
+      error += reader->GetLastError().c_str();
+      QMessageBox::information(this,tr("Reading problem"),error);
+      return;
+    }
+    vvImage::Pointer binaryImage = reader->GetOutput();
+    AddImage(binaryImage, filename[i].toStdString(), mBackgroundValueSpinBox->value(),
+             (!mBGModeCheckBox->isChecked()));
+    mOpenedBinaryImage.push_back(binaryImage);
+  }
+
+  // Update the contours
+  UpdateAllContours(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::OpenDicomImage() 
+{
+  DD("OpenDicomImage");
+  QString Extensions = "Dicom Files ( *.dcm RS*)";
+  Extensions += ";;All Files (*)";
+  QString file = QFileDialog::getOpenFileName(this,tr("Merge Images"), 
+                                              mMainWindow->GetInputPathName(), 
+                                              Extensions);
+  if (file.isNull()) return;
+
+  //  AddDCStructContour(index, file);
+  vvMeshReader reader;
+  reader.SetFilename(file.toStdString());
+  vvStructSelector selector;
+  selector.SetStructures(reader.GetROINames());
+  // selector.EnablePropagationCheckBox(); FIXME Disable
+
+  // FIXME : change text -> allow to save binary image
+
+  if (selector.exec()) {
+    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+    reader.SetSelectedItems(selector.getSelectedItems());
+    reader.SetImage(mSlicerManager->GetImage());
+    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 vvToolROIManager::AddImage(vvImage * binaryImage, std::string filename, 
+                                double BG, bool modeBG) 
+{
+  // Check Dimension
+  int dim = mCurrentImage->GetNumberOfDimensions();
+  int bin_dim = binaryImage->GetNumberOfDimensions();
+  if (dim < bin_dim) {
+    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;
+  }
+  
+  // Compute roi index
+  int n = mROIList.size();
+  
+  // Compute the name of the new ROI
+  std::ostringstream oss;
+  oss << vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename));
+  std::string name = oss.str();
+  
+  // Set color
+  std::vector<double> color;
+  color.push_back(1);
+  color.push_back(0);
+  color.push_back(0);
+
+  // Create ROI
+  clitk::DicomRT_ROI::Pointer roi = clitk::DicomRT_ROI::New();
+  roi->SetFromBinaryImage(binaryImage, n, name, color, filename);
+
+  // Add a new roi to the list
+  mROIList.push_back(roi);
+  // Set BG or FG mode
+  if (modeBG) 
+    roi->SetBackgroundValueLabelImage(BG);
+  else 
+    roi->SetForegroundValueLabelImage(BG);
+  
+  // Change color
+  if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
+    double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ());
+    roi->SetDisplayColor(color[0], color[1], color[2]);
+  }
+  
+  // Add a new roi actor
+  QSharedPointer<vvROIActor> actor = QSharedPointer<vvROIActor>(new vvROIActor);
+  actor->SetBGMode(modeBG);
+  actor->SetROI(roi);
+  actor->SetSlicerManager(mSlicerManager);
+  actor->Initialize(n+1); // depth is n+1 to start at 1
+  mROIActorsList.push_back(actor);
+  
+  // CheckBox for "All"
+  if (actor->IsVisible()) mNumberOfVisibleROI++;
+  if (actor->IsContourVisible()) mNumberOfVisibleContourROI++;
+  
+  // Add ROI in tree
+  mTreeWidgetList.push_back(QSharedPointer<QTreeWidgetItem>(new QTreeWidgetItem(mTree)));
+  QTreeWidgetItem * w = mTreeWidgetList.back().data();
+  w->setText(0, QString("%1").arg(roi->GetROINumber()));
+  w->setText(1, QString("%1").arg(roi->GetName().c_str()));
+  w->setText(3, QString("%1").arg(actor->GetDepth()));  
+  QBrush brush(QColor(roi->GetDisplayColor()[0]*255, 
+                      roi->GetDisplayColor()[1]*255, 
+                      roi->GetDisplayColor()[2]*255));
+  brush.setStyle(Qt::SolidPattern);
+  w->setBackground(2, brush);
+  mMapROIToTreeWidget[roi] = w;
+  mMapTreeWidgetToROI[w] = roi;
+  mTree->resizeColumnToContents(0);
+  mTree->resizeColumnToContents(1);
+
+  // Update 
+  UpdateAllROIStatus(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::UpdateAllContours() 
+{
+  // Render loaded ROIs (the first is sufficient)
+  for(unsigned int i=0; i<mROIList.size(); i++) {
+    mROIActorsList[i]->Update();
+  }
+  for(int i=0; i<mSlicerManager->GetNumberOfSlicers(); i++) {
+    mSlicerManager->GetSlicer(i)->Render();
+  }  
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::UpdateAllROIStatus() {
+  int nbVisible = 0;
+  int nb = mROIList.size();
+  for(int i=0; i<nb; i++) {
+    if (mROIActorsList[i]->IsVisible()) {
+      nbVisible++;
+    }
+  }
+
+  // change the states
+  disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));  
+  disconnect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
+  if (nbVisible == nb) mCheckBoxShowAll->setCheckState(Qt::Checked);
+  else {
+    if (nbVisible == 0) mCheckBoxShowAll->setCheckState(Qt::Unchecked);
+    else mCheckBoxShowAll->setCheckState(Qt::PartiallyChecked);
+  }
+  connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
+  connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::SelectedItemChangedInTree() {
+  // Search which roi is selected
+  QList<QTreeWidgetItem *> l = mTree->selectedItems();
+  if (l.size() == 0) {
+    //    mCurrentROIActor = 0;
+    mCurrentROI = NULL;
+    mGroupBoxROI->setEnabled(false);
+    return;
+  }
+  QTreeWidgetItem * w = l[0];
+  if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) {
+    //    mCurrentROIActor = 0;
+    mCurrentROI = NULL;
+    mGroupBoxROI->setEnabled(false);
+    return;
+  }
+  if (w == NULL) return;
+  clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w];
+  if (roi == NULL) return; // sometimes it is called while there is no roi anymore
+  // Get selected roi actor
+  int n = roi->GetROINumber();
+  QSharedPointer<vvROIActor> actor = mROIActorsList[n];
+  mCurrentROI = roi;
+  mCurrentROIActor = actor;
+
+  // Warning -> avoid unuseful Render here by disconnect slider 
+  // Update GUI
+  disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
+  disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
+  disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
+  disconnect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
+  disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  disconnect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
+  disconnect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
+  disconnect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
+
+  mGroupBoxROI->setEnabled(true);
+  mROInameLabel->setText(roi->GetName().c_str());
+  mCheckBoxShow->setChecked(actor->IsVisible());
+  mContourCheckBoxShow->setChecked(actor->IsContourVisible());
+  mContourWidthSpinBox->setValue(actor->GetContourWidth());
+  mDepthSpinBox->setValue(actor->GetDepth());
+  w->setText(3, QString("%1").arg(actor->GetDepth()));
+  mOpacitySlider->setValue((int)lrint(actor->GetOpacity()*100));
+  mOpacitySpinBox->setValue((int)lrint(actor->GetOpacity()*100));
+
+  connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
+  connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
+  connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
+  connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
+  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
+  connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
+  connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
+
+  
+  // Set the current color to the selected ROI name
+  mROInameLabel->setAutoFillBackground(true);// # This is important!!
+  mROInameLabel->setStyleSheet("QLabel { background-color : red; color : blue; }");
+  QColor color = QColor(mCurrentROI->GetDisplayColor()[0]*255,
+                        mCurrentROI->GetDisplayColor()[1]*255,
+                        mCurrentROI->GetDisplayColor()[2]*255);
+  QString values = QString("%1, %2, %3").arg(color.red()).arg(color.green()).arg(color.blue());
+  mROInameLabel->setStyleSheet("QLabel { background-color: rgb("+values+"); }");
+
+
+  mGroupBoxROI->setEnabled(true);
+  // is this needed ?
+  //  actor->Update(); 
+  // Final rendering
+  // mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::VisibleROIToggled(bool b) {
+  if (mCurrentROIActor == NULL) return;
+  if (b == mCurrentROIActor->IsVisible()) return; // nothing to do
+  mCurrentROIActor->SetVisible(b);
+  UpdateAllROIStatus();
+  mSlicerManager->Render(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::VisibleContourROIToggled(bool b) {
+  if (mCurrentROIActor == NULL) return;
+  if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do
+  mCurrentROIActor->SetContourVisible(b);
+  mCurrentROIActor->UpdateColor();
+  mSlicerManager->Render(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::OpacityChanged(int v) {
+  if (mCurrentROIActor == NULL) return;
+  mCurrentROIActor->SetOpacity((double)v/100.0);
+  mCurrentROIActor->UpdateColor();
+  mSlicerManager->Render(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::AllVisibleROIToggled(int b) {
+  bool status = false;
+  if ((mCheckBoxShowAll->checkState() == Qt::Checked) ||
+      (mCheckBoxShowAll->checkState() == Qt::PartiallyChecked))  status = true;
+
+  for(uint i=0; i<mROIList.size(); i++) {
+    mROIActorsList[i]->SetVisible(status);
+  }
+  if (status) mCheckBoxShowAll->setCheckState(Qt::Checked);
+  else  mCheckBoxShowAll->setCheckState(Qt::Unchecked);
+  mCheckBoxShow->setChecked(status);
+  mSlicerManager->Render(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::AllVisibleContourROIToggled(bool b) {
+  bool status = false;
+  if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) ||
+      (mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked))  status = true;
+  // Update current 
+  for(uint i=0; i<mROIActorsList.size(); i++) {
+    mROIActorsList[i]->SetContourVisible(status);
+  }
+  // Update current selection
+  if (status) mContourCheckBoxShowAll->setCheckState(Qt::Checked);
+  else  mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
+  mContourCheckBoxShow->setChecked(status);
+  mSlicerManager->Render(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::ChangeColor() {
+  if (mCurrentROIActor == NULL) return;
+  QColor color;
+  color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0],
+                mCurrentROIActor->GetROI()->GetDisplayColor()[1],
+                mCurrentROIActor->GetROI()->GetDisplayColor()[2]);
+  QColor c = QColorDialog::getColor(color, this, "Choose the ROI color");
+  mCurrentROIActor->GetROI()->SetDisplayColor(c.redF(), c.greenF(), c.blueF());
+  mCurrentROIActor->UpdateColor();
+
+  QTreeWidgetItem * w = mMapROIToTreeWidget[mCurrentROI];
+  QBrush brush(QColor(mCurrentROI->GetDisplayColor()[0]*255,
+                      mCurrentROI->GetDisplayColor()[1]*255,
+                      mCurrentROI->GetDisplayColor()[2]*255));
+  brush.setStyle(Qt::SolidPattern);
+  w->setBackground(2, brush);
+  // Render
+  mSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::ChangeContourColor() {
+  if (mCurrentROIActor == NULL) return;
+  QColor color;
+  color.setRgbF(mCurrentROIActor->GetContourColor()[0], 
+               mCurrentROIActor->GetContourColor()[1], 
+               mCurrentROIActor->GetContourColor()[2]);
+  QColor c = QColorDialog::getColor(color, this, "Choose the contour color");
+  mCurrentROIActor->SetContourColor(c.redF(), c.greenF(), c.blueF());
+  mCurrentROIActor->UpdateColor();
+  mSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::ChangeContourWidth(int n) {
+  if (mCurrentROIActor == NULL) return;
+  mCurrentROIActor->SetContourWidth(n);
+  mCurrentROIActor->UpdateColor();
+  mSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::ChangeDepth(int n) {
+  if (mCurrentROIActor == NULL) return;
+  mCurrentROIActor->SetDepth(n);
+  mCurrentROIActor->UpdateImage();
+  mSlicerManager->Render();
+  QList<QTreeWidgetItem *> l = mTree->selectedItems();
+  QTreeWidgetItem * w = l[0];
+  w->setText(3, QString("%1").arg(mCurrentROIActor->GetDepth()));
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolROIManager::ReloadCurrentROI() {
+
+  // Remove all contours/overlay first
+  bool visible = mCurrentROIActor->IsVisible();
+  bool cvisible = mCurrentROIActor->IsContourVisible();
+  mCurrentROIActor->SetVisible(false);
+  mCurrentROIActor->SetContourVisible(false);
+  mSlicerManager->Render();
+  
+  // Reload image
+  vvImageReader::Pointer reader = vvImageReader::New();
+  reader->SetInputFilename(mCurrentROI->GetFilename());
+  reader->Update(vvImageReader::IMAGE);
+  if (reader->GetLastError() != "") {
+    QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), 
+                             reader->GetLastError().c_str());
+    return;
+  }
+
+  mCurrentROI->GetImage()->Reset();//GetFirstVTKImageData()->ReleaseData();
+  mCurrentROI->SetImage(reader->GetOutput());
+  
+  // Update visu
+  mCurrentROIActor->UpdateImage();
+  mCurrentROIActor->SetVisible(visible);
+  mCurrentROIActor->SetContourVisible(cvisible);
+  mSlicerManager->Render();    
 }
 //------------------------------------------------------------------------------
index 2d91264405229913f4e8da7029c7f2bd7b5a1d96..3e139c9439f662e1b78295ba135f1494859f94b3 100644 (file)
@@ -43,13 +43,52 @@ class vvToolROIManager:
   static void Initialize();
   virtual void InputIsSelected(vvSlicerManager *m);
 
+  void AddImage(vvImage * binaryImage, std::string filename, double BG, bool m_modeBG=true);
+  void UpdateAllContours();
+  void UpdateAllROIStatus();
+
   public slots:
   void AnImageIsBeingClosed(vvSlicerManager *);
   void SelectedImageHasChanged(vvSlicerManager *);
+  void OpenBinaryImage();
+  void OpenDicomImage();
+  void SelectedItemChangedInTree();
+  void VisibleROIToggled(bool b);
+  void VisibleContourROIToggled(bool b);
+  void OpacityChanged(int v);
+  void ChangeColor();
+  void ChangeContourColor();
+  void ChangeContourWidth(int n);
+  void ChangeDepth(int n);
+  void AllVisibleROIToggled(int b);
+  void AllVisibleContourROIToggled(bool b);
+  void ReloadCurrentROI();  
+  void close();
 
 protected:
   Ui::vvToolROIManager ui;
   vvSlicerManager * mSlicerManager;
+  vvImage * mCurrentImage;
+  vvMainWindowBase * mMainWindow;
+  int mIndexFirstTab;
+  
+  int mNumberOfVisibleROI;
+  int mNumberOfVisibleContourROI;
+
+  vtkSmartPointer<vtkLookupTable> mDefaultLUTColor;
+
+  std::vector<vvImage::Pointer> mOpenedBinaryImage;
+  std::vector<clitk::DicomRT_ROI::Pointer> mROIList;
+  std::vector<QSharedPointer<vvROIActor> > mROIActorsList;
+
+  // Data for the widget Tree
+  std::vector< QSharedPointer<QTreeWidgetItem> > mTreeWidgetList;
+  std::map<clitk::DicomRT_ROI::Pointer, QTreeWidgetItem *> mMapROIToTreeWidget;
+  std::map<QTreeWidgetItem *, clitk::DicomRT_ROI::Pointer> mMapTreeWidgetToROI;
+  
+  // Data for current selected roi
+  clitk::DicomRT_ROI::Pointer mCurrentROI;
+  QSharedPointer<vvROIActor> mCurrentROIActor;
  
 }; // end class vvToolROIManager
 //------------------------------------------------------------------------------