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 # ------------------------------------------------------------------------
29 #ifndef __creaImageIOWxGimmickView_h_INCLUDED__
30 #define __creaImageIOWxGimmickView_h_INCLUDED__
34 #include <creaImageIOGimmickView.h>
35 #include <creaImageIOWxViewer.h>
36 #include <creaImageIOWxGimmickTools.h>
37 #include <creaImageIOListener.h>
41 #include "wx/progdlg.h"
44 #include <wx/splitter.h>
45 #include <wx/toolbar.h>
46 #include <wx/tbarbase.h>
47 #include <wx/notebook.h>
54 //=====================================================================
56 //=====================================================================
57 /// Concrete derivative of GimmickView which implements a wxWidgets-based view
59 class WxGimmickView : public wxPanel, virtual public GimmickView
63 typedef int EventType;
67 WxGimmickView(boost::shared_ptr<Gimmick>,
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);
74 /// Virtual destructor
75 virtual ~WxGimmickView();
77 /// Returns the selected files
78 ///(overloaded from GimmickView)
79 void GetSelectedFiles(std::vector<std::string>& s);
81 /// Returns the selected files in output structure
82 void getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> out_infos, bool mult = false, const std::string out_model = "");
84 /// Returns the selected Images so that they comply with the
85 /// given parameter(4D) (overloaded from GimmickView)
86 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
87 void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim);
90 /// Returns the images indicated by the filenames in the vector
91 /// so that they comply with the given parameter(dim)
92 //(overloaded from GimmickView)
93 void GetImages(int dim, const std::vector<std::string>& files,
94 std::vector<vtkImageData*>& s);
96 /// Callback called when a selection from a TreeView has changed
97 //(overloaded from GimmickView)
98 void OnSelectionChange(const std::vector<tree::Node*>& s,
99 bool isSelection, int selection, bool mProcess);
101 void StopPlayer(){mViewer->StopPlayer();}
102 ///Adds a file to ignore
103 void AddIgnoreFile(tree::Node* toRemove);
104 ///Resets the default image
105 void ClearSelection();
106 ///Copies selected files
107 void CopyFiles(const std::vector<std::string>& filenames);
108 ///Add selected files to the Database
109 void AddDir(std::string dirName);
112 ///Sends a request to read the currently selected node and the ones that surround it.
113 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
115 ///Saves the settings to the file
116 void OnSaveSettingsCallback(const std::string& copyPath,
117 const std::string& dbPath,
118 const std::string& syncEvent,
119 const std::string& syncFreq);
121 ///Changes listener state
122 void OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles);
124 ///Acts upon a drive mount
125 void OnDriveMount(bool mount);
127 ///Starts the listening thread on the CD/DVD drive
128 void StartListeningThread();
130 ///Stops the listening thread on the CD/DVD drive
131 void StopListeningThread();
133 ///Called upon when a field has been edited
134 void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
136 ///Called upon to return the visible attributes of the current tab
137 void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
139 ///Called when there has been a change in the visible attributes of a tree view
140 void OnAttributesChanged(const std::vector<std::string>& nShown, int level);
144 /// Creates the tool bar
145 void CreateToolBar();
147 /// Create the tree view for TreeHandler provided
148 /// (overloaded from GimmickView)
149 void CreateTreeView( TreeHandler* );
153 wxBoxSizer *mbottom_sizer;
155 /// Is set to true at the end of constructor
156 /// (in order to lock callbacks from threaded objects or event
157 /// before everything is ok)
159 /// The ToolBar and the tools
161 wxToolBarToolBase* mToolAddFile;
162 wxToolBarToolBase* mToolAddDir;
163 wxToolBarToolBase* mToolRemove;
164 wxToolBarToolBase* mToolAddDatabase;
165 wxToolBarToolBase* mToolHelp;
166 wxToolBarToolBase* mToolSynchronize;
167 wxToolBarToolBase* mToolSettings;
168 wxToolBarToolBase* mToolTools;
170 wxSplitterWindow* mSplitter;
171 wxPanel* mBottomPanel;
172 wxStaticText * mText;
173 wxNotebook* mNotebook;
175 /// The list of icons
177 void CreateIconList();
179 boost::shared_ptr<Gimmick> mGimmick;
183 /// Callback for adding files
184 void OnAddFiles(wxCommandEvent& event);
186 /// Callback for adding dir
187 void OnAddDir(wxCommandEvent& event);
189 /// Callback for removing files
190 void OnRemove(wxCommandEvent& event);
192 /// Callback for synchronization
193 void OnSynchronize(wxCommandEvent& event);
195 /// Callback for settings edition
196 void OnSettings(wxCommandEvent& event);
198 /// Callback for settings edition
199 void OnTools(wxCommandEvent& event);
201 /// Callback for Import/Export images
202 void OnImportExport(wxCommandEvent& event);
204 // Import Images from an archive
207 //Export Images to an archive
210 ///Creates the settings dialog (the pages inside and the information)
211 void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
213 /// Display a message box with the last addition statistics
214 void DisplayAddSummary();
216 /// Test a directory to know if contains sub-directory to analyze
217 bool isNeedRecursive(std::string i_name);
219 /// Determines number of files potentially to add to database
220 int NumberFilesToAdd(const std::string &dirpath, bool recursive);
222 /// AddProgress Gimmick callback
223 void OnAddProgress( Gimmick::AddProgress& );
226 /// Called upon to refresh the viewer once there are no actions to be done
227 void OnInternalIdle();
229 void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
231 /// callback to add a database
232 void OnAddDB(wxCommandEvent& event);
234 ///Create a DB from an Attributes Descriptor files
235 void OnCreateDB(wxCommandEvent& event);
237 std::string ExtractName(const std::string &i_name);
239 ///Edits the fields of a given node
240 void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
243 /// Display all Dicom Tags
244 void DumpTags(const std::string i_filename);
246 /// Export from Storage to Storage
247 void ExportToStorage(const std::vector<std::string> i_filenames);
250 wxProgressDialog* mProgressDialog;
252 ///The selection's maximum dimension
253 int mSelectionMaxDimension;
255 ///The selection's minimum dimension
256 int mSelectionMinDimension;
261 ///Currently Displayed Node
262 tree::Node* mCurImageItemToShow;
264 //Pointer holders for images to be shown
265 std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
267 //kill Progress DialogBar
270 wxString mCurrentDirectory;
272 DECLARE_EVENT_TABLE()
274 // EO class WxGimmickView
275 //=====================================================================
277 } // EO namespace creaImageIO
279 #endif // USE_WIDGETS