Fawkes API  Fawkes Development Version
lasergui.cpp
1 
2 /***************************************************************************
3  * lasergui.cpp - minimalistic laser visualization
4  *
5  * Created: Thu Oct 09 12:51:52 2008
6  * Copyright 2008-2011 Tim Niemueller [www.niemueller.de]
7  * 2009 Masrur Doostdar <doostdar@kbsg.rwth-aachen.de>
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL file in the doc directory.
22  */
23 
24 #include "laser_drawing_area.h"
25 
26 #include <blackboard/remote.h>
27 #include <gtkmm/main.h>
28 #include <gui_utils/connection_dispatcher.h>
29 #include <gui_utils/interface_dispatcher.h>
30 #include <gui_utils/multi_interface_chooser_dialog.h>
31 #include <gui_utils/robot/allemaniacs_athome.h>
32 #include <gui_utils/service_chooser_dialog.h>
33 #include <interfaces/Laser1080Interface.h>
34 #include <interfaces/Laser360Interface.h>
35 #include <interfaces/Laser720Interface.h>
36 #include <interfaces/ObjectPositionInterface.h>
37 #include <interfaces/Position2DTrackInterface.h>
38 #include <interfaces/SwitchInterface.h>
39 #include <interfaces/VisualDisplay2DInterface.h>
40 #include <netcomm/fawkes/client.h>
41 #include <utils/misc/string_conversions.h>
42 
43 #include <list>
44 #include <map>
45 #include <memory>
46 #include <set>
47 
48 #define MAX_OBJECTPOSITIONINTERFACES_PERSONS 10
49 #define MAX_OBJECTPOSITIONINTERFACES_LEGS 15
50 #define MAX_OBJECTPOSITIONINTERFACES_MISC 20
51 #define MAX_TRACKINTERFACES 10
52 
53 using namespace fawkes;
54 
55 /** @class LaserGuiGtkWindow "lasergui.cpp"
56  * Laser GUI window for Gtkmm.
57  * @author Tim Niemueller
58  */
59 class LaserGuiGtkWindow : public Gtk::Window
60 {
61 public:
62  /** Typedef of fawkes::Interface to override Glib::Interface. */
64  /** Shorthand for pair of interface type and ID. */
66  /** Shorthand for set of pairs of interface type and ID. */
68  /** For each interface, an interface dispatcher is opened that listens for
69  * data changes. */
70  typedef std::pair<Interface *, InterfaceDispatcher *> InterfaceDispatcherPair;
71  /** A list of interfaces and their respective dispatchers.
72  * Note that this is a list and not a map from interface to dispatcher only
73  * to keep the ordering specified by the user in the GUI. */
74  typedef std::list<InterfaceDispatcherPair> InterfaceDispatcherPairList;
75 
76  /** Constructor for Gtk::Builder.
77  * @param cobject C base object
78  * @param builder Gtk Builder
79  */
80  LaserGuiGtkWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder)
81  : Gtk::Window(cobject), athome_drawer_(true)
82  {
83  laser_if_names_.push_back(std::make_pair("Laser360Interface", "Laser"));
84 
85  builder->get_widget_derived("da_laser", area_);
86  builder->get_widget("tb_connection", tb_connection_);
87  builder->get_widget("tb_select", tb_select_);
88  builder->get_widget("tb_lines", tb_lines_);
89  builder->get_widget("tb_points", tb_points_);
90  builder->get_widget("tb_hull", tb_hull_);
91  builder->get_widget("tb_trimvals", tb_trimvals_);
92  builder->get_widget("tb_rotation", tb_rotation_);
93  builder->get_widget("tb_legtracker", tb_legtracker_);
94  builder->get_widget("tb_stop", tb_stop_);
95  builder->get_widget("tb_zoom_in", tb_zoom_in_);
96  builder->get_widget("tb_zoom_out", tb_zoom_out_);
97  builder->get_widget("tb_exit", tb_exit_);
98  builder->get_widget("dlg_ltopen", dlg_ltopen_);
99  builder->get_widget("pgb_ltopen", pgb_ltopen_);
100 
101  area_->set_robot_drawer(&athome_drawer_);
102 
103  tb_select_->set_sensitive(false);
104  tb_lines_->set_sensitive(false);
105  tb_points_->set_sensitive(false);
106  tb_hull_->set_sensitive(false);
107  tb_trimvals_->set_sensitive(false);
108  tb_rotation_->set_sensitive(false);
109  tb_legtracker_->set_sensitive(false);
110  tb_stop_->set_sensitive(false);
111  tb_zoom_in_->set_sensitive(false);
112  tb_zoom_out_->set_sensitive(false);
113 
114  tb_connection_->signal_clicked().connect(
115  sigc::mem_fun(*this, &LaserGuiGtkWindow::on_connection_clicked));
116  tb_select_->signal_clicked().connect(
117  sigc::mem_fun(*this, &LaserGuiGtkWindow::on_select_clicked));
118  tb_lines_->signal_toggled().connect(
119  sigc::bind(sigc::mem_fun(*area_, &LaserDrawingArea::set_draw_mode),
121  tb_points_->signal_toggled().connect(
122  sigc::bind(sigc::mem_fun(*area_, &LaserDrawingArea::set_draw_mode),
124  tb_hull_->signal_toggled().connect(
125  sigc::bind(sigc::mem_fun(*area_, &LaserDrawingArea::set_draw_mode),
127  tb_zoom_in_->signal_clicked().connect(sigc::mem_fun(*area_, &LaserDrawingArea::zoom_in));
128  tb_zoom_out_->signal_clicked().connect(sigc::mem_fun(*area_, &LaserDrawingArea::zoom_out));
129 
130  tb_legtracker_->signal_clicked().connect(
131  sigc::mem_fun(*this, &LaserGuiGtkWindow::on_legtracker_toggled));
132  tb_trimvals_->signal_clicked().connect(
133  sigc::mem_fun(*this, &LaserGuiGtkWindow::on_trimvals_toggled));
134  tb_rotation_->signal_clicked().connect(
135  sigc::mem_fun(*this, &LaserGuiGtkWindow::on_rotation_toggled));
136  tb_stop_->signal_clicked().connect(sigc::mem_fun(*this, &LaserGuiGtkWindow::on_stop_toggled));
137  tb_exit_->signal_clicked().connect(sigc::mem_fun(*this, &LaserGuiGtkWindow::on_exit_clicked));
138 
139  connection_dispatcher_.signal_connected().connect(
140  sigc::mem_fun(*this, &LaserGuiGtkWindow::on_connect));
141  connection_dispatcher_.signal_disconnected().connect(
142  sigc::mem_fun(*this, &LaserGuiGtkWindow::on_disconnect));
143  }
144 
145 protected:
146  /** Event handler for connection button. */
147  virtual void
149  {
150  if (!connection_dispatcher_.get_client()->connected()) {
151  ServiceChooserDialog ssd(*this, connection_dispatcher_.get_client());
152  ssd.run_and_connect();
153  } else {
154  connection_dispatcher_.get_client()->disconnect();
155  }
156  }
157 
158  /** Event handler for connection button. */
159  virtual void
161  {
162  if (!connection_dispatcher_.get_client()->connected()) {
163  Gtk::MessageDialog md(*this,
164  "Cannot get list of interfaces if not connected.",
165  /* markup */ false,
166  Gtk::MESSAGE_ERROR,
167  Gtk::BUTTONS_OK,
168  /* modal */ true);
169  md.set_title("Interface Selection Failed");
170  md.run();
171  } else {
172 #if __cplusplus >= 201103L
173  std::unique_ptr<MultiInterfaceChooserDialog> ifcd(
174 #else
175  std::auto_ptr<MultiInterfaceChooserDialog> ifcd(
176 #endif
177  MultiInterfaceChooserDialog::create(*this, bb_, "Laser*Interface", "*", laser_if_names_));
178  if (ifcd->run()) {
179  const TypeIdPairList interfaces = ifcd->get_selected_interfaces();
180  open_interfaces(interfaces);
181  }
182  }
183  }
184 
185  /** Open interfaces.
186  * Tries to open the interfaces.
187  * Even if it fails, the old interfaces are closed.
188  * @param types_and_ids types and ids of interfaces to open
189  */
190  void
191  open_interfaces(const TypeIdPairList &types_and_ids)
192  {
193  area_->reset_laser_ifs();
194  for (InterfaceDispatcherPairList::const_iterator it = laser_ifs_.begin();
195  it != laser_ifs_.end();
196  ++it) {
197  bb_->unregister_listener(it->second);
198  delete it->second;
199  bb_->close(it->first);
200  }
201  laser_ifs_.clear();
202  laser_if_names_ = types_and_ids;
203 
204  // Open interfaces.
205  for (TypeIdPairList::const_iterator it = types_and_ids.begin(); it != types_and_ids.end();
206  ++it) {
207  const Glib::ustring &type = it->first;
208  const Glib::ustring &id = it->second;
209  Interface * itf = NULL;
210  try {
211  if (type == "Laser1080Interface") {
212  itf = bb_->open_for_reading<Laser1080Interface>(id.c_str());
213  } else if (type == "Laser720Interface") {
214  itf = bb_->open_for_reading<Laser720Interface>(id.c_str());
215  } else if (type == "Laser360Interface") {
216  itf = bb_->open_for_reading<Laser360Interface>(id.c_str());
217  } else {
218  throw Exception("Invalid interface type %s", type.c_str());
219  }
220  } catch (const Exception &e) {
221  std::string msg = std::string("Failed to open interface: ") + e.what();
222  Gtk::MessageDialog md(*this,
223  msg,
224  /* markup */ false,
225  Gtk::MESSAGE_ERROR,
226  Gtk::BUTTONS_OK,
227  /* modal */ true);
228  md.set_title("Opening Interface Failed");
229  md.run();
230  continue;
231  }
232  InterfaceDispatcher *itfd = new InterfaceDispatcher("LaserInterfaceDispatcher", itf);
233  itfd->signal_data_changed().connect(
234  sigc::hide(sigc::mem_fun(*area_, &LaserDrawingArea::queue_draw)));
235  try {
236  bb_->register_listener(itfd, BlackBoard::BBIL_FLAG_DATA);
237  } catch (const Exception &e) {
238  std::string msg = std::string("Failed to register interface dispatcher: ") + e.what();
239  Gtk::MessageDialog md(*this,
240  msg,
241  /* markup */ false,
242  Gtk::MESSAGE_ERROR,
243  Gtk::BUTTONS_OK,
244  /* modal */ true);
245  md.set_title("Registrating Interface Dispatcher Failed");
246  md.run();
247  delete itfd;
248  bb_->close(itf);
249  continue;
250  }
251  const InterfaceDispatcherPair p = std::make_pair(itf, itfd);
252  laser_ifs_.push_back(p);
253  }
254 
255  // Inform the drawing area.
256  std::list<Interface *> keys;
257  for (InterfaceDispatcherPairList::const_iterator it = laser_ifs_.begin();
258  it != laser_ifs_.end();
259  ++it) {
260  keys.push_back(it->first);
261  }
262  area_->set_laser_ifs(keys);
263  }
264 
265  /** Event handler for connected event. */
266  virtual void
268  {
269  try {
270  bb_ = new RemoteBlackBoard(connection_dispatcher_.get_client());
271  laser_ifs_.clear();
272  l_objpos_if_persons_ = NULL;
273  l_objpos_if_legs_ = NULL;
274  l_objpos_if_misc_ = NULL;
275  l_track_if_ = NULL;
276  laser_segmentation_if_ = NULL;
277  switch_if_ = NULL;
278  target_if_ = NULL;
279  line_if_ = NULL;
280  visdis_if_ = NULL;
281 
282  //laser_if_ = bb_->open_for_reading<Laser360Interface>("LegtrackerAveragedLaser");
283 
284  area_->set_connected(true);
285  open_interfaces(laser_if_names_);
286 
287  line_if_ = bb_->open_for_reading<ObjectPositionInterface>("LaserLine");
288  area_->set_line_if(line_if_);
289  try {
290  visdis_if_ = bb_->open_for_writing<VisualDisplay2DInterface>("LaserGUI");
291  area_->set_visdisp_if(visdis_if_);
292  } catch (Exception &e) {
293  visdis_if_ = NULL;
294  // visdisplay is optional, probably some other lasergui has it
295  // open atm
296  }
297 
298  on_legtracker_toggled();
299 
300  area_->queue_draw();
301 
302  tb_connection_->set_stock_id(Gtk::Stock::DISCONNECT);
303  tb_select_->set_sensitive(true);
304  tb_lines_->set_sensitive(true);
305  tb_points_->set_sensitive(true);
306  tb_hull_->set_sensitive(true);
307  tb_trimvals_->set_sensitive(true);
308  tb_rotation_->set_sensitive(true);
309  tb_legtracker_->set_sensitive(true);
310  tb_stop_->set_sensitive(true);
311  tb_zoom_in_->set_sensitive(true);
312  tb_zoom_out_->set_sensitive(true);
313  } catch (Exception &e) {
314  area_->reset_laser_ifs();
315  area_->set_line_if(NULL);
316  area_->set_visdisp_if(NULL);
317  area_->queue_draw();
318  area_->set_connected(false);
319  if (bb_) {
320  area_->reset_laser_ifs();
321  for (InterfaceDispatcherPairList::const_iterator it = laser_ifs_.begin();
322  it != laser_ifs_.end();
323  ++it) {
324  bb_->unregister_listener(it->second);
325  delete it->second;
326  bb_->close(it->first);
327  }
328  bb_->close(line_if_);
329  bb_->close(visdis_if_);
330  delete bb_;
331  laser_ifs_.clear();
332  bb_ = NULL;
333  line_if_ = NULL;
334  visdis_if_ = NULL;
335  }
336  }
337  }
338 
339  /** Event handler for disconnected event. */
340  virtual void
342  {
343  area_->set_connected(false);
344  area_->reset_laser_ifs();
345  area_->set_line_if(NULL);
346  area_->set_visdisp_if(NULL);
347  area_->queue_draw();
348  for (InterfaceDispatcherPairList::const_iterator it = laser_ifs_.begin();
349  it != laser_ifs_.end();
350  ++it) {
351  bb_->unregister_listener(it->second);
352  delete it->second;
353  bb_->close(it->first);
354  }
355  laser_ifs_.clear();
356  if (laser_segmentation_if_)
357  bb_->close(laser_segmentation_if_);
358  if (switch_if_)
359  bb_->close(switch_if_);
360  if (target_if_)
361  bb_->close(target_if_);
362  bb_->close(line_if_);
363  bb_->close(visdis_if_);
364 
365  std::list<ObjectPositionInterface *>::iterator objpos_if_itt;
366  std::list<Position2DTrackInterface *>::iterator track_if_itt;
367  if (l_objpos_if_persons_) {
368  for (objpos_if_itt = l_objpos_if_persons_->begin();
369  objpos_if_itt != l_objpos_if_persons_->end();
370  ++objpos_if_itt) {
371  bb_->close(*objpos_if_itt);
372  }
373  l_objpos_if_persons_->clear();
374  }
375  if (l_objpos_if_legs_) {
376  for (objpos_if_itt = l_objpos_if_legs_->begin(); objpos_if_itt != l_objpos_if_legs_->end();
377  ++objpos_if_itt) {
378  bb_->close(*objpos_if_itt);
379  }
380  l_objpos_if_legs_->clear();
381  }
382  if (l_objpos_if_misc_) {
383  for (objpos_if_itt = l_objpos_if_misc_->begin(); objpos_if_itt != l_objpos_if_misc_->end();
384  ++objpos_if_itt) {
385  bb_->close(*objpos_if_itt);
386  }
387  l_objpos_if_misc_->clear();
388  }
389  if (l_track_if_) {
390  for (track_if_itt = l_track_if_->begin(); track_if_itt != l_track_if_->end();
391  ++track_if_itt) {
392  bb_->close(*track_if_itt);
393  }
394  l_track_if_->clear();
395  }
396 
397  delete bb_;
398  bb_ = NULL;
399  laser_ifs_.clear();
400  l_objpos_if_persons_ = NULL;
401  l_objpos_if_legs_ = NULL;
402  l_objpos_if_misc_ = NULL;
403  l_track_if_ = NULL;
404  laser_segmentation_if_ = NULL;
405  switch_if_ = NULL;
406  target_if_ = NULL;
407  visdis_if_ = NULL;
408  line_if_ = NULL;
409 
410  tb_connection_->set_stock_id(Gtk::Stock::CONNECT);
411  tb_select_->set_sensitive(false);
412  tb_lines_->set_sensitive(false);
413  tb_points_->set_sensitive(false);
414  tb_hull_->set_sensitive(false);
415  tb_trimvals_->set_sensitive(false);
416  tb_rotation_->set_sensitive(false);
417  tb_legtracker_->set_sensitive(false);
418  tb_stop_->set_sensitive(false);
419  tb_zoom_in_->set_sensitive(false);
420  tb_zoom_out_->set_sensitive(false);
421  }
422 
423  /** Event handler for rotation button. */
424  void
426  {
427  if (tb_rotation_->get_active()) {
428  area_->set_rotation(M_PI / 2);
429  } else {
430  area_->set_rotation(0);
431  }
432  }
433 
434  /** Event handler for stop button */
435  void
437  {
438  area_->toggle_break_drawing();
439  }
440 
441  /** Event handler for legtracker button */
442  void
444  {
445  if (!bb_)
446  return;
447 
448  if (!tb_legtracker_->get_active()) {
449  bb_->close(laser_segmentation_if_);
450  bb_->close(switch_if_);
451  bb_->close(target_if_);
452 
453  std::list<ObjectPositionInterface *>::iterator objpos_if_itt;
454  std::list<Position2DTrackInterface *>::iterator track_if_itt;
455  if (l_objpos_if_persons_) {
456  for (objpos_if_itt = l_objpos_if_persons_->begin();
457  objpos_if_itt != l_objpos_if_persons_->end();
458  ++objpos_if_itt) {
459  bb_->close(*objpos_if_itt);
460  }
461  l_objpos_if_persons_->clear();
462  }
463  if (l_objpos_if_legs_) {
464  for (objpos_if_itt = l_objpos_if_legs_->begin(); objpos_if_itt != l_objpos_if_legs_->end();
465  ++objpos_if_itt) {
466  bb_->close(*objpos_if_itt);
467  }
468  l_objpos_if_legs_->clear();
469  }
470  if (l_objpos_if_misc_) {
471  for (objpos_if_itt = l_objpos_if_misc_->begin(); objpos_if_itt != l_objpos_if_misc_->end();
472  ++objpos_if_itt) {
473  bb_->close(*objpos_if_itt);
474  }
475  l_objpos_if_misc_->clear();
476  }
477 
478  if (l_track_if_) {
479  for (track_if_itt = l_track_if_->begin(); track_if_itt != l_track_if_->end();
480  ++track_if_itt) {
481  bb_->close(*track_if_itt);
482  }
483  l_track_if_->clear();
484  }
485 
486  laser_segmentation_if_ = NULL;
487  switch_if_ = NULL;
488  target_if_ = NULL;
489  l_objpos_if_persons_ = NULL;
490  l_objpos_if_legs_ = NULL;
491  l_objpos_if_misc_ = NULL;
492  l_track_if_ = NULL;
493 
494  area_->set_objpos_if(l_objpos_if_persons_,
495  l_objpos_if_legs_,
496  l_objpos_if_misc_,
497  laser_segmentation_if_,
498  l_track_if_,
499  target_if_,
500  switch_if_);
501 
502  } else {
503  unsigned int num_opens = 3 + MAX_OBJECTPOSITIONINTERFACES_PERSONS
504  + MAX_OBJECTPOSITIONINTERFACES_LEGS
505  + MAX_OBJECTPOSITIONINTERFACES_MISC + MAX_TRACKINTERFACES;
506 
507  float step_fraction = 1.0 / num_opens;
508  unsigned int opened = 0;
509  pgb_ltopen_->set_fraction(0);
510  dlg_ltopen_->show();
511  area_->queue_draw();
512 
513  laser_segmentation_if_ = bb_->open_for_reading<Laser720Interface>("SegmentsLaser");
514  pgb_ltopen_->set_fraction(++opened * step_fraction);
515  while (Gtk::Main::events_pending())
516  Gtk::Main::iteration();
517 
518  target_if_ = bb_->open_for_reading<ObjectPositionInterface>("legtracker Target");
519 
520  ObjectPositionInterface *new_objpos_if;
521  l_objpos_if_persons_ = new std::list<ObjectPositionInterface *>();
522  l_objpos_if_legs_ = new std::list<ObjectPositionInterface *>();
523  l_objpos_if_misc_ = new std::list<ObjectPositionInterface *>();
524  l_track_if_ = new std::list<Position2DTrackInterface *>();
525  for (int i = 1; i <= MAX_OBJECTPOSITIONINTERFACES_PERSONS; ++i) {
526  new_objpos_if = bb_->open_for_reading<ObjectPositionInterface>(
527  (std::string("legtracker CurrentLegsTracked") + StringConversions::to_string(i)).c_str());
528  l_objpos_if_persons_->push_back(new_objpos_if);
529  pgb_ltopen_->set_fraction(++opened * step_fraction);
530  while (Gtk::Main::events_pending())
531  Gtk::Main::iteration();
532  }
533  for (int i = 1; i <= MAX_OBJECTPOSITIONINTERFACES_LEGS; ++i) {
534  new_objpos_if = bb_->open_for_reading<ObjectPositionInterface>(
535  (std::string("legtracker Leg") + StringConversions::to_string(i)).c_str());
536  l_objpos_if_legs_->push_back(new_objpos_if);
537  pgb_ltopen_->set_fraction(++opened * step_fraction);
538  while (Gtk::Main::events_pending())
539  Gtk::Main::iteration();
540  }
541  for (int i = 1; i <= MAX_OBJECTPOSITIONINTERFACES_MISC; ++i) {
542  new_objpos_if = bb_->open_for_reading<ObjectPositionInterface>(
543  (std::string("legtracker Misc") + StringConversions::to_string(i)).c_str());
544  l_objpos_if_misc_->push_back(new_objpos_if);
545  pgb_ltopen_->set_fraction(++opened * step_fraction);
546  while (Gtk::Main::events_pending())
547  Gtk::Main::iteration();
548  }
549  for (int i = 1; i <= MAX_TRACKINTERFACES; ++i) {
550  Position2DTrackInterface *new_track_if = bb_->open_for_reading<Position2DTrackInterface>(
551  (std::string("legtracker Track") + StringConversions::to_string(i)).c_str());
552  l_track_if_->push_back(new_track_if);
553  pgb_ltopen_->set_fraction(++opened * step_fraction);
554  while (Gtk::Main::events_pending())
555  Gtk::Main::iteration();
556  }
557 
558  switch_if_ = bb_->open_for_reading<SwitchInterface>("legtracker write!");
559  pgb_ltopen_->set_fraction(++opened * step_fraction);
560  while (Gtk::Main::events_pending())
561  Gtk::Main::iteration();
562  dlg_ltopen_->hide();
563  area_->set_objpos_if(l_objpos_if_persons_,
564  l_objpos_if_legs_,
565  l_objpos_if_misc_,
566  laser_segmentation_if_,
567  l_track_if_,
568  target_if_,
569  switch_if_);
570  area_->queue_draw();
571  }
572  }
573 
574  /** Event handler for trim button. */
575  void
577  {
578  if (tb_trimvals_->get_active()) {
579  area_->set_resolution(3);
580  } else {
581  area_->set_resolution(1);
582  }
583  }
584 
585  /** Event handler for exit button. */
586  void
588  {
589  Gtk::Main::quit();
590  }
591 
592 private:
593  BlackBoard * bb_;
594  InterfaceDispatcherPairList laser_ifs_;
595  Laser720Interface * laser_segmentation_if_;
596  SwitchInterface * switch_if_;
597  ObjectPositionInterface * target_if_;
598 
599  std::list<ObjectPositionInterface *> * l_objpos_if_persons_;
600  std::list<ObjectPositionInterface *> * l_objpos_if_legs_;
601  std::list<ObjectPositionInterface *> * l_objpos_if_misc_;
602  std::list<Position2DTrackInterface *> *l_track_if_;
603 
604  ObjectPositionInterface * line_if_;
605  VisualDisplay2DInterface *visdis_if_;
606 
607  LaserDrawingArea * area_;
608  AllemaniACsAtHomeCairoRobotDrawer athome_drawer_;
609  ConnectionDispatcher connection_dispatcher_;
610 
611  Gtk::ToolButton * tb_connection_;
612  Gtk::RadioToolButton * tb_lines_;
613  Gtk::RadioToolButton * tb_points_;
614  Gtk::RadioToolButton * tb_hull_;
615  Gtk::ToggleToolButton *tb_trimvals_;
616  Gtk::ToggleToolButton *tb_rotation_;
617  Gtk::ToggleToolButton *tb_legtracker_;
618  Gtk::ToggleToolButton *tb_stop_;
619  Gtk::ToolButton * tb_zoom_in_;
620  Gtk::ToolButton * tb_zoom_out_;
621  Gtk::ToolButton * tb_exit_;
622  Gtk::ToolButton * tb_select_;
623 
624  Gtk::Dialog * dlg_ltopen_;
625  Gtk::ProgressBar *pgb_ltopen_;
626 
627  TypeIdPairList laser_if_names_;
628 };
629 
630 int
631 main(int argc, char **argv)
632 {
633  Gtk::Main kit(argc, argv);
634 #ifdef HAVE_GCONFMM
635  Gnome::Conf::init();
636 #endif
637 
638  Glib::RefPtr<Gtk::Builder> builder;
639  builder = Gtk::Builder::create_from_file(RESDIR "/guis/lasergui/lasergui.ui");
640 
641  LaserGuiGtkWindow *window = NULL;
642  builder->get_widget_derived("wnd_lasergui", window);
643 
644  Gtk::Main::run(*window);
645 
646  return 0;
647 }
Laser drawing area.
@ MODE_HULL
Draw hull of beams.
@ MODE_POINTS
Only draw beam end points.
@ MODE_LINES
Draw beams as lines.
void set_draw_mode(draw_mode_t mode)
Set the drawing mode.
void zoom_in()
Zoom in.
void zoom_out()
Zoom out.
Laser GUI window for Gtkmm.
Definition: lasergui.cpp:60
virtual void on_connection_clicked()
Event handler for connection button.
Definition: lasergui.cpp:148
fawkes::Interface Interface
Typedef of fawkes::Interface to override Glib::Interface.
Definition: lasergui.cpp:63
void on_stop_toggled()
Event handler for stop button.
Definition: lasergui.cpp:436
virtual void on_connect()
Event handler for connected event.
Definition: lasergui.cpp:267
LaserGuiGtkWindow(BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder)
Constructor for Gtk::Builder.
Definition: lasergui.cpp:80
virtual void on_disconnect()
Event handler for disconnected event.
Definition: lasergui.cpp:341
void on_exit_clicked()
Event handler for exit button.
Definition: lasergui.cpp:587
MultiInterfaceChooserDialog::TypeIdPairList TypeIdPairList
Shorthand for set of pairs of interface type and ID.
Definition: lasergui.cpp:67
void on_legtracker_toggled()
Event handler for legtracker button.
Definition: lasergui.cpp:443
MultiInterfaceChooserDialog::TypeIdPair TypeIdPair
Shorthand for pair of interface type and ID.
Definition: lasergui.cpp:65
std::pair< Interface *, InterfaceDispatcher * > InterfaceDispatcherPair
For each interface, an interface dispatcher is opened that listens for data changes.
Definition: lasergui.cpp:70
void on_rotation_toggled()
Event handler for rotation button.
Definition: lasergui.cpp:425
std::list< InterfaceDispatcherPair > InterfaceDispatcherPairList
A list of interfaces and their respective dispatchers.
Definition: lasergui.cpp:74
void on_trimvals_toggled()
Event handler for trim button.
Definition: lasergui.cpp:576
virtual void on_select_clicked()
Event handler for connection button.
Definition: lasergui.cpp:160
void open_interfaces(const TypeIdPairList &types_and_ids)
Open interfaces.
Definition: lasergui.cpp:191
The BlackBoard abstract class.
Definition: blackboard.h:46
@ BBIL_FLAG_DATA
consider data events
Definition: blackboard.h:88
Watches network client events and dispatches them as signals.
Base class for exceptions in Fawkes.
Definition: exception.h:36
virtual const char * what() const
Get primary string.
Definition: exception.cpp:639
Interface listener with dispatcher.
sigc::signal< void, Interface * > signal_data_changed()
Get "data changed" signal.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
Laser1080Interface Fawkes BlackBoard Interface.
Laser360Interface Fawkes BlackBoard Interface.
Laser720Interface Fawkes BlackBoard Interface.
std::list< TypeIdPair > TypeIdPairList
List of type and ID of an interface.
static MultiInterfaceChooserDialog * create(Gtk::Window &parent, BlackBoard *blackboard, const char *type_pattern, const char *id_pattern, const TypeIdPairList &loaded_interfaces, const Glib::ustring &title=DEFAULT_TITLE)
Factory method.
std::pair< Glib::ustring, Glib::ustring > TypeIdPair
Pair of type and IDs of interfaces.
ObjectPositionInterface Fawkes BlackBoard Interface.
Position2DTrackInterface Fawkes BlackBoard Interface.
Remote BlackBoard.
Definition: remote.h:49
void run_and_connect()
Run dialog and try to connect.
static std::string to_string(unsigned int i)
Convert unsigned int value to a string.
SwitchInterface Fawkes BlackBoard Interface.
VisualDisplay2DInterface Fawkes BlackBoard Interface.
Fawkes library namespace.