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);
126 /// Display a message box with the last addition statistics
127 void DisplayAddSummary();
129 /// Test a directory to know if contains sub-directory to analyze
130 bool isNeedRecursive(std::string i_name);
132 /// AddProgress Gimmick callback
133 void OnAddProgress( Gimmick::AddProgress& );
134 /// Called upon to refresh the viewer once there are no actions to be done
135 void OnInternalIdle();
137 // callback to add a database
138 void OnAddDB(wxCommandEvent& event);
140 //Create a DB from an Attributes Descriptor files
141 void OnCreateDB(wxCommandEvent& event);
144 wxProgressDialog* mProgressDialog;
145 ///The selection's maximum dimension
146 int mSelectionMaxDimension;
147 ///The selection's minimum dimension
148 int mSelectionMinDimension;
151 ///Currently Displayed Node
152 tree::Node* mCurImageItemToShow;
153 //Pointer holders for images to be shown
154 std::vector<ImagePointerHolder*> pointers;
157 wxString mCurrentDirectory;
159 DECLARE_EVENT_TABLE()
161 // EO class WxGimmickView
162 //=====================================================================
174 //====================================================================
176 //====================================================================
178 /// Returns the size of the current selection
179 virtual int GetSelectionSize() { return 0; }
180 /// Returns true if there is a valid selection
181 virtual bool IsSelectionValid(){ return false; }
182 /// Returns the vector of full filenames of selected images
183 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
184 /// Returns the vector of images corresponding to selection
185 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
186 /// Returns the vector of DicomNode corresponding to selection
187 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
188 /// Returns the DicomNode corresponding to the tree item
189 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
192 /// Type of list of DicomDatabase
193 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
194 /// Returns the list of DicomDatabase open
195 virtual DicomDatabaseListType& GetDicomDatabaseList()
197 /// Returns the list of DicomDatabase open (const)
198 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
202 ///Opens an existing database, or else, creates a local database.
203 virtual void OpenOrNewDatabase(bool open){ return; }
205 virtual void ShowHelp();
208 ///Gets the extension of the database
209 const std::string& GetDatabaseExtension() { return null; }
210 ///Sets the extension of the database
211 virtual void SetDatabaseExtension(const std::string& ext){ return; }
214 //====================================================================
215 // Preview Display Related
216 //====================================================================
219 ///Shows the image sent as a parameter
221 virtual void ShowImage(vtkImageData* image){ return; }
223 //====================================================================
225 //====================================================================
229 ///Loads or creates a favorites database
230 virtual void LoadOrCreateFavoritesDatabase(){ return; }
232 ///Creates the user settings directory
233 void CreateUserSettingsDirectory(){ return; }
234 ///Obtains the user settings directory
235 const std::string& GetUserSettingsDirectory(){ return null; }
237 //====================================================================
238 // Attribute Display Related
239 //====================================================================
242 ///Shows the Information regarding the node sent as a parameter
244 virtual void ShowInformation(DicomNode*){ return; }
246 //====================================================================
247 // Tree Display Related
248 //====================================================================
251 /// Completely rebuilds the view with
252 /// current DicomDatabaseList
253 virtual void RebuildView(){ return; }
254 /// Recursively updates the part of the view corresponding
255 /// to the DicomDatabase passed
256 /// i.e. creates items for the DicomNode which do not have
257 /// deletes obsolete items (whose DicomNode has been deleted)
258 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
259 /// Recursively updates the part of the view corresponding
260 /// to the DicomNode provided.
261 /// parent is its parent in the tree (where to insert / remove it)
262 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
265 ///Type definition of the data regarding the tree
266 typedef WxGimmickTreeItemData TreeItemData;
267 ///Gets the item data of the tree item passed as a parameter
268 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
269 ///Type definition of the data insid a node of the tree
270 typedef WxGimmickDicomNodeData NodeData;
273 //====================================================================
275 //====================================================================
279 int mSelectionMaxImageDimension;
280 int mCurrentSelectionImageSize[4];
282 ///Existent Database List
283 DicomDatabaseListType mDicomDatabaseList;
284 ///Favorites database
285 DicomDatabase* mFavoriteDatabase;
287 ///Path to the database list file
288 std::string mDatabaseListFile;
289 ///Extension of the database
290 std::string mDatabaseExtension;
294 int mFirstDicomDatabaseIconIndex;
297 vtkImageViewer2* mViewer;
299 int mx1,mx2,my1,my2,mz1,mz2;
300 double mspx,mspy,mspz;
303 // Multi-thread image reader
304 MultiThreadImageReader mReader;
305 // map of images name to node
306 std::map<std::string,DicomNode*> mImageFileNameToNode;
309 } // EO namespace creaImageIO
311 #endif // USE_WIDGETS