Starlink-AST

 view release on metacpan or  search on metacpan

ast/src/plot.c  view on Meta::CPAN


/* Update the box containing all plotted lines. */
   Box_lbnd[ 0 ] = astMIN( x, Box_lbnd[ 0 ] );
   Box_ubnd[ 0 ] = astMAX( x, Box_ubnd[ 0 ] );
   Box_lbnd[ 1 ] = astMIN( y, Box_lbnd[ 1 ] );
   Box_ubnd[ 1 ] = astMAX( y, Box_ubnd[ 1 ] );

}

static void AxPlot( AstPlot *this, int axis, const double *start, double length,
                    int ink, AstPlotCurveData *cdata, const char *method, const char *class, int *status ){
/*
*
*  Name:
*     AxPlot

*  Purpose:
*     Draw a curve with constant axis value.

*  Type:
*     Private function.

*  Synopsis:
*     #include "plot.h"
*     void AxPlot( AstPlot *this, int axis, const double *start, double length,
*                  int ink, AstPlotCurveData *cdata, const char *method, const char *class, int *status )

*  Class Membership:
*     Plot member function.

*  Description:
*     This function draws a section of a curve of the specified length
*     with constant value on a specified axis in the current Frame of the
*     Plot, starting at the specified position. The algorithm used can handle
*     discontinuities in the Mapping between the current Frame and graphics
*     coordinates, and information describing any breaks in the curve

ast/src/plot.c  view on Meta::CPAN

*        The curve has a varying value on this axis.
*     start
*        A pointer to a an array holding the coordinates of the start of the
*        curve within the current Frame of the Plot.
*     length
*        The length of the section of the curve to be drawn, given as an
*        increment along the axis specified by parameter "axis".
*     ink
*        If zero, the curve is not actually drawn, but information about
*        the breaks is still returned. If non-zero, the curve is also drawn.
*     cdata
*        A pointer to a structure in which to return information about the
*        breaks in the curve.
*     method
*        Pointer to a string holding the name of the calling method.
*        This is only for use in constructing error messages.
*     class
*        Pointer to a string holding the name of the supplied object class.
*        This is only for use in constructing error messages.
*     status
*        Pointer to the inherited status variable.

*  Notes:
*     -  No curve is draw if the "start" array contains any bad values
*     (i.e. values equal to AST__BAD), or if the "length" value is bad,
*     or if a NULL pointer is supplied for "cdata". No errors are reported
*     in these cases.
*/

/* Local Variables: */
   astDECLARE_GLOBALS      /* Pointer to thread-specific global data */
   double d[ CRV_NPNT ];   /* Offsets to evenly spaced points along curve */
   double x[ CRV_NPNT ];   /* X coords at evenly spaced points along curve */
   double y[ CRV_NPNT ];   /* Y coords at evenly spaced points along curve */
   double tol;             /* Absolute tolerance value */
   int i;                  /* Loop count */

ast/src/plot.c  view on Meta::CPAN

/* Get a pointer to the thread specific global data structure. */
   astGET_GLOBALS(this);

#ifdef CRV_TRACE
   printf("AXPLOT: axis %d, start (%.*g,%.*g), length %.*g\n",
          axis, AST__DBL_DIG, start[0], AST__DBL_DIG, start[1], AST__DBL_DIG, length );
   getchar();
#endif


/* Initialise any supplied cdata structure to hold safe values. */
   if( cdata ){
      cdata->length = 0.0;
      cdata->out = 1;
      cdata->nbrk = 0;
   }

/* Get the number of axes in the current Frame. */
   naxes = astGetNout( this );

/* Check the "start" parameter for bad values. */
   ok = 1;
   for( i = 0; i < naxes; i++ ) {
      if( start[ i ] == AST__BAD ){
         ok = 0;
         break;
      }
   }

/* Check the "length" parameter for bad values. */
   if( length == AST__BAD ) ok = 0;

/* Check that the "cdata" pointer can be used. */
   if( !cdata ) ok = 0;

/* Only proceed if the parameters are OK, and there has been no error. */
   if( ok && astOK ){

/* Establish the correct graphical attributes as defined by attributes
   with the supplied Plot. */
      if( axis == 0 ) {
         gridid = AST__GRIDLINE2_ID;
      } else {
         gridid = AST__GRIDLINE1_ID;

ast/src/plot.c  view on Meta::CPAN

      Crv_ux0 = AST__BAD;
      Crv_tol = tol;
      Crv_limit = 0.5*tol*tol;
      Crv_map = Map1;
      Crv_ink = ink;
      Crv_xlo = this->xlo;
      Crv_xhi = this->xhi;
      Crv_ylo = this->ylo;
      Crv_yhi = this->yhi;
      Crv_out = 1;
      Crv_xbrk = cdata->xbrk;
      Crv_ybrk = cdata->ybrk;
      Crv_vxbrk = cdata->vxbrk;
      Crv_vybrk = cdata->vybrk;
      Crv_clip = astGetClip( this ) & 1;

/* Set up a list of points spread evenly over the curve. */
      for( i = 0; i < CRV_NPNT; i++ ){
        d[ i ] = ( (double) i)/( (double) CRV_NSEG );
      }

/* Map these points into graphics coordinates. */
      Map1( CRV_NPNT, d, x, y, method, class, status GLOBALS_NAME );

ast/src/plot.c  view on Meta::CPAN

         } else {
            *(Crv_xbrk++) = (float) Crv_xl;
            *(Crv_ybrk++) = (float) Crv_yl;
            *(Crv_vxbrk++) = (float) -Crv_vxl;
            *(Crv_vybrk++) = (float) -Crv_vyl;
         }
      }

/* Store extra information about the curve in the returned structure, and
   purge any zero length sections. */
      if( cdata ){
         cdata->length = Crv_len;
         cdata->out = Crv_out;
         cdata->nbrk = Crv_nbrk;
         PurgeCdata( cdata, status );
      }

/* Annul the Frame and Mapping. */
      Map1_frame = astAnnul( Map1_frame );
      Map1_map = astAnnul( Map1_map );

/* Re-establish the original graphical attributes. */
      astGrfAttrs( this, gridid, 0, GRF__LINE, method, class );

   }

ast/src/plot.c  view on Meta::CPAN

*     of the Plot is not 2-dimensional or (for a Plot3D) 3-dimensional.
*     - An error also results if the transformation between the base
*     and current Frames of the Plot is not defined (i.e. the Plot's
*     TranForward attribute is zero).
*--
*/

/* Local Variables: */
   astDECLARE_GLOBALS      /* Pointer to thread-specific global data */
   AstPlot *this;          /* Plot with no more than 2 current axes */
   AstPlotCurveData cdata; /* Structure to receive break information */
   const char *class;      /* Object class */
   const char *method;     /* Current method */
   int inval;              /* Were any bad regions found? */
   int naxes;              /* No. of axes in the base Frame */

/* Check the global error status. */
   if ( !astOK ) return 0;

/* Get a pointer to the thread specific global data structure. */
   astGET_GLOBALS(this_nd);

ast/src/plot.c  view on Meta::CPAN

   RESET_GRF;

/* Establish the correct graphical attributes as defined by attributes
   with the supplied Plot. */
   astGrfAttrs( this, AST__BORDER_ID, 1, GRF__LINE, method, class );

/* We first draw the intersections of the regions containing valid
   physical coordinates with the edges of the plotting area. First do
   the bottom edge. */
   LinePlot( this, this->xlo, this->ylo, this->xhi, this->ylo,
             1, &cdata, method, class, status );

/* Now do the right-hand edge. */
   LinePlot( this, this->xhi, this->ylo, this->xhi, this->yhi,
             1, &cdata, method, class, status );

/* Now do the top edge. */
   LinePlot( this, this->xhi, this->yhi, this->xlo, this->yhi,
             1, &cdata, method, class, status );

/* Now do the left-hand edge. */
   LinePlot( this, this->xlo, this->yhi, this->xlo, this->ylo,
             1, &cdata, method, class, status );

/* Now draw a curve following the boundary through the interior of the
   plotting area. If the current Frame in the Plot is a Region, we use a
   shorter method if possible. If this is not possible, we use a longer
   method. */
   inval = Boundary( this, method, class, status );

/* Ensure all lines are flushed to the graphics system. */
   Fpoly( this, method, class, status );

ast/src/plot.c  view on Meta::CPAN

         c--;
         ret--;
      }
   }

/* Return the answer. */
   return ret;

}

static AstPlotCurveData **CleanCdata( AstPlotCurveData **cdata, int *status ){
/*
*  Name:
*     CleanCdata

*  Purpose:
*     Release the structures holding curve break information.

*  Type:
*     Private function.

*  Synopsis:
*     #include "plot.h"
*     AstPlotCurveData **CleanCdata( AstPlotCurveData **cdata, int *status )

*  Class Membership:
*     Plot member function.

*  Description:
*     This function releases the memory used to hold the curve break
*     information returned by function DrawGrid, and returns a NULL pointer.

*  Parameters:
*     cdata
*        Pointer to the information to be freed.
*     status
*        Pointer to the inherited status variable.

*  Returned Value:
*     A NULL pointer.

*  Notes:
*     -  This function attempts to execute even if an error has already
*     occurred.

*/

/* Return if a NULL pointer has been supplied. */
   if( !cdata ) return NULL;

/* Release each of the two structures in turn (if they exist). */
   (void) astFree( (void *) cdata[ 0 ] );
   (void) astFree( (void *) cdata[ 1 ] );

/* Release the memory used to hold the two AstPlotCurveData pointers. */
   (void) astFree( (void *) cdata );

/* Return. */
   return NULL;

}

static TickInfo **CleanGrid( TickInfo **grid, int *status ){
/*
*  Name:
*     CleanGrid

ast/src/plot.c  view on Meta::CPAN

   CurvePlot( this, start, finish, 1, &Curve_data, method, class, status );

/* Ensure all lines are flushed to the graphics system. */
   Fpoly( this, method, class, status );

/* Return. */
   return;
}

static void CurvePlot( AstPlot *this, const double *start, const double *finish,
                     int ink, AstPlotCurveData *cdata, const char *method,
                     const char *class, int *status ){
/*
*
*  Name:
*     CurvePlot

*  Purpose:
*     Draw a geodesic curve.

*  Type:
*     Private function.

*  Synopsis:
*     #include "plot.h"
*     void CurvePlot( AstPlot *this, const double *start, const double *finish,
*                   int ink, AstPlotCurveData *cdata, const char *method,
*                   const char *class, int *status )

*  Class Membership:
*     Plot member function.

*  Description:
*     This function draws a geodesic curve between the supplied starting and
*     finishing positions. The algorithm used can handle discontinuities in the
*     Mapping between the current Frame and graphics coordinates, and
*     information describing any breaks in the curve (including the start and

ast/src/plot.c  view on Meta::CPAN

*        Pointer to the Plot.
*     start
*        A pointer to a an array holding the coordinates of the start of the
*        curve within the current Frame of the Plot.
*     finish
*        A pointer to a an array holding the coordinates of the finish of the
*        curve within the current Frame of the Plot.
*     ink
*        If zero, the curve is not actually drawn, but information about
*        the breaks is still returned. If non-zero, the curve is also drawn.
*     cdata
*        A pointer to a structure in which to return information about the
*        breaks in the curve.
*     method
*        Pointer to a string holding the name of the calling method.
*        This is only for use in constructing error messages.
*     class
*        Pointer to a string holding the name of the supplied object class.
*        This is only for use in constructing error messages.
*     status
*        Pointer to the inherited status variable.

*  Notes:
*     -  No curve is draw if the "start" or "finish" arrays contains any bad
*     values, or if a NULL pointer is supplied for "cdata". No errors are
*     reported in these cases.
*/

/* Local Variables: */
   astDECLARE_GLOBALS      /* Pointer to thread-specific global data */
   double d[ CRV_NPNT ];   /* Offsets to evenly spaced points along curve */
   double x[ CRV_NPNT ];   /* X coords at evenly spaced points along curve */
   double y[ CRV_NPNT ];   /* Y coords at evenly spaced points along curve */
   double tol;             /* Absolute tolerance value */
   int i;                  /* Loop count */

ast/src/plot.c  view on Meta::CPAN


/* Check the "start" and "finish" parameter for bad values. */
   ok = 1;
   for( i = 0; i < naxes; i++ ) {
      if( start[ i ] == AST__BAD || finish[ i ] == AST__BAD ){
         ok = 0;
         break;
      }
   }

/* Check that the "cdata" pointer can be used. */
   if( !cdata ) ok = 0;

/* Only proceed if the parameters are OK, and there has been no error. */
   if( ok && astOK ){

/* Establish the correct graphical attributes as defined by attributes
   with the supplied Plot. */
      astGrfAttrs( this, AST__CURVE_ID, 1, GRF__LINE, method, class );

/* Ensure the globals holding the scaling from graphics coords to equally
   scaled coords are available. */

ast/src/plot.c  view on Meta::CPAN

      Crv_ux0 = AST__BAD;
      Crv_tol = tol;
      Crv_limit = 0.5*tol*tol;
      Crv_map = Map3;
      Crv_ink = ink;
      Crv_xlo = this->xlo;
      Crv_xhi = this->xhi;
      Crv_ylo = this->ylo;
      Crv_yhi = this->yhi;
      Crv_out = 1;
      Crv_xbrk = cdata->xbrk;
      Crv_ybrk = cdata->ybrk;
      Crv_vxbrk = cdata->vxbrk;
      Crv_vybrk = cdata->vybrk;
      Crv_clip = astGetClip( this ) & 1;

/* Set up a list of points spread evenly over the curve. */
      for( i = 0; i < CRV_NPNT; i++ ){
        d[ i ] = ( (double) i)/( (double) CRV_NSEG );
      }

/* Map these points into graphics coordinates. */
      Map3( CRV_NPNT, d, x, y, method, class, status GLOBALS_NAME );

ast/src/plot.c  view on Meta::CPAN

         } else {
            *(Crv_xbrk++) = (float) Crv_xl;
            *(Crv_ybrk++) = (float) Crv_yl;
            *(Crv_vxbrk++) = (float) -Crv_vxl;
            *(Crv_vybrk++) = (float) -Crv_vyl;
         }
      }

/* Store extra information about the curve in the returned structure, and
   purge any zero length sections. */
      if( cdata ){
         cdata->length = Crv_len;
         cdata->out = Crv_out;
         cdata->nbrk = Crv_nbrk;
         PurgeCdata( cdata, status );
      }

/* Annul the Frame and Mapping. */
      Map3_frame = astAnnul( Map3_frame );
      Map3_map = astAnnul( Map3_map );

/* Re-establish the original graphical attributes. */
      astGrfAttrs( this, AST__CURVE_ID, 0, GRF__LINE, method, class );

   }

ast/src/plot.c  view on Meta::CPAN

*        Pointer to the inherited status variable.

*  Notes:
*     -  This function assumes the current Frame of the Plot is 2
*     dimensional, and it should not be called if this is not the case.

*/

/* Local Variables: */
   AstFrame *frm;         /* Pointer to current Frame */
   AstPlotCurveData cdata;/* Somewhere to put the unneeded curve information */
   TickInfo *info;        /* Pointer to the TickInfo for the current axis */
   double *value;         /* Current tick value */
   double bot;            /* Lowest axis value to be displayed */
   double diff;           /* Difference between adjacent tick marks */
   double udiff;          /* Used section length */
   double start[ 2 ];     /* The start of the curve in physical coordinates */
   double tmp;            /* Temporary storage */
   double top;            /* Highest axis value to be displayed */
   int axis;              /* Current axis index */
   int axisid;            /* ID value for current axis plotting attributes */

ast/src/plot.c  view on Meta::CPAN

               start[ 1 - axis ] = labelat[ axis ];

/* If this is the first tick, draw an axis section going "backwards" in
   case the first tick isn't at the lower visible bound. Limit the length
   of this backwards section so that it does not extend beyond the minimum
   axis value. */
               if( tick == 0 ) {
                  udiff = *value - bot;
                  if( udiff > diff ) udiff = diff;
                  if( udiff > 0.0 ) {
                     AxPlot( this, axis, start, -udiff, 1, &cdata, method,
                             class, status );
                  }
               }

/* Limit the length of the section so that it does not extend beyond the
   maximum axis value. */
               udiff = ( *value + diff > top ) ? top - *value : diff;

/* Do not draw zero length sections. */
               if( udiff > 0.0 ) {

/* Draw a curve parallel to the current axis, starting at the tick mark,
   with length equal to the gap between tick marks. Do not draw sections
   of the curve which are outside the primary domains of the physical axes. */
                  AxPlot( this, axis, start, udiff, 1, &cdata, method,
                          class, status );
               }

            }

/* Once the last section has been drawn, draw another axis section in case the
   last tick isn't at the upper visible bound. Limit the length of this
   section so that it does not extend beyond the maximum axis value. */
            udiff = top - start[ axis ];
            if( udiff > diff ) udiff = diff;
            if( udiff > 0.0 ) {
               AxPlot( this, axis, start, udiff, 1, &cdata, method,
                       class, status );
            }
         }
      }

/* Re-establish the original graphical attributes. */
      astGrfAttrs( this, axisid, 0, GRF__LINE, method, class );

/* Set up the id value for the next axis. */
      axisid = AST__AXIS2_ID;

ast/src/plot.c  view on Meta::CPAN


*  Notes:
*     -  This function assumes that the physical coordinate system is 2
*     dimensional, and it should not be used if this is not the case.
*     -  If an error has already occurred, or if this function should fail
*     for any reason, then a NULL pointer is returned.

*/

/* Local Variables: */
   AstPlotCurveData **cdata;/* The returned pointer */
   AstPlotCurveData *cdt;   /* Pointer to break info. for current tick mark */
   AstPlotCurveData tcdt;   /* Pointer to break info. for current curve section */
   TickInfo *info;          /* Tick mark information for a single axis */
   double start[ 2 ];       /* Strting position for current curve section */
   double total_length;     /* Total curve length for all axis ticks */
   int i;                   /* Axis index */
   int j;                   /* Tick mark index */
   int k;                   /* Curve section index */

/* Check the global status. */
   if( !astOK ) return NULL;

/* Allocate memory to hold two pointers, each pointing to an array of
   AstPlotCurveData structure. */
   cdata = (AstPlotCurveData **) astMalloc( 2*sizeof( AstPlotCurveData *) );

/* If succesful, initialise the pointers. */
   if( astOK ){
      cdata[ 0 ] = NULL;
      cdata[ 1 ] = NULL;

/* Draw the curves marking the major tick values on each axis. If no grid is
   required, we still do this in order to get information about the breaks
   in the curves which will be used later to decide where to put the labels,
   but we use "invisible ink". */
      for( i = 0; i < 2; i++ ){

/* Get a pointer to the TickInfo structure for this axis holding information
   about where to put tick marks on this axis. */
         info = grid[ i ];

/* Allocate memory to hold information describing the breaks in each tick
   mark curve. This takes the form of an array of AstPlotCurveData structures,
   one for each tick mark. */
         cdata[ i ] = (AstPlotCurveData *) astMalloc( sizeof(AstPlotCurveData)*
                                               (size_t) info->nmajor );

/* Check the pointer can be used. */
         if( astOK ){

/* Initialise a pointer to the first AstPlotCurveData structure for this axis. */
            cdt = cdata[ i ];
            total_length = 0.0;

/* Do each tick mark. */
            for( j = 0; j < info->nmajor; j++ ){

/* Store the starting point of the first section of the curve. */
               start[ i ] = (info->ticks)[ j ];
               start[ 1 - i ] = (info->start)[ 0 ];

/* Draw the first section of the curve parallel to the other axis, starting

ast/src/plot.c  view on Meta::CPAN

                         "axis %d.", status, method, class, i + 1 );
            }

         }

      }

   }

/* If an error has occurred, clean up the returned structures. */
   if( !astOK ) cdata = CleanCdata( cdata, status );

/* Return. */
   return cdata;

}

static int DrawRegion( AstPlot *this, AstFrame *frm, const char *method,
                       const char *class, int *status ){
/*
*
*  Name:
*     DrawRegion

ast/src/plot.c  view on Meta::CPAN

*     status
*        Pointer to the inherited status variable.

*  Returned Value:
*     Non-zero if and only if a Region outline was drawn.

*/

/* Local Variables: */
   AstMapping *map;        /* Mapping with Region masking included */
   AstPlotCurveData cdata; /* Stores information about curve breaks */
   AstRegion **comps;      /* List of component Regions */
   astDECLARE_GLOBALS      /* Pointer to thread-specific global data */
   double d[ CRV_NPNT ];   /* Offsets to evenly spaced points along curve */
   double tol;             /* Absolute tolerance value */
   double x[ CRV_NPNT ];   /* X coords at evenly spaced points along curve */
   double y[ CRV_NPNT ];   /* Y coords at evenly spaced points along curve */
   int i;                  /* Loop count */
   int icomp;              /* Index of component Region */
   int ncomp;              /* Number of component Regions */
   int result;             /* The returned value */

ast/src/plot.c  view on Meta::CPAN

      Crv_ux0 = AST__BAD;
      Crv_tol = 2*tol;
      Crv_limit = 0.5*tol*tol;
      Crv_map = Map5;
      Crv_ink = 1;
      Crv_xlo = this->xlo;
      Crv_xhi = this->xhi;
      Crv_ylo = this->ylo;
      Crv_yhi = this->yhi;
      Crv_out = 1;
      Crv_xbrk = cdata.xbrk;
      Crv_ybrk = cdata.ybrk;
      Crv_vxbrk = cdata.vxbrk;
      Crv_vybrk = cdata.vybrk;
      Crv_clip = astGetClip( this ) & 1;

/* Attempt to split the Region into a set of disjoint component Regions. */
      comps = astRegSplit( (AstRegion *) frm, &ncomp );

/* Draw each one. */
      for( icomp = 0; icomp < ncomp; icomp++ ) {

/* A pointer to the Region. */
         Map5_region = comps[ icomp ];

ast/src/plot.c  view on Meta::CPAN

*/

/* Check the global error status. */
   if ( !astOK ) return;

/* Invoke the active GRF EBuf function. */
   GEBuf( this, "astEBuf", astGetClass( this ), status );
}

static int EdgeLabels( AstPlot *this, int ink, TickInfo **grid,
                       AstPlotCurveData **cdata, int force, const char *method,
                       const char *class, int *status ){
/*
*
*  Name:
*     EdgeLabels

*  Purpose:
*     Attempts to display labels for the major tick values around the edges
*     of the plotting area.

*  Type:
*     Private function.

*  Synopsis:
*     #include "plot.h"
*     int EdgeLabels( AstPlot *this, int ink, TickInfo **grid,
*                     AstPlotCurveData **cdata, int force, const char *method,
*                     const char *class, int *status )

*  Class Membership:
*     Plot member function.

*  Description:
*     This function determines how many major tick value labels could be
*     placed on the specified edges of the plotting area, and then if
*     requested, and if sufficient such labels are found (more than 3 on
*     each axis), they are drawn. To place a label on an edge, the curve

ast/src/plot.c  view on Meta::CPAN

*     this
*        A pointer to the Plot.
*     ink
*        If zero, then no labels are drawn, but the decision whether or
*        not to draw them is still made and indicated in the returned function
*        value.
*     grid
*        A pointer to an array of two TickInfo pointers (one for each axis),
*        each pointing to a TickInfo structure holding information about
*        tick marks on the axis. See function GridLines.
*     cdata
*        A pointer to an array of two AstPlotCurveData pointers (one for each axis),
*        each pointing to an array of AstPlotCurveData structure (one for each
*        major tick value on the axis), holding information about breaks
*        in the curves drawn to mark the major tick values. See function
*        DrawGrid.
*     force
*        If non-zero, then an attempt is made to draw edge labels even if
*        it looks like insufficient edge labels can be produced.
*     method
*        Pointer to a string holding the name of the calling method.

ast/src/plot.c  view on Meta::CPAN


      }

/* Get a pointer to the structure containing information describing the
   positions of the major tick marks along this axis. */
      info = grid[ axis ];

/* Get a pointer to the structure containing information describing the
   breaks in the curve which is parallel to the other axis and passes
   through the first major tick mark. */
      cdt = cdata[ axis ];

/* Initialise the pointer to the list of text strings to be drawn. */
      labellist = NULL;

/* Initialise the number of labels which can be placed on the near edge of
   the plotting zone (some of which may be the same). */
      naxlab = 0;

/* Initialise the number of distinct labelled tick mark values. */
      maxlab = 0;

ast/src/plot.c  view on Meta::CPAN

*     - An error also results if the transformation between the base
*     and current Frames of the Plot is not defined in either
*     direction (i.e. the Plot's TranForward or TranInverse attribute
*     is zero).
*--
*/

/* Local Variables: */
   astDECLARE_GLOBALS      /* Pointer to thread-specific global data */
   AstPlot *this;          /* Plot with 2d current Frame */
   AstPlotCurveData **cdata;/* Pointer to info. about breaks in curves */
   TickInfo **grid;        /* Pointer to info. about tick marks */
   const char *class;      /* Object class */
   const char *method;     /* Current method */
   double cen[ 2 ];        /* Position of first tick mark */
   double gap[ 2 ];        /* Gap between tick marks */
   double labelat[ 2 ];    /* Axis values at which tick marks are put */
   int axis;               /* Physical axis index */
   int border;             /* Draw a border? */
   int clip;               /* Original Clip attribute value */
   int dounits[2];         /* Include Units in each axis label? */

ast/src/plot.c  view on Meta::CPAN

   invalid regions. */
   } else if( inval ){
      drawgrid = 1;

   } else {
      drawgrid = 0;
   }

/* Draw the curves marking the major tick values on each axis. Information
   is returned describing the positions of the breaks in these curves. */
   cdata = DrawGrid( this, grid, ( ink && drawgrid ), method, class, status );

/* See if labels and tick marks will be drawn round the edges of the
   plotting area, rather than within it (no labels are actually drawn
   yet). Interior labels can always be produced, in which case edgeticks
   is set explicitly to zero to indicate that ticks will be internal.
   Exterior labelling may or may not be possible. If it is requested,
   check to see if it is possible. */
   clredge = 0;
   labelling = astGetLabelling( this );
   if( labelling ){
      edgeticks = 0;
   } else {
      edgeticks = EdgeLabels( this, 0, grid, cdata, 0, method, class, status );

/* If the external labelling was requested, but could not be produced... */
      if( !edgeticks ) {

/* and if the Edge attributes have not been set... */
         if( !astTestEdge( this, 0 ) && !astTestEdge( this, 1 ) ) {

/* Try flipping the default Edge values, to see if this allows us to
   honour the requested Labelling scheme. */
            oldedge0 = astGetEdge( this, 0 );
            oldedge1 = astGetEdge( this, 1 );
            astSetEdge( this, 0, oldedge1 );
            astSetEdge( this, 1, oldedge0 );

/* See if exterior labels could be drawn with these new edges. */
            edgeticks = EdgeLabels( this, 0, grid, cdata, 0, method, class, status );

/* If this would allow us to use the requested labelling scheme, retain
   the new Edge values, setting a flag to indicate that they will need to be
   cleared before returning. Otherwise, clear them. */
            if( edgeticks ) {
               clredge = 1;

            } else {
               astClearEdge( this, 0 );
               astClearEdge( this, 1 );
            }
         }
      }
   }

/* If edge ticks can still not be produced, but the ForceExterior attribute
   has a non-zero value, attempt to create exterior labels even though it
   looks like there may be insufficient of them to justify their use. */
   if( !edgeticks && astGetForceExterior( this ) ) {
      edgeticks = EdgeLabels( this, 0, grid, cdata, 1, method, class, status );
   }

/* We may also need to swap edge values when using interior labelling in
   order to ensure that the text labels are placed on appropriate edges of
   the plotting box. */
   if( !edgeticks && !astTestEdge( this, 0 ) && !astTestEdge( this, 1 ) ) {
      if( swapEdges( this, grid, cdata, status ) ) {
         oldedge0 = astGetEdge( this, 0 );
         oldedge1 = astGetEdge( this, 1 );
         astSetEdge( this, 0, oldedge1 );
         astSetEdge( this, 1, oldedge0 );
         clredge = 1;
      }
   }

/* If edge ticks are being used, store bad values for the labelat values to
   indicate that labels are not being drawn within the interior of the
   plotting area. */
   if( edgeticks ){
      labelat[ 0 ] = AST__BAD;
      labelat[ 1 ] = AST__BAD;

/* Otherwise, see where interior labels and tick marks should go (the axis
   values are put in "labelat"). */
   } else {
      useint = Labelat( this, grid, cdata, labelat, method, class, status );

/* If interior labelling does not allow us to draw any more ticks, revert
   to edge labelling if that is what the user requested. */
      if( !useint && !labelling ) {
         labelat[ 0 ] = AST__BAD;
         labelat[ 1 ] = AST__BAD;
         edgeticks = EdgeLabels( this, 0, grid, cdata, 1, method, class, status );
      }
   }

/* See if a border is required. By default, a border is drawn only when
   using exterior labelling. */
   if( astTestBorder( this ) ) {
      border = astGetBorder( this );
   } else {
      border = edgeticks;
   }

ast/src/plot.c  view on Meta::CPAN

      DrawTicks( this, grid, drawgrid, labelat, gap, method, class, status );

/* If required, ensure that curves through the tick marks have been drawn */
      DrawAxis( this, grid, labelat, gap, method, class, status );

/* If required, draw a curve around the edge of the area containing valid
   physical coordinates. */
      if( border ) (void) astBorder( this );

/* Draw the numerical labels at the major tick values. */
      Labels( this, grid, cdata, gap, labelat, method, class, status );

/* Draw the textual labels for each axis and a title. */
      TextLabels( this, edgeticks, dounits, method, class, status );
   }

/* Ensure all lines are flushed to the graphics system. */
   Fpoly( this, method, class, status );

/* Store the actual values used for all attributes which have dynamic
   defaults. Check the global status to ensure the pointer "grid" can be

ast/src/plot.c  view on Meta::CPAN

                                           astGetMajTickLen( this, axis ), status );
      }

   }

   SetUsedGrid( this_nd, drawgrid, status );
   SetUsedLabelling( this_nd, edgeticks ? 0 : 1, status );
   SetUsedBorder( this_nd, border, status );

/* Free the memory used to hold information about the curves. */
   cdata = CleanCdata( cdata, status );

/* Free the memory used to hold information about the tick marks. */
   grid = CleanGrid( grid, status );

/* If required clear attributes. */
   if( clredge ) {
      astClearEdge( this, 0 );
      astClearEdge( this, 1 );
   }

ast/src/plot.c  view on Meta::CPAN


         *x0 -= f*uxu;
         *y0 -= f*uyu;
      }
   }

/* Return the result. */
   return result;
}

static int Labelat( AstPlot *this, TickInfo **grid, AstPlotCurveData **cdata,
                    double *labelat, const char *method, const char *class,
                    int *status ){
/*
*
*  Name:
*     Labelat

*  Purpose:
*     Determine the other axis value at which to place interior labels
*     and tick marks.

*  Type:
*     Private function.

*  Synopsis:
*     #include "plot.h"
*     int Labelat( AstPlot *this, TickInfo **grid, AstPlotCurveData **cdata,
*                  double *labelat, const char *method, const char *class )

*  Class Membership:
*     Plot member function.

*  Description:
*     If tick marks and labels are to be placed within the plotting area,
*     the tick values stored in "grid" determine their position on one
*     axis, and their position on the other axis is determined by this
*     function. If a value has been set for the "LabelAt" attribute, then

ast/src/plot.c  view on Meta::CPAN

*     independent, in which case there is nothing to be gained by using
*     interior labelling.

*  Parameters:
*     this
*        A pointer to the Plot.
*     grid
*        A pointer to an array of two TickInfo pointers (one for each axis),
*        each pointing to a TickInfo structure holding information about
*        tick values on the axis. See function GridLines.
*     cdata
*        A pointer to an array of two AstPlotCurveData pointers (one for each axis),
*        each pointing to an array of AstPlotCurveData structure (one for each
*        major tick value on the axis), holding information about breaks
*        in the curves drawn to mark the major tick values. See function
*        DrawGrid.
*     labelat
*        A pointer to a 2 element array in which to store the constant axis
*        values at which tick marks are put. Element 0 is returned holding
*        the axis 1 value at which tick marks for axis 0 are placed. Element
*        1 is returned holding the axis 0 value at which tick marks for axis

ast/src/plot.c  view on Meta::CPAN

/* Get a pointer to the other axis value at the first other axis major tick
   mark. */
      value = info->ticks;

/* Get a limit on absolute magnitude for an axis value to be consider
   equal to zero. */
      lim = 1.0E-6*fabs( value[ 1 ] - value [ 0 ] );

/* Get a pointer to the structure containing information describing the
   breaks in the curve which passes through the first major tick mark. */
      cdt = cdata[ 1 - axis ];

/* Initialise the effective length of the longest and shortest curves, and
   the curve passing through the origin. */
      maxlen = -1.0;
      minlen = DBL_MAX;
      zerolen = 0.0;
      labelat[ axis ] = AST__BAD;

/* Loop round each of the major tick marks on the other axis. */
      for( tick = 0; tick < info->nmajor && astOK; tick++ ){

ast/src/plot.c  view on Meta::CPAN

      if( pset[ axis ] ) pset[ axis ] = astAnnul( pset[ axis ] );
      if( tvals[ axis ] ) tvals[ axis ] = (double *) astFree( (void *) tvals[ axis ] );
   }
   mapping = astAnnul( mapping );

/* Return. */
   return result;

}

static void Labels( AstPlot *this, TickInfo **grid, AstPlotCurveData **cdata,
                    double *gap, double *labelat, const char *method,
                    const char *class, int *status ){
/*
*
*  Name:
*     Labels

*  Purpose:
*     Draw numerical axis labels for a 2-D annotated coordinate grid.

*  Type:
*     Private function.

*  Synopsis:
*     #include "plot.h"
*     void Labels( AstPlot *this, TickInfo **grid, AstPlotCurveData **cdata,
*                  double *gap, double *labelat, const char *method,
*                  const char *class, int *status )

*  Class Membership:
*     Plot member function.

*  Description:
*     The policy for placing labels for the major tick values is broadly as
*     follows: if possible, labels for a given physical axis are placed on
*     one edge of the plotting area, at the place where the curve for a

ast/src/plot.c  view on Meta::CPAN

*     of that curve with the longest of the curves representing the major
*     tick values on the other axis.

*  Parameters:
*     this
*        A pointer to the Plot.
*     grid
*        A pointer to an array of two TickInfo pointers (one for each axis),
*        each pointing to a TickInfo structure holding information about
*        tick values on the axis. See function GridLines.
*     cdata
*        A pointer to an array of two AstPlotCurveData pointers (one for each axis),
*        each pointing to an array of AstPlotCurveData structure (one for each
*        major tick value on the axis), holding information about breaks
*        in the curves drawn to mark the major tick values. See function
*        DrawGrid.
*     gap
*        Pointer to array of two values holding the gap between major
*        tick values on the two axes.
*     labelat
*        A pointer to a 2 element array holding the constant axis

ast/src/plot.c  view on Meta::CPAN


/* See if escape sequences in text strings are to be interpreted */
   esc = astGetEscape( this );

/* Empty the list of bounding boxes kept by the Overlap function. */
   (void) Overlap( this, 0, 0, NULL, 0.0, 0.0, NULL, 0.0, 0.0, NULL,
                   method, class, status );

/* If required, draw the labels around the edges of the plotting area. */
   if( labelat[ 0 ] == AST__BAD || labelat[ 1 ] == AST__BAD ){
      (void) EdgeLabels( this, 1, grid, cdata, 1, method, class, status );

/* Otherwise, draw labels within the interior of the plotting area. */
   } else {

/* Find the scale factors for the two axes which scale graphics coordinates
   into a "standard" equal scaled coordinate system in which: 1) the axes
   have equal scale in terms of (for instance) millimetres per unit distance,
   2) X values increase from left to right, 3) Y values increase from bottom
   to top. */
      GScales( this, &alpha, &beta, method, class, status );

ast/src/plot.c  view on Meta::CPAN

      frame = astAnnul( frame );

   }

/* Return. */
   return;

}

static void LinePlot( AstPlot *this, double xa, double ya, double xb,
                      double yb, int ink, AstPlotCurveData *cdata,
                      const char *method, const char *class, int *status ){
/*
*
*  Name:
*     LinePlot

*  Purpose:
*     Draws a straight line omitting bad regions.

*  Type:
*     Private function.

*  Synopsis:
*     #include "plot.h"
*     void LinePlot( AstPlot *this, double xa, double ya, double xb,
*                    double yb, int ink, AstPlotCurveData *cdata,
*                    const char *method, const char *class, int *status )

*  Class Membership:
*     Plot member function.

*  Description:
*     This function draws a straight line between two positions in graphics
*     coordinates but leaves gaps in the line where it passes through
*     regions which have no corresponding physical coordinates.

ast/src/plot.c  view on Meta::CPAN

*        The graphics X coordinate at the start of the line.
*     ya
*        The graphics Y coordinate at the start of the line.
*     xb
*        The graphics X coordinate at the end of the line.
*     yb
*        The graphics Y coordinate at the end of the line.
*     ink
*        If zero, the line is not actually drawn, but information about
*        the breaks is still returned. If non-zero, the line is also drawn.
*     cdata
*        A pointer to a structure in which to return information about the
*        breaks in the line.
*     method
*        Pointer to a string holding the name of the calling method.
*        This is only for use in constructing error messages.
*     class
*        Pointer to a string holding the name of the supplied object class.
*        This is only for use in constructing error messages.
*     status
*        Pointer to the inherited status variable.

*  Notes:
*     -  No curve is draw if any of the start or end positions are bad
*     (i.e. equal to AST__BAD), or if a NULL pointer is supplied for "cdata".
*     No errors are reported in these cases.
*/

/* Local Variables: */
   astDECLARE_GLOBALS      /* Pointer to thread-specific global data */
   double d[ CRV_NPNT ];   /* Offsets to evenly spaced points along curve */
   double x[ CRV_NPNT ];   /* X coords at evenly spaced points along curve */
   double y[ CRV_NPNT ];   /* Y coords at evenly spaced points along curve */
   double tol;             /* Absolute tolerance value */
   int i;                  /* Loop count */

/* Check the global error status. */
   if ( !astOK ) return;

/* Get a pointer to the thread specific global data structure. */
   astGET_GLOBALS(this);

/* Check the supplied values are usable. */
   if( xa == AST__BAD || ya == AST__BAD ||
       xb == AST__BAD || yb == AST__BAD ||
      !cdata ) return;

/* Convert the tolerance from relative to absolute graphics coordinates. */
   tol = astGetTol( this )*astMAX( this->xhi - this->xlo, this->yhi - this->ylo );

/* Ensure the globals holding the scaling from graphics coords to equally
   scaled coords are available. */
   GScales( this, NULL, NULL, method, class, status );

/* Set up the external variables used by the Crv and CrvLine function (see
   their prologues for details). */

ast/src/plot.c  view on Meta::CPAN

   Crv_limit = 0.5*tol*tol;
   Crv_tol = tol;
   Crv_map = Map2;
   Crv_ink = ink;
   Crv_len = 0.0F;
   Crv_xlo = this->xlo;
   Crv_xhi = this->xhi;
   Crv_ylo = this->ylo;
   Crv_yhi = this->yhi;
   Crv_out = 1;
   Crv_xbrk = cdata->xbrk;
   Crv_ybrk = cdata->ybrk;
   Crv_vxbrk = cdata->vxbrk;
   Crv_vybrk = cdata->vybrk;
   Crv_clip = astGetClip( this ) & 1;

/* Create a set of evenly spaced values between 0.0 and 1.0. These are the
   offsets the edge of the plotting zone at which the mapping is tested. */
   for( i = 0; i < CRV_NPNT; i++ ){
     d[ i ] = ( (double) i)/( (double) CRV_NSEG );
   }

/* Now set up the externals used to communicate with the Map2 function.
   Map2 transforms a set of offsets between zero and one into a set of

ast/src/plot.c  view on Meta::CPAN

      } else {
         *(Crv_xbrk++) = (float) Crv_xl;
         *(Crv_ybrk++) = (float) Crv_yl;
         *(Crv_vxbrk++) = (float) -Crv_vxl;
         *(Crv_vybrk++) = (float) -Crv_vyl;
      }
   }

/* Store extra information about the curve in the returned structure, and
   purge any zero length sections. */
   if( cdata ){
      cdata->length = Crv_len;
      cdata->out = Crv_out;
      cdata->nbrk = Crv_nbrk;
      PurgeCdata( cdata, status );
   }

/* Annul the Mapping. */
   Map2_map = astAnnul( Map2_map );

/* Return. */
   return;

}

ast/src/plot.c  view on Meta::CPAN


/* Indicate success.*/
      result = 1;
   }

/* Return the result. */
   return result;

}

static void PurgeCdata( AstPlotCurveData *cdata, int *status ){
/*
*
*  Name:
*     AstPlotCurveData

*  Purpose:
*     Remove any zero length sections from the description of a curve.

*  Type:
*     Private function.

*  Synopsis:
*     #include "plot.h"
*     void PurgeCdata( AstPlotCurveData *cdata )

*  Class Membership:
*     Plot member function.

*  Description:
*     This function removes any zero length sections from the supplied
*     AstPlotCurveData struture, which describes a multi-section curve.

*  Parameters:
*     cdata
*        A pointer to the structure containing information about the
*        breaks in a curve.

*/

/* Local Variables: */
   int brk;                       /*Break index */
   int i;                       /*Break index */

/* Check the global error status. */
   if ( !astOK || !cdata ) return;

/* Loop round all breaks. */
   brk = 0;
   while( brk < cdata->nbrk ) {

/* If this break and the next one are co-incident, remove both breaks. */
      if( cdata->xbrk[ brk ] == cdata->xbrk[ brk + 1 ] &&
          cdata->ybrk[ brk ] == cdata->ybrk[ brk + 1 ] ) {

/* Shuffle down the higher elements of all the arrays in the curve data. */
         for( i = brk + 2; i < cdata->nbrk; i++ ){
            cdata->xbrk[ i - 2 ] = cdata->xbrk[ i ];
            cdata->ybrk[ i - 2 ] = cdata->ybrk[ i ];
            cdata->vxbrk[ i - 2 ] = cdata->vxbrk[ i ];
            cdata->vybrk[ i - 2 ] = cdata->vybrk[ i ];
         }

/*  Decrement the number of breaks in the curve data. */
         cdata->nbrk -= 2;

/* If the section is not zero length, move on to the next pair of breaks. */
      } else {
         brk += 2;
      }
   }
}

static void PushGat( AstPlot *this, float rise, const char *method,
                     const char *class, int *status ) {

ast/src/plot.c  view on Meta::CPAN

      }
   }

/* Terminate the returned string. */
   *b = 0;

/* Return the result.*/
   return stripescapes_buff;
}

static int swapEdges( AstPlot *this, TickInfo **grid, AstPlotCurveData **cdata, int *status ) {
/*
*  Name:
*     swapEdges

*  Purpose:
*     Determine if edges for text labels should be swapped.

*  Type:
*     Private function.

*  Synopsis:
*     #include "plot.h"
*     int swapEdges( AstPlot *this, TickInfo **grid, AstPlotCurveData **cdata, int *status )

*  Class Membership:
*     Plot member function.

*  Description:
*     This function returns a boolean result (0 or 1) to indicate whether
*     or not it is necessary to swap the Edges(0) and Edges(1) attributes
*     in order to place textual labels on appropriate edges. This should
*     only be used if the attributes have not explicitly been set, and if
*     interior labelling is being used. The sides are determines by

ast/src/plot.c  view on Meta::CPAN

*     The label for axis 1 is placed parallel to the shortest side of this
*     bounding box.

*  Parameters:
*     this
*        A pointer to the Plot.
*     grid
*        A pointer to an array of two TickInfo pointers (one for each axis),
*        each pointing to a TickInfo structure holding information about
*        tick marks on the axis. See function GridLines.
*     cdata
*        A pointer to an array of two AstPlotCurveData pointers (one for each axis),
*        each pointing to an array of AstPlotCurveData structure (one for each
*        major tick value on the axis), holding information about breaks
*        in the curves drawn to mark the major tick values. See function
*        DrawGrid.
*     status
*        Pointer to the inherited status variable.

*  Returned Value:
*     One if the edges should be swapped, otherwise zero.

ast/src/plot.c  view on Meta::CPAN

/* Check the global error status. */
   if ( !astOK ) return result;

/* Get a pointer to the structure containing information describing the
   positions of the major tick marks along axis 0. */
   info = grid[ 0 ];

/* Get a pointer to the structure containing information describing
   the breaks in the curve which is parallel to axis 1 and passes
   through the first major tick mark on axis 0. */
   cdt = cdata[ 0 ];

/* Initialise the graphiocs X and Y bounds of the area covered by the
   axis. */
   xmax = -1.0E10;
   xmin = 1.0E10;
   ymax = -1.0E10;
   ymin = 1.0E10;

/* Loop round each of the major tick marks on axis 0. */
   for( tick = 0; cdt && info && tick < info->nmajor; tick++ ){

ast/src/xml.c  view on Meta::CPAN

*     - NULL is returned if NULL pointer is supplied.
*     - NULL is returned if an error has already occurred, or if this
*     function should fail for any reason.
*-
*/


/* Local Variables: */
   AstXmlAttribute *attr;
   AstXmlBlack *black;
   AstXmlCDataSection *cdata;
   AstXmlComment *comm;
   AstXmlDTDec *dtd;
   AstXmlDeclPI *dec;
   AstXmlDocument *doc, *newdoc;
   AstXmlElement *elem, *newelem;
   AstXmlNamespace *ns;
   AstXmlObject *new;
   AstXmlPI *pi;
   AstXmlPrologue *pro, *newpro;
   AstXmlWhite *white;

ast/src/xml.c  view on Meta::CPAN

      InitXmlBlack( (AstXmlBlack *) new, AST__XMLBLACK,
                    black->text, status );

   } else if( type == AST__XMLWHITE ){
      white = (AstXmlWhite *) this;
      new = astMalloc( sizeof( AstXmlWhite ) );
      InitXmlWhite( (AstXmlWhite *) new, AST__XMLWHITE,
                    white->text, status );

   } else if( type == AST__XMLCDATA ){
      cdata = (AstXmlCDataSection *) this;
      new = astMalloc( sizeof( AstXmlCDataSection ) );
      InitXmlCDataSection( (AstXmlCDataSection *) new, AST__XMLCDATA,
                           cdata->text, status );

   } else if( type == AST__XMLCOM ){
      comm = (AstXmlComment *) this;
      new = astMalloc( sizeof( AstXmlComment ) );
      InitXmlComment( (AstXmlComment *) new, AST__XMLCOM,
                      comm->text, status );

   } else if( type == AST__XMLPI ){
      pi = (AstXmlPI *) this;
      new = astMalloc( sizeof( AstXmlPI ) );

ast/src/xml.c  view on Meta::CPAN


*  Notes:
*     This function attempts to execute even if an error has already
*     occurred.
*-
*/

/* Local Variables: */
   AstXmlAttribute *attr;
   AstXmlBlack *black;
   AstXmlCDataSection *cdatasec;
   AstXmlComment *comm;
   AstXmlDTDec *dtd;
   AstXmlDeclPI *dec;
   AstXmlDocument *doc;
   AstXmlElement *elem;
   AstXmlNamespace *ns;
   AstXmlPI *pi;
   AstXmlPrologue *pro;
   AstXmlWhite *white;

ast/src/xml.c  view on Meta::CPAN

      black = (AstXmlBlack *) this;
      black->text = astFree( black->text );
      CleanXml( this, AST__XMLOBJECT, status );

   } else if( type == AST__XMLWHITE ){
      white = (AstXmlWhite *) this;
      white->text = astFree( white->text );
      CleanXml( this, AST__XMLOBJECT, status );

   } else if( type == AST__XMLCDATA ){
      cdatasec = (AstXmlCDataSection *) this;
      cdatasec->text = astFree( cdatasec->text );
      CleanXml( this, AST__XMLOBJECT, status );

   } else if( type == AST__XMLCOM ){
      comm = (AstXmlComment *) this;
      comm->text = astFree( comm->text );
      CleanXml( this, AST__XMLOBJECT, status );

   } else if( type == AST__XMLPI ){
      pi = (AstXmlPI *) this;
      pi->target = astFree( pi->target );

ast/src/xml.c  view on Meta::CPAN

*  Notes:
*     - Empty elements are represented as an start tag of the form <.../>,
*     with no corresponding end tag.
*     - NULL is returned if an error has already occurred, or if this
*     function should fail for any reason.
*-
*/


/* Local Variables: */
   AstXmlCDataSection *cdata;/* Pointer to XML CDATA section */
   AstXmlElement *elem;      /* Pointer to XML element */
   AstXmlComment *com;       /* Pointer to XML comment */
   AstXmlPI *pi;             /* Pointer to XML processing instruction */
   AstXmlDTDec *dtd;         /* Pointer to XML data type declaration */
   AstXmlDeclPI *xmlpi;      /* XML version declaration */
   char *result;             /* The returned pointer */
   const char *temp;         /* A temporary string pointer */
   int i;                    /* Loop count */
   int nc;                   /* Length of returned string */
   int type;                 /* Object type */

ast/src/xml.c  view on Meta::CPAN

         if( dtd->internal && dtd->internal[ 0 ] ) {
            result = astAppendString( result, &nc, " [" );
            result = astAppendString( result, &nc, dtd->internal );
            result = astAppendString( result, &nc, "]" );
         }
         result = astAppendString( result, &nc, ">" );
      }

   } else if( type == AST__XMLCDATA ){
      if( opening ) {
         cdata = (AstXmlCDataSection *) this;
         result = astAppendString( result, &nc, "<![CDATA[" );
         result = astAppendString( result, &nc, cdata->text );
         result = astAppendString( result, &nc, "]]>" );
      }

   } else if( type == AST__XMLCOM ){
      if( opening ) {
         com = (AstXmlComment *) this;
         result = astAppendString( result, &nc, "<!--" );
         result = astAppendString( result, &nc, com->text );
         result = astAppendString( result, &nc, "-->" );
      }

ast/src/xml.h  view on Meta::CPAN

struct AstXmlWhite {
   AstXmlObject obj;          /* General information for this XmlObject */
   char *text;                /* The white character data */
};

/* XmlCDataSection structure. */
/* ----------------------- */
/* Describes an XML CDATA section */
struct AstXmlCDataSection {
   AstXmlObject obj;          /* General information for this XmlObject */
   char *text;                /* The text of the cdata section */
};

/* XmlComment structure. */
/* --------------------- */
/* Describes an XML CDATA section */
struct AstXmlComment {
   AstXmlObject obj;          /* General information for this XmlObject */
   char *text;                /* The text of the comment */
};

lib/Starlink/AST.xs  view on Meta::CPAN

 OUTPUT:
  RETVAL

void
GetMocData( this )
  AstMoc * this
 PREINIT:
  int nb;
  size_t ln;
  size_t mxsize;
  void * cdata;
  AV * data;
 PPCODE:
  nb = astGetI( this, "moctype" );
  ln = astGetI( this, "moclength" );
  mxsize = nb * ln;
  cdata = get_mortalspace( mxsize, 'u' );
  ASTCALL(
    astGetMocData( this, mxsize, cdata );
  )
  if (nb == 4) {
    data = newAV();
    unpack1D(newRV_noinc((SV*) data), cdata, 'i', ln);
    XPUSHs(newRV_noinc((SV*) data));
  }
  else if (nb == 8) {
    data = newAV();
    unpack1D(newRV_noinc((SV*) data), cdata, 'q', ln);
    XPUSHs(newRV_noinc((SV*) data));
  }
  else {
    Perl_croak(aTHX_ "Unexpected byte-length MOC data\n");
  }

void
AddMocData( this, cmode, negate, maxorder, data )
  AstMoc * this
  int cmode
  int negate
  int maxorder
  AV * data
 PREINIT:
  int len;
  int64_t * cdata;
 CODE:
  len = av_len( data ) + 1;
  cdata = pack1D( newRV_noinc((SV*)data), 'q' );
  ASTCALL(
    astAddMocData( this, cmode, negate, maxorder, len, 8, cdata );
  )

void
AddPixelMaskD( this, cmode, wcs, value, oper, flags, badval, array, dims )
  AstMoc * this
  int cmode
  AstFrameSet * wcs
  double value
  int oper
  int flags



( run in 0.386 second using v1.01-cache-2.11-cpan-454fe037f31 )