23#include "laser_drawing_area.h"
25#include <blackboard/remote.h>
26#include <gui_utils/connection_dispatcher.h>
27#include <gui_utils/interface_dispatcher.h>
28#include <gui_utils/robot/allemaniacs_athome.h>
29#include <gui_utils/service_chooser_dialog.h>
30#include <interfaces/Laser360Interface.h>
31#include <netcomm/fawkes/client.h>
37#if MAEMO_VERSION_MAJOR >= 5
38# define ICON_FORMAT "white_48x48"
40# define ICON_FORMAT "32x32"
55 : athome_drawer_(true),
56 img_lines_(RESDIR
"/guis/lasergui/lines_" ICON_FORMAT
".png"),
57 img_points_(RESDIR
"/guis/lasergui/points_" ICON_FORMAT
".png"),
58 img_hull_(RESDIR
"/guis/lasergui/hull_" ICON_FORMAT
".png"),
59 img_lowres_(RESDIR
"/guis/lasergui/lines_lowres_" ICON_FORMAT
".png"),
60 img_rotation_(RESDIR
"/guis/lasergui/rotate-90.png"),
61 tb_connection_(Gtk::Stock::CONNECT),
62 tb_lines_(img_lines_),
63 tb_points_(img_points_),
65 tb_lowres_(img_lowres_),
66 tb_rotation_(img_rotation_),
67 tb_zoom_in_(Gtk::Stock::ZOOM_IN),
68 tb_zoom_out_(Gtk::Stock::ZOOM_OUT)
75#if GLIBMM_MAJOR_VERSION > 2 || (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION >= 48)
76 std::unique_ptr<Glib::Error> error;
78 std::auto_ptr<Glib::Error> error;
80 set_icon_from_file(RESDIR
"/guis/lasergui/lines_" ICON_FORMAT
".png", error);
86 Gtk::RadioButton::Group group = tb_lines_.get_group();
87 tb_points_.set_group(group);
88 group = tb_lines_.get_group();
89 tb_hull_.set_group(group);
90 tb_lines_.set_active(
true);
92 tb_lines_.set_sensitive(
false);
93 tb_points_.set_sensitive(
false);
94 tb_hull_.set_sensitive(
false);
95 tb_lowres_.set_sensitive(
false);
96 tb_rotation_.set_sensitive(
false);
97 tb_zoom_in_.set_sensitive(
false);
98 tb_zoom_out_.set_sensitive(
false);
100 tbar_.append(tb_connection_);
101 tbar_.append(sep_0_);
102 tbar_.append(tb_lines_);
103 tbar_.append(tb_points_);
104 tbar_.append(tb_hull_);
105 tbar_.append(sep_1_);
106 tbar_.append(tb_lowres_);
107 tbar_.append(tb_rotation_);
108 tbar_.append(sep_2_);
109 tbar_.append(tb_zoom_in_);
110 tbar_.append(tb_zoom_out_);
115 tb_lines_.signal_toggled().connect(
118 tb_points_.signal_toggled().connect(
121 tb_hull_.signal_toggled().connect(
127 tb_connection_.signal_clicked().connect(
129 tb_rotation_.signal_clicked().connect(
131 tb_lowres_.signal_clicked().connect(
139#ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
141 signal_window_state_event().connect(
149 area_.set_laser360_if(NULL);
151 bb_->
close(laser_if_);
168 switch (event->keyval) {
176 case GDK_F7: area_.
zoom_in();
break;
177 case GDK_F8: area_.
zoom_out();
break;
191 if (event->new_window_state == GDK_WINDOW_STATE_FULLSCREEN) {
219 area_.set_laser360_if(laser_if_);
222 sigc::hide(sigc::mem_fun(area_, &LaserDrawingArea::queue_draw)));
224 sigc::hide(sigc::mem_fun(area_, &LaserDrawingArea::queue_draw)));
225 bb_->
register_listener(ifd_, BlackBoard::BBIL_FLAG_DATA | BlackBoard::BBIL_FLAG_WRITER);
229 tb_connection_.set_stock_id(Gtk::Stock::DISCONNECT);
230 tb_lines_.set_sensitive(
true);
231 tb_points_.set_sensitive(
true);
232 tb_hull_.set_sensitive(
true);
233 tb_lowres_.set_sensitive(
true);
234 tb_rotation_.set_sensitive(
true);
235 tb_zoom_in_.set_sensitive(
true);
236 tb_zoom_out_.set_sensitive(
true);
240 bb_->
close(laser_if_);
254 area_.set_laser360_if(NULL);
256 bb_->
close(laser_if_);
262 tb_connection_.set_stock_id(Gtk::Stock::CONNECT);
263 tb_lines_.set_sensitive(
false);
264 tb_points_.set_sensitive(
false);
265 tb_hull_.set_sensitive(
false);
266 tb_lowres_.set_sensitive(
false);
267 tb_rotation_.set_sensitive(
false);
268 tb_zoom_in_.set_sensitive(
false);
269 tb_zoom_out_.set_sensitive(
false);
276 if (tb_rotation_.get_active()) {
287 if (tb_lowres_.get_active()) {
301 Gtk::Image img_lines_;
302 Gtk::Image img_points_;
303 Gtk::Image img_hull_;
304 Gtk::Image img_lowres_;
305 Gtk::Image img_rotation_;
306 Gtk::ToolButton tb_connection_;
307 Gtk::SeparatorToolItem sep_0_;
308 Gtk::RadioToolButton tb_lines_;
309 Gtk::RadioToolButton tb_points_;
310 Gtk::RadioToolButton tb_hull_;
311 Gtk::SeparatorToolItem sep_1_;
312 Gtk::ToggleToolButton tb_lowres_;
313 Gtk::ToggleToolButton tb_rotation_;
314 Gtk::SeparatorToolItem sep_2_;
315 Gtk::ToolButton tb_zoom_in_;
316 Gtk::ToolButton tb_zoom_out_;
325main(
int argc,
char **argv)
327 Gtk::Main kit(argc, argv);
330 osso_context_t *osso_context = osso_initialize(
"lasergui",
334 Glib::set_application_name(
"Laser GUI");
339 osso_deinitialize(osso_context);
void set_robot_drawer(fawkes::CairoRobotDrawer *robot_drawer)
Set robot drawer.
@ MODE_HULL
Draw hull of beams.
@ MODE_POINTS
Only draw beam end points.
@ MODE_LINES
Draw beams as lines.
void set_resolution(unsigned int resolution)
Set resolution.
void set_rotation(float rot_rad)
Set rotation.
void set_draw_mode(draw_mode_t mode)
Set the drawing mode.
Laser GUI window for Hildon.
void on_resolution_toggled()
Event handler for rotation button.
virtual bool on_window_state_event(GdkEventWindowState *event)
Event handler for window state change events.
LaserGuiHildonWindow()
Constructor.
void on_rotation_toggled()
Event handler for rotation button.
~LaserGuiHildonWindow()
Destructor.
virtual void on_connect()
Event handler for connected event.
void on_connection_clicked()
Event handler for connection button.
virtual bool on_key_pressed(GdkEventKey *event)
Event handler for key pressed events.
virtual void on_disconnect()
Event handler for disconnected event.
Draw AllemaniACs AtHome robot.
The BlackBoard abstract class.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
virtual void register_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Register BB event listener.
virtual void close(Interface *interface)=0
Close interface.
Watches network client events and dispatches them as signals.
sigc::signal< void > signal_connected()
Get "connected" signal.
FawkesNetworkClient * get_client()
Get client.
sigc::signal< void > signal_disconnected()
Get "disconnected" signal.
Base class for exceptions in Fawkes.
void print_trace() noexcept
Prints trace to stderr.
void disconnect()
Disconnect socket.
bool connected() const noexcept
Check if connection is alive.
Interface listener with dispatcher.
sigc::signal< void, Interface * > signal_writer_removed()
Get "writer removed" signal.
sigc::signal< void, Interface * > signal_data_changed()
Get "data changed" signal.
Laser360Interface Fawkes BlackBoard Interface.
void run_and_connect()
Run dialog and try to connect.
Fawkes library namespace.