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
25 class WxGimmickView : public wxPanel, virtual public GimmickView
29 typedef int EventType;
32 WxGimmickView(Gimmick*,
35 const wxPoint& pos, const wxSize& size,
36 int min_dim = GIMMICK_2D_IMAGE_SELECTION,
37 int max_dim = GIMMICK_3D_IMAGE_SELECTION,
38 int number_of_threads = 0);
39 /// Virtual destructor
40 virtual ~WxGimmickView();
42 /// Returns the selected files
43 ///(overloaded from GimmickView)
44 void GetSelectedFiles(std::vector<std::string>& s);
45 /// Returns the selected Images so that they comply with the given parameter(4D)
46 //(overloaded from GimmickView)
47 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
48 /// Callback called when a selection from a TreeView has changed
49 //(overloaded from GimmickView)
50 void OnSelectionChange(std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess);
52 void StopPlayer(){mViewer->StopPlayer();}
53 ///Resets the default image
54 void ClearSelection();
57 ///Sends a request to read the currently selected node and the ones that surround it.
58 void ReadImageThreaded(std::vector<tree::Node*> sel);
62 /// Creates the tool bar
65 /// Create the tree view for TreeHandler provided
66 /// (overloaded from GimmickView)
67 void CreateTreeView( TreeHandler* );
71 /// Is set to true at the end of constructor
72 /// (in order to lock callbacks from threaded objects or event
73 /// before everything is ok)
75 /// The ToolBar and the tools
77 wxToolBarToolBase* mToolAddFile;
78 wxToolBarToolBase* mToolAddDir;
79 wxToolBarToolBase* mToolRemove;
80 wxToolBarToolBase* mToolAddDatabase;
81 wxToolBarToolBase* mToolHelp;
83 wxSplitterWindow* mSplitter;
84 wxPanel* mBottomPanel;
86 wxNotebook* mNotebook;
90 void CreateIconList();
93 /// Callback for adding files
94 void OnAddFiles(wxCommandEvent& event);
95 /// Callback for adding dir
96 void OnAddDir(wxCommandEvent& event);
97 /// Callback for removing files
98 void OnRemove(wxCommandEvent& event);
100 /// Display a message box with the last addition statistics
101 void DisplayAddSummary();
104 /// AddProgress Gimmick callback
105 void OnAddProgress( Gimmick::AddProgress& );
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;
119 //Pointer holders for images to be shown
120 std::vector<ImagePointerHolder*> pointers;
123 wxString mCurrentDirectory;
125 DECLARE_EVENT_TABLE()
127 // EO class WxGimmickView
128 //=====================================================================
140 //====================================================================
142 //====================================================================
144 /// Returns the size of the current selection
145 virtual int GetSelectionSize() { return 0; }
146 /// Returns true if there is a valid selection
147 virtual bool IsSelectionValid(){ return false; }
148 /// Returns the vector of full filenames of selected images
149 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
150 /// Returns the vector of images corresponding to selection
151 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
152 /// Returns the vector of DicomNode corresponding to selection
153 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
154 /// Returns the DicomNode corresponding to the tree item
155 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
158 /// Type of list of DicomDatabase
159 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
160 /// Returns the list of DicomDatabase open
161 virtual DicomDatabaseListType& GetDicomDatabaseList()
163 /// Returns the list of DicomDatabase open (const)
164 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
168 ///Opens an existing database, or else, creates a local database.
169 virtual void OpenOrNewDatabase(bool open){ return; }
171 virtual void ShowHelp();
174 ///Gets the extension of the database
175 const std::string& GetDatabaseExtension() { return null; }
176 ///Sets the extension of the database
177 virtual void SetDatabaseExtension(const std::string& ext){ return; }
180 //====================================================================
181 // Preview Display Related
182 //====================================================================
185 ///Shows the image sent as a parameter
187 virtual void ShowImage(vtkImageData* image){ return; }
189 //====================================================================
191 //====================================================================
195 ///Loads or creates a favorites database
196 virtual void LoadOrCreateFavoritesDatabase(){ return; }
198 ///Creates the user settings directory
199 void CreateUserSettingsDirectory(){ return; }
200 ///Obtains the user settings directory
201 const std::string& GetUserSettingsDirectory(){ return null; }
203 //====================================================================
204 // Attribute Display Related
205 //====================================================================
208 ///Shows the Information regarding the node sent as a parameter
210 virtual void ShowInformation(DicomNode*){ return; }
212 //====================================================================
213 // Tree Display Related
214 //====================================================================
217 /// Completely rebuilds the view with
218 /// current DicomDatabaseList
219 virtual void RebuildView(){ return; }
220 /// Recursively updates the part of the view corresponding
221 /// to the DicomDatabase passed
222 /// i.e. creates items for the DicomNode which do not have
223 /// deletes obsolete items (whose DicomNode has been deleted)
224 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
225 /// Recursively updates the part of the view corresponding
226 /// to the DicomNode provided.
227 /// parent is its parent in the tree (where to insert / remove it)
228 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
231 ///Type definition of the data regarding the tree
232 typedef WxGimmickTreeItemData TreeItemData;
233 ///Gets the item data of the tree item passed as a parameter
234 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
235 ///Type definition of the data insid a node of the tree
236 typedef WxGimmickDicomNodeData NodeData;
239 //====================================================================
241 //====================================================================
245 int mSelectionMaxImageDimension;
246 int mCurrentSelectionImageSize[4];
248 ///Existent Database List
249 DicomDatabaseListType mDicomDatabaseList;
250 ///Favorites database
251 DicomDatabase* mFavoriteDatabase;
253 ///Path to the database list file
254 std::string mDatabaseListFile;
255 ///Extension of the database
256 std::string mDatabaseExtension;
260 int mFirstDicomDatabaseIconIndex;
263 vtkImageViewer2* mViewer;
265 int mx1,mx2,my1,my2,mz1,mz2;
266 double mspx,mspy,mspz;
269 // Multi-thread image reader
270 MultiThreadImageReader mReader;
271 // map of images name to node
272 std::map<std::string,DicomNode*> mImageFileNameToNode;
275 } // EO namespace creaImageIO
277 #endif // USE_WIDGETS