⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uwplot.c

📁 wavlet compression on c++ only cods
💻 C
字号:
// Copyright (c) 1999 Stephen T. Welstead. All rights reserved.
// UWPLOT.C  X-Y plotting for Windows graphics

#include <string.h>

#include "messages.h"
#include "uwplot.h"
#include "utofile.h"

void plot_xy (graph_window_struct *gr,graph_setup_rec *gr_setup,
       plot_xy_data_struct *plot_data,
       char descr1[],char descr2[]) {
     /* First data only is used for window setup and axes  */
     /* Other data sets are drawn relative to this window  */
     plot_xy_data_struct *the_data;
     int gr_x0 = 0,gr_y0 = 0,gr_xmin = 0,gr_xmax = 0,
	 gr_ymin = 0,gr_ymax = 0,gr_x = 0,gr_y = 0,
	 old_gr_x = 0,old_gr_y = 0;
     int i,show_descr1,show_descr2;
     UINT old_text_align;
     FILE *xdata_file,*ydata_file;
     the_data = plot_data;

     if (!the_data) return;
     if (gr->hDC) release_dc (gr);
     if (!graph_setup(gr)) return;

     if (gr_setup->scale_window_from_data) {
     /* Determine max-min values from data  */
	gr_setup->x_min = the_data->xdata[0];
	gr_setup->x_max = the_data->xdata[0];
	gr_setup->y_min = the_data->ydata[0];
	gr_setup->y_max = the_data->ydata[0];

	while (the_data) {
	    for (i=1;i<the_data->npts;i++) {
		if (the_data->xdata[i] < gr_setup->x_min)
		   gr_setup->x_min = the_data->xdata[i];
		if (the_data->xdata[i] > gr_setup->x_max)
		   gr_setup->x_max = the_data->xdata[i];
		if (the_data->ydata[i] < gr_setup->y_min)
		   gr_setup->y_min = the_data->ydata[i];
		if (the_data->ydata[i] > gr_setup->y_max)
		   gr_setup->y_max = the_data->ydata[i];
		}  // end i
	    the_data = the_data->next;
	    } /* end while */
     }  // end if
     the_data = plot_data;

     set_graph_max_min_2 (gr_setup,gr);

     clear_window (gr);
     draw_border(gr_setup,gr,1);
     draw_border_axes(gr_setup,gr);
     display_title (gr_setup,gr);

     graph_x_y_labels (gr_setup,gr);

     show_descr1 = the_data->show_descr1;
     show_descr2 = the_data->show_descr2;

     xy_to_window_col_row (gr,0.0,0.0,&gr_x0,&gr_y0);
     xy_to_window_col_row (gr,gr->x_min,
	    gr->y_min,&gr_xmin,&gr_ymin);
     xy_to_window_col_row (gr,gr->x_max,
	    gr->y_max, &gr_xmax,&gr_ymax);
     /* draw axes  */
     draw_color_line (gr,gr_xmin,gr_y0,gr_xmax,gr_y0,
	   gr_setup->line_color);
     draw_color_line (gr,gr_x0,gr_ymax,gr_x0,gr_ymin,
	   gr_setup->line_color);
     while (the_data) {
	if (the_data->xdata_to_file) {
	   if (!open_output_text_file(&xdata_file,the_data->xdata_filename))
	      the_data->xdata_to_file = 0;
	   }
	if (the_data->ydata_to_file) {
	   if (!open_output_text_file(&ydata_file,the_data->ydata_filename))
	      the_data->ydata_to_file = 0;
	   }
	xy_to_window_col_row (gr,the_data->xdata[0],the_data->ydata[0],
	   &gr_x,&gr_y);
	draw_color_line (gr,gr_x,gr_y,gr_x,gr_y,
	   the_data->color);
	old_gr_x = gr_x;
	old_gr_y = gr_y;
	if (the_data->xdata_to_file)
	   fprintf (xdata_file,"%8.4f\n",the_data->xdata[0]);
	if (the_data->ydata_to_file)
	   fprintf (ydata_file,"%8.4f\n",the_data->ydata[0]);
	for (i=1;i<the_data->npts;i++) {
	    xy_to_window_col_row (gr,the_data->xdata[i],
		 the_data->ydata[i],&gr_x,&gr_y);
	    draw_color_line (gr,old_gr_x,old_gr_y,gr_x,gr_y,
		 the_data->color);
	    old_gr_x = gr_x;
	    old_gr_y = gr_y;
	    if (the_data->xdata_to_file)
	       fprintf (xdata_file,"%8.4f\n",the_data->xdata[i]);
	    if (the_data->ydata_to_file)
	       fprintf (ydata_file,"%8.4f\n",the_data->ydata[i]);
	    }  /* i  */

	if (the_data->xdata_to_file)
	   fclose (xdata_file);
	if (the_data->ydata_to_file)
	   fclose (ydata_file);

	the_data = the_data->next;
	} /* end while */

   SetTextColor (gr->hDC,gr_setup->text_color);
   old_text_align = GetTextAlign (gr->hDC);
   SetTextAlign (gr->hDC,TA_BOTTOM | TA_LEFT);
   if (show_descr1)
   if (descr1)
       TextOut(gr->hDC,gr->iter_col,gr->y_max_row + 2*gr->y_space,
	     descr1,strlen(descr1));
   if (show_descr2)
   if (descr2)
       TextOut(gr->hDC,gr->iter_col,gr->y_max_row + 7*gr->y_space,
	     descr2,strlen(descr2));
   SetTextAlign (gr->hDC,old_text_align);
   return;
   }  /* end proc */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -