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 Images so that they comply with the given parameter(<4D)
41 ///(overloaded from GimmickView)
42 vtkImageData* GetSelectedImage(int dim);
43 /// Returns the selected files
44 ///(overloaded from GimmickView)
45 void GetSelectedFiles(std::vector<std::string>& s);
46 /// Returns the selected Images so that they comply with the given parameter(4D)
47 //(overloaded from GimmickView)
48 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
49 /// Validates the selected images
50 bool ValidateSelection(void *);
51 ///Sends a request to read the currently selected node and the ones that surround it.
52 void ReadImageThreaded(std::vector<tree::Node*> sel);
56 /// Creates the tool bar
59 /// Create the tree view for TreeHandler provided
60 /// (overloaded from GimmickView)
61 void CreateTreeView( TreeHandler* );
65 /// The ToolBar and the tools
67 wxToolBarToolBase* mToolAddFile;
68 wxToolBarToolBase* mToolAddDir;
69 wxToolBarToolBase* mToolRemove;
70 wxToolBarToolBase* mToolAddDatabase;
71 wxToolBarToolBase* mToolHelp;
73 wxSplitterWindow* mSplitter;
74 wxPanel* mBottomPanel;
76 wxNotebook* mNotebook;
80 void CreateIconList();
83 /// Callback for adding files
84 void OnAddFiles(wxCommandEvent& event);
85 /// Callback for adding dir
86 void OnAddDir(wxCommandEvent& event);
87 /// Callback for removing files
88 void OnRemove(wxCommandEvent& event);
90 /// Display a message box with the last addition statistics
91 void DisplayAddSummary();
94 /// AddProgress Gimmick callback
95 void OnAddProgress( Gimmick::AddProgress& );
96 /// Processes the queue of image events
97 /// Called in OnInternalIdle();
98 /// (locks the MultiThreadImageReaderEvent mutex)
99 void ProcessImageEvents();
100 /// Called upon to refresh the viewer once there are no actions to be done
101 void OnInternalIdle();
104 wxProgressDialog* mProgressDialog;
105 ///The selection's maximum dimension
106 int mSelectionMaxDimension;
107 ///The selection's minimum dimension
108 int mSelectionMinDimension;
111 ///Currently Displayed Node
112 tree::Node* mCurImageItemToShow;
115 wxString mCurrentDirectory;
117 DECLARE_EVENT_TABLE()
119 // EO class WxGimmickView
120 //=====================================================================
132 //====================================================================
134 //====================================================================
136 /// Returns the size of the current selection
137 virtual int GetSelectionSize() { return 0; }
138 /// Returns true if there is a valid selection
139 virtual bool IsSelectionValid(){ return false; }
140 /// Returns the vector of full filenames of selected images
141 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
142 /// Returns the vector of images corresponding to selection
143 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
144 /// Returns the vector of DicomNode corresponding to selection
145 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
146 /// Returns the DicomNode corresponding to the tree item
147 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
150 /// Type of list of DicomDatabase
151 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
152 /// Returns the list of DicomDatabase open
153 virtual DicomDatabaseListType& GetDicomDatabaseList()
155 /// Returns the list of DicomDatabase open (const)
156 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
160 ///Opens an existing database, or else, creates a local database.
161 virtual void OpenOrNewDatabase(bool open){ return; }
163 virtual void ShowHelp();
166 ///Gets the extension of the database
167 const std::string& GetDatabaseExtension() { return null; }
168 ///Sets the extension of the database
169 virtual void SetDatabaseExtension(const std::string& ext){ return; }
172 //====================================================================
173 // Preview Display Related
174 //====================================================================
177 ///Shows the image sent as a parameter
179 virtual void ShowImage(vtkImageData* image){ return; }
181 //====================================================================
183 //====================================================================
187 ///Loads or creates a favorites database
188 virtual void LoadOrCreateFavoritesDatabase(){ return; }
190 ///Creates the user settings directory
191 void CreateUserSettingsDirectory(){ return; }
192 ///Obtains the user settings directory
193 const std::string& GetUserSettingsDirectory(){ return null; }
195 //====================================================================
196 // Attribute Display Related
197 //====================================================================
200 ///Shows the Information regarding the node sent as a parameter
202 virtual void ShowInformation(DicomNode*){ return; }
204 //====================================================================
205 // Tree Display Related
206 //====================================================================
209 /// Completely rebuilds the view with
210 /// current DicomDatabaseList
211 virtual void RebuildView(){ return; }
212 /// Recursively updates the part of the view corresponding
213 /// to the DicomDatabase passed
214 /// i.e. creates items for the DicomNode which do not have
215 /// deletes obsolete items (whose DicomNode has been deleted)
216 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
217 /// Recursively updates the part of the view corresponding
218 /// to the DicomNode provided.
219 /// parent is its parent in the tree (where to insert / remove it)
220 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
223 ///Type definition of the data regarding the tree
224 typedef WxGimmickTreeItemData TreeItemData;
225 ///Gets the item data of the tree item passed as a parameter
226 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
227 ///Type definition of the data insid a node of the tree
228 typedef WxGimmickDicomNodeData NodeData;
231 //====================================================================
233 //====================================================================
237 int mSelectionMaxImageDimension;
238 int mCurrentSelectionImageSize[4];
240 ///Existent Database List
241 DicomDatabaseListType mDicomDatabaseList;
242 ///Favorites database
243 DicomDatabase* mFavoriteDatabase;
245 ///Path to the database list file
246 std::string mDatabaseListFile;
247 ///Extension of the database
248 std::string mDatabaseExtension;
252 int mFirstDicomDatabaseIconIndex;
255 vtkImageViewer2* mViewer;
257 int mx1,mx2,my1,my2,mz1,mz2;
258 double mspx,mspy,mspz;
261 // Multi-thread image reader
262 MultiThreadImageReader mReader;
263 // map of images name to node
264 std::map<std::string,DicomNode*> mImageFileNameToNode;
267 } // EO namespace creaImageIO
269 #endif // USE_WIDGETS