appkit  1.5.1
RoadNarrows Robotics Application Kit
StateWinCamera.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: RoadNarrows Robotics Application Tool Kit
4 //
5 // Link: https://github.com/roadnarrows-robotics/rnr-sdk
6 //
7 // Library: librnr_cam
8 //
9 // File: StateWinCamera.h
10 //
11 /*! \file
12  *
13  * $LastChangedDate: 2013-07-13 13:54:59 -0600 (Sat, 13 Jul 2013) $
14  * $Rev: 3122 $
15  *
16  * \brief StateWinCamera derived state class interface.
17  *
18  * The StateWinCamera class uses the GTK windowing system along with the
19  * GStreamer interface to a video camera.
20  *
21  * \author Robin Knight (robin.knight@roadnarrows.com)
22  * \author Daniel Packard (daniel@roadnarrows.com)
23  *
24  * \par Copyright
25  * \h_copy 2012-2017. RoadNarrows LLC.\n
26  * http://www.roadnarrows.com\n
27  * All Rights Reserved
28  */
29 /*
30  * @EulaBegin@
31  *
32  * Permission is hereby granted, without written agreement and without
33  * license or royalty fees, to use, copy, modify, and distribute this
34  * software and its documentation for any purpose, provided that
35  * (1) The above copyright notice and the following two paragraphs
36  * appear in all copies of the source code and (2) redistributions
37  * including binaries reproduces these notices in the supporting
38  * documentation. Substantial modifications to this software may be
39  * copyrighted by their authors and need not follow the licensing terms
40  * described here, provided that the new terms are clearly indicated in
41  * all files where they apply.
42  *
43  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
44  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
45  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
46  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
47  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
48  * THE POSSIBILITY OF SUCH DAMAGE.
49  *
50  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
51  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
52  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
53  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
54  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
55  *
56  * @EulaEnd@
57  */
58 ////////////////////////////////////////////////////////////////////////////////
59 
60 #ifndef _RNR_STATE_WIN_CAMERA_H
61 #define _RNR_STATE_WIN_CAMERA_H
62 
63 #include <stdio.h>
64 
65 #include <string>
66 #include <map>
67 
68 #include "rnr/rnrconfig.h"
69 
70 #include "rnr/appkit/Win.h"
71 #include "rnr/appkit/WinGtk.h"
72 #include "rnr/appkit/WinMenuGtk.h"
73 #include "rnr/appkit/CameraGst.h"
74 #include "rnr/appkit/SessionWin.h"
75 #include "rnr/appkit/State.h"
76 #include "rnr/appkit/StateWin.h"
77 
78 /*!
79  * \brief RoadNarrows Robotics
80  */
81 namespace rnr
82 {
83  //----------------------------------------------------------------------------
84  // StateWinCamera Class
85  //----------------------------------------------------------------------------
86 
87  /*!
88  * State base class.
89  */
90  class StateWinCamera : public StateWin
91  {
92  public:
93  /*!
94  * \brief Initialization constructor.
95  *
96  * \param nStateId State id. Must be state machine unique.
97  * \param session State's embedding in (derived) window session.
98  * \param strStateName State name.
99  * \param strRefTag State reference id.
100  */
101  StateWinCamera(int nStateId,
103  const std::string &strStateName="",
104  const std::string &strRefTag="") :
105  StateWin(nStateId, session, strStateName, strRefTag)
106  {
107  m_bOneTimeInit = false;
108  m_bMouseEvents = true;
109  m_bKbEvents = false;
110  m_pButtons = NULL;
111  }
112 
113  /*!
114  * \brief List constructor.
115  *
116  * \param nStateId State id. Must be state machine unique.
117  * \param session State's embedding in (derived) window session.
118  * \param strStateName State name.
119  * \param strRefTag State reference id.
120  * \param listStateEvents Declaration list of allocated state events.
121  * NULL terminated.
122  */
123  StateWinCamera(int nStateId,
125  const std::string &strStateName,
126  const std::string &strRefTag,
127  StateEvent *listStateEvents[]) :
128  StateWin(nStateId, session, strStateName, strRefTag, listStateEvents)
129  {
130  m_bOneTimeInit = false;
131  m_bMouseEvents = true;
132  m_bKbEvents = false;
133  m_pButtons = NULL;
134  }
135 
136  /*!
137  * \brief Destructor.
138  */
139  virtual ~StateWinCamera()
140  {
141  }
142 
143  /*!
144  * \brief Set button states.
145  *
146  * State and/or session data determine the state of the buttons.
147  */
148  virtual void setButtonStates();
149 
150  protected:
151  CameraGst m_camera; ///< the camera
152 
153  friend class StateEvent; ///< friend
154 
155  /*!
156  * \brief One-time button menu initialization.
157  *
158  * This function is called on the "enter state" action.
159  */
160  virtual void initOnceButtons();
161 
162  /*!
163  * \brief Build the window gui interface.
164  *
165  * This function is called on the "enter state" action.
166  */
167  virtual void buildGuiInterface();
168  };
169 
170 } // namespace rnr
171 
172 
173 #endif // _RNR_STATE_WIN_CAMERA_H
virtual ~StateWinCamera()
Destructor.
WinButtonMenu * m_pButtons
button menu
Definition: StateWin.h:213
bool m_bMouseEvents
enable/disable mouse events
Definition: StateWin.h:211
RoadNarrows Robotics GTK derived WinGtk window class interface.
RoadNarrows Robotics Win abstract base class interface.
virtual void setButtonStates()
Set button states.
GUI window StateWin derived state class interface.
SessionWin derived class.
virtual void buildGuiInterface()
Build the window gui interface.
StateWinCamera(int nStateId, SessionWin &session, const std::string &strStateName, const std::string &strRefTag, StateEvent *listStateEvents[])
List constructor.
bool m_bOneTimeInit
state&#39;s one-time initializaion
Definition: StateWin.h:210
bool m_bKbEvents
enable/disable keyboard events
Definition: StateWin.h:212
StateWinCamera(int nStateId, SessionWin &session, const std::string &strStateName="", const std::string &strRefTag="")
Initialization constructor.
CameraGst m_camera
the camera
GStreamer implementation of the camera class. The video is streamed via a Gstreamer/GTK callback mech...
Definition: CameraGst.h:84
virtual void initOnceButtons()
One-time button menu initialization.
State base class interface.
SessionWin & session()
Get the embedding window session.
Definition: StateWin.h:183
RoadNarrows Robotics.
Definition: Camera.h:74
Gstreamer video and still image camera class.