std::ostream &
Symbol::print (std::ostream &out, int maxvals) const
{
    out << Symbol::symtype_shortname(symtype())
        << " " << typespec().string() << " " << name();
    if (everused())
        out << " (used " << firstuse() << ' ' << lastuse()
            << " read " << firstread() << ' ' << lastread()
            << " write " << firstwrite() << ' ' << lastwrite();
    else
        out << " (unused";
    out << (has_derivs() ? " derivs" : "") << ")";
    if (symtype() == SymTypeParam || symtype() == SymTypeOutputParam) {
        if (has_init_ops())
            out << " init [" << initbegin() << ',' << initend() << ")";
        if (connected())
            out << " connected";
        if (connected_down())
            out << " down-connected";
        if (!connected() && !connected_down())
            out << " unconnected";
        if (renderer_output())
            out << " renderer-output";
        if (symtype() == SymTypeParam && ! lockgeom())
            out << " lockgeom=0";
    }
    out << "\n";
    if (symtype() == SymTypeConst) {
        out << "\tconst: ";
        print_vals (out, maxvals);
        out << "\n";
    } else if (symtype() == SymTypeParam || symtype() == SymTypeOutputParam) {
        if (valuesource() == Symbol::DefaultVal && !has_init_ops()) {
            out << "\tdefault: ";
            print_vals (out, maxvals);
            out << "\n";
        } else if (valuesource() == Symbol::InstanceVal) {
            out << "\tvalue: ";
            print_vals (out, maxvals);
            out << "\n";
        }
    }
    return out;
}
Example #2
0
main()
{
	int	x,	/* x coordinate of current mouse position */ 
		y;	/* y coordinate of current mouse position */

	int	button,		/* button state */
		handle,		/* handle of window */
		w,		/* width of window */
		h;		/* height or window */

	int	x_start,	/* start point on abscissa */
		y_start;	/* start point on ordinate */

	int	old_x = 0,	/* previous x location */
		old_y = 0;	/* previous y location */

	int	i = 1;

	int	button1_up = TRUE;	/* LEFT button position */
	int	button2_up = TRUE;	/* MIDDLE button position */

	int	location;	/* location on abscisa */

	int	click = 0;	/* number of times mouse has been clicked */

	int	x0,		/* origin of graph x-coordinate */
		y0;		/* origin of graph y-coordinate */

	int	x_final,	/* endpoint of graph x-coordinate */
		y_final;	/* endpoint of graph y-coordinate */


 	/* Start a loop to get button input and to
	 * print coordinates.
	 */

	(void) read_params (NULL,SC_CHECK_FILE,NULL);

	if(symtype("beginplot")==ST_UNDEF || symtype("endplot")==ST_UNDEF) {
	  fprintf(stderr,"range: no beginplot or endplot in Common file\n");
	  exit(1);
	}
	beginplot = getsym_i ("beginplot");
	endplot = getsym_i  ("endplot");
	points = endplot - beginplot + 1;

	winloadcur16( standard_x, standard_y, standard_cursor );
	wincurlife( 1 );

	HOME

	while ( button1_up ) {
	  CLEAR
	  if (click == 0)
	     printf ("Click on the origin with the left mouse button.");
	  else
	     printf ("Now click on the endpoint with the left mouse button.");

	  fflush (stdout);

	  wincurgetwait( &x, &y, &button );

	  if ( button == 4 ) {
	     if ( click == 0 ) {	/* first mouse click */
		x0 = x;
		y0 = y;
		click = 1;
	     } else {	/* second mouse click */
		x_final = x;
	  	y_final = y;
		button1_up = FALSE;
	     }
	  }
	}

	fflush (stdout);

RESTART:

	HOME
	CLEAR
	printf ("Now click start point with left button.\n");
	printf ("(middle button to save range and exit, right button to reselect range)\n");
	fflush (stdout);

	button1_up = TRUE;
	while (button1_up)
	{
		wincurgetwait( &x, &y, &button );
		if ( button == 4 ) {
			x_start = x;
			y_start = y;
			button1_up = FALSE;
		}
	}

	new_start = beginplot + (points * (x_start - x0) / (x_final - x0));

	while (button2_up) {

	    /* Print coordinates at button signal. */

	    wincurget( &x, &y, &button );
	    if ( (x != old_x) || (y != old_y) ) {
		CLEAR
		if ( (x < x_start) || (x > x_final) )
		   printf ("OUT OF RANGE");
		else
		{
		   new_nan = beginplot + (points * (x - x0) / (x_final - x0));
		   printf ("Range selected is from %d to %d",
		   new_start, new_nan);
		}
		fflush (stdout);
		old_x = x;
		old_y = y;
	    }

	    switch (button) {
		case RIGHT:
		   CLEAR
		   goto RESTART;
		   break;
		case MIDDLE: 
		   {
			if (putsym_i("start", new_start) == -1)
			   (void) fprintf (stderr,
			   "%s: could not write into SPS Common file.\n",
			   THISPROG);
			if (putsym_i("nan", new_nan - new_start + 1) == -1)
			   (void) fprintf (stderr,
			   "%s: could not write into SPS Common file.\n",
			   THISPROG);
			   			   
			button2_up = FALSE;
		   }
		   break;
		case LEFT:
		   break;
		default:
		   break;
	    }

	}