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>
50 #include <boost/format.hpp>
57 using namespace boost;
71 return o<<i.x<<
" "<<i.y;
76 return o<<
"LL: "<<i.LL<<
" UR: "<<i.UR;
82 if(pthread_mutex_trylock(&(
htreePtr->_draw_mutex))!=0)
87 pthread_mutex_unlock(&(
htreePtr->_draw_mutex));
104 for(uint a=0;a<(*it)->_attribute_names.size();++a)
117 pthread_mutex_unlock(&(
htreePtr->_draw_mutex));
125 pthread_mutex_lock(&(
htreePtr->_draw_mutex));
127 GVJ_t *job = (GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
128 cairo_t *cr = gdk_cairo_create(widget->window);
130 (job->callbacks->motion)(job, job->pointer);
132 job->context = (
void *)cr;
133 job->external_context =
true;
134 job->width = widget->allocation.width;
135 job->height = widget->allocation.height;
138 (job->callbacks->refresh)(job);
143 pthread_mutex_unlock(&(
htreePtr->_draw_mutex));
150 static bool init=
true;
151 static bool dragging=
false;
155 g_object_set_data(G_OBJECT(widget),
"dragging",&dragging);
159 if(event->type==GDK_BUTTON_PRESS)
161 else if(event->type==GDK_BUTTON_RELEASE)
169 static bool first_drag=
true;
171 GVJ_t *job = (GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
173 bool *dragging_p = (
bool*)g_object_get_data(G_OBJECT(widget),
"dragging");
177 bool dragging=*dragging_p;
181 double dpix=-1/job->devscale.x;
182 double dpiy=-1/job->devscale.y;
184 diff.x=
event->x-job->pointer.x;
185 diff.y=
event->y-job->pointer.y;
187 job->pointer.x =
event->x;
188 job->pointer.y =
event->y;
190 gtk_widget_queue_draw(widget);
201 job->focus.x+= diff.x*dpix/job->zoom;
202 job->focus.y+= diff.y*dpiy/job->zoom;
204 double x_lim = (0.37*job->width-1)/job->zoom;
205 double y_lim = (0.37*job->height-1)/job->zoom;
214 if(job->focus.x>= x_lim)
217 if(job->focus.y>= y_lim)
226 if(event->type==GDK_SCROLL)
228 GVJ_t *job = (GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
234 if(event->direction==GDK_SCROLL_UP)
235 (job->callbacks->button_press)(job,4, pointer);
236 else if(event->direction==GDK_SCROLL_DOWN)
237 (job->callbacks->button_press)(job,5, pointer);
239 double x_lim = (0.37*job->width-1)/job->zoom;
240 double y_lim = (0.37*job->height-1)/job->zoom;
242 if(job->focus.x>= x_lim)
245 if(job->focus.y>= y_lim)
269 job = (GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
271 if (! job->has_been_rendered)
273 zoom_to_fit = MIN((
double) event->width / (
double) job->width,(
double) event->height / (
double) job->height);
274 if (zoom_to_fit < 1.0)
275 job->zoom *= zoom_to_fit;
276 }
else if(job->fit_mode)
278 zoom_to_fit = MIN((
double) event->width / (
double) job->width, (
double) event->height / (
double) job->height);
279 job->zoom *= zoom_to_fit;
282 if ((
unsigned int)event->width > job->width || (
unsigned int)event->height > job->height)
283 job->has_grown = TRUE;
285 job->width =
event->width;
286 job->height =
event->height;
287 job->needs_refresh = TRUE;
gboolean WindowDeleteEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data)
An object containing a libgraph graph and its associated nodes and edges. .
gboolean DrawingareaMotionNotifyEvent(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
gboolean DrawingareaScrollEvent(GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
gboolean DrawingareaConfigureEvent(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
GVGraph * graph_context
External variable linking to the main graph context created in the mht main source code pmht...
void clearNodes()
Clear the whole graph.
void addNode(const string &name)
Add a new node to the graph.
gboolean DrawingareaExposeEvent(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
boost::shared_ptr< HypothesisTree > hypothesisTreePtr
Shared pointer to the HypothesisTree class.
ostream & operator<<(ostream &o, const pointf &i)
gboolean DrawingareaButtonPressEvent(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
int agrelabel_node(Agnode_t *n, char *newname)
GVGraph class declaration.
int setNodeAttribute(string name, string attribute, string value)
Sets node attributes.
void freeLayout()
Free the layout This function should be called before any modifications to the current graph...
Callback header, only function prototypes.
void addEdge(const string &source, const string &target)
Add a new edge.
pre_order_iterator iterator
The default iterator types throughout the tree class.
void applyLayout()
Apply a new layout.
hypothesisTreePtr htreePtr
External variable linking to the Mht context class (main workhorse of the mht algorithm) ...
Hypotheses tree class declaration.