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