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);
55 /// Returns the images indicated by the filenames in the vector
56 /// so that they comply with the given parameter(dim)
57 //(overloaded from GimmickView)
58 void GetImages(int dim, const std::vector<std::string>& files,
59 std::vector<vtkImageData*>& s);
61 /// Callback called when a selection from a TreeView has changed
62 //(overloaded from GimmickView)
63 void OnSelectionChange(const std::vector<tree::Node*>& s,
64 bool isSelection, int selection, bool mProcess);
66 void StopPlayer(){mViewer->StopPlayer();}
67 ///Adds a file to ignore
68 void AddIgnoreFile(tree::Node* toRemove);
69 ///Resets the default image
70 void ClearSelection();
71 ///Copies selected files
72 void CopyFiles(const std::vector<std::string>& filenames);
73 ///Add selected files to the Database
74 void AddDir(std::string dirName);
77 ///Sends a request to read the currently selected node and the ones that surround it.
78 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
80 ///Saves the settings to the file
81 void OnSaveSettingsCallback(const std::string& copyPath,
82 const std::string& dbPath,
83 const std::string& syncEvent,
84 const std::string& syncFreq);
86 ///Changes listener state
87 void OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles);
89 ///Acts upon a drive mount
90 void OnDriveMount(bool mount);
92 ///Starts the listening thread on the CD/DVD drive
93 void StartListeningThread();
95 ///Stops the listening thread on the CD/DVD drive
96 void StopListeningThread();
98 ///Called upon when a field has been edited
99 void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
101 ///Called upon to return the visible attributes of the current tab
102 void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
104 ///Called when there has been a change in the visible attributes of a tree view
105 void OnAttributesChanged(const std::vector<std::string>& nShown, int level);
108 /// Creates the tool bar
109 void CreateToolBar();
111 /// Create the tree view for TreeHandler provided
112 /// (overloaded from GimmickView)
113 void CreateTreeView( TreeHandler* );
117 /// Is set to true at the end of constructor
118 /// (in order to lock callbacks from threaded objects or event
119 /// before everything is ok)
121 /// The ToolBar and the tools
123 wxToolBarToolBase* mToolAddFile;
124 wxToolBarToolBase* mToolAddDir;
125 wxToolBarToolBase* mToolRemove;
126 wxToolBarToolBase* mToolAddDatabase;
127 wxToolBarToolBase* mToolHelp;
128 wxToolBarToolBase* mToolSynchronize;
129 wxToolBarToolBase* mToolSettings;
130 wxToolBarToolBase* mToolTools;
132 wxSplitterWindow* mSplitter;
133 wxPanel* mBottomPanel;
134 wxStaticText * mText;
135 wxNotebook* mNotebook;
137 /// The list of icons
139 void CreateIconList();
141 boost::shared_ptr<Gimmick> mGimmick;
144 /// Callback for adding files
145 void OnAddFiles(wxCommandEvent& event);
146 /// Callback for adding dir
147 void OnAddDir(wxCommandEvent& event);
148 /// Callback for removing files
149 void OnRemove(wxCommandEvent& event);
150 /// Callback for synchronization
151 void OnSynchronize(wxCommandEvent& event);
152 /// Callback for settings edition
153 void OnSettings(wxCommandEvent& event);
154 /// Callback for settings edition
155 void OnTools(wxCommandEvent& event);
156 /// Callback for Import/Export images
157 void OnImportExport(wxCommandEvent& event);
159 // Import Images from an archive
162 //Export Images to an archive
165 ///Creates the settings dialog (the pages inside and the information)
166 void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
168 /// Display a message box with the last addition statistics
169 void DisplayAddSummary();
171 /// Test a directory to know if contains sub-directory to analyze
172 bool isNeedRecursive(std::string i_name);
174 /// Determines number of files potentially to add to database
175 int NumberFilesToAdd(const std::string &dirpath, bool recursive);
177 /// AddProgress Gimmick callback
178 void OnAddProgress( Gimmick::AddProgress& );
179 /// Called upon to refresh the viewer once there are no actions to be done
180 void OnInternalIdle();
182 /// callback to add a database
183 void OnAddDB(wxCommandEvent& event);
185 ///Create a DB from an Attributes Descriptor files
186 void OnCreateDB(wxCommandEvent& event);
188 std::string ExtractName(const std::string &i_name);
190 ///Edits the fields of a given node
191 void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
194 wxProgressDialog* mProgressDialog;
195 ///The selection's maximum dimension
196 int mSelectionMaxDimension;
197 ///The selection's minimum dimension
198 int mSelectionMinDimension;
201 ///Currently Displayed Node
202 tree::Node* mCurImageItemToShow;
203 //Pointer holders for images to be shown
204 std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
207 wxString mCurrentDirectory;
209 DECLARE_EVENT_TABLE()
211 // EO class WxGimmickView
212 //=====================================================================
216 } // EO namespace creaImageIO
218 #endif // USE_WIDGETS