34 #include <graphviz/gvplugin_device.h>
35 #include <graphviz/gvplugin_render.h>
36 #include <graphviz/gvplugin.h>
37 #include <graphviz/gvc.h>
38 #include <graphviz/gvplugin_layout.h>
39 #include <graphviz/gvcjob.h>
40 #include <graphviz/gvcommon.h>
41 #include <graphviz/gvcext.h>
42 #include <graphviz/types.h>
43 #include <graphviz/graph.h>
44 #include <graphviz/geom.h>
51 #include <mtt/tree.hh>
54 #include <boost/format.hpp>
59 using namespace boost;
73 return o<<i.x<<
" "<<i.y;
78 return o<<
"LL: "<<i.LL<<
" UR: "<<i.UR;
83 GVJ_t *job = (GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
84 cairo_t *cr = gdk_cairo_create(widget->window);
86 (job->callbacks->motion)(job, job->pointer);
88 job->context = (
void *)cr;
89 job->external_context =
true;
90 job->width = widget->allocation.width;
91 job->height = widget->allocation.height;
100 (job->callbacks->refresh)(job);
149 (job->callbacks->refresh)(job);
158 static bool init=
true;
159 static bool dragging=
false;
163 g_object_set_data(G_OBJECT(widget),
"dragging",&dragging);
167 if(event->type==GDK_BUTTON_PRESS)
169 else if(event->type==GDK_BUTTON_RELEASE)
177 static bool first_drag=
true;
179 GVJ_t *job = (GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
181 bool *dragging_p = (
bool*)g_object_get_data(G_OBJECT(widget),
"dragging");
185 bool dragging=*dragging_p;
189 double dpix=-1/job->devscale.x;
190 double dpiy=-1/job->devscale.y;
192 diff.x=
event->x-job->pointer.x;
193 diff.y=
event->y-job->pointer.y;
195 job->pointer.x =
event->x;
196 job->pointer.y =
event->y;
198 gtk_widget_queue_draw(widget);
209 job->focus.x+= diff.x*dpix/job->zoom;
210 job->focus.y+= diff.y*dpiy/job->zoom;
212 double x_lim = (0.37*job->width-1)/job->zoom;
213 double y_lim = (0.37*job->height-1)/job->zoom;
222 if(job->focus.x>= x_lim)
225 if(job->focus.y>= y_lim)
234 if(event->type==GDK_SCROLL)
236 GVJ_t *job = (GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
242 if(event->direction==GDK_SCROLL_UP)
243 (job->callbacks->button_press)(job,4, pointer);
244 else if(event->direction==GDK_SCROLL_DOWN)
245 (job->callbacks->button_press)(job,5, pointer);
247 double x_lim = (0.37*job->width-1)/job->zoom;
248 double y_lim = (0.37*job->height-1)/job->zoom;
250 if(job->focus.x>= x_lim)
253 if(job->focus.y>= y_lim)
277 job = (GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
279 if (! job->has_been_rendered)
281 zoom_to_fit = MIN((
double) event->width / (
double) job->width,(
double) event->height / (
double) job->height);
282 if (zoom_to_fit < 1.0)
283 job->zoom *= zoom_to_fit;
284 }
else if(job->fit_mode)
286 zoom_to_fit = MIN((
double) event->width / (
double) job->width, (
double) event->height / (
double) job->height);
287 job->zoom *= zoom_to_fit;
290 if ((
unsigned int)event->width > job->width || (
unsigned int)event->height > job->height)
291 job->has_grown = TRUE;
293 job->width =
event->width;
294 job->height =
event->height;
295 job->needs_refresh = TRUE;
An object containing a libgraph graph and its associated nodes and edges. .
gboolean WindowDeleteEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data)
int agrelabel_node(Agnode_t *n, char *newname)
void clearNodes()
Clear the whole graph.
tree< t_nodePtr > global_tree
External variable linking to the main tree pointer in pmht.cpp.
void addNode(const string &name)
Add a new node to the graph.
ostream & operator<<(ostream &o, const pointf &i)
GVGraph * graph_context
External variable linking to the main graph context created in the mht main source code pmht...
Header for type declaration, only constant velocity Kalman filter.
gboolean DrawingareaExposeEvent(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
gboolean DrawingareaScrollEvent(GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
gboolean DrawingareaButtonPressEvent(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
GVGraph class declaration.
gboolean DrawingareaConfigureEvent(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
int setNodeAttribute(string name, string attribute, string value)
Sets node attributes.
gboolean DrawingareaMotionNotifyEvent(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
Depth-first iterator, first accessing the node, then its children.
Callback header, only function prototypes.
void addEdge(const string &source, const string &target)
Add a new edge.
void applyLayout()
Apply a new layout.