Example #1
0
void plot_string_on_buttun(IplImage* image, const char* text, int thickness, int x, int y, bool on_mouse)
{
    if (on_mouse)
        plot_string(image, text, thickness, x, y, CV_RGB(250, 250, 250));
    else
        plot_string(image, text, thickness, x, y, CV_RGB(150, 150, 150));
}
Example #2
0
void  display_trg_level(int x_pos, int y_pos, int style)
{
    /* variables */
    char      level_str[] = "        "; /* string containing the trigger level */
    long int  l;			/* trigger level in mV */



    /* compute the trigger level in millivolts */
    l = ((long int) MAX_LEVEL - MIN_LEVEL) * level / (MAX_TRG_LEVEL_SET - MIN_TRG_LEVEL_SET) + MIN_LEVEL;

    /* convert the level to the string (leave first character blank) */
    cvt_num_field(l, &level_str[1]);

    /* add in the units */
    level_str[7] = 'V';


    /* now finally display the trigger level */
    plot_string(x_pos, y_pos, level_str, style);


    /* all done displaying the trigger level - return */
    return;

}
Example #3
0
struct plot_data *get_plot_details_new(struct plot_info *pi, int time, struct membuffer *mb)
{
	struct plot_data *entry = NULL;
	int i;

	for (i = 0; i < pi->nr; i++) {
		entry = pi->entry + i;
		if (entry->sec >= time)
			break;
	}
	if (entry)
		plot_string(pi, entry, mb, pi->has_ndl);
	return (entry);
}
Example #4
0
void  display_sweep(int x_pos, int y_pos, int style)
{
    /* variables */
      /* none */



    /* display the sweep rate */
    plot_string(x_pos, y_pos, sweep_rates[sweep].s, style);


    /* all done displaying the sweep rate - return */
    return;

}
Example #5
0
void  display_trg_slope(int x_pos, int y_pos, int style)
{
    /* variables */

    /* the trigger slope strings (must match enumerated type) */
    const char * const  slopes[] =  {  " +", " -"  };



    /* display the trigger slope */
    plot_string(x_pos, y_pos, slopes[slope], style);


    /* all done displaying the trigger slope - return */
    return;

}
Example #6
0
void  display_scale(int x_pos, int y_pos, int style)
{
    /* variables */

    /* the scale type strings (must match enumerated type) */
    const char * const  scale_stat[] =  {  " None",
                                                  " Axes",
                                                  " Grid"  };



    /* display the scale status */
    plot_string(x_pos, y_pos, scale_stat[scale], style);


    /* all done displaying the scale status - return */
    return;

}
Example #7
0
void  display_mode(int x_pos, int y_pos, int style)
{
    /* variables */

    /* the mode strings (must match enumerated type) */
    const char * const  modes[] =  {  " Normal   ",
                                             " Automatic",
                                             " One-Shot "  };



    /* display the trigger mode */
    plot_string(x_pos, y_pos, modes[trigger_mode], style);


    /* all done displaying the trigger mode - return */
    return;

}
Example #8
0
void label_contour(
    double **data,
    long nx,
    long ny,
    double value,
    char *string,
    double xmin,
    double dx,
    double ymin,
    double dy,
    double error_limit,
    long label_mode  
    )
{
/* long label_mode    0 -> on contours,  1 -> around border */
    register double distance, best_distance, nbest_distance;
    register long iy;
    long ix, ix_best, iy_best, ix_nbest=0, iy_nbest=0, n_data;
    double x, y, xmax, ymax, i_int;
    double xd, yd;
    double hoff, voff;

    xmax = xmin + dx*(nx-1);
    ymax = ymin + dy*(ny-1);

    if (label_mode==0) {
        distance = best_distance = 1.0E37;
        ix_best = iy_best = -1;
        n_data = nx*ny;
    
        for (ix=1; ix<nx-2; ix++) {
            for (iy=1; iy<ny-2; iy++) {
                distance = fabs(value - data[ix][iy])/error_limit;
                if (distance<1) {
                    distance += sqr((ix-nx/2.)/nx)+sqr((iy-ny/2.)/ny);
                    if (distance<best_distance) {
                        ix_nbest = ix_best; 
                        iy_nbest = iy_best;
                        nbest_distance = best_distance;
                        ix_best = ix;
                        iy_best = iy;
                        best_distance = distance;
                        }
                    }
                }
            }
        ix = ix_best;
        iy = iy_best;
    
        if (ix==-1) {
            ix = 0;
            for (iy=1; iy<ny-2; iy++) {
                distance = fabs(value - data[ix][iy])/error_limit;
                if (distance<1) {
                    distance += sqr((ix-nx/2.)/nx)+sqr((iy-ny/2.)/ny);
                    if (distance<best_distance) {
                        ix_nbest = ix_best; 
                        iy_nbest = iy_best;
                        nbest_distance = best_distance;
                        ix_best = ix;
                        iy_best = iy;
                        best_distance = distance;
                        }
                    }
                }
            if (ix_best==-1) {
                printf("note: failed to find acceptable contour to label for value %e\n", value);
                return;
                }
            ix = ix_best;
            iy = iy_best;
            }

        if (fabs(value-data[ix][iy])>error_limit)
            bomb("algorithmic error (1) in label_contour()", NULL);
    
        x = dx*ix + xmin;
        y = dy*iy + ymin;
        if (ix<nx-1 && data[ix][iy]!=data[ix+1][iy])
            x += dx*(value-data[ix][iy])/(data[ix+1][iy]-data[ix][iy]);
        else if (iy<ny-1 && data[ix][iy]!=data[ix][iy+1])
            y += dy*(value-data[ix][iy])/(data[ix][iy+1]-data[ix][iy]);
    
        if (x>=xmax-dx/2 || y>=ymax-dy/2 || x<xmin+dx/4 || y<ymin+dy/4) {
            ix = ix_nbest;
            iy = iy_nbest;
            if (ix!=-1) {
                x = dx*ix + xmin;
                y = dy*iy + ymin;
                if (ix<nx-1 && data[ix][iy]!=data[ix+1][iy])
                    x += dx*(value-data[ix][iy])/(data[ix+1][iy]-data[ix][iy]);
                else if (iy<ny-1 && data[ix][iy]!=data[ix][iy+1])
                    y += dy*(value-data[ix][iy])/(data[ix][iy+1]-data[ix][iy]);
                if (x>=xmax-dx/2 || y>=ymax-dy/2 || x<xmin+dx/4 || y<ymin+dy/4) {
                    printf("note: label algorithm went outside plot region for value %e\n", value);
                    return;
                    }
                }
            else {
                printf("note: label algorithm went outside plot region for value %e\n", value);
                return;
                }
            }

        xd = x;
        yd = y;
        plot_string(&xd, &yd, string);
        }
    else {
        distance = best_distance = 1.0E37;
        vertical_print(1);

        /* search for end of contour along top edge */
        iy = ny-1;
        get_char_size(&hoff, &voff, 1);
        for (ix=nx-1; ix>0; ix--) {
            if ((data[ix][iy]<value && data[(ix-1)][iy]>=value) ||
                (data[ix][iy]>value && data[(ix-1)][iy]<=value) ) {
                xd = xmin + hoff/3 + dx*(i_int=INTERPOLATE(ix-1, ix, 
                                    data[ix-1][iy], data[ix][iy], value));
                if (i_int>=ix-1 && i_int<=ix) {
                    yd = ymin + (ny-1)*dy + (value>0?voff:voff/2);
                    plot_string(&xd, &yd, string);
                    }
                }
            }
    
        /* search for end of contour along right edge */
        ix = nx-1;
        vertical_print(0);
        get_char_size(&hoff, &voff, 1);
        for (iy=1; iy<ny; iy++) {
            if ((data[ix][iy]<value && value<=data[ix][iy-1]) ||
                (data[ix][iy]>value && value>=data[ix][iy-1]) ) {
                yd = ymin - 2*voff/3 + dy*(i_int=INTERPOLATE(iy-1, iy, 
                                        data[ix][iy-1],
                                        data[ix][iy], value));
                if (!(i_int<iy-1 || i_int>iy)) {
                    xd = xmin + (nx-1)*dx + hoff/2;
                    plot_string(&xd, &yd, string);
                    }
                }
            }
        }
}
Example #9
0
void  display_trg_delay(int x_pos, int y_pos, int style)
{
    /* variables */
    char      delay_str[] = "         "; /* string containing the trigger delay */
    long int  units_adj;		 /* adjustment to get to microseconds */

    long int  d;                         /* delay in appropriate units */


    /* compute the delay in the appropriate units */
    /* have to watch out for overflow, so be careful */
    if (sweep_rates[sweep].sample_rate > 1000000L)  {
        /* have a fast sweep rate, could overflow */
        /* first compute in units of 100 ns */
        d = delay * (10000000L / sweep_rates[sweep].sample_rate);
	/* now convert to nanoseconds */
	d *= 100L;
	/* need to divide by 1000 to get to microseconds */
	units_adj = 1000;
    }
    else  {
        /* slow sweep rate, don't have to worry about overflow */
        d = delay * (1000000L / sweep_rates[sweep].sample_rate);
	/* already in microseconds, so adjustment is 1 */
	units_adj = 1;
    }

    /* convert it to the string (leave first character blank) */
    cvt_num_field(d, &delay_str[1]);

    /* add in the units */
    if (((d / units_adj) < 1000) && ((d / units_adj) > -1000) && (units_adj == 1000)) {
        /* delay is in microseconds */
	delay_str[7] = '\004';
	delay_str[8] = 's';
    }
    else if (((d / units_adj) < 1000000) && ((d / units_adj) > -1000000)) {
        /* delay is in milliseconds */
	delay_str[7] = 'm';
	delay_str[8] = 's';
    }
    else if (((d / units_adj) < 1000000000) && ((d / units_adj) > -1000000000))  {
        /* delay is in seconds */
	delay_str[7] = 's';
	delay_str[8] = ' ';
    }
    else  {
        /* delay is in kiloseconds */
	delay_str[7] = 'k';
	delay_str[8] = 's';
    }


    /* now actually display the trigger delay */
    plot_string(x_pos, y_pos, delay_str, style);


    /* all done displaying the trigger delay - return */
    return;

}
Example #10
0
File: box.c Project: drafnel/Vis5d
void draw_tick_marks( Display_Context dtx )
{
    float verts[2][3];
    /* base and up vectors for text drawn along x,y,z axes. */
    static float bx[3] = { 0.05, 0.0, 0.0 },      ux[3] = { 0.0, 0.05, 0.05 };
    /*
    static float by[3] = { -0.035, 0.0, -0.035 },  uy[3] = { 0.0, 0.07, 0.0 };
    static float bz[3] = { -0.035, -0.035, 0.0 }, uz[3] = { 0.0, 0.0, 0.07 };
    */
    float tick_inc, i, row, col, lev;
    char str[100];

    /* set depth cueing & line color */
    /* MJK 3.29.99 */
    if (dtx->Reversed) {
        set_color( PACK_COLOR(0,0,0,255) );
    }
    else {
        set_color( dtx->BoxColor );
    }


    set_depthcue( dtx->DepthCue );

    /* go in the order.. low south side, low east side,
       go counter-clock-wise, then high south side, couterclockwise,
       then southeast side, and work coutner-clockwise, so there are
       12 sides to loop through */

    dtx->tick_do[0] = 1;
    dtx->tick_type[0] = 1;
    dtx->tick_num[0] = 10;
    if (dtx->tick_do[0]) {
        tick_inc = (float)(dtx->Nc)/(float)(dtx->tick_num[0]-1);
        row = dtx->Nr-1;
        lev = 0;
        for (i = tick_inc; i < dtx->Nc; i += tick_inc) {
            col = i;
            vis5d_gridPRIME_to_xyzPRIME(dtx->dpy_context_index, 0, 0,
                                        row, col, lev, &verts[0][0], &verts[0][1], &verts[0][2]);
            verts[1][0] = verts[0][0];
            verts[1][1] = verts[0][1] - 0.05;
            verts[1][2] = verts[0][2] - 0.062;
            polyline( verts, 2);
            if (dtx->tick_type[0] == 0) {
                float lat, lon, hgt;
                vis5d_gridPRIME_to_geo(dtx->dpy_context_index, 0, 0,
                                       row, col, lev, &lat, &lon, &hgt);
                /*float2string(lon, str); */
                if (strlen(str) <2) {
                    plot_string( str, verts[1][0]-.009, verts[1][1]-.05, verts[1][2]-0.062, bx, ux, 0);
                }
                else if (strlen(str) <4) {
                    plot_string( str, verts[1][0]-.02, verts[1][1]-.05, verts[1][2]-0.062, bx, ux, 0);
                }
                else {
                    plot_string( str, verts[1][0]-.05, verts[1][1]-.05, verts[1][2]-0.062, bx, ux, 0);
                }
            }
            else if (dtx->tick_type[0] == 1) {
                /* float2string(col, str); */
                if (strlen(str) <2) {
                    plot_string( str, verts[1][0]-.009, verts[1][1]-.05, verts[1][2]-0.062, bx, ux, 0);
                }
                else if (strlen(str) <4) {
                    plot_string( str, verts[1][0]-.02, verts[1][1]-.05, verts[1][2]-0.062, bx, ux, 0);
                }
                else {
                    plot_string( str, verts[1][0]-.05, verts[1][1]-.05, verts[1][2]-0.062, bx, ux, 0);
                }
            }
        }
    }
}
Example #11
0
File: box.c Project: drafnel/Vis5d
/*
 * Draw the 3-D box.
 * Input:  it - time step.
 */
void draw_box( Display_Context dtx, int it )
{
    /* base and up vectors for text drawn along x,y,z axes. */
    static float bx[3] = { 0.05, 0.0, 0.0 },      ux[3] = { 0.0, 0.05, 0.05 };
    static float by[3] = { -0.035, 0.0, -0.035 },  uy[3] = { 0.0, 0.07, 0.0 };
    static float bz[3] = { -0.035, -0.035, 0.0 }, uz[3] = { 0.0, 0.0, 0.07 };
    float x1, y1, z1, x2, y2, z2;
    char str[100], xdir1[8], xdir2[8], ydir1[8], ydir2[8];

    /* set depth cueing & line color */
    /* MJK 3.29.99 */
    if (dtx->Reversed) {
        set_color( PACK_COLOR(0,0,0,255) );
    }
    else {
        set_color( dtx->BoxColor );
    }
    /*MiB*/
    xdir1[0] = ' ';
    xdir2[0] = ' ';
    xdir1[1] = '\0';
    xdir2[1] = '\0';
    ydir1[0] = ' ';
    ydir2[0] = ' ';
    ydir1[1] = '\0';
    ydir2[1] = '\0';

    set_depthcue( dtx->DepthCue );

    if(dtx->NumBoxVerts > 0) {
        if (dtx->Reversed) {
            draw_multi_lines( dtx->NumBoxVerts, dtx->BoxVerts, PACK_COLOR(0,0,0,255) );
        }
        else {
            draw_multi_lines( dtx->NumBoxVerts, dtx->BoxVerts, dtx->BoxColor );
        }
    }


    if (dtx->TickMarks) {
        /* Draw axis labels. */
        if (dtx->CoordFlag) {
            x1 = 1.0;
            x2 = (float) dtx->Nc;
            y1 = 1.0;
            y2 = (float) dtx->Nr;
            z1 = 1.0;
            z2 = (float) dtx->MaxNl;
        }
        else {
            x1 = dtx->WestBound;
            x2 = dtx->EastBound;

            y1 = dtx->NorthBound;
            y2 = dtx->SouthBound;

            /*MiB   03/2001 limit range to -180, 180 */
            if (x1 < -180.) {
                x1 = 360. + x1;
            }
            if (x2 < -180.) {
                x2 = 360. + x2;
            }
            if (x1 > 180.) {
                x1 = -360. + x1;
            }
            if (x2 > 180.) {
                x2 = -360. + x2;
            }
            /*MiB   03/2001 Define East/West  */
            if (x1 > 0.) {
                xdir1[0] = 'W';
            } else {
                xdir1[0] = 'E';
                x1 = x1 *(-1.);
            }
            if (x2 > 0.) {
                xdir2[0] = 'W';
            } else {
                xdir2[0] = 'E';
                x2 = x2 *(-1.);
            }
            /*MiB   03/2001 Define North/South  */
            if (y1 > 0.) {
                ydir1[0] = 'N';
            } else {
                ydir1[0] = 'S';
                y1 = y1 *(-1.);
            }
            if (y2 > 0.) {
                ydir2[0] = 'N';
            } else {
                ydir2[0] = 'S';
                y2 = y2 *(-1.);
            }


#ifdef LEVELTYPES
            z1 = dtx->BottomCoordinate;
            z2 = dtx->TopCoordinate;
#else
            z1 = dtx->BottomBound;
            z2 = dtx->TopBound;
#endif
            z1 = VERT(z1);
            z2 = VERT(z2);
        }

        if (dtx->CursorX - dtx->Xmin > 0.1 || dtx->DisplayCursor==0) {
            /* MJK 12.02.98 */
            float2string (dtx, 0, x1, str);
            /*MiB*/  strcat(str,xdir1);
            plot_string( str, dtx->Xmin-0.02, dtx->Ymin-0.1, dtx->Zmin-0.125, bx, ux, 0 );
        }

        if (dtx->Xmax - dtx->CursorX > 0.1 || dtx->DisplayCursor==0) {
            /* MJK 12.02.98 */
            float2string (dtx, 0, x2, str);
            /*MiB*/  strcat(str,xdir2);
            plot_string( str, dtx->Xmax-0.05, dtx->Ymin-0.1, dtx->Zmin-0.125, bx, ux, 0 );
        }

        if (dtx->Ymax - dtx->CursorY > 0.1 || dtx->DisplayCursor==0) {
            /* MJK 12.02.98 */
            float2string (dtx, 1, y1, str);
            /*MiB*/  strcat(str,ydir1);
            plot_string( str, dtx->Xmin-0.075, dtx->Ymax-0.03, dtx->Zmin-0.075, by, uy, 1 );
        }

        if (dtx->CursorY-dtx->Ymin > 0.1 || dtx->DisplayCursor==0) {
            /* MJK 12.02.98 */
            float2string (dtx, 2, y2, str);
            /*MiB*/  strcat(str,ydir2);
            plot_string( str, dtx->Xmin-0.075, dtx->Ymin-0.02, dtx->Zmin-0.075, by, uy, 1 );
        }

        if (dtx->CursorZ-dtx->Zmin > 0.1 || dtx->DisplayCursor==0) {
            /* MJK 12.02.98 */
            float2string (dtx, 2, z1, str);
            plot_string( str, dtx->Xmin-0.07, dtx->Ymin-0.07, dtx->Zmin+0.005, bz, uz, 1 );
        }

        if (dtx->Zmax-dtx->CursorZ > 0.1 || dtx->DisplayCursor==0) {
            /* MJK 12.02.98 */
            float2string(dtx, 2, z2, str);
            plot_string( str, dtx->Xmin-0.07, dtx->Ymin-0.07, dtx->Zmax+0.005, bz, uz, 1 );
        }
    }

    set_depthcue( 0 );

}