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 /// Returns the images indicated by the filenames in the vector so that they comply with the given parameter(dim)
49 //(overloaded from GimmickView)
50 void GetImages(int dim, std::vector<std::string> files, std::vector<vtkImageData*>& s);
51 /// Callback called when a selection from a TreeView has changed
52 //(overloaded from GimmickView)
53 void OnSelectionChange(std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess);
55 void StopPlayer(){mViewer->StopPlayer();}
56 ///Resets the default image
57 void ClearSelection();
60 ///Sends a request to read the currently selected node and the ones that surround it.
61 void ReadImageThreaded(std::vector<tree::Node*> sel);
65 /// Creates the tool bar
68 /// Create the tree view for TreeHandler provided
69 /// (overloaded from GimmickView)
70 void CreateTreeView( TreeHandler* );
74 /// Is set to true at the end of constructor
75 /// (in order to lock callbacks from threaded objects or event
76 /// before everything is ok)
78 /// The ToolBar and the tools
80 wxToolBarToolBase* mToolAddFile;
81 wxToolBarToolBase* mToolAddDir;
82 wxToolBarToolBase* mToolRemove;
83 wxToolBarToolBase* mToolAddDatabase;
84 wxToolBarToolBase* mToolHelp;
86 wxSplitterWindow* mSplitter;
87 wxPanel* mBottomPanel;
89 wxNotebook* mNotebook;
93 void CreateIconList();
96 /// Callback for adding files
97 void OnAddFiles(wxCommandEvent& event);
98 /// Callback for adding dir
99 void OnAddDir(wxCommandEvent& event);
100 /// Callback for removing files
101 void OnRemove(wxCommandEvent& event);
103 /// Display a message box with the last addition statistics
104 void DisplayAddSummary();
107 /// AddProgress Gimmick callback
108 void OnAddProgress( Gimmick::AddProgress& );
109 /// Called upon to refresh the viewer once there are no actions to be done
110 void OnInternalIdle();
113 wxProgressDialog* mProgressDialog;
114 ///The selection's maximum dimension
115 int mSelectionMaxDimension;
116 ///The selection's minimum dimension
117 int mSelectionMinDimension;
120 ///Currently Displayed Node
121 tree::Node* mCurImageItemToShow;
122 //Pointer holders for images to be shown
123 std::vector<ImagePointerHolder*> pointers;
126 wxString mCurrentDirectory;
128 DECLARE_EVENT_TABLE()
130 // EO class WxGimmickView
131 //=====================================================================
143 //====================================================================
145 //====================================================================
147 /// Returns the size of the current selection
148 virtual int GetSelectionSize() { return 0; }
149 /// Returns true if there is a valid selection
150 virtual bool IsSelectionValid(){ return false; }
151 /// Returns the vector of full filenames of selected images
152 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
153 /// Returns the vector of images corresponding to selection
154 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
155 /// Returns the vector of DicomNode corresponding to selection
156 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
157 /// Returns the DicomNode corresponding to the tree item
158 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
161 /// Type of list of DicomDatabase
162 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
163 /// Returns the list of DicomDatabase open
164 virtual DicomDatabaseListType& GetDicomDatabaseList()
166 /// Returns the list of DicomDatabase open (const)
167 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
171 ///Opens an existing database, or else, creates a local database.
172 virtual void OpenOrNewDatabase(bool open){ return; }
174 virtual void ShowHelp();
177 ///Gets the extension of the database
178 const std::string& GetDatabaseExtension() { return null; }
179 ///Sets the extension of the database
180 virtual void SetDatabaseExtension(const std::string& ext){ return; }
183 //====================================================================
184 // Preview Display Related
185 //====================================================================
188 ///Shows the image sent as a parameter
190 virtual void ShowImage(vtkImageData* image){ return; }
192 //====================================================================
194 //====================================================================
198 ///Loads or creates a favorites database
199 virtual void LoadOrCreateFavoritesDatabase(){ return; }
201 ///Creates the user settings directory
202 void CreateUserSettingsDirectory(){ return; }
203 ///Obtains the user settings directory
204 const std::string& GetUserSettingsDirectory(){ return null; }
206 //====================================================================
207 // Attribute Display Related
208 //====================================================================
211 ///Shows the Information regarding the node sent as a parameter
213 virtual void ShowInformation(DicomNode*){ return; }
215 //====================================================================
216 // Tree Display Related
217 //====================================================================
220 /// Completely rebuilds the view with
221 /// current DicomDatabaseList
222 virtual void RebuildView(){ return; }
223 /// Recursively updates the part of the view corresponding
224 /// to the DicomDatabase passed
225 /// i.e. creates items for the DicomNode which do not have
226 /// deletes obsolete items (whose DicomNode has been deleted)
227 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
228 /// Recursively updates the part of the view corresponding
229 /// to the DicomNode provided.
230 /// parent is its parent in the tree (where to insert / remove it)
231 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
234 ///Type definition of the data regarding the tree
235 typedef WxGimmickTreeItemData TreeItemData;
236 ///Gets the item data of the tree item passed as a parameter
237 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
238 ///Type definition of the data insid a node of the tree
239 typedef WxGimmickDicomNodeData NodeData;
242 //====================================================================
244 //====================================================================
248 int mSelectionMaxImageDimension;
249 int mCurrentSelectionImageSize[4];
251 ///Existent Database List
252 DicomDatabaseListType mDicomDatabaseList;
253 ///Favorites database
254 DicomDatabase* mFavoriteDatabase;
256 ///Path to the database list file
257 std::string mDatabaseListFile;
258 ///Extension of the database
259 std::string mDatabaseExtension;
263 int mFirstDicomDatabaseIconIndex;
266 vtkImageViewer2* mViewer;
268 int mx1,mx2,my1,my2,mz1,mz2;
269 double mspx,mspy,mspz;
272 // Multi-thread image reader
273 MultiThreadImageReader mReader;
274 // map of images name to node
275 std::map<std::string,DicomNode*> mImageFileNameToNode;
278 } // EO namespace creaImageIO
280 #endif // USE_WIDGETS