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(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);
128 //Create a DB from an Attributes Descriptor files
129 void OnCreateDB(wxCommandEvent& event);
132 wxProgressDialog* mProgressDialog;
133 ///The selection's maximum dimension
134 int mSelectionMaxDimension;
135 ///The selection's minimum dimension
136 int mSelectionMinDimension;
139 ///Currently Displayed Node
140 tree::Node* mCurImageItemToShow;
141 //Pointer holders for images to be shown
142 std::vector<ImagePointerHolder*> pointers;
145 wxString mCurrentDirectory;
147 DECLARE_EVENT_TABLE()
149 // EO class WxGimmickView
150 //=====================================================================
162 //====================================================================
164 //====================================================================
166 /// Returns the size of the current selection
167 virtual int GetSelectionSize() { return 0; }
168 /// Returns true if there is a valid selection
169 virtual bool IsSelectionValid(){ return false; }
170 /// Returns the vector of full filenames of selected images
171 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
172 /// Returns the vector of images corresponding to selection
173 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
174 /// Returns the vector of DicomNode corresponding to selection
175 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
176 /// Returns the DicomNode corresponding to the tree item
177 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
180 /// Type of list of DicomDatabase
181 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
182 /// Returns the list of DicomDatabase open
183 virtual DicomDatabaseListType& GetDicomDatabaseList()
185 /// Returns the list of DicomDatabase open (const)
186 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
190 ///Opens an existing database, or else, creates a local database.
191 virtual void OpenOrNewDatabase(bool open){ return; }
193 virtual void ShowHelp();
196 ///Gets the extension of the database
197 const std::string& GetDatabaseExtension() { return null; }
198 ///Sets the extension of the database
199 virtual void SetDatabaseExtension(const std::string& ext){ return; }
202 //====================================================================
203 // Preview Display Related
204 //====================================================================
207 ///Shows the image sent as a parameter
209 virtual void ShowImage(vtkImageData* image){ return; }
211 //====================================================================
213 //====================================================================
217 ///Loads or creates a favorites database
218 virtual void LoadOrCreateFavoritesDatabase(){ return; }
220 ///Creates the user settings directory
221 void CreateUserSettingsDirectory(){ return; }
222 ///Obtains the user settings directory
223 const std::string& GetUserSettingsDirectory(){ return null; }
225 //====================================================================
226 // Attribute Display Related
227 //====================================================================
230 ///Shows the Information regarding the node sent as a parameter
232 virtual void ShowInformation(DicomNode*){ return; }
234 //====================================================================
235 // Tree Display Related
236 //====================================================================
239 /// Completely rebuilds the view with
240 /// current DicomDatabaseList
241 virtual void RebuildView(){ return; }
242 /// Recursively updates the part of the view corresponding
243 /// to the DicomDatabase passed
244 /// i.e. creates items for the DicomNode which do not have
245 /// deletes obsolete items (whose DicomNode has been deleted)
246 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
247 /// Recursively updates the part of the view corresponding
248 /// to the DicomNode provided.
249 /// parent is its parent in the tree (where to insert / remove it)
250 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
253 ///Type definition of the data regarding the tree
254 typedef WxGimmickTreeItemData TreeItemData;
255 ///Gets the item data of the tree item passed as a parameter
256 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
257 ///Type definition of the data insid a node of the tree
258 typedef WxGimmickDicomNodeData NodeData;
261 //====================================================================
263 //====================================================================
267 int mSelectionMaxImageDimension;
268 int mCurrentSelectionImageSize[4];
270 ///Existent Database List
271 DicomDatabaseListType mDicomDatabaseList;
272 ///Favorites database
273 DicomDatabase* mFavoriteDatabase;
275 ///Path to the database list file
276 std::string mDatabaseListFile;
277 ///Extension of the database
278 std::string mDatabaseExtension;
282 int mFirstDicomDatabaseIconIndex;
285 vtkImageViewer2* mViewer;
287 int mx1,mx2,my1,my2,mz1,mz2;
288 double mspx,mspy,mspz;
291 // Multi-thread image reader
292 MultiThreadImageReader mReader;
293 // map of images name to node
294 std::map<std::string,DicomNode*> mImageFileNameToNode;
297 } // EO namespace creaImageIO
299 #endif // USE_WIDGETS