Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BVWXMainFrame.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 __BVWXMainFrame_HH
26 #define __BVWXMainFrame_HH
27 
28 #include <Base/Common/W32Compat.hh>
29 
30 #include <wx/wx.h>
31 #include <wx/spinctrl.h>
32 
33 #include "BVWXApp.hh"
34 //#include "BVWXDnDTarget.hh"
35 
36 #include <Gui/ImageCanvas.hh>
37 #include <Gui/ScaledImageCanvas.hh>
38 #include <Base/Image/ImageConvert.hh>
39 #include <Gui/ConsoleRedirectIO.hh>
40 #include <Gui/StringConv.hh>
41 #include <Base/Image/ImageIO.hh>
42 #include <Base/Common/FileHandling.hh>
43 #include <Image/Camera.hh>
44 #include <Utils/Param.hh>
45 #include <Gui/FilterDialogBase.hh>
46 
47 
48 namespace BIAS {
49 
50 /**
51  @class BVWXMainFrame
52  @internal
53  @ingroup g_tools
54  @brief The main frame of the BiasViewWX application
55  @author MIP
56 */
57 class BVWXMainFrame : public wxFrame
58 {
59 
60 public:
61  //friend class BIAS::BVWXDnDTarget;
62 
63  BVWXMainFrame(const wxString& title,
64  const wxPoint& pos,
65  const wxSize& size);
67 
68  void SetFileList(const std::vector<std::string>& fileNames);
69  void LoadImages(const wxArrayString &paths);
70 
71  /// fits the frame size if it is too small for curent image
72  void FitSizetIfTooSmall();
73 
74  /// workaround adapting client canvases size
75  void RefitClients();
76 
77  /// some compressed images display size is bigger then original size
78  /// e.b. X3B images can be displayed three times a swide as loaded
79  /// Uncompress after laod to keep same display and orig image size
80  /// which eases coordinate transforms
81  /// between mouse, display rgb and orig image. (JW)
82  void UncompressImage(BIAS::ImageBase & image);
83 
84  /// print info such as dim, video format ro info stream.
85  /// Used by GetInfo (JW)
86  void AddInfo(const BIAS::ImageBase & image, std::stringstream & info);
87 
88  int ConvertFLtoUC(ImageBase& img);
89 
90  // some error messages and hints
91  void PrintSavingError(const int errorNo, wxString fname);
92  void PrintConversionError(const int errorNo, wxString fname);
93  void PrintEmptyNameMsg();
94  void PrintNoImageToFilter();
95 
96  // when an image is filtered then ask user, if she/he wants
97  // to save the image
98  // void SaveFilteredImgDlg();
99 
100 
101 
102 protected:
103  void LoadImageFromList(int index);
104 
105  //SizerWindow and its content, _MainSizer which handles
106  //the sizing-events for the canvases
108  wxBoxSizer* _MainSizer;
109 
110  //Canvases for UChar and Float images
115 
116  std::vector<std::string> _FileNames;
118  std::string _MetaData;
119  wxTimer _Timer;
121  wxSpinCtrl* _DelaySpin;
122  wxCheckBox* _FitCheckBox;
124  wxCheckBox* _ReverseCheckBox;
125  wxMenuItem* _DrawROICheckItem;
126  wxMenuItem* _HistogramCheckItem;
127  wxMenuItem* _ValueBarCheckItem;
128 
129  wxButton* _PreviousButton;
130  wxButton* _NewButton;
131  wxButton* _RunStopButton;
132  wxToolBarToolBase *_RunTool;
133  wxButton* _HistogrammButton;
134  wxButton* _ValueBarButton;
138  unsigned int _SelectedChannel;
139 
140  // for file open dialog
141  wxString _DefaultFile;
142  wxString _DefaultDir;
143 
144  // event handlers
145  void OnLoad(wxCommandEvent& event);
146  void OnRemoveCurrent(wxCommandEvent& event);
147  void OnRemoveAllButCurrent(wxCommandEvent& event);
148  void OnInfo(wxCommandEvent& event);
149  void OnMetaData(wxCommandEvent& event);
150  void OnExit(wxCommandEvent& event);
151  void OnKeyInfo(wxCommandEvent& event);
152  void OnAbout(wxCommandEvent& event);
153  void OnImageValues(wxCommandEvent& event);
154 
155  /* ==== Saving file(s) operations ==== */
156  /*
157  * Save an image to disk with extension choice if no extension we use mip as
158  * default. On some cases storagetype conversion will be taken - from float
159  * to uchar but the other way won't be supported (may be in the future).
160  */
161  void OnSaveAs(wxCommandEvent& event);
162 
163  void OnSaveAsMovie(wxCommandEvent& event);
164 
165  /** @brief Save current displayed image with original dimension and .mip as default */
166  void OnSaveCurrent(wxCommandEvent& event);
167 
168  /** @brief Print current image */
169  void OnPrintCurrent(wxCommandEvent& event);
170 
171  /** @brief Print multiple images */
172  void OnPrint(wxCommandEvent& event);
173 
174  /// save all filenames to disk
175  void OnSaveList(wxCommandEvent& event);
176 
177  void OnNext(wxCommandEvent& event);
178  void OnPrev(wxCommandEvent& event);
179  void OnRunStop(wxCommandEvent& event);
180  void OnRun(wxCommandEvent& event);
181  void OnStop(wxCommandEvent& event);
182 
183  void OnImageValueBar(wxCommandEvent& event);
184  void ShowImageValueBar(ImageBase& image);
185  void OnHistogramm(wxCommandEvent& event);
186  void ShowHistogramm(ImageBase& image);
187 
188  void OnDelay(wxSpinEvent& event);
189  void OnFit(wxCommandEvent& event);
190  void OnKeepScrollPosition(wxCommandEvent& event);
191 
192  void OnChangeChannel_1(wxCommandEvent& event);
193  void OnChangeChannel_2(wxCommandEvent& event);
194  void OnChangeChannel_3(wxCommandEvent& event);
195  void OnChangeChannel_4(wxCommandEvent& event);
196  void OnChangeChannel_5(wxCommandEvent& event);
197  void OnChangeChannel_6(wxCommandEvent& event);
198  void OnChangeChannel_7(wxCommandEvent& event);
199  void OnChangeChannel_8(wxCommandEvent& event);
200  void OnChangeChannel_ALL(wxCommandEvent& event);
201 
202  void OnFilterCannyEdge(wxCommandEvent& event);
203  void OnFilterGauss(wxCommandEvent& event);
204  void OnFilterGradientSobel3x3(wxCommandEvent& event);
205  void OnFilterMean(wxCommandEvent& WXUNUSED(event));
206  void OnFilterMedian(wxCommandEvent& event);
207  void OnFilterRescale(wxCommandEvent& event);
208  void OnDrawROI(wxCommandEvent& event);
209 
210  void OnTimer(wxTimerEvent& event);
211  void OnIdle(wxIdleEvent& event);
212  void OnSize(wxSizeEvent& event);
213 
214  void OnFilterSave( wxCommandEvent &event );
215  void OnToolEnter ( wxCommandEvent &event);
216 
217  std::string infoRaw_;//< global info field filled by Uncompress
218 
219  /** \internal */
221  {
222 
223  // standard ids
224  ID_About = wxID_ABOUT,
225  ID_Exit = wxID_EXIT,
226 
227  // our custom ids
228  ID_Load = wxID_HIGHEST+2001, /* first custom id. */
229 
232 
236 
237  // toolbar item IDs
249  // timer ID
251 
261 
268 
276 
280 
282 
283  };
284 
285  DECLARE_EVENT_TABLE()
286 };
287 
288 } // namespace BIAS
289 
290 #endif // __BVWXMainFrame_HH
void OnFilterSave(wxCommandEvent &event)
void OnImageValues(wxCommandEvent &event)
wxCheckBox * _FitCheckBox
void OnSaveCurrent(wxCommandEvent &event)
Save current displayed image with original dimension and .mip as default.
void PrintConversionError(const int errorNo, wxString fname)
void OnFilterMean(wxCommandEvent &WXUNUSED(event))
void OnSaveAs(wxCommandEvent &event)
void OnSize(wxSizeEvent &event)
void OnPrintCurrent(wxCommandEvent &event)
Print current image.
void OnChangeChannel_2(wxCommandEvent &event)
void FitSizetIfTooSmall()
fits the frame size if it is too small for curent image
void OnFilterGradientSobel3x3(wxCommandEvent &event)
void OnKeepScrollPosition(wxCommandEvent &event)
void OnTimer(wxTimerEvent &event)
void OnRun(wxCommandEvent &event)
void ShowImageValueBar(ImageBase &image)
wxCheckBox * _KeepScrollPositionCheckBox
void OnRunStop(wxCommandEvent &event)
void OnFilterMedian(wxCommandEvent &event)
display image in wx application, provides zoom and investigation functionality
Definition: ImageCanvas.hh:38
wxMenuItem * _ValueBarCheckItem
void OnPrev(wxCommandEvent &event)
void SetFileList(const std::vector< std::string > &fileNames)
void OnFilterRescale(wxCommandEvent &event)
wxButton * _ValueBarButton
void OnIdle(wxIdleEvent &event)
void OnRemoveAllButCurrent(wxCommandEvent &event)
void OnChangeChannel_7(wxCommandEvent &event)
wxButton * _HistogrammButton
void OnHistogramm(wxCommandEvent &event)
wxCheckBox * _ReverseCheckBox
void OnStop(wxCommandEvent &event)
void OnAbout(wxCommandEvent &event)
ImageCanvas * _ImageCanvasUC
void OnToolEnter(wxCommandEvent &event)
unsigned int _SelectedChannel
void OnLoad(wxCommandEvent &event)
void OnMetaData(wxCommandEvent &event)
void OnChangeChannel_8(wxCommandEvent &event)
void OnSaveList(wxCommandEvent &event)
save all filenames to disk
void OnNext(wxCommandEvent &event)
std::vector< std::string > _FileNames
ScaledImageCanvas * _ImageCanvasFloat
wxButton * _PreviousButton
wxMenuItem * _DrawROICheckItem
void OnChangeChannel_4(wxCommandEvent &event)
void RefitClients()
workaround adapting client canvases size
void OnExit(wxCommandEvent &event)
void OnImageValueBar(wxCommandEvent &event)
void OnChangeChannel_5(wxCommandEvent &event)
void OnSaveAsMovie(wxCommandEvent &event)
wxBoxSizer * _MainSizer
void AddInfo(const BIAS::ImageBase &image, std::stringstream &info)
print info such as dim, video format ro info stream.
void PrintSavingError(const int errorNo, wxString fname)
void OnPrint(wxCommandEvent &event)
Print multiple images.
void OnChangeChannel_ALL(wxCommandEvent &event)
void OnRemoveCurrent(wxCommandEvent &event)
void OnChangeChannel_1(wxCommandEvent &event)
void OnKeyInfo(wxCommandEvent &event)
void OnFilterCannyEdge(wxCommandEvent &event)
void ShowHistogramm(ImageBase &image)
wxToolBarToolBase * _RunTool
void UncompressImage(BIAS::ImageBase &image)
some compressed images display size is bigger then original size e.b.
void OnChangeChannel_6(wxCommandEvent &event)
void LoadImages(const wxArrayString &paths)
display float images in wx application, provides zoom, scale, shift and investigation functionality ...
BVWXMainFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
void OnDelay(wxSpinEvent &event)
void LoadImageFromList(int index)
void OnDrawROI(wxCommandEvent &event)
wxSpinCtrl * _DelaySpin
wxButton * _RunStopButton
wxMenuItem * _HistogramCheckItem
int ConvertFLtoUC(ImageBase &img)
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
void OnInfo(wxCommandEvent &event)
void OnFit(wxCommandEvent &event)
void OnFilterGauss(wxCommandEvent &event)
void OnChangeChannel_3(wxCommandEvent &event)