creaImageIO_lib
creaImageIOWxTreeView.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 #ifndef __creaImageIOWxTreeView_h_INCLUDED__
29 #define __creaImageIOWxTreeView_h_INCLUDED__
30 
31 #ifdef USE_WXWIDGETS
32 
33 #include <creaImageIOTreeView.h>
34 #include <creaWx.h>
35 
36 #include <wx/listctrl.h>
37 #include <wx/splitter.h>
38 //#include <vector>
39 const std::string empty_string("");
40 namespace creaImageIO
41 {
42 
43  //=====================================================================
45  struct ItemData
46  {
47  ItemData() : node(0), id(-1), attr(&empty_string) {}
48  // The corresponding Node
50  // The id ?
51  int id;
52  // The pointer on the current attribute string to sort on
53  const std::string* attr;
54  // Was the item previously selected ?
55  // Useful for reselecting the item after sort
56  bool selected;
57  };
61  //=====================================================================
62 
63  //=====================================================================
65  class WxTreeView : public wxPanel, virtual public TreeView
66  {
67  public:
70  wxWindow* parent, const wxWindowID id);
72  virtual ~WxTreeView();
73 
74 
76  virtual void UpdateLevel( int );
77 
79  virtual void RemoveSelected(std::string &i_save);
80 
82  virtual unsigned int GetLastSelectedLevel(){return mLastLevel;}
83 
85  void OnItemSelected(wxListEvent& event);
86 
88  void OnItemDeSelected(wxListEvent& event);
89 
91  void OnColClick(wxListEvent& event);
92 
94  void OnPopupSort(wxCommandEvent& event);
95 
97  void OnPopupFilter(wxCommandEvent& event);
98 
100  void OnLocalCopy(wxCommandEvent& event);
101 
102 
104  void OnAnonymizer(wxCommandEvent& event);
105 
106 
108  void OnEditField(wxCommandEvent& event);
109 
111  void OnDumpTags(wxCommandEvent &event);
112 
114  void OnExportToStorage(wxCommandEvent &event);
115 
117  void OnMouseClick(wxMouseEvent& event);
118 
120  void OnItemMenu(wxListEvent &event);
121 
123  void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level);
124 
126  void SetNonVisibleAttributes(const std::vector<std::string>& notShown, int level);
127 
129  void CreateCtrl(std::vector<std::string>& notShown, int nlevel);
130 
132  bool IsAttributeVisible(const std::string& val, int level);
133 
136  // void ProcessItem
137  private:
138  wxBoxSizer *msizer;
142  struct LevelType
143  {
144  // The List Control
145  wxListCtrl* wxCtrl;
146  wxSplitterWindow* wxSplitter;
147  std::vector<std::string> key;
148  // The vector of currently selected nodes of the level
149  std::vector<tree::Node*> Selected;
150  // True iff the vector Selected is up to date
152  // The column used for sorting
153  unsigned int SortColumn;
157  //The vector of not shown attributes
158  std::vector<std::string> notShownAtts;
159  };
161  std::vector<LevelType> mLevelList;
162 
164  wxListCtrl* GetCtrl(int l) { return mLevelList[l].wxCtrl; }
166  wxSplitterWindow* GetSplitter(int l) { return mLevelList[l].wxSplitter; }
167  //Returns the maximum number of levels
168  int GetNumberOfLevels(){ return (int)mLevelList.size(); }
171  const std::vector<tree::Node*>& GetSelected(int level);
173  void SetSelectedUpToDate(int l, bool v) { mLevelList[l].SelectedUpToDate = v; }
175  bool GetSelectedUpToDate(int l) { return mLevelList[l].SelectedUpToDate; }
177  void ValidateSelectedImages(bool isSelection);
179  void GetSelectedAsString(std::vector<std::string>&s);
181  void GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s);
183  void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
186  virtual void RecursiveUpdateLevel( int );
188  void SelectAll(int level);
190  void UnSelectAll(int level);
191 
192  void OnKeyDown(wxListEvent &event);
194  void SortLevel(int level);
195 
200 
203 
207  typedef std::map<tree::Node*,wxColour> ColorMap;
208  typedef std::pair<tree::Node*,wxColour> NodeColorPair;
211  std::vector<std::string> mColorPalette;
212 
213  wxMenu* menu;
214 
215  wxObject* senderCtrl;
219  unsigned int mLastLevel;
220 
221  wxMenu* menuItem;
222  wxMenu *subExportMenu;
226  int mDumpID;
229 
230  // If set to true then OnSelectedChanged returns immediately.
231  // Used to do avoid useless process during multiple selections
232  // or sorting
234 
235  DECLARE_EVENT_TABLE()
236  };
237  // EO class WxTreeView
238  //=====================================================================
239 
240  class RemoveAlertDlg : public wxDialog
241  {
242  public:
243  RemoveAlertDlg(wxWindow *parent,
244  wxString title,
245  const wxSize& size);
246  ~RemoveAlertDlg();
247 
248  bool isChecked();
249 
250  private :
251  void onCheck(wxCommandEvent &Event);
252  bool mSave;
253  wxCheckBox *mcheck;
254 
255  };
256 
257 
258 } // EO namespace creaImageIO
259 
260 
261 #endif // USE_WIDGETS
262 // EOF
263 #endif