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   virtual bool on_expose_event(GdkEventExpose* event);
00072   virtual bool on_scroll_event(GdkEventScroll *event);
00073   virtual bool on_button_press_event(GdkEventButton *event);
00074   virtual bool on_motion_notify_event(GdkEventMotion *event);
00075 
00076  private:
00077   void save_dotfile(const char *filename);
00078 
00079  private:
00080   Cairo::RefPtr<Cairo::Context> __cairo;
00081   Gtk::FileChooserDialog *__fcd_save;
00082   Gtk::FileChooserDialog *__fcd_open;
00083   Gtk::FileChooserDialog *__fcd_recording;
00084   Gtk::FileFilter *__filter_pdf;
00085   Gtk::FileFilter *__filter_svg;
00086   Gtk::FileFilter *__filter_png;
00087   Gtk::FileFilter *__filter_dot;
00088 
00089   sigc::signal<void> __signal_update_disabled;
00090 
00091   GVC_t *__gvc;
00092 
00093   std::string __graph_fsm;
00094   std::string __graph;
00095   std::string __nonupd_graph;
00096   std::string __nonupd_graph_fsm;
00097 
00098   double __bbw;
00099   double __bbh;
00100   double __pad_x;
00101   double __pad_y;
00102   double __translation_x;
00103   double __translation_y;
00104   double __scale;
00105 
00106   double __last_mouse_x;
00107   double __last_mouse_y;
00108 
00109   bool __scale_override;
00110   bool __update_graph;
00111 
00112 
00113   bool __recording;
00114   std::string __record_directory;
00115 };
00116 
00117 #endif