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;
37 WxGimmickView(boost::shared_ptr<Gimmick>,
40 const wxPoint& pos, const wxSize& size,
41 int min_dim = GIMMICK_2D_IMAGE_SELECTION,
42 int max_dim = GIMMICK_3D_IMAGE_SELECTION,
43 int number_of_threads = 0);
44 /// Virtual destructor
45 virtual ~WxGimmickView();
47 /// Returns the selected files
48 ///(overloaded from GimmickView)
49 void GetSelectedFiles(std::vector<std::string>& s);
51 /// Returns the selected Images so that they comply with the
52 /// given parameter(4D) (overloaded from GimmickView)
53 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
54 void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim);
56 /// Returns the images indicated by the filenames in the vector
57 /// so that they comply with the given parameter(dim)
58 //(overloaded from GimmickView)
59 void GetImages(int dim, const std::vector<std::string>& files,
60 std::vector<vtkImageData*>& s);
62 /// Callback called when a selection from a TreeView has changed
63 //(overloaded from GimmickView)
64 void OnSelectionChange(const std::vector<tree::Node*>& s,
65 bool isSelection, int selection, bool mProcess);
67 void StopPlayer(){mViewer->StopPlayer();}
68 ///Adds a file to ignore
69 void AddIgnoreFile(tree::Node* toRemove);
70 ///Resets the default image
71 void ClearSelection();
72 ///Copies selected files
73 void CopyFiles(const std::vector<std::string>& filenames);
74 ///Add selected files to the Database
75 void AddDir(std::string dirName);
78 ///Sends a request to read the currently selected node and the ones that surround it.
79 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
81 ///Saves the settings to the file
82 void OnSaveSettingsCallback(const std::string& copyPath,
83 const std::string& dbPath,
84 const std::string& syncEvent,
85 const std::string& syncFreq);
87 ///Changes listener state
88 void OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles);
90 ///Acts upon a drive mount
91 void OnDriveMount(bool mount);
93 ///Starts the listening thread on the CD/DVD drive
94 void StartListeningThread();
96 ///Stops the listening thread on the CD/DVD drive
97 void StopListeningThread();
99 ///Called upon when a field has been edited
100 void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
102 ///Called upon to return the visible attributes of the current tab
103 void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
105 ///Called when there has been a change in the visible attributes of a tree view
106 void OnAttributesChanged(const std::vector<std::string>& nShown, int level);
109 /// Creates the tool bar
110 void CreateToolBar();
112 /// Create the tree view for TreeHandler provided
113 /// (overloaded from GimmickView)
114 void CreateTreeView( TreeHandler* );
118 wxBoxSizer *mbottom_sizer;
120 /// Is set to true at the end of constructor
121 /// (in order to lock callbacks from threaded objects or event
122 /// before everything is ok)
124 /// The ToolBar and the tools
126 wxToolBarToolBase* mToolAddFile;
127 wxToolBarToolBase* mToolAddDir;
128 wxToolBarToolBase* mToolRemove;
129 wxToolBarToolBase* mToolAddDatabase;
130 wxToolBarToolBase* mToolHelp;
131 wxToolBarToolBase* mToolSynchronize;
132 wxToolBarToolBase* mToolSettings;
133 wxToolBarToolBase* mToolTools;
135 wxSplitterWindow* mSplitter;
136 wxPanel* mBottomPanel;
137 wxStaticText * mText;
138 wxNotebook* mNotebook;
140 /// The list of icons
142 void CreateIconList();
144 boost::shared_ptr<Gimmick> mGimmick;
148 /// Callback for adding files
149 void OnAddFiles(wxCommandEvent& event);
151 /// Callback for adding dir
152 void OnAddDir(wxCommandEvent& event);
154 /// Callback for removing files
155 void OnRemove(wxCommandEvent& event);
157 /// Callback for synchronization
158 void OnSynchronize(wxCommandEvent& event);
160 /// Callback for settings edition
161 void OnSettings(wxCommandEvent& event);
163 /// Callback for settings edition
164 void OnTools(wxCommandEvent& event);
166 /// Callback for Import/Export images
167 void OnImportExport(wxCommandEvent& event);
169 // Import Images from an archive
172 //Export Images to an archive
175 ///Creates the settings dialog (the pages inside and the information)
176 void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
178 /// Display a message box with the last addition statistics
179 void DisplayAddSummary();
181 /// Test a directory to know if contains sub-directory to analyze
182 bool isNeedRecursive(std::string i_name);
184 /// Determines number of files potentially to add to database
185 int NumberFilesToAdd(const std::string &dirpath, bool recursive);
187 /// AddProgress Gimmick callback
188 void OnAddProgress( Gimmick::AddProgress& );
189 /// Called upon to refresh the viewer once there are no actions to be done
190 void OnInternalIdle();
192 /// callback to add a database
193 void OnAddDB(wxCommandEvent& event);
195 ///Create a DB from an Attributes Descriptor files
196 void OnCreateDB(wxCommandEvent& event);
198 std::string ExtractName(const std::string &i_name);
200 ///Edits the fields of a given node
201 void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
203 /// Display all Dicom Tags
204 void DumpTags(const std::string i_filename);
206 /// Export from Storage to Storage
207 void ExportToStorage(const std::vector<std::string> i_filenames);
210 wxProgressDialog* mProgressDialog;
212 ///The selection's maximum dimension
213 int mSelectionMaxDimension;
215 ///The selection's minimum dimension
216 int mSelectionMinDimension;
221 ///Currently Displayed Node
222 tree::Node* mCurImageItemToShow;
224 //Pointer holders for images to be shown
225 std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
227 wxString mCurrentDirectory;
229 DECLARE_EVENT_TABLE()
231 // EO class WxGimmickView
232 //=====================================================================
234 } // EO namespace creaImageIO
236 #endif // USE_WIDGETS