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 /// Is set to true at the end of constructor
119 /// (in order to lock callbacks from threaded objects or event
120 /// before everything is ok)
122 /// The ToolBar and the tools
124 wxToolBarToolBase* mToolAddFile;
125 wxToolBarToolBase* mToolAddDir;
126 wxToolBarToolBase* mToolRemove;
127 wxToolBarToolBase* mToolAddDatabase;
128 wxToolBarToolBase* mToolHelp;
129 wxToolBarToolBase* mToolSynchronize;
130 wxToolBarToolBase* mToolSettings;
131 wxToolBarToolBase* mToolTools;
133 wxSplitterWindow* mSplitter;
134 wxPanel* mBottomPanel;
135 wxStaticText * mText;
136 wxNotebook* mNotebook;
138 /// The list of icons
140 void CreateIconList();
142 boost::shared_ptr<Gimmick> mGimmick;
146 /// Callback for adding files
147 void OnAddFiles(wxCommandEvent& event);
149 /// Callback for adding dir
150 void OnAddDir(wxCommandEvent& event);
152 /// Callback for removing files
153 void OnRemove(wxCommandEvent& event);
155 /// Callback for synchronization
156 void OnSynchronize(wxCommandEvent& event);
158 /// Callback for settings edition
159 void OnSettings(wxCommandEvent& event);
161 /// Callback for settings edition
162 void OnTools(wxCommandEvent& event);
164 /// Callback for Import/Export images
165 void OnImportExport(wxCommandEvent& event);
167 // Import Images from an archive
170 //Export Images to an archive
173 ///Creates the settings dialog (the pages inside and the information)
174 void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
176 /// Display a message box with the last addition statistics
177 void DisplayAddSummary();
179 /// Test a directory to know if contains sub-directory to analyze
180 bool isNeedRecursive(std::string i_name);
182 /// Determines number of files potentially to add to database
183 int NumberFilesToAdd(const std::string &dirpath, bool recursive);
185 /// AddProgress Gimmick callback
186 void OnAddProgress( Gimmick::AddProgress& );
187 /// Called upon to refresh the viewer once there are no actions to be done
188 void OnInternalIdle();
190 /// callback to add a database
191 void OnAddDB(wxCommandEvent& event);
193 ///Create a DB from an Attributes Descriptor files
194 void OnCreateDB(wxCommandEvent& event);
196 std::string ExtractName(const std::string &i_name);
198 ///Edits the fields of a given node
199 void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
202 wxProgressDialog* mProgressDialog;
204 ///The selection's maximum dimension
205 int mSelectionMaxDimension;
207 ///The selection's minimum dimension
208 int mSelectionMinDimension;
213 ///Currently Displayed Node
214 tree::Node* mCurImageItemToShow;
216 //Pointer holders for images to be shown
217 std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
219 wxString mCurrentDirectory;
221 DECLARE_EVENT_TABLE()
223 // EO class WxGimmickView
224 //=====================================================================
226 } // EO namespace creaImageIO
228 #endif // USE_WIDGETS