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