Changeset 2923


Ignore:
Timestamp:
Apr 2, 2012, 1:44:45 AM (8 years ago)
Author:
ldelgass
Message:

style fixes

Location:
trunk/packages/vizservers/nanovis
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Axis.cpp

    r2871 r2923  
    3232}
    3333
    34 /*
    35  * ----------------------------------------------------------------------
    36  *
    37  * NiceNum --
    38  *
    39  *      Reference: Paul Heckbert, "Nice Numbers for Graph Labels",
    40  *                 Graphics Gems, pp 61-63. 
    41  *
    42  *      Finds a "nice" number approximately equal to x.
    43  *
    44  * ----------------------------------------------------------------------
     34/**
     35 * Reference: Paul Heckbert, "Nice Numbers for Graph Labels",
     36 *            Graphics Gems, pp 61-63. 
     37 *
     38 * Finds a "nice" number approximately equal to x.
    4539 */
    4640static double
    47 NiceNum(
    48     double x,
    49     int round)                  /* If non-zero, round. Otherwise take ceiling
    50                                  * of value. */
    51 {
    52     double expt;                /* Exponent of x */
    53     double frac;                /* Fractional part of x */
    54     double nice;                /* Nice, rounded fraction */
     41niceNum(double x,
     42        int round)              /* If non-zero, round. Otherwise take ceiling
     43                                 * of value. */
     44{
     45    double expt;                /* Exponent of x */
     46    double frac;                /* Fractional part of x */
     47    double nice;                /* Nice, rounded fraction */
    5548
    5649    expt = floor(log10(x));
    57     frac = x / EXP10(expt);     /* between 1 and 10 */
     50    frac = x / EXP10(expt);     /* between 1 and 10 */
    5851    if (round) {
    59         if (frac < 1.5) {
    60             nice = 1.0;
    61         } else if (frac < 3.0) {
    62             nice = 2.0;
    63         } else if (frac < 7.0) {
    64             nice = 5.0;
    65         } else {
    66             nice = 10.0;
    67         }
     52        if (frac < 1.5) {
     53            nice = 1.0;
     54        } else if (frac < 3.0) {
     55            nice = 2.0;
     56        } else if (frac < 7.0) {
     57            nice = 5.0;
     58        } else {
     59            nice = 10.0;
     60        }
    6861    } else {
    69         if (frac <= 1.0) {
    70             nice = 1.0;
    71         } else if (frac <= 2.0) {
    72             nice = 2.0;
    73         } else if (frac <= 5.0) {
    74             nice = 5.0;
    75         } else {
    76             nice = 10.0;
    77         }
     62        if (frac <= 1.0) {
     63            nice = 1.0;
     64        } else if (frac <= 2.0) {
     65            nice = 2.0;
     66        } else if (frac <= 5.0) {
     67            nice = 5.0;
     68        } else {
     69            nice = 10.0;
     70        }
    7871    }
    7972    return nice * EXP10(expt);
     
    8174
    8275void
    83 Ticks::SetTicks()
     76Ticks::setTicks()
    8477{
    8578    _numTicks = 0;
    8679    _ticks = new float[_nSteps];
    8780    if (_step == 0.0) {
    88         /* Hack: A zero step indicates to use log values. */
    89         unsigned int i;
    90         /* Precomputed log10 values [1..10] */
    91         static double logTable[] = {
    92             0.0,
    93             0.301029995663981,
    94             0.477121254719662,
    95             0.602059991327962,
    96             0.698970004336019,
    97             0.778151250383644,
    98             0.845098040014257,
    99             0.903089986991944,
    100             0.954242509439325,
    101             1.0
    102         };
    103         for (i = 0; i < _nSteps; i++) {
    104             _ticks[i] = logTable[i];
    105         }
     81        /* Hack: A zero step indicates to use log values. */
     82        unsigned int i;
     83        /* Precomputed log10 values [1..10] */
     84        static double logTable[] = {
     85            0.0,
     86            0.301029995663981,
     87            0.477121254719662,
     88            0.602059991327962,
     89            0.698970004336019,
     90            0.778151250383644,
     91            0.845098040014257,
     92            0.903089986991944,
     93            0.954242509439325,
     94            1.0
     95        };
     96        for (i = 0; i < _nSteps; i++) {
     97            _ticks[i] = logTable[i];
     98        }
    10699    } else {
    107         double value;
    108         unsigned int i;
     100        double value;
     101        unsigned int i;
    109102   
    110         value = _initial;       /* Start from smallest axis tick */
    111         for (i = 0; i < _nSteps; i++) {
    112             value = _initial + (_step * i);
    113             _ticks[i] = UROUND(value, _step);
    114         }
     103        value = _initial;        /* Start from smallest axis tick */
     104        for (i = 0; i < _nSteps; i++) {
     105            value = _initial + (_step * i);
     106            _ticks[i] = UROUND(value, _step);
     107        }
    115108    }
    116109    _numTicks = _nSteps;
     
    136129}
    137130
    138 /*
    139  * ----------------------------------------------------------------------
    140  *
    141  * InRange --
    142  *
    143  *      Determines if a value lies within a given range.
    144  *
    145  *      The value is normalized by the current axis range. If the normalized
    146  *      value is between [0.0..1.0] then it's in range.  The value is compared
    147  *      to 0 and 1., where 0.0 is the minimum and 1.0 is the maximum.
    148  *      DBL_EPSILON is the smallest number that can be represented on the host
    149  *      machine, such that (1.0 + epsilon) != 1.0.
    150  *
    151  *      Please note, *max* can't equal *min*.
    152  *
    153  * Results:
    154  *      If the value is within the interval [min..max], 1 is returned; 0
    155  *      otherwise.
    156  *
    157  * ----------------------------------------------------------------------
     131/**
     132 * \brief Determines if a value lies within a given range.
     133 *
     134 * The value is normalized by the current axis range. If the normalized
     135 * value is between [0.0..1.0] then it's in range.  The value is compared
     136 * to 0 and 1., where 0.0 is the minimum and 1.0 is the maximum.
     137 * DBL_EPSILON is the smallest number that can be represented on the host
     138 * machine, such that (1.0 + epsilon) != 1.0.
     139 *
     140 * Please note, *max* can't equal *min*.
     141 *
     142 * \return If the value is within the interval [min..max], 1 is returned; 0
     143 * otherwise.
    158144 */
    159145bool
    160 Axis::InRange(double x)
     146Axis::inRange(double x)
    161147{
    162148    if (_range < DBL_EPSILON) {
    163         return (fabs(_max - x) >= DBL_EPSILON);
     149        return (fabs(_max - x) >= DBL_EPSILON);
    164150    } else {
    165         x = (x - _min) * _scale;
    166         return ((x >= -DBL_EPSILON) && ((x - 1.0) < DBL_EPSILON));
     151        x = (x - _min) * _scale;
     152        return ((x >= -DBL_EPSILON) && ((x - 1.0) < DBL_EPSILON));
    167153    }
    168154}
    169155
    170156void
    171 Axis::FixRange(double min, double max)
     157Axis::fixRange(double min, double max)
    172158{
    173159    if (min == DBL_MAX) {
    174         if (DEFINED(_reqMin)) {
    175             min = _reqMin;
    176         } else {
    177             min = (_flags & LOGSCALE) ? 0.001 : 0.0;
    178         }
     160        if (DEFINED(_reqMin)) {
     161            min = _reqMin;
     162        } else {
     163            min = (_flags & LOGSCALE) ? 0.001 : 0.0;
     164        }
    179165    }
    180166    if (max == -DBL_MAX) {
    181         if (DEFINED(_reqMax)) {
    182             max = _reqMax;
    183         } else {
    184             max = 1.0;
    185         }
     167        if (DEFINED(_reqMax)) {
     168            max = _reqMax;
     169        } else {
     170            max = 1.0;
     171        }
    186172    }
    187173    if (min >= max) {
    188         /*
    189         * There is no range of data (i.e. min is not less than max), so
    190         * manufacture one.
    191         */
    192         if (min == 0.0) {
    193             min = 0.0, max = 1.0;
    194         } else {
    195             max = min + (fabs(min) * 0.1);
    196         }
     174        /*
     175        * There is no range of data (i.e. min is not less than max), so
     176        * manufacture one.
     177        */
     178        if (min == 0.0) {
     179            min = 0.0, max = 1.0;
     180        } else {
     181            max = min + (fabs(min) * 0.1);
     182        }
    197183    }
    198184
     
    204190    _valueMax = (DEFINED(_reqMax)) ? _reqMax : max;
    205191    if (_valueMax < _valueMin) {
    206         /*   
    207          * If the limits still don't make sense, it's because one limit
    208          * configuration option (-min or -max) was set and the other default
    209          * (based upon the data) is too small or large.  Remedy this by making
    210          * up a new min or max from the user-defined limit.
    211          */
    212         if (!DEFINED(_reqMin)) {
    213             _valueMin = _valueMax - (fabs(_valueMax) * 0.1);
    214         }
    215         if (!DEFINED(_reqMax)) {
    216             _valueMax = _valueMin + (fabs(_valueMax) * 0.1);
    217         }
    218     }
    219 }
    220 
    221 /*
    222  * ----------------------------------------------------------------------
    223  *
    224  * LogScale --
    225  *
    226  *      Determine the range and units of a log scaled axis.
    227  *
    228  *      Unless the axis limits are specified, the axis is scaled
    229  *      automatically, where the smallest and largest major ticks encompass
    230  *      the range of actual data values.  When an axis limit is specified,
    231  *      that value represents the smallest(min)/largest(max) value in the
    232  *      displayed range of values.
    233  *
    234  *      Both manual and automatic scaling are affected by the step used.  By
    235  *      default, the step is the largest power of ten to divide the range in
    236  *      more than one piece.
    237  *
    238  *      Automatic scaling:
    239  *      Find the smallest number of units which contain the range of values.
    240  *      The minimum and maximum major tick values will be represent the
    241  *      range of values for the axis. This greatest number of major ticks
    242  *      possible is 10.
    243  *
    244  *      Manual scaling:
    245  *      Make the minimum and maximum data values the represent the range of
    246  *      the values for the axis.  The minimum and maximum major ticks will be
    247  *      inclusive of this range.  This provides the largest area for plotting
    248  *      and the expected results when the axis min and max values have be set
    249  *      by the user (.e.g zooming).  The maximum number of major ticks is 20.
    250  *
    251  *      For log scale, there's the possibility that the minimum and
    252  *      maximum data values are the same magnitude.  To represent the
    253  *      points properly, at least one full decade should be shown.
    254  *      However, if you zoom a log scale plot, the results should be
    255  *      predictable. Therefore, in that case, show only minor ticks.
    256  *      Lastly, there should be an appropriate way to handle numbers
    257  *      <=0.
    258  *
     192        /*   
     193         * If the limits still don't make sense, it's because one limit
     194         * configuration option (-min or -max) was set and the other default
     195         * (based upon the data) is too small or large.  Remedy this by making
     196         * up a new min or max from the user-defined limit.
     197         */
     198        if (!DEFINED(_reqMin)) {
     199            _valueMin = _valueMax - (fabs(_valueMax) * 0.1);
     200        }
     201        if (!DEFINED(_reqMax)) {
     202            _valueMax = _valueMin + (fabs(_valueMax) * 0.1);
     203        }
     204    }
     205}
     206
     207/**
     208 * \brief Determine the range and units of a log scaled axis.
     209 *
     210 * Unless the axis limits are specified, the axis is scaled
     211 * automatically, where the smallest and largest major ticks encompass
     212 * the range of actual data values.  When an axis limit is specified,
     213 * that value represents the smallest(min)/largest(max) value in the
     214 * displayed range of values.
     215 *
     216 * Both manual and automatic scaling are affected by the step used.  By
     217 * default, the step is the largest power of ten to divide the range in
     218 * more than one piece.
     219 *
     220 * Automatic scaling:
     221 * Find the smallest number of units which contain the range of values.
     222 * The minimum and maximum major tick values will be represent the
     223 * range of values for the axis. This greatest number of major ticks
     224 * possible is 10.
     225 *
     226 * Manual scaling:
     227 * Make the minimum and maximum data values the represent the range of
     228 * the values for the axis.  The minimum and maximum major ticks will be
     229 * inclusive of this range.  This provides the largest area for plotting
     230 * and the expected results when the axis min and max values have be set
     231 * by the user (.e.g zooming).  The maximum number of major ticks is 20.
     232 *
     233 * For log scale, there's the possibility that the minimum and
     234 * maximum data values are the same magnitude.  To represent the
     235 * points properly, at least one full decade should be shown.
     236 * However, if you zoom a log scale plot, the results should be
     237 * predictable. Therefore, in that case, show only minor ticks.
     238 * Lastly, there should be an appropriate way to handle numbers
     239 * <=0.
     240 * <pre>
    259241 *          maxY
    260242 *            |    units = magnitude (of least significant digit)
     
    279261 *           minY
    280262 *
    281  *
    282  *      numTicks = Number of ticks
    283  *      min = Minimum value of axis
    284  *      max = Maximum value of axis
    285  *      range    = Range of values (max - min)
    286  *
    287  *      If the number of decades is greater than ten, it is assumed
    288  *      that the full set of log-style ticks can't be drawn properly.
    289  *
    290  * Results:
    291  *      None
    292  *
    293  * ---------------------------------------------------------------------- */
     263 *      numTicks = Number of ticks
     264 *      min = Minimum value of axis
     265 *      max = Maximum value of axis
     266 *      range = Range of values (max - min)
     267 *
     268 * </pre>
     269 *
     270 *      If the number of decades is greater than ten, it is assumed
     271 *      that the full set of log-style ticks can't be drawn properly.
     272 */
    294273void
    295 Axis::LogScale()
     274Axis::logScale()
    296275{
    297276    double range;
     
    307286    min = _valueMin, max = _valueMax;
    308287    if (min < max) {
    309         min = (min != 0.0) ? log10(fabs(min)) : 0.0;
    310         max = (max != 0.0) ? log10(fabs(max)) : 1.0;
    311 
    312         tickMin = floor(min);
    313         tickMax = ceil(max);
    314         range = tickMax - tickMin;
    315        
    316         if (range > 10) {
    317             /* There are too many decades to display a major tick at every
    318              * decade.  Instead, treat the axis as a linear scale.  */
    319             range = NiceNum(range, 0);
    320             majorStep = NiceNum(range / _major.reqNumTicks, 1);
    321             tickMin = UFLOOR(tickMin, majorStep);
    322             tickMax = UCEIL(tickMax, majorStep);
    323             nMajor = (int)((tickMax - tickMin) / majorStep) + 1;
    324             minorStep = EXP10(floor(log10(majorStep)));
    325             if (minorStep == majorStep) {
    326                 nMinor = 4, minorStep = 0.2;
    327             } else {
    328                 nMinor = ROUND(majorStep / minorStep) - 1;
    329             }
    330         } else {
    331             if (tickMin == tickMax) {
    332                 tickMax++;
    333             }
    334             majorStep = 1.0;
    335             nMajor = (int)(tickMax - tickMin + 1); /* FIXME: Check this. */
    336            
    337             minorStep = 0.0;    /* This is a special hack to pass
    338                                 * information to the SetTicks
    339                                 * method. An interval of 0.0 indicates
    340                                  *      1) this is a minor sweep and
    341                                  *      2) the axis is log scale. 
    342                                 */
    343             nMinor = 10;
    344         }
    345         if ((_flags & TIGHT_MIN) || (DEFINED(_reqMin))) {
    346             tickMin = min;
    347             nMajor++;
    348         }
    349         if ((_flags & TIGHT_MAX) || (DEFINED(_reqMax))) {
    350             tickMax = max;
    351         }
    352     }
    353     _major.SetValues(floor(tickMin), majorStep, nMajor);
    354     _minor.SetValues(minorStep, minorStep, nMinor);
     288        min = (min != 0.0) ? log10(fabs(min)) : 0.0;
     289        max = (max != 0.0) ? log10(fabs(max)) : 1.0;
     290
     291        tickMin = floor(min);
     292        tickMax = ceil(max);
     293        range = tickMax - tickMin;
     294       
     295        if (range > 10) {
     296            /* There are too many decades to display a major tick at every
     297             * decade.  Instead, treat the axis as a linear scale.  */
     298            range = niceNum(range, 0);
     299            majorStep = niceNum(range / _major.reqNumTicks, 1);
     300            tickMin = UFLOOR(tickMin, majorStep);
     301            tickMax = UCEIL(tickMax, majorStep);
     302            nMajor = (int)((tickMax - tickMin) / majorStep) + 1;
     303            minorStep = EXP10(floor(log10(majorStep)));
     304            if (minorStep == majorStep) {
     305                nMinor = 4, minorStep = 0.2;
     306            } else {
     307                nMinor = ROUND(majorStep / minorStep) - 1;
     308            }
     309        } else {
     310            if (tickMin == tickMax) {
     311                tickMax++;
     312            }
     313            majorStep = 1.0;
     314            nMajor = (int)(tickMax - tickMin + 1); /* FIXME: Check this. */
     315           
     316            minorStep = 0.0;    /* This is a special hack to pass
     317                                * information to the SetTicks
     318                                * method. An interval of 0.0 indicates
     319                                 *   1) this is a minor sweep and
     320                                 *   2) the axis is log scale. 
     321                                */
     322            nMinor = 10;
     323        }
     324        if ((_flags & TIGHT_MIN) || (DEFINED(_reqMin))) {
     325            tickMin = min;
     326            nMajor++;
     327        }
     328        if ((_flags & TIGHT_MAX) || (DEFINED(_reqMax))) {
     329            tickMax = max;
     330        }
     331    }
     332    _major.setValues(floor(tickMin), majorStep, nMajor);
     333    _minor.setValues(minorStep, minorStep, nMinor);
    355334    _min = tickMin;
    356335    _max = tickMax;
     
    359338}
    360339
    361 /*
    362  * ----------------------------------------------------------------------
    363  *
    364  * Axis::LinearScale --
    365  *
    366  *      Determine the units of a linear scaled axis.
    367  *
    368  *      The axis limits are either the range of the data values mapped
    369  *      to the axis (autoscaled), or the values specified by the -min
    370  *      and -max options (manual).
    371  *
    372  *      If autoscaled, the smallest and largest major ticks will
    373  *      encompass the range of data values.  If the -loose option is
    374  *      selected, the next outer ticks are choosen.  If tight, the
    375  *      ticks are at or inside of the data limits are used.
    376  *
    377  *      If manually set, the ticks are at or inside the data limits
    378  *      are used.  This makes sense for zooming.  You want the
    379  *      selected range to represent the next limit, not something a
    380  *      bit bigger.
    381  *
    382  *      Note: I added an "always" value to the -loose option to force
    383  *            the manually selected axes to be loose. It's probably
    384  *            not a good idea.
    385  *
     340/**
     341 * \brief Determine the units of a linear scaled axis.
     342 *
     343 * The axis limits are either the range of the data values mapped
     344 * to the axis (autoscaled), or the values specified by the -min
     345 * and -max options (manual).
     346 *
     347 * If autoscaled, the smallest and largest major ticks will
     348 * encompass the range of data values.  If the -loose option is
     349 * selected, the next outer ticks are choosen.  If tight, the
     350 * ticks are at or inside of the data limits are used.
     351 *
     352 * If manually set, the ticks are at or inside the data limits
     353 * are used.  This makes sense for zooming.  You want the
     354 * selected range to represent the next limit, not something a
     355 * bit bigger.
     356 *
     357 * Note: I added an "always" value to the -loose option to force
     358 * the manually selected axes to be loose. It's probably
     359 * not a good idea.
     360 *
     361 * <pre>
    386362 *          maxY
    387363 *            |    units = magnitude (of least significant digit)
     
    409385 *      min = Minimum value of axis
    410386 *      max = Maximum value of axis
    411  *      range    = Range of values (max - min)
    412  *
    413  * Results:
    414  *      None.
     387 *      range = Range of values (max - min)
     388 *
     389 * </pre>
    415390 *
    416391 * Side Effects:
    417392 *      The axis tick information is set.  The actual tick values will
    418393 *      be generated later.
    419  *
    420  * ----------------------------------------------------------------------
    421394 */
    422395void
    423 Axis::LinearScale()
     396Axis::linearScale()
    424397{
    425398    double step;
     
    432405    tickMin = tickMax = 0.0;
    433406    if (_valueMin < _valueMax) {
    434         double range;
    435 
    436         range = _valueMax - _valueMin;
    437         /* Calculate the major tick stepping. */
    438         if (_reqStep > 0.0) {
    439             /* An interval was designated by the user.  Keep scaling it until
    440              * it fits comfortably within the current range of the axis.  */
    441             step = _reqStep;
    442             while ((2 * step) >= range) {
    443                 step *= 0.5;
    444             }
    445         } else {
    446             range = NiceNum(range, 0);
    447             step = NiceNum(range / _major.reqNumTicks, 1);
    448         }
    449        
    450         /* Find the outer tick values. Add 0.0 to prevent getting -0.0. */
    451         tickMin = floor(_valueMin / step) * step + 0.0;
    452         tickMax = ceil(_valueMax / step) * step + 0.0;
    453        
    454         nTicks = ROUND((tickMax - tickMin) / step) + 1;
     407        double range;
     408
     409        range = _valueMax - _valueMin;
     410        /* Calculate the major tick stepping. */
     411        if (_reqStep > 0.0) {
     412            /* An interval was designated by the user.  Keep scaling it until
     413             * it fits comfortably within the current range of the axis.  */
     414            step = _reqStep;
     415            while ((2 * step) >= range) {
     416                step *= 0.5;
     417            }
     418        } else {
     419            range = niceNum(range, 0);
     420            step = niceNum(range / _major.reqNumTicks, 1);
     421        }
     422       
     423        /* Find the outer tick values. Add 0.0 to prevent getting -0.0. */
     424        tickMin = floor(_valueMin / step) * step + 0.0;
     425        tickMax = ceil(_valueMax / step) * step + 0.0;
     426       
     427        nTicks = ROUND((tickMax - tickMin) / step) + 1;
    455428    }
    456     _major.SetValues(tickMin, step, nTicks);
     429    _major.setValues(tickMin, step, nTicks);
    457430
    458431    /*
     
    472445
    473446    if ((_minor.reqNumTicks > 0) && (_minor.autoscale())) {
    474         nTicks = _minor.reqNumTicks - 1;
    475         step = 1.0 / (nTicks + 1);
     447        nTicks = _minor.reqNumTicks - 1;
     448        step = 1.0 / (nTicks + 1);
    476449    } else {
    477         nTicks = 0;             /* No minor ticks. */
    478         step = 0.5;             /* Don't set the minor tick interval to
    479                                 * 0.0. It makes the GenerateTicks routine
    480                                 * create minor log-scale tick marks.  */
    481     }
    482     _minor.SetValues(step, step, nTicks);
     450        nTicks = 0;             /* No minor ticks. */
     451        step = 0.5;             /* Don't set the minor tick interval to
     452                                * 0.0. It makes the GenerateTicks routine
     453                                * create minor log-scale tick marks.  */
     454    }
     455    _minor.setValues(step, step, nTicks);
    483456}
    484457
    485458
    486459void
    487 Axis::SetScale(double min, double max)
    488 {
    489     FixRange(min, max);
     460Axis::setScale(double min, double max)
     461{
     462    fixRange(min, max);
    490463    if (_flags & LOGSCALE) {
    491         LogScale();
     464        logScale();
    492465    } else {
    493         LinearScale();
    494     }
    495     _major.SweepTicks();
    496     _minor.SweepTicks();
    497     MakeTicks();
     466        linearScale();
     467    }
     468    _major.sweepTicks();
     469    _minor.sweepTicks();
     470    makeTicks();
    498471}
    499472
    500473void
    501 Axis::MakeTicks()
    502 {
    503     _major.Reset();
    504     _minor.Reset();
     474Axis::makeTicks()
     475{
     476    _major.reset();
     477    _minor.reset();
    505478    int i;
    506479    for (i = 0; i < _major.numTicks(); i++) {
    507         double t1, t2;
    508         int j;
    509        
    510         t1 = _major.tick(i);
    511         /* Minor ticks */
    512         for (j = 0; j < _minor.numTicks(); j++) {
    513             t2 = t1 + (_major.step() * _minor.tick(j));
    514             if (!InRange(t2)) {
    515                 continue;
    516             }
    517             if (t1 == t2) {
    518                 continue;       // Don't add duplicate minor ticks.
    519             }
    520             _minor.Append(t2);
    521         }
    522         if (!InRange(t1)) {
    523             continue;
    524         }
    525         _major.Append(t1);
     480        double t1, t2;
     481        int j;
     482       
     483        t1 = _major.tick(i);
     484        /* Minor ticks */
     485        for (j = 0; j < _minor.numTicks(); j++) {
     486            t2 = t1 + (_major.step() * _minor.tick(j));
     487            if (!inRange(t2)) {
     488                continue;
     489            }
     490            if (t1 == t2) {
     491                continue;        // Don't add duplicate minor ticks.
     492            }
     493            _minor.append(t2);
     494        }
     495        if (!inRange(t1)) {
     496            continue;
     497        }
     498        _major.append(t1);
    526499    }
    527500}
    528501
    529502double
    530 Axis::Map(double x)
     503Axis::map(double x)
    531504{
    532505    if ((_flags & LOGSCALE) && (x != 0.0)) {
    533         x = log10(fabs(x));
     506        x = log10(fabs(x));
    534507    }
    535508    /* Map graph coordinate to normalized coordinates [0..1] */
    536509    x = (x - _min) * _scale;
    537510    if (_flags & DESCENDING) {
    538         x = 1.0 - x;
     511        x = 1.0 - x;
    539512    }
    540513    return x;
     
    542515
    543516double
    544 Axis::InvMap(double x)
     517Axis::invMap(double x)
    545518{
    546519    if (_flags & DESCENDING) {
    547         x = 1.0 - x;
     520        x = 1.0 - x;
    548521    }
    549522    x = (x * _range) + _min;
    550523    if (_flags & LOGSCALE) {
    551         x = EXP10(x);
     524        x = EXP10(x);
    552525    }
    553526    return x;
  • trunk/packages/vizservers/nanovis/Axis.h

    r2871 r2923  
    1717{
    1818public:
    19     void SetStartingLink(ChainLink *linkPtr)
     19    void setStartingLink(ChainLink *linkPtr)
    2020    {
    2121        _linkPtr = linkPtr;
    2222    }
    2323
    24     bool Next()
     24    bool next()
    2525    {
    2626        if (_linkPtr == NULL) {
    2727            return false;
    2828        }
    29         _linkPtr = _linkPtr->Next();
     29        _linkPtr = _linkPtr->next();
    3030        return (_linkPtr != NULL);
    3131    }
    3232
    33     float GetValue()
     33    float getValue()
    3434    {
    3535        union {
     
    3737            void *clientData;
    3838        } value;
    39         value.clientData = _linkPtr->GetValue();
     39        value.clientData = _linkPtr->getValue();
    4040        return value.x;
    4141    }
     
    7171            delete [] _ticks;
    7272        }
    73         _chain.Reset();
    74     }
    75 
    76     void SetTicks(float *ticks, int nTicks)
     73        _chain.reset();
     74    }
     75
     76    void setTicks(float *ticks, int nTicks)
    7777    {
    7878        _ticks = ticks, _numTicks = nTicks;
     
    9292    }
    9393
    94     void Reset()
    95     {
    96         _chain.Reset();
     94    void reset()
     95    {
     96        _chain.reset();
    9797    }
    9898
     
    102102    }
    103103
    104     void Append (float x)
    105     {
    106         _chain.Append(GetClientData(x));
    107     }
    108 
    109     void SetValues(double initial, double step, unsigned int nSteps)
     104    void append (float x)
     105    {
     106        _chain.append(getClientData(x));
     107    }
     108
     109    void setValues(double initial, double step, unsigned int nSteps)
    110110    {
    111111        _initial = initial, _step = step, _nSteps = nSteps;
     
    117117    }
    118118
    119     void SweepTicks()
     119    void sweepTicks()
    120120    {
    121121        if (_autoscale) {
     
    123123                delete [] _ticks;
    124124            }
    125             SetTicks();
    126         }
    127     }
    128 
    129     bool FirstTick(TickIter &iter)
     125            setTicks();
     126        }
     127    }
     128
     129    bool firstTick(TickIter &iter)
    130130    {
    131131        ChainLink *linkPtr;
    132132
    133         linkPtr = _chain.FirstLink();
    134         iter.SetStartingLink(linkPtr);
     133        linkPtr = _chain.firstLink();
     134        iter.setStartingLink(linkPtr);
    135135        return (linkPtr != NULL);
    136136    }
     
    139139
    140140private:
    141     void SetTicks();    /**< Routine used internally to create the array
     141    void setTicks();    /**< Routine used internally to create the array
    142142                                 * of ticks as defined by a given sweep. */
    143     void *GetClientData(float x)
     143    void *getClientData(float x)
    144144    {
    145145        union {
     
    212212    }
    213213
    214     void ResetRange();
    215 
    216     void FixRange(double min, double max);
    217 
    218     void SetScale(double min, double max);
     214    void resetRange();
     215
     216    void fixRange(double min, double max);
     217
     218    void setScale(double min, double max);
    219219
    220220    double scale()
     
    228228    }
    229229
    230     bool FirstMajor(TickIter& iter)
    231     {
    232         return _major.FirstTick(iter);
    233     }
    234 
    235     bool FirstMinor(TickIter& iter)
    236     {
    237         return _minor.FirstTick(iter);
    238     }
    239 
    240     void GetDataLimits(double& min, double& max)
     230    bool firstMajor(TickIter& iter)
     231    {
     232        return _major.firstTick(iter);
     233    }
     234
     235    bool firstMinor(TickIter& iter)
     236    {
     237        return _minor.firstTick(iter);
     238    }
     239
     240    void getDataLimits(double& min, double& max)
    241241    {
    242242        min = _valueMin, max = _valueMax;
    243243    }
    244244
    245     double Map(double x);
    246 
    247     double InvMap(double x);
     245    double map(double x);
     246
     247    double invMap(double x);
    248248
    249249    const char *name()
     
    306306    }
    307307
    308     void SetLimits(double min, double max)
     308    void setLimits(double min, double max)
    309309    {
    310310        _reqMin = min, _reqMax = max;
    311311    }
    312312
    313     void UnsetLimits()
     313    void unsetLimits()
    314314    {
    315315        min(NAN), max(NAN);
    316316    }
    317317
    318     void SetDescendingOption(bool value)
     318    void setDescendingOption(bool value)
    319319    {
    320320        if (value) {
     
    325325    }
    326326
    327     void SetTightMinOption(bool value)
     327    void setTightMinOption(bool value)
    328328    {
    329329        if (value) {
     
    334334    }
    335335
    336     void SetTightMaxOption(bool value)
     336    void setTightMaxOption(bool value)
    337337    {
    338338        if (value) {
     
    343343    }
    344344
    345     void SetLogScaleOption(bool value)
     345    void setLogScaleOption(bool value)
    346346    {
    347347        if (value) {
     
    352352    }
    353353
    354     void SetMajorStepOption(double value)
     354    void setMajorStepOption(double value)
    355355    {
    356356        _reqStep = value;       // Setting to 0.0 resets step to "auto"
    357357    }
    358358
    359     void SetNumMinorTicksOption(int n)
     359    void setNumMinorTicksOption(int n)
    360360    {
    361361        _minor.reqNumTicks = n;
    362362    }
    363363
    364     void SetNumMajorTicksOption(int n)
     364    void setNumMajorTicksOption(int n)
    365365    {
    366366        _major.reqNumTicks = n;
     
    368368
    369369private:
    370     void LogScale();
    371 
    372     void LinearScale();
    373 
    374     bool InRange(double x);
    375 
    376     void MakeTicks();
     370    void logScale();
     371
     372    void linearScale();
     373
     374    bool inRange(double x);
     375
     376    void makeTicks();
    377377
    378378    const char *_name;          /**< Name of the axis. Malloc-ed */
  • trunk/packages/vizservers/nanovis/Chain.cpp

    r2798 r2923  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /*
    3  * Chain.cpp --
    4  *
    5  * The module implements a generic linked list package.
    6  *
    7  *      Copyright 1991-2004 George A Howlett.
    8  *
    9  *      Permission is hereby granted, free of charge, to any person obtaining
    10  *      a copy of this software and associated documentation files (the
    11  *      "Software"), to deal in the Software without restriction, including
    12  *      without limitation the rights to use, copy, modify, merge, publish,
    13  *      distribute, sublicense, and/or sell copies of the Software, and to
    14  *      permit persons to whom the Software is furnished to do so, subject to
    15  *      the following conditions:
    16  *
    17  *      The above copyright notice and this permission notice shall be
    18  *      included in all copies or substantial portions of the Software.
    19  *
    20  *      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    21  *      EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    22  *      MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    23  *      NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    24  *      LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    25  *      OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    26  *      WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    27  */
    28 
     2/* The module implements a generic linked list package.
     3 *
     4 * Copyright 1991-2004 George A Howlett.
     5 *
     6 * Permission is hereby granted, free of charge, to any person obtaining
     7 * a copy of this software and associated documentation files (the
     8 * "Software"), to deal in the Software without restriction, including
     9 * without limitation the rights to use, copy, modify, merge, publish,
     10 * distribute, sublicense, and/or sell copies of the Software, and to
     11 * permit persons to whom the Software is furnished to do so, subject to
     12 * the following conditions:
     13 *
     14 * The above copyright notice and this permission notice shall be
     15 * included in all copies or substantial portions of the Software.
     16 *
     17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     24 */
    2925#include <stdlib.h>
    3026#include <stdio.h>
     27
    3128#include "Chain.h"
    3229
    3330typedef int (QSortCompareProc) (const void *, const void *);
    3431
    35 /*
    36  *----------------------------------------------------------------------
    37  *
    38  * Reset --
    39  *
    40  *      Removes all the links from the chain, freeing the memory for each
    41  *      link.  Memory pointed to by the link (clientData) is not freed.  It's
    42  *      the caller's responsibility to deallocate it.
    43  *
    44  * Results:
    45  *      None.
    46  *
    47  *----------------------------------------------------------------------
    48  */
    49 void
    50 Chain::Reset() /* Chain to clear */
     32/**
     33 * Removes all the links from the chain, freeing the memory for each
     34 * link.  Memory pointed to by the link (clientData) is not freed.  It's
     35 * the caller's responsibility to deallocate it.
     36 */
     37void
     38Chain::reset()
    5139{
    5240    ChainLink *oldPtr;
     
    5543    while (linkPtr != NULL) {
    5644        oldPtr = linkPtr;
    57         linkPtr = linkPtr->Next();
     45        linkPtr = linkPtr->next();
    5846        delete oldPtr;
    5947    }
    60     Init();
    61 }
    62 
    63 /*
    64  *----------------------------------------------------------------------
    65  *
    66  * LinkAfter --
    67  *
    68  *      Inserts a link after another link.  If afterPtr is NULL, then the new
    69  *      link is prepended to the beginning of the chain.
    70  *
    71  * Results:
    72  *      None.
    73  *
    74  *----------------------------------------------------------------------
    75  */
    76 void
    77 Chain::LinkAfter(ChainLink *linkPtr, ChainLink *afterPtr)
     48    init();
     49}
     50
     51/**
     52 * Inserts a link after another link.  If afterPtr is NULL, then the new
     53 * link is prepended to the beginning of the chain.
     54 */
     55void
     56Chain::linkAfter(ChainLink *linkPtr, ChainLink *afterPtr)
    7857{
    7958    if (_head == NULL) {
     
    8766            _head = linkPtr;
    8867        } else {
    89             linkPtr->_next = afterPtr->Next();
     68            linkPtr->_next = afterPtr->next();
    9069            linkPtr->_prev = afterPtr;
    9170            if (afterPtr == _tail) {
    9271                _tail = linkPtr;
    9372            } else {
    94                 afterPtr->Next()->_prev = linkPtr;
     73                afterPtr->next()->_prev = linkPtr;
    9574            }
    9675            afterPtr->_next = linkPtr;
     
    10079}
    10180
    102 /*
    103  *----------------------------------------------------------------------
    104  *
    105  * LinkBefore --
    106  *
    107  *      Inserts a new link preceding a given link in a chain.  If beforePtr is
    108  *      NULL, then the new link is placed at the beginning of the list.
    109  *
    110  * Results:
    111  *      None.
    112  *
    113  *----------------------------------------------------------------------
    114  */
    115 void
    116 Chain::LinkBefore(
    117     ChainLink *linkPtr,         /* New entry to be inserted */
    118     ChainLink *beforePtr)       /* Entry to link before */
     81/**
     82 * Inserts a new link preceding a given link in a chain.  If beforePtr is
     83 * NULL, then the new link is placed at the beginning of the list.
     84 *
     85 * \param linkPtr New entry to be inserted
     86 * \param beforePtr Entry to link before
     87 */
     88void
     89Chain::linkBefore(ChainLink *linkPtr,
     90                  ChainLink *beforePtr)
    11991{
    12092    if (_head == NULL) {
     
    12294    } else {
    12395        if (beforePtr == NULL) {
    124             /* Append to the end of the chain. */
     96            // Append to the end of the chain.
    12597            linkPtr->_next = NULL;
    12698            linkPtr->_prev = _tail;
     
    128100            _tail = linkPtr;
    129101        } else {
    130             linkPtr->_prev = beforePtr->Prev();
     102            linkPtr->_prev = beforePtr->prev();
    131103            linkPtr->_next = beforePtr;
    132104            if (beforePtr == _head) {
    133105                _head = linkPtr;
    134106            } else {
    135                 beforePtr->Prev()->_next = linkPtr;
     107                beforePtr->prev()->_next = linkPtr;
    136108            }
    137109            beforePtr->_prev = linkPtr;
     
    141113}
    142114
    143 /*
    144  *----------------------------------------------------------------------
    145  *
    146  * Unlink --
    147  *
    148  *      Unlinks a link from the chain. The link is not deallocated,
    149  *      but only removed from the chain.
    150  *
    151  * Results:
    152  *      None.
    153  *
    154  *----------------------------------------------------------------------
    155  */
    156 void
    157 Chain::Unlink(ChainLink *linkPtr)
     115/**
     116 * Unlinks a link from the chain. The link is not deallocated,
     117 * but only removed from the chain.
     118 */
     119void
     120Chain::unlink(ChainLink *linkPtr)
    158121{
    159122    bool unlinked;              /* Indicates if the link is actually removed
     
    162125    unlinked = false;
    163126    if (_head == linkPtr) {
    164         _head = linkPtr->Next();
     127        _head = linkPtr->next();
    165128        unlinked = true;
    166129    }
    167130    if (_tail == linkPtr) {
    168         _tail = linkPtr->Prev();
    169         unlinked = true;
    170     }
    171     if (linkPtr->Next() != NULL) {
    172         linkPtr->Next()->_prev = linkPtr->Prev();
    173         unlinked = true;
    174     }
    175     if (linkPtr->Prev() != NULL) {
    176         linkPtr->Prev()->_next = linkPtr->Next();
     131        _tail = linkPtr->prev();
     132        unlinked = true;
     133    }
     134    if (linkPtr->next() != NULL) {
     135        linkPtr->next()->_prev = linkPtr->prev();
     136        unlinked = true;
     137    }
     138    if (linkPtr->prev() != NULL) {
     139        linkPtr->prev()->_next = linkPtr->next();
    177140        unlinked = true;
    178141    }
     
    183146}
    184147
    185 /*
    186  *----------------------------------------------------------------------
    187  *
    188  * DeleteLink --
    189  *
    190  *      Unlinks and frees the given link from the chain.  It's assumed that
    191  *      the link belong to the chain. No error checking is performed to verify
    192  *      this.
    193  *
    194  * Results:
    195  *      None.
    196  *
    197  *----------------------------------------------------------------------
    198  */
    199 void
    200 Chain::DeleteLink(ChainLink *linkPtr)
    201 {
    202     Unlink(linkPtr);
     148/**
     149 * Unlinks and frees the given link from the chain.  It's assumed that
     150 * the link belong to the chain. No error checking is performed to verify
     151 * this.
     152 */
     153void
     154Chain::deleteLink(ChainLink *linkPtr)
     155{
     156    unlink(linkPtr);
    203157    delete linkPtr;
    204158}
    205159
    206 /*
    207  *----------------------------------------------------------------------
    208  *
    209  * Append --
    210  *
    211  *      Creates and new link with the given data and appends it to the end of
    212  *      the chain.
    213  *
    214  * Results:
    215  *      Returns a pointer to the link created.
    216  *
    217  *----------------------------------------------------------------------
     160/**
     161 * Creates and new link with the given data and appends it to the end of
     162 * the chain.
     163 *
     164 * \return a pointer to the link created.
    218165 */
    219166ChainLink *
    220 Chain::Append(void *clientData)
     167Chain::append(void *clientData)
    221168{
    222169    ChainLink *linkPtr;
    223170
    224171    linkPtr = new ChainLink(clientData);
    225     LinkBefore(linkPtr, (ChainLink *)NULL);
     172    linkBefore(linkPtr, (ChainLink *)NULL);
    226173    return linkPtr;
    227174}
    228175
    229 /*
    230  *----------------------------------------------------------------------
    231  *
    232  * Prepend --
    233  *
    234  *      Creates and new link with the given data and prepends it to beginning
    235  *      of the chain.
    236  *
    237  * Results:
    238  *      Returns a pointer to the link created.
    239  *
    240  *----------------------------------------------------------------------
     176/**
     177 * Creates and new link with the given data and prepends it to beginning
     178 * of the chain.
     179 *
     180 * \return a pointer to the link created.
    241181 */
    242182ChainLink  *
    243 Chain::Prepend(void *clientData)
     183Chain::prepend(void *clientData)
    244184{
    245185    ChainLink *linkPtr;
    246186
    247187    linkPtr = new ChainLink(clientData);
    248     LinkAfter(linkPtr, (ChainLink *)NULL);
     188    linkAfter(linkPtr, (ChainLink *)NULL);
    249189    return linkPtr;
    250190}
    251191
    252 /*
    253  *----------------------------------------------------------------------
    254  *
    255  * GetNthLink --
    256  *
    257  *      Find the link at the given position in the chain.
    258  *
    259  * Results:
    260  *      Returns the pointer to the link, if that numbered link
    261  *      exists. Otherwise NULL.
    262  *
    263  *----------------------------------------------------------------------
     192/**
     193 * Find the link at the given position in the chain.
     194 *
     195 * \param position Index of link to select from front or back of the chain.
     196 *
     197 * \return  the pointer to the link, if that numbered link
     198 * exists. Otherwise NULL.
    264199 */
    265200ChainLink *
    266 Chain::GetNthLink(long position) /* Index of link to select from front or back
    267                                   * of the chain. */
    268 {
    269     ChainLink *linkPtr;
    270 
    271     for (linkPtr = _head; linkPtr != NULL; linkPtr = linkPtr->Next()) {
     201Chain::getNthLink(long position)
     202{
     203    ChainLink *linkPtr;
     204
     205    for (linkPtr = _head; linkPtr != NULL; linkPtr = linkPtr->next()) {
    272206        if (position == 0) {
    273207            return linkPtr;
     
    278212}
    279213
    280 /*
    281  *----------------------------------------------------------------------
    282  *
    283  * Sort --
    284  *
    285  *      Sorts the chain according to the given comparison routine. 
    286  *
    287  * Results:
    288  *      None.
     214/**
     215 * Sorts the chain according to the given comparison routine. 
    289216 *
    290217 * Side Effects:
    291  *      The chain is reordered.
    292  *
    293  *----------------------------------------------------------------------
    294  */
    295 
    296 void
    297 Chain::Sort(ChainCompareProc *proc)
     218 *   The chain is reordered.
     219 */
     220void
     221Chain::sort(ChainCompareProc *proc)
    298222{
    299223    ChainLink *linkPtr;
     
    308232    }
    309233    i = 0;
    310     for (linkPtr = _head; linkPtr != NULL; linkPtr = linkPtr->Next()) {
     234    for (linkPtr = _head; linkPtr != NULL; linkPtr = linkPtr->next()) {
    311235        linkArr[i++] = linkPtr;
    312236    }
     
    320244    for (i = 1; i < _nLinks; i++) {
    321245        linkPtr->_next = linkArr[i];
    322         linkPtr->Next()->_prev = linkPtr;
    323         linkPtr = linkPtr->Next();
     246        linkPtr->next()->_prev = linkPtr;
     247        linkPtr = linkPtr->next();
    324248    }
    325249    _tail = linkPtr;
     
    327251    delete [] linkArr;
    328252}
    329 
  • trunk/packages/vizservers/nanovis/Chain.h

    r2798 r2923  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    22/*
    3  * Chain.h --
     3 * Copyright 1993-2004 George A Howlett.
    44 *
    5  *      Copyright 1993-2004 George A Howlett.
     5 * Permission is hereby granted, free of charge, to any person obtaining
     6 * a copy of this software and associated documentation files (the
     7 * "Software"), to deal in the Software without restriction, including
     8 * without limitation the rights to use, copy, modify, merge, publish,
     9 * distribute, sublicense, and/or sell copies of the Software, and to
     10 * permit persons to whom the Software is furnished to do so, subject to
     11 * the following conditions:
    612 *
    7  *      Permission is hereby granted, free of charge, to any person obtaining
    8  *      a copy of this software and associated documentation files (the
    9  *      "Software"), to deal in the Software without restriction, including
    10  *      without limitation the rights to use, copy, modify, merge, publish,
    11  *      distribute, sublicense, and/or sell copies of the Software, and to
    12  *      permit persons to whom the Software is furnished to do so, subject to
    13  *      the following conditions:
     13 * The above copyright notice and this permission notice shall be
     14 * included in all copies or substantial portions of the Software.
    1415 *
    15  *      The above copyright notice and this permission notice shall be
    16  *      included in all copies or substantial portions of the Software.
    17  *
    18  *      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    19  *      EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    20  *      MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    21  *      NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    22  *      LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    23  *      OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    24  *      WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    2523 */
    26 #ifndef _CHAIN_H
    27 #define _CHAIN_H
     24#ifndef CHAIN_H
     25#define CHAIN_H
    2826
    29 /*
    30  * A ChainLink is the container structure for the Chain.
     27/**
     28 * \brief A ChainLink is the container structure for the Chain.
    3129 */
    32 class ChainLink {
     30class ChainLink
     31{
     32public:
     33    ChainLink()
     34    {
     35        _clientData = NULL;
     36        _next = _prev = NULL;
     37    }
     38
     39    ChainLink(void *clientData)
     40    {
     41        _clientData = clientData;
     42         _next = _prev = NULL;
     43    }
     44
     45    void *getValue()
     46    {
     47        return _clientData;
     48    }
     49
     50    void setValue(void *clientData)
     51    {
     52        _clientData = clientData;
     53    }
     54
     55    ChainLink *next()
     56    {
     57        return _next;
     58    }
     59
     60    ChainLink *prev()
     61    {
     62        return _prev;
     63    }
     64
    3365    friend class Chain;
     66
    3467private:
    35     ChainLink *_prev;           /* Link to the previous link */
    36     ChainLink *_next;           /* Link to the next link */
    37     void *_clientData;          /* Pointer to the data object */
    38 public:
    39     ChainLink(void) {
    40         _clientData = NULL;
    41         _next = _prev = NULL;
    42     }
    43     ChainLink(void *clientData) {
    44         _clientData = clientData;
    45         _next = _prev = NULL;
    46     }
    47     void *GetValue(void) {
    48         return _clientData;
    49     }
    50     void SetValue(void *clientData) {
    51         _clientData = clientData;
    52     }
    53     ChainLink *Next(void) {
    54         return _next;
    55     }
    56     ChainLink *Prev(void) {
    57         return _prev;
    58     }
     68    ChainLink *_prev;  ///< Link to the previous link
     69    ChainLink *_next;  ///< Link to the next link
     70    void *_clientData; ///< Pointer to the data object
    5971};
    6072
    6173typedef int (ChainCompareProc) (ChainLink *l1Ptr, ChainLink *l2Ptr);
    6274
    63 /*
    64  * A Chain is a doubly linked list structure.
     75/**
     76 * \brief A Chain is a doubly linked list structure.
    6577 */
    66 class Chain {
     78class Chain
     79{
     80public:
     81    Chain()
     82    {
     83        init();
     84    }
     85    ~Chain()
     86    {
     87        reset();
     88    }
     89
     90    void init()
     91    {
     92        _nLinks = 0;
     93        _head = _tail = NULL;
     94    }
     95
     96    ChainLink *append(void *clientData);
     97
     98    ChainLink *prepend(void *clientData);
     99
     100    ChainLink *getNthLink(long position);
     101
     102    void linkBefore(ChainLink *linkPtr, ChainLink *beforePtr);
     103
     104    void linkAfter(ChainLink *linkPtr, ChainLink *afterPtr);
     105
     106    void deleteLink(ChainLink *linkPtr);
     107
     108    void unlink(ChainLink *linkPtr);
     109
     110    void reset();
     111
     112    void sort(ChainCompareProc *proc);
     113
     114    long getLength()
     115    {
     116        return _nLinks;
     117    }
     118
     119    ChainLink *firstLink()
     120    {
     121        return _head;
     122    }
     123
     124    ChainLink *lastLink()
     125    {
     126        return _tail;
     127    }
     128
     129    void appendLink(ChainLink *linkPtr)
     130    {
     131        linkBefore(linkPtr, (ChainLink *)NULL);
     132    }
     133
     134    void prependLink(ChainLink *linkPtr)
     135    {
     136        linkAfter(linkPtr, (ChainLink *)NULL);
     137    }
     138
    67139private:
    68     ChainLink *_head;           /* Pointer to first element in chain */
    69     ChainLink *_tail;           /* Pointer to last element in chain */
    70     long _nLinks;               /* Number of elements in chain */
    71 public:
    72     Chain(void) {
    73         Init();
    74     }
    75     ~Chain(void) {
    76         Reset();
    77     }
    78     void Init(void) {
    79         _nLinks = 0;
    80         _head = _tail = NULL;
    81     }
    82     ChainLink *Append(void *clientData);
    83     ChainLink *Prepend(void *clientData);
    84     ChainLink *GetNthLink(long position);
    85     void LinkBefore(ChainLink *linkPtr, ChainLink *beforePtr);
    86     void LinkAfter(ChainLink *linkPtr, ChainLink *afterPtr);
    87     void DeleteLink(ChainLink *linkPtr);
    88     void Unlink(ChainLink *linkPtr);
    89     void Reset(void);
    90     void Sort(ChainCompareProc *proc);
    91     long GetLength(void)   {
    92         return _nLinks;
    93     }
    94     ChainLink *FirstLink(void) {
    95         return _head;
    96     }
    97     ChainLink *LastLink(void) {
    98         return _tail;
    99     }
    100     void AppendLink(ChainLink *linkPtr) {
    101         LinkBefore(linkPtr, (ChainLink *)NULL);
    102     }
    103     void PrependLink(ChainLink *linkPtr) {
    104         LinkAfter(linkPtr, (ChainLink *)NULL);
    105     }
     140    ChainLink *_head; ///< Pointer to first element in chain
     141    ChainLink *_tail; ///< Pointer to last element in chain
     142    long _nLinks;     ///< Number of elements in chain
    106143};
    107144
    108 #endif /* _CHAIN_H */
     145#endif
  • trunk/packages/vizservers/nanovis/Grid.cpp

    r2871 r2923  
    6565        TickIter iter;
    6666
    67         for (result = xAxis.FirstMajor(iter); result; result = iter.Next()) {
     67        for (result = xAxis.firstMajor(iter); result; result = iter.next()) {
    6868            float x;
    69             x = xAxis.Map(iter.GetValue());
     69            x = xAxis.map(iter.getValue());
    7070            glVertex3f(x, 0.0f, 0.0f);
    7171            glVertex3f(x, 1.0f, 0.0f);
     
    7373            glVertex3f(x, 0.0f, 1.0f + GRID_TICK);
    7474        }
    75         for (result = yAxis.FirstMajor(iter); result; result = iter.Next()) {
     75        for (result = yAxis.firstMajor(iter); result; result = iter.next()) {
    7676            float y;
    77             y = yAxis.Map(iter.GetValue());
     77            y = yAxis.map(iter.getValue());
    7878            glVertex3f(0.0f, y, 0.0f);
    7979            glVertex3f(1.0f + GRID_TICK, y, 0.0f);
     
    8181            glVertex3f(0.0f, y, 1.0f);
    8282        }
    83         for (result = zAxis.FirstMajor(iter); result; result = iter.Next()) {
     83        for (result = zAxis.firstMajor(iter); result; result = iter.next()) {
    8484            float z;
    85             z = zAxis.Map(iter.GetValue());
     85            z = zAxis.map(iter.getValue());
    8686            glVertex3f(0.0f, 0.0f, z);
    8787            glVertex3f(0.0f, 1.0f, z);
     
    101101        TickIter iter;
    102102
    103         for (result = xAxis.FirstMinor(iter); result; result = iter.Next()) {
     103        for (result = xAxis.firstMinor(iter); result; result = iter.next()) {
    104104            float x;
    105             x = xAxis.Map(iter.GetValue());
     105            x = xAxis.map(iter.getValue());
    106106            glVertex3f(x, 0.0f, 0.0f);
    107107            glVertex3f(x, 1.0f, 0.0f);
     
    109109            glVertex3f(x, 0.0f, 1.0f);
    110110        }
    111         for (result = yAxis.FirstMinor(iter); result; result = iter.Next()) {
     111        for (result = yAxis.firstMinor(iter); result; result = iter.next()) {
    112112            float y;
    113             y = yAxis.Map(iter.GetValue());
     113            y = yAxis.map(iter.getValue());
    114114            glVertex3f(0.0f, y, 0.0f);
    115115            glVertex3f(1.0f, y, 0.0f);
     
    117117            glVertex3f(0.0f, y, 1.0f);
    118118        }
    119         for (result = zAxis.FirstMinor(iter); result; result = iter.Next()) {
     119        for (result = zAxis.firstMinor(iter); result; result = iter.next()) {
    120120            float z;
    121             z = zAxis.Map(iter.GetValue());
     121            z = zAxis.map(iter.getValue());
    122122            glVertex3f(0.0f, 0.0f, z);
    123123            glVertex3f(0.0f, 1.0f, z);
     
    172172        glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
    173173
    174         for (result = xAxis.FirstMajor(iter); result; result = iter.Next()) {
     174        for (result = xAxis.firstMajor(iter); result; result = iter.next()) {
    175175            float x;
    176             x = xAxis.Map(iter.GetValue());
     176            x = xAxis.map(iter.getValue());
    177177            if (gluProject(x, 0.0f, 1.06f, mv, prjm, viewport, &wx, &wy, &wz)) {
    178178                char buff[20];
    179179                glLoadIdentity();
    180180                glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f);
    181                 sprintf(buff, "%.*g", NUMDIGITS, iter.GetValue());
     181                sprintf(buff, "%.*g", NUMDIGITS, iter.getValue());
    182182                _font->draw(buff);
    183183            }
    184184        }
    185         for (result = yAxis.FirstMajor(iter); result; result = iter.Next()) {
     185        for (result = yAxis.firstMajor(iter); result; result = iter.next()) {
    186186            float y;
    187             y = yAxis.Map(iter.GetValue());
     187            y = yAxis.map(iter.getValue());
    188188            if (gluProject(1.06f, y, 0.0f, mv, prjm, viewport, &wx, &wy, &wz)) {
    189189                char buff[20];
    190190                glLoadIdentity();
    191191                glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f);
    192                 sprintf(buff, "%.*g", NUMDIGITS, iter.GetValue());
     192                sprintf(buff, "%.*g", NUMDIGITS, iter.getValue());
    193193                _font->draw(buff);
    194194            }
    195195        }
    196         for (result = zAxis.FirstMajor(iter); result; result = iter.Next()) {
     196        for (result = zAxis.firstMajor(iter); result; result = iter.next()) {
    197197            float z;
    198             z = zAxis.Map(iter.GetValue());
     198            z = zAxis.map(iter.getValue());
    199199            if (gluProject(1.06f, 0.0f, z, mv, prjm, viewport, &wx, &wy, &wz)) {
    200200                char buff[20];
    201201                glLoadIdentity();
    202202                glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f);
    203                 sprintf(buff, "%.*g", NUMDIGITS, iter.GetValue());
     203                sprintf(buff, "%.*g", NUMDIGITS, iter.getValue());
    204204                _font->draw(buff);
    205205            }
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r2920 r2923  
    14891489    }
    14901490    if ((xMin < DBL_MAX) && (xMax > -DBL_MAX)) {
    1491         grid->xAxis.SetScale(xMin, xMax);
     1491        grid->xAxis.setScale(xMin, xMax);
    14921492    }
    14931493    if ((yMin < DBL_MAX) && (yMax > -DBL_MAX)) {
    1494         grid->yAxis.SetScale(yMin, yMax);
     1494        grid->yAxis.setScale(yMin, yMax);
    14951495    }
    14961496    if ((zMin < DBL_MAX) && (zMax > -DBL_MAX)) {
    1497         grid->zAxis.SetScale(zMin, zMax);
     1497        grid->zAxis.setScale(zMin, zMax);
    14981498    }
    14991499    if ((wMin < DBL_MAX) && (wMax > -DBL_MAX)) {
     
    15441544    }
    15451545    if ((xMin < DBL_MAX) && (xMax > -DBL_MAX)) {
    1546         grid->xAxis.SetScale(xMin, xMax);
     1546        grid->xAxis.setScale(xMin, xMax);
    15471547    }
    15481548    if ((yMin < DBL_MAX) && (yMax > -DBL_MAX)) {
    1549         grid->yAxis.SetScale(yMin, yMax);
     1549        grid->yAxis.setScale(yMin, yMax);
    15501550    }
    15511551    if ((zMin < DBL_MAX) && (zMax > -DBL_MAX)) {
    1552         grid->zAxis.SetScale(zMin, zMax);
     1552        grid->zAxis.setScale(zMin, zMax);
    15531553    }
    15541554    if ((wMin < DBL_MAX) && (wMax > -DBL_MAX)) {
     
    15791579    if (flags & MAP_FLOWS) {
    15801580        MapFlows();
    1581         grid->xAxis.SetScale(xMin, xMax);
    1582         grid->yAxis.SetScale(yMin, yMax);
    1583         grid->zAxis.SetScale(zMin, zMax);
     1581        grid->xAxis.setScale(xMin, xMax);
     1582        grid->yAxis.setScale(yMin, yMax);
     1583        grid->zAxis.setScale(zMin, zMax);
    15841584    }
    15851585    //assert(glGetError()==0);
Note: See TracChangeset for help on using the changeset viewer.