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