creaImageIOGimmickView.h

Go to the documentation of this file.
00001 #ifndef __creaImageIOGimmickView_h_INCLUDED__
00002 #define __creaImageIOGimmickView_h_INCLUDED__
00003 
00004 #include <creaImageIOGimmick.h>
00005 #include <creaImageIOTreeView.h>
00006 #include <creaImageIOSystem.h>
00007 #include <creaImageIOImagePointerHolder.h>
00008 
00009 //#include <map>
00010 #include <vtkImageData.h>
00011 #include <creaImageIOMultiThreadImageReader.h>
00012 
00013 // Signal/slot mechanism for progress events
00014 #include <boost/signal.hpp>
00015 #include <boost/bind.hpp>
00016 
00017 #define GIMMICK_NO_IMAGE_SELECTION 0
00018 #define GIMMICK_2D_IMAGE_SELECTION 2
00019 #define GIMMICK_3D_IMAGE_SELECTION 3
00020 #define GIMMICK_4D_IMAGE_SELECTION 4
00021 
00022 #define NATIVE 0
00023 #define _2D 2
00024 #define _3D 3
00025 
00026 
00027 namespace creaImageIO
00028 {
00033         class ImageExtent;
00034     //=====================================================================
00035     
00036     //=====================================================================
00038         class GimmickView: public MultiThreadImageReaderUser
00039     {
00040     public:
00042       GimmickView(Gimmick*, int number_of_threads = 0 );
00044       virtual ~GimmickView();
00048       virtual void Initialize();
00049 
00052       typedef std::map<std::string, TreeView*> TreeViewMapType;
00053       
00055       TreeViewMapType& GetTreeViewMap() { return mTreeViewMap; }
00057       const TreeViewMapType& GetTreeViewMap() const
00058       { return mTreeViewMap; }
00059 
00061       virtual void Finalize();
00062 
00063           //Returns the maximal priority
00064           int GetMaximalPriority(){return mReader.GetMaximalPriority();}
00065 
00067       virtual void GetSelectedImages(std::vector<vtkImageData*>& s, int dim) 
00068           { GimmickError("INTERNAL ERROR : GetSelectedImages not implemented"); }
00069 
00070       virtual void GetSelectedFiles(std::vector<std::string>& s)
00071       { GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); }
00072 
00073           virtual void GetImages(int dim, std::vector<std::string> files, std::vector<vtkImageData*>& s) 
00074           { GimmickError("INTERNAL ERROR : GetImages not implemented"); }
00075 
00076       virtual void OnSelectionChange(const std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess)
00077       { GimmickError("INTERNAL ERROR : OnSelectionChange not implemented"); }
00078 
00079            virtual void ClearSelection()
00080       { GimmickError("INTERNAL ERROR : ClearSelection not implemented"); }
00081 
00083           virtual void AddIgnoreFile(tree::Node* toRemove)
00084           { GimmickError("INTERNAL ERROR : AddIgnoreFile not implemented"); }
00085       
00087           virtual void CopyFiles(const std::vector<std::string>& filenames)
00088           { GimmickError("INTERNAL ERROR : CopyFiles not implemented"); }
00089 
00091           virtual void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys)
00092           { GimmickError("INTERNAL ERROR : EditFields not implemented"); }
00093       
00095       bool ValidateSelected (tree::Node* sel, int min_dim, int max_dim);
00096       
00098           void ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<std::string> files, int dim);
00101       void RequestReading(tree::Node* n, int prio, int selection_index , ImagePointerHolder *p);
00102      
00103       
00105       std::string GetMessage(){return mMess;}
00107       void SetMessage(std::string mess){mMess=mess;}
00109           void ResetExtent();
00110 
00112       void CreateTreeViews();
00113 
00115           void CreateSingleTreeView(std::string &i_name);
00116 
00118       virtual void CreateTreeView( TreeHandler* ) 
00119       { GimmickError("INTERNAL ERROR : CreateTreeView not implemented"); }
00120 
00123       virtual void UpdateTreeViewLevel(const std::string&, int l);
00124           // Multi-thread image reader callback
00125           void OnMultiThreadImageReaderEvent(const std::string& filename,
00126                                        MultiThreadImageReaderUser::EventType t,
00127                                        vtkImageData* image);
00128 
00129       vtkImageData* GetDefaultImage() { return mReader.GetImage(""); }
00130 
00131 
00132       //=============================================
00133       typedef boost::signal<void (bool)>  ValidationSignalType;
00134       typedef ValidationSignalType::slot_function_type ValidationCallbackType;
00135       //=============================================
00136 
00137      //==================================================================
00145       void ConnectValidationObserver(ValidationCallbackType callback);
00146      //==================================================================
00147 
00148           
00149 
00150         void modifyValidationSignal(bool ivalid);
00151 
00152     private:
00153         
00155       Gimmick* mGimmick;
00157       TreeViewMapType mTreeViewMap;
00159       std::string mMess;
00160 
00162       MultiThreadImageReader mReader;
00166       struct ImageEventType
00167       {
00168         ImageEventType( tree::Node* no = 0,   
00169                         int sel_index = -1,
00170                         ImagePointerHolder* ph= 0)
00171           : node(no), index(sel_index),  pointerHolder(ph){}
00172         ImageEventType(vtkImageData* im )
00173           : image(im) {}
00174         tree::Node* node;
00175         vtkImageData* image;
00176                 int index;
00177                 ImagePointerHolder* pointerHolder;
00178       };
00179       typedef std::map<std::string,ImageEventType> ImageEventTypeMap;
00182       ImageEventTypeMap mImageEventMap;
00183       // queue of image event 
00184       typedef std::deque<ImageEventType> ImageEventQueueType;
00185       //ImageEventQueueType mImageEventQueue;
00186 
00188           ImageExtent* mImageExtent;
00190           ValidationSignalType mValidationSignal;
00192           bool valid;
00194           bool mReaderStarted;
00195       
00196         };
00197   // EO class GimmickView
00198     //=====================================================================
00199   
00200 
00201   /*
00202 
00203 
00204 
00205 
00206 
00207 
00208 
00209 
00210         //====================================================================
00211         // General
00212         //====================================================================
00213 
00215     virtual int GetSelectionSize() { return 0; } 
00217     virtual bool IsSelectionValid(){ return false; }
00219     virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
00221     virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
00223     virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
00225     virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
00226 
00227         
00229     typedef std::vector<DicomDatabase*> DicomDatabaseListType;
00231     virtual DicomDatabaseListType& GetDicomDatabaseList() 
00232     { return null; }
00234     virtual const DicomDatabaseListType& GetDicomDatabaseList() const 
00235     { return null; }
00236 
00237         protected:
00239     virtual void OpenOrNewDatabase(bool open){ return; }
00241         virtual void ShowHelp();
00242 
00243         private:
00245         const std::string& GetDatabaseExtension() { return null; }
00247     virtual void SetDatabaseExtension(const std::string& ext){ return; }
00248 
00249 
00250         //====================================================================
00251     // Preview Display Related
00252         //====================================================================
00253 
00254 
00256         private:
00257          virtual void ShowImage(vtkImageData* image){ return; }
00258 
00259         //====================================================================
00260     // Favorites Related
00261         //====================================================================
00262 
00263 
00264         public:
00266     virtual void LoadOrCreateFavoritesDatabase(){ return; }
00267         private:
00269     void CreateUserSettingsDirectory(){ return; }
00271         const std::string& GetUserSettingsDirectory(){ return null; }
00272 
00273         //====================================================================  
00274         // Attribute Display Related
00275         //====================================================================
00276 
00277 
00279         private:
00280      virtual void ShowInformation(DicomNode*){ return; }
00281    
00282         //====================================================================
00283     // Tree Display Related
00284     //====================================================================
00285 
00286         protected:
00289     virtual void RebuildView(){ return; }
00294     virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
00298         virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
00299     
00300         private:
00302     typedef WxGimmickTreeItemData TreeItemData;
00304     TreeItemData* GetItemData(const TreeItemId& id){ return null; }
00306     typedef WxGimmickDicomNodeData NodeData;
00307 
00308 
00309         //====================================================================
00310     // Class Attributes
00311     //====================================================================
00312 
00313         
00314         int mSelectionType;
00315     int mSelectionMaxImageDimension;
00316     int mCurrentSelectionImageSize[4];
00317 
00319     DicomDatabaseListType mDicomDatabaseList;
00321     DicomDatabase* mFavoriteDatabase;
00322 
00324     std::string mDatabaseListFile;
00326     std::string mDatabaseExtension;
00327 
00328     bool mJustStarted;
00329 
00330     int  mFirstDicomDatabaseIconIndex;
00331 
00332    // Previewer
00333     vtkImageViewer2* mViewer;
00334     
00335     int mx1,mx2,my1,my2,mz1,mz2;
00336     double mspx,mspy,mspz;
00337   
00338     // Image preview :
00339     // Multi-thread image reader
00340     MultiThreadImageReader mReader;
00341     // map of images name to node
00342     std::map<std::string,DicomNode*> mImageFileNameToNode;
00343   */
00344  
00345 } // EO namespace creaImageIO
00346 
00347 // EOF
00348 #endif

Generated on Mon Jun 22 10:49:30 2009 for CreaImageIO by  doxygen 1.5.3