]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxGimmickView.h
250f5a8e5a43604d5ebe8997f59bdd90d547898a
[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           /// Sets the message state
46           void SetMessage(wxString& mess);
47
48     protected:
49       /// Creates the tool bar
50       void CreateToolBar(); 
51
52       /// Create the tree view for TreeHandler provided 
53       /// (overloaded from GimmickView)
54       void CreateTreeView( TreeHandler* );
55
56
57     private:
58       /// The ToolBar and the tools
59       wxToolBar*         mToolBar;
60       wxToolBarToolBase* mToolAddFile;
61       wxToolBarToolBase* mToolAddDir;
62       wxToolBarToolBase* mToolRemove;
63       wxToolBarToolBase* mToolAddDatabase;
64       wxToolBarToolBase* mToolHelp;
65
66       wxSplitterWindow* mSplitter;
67       wxPanel*          mBottomPanel;
68           wxStaticText *    mText;
69       wxNotebook*       mNotebook;
70
71       /// The list of icons 
72       wxImageList *    mIcon;
73       void CreateIconList();
74
75       Gimmick * mGimmick;
76       /// Callback for adding files
77       void OnAddFiles(wxCommandEvent& event);
78       /// Callback for adding dir
79       void OnAddDir(wxCommandEvent& event);
80           /// Callback for removing files
81       void OnRemove(wxCommandEvent& event);
82           /// Display a message box with the last addition statistics
83       void DisplayAddSummary();
84
85
86       /// AddProgress Gimmick callback
87       void OnAddProgress( Gimmick::AddProgress& );
88      
89       /// Progress dialog
90       wxProgressDialog* mProgressDialog;
91           //The selection's maximum dimension
92           int mSelectionMaxDimension;
93           //The selection's minimum dimension
94           int mSelectionMinDimension;
95
96
97       wxString mCurrentDirectory;
98
99       DECLARE_EVENT_TABLE()
100    };
101     // EO class WxGimmickView
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 #endif // USE_WIDGETS
252 // EOF
253 #endif