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