Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FilterDialogBase.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef __FILTER_DIALOG_BASE_HH_
26 #define __FILTER_DIALOG_BASE_HH_
27 
28 #include <wx/wx.h>
29 #include <wx/frame.h>
30 #include <wx/button.h>
31 #include <wx/sizer.h>
32 #include <wx/statline.h>
33 #include <Base/Common/BIASpragmaStart.hh>
34 #include <Base/Image/Image.hh>
35 #include <Base/Common/BIASpragmaEnd.hh>
36 
37 #ifdef WIN32
38  DECLARE_EXPORTED_EVENT_TYPE(BIASGui_EXPORT, wxEVT_FILTER_SAVE, 0)
39 #else
40  DECLARE_EVENT_TYPE(wxEVT_FILTER_SAVE,-1)
41 #endif
42 
43 namespace BIAS {
44 
45  /**
46  * @class FilterDialogBase
47  * @ingroup g_gui
48  * @brief Base class for all filter dialogs
49  *
50  * this class is a simple container with some gui elements and it provides some
51  * very basic funtionality. It doesn't contain a Filter because it is intended
52  * that subclasses can take whatever Filter they want.
53  *
54  * @author jfernand 08/09
55  */
56 
57  template <class InputST, class OutputST>
58  class BIASGui_EXPORT FilterDialogBase : public wxFrame
59  {
60 
61  public:
62 
63  FilterDialogBase(const Image<InputST>& origImg,
64  wxWindow* parent,
65  wxWindowID id,
66  const wxString& title,
67  const wxString& name = wxT("Filter Dialog Base"),
68  const wxPoint& pos = wxDefaultPosition,
69  const wxSize& size = wxDefaultSize,
70  long style = wxDEFAULT_FRAME_STYLE & ~ (wxRESIZE_BORDER | wxMAXIMIZE_BOX));
71  virtual ~FilterDialogBase();
72 
73  /**
74  * Orientation: wxVERTICAL
75  * @return pointer to the main sizer of this window
76  */
77  virtual wxBoxSizer* GetMainSizer() const;
78 
79  /**
80  * It's purpose is to hold few elements like spinctrl/slider/etc for parameter
81  * inputs. If you want elements to be added vertically, then add another sizer
82  * in this sizer with your flavor.
83  *
84  * Orientation: wxHORIZONTAL
85  *
86  * @return pointer to the sizer (wxHORIZONTAL).
87  */
88  virtual wxBoxSizer* GetParamSizer() const;
89 
90  /**
91  * @return pointer to the sizer which holds the buttons
92  * Orientation: wxHORIZONTAL
93  */
94  virtual wxBoxSizer* GetButtonSizer() const;
95 
96  /**
97  * @return original (NEVER filtered!!!) image
98  */
99  Image<InputST> GetOriginalImage() const;
100 
101  /**
102  * @return filtered image if it was succesfully filtered
103  */
104  Image<OutputST> GetFilteredImage() const;
105 
106  /**
107  * @return TRUE if image was filtered
108  */
109  virtual bool GetImageIsFiltered() const;
110 
111  /**
112  * @return the directory in which the filtered image was saved
113  */
114  virtual wxString GetSavedImagePath() const;
115 
116  /**
117  * Sets the source image for filter
118  */
119  virtual void SetOriginalImage(const Image<InputST>& img);
120 
121  /**
122  * Sets the filtered image. Used by derived classes for replacing the old
123  * filtered image with that from the successful filter procedure.
124  */
125  virtual void SetFilteredImage(const Image<OutputST>& img);
126 
127  /**
128  * Sets if image was filtered or not.
129  */
130  virtual void SetImageIsFiltered(const bool filtered);
131 
132  /**
133  * Copy the OrigImg's content to the FilteredImage
134  */
135  virtual void CopyOriginalImage();
136 
137  /**
138  * Save the image to the disk
139  */
140  void SaveFilteredImage(wxCommandEvent& WXUNUSED(event));
141 
142  virtual void EnableSaveButton(bool enable = true) const;
143  virtual void EnableFilterButton(bool enable = true) const;
144  virtual void EnablePreviewButton(bool enable = true) const;
145  virtual void EnableResetButton(bool enable = true) const;
146  virtual void EnableCancelButton(bool enable = true) const;
147 
148  /**
149  * Just for optical reason, if you don't want that line, just remove it
150  */
151  virtual void RemoveLine();
152 
153 
154  protected:
155 
156  /**
157  * The save logic should be implemented here
158  */
159  //virtual void OnSaveButton(wxCommandEvent& WXUNUSED(event)) = 0;
160 
161  /**
162  * The filter logic should be implemented here
163  */
164  virtual void OnFilterButton(wxCommandEvent& WXUNUSED(event)) = 0;
165 
166  /**
167  * Shows the filtered image
168  */
169  virtual void OnPreviewButton(wxCommandEvent& WXUNUSED(event));
170 
171  /**
172  * Reset the original image but it does not reset the given parameter(s)
173  */
174  virtual void OnResetButton(wxCommandEvent& WXUNUSED(event));
175 
176  /**
177  * Quits the dialog
178  */
179  virtual void OnCancelButton(wxCommandEvent& WXUNUSED(event));
180 
181 
182  private:
183 
184  Image<InputST> OrigImg;
185 
186  /**
187  * The filtered image. StorageType conversion between InputST and OutputST
188  * is handled automatically within this base class.
189  */
190  Image<OutputST> FilteredImage;
191 
192  /**
193  * the location of the last saved image else empty
194  */
195  wxString SavedImagePath;
196 
197  /**
198  * The dialog's main sizer. It contains the ParamSizer and the ButtonSizer
199  * Orientation: wxVERTICAL
200  */
201  wxBoxSizer* MainSizer;
202 
203  /**
204  * It's intention is to hold elements for parameter inputs. This should
205  * hold spinctrl/slider/etc... but in the base class it has no content.
206  * Orientation: wxHORIZONTAL
207  */
208  wxBoxSizer* ParamSizer;
209 
210  /**
211  * The sizer which holds the buttons below
212  * Orientation: wxHORIZONTAL
213  */
214  wxBoxSizer* ButtonSizer;
215 
216  wxButton* SaveButton;
217  wxButton* FilterButton;
218  wxButton* PreviewButton;
219  wxButton* ResetButton;
220  wxButton* CancelButton;
221 
222  wxStaticLine* Line;
223 
224  /**
225  * An indicator if the image was filtered.
226  */
227  bool ImageIsFiltered;
228 
229  };
230 
231 
232  /**
233  * all non-standard IDs related to this dialog -- classes inherited from this
234  * included and all classes that use this class -- should be entered here to
235  * decrease conflict possibilities.
236  */
238 
239  ID_WIN_GAUSS = 2080, //1934572,
246 
248 
252 
256 
258  };
259 
260 
261 } // end namespace BIAS
262 
263 #endif // __FILTER_DIALOG_BASE_HH_
FILTER_DIALOG_IDs
all non-standard IDs related to this dialog – classes inherited from this included and all classes th...
Base class for all filter dialogs.