1 #ifndef __creaImageIOWxGimmickView_h_INCLUDED__
2 #define __creaImageIOWxGimmickView_h_INCLUDED__
6 #include <creaImageIOGimmickView.h>
7 #include <creaImageIOWxViewer.h>
8 #include <creaImageIOWxGimmickTools.h>
11 //#include "bruker2dicom.h"
13 #include <wx/splitter.h>
14 #include <wx/toolbar.h>
15 #include <wx/tbarbase.h>
16 #include <wx/notebook.h>
23 //=====================================================================
25 //=====================================================================
26 /// Concrete derivative of GimmickView which implements a wxWidgets-based view
28 class WxGimmickView : public wxPanel, virtual public GimmickView
32 typedef int EventType;
35 WxGimmickView(Gimmick*,
38 const wxPoint& pos, const wxSize& size,
39 int min_dim = GIMMICK_2D_IMAGE_SELECTION,
40 int max_dim = GIMMICK_3D_IMAGE_SELECTION,
41 int number_of_threads = 0);
42 /// Virtual destructor
43 virtual ~WxGimmickView();
45 /// Returns the selected files
46 ///(overloaded from GimmickView)
47 void GetSelectedFiles(std::vector<std::string>& s);
49 /// Returns the selected Images so that they comply with the
50 /// given parameter(4D) (overloaded from GimmickView)
51 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
53 /// Returns the images indicated by the filenames in the vector
54 /// so that they comply with the given parameter(dim)
55 //(overloaded from GimmickView)
56 void GetImages(int dim, const std::vector<std::string>& files,
57 std::vector<vtkImageData*>& s);
59 /// Callback called when a selection from a TreeView has changed
60 //(overloaded from GimmickView)
61 void OnSelectionChange(const std::vector<tree::Node*>& s,
62 bool isSelection, int selection, bool mProcess);
64 void StopPlayer(){mViewer->StopPlayer();}
65 ///Adds a file to ignore
66 void AddIgnoreFile(tree::Node* toRemove);
67 ///Resets the default image
68 void ClearSelection();
69 ///Copies selected files
70 void CopyFiles(const std::vector<std::string>& filenames);
73 ///Sends a request to read the currently selected node and the ones that surround it.
74 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
78 /// Creates the tool bar
81 /// Create the tree view for TreeHandler provided
82 /// (overloaded from GimmickView)
83 void CreateTreeView( TreeHandler* );
87 /// Is set to true at the end of constructor
88 /// (in order to lock callbacks from threaded objects or event
89 /// before everything is ok)
91 /// The ToolBar and the tools
93 wxToolBarToolBase* mToolAddFile;
94 wxToolBarToolBase* mToolAddDir;
95 wxToolBarToolBase* mToolRemove;
96 wxToolBarToolBase* mToolAddDatabase;
97 wxToolBarToolBase* mToolHelp;
98 wxToolBarToolBase* mToolSynchronize;
99 wxToolBarToolBase* mToolSettings;
100 wxToolBarToolBase* mToolTools;
102 wxSplitterWindow* mSplitter;
103 wxPanel* mBottomPanel;
104 wxStaticText * mText;
105 wxNotebook* mNotebook;
107 /// The list of icons
109 void CreateIconList();
112 /// Callback for adding files
113 void OnAddFiles(wxCommandEvent& event);
114 /// Callback for adding dir
115 void OnAddDir(wxCommandEvent& event);
116 /// Callback for removing files
117 void OnRemove(wxCommandEvent& event);
118 /// Callback for synchronization
119 void OnSynchronize(wxCommandEvent& event);
120 /// Callback for settings edition
121 void OnSettings(wxCommandEvent& event);
122 /// Callback for settings edition
123 void OnTools(wxCommandEvent& event);
124 ///Creates the settings dialog (the pages inside and the information)
125 void CreateSettingsDialog(wxNotebook* nb);
127 /// Display a message box with the last addition statistics
128 void DisplayAddSummary();
130 /// Test a directory to know if contains sub-directory to analyze
131 bool isNeedRecursive(std::string i_name);
133 /// AddProgress Gimmick callback
134 void OnAddProgress( Gimmick::AddProgress& );
135 /// Called upon to refresh the viewer once there are no actions to be done
136 void OnInternalIdle();
138 // callback to add a database
139 void OnAddDB(wxCommandEvent& event);
141 //Create a DB from an Attributes Descriptor files
142 void OnCreateDB(wxCommandEvent& event);
145 wxProgressDialog* mProgressDialog;
146 ///The selection's maximum dimension
147 int mSelectionMaxDimension;
148 ///The selection's minimum dimension
149 int mSelectionMinDimension;
152 ///Currently Displayed Node
153 tree::Node* mCurImageItemToShow;
154 //Pointer holders for images to be shown
155 std::vector<ImagePointerHolder*> pointers;
158 wxString mCurrentDirectory;
160 DECLARE_EVENT_TABLE()
162 // EO class WxGimmickView
163 //=====================================================================
175 //====================================================================
177 //====================================================================
179 /// Returns the size of the current selection
180 virtual int GetSelectionSize() { return 0; }
181 /// Returns true if there is a valid selection
182 virtual bool IsSelectionValid(){ return false; }
183 /// Returns the vector of full filenames of selected images
184 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
185 /// Returns the vector of images corresponding to selection
186 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
187 /// Returns the vector of DicomNode corresponding to selection
188 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
189 /// Returns the DicomNode corresponding to the tree item
190 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
193 /// Type of list of DicomDatabase
194 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
195 /// Returns the list of DicomDatabase open
196 virtual DicomDatabaseListType& GetDicomDatabaseList()
198 /// Returns the list of DicomDatabase open (const)
199 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
203 ///Opens an existing database, or else, creates a local database.
204 virtual void OpenOrNewDatabase(bool open){ return; }
206 virtual void ShowHelp();
209 ///Gets the extension of the database
210 const std::string& GetDatabaseExtension() { return null; }
211 ///Sets the extension of the database
212 virtual void SetDatabaseExtension(const std::string& ext){ return; }
215 //====================================================================
216 // Preview Display Related
217 //====================================================================
220 ///Shows the image sent as a parameter
222 virtual void ShowImage(vtkImageData* image){ return; }
224 //====================================================================
226 //====================================================================
230 ///Loads or creates a favorites database
231 virtual void LoadOrCreateFavoritesDatabase(){ return; }
233 ///Creates the user settings directory
234 void CreateUserSettingsDirectory(){ return; }
235 ///Obtains the user settings directory
236 const std::string& GetUserSettingsDirectory(){ return null; }
238 //====================================================================
239 // Attribute Display Related
240 //====================================================================
243 ///Shows the Information regarding the node sent as a parameter
245 virtual void ShowInformation(DicomNode*){ return; }
247 //====================================================================
248 // Tree Display Related
249 //====================================================================
252 /// Completely rebuilds the view with
253 /// current DicomDatabaseList
254 virtual void RebuildView(){ return; }
255 /// Recursively updates the part of the view corresponding
256 /// to the DicomDatabase passed
257 /// i.e. creates items for the DicomNode which do not have
258 /// deletes obsolete items (whose DicomNode has been deleted)
259 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
260 /// Recursively updates the part of the view corresponding
261 /// to the DicomNode provided.
262 /// parent is its parent in the tree (where to insert / remove it)
263 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
266 ///Type definition of the data regarding the tree
267 typedef WxGimmickTreeItemData TreeItemData;
268 ///Gets the item data of the tree item passed as a parameter
269 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
270 ///Type definition of the data insid a node of the tree
271 typedef WxGimmickDicomNodeData NodeData;
274 //====================================================================
276 //====================================================================
280 int mSelectionMaxImageDimension;
281 int mCurrentSelectionImageSize[4];
283 ///Existent Database List
284 DicomDatabaseListType mDicomDatabaseList;
285 ///Favorites database
286 DicomDatabase* mFavoriteDatabase;
288 ///Path to the database list file
289 std::string mDatabaseListFile;
290 ///Extension of the database
291 std::string mDatabaseExtension;
295 int mFirstDicomDatabaseIconIndex;
298 vtkImageViewer2* mViewer;
300 int mx1,mx2,my1,my2,mz1,mz2;
301 double mspx,mspy,mspz;
304 // Multi-thread image reader
305 MultiThreadImageReader mReader;
306 // map of images name to node
307 std::map<std::string,DicomNode*> mImageFileNameToNode;
310 } // EO namespace creaImageIO
312 #endif // USE_WIDGETS