]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxGimmickView.h
314d1720b414b32bc66725f19e8d8e7ab9d54ed2
[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       /// Callback called when a selection from a TreeView has changed 
49       //(overloaded from GimmickView)
50       void OnSelectionChange(std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess);
51           ///Stops the player
52           void StopPlayer(){mViewer->StopPlayer();}
53           ///Resets the default image
54           void ClearSelection();
55
56
57       ///Sends a request to read the currently selected node and the ones that surround it.
58       void ReadImageThreaded(std::vector<tree::Node*> sel);
59       
60
61     protected:
62       /// Creates the tool bar
63       void CreateToolBar(); 
64
65       /// Create the tree view for TreeHandler provided 
66       /// (overloaded from GimmickView)
67       void CreateTreeView( TreeHandler* );
68
69
70     private:
71       /// Is set to true at the end of constructor 
72       /// (in order to lock callbacks from threaded objects or event 
73       /// before everything is ok)
74       bool mConstructed;
75       /// The ToolBar and the tools
76       wxToolBar*         mToolBar;
77       wxToolBarToolBase* mToolAddFile;
78       wxToolBarToolBase* mToolAddDir;
79       wxToolBarToolBase* mToolRemove;
80       wxToolBarToolBase* mToolAddDatabase;
81       wxToolBarToolBase* mToolHelp;
82
83       wxSplitterWindow* mSplitter;
84       wxPanel*          mBottomPanel;
85           wxStaticText *    mText;
86       wxNotebook*       mNotebook;
87
88       /// The list of icons 
89       wxImageList *    mIcon;
90       void CreateIconList();
91
92       Gimmick * mGimmick;
93       /// Callback for adding files
94       void OnAddFiles(wxCommandEvent& event);
95       /// Callback for adding dir
96       void OnAddDir(wxCommandEvent& event);
97           /// Callback for removing files
98       void OnRemove(wxCommandEvent& event);
99         
100           /// Display a message box with the last addition statistics
101       void DisplayAddSummary();
102
103
104       /// AddProgress Gimmick callback
105       void OnAddProgress( Gimmick::AddProgress& );
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           //Pointer holders for images to be shown
120           std::vector<ImagePointerHolder*> pointers;
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