]> 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     /// Display a message box with the last addition statistics
127     void DisplayAddSummary();
128
129         /// Test a directory to know if contains sub-directory to analyze
130         bool isNeedRecursive(std::string i_name);
131     
132     /// AddProgress Gimmick callback
133     void OnAddProgress( Gimmick::AddProgress& );
134     /// Called upon to refresh the viewer once there are no actions to be done
135     void OnInternalIdle();
136
137         // callback to add a database
138         void OnAddDB(wxCommandEvent& event);
139     
140         //Create a DB from an Attributes Descriptor files 
141         void OnCreateDB(wxCommandEvent& event);
142
143     /// Progress dialog
144     wxProgressDialog* mProgressDialog;
145     ///The selection's maximum dimension
146     int mSelectionMaxDimension;
147     ///The selection's minimum dimension
148     int mSelectionMinDimension;
149     ///Image previewer
150     WxViewer* mViewer;
151     ///Currently Displayed Node
152     tree::Node* mCurImageItemToShow;
153     //Pointer holders for images to be shown
154     std::vector<ImagePointerHolder*> pointers;
155     
156     
157     wxString mCurrentDirectory;
158     
159     DECLARE_EVENT_TABLE()
160       };
161   // EO class WxGimmickView
162   //=====================================================================
163   
164   
165   /*
166
167
168
169
170
171
172
173
174         //====================================================================
175         // General
176         //====================================================================
177
178     /// Returns the size of the current selection
179     virtual int GetSelectionSize() { return 0; } 
180     /// Returns true if there is a valid selection
181     virtual bool IsSelectionValid(){ return false; }
182     /// Returns the vector of full filenames of selected images
183     virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
184     /// Returns the vector of images corresponding to selection
185     virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
186     /// Returns the vector of DicomNode corresponding to selection
187     virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
188    /// Returns the DicomNode corresponding to the tree item
189     virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
190
191         
192         /// Type of list of DicomDatabase
193     typedef std::vector<DicomDatabase*> DicomDatabaseListType;
194     /// Returns the list of DicomDatabase open
195     virtual DicomDatabaseListType& GetDicomDatabaseList() 
196     { return null; }
197     /// Returns the list of DicomDatabase open (const)
198     virtual const DicomDatabaseListType& GetDicomDatabaseList() const 
199     { return null; }
200
201         protected:
202         ///Opens an existing database, or else, creates a local database.
203     virtual void OpenOrNewDatabase(bool open){ return; }
204         ///Shows the help
205         virtual void ShowHelp();
206
207         private:
208         ///Gets the extension of the database
209         const std::string& GetDatabaseExtension() { return null; }
210         ///Sets the extension of the database
211     virtual void SetDatabaseExtension(const std::string& ext){ return; }
212
213
214         //====================================================================
215     // Preview Display Related
216         //====================================================================
217
218
219     ///Shows the image sent as a parameter
220         private:
221          virtual void ShowImage(vtkImageData* image){ return; }
222
223         //====================================================================
224     // Favorites Related
225         //====================================================================
226
227
228         public:
229         ///Loads or creates a favorites database
230     virtual void LoadOrCreateFavoritesDatabase(){ return; }
231         private:
232         ///Creates the user settings directory
233     void CreateUserSettingsDirectory(){ return; }
234         ///Obtains the user settings directory
235         const std::string& GetUserSettingsDirectory(){ return null; }
236
237         //====================================================================  
238         // Attribute Display Related
239         //====================================================================
240
241
242         ///Shows the Information regarding the node sent as a parameter
243         private:
244      virtual void ShowInformation(DicomNode*){ return; }
245    
246         //====================================================================
247     // Tree Display Related
248     //====================================================================
249
250         protected:
251     /// Completely rebuilds the view with 
252     /// current DicomDatabaseList
253     virtual void RebuildView(){ return; }
254         /// Recursively updates the part of the view corresponding 
255     /// to the DicomDatabase passed
256     /// i.e. creates items for the DicomNode which do not have
257     ///      deletes obsolete items (whose DicomNode has been deleted)
258     virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
259     /// Recursively updates the part of the view corresponding 
260     /// to the DicomNode provided.
261     /// parent is its parent in the tree (where to insert / remove it)
262         virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
263     
264         private:
265         ///Type definition of the data regarding the tree
266     typedef WxGimmickTreeItemData TreeItemData;
267         ///Gets the item data of the tree item passed as a parameter
268     TreeItemData* GetItemData(const TreeItemId& id){ return null; }
269     ///Type definition of the data insid a node of the tree
270     typedef WxGimmickDicomNodeData NodeData;
271
272
273         //====================================================================
274     // Class Attributes
275     //====================================================================
276
277         
278         int mSelectionType;
279     int mSelectionMaxImageDimension;
280     int mCurrentSelectionImageSize[4];
281
282         ///Existent Database List
283     DicomDatabaseListType mDicomDatabaseList;
284         ///Favorites database
285     DicomDatabase* mFavoriteDatabase;
286
287         ///Path to the database list file
288     std::string mDatabaseListFile;
289         ///Extension of the database
290     std::string mDatabaseExtension;
291
292     bool mJustStarted;
293
294     int  mFirstDicomDatabaseIconIndex;
295
296    // Previewer
297     vtkImageViewer2* mViewer;
298     
299     int mx1,mx2,my1,my2,mz1,mz2;
300     double mspx,mspy,mspz;
301   
302     // Image preview :
303     // Multi-thread image reader
304     MultiThreadImageReader mReader;
305     // map of images name to node
306     std::map<std::string,DicomNode*> mImageFileNameToNode;
307   */
308  
309 } // EO namespace creaImageIO
310
311 #endif // USE_WIDGETS
312 // EOF
313 #endif