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 "gvplugin_skillgui_cairo.h"
27 
28 #include <gtkmm.h>
29 #include <gvc.h>
30 #include <gvcjob.h>
31 
32 class SkillGuiGraphDrawingArea : public Gtk::DrawingArea, public SkillGuiCairoRenderInstructor
33 {
34 public:
37 
39 
40  void save();
41  void open();
42  bool set_recording(bool recording);
43 
44  void zoom_in();
45  void zoom_out();
46  void zoom_fit();
47  void zoom_reset();
48 
49  void set_graph_fsm(const std::string &fsm_name);
50  void set_graph(const std::string &graph);
51 
52  void set_bb(double bbw, double bbh);
53  void set_pad(double pad_x, double pad_y);
54  void set_translation(double tx, double ty);
55  void set_scale(double scale);
56  bool scale_override();
57  double get_scale();
58  void get_translation(double &tx, double &ty);
59  void get_dimensions(double &width, double &height);
60  void get_pad(double &pad_x, double &pad_y);
61  Cairo::RefPtr<Cairo::Context> get_cairo();
62 
63  bool get_update_graph();
64  void set_update_graph(bool update);
65 
66  sigc::signal<void> signal_update_disabled();
67 
68 protected:
69 #if GTK_VERSION_GE(3, 0)
70  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
71 #else
72  virtual bool on_expose_event(GdkEventExpose *event);
73 #endif
74  virtual bool on_scroll_event(GdkEventScroll *event);
75  virtual bool on_button_press_event(GdkEventButton *event);
76  virtual bool on_motion_notify_event(GdkEventMotion *event);
77 
78 private:
79  void save_dotfile(const char *filename);
80 
81 private:
82  Cairo::RefPtr<Cairo::Context> cairo_;
83  Gtk::FileChooserDialog * fcd_save_;
84  Gtk::FileChooserDialog * fcd_open_;
85  Gtk::FileChooserDialog * fcd_recording_;
86 #if GTK_VERSION_GE(3, 0)
87  Glib::RefPtr<Gtk::FileFilter> filter_pdf_;
88  Glib::RefPtr<Gtk::FileFilter> filter_svg_;
89  Glib::RefPtr<Gtk::FileFilter> filter_png_;
90  Glib::RefPtr<Gtk::FileFilter> filter_dot_;
91 #else
92  Gtk::FileFilter *filter_pdf_;
93  Gtk::FileFilter *filter_svg_;
94  Gtk::FileFilter *filter_png_;
95  Gtk::FileFilter *filter_dot_;
96 #endif
97 
98  sigc::signal<void> signal_update_disabled_;
99 
100  GVC_t *gvc_;
101 
102  std::string graph_fsm_;
103  std::string graph_;
104  std::string nonupd_graph_;
105  std::string nonupd_graph_fsm_;
106 
107  double bbw_;
108  double bbh_;
109  double pad_x_;
110  double pad_y_;
111  double translation_x_;
112  double translation_y_;
113  double scale_;
114 
115  double last_mouse_x_;
116  double last_mouse_y_;
117 
118  bool scale_override_;
119  bool update_graph_;
120 
121  bool recording_;
122  std::string record_directory_;
123 };
124 
125 #endif
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.
bool get_update_graph()
Check if graph is being updated.
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.
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 set_graph(const std::string &graph)
Set graph.
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_graph_fsm(const std::string &fsm_name)
Set graph's FSM name.
void set_scale(double scale)
Set scale.