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);
52 ///Sends a request to read the currently selected node and the ones that surround it.
53 void ReadImageThreaded(std::vector<tree::Node*> sel);
57 /// Creates the tool bar
60 /// Create the tree view for TreeHandler provided
61 /// (overloaded from GimmickView)
62 void CreateTreeView( TreeHandler* );
66 /// Is set to true at the end of constructor
67 /// (in order to lock callbacks from threaded objects or event
68 /// before everything is ok)
70 /// The ToolBar and the tools
72 wxToolBarToolBase* mToolAddFile;
73 wxToolBarToolBase* mToolAddDir;
74 wxToolBarToolBase* mToolRemove;
75 wxToolBarToolBase* mToolAddDatabase;
76 wxToolBarToolBase* mToolHelp;
78 wxSplitterWindow* mSplitter;
79 wxPanel* mBottomPanel;
81 wxNotebook* mNotebook;
85 void CreateIconList();
88 /// Callback for adding files
89 void OnAddFiles(wxCommandEvent& event);
90 /// Callback for adding dir
91 void OnAddDir(wxCommandEvent& event);
92 /// Callback for removing files
93 void OnRemove(wxCommandEvent& event);
95 /// Display a message box with the last addition statistics
96 void DisplayAddSummary();
99 /// AddProgress Gimmick callback
100 void OnAddProgress( Gimmick::AddProgress& );
101 /// Processes the queue of image events
102 /// Called in OnInternalIdle();
103 /// (locks the MultiThreadImageReaderEvent mutex)
104 void ProcessImageEvents();
105 /// Called upon to refresh the viewer once there are no actions to be done
106 void OnInternalIdle();
109 wxProgressDialog* mProgressDialog;
110 ///The selection's maximum dimension
111 int mSelectionMaxDimension;
112 ///The selection's minimum dimension
113 int mSelectionMinDimension;
116 ///Currently Displayed Node
117 tree::Node* mCurImageItemToShow;
120 wxString mCurrentDirectory;
122 DECLARE_EVENT_TABLE()
124 // EO class WxGimmickView
125 //=====================================================================
137 //====================================================================
139 //====================================================================
141 /// Returns the size of the current selection
142 virtual int GetSelectionSize() { return 0; }
143 /// Returns true if there is a valid selection
144 virtual bool IsSelectionValid(){ return false; }
145 /// Returns the vector of full filenames of selected images
146 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
147 /// Returns the vector of images corresponding to selection
148 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
149 /// Returns the vector of DicomNode corresponding to selection
150 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
151 /// Returns the DicomNode corresponding to the tree item
152 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
155 /// Type of list of DicomDatabase
156 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
157 /// Returns the list of DicomDatabase open
158 virtual DicomDatabaseListType& GetDicomDatabaseList()
160 /// Returns the list of DicomDatabase open (const)
161 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
165 ///Opens an existing database, or else, creates a local database.
166 virtual void OpenOrNewDatabase(bool open){ return; }
168 virtual void ShowHelp();
171 ///Gets the extension of the database
172 const std::string& GetDatabaseExtension() { return null; }
173 ///Sets the extension of the database
174 virtual void SetDatabaseExtension(const std::string& ext){ return; }
177 //====================================================================
178 // Preview Display Related
179 //====================================================================
182 ///Shows the image sent as a parameter
184 virtual void ShowImage(vtkImageData* image){ return; }
186 //====================================================================
188 //====================================================================
192 ///Loads or creates a favorites database
193 virtual void LoadOrCreateFavoritesDatabase(){ return; }
195 ///Creates the user settings directory
196 void CreateUserSettingsDirectory(){ return; }
197 ///Obtains the user settings directory
198 const std::string& GetUserSettingsDirectory(){ return null; }
200 //====================================================================
201 // Attribute Display Related
202 //====================================================================
205 ///Shows the Information regarding the node sent as a parameter
207 virtual void ShowInformation(DicomNode*){ return; }
209 //====================================================================
210 // Tree Display Related
211 //====================================================================
214 /// Completely rebuilds the view with
215 /// current DicomDatabaseList
216 virtual void RebuildView(){ return; }
217 /// Recursively updates the part of the view corresponding
218 /// to the DicomDatabase passed
219 /// i.e. creates items for the DicomNode which do not have
220 /// deletes obsolete items (whose DicomNode has been deleted)
221 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
222 /// Recursively updates the part of the view corresponding
223 /// to the DicomNode provided.
224 /// parent is its parent in the tree (where to insert / remove it)
225 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
228 ///Type definition of the data regarding the tree
229 typedef WxGimmickTreeItemData TreeItemData;
230 ///Gets the item data of the tree item passed as a parameter
231 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
232 ///Type definition of the data insid a node of the tree
233 typedef WxGimmickDicomNodeData NodeData;
236 //====================================================================
238 //====================================================================
242 int mSelectionMaxImageDimension;
243 int mCurrentSelectionImageSize[4];
245 ///Existent Database List
246 DicomDatabaseListType mDicomDatabaseList;
247 ///Favorites database
248 DicomDatabase* mFavoriteDatabase;
250 ///Path to the database list file
251 std::string mDatabaseListFile;
252 ///Extension of the database
253 std::string mDatabaseExtension;
257 int mFirstDicomDatabaseIconIndex;
260 vtkImageViewer2* mViewer;
262 int mx1,mx2,my1,my2,mz1,mz2;
263 double mspx,mspy,mspz;
266 // Multi-thread image reader
267 MultiThreadImageReader mReader;
268 // map of images name to node
269 std::map<std::string,DicomNode*> mImageFileNameToNode;
272 } // EO namespace creaImageIO
274 #endif // USE_WIDGETS