From 02e266e74b1cf217c9bc8555e9fd4608c2d3e91a Mon Sep 17 00:00:00 2001 From: arif Date: Tue, 2 Mar 2010 19:45:31 +0000 Subject: [PATCH] smyrna polygon selection --- cmd/smyrna/draw.c | 38 +++++++++- cmd/smyrna/drawxdot.c | 44 +---------- cmd/smyrna/glexpose.c | 1 + cmd/smyrna/gltemplate.c | 2 +- cmd/smyrna/gui/appmouse.c | 17 ++++- cmd/smyrna/gui/glcompui.c | 2 +- cmd/smyrna/gui/gui.c | 34 --------- cmd/smyrna/gui/menucallbacks.c | 48 +----------- cmd/smyrna/gui/toolboxcallbacks.c | 47 +----------- cmd/smyrna/hotkeymap.c | 4 + cmd/smyrna/polytess.c | 46 +++++------- cmd/smyrna/selection.c | 13 ++++ cmd/smyrna/selectionfuncs.c | 83 ++++++++++++++++++++- cmd/smyrna/selectionfuncs.h | 4 +- cmd/smyrna/smyrna.vcproj | 12 --- cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user | 2 +- cmd/smyrna/smyrna_utils.c | 61 +++++++++++++++ cmd/smyrna/smyrna_utils.h | 3 +- cmd/smyrna/smyrnadefs.h | 17 ++++- cmd/smyrna/topfisheyeview.c | 2 +- cmd/smyrna/topviewfuncs.c | 65 ++++++++-------- cmd/smyrna/tvnodes.c | 14 ++-- cmd/smyrna/viewport.c | 8 +- lib/cdt/cdt.vcproj | 4 +- lib/cgraph/cgraph.vcproj | 2 +- lib/glcomp/glcompdefs.h | 6 +- lib/glcomp/glcompfont.c | 2 +- lib/glcomp/glutils.c | 41 ---------- lib/gvc.def | 3 +- share/gui/mouse_actions.txt | 4 +- 30 files changed, 309 insertions(+), 320 deletions(-) diff --git a/cmd/smyrna/draw.c b/cmd/smyrna/draw.c index 32c1b9d70..615271d89 100755 --- a/cmd/smyrna/draw.c +++ b/cmd/smyrna/draw.c @@ -24,7 +24,7 @@ XDOT DRAWING FUNCTIONS, maybe need to move them somewhere else #include "colorprocs.h" #include "glutils.h" #include "math.h" -#include "selection.h" + #include "xdot.h" #include "viewport.h" #include "topfisheyeview.h" @@ -422,8 +422,27 @@ void SetFont(sdot_op * o, int param) font_op=o; } +/*for now we only support png files in 2d space, no image rotation*/ void InsertImage(sdot_op * o, int param) { + + + float w,h,x,y; + if(!o->obj) + return; + w=atof(agget(o->obj,"width"))*72; + h=atof(agget(o->obj,"height"))*72; + + if(!o->iData.data) + o->iData.data = load_png(o->op.u.image.name, &o->iData.w, &o->iData.h); + x=o->op.u.image.pos.x; + y=o->op.u.image.pos.y; + x=x+(o->iData.w-w)/2.0; + y=y+(o->iData.h-h)/2.0; + // glRasterPos3f(x,y,5); + glRasterPos3f(20,20,0); + if(o->iData.data) + glDrawPixels(o->iData.w,o->iData.h,GL_RGBA,GL_UNSIGNED_BYTE,o->iData.data); } void EmbedText(sdot_op* o, int param) { @@ -945,6 +964,23 @@ void draw_sphere(float x, float y, float z, float r) glTranslatef(-x, -y, -z); } +void draw_selpoly(glCompPoly* selPoly) +{ + int i=0; +/* glColor4f(view->gridColor.R, view->gridColor.G, view->gridColor.B, + view->gridColor.A);*/ + glDisable(GL_DEPTH_TEST); + glColor4f(1,0,0,1); + glBegin(GL_LINE_STRIP); + for (i;i < selPoly->cnt ; i++) + { + glVertex3f(selPoly->pts[i].x,selPoly->pts[i].y,selPoly->pts[i].z); + } + glEnd(); + glEnable(GL_DEPTH_TEST); + +} + #ifdef UNUSED void draw_xdot_set(xdot_set * s) { diff --git a/cmd/smyrna/drawxdot.c b/cmd/smyrna/drawxdot.c index 4eac8c0e7..f28398427 100644 --- a/cmd/smyrna/drawxdot.c +++ b/cmd/smyrna/drawxdot.c @@ -25,7 +25,7 @@ XDOT DRAWING FUNCTIONS, maybe need to move them somewhere else #include "colorprocs.h" #include "glutils.h" #include "math.h" -#include "selection.h" + #include "xdot.h" #include "viewport.h" #include "topfisheyeview.h" @@ -253,48 +253,6 @@ static void drawXdotwithattrs(void *e, int param) -void drawGraph(Agraph_t * g) -{ - Agnode_t *v; - Agedge_t *e; - Agraph_t *s; - int param = 0; - for (s = agfstsubg(g); s; s = agnxtsubg(s)) { -/* OD_SelFlag(s) = 0; - if (OD_Selected(s) == 1) - param = 1; - else*/ - param = 0; - drawXdotwithattrs(s, param); - } - - for (v = agfstnode(g); v; v = agnxtnode(g, v)) { -/* if (OD_Selected(v) == 1) - param = 1; - else*/ - param = 0; -// OD_SelFlag(v) = 0; - drawXdotwithattr(v, "_draw_", param); //draw primitives - drawXdotwithattr(v, "_ldraw_", param); //label drawing - for (e = agfstout(g, v); e; e = agnxtout(g, e)) { -/* OD_SelFlag(e) = 0; - if (OD_Selected(e) == 1) - param = 1; - else*/ - param = 0; - drawXdotwithattrs(e, param); - } - } - if ((view->Selection.Active > 0) && (!view->SignalBlock)) { - view->Selection.Active = 0; - drawGraph(g); - view->SignalBlock = 1; - glexpose(); - view->SignalBlock = 0; - } - -} - /* this function is used to cache fonts in view->fontset diff --git a/cmd/smyrna/glexpose.c b/cmd/smyrna/glexpose.c index f0f657a6b..e35fa2082 100644 --- a/cmd/smyrna/glexpose.c +++ b/cmd/smyrna/glexpose.c @@ -181,6 +181,7 @@ int glexpose_main(ViewInfo * view) // drawRotatingTools(); // draw_cube(); drawRotatingAxis(); + draw_selpoly(&view->Topview->selPoly); // draw_stuff(); // test_color_pallete(); // drawtestpoly(); diff --git a/cmd/smyrna/gltemplate.c b/cmd/smyrna/gltemplate.c index b24f81009..688855ee3 100755 --- a/cmd/smyrna/gltemplate.c +++ b/cmd/smyrna/gltemplate.c @@ -24,7 +24,7 @@ #include "glutils.h" #include "glexpose.h" #include "glmotion.h" -#include "selection.h" + #include "glcompset.h" #include "viewportcamera.h" #include "gui/menucallbacks.h" diff --git a/cmd/smyrna/gui/appmouse.c b/cmd/smyrna/gui/appmouse.c index 3f5a736d2..516bccb48 100644 --- a/cmd/smyrna/gui/appmouse.c +++ b/cmd/smyrna/gui/appmouse.c @@ -21,7 +21,7 @@ #include "glmotion.h" #include "beacon.h" #include "hotkeymap.h" -#include "selection.h" + #include "selectionfuncs.h" #include "topviewfuncs.h" @@ -50,7 +50,10 @@ static void apply_actions(ViewInfo* v,int x,int y) glmotion_pan(v); } if (a==MM_MOVE) - move_TVnodes(); + { +// move_TVnodes(); + ; + } if(a==MM_RECTANGULAR_SELECT) { @@ -59,6 +62,12 @@ static void apply_actions(ViewInfo* v,int x,int y) pick_objects_rect(view->g[view->activeGraph]) ; } + if(a==MM_POLYGON_SELECT) + { + add_selpoly(view->g[view->activeGraph],&view->Topview->selPoly,view->mouse.GLfinalPos); + } + + if (a==MM_SINGLE_SELECT) { pick_object_xyz(view->g[view->activeGraph],view->Topview,view->mouse.GLfinalPos.x,view->mouse.GLfinalPos.y,view->mouse.GLfinalPos.z); @@ -113,8 +122,8 @@ static void appmouse_down(ViewInfo* v,int x,int y) prevX=0; prevY=0; - view->Selection.X = view->mouse.GLpos.x; - view->Selection.Y = view->mouse.GLpos.y; +/* view->Selection.X = view->mouse.GLpos.x; + view->Selection.Y = view->mouse.GLpos.y;*/ } static void appmouse_up(ViewInfo* v,int x,int y) { diff --git a/cmd/smyrna/gui/glcompui.c b/cmd/smyrna/gui/glcompui.c index c78db4a7c..5e795621b 100644 --- a/cmd/smyrna/gui/glcompui.c +++ b/cmd/smyrna/gui/glcompui.c @@ -25,7 +25,7 @@ #include "topfisheyeview.h" #include "toolboxcallbacks.h" #include "viewportcamera.h" -#include "selection.h" + #include "frmobjectui.h" diff --git a/cmd/smyrna/gui/gui.c b/cmd/smyrna/gui/gui.c index 27d1ca18a..95f6f1870 100755 --- a/cmd/smyrna/gui/gui.c +++ b/cmd/smyrna/gui/gui.c @@ -100,40 +100,6 @@ void object_properties_graph_init(void) //customize window for Graph , this show } -void graph_properties_init(int newgraph) //initialize little open graph dialog -{ - //newgraph 0 : open graph mode - //newgraph 1 : new graph mode - - - gint result = 0; - xml = glade_xml_new(smyrnaGlade, NULL, NULL); - gladewidget = glade_xml_get_widget(xml, "entryGraphFileName"); - - //signals - //OK - gladewidget = glade_xml_get_widget(xml, "btnOK"); - - - g_signal_connect((gpointer) gladewidget, "clicked", - G_CALLBACK(dlgOpenGraph_OK_Clicked), &newgraph); - - - - if (newgraph) { - gladewidget = glade_xml_get_widget(xml, "entryGraphName"); - gtk_entry_set_text((GtkEntry *) gladewidget, "Untitled"); - gladewidget = glade_xml_get_widget(xml, "entryGraphFileName"); - gtk_entry_set_text((GtkEntry *) gladewidget, "Untitled.dot"); - } else { - gladewidget = glade_xml_get_widget(xml, "entryGraphName"); - gtk_entry_set_text((GtkEntry *) gladewidget, ""); - gladewidget = glade_xml_get_widget(xml, "entryGraphFileName"); - gtk_entry_set_text((GtkEntry *) gladewidget, ""); - } - gladewidget = glade_xml_get_widget(xml, "dlgOpenGraph"); - result = gtk_dialog_run(GTK_DIALOG(gladewidget)); -} GtkComboBox *get_SelectGraph(void) { diff --git a/cmd/smyrna/gui/menucallbacks.c b/cmd/smyrna/gui/menucallbacks.c index d6366090b..efac6a64e 100755 --- a/cmd/smyrna/gui/menucallbacks.c +++ b/cmd/smyrna/gui/menucallbacks.c @@ -18,7 +18,7 @@ #include "viewport.h" #include "topview.h" #include "tvnodes.h" -#include "selection.h" + #include "gvprpipe.h" #include "topviewsettings.h" #include "gltemplate.h" @@ -310,52 +310,6 @@ void mSfdpSlot(GtkWidget * widget, gpointer user_data) -//select -void mSelectAllSlot(GtkWidget * widget, gpointer user_data) -{ - select_all(view->g[view->activeGraph]); -} - - -void mUnselectAllSlot(GtkWidget * widget, gpointer user_data) -{ - deselect_all(view->g[view->activeGraph]); -} - -void mSelectAllNodesSlot(GtkWidget * widget, gpointer user_data) -{ - select_all_nodes(view->g[view->activeGraph]); -} - -void mSelectAllEdgesSlot(GtkWidget * widget, gpointer user_data) -{ - select_all_edges(view->g[view->activeGraph]); -} - -void mSelectAllClustersSlot(GtkWidget * widget, gpointer user_data) -{ - //select_all_graphs(view->g[view->activeGraph]); -} - - -void mUnselectAllNodesSlot(GtkWidget * widget, gpointer user_data) -{ - deselect_all_nodes(view->g[view->activeGraph]); -} - -void mUnselectAllEdgesSlot(GtkWidget * widget, gpointer user_data) -{ - deselect_all_edges(view->g[view->activeGraph]); -} - - -void mUnselectAllClustersSlot(GtkWidget * widget, gpointer user_data) -{ -// deselect_all_graphs(view->g[view->activeGraph]); -} - - -//help void mAbout(GtkWidget * widget, gpointer user_data) { } diff --git a/cmd/smyrna/gui/toolboxcallbacks.c b/cmd/smyrna/gui/toolboxcallbacks.c index deeded5a7..76c8a1291 100755 --- a/cmd/smyrna/gui/toolboxcallbacks.c +++ b/cmd/smyrna/gui/toolboxcallbacks.c @@ -16,59 +16,14 @@ #include "toolboxcallbacks.h" #include "viewport.h" -#include "selection.h" + #include "gltemplate.h" #include "glutils.h" #include "glmotion.h" -void btnToolSingleSelect_clicked(GtkWidget * widget, gpointer user_data) -{ - deselect_all(view->g[view->activeGraph]); - //gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)widget,1); -} - -void btnToolRectSelect_clicked(GtkWidget * widget, gpointer user_data) -{ - - deselect_all(view->g[view->activeGraph]); -} - -void btnToolRectXSelect_clicked(GtkWidget * widget, gpointer user_data) -{ - deselect_all(view->g[view->activeGraph]); - view->Selection.Anti = 0; -} - -void btnToolAntiRectSelect_clicked(GtkWidget * widget, gpointer user_data) -{ - view->Selection.Anti = 1; - -} - -void btnToolAntiRectXSelect_clicked(GtkWidget * widget, gpointer user_data) -{ - view->Selection.Anti = 1; - -} - - -void btnToolPan_clicked(GtkWidget * widget, gpointer user_data) -{ - - -} - -void btnToolZoom_clicked(GtkWidget * widget, gpointer user_data) -{ -} - -void btnToolZoomIn_clicked(GtkWidget * widget, gpointer user_data) -{ - glmotion_zoom_inc(1); -} void btnToolZoomOut_clicked(GtkWidget * widget, gpointer user_data) { diff --git a/cmd/smyrna/hotkeymap.c b/cmd/smyrna/hotkeymap.c index 9605e3ca0..674c7701b 100644 --- a/cmd/smyrna/hotkeymap.c +++ b/cmd/smyrna/hotkeymap.c @@ -15,6 +15,10 @@ int static get_mouse_mode(const char* s) return MM_RECTANGULAR_SELECT; if (strcmp(s,"MM_RECTANGULAR_X_SELECT")==0) return MM_RECTANGULAR_X_SELECT; + + if (strcmp(s,"MM_POLYGON_SELECT")==0) + return MM_POLYGON_SELECT; + if (strcmp(s,"MM_MOVE")==0) return MM_MOVE; if (strcmp(s,"MM_MOVE")==0) diff --git a/cmd/smyrna/polytess.c b/cmd/smyrna/polytess.c index a966a52fb..d8144dcb1 100644 --- a/cmd/smyrna/polytess.c +++ b/cmd/smyrna/polytess.c @@ -1,21 +1,6 @@ -/* $Id$Revision: */ -/* vim:set shiftwidth=4 ts=8: */ - -/********************************************************** -* This software is part of the graphviz package * -* http://www.graphviz.org/ * -* * -* Copyright (c) 1994-2004 AT&T Corp. * -* and is licensed under the * -* Common Public License, Version 1.0 * -* by AT&T Corp. * -* * -* Information and Software Systems Research * -* AT&T Research, Florham Park NJ * -**********************************************************/ #include "polytess.h" #include "xdot.h" - +tessPoly TP; #if 0 GLdouble star[5][3] = { 0.6f, -0.1f, 0.0f, 1.35f, 1.4f, 0.0f, @@ -91,7 +76,10 @@ GLdouble complex[25][3] = { 0.0f, 0.0f, 0.0f, #endif -void combineCallback(GLdouble coords[3], GLdouble *vertex_data[4],GLfloat weight[4], GLdouble **dataOut) +#ifndef WIN32 +#define CALLBACK +#endif +void CALLBACK combineCallback(GLdouble coords[3], GLdouble *vertex_data[4],GLfloat weight[4], GLdouble **dataOut) { GLdouble *vertex; int i; @@ -111,7 +99,7 @@ void combineCallback(GLdouble coords[3], GLdouble *vertex_data[4],GLfloat weight *dataOut = vertex; } -void vertexCallback(GLvoid *vertex) +void CALLBACK vertexCallback(GLvoid *vertex) { GLdouble *ptr; ptr = (GLdouble *) vertex; @@ -126,10 +114,10 @@ static GLUtesselator* Init() // Create a new tessellation object GLUtesselator* tobj = gluNewTess(); // Set callback functions - gluTessCallback(tobj, GLU_TESS_VERTEX, (void*)&vertexCallback); + gluTessCallback(tobj, GLU_TESS_VERTEX, &vertexCallback); gluTessCallback(tobj, GLU_TESS_BEGIN, &glBegin); gluTessCallback(tobj, GLU_TESS_END, &glEnd); - gluTessCallback(tobj, GLU_TESS_COMBINE,(void*)&combineCallback); + gluTessCallback(tobj, GLU_TESS_COMBINE,&combineCallback); return tobj; } @@ -147,16 +135,16 @@ static int Render_Contour2(GLUtesselator *tobj,sdot_op* p) { GLdouble** d; int x=0; - /* int y=0; */ + int y=0; d=(GLdouble**) malloc(sizeof(GLdouble)* p->op.u.polygon.cnt); for (x=0;x < p->op.u.polygon.cnt; x++) { - /* GLdouble temp; */ + GLdouble temp; d[x]=(GLdouble*)(malloc(sizeof(GLdouble)*3)); d[x][0]=p->op.u.polygon.pts[x].x; d[x][1]=p->op.u.polygon.pts[x].y; - d[x][2]=p->op.u.polygon.pts[x].z; + d[x][2]=p->op.u.polygon.pts[x].z+view->Topview->global_z; } for (x = 0; x < p->op.u.polygon.cnt; x++) //loop through the vertices { @@ -175,7 +163,6 @@ static int Render_Contour2(GLUtesselator *tobj,sdot_op* p) return(1); } -#if 0 static int Render_Contour(GLUtesselator *tobj, GLdouble obj_data[][3],int cnt) { @@ -184,13 +171,13 @@ static int Render_Contour(GLUtesselator *tobj, GLdouble obj_data[][3],int cnt) // GLdouble d[1][3]; static GLdouble**d; int x=0; - /* int y=0; */ + int y=0; if (!d) { d=(GLdouble**) malloc(sizeof(GLdouble)* cnt); for (x=0;x < cnt; x++) { - /* GLdouble temp; */ + GLdouble temp; d[x]=(GLdouble*)(malloc(sizeof(GLdouble)*3)); d[x][0]=obj_data[x][0]; d[x][1]=obj_data[x][1]; @@ -224,7 +211,11 @@ static int Render_Contour(GLUtesselator *tobj, GLdouble obj_data[][3],int cnt) return(1); } -#endif + + + + + static int Begin_Polygon(GLUtesselator *tobj) { @@ -258,7 +249,6 @@ static int freeTes(GLUtesselator *tobj) } int drawTessPolygon(sdot_op* p) { - static tessPoly TP; if (!TP.tobj) { TP.tobj=Init(); diff --git a/cmd/smyrna/selection.c b/cmd/smyrna/selection.c index 6e6a640ff..e8354ebcb 100755 --- a/cmd/smyrna/selection.c +++ b/cmd/smyrna/selection.c @@ -777,3 +777,16 @@ float distance_to_line(float ax, float ay, float bx, float by, float cx, / (pow((bx - ax), 2) + pow((by - ay), 2)) ); } + +int point_in_polygon(int npol, float *xp, float *yp, float x, float y) +{ + int i, j, c = 0; + for (i = 0, j = npol-1; i < npol; j = i++) { + if ((((yp[i] <= y) && (y < yp[j])) || + ((yp[j] <= y) && (y < yp[i]))) && + (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i])) + c = !c; + } + return c; + } + diff --git a/cmd/smyrna/selectionfuncs.c b/cmd/smyrna/selectionfuncs.c index a70ee24d6..75e751083 100644 --- a/cmd/smyrna/selectionfuncs.c +++ b/cmd/smyrna/selectionfuncs.c @@ -34,7 +34,7 @@ static void select_node(Agraph_t* g,Agnode_t* obj,int reverse) { agxset(obj,sel_attr,"0"); ((nodeRec*)(aggetrec(obj,"nodeRec",0)))->selected=0; - ((edgeRec*)(aggetrec(obj,"nodeRec",0)))->printLabel=0; + ((nodeRec*)(aggetrec(obj,"nodeRec",0)))->printLabel=0; } @@ -176,8 +176,6 @@ void pick_object_xyz(Agraph_t* g,topview* t,GLfloat x,GLfloat y,GLfloat z) cacheSelectedEdges(g,t); ((edgeRec*)(aggetrec(a,"edgeRec",0)))->printLabel=1; } - - } void pick_objects_rect(Agraph_t* g) { @@ -213,3 +211,82 @@ void pick_objects_rect(Agraph_t* g) } + +void deselect_all(Agraph_t* g) +{ + static Agnode_t *v; + static Agedge_t *e; + static Agsym_t* nsel_attr=(Agsym_t*)0; + static Agsym_t* esel_attr=(Agsym_t*)0; + if(!nsel_attr) + nsel_attr=agattr(g, AGNODE,"selected","0"); + if(!esel_attr) + esel_attr=agattr(g, AGEDGE,"selected","0"); + for (v = agfstnode(g); v; v = agnxtnode(g, v)) + { + agxset(v,nsel_attr,"0"); + ((nodeRec*)(aggetrec(v,"nodeRec",0)))->selected=0; + ((edgeRec*)(aggetrec(v,"nodeRec",0)))->printLabel=0; + + for (e = agfstout(g, v); e; e = agnxtout(g, e)) + { + agxset(e,esel_attr,"0"); + ((edgeRec*)(aggetrec(e,"edgeRec",0)))->selected=0; + ((edgeRec*)(aggetrec(e,"edgeRec",0)))->printLabel=0; + } + } + cacheSelectedNodes(g,view->Topview); + cacheSelectedEdges(g,view->Topview); + +} +void clear_selpoly(glCompPoly* sp) +{ + sp->pts=realloc(sp->pts,0); + sp->cnt=0; +} +static int close_poly(glCompPoly* selPoly,glCompPoint pt) +{ + int i=0; + float EPS=GetOGLDistance(3); + if (selPoly->cnt < 2) + return 0; + if( + ( (selPoly->pts[0].x-pt.x) < EPS) && + ( (selPoly->pts[0].y-pt.y) < EPS)) + return 1; + return 0; +} + + +static void select_polygon (Agraph_t* g,glCompPoly* selPoly) +{ + static Agnode_t *v; + static glCompPoint posN; + + for (v = agfstnode(g); v; v = agnxtnode(g, v)) + { + posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A; + if(point_in_polygon(selPoly,posN)) + select_node(g,v,0); + } + cacheSelectedNodes(g,view->Topview); +} + + +void add_selpoly(Agraph_t* g,glCompPoly* selPoly,glCompPoint pt) +{ + if(!close_poly(selPoly,pt)) + { + selPoly->cnt ++; + selPoly->pts=realloc(selPoly->pts,sizeof(glCompPoint)*selPoly->cnt); + selPoly->pts[selPoly->cnt-1].x=pt.x; + selPoly->pts[selPoly->cnt-1].y=pt.y; + selPoly->pts[selPoly->cnt-1].z=0; + } + else + { + select_polygon (g,selPoly); + clear_selpoly(selPoly); + } +} + diff --git a/cmd/smyrna/selectionfuncs.h b/cmd/smyrna/selectionfuncs.h index 3a5cbc7e3..4a70b2458 100644 --- a/cmd/smyrna/selectionfuncs.h +++ b/cmd/smyrna/selectionfuncs.h @@ -23,8 +23,10 @@ #ifdef __cplusplus extern "C" { #endif -extern void pick_objects_rect(Agraph_t* g) ; +extern void pick_objects_rect(Agraph_t* g) ; +extern void deselect_all(Agraph_t* g); +extern void add_selpoly(Agraph_t* g,glCompPoly* selPoly,glCompPoint pt); #ifdef __cplusplus } /* end extern "C" */ #endif diff --git a/cmd/smyrna/smyrna.vcproj b/cmd/smyrna/smyrna.vcproj index 137a294b1..d4390ef08 100644 --- a/cmd/smyrna/smyrna.vcproj +++ b/cmd/smyrna/smyrna.vcproj @@ -325,18 +325,10 @@ RelativePath=".\arcball.c" > - - - - @@ -441,10 +433,6 @@ RelativePath=".\polytess.c" > - - diff --git a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user index a5df9467e..8a66275dc 100644 --- a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user +++ b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user @@ -11,7 +11,7 @@ cnt; + + int i, j, c = 0; + for (i = 0, j = npol-1; i < npol; j = i++) + { + if ((((selPoly->pts[i].y <= p.y) && (p.y < selPoly->pts[j].y)) || + ((selPoly->pts[j].y <= p.y) && (p.y < selPoly->pts[i].y))) && + (p.x < (selPoly->pts[j].x - selPoly->pts[i].x) * (p.y - selPoly->pts[i].y) / (selPoly->pts[j].y - selPoly->pts[i].y) + selPoly->pts[i].x)) + c = !c; + } + return c; + } + + diff --git a/cmd/smyrna/smyrna_utils.h b/cmd/smyrna/smyrna_utils.h index e5e3e23e8..1f2ce5345 100644 --- a/cmd/smyrna/smyrna_utils.h +++ b/cmd/smyrna/smyrna_utils.h @@ -28,5 +28,6 @@ extern char* getAttrStr(Agraph_t* g,void* obj,char* attr_name,char* def); extern void setColor(glCompColor* c,GLfloat R,GLfloat G,GLfloat B,GLfloat A); extern void getcolorfromschema(colorschemaset * sc, float l, float maxl,glCompColor * c); extern glCompPoint getPointFromStr(char* str); - +extern float distance_to_line(float ax, float ay, float bx, float by, float cx,float cy); +extern int point_in_polygon(glCompPoly* selPoly,glCompPoint p); #endif diff --git a/cmd/smyrna/smyrnadefs.h b/cmd/smyrna/smyrnadefs.h index e54c8769c..32547d32b 100644 --- a/cmd/smyrna/smyrnadefs.h +++ b/cmd/smyrna/smyrnadefs.h @@ -72,6 +72,7 @@ typedef struct _ArcBall_t ArcBall_t; #define MM_MAGNIFIER 20 #define MM_FISHEYE_MAGNIFIER 21 #define MM_FISHEYE_PICK 22 /*fisheye select foci point*/ +#define MM_POLYGON_SELECT 30 @@ -146,6 +147,12 @@ typedef struct MOUSE_ROTATE_Z } mouse_rotate_axis; + typedef struct + { + unsigned char *data; + int w; + int h; + }image_data; typedef struct { xdot_op op; @@ -154,7 +161,7 @@ typedef struct int size; int layer; int listId;/*opengl list id*/ - + image_data iData; } sdot_op; @@ -450,6 +457,8 @@ typedef struct topviewcache cache; int xdotId; + glCompPoly selPoly; + } topview; @@ -494,7 +503,7 @@ typedef struct } attribute; - typedef struct _selection { +/* typedef struct _selection { int Active; //0 there is no selection need to be applied char Type; //0 single selection , 1 rectangle , 2 rectangleX int PickingType; //0 normal, union,2 subtract 3 intersection @@ -507,7 +516,7 @@ typedef struct //before the node/edge loop this value is nulled topview_edge *single_selected_edge; //pointer to selected/picked edge - } selection; + } selection;*/ typedef struct _magnifier { float x, y; float kts; //zoom X @@ -612,7 +621,7 @@ typedef struct glCompMouse mouse; /*selection object,refer to smyrnadefs.h for more info */ - selection Selection; +// selection Selection; /*rectangular magnifier object */ magnifier mg; diff --git a/cmd/smyrna/topfisheyeview.c b/cmd/smyrna/topfisheyeview.c index 2beeca95a..7720aaf17 100644 --- a/cmd/smyrna/topfisheyeview.c +++ b/cmd/smyrna/topfisheyeview.c @@ -22,7 +22,7 @@ #include "viewport.h" #include "viewportcamera.h" #include "draw.h" -#include "selection.h" + #include "assert.h" #include "hier.h" #include "topfisheyeview.h" diff --git a/cmd/smyrna/topviewfuncs.c b/cmd/smyrna/topviewfuncs.c index 210a0fb2b..3fccd7d53 100644 --- a/cmd/smyrna/topviewfuncs.c +++ b/cmd/smyrna/topviewfuncs.c @@ -140,16 +140,11 @@ int object_color(void* obj,glCompColor* c) objType=AGTYPE(obj); if(objType==AGEDGE) - Alpha=getAttrFloat(g,obj,"defaultedgealpha",1); + Alpha=getAttrFloat(g,agraphof(obj),"defaultedgealpha",1); if(objType==AGNODE) - Alpha=getAttrFloat(g,obj,"defaultnodealpha",1); + Alpha=getAttrFloat(g,agraphof(obj),"defaultnodealpha",1); if(!getAttrBool(g,obj,"visible",1)) return 0; - if(getAttrBool(g,obj,"selected",0)) - { - setColor(c,view->selectedEdgeColor.R, view->selectedEdgeColor.G,view->selectedEdgeColor.B, view->selectedEdgeColor.A); - return return_value; - } /*get edge's color attribute */ bf=getAttrStr(g,obj,"color",NULL); if((bf)&&(strlen(bf)>0)) @@ -173,6 +168,7 @@ int object_color(void* obj,glCompColor* c) c->B=cl.u.RGBA[2]; c->A=cl.u.RGBA[3]; } + c->A=c->A*Alpha; } return return_value; @@ -237,7 +233,7 @@ void renderSelectedNodes(Agraph_t * g) if(!((nodeRec*)(aggetrec(v,"nodeRec",0)))->selected); continue; x=parseXdotwithattrs(v); - draw_xdot(x,0); + draw_xdot(x,-1); if(x) freeXDot (x); } @@ -247,7 +243,7 @@ void renderSelectedNodes(Agraph_t * g) { if(!((nodeRec*)(aggetrec(v,"nodeRec",0)))->selected) continue; - glColor4f(1,0,0,1); + glColor4f(view->selectedEdgeColor.R, view->selectedNodeColor.G,view->selectedNodeColor.B, view->selectedNodeColor.A); pos=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A; nodeSize=((nodeRec*)(aggetrec(v,"nodeRec",0)))->size; @@ -275,11 +271,10 @@ void renderNodes(Agraph_t * g) static int defaultNodeShape=0; static GLfloat nodeSize=0; static glCompColor c; - static xdot * x; + xdot * x; - if(!defaultNodeShape) - defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0); + defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0); if(!pos_attr) pos_attr=agattr(g, AGNODE,"pos",0); if(!size_attr) @@ -287,15 +282,13 @@ void renderNodes(Agraph_t * g) if(!selected_attr) selected_attr=agattr(g, AGNODE,"selected",0); - if(defaultNodeShape==0) - glBegin(GL_POINTS); for (v = agfstnode(g); v; v = agnxtnode(g, v)) { if(!object_color(v,&c)) continue; x=parseXdotwithattrs(v); - draw_xdot(x,0); + draw_xdot(x,-0.1); if(x) @@ -304,6 +297,15 @@ void renderNodes(Agraph_t * g) + if(defaultNodeShape==0) + glBegin(GL_POINTS); + + + + + + + for (v = agfstnode(g); v; v = agnxtnode(g, v)) { @@ -319,7 +321,6 @@ void renderNodes(Agraph_t * g) if(l_int(v, selected_attr,0)) { ((nodeRec*)(aggetrec(v,"nodeRec",0)))->selected=1; - continue; } glColor4f(c.R,c.G,c.B,c.A); pos=getPointFromStr(agxget(v, pos_attr)); @@ -422,10 +423,6 @@ void renderEdges(Agraph_t * g) } else ((edgeRec*)(aggetrec(e,"edgeRec",0)))->visible=1; - - if(((edgeRec*)(aggetrec(e,"edgeRec",0)))->selected) - continue; - x=parseXdotwithattrs(e); draw_xdot(x,0); @@ -549,14 +546,22 @@ void renderEdgeLabels(Agraph_t * g) static xdot *parseXdotwithattrs(void *e) { - xdot* xDot=NULL; - xDot=parseXDotFOn (agget(e,"_draw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_ldraw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_hdraw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_tdraw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_hldraw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_tldraw_" ), OpFns,sizeof(sdot_op), xDot); - return xDot; + int cnt=0; + xdot* xDot=NULL; + xDot=parseXDotFOn (agget(e,"_draw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_ldraw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_hdraw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_tdraw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_hldraw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_tldraw_" ), OpFns,sizeof(sdot_op), xDot); + if(xDot) + { + for (cnt=0;cnt < xDot->cnt ; cnt++) + { + ((sdot_op*)(xDot->ops))[cnt].obj=e; + } + } + return xDot; } @@ -641,8 +646,8 @@ void updateSmGraph(Agraph_t * g,topview* t) t->picked_edge_count = 0; t->picked_edges = '\0'; t->global_z=0; - - + t->selPoly.cnt=0; + t->selPoly.pts=NULL; if(!t) return ; diff --git a/cmd/smyrna/tvnodes.c b/cmd/smyrna/tvnodes.c index ffbe4ebe2..844815cd7 100755 --- a/cmd/smyrna/tvnodes.c +++ b/cmd/smyrna/tvnodes.c @@ -18,7 +18,7 @@ #include "tvnodes.h" #include "btree.h" #include "viewport.h" -#include "selection.h" + #include "memory.h" tv_nodes TV_Nodes; @@ -463,7 +463,7 @@ int create_save_subgraph_from_filter(char *filename) int update_TV_data_from_gui(void) { - int i; +/* int i; int index = 0; char *data_attr1; char *data_attr2; @@ -498,7 +498,7 @@ int update_TV_data_from_gui(void) (char *) gtk_entry_get_text(TV_Nodes.TV_Node[i].Data2)); } - } + }*/ return 1; @@ -575,7 +575,7 @@ static int cache_validate_node(tv_node * tvn) int tv_select_all(void) { - tv_node tvn; +/* tv_node tvn; int i; for (i = 0; i < view->Topview->Nodecount; i++) { tvn.index = i; @@ -584,13 +584,13 @@ int tv_select_all(void) } } apply_filter_from_gui(); - return 1; + return 1;*/ } int tv_unselect_all() { - +/* tv_node tvn; int i; for (i = 0; i < view->Topview->Nodecount; i++) { @@ -600,7 +600,7 @@ int tv_unselect_all() } } apply_filter_from_gui(); - return 1; + return 1;*/ } diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index 322a3e60e..0dd798d4a 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -462,12 +462,6 @@ void init_viewport(ViewInfo * view) view->mouse.down = 0; view->activeGraph = -1; view->SignalBlock = 0; - view->Selection.Active = 0; - view->Selection.SelectionColor.R = 0.5; - view->Selection.SelectionColor.G = (float) 0.2; - view->Selection.SelectionColor.B = 1; - view->Selection.SelectionColor.A = 1; - view->Selection.Anti = 0; view->Topview = GNEW(topview); view->Topview->fisheyeParams.fs = 0; view->Topview->xDot=NULL; @@ -612,7 +606,7 @@ static Agraph_t *loadGraph(char *filename) g_print("There is no position info in %s\n", filename); return 0; } - free(view->Topview->Graphdata.GraphFileName); +// free(view->Topview->Graphdata.GraphFileName); view->Topview->Graphdata.GraphFileName = strdup(filename); return g; } diff --git a/lib/cdt/cdt.vcproj b/lib/cdt/cdt.vcproj index c988c7eb4..f3c1aadfa 100644 --- a/lib/cdt/cdt.vcproj +++ b/lib/cdt/cdt.vcproj @@ -40,7 +40,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""C:\gtk\lib\glib-2.0\include";"C:\gtk\include\glib-2.0";"C:\gtk\include\pango-1.0\";C:\gtk\include\cairo;C:\gtk\include\freetype2;C:\gtk\include;"$(SolutionDir)/libltdl";"$(SolutionDir)/lib/neatogen";"$(SolutionDir)/lib/agutil";"$(SolutionDir)/windows/lib/cdt";"$(SolutionDir)/";"$(SolutionDir)/lib/graph";"$(SolutionDir)/lib/vpsc";"$(SolutionDir)/lib/vmalloc";"$(SolutionDir)/lib/twopigen";"$(SolutionDir)/lib/sparse";"$(SolutionDir)/lib/sfio";"$(SolutionDir)/lib/sfpdpgen";"$(SolutionDir)/lib/rbtree";"$(SolutionDir)/lib/pathplan";"$(SolutionDir)/lib/patchwork";"$(SolutionDir)/lib/pack";"$(SolutionDir)/lib/ortho";"$(SolutionDir)/lib/inkpot";"$(SolutionDir)/lib/ingraphs";"$(SolutionDir)/lib/gd";"$(SolutionDir)/lib/filter";"$(SolutionDir)/lib/fdpgen";"$(SolutionDir)/lib/expr";"$(SolutionDir)/lib/dotgen";"$(SolutionDir)/lib/circogen";"$(SolutionDir)/lib/ast";"$(SolutionDir)/lib/agraph";"$(SolutionDir)/lib/common";"$(SolutionDir)/lib/gvc";"$(SolutionDir)/lib/cdt";"$(SolutionDir)/lib/cgraph"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CDT_EXPORTS;WIN32_DLL" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CDT_EXPORTS;WIN32_DLL;_BLD_cdt ;__EXPORT__" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -116,7 +116,7 @@ reference = 0; font->color.R = c->R; font->color.G = c->G; diff --git a/lib/glcomp/glutils.c b/lib/glcomp/glutils.c index ff1abd31f..10b185a82 100644 --- a/lib/glcomp/glutils.c +++ b/lib/glcomp/glutils.c @@ -728,44 +728,3 @@ int is_point_in_rectangle(float X, float Y, float RX, float RY, float RW,float R -#ifdef DEBUG -void main(void) -{ - glCompPoint LineStart, LineEnd, Point; - float Distance; - - - LineStart.x = 50.0f; - LineStart.y = 80.0f; - LineStart.z = 300.0f; - LineEnd.x = 50.0f; - LineEnd.y = -800.0f; - LineEnd.z = 1000.0f; - Point.x = 20.0f; - Point.y = 1000.0f; - Point.z = 400.0f; - - if (DistancePointLine(&Point, &LineStart, &LineEnd, &Distance)) - printf("closest point falls within line segment, distance = %f\n", - Distance); - else - printf("closest point does not fall within line segment\n"); - - - LineStart.x = 0.0f; - LineStart.y = 0.0f; - LineStart.z = 50.0f; - LineEnd.x = 0.0f; - LineEnd.y = 0.0f; - LineEnd.z = -50.0f; - Point.x = 10.0f; - Point.y = 50.0f; - Point.z = 10.0f; - - if (DistancePointLine(&Point, &LineStart, &LineEnd, &Distance)) - printf("closest point falls within line segment, distance = %f\n", - Distance); - else - printf("closest point does not fall within line segment\n"); -} -#endif diff --git a/lib/gvc.def b/lib/gvc.def index 627aeee8d..3b5cf9d44 100644 --- a/lib/gvc.def +++ b/lib/gvc.def @@ -335,4 +335,5 @@ xdotBB gvFinalize gv_postprocess gvRenderContext -gvflush \ No newline at end of file +gvflush +gvrender_ptf \ No newline at end of file diff --git a/share/gui/mouse_actions.txt b/share/gui/mouse_actions.txt index 2f1851078..f1d62efb0 100644 --- a/share/gui/mouse_actions.txt +++ b/share/gui/mouse_actions.txt @@ -3,6 +3,7 @@ #MM_ROTATE #MM_SINGLE_SELECT #MM_RECTANGULAR_SELECT +#MM_POLYGON_SELECT #MM_MOVE #MM_FISHEYE_MAGNIFIER #keys:These are pre defined keys in the code , more keys can be added by using their GTK key event correspondants, 0 means no key @@ -31,4 +32,5 @@ MM_SINGLE_SELECT,0,NO_FISHEYE,RIGHT,0 MM_RECTANGULAR_SELECT,0,ALL,RIGHT,1 MM_MOVE,B_LCTRL,2D,LEFT,1 MM_FISHEYE_MAGNIFIER,B_LSHIFT,2D,LEFT,1 -MM_FISHEYE_PICK,0,FISHEYE,RIGHT,0 \ No newline at end of file +MM_FISHEYE_PICK,0,FISHEYE,RIGHT,0 +MM_POLYGON_SELECT,B_LCTRL,NO_FISHEYE,RIGHT,0 -- 2.40.0