Fawkes API  Fawkes Development Version
laser_drawing_area.h
1 
2 /***************************************************************************
3  * laser_drawing_area.h - Laser drawing area derived from Gtk::DrawingArea
4  *
5  * Created: Thu Oct 09 18:19:54 2008
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program 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 Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __TOOLS_LASERGUI_LASER_DRAWING_AREA_H_
24 #define __TOOLS_LASERGUI_LASER_DRAWING_AREA_H_
25 
26 #include <gtkmm.h>
27 #include <list>
28 #include <interfaces/Position2DTrackInterface.h>
29 #include <interfaces/SwitchInterface.h>
30 
31 namespace fawkes {
32  class Laser360Interface;
33  class Laser720Interface;
34  class Laser1080Interface;
35  class ObjectPositionInterface;
36  class CairoRobotDrawer;
37  class LegtrackerTrackinterface;
38  class SwitchInterface;
39  class VisualDisplay2DInterface;
40 }
41 
42 class VisualDisplay2D;
43 
45  : public Gtk::DrawingArea
46 {
47  public:
48  /** Draw modes. */
49  typedef enum {
50  MODE_LINES, /**< Draw beams as lines */
51  MODE_POINTS, /**< Only draw beam end points */
52  MODE_HULL /**< Draw hull of beams */
53  } draw_mode_t;
54 
56  LaserDrawingArea(BaseObjectType* cobject,
57  const Glib::RefPtr<Gtk::Builder> &builder);
59 
60  void set_laser_ifs(const std::list<fawkes::Interface*>& laser_if);
61  void reset_laser_ifs();
62  void set_objpos_if(std::list<fawkes::ObjectPositionInterface*>* l_objpos_if_persons,
63  std::list<fawkes::ObjectPositionInterface*>* l_objpos_if_legs,
64  std::list<fawkes::ObjectPositionInterface*>* l_objpos_if_misc,
65  fawkes::Laser720Interface* laser_segmentation_if,
66  std::list<fawkes::Position2DTrackInterface*>* l_track_if,
68  fawkes::SwitchInterface* switch_if);
69  void set_line_if(fawkes::ObjectPositionInterface *line_if);
70  void set_visdisp_if(fawkes::VisualDisplay2DInterface *visdisp_if);
71  void set_robot_drawer(fawkes::CairoRobotDrawer *robot_drawer);
72  void set_resolution(unsigned int resolution);
73 
74  void zoom_in();
75  void zoom_out();
76 
77  void set_rotation(float rot_rad);
78  void set_draw_mode(draw_mode_t mode);
79  void set_connected(bool connected);
80 
81  void toggle_break_drawing();
82 
83  protected:
84 #if GTK_VERSION_GE(3,0)
85  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
86 #else
87  virtual bool on_expose_event(GdkEventExpose *event);
88 #endif
89  virtual bool on_scroll_event(GdkEventScroll *event);
90  virtual bool on_motion_notify_event(GdkEventMotion *event);
91  virtual bool on_button_press_event(GdkEventButton *event);
92 
93  void draw_beams(const fawkes::Interface* itf,
94  Glib::RefPtr<Gdk::Window> &window,
95  const Cairo::RefPtr<Cairo::Context> &cr);
96  void draw_segments(const fawkes::Interface* itf,
97  Glib::RefPtr<Gdk::Window> &window,
98  const Cairo::RefPtr<Cairo::Context> &cr);
99  void draw_scalebox(Glib::RefPtr<Gdk::Window> &window,
100  const Cairo::RefPtr<Cairo::Context> &cr);
101  void draw_persons_legs(Glib::RefPtr<Gdk::Window> &window,
102  const Cairo::RefPtr<Cairo::Context> &cr);
103  std::pair<float,float> transform_coords_from_fawkes(float p_x, float p_y);
104 
105 
106  private:
107  /// @cond INTERNALS
108  struct Color {
109  unsigned char r;
110  unsigned char g;
111  unsigned char b;
112  };
113  /// @endcond
114  typedef std::pair<fawkes::Interface*, Color> InterfaceColorPair;
115  typedef std::list<InterfaceColorPair> InterfaceColorPairList;
116 
117  bool all_laser_ifs_have_writer() const;
118 
119  InterfaceColorPairList __laser_ifs;
120  fawkes::Laser720Interface *__laser_segmentation_if;
121  fawkes::SwitchInterface *__switch_if;
122  fawkes::ObjectPositionInterface *__target_if;
123 
125 
126  std::list<fawkes::ObjectPositionInterface*>* __l_objpos_if_persons;
127  std::list<fawkes::ObjectPositionInterface*>* __l_objpos_if_legs;
128  std::list<fawkes::ObjectPositionInterface*>* __l_objpos_if_misc;
129  std::list<fawkes::Position2DTrackInterface*>* __l_track_if;
130 
131  bool __connected;
132  draw_mode_t __draw_mode;
133 
134  float __zoom_factor;
135  unsigned int __resolution;
136  float __rotation;
137  bool __break_drawing;
138  bool __first_draw;
139  double __last_mouse_x;
140  double __last_mouse_y;
141  double __xc;
142  double __yc;
143 
144  fawkes::CairoRobotDrawer *__robot_drawer;
145 
146  VisualDisplay2D *__visdisp;
147  fawkes::VisualDisplay2DInterface *__visdisp_if;
148 };
149 
150 #endif
Only draw beam end points.
Laser drawing area.
ObjectPositionInterface Fawkes BlackBoard Interface.
2D visualization processor for VisualDisplay2DInterface.
Definition: visdisplay.h:32
draw_mode_t
Draw modes.
Fawkes library namespace.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
Robot drawing interface.
Definition: drawer.h:34
SwitchInterface Fawkes BlackBoard Interface.
VisualDisplay2DInterface Fawkes BlackBoard Interface.
Laser720Interface Fawkes BlackBoard Interface.