]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxGimmickView.h
*** empty log message ***
[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 <creaImageIOWxViewer.h>
8 #include <creaImageIOWxGimmickTools.h>
9 #include <creaWx.h>
10 #include "wx/wx.h"
11 //#include "bruker2dicom.h"
12
13 #include <wx/splitter.h>
14 #include <wx/toolbar.h> 
15 #include <wx/tbarbase.h> 
16 #include <wx/notebook.h>
17
18 namespace creaImageIO
19 {
20   /**
21    * \ingroup View
22    */
23   //=====================================================================
24   
25   //=====================================================================
26   /// Concrete derivative of GimmickView which implements a wxWidgets-based view
27
28   class WxGimmickView : public wxPanel, virtual public GimmickView
29   {
30   public:
31     
32     typedef int EventType;
33     
34     /// Ctor
35     WxGimmickView(Gimmick*, 
36                   wxWindow *parent, 
37                   const wxWindowID id,
38                   const wxPoint& pos, const wxSize& size,
39                   int min_dim = GIMMICK_2D_IMAGE_SELECTION,
40                   int max_dim = GIMMICK_3D_IMAGE_SELECTION,
41                   int number_of_threads = 0);
42     /// Virtual destructor
43     virtual ~WxGimmickView();
44     
45     /// Returns the selected files
46     ///(overloaded from GimmickView)
47     void GetSelectedFiles(std::vector<std::string>& s);
48     
49     /// Returns the selected Images so that they comply with the 
50     /// given parameter(4D) (overloaded from GimmickView)
51     void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
52
53     /// Returns the images indicated by the filenames in the vector 
54     /// so that they comply with the given parameter(dim)
55     //(overloaded from GimmickView) 
56     void GetImages(int dim, const std::vector<std::string>& files, 
57                    std::vector<vtkImageData*>& s);
58     
59     /// Callback called when a selection from a TreeView has changed 
60     //(overloaded from GimmickView)
61     void OnSelectionChange(const std::vector<tree::Node*>& s, 
62                            bool isSelection, int selection, bool mProcess);
63     ///Stops the player
64     void StopPlayer(){mViewer->StopPlayer();}
65     ///Adds a file to ignore
66     void AddIgnoreFile(tree::Node* toRemove);
67     ///Resets the default image
68     void ClearSelection();
69         ///Copies selected files
70         void CopyFiles(const std::vector<std::string>& filenames);
71     
72     
73     ///Sends a request to read the currently selected node and the ones that surround it.
74     void ReadImageThreaded(const std::vector<tree::Node*>& sel);
75     
76     
77   protected:
78     /// Creates the tool bar
79     void CreateToolBar(); 
80     
81     /// Create the tree view for TreeHandler provided 
82     /// (overloaded from GimmickView)
83     void CreateTreeView( TreeHandler* );
84     
85     
86   private:
87     /// Is set to true at the end of constructor 
88     /// (in order to lock callbacks from threaded objects or event 
89     /// before everything is ok)
90     bool mConstructed;
91     /// The ToolBar and the tools
92     wxToolBar*         mToolBar;
93     wxToolBarToolBase* mToolAddFile;
94     wxToolBarToolBase* mToolAddDir;
95     wxToolBarToolBase* mToolRemove;
96     wxToolBarToolBase* mToolAddDatabase;
97     wxToolBarToolBase* mToolHelp;
98         wxToolBarToolBase* mToolSynchronize;
99         wxToolBarToolBase* mToolSettings;
100         wxToolBarToolBase* mToolTools;
101     
102     wxSplitterWindow* mSplitter;
103     wxPanel*          mBottomPanel;
104     wxStaticText *    mText;
105     wxNotebook*       mNotebook;
106     
107     /// The list of icons 
108     wxImageList *    mIcon;
109     void CreateIconList();
110     
111     Gimmick * mGimmick;
112     /// Callback for adding files
113     void OnAddFiles(wxCommandEvent& event);
114     /// Callback for adding dir
115     void OnAddDir(wxCommandEvent& event);
116     /// Callback for removing files
117     void OnRemove(wxCommandEvent& event);
118         /// Callback for synchronization
119     void OnSynchronize(wxCommandEvent& event);
120         /// Callback for settings edition
121     void OnSettings(wxCommandEvent& event);
122         /// Callback for settings edition
123     void OnTools(wxCommandEvent& event);
124         ///Creates the settings dialog (the pages inside and the information)
125         void CreateSettingsDialog(wxNotebook* nb);
126     
127     /// Display a message box with the last addition statistics
128     void DisplayAddSummary();
129
130         /// Test a directory to know if contains sub-directory to analyze
131         bool isNeedRecursive(std::string i_name);
132     
133     /// AddProgress Gimmick callback
134     void OnAddProgress( Gimmick::AddProgress& );
135     /// Called upon to refresh the viewer once there are no actions to be done
136     void OnInternalIdle();
137
138         // callback to add a database
139         void OnAddDB(wxCommandEvent& event);
140     
141         //Create a DB from an Attributes Descriptor files 
142         void OnCreateDB(wxCommandEvent& event);
143
144     /// Progress dialog
145     wxProgressDialog* mProgressDialog;
146     ///The selection's maximum dimension
147     int mSelectionMaxDimension;
148     ///The selection's minimum dimension
149     int mSelectionMinDimension;
150     ///Image previewer
151     WxViewer* mViewer;
152     ///Currently Displayed Node
153     tree::Node* mCurImageItemToShow;
154     //Pointer holders for images to be shown
155     std::vector<ImagePointerHolder*> pointers;
156     
157     
158     wxString mCurrentDirectory;
159     
160     DECLARE_EVENT_TABLE()
161       };
162   // EO class WxGimmickView
163   //=====================================================================
164   
165   
166   /*
167
168
169
170
171
172
173
174
175         //====================================================================
176         // General
177         //====================================================================
178
179     /// Returns the size of the current selection
180     virtual int GetSelectionSize() { return 0; } 
181     /// Returns true if there is a valid selection
182     virtual bool IsSelectionValid(){ return false; }
183     /// Returns the vector of full filenames of selected images
184     virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
185     /// Returns the vector of images corresponding to selection
186     virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
187     /// Returns the vector of DicomNode corresponding to selection
188     virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
189    /// Returns the DicomNode corresponding to the tree item
190     virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
191
192         
193         /// Type of list of DicomDatabase
194     typedef std::vector<DicomDatabase*> DicomDatabaseListType;
195     /// Returns the list of DicomDatabase open
196     virtual DicomDatabaseListType& GetDicomDatabaseList() 
197     { return null; }
198     /// Returns the list of DicomDatabase open (const)
199     virtual const DicomDatabaseListType& GetDicomDatabaseList() const 
200     { return null; }
201
202         protected:
203         ///Opens an existing database, or else, creates a local database.
204     virtual void OpenOrNewDatabase(bool open){ return; }
205         ///Shows the help
206         virtual void ShowHelp();
207
208         private:
209         ///Gets the extension of the database
210         const std::string& GetDatabaseExtension() { return null; }
211         ///Sets the extension of the database
212     virtual void SetDatabaseExtension(const std::string& ext){ return; }
213
214
215         //====================================================================
216     // Preview Display Related
217         //====================================================================
218
219
220     ///Shows the image sent as a parameter
221         private:
222          virtual void ShowImage(vtkImageData* image){ return; }
223
224         //====================================================================
225     // Favorites Related
226         //====================================================================
227
228
229         public:
230         ///Loads or creates a favorites database
231     virtual void LoadOrCreateFavoritesDatabase(){ return; }
232         private:
233         ///Creates the user settings directory
234     void CreateUserSettingsDirectory(){ return; }
235         ///Obtains the user settings directory
236         const std::string& GetUserSettingsDirectory(){ return null; }
237
238         //====================================================================  
239         // Attribute Display Related
240         //====================================================================
241
242
243         ///Shows the Information regarding the node sent as a parameter
244         private:
245      virtual void ShowInformation(DicomNode*){ return; }
246    
247         //====================================================================
248     // Tree Display Related
249     //====================================================================
250
251         protected:
252     /// Completely rebuilds the view with 
253     /// current DicomDatabaseList
254     virtual void RebuildView(){ return; }
255         /// Recursively updates the part of the view corresponding 
256     /// to the DicomDatabase passed
257     /// i.e. creates items for the DicomNode which do not have
258     ///      deletes obsolete items (whose DicomNode has been deleted)
259     virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
260     /// Recursively updates the part of the view corresponding 
261     /// to the DicomNode provided.
262     /// parent is its parent in the tree (where to insert / remove it)
263         virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
264     
265         private:
266         ///Type definition of the data regarding the tree
267     typedef WxGimmickTreeItemData TreeItemData;
268         ///Gets the item data of the tree item passed as a parameter
269     TreeItemData* GetItemData(const TreeItemId& id){ return null; }
270     ///Type definition of the data insid a node of the tree
271     typedef WxGimmickDicomNodeData NodeData;
272
273
274         //====================================================================
275     // Class Attributes
276     //====================================================================
277
278         
279         int mSelectionType;
280     int mSelectionMaxImageDimension;
281     int mCurrentSelectionImageSize[4];
282
283         ///Existent Database List
284     DicomDatabaseListType mDicomDatabaseList;
285         ///Favorites database
286     DicomDatabase* mFavoriteDatabase;
287
288         ///Path to the database list file
289     std::string mDatabaseListFile;
290         ///Extension of the database
291     std::string mDatabaseExtension;
292
293     bool mJustStarted;
294
295     int  mFirstDicomDatabaseIconIndex;
296
297    // Previewer
298     vtkImageViewer2* mViewer;
299     
300     int mx1,mx2,my1,my2,mz1,mz2;
301     double mspx,mspy,mspz;
302   
303     // Image preview :
304     // Multi-thread image reader
305     MultiThreadImageReader mReader;
306     // map of images name to node
307     std::map<std::string,DicomNode*> mImageFileNameToNode;
308   */
309  
310 } // EO namespace creaImageIO
311
312 #endif // USE_WIDGETS
313 // EOF
314 #endif