[BACK]Return to plot2d.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot

Diff for /OpenXM_contrib/gnuplot/Attic/plot2d.c between version 1.1.1.1 and 1.1.1.3

version 1.1.1.1, 2000/01/09 17:00:54 version 1.1.1.3, 2003/09/15 07:09:25
Line 120  extern TBOOLEAN df_binary;
Line 120  extern TBOOLEAN df_binary;
  * dont know we have to support ranges [10:-10] - lets reverse   * dont know we have to support ranges [10:-10] - lets reverse
  * it for now, then fix it at the end.   * it for now, then fix it at the end.
  */   */
 #define INIT_ARRAYS(axis, min, max, auto, is_log, base, log_base, infinite) \  
 do{auto_array[axis] = auto; \  /* HBB 20021103: try to circumvent BC31 bug by turning this macro into
    min_array[axis] = (infinite && (auto&1)) ? VERYLARGE : min; \   * a function... */
    max_array[axis] = (infinite && (auto&2)) ? -VERYLARGE : max; \  static GP_INLINE void
    log_array[axis] = is_log; base_array[axis] = base; log_base_array[axis] = log_base;\  init_arrays(int axis, double min, double max, int autosc, int is_log, double base, double log_base, TBOOLEAN infinite)
 }while(0)  {
      auto_array[axis] = autosc;
      min_array[axis] = (infinite && (autosc & 1)) ? VERYLARGE : min;
      max_array[axis] = (infinite && (autosc & 2)) ? -VERYLARGE : max;
      log_array[axis] = is_log;
      base_array[axis] = base;
      log_base_array[axis] = log_base;
   }
   #define INIT_ARRAYS init_arrays
   
 /* handle reversed ranges */  /* handle reversed ranges */
 #define CHECK_REVERSE(axis) \  #define CHECK_REVERSE(axis) \
 do{\  do{\
Line 248  void plotrequest()
Line 257  void plotrequest()
     }                           /* first '[' */      }                           /* first '[' */
     if (parametric || polar)    /* set optional x ranges */      if (parametric || polar)    /* set optional x ranges */
         LOAD_RANGE(FIRST_X_AXIS);          LOAD_RANGE(FIRST_X_AXIS);
     else {  
         /* order of t doesn't matter, but x does */  
         CHECK_REVERSE(FIRST_X_AXIS);  
     }  
   
       /* order of x range does matter, even if we're in parametric mode */
       CHECK_REVERSE(FIRST_X_AXIS);
   
     LOAD_RANGE(FIRST_Y_AXIS);      LOAD_RANGE(FIRST_Y_AXIS);
     CHECK_REVERSE(FIRST_Y_AXIS);      CHECK_REVERSE(FIRST_Y_AXIS);
     LOAD_RANGE(SECOND_X_AXIS);      LOAD_RANGE(SECOND_X_AXIS);
Line 288  struct curve_points *this_plot;
Line 296  struct curve_points *this_plot;
  * it will later be moved passed title/with/linetype/pointtype   * it will later be moved passed title/with/linetype/pointtype
  */   */
 {  {
     register int i /* num. points ! */ , j, col;      int i /* num. points ! */ , j;
       int max_cols, min_cols;     /* allowed range of column numbers */
     double v[NCOL];      double v[NCOL];
     int storetoken = this_plot->token;      int storetoken = this_plot->token;
   
Line 297  struct curve_points *this_plot;
Line 306  struct curve_points *this_plot;
     switch (this_plot->plot_style) {    /* set maximum columns to scan */      switch (this_plot->plot_style) {    /* set maximum columns to scan */
     case XYERRORBARS:      case XYERRORBARS:
     case BOXXYERROR:      case BOXXYERROR:
         col = 7;          max_cols = 7;
           min_cols = 4;
         break;          break;
   
     case BOXERROR:  
     case FINANCEBARS:      case FINANCEBARS:
     case CANDLESTICKS:      case CANDLESTICKS:
         col = 5;          min_cols = max_cols = 5;
         break;          break;
   
       case BOXERROR:
           max_cols = 5;
           min_cols = 4;
           break;
   
       case VECTOR:
           min_cols = max_cols = 4;
           break;
   
     case XERRORBARS:      case XERRORBARS:
     case YERRORBARS:      case YERRORBARS:
     case VECTOR:          max_cols = 4;
         col = 4;          min_cols = 3;
         break;          break;
   
     case BOXES:      case BOXES:
         col = 4;          min_cols = 2;
           max_cols = 4;
         break;          break;
   
     default:      default:
         col = 2;          min_cols = 1;
           max_cols = 2;
     }      }
   
     if (this_plot->plot_smooth == ACSPLINES)      if (this_plot->plot_smooth == ACSPLINES)
         col = 3;          max_cols = 3;
   
     if (df_no_use_specs > col)      if (df_no_use_specs > max_cols)
         fputs("warning : too many using specs for this style\n", stderr);          int_error("Too many using specs for this style", NO_CARET);
   
       if (df_no_use_specs >0 && df_no_use_specs < min_cols)
           int_error("Not enough columns for this style", NO_CARET);
   
     i = 0;      i = 0;
     while ((j = df_readline(v, col)) != DF_EOF) {      while ((j = df_readline(v, max_cols)) != DF_EOF) {
         /* j <= col */          /* j <= max_cols */
   
         if (i >= this_plot->p_max) {          if (i >= this_plot->p_max) {
             /*              /*
Line 704  struct curve_points *this_plot;
Line 727  struct curve_points *this_plot;
 int plot_num;  int plot_num;
 {  {
     int i, curve;      int i, curve;
       char *table_format = NULL;
       /* The data format is determined by the format of the axis labels.
        * See 'set format'.  Patch by Don Taber
        */
       table_format = gp_alloc(strlen(xformat)+strlen(yformat)+5, "table format");
       strcpy(table_format, xformat);
       strcat(table_format, " ");
       strcat(table_format, yformat);
       strcat(table_format, " %c\n");
   
       /* Not sure whether the missing plot styles require special treatment.
        * They all fall under the "default" case right now. Lars
        */
     for (curve = 0; curve < plot_num;      for (curve = 0; curve < plot_num;
          curve++, this_plot = this_plot->next_cp) {           curve++, this_plot = this_plot->next_cp) {
         fprintf(gpoutfile, "#Curve %d, %d points\n#x y type\n", curve, this_plot->p_count);          fprintf(gpoutfile, "#Curve %d, %d points\n#x y", curve, this_plot->p_count);
           switch (this_plot->plot_style) {
           case BOXES:
           case XERRORBARS:
               fprintf(gpoutfile, " xlow xhigh");
               break;
           case BOXERROR:
           case YERRORBARS:
               fprintf(gpoutfile, " ylow yhigh");
               break;
           case BOXXYERROR:
           case XYERRORBARS:
               fprintf(gpoutfile, " xlow xhigh ylow yhigh");
               break;
           case FINANCEBARS:
           case CANDLESTICKS:
           default:
               /* ? */
               break;
           }
   
           fprintf(gpoutfile, " type\n");
         for (i = 0; i < this_plot->p_count; i++) {          for (i = 0; i < this_plot->p_count; i++) {
             fprintf(gpoutfile, "%g %g %c\n",              fprintf(gpoutfile, "%g %g",
                     this_plot->points[i].x,                      this_plot->points[i].x,
                     this_plot->points[i].y,                      this_plot->points[i].y);
               switch (this_plot->plot_style) {
               case BOXES:
               case XERRORBARS:
                   fprintf(gpoutfile, " %g %g",
                           this_plot->points[i].xlow,
                           this_plot->points[i].xhigh);
                   break;
               case BOXERROR:
               case YERRORBARS:
                   fprintf(gpoutfile, " %g %g",
                           this_plot->points[i].ylow,
                           this_plot->points[i].yhigh);
                   break;
               case BOXXYERROR:
               case XYERRORBARS:
                   fprintf(gpoutfile, " %g %g %g %g",
                           this_plot->points[i].xlow,
                           this_plot->points[i].xhigh,
                           this_plot->points[i].ylow,
                           this_plot->points[i].yhigh);
                   break;
               case FINANCEBARS:
               case CANDLESTICKS:
               default:
                   /* ? */
                   break;
               }
               fprintf(gpoutfile, " %c\n",
                     this_plot->points[i].type == INRANGE ? 'i'                      this_plot->points[i].type == INRANGE ? 'i'
                     : this_plot->points[i].type == OUTRANGE ? 'o'                      : this_plot->points[i].type == OUTRANGE ? 'o'
                     : 'u');                      : 'u');
         }          }
         fputc('\n', gpoutfile);          fputc('\n', gpoutfile);
     }      }
 /* two blank lines between plots in table output */  
       /* two blank lines between plots in table output */
     fputc('\n', gpoutfile);      fputc('\n', gpoutfile);
     fflush(gpoutfile);      fflush(gpoutfile);
   
       free(table_format);
 }  }
   
 /*  /*
Line 1194  do{ assert(!polar && !parametric); \
Line 1281  do{ assert(!polar && !parametric); \
     if (plot_num == 0 || first_plot == NULL) {      if (plot_num == 0 || first_plot == NULL) {
         int_error("no functions or data to plot", c_token);          int_error("no functions or data to plot", c_token);
     }      }
   
   
     if (uses_axis[FIRST_X_AXIS]) {      if (uses_axis[FIRST_X_AXIS]) {
         if (max_array[FIRST_X_AXIS] == -VERYLARGE ||          if (max_array[FIRST_X_AXIS] == -VERYLARGE ||
             min_array[FIRST_X_AXIS] == VERYLARGE)              min_array[FIRST_X_AXIS] == VERYLARGE) {
               cp_free(first_plot);
               first_plot = NULL;
             int_error("all points undefined!", NO_CARET);              int_error("all points undefined!", NO_CARET);
           }
         FIXUP_RANGE_FOR_LOG(FIRST_X_AXIS, x);          FIXUP_RANGE_FOR_LOG(FIRST_X_AXIS, x);
     }      }
     if (uses_axis[SECOND_X_AXIS]) {      if (uses_axis[SECOND_X_AXIS]) {
         if (max_array[SECOND_X_AXIS] == -VERYLARGE ||          if (max_array[SECOND_X_AXIS] == -VERYLARGE ||
             min_array[SECOND_X_AXIS] == VERYLARGE)              min_array[SECOND_X_AXIS] == VERYLARGE) {
               cp_free(first_plot);
               first_plot = NULL;
             int_error("all points undefined!", NO_CARET);              int_error("all points undefined!", NO_CARET);
           }
         FIXUP_RANGE_FOR_LOG(SECOND_X_AXIS, x2);          FIXUP_RANGE_FOR_LOG(SECOND_X_AXIS, x2);
     } else {      } else {
         assert(uses_axis[FIRST_X_AXIS]);          assert(uses_axis[FIRST_X_AXIS]);
Line 1211  do{ assert(!polar && !parametric); \
Line 1306  do{ assert(!polar && !parametric); \
             min_array[SECOND_X_AXIS] = min_array[FIRST_X_AXIS];              min_array[SECOND_X_AXIS] = min_array[FIRST_X_AXIS];
         if (auto_array[SECOND_X_AXIS] & 2)          if (auto_array[SECOND_X_AXIS] & 2)
             max_array[SECOND_X_AXIS] = max_array[FIRST_X_AXIS];              max_array[SECOND_X_AXIS] = max_array[FIRST_X_AXIS];
           if (! auto_array[SECOND_X_AXIS])
               FIXUP_RANGE_FOR_LOG(SECOND_X_AXIS, x2);
     }      }
   
     if (!uses_axis[FIRST_X_AXIS]) {      if (!uses_axis[FIRST_X_AXIS]) {
         assert(uses_axis[SECOND_X_AXIS]);          assert(uses_axis[SECOND_X_AXIS]);
         if (auto_array[FIRST_X_AXIS] & 1)          if (auto_array[FIRST_X_AXIS] & 1)
Line 1220  do{ assert(!polar && !parametric); \
Line 1316  do{ assert(!polar && !parametric); \
         if (auto_array[FIRST_X_AXIS] & 2)          if (auto_array[FIRST_X_AXIS] & 2)
             max_array[FIRST_X_AXIS] = max_array[SECOND_X_AXIS];              max_array[FIRST_X_AXIS] = max_array[SECOND_X_AXIS];
     }      }
   
   
     if (uses_axis[FIRST_Y_AXIS]) {      if (uses_axis[FIRST_Y_AXIS]) {
         if (max_array[FIRST_Y_AXIS] == -VERYLARGE ||          if (max_array[FIRST_Y_AXIS] == -VERYLARGE ||
             min_array[FIRST_Y_AXIS] == VERYLARGE)              min_array[FIRST_Y_AXIS] == VERYLARGE) {
               cp_free(first_plot);
               first_plot = NULL;
             int_error("all points undefined!", NO_CARET);              int_error("all points undefined!", NO_CARET);
           }
         fixup_range(FIRST_Y_AXIS, "y");          fixup_range(FIRST_Y_AXIS, "y");
         FIXUP_RANGE_FOR_LOG(FIRST_Y_AXIS, y);          FIXUP_RANGE_FOR_LOG(FIRST_Y_AXIS, y);
     }                           /* else we want to copy y2 range, but need to fix it up first */      }
     if (uses_axis[SECOND_Y_AXIS]) {      if (uses_axis[SECOND_Y_AXIS]) {
         if (max_array[SECOND_Y_AXIS] == -VERYLARGE ||          if (max_array[SECOND_Y_AXIS] == -VERYLARGE ||
             min_array[SECOND_Y_AXIS] == VERYLARGE)              min_array[SECOND_Y_AXIS] == VERYLARGE) {
               cp_free(first_plot);
               first_plot = NULL;
             int_error("all points undefined!", NO_CARET);              int_error("all points undefined!", NO_CARET);
           }
         fixup_range(SECOND_Y_AXIS, "y2");          fixup_range(SECOND_Y_AXIS, "y2");
         FIXUP_RANGE_FOR_LOG(SECOND_Y_AXIS, y2);          FIXUP_RANGE_FOR_LOG(SECOND_Y_AXIS, y2);
     } else {      } else {
           /* else we want to copy y2 range */
         assert(uses_axis[FIRST_Y_AXIS]);          assert(uses_axis[FIRST_Y_AXIS]);
         if (auto_array[SECOND_Y_AXIS] & 1)          if (auto_array[SECOND_Y_AXIS] & 1)
             min_array[SECOND_Y_AXIS] = min_array[FIRST_Y_AXIS];              min_array[SECOND_Y_AXIS] = min_array[FIRST_Y_AXIS];
         if (auto_array[SECOND_Y_AXIS] & 2)          if (auto_array[SECOND_Y_AXIS] & 2)
             max_array[SECOND_Y_AXIS] = max_array[FIRST_Y_AXIS];              max_array[SECOND_Y_AXIS] = max_array[FIRST_Y_AXIS];
           /* Log() fixup is only necessary if the range was *not* copied from
            * the (already logarithmized) yrange */
           if (! auto_array[SECOND_Y_AXIS])
               FIXUP_RANGE_FOR_LOG(SECOND_Y_AXIS, y2);
     }      }
   
     if (!uses_axis[FIRST_Y_AXIS]) {      if (!uses_axis[FIRST_Y_AXIS]) {
         assert(uses_axis[SECOND_Y_AXIS]);          assert(uses_axis[SECOND_Y_AXIS]);
         if (auto_array[FIRST_Y_AXIS] & 1)          if (auto_array[FIRST_Y_AXIS] & 1)
Line 1248  do{ assert(!polar && !parametric); \
Line 1356  do{ assert(!polar && !parametric); \
         if (auto_array[FIRST_Y_AXIS] & 2)          if (auto_array[FIRST_Y_AXIS] & 2)
             max_array[FIRST_Y_AXIS] = max_array[SECOND_Y_AXIS];              max_array[FIRST_Y_AXIS] = max_array[SECOND_Y_AXIS];
     }      }
 #define WRITEBACK(axis,min,max) \  
 if(range_flags[axis]&RANGE_WRITEBACK) \  
   {if (auto_array[axis]&1) min = min_array[axis]; \  
    if (auto_array[axis]&2) max = max_array[axis]; \  
   }  
   
     WRITEBACK(FIRST_X_AXIS, xmin, xmax)      if (strcmp(term->name, "table") == 0)
         WRITEBACK(FIRST_Y_AXIS, ymin, ymax)  
         WRITEBACK(SECOND_X_AXIS, x2min, x2max)  
         WRITEBACK(SECOND_Y_AXIS, y2min, y2max)  
         if (strcmp(term->name, "table") == 0)  
         print_table(first_plot, plot_num);          print_table(first_plot, plot_num);
     else {      else {
         START_LEAK_CHECK();     /* check for memory leaks in this routine */          START_LEAK_CHECK();     /* check for memory leaks in this routine */
Line 1267  if(range_flags[axis]&RANGE_WRITEBACK) \
Line 1366  if(range_flags[axis]&RANGE_WRITEBACK) \
         do_plot(first_plot, plot_num);          do_plot(first_plot, plot_num);
   
         END_LEAK_CHECK();          END_LEAK_CHECK();
   
           /* after do_plot(), min_array[] and max_array[]
              contain the plotting range actually used (rounded
              to tic marks, not only the min/max data values)
              --> save them now for writeback if requested */
   
   #define SAVE_WRITEBACK(axis) /* ULIG */ \
     if(range_flags[axis]&RANGE_WRITEBACK) { \
       set_writeback_min(axis,min_array[axis]); \
       set_writeback_max(axis,max_array[axis]); \
     }
           SAVE_WRITEBACK(FIRST_X_AXIS)
           SAVE_WRITEBACK(FIRST_Y_AXIS)
           SAVE_WRITEBACK(FIRST_Z_AXIS)
           SAVE_WRITEBACK(SECOND_X_AXIS)
           SAVE_WRITEBACK(SECOND_Y_AXIS)
           SAVE_WRITEBACK(SECOND_Z_AXIS)
           SAVE_WRITEBACK(T_AXIS)
           SAVE_WRITEBACK(R_AXIS)
           SAVE_WRITEBACK(U_AXIS)
           SAVE_WRITEBACK(V_AXIS)
     }      }
   
     /* if we get here, all went well, so record this line for replot */      /* if we get here, all went well, so record this line for replot */
Line 1365  int *plot_num;
Line 1485  int *plot_num;
             /* Ok, fix up the title to include both the xp and yp plots. */              /* Ok, fix up the title to include both the xp and yp plots. */
             if (xp->title && xp->title[0] != '\0' && yp->title) {              if (xp->title && xp->title[0] != '\0' && yp->title) {
                 tlen = strlen(yp->title) + strlen(xp->title) + 3;                  tlen = strlen(yp->title) + strlen(xp->title) + 3;
                 new_title = gp_alloc((unsigned long) tlen, "string");                  new_title = gp_alloc(tlen, "string");
                 strcpy(new_title, xp->title);                  strcpy(new_title, xp->title);
                 strcat(new_title, ", ");        /* + 2 */                  strcat(new_title, ", ");        /* + 2 */
                 strcat(new_title, yp->title);   /* + 1 = + 3 */                  strcat(new_title, yp->title);   /* + 1 = + 3 */

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>