From: arif Date: Wed, 3 Mar 2010 19:23:10 +0000 (+0000) Subject: smyrna polygon selection improvement X-Git-Tag: LAST_LIBGRAPH~32^2~1414 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1a3395c4b3702acdf9bc8359ff614d5defbfdd56;p=graphviz smyrna polygon selection improvement --- diff --git a/cmd/smyrna/draw.c b/cmd/smyrna/draw.c index 615271d89..61b806b26 100755 --- a/cmd/smyrna/draw.c +++ b/cmd/smyrna/draw.c @@ -977,8 +977,16 @@ void draw_selpoly(glCompPoly* selPoly) glVertex3f(selPoly->pts[i].x,selPoly->pts[i].y,selPoly->pts[i].z); } glEnd(); + if(selPoly->cnt >0) + { + glBegin(GL_LINE_STRIP); + glVertex3f(selPoly->pts[selPoly->cnt-1].x,selPoly->pts[selPoly->cnt-1].y,selPoly->pts[selPoly->cnt-1].z); + glVertex3f(view->mouse.GLpos.x,view->mouse.GLpos.y,0); + glEnd(); + } glEnable(GL_DEPTH_TEST); + } #ifdef UNUSED diff --git a/cmd/smyrna/gltemplate.c b/cmd/smyrna/gltemplate.c index 688855ee3..33ecc7943 100755 --- a/cmd/smyrna/gltemplate.c +++ b/cmd/smyrna/gltemplate.c @@ -325,20 +325,17 @@ static gboolean button_release_event(GtkWidget * widget, } static gboolean key_press_event(GtkWidget * widget, GdkEventKey * event, gpointer data) { - view->keymap.down=1; - view->keymap.keyVal=event->keyval; - return FALSE; + appmouse_key_press(view,event->keyval); + return FALSE; + } static gboolean key_release_event(GtkWidget * widget, GdkEventKey * event, gpointer data) { - // printf ("key is released:%d\n",event->keyval); - view->keymap.down=0; - view->keymap.keyVal=0; - return FALSE; - + appmouse_key_release(view,event->keyval); + return FALSE; } @@ -382,6 +379,8 @@ static gboolean motion_notify_event(GtkWidget * widget, dy = y - begin_y; view->mouse.dragX = dx; view->mouse.dragY = dy; + appmouse_move(view,(int)event->x,(int)event->y); + if((view->mouse.t==glMouseLeftButton) && (view->mouse.down) ) { appmouse_left_drag(view,(int)event->x,(int)event->y); @@ -398,6 +397,8 @@ static gboolean motion_notify_event(GtkWidget * widget, appmouse_middle_drag(view,(int)event->x,(int)event->y); redraw = TRUE; } + if(view->Topview->selPoly.cnt > 0) + redraw=TRUE; diff --git a/cmd/smyrna/gui/appmouse.c b/cmd/smyrna/gui/appmouse.c index 516bccb48..6d12a14b1 100644 --- a/cmd/smyrna/gui/appmouse.c +++ b/cmd/smyrna/gui/appmouse.c @@ -28,6 +28,7 @@ static float prevX=0; static float prevY=0; + static int lastAction; static void apply_actions(ViewInfo* v,int x,int y) { int a; @@ -88,6 +89,7 @@ static void apply_actions(ViewInfo* v,int x,int y) } } + lastAction=a; @@ -220,4 +222,25 @@ void appmouse_middle_drag(ViewInfo* v,int x,int y) appmouse_drag(v,x,y); } +void appmouse_move(ViewInfo* v,int x,int y) +{ + to3D( x,y, &v->mouse.GLpos.x,&v->mouse.GLpos.y,&v->mouse.GLpos.z); +} +void appmouse_key_release(ViewInfo* v,int key) +{ + int action=get_key_action(v,key); + if(lastAction==MM_POLYGON_SELECT) + { + clear_selpoly(&view->Topview->selPoly); + glexpose(); + } + v->keymap.down=0; + v->keymap.keyVal=0; +} +void appmouse_key_press(ViewInfo* v,int key) +{ + v->keymap.down=1; + v->keymap.keyVal=key; +} + diff --git a/cmd/smyrna/gui/appmouse.h b/cmd/smyrna/gui/appmouse.h index 446a33521..99f140247 100644 --- a/cmd/smyrna/gui/appmouse.h +++ b/cmd/smyrna/gui/appmouse.h @@ -29,6 +29,10 @@ extern void appmouse_right_drag(ViewInfo* v,int x,int y); extern void appmouse_middle_click_down(ViewInfo* v,int x,int y); extern void appmouse_middle_click_up(ViewInfo* v,int x,int y); extern void appmouse_middle_drag(ViewInfo* v,int x,int y); +extern void appmouse_move(ViewInfo* v,int x,int y); +extern void appmouse_key_release(ViewInfo* v,int key); +extern void appmouse_key_press(ViewInfo* v,int key); + #endif diff --git a/cmd/smyrna/hotkeymap.c b/cmd/smyrna/hotkeymap.c index 674c7701b..dd3b8a68f 100644 --- a/cmd/smyrna/hotkeymap.c +++ b/cmd/smyrna/hotkeymap.c @@ -213,6 +213,18 @@ void load_mouse_actions (char* modefile,ViewInfo* v) */ } +int get_key_action(ViewInfo* v,int key) +{ + int ind=0; + for (;ind < v->mouse_action_count ; ind ++) + { + + if (v->mouse_actions[ind].hotkey==key) + return v->mouse_actions[ind].action; + } + return -1; +} + int get_mode(ViewInfo* v) { diff --git a/cmd/smyrna/hotkeymap.h b/cmd/smyrna/hotkeymap.h index 9bc07885b..b0e511903 100644 --- a/cmd/smyrna/hotkeymap.h +++ b/cmd/smyrna/hotkeymap.h @@ -43,6 +43,7 @@ extern void load_mouse_actions (char* modefile,ViewInfo* v); extern int get_mode(ViewInfo* v); +extern int get_key_action(ViewInfo* v,int key); diff --git a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user index 8a66275dc..49b77cfb3 100644 --- a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user +++ b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user @@ -39,7 +39,7 @@