Exemple #1
0
/* getdoubles2ptf:
 * converts a graph attribute in inches to a pointf in points.
 * If only one number is given, it is used for both x and y.
 * Returns true if the attribute ends in '!'.
 */
static boolean getdoubles2ptf(graph_t * g, char *name, pointf * result)
{
    char *p;
    int i;
    double xf, yf;
    char c = '\0';
    boolean rv = FALSE;

    if ((p = agget(g, name))) {
	i = sscanf(p, "%lf,%lf%c", &xf, &yf, &c);
	if ((i > 1) && (xf > 0) && (yf > 0)) {
	    result->x = POINTS(xf);
	    result->y = POINTS(yf);
	    if (c == '!')
		rv = TRUE;
	}
	else {
	    c = '\0';
	    i = sscanf(p, "%lf%c", &xf, &c);
	    if ((i > 0) && (xf > 0)) {
		result->y = result->x = POINTS(xf);
		if (c == '!') rv = TRUE;
	    }
	}
    }
    return rv;
}
Exemple #2
0
point
cvt2pt(pointf p)
{
	point	rv;
	rv.x = POINTS(p.x);
	rv.y = POINTS(p.y);
	return rv;
}
Exemple #3
0
static void copyPos(Agraph_t * g)
{
    Agnode_t *n;
    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
	ND_coord_i(n).x = POINTS(ND_pos(n)[0]);
	ND_coord_i(n).y = POINTS(ND_pos(n)[1]);
    }
}
Exemple #4
0
static void ptest_nodesize(node_t * n, boolean flip)
{
    int w;

    w = ND_xsize(n) = POINTS(ND_width(n));
    ND_lw(n) = ND_rw(n) = w / 2;
    ND_ht(n) = ND_ysize(n) = POINTS(ND_height(n));
}
Exemple #5
0
void neato_nodesize(node_t * n, bool flip)
{
    int w;

    w = ND_xsize(n) = POINTS(ND_width(n));
    ND_lw_i(n) = ND_rw_i(n) = w / 2;
    ND_ht_i(n) = ND_ysize(n) = POINTS(ND_height(n));
}
Exemple #6
0
void getdoubles2pt(graph_t* g, char* name, point* result)
{
    char        *p;
    int         i;
    double      xf,yf;

    if ((p = agget(g,name))) {
        i = sscanf(p,"%lf,%lf",&xf,&yf);
        if ((i > 1) && (xf > 0) && (yf > 0)) {
            result->x = POINTS(xf);
            result->y = POINTS(yf);
        }
    }
}
Exemple #7
0
static void initPos(Agraph_t * g)
{
    Agnode_t *n;
    Agedge_t *e;
    double *pvec;
    char *p;
    point *sp;
    int pn;
    attrsym_t *N_pos = agfindnodeattr(g, "pos");
    attrsym_t *E_pos = agfindedgeattr(g, "pos");

    assert(N_pos);
    if (!E_pos) {
	if (doEdges)
	    fprintf(stderr, "Warning: turning off doEdges, graph %s\n",
		    g->name);
	doEdges = 0;
    }
    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
	pvec = ND_pos(n);
	p = agxget(n, N_pos->index);
	if (p[0] && (sscanf(p, "%lf,%lf", pvec, pvec + 1) == 2)) {
	    int i;
	    for (i = 0; i < NDIM; i++)
		pvec[i] = pvec[i] / PSinputscale;
	} else {
	    fprintf(stderr, "could not find pos for node %s in graph %s\n",
		    n->name, g->name);
	    exit(1);
	}
	ND_coord_i(n).x = POINTS(ND_pos(n)[0]);
	ND_coord_i(n).y = POINTS(ND_pos(n)[1]);
    }

    if (doEdges) {
	for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
	    for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
		if ((sp = user_spline(E_pos, e, &pn)) != 0) {
		    clip_and_install(e, sp, pn);
		    free(sp);
		} else {
		    fprintf(stderr,
			    "Missing edge pos for edge %s - %s in graph %s\n",
			    n->name, e->head->name, g->name);
		    exit(1);
		}
	    }
	}
    }
}
Exemple #8
0
void dot_nodesize(node_t * n, bool flip)
{
    double x, y;
    int ps;

    if (flip == FALSE) {
	x = ND_width(n);
	y = ND_height(n);
    } else {
	y = ND_width(n);
	x = ND_height(n);
    }
    ps = POINTS(x) / 2;
    if (ps < 1)
	ps = 1;
    ND_lw_i(n) = ND_rw_i(n) = ps;
    ND_ht_i(n) = POINTS(y);
}
Exemple #9
0
/* initItem:
 */
static void initItem(node_t * n, nitem * p, double margin)
{
    int x = POINTS(SCALE * ND_pos(n)[0]);
    int y = POINTS(SCALE * ND_pos(n)[1]);
    int w2 = POINTS(margin * SCALE2 * ND_width(n));
    int h2 = POINTS(margin * SCALE2 * ND_height(n));
    box b;

    b.LL.x = x - w2;
    b.LL.y = y - h2;
    b.UR.x = x + w2;
    b.UR.y = y + h2;

    p->pos.x = x;
    p->pos.y = y;
    p->np = n;
    p->bb = b;
}
Exemple #10
0
/* initItem:
 */
static void initItem(node_t * n, nitem * p, expand_t margin)
{
    int x = POINTS(SCALE * ND_pos(n)[0]);
    int y = POINTS(SCALE * ND_pos(n)[1]);
    int w2, h2;
    box b;

    if (margin.doAdd) {
	w2 = SCALE * (POINTS(ND_width(n)/2.0) + margin.x);
	h2 = SCALE * (POINTS(ND_height(n)/2.0) + margin.y);
    }
    else {
	w2 = POINTS(margin.x * SCALE2 * ND_width(n));
	h2 = POINTS(margin.y * SCALE2 * ND_height(n));
    }

    b.LL.x = x - w2;
    b.LL.y = y - h2;
    b.UR.x = x + w2;
    b.UR.y = y + h2;

    p->pos.x = x;
    p->pos.y = y;
    p->np = n;
    p->bb = b;
}
Exemple #11
0
/* GetCurUsage()
 * ======================================================================
 * Get the current Speedo Data Cache Usage.
 */
long
GetCurUsage( void )
{
    FON_PTR  curptr;
    int      i;
    long     Used;
    int      icount;

    /* Get the Fixed amount - always have this...*/
    Used = FONTP_ACTUAL;
    
    /* Get the per font allocation */
    icount = CountFonts( installed_list, SPD_FONT );
    
    Used +=  (long)icount * ( FSMHEADER + ARB_PTSBLK );
    
    /* Get the per pointsize per font allocation. */
    curptr = installed_list;
    while( curptr )
    {
       if( FTYPE( curptr ) == SPD_FONT )
       {
         for( i=0; i < MAX_POINTS; i++ )
         {
           if( POINTS( curptr )[i] )
           {
              if( Current.Width )
                 Used += WIDTH_TABLE_DATA;
              Used += THE_PTSBLK;
           }
           else
            break;
         }
       }         
       curptr = FNEXT( curptr );
    }
    
    Used += ( GetFontMin() + GetCharMin() );
    
    /* Make sure we ALWAYS have at least 10K */
    if( Used < 10240L )
      Used = 10240L;	

    Used /= 1024L;
    return( Used );
}
int main (int argc, char** argv) {
  
  HaarFaceDetector* haarFaceDetector = new HaarFaceDetector(
    "/workspace/OpenCV-2.3.0/data/haarcascades/haarcascade_frontalface_default.xml",
    "/workspace/OpenCV-2.3.0/data/haarcascades/haarcascade_eye_tree_eyeglasses.xml",
    "/workspace/OpenCV-2.3.0/data/haarcascades/haarcascade_mcs_mouth.xml");
  ObjectMatcher* objectMatcher = new ObjectMatcher();
  // load feature vector
  objectMatcher->loadDescription("/workspace/OpenCV-2.3.0/android/apps/FaceRecognition/assets/features/takahiro.txt");
  objectMatcher->loadDescription("/workspace/OpenCV-2.3.0/android/apps/FaceRecognition/assets/features/akita.txt");
  objectMatcher->loadDescription("/workspace/OpenCV-2.3.0/android/apps/FaceRecognition/assets/features/kei.txt");
  objectMatcher->loadDescription("/workspace/OpenCV-2.3.0/android/apps/FaceRecognition/assets/features/koga.txt");
  objectMatcher->loadDescription("/workspace/OpenCV-2.3.0/android/apps/FaceRecognition/assets/features/sato.txt");
  objectMatcher->loadDescription("/workspace/OpenCV-2.3.0/android/apps/FaceRecognition/assets/features/pan.txt");
  //cvInitFont(&font, CV_FONT_HERSHEY_DUPLEX, 1.0, 1.0, 0, 3, 8);

  const char* imageFile = argc == 2 ? argv[1] : "image/accordion_image_0001.jpg";
  
  // SURF抽出用に画像をグレースケールで読み込む
  IplImage* grayImage = cvLoadImage(imageFile, CV_LOAD_IMAGE_GRAYSCALE);
  if (!grayImage) {
    LOGE("cannot find image file: %s", imageFile);
    return -1;
  }

  CvRect faceRect;
  bool find = haarFaceDetector->detectFace(grayImage, &faceRect);
  if (find) {
    cvRectangle(grayImage, POINTS(faceRect), CV_RGB(255,255,0), 2, 8, 0);
    cvSetImageROI(grayImage, faceRect);

    int objId = objectMatcher->match(grayImage);
  }

  cvShowImage("", grayImage);
  cvWaitKey(0);
  
  // 後始末
  cvReleaseImage(&grayImage);
  cvDestroyAllWindows();
  
  return 0;
}
Exemple #13
0
/* GetCurUsage()
 * ======================================================================
 * Get the current FSM Data Cache Usage.
 */
long
GetCurUsage( void )
{
    FON_PTR  curptr;
    int      i;
    long     Used;
       
    /* Get the Fixed amount - always have this...*/
    Used = XCLIENT + XHEBREW + XSYMBOL + FONTP_ACTUAL;
    
    /* Get the per font allocation */
    Used +=  (long)active_fsm_count * ( FSMHEADER + ARB_PTSBLK );
    /* Get the per pointsize per font allocation. */
    curptr = active_fsm_list;
    while( curptr )
    {
       for( i=0; i < MAX_DEV; i++ )
       {
         if( POINTS( curptr )[i] )
         {
            if( Current.Width )
               Used += WIDTH_TABLE_DATA;
            Used += THE_PTSBLK;
         }
         else
          break;
       }       
       curptr = FNEXT( curptr );
    }
    /* If FSM GDOS is installed, we'll add roughly 8K to the used amount.
     * This way, we don't need to parse the ASSIGN.SYS since this whole
     * thing is supposed to be just an estimate.
     */
    if( gdos_flag )
        Used += 8000L;

    Used /= 1024L;
    return( Used );
}
Exemple #14
0
/*
	cgraph requires 

*/
void graph_init(graph_t * g, boolean use_rankdir)
{
    char *p;
    double xf;
    static char *rankname[] = { "local", "global", "none", NULL };
    static int rankcode[] = { LOCAL, GLOBAL, NOCLUST, LOCAL };
    static char *fontnamenames[] = {"gd","ps","svg", NULL};
    static int fontnamecodes[] = {NATIVEFONTS,PSFONTS,SVGFONTS,-1};
    int rankdir;
    GD_drawing(g) = NEW(layout_t);

    /* set this up fairly early in case any string sizes are needed */
    if ((p = agget(g, "fontpath")) || (p = getenv("DOTFONTPATH"))) {
	/* overide GDFONTPATH in local environment if dot
	 * wants its own */
#ifdef HAVE_SETENV
	setenv("GDFONTPATH", p, 1);
#else
	static char *buf = 0;

	buf = grealloc(buf, strlen("GDFONTPATH=") + strlen(p) + 1);
	strcpy(buf, "GDFONTPATH=");
	strcat(buf, p);
	putenv(buf);
#endif
    }

    GD_charset(g) = findCharset (g);

    if (!HTTPServerEnVar) {
	Gvimagepath = agget (g, "imagepath");
	if (!Gvimagepath)
	    Gvimagepath = Gvfilepath;
    }

    GD_drawing(g)->quantum =
	late_double(g, agfindgraphattr(g, "quantum"), 0.0, 0.0);

    /* setting rankdir=LR is only defined in dot,
     * but having it set causes shape code and others to use it. 
     * The result is confused output, so we turn it off unless requested.
     * This effective rankdir is stored in the bottom 2 bits of g->u.rankdir.
     * Sometimes, the code really needs the graph's rankdir, e.g., neato -n
     * with record shapes, so we store the real rankdir in the next 2 bits.
     */
    rankdir = RANKDIR_TB;
    if ((p = agget(g, "rankdir"))) {
	if (streq(p, "LR"))
	    rankdir = RANKDIR_LR;
	else if (streq(p, "BT"))
	    rankdir = RANKDIR_BT;
	else if (streq(p, "RL"))
	    rankdir = RANKDIR_RL;
    }
    if (use_rankdir)
	SET_RANKDIR (g, (rankdir << 2) | rankdir);
    else
	SET_RANKDIR (g, (rankdir << 2));

    xf = late_double(g, agfindgraphattr(g, "nodesep"),
		DEFAULT_NODESEP, MIN_NODESEP);
    GD_nodesep(g) = POINTS(xf);

    p = late_string(g, agfindgraphattr(g, "ranksep"), NULL);
    if (p) {
	if (sscanf(p, "%lf", &xf) == 0)
	    xf = DEFAULT_RANKSEP;
	else {
	    if (xf < MIN_RANKSEP)
		xf = MIN_RANKSEP;
	}
	if (strstr(p, "equally"))
	    GD_exact_ranksep(g) = TRUE;
    } else
	xf = DEFAULT_RANKSEP;
    GD_ranksep(g) = POINTS(xf);

    GD_showboxes(g) = late_int(g, agfindgraphattr(g, "showboxes"), 0, 0);
    p = late_string(g, agfindgraphattr(g, "fontnames"), NULL);
    GD_fontnames(g) = maptoken(p, fontnamenames, fontnamecodes);

    setRatio(g);
    GD_drawing(g)->filled =
	getdoubles2ptf(g, "size", &(GD_drawing(g)->size));
    getdoubles2ptf(g, "page", &(GD_drawing(g)->page));

    GD_drawing(g)->centered = mapbool(agget(g, "center"));

    if ((p = agget(g, "rotate")))
	GD_drawing(g)->landscape = (atoi(p) == 90);
    else if ((p = agget(g, "orientation")))
	GD_drawing(g)->landscape = ((p[0] == 'l') || (p[0] == 'L'));
    else if ((p = agget(g, "landscape")))
	GD_drawing(g)->landscape = mapbool(p);

    p = agget(g, "clusterrank");
    CL_type = maptoken(p, rankname, rankcode);
    p = agget(g, "concentrate");
    Concentrate = mapbool(p);
    State = GVBEGIN;
    EdgeLabelsDone = 0;

    GD_drawing(g)->dpi = 0.0;
    if (((p = agget(g, "dpi")) && p[0])
	|| ((p = agget(g, "resolution")) && p[0]))
	GD_drawing(g)->dpi = atof(p);

    do_graph_label(g);

    Initial_dist = MYHUGE;

    G_ordering = agfindgraphattr(g, "ordering");
    G_gradientangle = agfindgraphattr(g,"gradientangle");
    G_margin = agfindgraphattr(g, "margin");

    /* initialize nodes */
    N_height = agfindnodeattr(g, "height");
    N_width = agfindnodeattr(g, "width");
    N_shape = agfindnodeattr(g, "shape");
    N_color = agfindnodeattr(g, "color");
    N_fillcolor = agfindnodeattr(g, "fillcolor");
    N_style = agfindnodeattr(g, "style");
    N_fontsize = agfindnodeattr(g, "fontsize");
    N_fontname = agfindnodeattr(g, "fontname");
    N_fontcolor = agfindnodeattr(g, "fontcolor");
    N_label = agfindnodeattr(g, "label");
    if (!N_label)
	N_label = agattr(g, AGNODE, "label", NODENAME_ESC);
    N_xlabel = agfindnodeattr(g, "xlabel");
    N_showboxes = agfindnodeattr(g, "showboxes");
    N_penwidth = agfindnodeattr(g, "penwidth");
    N_ordering = agfindnodeattr(g, "ordering");
    N_margin = agfindnodeattr(g, "margin");
    /* attribs for polygon shapes */
    N_sides = agfindnodeattr(g, "sides");
    N_peripheries = agfindnodeattr(g, "peripheries");
    N_skew = agfindnodeattr(g, "skew");
    N_orientation = agfindnodeattr(g, "orientation");
    N_distortion = agfindnodeattr(g, "distortion");
    N_fixed = agfindnodeattr(g, "fixedsize");
    N_imagescale = agfindnodeattr(g, "imagescale");
    N_nojustify = agfindnodeattr(g, "nojustify");
    N_layer = agfindnodeattr(g, "layer");
    N_group = agfindnodeattr(g, "group");
    N_comment = agfindnodeattr(g, "comment");
    N_vertices = agfindnodeattr(g, "vertices");
    N_z = agfindnodeattr(g, "z");
    N_gradientangle = agfindnodeattr(g,"gradientangle");

    /* initialize edges */
    E_weight = agfindedgeattr(g, "weight");
    E_color = agfindedgeattr(g, "color");
    E_fillcolor = agfindedgeattr(g, "fillcolor");
    E_fontsize = agfindedgeattr(g, "fontsize");
    E_fontname = agfindedgeattr(g, "fontname");
    E_fontcolor = agfindedgeattr(g, "fontcolor");
    E_label = agfindedgeattr(g, "label");
    E_xlabel = agfindedgeattr(g, "xlabel");
    E_label_float = agfindedgeattr(g, "labelfloat");
    /* vladimir */
    E_dir = agfindedgeattr(g, "dir");
    E_arrowhead = agfindedgeattr(g, "arrowhead");
    E_arrowtail = agfindedgeattr(g, "arrowtail");
    E_headlabel = agfindedgeattr(g, "headlabel");
    E_taillabel = agfindedgeattr(g, "taillabel");
    E_labelfontsize = agfindedgeattr(g, "labelfontsize");
    E_labelfontname = agfindedgeattr(g, "labelfontname");
    E_labelfontcolor = agfindedgeattr(g, "labelfontcolor");
    E_labeldistance = agfindedgeattr(g, "labeldistance");
    E_labelangle = agfindedgeattr(g, "labelangle");
    /* end vladimir */
    E_minlen = agfindedgeattr(g, "minlen");
    E_showboxes = agfindedgeattr(g, "showboxes");
    E_style = agfindedgeattr(g, "style");
    E_decorate = agfindedgeattr(g, "decorate");
    E_arrowsz = agfindedgeattr(g, "arrowsize");
    E_constr = agfindedgeattr(g, "constraint");
    E_layer = agfindedgeattr(g, "layer");
    E_comment = agfindedgeattr(g, "comment");
    E_tailclip = agfindedgeattr(g, "tailclip");
    E_headclip = agfindedgeattr(g, "headclip");
    E_penwidth = agfindedgeattr(g, "penwidth");

    /* background */
    GD_drawing(g)->xdots = init_xdot (g);

    /* initialize id, if any */

    if ((p = agget(g, "id")) && *p)
	GD_drawing(g)->id = strdup_and_subst_obj(p, g);
}
Exemple #15
0
void dotneato_write(graph_t* g, std::string *output_str)
{
	double	xf, yf;
	char	*p;
	int	i;

	/* margins */
	if ((p = agget(g,"margin"))) {
		i = sscanf(p,"%lf,%lf",&xf,&yf);
		if (i > 0) g->u.drawing->margin.x = g->u.drawing->margin.y = POINTS(xf);
		if (i > 1) g->u.drawing->margin.y = POINTS(yf);
	}
	else {
		/* set default margins depending on format */
		switch (Output_lang) {
			case GIF:
			case PNG:
			case JPEG:
			case GD:
			case GD2:
			case ISMAP:
			case IMAP:
			case VRML:
			case SVG:
	        		g->u.drawing->margin.x = DEFAULT_EMBED_MARGIN_X;
				g->u.drawing->margin.y = DEFAULT_EMBED_MARGIN_Y;
				break;
			case POSTSCRIPT:
			case HPGL:
			case PCL:
			case MIF:
			case METAPOST:
			case FIG:
			case VTX:
			case ATTRIBUTED_DOT:
			case PLAIN:		
	        		g->u.drawing->margin.x = g->u.drawing->margin.y = DEFAULT_MARGIN;
				break;
			case CANONICAL_DOT:
				break;
		}
	}

	switch (Output_lang) {
		case POSTSCRIPT:
		case HPGL:
		case PCL:
		case MIF:
		case GIF:
		case PNG:
		case JPEG:
		case GD:
		case GD2:
		case ISMAP:
		case IMAP:
		case VRML:
		case METAPOST:
		case FIG:
		case SVG:
			/* output in breadth first graph walk order */
			emit_graph(g,0); break;
		case VTX:
			/* output sorted, i.e. all nodes then all edges */
			emit_graph(g,1); break;
		case ATTRIBUTED_DOT:
			attach_attrs(g);
			agwrite(g,Output_file); break;
		case CANONICAL_DOT:
			agwrite(g,Output_file); break;
		case PLAIN:
			attach_attrs(g);
			if (output_str)
			    write_plainstr(g,output_str);
			else
			    write_plain(g,Output_file);
			break;
	}
	fflush(Output_file);
}
#include "highgui.h"   
#define FRAME_WIDTH        240   
#define FRAME_HEIGHT    180   
#define TPL_WIDTH         16   
#define TPL_HEIGHT         12   
#define WIN_WIDTH        TPL_WIDTH * 2   
#define WIN_HEIGHT        TPL_HEIGHT * 2   
#define TM_THRESHOLD    0.4   
#define STAGE_INIT        1   
#define STAGE_TRACKING    2   
#define POINT_TL(r)        cvPoint(r.x, r.y)   
#define POINT_BR(r)        cvPoint(r.x + r.width, r.y + r.height)   
#define POINTS(r)        POINT_TL(r), POINT_BR(r)   
#define DRAW_RECTS(f, d, rw, ro)                                \   
{                                                                \   
    cvRectangle(f, POINTS(rw), CV_RGB(255, 0, 0), 1, 8, 0);        \   
    cvRectangle(f, POINTS(ro), CV_RGB(0, 255, 0), 1, 8, 0);        \   
    cvRectangle(d, POINTS(rw), cvScalarAll(255),  1, 8, 0);        \   
    cvRectangle(d, POINTS(ro), cvScalarAll(255),  1, 8, 0);        \   
}   
#define    DRAW_TEXT(f, t, d, use_bg)                                \   
if (d)                                                            \   
{                                                                \   
    CvSize _size;                                                \   
    cvGetTextSize(t, &font, &_size, NULL);                        \   
    if (use_bg)                                                    \   
    {                                                            \   
        cvRectangle(f, cvPoint(0, f->height),                     \   
                    cvPoint(_size.width + 5,                     \   
                            f->height - _size.height * 2),        \   
                    CV_RGB(255, 0, 0), CV_FILLED, 8, 0);        \   
Exemple #17
0
void init_ugraph(graph_t *g)
{
	char		*p;
	double		xf;
	static char *rankname[] = {"local","global","none",NULL};
	static int	rankcode[] =  {LOCAL, GLOBAL, NOCLUST, LOCAL};
	double X,Y,Z,x,y;

	GD_drawing(g) = NEW(layout_t);

	/* set this up fairly early in case any string sizes are needed */
	if ((p = agget(g,"fontpath")) || (p = getenv("DOTFONTPATH"))) {
		/* overide GDFONTPATH in local environment if dot
		 * wants its own */
#ifdef HAVE_SETENV
		setenv("GDFONTPATH", p, 1);
#else
		static char *buf=0;

		buf=grealloc(buf,strlen("GDFONTPATH=")+strlen(p)+1);
		strcpy(buf,"GDFONTPATH=");
		strcat(buf,p);
		putenv(buf);
#endif
	}

	GD_drawing(g)->quantum = late_double(g,agfindattr(g,"quantum"),0.0,0.0);
 	GD_drawing(g)->font_scale_adj = 1.0;

    /* setting rankdir=LR is only defined in dot,
     * but having it set causes shape code and others to use it. 
     * The result is confused output, so we turn it off unless requested.
     */
	if (UseRankdir)
		GD_left_to_right(g) = ((p = agget(g,"rankdir")) && streq(p,"LR"));
	else
		GD_left_to_right(g) = FALSE;
	do_graph_label(g);
	xf = late_double(g,agfindattr(g,"nodesep"),DEFAULT_NODESEP,MIN_NODESEP);
	GD_nodesep(g) = POINTS(xf);

	p = late_string(g,agfindattr(g,"ranksep"),NULL);
	if (p) {
			if (sscanf(p,"%lf",&xf) == 0) xf = DEFAULT_RANKSEP;
			else {if (xf < MIN_RANKSEP) xf = MIN_RANKSEP;}
			if (strstr(p,"equally")) GD_exact_ranksep(g) = TRUE;
	}
	else xf = DEFAULT_RANKSEP;
	GD_ranksep(g) = POINTS(xf);

	GD_showboxes(g) = late_int(g,agfindattr(g,"showboxes"),0,0);

	Epsilon = .0001 * agnnodes(g);
	getdoubles2pt(g,"size",&(GD_drawing(g)->size));
	getdoubles2pt(g,"page",&(GD_drawing(g)->page));
	getdouble(g,"epsilon",&Epsilon);
	getdouble(g,"nodesep",&Nodesep);
	getdouble(g,"nodefactor",&Nodefactor);

	X = Y = Z = x = y = 0.0;
	if ((p = agget(g,"viewport")))
            sscanf(p,"%lf,%lf,%lf,%lf,%lf",&X,&Y,&Z,&x,&y);
	GD_drawing(g)->viewport.size.x = ROUND(X); /* viewport size in dev units - pixels */
	GD_drawing(g)->viewport.size.y = ROUND(Y);
	GD_drawing(g)->viewport.zoom = Z;    /* scaling factor */
	GD_drawing(g)->viewport.focus.x = x; /* graph coord of focus - points */
	GD_drawing(g)->viewport.focus.y = y; 

	GD_drawing(g)->centered = mapbool(agget(g,"center"));
	if ((p = agget(g,"rotate"))) GD_drawing(g)->landscape = (atoi(p) == 90);
	else {		/* today we learned the importance of backward compatibilty */
		if ((p = agget(g,"orientation")))
			GD_drawing(g)->landscape = ((p[0] == 'l') || (p[0] == 'L'));
	}

	p = agget(g,"clusterrank");
	CL_type = maptoken(p,rankname,rankcode);
	p = agget(g,"concentrate");
	Concentrate = mapbool(p);
	
	Nodesep = 1.0;
	Nodefactor = 1.0;
	Initial_dist = MYHUGE;
}
Exemple #18
0
/* finalCC:
 * Set graph bounding box given list of connected
 * components, each with its bounding box set.
 * If c_cnt > 1, then pts != NULL and gives translations for components.
 * Add margin about whole graph unless isRoot is true.
 * Reposition nodes based on final position of
 * node's connected component.
 * Also, entire layout is translated to origin.
 */
static void
finalCC(graph_t * g, int c_cnt, graph_t ** cc, point * pts, graph_t * rg,
	layout_info* infop)
{
    attrsym_t * G_width = infop->G_width;
    attrsym_t * G_height = infop->G_height;
    graph_t *cg;
    box b, bb;
    boxf bbf;
    point pt;
    int margin;
    graph_t **cp = cc;
    point *pp = pts;
    int isRoot = (rg == infop->rootg);
    int isEmpty = 0;

    /* compute graph bounding box in points */
    if (c_cnt) {
	cg = *cp++;
	BF2B(GD_bb(cg), bb);
	if (c_cnt > 1) {
	    pt = *pp++;
	    bb.LL.x += pt.x;
	    bb.LL.y += pt.y;
	    bb.UR.x += pt.x;
	    bb.UR.y += pt.y;
	    while ((cg = *cp++)) {
		BF2B(GD_bb(cg), b);
		pt = *pp++;
		b.LL.x += pt.x;
		b.LL.y += pt.y;
		b.UR.x += pt.x;
		b.UR.y += pt.y;
		bb.LL.x = MIN(bb.LL.x, b.LL.x);
		bb.LL.y = MIN(bb.LL.y, b.LL.y);
		bb.UR.x = MAX(bb.UR.x, b.UR.x);
		bb.UR.y = MAX(bb.UR.y, b.UR.y);
	    }
	}
    } else {			/* empty graph */
	bb.LL.x = 0;
	bb.LL.y = 0;
	bb.UR.x = late_int(rg, G_width, POINTS(DEFAULT_NODEWIDTH), 3);
	bb.UR.y = late_int(rg, G_height, POINTS(DEFAULT_NODEHEIGHT), 3);
	isEmpty = 1;
    }

    if (GD_label(rg)) {
	point p;
	int d;

	isEmpty = 0;
	PF2P(GD_label(rg)->dimen, p);
	d = p.x - (bb.UR.x - bb.LL.x);
	if (d > 0) {		/* height of label added below */
	    d /= 2;
	    bb.LL.x -= d;
	    bb.UR.x += d;
	}
    }

    if (isRoot || isEmpty)
	margin = 0;
    else
	margin = late_int (g, G_margin, CL_OFFSET, 0);
    pt.x = -bb.LL.x + margin;
    pt.y = -bb.LL.y + margin + GD_border(rg)[BOTTOM_IX].y;
    bb.LL.x = 0;
    bb.LL.y = 0;
    bb.UR.x += pt.x + margin;
    bb.UR.y += pt.y + margin + GD_border(rg)[TOP_IX].y;

    /* translate nodes */
    if (c_cnt) {
	cp = cc;
	pp = pts;
	while ((cg = *cp++)) {
	    point p;
	    node_t *n;
	    pointf del;

	    if (pp) {
		p = *pp++;
		p.x += pt.x;
		p.y += pt.y;
	    } else {
		p = pt;
	    }
	    del.x = PS2INCH(p.x);
	    del.y = PS2INCH(p.y);
	    for (n = agfstnode(cg); n; n = agnxtnode(cg, n)) {
		ND_pos(n)[0] += del.x;
		ND_pos(n)[1] += del.y;
	    }
	}
    }

    bbf.LL.x = PS2INCH(bb.LL.x);
    bbf.LL.y = PS2INCH(bb.LL.y);
    bbf.UR.x = PS2INCH(bb.UR.x);
    bbf.UR.y = PS2INCH(bb.UR.y);
    BB(g) = bbf;

}
Exemple #19
0
void init_ugraph(graph_t* g)
{
	char		*p;
	int			i;
	double		xf;
	static char *rankname[] = {"local","global","none",NULL};
	static int	rankcode[] =  {LOCAL, GLOBAL, NOCLUST, LOCAL};
	
	g->u.drawing = NEW(layout_t);

	/* set this up fairly early in case any string sizes are needed */
	if ((p = agget(g,"fontpath")) || (p = getenv("DOTFONTPATH"))) {
		/* overide GDFONTPATH in local environment if dot
		 * wants its own */
#ifdef HAVE_SETENV
		setenv("GDFONTPATH", p, 1);
#else
		static char *buf=0;

		buf=(char *)realloc(buf,strlen("GDFONTPATH=")+strlen(p)+1);
		strcpy(buf,"GDFONTPATH=");
		strcat(buf,p);
		putenv(buf);
#endif
	}

	g->u.drawing->quantum = late_float(g,agfindattr(g,"quantum"),0.0,0.0);
 	g->u.drawing->font_scale_adj = 1.0;
	g->u.left_to_right = ((p = agget(g,"rankdir")) && streq(p,"LR"));
	do_graph_label(g);
	xf = late_float(g,agfindattr(g,"nodesep"),DEFAULT_NODESEP,MIN_NODESEP);
	g->u.nodesep = POINTS(xf);

	p = late_string(g,agfindattr(g,"ranksep"),NULL);
	if (p) {
			if (sscanf(p,"%lf",&xf) == 0) xf = DEFAULT_RANKSEP;
			else {if (xf < MIN_RANKSEP) xf = MIN_RANKSEP;}
			if (strstr(p,"equally")) g->u.exact_ranksep = TRUE;
	}
	else xf = DEFAULT_RANKSEP;
	g->u.ranksep = POINTS(xf);

	g->u.showboxes = late_int(g,agfindattr(g,"showboxes"),0,0);

	Epsilon = .0001 * agnnodes(g);
	getfloats2pt(g,"size",&(g->u.drawing->size));
	getfloats2pt(g,"page",&(g->u.drawing->page));
	getfloat(g,"epsilon",&Epsilon);
	getfloat(g,"nodesep",&Nodesep);
	getfloat(g,"nodefactor",&Nodefactor);

	g->u.drawing->centered = mapbool(agget(g,"center"));
	if ((p = agget(g,"rotate"))) g->u.drawing->landscape = (atoi(p) == 90);
	else {		/* today we learned the importance of backward compatibilty */
		if ((p = agget(g,"orientation")))
			g->u.drawing->landscape = ((p[0] == 'l') || (p[0] == 'L'));
	}

	p = agget(g,"clusterrank");
	CL_type = maptoken(p,rankname,rankcode);
	p = agget(g,"concentrate");
	Concentrate = mapbool(p);
	
	Nodesep = 1.0;
	Nodefactor = 1.0;
	Initial_dist = MYHUGE;
}