Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GuiWX.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 
26 #include <Base/Common/W32Compat.hh>
27 #include <Base/Image/ImageIO.hh>
28 #include <Base/Image/ImageConvert.hh>
29 #include <Base/Image/Image.hh>
30 #include <Gui/GuiBase.hh>
31 #include <Gui/PlainImageCanvas.hh>
32 #include <pthread.h>
33 
34 namespace BIAS{
35 
36  //forward declaration
37  /**
38  * \class GuiWX
39  * \ingroup g_gui
40  * \brief simple wxWindow to display an image. WxWidgets is not optimal
41  * to do this, so a lot of workaround is needed. Still does not react to
42  * key presses, better use GuiCV
43  * \author ischiller
44  * \date 06/2010
45  */
46  class BIASGui_EXPORT GuiWXFrame;
47  class BIASGui_EXPORT GuiWXApp;
48  ////////////////////////////////////////////////////////////////////////////
49  class BIASGui_EXPORT GuiWX : public BIAS::GuiBase
50  {
51  public:
52  GuiWX();
53  ~GuiWX();
54  virtual void SetTitle(std::string const& Title);
55 
56  protected:
57  virtual int ShowConvertedImage_(BIAS::Image<unsigned char> &image);
59 
60  #ifdef BIAS_HAVE_PTHREADS
61  static void* guiThreadFunc_(GuiWX *caller);
62  pthread_t guiThread_;
63  pthread_mutex_t guiMutex_;
64  #endif
65  };
66  //////////////////////////////////////////////////////////////////////////////
67  class BIASGui_EXPORT GuiWXApp: public wxApp
68  {
69  public:
70  GuiWXApp();
71  void Init();
72  void SetTitle(std::string const& Title);
73  int ShowConvertedImage(BIAS::Image<unsigned char> &image);
74 
75  protected:
77  };
78  //////////////////////////////////////////////////////////////////////////////
79  enum
80  {
81  ID_Quit = 1,
83  ID_TIMER = 1001
84  };
85  //////////////////////////////////////////////////////////////////////////////
86  class BIASGui_EXPORT GuiWXFrame: public wxFrame
87  {
88 
89  public:
90  GuiWXFrame(const wxString title=wxT(""),
91  const wxPoint pos=wxDefaultPosition,
92  const wxSize size=wxDefaultSize);
93 
94  virtual void SetTitle(std::string const& Title);
95  virtual void OnQuit(wxCommandEvent& event);
96  virtual void OnTimer(wxTimerEvent& event);
97  virtual void OnKeyDown(wxKeyEvent &event);
99 
100 
101  virtual int ShowConvertedImage(BIAS::Image<unsigned char> &image);
102 
103  DECLARE_EVENT_TABLE()
104 
105  protected:
106  wxPanel *panel_;
107  BIAS::PlainImageCanvas *ic_;
108 
109  wxTimer Timer_;
110  BIAS::Image<unsigned char> image_;
111  };
112 
113 
114 }
pthread_mutex_t guiMutex_
Definition: GuiWX.hh:63
class BIASGui_EXPORT GuiWXFrame
Definition: GuiWX.hh:46
simple wxWindow to display an image.
Definition: GuiWX.hh:49
Gui is a simple windowing environment...
Definition: GuiBase.hh:75
class BIASGui_EXPORT GuiWXApp
Definition: GuiWX.hh:47
BIAS::PlainImageCanvas * GetCanvas()
Definition: GuiWX.hh:98
GuiWXApp * app_
Definition: GuiWX.hh:58
Image canvas that does not show zoom frames and redirects mouse click events to its parent...
BIAS::GuiWXFrame * frame_
Definition: GuiWX.hh:76
pthread_t guiThread_
Definition: GuiWX.hh:62