]> Creatis software - creaImageIO.git/blob - src2/creaImageIOGimmickView.h
Added creaImageIOGimmickView.h
[creaImageIO.git] / src2 / creaImageIOGimmickView.h
1 namespace creaImageIO
2 {
3     /**
4         * \ingroup View
5         */
6
7         //=====================================================================  
8     
9     //=====================================================================
10     /// Abstract class to handle tree item information
11     struct TreeListCtrl
12     { 
13       TreeListCtrl() {}
14       virtual ~TreeListCtrl() {}
15     };
16         // EO class TreeListCtrl
17
18         /**
19         * \ingroup View
20         */
21         //=====================================================================  
22     
23     //=====================================================================
24     /// Abstract class to handle tree item ids
25     struct TreeItemId
26     { 
27       TreeItemId() {}
28       virtual ~TreeItemId() {}
29     };
30         // EO class TreeItemId
31
32         /**
33         * \ingroup View
34         */
35     //=====================================================================
36     
37     //=====================================================================
38     ///Abstract class that handles views, attributes and previews (GUI) for Gimmick.
39         class GimmickView
40     {
41     public:
42       /// Ctor
43       GimmickView();
44       /// Virtual destructor
45       virtual ~GimmickView();
46
47         //====================================================================
48         // General
49         //====================================================================
50
51     /// Returns the size of the current selection
52     virtual int GetSelectionSize() { return 0; } 
53     /// Returns true if there is a valid selection
54     virtual bool IsSelectionValid(){ return false; }
55     /// Returns the vector of full filenames of selected images
56     virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
57     /// Returns the vector of images corresponding to selection
58     virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
59     /// Returns the vector of DicomNode corresponding to selection
60     virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
61     /// Returns the vector of TreeItemId corresponding to selection
62     virtual void GetSelectedItems(std::vector<TreeItemId>&){ return; }
63         /// Returns the DicomNode corresponding to the tree item
64     virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
65
66         
67         /// Type of list of DicomDatabase
68     typedef std::vector<DicomDatabase*> DicomDatabaseListType;
69     /// Returns the list of DicomDatabase open
70     virtual DicomDatabaseListType& GetDicomDatabaseList() 
71     { return null; }
72     /// Returns the list of DicomDatabase open (const)
73     virtual const DicomDatabaseListType& GetDicomDatabaseList() const 
74     { return null; }
75
76         /// Returns the TreeListCtrl of the main view
77     TreeListCtrl* GetTreeListCtrl() { return null; }
78     /// Returns the TreeListCtrl of the main view (const)
79     const TreeListCtrl* GetTreeListCtrl() const { return null; }
80
81         protected:
82         ///Inserts a TreeItem in a specified database
83         virtual void InsertDicomDatabase(TreeItemId& id, DicomDatabase* r);
84         ///Deletes a TreeItem from a specified database
85     virtual void DeleteDicomDatabase(TreeItemId& id, DicomDatabase* r);
86         ///Loads the children of the specified TreeItem
87         virtual void LoadChildren( TreeItemId& id );
88         ///Opens an existing database, or else, creates a local database.
89     virtual void OpenOrNewDatabase(bool open){ return; }
90         ///Shows the help
91         virtual void ShowHelp();
92
93         private:
94         ///Gets the extension of the database
95         const std::string& GetDatabaseExtension() { return null; }
96         ///Sets the extension of the database
97     virtual void SetDatabaseExtension(const std::string& ext){ return; }
98
99
100         //====================================================================
101     // Preview Display Related
102         //====================================================================
103
104
105     ///Shows the image sent as a parameter
106         private:
107          virtual void ShowImage(vtkImageData* image){ return; }
108
109         //====================================================================
110     // Favorites Related
111         //====================================================================
112
113
114         public:
115         /// Sets a new configuration file
116     virtual void SetConfigurationFile(const std::string& filename){ return; }
117         ///Loads a configuration file with the parameters for the favorites database
118     virtual void LoadConfiguration(){ return; }
119         ///Saves a configuration file with the parameters for the favorites database
120     virtual void SaveConfiguration(){ return; }
121         ///Sets the status for the save configuration on close to the new value 
122         ///specified by the parameter
123     virtual void SetSaveConfigurationOnClose(bool v) { return; }
124         ///Loads or creates a favorites database
125     virtual void LoadOrCreateFavoritesDatabase(){ return; }
126         private:
127         ///Creates the user settings directory
128     void CreateUserSettingsDirectory(){ return; }
129         ///Obtains the user settings directory
130         const std::string& GetUserSettingsDirectory(){ return null; }
131
132         //====================================================================  
133         // Attribute Display Related
134         //====================================================================
135
136
137         ///Shows the Information regarding the node sent as a parameter
138         private:
139      virtual void ShowInformation(DicomNode*){ return; }
140    
141         //====================================================================
142     // Tree Display Related
143     //====================================================================
144
145         protected:
146     /// Completely rebuilds the view with 
147     /// current DicomDatabaseList
148     virtual void RebuildView(){ return; }
149         /// Recursively updates the part of the view corresponding 
150     /// to the DicomDatabase passed
151     /// i.e. creates items for the DicomNode which do not have
152     ///      deletes obsolete items (whose DicomNode has been deleted)
153     virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
154     /// Recursively updates the part of the view corresponding 
155     /// to the DicomNode provided.
156     /// parent is its parent in the tree (where to insert / remove it)
157         virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
158     /// Recursively deletes 
159     virtual void DeleteObsoleteChildren(TreeItemId& id){ return; }
160     /// Create the column titles of the children of the item
161     virtual TreeItemId CreateChildrenColumnsTitles(TreeItemId& item,
162                                              DicomNode::Type t){ return null }
163     /// Updates the titles of the columns
164     virtual void UpdateColumnsTitles(TreeItemId& item, DicomNode::Type t){ return; }
165     /// Updates the information on the columns
166     virtual void UpdateColumns(TreeItemId& item, bool only_first = false){ return; }
167
168         private:
169         ///Type definition of the data regarding the tree
170     typedef WxGimmickTreeItemData TreeItemData;
171         ///Gets the item data of the tree item passed as a parameter
172     TreeItemData* GetItemData(const TreeItemId& id){ return null; }
173     ///Type definition of the data insid a node of the tree
174     typedef WxGimmickDicomNodeData NodeData;
175
176
177         //====================================================================
178     // Class Attributes
179     //====================================================================
180
181         
182         int mSelectionType;
183     int mSelectionMaxImageDimension;
184     int mCurrentSelectionImageSize[4];
185
186         ///Existent Database List
187     DicomDatabaseListType mDicomDatabaseList;
188         ///Favorites database
189     DicomDatabase* mFavoriteDatabase;
190         ///The tree list controller
191     TreeListCtrl* mTreeListCtrl;
192         ///Path to the user settings directory
193     std::string mUserSettingsDirectory;
194     ///Path to the configuration file    
195     std::string mConfigurationFile;
196         ///Path to the database list file
197     std::string mDatabaseListFile;
198         ///Boolean to check wether to save on close or not
199     bool mSaveConfigurationOnClose;
200         ///Extension of the database
201     std::string mDatabaseExtension;
202
203     bool mJustStarted;
204
205     int  mFirstDicomDatabaseIconIndex;
206     // Id of the item which activated the popup menu 
207     TreeItemId mItemOfMenu;
208
209    // Previewer
210     vtkImageViewer2* mViewer;
211     
212     int mx1,mx2,my1,my2,mz1,mz2;
213     double mspx,mspy,mspz;
214   
215     // Image preview :
216     // Multi-thread image reader
217     MultiThreadImageReader mReader;
218     // map of images name to node
219     std::map<std::string,DicomNode*> mImageFileNameToNode;
220     // Cur image item to show
221     TreeItemId mCurImageItemToShow;
222
223     };
224     // EO class GimmickView
225     //=====================================================================
226   
227 } // EO namespace creaImageIO
228
229 // EOF
230 #endif