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 "bruker2dicom.h"
14 #include <wx/splitter.h>
15 #include <wx/toolbar.h>
16 #include <wx/tbarbase.h>
17 #include <wx/notebook.h>
24 //=====================================================================
26 //=====================================================================
27 /// Concrete derivative of GimmickView which implements a wxWidgets-based view
29 class WxGimmickView : public wxPanel, virtual public GimmickView
33 typedef int EventType;
36 WxGimmickView(Gimmick*,
39 const wxPoint& pos, const wxSize& size,
40 int min_dim = GIMMICK_2D_IMAGE_SELECTION,
41 int max_dim = GIMMICK_3D_IMAGE_SELECTION,
42 int number_of_threads = 0);
43 /// Virtual destructor
44 virtual ~WxGimmickView();
46 /// Returns the selected files
47 ///(overloaded from GimmickView)
48 void GetSelectedFiles(std::vector<std::string>& s);
50 /// Returns the selected Images so that they comply with the
51 /// given parameter(4D) (overloaded from GimmickView)
52 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
54 /// Returns the images indicated by the filenames in the vector
55 /// so that they comply with the given parameter(dim)
56 //(overloaded from GimmickView)
57 void GetImages(int dim, const std::vector<std::string>& files,
58 std::vector<vtkImageData*>& s);
60 /// Callback called when a selection from a TreeView has changed
61 //(overloaded from GimmickView)
62 void OnSelectionChange(const std::vector<tree::Node*>& s,
63 bool isSelection, int selection, bool mProcess);
65 void StopPlayer(){mViewer->StopPlayer();}
66 ///Adds a file to ignore
67 void AddIgnoreFile(tree::Node* toRemove);
68 ///Resets the default image
69 void ClearSelection();
70 ///Copies selected files
71 void CopyFiles(const std::vector<std::string>& filenames);
74 ///Sends a request to read the currently selected node and the ones that surround it.
75 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
77 ///Saves the settings to the file
78 void OnSaveSettingsCallback(const std::string& copyPath,
79 const std::string& dbPath,
80 const std::string& syncEvent,
81 const std::string& syncFreq);
83 ///Changes listener state
84 void OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles);
86 ///Acts upon a drive mount
87 void OnDriveMount(bool mount);
89 ///Starts the listening thread on the CD/DVD drive
90 void StartListeningThread();
92 ///Stops the listening thread on the CD/DVD drive
93 void StopListeningThread();
97 /// Creates the tool bar
100 /// Create the tree view for TreeHandler provided
101 /// (overloaded from GimmickView)
102 void CreateTreeView( TreeHandler* );
106 /// Is set to true at the end of constructor
107 /// (in order to lock callbacks from threaded objects or event
108 /// before everything is ok)
110 /// The ToolBar and the tools
112 wxToolBarToolBase* mToolAddFile;
113 wxToolBarToolBase* mToolAddDir;
114 wxToolBarToolBase* mToolRemove;
115 wxToolBarToolBase* mToolAddDatabase;
116 wxToolBarToolBase* mToolHelp;
117 wxToolBarToolBase* mToolSynchronize;
118 wxToolBarToolBase* mToolSettings;
119 wxToolBarToolBase* mToolTools;
121 wxSplitterWindow* mSplitter;
122 wxPanel* mBottomPanel;
123 wxStaticText * mText;
124 wxNotebook* mNotebook;
126 /// The list of icons
128 void CreateIconList();
133 /// Callback for adding files
134 void OnAddFiles(wxCommandEvent& event);
135 /// Callback for adding dir
136 void OnAddDir(wxCommandEvent& event);
137 /// Callback for removing files
138 void OnRemove(wxCommandEvent& event);
139 /// Callback for synchronization
140 void OnSynchronize(wxCommandEvent& event);
141 /// Callback for settings edition
142 void OnSettings(wxCommandEvent& event);
143 /// Callback for settings edition
144 void OnTools(wxCommandEvent& event);
145 ///Creates the settings dialog (the pages inside and the information)
146 void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
148 /// Display a message box with the last addition statistics
149 void DisplayAddSummary();
151 /// Test a directory to know if contains sub-directory to analyze
152 bool isNeedRecursive(std::string i_name);
154 /// AddProgress Gimmick callback
155 void OnAddProgress( Gimmick::AddProgress& );
156 /// Called upon to refresh the viewer once there are no actions to be done
157 void OnInternalIdle();
159 // callback to add a database
160 void OnAddDB(wxCommandEvent& event);
162 //Create a DB from an Attributes Descriptor files
163 void OnCreateDB(wxCommandEvent& event);
166 wxProgressDialog* mProgressDialog;
167 ///The selection's maximum dimension
168 int mSelectionMaxDimension;
169 ///The selection's minimum dimension
170 int mSelectionMinDimension;
173 ///Currently Displayed Node
174 tree::Node* mCurImageItemToShow;
175 //Pointer holders for images to be shown
176 std::vector<ImagePointerHolder*> pointers;
179 wxString mCurrentDirectory;
181 DECLARE_EVENT_TABLE()
183 // EO class WxGimmickView
184 //=====================================================================
196 //====================================================================
198 //====================================================================
200 /// Returns the size of the current selection
201 virtual int GetSelectionSize() { return 0; }
202 /// Returns true if there is a valid selection
203 virtual bool IsSelectionValid(){ return false; }
204 /// Returns the vector of full filenames of selected images
205 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
206 /// Returns the vector of images corresponding to selection
207 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
208 /// Returns the vector of DicomNode corresponding to selection
209 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
210 /// Returns the DicomNode corresponding to the tree item
211 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
214 /// Type of list of DicomDatabase
215 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
216 /// Returns the list of DicomDatabase open
217 virtual DicomDatabaseListType& GetDicomDatabaseList()
219 /// Returns the list of DicomDatabase open (const)
220 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
224 ///Opens an existing database, or else, creates a local database.
225 virtual void OpenOrNewDatabase(bool open){ return; }
227 virtual void ShowHelp();
230 ///Gets the extension of the database
231 const std::string& GetDatabaseExtension() { return null; }
232 ///Sets the extension of the database
233 virtual void SetDatabaseExtension(const std::string& ext){ return; }
236 //====================================================================
237 // Preview Display Related
238 //====================================================================
241 ///Shows the image sent as a parameter
243 virtual void ShowImage(vtkImageData* image){ return; }
245 //====================================================================
247 //====================================================================
251 ///Loads or creates a favorites database
252 virtual void LoadOrCreateFavoritesDatabase(){ return; }
254 ///Creates the user settings directory
255 void CreateUserSettingsDirectory(){ return; }
256 ///Obtains the user settings directory
257 const std::string& GetUserSettingsDirectory(){ return null; }
259 //====================================================================
260 // Attribute Display Related
261 //====================================================================
264 ///Shows the Information regarding the node sent as a parameter
266 virtual void ShowInformation(DicomNode*){ return; }
268 //====================================================================
269 // Tree Display Related
270 //====================================================================
273 /// Completely rebuilds the view with
274 /// current DicomDatabaseList
275 virtual void RebuildView(){ return; }
276 /// Recursively updates the part of the view corresponding
277 /// to the DicomDatabase passed
278 /// i.e. creates items for the DicomNode which do not have
279 /// deletes obsolete items (whose DicomNode has been deleted)
280 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
281 /// Recursively updates the part of the view corresponding
282 /// to the DicomNode provided.
283 /// parent is its parent in the tree (where to insert / remove it)
284 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
287 ///Type definition of the data regarding the tree
288 typedef WxGimmickTreeItemData TreeItemData;
289 ///Gets the item data of the tree item passed as a parameter
290 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
291 ///Type definition of the data insid a node of the tree
292 typedef WxGimmickDicomNodeData NodeData;
295 //====================================================================
297 //====================================================================
301 int mSelectionMaxImageDimension;
302 int mCurrentSelectionImageSize[4];
304 ///Existent Database List
305 DicomDatabaseListType mDicomDatabaseList;
306 ///Favorites database
307 DicomDatabase* mFavoriteDatabase;
309 ///Path to the database list file
310 std::string mDatabaseListFile;
311 ///Extension of the database
312 std::string mDatabaseExtension;
316 int mFirstDicomDatabaseIconIndex;
319 vtkImageViewer2* mViewer;
321 int mx1,mx2,my1,my2,mz1,mz2;
322 double mspx,mspy,mspz;
325 // Multi-thread image reader
326 MultiThreadImageReader mReader;
327 // map of images name to node
328 std::map<std::string,DicomNode*> mImageFileNameToNode;
331 } // EO namespace creaImageIO
333 #endif // USE_WIDGETS