]> Creatis software - clitk.git/commitdiff
Moved vvImageReader and vvImageWriter to clitkCommon for use in tools. Removed vvCons...
authorsrit <srit>
Mon, 11 Apr 2011 09:54:16 +0000 (09:54 +0000)
committersrit <srit>
Mon, 11 Apr 2011 09:54:16 +0000 (09:54 +0000)
16 files changed:
common/CMakeLists.txt
common/vvImageReader.cxx [moved from vv/vvImageReader.cxx with 94% similarity]
common/vvImageReader.h [moved from vv/vvImageReader.h with 92% similarity]
common/vvImageReader.txx [moved from vv/vvImageReader.txx with 99% similarity]
common/vvImageWriter.cxx [moved from vv/vvImageWriter.cxx with 100% similarity]
common/vvImageWriter.h [moved from vv/vvImageWriter.h with 100% similarity]
common/vvImageWriter.txx [moved from vv/vvImageWriter.txx with 100% similarity]
vv/CMakeLists.txt
vv/vv.cxx
vv/vvConstants.h [deleted file]
vv/vvDeformableRegistration.cxx
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvToolStructureSetManager.cxx

index bc11149ad3982d7f10f7519d43769c8c8ea40575..5458f0128f90f1aa0912b164212b9691582df982 100644 (file)
@@ -27,12 +27,14 @@ SET(clitkCommon_SRC
   clitkDicomRTDoseIO.cxx
   clitkDicomRTDoseIOFactory.cxx
   clitkOrientation.cxx
-  vvImage.cxx
   clitkImageToImageGenericFilterBase.cxx
   clitkExceptionObject.cxx
   clitkFilterBase.cxx
   clitkMemoryUsage.cxx
-)  
+  vvImage.cxx
+  vvImageReader.cxx
+  vvImageWriter.cxx
+)
 
 ### Declare clitkCommon library
 ADD_LIBRARY(clitkCommon STATIC ${clitkCommon_SRC})
similarity index 94%
rename from vv/vvImageReader.cxx
rename to common/vvImageReader.cxx
index 25e235a08edb3b713b347b5a5a1147aaed7fb061..4aad9b88099fed601a7a24a5aef4f2089824c45e 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef VVIMAGEREADER_CXX
 #define VVIMAGEREADER_CXX
 
-#include <QApplication>
 #include <itkImageFileReader.h>
 #include "vvImageReader.h"
 #include "vvImageReader.txx"
@@ -74,18 +73,7 @@ void vvImageReader::Update(int dim,std::string inputPixelType, LoadedImageType t
   mType = type;
   mDim = dim;
   mInputPixelType=inputPixelType;
-  this->start(); //Start heavy read operation in a separate thread
-  while (this->isRunning()) {
-    qApp->processEvents();
-    this->wait(50);
-  }
-}
-//------------------------------------------------------------------------------
 
-
-//------------------------------------------------------------------------------
-void vvImageReader::run()
-{
   switch(mDim)     {
   case 2:
     UpdateWithDim<2>(mInputPixelType);
similarity index 92%
rename from vv/vvImageReader.h
rename to common/vvImageReader.h
index cbe7d1607e62b63c1bca49cdaeb93fd8cf8ed909..2056880c0e567015c4dec4fa405d551c461568da 100644 (file)
 #define vvImageReader_H
 #include <string>
 #include <vector>
-#include <QThread>
 
 #include "itkCommand.h"
 #include "vvImage.h"
-#include "vvConstants.h"
 
-class vvImageReader : public itk::LightObject, public QThread {
+class vvImageReader : public itk::LightObject {
 
 public:
+  //Image types
+  typedef enum _IMAGETYPE {
+  IMAGE = 20,
+  DICOM,
+  MERGED,
+  SLICED,
+  IMAGEWITHTIME,
+  MERGEDWITHTIME,
+  VECTORFIELD,
+  UNDEFINEDIMAGETYPE
+  } LoadedImageType;
+
   typedef vvImageReader Self;
   typedef itk::SmartPointer<Self> Pointer;
   itkNewMacro(Self);
@@ -52,7 +62,6 @@ public:
   void Update(int dim, std::string InputPixelType, LoadedImageType type);
 
 protected:
-  void run();
   //====================================================================
   std::vector<std::string> mInputFilenames;
   ///Method used to load the image, see vvConstants.h for definition
similarity index 99%
rename from vv/vvImageReader.txx
rename to common/vvImageReader.txx
index 3c5e1545878b27511d100c559db30a1c2f473dbf..e3c2bca72d327e25743346b604dac59ba6c11bb0 100644 (file)
@@ -29,8 +29,6 @@
 #include "clitkCommon.h"
 #include "clitkConfiguration.h"
 #include "vvFromITK.h"
-#include "vvConstants.h"
-
 //----------------------------------------------------------------------------
 template<unsigned int VImageDimension>
 void vvImageReader::UpdateWithDim(std::string InputPixelType)
similarity index 100%
rename from vv/vvImageWriter.h
rename to common/vvImageWriter.h
index 12e38a5d36ae0d254d46b17f8fecea4613d412ba..e91c2bff7514dd8d74127f4ecfafa9b0fe1395c9 100644 (file)
@@ -73,10 +73,6 @@ SET(vv_SRCS
   vtkVOXImageWriter.cxx
   vvInteractorStyleNavigator.cxx
   vvSlicer.cxx
-  vvImageReader.cxx
-  vvImageReader.txx
-  vvImageWriter.cxx
-  vvImageWriter.txx
   vvLandmarks.cxx
   vvLandmarksGlyph.cxx
   vvGlyphSource.cxx
index 59cacb58911b5bb3ba8d51c18a49d46ae0840fee..2a04dc0d396f3765155fadeb098eac8c29c06360 100644 (file)
--- a/vv/vv.cxx
+++ b/vv/vv.cxx
@@ -30,8 +30,6 @@
 
 #include "clitkIO.h"
 #include "vvMainWindow.h"
-#include "vvConstants.h"
-
 #include <vtkFileOutputWindow.h>
 #include <vtkSmartPointer.h>
 #include <itkFileOutputWindow.h>
@@ -99,7 +97,7 @@ int main( int argc, char** argv )
       std::string current = argv[i];
       if (!current.compare(0,2,"--")) { //We are parsing an option
         if (parse_mode == P_SEQUENCE) {//First finish the current sequence
-          window.LoadImages(sequence_filenames,MERGEDWITHTIME);
+          window.LoadImages(sequence_filenames, vvImageReader::MERGEDWITHTIME);
           sequence_filenames.clear();
           parse_mode=P_NORMAL;
         }
@@ -161,12 +159,12 @@ int main( int argc, char** argv )
       } else {
         std::vector<std::string> image;
         image.push_back(current);
-        window.LoadImages(image,IMAGE);
+        window.LoadImages(image, vvImageReader::IMAGE);
         n_image_loaded++;
       }
     }
     if (parse_mode == P_SEQUENCE) { //Finish any current sequence
-      window.LoadImages(sequence_filenames,MERGEDWITHTIME);
+      window.LoadImages(sequence_filenames, vvImageReader::MERGEDWITHTIME);
       sequence_filenames.clear();
       parse_mode=P_NORMAL;
     }
diff --git a/vv/vvConstants.h b/vv/vvConstants.h
deleted file mode 100644 (file)
index dfc7b75..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*=========================================================================
-  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
-
-  Authors belong to: 
-  - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
-  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
-
-  This software is distributed WITHOUT ANY WARRANTY; without even
-  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-  PURPOSE.  See the copyright notices for more information.
-
-  It is distributed under dual licence
-
-  - BSD        See included LICENSE.txt file
-  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
-#ifndef vvConstants_h
-#define vvConstants_h
-
-//Constants used everywhere in the program
-
-//Image types
-typedef enum _IMAGETYPE {
-IMAGE = 20,
-DICOM,
-MERGED,
-SLICED,
-IMAGEWITHTIME,
-MERGEDWITHTIME,
-VECTORFIELD,
-UNDEFINEDIMAGETYPE
-} LoadedImageType;
-
-#endif
index 1586808ed1271ae624dda2d6e8471a456292ff35..227496404d90a64249eec28093efb1318a4ec93b 100644 (file)
@@ -182,7 +182,7 @@ void vvDeformableRegistration::run()
   }
   vvImageReader::Pointer reader = vvImageReader::New();
   reader->SetInputFilename(output_filename);
-  reader->Update(VECTORFIELD);
+  reader->Update(vvImageReader::VECTORFIELD);
   finish=clock();
   DD((finish - start)/static_cast<double>(CLOCKS_PER_SEC));
   mOutput = reader->GetOutput();
index 2d1feeb3d4c2ebcd4b2213241ce1241d4a6bd9f5..7a95ae68d80084e1fd4c6ceaa06bb7717dd916bc 100644 (file)
@@ -42,7 +42,6 @@
 #include "vvMesh.h"
 #include "vvStructSelector.h"
 #include "vvMeshReader.h"
-#include "vvConstants.h"
 #include "clitkConfiguration.h"
 
 // ITK include
@@ -603,7 +602,7 @@ void vvMainWindow::MergeImages()
     }
   }
   if (vector.size() > 0)
-    LoadImages(vector, MERGED);
+    LoadImages(vector, vvImageReader::MERGED);
 }
 //------------------------------------------------------------------------------
 
@@ -620,7 +619,7 @@ void vvMainWindow::SliceImages()
   std::vector<std::string> vector;
   for (int i = 0; i < files.size(); i++)
     vector.push_back(files[i].toStdString());
-  LoadImages(vector, SLICED);
+  LoadImages(vector, vvImageReader::SLICED);
 }
 //------------------------------------------------------------------------------
 
@@ -682,7 +681,7 @@ void vvMainWindow::MergeImagesWithTime()
   }
   sort(vector.begin(),vector.end());
   if (vector.size() > 1)
-    LoadImages(vector, MERGEDWITHTIME);
+    LoadImages(vector, vvImageReader::MERGEDWITHTIME);
   else
     QMessageBox::warning(this,tr("Reading problem"),"You need to select at least two images to merge images with time.\nIf you only want to open one image, please use the \"Open Image\" function.");
 }
@@ -697,7 +696,7 @@ void vvMainWindow::OpenDicom()
   std::cout << "dicomSeriesSelector " << std::endl;
   if (dicomSeriesSelector->exec() == QDialog::Accepted) {
     files = *(dicomSeriesSelector->GetFilenames());
-    LoadImages(files,DICOM);
+    LoadImages(files, vvImageReader::DICOM);
   }
 }
 //------------------------------------------------------------------------------
@@ -715,7 +714,7 @@ void vvMainWindow::OpenImages()
   std::vector<std::string> vector;
   for (int i = 0; i < files.size(); i++)
     vector.push_back(files[i].toStdString());
-  LoadImages(vector, IMAGE);
+  LoadImages(vector, vvImageReader::IMAGE);
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenRecentImage()
@@ -724,7 +723,7 @@ void vvMainWindow::OpenRecentImage()
   std::vector<std::string> images;
   images.push_back(caller->text().toStdString());
   mInputPathName = itksys::SystemTools::GetFilenamePath(images[0]).c_str();
-  LoadImages(images,IMAGE);
+  LoadImages(images, vvImageReader::IMAGE);
 }
 //------------------------------------------------------------------------------
 
@@ -743,17 +742,17 @@ void vvMainWindow::OpenImageWithTime()
   for (int i = 0; i < files.size(); i++) {
     vector.push_back(files[i].toStdString());
   }
-  LoadImages(vector, IMAGEWITHTIME);
+  LoadImages(vector, vvImageReader::IMAGEWITHTIME);
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvMainWindow::LoadImages(std::vector<std::string> files, LoadedImageType filetype)
+void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::LoadedImageType filetype)
 {
   //Separate the way to open images and dicoms
   int fileSize;
-  if (filetype == IMAGE || filetype == IMAGEWITHTIME)
+  if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME)
     fileSize = files.size();
   else
     fileSize = 1;
@@ -762,7 +761,7 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, LoadedImageType fi
   std::vector<unsigned int> nSlices;
   nSlices.resize(files.size());
   std::fill(nSlices.begin(), nSlices.end(), 1);
-  if (filetype == SLICED) {
+  if (filetype == vvImageReader::SLICED) {
     for (int i = 0; i < fileSize; i++) {
       itk::ImageIOBase::Pointer header = clitk::readImageHeader(files[i]);
       QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@@ -813,7 +812,7 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, LoadedImageType fi
       // Change filename if an image with the same already exist
       int number = GetImageDuplicateFilenameNumber(files[i] + std::string("_slice"));
 
-      if (filetype == IMAGE || filetype == IMAGEWITHTIME || filetype == SLICED)
+      if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME || filetype == vvImageReader::SLICED)
         SetImageSucceed = imageManager->SetImage(files[i],filetype, number, j);
       else {
         SetImageSucceed = imageManager->SetImages(files,filetype, number);
@@ -1461,12 +1460,12 @@ void vvMainWindow::DisplaySliders(int slicer, int window)
   bool showVertical = false;
   if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3
       || (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 2
-          && mSlicerManagers[slicer]->GetType() != IMAGEWITHTIME
-          && mSlicerManagers[slicer]->GetType() != MERGEDWITHTIME))
+          && mSlicerManagers[slicer]->GetType() != vvImageReader::IMAGEWITHTIME
+          && mSlicerManagers[slicer]->GetType() != vvImageReader::MERGEDWITHTIME))
     showVertical = true;
   if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3
-      || mSlicerManagers[slicer]->GetType() == IMAGEWITHTIME
-      || mSlicerManagers[slicer]->GetType() == MERGEDWITHTIME)
+      || mSlicerManagers[slicer]->GetType() == vvImageReader::IMAGEWITHTIME
+      || mSlicerManagers[slicer]->GetType() == vvImageReader::MERGEDWITHTIME)
     showHorizontal = true;
 
   if (showVertical)
index cc53aa6bf80d151e7c45d605590d415d1962dae6..b1052cfc1f7c711db6f9b06efc2e828a5d13d1ce 100644 (file)
@@ -24,7 +24,7 @@
 #include "ui_vvMainWindow.h"
 #include "vvMainWindowBase.h"
 #include "vvToolManager.h"
-#include "vvConstants.h"
+#include "vvImageReader.h"
 #include "vvMesh.h"
 #include "clitkMemoryUsage.h"
 
@@ -50,7 +50,7 @@ class vvMainWindow: public vvMainWindowBase,
   public:
   vvMainWindow();
   ~vvMainWindow();
-  void LoadImages(std::vector<std::string> filenames, LoadedImageType type);
+  void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
   vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
   void AddField(QString file,int index);
   void AddOverlayImage(int index, QString filename);
index 0278de0e6d0d8443f99d2261a7e72dcb62af0f6b..a44889fd92b3f6e98e8816197d5eb315e42499c3 100644 (file)
@@ -50,7 +50,7 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers)
   mFusionName = "";
   mVFId = "";
   mLastError = "";
-  mType = UNDEFINEDIMAGETYPE;
+  mType = vvImageReader::UNDEFINEDIMAGETYPE;
   mColorMap = 0;
   mPreset = 0;
   mOverlayColor = 130;
@@ -123,7 +123,7 @@ void vvSlicerManager::ToggleContourSuperposition()
 
 
 //----------------------------------------------------------------------------
-bool vvSlicerManager::SetImage(std::string filename, LoadedImageType type, int n, unsigned int slice)
+bool vvSlicerManager::SetImage(std::string filename, vvImageReader::LoadedImageType type, int n, unsigned int slice)
 {
   mType = type;
   if (mReader.IsNull())
@@ -169,15 +169,15 @@ void vvSlicerManager::SetImage(vvImage::Pointer image)
 
 
 //----------------------------------------------------------------------------
-bool vvSlicerManager::SetImages(std::vector<std::string> filenames,LoadedImageType type, int n)
+bool vvSlicerManager::SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n)
 {
   mType = type;
   std::string fileWithoutExtension = vtksys::SystemTools::GetFilenameWithoutExtension(filenames[0]);
-  if (type == DICOM)
+  if (type == vvImageReader::DICOM)
     fileWithoutExtension += "_dicom";
-  else if (type == MERGED)
+  else if (type == vvImageReader::MERGED)
     fileWithoutExtension += "_merged";
-  else if (type == MERGEDWITHTIME)
+  else if (type == vvImageReader::MERGEDWITHTIME)
     fileWithoutExtension += "_merged_wt";
 
   mFileName = vtksys::SystemTools::GetFilenameName(mFileName);
@@ -273,7 +273,7 @@ bool vvSlicerManager::SetVF(std::string filename)
   if (mVectorReader.IsNull())
     mVectorReader = vvImageReader::New();
   mVectorReader->SetInputFilename(filename);
-  mVectorReader->Update(VECTORFIELD);
+  mVectorReader->Update(vvImageReader::VECTORFIELD);
   if (mVectorReader->GetLastError().size() != 0) {
     mLastError = mVectorReader->GetLastError();
     return false;
@@ -751,7 +751,7 @@ void vvSlicerManager::ReloadOverlay()
 //----------------------------------------------------------------------------
 void vvSlicerManager::ReloadVF()
 {
-  mVectorReader->Update(VECTORFIELD); //deletes the old images through the VF::Init() function
+  mVectorReader->Update(vvImageReader::VECTORFIELD); //deletes the old images through the VF::Init() function
   mVF=mVectorReader->GetOutput();
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {
     mSlicers[i]->SetVF(mVF);
index eda2d227a2ead7e85b76b7f7be4a82e22ae430d5..f5a338b6b6027e0e22721e55ac9eb7ac7ee8c6dd 100644 (file)
@@ -36,7 +36,6 @@ class vtkRenderWindow;
 class vtkPolyData;
 
 // VV
-#include "vvConstants.h"
 #include "clitkCommon.h"
 #include "vvImage.h"
 #include "vvMesh.h"
@@ -60,9 +59,9 @@ class vvSlicerManager : public QObject {
     return mLastError;
   }
 
-  bool SetImage(std::string filename,LoadedImageType type, int n=0, unsigned int slice=0);
+  bool SetImage(std::string filename, vvImageReader::LoadedImageType type, int n=0, unsigned int slice=0);
   void SetImage(vvImage::Pointer image);
-  bool SetImages(std::vector<std::string> filenames, LoadedImageType type, int n=0);
+  bool SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n=0);
 
   bool SetOverlay(std::string filename, int dim, std::string component);
   bool SetFusion(std::string filename, int dim, std::string component);
@@ -234,7 +233,7 @@ protected:
   double mFusionLevel;
 
   int mPreset;
-  LoadedImageType mType;
+  vvImageReader::LoadedImageType mType;
   std::string mVFComponent;
   std::string mOverlayComponent;
   std::string mFusionComponent;
index fd09b11f2fc9c74b97af0167da47bd379acd5fa7..3c4b5c1c7eba2ee9799c98ef5b721ea3b6a839a6 100644 (file)
@@ -261,7 +261,7 @@ void vvToolStructureSetManager::OpenBinaryImage()
     std::vector<std::string> filenames;
     filenames.push_back(filename[i].toStdString());
     reader->SetInputFilenames(filenames);
-    reader->Update(IMAGE);
+    reader->Update(vvImageReader::IMAGE);
     QApplication::restoreOverrideCursor();
 
     if (reader->GetLastError().size() != 0) {
@@ -593,7 +593,7 @@ void vvToolStructureSetManager::ReloadCurrentROI() {
   // Reload image
   vvImageReader::Pointer reader = vvImageReader::New();
   reader->SetInputFilename(mCurrentROI->GetFilename());
-  reader->Update(IMAGE);
+  reader->Update(vvImageReader::IMAGE);
   if (reader->GetLastError() != "") {
     QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), reader->GetLastError().c_str());
     return;