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