]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxGimmickView.h
9fd54a963a87d3c56864e781d21576be0943e0c2
[creaImageIO.git] / src2 / creaImageIOWxGimmickView.h
1 #ifndef __creaImageIOWxGimmickView_h_INCLUDED__
2 #define __creaImageIOWxGimmickView_h_INCLUDED__
3
4 #ifdef USE_WXWIDGETS
5
6 #include <creaImageIOGimmickView.h>
7 #include <creaImageIOWxViewer.h>
8 #include <creaWx.h>
9
10 #include <wx/splitter.h>
11 #include <wx/toolbar.h> 
12 #include <wx/tbarbase.h> 
13 #include <wx/notebook.h>
14
15 namespace creaImageIO
16 {
17   /**
18    * \ingroup View
19    */
20   //=====================================================================
21   
22   //=====================================================================
23   /// Concrete derivative of GimmickView which implements a wxWidgets-based view
24
25   class WxGimmickView : public wxPanel, virtual public GimmickView
26     {
27     public:
28           
29       typedef int EventType;
30
31       /// Ctor
32       WxGimmickView(Gimmick*, 
33                     wxWindow *parent, 
34                     const wxWindowID id,
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();
41       
42       /// Returns the selected files
43       ///(overloaded from GimmickView)
44       void GetSelectedFiles(std::vector<std::string>& s);
45       /// Returns the selected Images so that they comply with the given parameter(4D)
46       //(overloaded from GimmickView)
47       void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
48           /// Returns the images indicated by the filenames in the vector so that they comply with the given parameter(dim)
49       //(overloaded from GimmickView) 
50           void GetImages(int dim, std::vector<std::string> files, std::vector<vtkImageData*>& s);
51       /// Callback called when a selection from a TreeView has changed 
52       //(overloaded from GimmickView)
53       void OnSelectionChange(std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess);
54           ///Stops the player
55           void StopPlayer(){mViewer->StopPlayer();}
56           ///Resets the default image
57           void ClearSelection();
58
59
60       ///Sends a request to read the currently selected node and the ones that surround it.
61       void ReadImageThreaded(std::vector<tree::Node*> sel);
62       
63
64     protected:
65       /// Creates the tool bar
66       void CreateToolBar(); 
67
68       /// Create the tree view for TreeHandler provided 
69       /// (overloaded from GimmickView)
70       void CreateTreeView( TreeHandler* );
71
72
73     private:
74       /// Is set to true at the end of constructor 
75       /// (in order to lock callbacks from threaded objects or event 
76       /// before everything is ok)
77       bool mConstructed;
78       /// The ToolBar and the tools
79       wxToolBar*         mToolBar;
80       wxToolBarToolBase* mToolAddFile;
81       wxToolBarToolBase* mToolAddDir;
82       wxToolBarToolBase* mToolRemove;
83       wxToolBarToolBase* mToolAddDatabase;
84       wxToolBarToolBase* mToolHelp;
85
86       wxSplitterWindow* mSplitter;
87       wxPanel*          mBottomPanel;
88           wxStaticText *    mText;
89       wxNotebook*       mNotebook;
90
91       /// The list of icons 
92       wxImageList *    mIcon;
93       void CreateIconList();
94
95       Gimmick * mGimmick;
96       /// Callback for adding files
97       void OnAddFiles(wxCommandEvent& event);
98       /// Callback for adding dir
99       void OnAddDir(wxCommandEvent& event);
100           /// Callback for removing files
101       void OnRemove(wxCommandEvent& event);
102         
103           /// Display a message box with the last addition statistics
104       void DisplayAddSummary();
105
106
107       /// AddProgress Gimmick callback
108       void OnAddProgress( Gimmick::AddProgress& );
109       /// Called upon to refresh the viewer once there are no actions to be done
110       void OnInternalIdle();
111      
112       /// Progress dialog
113       wxProgressDialog* mProgressDialog;
114           ///The selection's maximum dimension
115           int mSelectionMaxDimension;
116           ///The selection's minimum dimension
117           int mSelectionMinDimension;
118           ///Image previewer
119           WxViewer* mViewer;
120           ///Currently Displayed Node
121           tree::Node* mCurImageItemToShow;
122           //Pointer holders for images to be shown
123           std::vector<ImagePointerHolder*> pointers;
124
125
126       wxString mCurrentDirectory;
127
128       DECLARE_EVENT_TABLE()
129    };
130     // EO class WxGimmickView
131     //=====================================================================
132   
133
134   /*
135
136
137
138
139
140
141
142
143         //====================================================================
144         // General
145         //====================================================================
146
147     /// Returns the size of the current selection
148     virtual int GetSelectionSize() { return 0; } 
149     /// Returns true if there is a valid selection
150     virtual bool IsSelectionValid(){ return false; }
151     /// Returns the vector of full filenames of selected images
152     virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
153     /// Returns the vector of images corresponding to selection
154     virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
155     /// Returns the vector of DicomNode corresponding to selection
156     virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
157    /// Returns the DicomNode corresponding to the tree item
158     virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
159
160         
161         /// Type of list of DicomDatabase
162     typedef std::vector<DicomDatabase*> DicomDatabaseListType;
163     /// Returns the list of DicomDatabase open
164     virtual DicomDatabaseListType& GetDicomDatabaseList() 
165     { return null; }
166     /// Returns the list of DicomDatabase open (const)
167     virtual const DicomDatabaseListType& GetDicomDatabaseList() const 
168     { return null; }
169
170         protected:
171         ///Opens an existing database, or else, creates a local database.
172     virtual void OpenOrNewDatabase(bool open){ return; }
173         ///Shows the help
174         virtual void ShowHelp();
175
176         private:
177         ///Gets the extension of the database
178         const std::string& GetDatabaseExtension() { return null; }
179         ///Sets the extension of the database
180     virtual void SetDatabaseExtension(const std::string& ext){ return; }
181
182
183         //====================================================================
184     // Preview Display Related
185         //====================================================================
186
187
188     ///Shows the image sent as a parameter
189         private:
190          virtual void ShowImage(vtkImageData* image){ return; }
191
192         //====================================================================
193     // Favorites Related
194         //====================================================================
195
196
197         public:
198         ///Loads or creates a favorites database
199     virtual void LoadOrCreateFavoritesDatabase(){ return; }
200         private:
201         ///Creates the user settings directory
202     void CreateUserSettingsDirectory(){ return; }
203         ///Obtains the user settings directory
204         const std::string& GetUserSettingsDirectory(){ return null; }
205
206         //====================================================================  
207         // Attribute Display Related
208         //====================================================================
209
210
211         ///Shows the Information regarding the node sent as a parameter
212         private:
213      virtual void ShowInformation(DicomNode*){ return; }
214    
215         //====================================================================
216     // Tree Display Related
217     //====================================================================
218
219         protected:
220     /// Completely rebuilds the view with 
221     /// current DicomDatabaseList
222     virtual void RebuildView(){ return; }
223         /// Recursively updates the part of the view corresponding 
224     /// to the DicomDatabase passed
225     /// i.e. creates items for the DicomNode which do not have
226     ///      deletes obsolete items (whose DicomNode has been deleted)
227     virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
228     /// Recursively updates the part of the view corresponding 
229     /// to the DicomNode provided.
230     /// parent is its parent in the tree (where to insert / remove it)
231         virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
232     
233         private:
234         ///Type definition of the data regarding the tree
235     typedef WxGimmickTreeItemData TreeItemData;
236         ///Gets the item data of the tree item passed as a parameter
237     TreeItemData* GetItemData(const TreeItemId& id){ return null; }
238     ///Type definition of the data insid a node of the tree
239     typedef WxGimmickDicomNodeData NodeData;
240
241
242         //====================================================================
243     // Class Attributes
244     //====================================================================
245
246         
247         int mSelectionType;
248     int mSelectionMaxImageDimension;
249     int mCurrentSelectionImageSize[4];
250
251         ///Existent Database List
252     DicomDatabaseListType mDicomDatabaseList;
253         ///Favorites database
254     DicomDatabase* mFavoriteDatabase;
255
256         ///Path to the database list file
257     std::string mDatabaseListFile;
258         ///Extension of the database
259     std::string mDatabaseExtension;
260
261     bool mJustStarted;
262
263     int  mFirstDicomDatabaseIconIndex;
264
265    // Previewer
266     vtkImageViewer2* mViewer;
267     
268     int mx1,mx2,my1,my2,mz1,mz2;
269     double mspx,mspy,mspz;
270   
271     // Image preview :
272     // Multi-thread image reader
273     MultiThreadImageReader mReader;
274     // map of images name to node
275     std::map<std::string,DicomNode*> mImageFileNameToNode;
276   */
277  
278 } // EO namespace creaImageIO
279
280 #endif // USE_WIDGETS
281 // EOF
282 #endif