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