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);
46 /// Returns the selected Images so that they comply with the
47 /// given parameter(4D) (overloaded from GimmickView)
48 void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
50 /// Returns the images indicated by the filenames in the vector
51 /// so that they comply with the given parameter(dim)
52 //(overloaded from GimmickView)
53 void GetImages(int dim, const std::vector<std::string>& files,
54 std::vector<vtkImageData*>& s);
56 /// Callback called when a selection from a TreeView has changed
57 //(overloaded from GimmickView)
58 void OnSelectionChange(const std::vector<tree::Node*>& s,
59 bool isSelection, int selection, bool mProcess);
61 void StopPlayer(){mViewer->StopPlayer();}
62 ///Adds a file to ignore
63 void AddIgnoreFile(const tree::Node* & toRemove);
64 ///Resets the default image
65 void ClearSelection();
68 ///Sends a request to read the currently selected node and the ones that surround it.
69 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
73 /// Creates the tool bar
76 /// Create the tree view for TreeHandler provided
77 /// (overloaded from GimmickView)
78 void CreateTreeView( TreeHandler* );
82 /// Is set to true at the end of constructor
83 /// (in order to lock callbacks from threaded objects or event
84 /// before everything is ok)
86 /// The ToolBar and the tools
88 wxToolBarToolBase* mToolAddFile;
89 wxToolBarToolBase* mToolAddDir;
90 wxToolBarToolBase* mToolRemove;
91 wxToolBarToolBase* mToolAddDatabase;
92 wxToolBarToolBase* mToolHelp;
93 wxToolBarToolBase* mToolSynchronize;
95 wxSplitterWindow* mSplitter;
96 wxPanel* mBottomPanel;
98 wxNotebook* mNotebook;
100 /// The list of icons
102 void CreateIconList();
105 /// Callback for adding files
106 void OnAddFiles(wxCommandEvent& event);
107 /// Callback for adding dir
108 void OnAddDir(wxCommandEvent& event);
109 /// Callback for removing files
110 void OnRemove(wxCommandEvent& event);
111 /// Callback for removing files
112 void OnSynchronize(wxCommandEvent& event);
114 /// Display a message box with the last addition statistics
115 void DisplayAddSummary();
117 /// Test a directory to know if contains sub-directory to analyze
118 bool isNeedRecursive(std::string i_name);
120 /// AddProgress Gimmick callback
121 void OnAddProgress( Gimmick::AddProgress& );
122 /// Called upon to refresh the viewer once there are no actions to be done
123 void OnInternalIdle();
125 // callback to add a database
126 void OnAddDB(wxCommandEvent& event);
129 wxProgressDialog* mProgressDialog;
130 ///The selection's maximum dimension
131 int mSelectionMaxDimension;
132 ///The selection's minimum dimension
133 int mSelectionMinDimension;
136 ///Currently Displayed Node
137 tree::Node* mCurImageItemToShow;
138 //Pointer holders for images to be shown
139 std::vector<ImagePointerHolder*> pointers;
142 wxString mCurrentDirectory;
144 DECLARE_EVENT_TABLE()
146 // EO class WxGimmickView
147 //=====================================================================
159 //====================================================================
161 //====================================================================
163 /// Returns the size of the current selection
164 virtual int GetSelectionSize() { return 0; }
165 /// Returns true if there is a valid selection
166 virtual bool IsSelectionValid(){ return false; }
167 /// Returns the vector of full filenames of selected images
168 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
169 /// Returns the vector of images corresponding to selection
170 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
171 /// Returns the vector of DicomNode corresponding to selection
172 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
173 /// Returns the DicomNode corresponding to the tree item
174 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
177 /// Type of list of DicomDatabase
178 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
179 /// Returns the list of DicomDatabase open
180 virtual DicomDatabaseListType& GetDicomDatabaseList()
182 /// Returns the list of DicomDatabase open (const)
183 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
187 ///Opens an existing database, or else, creates a local database.
188 virtual void OpenOrNewDatabase(bool open){ return; }
190 virtual void ShowHelp();
193 ///Gets the extension of the database
194 const std::string& GetDatabaseExtension() { return null; }
195 ///Sets the extension of the database
196 virtual void SetDatabaseExtension(const std::string& ext){ return; }
199 //====================================================================
200 // Preview Display Related
201 //====================================================================
204 ///Shows the image sent as a parameter
206 virtual void ShowImage(vtkImageData* image){ return; }
208 //====================================================================
210 //====================================================================
214 ///Loads or creates a favorites database
215 virtual void LoadOrCreateFavoritesDatabase(){ return; }
217 ///Creates the user settings directory
218 void CreateUserSettingsDirectory(){ return; }
219 ///Obtains the user settings directory
220 const std::string& GetUserSettingsDirectory(){ return null; }
222 //====================================================================
223 // Attribute Display Related
224 //====================================================================
227 ///Shows the Information regarding the node sent as a parameter
229 virtual void ShowInformation(DicomNode*){ return; }
231 //====================================================================
232 // Tree Display Related
233 //====================================================================
236 /// Completely rebuilds the view with
237 /// current DicomDatabaseList
238 virtual void RebuildView(){ return; }
239 /// Recursively updates the part of the view corresponding
240 /// to the DicomDatabase passed
241 /// i.e. creates items for the DicomNode which do not have
242 /// deletes obsolete items (whose DicomNode has been deleted)
243 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
244 /// Recursively updates the part of the view corresponding
245 /// to the DicomNode provided.
246 /// parent is its parent in the tree (where to insert / remove it)
247 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
250 ///Type definition of the data regarding the tree
251 typedef WxGimmickTreeItemData TreeItemData;
252 ///Gets the item data of the tree item passed as a parameter
253 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
254 ///Type definition of the data insid a node of the tree
255 typedef WxGimmickDicomNodeData NodeData;
258 //====================================================================
260 //====================================================================
264 int mSelectionMaxImageDimension;
265 int mCurrentSelectionImageSize[4];
267 ///Existent Database List
268 DicomDatabaseListType mDicomDatabaseList;
269 ///Favorites database
270 DicomDatabase* mFavoriteDatabase;
272 ///Path to the database list file
273 std::string mDatabaseListFile;
274 ///Extension of the database
275 std::string mDatabaseExtension;
279 int mFirstDicomDatabaseIconIndex;
282 vtkImageViewer2* mViewer;
284 int mx1,mx2,my1,my2,mz1,mz2;
285 double mspx,mspy,mspz;
288 // Multi-thread image reader
289 MultiThreadImageReader mReader;
290 // map of images name to node
291 std::map<std::string,DicomNode*> mImageFileNameToNode;
294 } // EO namespace creaImageIO
296 #endif // USE_WIDGETS