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;
96 wxToolBarToolBase* mToolSettings;
97 wxToolBarToolBase* mToolTools;
99 wxSplitterWindow* mSplitter;
100 wxPanel* mBottomPanel;
101 wxStaticText * mText;
102 wxNotebook* mNotebook;
104 /// The list of icons
106 void CreateIconList();
109 /// Callback for adding files
110 void OnAddFiles(wxCommandEvent& event);
111 /// Callback for adding dir
112 void OnAddDir(wxCommandEvent& event);
113 /// Callback for removing files
114 void OnRemove(wxCommandEvent& event);
115 /// Callback for synchronization
116 void OnSynchronize(wxCommandEvent& event);
117 /// Callback for settings edition
118 void OnSettings(wxCommandEvent& event);
119 /// Callback for settings edition
120 void OnTools(wxCommandEvent& event);
121 ///Creates the settings dialog (the pages inside and the information)
122 void CreateSettingsDialog(wxNotebook* nb);
124 /// Display a message box with the last addition statistics
125 void DisplayAddSummary();
127 /// Test a directory to know if contains sub-directory to analyze
128 bool isNeedRecursive(std::string i_name);
130 /// AddProgress Gimmick callback
131 void OnAddProgress( Gimmick::AddProgress& );
132 /// Called upon to refresh the viewer once there are no actions to be done
133 void OnInternalIdle();
135 // callback to add a database
136 void OnAddDB(wxCommandEvent& event);
138 //Create a DB from an Attributes Descriptor files
139 void OnCreateDB(wxCommandEvent& event);
142 wxProgressDialog* mProgressDialog;
143 ///The selection's maximum dimension
144 int mSelectionMaxDimension;
145 ///The selection's minimum dimension
146 int mSelectionMinDimension;
149 ///Currently Displayed Node
150 tree::Node* mCurImageItemToShow;
151 //Pointer holders for images to be shown
152 std::vector<ImagePointerHolder*> pointers;
155 wxString mCurrentDirectory;
157 DECLARE_EVENT_TABLE()
159 // EO class WxGimmickView
160 //=====================================================================
172 //====================================================================
174 //====================================================================
176 /// Returns the size of the current selection
177 virtual int GetSelectionSize() { return 0; }
178 /// Returns true if there is a valid selection
179 virtual bool IsSelectionValid(){ return false; }
180 /// Returns the vector of full filenames of selected images
181 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
182 /// Returns the vector of images corresponding to selection
183 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
184 /// Returns the vector of DicomNode corresponding to selection
185 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
186 /// Returns the DicomNode corresponding to the tree item
187 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
190 /// Type of list of DicomDatabase
191 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
192 /// Returns the list of DicomDatabase open
193 virtual DicomDatabaseListType& GetDicomDatabaseList()
195 /// Returns the list of DicomDatabase open (const)
196 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
200 ///Opens an existing database, or else, creates a local database.
201 virtual void OpenOrNewDatabase(bool open){ return; }
203 virtual void ShowHelp();
206 ///Gets the extension of the database
207 const std::string& GetDatabaseExtension() { return null; }
208 ///Sets the extension of the database
209 virtual void SetDatabaseExtension(const std::string& ext){ return; }
212 //====================================================================
213 // Preview Display Related
214 //====================================================================
217 ///Shows the image sent as a parameter
219 virtual void ShowImage(vtkImageData* image){ return; }
221 //====================================================================
223 //====================================================================
227 ///Loads or creates a favorites database
228 virtual void LoadOrCreateFavoritesDatabase(){ return; }
230 ///Creates the user settings directory
231 void CreateUserSettingsDirectory(){ return; }
232 ///Obtains the user settings directory
233 const std::string& GetUserSettingsDirectory(){ return null; }
235 //====================================================================
236 // Attribute Display Related
237 //====================================================================
240 ///Shows the Information regarding the node sent as a parameter
242 virtual void ShowInformation(DicomNode*){ return; }
244 //====================================================================
245 // Tree Display Related
246 //====================================================================
249 /// Completely rebuilds the view with
250 /// current DicomDatabaseList
251 virtual void RebuildView(){ return; }
252 /// Recursively updates the part of the view corresponding
253 /// to the DicomDatabase passed
254 /// i.e. creates items for the DicomNode which do not have
255 /// deletes obsolete items (whose DicomNode has been deleted)
256 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
257 /// Recursively updates the part of the view corresponding
258 /// to the DicomNode provided.
259 /// parent is its parent in the tree (where to insert / remove it)
260 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
263 ///Type definition of the data regarding the tree
264 typedef WxGimmickTreeItemData TreeItemData;
265 ///Gets the item data of the tree item passed as a parameter
266 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
267 ///Type definition of the data insid a node of the tree
268 typedef WxGimmickDicomNodeData NodeData;
271 //====================================================================
273 //====================================================================
277 int mSelectionMaxImageDimension;
278 int mCurrentSelectionImageSize[4];
280 ///Existent Database List
281 DicomDatabaseListType mDicomDatabaseList;
282 ///Favorites database
283 DicomDatabase* mFavoriteDatabase;
285 ///Path to the database list file
286 std::string mDatabaseListFile;
287 ///Extension of the database
288 std::string mDatabaseExtension;
292 int mFirstDicomDatabaseIconIndex;
295 vtkImageViewer2* mViewer;
297 int mx1,mx2,my1,my2,mz1,mz2;
298 double mspx,mspy,mspz;
301 // Multi-thread image reader
302 MultiThreadImageReader mReader;
303 // map of images name to node
304 std::map<std::string,DicomNode*> mImageFileNameToNode;
307 } // EO namespace creaImageIO
309 #endif // USE_WIDGETS