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