From: erg Date: Wed, 19 Mar 2008 21:43:58 +0000 (+0000) Subject: Clean up smyrna files: X-Git-Tag: LAST_LIBGRAPH~32^2~4473 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=169b919f82ddf88c21cc7790e59c9acebcc5a340;p=graphviz Clean up smyrna files: remove unnecessary globals modify libraries not to rely on code in cmd/smyrna remove static declarations from .h files remove unnecessary libraries mark unused code and clean up warnings --- diff --git a/cmd/smyrna/smyrnadefs.h b/cmd/smyrna/smyrnadefs.h index 02bc3198f..1b21ef053 100644 --- a/cmd/smyrna/smyrnadefs.h +++ b/cmd/smyrna/smyrnadefs.h @@ -1,9 +1,24 @@ +/* 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 * +**********************************************************/ + #ifndef SMYRNADEFS_H #define SMYRNADEFS_H #ifdef WIN32 #include "windows.h" -//#define SMYRNA_GLADE "C:/Projects/graphviz2/share/gui/smyrna.glade" +//#define SMYRNA_GLADE "C:/Projects/graphviz2/share/gui/smyrna.glade" #define SMYRNA_ATTRS "c:/Projects/graphviz2/share/gui/attrs.txt" #endif #ifdef _WIN32 @@ -14,25 +29,20 @@ // using -DGTKTOPVIEW_GLADE from Makefile.am and configure.ac // using -DGTKTOPVIEW_ATTRS from Makefile.am and configure.ac #endif -#ifdef WIN32 //this is needed on WIN32 to get libglade see the callback +#ifdef WIN32 //this is needed on WIN32 to get libglade see the callback #define _BB __declspec(dllexport) #else -#define _BB +#define _BB #endif - - - - #include #include "cgraph.h" #include -#include +#include #include #include "glcompset.h" #include "hierarchy.h" - #define IS_TEST_MODE_ON 0 #define DEFAULT_MAGNIFIER_WIDTH 300 #define DEFAULT_MAGNIFIER_HEIGHT 225 @@ -67,289 +77,281 @@ -typedef struct{ - float R; - float G; - float B; - float A; //Alpha +typedef struct { + float R; + float G; + float B; + float A; //Alpha } RGBColor; typedef struct { - GtkButton** gtkhostbtn; - int gtkhostbtncount; - GtkColorButton** gtkhostcolor; - int hostactive[50]; //temporary static, convert to dynamic,realloc - char** hostregex; + GtkButton **gtkhostbtn; + int gtkhostbtncount; + GtkColorButton **gtkhostcolor; + int hostactive[50]; //temporary static, convert to dynamic,realloc + char **hostregex; } topviewdata; -typedef struct{ - Agnode_t* Node; - /*original coordinates*/ - float x; - float y; - float z; - /*coordinates to draw*/ - float distorted_x; - float distorted_y; - float distorted_z; - float zoom_factor; - int in_fish_eye; //boolean value if to apply fisheye - RGBColor Color; - RGBColor GroupColor; - int GroupIndex; //default -1; - int update_required; - char* Label; - char* Label2; - int degree; - float node_alpha; - int valid; -}topview_node; - -typedef struct{ - Agnode_t* Tnode; //Tail node - Agnode_t* Hnode; //Tail node - Agedge_t *Edge; //edge itself - float x1; - float y1; - float z1; - float x2; - float y2; - float z2; - topview_node* Node1; - topview_node* Node2; - RGBColor Color; - int update_required; - -}topview_edge; typedef struct { - topview_node* Nodes; - topview_edge* Edges; - int Nodecount; - int Edgecount; - int limits[4]; - glCompSet* topviewmenu; //for novice user open gl menu - topviewdata* TopviewData; - void* customptr; - Hierarchy* h; + Agnode_t *Node; + /*original coordinates */ + float x; + float y; + float z; + /*coordinates to draw */ + float distorted_x; + float distorted_y; + float distorted_z; + float zoom_factor; + int in_fish_eye; //boolean value if to apply fisheye + RGBColor Color; + RGBColor GroupColor; + int GroupIndex; //default -1; + int update_required; + char *Label; + char *Label2; + int degree; + float node_alpha; + int valid; +} topview_node; + +typedef struct { + Agnode_t *Tnode; //Tail node + Agnode_t *Hnode; //Tail node + Agedge_t *Edge; //edge itself + float x1; + float y1; + float z1; + float x2; + float y2; + float z2; + topview_node *Node1; + topview_node *Node2; + RGBColor Color; + int update_required; + +} topview_edge; +typedef struct { + topview_node *Nodes; + topview_edge *Edges; + int Nodecount; + int Edgecount; + int limits[4]; + glCompSet *topviewmenu; //for novice user open gl menu + topviewdata *TopviewData; + void *customptr; + Hierarchy *h; } topview; -enum -{ - COL_NAME = 0, - COL_FILENAME, - NUM_COLS -} ; +enum { + COL_NAME = 0, + COL_FILENAME, + NUM_COLS +}; //atributes -typedef struct _mouse_attr -{ - int mouse_down; - int mouse_mode; - int mouse_X; - int mouse_Y; -}mouse_attr; - - -typedef struct _attribute -{ - char Type; - char* Name; - char* Default; - char ApplyTo[4]; - char Engine[5]; - char** ComboValues; - int ComboValuesCount; - GtkWidget* attrWidget; - -}attribute; +typedef struct _mouse_attr { + int mouse_down; + int mouse_mode; + int mouse_X; + int mouse_Y; +} mouse_attr; + + +typedef struct _attribute { + char Type; + char *Name; + char *Default; + char ApplyTo[4]; + char Engine[5]; + char **ComboValues; + int ComboValuesCount; + GtkWidget *attrWidget; + +} attribute; //bind this to cgraph g -typedef struct _custom_graph_data -{ - Agrec_t h; - char* GraphName; - char* GraphFileName; - int AlwaysShow; //active or not draw it - int TopView; //default 0, 1 for topview data, dots and lines - int Locked; - int Engine; //enum GVEngine{DOT,NEATO,TWOPI,CIRCO,FDP}; - //graph's location, change these to move the whole graph - int Modified; //if graph has been modified after loading - float offsetx; - float offsety; - float offsetz; - - Agraph_t** selectedGraphs; //clusters , subgraphs indeed - Agnode_t** selectedNodes; - Agedge_t** selectedEdges; - - int selectedGraphsCount; - int selectedNodesCount; - int selectedEdgesCount; +typedef struct _custom_graph_data { + Agrec_t h; + char *GraphName; + char *GraphFileName; + int AlwaysShow; //active or not draw it + int TopView; //default 0, 1 for topview data, dots and lines + int Locked; + int Engine; //enum GVEngine{DOT,NEATO,TWOPI,CIRCO,FDP}; + //graph's location, change these to move the whole graph + int Modified; //if graph has been modified after loading + float offsetx; + float offsety; + float offsetz; + + Agraph_t **selectedGraphs; //clusters , subgraphs indeed + Agnode_t **selectedNodes; + Agedge_t **selectedEdges; + + int selectedGraphsCount; + int selectedNodesCount; + int selectedEdgesCount; } custom_graph_data; -enum GEunit{GEpixels,GEinches,GEmm}; +enum GEunit { GEpixels, GEinches, GEmm }; -typedef struct _custom_object_data //has to be attached to every Node, Edge, Graph and cluster -{ - Agrec_t h; - int ID; - char* ObjName; - int ObjType; - int Layer; - int Visible; - int Locked; - int Highlighted; - int Selected; - int Preselected; - int NumDataCount; - float* NumData; - int StrDataCount; - char** StrData; - int selectionflag; - int param; //generic purpose param - int TVRef; //Topview reference - -}custom_object_data; - -typedef struct _selection +typedef struct _custom_object_data //has to be attached to every Node, Edge, Graph and cluster { - int Active; //0 there is no selection need to be applied - char Type; //0 single selection , 1 rectangle , 2 rectangleX - float X,Y,W,H; //selection boundries - int Anti; //subtract selections if 1 - int AlreadySelected; //for single selections to avoid selecting more than one object - RGBColor SelectionColor; - -}selection; -typedef struct _magnifier -{ - float x,y; - float kts; //zoom X - float GLwidth,GLheight; - int width,height; //how big is the magnifier referenced from windows - int active; + Agrec_t h; + int ID; + char *ObjName; + int ObjType; + int Layer; + int Visible; + int Locked; + int Highlighted; + int Selected; + int Preselected; + int NumDataCount; + float *NumData; + int StrDataCount; + char **StrData; + int selectionflag; + int param; //generic purpose param + int TVRef; //Topview reference + +} custom_object_data; + +#define OD_Selected(p) (((custom_object_data*)AGDATA(p))->Selected) +#define OD_Preselected(p) (((custom_object_data*)AGDATA(p))->Preselected) +#define OD_SelFlag(p) (((custom_object_data*)AGDATA(p))->selectionflag) + +typedef struct _selection { + int Active; //0 there is no selection need to be applied + char Type; //0 single selection , 1 rectangle , 2 rectangleX + float X, Y, W, H; //selection boundries + int Anti; //subtract selections if 1 + int AlreadySelected; //for single selections to avoid selecting more than one object + RGBColor SelectionColor; + +} selection; +typedef struct _magnifier { + float x, y; + float kts; //zoom X + float GLwidth, GLheight; + int width, height; //how big is the magnifier referenced from windows + int active; } magnifier; -typedef struct _fisheye_magnifier -{ - float x,y;//center coords of active circle - float distortion_factor; //distortion factor ,default 1 - int R; //radius of the magnifier referenced from windows - int active; - int fisheye_distortion_fac; +typedef struct _fisheye_magnifier { + float x, y; //center coords of active circle + float distortion_factor; //distortion factor ,default 1 + int R; //radius of the magnifier referenced from windows + int active; + int fisheye_distortion_fac; } fisheye_magnifier; -typedef struct _ViewInfo -{ - /*view variables*/ - float panx; - float pany; - float panz; - float prevpanx; - float prevpany; - float prevpanz; - float zoom; - - /*clipping coordinates, to avoid unnecesarry rendering*/ - float clipX1,clipX2,clipY1,clipY2,clipZ1,clipZ2; - - /*background color*/ - RGBColor bgColor; - /*default pen color*/ - RGBColor penColor; - /*default fill color*/ - RGBColor fillColor; - /*highlighted Node Color*/ - RGBColor highlightedNodeColor; - /*highlighted Edge Color*/ - RGBColor highlightedEdgeColor; - /*grid color*/ - RGBColor gridColor; //grid color - /*border color*/ - RGBColor borderColor; - /*selected node color*/ - RGBColor selectedNodeColor; - /*selected edge color*/ - RGBColor selectedEdgeColor; - - /*default line width*/ - float LineWidth; - - /*grid is drawn if this variable is 1*/ - int gridVisible; - /*grid cell size in gl coords system*/ - float gridSize; //grid cell size - - /*draws a border in border colors if it is 1*/ - int bdVisible; //if borders are visible (boundries of the drawing, - /*border coordinates, needs to be calculated for each graph*/ - - - - float bdxLeft,bdyTop,bdzTop; - float bdxRight,bdyBottom,bdzBottom; - - /*reserved , not being used yet*/ - enum GEunit unit; //default pixels :0 - - /*variable to hold mouse coordinates temporarily*/ - float GLx,GLy,GLz; - /*this is second set of mouse coordinates holder for, it is needed to draw a rectangle with mouse*/ - float GLx2,GLy2,GLz2; - - /*screen window size in 2d*/ - int w,h; - /*graph pointer to hold loaded graphs*/ - Agraph_t** g; - /*number of graphs loaded*/ - int graphCount; - /*active graph*/ - int activeGraph; - - /**/ - int FontSize; - /*texture data*/ - int texture; /*1 texturing enabled, 0 disabled*/ - /*opengl depth value to convert mouse to GL coords*/ - float GLDepth; - - /*stores the info about status of mouse,pressed? what button ? where?*/ - mouse_attr mouse; - - /*selection object,refer to smyrnadefs.h for more info*/ - selection Selection; - - /*rectangular magnifier object*/ - magnifier mg; - /*fisheye magnifier object*/ - fisheye_magnifier fmg; - - /*data attributes are read from graph's attributes DataAttribute1 and DataAttribute2*/ - char* node_data_attribute1; /*for topview graphs this is the node data attribute to put as label*/ - char* node_data_attribute2; /*for topview graphs this is the node data attribute to be stored and used for something else*/ - - /*0 advanced users with editing options 1 nonice users just navigate (glmenu system)*/ - int topviewusermode; - - /*open gl canvas, used to be a globa variable before looks better wrapped in viewinfo*/ - GtkWidget *drawing_area; - - /*some boolean variable for variety hacks used in the software*/ - int SignalBlock; - - /*Topview data structure, refer topview.h for more info*/ - topview* Topview; -}ViewInfo; - -extern ViewInfo* view; -extern GtkMessageDialog* Dlg; +typedef struct _ViewInfo { + /*view variables */ + float panx; + float pany; + float panz; + float prevpanx; + float prevpany; + float prevpanz; + float zoom; + + /*clipping coordinates, to avoid unnecesarry rendering */ + float clipX1, clipX2, clipY1, clipY2, clipZ1, clipZ2; + + /*background color */ + RGBColor bgColor; + /*default pen color */ + RGBColor penColor; + /*default fill color */ + RGBColor fillColor; + /*highlighted Node Color */ + RGBColor highlightedNodeColor; + /*highlighted Edge Color */ + RGBColor highlightedEdgeColor; + /*grid color */ + RGBColor gridColor; //grid color + /*border color */ + RGBColor borderColor; + /*selected node color */ + RGBColor selectedNodeColor; + /*selected edge color */ + RGBColor selectedEdgeColor; + + /*default line width */ + float LineWidth; + + /*grid is drawn if this variable is 1 */ + int gridVisible; + /*grid cell size in gl coords system */ + float gridSize; //grid cell size + + /*draws a border in border colors if it is 1 */ + int bdVisible; //if borders are visible (boundries of the drawing, + /*border coordinates, needs to be calculated for each graph */ + + + + float bdxLeft, bdyTop, bdzTop; + float bdxRight, bdyBottom, bdzBottom; + + /*reserved , not being used yet */ + enum GEunit unit; //default pixels :0 + + /*variable to hold mouse coordinates temporarily */ + float GLx, GLy, GLz; + /*this is second set of mouse coordinates holder for, it is needed to draw a rectangle with mouse */ + float GLx2, GLy2, GLz2; + + /*screen window size in 2d */ + int w, h; + /*graph pointer to hold loaded graphs */ + Agraph_t **g; + /*number of graphs loaded */ + int graphCount; + /*active graph */ + int activeGraph; + + /**/ int FontSize; + /*texture data */ + int texture; /*1 texturing enabled, 0 disabled */ + /*opengl depth value to convert mouse to GL coords */ + float GLDepth; + + /*stores the info about status of mouse,pressed? what button ? where? */ + mouse_attr mouse; + + /*selection object,refer to smyrnadefs.h for more info */ + selection Selection; + + /*rectangular magnifier object */ + magnifier mg; + /*fisheye magnifier object */ + fisheye_magnifier fmg; + + /*data attributes are read from graph's attributes DataAttribute1 and DataAttribute2 */ + char *node_data_attribute1; /*for topview graphs this is the node data attribute to put as label */ + char *node_data_attribute2; /*for topview graphs this is the node data attribute to be stored and used for something else */ + + /*0 advanced users with editing options 1 nonice users just navigate (glmenu system) */ + int topviewusermode; + + /*open gl canvas, used to be a globa variable before looks better wrapped in viewinfo */ + GtkWidget *drawing_area; + + /*some boolean variable for variety hacks used in the software */ + int SignalBlock; + + /*Topview data structure, refer topview.h for more info */ + topview *Topview; +} ViewInfo; + +extern ViewInfo *view; +extern GtkMessageDialog *Dlg; extern int respond; extern void glexpose(); - - - #endif diff --git a/lib/Makefile.am b/lib/Makefile.am index e0e290ca7..539194af5 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -3,6 +3,6 @@ SUBDIRS = cdt graph agraph gd pathplan agutil sfio vmalloc ast vpsc \ circogen dotgen fdpgen neatogen twopigen common pack gvc \ - ingraphs expr cgraph utilities xdot filter topfish glcomp + ingraphs expr cgraph xdot topfish glcomp EXTRA_DIST = Makefile.old diff --git a/lib/common/geom.c b/lib/common/geom.c index 59dbb989f..33bd07a25 100644 --- a/lib/common/geom.c +++ b/lib/common/geom.c @@ -531,3 +531,62 @@ double ptToLine2 (pointf a, pointf b, pointf p) if (a2 < .00001) return 0.; /* avoid 0/0 problems */ return a2 / (dx*dx + dy*dy); } + +#define SMALL 0.0000000001 + +static pointf +subPt (pointf a, pointf b) +{ + pointf c; + + c.x = a.x-b.x; + c.y = a.y-b.y; + return c; +} + +static pointf +perp (pointf a) +{ + pointf c; + + c.x = -a.y; + c.y = a.x; + return c; +} + +static double +dot (pointf a, pointf b) +{ + return (a.x*b.x + a.y*b.y); +} + +static pointf +scale (double c, pointf a) +{ + pointf b; + + b.x = c*a.x; + b.y = c*a.y; + return b; +} + +/* intersect: + * Computes intersection of lines a-b and c-d, returning intersection + * point in *x. + * Returns 0 if no intersection (lines parallel), 1 otherwise. + */ +int +intersect (pointf a, pointf b, pointf c, pointf d, pointf* x) +{ + pointf mv = subPt (b,a); + pointf lv = subPt (d,c); + pointf ln = perp (lv); + double lc = -dot(ln,c); + double dt = dot(ln,mv); + + if (fabs(dt) < SMALL) return 0; + + *x = subPt(a,scale((dot(ln,a)+lc)/dt,mv)); + return 1; +} + diff --git a/lib/common/geomprocs.h b/lib/common/geomprocs.h index 4903ecb29..18d610df1 100644 --- a/lib/common/geomprocs.h +++ b/lib/common/geomprocs.h @@ -24,6 +24,8 @@ extern "C" { #endif +#include + extern point pointof(int, int); extern pointf pointfof(double, double); @@ -71,6 +73,7 @@ extern pointf cwrotatepf(pointf p, int cwrot); extern void rect2poly(pointf *p); +extern int intersect (pointf a, pointf b, pointf c, pointf d, pointf* x); #ifdef __cplusplus } #endif