From: Frederic Cervenansky Date: Wed, 24 Jun 2009 12:37:18 +0000 (+0000) Subject: Remove dependencies of WxWidget from Model and Controller class. X-Git-Tag: EED.02Oct2009~41 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2df647c186de559388c62bfebba8795b860ee8ae;p=creaImageIO.git Remove dependencies of WxWidget from Model and Controller class. Add directory_path as new Descriptor Attribute. First implementation of SaveAs --- diff --git a/src2/creaImageIODicomImageReader.cpp b/src2/creaImageIODicomImageReader.cpp index b95f27f..b51bff2 100644 --- a/src2/creaImageIODicomImageReader.cpp +++ b/src2/creaImageIODicomImageReader.cpp @@ -39,11 +39,17 @@ namespace creaImageIO // << "'" // <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 '" <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::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 { diff --git a/src2/creaImageIOGimmick.cpp b/src2/creaImageIOGimmick.cpp index 5aa2c10..1e7b74a 100644 --- a/src2/creaImageIOGimmick.cpp +++ b/src2/creaImageIOGimmick.cpp @@ -3,7 +3,7 @@ #include #include #include - +#include "io.h" #ifndef PATH_MAX // If not defined yet : do it # define PATH_MAX 2048 #endif diff --git a/src2/creaImageIOGimmickView.h b/src2/creaImageIOGimmickView.h index bc160c5..3287c4d 100644 --- a/src2/creaImageIOGimmickView.h +++ b/src2/creaImageIOGimmickView.h @@ -91,6 +91,11 @@ namespace creaImageIO virtual void CreateEditFieldsDialog(tree::Node* node, std::vector names, std::vector keys) { GimmickError("INTERNAL ERROR : EditFields not implemented"); } + ///Copies selected files + virtual void SaveAs(const std::vector& 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); diff --git a/src2/creaImageIOImagePointerHolder.h b/src2/creaImageIOImagePointerHolder.h index bdea46b..98251b6 100644 --- a/src2/creaImageIOImagePointerHolder.h +++ b/src2/creaImageIOImagePointerHolder.h @@ -1,14 +1,11 @@ #ifndef __creaImageIOImagePointerHolder_INCLUDED__ #define __creaImageIOImagePointerHolder_INCLUDED__ -#include -#ifdef USE_WXWIDGETS -// wx -#include -#include -#include -#include +#include #include +#include + + 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 + diff --git a/src2/creaImageIOListener.cpp b/src2/creaImageIOListener.cpp index 9a63c87..f2505e0 100644 --- a/src2/creaImageIOListener.cpp +++ b/src2/creaImageIOListener.cpp @@ -16,7 +16,8 @@ namespace creaImageIO // CTor Listener::Listener() { - wxMutexLocker lock(mMutex); + + boost::mutex::scoped_lock lock(mMutex); GimmickDebugMessage(6,"Listener::Listener" < #include #include -#include + // Signal/slot mechanism #include #include +#include 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 diff --git a/src2/creaImageIOSQLiteTreeHandler.cpp b/src2/creaImageIOSQLiteTreeHandler.cpp index 8471606..3d3fe70 100644 --- a/src2/creaImageIOSQLiteTreeHandler.cpp +++ b/src2/creaImageIOSQLiteTreeHandler.cpp @@ -13,11 +13,6 @@ #include -#include "wx/wx.h" -#include -#include - - //#include #include @@ -870,6 +865,7 @@ namespace creaImageIO sql +="'"; // sql += " LIMIT 1"; UPDATEDB(sql); + return true; } //===================================================================== diff --git a/src2/creaImageIOTimestampDatabaseHandler.cpp b/src2/creaImageIOTimestampDatabaseHandler.cpp index f156111..a0a522b 100644 --- a/src2/creaImageIOTimestampDatabaseHandler.cpp +++ b/src2/creaImageIOTimestampDatabaseHandler.cpp @@ -7,13 +7,6 @@ #include -#include "wx/wx.h" -#include -#include - -#include -using namespace crea; - #include #include diff --git a/src2/creaImageIOTreeHandlerImageAdder.cpp b/src2/creaImageIOTreeHandlerImageAdder.cpp index 258cc74..f0f5bf3 100644 --- a/src2/creaImageIOTreeHandlerImageAdder.cpp +++ b/src2/creaImageIOTreeHandlerImageAdder.cpp @@ -448,6 +448,15 @@ namespace creaImageIO } } + void TreeHandlerImageAdder::SaveAs(const std::vector& filenames, std::vector i_images) + { + std::vector::const_iterator it_file = filenames.begin(); + std::vector::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) { diff --git a/src2/creaImageIOTreeHandlerImageAdder.h b/src2/creaImageIOTreeHandlerImageAdder.h index 521f0ff..a9666ea 100644 --- a/src2/creaImageIOTreeHandlerImageAdder.h +++ b/src2/creaImageIOTreeHandlerImageAdder.h @@ -5,9 +5,8 @@ #include #include #include -#include -#include -#include +//#include + // Signal/slot mechanism for progress events #include #include @@ -125,6 +124,9 @@ namespace creaImageIO std::vector & newfiles); ///Copies the files indicated in the vector and updates all databases void CopyFiles(const std::vector& filenames, const std::string directory ); + + ///Saves as the files indicated in the vector in a specific directory + void SaveAs(const std::vector& filenames, std::vector 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; diff --git a/src2/creaImageIOVtkImageReader.cpp b/src2/creaImageIOVtkImageReader.cpp index 66f7059..69dd65f 100644 --- a/src2/creaImageIOVtkImageReader.cpp +++ b/src2/creaImageIOVtkImageReader.cpp @@ -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:"<