frame.c   frame.c 
skipping to change at line 269 skipping to change at line 269
* Fixed bug in LineCrossing. * Fixed bug in LineCrossing.
* 18-JUN-2000 (DSB): * 18-JUN-2000 (DSB):
* Added ObsAlt attribute. * Added ObsAlt attribute.
* 28-SEP-2009 (DSB): * 28-SEP-2009 (DSB):
* Added astMatchAxes method. * Added astMatchAxes method.
* 22-MAR-2011 (DSB): * 22-MAR-2011 (DSB):
* Add astFrameGrid method. * Add astFrameGrid method.
* 29-APR-2011 (DSB): * 29-APR-2011 (DSB):
* Prevent astFindFrame from matching a subclass template against a * Prevent astFindFrame from matching a subclass template against a
* superclass target. * superclass target.
* 11-APR-2012 (DSB):
* Change astValidateAxis so that it can permute in either direction.
*class-- *class--
*/ */
/* Module Macros. */ /* Module Macros. */
/* ============== */ /* ============== */
/* Set the name of the class we are implementing. This indicates to /* Set the name of the class we are implementing. This indicates to
the header files that define class interfaces that they should make the header files that define class interfaces that they should make
"protected" symbols available. */ "protected" symbols available. */
#define astCLASS Frame #define astCLASS Frame
skipping to change at line 349 skipping to change at line 351
\ \
/* Private member function. */ \ /* Private member function. */ \
/* ------------------------ */ \ /* ------------------------ */ \
static void Clear##attribute( AstFrame *this, int axis, int *status ) { \ static void Clear##attribute( AstFrame *this, int axis, int *status ) { \
AstAxis *ax; /* Pointer to Axis object */ \ AstAxis *ax; /* Pointer to Axis object */ \
\ \
/* Check the global error status. */ \ /* Check the global error status. */ \
if ( !astOK ) return; \ if ( !astOK ) return; \
\ \
/* Validate the axis index and obtain a pointer to the required Axis. */ \ /* Validate the axis index and obtain a pointer to the required Axis. */ \
(void) astValidateAxis( this, axis, "astClear" #attribute ); \ (void) astValidateAxis( this, axis, 1, "astClear" #attribute ); \
ax = astGetAxis( this, axis ); \ ax = astGetAxis( this, axis ); \
\ \
/* Clear the Axis attribute. */ \ /* Clear the Axis attribute. */ \
astClearAxis##attribute( ax ); \ astClearAxis##attribute( ax ); \
\ \
/* Annul the Axis pointer. */ \ /* Annul the Axis pointer. */ \
ax = astAnnul( ax ); \ ax = astAnnul( ax ); \
} \ } \
\ \
/* External interface. */ \ /* External interface. */ \
skipping to change at line 450 skipping to change at line 452
\ \
/* Initialise. */ \ /* Initialise. */ \
result = (bad_value); \ result = (bad_value); \
\ \
/* Check the global error status. */ \ /* Check the global error status. */ \
if ( !astOK ) return result; \ if ( !astOK ) return result; \
\ \
/* Validate and permute the axis index and obtain a pointer to the required \ /* Validate and permute the axis index and obtain a pointer to the required \
Axis. */ \ Axis. */ \
old_axis = axis; \ old_axis = axis; \
axis = astValidateAxis( this, axis, "astGet" #attribute ); \ axis = astValidateAxis( this, axis, 1, "astGet" #attribute ); \
ax = astGetAxis( this, old_axis ); \ ax = astGetAxis( this, old_axis ); \
\ \
/* Since the Axis is "managed" by the enclosing Frame, we next test if any \ /* Since the Axis is "managed" by the enclosing Frame, we next test if any \
Axis attributes which may affect the result are undefined (i.e. have not \ Axis attributes which may affect the result are undefined (i.e. have not \
been explicitly set). If so, we over-ride them, giving them temporary \ been explicitly set). If so, we over-ride them, giving them temporary \
values dictated by the Frame. Only the Digits attribute is relevant \ values dictated by the Frame. Only the Digits attribute is relevant \
here. */ \ here. */ \
digits_set = astTestAxisDigits( ax ); \ digits_set = astTestAxisDigits( ax ); \
if ( !digits_set ) astSetAxisDigits( ax, astGetDigits( this ) ); \ if ( !digits_set ) astSetAxisDigits( ax, astGetDigits( this ) ); \
\ \
skipping to change at line 553 skipping to change at line 555
\ \
/* Private member function. */ \ /* Private member function. */ \
/* ------------------------ */ \ /* ------------------------ */ \
static void Set##attribute( AstFrame *this, int axis, type value, int *stat us ) { \ static void Set##attribute( AstFrame *this, int axis, type value, int *stat us ) { \
AstAxis *ax; /* Pointer to Axis object */ \ AstAxis *ax; /* Pointer to Axis object */ \
\ \
/* Check the global error status. */ \ /* Check the global error status. */ \
if ( !astOK ) return; \ if ( !astOK ) return; \
\ \
/* Validate the axis index and obtain a pointer to the required Axis. */ \ /* Validate the axis index and obtain a pointer to the required Axis. */ \
(void) astValidateAxis( this, axis, "astSet" #attribute ); \ (void) astValidateAxis( this, axis, 1, "astSet" #attribute ); \
ax = astGetAxis( this, axis ); \ ax = astGetAxis( this, axis ); \
\ \
/* Set the Axis attribute value. */ \ /* Set the Axis attribute value. */ \
astSetAxis##attribute( ax, value ); \ astSetAxis##attribute( ax, value ); \
\ \
/* Annul the Axis pointer. */ \ /* Annul the Axis pointer. */ \
ax = astAnnul( ax ); \ ax = astAnnul( ax ); \
} \ } \
\ \
/* External interface. */ \ /* External interface. */ \
skipping to change at line 632 skipping to change at line 634
/* Private member function. */ \ /* Private member function. */ \
/* ------------------------ */ \ /* ------------------------ */ \
static int Test##attribute( AstFrame *this, int axis, int *status ) { \ static int Test##attribute( AstFrame *this, int axis, int *status ) { \
AstAxis *ax; /* Pointer to Axis object */ \ AstAxis *ax; /* Pointer to Axis object */ \
int result; /* Value to be returned */ \ int result; /* Value to be returned */ \
\ \
/* Check the global error status. */ \ /* Check the global error status. */ \
if ( !astOK ) return 0; \ if ( !astOK ) return 0; \
\ \
/* Validate the axis index and obtain a pointer to the required Axis. */ \ /* Validate the axis index and obtain a pointer to the required Axis. */ \
(void) astValidateAxis( this, axis, "astTest" #attribute ); \ (void) astValidateAxis( this, axis, 1, "astTest" #attribute ); \
ax = astGetAxis( this, axis ); \ ax = astGetAxis( this, axis ); \
\ \
/* Test if the attribute has been set. */ \ /* Test if the attribute has been set. */ \
result = astTestAxis##attribute( ax ); \ result = astTestAxis##attribute( ax ); \
\ \
/* Annul the Axis pointer. */ \ /* Annul the Axis pointer. */ \
ax = astAnnul( ax ); \ ax = astAnnul( ax ); \
\ \
/* If an error occurred, clear the result value. */ \ /* If an error occurred, clear the result value. */ \
if ( !astOK ) result = 0; \ if ( !astOK ) result = 0; \
skipping to change at line 910 skipping to change at line 912
static int TestMatchEnd( AstFrame *, int * ); static int TestMatchEnd( AstFrame *, int * );
static int TestMaxAxes( AstFrame *, int * ); static int TestMaxAxes( AstFrame *, int * );
static int TestMinAxes( AstFrame *, int * ); static int TestMinAxes( AstFrame *, int * );
static int TestPermute( AstFrame *, int * ); static int TestPermute( AstFrame *, int * );
static int TestPreserveAxes( AstFrame *, int * ); static int TestPreserveAxes( AstFrame *, int * );
static int TestSymbol( AstFrame *, int, int * ); static int TestSymbol( AstFrame *, int, int * );
static int TestTitle( AstFrame *, int * ); static int TestTitle( AstFrame *, int * );
static int TestUnit( AstFrame *, int, int * ); static int TestUnit( AstFrame *, int, int * );
static int IsUnitFrame( AstFrame *, int * ); static int IsUnitFrame( AstFrame *, int * );
static int Unformat( AstFrame *, int, const char *, double *, int * ); static int Unformat( AstFrame *, int, const char *, double *, int * );
static int ValidateAxis( AstFrame *, int, const char *, int * ); static int ValidateAxis( AstFrame *, int, int, const char *, int * );
static AstSystemType ValidateSystem( AstFrame *, AstSystemType, const char *, int * ); static AstSystemType ValidateSystem( AstFrame *, AstSystemType, const char *, int * );
static AstSystemType SystemCode( AstFrame *, const char *, int * ); static AstSystemType SystemCode( AstFrame *, const char *, int * );
static const char *SystemString( AstFrame *, AstSystemType, int * ); static const char *SystemString( AstFrame *, AstSystemType, int * );
static void AddUnderscores( char *, int * ); static void AddUnderscores( char *, int * );
static void CheckPerm( AstFrame *, const int *, const char *, int * ); static void CheckPerm( AstFrame *, const int *, const char *, int * );
static void ClearAttrib( AstObject *, const char *, int * ); static void ClearAttrib( AstObject *, const char *, int * );
static void ClearDigits( AstFrame *, int * ); static void ClearDigits( AstFrame *, int * );
static void ClearDirection( AstFrame *, int, int * ); static void ClearDirection( AstFrame *, int, int * );
static void ClearDomain( AstFrame *, int * ); static void ClearDomain( AstFrame *, int * );
static void ClearFormat( AstFrame *, int, int * ); static void ClearFormat( AstFrame *, int, int * );
skipping to change at line 1044 skipping to change at line 1046
const char *result; /* Result pointer to return */ const char *result; /* Result pointer to return */
/* Initialise. */ /* Initialise. */
result = str2; result = str2;
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return result; if ( !astOK ) return result;
/* Validate the axis index and obtain a pointer to the required /* Validate the axis index and obtain a pointer to the required
Axis. */ Axis. */
(void) astValidateAxis( this, axis, "astAbbrev" ); (void) astValidateAxis( this, axis, 1, "astAbbrev" );
ax = astGetAxis( this, axis ); ax = astGetAxis( this, axis );
/* Invoke the Axis astAxisAbbrev method to perform the processing. */ /* Invoke the Axis astAxisAbbrev method to perform the processing. */
result = astAxisAbbrev( ax, fmt, str1, str2 ); result = astAxisAbbrev( ax, fmt, str1, str2 );
/* Annul the Axis pointer. */ /* Annul the Axis pointer. */
ax = astAnnul( ax ); ax = astAnnul( ax );
/* If an error occurred, clear the returned value. */ /* If an error occurred, clear the returned value. */
if ( !astOK ) result = str2; if ( !astOK ) result = str2;
skipping to change at line 1239 skipping to change at line 1241
/* Deal first with 2-dimensional Frames. */ /* Deal first with 2-dimensional Frames. */
if( naxes == 2 ) { if( naxes == 2 ) {
/* Find the angle from +ve Y to the line BA. */ /* Find the angle from +ve Y to the line BA. */
anga = atan2( ab[ 0 ], ab[ 1 ] ); anga = atan2( ab[ 0 ], ab[ 1 ] );
/* Find the angle from +ve Y to the line BC. */ /* Find the angle from +ve Y to the line BC. */
angc = atan2( cb[ 0 ], cb[ 1 ] ); angc = atan2( cb[ 0 ], cb[ 1 ] );
/* Find the difference, folded into the range +/- PI. */ /* Find the difference, folded into the range +/- PI. */
result = palDrange( angc - anga ); result = astDrange( angc - anga );
/* Now deal with Frames with more than 2 axes. */ /* Now deal with Frames with more than 2 axes. */
} else { } else {
/* Form the scalar product of the two vectors. */ /* Form the scalar product of the two vectors. */
sp = 0.0; sp = 0.0;
for( axis = 0; axis < naxes; axis++ ) { for( axis = 0; axis < naxes; axis++ ) {
sp += ab[ axis ]*cb[ axis ]; sp += ab[ axis ]*cb[ axis ];
} }
skipping to change at line 1358 skipping to change at line 1360
int naxes; /* Number of Frame axes */ int naxes; /* Number of Frame axes */
int ok; /* Are values ok to use? */ int ok; /* Are values ok to use? */
/* Initialise. */ /* Initialise. */
result = AST__BAD; result = AST__BAD;
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return result; if ( !astOK ) return result;
/* Validate the axis index. */ /* Validate the axis index. */
(void) astValidateAxis( this, axis - 1, "astAxAngle" ); (void) astValidateAxis( this, axis - 1, 1, "astAxAngle" );
/* Obtain the number of Frame axes. */ /* Obtain the number of Frame axes. */
naxes = astGetNaxes( this ); naxes = astGetNaxes( this );
/* Obtain workspace. */ /* Obtain workspace. */
aa = (double *) astMalloc( sizeof(double)*naxes ); aa = (double *) astMalloc( sizeof(double)*naxes );
/* Create a position which is offset slightly from point A in the /* Create a position which is offset slightly from point A in the
positive direction of the specified axis. Also get the largest absolute positive direction of the specified axis. Also get the largest absolute
value of any component of the vector AB. */ value of any component of the vector AB. */
skipping to change at line 1492 skipping to change at line 1494
AstAxis *ax; /* Pointer to Axis object */ AstAxis *ax; /* Pointer to Axis object */
double result; /* The returned answer */ double result; /* The returned answer */
/* Initialise. */ /* Initialise. */
result = AST__BAD; result = AST__BAD;
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return result; if ( !astOK ) return result;
/* Validate the axis index and obtain a pointer to the required Axis. */ /* Validate the axis index and obtain a pointer to the required Axis. */
(void) astValidateAxis( this, axis - 1, "astAxDistance" ); (void) astValidateAxis( this, axis - 1, 1, "astAxDistance" );
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
/* Use the AxisDistance method associated with the Axis. */ /* Use the AxisDistance method associated with the Axis. */
if( astOK ) result = astAxisDistance( ax, v1, v2 ); if( astOK ) result = astAxisDistance( ax, v1, v2 );
/* Annul the Axis pointer. */ /* Annul the Axis pointer. */
ax = astAnnul( ax ); ax = astAnnul( ax );
/* Return the result. */ /* Return the result. */
return result; return result;
skipping to change at line 1652 skipping to change at line 1654
AstAxis *ax; /* Pointer to Axis object */ AstAxis *ax; /* Pointer to Axis object */
double result; /* The returned answer */ double result; /* The returned answer */
/* Initialise. */ /* Initialise. */
result = AST__BAD; result = AST__BAD;
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return result; if ( !astOK ) return result;
/* Validate the axis index and obtain a pointer to the required Axis. */ /* Validate the axis index and obtain a pointer to the required Axis. */
(void) astValidateAxis( this, axis - 1, "astAxOffset" ); (void) astValidateAxis( this, axis - 1, 1, "astAxOffset" );
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
/* Use the AxisOffset method associated with the Axis. */ /* Use the AxisOffset method associated with the Axis. */
if( astOK ) result = astAxisOffset( ax, v1, dist ); if( astOK ) result = astAxisOffset( ax, v1, dist );
/* Annul the Axis pointer. */ /* Annul the Axis pointer. */
ax = astAnnul( ax ); ax = astAnnul( ax );
/* Return the result. */ /* Return the result. */
return result; return result;
skipping to change at line 1993 skipping to change at line 1995
/* Digits(axis). */ /* Digits(axis). */
/* ------------- */ /* ------------- */
} else if ( nc = 0, } else if ( nc = 0,
( 1 == astSscanf( attrib, "digits(%d)%n", &axis, &nc ) ) ( 1 == astSscanf( attrib, "digits(%d)%n", &axis, &nc ) )
&& ( nc >= len ) ) { && ( nc >= len ) ) {
/* There is no function to clear the Digits attribute for an axis /* There is no function to clear the Digits attribute for an axis
directly, so obtain a pointer to the Axis and use this to clear the directly, so obtain a pointer to the Axis and use this to clear the
attribute. */ attribute. */
(void) astValidateAxis( this, axis - 1, "astClearDigits(axis)" ); (void) astValidateAxis( this, axis - 1, 1, "astClearDigits(axis)" );
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
astClearAxisDigits( ax ); astClearAxisDigits( ax );
ax = astAnnul( ax ); ax = astAnnul( ax );
/* Direction(axis). */ /* Direction(axis). */
/* ---------------- */ /* ---------------- */
} else if ( nc = 0, } else if ( nc = 0,
( 1 == astSscanf( attrib, "direction(%d)%n", &axis, &nc ) ) ( 1 == astSscanf( attrib, "direction(%d)%n", &axis, &nc ) )
&& ( nc >= len ) ) { && ( nc >= len ) ) {
astClearDirection( this, axis - 1 ); astClearDirection( this, axis - 1 );
skipping to change at line 2138 skipping to change at line 2140
/* ---------------------- */ /* ---------------------- */
/* If the attribute was not identified above, but appears to refer to /* If the attribute was not identified above, but appears to refer to
a Frame axis, then it may refer to an Axis object of a derived type a Frame axis, then it may refer to an Axis object of a derived type
(which has additional attributes not recognised here). */ (which has additional attributes not recognised here). */
} else if( !free_axis_attrib && ( nc = 0, } else if( !free_axis_attrib && ( nc = 0,
( 1 == astSscanf( attrib, "%*[^()]%n(%d)%n", ( 1 == astSscanf( attrib, "%*[^()]%n(%d)%n",
&axis_nc, &axis, &nc ) ) &axis_nc, &axis, &nc ) )
&& ( nc >= len ) ) ) { && ( nc >= len ) ) ) {
/* Validate the axis index and extract the attribute name. */ /* Validate the axis index and extract the attribute name. */
(void) astValidateAxis( this, axis - 1, "astClear" ); (void) astValidateAxis( this, axis - 1, 1, "astClear" );
axis_attrib = astString( attrib, axis_nc ); axis_attrib = astString( attrib, axis_nc );
/* Obtain a pointer to the Axis object. */ /* Obtain a pointer to the Axis object. */
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
if( astOK ) { if( astOK ) {
/* Assume that we will be able to use the attribute name. */ /* Assume that we will be able to use the attribute name. */
used = 1; used = 1;
/* Temporarily switch off error reporting so that if the following attempt /* Temporarily switch off error reporting so that if the following attempt
skipping to change at line 2172 skipping to change at line 2174
if( astStatus == AST__BADAT ) { if( astStatus == AST__BADAT ) {
astClearStatus; astClearStatus;
/* Find the primary Frame containing the specified axis. */ /* Find the primary Frame containing the specified axis. */
astPrimaryFrame( this, axis - 1, &pfrm, &paxis ); astPrimaryFrame( this, axis - 1, &pfrm, &paxis );
/* Only attempt to use the primary Frame if it is not the same as "this" /* Only attempt to use the primary Frame if it is not the same as "this"
- otherwise we could end up in an infinite loop. */ - otherwise we could end up in an infinite loop. */
if( pfrm != this ) { if( pfrm != this ) {
/* astPrimaryFrame returns the original - unpermuted - axis index within
the primary Frame. So we need to take into account any axis permutation
which has been applied to the primary Frame when forming the attribute n
ame
to use below. Find the permuted (external) axis index which corresponds
to
the internal (unpermuted) axis index "paxis". */
paxis = astValidateAxis( pfrm, paxis, 0, "astClear" );
/* Modify the attribute name to refer to the axis numbering of the /* Modify the attribute name to refer to the axis numbering of the
primary frame. */ primary frame. */
sprintf( pfrm_attrib, "%s(%d)", axis_attrib, paxis + 1 ); sprintf( pfrm_attrib, "%s(%d)", axis_attrib, paxis + 1 );
/* Attempt to clear the attribute as an attribute of the primary Frame. */ /* Attempt to clear the attribute as an attribute of the primary Frame. */
astClearAttrib( pfrm, pfrm_attrib ); astClearAttrib( pfrm, pfrm_attrib );
/* If this failed, clear the status and indicate that we have not managed t o /* If this failed, clear the status and indicate that we have not managed t o
use the attribute name. */ use the attribute name. */
if( !astOK ) { if( !astOK ) {
skipping to change at line 2306 skipping to change at line 2315
/* Local Variables: */ /* Local Variables: */
AstAxis *ax; /* Pointer to Axis object */ AstAxis *ax; /* Pointer to Axis object */
const char *units; /* Pointer to units string */ const char *units; /* Pointer to units string */
char *old_units; /* Pointer to copy of original units */ char *old_units; /* Pointer to copy of original units */
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return; if ( !astOK ) return;
/* Validate the axis index. */ /* Validate the axis index. */
(void) astValidateAxis( this, axis, "astSetUnit" ); (void) astValidateAxis( this, axis, 1, "astSetUnit" );
/* Do nothing more if the attribute is already cleared. */ /* Do nothing more if the attribute is already cleared. */
if( astTestUnit( this, axis ) ) { if( astTestUnit( this, axis ) ) {
/* Obtain a pointer to the required Axis. */ /* Obtain a pointer to the required Axis. */
ax = astGetAxis( this, axis ); ax = astGetAxis( this, axis );
/* Save a copy of the old units. */ /* Save a copy of the old units. */
units = astGetAxisUnit( ax ); units = astGetAxisUnit( ax );
old_units = astStore( NULL, units, strlen( units ) + 1 ); old_units = astStore( NULL, units, strlen( units ) + 1 );
skipping to change at line 3426 skipping to change at line 3435
int result; /* Result field count to return */ int result; /* Result field count to return */
/* Initialise. */ /* Initialise. */
result = 0; result = 0;
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return result; if ( !astOK ) return result;
/* Validate the axis index and obtain a pointer to the required /* Validate the axis index and obtain a pointer to the required
Axis. */ Axis. */
(void) astValidateAxis( this, axis, "astFields" ); (void) astValidateAxis( this, axis, 1, "astFields" );
ax = astGetAxis( this, axis ); ax = astGetAxis( this, axis );
/* Invoke the Axis astAxisFields method to perform the processing. */ /* Invoke the Axis astAxisFields method to perform the processing. */
result = astAxisFields( ax, fmt, str, maxfld, fields, nc, val ); result = astAxisFields( ax, fmt, str, maxfld, fields, nc, val );
/* Annul the Axis pointer. */ /* Annul the Axis pointer. */
ax = astAnnul( ax ); ax = astAnnul( ax );
/* If an error occurred, clear the returned value. */ /* If an error occurred, clear the returned value. */
if ( !astOK ) result = 0; if ( !astOK ) result = 0;
skipping to change at line 3939 skipping to change at line 3948
* Notes: * Notes:
* - The result string is stored in static memory and may be * - The result string is stored in static memory and may be
* over-written by a subsequent invocation of this function. * over-written by a subsequent invocation of this function.
* - A NULL pointer is returned if this function is invoked with * - A NULL pointer is returned if this function is invoked with
* the global error status set or if it should fail for any reason. * the global error status set or if it should fail for any reason.
*- *-
*/ */
/* Local Variables: */ /* Local Variables: */
astDECLARE_GLOBALS /* Declare the thread specific global data */ astDECLARE_GLOBALS /* Declare the thread specific global data */
const char *result; /* Pointer value to return */
int nc; /* Number of characters in buffer */ int nc; /* Number of characters in buffer */
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return NULL; if ( !astOK ) return NULL;
/* Get a pointer to the structure holding thread-specific global data. */ /* Get a pointer to the structure holding thread-specific global data. */
astGET_GLOBALS(NULL); astGET_GLOBALS(NULL);
/* Limit the precision to what is meaningful. */ /* Limit the precision to what is meaningful. */
digits = ( digits > DBL_DIG ) ? DBL_DIG : digits; digits = ( digits > DBL_DIG ) ? DBL_DIG : digits;
/* Format the year value. Use "g" format to avoid buffer overflow and /* Format the year value. Use "g" format to avoid buffer overflow and
to get useful diagnostic output if a silly value is given. */ to get useful diagnostic output if a silly value is given. */
nc = sprintf( astfmtdecimalyr_buff, "%#.*g", digits, year ); nc = sprintf( astfmtdecimalyr_buff, "%#.*g", digits, year );
/* Set the result value. */
result = astfmtdecimalyr_buff;
/* Loop to remove redundant zeros from the end of the result. */ /* Loop to remove redundant zeros from the end of the result. */
while ( astfmtdecimalyr_buff[ --nc ] == '0' ) astfmtdecimalyr_buff[ nc ] = '\0'; while ( astfmtdecimalyr_buff[ --nc ] == '0' ) astfmtdecimalyr_buff[ nc ] = '\0';
/* If the last character is now a decimal point, put back one zero. */ /* If the last character is now a decimal point, put back one zero. */
if ( astfmtdecimalyr_buff[ nc ] == '.' ) { if ( astfmtdecimalyr_buff[ nc ] == '.' ) {
astfmtdecimalyr_buff[ ++nc ] = '0'; astfmtdecimalyr_buff[ ++nc ] = '0';
astfmtdecimalyr_buff[ ++nc ] = '\0'; astfmtdecimalyr_buff[ ++nc ] = '\0';
} }
/* Return the result. */ /* Return the result. */
skipping to change at line 4039 skipping to change at line 4044
/* Local Variables: */ /* Local Variables: */
AstAxis *ax; /* Pointer to Axis object */ AstAxis *ax; /* Pointer to Axis object */
const char *result; /* Pointer value to return */ const char *result; /* Pointer value to return */
int digits_set; /* Axis Digits attribute set? */ int digits_set; /* Axis Digits attribute set? */
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return NULL; if ( !astOK ) return NULL;
/* Validate the axis index and obtain a pointer to the required Axis. */ /* Validate the axis index and obtain a pointer to the required Axis. */
(void) astValidateAxis( this, axis, "astFormat" ); (void) astValidateAxis( this, axis, 1, "astFormat" );
ax = astGetAxis( this, axis ); ax = astGetAxis( this, axis );
/* Test if any Axis attributes which may affect the result are undefined (i .e. /* Test if any Axis attributes which may affect the result are undefined (i .e.
have not been explicitly set). If so, we over-ride them, giving them have not been explicitly set). If so, we over-ride them, giving them
temporary values dictated by the Frame. Only the Digits attribute is temporary values dictated by the Frame. Only the Digits attribute is
relevant here. */ relevant here. */
digits_set = astTestAxisDigits( ax ); digits_set = astTestAxisDigits( ax );
if ( !digits_set ) astSetAxisDigits( ax, astGetDigits( this ) ); if ( !digits_set ) astSetAxisDigits( ax, astGetDigits( this ) );
/* Format the value. */ /* Format the value. */
skipping to change at line 4346 skipping to change at line 4351
/* Local Variables: */ /* Local Variables: */
AstAxis *ax; /* Pointer to Axis object */ AstAxis *ax; /* Pointer to Axis object */
double result; /* The nice gap value */ double result; /* The nice gap value */
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return 0.0; if ( !astOK ) return 0.0;
/* Validate the axis index and obtain a pointer to the required /* Validate the axis index and obtain a pointer to the required
Axis. */ Axis. */
(void) astValidateAxis( this, axis, "astGap" ); (void) astValidateAxis( this, axis, 1, "astGap" );
ax = astGetAxis( this, axis ); ax = astGetAxis( this, axis );
/* Find the gap. */ /* Find the gap. */
result = astAxisGap( ax, gap, ntick ); result = astAxisGap( ax, gap, ntick );
/* Annul the Axis pointer. */ /* Annul the Axis pointer. */
ax = astAnnul( ax ); ax = astAnnul( ax );
/* If an error occurred, clear the result value. */ /* If an error occurred, clear the result value. */
if ( !astOK ) result = 0.0; if ( !astOK ) result = 0.0;
skipping to change at line 4585 skipping to change at line 4590
/* Digits(axis). */ /* Digits(axis). */
/* ------------- */ /* ------------- */
} else if ( nc = 0, } else if ( nc = 0,
( 1 == astSscanf( attrib, "digits(%d)%n", &axis, &nc ) ) ( 1 == astSscanf( attrib, "digits(%d)%n", &axis, &nc ) )
&& ( nc >= len ) ) { && ( nc >= len ) ) {
/* There is no function to obtain the Digits attribute value for an /* There is no function to obtain the Digits attribute value for an
axis directly, so obtain a pointer to the Axis and use this to axis directly, so obtain a pointer to the Axis and use this to
obtain the value. Use the Frame's Digits attribute instead if the obtain the value. Use the Frame's Digits attribute instead if the
Axis attribute value is not set. */ Axis attribute value is not set. */
(void) astValidateAxis( this, axis - 1, "astGetDigits(axis)" ); (void) astValidateAxis( this, axis - 1, 1, "astGetDigits(axis)" );
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
if ( astTestAxisDigits( ax ) ) { if ( astTestAxisDigits( ax ) ) {
digits = astGetAxisDigits( ax ); digits = astGetAxisDigits( ax );
} else { } else {
digits = astGetDigits( this ); digits = astGetDigits( this );
} }
ax = astAnnul( ax ); ax = astAnnul( ax );
if ( astOK ) { if ( astOK ) {
(void) sprintf( getattrib_buff, "%d", digits ); (void) sprintf( getattrib_buff, "%d", digits );
result = getattrib_buff; result = getattrib_buff;
skipping to change at line 4803 skipping to change at line 4808
result = getattrib_buff; result = getattrib_buff;
} }
/* ObsLon. */ /* ObsLon. */
/* ------- */ /* ------- */
} else if ( !strcmp( attrib, "obslon" ) ) { } else if ( !strcmp( attrib, "obslon" ) ) {
dval = astGetObsLon( this ); dval = astGetObsLon( this );
if ( astOK ) { if ( astOK ) {
/* Put into range +/- PI. */ /* Put into range +/- PI. */
dval = palDrange( dval ); dval = astDrange( dval );
/* If not already created, create an FK5 J2000 SkyFrame which will be used /* If not already created, create an FK5 J2000 SkyFrame which will be used
for formatting and unformatting ObsLon and ObsLat values. */ for formatting and unformatting ObsLon and ObsLat values. */
if( !skyframe ) { if( !skyframe ) {
astBeginPM; astBeginPM;
skyframe = astSkyFrame( "system=FK5,equinox=J2000,format(2)=dms .2", status ); skyframe = astSkyFrame( "system=FK5,equinox=J2000,format(2)=dms .2", status );
astEndPM; astEndPM;
} }
/* Display absolute value preceded by "E" or "W" as appropriate. */ /* Display absolute value preceded by "E" or "W" as appropriate. */
skipping to change at line 4852 skipping to change at line 4857
/* ---------------------- */ /* ---------------------- */
/* If the attribute was not identified above, but appears to refer to /* If the attribute was not identified above, but appears to refer to
a Frame axis, then it may refer to an Axis object of a derived type a Frame axis, then it may refer to an Axis object of a derived type
(which has additional attributes not recognised here). */ (which has additional attributes not recognised here). */
} else if ( !free_axis_attrib && ( nc = 0, } else if ( !free_axis_attrib && ( nc = 0,
( 1 == astSscanf( attrib, "%*[^()]%n(%d)%n", ( 1 == astSscanf( attrib, "%*[^()]%n(%d)%n",
&axis_nc, &axis, &nc ) ) &axis_nc, &axis, &nc ) )
&& ( nc >= len ) ) ) { && ( nc >= len ) ) ) {
/* Validate the axis index and extract the attribute name. */ /* Validate the axis index and extract the attribute name. */
(void) astValidateAxis( this, axis - 1, "astGet" ); (void) astValidateAxis( this, axis - 1, 1, "astGet" );
axis_attrib = astString( attrib, axis_nc ); axis_attrib = astString( attrib, axis_nc );
/* Obtain a pointer to the Axis object. */ /* Obtain a pointer to the Axis object. */
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
if( astOK ) { if( astOK ) {
/* Assume that we will be able to use the attribute name. */ /* Assume that we will be able to use the attribute name. */
used = 1; used = 1;
/* Temporarily switch off error reporting so that if the following attempt /* Temporarily switch off error reporting so that if the following attempt
skipping to change at line 4886 skipping to change at line 4891
if( astStatus == AST__BADAT ) { if( astStatus == AST__BADAT ) {
astClearStatus; astClearStatus;
/* Find the primary Frame containing the specified axis. */ /* Find the primary Frame containing the specified axis. */
astPrimaryFrame( this, axis - 1, &pfrm, &paxis ); astPrimaryFrame( this, axis - 1, &pfrm, &paxis );
/* Only attempt to use the primary Frame if it is not the same as "this" /* Only attempt to use the primary Frame if it is not the same as "this"
- otherwise we could end up in an infinite loop. */ - otherwise we could end up in an infinite loop. */
if( pfrm != this ) { if( pfrm != this ) {
/* astPrimaryFrame returns the original - unpermuted - axis index within
the primary Frame. So we need to take into account any axis permutation
which has been applied to the primary Frame when forming the attribute n
ame
to use below. Find the permuted (external) axis index which corresponds
to
the internal (unpermuted) axis index "paxis". */
paxis = astValidateAxis( pfrm, paxis, 0, "astGet" );
/* Modify the attribute name to refer to the axis numbering of the /* Modify the attribute name to refer to the axis numbering of the
primary frame. */ primary frame. */
sprintf( pfrm_attrib, "%s(%d)", axis_attrib, paxis + 1 ); sprintf( pfrm_attrib, "%s(%d)", axis_attrib, paxis + 1 );
/* Attempt to use the Axis astGetAttrib method to obtain the result. */ /* Attempt to use the Axis astGetAttrib method to obtain the result. */
result = astGetAttrib( pfrm, pfrm_attrib ); result = astGetAttrib( pfrm, pfrm_attrib );
/* If this failed, clear the status and indicate that we have not managed t o /* If this failed, clear the status and indicate that we have not managed t o
use the attribute name. */ use the attribute name. */
if( !astOK ) { if( !astOK ) {
skipping to change at line 5032 skipping to change at line 5044
/* Local Variables: */ /* Local Variables: */
AstAxis *result; /* Pointer to Axis */ AstAxis *result; /* Pointer to Axis */
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return NULL; if ( !astOK ) return NULL;
/* Initialise. */ /* Initialise. */
result = NULL; result = NULL;
/* Validate and permute the axis index. */ /* Validate and permute the axis index. */
axis = astValidateAxis( this, axis, "astGetAxis" ); axis = astValidateAxis( this, axis, 1, "astGetAxis" );
/* If OK, clone the required Axis pointer. */ /* If OK, clone the required Axis pointer. */
if ( astOK ) result = astClone( this->axis[ axis ] ); if ( astOK ) result = astClone( this->axis[ axis ] );
/* Return the result. */ /* Return the result. */
return result; return result;
} }
static const char *GetDefaultLabel( int axis, int *status ) { static const char *GetDefaultLabel( int axis, int *status ) {
/* /*
skipping to change at line 8011 skipping to change at line 8023
*/ */
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return; if ( !astOK ) return;
/* Initialise the returned values. */ /* Initialise the returned values. */
*frame = NULL; *frame = NULL;
*axis2 = 0; *axis2 = 0;
/* Validate and permute the axis index supplied. */ /* Validate and permute the axis index supplied. */
axis1 = astValidateAxis( this, axis1, "astPrimaryFrame" ); axis1 = astValidateAxis( this, axis1, 1, "astPrimaryFrame" );
/* Since "this" is a primary Frame (i.e. is not compound), simply clone a /* Since "this" is a primary Frame (i.e. is not compound), simply clone a
pointer to it. */ pointer to it. */
if ( astOK ) *frame = astClone( this ); if ( astOK ) *frame = astClone( this );
/* Return the permuted axis index, which refers to the original axis order. */ /* Return the permuted axis index, which refers to the original axis order. */
if ( astOK ) *axis2 = axis1; if ( astOK ) *axis2 = axis1;
} }
double astReadDateTime_( const char *value, int *status ) { double astReadDateTime_( const char *value, int *status ) {
skipping to change at line 9294 skipping to change at line 9306
/* Digits(axis). */ /* Digits(axis). */
/* ------------- */ /* ------------- */
} else if ( nc = 0, } else if ( nc = 0,
( 2 == astSscanf( setting, "digits(%d)= %d %n", ( 2 == astSscanf( setting, "digits(%d)= %d %n",
&axis, &digits, &nc ) ) &axis, &digits, &nc ) )
&& ( nc >= len ) ) { && ( nc >= len ) ) {
/* There is no function to set the Digits attribute value for an axis /* There is no function to set the Digits attribute value for an axis
directly, so obtain a pointer to the Axis and use this to set the directly, so obtain a pointer to the Axis and use this to set the
attribute. */ attribute. */
(void) astValidateAxis( this, axis - 1, "astSetDigits(axis)" ); (void) astValidateAxis( this, axis - 1, 1, "astSetDigits(axis)" );
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
astSetAxisDigits( ax, digits ); astSetAxisDigits( ax, digits );
ax = astAnnul( ax ); ax = astAnnul( ax );
/* Direction(axis). */ /* Direction(axis). */
/* ---------------- */ /* ---------------- */
} else if ( nc = 0, } else if ( nc = 0,
( 2 == astSscanf( setting, "direction(%d)= %d %n", ( 2 == astSscanf( setting, "direction(%d)= %d %n",
&axis, &direction, &nc ) ) &axis, &direction, &nc ) )
&& ( nc >= len ) ) { && ( nc >= len ) ) {
skipping to change at line 9580 skipping to change at line 9592
/* ---------------------- */ /* ---------------------- */
/* If the attribute was not identified above, but appears to refer to /* If the attribute was not identified above, but appears to refer to
a Frame axis, then it may refer to an Axis object of a derived type a Frame axis, then it may refer to an Axis object of a derived type
(which has additional attributes not recognised here). */ (which has additional attributes not recognised here). */
} else if ( !free_axis_setting && ( nc = 0, } else if ( !free_axis_setting && ( nc = 0,
( 1 == astSscanf( setting, "%*[^()]%n(%d)%n=%*[^\n]%n", ( 1 == astSscanf( setting, "%*[^()]%n(%d)%n=%*[^\n]%n",
&axis_nc, &axis, &axis_value, &nc ) ) &axis_nc, &axis, &axis_value, &nc ) )
&& ( nc >= len ) ) ) { && ( nc >= len ) ) ) {
/* Validate the axis index and copy the attribute setting string. */ /* Validate the axis index and copy the attribute setting string. */
(void) astValidateAxis( this, axis - 1, "astSet" ); (void) astValidateAxis( this, axis - 1, 1, "astSet" );
axis_setting = astString( setting, len ); axis_setting = astString( setting, len );
if ( astOK ) { if ( astOK ) {
/* Over-write the axis index in the copy with the value to be /* Over-write the axis index in the copy with the value to be
assigned. */ assigned. */
(void) strcpy( axis_setting + axis_nc, setting + axis_value ); (void) strcpy( axis_setting + axis_nc, setting + axis_value );
/* Obtain a pointer to the Axis object. */ /* Obtain a pointer to the Axis object. */
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
if( astOK ) { if( astOK ) {
skipping to change at line 9620 skipping to change at line 9632
if( astStatus == AST__BADAT ) { if( astStatus == AST__BADAT ) {
astClearStatus; astClearStatus;
/* Find the primary Frame containing the specified axis. */ /* Find the primary Frame containing the specified axis. */
astPrimaryFrame( this, axis - 1, &pfrm, &paxis ); astPrimaryFrame( this, axis - 1, &pfrm, &paxis );
/* Only attempt to use the primary Frame if it is not the same as "this" /* Only attempt to use the primary Frame if it is not the same as "this"
- otherwise we could end up in an infinite loop. */ - otherwise we could end up in an infinite loop. */
if( pfrm != this ) { if( pfrm != this ) {
/* astPrimaryFrame returns the original - unpermuted - axis index within
the primary Frame. So we need to take into account any axis permutation
which has been applied to the primary Frame when forming the attribute n
ame
to use below. Find the permuted (external) axis index which corresponds
to
the internal (unpermuted) axis index "paxis". */
paxis = astValidateAxis( pfrm, paxis, 0, "astSet" );
/* Modify the attribute name to refer to the axis numbering of the /* Modify the attribute name to refer to the axis numbering of the
primary frame. */ primary frame. */
sprintf( pfrm_attrib, "%.*s(%d)", axis_nc, setting, paxis + 1 ); sprintf( pfrm_attrib, "%.*s(%d)", axis_nc, setting, paxis + 1 );
/* Create a setting string in which the attribute name refers to the axis /* Create a setting string in which the attribute name refers to the axis
numbering of the primary frame. */ numbering of the primary frame. */
pfrm_setting = NULL; pfrm_setting = NULL;
nc = 0; nc = 0;
pfrm_setting = astAppendString( pfrm_setting, &nc, pfrm_a ttrib ); pfrm_setting = astAppendString( pfrm_setting, &nc, pfrm_a ttrib );
pfrm_setting = astAppendString( pfrm_setting, &nc, settin g + axis_value ); pfrm_setting = astAppendString( pfrm_setting, &nc, settin g + axis_value );
skipping to change at line 9770 skipping to change at line 9789
* be replaced. * be replaced.
* newaxis * newaxis
* Pointer to the new Axis object. * Pointer to the new Axis object.
*- *-
*/ */
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return; if ( !astOK ) return;
/* Validate and permute the axis index supplied. */ /* Validate and permute the axis index supplied. */
axis = astValidateAxis( this, axis, "astSetAxis" ); axis = astValidateAxis( this, axis, 1, "astSetAxis" );
/* If OK, annul the Frame's pointer to the old Axis object and clone a poin ter /* If OK, annul the Frame's pointer to the old Axis object and clone a poin ter
to the new one to replace it. */ to the new one to replace it. */
if ( astOK ) { if ( astOK ) {
this->axis[ axis ] = astAnnul( this->axis[ axis ] ); this->axis[ axis ] = astAnnul( this->axis[ axis ] );
this->axis[ axis ] = astClone( newaxis ); this->axis[ axis ] = astClone( newaxis );
} }
} }
static void SetFrameFlags( AstFrame *this, int flags, int *status ){ static void SetFrameFlags( AstFrame *this, int flags, int *status ){
skipping to change at line 9876 skipping to change at line 9895
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return; if ( !astOK ) return;
/* Get a copy of the supplied string which excludes trailing spaces. */ /* Get a copy of the supplied string which excludes trailing spaces. */
l = astChrLen( unit ); l = astChrLen( unit );
c = astStore( NULL, unit, (size_t) (l + 1) ); c = astStore( NULL, unit, (size_t) (l + 1) );
if( astOK ) { if( astOK ) {
c[ l ] = 0; c[ l ] = 0;
/* Validate the axis index and obtain a pointer to the required Axis. */ /* Validate the axis index and obtain a pointer to the required Axis. */
(void) astValidateAxis( this, axis, "astSetUnit" ); (void) astValidateAxis( this, axis, 1, "astSetUnit" );
ax = astGetAxis( this, axis ); ax = astGetAxis( this, axis );
/* The new unit may require the Label and/or Symbol to be changed, but /* The new unit may require the Label and/or Symbol to be changed, but
only if the Frames ActiveUnit flag is set. */ only if the Frames ActiveUnit flag is set. */
if( astGetActiveUnit( this ) ) { if( astGetActiveUnit( this ) ) {
/* Get the existing Axis unit, using the astGetUnit method (rather than /* Get the existing Axis unit, using the astGetUnit method (rather than
astGetAxisUnit) in order to get any default value in the case where astGetAxisUnit) in order to get any default value in the case where
the Unit attribute is not set. */ the Unit attribute is not set. */
oldunit = astGetUnit( this, axis ); oldunit = astGetUnit( this, axis );
skipping to change at line 10517 skipping to change at line 10536
/* Digits(axis). */ /* Digits(axis). */
/* ------------- */ /* ------------- */
} else if ( nc = 0, } else if ( nc = 0,
( 1 == astSscanf( attrib, "digits(%d)%n", &axis, &nc ) ) ( 1 == astSscanf( attrib, "digits(%d)%n", &axis, &nc ) )
&& ( nc >= len ) ) { && ( nc >= len ) ) {
/* There is no function to test the Digits attribute for an axis /* There is no function to test the Digits attribute for an axis
directly, so obtain a pointer to the Axis and use this to test the directly, so obtain a pointer to the Axis and use this to test the
attribute. */ attribute. */
(void) astValidateAxis( this, axis - 1, "astTestDigits(axis)" ); (void) astValidateAxis( this, axis - 1, 1, "astTestDigits(axis)" );
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
result = astTestAxisDigits( ax ); result = astTestAxisDigits( ax );
ax = astAnnul( ax ); ax = astAnnul( ax );
/* Direction(axis). */ /* Direction(axis). */
/* ---------------- */ /* ---------------- */
} else if ( nc = 0, } else if ( nc = 0,
( 1 == astSscanf( attrib, "direction(%d)%n", &axis, &nc ) ) ( 1 == astSscanf( attrib, "direction(%d)%n", &axis, &nc ) )
&& ( nc >= len ) ) { && ( nc >= len ) ) {
result = astTestDirection( this, axis - 1 ); result = astTestDirection( this, axis - 1 );
skipping to change at line 10660 skipping to change at line 10679
/* ---------------------- */ /* ---------------------- */
/* If the attribute was not identified above, but appears to refer to /* If the attribute was not identified above, but appears to refer to
a Frame axis, then it may refer to an Axis object of a derived type a Frame axis, then it may refer to an Axis object of a derived type
(which has additional attributes not recognised here). */ (which has additional attributes not recognised here). */
} else if ( !free_axis_attrib && ( nc = 0, } else if ( !free_axis_attrib && ( nc = 0,
( 1 == astSscanf( attrib, "%*[^()]%n(%d)%n", ( 1 == astSscanf( attrib, "%*[^()]%n(%d)%n",
&axis_nc, &axis, &nc ) ) &axis_nc, &axis, &nc ) )
&& ( nc >= len ) ) ) { && ( nc >= len ) ) ) {
/* Validate the axis index and extract the attribute name. */ /* Validate the axis index and extract the attribute name. */
(void) astValidateAxis( this, axis - 1, "astTest" ); (void) astValidateAxis( this, axis - 1, 1, "astTest" );
axis_attrib = astString( attrib, axis_nc ); axis_attrib = astString( attrib, axis_nc );
/* Obtain a pointer to the Axis object. */ /* Obtain a pointer to the Axis object. */
ax = astGetAxis( this, axis - 1 ); ax = astGetAxis( this, axis - 1 );
if( astOK ) { if( astOK ) {
/* Assume that we will be able to use the attribute name. */ /* Assume that we will be able to use the attribute name. */
used = 1; used = 1;
/* Temporarily switch off error reporting so that if the following attempt /* Temporarily switch off error reporting so that if the following attempt
skipping to change at line 10694 skipping to change at line 10713
if( astStatus == AST__BADAT ) { if( astStatus == AST__BADAT ) {
astClearStatus; astClearStatus;
/* Find the primary Frame containing the specified axis. */ /* Find the primary Frame containing the specified axis. */
astPrimaryFrame( this, axis - 1, &pfrm, &paxis ); astPrimaryFrame( this, axis - 1, &pfrm, &paxis );
/* Only attempt to use the primary Frame if it is not the same as "this" /* Only attempt to use the primary Frame if it is not the same as "this"
- otherwise we could end up in an infinite loop. */ - otherwise we could end up in an infinite loop. */
if( pfrm != this ) { if( pfrm != this ) {
/* astPrimaryFrame returns the original - unpermuted - axis index within
the primary Frame. So we need to take into account any axis permutation
which has been applied to the primary Frame when forming the attribute n
ame
to use below. Find the permuted (external) axis index which corresponds
to
the internal (unpermuted) axis index "paxis". */
paxis = astValidateAxis( pfrm, paxis, 0, "astTest" );
/* Modify the attribute name to refer to the axis numbering of the /* Modify the attribute name to refer to the axis numbering of the
primary frame. */ primary frame. */
sprintf( pfrm_attrib, "%s(%d)", axis_attrib, paxis + 1 ); sprintf( pfrm_attrib, "%s(%d)", axis_attrib, paxis + 1 );
/* Attempt to test the attribute as an attribute of the primary Frame. */ /* Attempt to test the attribute as an attribute of the primary Frame. */
result = astTestAttrib( pfrm, pfrm_attrib ); result = astTestAttrib( pfrm, pfrm_attrib );
/* If this failed, clear the status and indicate that we have not managed t o /* If this failed, clear the status and indicate that we have not managed t o
use the attribute name. */ use the attribute name. */
if( !astOK ) { if( !astOK ) {
skipping to change at line 10957 skipping to change at line 10983
int nc; /* Number of characters read */ int nc; /* Number of characters read */
int status_value; /* AST error status */ int status_value; /* AST error status */
/* Initialise. */ /* Initialise. */
nc = 0; nc = 0;
/* Check the global error status. */ /* Check the global error status. */
if ( !astOK ) return nc; if ( !astOK ) return nc;
/* Validate the axis index and obtain a pointer to the required Axis. */ /* Validate the axis index and obtain a pointer to the required Axis. */
(void) astValidateAxis( this, axis, "astUnformat" ); (void) astValidateAxis( this, axis, 1, "astUnformat" );
ax = astGetAxis( this, axis ); ax = astGetAxis( this, axis );
/* Test if any Axis attributes which may affect the result are /* Test if any Axis attributes which may affect the result are
undefined (i.e. have not been explicitly set). If so, we over-ride undefined (i.e. have not been explicitly set). If so, we over-ride
them, giving them temporary values dictated by the Frame. Only the them, giving them temporary values dictated by the Frame. Only the
Digits attribute is potentially relevant here. */ Digits attribute is potentially relevant here. */
digits_set = astTestAxisDigits( ax ); digits_set = astTestAxisDigits( ax );
if ( !digits_set ) astSetAxisDigits( ax, astGetDigits( this ) ); if ( !digits_set ) astSetAxisDigits( ax, astGetDigits( this ) );
/* Read the coordinate value. */ /* Read the coordinate value. */
skipping to change at line 11005 skipping to change at line 11031
/* Otherwise, if characters were read, return the coordinate value. */ /* Otherwise, if characters were read, return the coordinate value. */
} else if ( nc ) { } else if ( nc ) {
*value = coord; *value = coord;
} }
/* Return the number of characters read. */ /* Return the number of characters read. */
return nc; return nc;
} }
static int ValidateAxis( AstFrame *this, int axis, const char *method, int static int ValidateAxis( AstFrame *this, int axis, int fwd, const char *met
*status ) { hod,
int *status ) {
/* /*
*+ *+
* Name: * Name:
* astValidateAxis * astValidateAxis
* Purpose: * Purpose:
* Validate and permute a Frame's axis index. * Validate and permute a Frame's axis index.
* Type: * Type:
* Protected virtual function. * Protected virtual function.
* Synopsis: * Synopsis:
* #include "frame.h" * #include "frame.h"
* int astValidateAxis( AstFrame *this, int axis, const char *method ) * int astValidateAxis( AstFrame *this, int axis, int fwd,
* const char *method )
* Class Membership: * Class Membership:
* Frame method. * Frame method.
* Description: * Description:
* This function checks the validity of an index (zero-based) which * This function checks the validity of an index (zero-based) which
* is to be used to address one of the coordinate axes of a * is to be used to address one of the coordinate axes of a
* Frame. If the index is valid, it is permuted using the axis * Frame. If the index is valid, it is permuted using the axis
* permutation array associated with the Frame and the (zero-based) * permutation array associated with the Frame and the (zero-based)
* permuted axis index is returned. This gives the location of the * permuted axis index is returned. This gives the location of the
skipping to change at line 11041 skipping to change at line 11069
* the axis index supplied is not valid, an error is reported and * the axis index supplied is not valid, an error is reported and
* the global error status is set. * the global error status is set.
* Parameters: * Parameters:
* this * this
* Pointer to the Frame. * Pointer to the Frame.
* axis * axis
* The axis index (zero-based) to be checked. To be valid, it * The axis index (zero-based) to be checked. To be valid, it
* must lie between zero and (naxes-1) inclusive, where "naxes" * must lie between zero and (naxes-1) inclusive, where "naxes"
* is the number of coordinate axes associated with the Frame. * is the number of coordinate axes associated with the Frame.
* fwd
* If non-zero, the suppplied axis index is assumed to be an
* "external" axis index, and the corresponding "internal" axis index
* is returned as the function value. Otherwise, the suppplied axis
* index is assumed to be an "internal" axis index, and the
* corresponding "external" axis index is returned as the function
* value.
* method * method
* Pointer to a constant null-terminated character string * Pointer to a constant null-terminated character string
* containing the name of the method that invoked this function * containing the name of the method that invoked this function
* to validate an axis index. This method name is used solely * to validate an axis index. This method name is used solely
* for constructing error messages. * for constructing error messages.
* Returned Value: * Returned Value:
* The permuted axis index. * The permuted axis index - either "internal" or "external" as
* specified by "fwd".
* Notes: * Notes:
* - A value of zero will be returned if this function is invoked * - A value of zero will be returned if this function is invoked
* with the global error status set, or if it should fail for any * with the global error status set, or if it should fail for any
* reason. * reason.
* - Error messages issued by this function refer to the external * - Error messages issued by this function refer to the public
* (public) numbering system used for axes (which is one-based), * numbering system used for axes which is one-based (zero-based axis
* whereas zero-based axis indices are used internally. * indices are used internally).
*- *-
*/ */
/* Local Variables: */ /* Local Variables: */
const int *perm; /* Pointer to axis permutation array */ const int *perm; /* Pointer to axis permutation array */
int naxes; /* Number of Frame axes */ int naxes; /* Number of Frame axes */
int result; /* Permuted axis index */ int result; /* Permuted axis index */
/* Initialise. */ /* Initialise. */
result = 0; result = 0;
skipping to change at line 11090 skipping to change at line 11126
it is not valid (again, use one-based axis numbering). */ it is not valid (again, use one-based axis numbering). */
} else if ( ( axis < 0 ) || ( axis >= naxes ) ) { } else if ( ( axis < 0 ) || ( axis >= naxes ) ) {
astError( AST__AXIIN, "%s(%s): Axis index (%d) invalid - it should " astError( AST__AXIIN, "%s(%s): Axis index (%d) invalid - it should "
"be in the range 1 to %d.", status, method, astGetClass( this ), "be in the range 1 to %d.", status, method, astGetClass( this ),
axis + 1, naxes ); axis + 1, naxes );
/* If the axis index was valid, obtain the axis permutation array and /* If the axis index was valid, obtain the axis permutation array and
use this to generate the permuted axis value. */ use this to generate the permuted axis value. */
} else { } else {
perm = astGetPerm( this ); perm = astGetPerm( this );
if( perm ) result = perm[ axis ]; if( perm ) {
/* External to internal is a simple look-up. */
if( fwd ) {
result = perm[ axis ];
/* Internal to external requires a search through the permutation array. */
} else {
for( result = 0; result < naxes; result++ ) {
if( perm[ result ] == axis ) break;
}
}
}
} }
} }
/* Return the result. */ /* Return the result. */
return result; return result;
} }
static void ValidateAxisSelection( AstFrame *this, int naxes, const int *ax es, static void ValidateAxisSelection( AstFrame *this, int naxes, const int *ax es,
const char *method, int *status ) { const char *method, int *status ) {
/* /*
skipping to change at line 14515 skipping to change at line 14563
if ( !astOK ) return 0; if ( !astOK ) return 0;
return (**astMEMBER(target,Frame,SubFrame))( target, template, result_na xes, return (**astMEMBER(target,Frame,SubFrame))( target, template, result_na xes,
target_axes, template_axes, target_axes, template_axes,
map, result, status ); map, result, status );
} }
int astUnformat_( AstFrame *this, int axis, const char *string, int astUnformat_( AstFrame *this, int axis, const char *string,
double *value, int *status ) { double *value, int *status ) {
if ( !astOK ) return 0; if ( !astOK ) return 0;
return (**astMEMBER(this,Frame,Unformat))( this, axis, string, value, st atus ); return (**astMEMBER(this,Frame,Unformat))( this, axis, string, value, st atus );
} }
int astValidateAxis_( AstFrame *this, int axis, const char *method, int *st atus ) { int astValidateAxis_( AstFrame *this, int axis, int fwd, const char *method , int *status ) {
if ( !astOK ) return 0; if ( !astOK ) return 0;
return (**astMEMBER(this,Frame,ValidateAxis))( this, axis, method, statu s ); return (**astMEMBER(this,Frame,ValidateAxis))( this, axis, fwd, method, status );
} }
void astValidateAxisSelection_( AstFrame *this, int naxes, const int *axes, void astValidateAxisSelection_( AstFrame *this, int naxes, const int *axes,
const char *method, int *status ) { const char *method, int *status ) {
if ( !astOK ) return; if ( !astOK ) return;
(**astMEMBER(this,Frame,ValidateAxisSelection))( this, naxes, axes, (**astMEMBER(this,Frame,ValidateAxisSelection))( this, naxes, axes,
method, status ); method, status );
} }
AstSystemType astValidateSystem_( AstFrame *this, AstSystemType system, con st char *method, int *status ) { AstSystemType astValidateSystem_( AstFrame *this, AstSystemType system, con st char *method, int *status ) {
if ( !astOK ) return AST__BADSYSTEM; if ( !astOK ) return AST__BADSYSTEM;
return (**astMEMBER(this,Frame,ValidateSystem))( this, system, method, s tatus ); return (**astMEMBER(this,Frame,ValidateSystem))( this, system, method, s tatus );
 End of changes. 43 change blocks. 
42 lines changed or deleted 98 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/