IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40061


Ignore:
Timestamp:
Jun 7, 2017, 8:51:20 PM (9 years ago)
Author:
eugene
Message:

match ticks in X and PNG; do not put border around image

Location:
trunk/Ohana/src/kapa2/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/src/PSFrame.c

    r40018 r40061  
    44int PSFrame (KapaGraphWidget *graph, FILE *f) {
    55 
    6   int i, j, Nticks, P, doffset;
     6  int i, j, Nticks, doffset;
    77  double fx, fy, dfx, dfy, dx = 0, dy = 0, lweight;
    88  Graphic *graphic;
     
    1212  graphic = GetGraphic();
    1313
    14   P = 0.5 * (1 + 0.25*graph[0].axis[0].lweight) * (hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy) + hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy));
     14  // P = 0.5 * (1 + 0.25*graph[0].axis[0].lweight) * (hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy) + hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy));
     15
     16  int Px = 0.5 * (1 + 0.25*graph[0].axis[0].lweight) * (hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy) + hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy));
     17  int Py = 0.5 * (1 + 0.25*graph[0].axis[1].lweight) * (hypot (graph[0].axis[1].dfx, graph[0].axis[1].dfy) + hypot (graph[0].axis[1].dfx, graph[0].axis[1].dfy));
     18  int P = MIN (Px, Py);
    1519
    1620  /* each axis is drawn independently */
     
    102106    GetRotFont (&fontsize);
    103107
     108    pad = !isnan(axis->ticktextPad) ? axis->ticktextPad*fontsize : fontsize + 4.0;
     109    // pad = !isnan(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0;
     110   
     111    /* temporarily assume rectilinear axes */
     112    if (naxis == 0) { dx = 0; dy = -pad; pos = 1; }
     113    if (naxis == 2) { dx = 0; dy = +pad; pos = 7; }
     114
     115    if (naxis == 1) { dy = 0; dx = -pad; pos = 3; }
     116    if (naxis == 3) { dy = 0; dx = +pad; pos = 5; }
     117
     118    xt = fx + (value-min)*dfx/(max - min) + dx;
     119    yt = fy + (value-min)*dfy/(max - min) + dy;
     120
     121    PrintTick (string, value, min, max, tick->nsignif);
     122    PSRotText (f, xt, yt, string, pos, 0.0);
     123  }
     124}
     125
     126  /*
     127  dx = size*dfy*n;     
     128  dy = size*dfx*n;
     129  DrawLine (x, y, dx, dy);
     130 
     131  dx = -size*dfy*n;     
     132  dy = -size*dfx*n;
     133  DrawLine (x, y, dx, dy);
     134  */
     135 
     136# if (0)
     137void PSTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis, FILE *f) {
     138 
     139  double x, y, dx, dy;
     140  int pos, dir, fontsize;
     141  double size, n, pad;
     142  char string[64];
     143
     144  double fx  = axis->fx;
     145  double fy  = graphic->dy - axis->fy;
     146  double dfx = axis->dfx;
     147  double dfy = -axis->dfy;
     148
     149  double min = axis->min;
     150  double max = axis->max;
     151
     152  double value = tick->value;
     153
     154  pos = size = 0;
     155
     156  if (tick->IsMajor) {
     157    size = MAX (0.02, 7.0 / P);
     158  } else {
     159    size = MAX (0.01, 4.0 / P);
     160  }
     161 
     162  n = P / hypot(dfx, dfy);
     163  x = fx + (value-min)*dfx/(max - min);
     164  y = fy + (value-min)*dfy/(max - min);
     165
     166  if ((naxis == 0) || (naxis == 2)) {
     167    x = MIN(MAX(x, fx),fx+dfx);
     168  }
     169  if ((naxis == 1) || (naxis == 3)) {
     170    y = MIN(MAX(y, fy),fy+dfy);
     171  }
     172
     173  dir = ((naxis == 0) || (naxis == 1)) ? +1 : -1;
     174  dx = dir*size*dfy*n; 
     175  dy = dir*size*dfx*n;
     176 
     177  DrawLine (x, y, dx, dy);
     178
     179  if (tick->IsLabel) {
     180    int xt, yt;
     181
     182    // char *fontname is returned by not needed
     183    GetRotFont (&fontsize);
     184
    104185    pad = !isnan(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0;
    105186   
     
    118199  }
    119200}
    120 
    121   /*
    122   dx = size*dfy*n;     
    123   dy = size*dfx*n;
    124   DrawLine (x, y, dx, dy);
    125  
    126   dx = -size*dfy*n;     
    127   dy = -size*dfx*n;
    128   DrawLine (x, y, dx, dy);
    129   */
    130  
    131 # if (0)
    132 void PSTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis, FILE *f) {
    133  
    134   double x, y, dx, dy;
    135   int pos, dir, fontsize;
    136   double size, n, pad;
    137   char string[64];
    138 
    139   double fx  = axis->fx;
    140   double fy  = graphic->dy - axis->fy;
    141   double dfx = axis->dfx;
    142   double dfy = -axis->dfy;
    143 
    144   double min = axis->min;
    145   double max = axis->max;
    146 
    147   double value = tick->value;
    148 
    149   pos = size = 0;
    150 
    151   if (tick->IsMajor) {
    152     size = MAX (0.02, 7.0 / P);
    153   } else {
    154     size = MAX (0.01, 4.0 / P);
    155   }
    156  
    157   n = P / hypot(dfx, dfy);
    158   x = fx + (value-min)*dfx/(max - min);
    159   y = fy + (value-min)*dfy/(max - min);
    160 
    161   if ((naxis == 0) || (naxis == 2)) {
    162     x = MIN(MAX(x, fx),fx+dfx);
    163   }
    164   if ((naxis == 1) || (naxis == 3)) {
    165     y = MIN(MAX(y, fy),fy+dfy);
    166   }
    167 
    168   dir = ((naxis == 0) || (naxis == 1)) ? +1 : -1;
    169   dx = dir*size*dfy*n; 
    170   dy = dir*size*dfx*n;
    171  
    172   DrawLine (x, y, dx, dy);
    173 
    174   if (tick->IsLabel) {
    175     int xt, yt;
    176 
    177     // char *fontname is returned by not needed
    178     GetRotFont (&fontsize);
    179 
    180     pad = !isnan(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0;
    181    
    182     /* temporarily assume rectilinear axes */
    183     if (naxis == 0) { dx = 0; dy = -pad; pos = 1; }
    184     if (naxis == 2) { dx = 0; dy = +pad; pos = 7; }
    185 
    186     if (naxis == 1) { dy = 0; dx = -pad; pos = 3; }
    187     if (naxis == 3) { dy = 0; dx = +pad; pos = 5; }
    188 
    189     xt = fx + (value-min)*dfx/(max - min) + dx;
    190     yt = fy + (value-min)*dfy/(max - min) + dy;
    191 
    192     PrintTick (string, value, min, max, tick->nsignif);
    193     PSRotText (f, xt, yt, string, pos, 0.0);
    194   }
    195 }
    196201# endif
    197202
  • trunk/Ohana/src/kapa2/src/PSimage.c

    r32695 r40061  
    2020  // the values come from the following map: image[0].pixmap[i] -> cmap[pixel].red -> R (0-255)
    2121
    22   fprintf (f, " newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto closepath\n\n",
    23            (int) image[0].picture.x,                       graphic->dy - (int) image[0].picture.y,
    24            (int) image[0].picture.x + image[0].picture.dx, graphic->dy - (int) image[0].picture.y,
    25            (int) image[0].picture.x + image[0].picture.dx, graphic->dy - (int) image[0].picture.y - image[0].picture.dy,
    26            (int) image[0].picture.x,                       graphic->dy - (int) image[0].picture.y - image[0].picture.dy);
     22  if (0) {
     23    fprintf (f, " newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto closepath\n\n",
     24             (int) image[0].picture.x,                       graphic->dy - (int) image[0].picture.y,
     25             (int) image[0].picture.x + image[0].picture.dx, graphic->dy - (int) image[0].picture.y,
     26             (int) image[0].picture.x + image[0].picture.dx, graphic->dy - (int) image[0].picture.y - image[0].picture.dy,
     27             (int) image[0].picture.x,                       graphic->dy - (int) image[0].picture.y - image[0].picture.dy);
     28  }
     29
    2730  fprintf (f, "gsave %% encloses image\n");
    2831  fprintf (f, "%d %d translate\n", (int) image[0].picture.x, graphic->dy - (int) image[0].picture.y - image[0].picture.dy);
Note: See TracChangeset for help on using the changeset viewer.