$search
00001 00002 /*************************************************************************** 00003 * laser_drawing_area.h - Graph drawing area derived from Gtk::DrawingArea 00004 * 00005 * Created: Wed Mar 18 10:38:07 2009 00006 * Copyright 2009 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __TOOLS_SKILLGUI_GRAPH_DRAWING_AREA_H_ 00024 #define __TOOLS_SKILLGUI_GRAPH_DRAWING_AREA_H_ 00025 00026 #include <math.h> 00027 #include <sys/time.h> 00028 00029 #include <gtkmm.h> 00030 00031 #include <gvc.h> 00032 #include <gvcjob.h> 00033 00034 #include "gvplugin_skillgui_cairo.h" 00035 00036 class SkillGuiGraphDrawingArea 00037 : public Gtk::DrawingArea, 00038 public SkillGuiCairoRenderInstructor 00039 { 00040 public: 00041 00042 SkillGuiGraphDrawingArea(); 00043 ~SkillGuiGraphDrawingArea(); 00044 00045 void save(); 00046 void open(); 00047 bool set_recording(bool recording); 00048 00049 void zoom_in(); 00050 void zoom_out(); 00051 void zoom_fit(); 00052 void zoom_reset(); 00053 00054 bool set_follow_active_state(bool follow_active_state); 00055 00056 void set_graph_fsm(std::string fsm_name); 00057 void set_active_state(std::string active_state); 00058 void set_graph(std::string graph); 00059 00060 void set_bb(double bbw, double bbh); 00061 void set_pad(double pad_x, double pad_y); 00062 void set_translation(double tx, double ty); 00063 void set_scale(double scale); 00064 bool scale_override(); 00065 double get_scale(); 00066 void get_translation(double &tx, double &ty); 00067 void update_translations(); 00068 void get_dimensions(double &width, double &height); 00069 void get_pad(double &pad_x, double &pad_y); 00070 Cairo::RefPtr<Cairo::Context> get_cairo(); 00071 00072 bool get_update_graph(); 00073 void set_update_graph(bool update); 00074 00075 sigc::signal<void> signal_update_disabled(); 00076 00077 protected: 00078 virtual bool on_expose_event(GdkEventExpose* event); 00079 virtual bool on_scroll_event(GdkEventScroll *event); 00080 virtual bool on_button_press_event(GdkEventButton *event); 00081 virtual bool on_button_release_event(GdkEventButton *event); 00082 virtual bool on_motion_notify_event(GdkEventMotion *event); 00083 00084 private: 00085 void save_dotfile(const char *filename); 00086 void layout_graph(); 00087 std::string get_active_state(Agraph_t *graph); 00088 bool get_state_position(std::string state_name, double &px, double &py); 00089 00090 private: 00091 Cairo::RefPtr<Cairo::Context> __cairo; 00092 Gtk::FileChooserDialog *__fcd_save; 00093 Gtk::FileChooserDialog *__fcd_open; 00094 Gtk::FileChooserDialog *__fcd_recording; 00095 Gtk::FileFilter *__filter_pdf; 00096 Gtk::FileFilter *__filter_svg; 00097 Gtk::FileFilter *__filter_png; 00098 Gtk::FileFilter *__filter_dot; 00099 00100 sigc::signal<void> __signal_update_disabled; 00101 00102 GVC_t *__gvc; 00103 graph_t *__graph; 00104 00105 std::string __graph_dot; 00106 std::string __graph_fsm; 00107 std::string __active_state; 00108 std::string __nonupd_graph; 00109 std::string __nonupd_graph_fsm; 00110 std::string __nonupd_active_state; 00111 00112 double __bbw; 00113 double __bbh; 00114 double __pad_x; 00115 double __pad_y; 00116 double __translation_x; 00117 double __translation_y; 00118 double __scale; 00119 00120 double __last_update_time; 00121 double __speed; 00122 double __speed_max; 00123 double __speed_ramp_distance; 00124 double __translation_x_setpoint; 00125 double __translation_y_setpoint; 00126 00127 bool __mouse_motion; 00128 double __last_mouse_x; 00129 double __last_mouse_y; 00130 00131 bool __scale_override; 00132 bool __follow_active_state; 00133 bool __update_graph; 00134 00135 00136 bool __recording; 00137 std::string __record_directory; 00138 }; 00139 00140 #endif