2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------
28 #ifndef __creaImageIOWxTreeView_h_INCLUDED__
29 #define __creaImageIOWxTreeView_h_INCLUDED__
33 #include <creaImageIOTreeView.h>
36 #include <wx/listctrl.h>
37 #include <wx/splitter.h>
39 const std::string empty_string("");
43 //=====================================================================
44 /// Data stored by the list items
47 ItemData() : node(0), id(-1), attr(&empty_string) {}
48 // The corresponding Node
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
61 //=====================================================================
63 //=====================================================================
64 /// Abstract class that handles the view of a Tree through its TreeHandler
65 class WxTreeView : public wxPanel, virtual public TreeView
69 WxTreeView(TreeHandler*, GimmickView*,
70 wxWindow* parent, const wxWindowID id);
71 /// Virtual destructor
72 virtual ~WxTreeView();
75 /// Updates the view of a level given the selected items of upper level
76 virtual void UpdateLevel( int );
78 ///Removes selected nodes on given level
79 virtual void RemoveSelected(std::string &i_save);
81 ///Returns the last selected level
82 virtual unsigned int GetLastSelectedLevel(){return mLastLevel;}
84 /// Callback for item selection
85 void OnItemSelected(wxListEvent& event);
87 /// Callback for item deselection
88 void OnItemDeSelected(wxListEvent& event);
90 /// Callback for column click
91 void OnColClick(wxListEvent& event);
93 /// Callback when the user needs the items sorted
94 void OnPopupSort(wxCommandEvent& event);
96 ///Callback when the user need the items filtered
97 void OnPopupFilter(wxCommandEvent& event);
99 ///Callback when the user needs the item copied to the local disk
100 void OnLocalCopy(wxCommandEvent& event);
103 ///Callback when the user needs the item copied to the local disk
104 void OnAnonymizer(wxCommandEvent& event);
107 ///Callback when the user needs to edit a field
108 void OnEditField(wxCommandEvent& event);
110 ///Callback when the user needs to display alll dicom tags for a file
111 void OnDumpTags(wxCommandEvent &event);
113 ///Callback when the user needs to transfer data from storage to storage
114 void OnExportToStorage(wxCommandEvent &event);
116 ///Callback on mouse click
117 void OnMouseClick(wxMouseEvent& event);
119 /// Displays a menu for items
120 void OnItemMenu(wxListEvent &event);
122 /// Gets the attributes that are being shown and the ones that have been blocked on a specific level
123 void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level);
125 ///Sets the non visible attributes and refreshes the GUI
126 void SetNonVisibleAttributes(const std::vector<std::string>& notShown, int level);
128 ///Creates a new listctrl
129 void CreateCtrl(std::vector<std::string>& notShown, int nlevel);
131 ///Returns true if the attribute passed as a parameter is visible or not
132 bool IsAttributeVisible(const std::string& val, int level);
134 /// Actual processing of item selection/deselection
135 /// Called by OnItemSelected and OnItemDeSelected
139 /// The struct holding the data for one level
140 /// Holds the wx control and other data
141 /// such as the vector of attribute keys corresponding to the columns
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
151 bool SelectedUpToDate;
152 // The column used for sorting
153 unsigned int SortColumn;
154 ///Boolean that defines the direction of the sort
155 ///True is ascending order and false is descending
157 //The vector of not shown attributes
158 std::vector<std::string> notShownAtts;
160 /// The vector of levels : one for each level of the tree
161 std::vector<LevelType> mLevelList;
163 /// return the wxListCtrl of one level
164 wxListCtrl* GetCtrl(int l) { return mLevelList[l].wxCtrl; }
165 /// return the wxSplitter of one level
166 wxSplitterWindow* GetSplitter(int l) { return mLevelList[l].wxSplitter; }
167 //Returns the maximum number of levels
168 int GetNumberOfLevels(){ return mLevelList.size(); }
169 /// Gets the user selected data from the level passed as a parameter
170 /// Updates the vector if necessary
171 const std::vector<tree::Node*>& GetSelected(int level);
172 /// Set the bool SelectedUpToDate for level l
173 void SetSelectedUpToDate(int l, bool v) { mLevelList[l].SelectedUpToDate = v; }
174 /// Get the bool SelectedUpToDate for level l
175 bool GetSelectedUpToDate(int l) { return mLevelList[l].SelectedUpToDate; }
176 ///Validates the selected images
177 void ValidateSelectedImages(bool isSelection);
178 ///Gets selected filenames
179 void GetSelectedAsString(std::vector<std::string>&s);
180 ///Gets the filenames of the given nodes and returns them on the given vector. Is recursive.
181 void GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s);
182 /// Gets the next nodes on the list, be it up(true) or down(false).
183 void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
184 /// Updates the view of a level given the selected items of upper level
186 virtual void RecursiveUpdateLevel( int );
187 ///Selects all the elements of a level
188 void SelectAll(int level);
189 ///UnSelects all the elements of a level
190 void UnSelectAll(int level);
192 void OnKeyDown(wxListEvent &event);
194 void SortLevel(int level);
196 /// Currently Selected Column
198 ///The last selected item on the list (left click)
201 ///The last selected item on the list (right click)
202 long mLastRightSelected;
204 ///The last selected level (by right click)
207 typedef std::map<tree::Node*,wxColour> ColorMap;
208 typedef std::pair<tree::Node*,wxColour> NodeColorPair;
210 ///Initial color palette
211 std::vector<std::string> mColorPalette;
215 wxObject* senderCtrl;
219 unsigned int mLastLevel;
222 wxMenu *subExportMenu;
228 int mExport2StorageID;
230 // If set to true then OnSelectedChanged returns immediately.
231 // Used to do avoid useless process during multiple selections
233 bool mIgnoreSelectedChanged;
235 DECLARE_EVENT_TABLE()
237 // EO class WxTreeView
238 //=====================================================================
240 class RemoveAlertDlg : public wxDialog
243 RemoveAlertDlg(wxWindow *parent,
251 void onCheck(wxCommandEvent &Event);
258 } // EO namespace creaImageIO
261 #endif // USE_WIDGETS