]> Creatis software - creaImageIO.git/commitdiff
Remove dependencies of WxWidget from Model and Controller class.
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Wed, 24 Jun 2009 12:37:18 +0000 (12:37 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Wed, 24 Jun 2009 12:37:18 +0000 (12:37 +0000)
Add directory_path as new Descriptor Attribute.
First implementation of SaveAs

12 files changed:
src2/creaImageIODicomImageReader.cpp
src2/creaImageIOGimmick.cpp
src2/creaImageIOGimmickView.h
src2/creaImageIOImagePointerHolder.h
src2/creaImageIOListener.cpp
src2/creaImageIOListener.h
src2/creaImageIOSQLiteTreeHandler.cpp
src2/creaImageIOTimestampDatabaseHandler.cpp
src2/creaImageIOTreeHandlerImageAdder.cpp
src2/creaImageIOTreeHandlerImageAdder.h
src2/creaImageIOVtkImageReader.cpp
src2/creaImageIOWxGimmickReaderDialog.h

index b95f27ffb72ef4597f8fd494738c60c709ccd302..b51bff21b46f555ce69512d72dee795158d9d9db 100644 (file)
@@ -39,11 +39,17 @@ namespace creaImageIO
     // << "'" 
     // <<std::endl;
     
+       GDCM_NAME_SPACE::Document*doc;
     GDCM_NAME_SPACE::File* file = GDCM_NAME_SPACE::File::New();
     file->SetLoadMode( GDCM_NAME_SPACE::LD_ALL);
     file->SetFileName(filename.c_str());
     file->Load();
     bool ok = file->IsReadable();
+       if(!ok)
+       {
+               doc = (GDCM_NAME_SPACE::Document*)file; 
+               ok = doc->IsReadable();
+       }
     file->Delete();
     return ok;
   }
@@ -108,11 +114,16 @@ namespace creaImageIO
     GimmickMessage(2,"Reading attributes from DICOM file '"
                   <<filename<<"'"<<std::endl);
     
-    GDCM_NAME_SPACE::File* file = GDCM_NAME_SPACE::File::New();
+       GDCM_NAME_SPACE::File* file = GDCM_NAME_SPACE::File::New();
+
+       GDCM_NAME_SPACE::Document *doc= GDCM_NAME_SPACE::File::New();
+       doc->SetLoadMode( GDCM_NAME_SPACE::LD_ALL);
+    doc->SetFileName(filename.c_str());
+    doc->Load();
     file->SetLoadMode( GDCM_NAME_SPACE::LD_ALL);
     file->SetFileName(filename.c_str());
     file->Load();
-    if (file->IsReadable())
+    if (file->IsReadable() ||((GDCM_NAME_SPACE::Document*) file)->IsReadable())
       {
        
        std::map<std::string,std::string>::iterator i;
@@ -127,6 +138,12 @@ namespace creaImageIO
            else if ( i->first == "FullFileName" )
              {
                i->second = filename;
+             }
+                 else if ( i->first == "FullFileDirectory" )
+             {
+                         std::string::size_type last_pos = filename.find_last_of("//");
+                         //find first separator
+                         i->second = filename.substr(0, last_pos);
              }
            else
              {
index 5aa2c105cb4b5985cdc797719bd622403cd3038b..1e7b74a171352092a7419b90a746b5232abc96e8 100644 (file)
@@ -3,7 +3,7 @@
 #include <creaImageIOSystem.h>
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
-
+#include "io.h"
 #ifndef PATH_MAX // If not defined yet : do it 
 #  define PATH_MAX 2048
 #endif
index bc160c5bf853962664755009974ec6b0466b227e..3287c4d3209e3fd676e9ba9b1c68164314fa9402 100644 (file)
@@ -91,6 +91,11 @@ namespace creaImageIO
          virtual void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys)
          { GimmickError("INTERNAL ERROR : EditFields not implemented"); }
       
+          ///Copies selected files
+         virtual void SaveAs(const std::vector<std::string>& filenames)
+         { GimmickError("INTERNAL ERROR : SaveAs not implemented"); }
+
+
       ///Validates the dimension compliance of the images with the maximum and minimum given, and between their sizes
       bool ValidateSelected (tree::Node* sel, int min_dim, int max_dim);
       
index bdea46b63789b4cbfb58654363ddbe88f5238639..98251b6021828f53f03840c4a0d1dbc4fbf6f4b7 100644 (file)
@@ -1,14 +1,11 @@
 #ifndef __creaImageIOImagePointerHolder_INCLUDED__
 #define __creaImageIOImagePointerHolder_INCLUDED__
-#include <creaImageIOSystem.h>
-#ifdef USE_WXWIDGETS
 
-// wx
-#include <creaWx.h>
-#include <wx/image.h>
-#include <wx/imaglist.h>
-#include <wx/splitter.h>
+#include <creaImageIOSystem.h>
 #include <vtkImageData.h>
+#include <boost/thread/mutex.hpp>
+
+
 namespace creaImageIO
 {
          // The class that holds the pointer to the images to show
@@ -19,14 +16,14 @@ namespace creaImageIO
                mImage(im)
                {}
                ImagePointerHolder();
-                       void Set(vtkImageData* im){wxMutexLocker lock(mMutex);mImage=im;}
-                       vtkImageData* Get(){wxMutexLocker lock(mMutex);return mImage;}
+               void Set(vtkImageData* im){boost::mutex::scoped_lock lock(mMutex);mImage=im;}
+               vtkImageData* Get(){boost::mutex::scoped_lock lock(mMutex);return mImage;}
                private:
                        vtkImageData* mImage;
                        /// The mutex
-                       wxMutex mMutex;
+                       boost::mutex mMutex;
                };
 }
 #endif
-#endif
+
 
index 9a63c87592dccf809a54fbb3ff92d7c622d1cb94..f2505e052e153b373f6b017daf80ed2dd4213404 100644 (file)
@@ -16,7 +16,8 @@ namespace creaImageIO
   // CTor
   Listener::Listener()
   {
-    wxMutexLocker lock(mMutex);
+
+       boost::mutex::scoped_lock lock(mMutex);
     GimmickDebugMessage(6,"Listener::Listener"
                        <<std::endl);
        mDrive="E:";
@@ -31,7 +32,7 @@ namespace creaImageIO
   /// Destructor
   Listener::~Listener()
   {
-    wxMutexLocker lock(mMutex);
+    boost::mutex::scoped_lock lock(mMutex);
     GimmickDebugMessage(6,"Listener::~Listener"
                        <<std::endl);
   }
index 32b4caa1adc51a6fdf5f1605aecf06b67b8050a4..0405351b85f40eb512dee64e2ec19abd7cef32f3 100644 (file)
@@ -4,10 +4,11 @@
 #include <creaImageIOSystem.h>
 #include <stdio.h>
 #include <time.h>
-#include <wx/thread.h>
+
 // Signal/slot mechanism
 #include <boost/signal.hpp>
 #include <boost/bind.hpp>
+#include <boost/thread/mutex.hpp>
 
 namespace creaImageIO
 {
@@ -24,11 +25,11 @@ namespace creaImageIO
        ///Thread method called upon exiting
     void  OnExit();
        ///Sets the new state of adding files
-       void SetAddFilesState(bool addFiles){wxMutexLocker lock(mMutex);mAddFiles=addFiles;}
+       void SetAddFilesState(bool addFiles){boost::mutex::scoped_lock lock(mMutex);mAddFiles=addFiles;}
        ///Sets the new state of removing files
-       void SetRemoveFilesState(bool removeFiles){wxMutexLocker lock(mMutex);mRemoveFiles=removeFiles;}
+       void SetRemoveFilesState(bool removeFiles){boost::mutex::scoped_lock lock(mMutex);mRemoveFiles=removeFiles;}
        ///Sets the new monitored drive
-       void SetMonitoredDrive(const std::string& dr){wxMutexLocker lock(mMutex);mDrive=dr;}
+       void SetMonitoredDrive(const std::string& dr){boost::mutex::scoped_lock lock(mMutex);mDrive=dr;}
        ///Puts the name of the monitored drive in the given string
        void GetMonitoredDrive(std::string& drive){drive=mDrive;}
 
@@ -48,7 +49,7 @@ namespace creaImageIO
 
   private:
     /// The mutex
-    wxMutex mMutex;
+    boost::mutex mMutex;
     /// Boolean that declares if the files that are read on CD mount should be added
     bool mAddFiles;
        /// Boolean that declares if, on CD unmount, the files that were in the drive should be removed
index 847160617de0cd275683427a047d9afcd8389a00..3d3fe70c1639ad2357a75f628ff63462020a2e9f 100644 (file)
 
 #include <deque>
 
-#include "wx/wx.h"
-#include <wx/dir.h>
-#include <wx/filename.h>
-
-
 //#include <icons/close.xpm>
 
 #include <creaWx.h>
@@ -870,6 +865,7 @@ namespace creaImageIO
        sql +="'";
     //    sql += " LIMIT 1";
     UPDATEDB(sql);
+       return true;
   }
 
   //===================================================================== 
index f1561110b38acab9f7606338d6bca2e78dd16fe6..a0a522b019eecc644a1c325b389928bf1cad3a63 100644 (file)
@@ -7,13 +7,6 @@
 
 #include <deque>
 
-#include "wx/wx.h"
-#include <wx/dir.h>
-#include <wx/filename.h>
-
-#include <creaWx.h>
-using namespace crea;
-
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string/replace.hpp>
 
index 258cc74f5b0e8d3e95c4304e7369e01bf0b2b000..f0f5bf39dbda6e8c3a3fa79645057df8fefe01bd 100644 (file)
@@ -448,6 +448,15 @@ namespace creaImageIO
          }
   }
   
+  void TreeHandlerImageAdder::SaveAs(const std::vector<std::string>& filenames, std::vector<vtkImageData *> i_images)
+  {
+         std::vector<std::string>::const_iterator it_file = filenames.begin();
+         std::vector<vtkImageData *>::iterator it_image = i_images.begin();
+       /*  mWriter.CanWrite(".jpeg");
+         for(; it_file != filenames.end(); ++it_file, ++it_image)
+                 mWriter.WriteImage(it_file->c_str(), (vtkImageData &)it_image);*/
+  }
+
   //=======================================================================
   void TreeHandlerImageAdder::FindNodePartial(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node)
   {
index 521f0ffc13bf31d4d7fe8a6c1b45b0d44f7aa89c..a9666eac07d6e93b94a78e8b61fc022cd76d0d53 100644 (file)
@@ -5,9 +5,8 @@
 #include <creaImageIOTimestampDatabaseHandler.h>
 #include <creaImageIOSynchron.h>
 #include <creaImageIOImageReader.h>
-#include <wx/wx.h>
-#include <wx/progdlg.h>
-#include <creaWx.h>
+//#include <creaImageIOImageWriter.h>
+
 // Signal/slot mechanism for progress events
 #include <boost/signal.hpp>
 #include <boost/bind.hpp>
@@ -125,6 +124,9 @@ namespace creaImageIO
                                                        std::vector<std::string> & newfiles);
        ///Copies the files indicated in the vector and updates all databases
        void CopyFiles(const std::vector<std::string>& filenames, const std::string directory  );
+       
+       ///Saves as the files indicated in the vector in a specific directory
+       void SaveAs(const std::vector<std::string>& filenames, std::vector<vtkImageData *> i_images);
        ///Finds the node that matches the specified parameters
        void FindNode(tree::Node* parent, int level, 
                const std::string& searchParam, 
@@ -168,6 +170,7 @@ namespace creaImageIO
        TimestampDatabaseHandler* mTimestampHandler;
        Synchronizer* mSynchronizer;
     ImageReader mReader;
+       //ImageWriter mWriter;
        std::string mCurrentDB;
     
     Progress mProgress;
index 66f7059314a3096edb1c53ea91e77bf6afeb27ce..69dd65f03a8b8be541a48a811f51714529d9052c 100644 (file)
@@ -154,7 +154,12 @@ namespace creaImageIO
       {
        i->second = planes;
       }
-    
+         if ( (i = attr.find("FullFileDirectory")) != attr.end())
+      {
+        std::string::size_type last_pos = filename.find_last_of("//");
+                i->second = filename.substr(0, last_pos);
+         }
+
     GimmickMessage(2,"Attributes map:"<<std::endl<<attr<<std::endl);
   }
   //=====================================================================
index 0ed3d4ae521295ca9d4d8c8d0523477e1b570bd9..c254ea4b4569bd5a07d989813c9ddab459b0b80f 100644 (file)
@@ -14,7 +14,7 @@ namespace creaImageIO
        
   //=====================================================================
  //=====================================================================
-  class CREAIMAGEIO_EXPORT WxGimmickReaderDialog : public wxDialog
+  class CREAIMAGEIO_EXPORT  WxGimmickReaderDialog : public wxDialog
   {
   public:
     WxGimmickReaderDialog();