IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10866


Ignore:
Timestamp:
Jan 1, 2007, 11:03:41 AM (19 years ago)
Author:
magnier
Message:

adding some utility functions

Location:
trunk/psModules/src/extras
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/extras/pmKapaPlots.c

    r10849 r10866  
    77 *  @author EAM, IfA
    88 *
    9  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-12-29 18:29:12 $
     9 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-01-01 21:03:41 $
    1111 *
    1212 *  Copyright 2006 Institute for Astronomy, University of Hawaii
     
    2222// the top portion of this file defines plotting functions which use kapa for plotting.
    2323// if kapa is not available, these functions are defined in the bottom portion as stubs
    24 // which perform NOP and return false (XXX should this be true??)
     24// which perform NOP and return false (XXX should this be 'true' ??)
    2525
    2626# if (HAVE_KAPA)
    27     # include <kapa.h>
    2827
    2928    // XXX not thread safe (perhaps not needed)
    3029    // to make this thread safe, we could check the thread ID and tie to it
    3130    static int kapa_fd = -1;
     31
    3232int pmKapaOpen (bool showWindow)
    3333{
     
    5656}
    5757
     58bool pmKapaPlotVectorPair_AutoLimits_OpenGraph (int kapa, Graphdata *graphdata, psVector *xVec, psVector *yVec)
     59{
     60
     61    // set limits based on data values
     62    graphdata->xmin = FLT_MAX;
     63    graphdata->xmax = FLT_MIN;
     64    graphdata->ymin = FLT_MAX;
     65    graphdata->ymax = FLT_MIN;
     66    for (int i = 0; i < xVec->n; i++) {
     67        graphdata->xmin = PS_MIN (graphdata->xmin, xVec->data.F32[i]);
     68        graphdata->xmax = PS_MAX (graphdata->xmax, xVec->data.F32[i]);
     69        graphdata->ymin = PS_MIN (graphdata->ymin, yVec->data.F32[i]);
     70        graphdata->ymax = PS_MAX (graphdata->ymax, yVec->data.F32[i]);
     71    }
     72    // add 5% to range
     73    float range;
     74
     75    range = graphdata->xmax - graphdata->xmin;
     76    graphdata->xmax += 0.05*range;
     77    graphdata->xmin -= 0.05*range;
     78
     79    range = graphdata->ymax - graphdata->ymin;
     80    graphdata->ymax += 0.05*range;
     81    graphdata->ymin -= 0.05*range;
     82
     83    KapaSetLimits (kapa, graphdata);
     84    KapaSetFont (kapa, "helvetica", 14);
     85    KapaBox (kapa, graphdata);
     86
     87    KapaPrepPlot (kapa, xVec->n, graphdata);
     88    KapaPlotVector (kapa, xVec->n, xVec->data.F32);
     89    KapaPlotVector (kapa, yVec->n, yVec->data.F32);
     90    return true;
     91}
     92
    5893bool pmKapaPlotVectorPair (psVector *xVec, psVector *yVec)
    5994{
     
    71106
    72107    KapaInitGraph (&graphdata);
    73     KapaClear (kapa, FALSE);
     108    KapaClear (kapa, TRUE);
    74109
    75110    // set limits based on data values
     
    111146
    112147# else
     148    # include "pmKapaPlots.h"
    113149
    114150    int pmKapaOpen ()
     
    127163}
    128164
     165bool pmKapaPlotVectorPair_AutoLimits_OpenGraph (int kapa, void *graphdata, psVector *xVec, psVector *yVec)
     166{
     167    return false;
     168}
     169
    129170# endif
  • trunk/psModules/src/extras/pmKapaPlots.h

    r10849 r10866  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-12-29 18:29:12 $
     9*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2007-01-01 21:03:41 $
    1111*
    1212*  Copyright 2006 Institute for Astronomy, University of Hawaii
     
    2121bool pmKapaPlotVectorPair (psVector *xVec, psVector *yVec);
    2222
     23# if (HAVE_KAPA)
     24    # include <kapa.h>
     25
     26    // yes, this is an absurd name...
     27    bool pmKapaPlotVectorPair_AutoLimits_OpenGraph (int kapa, Graphdata *graphdata, psVector *xVec, psVector *yVec);
     28# else
     29
     30    bool pmKapaPlotVectorPair_AutoLimits_OpenGraph (int kapa, void *graphdata, psVector *xVec, psVector *yVec);
     31# endif
     32
    2333#endif // PM_KAPA_PLOTS_H
Note: See TracChangeset for help on using the changeset viewer.