]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxGimmickView.h
Changed validation methods from TreeView to GimmickView (Abstract)
[creaImageIO.git] / src2 / creaImageIOWxGimmickView.h
1 #ifndef __creaImageIOWxGimmickView_h_INCLUDED__
2 #define __creaImageIOWxGimmickView_h_INCLUDED__
3
4 #ifdef USE_WXWIDGETS
5
6 #include <creaImageIOGimmickView.h>
7 #include <creaWx.h>
8
9 #include <wx/splitter.h>
10 #include <wx/toolbar.h> 
11 #include <wx/tbarbase.h> 
12 #include <wx/notebook.h>
13
14 namespace creaImageIO
15 {
16   /**
17    * \ingroup View
18    */
19   //=====================================================================
20   
21   //=====================================================================
22   /// Concrete derivative of GimmickView which implements a wxWidgets-based view
23   class WxGimmickView : public wxPanel, virtual public GimmickView
24     {
25     public:
26       typedef int EventType;
27
28       /// Ctor
29       WxGimmickView(Gimmick*, 
30                     wxWindow *parent, 
31                     const wxWindowID id,
32                     const wxPoint& pos, const wxSize& size,
33                     int min_dim = GIMMICK_2D_IMAGE_SELECTION,
34                         int max_dim = GIMMICK_3D_IMAGE_SELECTION,
35                     int number_of_threads = 0);
36       /// Virtual destructor
37       virtual ~WxGimmickView();
38
39           /// Returns the selected Images so that they comply with the given parameter(<4D)
40           ///(overloaded from GimmickView)
41           vtkImageData* GetSelectedImage(int dim);
42           /// Returns the selected files
43           ///(overloaded from GimmickView)
44           void GetSelectedFiles(std::vector<std::string>& s);
45       /// Returns the selected Images so that they comply with the given parameter(4D)
46       //(overloaded from GimmickView)
47           void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
48           /// Validates the selected images
49           bool ValidateSelection(void *);
50
51     protected:
52       /// Creates the tool bar
53       void CreateToolBar(); 
54
55       /// Create the tree view for TreeHandler provided 
56       /// (overloaded from GimmickView)
57       void CreateTreeView( TreeHandler* );
58
59
60     private:
61       /// The ToolBar and the tools
62       wxToolBar*         mToolBar;
63       wxToolBarToolBase* mToolAddFile;
64       wxToolBarToolBase* mToolAddDir;
65       wxToolBarToolBase* mToolRemove;
66       wxToolBarToolBase* mToolAddDatabase;
67       wxToolBarToolBase* mToolHelp;
68
69       wxSplitterWindow* mSplitter;
70       wxPanel*          mBottomPanel;
71           wxStaticText *    mText;
72       wxNotebook*       mNotebook;
73
74       /// The list of icons 
75       wxImageList *    mIcon;
76       void CreateIconList();
77
78       Gimmick * mGimmick;
79       /// Callback for adding files
80       void OnAddFiles(wxCommandEvent& event);
81       /// Callback for adding dir
82       void OnAddDir(wxCommandEvent& event);
83           /// Callback for removing files
84       void OnRemove(wxCommandEvent& event);
85         
86           /// Display a message box with the last addition statistics
87       void DisplayAddSummary();
88
89
90       /// AddProgress Gimmick callback
91       void OnAddProgress( Gimmick::AddProgress& );
92      
93       /// Progress dialog
94       wxProgressDialog* mProgressDialog;
95           ///The selection's maximum dimension
96           int mSelectionMaxDimension;
97           ///The selection's minimum dimension
98           int mSelectionMinDimension;
99
100
101       wxString mCurrentDirectory;
102
103       DECLARE_EVENT_TABLE()
104    };
105     // EO class WxGimmickView
106     //=====================================================================
107   
108
109   /*
110
111
112
113
114
115
116
117
118         //====================================================================
119         // General
120         //====================================================================
121
122     /// Returns the size of the current selection
123     virtual int GetSelectionSize() { return 0; } 
124     /// Returns true if there is a valid selection
125     virtual bool IsSelectionValid(){ return false; }
126     /// Returns the vector of full filenames of selected images
127     virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
128     /// Returns the vector of images corresponding to selection
129     virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
130     /// Returns the vector of DicomNode corresponding to selection
131     virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
132    /// Returns the DicomNode corresponding to the tree item
133     virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
134
135         
136         /// Type of list of DicomDatabase
137     typedef std::vector<DicomDatabase*> DicomDatabaseListType;
138     /// Returns the list of DicomDatabase open
139     virtual DicomDatabaseListType& GetDicomDatabaseList() 
140     { return null; }
141     /// Returns the list of DicomDatabase open (const)
142     virtual const DicomDatabaseListType& GetDicomDatabaseList() const 
143     { return null; }
144
145         protected:
146         ///Opens an existing database, or else, creates a local database.
147     virtual void OpenOrNewDatabase(bool open){ return; }
148         ///Shows the help
149         virtual void ShowHelp();
150
151         private:
152         ///Gets the extension of the database
153         const std::string& GetDatabaseExtension() { return null; }
154         ///Sets the extension of the database
155     virtual void SetDatabaseExtension(const std::string& ext){ return; }
156
157
158         //====================================================================
159     // Preview Display Related
160         //====================================================================
161
162
163     ///Shows the image sent as a parameter
164         private:
165          virtual void ShowImage(vtkImageData* image){ return; }
166
167         //====================================================================
168     // Favorites Related
169         //====================================================================
170
171
172         public:
173         ///Loads or creates a favorites database
174     virtual void LoadOrCreateFavoritesDatabase(){ return; }
175         private:
176         ///Creates the user settings directory
177     void CreateUserSettingsDirectory(){ return; }
178         ///Obtains the user settings directory
179         const std::string& GetUserSettingsDirectory(){ return null; }
180
181         //====================================================================  
182         // Attribute Display Related
183         //====================================================================
184
185
186         ///Shows the Information regarding the node sent as a parameter
187         private:
188      virtual void ShowInformation(DicomNode*){ return; }
189    
190         //====================================================================
191     // Tree Display Related
192     //====================================================================
193
194         protected:
195     /// Completely rebuilds the view with 
196     /// current DicomDatabaseList
197     virtual void RebuildView(){ return; }
198         /// Recursively updates the part of the view corresponding 
199     /// to the DicomDatabase passed
200     /// i.e. creates items for the DicomNode which do not have
201     ///      deletes obsolete items (whose DicomNode has been deleted)
202     virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
203     /// Recursively updates the part of the view corresponding 
204     /// to the DicomNode provided.
205     /// parent is its parent in the tree (where to insert / remove it)
206         virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
207     
208         private:
209         ///Type definition of the data regarding the tree
210     typedef WxGimmickTreeItemData TreeItemData;
211         ///Gets the item data of the tree item passed as a parameter
212     TreeItemData* GetItemData(const TreeItemId& id){ return null; }
213     ///Type definition of the data insid a node of the tree
214     typedef WxGimmickDicomNodeData NodeData;
215
216
217         //====================================================================
218     // Class Attributes
219     //====================================================================
220
221         
222         int mSelectionType;
223     int mSelectionMaxImageDimension;
224     int mCurrentSelectionImageSize[4];
225
226         ///Existent Database List
227     DicomDatabaseListType mDicomDatabaseList;
228         ///Favorites database
229     DicomDatabase* mFavoriteDatabase;
230
231         ///Path to the database list file
232     std::string mDatabaseListFile;
233         ///Extension of the database
234     std::string mDatabaseExtension;
235
236     bool mJustStarted;
237
238     int  mFirstDicomDatabaseIconIndex;
239
240    // Previewer
241     vtkImageViewer2* mViewer;
242     
243     int mx1,mx2,my1,my2,mz1,mz2;
244     double mspx,mspy,mspz;
245   
246     // Image preview :
247     // Multi-thread image reader
248     MultiThreadImageReader mReader;
249     // map of images name to node
250     std::map<std::string,DicomNode*> mImageFileNameToNode;
251   */
252  
253 } // EO namespace creaImageIO
254
255 #endif // USE_WIDGETS
256 // EOF
257 #endif