The Plot Library

 

 

 

This library provide functions to display a 2D plots of lines connecting series of x/y points in 2D.  These plots can be either in a Windows GDI environment or in an OpenGL window.

 

 

The library has the following functions:

 

 

Plot_OpenGL

 

 

 

Plot_Window

 

 

 

Plot_OpenGL_HighLight

 

 

 

Plot_Window_HighLight

 

 

 

 

The structures used by the library are:

 

 

typedef struct          Plot_Point {

          float          x, y ;

} Plot_Point ;

 

 

 

typedef struct          Plot_List {

          short                    nb_point ;

          Plot_Point          *point ;

} Plot_List ;

 

 

 

typedef struct Plot_Datas {

          Plot_List *val ;

          char           flag ;

          long           color ;

} Plot_Datas ;

 

 

 

 

Sample use:

 

 

// ----------------------------------------------------------------------------

int          Ctrl_Draw_Demo( Boxs *box, float offset, float power, int width )

{

//float          s ;

int          i, j ;

 

          Error_Fct( hwnd, FCT_IN_TRACE, "Tool Gradient: Ctrl_Draw_Demo()" ) ;

 

          box->Clear() ;

 

Plot_Datas  plot_data, *plot_vect[2] ;

Plot_List   plot_list ;

 

          // --- prepare the curves ---

          plot_data.name = "Real /vs/ Amplifies GLI" ;

 

          plot_list.nb_point = 2 * (Gradient_Range+20) ;

          MALLOC( Plot_Point *, plot_list.point, plot_list.nb_point, sizeof(Plot_Point) ) ;

 

          for ( j=0, i=offset - (Gradient_Range+20); i < offset + (Gradient_Range+20); i++, j++ ) {

              plot_list.point[j].x = i ;

              plot_list.point[j].y = Gradient_Transform( i, offset, power, width ) ;

          }

 

          plot_data.val = &plot_list ;

          plot_data.color = 0x000FFFF ;

          plot_data.flag = PLOT_ON ;

 

          short Tools_Font_Scale =  (short)  Fct_Variable_Value( "$INTERFACE_TOOL_FONT_SCALE" ) ;

 

          plot_vect[0] = &plot_data ;

          plot_vect[1] = NULL ;

 

          Plot_Point min, max ;

 

          Plot_Window( box, plot_vect,

                        Tools_Font_Scale-1,

                        "Real GLI", "Amplified GLI",

                        "", "",

                        &min, &max ) ;

 

              // --- vertical line at the pos of the current slice ---

              Plot_Window_HighLight( box, ' ',

                        offset,

                        2*width,

                        min.x, max.x ) ;

 

          return( 1 ) ;

}