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>
12 #include "wx/progdlg.h"
15 #include <wx/splitter.h>
16 #include <wx/toolbar.h>
17 #include <wx/tbarbase.h>
18 #include <wx/notebook.h>
25 //=====================================================================
27 //=====================================================================
28 /// Concrete derivative of GimmickView which implements a wxWidgets-based view
30 class WxGimmickView : public wxPanel, virtual public GimmickView
34 typedef int EventType;
38 WxGimmickView(boost::shared_ptr<Gimmick>,
41 const wxPoint& pos, const wxSize& size,
42 int min_dim = GIMMICK_2D_IMAGE_SELECTION,
43 int max_dim = GIMMICK_3D_IMAGE_SELECTION,
44 int number_of_threads = 0);
45 /// Virtual destructor
46 virtual ~WxGimmickView();
48 /// Returns the selected files
49 ///(overloaded from GimmickView)
50 void GetSelectedFiles(std::vector<std::string>& s);
52 /// Returns the selected files in output structure
53 void getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> out_infos, bool mult = false, const std::string out_model = "");
55 /// Returns the selected Images so that they comply with the
56 /// given parameter(4D) (overloaded from GimmickView)
57 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
58 void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim);
61 /// Returns the images indicated by the filenames in the vector
62 /// so that they comply with the given parameter(dim)
63 //(overloaded from GimmickView)
64 void GetImages(int dim, const std::vector<std::string>& files,
65 std::vector<vtkImageData*>& s);
67 /// Callback called when a selection from a TreeView has changed
68 //(overloaded from GimmickView)
69 void OnSelectionChange(const std::vector<tree::Node*>& s,
70 bool isSelection, int selection, bool mProcess);
72 void StopPlayer(){mViewer->StopPlayer();}
73 ///Adds a file to ignore
74 void AddIgnoreFile(tree::Node* toRemove);
75 ///Resets the default image
76 void ClearSelection();
77 ///Copies selected files
78 void CopyFiles(const std::vector<std::string>& filenames);
79 ///Add selected files to the Database
80 void AddDir(std::string dirName);
83 ///Sends a request to read the currently selected node and the ones that surround it.
84 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
86 ///Saves the settings to the file
87 void OnSaveSettingsCallback(const std::string& copyPath,
88 const std::string& dbPath,
89 const std::string& syncEvent,
90 const std::string& syncFreq);
92 ///Changes listener state
93 void OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles);
95 ///Acts upon a drive mount
96 void OnDriveMount(bool mount);
98 ///Starts the listening thread on the CD/DVD drive
99 void StartListeningThread();
101 ///Stops the listening thread on the CD/DVD drive
102 void StopListeningThread();
104 ///Called upon when a field has been edited
105 void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
107 ///Called upon to return the visible attributes of the current tab
108 void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
110 ///Called when there has been a change in the visible attributes of a tree view
111 void OnAttributesChanged(const std::vector<std::string>& nShown, int level);
114 /// Creates the tool bar
115 void CreateToolBar();
117 /// Create the tree view for TreeHandler provided
118 /// (overloaded from GimmickView)
119 void CreateTreeView( TreeHandler* );
123 wxBoxSizer *mbottom_sizer;
125 /// Is set to true at the end of constructor
126 /// (in order to lock callbacks from threaded objects or event
127 /// before everything is ok)
129 /// The ToolBar and the tools
131 wxToolBarToolBase* mToolAddFile;
132 wxToolBarToolBase* mToolAddDir;
133 wxToolBarToolBase* mToolRemove;
134 wxToolBarToolBase* mToolAddDatabase;
135 wxToolBarToolBase* mToolHelp;
136 wxToolBarToolBase* mToolSynchronize;
137 wxToolBarToolBase* mToolSettings;
138 wxToolBarToolBase* mToolTools;
140 wxSplitterWindow* mSplitter;
141 wxPanel* mBottomPanel;
142 wxStaticText * mText;
143 wxNotebook* mNotebook;
145 /// The list of icons
147 void CreateIconList();
149 boost::shared_ptr<Gimmick> mGimmick;
153 /// Callback for adding files
154 void OnAddFiles(wxCommandEvent& event);
156 /// Callback for adding dir
157 void OnAddDir(wxCommandEvent& event);
159 /// Callback for removing files
160 void OnRemove(wxCommandEvent& event);
162 /// Callback for synchronization
163 void OnSynchronize(wxCommandEvent& event);
165 /// Callback for settings edition
166 void OnSettings(wxCommandEvent& event);
168 /// Callback for settings edition
169 void OnTools(wxCommandEvent& event);
171 /// Callback for Import/Export images
172 void OnImportExport(wxCommandEvent& event);
174 // Import Images from an archive
177 //Export Images to an archive
180 ///Creates the settings dialog (the pages inside and the information)
181 void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
183 /// Display a message box with the last addition statistics
184 void DisplayAddSummary();
186 /// Test a directory to know if contains sub-directory to analyze
187 bool isNeedRecursive(std::string i_name);
189 /// Determines number of files potentially to add to database
190 int NumberFilesToAdd(const std::string &dirpath, bool recursive);
192 /// AddProgress Gimmick callback
193 void OnAddProgress( Gimmick::AddProgress& );
196 /// Called upon to refresh the viewer once there are no actions to be done
197 void OnInternalIdle();
199 void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
201 /// callback to add a database
202 void OnAddDB(wxCommandEvent& event);
204 ///Create a DB from an Attributes Descriptor files
205 void OnCreateDB(wxCommandEvent& event);
207 std::string ExtractName(const std::string &i_name);
209 ///Edits the fields of a given node
210 void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
213 /// Display all Dicom Tags
214 void DumpTags(const std::string i_filename);
216 /// Export from Storage to Storage
217 void ExportToStorage(const std::vector<std::string> i_filenames);
220 wxProgressDialog* mProgressDialog;
222 ///The selection's maximum dimension
223 int mSelectionMaxDimension;
225 ///The selection's minimum dimension
226 int mSelectionMinDimension;
231 ///Currently Displayed Node
232 tree::Node* mCurImageItemToShow;
234 //Pointer holders for images to be shown
235 std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
237 wxString mCurrentDirectory;
239 DECLARE_EVENT_TABLE()
241 // EO class WxGimmickView
242 //=====================================================================
244 } // EO namespace creaImageIO
246 #endif // USE_WIDGETS