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