1 #ifndef __creaImageIOWxGimmickView_h_INCLUDED__
2 #define __creaImageIOWxGimmickView_h_INCLUDED__
6 #include <creaImageIOGimmickView.h>
7 #include <creaImageIOWxViewer.h>
8 #include <creaImageIOWxGimmickTools.h>
9 #include <creaImageIOListener.h>
13 #include "wx/progdlg.h"
16 #include <wx/splitter.h>
17 #include <wx/toolbar.h>
18 #include <wx/tbarbase.h>
19 #include <wx/notebook.h>
26 //=====================================================================
28 //=====================================================================
29 /// Concrete derivative of GimmickView which implements a wxWidgets-based view
31 class WxGimmickView : public wxPanel, virtual public GimmickView
35 typedef int EventType;
39 WxGimmickView(boost::shared_ptr<Gimmick>,
42 const wxPoint& pos, const wxSize& size,
43 int min_dim = GIMMICK_2D_IMAGE_SELECTION,
44 int max_dim = GIMMICK_3D_IMAGE_SELECTION,
45 int number_of_threads = 0);
46 /// Virtual destructor
47 virtual ~WxGimmickView();
49 /// Returns the selected files
50 ///(overloaded from GimmickView)
51 void GetSelectedFiles(std::vector<std::string>& s);
53 /// Returns the selected files in output structure
54 void getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> out_infos, bool mult = false, const std::string out_model = "");
56 /// Returns the selected Images so that they comply with the
57 /// given parameter(4D) (overloaded from GimmickView)
58 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
59 void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim);
62 /// Returns the images indicated by the filenames in the vector
63 /// so that they comply with the given parameter(dim)
64 //(overloaded from GimmickView)
65 void GetImages(int dim, const std::vector<std::string>& files,
66 std::vector<vtkImageData*>& s);
68 /// Callback called when a selection from a TreeView has changed
69 //(overloaded from GimmickView)
70 void OnSelectionChange(const std::vector<tree::Node*>& s,
71 bool isSelection, int selection, bool mProcess);
73 void StopPlayer(){mViewer->StopPlayer();}
74 ///Adds a file to ignore
75 void AddIgnoreFile(tree::Node* toRemove);
76 ///Resets the default image
77 void ClearSelection();
78 ///Copies selected files
79 void CopyFiles(const std::vector<std::string>& filenames);
80 ///Add selected files to the Database
81 void AddDir(std::string dirName);
84 ///Sends a request to read the currently selected node and the ones that surround it.
85 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
87 ///Saves the settings to the file
88 void OnSaveSettingsCallback(const std::string& copyPath,
89 const std::string& dbPath,
90 const std::string& syncEvent,
91 const std::string& syncFreq);
93 ///Changes listener state
94 void OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles);
96 ///Acts upon a drive mount
97 void OnDriveMount(bool mount);
99 ///Starts the listening thread on the CD/DVD drive
100 void StartListeningThread();
102 ///Stops the listening thread on the CD/DVD drive
103 void StopListeningThread();
105 ///Called upon when a field has been edited
106 void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
108 ///Called upon to return the visible attributes of the current tab
109 void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
111 ///Called when there has been a change in the visible attributes of a tree view
112 void OnAttributesChanged(const std::vector<std::string>& nShown, int level);
115 /// Creates the tool bar
116 void CreateToolBar();
118 /// Create the tree view for TreeHandler provided
119 /// (overloaded from GimmickView)
120 void CreateTreeView( TreeHandler* );
124 wxBoxSizer *mbottom_sizer;
126 /// Is set to true at the end of constructor
127 /// (in order to lock callbacks from threaded objects or event
128 /// before everything is ok)
130 /// The ToolBar and the tools
132 wxToolBarToolBase* mToolAddFile;
133 wxToolBarToolBase* mToolAddDir;
134 wxToolBarToolBase* mToolRemove;
135 wxToolBarToolBase* mToolAddDatabase;
136 wxToolBarToolBase* mToolHelp;
137 wxToolBarToolBase* mToolSynchronize;
138 wxToolBarToolBase* mToolSettings;
139 wxToolBarToolBase* mToolTools;
141 wxSplitterWindow* mSplitter;
142 wxPanel* mBottomPanel;
143 wxStaticText * mText;
144 wxNotebook* mNotebook;
146 /// The list of icons
148 void CreateIconList();
150 boost::shared_ptr<Gimmick> mGimmick;
154 /// Callback for adding files
155 void OnAddFiles(wxCommandEvent& event);
157 /// Callback for adding dir
158 void OnAddDir(wxCommandEvent& event);
160 /// Callback for removing files
161 void OnRemove(wxCommandEvent& event);
163 /// Callback for synchronization
164 void OnSynchronize(wxCommandEvent& event);
166 /// Callback for settings edition
167 void OnSettings(wxCommandEvent& event);
169 /// Callback for settings edition
170 void OnTools(wxCommandEvent& event);
172 /// Callback for Import/Export images
173 void OnImportExport(wxCommandEvent& event);
175 // Import Images from an archive
178 //Export Images to an archive
181 ///Creates the settings dialog (the pages inside and the information)
182 void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
184 /// Display a message box with the last addition statistics
185 void DisplayAddSummary();
187 /// Test a directory to know if contains sub-directory to analyze
188 bool isNeedRecursive(std::string i_name);
190 /// Determines number of files potentially to add to database
191 int NumberFilesToAdd(const std::string &dirpath, bool recursive);
193 /// AddProgress Gimmick callback
194 void OnAddProgress( Gimmick::AddProgress& );
197 /// Called upon to refresh the viewer once there are no actions to be done
198 void OnInternalIdle();
200 void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
202 /// callback to add a database
203 void OnAddDB(wxCommandEvent& event);
205 ///Create a DB from an Attributes Descriptor files
206 void OnCreateDB(wxCommandEvent& event);
208 std::string ExtractName(const std::string &i_name);
210 ///Edits the fields of a given node
211 void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
214 /// Display all Dicom Tags
215 void DumpTags(const std::string i_filename);
217 /// Export from Storage to Storage
218 void ExportToStorage(const std::vector<std::string> i_filenames);
221 wxProgressDialog* mProgressDialog;
223 ///The selection's maximum dimension
224 int mSelectionMaxDimension;
226 ///The selection's minimum dimension
227 int mSelectionMinDimension;
232 ///Currently Displayed Node
233 tree::Node* mCurImageItemToShow;
235 //Pointer holders for images to be shown
236 std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
238 //kill Progress DialogBar
241 wxString mCurrentDirectory;
243 DECLARE_EVENT_TABLE()
245 // EO class WxGimmickView
246 //=====================================================================
248 } // EO namespace creaImageIO
250 #endif // USE_WIDGETS