]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxGimmickView.h
235c8f0cd1f4619369e32205b328548a4efa3299
[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 <creaWx.h>
8
9 #include <wx/splitter.h>
10 #include <wx/toolbar.h> 
11 #include <wx/tbarbase.h> 
12 #include <wx/notebook.h>
13
14 namespace creaImageIO
15 {
16   /**
17    * \ingroup View
18    */
19   //=====================================================================
20   
21   //=====================================================================
22   /// Concrete derivative of GimmickView which implements a wxWidgets-based view
23   class WxGimmickView : public wxPanel, virtual public GimmickView
24     {
25     public:
26       typedef int EventType;
27
28       /// Ctor
29       WxGimmickView(Gimmick*, 
30                     wxWindow *parent, 
31                     const wxWindowID id,
32                     const wxPoint& pos, const wxSize& size,
33                     int min_dim = GIMMICK_2D_IMAGE_SELECTION,
34                         int max_dim = GIMMICK_3D_IMAGE_SELECTION,
35                         int out_dim = NATIVE,
36                     int number_of_threads = 0);
37       /// Virtual destructor
38       virtual ~WxGimmickView();
39
40           /// Returns the selected Images so that they comply with the given parameter(<4D)
41           ///(overloaded from GimmickView)
42           vtkImageData* GetSelectedImage(int dim);
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
47     protected:
48       /// Creates the tool bar
49       void CreateToolBar(); 
50
51       /// Create the tree view for TreeHandler provided 
52       /// (overloaded from GimmickView)
53       void CreateTreeView( TreeHandler* );
54
55
56     private:
57       /// The ToolBar and the tools
58       wxToolBar*         mToolBar;
59       wxToolBarToolBase* mToolAddFile;
60       wxToolBarToolBase* mToolAddDir;
61       wxToolBarToolBase* mToolRemove;
62       wxToolBarToolBase* mToolAddDatabase;
63       wxToolBarToolBase* mToolHelp;
64
65       wxSplitterWindow* mSplitter;
66       wxPanel*          mBottomPanel;
67       wxNotebook*       mNotebook;
68
69       /// The list of icons 
70       wxImageList *    mIcon;
71       void CreateIconList();
72
73       Gimmick * mGimmick;
74       /// Callback for adding files
75       void OnAddFiles(wxCommandEvent& event);
76       /// Callback for adding dir
77       void OnAddDir(wxCommandEvent& event);
78           /// Callback for removing files
79       void OnRemove(wxCommandEvent& event);
80       /// Display a message box with the last addition statistics
81       void DisplayAddSummary();
82
83
84       /// AddProgress Gimmick callback
85       void OnAddProgress( Gimmick::AddProgress& );
86       /// Progress dialog
87       wxProgressDialog* mProgressDialog;
88           //The selection's maximum dimension
89           int mSelectionMaxDimension;
90           //The selection's minimum dimension
91           int mSelectionMinDimension;
92           //The user desired output dimension
93           int mOutputDimension;
94
95
96       wxString mCurrentDirectory;
97
98       DECLARE_EVENT_TABLE()
99    };
100     // EO class WxGimmickView
101     //=====================================================================
102   
103
104   /*
105
106
107
108
109
110
111
112
113         //====================================================================
114         // General
115         //====================================================================
116
117     /// Returns the size of the current selection
118     virtual int GetSelectionSize() { return 0; } 
119     /// Returns true if there is a valid selection
120     virtual bool IsSelectionValid(){ return false; }
121     /// Returns the vector of full filenames of selected images
122     virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
123     /// Returns the vector of images corresponding to selection
124     virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
125     /// Returns the vector of DicomNode corresponding to selection
126     virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
127    /// Returns the DicomNode corresponding to the tree item
128     virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
129
130         
131         /// Type of list of DicomDatabase
132     typedef std::vector<DicomDatabase*> DicomDatabaseListType;
133     /// Returns the list of DicomDatabase open
134     virtual DicomDatabaseListType& GetDicomDatabaseList() 
135     { return null; }
136     /// Returns the list of DicomDatabase open (const)
137     virtual const DicomDatabaseListType& GetDicomDatabaseList() const 
138     { return null; }
139
140         protected:
141         ///Opens an existing database, or else, creates a local database.
142     virtual void OpenOrNewDatabase(bool open){ return; }
143         ///Shows the help
144         virtual void ShowHelp();
145
146         private:
147         ///Gets the extension of the database
148         const std::string& GetDatabaseExtension() { return null; }
149         ///Sets the extension of the database
150     virtual void SetDatabaseExtension(const std::string& ext){ return; }
151
152
153         //====================================================================
154     // Preview Display Related
155         //====================================================================
156
157
158     ///Shows the image sent as a parameter
159         private:
160          virtual void ShowImage(vtkImageData* image){ return; }
161
162         //====================================================================
163     // Favorites Related
164         //====================================================================
165
166
167         public:
168         ///Loads or creates a favorites database
169     virtual void LoadOrCreateFavoritesDatabase(){ return; }
170         private:
171         ///Creates the user settings directory
172     void CreateUserSettingsDirectory(){ return; }
173         ///Obtains the user settings directory
174         const std::string& GetUserSettingsDirectory(){ return null; }
175
176         //====================================================================  
177         // Attribute Display Related
178         //====================================================================
179
180
181         ///Shows the Information regarding the node sent as a parameter
182         private:
183      virtual void ShowInformation(DicomNode*){ return; }
184    
185         //====================================================================
186     // Tree Display Related
187     //====================================================================
188
189         protected:
190     /// Completely rebuilds the view with 
191     /// current DicomDatabaseList
192     virtual void RebuildView(){ return; }
193         /// Recursively updates the part of the view corresponding 
194     /// to the DicomDatabase passed
195     /// i.e. creates items for the DicomNode which do not have
196     ///      deletes obsolete items (whose DicomNode has been deleted)
197     virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
198     /// Recursively updates the part of the view corresponding 
199     /// to the DicomNode provided.
200     /// parent is its parent in the tree (where to insert / remove it)
201         virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
202     
203         private:
204         ///Type definition of the data regarding the tree
205     typedef WxGimmickTreeItemData TreeItemData;
206         ///Gets the item data of the tree item passed as a parameter
207     TreeItemData* GetItemData(const TreeItemId& id){ return null; }
208     ///Type definition of the data insid a node of the tree
209     typedef WxGimmickDicomNodeData NodeData;
210
211
212         //====================================================================
213     // Class Attributes
214     //====================================================================
215
216         
217         int mSelectionType;
218     int mSelectionMaxImageDimension;
219     int mCurrentSelectionImageSize[4];
220
221         ///Existent Database List
222     DicomDatabaseListType mDicomDatabaseList;
223         ///Favorites database
224     DicomDatabase* mFavoriteDatabase;
225
226         ///Path to the database list file
227     std::string mDatabaseListFile;
228         ///Extension of the database
229     std::string mDatabaseExtension;
230
231     bool mJustStarted;
232
233     int  mFirstDicomDatabaseIconIndex;
234
235    // Previewer
236     vtkImageViewer2* mViewer;
237     
238     int mx1,mx2,my1,my2,mz1,mz2;
239     double mspx,mspy,mspz;
240   
241     // Image preview :
242     // Multi-thread image reader
243     MultiThreadImageReader mReader;
244     // map of images name to node
245     std::map<std::string,DicomNode*> mImageFileNameToNode;
246   */
247  
248 } // EO namespace creaImageIO
249
250 #endif // USE_WIDGETS
251 // EOF
252 #endif