]> Creatis software - creaImageIO.git/blob - src2/creaImageIOGimmickView.h
8407a9179cb22008dbcdd940e934862777b0f10d
[creaImageIO.git] / src2 / creaImageIOGimmickView.h
1 #ifndef __creaImageIOGimmickView_h_INCLUDED__
2 #define __creaImageIOGimmickView_h_INCLUDED__
3
4 #include <creaImageIOGimmick.h>
5 #include <creaImageIOTreeView.h>
6 #include <creaImageIOSystem.h>
7
8 //#include <map>
9 #include <vtkImageData.h>
10
11 #define GIMMICK_NO_IMAGE_SELECTION 0
12 #define GIMMICK_2D_IMAGE_SELECTION 2
13 #define GIMMICK_3D_IMAGE_SELECTION 3
14 #define GIMMICK_4D_IMAGE_SELECTION 4
15
16
17 namespace creaImageIO
18 {
19         /**
20         * \ingroup View
21         */
22     //=====================================================================
23     
24     //=====================================================================
25     ///Abstract class that handles views, attributes and previews (GUI) for Gimmick.
26         class GimmickView
27     {
28     public:
29       /// Ctor
30       GimmickView(Gimmick* );
31       /// Virtual destructor
32       virtual ~GimmickView();
33
34
35       /// Initializes the view : 
36       /// Creates the TreeViews for all the TreeHandler of the Controller
37       /// 
38       virtual void Initialize();
39
40       /// Type of map from View name to TreeView* 
41       /// (This map is equivalent for Views of the TreeHandlerMap of Gimmick)
42       typedef std::map<std::string, TreeView*> TreeViewMapType;
43       
44       /// Returns the TreeViewMap (ref)
45       TreeViewMapType& GetTreeViewMap() { return mTreeViewMap; }
46       /// Returns the TreeViewMap (const ref)
47       const TreeViewMapType& GetTreeViewMap() const
48       { return mTreeViewMap; }
49
50       /// Finalize 
51       virtual void Finalize();
52           ///Returns the selected Images and validates to see if they comply with the given parameter(<4D)
53           vtkImageData* GetSelectedImage(int dim);
54       ///Adds the selected Images to the given vector and validates to see if they comply with the given parameter (4D)
55       virtual void GetSelectedImages(std::vector<vtkImageData*>& s, int dim) {}
56
57       virtual void GetSelectedFiles(std::vector<std::string>& s) {}
58
59       /// Create the tree views 
60       void CreateTreeViews();
61
62       /// Create the tree view for TreeHandler provided
63       virtual void CreateTreeView( TreeHandler*) 
64       { GimmickError("INTERNAL ERROR : CreateTreeView not implemented"); }
65
66       /// Updates the TreeView of given name from level l to bottom
67       /// (calls the virtual method TreeView::UpdateLevel(l))
68       virtual void UpdateTreeViewLevel(const std::string&, int l);
69
70     private:
71       /// Controller which manages the interaction with the model
72       Gimmick* mGimmick;
73       /// The views 
74       TreeViewMapType mTreeViewMap;
75       
76     };
77     // EO class GimmickView
78     //=====================================================================
79   
80
81   /*
82
83
84
85
86
87
88
89
90         //====================================================================
91         // General
92         //====================================================================
93
94     /// Returns the size of the current selection
95     virtual int GetSelectionSize() { return 0; } 
96     /// Returns true if there is a valid selection
97     virtual bool IsSelectionValid(){ return false; }
98     /// Returns the vector of full filenames of selected images
99     virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
100     /// Returns the vector of images corresponding to selection
101     virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
102     /// Returns the vector of DicomNode corresponding to selection
103     virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
104    /// Returns the DicomNode corresponding to the tree item
105     virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
106
107         
108         /// Type of list of DicomDatabase
109     typedef std::vector<DicomDatabase*> DicomDatabaseListType;
110     /// Returns the list of DicomDatabase open
111     virtual DicomDatabaseListType& GetDicomDatabaseList() 
112     { return null; }
113     /// Returns the list of DicomDatabase open (const)
114     virtual const DicomDatabaseListType& GetDicomDatabaseList() const 
115     { return null; }
116
117         protected:
118         ///Opens an existing database, or else, creates a local database.
119     virtual void OpenOrNewDatabase(bool open){ return; }
120         ///Shows the help
121         virtual void ShowHelp();
122
123         private:
124         ///Gets the extension of the database
125         const std::string& GetDatabaseExtension() { return null; }
126         ///Sets the extension of the database
127     virtual void SetDatabaseExtension(const std::string& ext){ return; }
128
129
130         //====================================================================
131     // Preview Display Related
132         //====================================================================
133
134
135     ///Shows the image sent as a parameter
136         private:
137          virtual void ShowImage(vtkImageData* image){ return; }
138
139         //====================================================================
140     // Favorites Related
141         //====================================================================
142
143
144         public:
145         ///Loads or creates a favorites database
146     virtual void LoadOrCreateFavoritesDatabase(){ return; }
147         private:
148         ///Creates the user settings directory
149     void CreateUserSettingsDirectory(){ return; }
150         ///Obtains the user settings directory
151         const std::string& GetUserSettingsDirectory(){ return null; }
152
153         //====================================================================  
154         // Attribute Display Related
155         //====================================================================
156
157
158         ///Shows the Information regarding the node sent as a parameter
159         private:
160      virtual void ShowInformation(DicomNode*){ return; }
161    
162         //====================================================================
163     // Tree Display Related
164     //====================================================================
165
166         protected:
167     /// Completely rebuilds the view with 
168     /// current DicomDatabaseList
169     virtual void RebuildView(){ return; }
170         /// Recursively updates the part of the view corresponding 
171     /// to the DicomDatabase passed
172     /// i.e. creates items for the DicomNode which do not have
173     ///      deletes obsolete items (whose DicomNode has been deleted)
174     virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
175     /// Recursively updates the part of the view corresponding 
176     /// to the DicomNode provided.
177     /// parent is its parent in the tree (where to insert / remove it)
178         virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
179     
180         private:
181         ///Type definition of the data regarding the tree
182     typedef WxGimmickTreeItemData TreeItemData;
183         ///Gets the item data of the tree item passed as a parameter
184     TreeItemData* GetItemData(const TreeItemId& id){ return null; }
185     ///Type definition of the data insid a node of the tree
186     typedef WxGimmickDicomNodeData NodeData;
187
188
189         //====================================================================
190     // Class Attributes
191     //====================================================================
192
193         
194         int mSelectionType;
195     int mSelectionMaxImageDimension;
196     int mCurrentSelectionImageSize[4];
197
198         ///Existent Database List
199     DicomDatabaseListType mDicomDatabaseList;
200         ///Favorites database
201     DicomDatabase* mFavoriteDatabase;
202
203         ///Path to the database list file
204     std::string mDatabaseListFile;
205         ///Extension of the database
206     std::string mDatabaseExtension;
207
208     bool mJustStarted;
209
210     int  mFirstDicomDatabaseIconIndex;
211
212    // Previewer
213     vtkImageViewer2* mViewer;
214     
215     int mx1,mx2,my1,my2,mz1,mz2;
216     double mspx,mspy,mspz;
217   
218     // Image preview :
219     // Multi-thread image reader
220     MultiThreadImageReader mReader;
221     // map of images name to node
222     std::map<std::string,DicomNode*> mImageFileNameToNode;
223   */
224  
225 } // EO namespace creaImageIO
226
227 // EOF
228 #endif