Fawkes API  Fawkes Development Version
graph_drawing_area.h
1 
2 /***************************************************************************
3  * laser_drawing_area.h - Graph drawing area derived from Gtk::DrawingArea
4  *
5  * Created: Wed Mar 18 10:38:07 2009
6  * Copyright 2009 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __TOOLS_SKILLGUI_GRAPH_DRAWING_AREA_H_
24 #define __TOOLS_SKILLGUI_GRAPH_DRAWING_AREA_H_
25 
26 #include <gtkmm.h>
27 
28 #include <gvc.h>
29 #include <gvcjob.h>
30 
31 #include "gvplugin_skillgui_cairo.h"
32 
34 : public Gtk::DrawingArea,
36 {
37  public:
38 
41 
42  void save();
43  void open();
44  bool set_recording(bool recording);
45 
46  void zoom_in();
47  void zoom_out();
48  void zoom_fit();
49  void zoom_reset();
50 
51  void set_graph_fsm(std::string fsm_name);
52  void set_graph(std::string graph);
53 
54  void set_bb(double bbw, double bbh);
55  void set_pad(double pad_x, double pad_y);
56  void set_translation(double tx, double ty);
57  void set_scale(double scale);
58  bool scale_override();
59  double get_scale();
60  void get_translation(double &tx, double &ty);
61  void get_dimensions(double &width, double &height);
62  void get_pad(double &pad_x, double &pad_y);
63  Cairo::RefPtr<Cairo::Context> get_cairo();
64 
65  bool get_update_graph();
66  void set_update_graph(bool update);
67 
68  sigc::signal<void> signal_update_disabled();
69 
70  protected:
71 #if GTK_VERSION_GE(3,0)
72  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
73 #else
74  virtual bool on_expose_event(GdkEventExpose* event);
75 #endif
76  virtual bool on_scroll_event(GdkEventScroll *event);
77  virtual bool on_button_press_event(GdkEventButton *event);
78  virtual bool on_motion_notify_event(GdkEventMotion *event);
79 
80  private:
81  void save_dotfile(const char *filename);
82 
83  private:
84  Cairo::RefPtr<Cairo::Context> __cairo;
85  Gtk::FileChooserDialog *__fcd_save;
86  Gtk::FileChooserDialog *__fcd_open;
87  Gtk::FileChooserDialog *__fcd_recording;
88 #if GTK_VERSION_GE(3,0)
89  Glib::RefPtr<Gtk::FileFilter> __filter_pdf;
90  Glib::RefPtr<Gtk::FileFilter> __filter_svg;
91  Glib::RefPtr<Gtk::FileFilter> __filter_png;
92  Glib::RefPtr<Gtk::FileFilter> __filter_dot;
93 #else
94  Gtk::FileFilter *__filter_pdf;
95  Gtk::FileFilter *__filter_svg;
96  Gtk::FileFilter *__filter_png;
97  Gtk::FileFilter *__filter_dot;
98 #endif
99 
100  sigc::signal<void> __signal_update_disabled;
101 
102  GVC_t *__gvc;
103 
104  std::string __graph_fsm;
105  std::string __graph;
106  std::string __nonupd_graph;
107  std::string __nonupd_graph_fsm;
108 
109  double __bbw;
110  double __bbh;
111  double __pad_x;
112  double __pad_y;
113  double __translation_x;
114  double __translation_y;
115  double __scale;
116 
117  double __last_mouse_x;
118  double __last_mouse_y;
119 
120  bool __scale_override;
121  bool __update_graph;
122 
123 
124  bool __recording;
125  std::string __record_directory;
126 };
127 
128 #endif
void set_graph(std::string graph)
Set graph.
Graphviz Cairo render plugin instructor.
virtual bool on_scroll_event(GdkEventScroll *event)
Scroll event handler.
bool set_recording(bool recording)
Enable/disable recording.
sigc::signal< void > signal_update_disabled()
Get "update disabled" signal.
SkillGuiGraphDrawingArea()
Constructor.
Graph drawing area.
double get_scale()
Get scale.
bool get_update_graph()
Check if graph is being updated.
void set_graph_fsm(std::string fsm_name)
Set graph&#39;s FSM name.
virtual bool on_expose_event(GdkEventExpose *event)
Expose event handler.
Cairo::RefPtr< Cairo::Context > get_cairo()
Get Cairo context.
virtual bool on_motion_notify_event(GdkEventMotion *event)
Mouse motion notify event handler.
void zoom_fit()
Zoom to fit.
bool scale_override()
Check if scale override is enabled.
void save()
save current graph.
void get_translation(double &tx, double &ty)
Get translation.
void set_update_graph(bool update)
Set if the graph should be updated on new data.
void get_dimensions(double &width, double &height)
Get dimensions.
void set_pad(double pad_x, double pad_y)
Set padding.
void get_pad(double &pad_x, double &pad_y)
Get padding.
void set_translation(double tx, double ty)
Set translation.
void set_bb(double bbw, double bbh)
Set bounding box.
void open()
Open a dot graph and display it.
virtual bool on_button_press_event(GdkEventButton *event)
Button press event handler.
void set_scale(double scale)
Set scale.