Exemple #1
0
void DrawPath(const std::vector<unsigned>& path, t_color color) {
    unsigned number_of_curvepoints;
// loop twice to draw the path and path border 
    for (unsigned dis = 0; dis < 2; dis++) {
        if (dis == 0) {
            setcolor(BLUE);
            setlinewidth(4);
        }
        if (dis == 1) {
            setcolor(color);
            setlinewidth(2);
        }
        for (unsigned i = 0; i < path.size(); i++) {
            StreetSegmentEnds end_points = getStreetSegmentEnds(path[i]);
            t_point start_point = LatLontoCoordinate(getIntersectionPosition(end_points.from));
            t_point end_point = LatLontoCoordinate(getIntersectionPosition(end_points.to));
            number_of_curvepoints = getStreetSegmentCurvePointCount(path[i]);
            if (number_of_curvepoints == 0) {
                drawline(start_point, end_point);
            } else {
                drawline(start_point, LatLontoCoordinate(getStreetSegmentCurvePoint(path[i], 0)));
                drawline(end_point, LatLontoCoordinate(getStreetSegmentCurvePoint(path[i], number_of_curvepoints - 1)));

                for (unsigned j = 0; j < number_of_curvepoints - 1; j++)
                    drawline(LatLontoCoordinate(getStreetSegmentCurvePoint(path[i], j)),
                        LatLontoCoordinate(getStreetSegmentCurvePoint(path[i], j + 1)));
            }
        }
    }
}
Exemple #2
0
static void draw_rr (void) {

/* Draws the routing resources that exist in the FPGA, if the user wants *
 * them drawn.                                                           */

 int inode, itrack;

 if (draw_rr_toggle == DRAW_NO_RR) {
    setlinewidth (3);
    drawroute (HIGHLIGHTED);
    setlinewidth (0);
    return;
 }

 setlinestyle (SOLID);
 setlinewidth (0);

 for (inode=0;inode<num_rr_nodes;inode++) {
 
     switch (rr_node[inode].type) {
     
     case SOURCE: case SINK:
        break;         /* Don't draw. */

     case CHANX:
       setcolor (BLACK);
       itrack = rr_node[inode].ptc_num;
       draw_rr_chanx (inode, itrack);
       draw_rr_edges (inode);
       break;

     case CHANY:
       setcolor (BLACK);
       itrack = rr_node[inode].ptc_num;
       draw_rr_chany (inode, itrack);
       draw_rr_edges (inode);
       break;

    case IPIN:
       draw_rr_pin (inode, BLUE);
       break;

    case OPIN:
       draw_rr_pin (inode, RED);
       setcolor (RED);
       draw_rr_edges (inode);
       break;

    default:
       printf("Error in draw_rr:  Unexpected rr_node type: %d.\n",
               rr_node[inode].type);
       exit (1);
    }
 }
 
 setlinewidth (3);
 drawroute (HIGHLIGHTED);
 setlinewidth (0);
}
Exemple #3
0
static void draw_radio(control c, rect r)
{
	int w;
	rect box, textrect;
	char *name;
	int style = (AlignLeft | AlignTop);
	font f;
	rgb old = currentcolour();

	/* Calculate rectangles. */
	f = gettextfont(c);
	setfont(f);
	w = strwidth(f,"W");
	if (w > r.width)  w = r.width;
	if (w > r.height) w = r.height;
	box = rect(r.x,r.y+1,w,w);
	if (w < getheight(f) - getdescent(f))
		box.y += getheight(f) - getdescent(f) - w;
	textrect = rect(r.x+w+w/2,r.y,r.width-(w+w/2),r.height);

	/* Clear the check area. */
	setlinewidth(1);
	setcolour(White);
	fillellipse(insetr(box,1));

	/* Draw the check area */
	if (isenabled(c))
		setcolour(Black);
	else
		setcolour(Grey);
	drawellipse(box);

	/* Provide 'pressed button' effect by black border. */
	if (ishighlighted(c)) {
		setlinewidth(2);
		drawellipse(box);
		setlinewidth(1);
	}

	/* Put o in circle if checked. */
	if (ischecked(c))
		fillellipse(insetr(box,3));

	name = getname(c);
	if (isenabled(c)) {
		/* if (hasfocus(c)) {
			style |= Underline;
			setlinewidth(2);
		} */
		setcolour(getforeground(c));
	}
	drawtext(textrect, style, name);

	setcolour(old);
}
Exemple #4
0
int FlowPdf::arrow( double x1, double y1, double x2, double y2, 
		    double x3, double y3, flow_eDrawType type, double idx)
{
  topdf->draw_arrow( x1 - offset_x, offset_y - y1, x2 - offset_x, offset_y - y2, 
		     x3 - offset_x, offset_y - y3, type == flow_eDrawType_LineGray);
  
#if 0
  if ( type == flow_eDrawType_LineGray)
  {
    fprintf( file, "gsave\n");
    fprintf( file, "0.5 setgray\n");    
  }

  setlinewidth( idx);
  fprintf( file, "newpath\n");
  fprintf( file, "%f %f moveto\n", x1-offset_x, offset_y-y1);
  fprintf( file, "%f %f lineto\n", x2-offset_x, offset_y-y2);
  fprintf( file, "%f %f lineto\n", x3-offset_x, offset_y-y3);
  fprintf( file, "%f %f lineto\n", x1-offset_x, offset_y-y1);
  fprintf( file, "closepath\n");
  fprintf( file, "fill\n");

  if ( type == flow_eDrawType_LineGray)
    fprintf( file, "grestore\n");

#endif
  return 1;
}
Exemple #5
0
static void draw_congestion (void) {

/* Draws all the overused routing resources (i.e. congestion) in RED.   */

 int inode, itrack;

 setcolor (RED);
 setlinewidth (2);

 for (inode=0;inode<num_rr_nodes;inode++) {
    if (rr_node[inode].occ > rr_node[inode].capacity) { 
    
       switch (rr_node[inode].type) {

       case CHANX:
          itrack = rr_node[inode].ptc_num;
          draw_rr_chanx (inode, itrack);
          break;
          
       case CHANY:
          itrack = rr_node[inode].ptc_num;
          draw_rr_chany (inode, itrack);
          break;
 
       case IPIN: case OPIN:
          draw_rr_pin (inode, RED);
          break;
  
       default:
          break;
       }
    }
 }
}
Exemple #6
0
static void drawnets (void) {

/* This routine draws the nets on the placement.  The nets have not *
 * yet been routed, so we just draw a chain showing a possible path *
 * for each net.  This gives some idea of future congestion.        */

 int inet, ipin, b1, b2;
 float x1, y1, x2, y2;
 
 setlinestyle (SOLID);
 setlinewidth (0);
 
/* Draw the net as a star from the source to each sink. Draw from centers of *
 * blocks (or sub blocks in the case of IOs).                                */

 for (inet=0;inet<num_nets;inet++) {
    if (is_global[inet])               /* Don't draw global nets. */
       continue;

    setcolor (net_color[inet]);
    b1 = net[inet].blocks[0];
    get_block_center (b1, &x1, &y1);
       
    for (ipin=1;ipin<net[inet].num_pins;ipin++) {
       b2 = net[inet].blocks[ipin];
       get_block_center (b2, &x2, &y2);
       drawline (x1,y1,x2,y2);
 /*      x1 = x2;  */    /* Uncomment to draw a chain instead of a star. */
 /*      y1 = y2;  */
    }
 }
}
Exemple #7
0
static void draw_image_button(button obj, rect r)
{
	image   img;
	bitmap	store = NULL;
	rect    ir;
	rgb     up, down;
	rgb     old = currentcolour();

	img = obj->img;
	if (has_transparent_pixels(img)) {
		store = newbitmap(r.width, r.height, 0);
		drawto(store);
		setcolour(getbackground(obj));
		fillrect(r);
	}

	if (img) {
		ir = insetr(r,2);
		if (ishighlighted(obj)) /* button is pressed */
			ir.x += 1, ir.y += 1;

		/* Draw the button image. */
		if (ischecked(obj))
			drawdarker(img, ir, getrect(img));
		else if (isenabled(obj))
			drawimage(img, ir, getrect(img));
		else
			drawgreyscale(img, ir, getrect(img));

		if (ishighlighted(obj)) { /* fill the gap */
			ir.x -= 1, ir.y -= 1;
			setcolour(getbackground(obj));
			drawline(topleft(ir),topright(ir));
			drawline(topleft(ir),bottomleft(ir));
		}
	}

	/* Draw button border. */
	setcolour(getforeground(obj));
	setlinewidth(1);
	drawrect(r);

	/* Draw button shadow. */
	up = White, down = Grey;
	if (ishighlighted(obj))
		up = Grey, down = LightGrey;
	draw_shadow(insetr(r,1), up, down, 1);

	if (store != NULL) {
		drawto(obj);
		copyrect(store, pt(0,0), getrect(store));
		del(store);
	}

	setcolour(old);
}
Exemple #8
0
//! Constructor. Argument is the name of the PostScript file to be created.
PSpage::PSpage(char *filename)
{
	file = new char[128];
	strcpy(file, filename);
	PLT = fopen(file,"wb");

	if(!PLT) throw("failure opening output file for plot");
	fprintf(PLT,"%%!\n/mt{moveto}def /lt{lineto}def /np{newpath}def\n");
	fprintf(PLT,"/st{stroke}def /cp{closepath}def /fi{fill}def\n");
	fprintf(PLT,"/zp {gsave /ZapfDingbats findfont exch ");
	fprintf(PLT,"scalefont setfont moveto show grestore} def\n");
	setfont("Times-Roman",12.);
	setlinewidth(0.5);
}
Exemple #9
0
static void drawInit( int sizex, int sizey, char* seqName, char* filename, float score) {

 int i,k=0;
 int x,y;
 char* c;
 c =(char*)malloc(sizeof(char)*1000);
 


/* initialize display */
 init_graphics("RNA");


/* still picture drawing allows user to zoom, etc. */
 init_world (0.,0.,CELLSIZE*sizex,CELLSIZE*sizey);
 //event_loop(button_press, drawscreen);   

/* animation section */
 clearscreen();
 init_postscript(filename);
 clearscreen();
 
 sprintf(c, "%s%s%s%d%s%f%s", "RNA: ", seqName, ", length = ", sizex, ", energy = ",-score/1000.0, " kal/mol");
 //printf(" output string is %s\n",c);
 update_message("RNA secondary structure");
 flushinput();
 
 drawtext (sizex*CELLSIZE/2,sizey*CELLSIZE/10,c,1.0e6);
 flushinput();
 setcolor (BLACK);
 setlinewidth(1);
 setlinestyle (SOLID);
 for (i=0;i<=sizex;i++) {
    drawline (i*CELLSIZE,(sizey/2-1)*CELLSIZE,i*CELLSIZE,CELLSIZE*sizey/2);
    flushinput();
 }
 drawline(0,(sizey/2-1)*CELLSIZE, sizex*CELLSIZE, CELLSIZE*(sizey/2-1));
 drawline(0,sizey*CELLSIZE/2, sizex*CELLSIZE, CELLSIZE*sizey/2);
 flushinput();
 free(c);
}
Exemple #10
0
static void draw_button(control c, rect r)
{
	rect textrect;
	rgb up, down;
	font f;
	rgb old = currentcolour();

	clear(c);

	/* Draw the button name. */
	if (isenabled(c))
		setcolour(getforeground(c));
	else
		setcolour(Grey);
	f = gettextfont(c);
	setfont(f);
	textrect = r;
	if (ishighlighted(c))
		textrect.x += 1, textrect.y += 1;
	drawtext(textrect, Center|VCenter, getname(c));

	/* Draw button border. */
	setlinewidth(1);
	drawrect(r);
	r = insetr(r,1);

	/* Draw button shadow. */
	up = White, down = Grey;
	if (ishighlighted(c))
		up = Grey, down = LightGrey;
	else if (hasfocus(c)) {
		setcolour(Black);
		drawrect(r);
		r = insetr(r,1);
	}
	draw_shadow(r, up, down, SHADOW_WIDTH);

	setcolour(old);
}
void drawFeature(unsigned i, char mini)
{
    t_point* featurePoints;
    if(mini)
    {
        allLargeFeatures[i].updatepolyMiniPoints();
        featurePoints = allLargeFeatures[i].getpolyPoints();
        i = allLargeFeatures[i].getID();
    } else {
        featurePoints = allFeatures[i].getpolyPoints();
    }
    
    //closed features are polygons
    if (allFeatures[i].isClosed())
    {
        setcolor(colorScheme[allFeatures[i].getcolorID()][colorMode]);
        fillpoly(featurePoints, allFeatures[i].getnPoints());

    } else { //open features are lines
        setcolor(colorScheme[allFeatures[i].getcolorID()][colorMode]);
        if(mini)
        {
            for (unsigned j = 0; j < allFeatures[i].getnPoints() - 1; j ++) {
                drawline(featurePoints[j],featurePoints[j+1]);
            }
        } else {
            setlinewidth(floor(allFeatures[i].getlineWidth()/trueScreen.get_width()));
            setlinestyle(allFeatures[i].getlineStyle());
            for (unsigned j = 0; j < allFeatures[i].getnPoints() - 1; j ++) {
                drawline(featurePoints[j],featurePoints[j+1]);
                fillarc(featurePoints[j].x,featurePoints[j].y,allFeatures[i].getlineWidth()/2200,0,360);
            }
            fillarc(featurePoints[allFeatures[i].getnPoints() - 1].x,featurePoints[allFeatures[i].getnPoints() - 1].y,allFeatures[i].getlineWidth()/2200,0,360);
        }           
    }
}
Exemple #12
0
void 
xlinax() {
	char ktemp[9];
	int lpower;
	int ia, ib, igdlog, jdiv, jpower, jstep, jtick, 
	 mds, nds, ndsu, ntick, nxdivu;
	float divlog, divtry, factor, grdlog, power, skfudge, 
	 value, valuei, xdivu, xgrdmn, xgrdmx, xref, xrefi, xtick, xticki, 
	 xvpmax, xvpmin, yloc, ypow, yvpmax, yvpmin;
	static char kvalue[17] = "                ";
	static char kpower[9] = "        ";


	/*=====================================================================
	 * PURPOSE:  To produce a linearly-scaled axis at the bottom and/or
	 *           top of the current plot window.
	 *=====================================================================
	 * MODULE/LEVEL:  gem/4
	 *=====================================================================
	 * GLOBAL INPUT:
	 *    MACH:    VSMALL
	 *    GEM:     LXDIV, XDIV, LNXDIV, NXDIV, CHHT, CHWID, LXREV,
	 *             XPMNU, XPMXU, XIMNZ, XIMXZ,
	 *             LBOTAX, LBOTTC, LTOPAX, LTOPTC,
	 *             IHORZ, IVERT, XMPIP1, XMPIP2,
	 *             LXGRD, IXGRD, IWIDTH, ISKWIDTH, ITHIN, SKDEVFUDGE
	 *=====================================================================
	 * GLOBAL OUTPUT:
	 *    GEM:     AXWBOT, AXWTOP
	 *=====================================================================
	 * SUBROUTINES CALLED:
	 *    SACLIB:  CNVITA, LJUST, SETLINESTYLE, LINE, PLTEXT, CNVFTA, 
	 *             SETTEXTJUST, SETLINEWIDTH, GETVPORT
	 *=====================================================================
	 * LOCAL VARIABLES:
	 *    xdivu:   Divison spacing used.
	 *    lpower:  Set to .TRUE. if there is a multiplying scale factor.
	 *    power:   Multiplying scale factor.
	 *    kpower:  Character string containing formatted scale factor.
	 *    ypow:    Y location in plot coordinates of scale factor.
	 *    divtry:  Trial division spacing.
	 *    jstep:   Integer trial step size (constrained to be 10, 5 or 2).
	 *    xgrdmn:  Minimum labeled grid value (including scale factor).
	 *    xgrdmx:  Maximum labeled grid value (including scale factor).
	 *    value:   Labeled grid value excluding scale factor.
	 *    valuei:  Increment in VALUE.
	 *    kvalue:  Character string containing formatted label value.
	 *    xref:    Location of labeled grid value in plot coordinates.
	 *    xrefi:   Increment in XREF.
	 *=====================================================================
	 * ASSUMPTIONS:
	 * - plmap has set up world to plot coordiate mapping.
	 * - Text orientation is horizontal.
	 *=====================================================================
	 * MODIFICATION HISTORY:
	 *    920526:  Added line-width. TEXT is always line-width THIN!
	 *    830929:  Added secondary tick marks.
	 *    830927:  Moved grid drawing logic into its own do loop.
	 *    830223:  Fixed logic in computing annotation format.
	 *    820928:  Cleaned up and documented.
	 *    810120:  Original PRIME version.
	 *===================================================================== */
	/* PROCEDURE: */
         settextangle(TEXT_HORIZONTAL);

	/* - Determine division spacing.  There are three possibilities:
	 *   (1) The division spacing is set by user (LXDIV=.TRUE.).
	 *   (2) The (approximate) number of divsions is set (LNXDIV=.TRUE.).
	 *   (3) "Nice" division spacings are calculated. */
	if( cmgem.xdiv_spacing_on ){
          xdivu = cmgem.xdiv_spacing;
          power = log10( xdivu );
          if( power < 0. )
            power = power - 1.;
          jpower = power;
        } else {
          if( cmgem.xdiv_number_on ){
            nxdivu = cmgem.xdiv_number;
          } else {
            nxdivu = (fabs( cmgem.uplot.xmax - cmgem.uplot.xmin )/(FDIVSP*cmgem.chht)) + .001;
            if( nxdivu < 5 )
              nxdivu = 5;
          }
          divtry = (cmgem.zdata.xmax - cmgem.zdata.xmin)/nxdivu;
          if( divtry > 0. ){
            power = log10( divtry );
          } else {
            power = 0.;
          }
          if( power < 0. )
            power = power - 1.;
          jpower = power;
          
          /* -- Limit divison spacings to steps of 10, 5, or 2 [cases (2) and (3)]. */
          jstep = divtry*(powi(10.,-jpower));
          if( jstep > 5 ){
            jstep = 1;
            jpower = jpower + 1;
            /* power = power + 1.; */
          } else if( jstep > 2 ) {
            jstep = 5;
          } else {
            jstep = 2;
          }
          xdivu = jstep*(powi(10.,jpower));
        }

	/* - Determine "nice-numbered" starting and ending values. */

	ia = cmgem.zdata.xmin/xdivu;
	xgrdmn = xdivu*ia;
	if( xgrdmn < cmgem.zdata.xmin ){
		ia = ia + 1;
		xgrdmn = xgrdmn + xdivu;
		}
	ib = cmgem.zdata.xmax/xdivu;
	xgrdmx = xdivu*ib;
	if( xgrdmx > cmgem.zdata.xmax ){
		ib = ib - 1;
		xgrdmx = xgrdmx - xdivu;
		}
	nxdivu = ib - ia + 1;

	/* - Determine the format (Fn.m) of the labels.
	 *   The variable NDS assumes the role of "n" and MDS the role of "m". */

	/* - The "magic numbers" used in this algorithm  generate good division
	 *   spacings almost all of the time.  Modify them at your own risk. */

	grdlog = log10( fmax( fabs( xgrdmn ), fabs( xgrdmx ) ) + 0.001 );
	if( grdlog >= 0. ){
		grdlog = grdlog + 1.001;
		}
	else{
		grdlog = grdlog - 0.999;
		}
	divlog = log10( xdivu );
	if( divlog >= 0. ){
		divlog = divlog + 1.001;
		}
	else{
		divlog = divlog - 0.999;
		}
	lpower = FALSE;
	factor = 1.;
	if( grdlog*divlog >= 0. ){
		if( grdlog < 0. ){
			igdlog = grdlog;
			}
		else{
			igdlog = divlog;
			}
		if( labs( igdlog ) >= 3 && cmgem.lxpowr ){
			mds = 0;
			nds = max( 4, (int)( grdlog ) - (int)( divlog ) + 2 );
			cnvita( jpower, ktemp,9 );
			ljust( ktemp,9 );
			if( jpower >= 0 ){
                                fstrncpy( kpower, 8, "X 10+", 5);
                                fstrncpy( kpower+5, 8-5, ktemp, strlen(ktemp));
				}
			else{
                                fstrncpy( kpower, 8, "X 10", 4);
                                fstrncpy( kpower+4, 8-4, ktemp, strlen(ktemp));
				}
			factor = powi(10.,-jpower);
			lpower = TRUE;
			}
		else{
			mds = labs( minfi( 0., divlog ) );
			nds = maxfi( 1., grdlog );
			if( mds > 0 )
				nds = nds + mds + 2;
			}
		}
	else{
		mds = labs( minfi( 0., divlog ) );
		nds = maxfi( 0., grdlog );
		if( mds > 0 )
			nds = nds + mds + 2;
		}

	/* - Determine axes fudge factor for thick axes lines. */
	getvport( &xvpmin, &xvpmax, &yvpmin, &yvpmax );
	skfudge = cmgem.skdevfudge*((yvpmin - yvpmax)/(xvpmin - xvpmax));

	/* - Draw the bottom axis. */

	setlinestyle( LINE_STYLE_SOLID );
	setlinewidth( cmgem.iskwidth );

	if( cmgem.axis[BOTTOM].annotate || cmgem.axis[BOTTOM].ticks ){

		/* -- Bottom Axes line. */
		if( cmgem.iskwidth > LINE_WIDTH_THIN ){
			line( cmgem.uplot.xmin - cmgem.iskwidth*skfudge, cmgem.uplot.ymin, 
			 cmgem.uplot.xmax + cmgem.iskwidth*skfudge, cmgem.uplot.ymin );
			}
		else{
			line( cmgem.uplot.xmin, cmgem.uplot.ymin, cmgem.uplot.xmax, cmgem.uplot.ymin );
			}

		/* -- Label for multiplying scale factor. */
		if( lpower && cmgem.axis[BOTTOM].annotate ){
			ypow = fmax( cmgem.uplot.ymin - 2.2*cmgem.chht, 0.1*cmgem.chht );
			if( cmgem.lxrev ){
				settextjust( "RIGHT", "BOTTOM" );
				}
			else{
				settextjust( "LEFT", "BOTTOM" );
				}
			pltext( kpower,9, cmgem.uplot.xmin, ypow );
			setlinewidth( cmgem.iskwidth );
			}

		/* -- Calculate constants for labeled tick marks. */
		value = xgrdmn*factor;
		xref = xgrdmn*cmgem.xmpip1 + cmgem.xmpip2;
		valuei = xdivu*factor;
		xrefi = xdivu*cmgem.xmpip1;
		strcpy( kvalue, "                " );

		/* -- Draw secondary tick marks before first labeled one. */
		ntick = 1;
		if( xrefi >= 0.10 ){
			ntick = 3;
			if( jstep == 5 )
				ntick = 4;
			}
		if( xrefi >= 0.25 )
			ntick = 9;
		xticki = xrefi/(float)( ntick + 1 );
		xtick = xref - xrefi;
		for( jtick = 1; jtick <= ntick; jtick++ ){
			xtick = xtick + xticki;
			if( xtick >= cmgem.uplot.xmin ){
				line( xtick, cmgem.uplot.ymin, xtick, cmgem.uplot.ymin + 
				 0.5*cmgem.chwid );
				}
			}

		/* -- Loop on labeled tick marks. */
		for( jdiv = 1; jdiv <= nxdivu; jdiv++ ){
			line( xref, cmgem.uplot.ymin, xref, cmgem.uplot.ymin + 
			 cmgem.chwid );
			if( cmgem.axis[BOTTOM].annotate ){
				if( value >= 0 ){
					ndsu = nds;
					}
				else{
					ndsu = nds + 1;
					}
				cnvfta( value, ndsu, mds, kvalue,17 );
				ljust( kvalue,17 );
				yloc = cmgem.uplot.ymin - 0.1*cmgem.chht;
				settextjust( "CENTER", "TOP" );
				pltext( kvalue,17, xref, yloc );
				setlinewidth( cmgem.iskwidth );
				}
			/* --- Loop on secondary tick marks. */
			xtick = xref;
			for( jtick = 1; jtick <= ntick; jtick++ ){
				xtick = xtick + xticki;
				if( xtick <= cmgem.uplot.xmax ){
					line( xtick, cmgem.uplot.ymin, xtick, cmgem.uplot.ymin + 
					 0.5*cmgem.chwid );
					}
				}
			value = value + valuei;
			xref = xref + xrefi;
			}

		/* -- Save axes widths. */
		if( cmgem.axis[BOTTOM].annotate ){
			cmgem.axis[BOTTOM].width = 1.1*cmgem.chht;
			if( lpower )
				cmgem.axis[BOTTOM].width = cmgem.uplot.ymin - ypow;
			}
		else{
			cmgem.axis[BOTTOM].width = 0.;
			}

		}

	/* - Top axis: */

	if( cmgem.axis[TOP].annotate || cmgem.axis[TOP].ticks ){

		/* -- Top Axes line. */
		if( cmgem.iskwidth > LINE_WIDTH_THIN ){
			line( cmgem.uplot.xmin - cmgem.iskwidth*skfudge, cmgem.uplot.ymax, 
			 cmgem.uplot.xmax + cmgem.iskwidth*skfudge, cmgem.uplot.ymax );
			}
		else{
			line( cmgem.uplot.xmin, cmgem.uplot.ymax, cmgem.uplot.xmax, cmgem.uplot.ymax );
			}

		/* -- Label for multiplying scale factor. */
		if( lpower && cmgem.axis[TOP].annotate ){
			ypow = fmin( cmgem.uplot.ymax + 2.2*cmgem.chht, cmgem.view.ymax - 
			 0.1*cmgem.chht );
			if( cmgem.lxrev ){
				settextjust( "RIGHT", "TOP" );
				}
			else{
				settextjust( "LEFT", "TOP" );
				}
			pltext( kpower,9, cmgem.uplot.xmin, ypow );
			setlinewidth( cmgem.iskwidth );
			}

		/* -- Calculate constants for labeled tick marks. */
		value = xgrdmn*factor;
		xref = xgrdmn*cmgem.xmpip1 + cmgem.xmpip2;
		valuei = xdivu*factor;
		xrefi = xdivu*cmgem.xmpip1;
		strcpy( kvalue, "                " );

		/* -- Draw secondary tick marks before first labeled one. */
		ntick = 1;
		if( xrefi >= 0.10 ){
			ntick = 3;
			if( jstep == 5 )
				ntick = 4;
			}
		if( xrefi >= 0.25 )
			ntick = 9;
		xticki = xrefi/(float)( ntick + 1 );
		xtick = xref - xrefi;
		for( jtick = 1; jtick <= ntick; jtick++ ){
			xtick = xtick + xticki;
			if( xtick >= cmgem.uplot.xmin ){
				line( xtick, cmgem.uplot.ymax, xtick, cmgem.uplot.ymax - 
				 0.5*cmgem.chwid );
				}
			}

		/* -- Loop on labeled tick marks. */
		for( jdiv = 1; jdiv <= nxdivu; jdiv++ ){
			line( xref, cmgem.uplot.ymax, xref, cmgem.uplot.ymax - 
			 cmgem.chwid );
			if( cmgem.axis[TOP].annotate ){
				if( value >= 0. ){
					ndsu = nds;
					}
				else{
					ndsu = nds + 1;
					}
				cnvfta( value, ndsu, mds, kvalue,17 );
				ljust( kvalue,17 );
				yloc = cmgem.uplot.ymax + 0.1*cmgem.chht;
				settextjust( "CENTER", "BOTTOM" );
				pltext( kvalue,17, xref, yloc );
				setlinewidth( cmgem.iskwidth );
				}
			/* --- Loop on secondary tick marks. */
			xtick = xref;
			for( jtick = 1; jtick <= ntick; jtick++ ){
				xtick = xtick + xticki;
				if( xtick <= cmgem.uplot.xmax ){
					line( xtick, cmgem.uplot.ymax, xtick, cmgem.uplot.ymax - 
					 0.5*cmgem.chwid );
					}
				}
			value = value + valuei;
			xref = xref + xrefi;
			}

		/* -- Save axes widths. */
		if( cmgem.axis[TOP].annotate ){
			cmgem.axis[TOP].width = 1.1*cmgem.chht;
			if( lpower )
				cmgem.axis[TOP].width = ypow - cmgem.uplot.ymax;
			}
		else{
			cmgem.axis[TOP].width = 0.;
			}

		}

	/* - Grid lines. */

	if( cmgem.lxgrd ){
		setlinewidth( LINE_WIDTH_THIN );
		xref = xgrdmn*cmgem.xmpip1 + cmgem.xmpip2;
		xrefi = xdivu*cmgem.xmpip1;
		setlinestyle( cmgem.ixgrd );
		for( jdiv = 1; jdiv <= nxdivu; jdiv++ ){
			line( xref, cmgem.uplot.ymin, xref, cmgem.uplot.ymax );
			xref = xref + xrefi;
			}
		setlinestyle( LINE_STYLE_SOLID );
		setlinewidth( cmgem.iskwidth );
		}

       

	return;

} /* end of function */
Exemple #13
0
void drawscreen (void)
{
   set_draw_mode(DRAW_NORMAL);
   clearscreen();

   for(auto it = cells.begin(); it != cells.end(); ++it)
   {
      t_point bt_marker = t_point(it->x_pos - 0.3, it->y_pos - 0.3);
      t_bound_box cell_rect = t_bound_box(bt_marker, 0.6, 0.6);
      if (it->fixed)
        setcolor(RED);
      else
        setcolor(BLUE);
      fillrect(cell_rect);
   }

#ifdef _DEBUG_
   setcolor(BLACK);
   for(auto it = virtual_pins.begin(); it != virtual_pins.end(); ++it)
   {
      t_point bt_marker = t_point(it->x_pos - 0.3, it->y_pos - 0.3);
      t_bound_box cell_rect = t_bound_box(bt_marker, 0.6, 0.6);
      fillrect(cell_rect);
   }
#endif

   setcolor(MEDIUMPURPLE);
   setlinestyle(SOLID);
   setlinewidth(1);
   std::vector<int> q_to_c_map;
   q_to_c_map.resize(Q.size());

   unsigned int q_idx=0;
   for(unsigned int i=0; i<cells.size(); i++)
   {
      if (Vertex::v_map_table[i] == -1)
        continue;
      assert(q_idx < Q.size());
      q_to_c_map[q_idx++] = i;
   }

   if (show_nets)
   {
      int drawn_lines =0;
      //draw lines between movable cells
      for(unsigned int c=0; c<Q.size(); c++)
      {
         for(unsigned int r=c+1; r<Q.size(); r++)
         {
            if (Q[c][r] != 0)
            {
                int src_idx = q_to_c_map.at(c);
                int tgt_idx = q_to_c_map.at(r);
                drawline(cells[src_idx].x_pos, cells[src_idx].y_pos, 
                         cells[tgt_idx].x_pos, cells[tgt_idx].y_pos);
                drawn_lines++;
            }
         }
      }
      setcolor(RED);
      setlinestyle(DASHED);
      setlinewidth(1);
      //used edge set to filter 
      std::unordered_set<std::pair<int, int>> u_edges;
      for(auto f_iter = fixed_cells.begin();  f_iter != fixed_cells.end(); ++f_iter)
      {
        std::list<Edge>& adj_cells = f_iter->adj_list;

        //iterating over the edge list to draw
        for(auto t_iter = adj_cells.begin(); t_iter != adj_cells.end(); ++t_iter)
        {
           std::pair<int, int> edge (f_iter->v_id, t_iter->tgt->v_id);
           auto set_idx = u_edges.find(edge);

           //skip if edge is found in the set
           if (set_idx != u_edges.end()) {
              continue;
           }
           u_edges.insert(edge);
           drawline(f_iter->x_pos, f_iter->y_pos, 
                    t_iter->tgt->x_pos, t_iter->tgt->y_pos);
           drawn_lines++;
        }
      }
   }

#ifdef _DEBUG_
   std::cout << "Number of lines drawn: " << drawn_lines << "\n";
#endif
}
Exemple #14
0
void GetPathInstructions(vector<unsigned> Path){
    
    
    
    
    // First, draw a box in the graphics window, on which the path instructions 
    // will be displayed. 
    float tempXCenter = get_visible_world().get_xcenter();
    float tempYCenter = get_visible_world().get_ycenter();
    float BoxLeft = tempXCenter + 0.18 * get_visible_world().get_width();
    float BoxRight = tempXCenter + 0.48 * get_visible_world().get_width();
    float BoxBottom = tempYCenter - 0.48 * get_visible_world().get_height();
    float BoxTop = tempYCenter + 0.12 * get_visible_world().get_height();
    t_bound_box HelpBox(BoxLeft, BoxBottom, BoxRight, BoxTop);
    
    // string intro = "Welcome to Map-2-Go"; 
    
    setcolor(246, 246, 246);

    fillrect(HelpBox);

    
    // Draw the borders of the box. 
    setcolor(200, 200, 200);
    setlinewidth(6);

    t_point border[6];
    border[5].x = BoxRight;
    border[5].y = BoxTop;

    
    // Add depth to the box, making the user feel as if he or she is looking 
    // in 3D perspective at the box. 
    border[2].x = BoxLeft + 0.02 * HelpBox.get_width();
    border[2].y = BoxBottom - 0.02 * HelpBox.get_width();

    border[3].x = BoxRight + 0.02 * HelpBox.get_width();
    border[3].y = BoxBottom - 0.02 * HelpBox.get_width();

    border[4].x = BoxRight + 0.02 * HelpBox.get_width();
    border[4].y = BoxTop - 0.02 * HelpBox.get_width();

    border[0].x = BoxRight;
    border[0].y = BoxBottom;

    border[1].x = BoxLeft;
    border[1].y = BoxBottom;

    fillpoly(border, 6);
    setcolor(20, 20, 20);
    setlinewidth(1);

    drawrect(border[1], border[5]);

    drawline(border[1], border[2]);
    drawline(border[2], border[3]);
    drawline(border[3], border[0]);
    drawline(border[4], border[5]);
    drawline(border[4], border[3]);
    
    // From now on, start displaying the path instructions. 
    
    settextrotation(0); 
    setcolor(20,20,20); 
    setfontsize(12); 
    
    string InstructionLabel = "Path Instructions"; 
    
    // Write "Path Instructions" onto the box in the graphics window. 
    drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - 0.03 * HelpBox.get_height(), InstructionLabel, HelpBox.get_width(), HelpBox.get_height());

    // Draw a line separating the header above from the instructions later on. 
    setlinewidth(2);
    drawline(HelpBox.left() + 0.05 * HelpBox.get_width(), HelpBox.top() - 0.06 * HelpBox.get_height(), HelpBox.right() - 0.05 * HelpBox.get_width(), HelpBox.top() - 0.06 * HelpBox.get_height()); //splitline 

    settextrotation(0); 
    setcolor(20,20,20); 
    setfontsize(10); 
   
    
    /////////////////////////////////////////////////////////
   
    bool differentStreet; // Bool flag to determine if two street segments belong to different streets. 
    bool needExtraLine; // Bool flag to determine if obtained path instruction has too many characters 
    // to fit in the width of the box. 
    
    int numLines = 0; // This counter determines how far down the box each subsequent instruction will be displayed at. 
    int displayStraightInstruction = 0; // When this integer counter is zero, a path instruction that has "Go Straight" 
    // will be displayed once, but if the subsequent instruction is still "Go Straight", the integer counter will have 
    // incremented by one already - thus preventing the redundant instruction rom being displayed. 
    
    // Traverse the vector of street segments, and access the current and current+1 street segment with each iteration. 
    for (unsigned i = 0; i < Path.size()-1; i++){
        
 
        
        int LeftOrRight = 3; // This integer determines whether to turn right, left, or go straight. It is initialized 
        // to 3 for each iteration, so as not to match any of the above cases initially. 
        
        string tempString; // This will store the path instruction. 
        string tempString2; // This will store the remainder of the path instruction, if the instruction is longer than 
        // 50 characters and will potentially be cut off. 
        
        // The bool flags are initially set to false, for each iteration. 
        differentStreet = false; 
        needExtraLine = false; 
        
        // Obtain street name of the first street segment. 
        string StreetName1 = getStreetName(getStreetSegmentStreetID(Path[i])); 
        // Obtain street name of the second street segment. 
        string StreetName2 = getStreetName(getStreetSegmentStreetID(Path[i+1])); 
        
        // If the second segment's street name is "(unknown)" or " ", then do not go and create 
        // a proper path instruction for it. 
        if ((StreetName2 != "(unknown)") && (StreetName2 != " ")){
            
            // If the second segment's street name WAS ACTUALLY a valid name...
            
            // If the two street names are different, the user will then go onto a different street, so 
            // set the flag to true. 
            if (StreetName2!=StreetName1){
                differentStreet = true; 
            }

            // Call TurnLeftOrRight function to determine which way to turn. 
            // If the returned value is 2, turn right; if the value is 0, turn left; 
            // else if the value is 1, go straight. 
            LeftOrRight = TurnLeftOrRight(Path[i],Path[i+1]); 
            if (LeftOrRight==2){
                tempString.append("Turn right");
                //displayStraightInstruction = 0; // If turning right, automatically enable the instruction to be 
                // displayed again, regardless of whether or not the street name remains the same. 
            } 
            else if (LeftOrRight==1){
                tempString.append("Go straight"); 
            } 
            else if (LeftOrRight==0){
                tempString.append("Turn left"); 
                //displayStraightInstruction = 0; // If turning left, automatically enable the instruction to be 
                // displayed again, regardless of whether or not the street name remains the same. 
            } 

            /////////////////////////////////////////////////////////
            
            // If the user does go onto a different street, add " onto " into the instruction. 
            if (differentStreet){
                tempString.append(" onto "); 
                tempString.append(StreetName2);
                displayStraightInstruction = 0; // If different street names, set the displayStraightInstruction counter 
                // back to zero, so that subsequent "Go Straight" instructions can be displayed at least once. 
            }
            else{ // If the user does NOT go onto a different street, add " along " into the instruction. 
                tempString.append(" along "); 
                tempString.append(StreetName2); 
            }
            
            /////////////////////////////////////////////////////////

            // If the string length is two wide to fit onto the box (max 50 characters), 
            // store the remainder of the string into a second string, and print it on the next line. 
            if (tempString.length()>=50){
                needExtraLine = true; 
                size_t pos = tempString.find_last_of(' ',string::npos); // Find the last occurrence of whitespace in the string.  
                tempString2 = tempString.substr(pos+1,30);
                tempString.erase(pos,string::npos); 
            }
            
            /////////////////////////////////////////////////////////
            
            // The following if case only applies to an instruction if it tells the user to "Go Straight". 
            // For the first occurrence of "Go Straight", the instruction will be displayed, but if it appears 
            // consecutively many times afterwards, the instructions will be disabled by incrementing the 
            // displayStraightInstruction counter. 
            if (displayStraightInstruction < 1){
                // Draw the text onto the box. 
                drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - (0.10 +0.04*numLines) * HelpBox.get_height(), tempString, HelpBox.get_width(), HelpBox.get_height());
                numLines++; // Increment the numLines counter so set the subsequent line further down the box. 
                if (needExtraLine){ // If an extra line is needed, display this instruction too. 
                    drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - (0.10 +0.04*numLines) * HelpBox.get_height(), tempString2, HelpBox.get_width(), HelpBox.get_height());
                    numLines++; 
                }
            }
            
            // Before iterating the overall for loop again and checking the next two segments, check if 
            // the instruction this time was 
            if (!differentStreet)
                displayStraightInstruction++; 

        }
        
    }
    
    // After exiting the for loop and displaying all instructions, display this message for users to 
    // know how to clear the screen of any displayed path or path instructions. 
    string endMessage = "Press 'Esc' to clear the path instructions. "; 
    drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - (0.10 +0.04*numLines + 0.015) * HelpBox.get_height(), endMessage, HelpBox.get_width(), HelpBox.get_height());
    // DisplayPathInstructions(InstructionVector); 
    
} 
Exemple #15
0
int main (int argc, char **argv)
{
  int n1,n2,n3,i1,i2,i3,
    n1tic,n2tic,n3tic,grid1,grid2,grid3,nz,iz,
    faces,style=SEISMIC,bbox[4],
    npar,nc,nplaces,ic;
  int  labelcf, nlabelc, labelcper;
  float d1,d2,d3,f1,f2,f3,size1,size2,size3,xbox,ybox,angle,
    x1min,x1max,x2min,x2max,x3min,x3max,
    x1beg,x1end,x2beg,x2end,x3beg,x3end,
    d1num,f1num,d2num,f2num,d3num,f3num,
    p1beg,p1end,p2beg,p2end,p3beg,p3end,
    labelsize,titlesize,
    *z,*zfront,*zside,*ztop,*temp,matrix[6],
    cwidth[NCMAX],cgray[NCMAX],cdash[NCMAX],
    dc,fc,*x1,*x2,*x3,c[NCMAX],zmin,zmax,
    x1scale,x2scale,x3scale;
  float labelcsize,lcsize,*w,*wfront,*wside,*wtop;
  char *label1="",*label2="",*label3="",*title="",
    *labelfont="Helvetica",*titlefont="Helvetica-Bold",
    *labelcfont="Helvetica-Bold",*labelccolor="black",
    *grid1s="none",*grid2s="none",*grid3s="none",
    *titlecolor="black",*axescolor="black",*gridcolor="black",
    *frontf,*sidef,*topf,
    *scolor="none",*ccolor[NCMAX];
  FILE *infp=stdin,*frontfp,*sidefp,*topfp;
  
  /* initialize getpar */
  initargs(argc,argv);
  requestdoc(1);
  
  /* get parameters describing 1st dimension sampling */
  if (!getparint("n1",&n1)) err("must specify n1!\n");
  if (!getparfloat("d1",&d1)) d1 = 1.0;
  if (!getparfloat("f1",&f1)) f1 = 0.0;
  x1 = ealloc1float(n1);
  for (i1=0; i1<n1; i1++)
    x1[i1] = f1+i1*d1;
  for (i1=1,x1min=x1max=x1[0]; i1<n1; i1++) {
    x1min = MIN(x1min,x1[i1]);
    x1max = MAX(x1max,x1[i1]);
  }

  /* get parameters describing 2nd dimension sampling */
  if (!getparint("n2",&n2)) err("must specify n2!\n");
  if (!getparfloat("d2",&d2)) d2 = 1.0;
  if (!getparfloat("f2",&f2)) f2 = 0.0;
  x2 = ealloc1float(n2);
  for (i2=0; i2<n2; i2++)
    x2[i2] = f2+i2*d2;
  for (i2=1,x2min=x2max=x2[0]; i2<n2; i2++) {
    x2min = MIN(x2min,x2[i2]);
    x2max = MAX(x2max,x2[i2]);
  }

  /* get parameters describing 3rd dimension sampling */
  if (!getparint("n3",&n3)) err("must specify n3!\n");
	if (n3<2)err("must have n3>=2!");
  if (!getparfloat("d3",&d3)) d3 = 1.0;
  if (!getparfloat("f3",&f3)) f3 = 0.0;
  x3 = ealloc1float(n3);
  for (i3=0; i3<n3; i3++)
    x3[i3] = f3+i3*d3;
  for (i3=1,x3min=x3max=x3[0]; i3<n3; i3++) {
    x3min = MIN(x3min,x3[i3]);
    x3max = MAX(x3max,x3[i3]);
  }

  /* determine input type */
  if (!getparint("faces",&faces)) faces = 0;
  
  /* allocate space */
  nz = n1*n2+n1*n3+n2*n3;
  z = ealloc1float(nz);
  zfront = z;
  zside = zfront+n1*n2;
  ztop = zside+n1*n3;
  
  /* read data */
  if (getparstring("front",&frontf)
      && getparstring("side",&sidef)
      && getparstring("top",&topf)) {
    
    /* read face files */
    if ((frontfp = fopen(frontf,"r")) == NULL)
      err("error opening front file!\n");
    if (fread(zfront,sizeof(float),n1*n2,frontfp)!=n1*n2)
      err("error reading front file!\n");
    if ((sidefp = fopen(sidef,"r")) == NULL)
      err("error opening side file!\n");
    if (fread(zside,sizeof(float),n1*n3,sidefp)!=n1*n3)
      err("error reading side file!\n");
    if ((topfp = fopen(topf,"r")) == NULL)
      err("error opening top file!\n");
    if (fread(ztop,sizeof(float),n2*n3,topfp)!=n2*n3)
      err("error reading top file!\n");
    
  } else if (getparstring("front",&frontf)
	     || getparstring("side",&sidef)
	     || getparstring("top",&topf)) {
    
    err("must specify all or none of face, side, and top!\n");
    
  } else if (faces) {
    /* read faces from stdin */
    if (fread(zfront,sizeof(float),n1*n2,infp)!=n1*n2)
      err("error reading front from input!\n");
    if (fread(zside,sizeof(float),n1*n3, infp)!=n1*n3)
      err("error reading side from input!\n");
    if (fread(ztop,sizeof(float),n2*n3, infp)!=n2*n3)
      err("error reading top from input!\n");
  } else {
    /* read cube from stdin, pick off faces */
    temp = ealloc1float(n1);
    for (i3=0; i3<n3; i3++) {
      for (i2=0; i2<n2; i2++) {
	if (fread(temp,sizeof(float),n1,infp)!=n1)
	  err("error reading cube from input!\n");
	if (i3==0) 
	  for (i1=0; i1<n1; i1++)
	    zfront[i1+i2*n1] = temp[i1];
	if (i2==n2-1)
	  for (i1=0; i1<n1; i1++)
	    zside[i1+i3*n1] = temp[i1];
	ztop[i2+i3*n2] = temp[0];
      }
    }
    free1float(temp);
  }
  
  /* zero w array for contour labeling	*/	
  w = ealloc1float(nz);
  wfront = w;
  wside = wfront+n1*n2;
  wtop = wside+n1*n3;
  for(iz=0; iz<nz; iz++)
    w[iz] = 0.;
	
  /* determine data min and max */
  for (iz=0,zmin=zmax=z[0]; iz<nz; iz++){
    zmin = MIN(zmin,z[iz]);
    zmax = MAX(zmax,z[iz]);
  }
  
  /* get contouring parameters */
  if ((nc=getparfloat("c",c))==0) {
    nc = 5;  getparint("nc",&nc);
    dc = (zmax-zmin)/nc;  getparfloat("dc",&dc);
    fc = zmin+dc;  getparfloat("fc",&fc);
    for (ic=0; ic<nc; ic++)
      c[ic] = fc+ic*dc;
  }
  for (ic=0; ic<nc; ic++) {
    cwidth[ic] = 1.0;
    cgray[ic] = 0.0;
    cdash[ic] = 0.0;
    ccolor[ic] = scolor;
  }
  if ((npar=getparfloat("cwidth",cwidth))!=0)
    for (ic=npar; ic<nc; ic++)
      cwidth[ic] = cwidth[npar-1];
  if ((npar=getparfloat("cgray",cgray))!=0)
    for (ic=npar; ic<nc; ic++)
      cgray[ic] = cgray[npar-1];
  if ((npar=getparfloat("cdash",cdash))!=0)
    for (ic=npar; ic<nc; ic++)
      cdash[ic] = cdash[npar-1];
  if (getparstring("ccolor",&scolor)) {
    int i,j;  char *s;
    for (i=0,s=strtok(scolor,","); s!=NULL; ++i,s=strtok(NULL,","))
      ccolor[i] = s;
    for (j=i-1; i<nc; ++i)
      ccolor[i] = ccolor[j];
  }
  labelcf = 1; getparint("labelcf",&labelcf);
  labelcper = 1; getparint("labelcper",&labelcper);
  nlabelc = nc; getparint("nlabelc",&nlabelc);
  labelcsize = 6; getparfloat("labelcsize",&labelcsize);
  getparstring("labelcfont",&labelcfont);
  getparstring("labelccolor",&labelccolor);
  if (!getparint("nplaces",&nplaces))		nplaces = 6;
  
  /* get axes parameters, convert to points */
  if(!getparfloat("size1",&size1)) size1 = 4.0;
  if(!getparfloat("size2",&size2)) size2 = 4.0;
  if(!getparfloat("size3",&size3)) size3 = 3.0;
  if (!getparfloat("xbox",&xbox)) xbox = 1.5;
  if (!getparfloat("ybox",&ybox)) ybox = 1.5;
  size1 *= 72;
  size2 *= 72;
  size3 *= 72;
  xbox *= 72;
  ybox *= 72;
  
  /* get projection angle, convert to radians */
  if(!getparfloat("angle",&angle)) angle = 45.0;
  angle = MAX(angle,0.00001);
  angle = MIN(angle,90.0);
  angle *= PI/180.0;
  
  /* get axis1 parameters */
  x1beg = x1min; 
  x1end = x1max; getparfloat("x1end",&x1end);
  d1num = 0.0; getparfloat("d1num",&d1num);
  f1num = x1min; getparfloat("f1num",&f1num);
  n1tic = 1; getparint("n1tic",&n1tic);
  getparstring("grid1",&grid1s);
  if (STREQ("dot",grid1s)) grid1 = DOT;
  else if (STREQ("dash",grid1s)) grid1 = DASH;
  else if (STREQ("solid",grid1s)) grid1 = SOLID;
  else grid1 = NONE;
  getparstring("label1",&label1);
  
  /* get axis2 parameters */
  x2beg = x2min; getparfloat("x2beg",&x2beg);
  x2end = x2max;
  d2num = 0.0; getparfloat("d2num",&d2num);
  f2num = x2min; getparfloat("f2num",&f2num);
  n2tic = 1; getparint("n2tic",&n2tic);
  getparstring("grid2",&grid2s);
  if (STREQ("dot",grid2s)) grid2 = DOT;
  else if (STREQ("dash",grid2s)) grid2 = DASH;
  else if (STREQ("solid",grid2s)) grid2 = SOLID;
  else grid2 = NONE;
  getparstring("label2",&label2);

  /* get axis3 parameters */
  x3beg = x3min;
  x3end = x3max; getparfloat("x3end",&x3end);
  d3num = 0.0; getparfloat("d3num",&d3num);
  f3num = x3min; getparfloat("f3num",&f3num);
  n3tic = 1; getparint("n3tic",&n3tic);
  getparstring("grid3",&grid3s);
  if (STREQ("dot",grid3s)) grid3 = DOT;
  else if (STREQ("dash",grid3s)) grid3 = DASH;
  else if (STREQ("solid",grid3s)) grid3 = SOLID;
  else grid3 = NONE;
  getparstring("label3",&label3);
  
  /* get additional font parameters */
  getparstring("labelfont",&labelfont);
  labelsize = 18.0; getparfloat("labelsize",&labelsize);
  getparstring("title",&title);
  getparstring("titlefont",&titlefont);
  titlesize = 24.0; getparfloat("titlesize",&titlesize);
  getparstring("titlecolor",&titlecolor);
  getparstring("axescolor",&axescolor);
  getparstring("gridcolor",&gridcolor);
  style = SEISMIC;
  
   
  /* determine axes pads */
  p1beg = (x1end>x1beg)?-fabs(d1)/2:fabs(d1)/2;
  p1end = (x1end>x1beg)?fabs(d1)/2:-fabs(d1)/2;
  p2beg = (x2end>x2beg)?-fabs(d2)/2:fabs(d2)/2;
  p2end = (x2end>x2beg)?fabs(d2)/2:-fabs(d2)/2;
  p3beg = (x3end>x3beg)?-fabs(d3)/2:fabs(d3)/2;
  p3end = (x3end>x3beg)?fabs(d3)/2:-fabs(d3)/2; 
  
  /* set bounding box */
  psAxesBBox(xbox,ybox,size2+cos(angle)*size3,size1+sin(angle)*size3,
	     labelfont,labelsize,titlefont,titlesize,style,bbox);
  boundingbox(bbox[0],bbox[1],bbox[2],bbox[3]);
  
  /* begin PostScript */
  begineps();
  
  /* save graphics state */
  gsave();
  
  /* translate coordinate system by box offset */
  translate(xbox,ybox);
  
  /* begin top */
  gsave();
  
  /* determine x2 and x3 scale factors */
  x2scale = size2/(x2end-x2beg);
  x3scale = size3*sin(angle)/(x3end-x3beg);
  
  /* scale x2 and x3 coordinates */
  for (i2=0; i2<n2; i2++)
    x2[i2] *= x2scale;
  for (i3=0; i3<n3; i3++)
    x3[i3] *= x3scale;

  /* transform and skew coordinates */
  matrix[0] = 1;  matrix[1] = 0;  matrix[2] = 1/tan(angle);
  matrix[3] = 1;  matrix[4] = 0;  matrix[5] = 0;
  translate(-(f2-x2min+x2beg)*x2scale-f3*x3scale/tan(angle),size1-f3*x3scale);
  concat(matrix);
  rectclip(x2beg*x2scale,f3*x3scale,size2,size3*sin(angle));
  
  /* draw contours */
  for (ic=0; ic<nc; ic++) {
    setlinewidth(cwidth[ic]);
    if (strcmp(ccolor[ic],"none"))
      setcolor(ccolor[ic]);
    else
      setgray(cgray[ic]);
    if (cdash[ic]!=0.0)
      setdash(&cdash[ic],1,0.0);
    else
      setdash(&cdash[ic],0,0.0);
    lcsize = 0.;
    if (nlabelc>0) {
      if((ic-labelcf+1)%labelcper==0 && ic>=labelcf-1  
	 && ic<labelcf-1+labelcper*nlabelc) {
	setlinewidth(cwidth[ic]);
	lcsize = labelcsize;
      }
      else { 
	lcsize = 0.;
	setlinewidth(0.25*cwidth[ic]);
      }
    }
    /* no labels -> lcsize=0 to psContour */
    psContour(c[ic],n2,x2,n3,x3,ztop,0,labelcfont,labelccolor,wtop,nplaces);
  }
  /* unscale x2 and x3 coordinates */
  for (i2=0; i2<n2; i2++)
    x2[i2] /= x2scale;
  for (i3=0; i3<n3; i3++)
    x3[i3] /= x3scale;

  translate((f2-x2min+x2beg)*x2scale+f3*x3scale/tan(angle),-size1+f3*x3scale);
  
  /* end top */
  grestore();

 /* begin front */
  gsave();
 
  /* determine x1 and x2 scale factors */
  x1scale = size1/(x1end-x1beg);
  x2scale = size2/(x2end-x2beg);
  
  /* scale x1 and x2 coordinates */
  for (i1=0; i1<n1; i1++)
    x1[i1] *= x1scale;
  for (i2=0; i2<n2; i2++)
    x2[i2] *= x2scale;


  rotate(-90);
  translate(-size1-f1*x1scale,-(f2-x2min+x2beg)*x2scale);
  rectclip(size1+f1*x1scale,(f2-x2min+x2beg)*x2scale,-size1,size2);
  
  /* draw contours */
  for (ic=0; ic<nc; ic++) {
    setlinewidth(cwidth[ic]);
    if (strcmp(ccolor[ic],"none"))
      setcolor(ccolor[ic]);
    else
      setgray(cgray[ic]);
    if (cdash[ic]!=0.0)
      setdash(&cdash[ic],1,0.0);
    else
      setdash(&cdash[ic],0,0.0);
    lcsize = 0.;
    if (nlabelc>0) {
      if((ic-labelcf+1)%labelcper==0 && ic>=labelcf-1  
	 && ic<labelcf-1+labelcper*nlabelc) {
	setlinewidth(cwidth[ic]);
	lcsize = labelcsize;
      }
      else { 
	lcsize = 0.;
	setlinewidth(0.25*cwidth[ic]);
      }
    }
    psContour(c[ic],n1,x1,n2,x2,z,lcsize,labelcfont,labelccolor,w,nplaces);
  }
 
  /* unscale x1 and x2 coordinates */
  for (i1=0; i1<n1; i1++)
    x1[i1] /= x1scale;
  for (i2=0; i2<n2; i2++)
    x2[i2] /= x2scale;
  
  translate(size1+f1*x1scale,(f2-x2min+x2beg)*x2scale);
  rotate(90);
  
  /* end front */
  grestore();

  /* begin side */
  gsave();
  
  /* determine x1 and x3 scale factors */
  x1scale = size1/(x1end-x1beg);
  x3scale = size3*cos(angle)/(x3end-x3beg);
  
  /* scale x1 and x3 coordinates */
  for (i1=0; i1<n1; i1++)
    x1[i1] *= x1scale;
  for (i3=0; i3<n3; i3++)
    x3[i3] *= x3scale;
  
  /* transform and skew coordinates */
  matrix[0] = 1;  matrix[1] = tan(angle);  matrix[2] = 0;
  matrix[3] = 1;  matrix[4] = 0;  matrix[5] = 0;
  
  translate(size2-f3*x3scale,size1+f1*x1scale-f3*x3scale*tan(angle));
  concat(matrix);
  rectclip(f3*x3scale,-x1end*x1scale,size3*cos(angle),size1);
  rotate(-90);
  
    /* draw contours */ 
  for (ic=0; ic<nc; ic++) {
    setlinewidth(cwidth[ic]);
    if (strcmp(ccolor[ic],"none"))
      setcolor(ccolor[ic]);
    else
      setgray(cgray[ic]);
    if (cdash[ic]!=0.0)
      setdash(&cdash[ic],1,0.0);
    else
      setdash(&cdash[ic],0,0.0);
    lcsize = 0.;
    if (nlabelc>0) {
      if((ic-labelcf+1)%labelcper==0 && ic>=labelcf-1  
	 && ic<labelcf-1+labelcper*nlabelc) {
	setlinewidth(cwidth[ic]);
	lcsize = labelcsize;
      }
      else { 
	lcsize = 0.;
	setlinewidth(0.25*cwidth[ic]);
      }
    }
    /* no labels -> lcsize=0 to psContour */
    psContour(c[ic],n1,x1,n3,x3,zside,0,labelcfont,labelccolor,wside,nplaces);
  }

  /* unscale x1 and x3 coordinates */
  for (i1=0; i1<n1; i1++)
    x1[i1] /= x1scale;
  for (i3=0; i3<n3; i3++)
    x3[i3] /= x3scale;
  
  rotate(90);
  translate(-size2+f3*x3scale,-size1-f1*x1scale+f3*x3scale*tan(angle));
  /* end side */
  grestore();
  
  
  /* restore graphics state */
  grestore();
  
  psCubeAxesBox(xbox,ybox,size1,size2,size3,angle,
		x1beg,x1end,p1beg,p1end,
		d1num,f1num,n1tic,grid1,label1,
		x2beg,x2end,p2beg,p2end,
		d2num,f2num,n2tic,grid2,label2,
		x3beg,x3end,p3beg,p3end,
		d3num,f3num,n3tic,grid3,label3,
		labelfont,labelsize,
		title,titlefont,titlesize,
		titlecolor,axescolor,gridcolor);
  
  /* end PostScript */
  showpage();
  endeps();
  
  return 0;
}
Exemple #16
0
static void drawplace (void) {

/* Draws the blocks placed on the proper clbs.  Occupied clbs are light *
 * grey, while empty ones are left white and have a dashed border.      */

 float io_step = clb_width/io_rat;
 float x1, y1, x2, y2;
 int i, j, k, bnum;

 /* Draw the IO Pads first. Want each subblock to border on core. */

 setlinewidth (0);

 for (i=1;i<=nx;i++) { 
    for (j=0;j<=ny+1;j+=ny+1) {  /* top and bottom */
       y1 = y_clb_bottom[j];
       y2 = y1 + clb_width;

       setlinestyle (SOLID);
       for (k=0;k<clb[i][j].occ;k++) {
          bnum = clb[i][j].u.io_blocks[k];
          setcolor (block_color[bnum]);
          x1 = x_clb_left[i] + k * io_step;
          x2 = x1 + io_step;
          fillrect (x1,y1,x2,y2);

          setcolor (BLACK);
          drawrect (x1,y1,x2,y2);
/* Vertically offset text so these closely spaced names don't overlap. */
          drawtext ((x1 + x2)/2., y1 + io_step * (k + 0.5), 
             block[clb[i][j].u.io_blocks[k]].name, clb_width);
       }

       setlinestyle (DASHED);
       setcolor (BLACK);
       for (k=clb[i][j].occ;k<io_rat;k++) {
          x1 = x_clb_left[i] + k * io_step;
          x2 = x1 + io_step;
          drawrect (x1,y1,x2,y2);
       }
    }
 }
        
 for (j=1;j<=ny;j++) {
    for (i=0;i<=nx+1;i+=nx+1) {  /* IOs on left and right */
       x1 = x_clb_left[i];
       x2 = x1 + clb_width;

       setlinestyle (SOLID);
       for (k=0;k<clb[i][j].occ;k++) {
          bnum = clb[i][j].u.io_blocks[k];
          setcolor (block_color[bnum]);
          y1 = y_clb_bottom[j] + k * io_step;
          y2 = y1 + io_step;
          fillrect (x1,y1,x2,y2);
 
          setcolor (BLACK);
          drawrect (x1,y1,x2,y2);
          drawtext ((x1 + x2)/2., (y1 + y2)/2.,
             block[clb[i][j].u.io_blocks[k]].name, clb_width);
       }
          
       setlinestyle (DASHED);
       setcolor (BLACK);
       for (k=clb[i][j].occ;k<io_rat;k++) {
          y1 = y_clb_bottom[j] + k * io_step;
          y2 = y1 + io_step;
          drawrect (x1,y1,x2,y2);
       }
    }     
 }     

/* Now do the CLBs in the middle. */

 for (i=1;i<=nx;i++) {
    x1 = x_clb_left[i];
    x2 = x1 + clb_width;
    for (j=1;j<=ny;j++) {
       y1 = y_clb_bottom[j];
       y2 = y1 + clb_width;
       if (clb[i][j].occ != 0) {
          setlinestyle (SOLID);
          bnum = clb[i][j].u.block;
          setcolor (block_color[bnum]);
          fillrect (x1,y1,x2,y2);

          setcolor (BLACK);
          drawrect (x1,y1,x2,y2);
          drawtext ((x1 + x2)/2., (y1 + y2)/2., block[clb[i][j].u.block].name, 
             clb_width);
       }
       else {
          setlinestyle (DASHED);
          setcolor (BLACK);
          drawrect (x1,y1,x2,y2);
       }
    }    /* end j */
 }    /* end i */
}