Fawkes API  Fawkes Development Version
graph_drawing_area.h
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 <gtkmm.h>
00027 
00028 #include <gvc.h>
00029 #include <gvcjob.h>
00030 
00031 #include "gvplugin_skillgui_cairo.h"
00032 
00033 class SkillGuiGraphDrawingArea
00034 : public Gtk::DrawingArea,
00035   public SkillGuiCairoRenderInstructor
00036 {
00037  public:
00038 
00039   SkillGuiGraphDrawingArea();
00040   ~SkillGuiGraphDrawingArea();
00041 
00042   void save();
00043   void open();
00044   bool set_recording(bool recording);
00045 
00046   void zoom_in();
00047   void zoom_out();
00048   void zoom_fit();
00049   void zoom_reset();
00050 
00051   void set_graph_fsm(std::string fsm_name);
00052   void set_graph(std::string graph);
00053 
00054   void   set_bb(double bbw, double bbh);
00055   void   set_pad(double pad_x, double pad_y);
00056   void   set_translation(double tx, double ty);
00057   void   set_scale(double scale);
00058   bool   scale_override();
00059   double get_scale();
00060   void   get_translation(double &tx, double &ty);
00061   void   get_dimensions(double &width, double &height);
00062   void   get_pad(double &pad_x, double &pad_y);
00063   Cairo::RefPtr<Cairo::Context> get_cairo();
00064 
00065   bool get_update_graph();
00066   void set_update_graph(bool update);
00067 
00068   sigc::signal<void> signal_update_disabled();
00069 
00070  protected:
00071 #if GTK_VERSION_GE(3,0)
00072   virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
00073 #else
00074   virtual bool on_expose_event(GdkEventExpose* event);
00075 #endif
00076   virtual bool on_scroll_event(GdkEventScroll *event);
00077   virtual bool on_button_press_event(GdkEventButton *event);
00078   virtual bool on_motion_notify_event(GdkEventMotion *event);
00079 
00080  private:
00081   void save_dotfile(const char *filename);
00082 
00083  private:
00084   Cairo::RefPtr<Cairo::Context> __cairo;
00085   Gtk::FileChooserDialog *__fcd_save;
00086   Gtk::FileChooserDialog *__fcd_open;
00087   Gtk::FileChooserDialog *__fcd_recording;
00088 #if GTK_VERSION_GE(3,0)
00089   Glib::RefPtr<Gtk::FileFilter> __filter_pdf;
00090   Glib::RefPtr<Gtk::FileFilter> __filter_svg;
00091   Glib::RefPtr<Gtk::FileFilter> __filter_png;
00092   Glib::RefPtr<Gtk::FileFilter> __filter_dot;
00093 #else
00094   Gtk::FileFilter *__filter_pdf;
00095   Gtk::FileFilter *__filter_svg;
00096   Gtk::FileFilter *__filter_png;
00097   Gtk::FileFilter *__filter_dot;
00098 #endif
00099 
00100   sigc::signal<void> __signal_update_disabled;
00101 
00102   GVC_t *__gvc;
00103 
00104   std::string __graph_fsm;
00105   std::string __graph;
00106   std::string __nonupd_graph;
00107   std::string __nonupd_graph_fsm;
00108 
00109   double __bbw;
00110   double __bbh;
00111   double __pad_x;
00112   double __pad_y;
00113   double __translation_x;
00114   double __translation_y;
00115   double __scale;
00116 
00117   double __last_mouse_x;
00118   double __last_mouse_y;
00119 
00120   bool __scale_override;
00121   bool __update_graph;
00122 
00123 
00124   bool __recording;
00125   std::string __record_directory;
00126 };
00127 
00128 #endif