creaImageIO_lib
creaImageIOWxGimmickView.h
Go to the documentation of this file.
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
16 #
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
21 # liability.
22 #
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
26 */
27 
28 
29 #ifndef __creaImageIOWxGimmickView_h_INCLUDED__
30 #define __creaImageIOWxGimmickView_h_INCLUDED__
31 
32 #ifdef USE_WXWIDGETS
33 
34 #include <creaImageIOGimmickView.h>
35 #include <creaImageIOWxViewer.h>
37 #include <creaImageIOListener.h>
38 #include <creaWx.h>
39 #include <time.h>
40 
41 #include "wx/progdlg.h"
42 
43 #include "wx/wx.h"
44 #include <wx/splitter.h>
45 #include <wx/toolbar.h>
46 #include <wx/tbarbase.h>
47 #include <wx/notebook.h>
48 
49 namespace creaImageIO
50 {
54  //=====================================================================
55 
56  //=====================================================================
58 
59  class WxGimmickView : public wxPanel, virtual public GimmickView
60  {
61  public:
62 
63  typedef int EventType;
65 
67  WxGimmickView(boost::shared_ptr<Gimmick>,
68  wxWindow *parent,
69  const wxWindowID id,
70  const wxPoint& pos, const wxSize& size,
71  int min_dim = GIMMICK_2D_IMAGE_SELECTION,
72  int max_dim = GIMMICK_3D_IMAGE_SELECTION,
73  int number_of_threads = 0);
75  virtual ~WxGimmickView();
76 
79  void GetSelectedFiles(std::vector<std::string>& s);
80 
82  void getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> out_infos, bool mult = false, const std::string out_model = "");
83 
86  void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
87  void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim);
88 
89 
92  //(overloaded from GimmickView)
93  void GetImages(int dim, const std::vector<std::string>& files,
94  std::vector<vtkImageData*>& s);
95 
97  //(overloaded from GimmickView)
98  void OnSelectionChange(const std::vector<tree::Node*>& s,
99  bool isSelection, int selection, bool mProcess);
103  void AddIgnoreFile(tree::Node* toRemove);
105  void ClearSelection();
107  void CopyFiles(const std::vector<std::string>& filenames);
109  void AddDir(std::string dirName);
110 
111 
113  void ReadImageThreaded(const std::vector<tree::Node*>& sel);
114 
116  void OnSaveSettingsCallback(const std::string& copyPath,
117  const std::string& dbPath,
118  const std::string& syncEvent,
119  const std::string& syncFreq);
120 
122  void OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles);
123 
125  void OnDriveMount(bool mount);
126 
128  void StartListeningThread();
129 
131  void StopListeningThread();
132 
134  void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
135 
137  void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
138 
140  void OnAttributesChanged(const std::vector<std::string>& nShown, int level);
141 
142 
143  protected:
145  void CreateToolBar();
146 
149  void CreateTreeView( TreeHandler* );
150 
151 
152  private:
153  wxBoxSizer *mbottom_sizer;
154  wxBoxSizer *msizer;
160  wxToolBar* mToolBar;
161  wxToolBarToolBase* mToolAddFile;
162  wxToolBarToolBase* mToolAddDir;
163  wxToolBarToolBase* mToolRemove;
164  wxToolBarToolBase* mToolAddDatabase;
165  wxToolBarToolBase* mToolHelp;
166  wxToolBarToolBase* mToolSynchronize;
167  wxToolBarToolBase* mToolSettings;
168  wxToolBarToolBase* mToolTools;
169 
170  wxSplitterWindow* mSplitter;
171  wxPanel* mBottomPanel;
172  wxStaticText * mText;
173  wxNotebook* mNotebook;
174 
176  wxImageList * mIcon;
177  void CreateIconList();
178 
179  boost::shared_ptr<Gimmick> mGimmick;
180 
182 
184  void OnAddFiles(wxCommandEvent& event);
185 
187  void OnAddDir(wxCommandEvent& event);
188 
190  void OnRemove(wxCommandEvent& event);
191 
193  void OnSynchronize(wxCommandEvent& event);
194 
196  void OnSettings(wxCommandEvent& event);
197 
199  void OnTools(wxCommandEvent& event);
200 
202  void OnImportExport(wxCommandEvent& event);
203 
204  // Import Images from an archive
205  void ImportImages();
206 
207  //Export Images to an archive
208  void ExportImages();
209 
211  void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
212 
214  void DisplayAddSummary();
215  time_t mstart;
217  bool isNeedRecursive(std::string i_name);
218 
220  int NumberFilesToAdd(const std::string &dirpath, bool recursive);
221 
224 
225 #if defined(WIN32)
226 
227  void OnInternalIdle();
228 #else
229  void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
230 #endif
231 
232  void OnAddDB(wxCommandEvent& event);
233 
235  void OnCreateDB(wxCommandEvent& event);
236 
237  std::string ExtractName(const std::string &i_name);
238 
240  void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
241 
242 
244  void DumpTags(const std::string i_filename);
245 
247  void ExportToStorage(const std::vector<std::string> i_filenames);
248 
250  wxProgressDialog* mProgressDialog;
251 
254 
257 
260 
263 
264  //Pointer holders for images to be shown
265  std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
266 
267  //kill Progress DialogBar
268  void killProgress();
269 
271 
272  DECLARE_EVENT_TABLE()
273  };
274  // EO class WxGimmickView
275  //=====================================================================
276 
277 } // EO namespace creaImageIO
278 
279 #endif // USE_WIDGETS
280 // EOF
281 #endif