1 #ifndef __creaImageIOWxGimmickView_h_INCLUDED__
2 #define __creaImageIOWxGimmickView_h_INCLUDED__
6 #include <creaImageIOGimmickView.h>
7 #include <creaImageIOWxViewer.h>
10 #include <wx/splitter.h>
11 #include <wx/toolbar.h>
12 #include <wx/tbarbase.h>
13 #include <wx/notebook.h>
20 //=====================================================================
22 //=====================================================================
23 /// Concrete derivative of GimmickView which implements a wxWidgets-based view
24 class WxGimmickView : public wxPanel, virtual public GimmickView
27 typedef int EventType;
30 WxGimmickView(Gimmick*,
33 const wxPoint& pos, const wxSize& size,
34 int min_dim = GIMMICK_2D_IMAGE_SELECTION,
35 int max_dim = GIMMICK_3D_IMAGE_SELECTION,
36 int number_of_threads = 0);
37 /// Virtual destructor
38 virtual ~WxGimmickView();
40 /// Returns the selected files
41 ///(overloaded from GimmickView)
42 void GetSelectedFiles(std::vector<std::string>& s);
43 /// Returns the selected Images so that they comply with the given parameter(4D)
44 //(overloaded from GimmickView)
45 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
46 /// Callback called when a selection from a TreeView has changed
47 //(overloaded from GimmickView)
48 void OnSelectionChange(std::vector<tree::Node*>& s);
50 void StopPlayer(){mViewer->StopPlayer();}
53 ///Sends a request to read the currently selected node and the ones that surround it.
54 void ReadImageThreaded(std::vector<tree::Node*> sel);
58 /// Creates the tool bar
61 /// Create the tree view for TreeHandler provided
62 /// (overloaded from GimmickView)
63 void CreateTreeView( TreeHandler* );
67 /// Is set to true at the end of constructor
68 /// (in order to lock callbacks from threaded objects or event
69 /// before everything is ok)
71 /// The ToolBar and the tools
73 wxToolBarToolBase* mToolAddFile;
74 wxToolBarToolBase* mToolAddDir;
75 wxToolBarToolBase* mToolRemove;
76 wxToolBarToolBase* mToolAddDatabase;
77 wxToolBarToolBase* mToolHelp;
79 wxSplitterWindow* mSplitter;
80 wxPanel* mBottomPanel;
82 wxNotebook* mNotebook;
86 void CreateIconList();
89 /// Callback for adding files
90 void OnAddFiles(wxCommandEvent& event);
91 /// Callback for adding dir
92 void OnAddDir(wxCommandEvent& event);
93 /// Callback for removing files
94 void OnRemove(wxCommandEvent& event);
96 /// Display a message box with the last addition statistics
97 void DisplayAddSummary();
100 /// AddProgress Gimmick callback
101 void OnAddProgress( Gimmick::AddProgress& );
102 /// Processes the queue of image events
103 /// Called in OnInternalIdle();
104 /// (locks the MultiThreadImageReaderEvent mutex)
105 void ProcessImageEvents();
106 /// Called upon to refresh the viewer once there are no actions to be done
107 void OnInternalIdle();
110 wxProgressDialog* mProgressDialog;
111 ///The selection's maximum dimension
112 int mSelectionMaxDimension;
113 ///The selection's minimum dimension
114 int mSelectionMinDimension;
117 ///Currently Displayed Node
118 tree::Node* mCurImageItemToShow;
121 wxString mCurrentDirectory;
123 DECLARE_EVENT_TABLE()
125 // EO class WxGimmickView
126 //=====================================================================
138 //====================================================================
140 //====================================================================
142 /// Returns the size of the current selection
143 virtual int GetSelectionSize() { return 0; }
144 /// Returns true if there is a valid selection
145 virtual bool IsSelectionValid(){ return false; }
146 /// Returns the vector of full filenames of selected images
147 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
148 /// Returns the vector of images corresponding to selection
149 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
150 /// Returns the vector of DicomNode corresponding to selection
151 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
152 /// Returns the DicomNode corresponding to the tree item
153 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
156 /// Type of list of DicomDatabase
157 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
158 /// Returns the list of DicomDatabase open
159 virtual DicomDatabaseListType& GetDicomDatabaseList()
161 /// Returns the list of DicomDatabase open (const)
162 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
166 ///Opens an existing database, or else, creates a local database.
167 virtual void OpenOrNewDatabase(bool open){ return; }
169 virtual void ShowHelp();
172 ///Gets the extension of the database
173 const std::string& GetDatabaseExtension() { return null; }
174 ///Sets the extension of the database
175 virtual void SetDatabaseExtension(const std::string& ext){ return; }
178 //====================================================================
179 // Preview Display Related
180 //====================================================================
183 ///Shows the image sent as a parameter
185 virtual void ShowImage(vtkImageData* image){ return; }
187 //====================================================================
189 //====================================================================
193 ///Loads or creates a favorites database
194 virtual void LoadOrCreateFavoritesDatabase(){ return; }
196 ///Creates the user settings directory
197 void CreateUserSettingsDirectory(){ return; }
198 ///Obtains the user settings directory
199 const std::string& GetUserSettingsDirectory(){ return null; }
201 //====================================================================
202 // Attribute Display Related
203 //====================================================================
206 ///Shows the Information regarding the node sent as a parameter
208 virtual void ShowInformation(DicomNode*){ return; }
210 //====================================================================
211 // Tree Display Related
212 //====================================================================
215 /// Completely rebuilds the view with
216 /// current DicomDatabaseList
217 virtual void RebuildView(){ return; }
218 /// Recursively updates the part of the view corresponding
219 /// to the DicomDatabase passed
220 /// i.e. creates items for the DicomNode which do not have
221 /// deletes obsolete items (whose DicomNode has been deleted)
222 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
223 /// Recursively updates the part of the view corresponding
224 /// to the DicomNode provided.
225 /// parent is its parent in the tree (where to insert / remove it)
226 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
229 ///Type definition of the data regarding the tree
230 typedef WxGimmickTreeItemData TreeItemData;
231 ///Gets the item data of the tree item passed as a parameter
232 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
233 ///Type definition of the data insid a node of the tree
234 typedef WxGimmickDicomNodeData NodeData;
237 //====================================================================
239 //====================================================================
243 int mSelectionMaxImageDimension;
244 int mCurrentSelectionImageSize[4];
246 ///Existent Database List
247 DicomDatabaseListType mDicomDatabaseList;
248 ///Favorites database
249 DicomDatabase* mFavoriteDatabase;
251 ///Path to the database list file
252 std::string mDatabaseListFile;
253 ///Extension of the database
254 std::string mDatabaseExtension;
258 int mFirstDicomDatabaseIconIndex;
261 vtkImageViewer2* mViewer;
263 int mx1,mx2,my1,my2,mz1,mz2;
264 double mspx,mspy,mspz;
267 // Multi-thread image reader
268 MultiThreadImageReader mReader;
269 // map of images name to node
270 std::map<std::string,DicomNode*> mImageFileNameToNode;
273 } // EO namespace creaImageIO
275 #endif // USE_WIDGETS