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