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" 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 # 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);
84 __area.set_robot_drawer(&__athome_drawer);
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);
128 #ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED 137 __area.set_laser360_if(NULL);
139 __bb->close(__laser_if);
152 if(!event)
return false;
154 switch (event->keyval) {
156 if ( __fullscreen ) {
180 if (event->new_window_state == GDK_WINDOW_STATE_FULLSCREEN) {
183 __fullscreen =
false;
191 if ( ! __connection_dispatcher.get_client()->connected() ) {
195 __connection_dispatcher.get_client()->disconnect();
206 __area.set_laser360_if(__laser_if);
208 __ifd->signal_data_changed().connect(sigc::hide(sigc::mem_fun(__area, &LaserDrawingArea::queue_draw)));
209 __ifd->signal_writer_removed().connect(sigc::hide(sigc::mem_fun(__area, &LaserDrawingArea::queue_draw)));
214 __tb_connection.set_stock_id(Gtk::Stock::DISCONNECT);
215 __tb_lines.set_sensitive(
true);
216 __tb_points.set_sensitive(
true);
217 __tb_hull.set_sensitive(
true);
218 __tb_lowres.set_sensitive(
true);
219 __tb_rotation.set_sensitive(
true);
220 __tb_zoom_in.set_sensitive(
true);
221 __tb_zoom_out.set_sensitive(
true);
225 __bb->close(__laser_if);
238 __area.set_laser360_if(NULL);
240 __bb->close(__laser_if);
246 __tb_connection.set_stock_id(Gtk::Stock::CONNECT);
247 __tb_lines.set_sensitive(
false);
248 __tb_points.set_sensitive(
false);
249 __tb_hull.set_sensitive(
false);
250 __tb_lowres.set_sensitive(
false);
251 __tb_rotation.set_sensitive(
false);
252 __tb_zoom_in.set_sensitive(
false);
253 __tb_zoom_out.set_sensitive(
false);
259 if ( __tb_rotation.get_active() ) {
260 __area.set_rotation(M_PI / 2);
262 __area.set_rotation(0);
269 if ( __tb_lowres.get_active() ) {
270 __area.set_resolution(3);
272 __area.set_resolution(1);
283 Gtk::Image __img_lines;
284 Gtk::Image __img_points;
285 Gtk::Image __img_hull;
286 Gtk::Image __img_lowres;
287 Gtk::Image __img_rotation;
288 Gtk::ToolButton __tb_connection;
289 Gtk::SeparatorToolItem __sep_0;
290 Gtk::RadioToolButton __tb_lines;
291 Gtk::RadioToolButton __tb_points;
292 Gtk::RadioToolButton __tb_hull;
293 Gtk::SeparatorToolItem __sep_1;
294 Gtk::ToggleToolButton __tb_lowres;
295 Gtk::ToggleToolButton __tb_rotation;
296 Gtk::SeparatorToolItem __sep_2;
297 Gtk::ToolButton __tb_zoom_in;
298 Gtk::ToolButton __tb_zoom_out;
307 main(
int argc,
char** argv)
309 Gtk::Main kit(argc, argv);
312 osso_context_t* osso_context = osso_initialize(
"lasergui",
"0.1", TRUE , 0 );
313 Glib::set_application_name(
"Laser GUI");
318 osso_deinitialize(osso_context);
Laser360Interface Fawkes BlackBoard Interface.
Only draw beam end points.
Fawkes library namespace.
virtual bool on_key_pressed(GdkEventKey *event)
Event handler for key pressed events.
virtual void on_disconnect()
Event handler for disconnected event.
void set_draw_mode(draw_mode_t mode)
Set the drawing mode.
void on_connection_clicked()
Event handler for connection button.
virtual void on_connect()
Event handler for connected event.
Base class for exceptions in Fawkes.
void run_and_connect()
Run dialog and try to connect.
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()
Destructor.
void print_trace()
Prints trace to stderr.
The BlackBoard abstract class.
Watches network client events and dispatches them as signals.
Draw AllemaniACs AtHome robot.
Interface listener with dispatcher.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)
Open interface for reading.
void on_rotation_toggled()
Event handler for rotation button.
LaserGuiHildonWindow()
Constructor.