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();
66 ///Copies selected files
67 void CopyFiles(const std::vector<std::string>& filenames);
70 ///Sends a request to read the currently selected node and the ones that surround it.
71 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
75 /// Creates the tool bar
78 /// Create the tree view for TreeHandler provided
79 /// (overloaded from GimmickView)
80 void CreateTreeView( TreeHandler* );
84 /// Is set to true at the end of constructor
85 /// (in order to lock callbacks from threaded objects or event
86 /// before everything is ok)
88 /// The ToolBar and the tools
90 wxToolBarToolBase* mToolAddFile;
91 wxToolBarToolBase* mToolAddDir;
92 wxToolBarToolBase* mToolRemove;
93 wxToolBarToolBase* mToolAddDatabase;
94 wxToolBarToolBase* mToolHelp;
95 wxToolBarToolBase* mToolSynchronize;
97 wxSplitterWindow* mSplitter;
98 wxPanel* mBottomPanel;
100 wxNotebook* mNotebook;
102 /// The list of icons
104 void CreateIconList();
107 /// Callback for adding files
108 void OnAddFiles(wxCommandEvent& event);
109 /// Callback for adding dir
110 void OnAddDir(wxCommandEvent& event);
111 /// Callback for removing files
112 void OnRemove(wxCommandEvent& event);
113 /// Callback for removing files
114 void OnSynchronize(wxCommandEvent& event);
116 /// Display a message box with the last addition statistics
117 void DisplayAddSummary();
119 /// Test a directory to know if contains sub-directory to analyze
120 bool isNeedRecursive(std::string i_name);
122 /// AddProgress Gimmick callback
123 void OnAddProgress( Gimmick::AddProgress& );
124 /// Called upon to refresh the viewer once there are no actions to be done
125 void OnInternalIdle();
127 // callback to add a database
128 void OnAddDB(wxCommandEvent& event);
130 //Create a DB from an Attributes Descriptor files
131 void OnCreateDB(wxCommandEvent& event);
134 wxProgressDialog* mProgressDialog;
135 ///The selection's maximum dimension
136 int mSelectionMaxDimension;
137 ///The selection's minimum dimension
138 int mSelectionMinDimension;
141 ///Currently Displayed Node
142 tree::Node* mCurImageItemToShow;
143 //Pointer holders for images to be shown
144 std::vector<ImagePointerHolder*> pointers;
147 wxString mCurrentDirectory;
149 DECLARE_EVENT_TABLE()
151 // EO class WxGimmickView
152 //=====================================================================
164 //====================================================================
166 //====================================================================
168 /// Returns the size of the current selection
169 virtual int GetSelectionSize() { return 0; }
170 /// Returns true if there is a valid selection
171 virtual bool IsSelectionValid(){ return false; }
172 /// Returns the vector of full filenames of selected images
173 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
174 /// Returns the vector of images corresponding to selection
175 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
176 /// Returns the vector of DicomNode corresponding to selection
177 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
178 /// Returns the DicomNode corresponding to the tree item
179 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
182 /// Type of list of DicomDatabase
183 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
184 /// Returns the list of DicomDatabase open
185 virtual DicomDatabaseListType& GetDicomDatabaseList()
187 /// Returns the list of DicomDatabase open (const)
188 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
192 ///Opens an existing database, or else, creates a local database.
193 virtual void OpenOrNewDatabase(bool open){ return; }
195 virtual void ShowHelp();
198 ///Gets the extension of the database
199 const std::string& GetDatabaseExtension() { return null; }
200 ///Sets the extension of the database
201 virtual void SetDatabaseExtension(const std::string& ext){ return; }
204 //====================================================================
205 // Preview Display Related
206 //====================================================================
209 ///Shows the image sent as a parameter
211 virtual void ShowImage(vtkImageData* image){ return; }
213 //====================================================================
215 //====================================================================
219 ///Loads or creates a favorites database
220 virtual void LoadOrCreateFavoritesDatabase(){ return; }
222 ///Creates the user settings directory
223 void CreateUserSettingsDirectory(){ return; }
224 ///Obtains the user settings directory
225 const std::string& GetUserSettingsDirectory(){ return null; }
227 //====================================================================
228 // Attribute Display Related
229 //====================================================================
232 ///Shows the Information regarding the node sent as a parameter
234 virtual void ShowInformation(DicomNode*){ return; }
236 //====================================================================
237 // Tree Display Related
238 //====================================================================
241 /// Completely rebuilds the view with
242 /// current DicomDatabaseList
243 virtual void RebuildView(){ return; }
244 /// Recursively updates the part of the view corresponding
245 /// to the DicomDatabase passed
246 /// i.e. creates items for the DicomNode which do not have
247 /// deletes obsolete items (whose DicomNode has been deleted)
248 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
249 /// Recursively updates the part of the view corresponding
250 /// to the DicomNode provided.
251 /// parent is its parent in the tree (where to insert / remove it)
252 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
255 ///Type definition of the data regarding the tree
256 typedef WxGimmickTreeItemData TreeItemData;
257 ///Gets the item data of the tree item passed as a parameter
258 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
259 ///Type definition of the data insid a node of the tree
260 typedef WxGimmickDicomNodeData NodeData;
263 //====================================================================
265 //====================================================================
269 int mSelectionMaxImageDimension;
270 int mCurrentSelectionImageSize[4];
272 ///Existent Database List
273 DicomDatabaseListType mDicomDatabaseList;
274 ///Favorites database
275 DicomDatabase* mFavoriteDatabase;
277 ///Path to the database list file
278 std::string mDatabaseListFile;
279 ///Extension of the database
280 std::string mDatabaseExtension;
284 int mFirstDicomDatabaseIconIndex;
287 vtkImageViewer2* mViewer;
289 int mx1,mx2,my1,my2,mz1,mz2;
290 double mspx,mspy,mspz;
293 // Multi-thread image reader
294 MultiThreadImageReader mReader;
295 // map of images name to node
296 std::map<std::string,DicomNode*> mImageFileNameToNode;
299 } // EO namespace creaImageIO
301 #endif // USE_WIDGETS