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);
116 /// Creates the tool bar
117 void CreateToolBar();
119 /// Create the tree view for TreeHandler provided
120 /// (overloaded from GimmickView)
121 void CreateTreeView( TreeHandler* );
125 wxBoxSizer *mbottom_sizer;
127 /// Is set to true at the end of constructor
128 /// (in order to lock callbacks from threaded objects or event
129 /// before everything is ok)
131 /// The ToolBar and the tools
133 wxToolBarToolBase* mToolAddFile;
134 wxToolBarToolBase* mToolAddDir;
135 wxToolBarToolBase* mToolRemove;
136 wxToolBarToolBase* mToolAddDatabase;
137 wxToolBarToolBase* mToolHelp;
138 wxToolBarToolBase* mToolSynchronize;
139 wxToolBarToolBase* mToolSettings;
140 wxToolBarToolBase* mToolTools;
142 wxSplitterWindow* mSplitter;
143 wxPanel* mBottomPanel;
144 wxStaticText * mText;
145 wxNotebook* mNotebook;
147 /// The list of icons
149 void CreateIconList();
151 boost::shared_ptr<Gimmick> mGimmick;
155 /// Callback for adding files
156 void OnAddFiles(wxCommandEvent& event);
158 /// Callback for adding dir
159 void OnAddDir(wxCommandEvent& event);
161 /// Callback for removing files
162 void OnRemove(wxCommandEvent& event);
164 /// Callback for synchronization
165 void OnSynchronize(wxCommandEvent& event);
167 /// Callback for settings edition
168 void OnSettings(wxCommandEvent& event);
170 /// Callback for settings edition
171 void OnTools(wxCommandEvent& event);
173 /// Callback for Import/Export images
174 void OnImportExport(wxCommandEvent& event);
176 // Import Images from an archive
179 //Export Images to an archive
182 ///Creates the settings dialog (the pages inside and the information)
183 void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
185 /// Display a message box with the last addition statistics
186 void DisplayAddSummary();
188 /// Test a directory to know if contains sub-directory to analyze
189 bool isNeedRecursive(std::string i_name);
191 /// Determines number of files potentially to add to database
192 int NumberFilesToAdd(const std::string &dirpath, bool recursive);
194 /// AddProgress Gimmick callback
195 void OnAddProgress( Gimmick::AddProgress& );
198 /// Called upon to refresh the viewer once there are no actions to be done
199 void OnInternalIdle();
201 void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
203 /// callback to add a database
204 void OnAddDB(wxCommandEvent& event);
206 ///Create a DB from an Attributes Descriptor files
207 void OnCreateDB(wxCommandEvent& event);
209 std::string ExtractName(const std::string &i_name);
211 ///Edits the fields of a given node
212 void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
215 /// Display all Dicom Tags
216 void DumpTags(const std::string i_filename);
218 /// Export from Storage to Storage
219 void ExportToStorage(const std::vector<std::string> i_filenames);
222 wxProgressDialog* mProgressDialog;
224 ///The selection's maximum dimension
225 int mSelectionMaxDimension;
227 ///The selection's minimum dimension
228 int mSelectionMinDimension;
233 ///Currently Displayed Node
234 tree::Node* mCurImageItemToShow;
236 //Pointer holders for images to be shown
237 std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
239 //kill Progress DialogBar
242 wxString mCurrentDirectory;
244 DECLARE_EVENT_TABLE()
246 // EO class WxGimmickView
247 //=====================================================================
249 } // EO namespace creaImageIO
251 #endif // USE_WIDGETS