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 CREAIMAGEIO_EXPORT 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, std::vector<std::string> &outFileNames, 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
160 // wxToolBar *mToolBar;
162 wxToolBarToolBase *mToolAddFile;
163 wxToolBarToolBase *mToolAddDir;
164 wxToolBarToolBase *mToolRemove;
165 wxToolBarToolBase *mToolAddDatabase;
166 wxToolBarToolBase *mToolHelp;
167 wxToolBarToolBase *mToolSynchronize;
168 wxToolBarToolBase *mToolSettings;
169 wxToolBarToolBase *mToolTools;
171 wxSplitterWindow *mSplitter;
172 wxPanel *mBottomPanel;
174 wxNotebook *mNotebook;
176 /// The list of icons
178 void CreateIconList();
179 void AddBtnTool(wxPanel *panel, wxBoxSizer *sizerH, int id, wxString label, int idBitmap, wxString tooltip );
182 boost::shared_ptr<Gimmick> mGimmick;
186 /// Callback for adding files
187 void OnAddFiles(wxCommandEvent& event);
189 /// Callback for adding dir
190 void OnAddDir(wxCommandEvent& event);
192 /// Callback for removing files
193 void OnRemove(wxCommandEvent& event);
195 /// Callback for synchronization
196 void OnSynchronize(wxCommandEvent& event);
198 /// Callback for settings edition
199 void OnSettings(wxCommandEvent& event);
201 /// Callback for settings edition
202 void OnTools(wxCommandEvent& event);
204 /// Callback for Import/Export images
205 void OnImportExport(wxCommandEvent& event);
207 // Import Images from an archive
210 //Export Images to an archive
213 ///Creates the settings dialog (the pages inside and the information)
214 void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
216 /// Display a message box with the last addition statistics
217 void DisplayAddSummary();
219 /// Test a directory to know if contains sub-directory to analyze
220 bool isNeedRecursive(std::string i_name);
222 /// Determines number of files potentially to add to database
223 int NumberFilesToAdd(const std::string &dirpath, bool recursive);
225 /// AddProgress Gimmick callback
226 void OnAddProgress( Gimmick::AddProgress& );
229 /// Called upon to refresh the viewer once there are no actions to be done
230 void OnInternalIdle();
232 void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
234 /// callback to add a database
235 void OnAddDB(wxCommandEvent& event);
237 ///Create a DB from an Attributes Descriptor files
238 void OnCreateDB(wxCommandEvent& event);
240 std::string ExtractName(const std::string &i_name);
242 ///Edits the fields of a given node
243 void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
246 /// Display all Dicom Tags
247 void DumpTags(const std::string i_filename);
249 /// Export from Storage to Storage
250 void ExportToStorage(const std::vector<std::string> i_filenames);
253 wxProgressDialog *mProgressDialog;
255 ///The selection's maximum dimension
256 int mSelectionMaxDimension;
258 ///The selection's minimum dimension
259 int mSelectionMinDimension;
264 ///Currently Displayed Node
265 tree::Node *mCurImageItemToShow;
267 //Pointer holders for images to be shown
268 std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
270 //kill Progress DialogBar
273 wxString mCurrentDirectory;
275 DECLARE_EVENT_TABLE()
277 // EO class WxGimmickView
278 //=====================================================================
280 } // EO namespace creaImageIO
282 #endif // USE_WIDGETS