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