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 ///Resets the default image
63 void ClearSelection();
66 ///Sends a request to read the currently selected node and the ones that surround it.
67 void ReadImageThreaded(const std::vector<tree::Node*>& sel);
71 /// Creates the tool bar
74 /// Create the tree view for TreeHandler provided
75 /// (overloaded from GimmickView)
76 void CreateTreeView( TreeHandler*, TimestampDatabaseHandler* );
80 /// Is set to true at the end of constructor
81 /// (in order to lock callbacks from threaded objects or event
82 /// before everything is ok)
84 /// The ToolBar and the tools
86 wxToolBarToolBase* mToolAddFile;
87 wxToolBarToolBase* mToolAddDir;
88 wxToolBarToolBase* mToolRemove;
89 wxToolBarToolBase* mToolAddDatabase;
90 wxToolBarToolBase* mToolHelp;
92 wxSplitterWindow* mSplitter;
93 wxPanel* mBottomPanel;
95 wxNotebook* mNotebook;
99 void CreateIconList();
102 /// Callback for adding files
103 void OnAddFiles(wxCommandEvent& event);
104 /// Callback for adding dir
105 void OnAddDir(wxCommandEvent& event);
106 /// Callback for removing files
107 void OnRemove(wxCommandEvent& event);
109 /// Display a message box with the last addition statistics
110 void DisplayAddSummary();
112 /// Test a directory to know if contains sub-directory to analyze
113 bool isNeedRecursive(std::string i_name);
115 /// AddProgress Gimmick callback
116 void OnAddProgress( Gimmick::AddProgress& );
117 /// Called upon to refresh the viewer once there are no actions to be done
118 void OnInternalIdle();
121 wxProgressDialog* mProgressDialog;
122 ///The selection's maximum dimension
123 int mSelectionMaxDimension;
124 ///The selection's minimum dimension
125 int mSelectionMinDimension;
128 ///Currently Displayed Node
129 tree::Node* mCurImageItemToShow;
130 //Pointer holders for images to be shown
131 std::vector<ImagePointerHolder*> pointers;
134 wxString mCurrentDirectory;
136 DECLARE_EVENT_TABLE()
138 // EO class WxGimmickView
139 //=====================================================================
151 //====================================================================
153 //====================================================================
155 /// Returns the size of the current selection
156 virtual int GetSelectionSize() { return 0; }
157 /// Returns true if there is a valid selection
158 virtual bool IsSelectionValid(){ return false; }
159 /// Returns the vector of full filenames of selected images
160 virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
161 /// Returns the vector of images corresponding to selection
162 virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
163 /// Returns the vector of DicomNode corresponding to selection
164 virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
165 /// Returns the DicomNode corresponding to the tree item
166 virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
169 /// Type of list of DicomDatabase
170 typedef std::vector<DicomDatabase*> DicomDatabaseListType;
171 /// Returns the list of DicomDatabase open
172 virtual DicomDatabaseListType& GetDicomDatabaseList()
174 /// Returns the list of DicomDatabase open (const)
175 virtual const DicomDatabaseListType& GetDicomDatabaseList() const
179 ///Opens an existing database, or else, creates a local database.
180 virtual void OpenOrNewDatabase(bool open){ return; }
182 virtual void ShowHelp();
185 ///Gets the extension of the database
186 const std::string& GetDatabaseExtension() { return null; }
187 ///Sets the extension of the database
188 virtual void SetDatabaseExtension(const std::string& ext){ return; }
191 //====================================================================
192 // Preview Display Related
193 //====================================================================
196 ///Shows the image sent as a parameter
198 virtual void ShowImage(vtkImageData* image){ return; }
200 //====================================================================
202 //====================================================================
206 ///Loads or creates a favorites database
207 virtual void LoadOrCreateFavoritesDatabase(){ return; }
209 ///Creates the user settings directory
210 void CreateUserSettingsDirectory(){ return; }
211 ///Obtains the user settings directory
212 const std::string& GetUserSettingsDirectory(){ return null; }
214 //====================================================================
215 // Attribute Display Related
216 //====================================================================
219 ///Shows the Information regarding the node sent as a parameter
221 virtual void ShowInformation(DicomNode*){ return; }
223 //====================================================================
224 // Tree Display Related
225 //====================================================================
228 /// Completely rebuilds the view with
229 /// current DicomDatabaseList
230 virtual void RebuildView(){ return; }
231 /// Recursively updates the part of the view corresponding
232 /// to the DicomDatabase passed
233 /// i.e. creates items for the DicomNode which do not have
234 /// deletes obsolete items (whose DicomNode has been deleted)
235 virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
236 /// Recursively updates the part of the view corresponding
237 /// to the DicomNode provided.
238 /// parent is its parent in the tree (where to insert / remove it)
239 virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
242 ///Type definition of the data regarding the tree
243 typedef WxGimmickTreeItemData TreeItemData;
244 ///Gets the item data of the tree item passed as a parameter
245 TreeItemData* GetItemData(const TreeItemId& id){ return null; }
246 ///Type definition of the data insid a node of the tree
247 typedef WxGimmickDicomNodeData NodeData;
250 //====================================================================
252 //====================================================================
256 int mSelectionMaxImageDimension;
257 int mCurrentSelectionImageSize[4];
259 ///Existent Database List
260 DicomDatabaseListType mDicomDatabaseList;
261 ///Favorites database
262 DicomDatabase* mFavoriteDatabase;
264 ///Path to the database list file
265 std::string mDatabaseListFile;
266 ///Extension of the database
267 std::string mDatabaseExtension;
271 int mFirstDicomDatabaseIconIndex;
274 vtkImageViewer2* mViewer;
276 int mx1,mx2,my1,my2,mz1,mz2;
277 double mspx,mspy,mspz;
280 // Multi-thread image reader
281 MultiThreadImageReader mReader;
282 // map of images name to node
283 std::map<std::string,DicomNode*> mImageFileNameToNode;
286 } // EO namespace creaImageIO
288 #endif // USE_WIDGETS