Changeset 420 for trunk/Jgraph/process.c


Ignore:
Timestamp:
02/27/08 07:13:31 (16 years ago)
Author:
Nicholas Riley
Message:

Jgraph: my changes - ANSIfication, few minor bug fixes; works on OS X 10.5 now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Jgraph/process.c

    r418 r420  
    88#include <stdio.h>
    99#include <math.h>
     10#include <string.h>
    1011
    1112#include "jgraph.h"
     
    1920static double Pi;
    2021
    21 process_title(g)
    22 Graph g;
     22void process_label(Label l, Graph g, int adjust);
     23
     24void process_title(Graph g)
    2325{
    2426
     
    4446}
    4547
    46 process_legend(g)
    47 Graph g;
     48void process_label_max_n_mins(Label l, float len, float height)
     49{
     50  float xlen, ylen, xheight, yheight;
     51  float x, y;
     52
     53  xlen = len * cos(l->rotate * Pi / 180.00);
     54  ylen = height * cos((l->rotate + 90.0) * Pi / 180.00);
     55  xheight = len * sin(l->rotate * Pi / 180.00);
     56  yheight = height * sin((l->rotate + 90.0) * Pi / 180.00);
     57 
     58  x = l->x;
     59  y = l->y;
     60
     61  if (l->hj == 'c') {
     62    x -= xlen / 2.0;
     63    y -= xheight / 2.0;
     64  } else if (l->hj == 'r') {
     65    x -= xlen;
     66    y -= xheight;
     67  }
     68  if (l->vj == 'c') {
     69    x -= ylen / 2.0;
     70    y -= yheight / 2.0;
     71  } else if (l->vj == 't') {
     72    x -= ylen;
     73    y -= yheight;
     74  }
     75
     76  l->xmin = MIN(x, x + xlen);
     77  l->xmin = MIN(l->xmin, x + xlen + ylen);
     78  l->xmin = MIN(l->xmin, x + ylen);
     79
     80  l->ymin = MIN(y, y + xheight);
     81  l->ymin = MIN(l->ymin, y + yheight);
     82  l->ymin = MIN(l->ymin, y + xheight + yheight);
     83
     84  l->xmax = MAX(x, x + xlen);
     85  l->xmax = MAX(l->xmax, x + xlen + ylen);
     86  l->xmax = MAX(l->xmax, x + ylen);
     87
     88  l->ymax = MAX(y, y + xheight);
     89  l->ymax = MAX(l->ymax, y + yheight);
     90  l->ymax = MAX(l->ymax, y + xheight + yheight);
     91
     92}
     93
     94void process_legend(Graph g)
    4895{
    4996  Legend l;
     
    209256}
    210257
    211 float find_reasonable_hash_interval(a)
    212 Axis a;
     258float find_reasonable_hash_interval(Axis a)
    213259{
    214260  float s, d;
     
    238284}
    239285
    240 float find_reasonable_hash_start(a)
    241 Axis a;
     286float find_reasonable_hash_start(Axis a)
    242287{
    243288  int i;
     
    249294}
    250295
    251 int find_reasonable_precision(a)
    252 Axis a;
     296int find_reasonable_precision(Axis a)
    253297{
    254298  int i, b, b2, done;
     
    293337}
    294338
    295 int find_reasonable_minor_hashes(a)
    296 Axis a;
     339int find_reasonable_minor_hashes(Axis a)
    297340{
    298341  float d; 
     
    316359}
    317360
    318 process_axis1(a, g)
    319 Axis a;
    320 Graph g;
     361void process_axis1(Axis a, Graph g)
    321362{
    322363  float tmp;
     
    386427}
    387428
    388 process_axis2(a, g)
    389 Axis a;
    390 Graph g;
     429void process_axis2(Axis a, Graph g)
    391430{
    392431  float t1, t2, t3, minor_hashes, hloc, tmp;
     
    576615}
    577616
    578 process_label(l, g, adjust)
    579 Label l;
    580 Graph g;
    581 int adjust;
     617void process_label(Label l, Graph g, int adjust)
    582618{
    583619  float len, height;
     
    618654}
    619655   
    620 process_label_max_n_mins(l, len, height)
    621 Label l;
    622 float len;
    623 float height;
    624 {
    625   float xlen, ylen, xheight, yheight;
    626   float x, y;
    627 
    628   xlen = len * cos(l->rotate * Pi / 180.00);
    629   ylen = height * cos((l->rotate + 90.0) * Pi / 180.00);
    630   xheight = len * sin(l->rotate * Pi / 180.00);
    631   yheight = height * sin((l->rotate + 90.0) * Pi / 180.00);
    632  
    633   x = l->x;
    634   y = l->y;
    635 
    636   if (l->hj == 'c') {
    637     x -= xlen / 2.0;
    638     y -= xheight / 2.0;
    639   } else if (l->hj == 'r') {
    640     x -= xlen;
    641     y -= xheight;
    642   }
    643   if (l->vj == 'c') {
    644     x -= ylen / 2.0;
    645     y -= yheight / 2.0;
    646   } else if (l->vj == 't') {
    647     x -= ylen;
    648     y -= yheight;
    649   }
    650 
    651   l->xmin = MIN(x, x + xlen);
    652   l->xmin = MIN(l->xmin, x + xlen + ylen);
    653   l->xmin = MIN(l->xmin, x + ylen);
    654 
    655   l->ymin = MIN(y, y + xheight);
    656   l->ymin = MIN(l->ymin, y + yheight);
    657   l->ymin = MIN(l->ymin, y + xheight + yheight);
    658 
    659   l->xmax = MAX(x, x + xlen);
    660   l->xmax = MAX(l->xmax, x + xlen + ylen);
    661   l->xmax = MAX(l->xmax, x + ylen);
    662 
    663   l->ymax = MAX(y, y + xheight);
    664   l->ymax = MAX(l->ymax, y + yheight);
    665   l->ymax = MAX(l->ymax, y + xheight + yheight);
    666 
    667 }
    668 
    669 process_strings(g)
    670 Graph g;
     656void process_strings(Graph g)
    671657{
    672658  String s;
     
    677663}
    678664
    679 process_curve(c, g)
    680 Curve c;
    681 Graph g;
     665void process_curve(Curve c, Graph g)
    682666{
    683667  if (c->bezier && (c->npts < 4 || (c->npts % 3 != 1))) {
     
    705689}
    706690
    707 process_curves(g)
    708 Graph g;
     691void process_curves(Graph g)
    709692{
    710693  Curve c;
     
    713696  }
    714697}
     698
     699void process_label_extrema(Label l, Graph g)
     700{
     701  if (l->label == CNULL) return;
     702  g->yminval = MIN(g->yminval, l->ymin);
     703  g->ymaxval = MAX(g->ymaxval, l->ymax);
     704  g->xminval = MIN(g->xminval, l->xmin);
     705  g->xmaxval = MAX(g->xmaxval, l->xmax);
     706}
    715707 
    716 process_extrema(g)  /* This finds all the minval/maxvals for bbox calc */
    717 Graph g;
     708void process_extrema(Graph g)  /* Finds all the minval/maxvals for bbox calc */
    718709{
    719710  Curve c;
     
    764755}
    765756
    766 process_label_extrema(l, g)
    767 Label l;
    768 Graph g;
    769 {
    770   if (l->label == CNULL) return;
    771   g->yminval = MIN(g->yminval, l->ymin);
    772   g->ymaxval = MAX(g->ymaxval, l->ymax);
    773   g->xminval = MIN(g->xminval, l->xmin);
    774   g->xmaxval = MAX(g->xmaxval, l->xmax);
    775 }
    776 
    777 process_graph(g)
    778 Graph g;
     757void process_graph(Graph g)
    779758{
    780759  g->x_translate = intop(g->x_translate);
     
    791770}
    792771
    793 process_graphs(gs)
    794 Graphs gs;
     772void process_graphs(Graphs gs)
    795773{
    796774  Graphs the_g;
Note: See TracChangeset for help on using the changeset viewer.