23 #include "laser_drawing_area.h"
25 #include <gui_utils/robot/allemaniacs_athome.h>
30 #include <netcomm/fawkes/client.h>
31 #include <blackboard/remote.h>
32 #include <interfaces/Laser360Interface.h>
33 #include <gui_utils/interface_dispatcher.h>
34 #include <gui_utils/connection_dispatcher.h>
35 #include <gui_utils/service_chooser_dialog.h>
37 #if MAEMO_VERSION_MAJOR >= 5
38 # define ICON_FORMAT "white_48x48"
40 # define ICON_FORMAT "32x32"
43 using namespace fawkes;
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),
64 __tb_hull(__img_hull),
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 std::auto_ptr<Glib::Error> error;
76 set_icon_from_file(RESDIR
"/guis/lasergui/lines_"ICON_FORMAT
".png", error);
80 __area.set_robot_drawer(&__athome_drawer);
82 Gtk::RadioButton::Group group = __tb_lines.get_group();
83 __tb_points.set_group(group);
84 group = __tb_lines.get_group();
85 __tb_hull.set_group(group);
86 __tb_lines.set_active(
true);
88 __tb_lines.set_sensitive(
false);
89 __tb_points.set_sensitive(
false);
90 __tb_hull.set_sensitive(
false);
91 __tb_lowres.set_sensitive(
false);
92 __tb_rotation.set_sensitive(
false);
93 __tb_zoom_in.set_sensitive(
false);
94 __tb_zoom_out.set_sensitive(
false);
96 __tbar.append(__tb_connection);
97 __tbar.append(__sep_0);
98 __tbar.append(__tb_lines);
99 __tbar.append(__tb_points);
100 __tbar.append(__tb_hull);
101 __tbar.append(__sep_1);
102 __tbar.append(__tb_lowres);
103 __tbar.append(__tb_rotation);
104 __tbar.append(__sep_2);
105 __tbar.append(__tb_zoom_in);
106 __tbar.append(__tb_zoom_out);
124 #ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
133 __area.set_laser360_if(NULL);
135 __bb->close(__laser_if);
146 virtual bool on_key_pressed(GdkEventKey* event)
148 if(!event)
return false;
150 switch (event->keyval) {
152 if ( __fullscreen ) {
174 virtual bool on_window_state_event(GdkEventWindowState *event)
176 if (event->new_window_state == GDK_WINDOW_STATE_FULLSCREEN) {
179 __fullscreen =
false;
185 void on_connection_clicked()
187 if ( ! __connection_dispatcher.get_client()->connected() ) {
191 __connection_dispatcher.get_client()->disconnect();
196 virtual void on_connect()
202 __area.set_laser360_if(__laser_if);
204 __ifd->signal_data_changed().connect(sigc::hide(sigc::mem_fun(__area, &LaserDrawingArea::queue_draw)));
205 __ifd->signal_writer_removed().connect(sigc::hide(sigc::mem_fun(__area, &LaserDrawingArea::queue_draw)));
210 __tb_connection.set_stock_id(Gtk::Stock::DISCONNECT);
211 __tb_lines.set_sensitive(
true);
212 __tb_points.set_sensitive(
true);
213 __tb_hull.set_sensitive(
true);
214 __tb_lowres.set_sensitive(
true);
215 __tb_rotation.set_sensitive(
true);
216 __tb_zoom_in.set_sensitive(
true);
217 __tb_zoom_out.set_sensitive(
true);
221 __bb->close(__laser_if);
232 virtual void on_disconnect()
234 __area.set_laser360_if(NULL);
236 __bb->close(__laser_if);
242 __tb_connection.set_stock_id(Gtk::Stock::CONNECT);
243 __tb_lines.set_sensitive(
false);
244 __tb_points.set_sensitive(
false);
245 __tb_hull.set_sensitive(
false);
246 __tb_lowres.set_sensitive(
false);
247 __tb_rotation.set_sensitive(
false);
248 __tb_zoom_in.set_sensitive(
false);
249 __tb_zoom_out.set_sensitive(
false);
253 void on_rotation_toggled()
255 if ( __tb_rotation.get_active() ) {
256 __area.set_rotation(M_PI / 2);
258 __area.set_rotation(0);
263 void on_resolution_toggled()
265 if ( __tb_lowres.get_active() ) {
266 __area.set_resolution(3);
268 __area.set_resolution(1);
279 Gtk::Image __img_lines;
280 Gtk::Image __img_points;
281 Gtk::Image __img_hull;
282 Gtk::Image __img_lowres;
283 Gtk::Image __img_rotation;
284 Gtk::ToolButton __tb_connection;
285 Gtk::SeparatorToolItem __sep_0;
286 Gtk::RadioToolButton __tb_lines;
287 Gtk::RadioToolButton __tb_points;
288 Gtk::RadioToolButton __tb_hull;
289 Gtk::SeparatorToolItem __sep_1;
290 Gtk::ToggleToolButton __tb_lowres;
291 Gtk::ToggleToolButton __tb_rotation;
292 Gtk::SeparatorToolItem __sep_2;
293 Gtk::ToolButton __tb_zoom_in;
294 Gtk::ToolButton __tb_zoom_out;
303 main(
int argc,
char** argv)
305 Gtk::Main kit(argc, argv);
308 osso_context_t* osso_context = osso_initialize(
"lasergui",
"0.1", TRUE , 0 );
309 Glib::set_application_name(
"Laser GUI");
314 osso_deinitialize(osso_context);