view release on metacpan or search on metacpan
ast/src/axis.c view on Meta::CPAN
result = "<bad>";
/* Otherwise, obtain a pointer to the Format string. Note a private member
function is used here in preference to an object method. This is because the
syntax of the Format string may be extended by derived classes and we do not
want to obtain a string that we cannot interpret here (where we are
restricted to C format specifiers capable of formatting double values).
Classes that extend the syntax should provide their own astAxisFormat method
and may need to store the string in a separate location. The original
location should not be re-used as the string it contains may be needed by
the Axis astOverlay method when overlaying attributes on to another Axis
object. */
} else {
fmt0 = GetAxisFormat( this, status );
/* Parse the Format string. This returns a collection of flags indicating
if any AST specific formatting features are specified in the Format
string. It also returns a pointer to a new Format string which is a
standard C printf format specifier. Currently the only flags are "log"
which indicates if the value should be formatted as "10**x" using
the graphical escape sequences defined within the Plot class to produce
ast/src/axis.c view on Meta::CPAN
* Protected virtual function.
* Synopsis:
* #include "axis.h"
* void astAxisOverlay( AstAxis *template, AstAxis *result )
* Class Membership:
* Axis method.
* Description:
* This function overlays attributes of one Axis (the "template") on to
* another Axis, so as to over-ride selected attributes of that second
* Axis. Normally only those attributes which have been specifically set
* in the template will be transferred. This implements a form of
* defaulting, in which an Axis acquires attributes from the template, but
* retains its original attributes (as the default) if new values have not
* previously been explicitly set in the template.
* Parameters:
* template
* Pointer to the template Axis, for which values should have been
ast/src/axis.c view on Meta::CPAN
* Pointer to the Axis which is to receive the new attribute values.
* Returned Value:
* void
*-
*/
/* Check the global error status. */
if ( !astOK ) return;
/* Define a macro to overlay a single attribute. This tests if the attribute
is set in the template Axis. If it is, its value is obtained and set in the
result Axis also. */
#define OVERLAY(par) \
if ( astTestAxis##par( template ) ) { \
astSetAxis##par( result, astGetAxis##par( template ) ); \
}
/* Overlay each Axis attribute in turn. */
OVERLAY(Digits);
OVERLAY(Direction);
OVERLAY(Label);
ast/src/cmpframe.c view on Meta::CPAN
static int (* parent_getusedefs)( AstObject *, int * );
static int (* parent_testattrib)( AstObject *, const char *, int * );
static void (* parent_clearalignsystem)( AstFrame *, int * );
static void (* parent_clearattrib)( AstObject *, const char *, int * );
static void (* parent_cleardtai)( AstFrame *, int * );
static void (* parent_cleardut1)( AstFrame *, int * );
static void (* parent_clearepoch)( AstFrame *, int * );
static void (* parent_clearobsalt)( AstFrame *, int * );
static void (* parent_clearobslat)( AstFrame *, int * );
static void (* parent_clearobslon)( AstFrame *, int * );
static void (* parent_overlay)( AstFrame *, const int *, AstFrame *, int * );
static void (* parent_setactiveunit)( AstFrame *, int, int * );
static void (* parent_setattrib)( AstObject *, const char *, int * );
static void (* parent_setdtai)( AstFrame *, double, int * );
static void (* parent_setdut1)( AstFrame *, double, int * );
static void (* parent_setepoch)( AstFrame *, double, int * );
static void (* parent_setframeflags)( AstFrame *, int, int * );
static void (* parent_setobsalt)( AstFrame *, double, int * );
static void (* parent_setobslat)( AstFrame *, double, int * );
static void (* parent_setobslon)( AstFrame *, double, int * );
ast/src/cmpframe.c view on Meta::CPAN
parent_getsystem = frame->GetSystem;
frame->GetSystem = GetSystem;
parent_getalignsystem = frame->GetAlignSystem;
frame->GetAlignSystem = GetAlignSystem;
parent_clearalignsystem = frame->ClearAlignSystem;
frame->ClearAlignSystem = ClearAlignSystem;
parent_overlay = frame->Overlay;
frame->Overlay = Overlay;
parent_setactiveunit = frame->SetActiveUnit;
frame->SetActiveUnit = SetActiveUnit;
parent_getactiveunit = frame->GetActiveUnit;
frame->GetActiveUnit = GetActiveUnit;
parent_setframeflags = frame->SetFrameFlags;
frame->SetFrameFlags = SetFrameFlags;
ast/src/cmpframe.c view on Meta::CPAN
* Synopsis:
* #include "cmpframe.h"
* void Overlay( AstFrame *template, const int *template_axes,
* AstFrame *result, int *status )
* Class Membership:
* CmpFrame member function (over-rides the protected astOverlay
* method inherited from the Frame class).
* Description:
* This function overlays attributes from a CmpFrame on to another Frame,
* so as to over-ride selected attributes of that second Frame. Normally
* only those attributes which have been specifically set in the template
* will be transferred. This implements a form of defaulting, in which
* a Frame acquires attributes from the template, but retains its
* original attributes (as the default) if new values have not previously
* been explicitly set in the template.
* Parameters:
* template
* Pointer to the template CmpFrame, for whose current Frame
ast/src/cmpframe.c view on Meta::CPAN
/* Local Variables: */
AstCmpFrame *res; /* Pointer to the result CmpFrame structure */
AstCmpFrame *template; /* Pointer to the template CmpFrame structure */
AstFrame *sub1; /* Template subframe for 1st result subframe */
AstFrame *sub2; /* Template subframe for 2nd result subframe */
const int *perm; /* Template axis permutation array */
const int *rperm; /* Result axis permutation array */
int *axes1; /* Axis associations with template frame1 */
int *axes2; /* Axis associations with template frame2 */
int done; /* Have attributes been overlayed yet? */
int i; /* Index of result axis */
int icmp; /* Internal template axis number */
int isfirst; /* Res. subframe -> 1st template subframe? */
int issecond; /* Res. subframe -> 2nd template subframe? */
int j; /* Index of template axis */
int nc1; /* Number of axes in template frame1 */
int nres1; /* Number of axes in first result subframe */
int nres2; /* Number of axes in second result subframe */
int nres; /* Number of axes in result Frame */
ast/src/cmpframe.c view on Meta::CPAN
/* Obtain a pointer to the CmpFrame structure. */
template = (AstCmpFrame *) template_frame;
/* Get the axis permutation array for the template CmpFrame. */
perm = astGetPerm( template );
/* Get the number of axes in the first component Frame in the template
CmpFrame. */
nc1 = astGetNaxes( template->frame1 );
/* Indicate we have not yet overlayed any attributes. */
done = 0;
/* If the result Frame is a CmpFrame... */
if( astIsACmpFrame( result ) ) {
/* Get the number of axes in the two component Frames of the result CmpFrame. */
res = (AstCmpFrame *) result;
nres1 = astGetNaxes( res->frame1 );
nres2 = astGetNaxes( res->frame2 );
ast/src/cmpframe.c view on Meta::CPAN
/* Get the axis permutation array for the result CmpFrame. */
rperm = astGetPerm( result );
/* Allocate memory for two new axes arrays, one for each result sub-frame. */
axes1 = astMalloc( sizeof(int)*(size_t)nres1 );
axes2 = astMalloc( sizeof(int)*(size_t)nres2 );
if( astOK ) {
/* Assume that there is a 1-to-1 correspondence between axes in the
subframes of the result and template CmpFrame. That is, all the axes
in each result sub-frame are overlayed from the same template sub-frame. */
done = 1;
/* Loop round each axis in the first result sub-frame. */
isfirst = 0;
issecond = 0;
for( i = 0; i < nres1; i++ ) {
/* Find the external result CmpFrame axis index (j) for internal axis i. */
for( j = 0; j < nres; j++ ) {
if( rperm[ j ] == i ) break;
ast/src/cmpframe.c view on Meta::CPAN
astOverlay( sub1, axes1, res->frame1 );
astOverlay( sub2, axes2, res->frame2 );
}
}
/* Free the axes arrays. */
axes1 = astFree( axes1 );
axes2 = astFree( axes2 );
}
/* If we have not yet overlayed any attributes... */
if( !done ) {
/* Get the number of axes in the result Frame. */
nres = astGetNaxes( result );
/* Allocate memory for two new template_axes arrays. */
axes1 = astMalloc( sizeof(int)*(size_t)nres );
axes2 = astMalloc( sizeof(int)*(size_t)nres );
if( astOK ) {
ast/src/cmpframe.c view on Meta::CPAN
/* If this template axis is in the second component Frame, store the
corresponding internal frame axis index in "axes2" and set "axis1" to
-1. */
} else {
axes1[ i ] = -1;
axes2[ i ] = icmp - nc1;
}
}
/* Now use the astOverlay methods of the two component Frames to overlay
attributes onto the appropriate axes of the results Frame. */
astOverlay( template->frame1, axes1, result );
astOverlay( template->frame2, axes2, result );
}
/* Free the axes arrays. */
axes1 = astFree( axes1 );
axes2 = astFree( axes2 );
}
}
ast/src/cmpframe.c view on Meta::CPAN
/* Check the global error status. */
if ( !astOK ) return match;
/* Initialise other variables to avoid compiler errors. */
ref_naxes = 0;
/* Select the required sub-Frames from the target. */
/* ----------------------------------------------- */
/* We first create two sub-Frames (that can be matched against the two
template component Frames) by selecting the two specified sets of
axes from the target. This is done without overlaying any template
attributes. Annul the Mappings produced by this process, as these
are not needed. */
frame1 = NULL;
junk_map = NULL;
(void) astSubFrame( target, NULL, naxes1, axes1, NULL, &junk_map, &frame1 );
if( junk_map ) junk_map = astAnnul( junk_map );
frame2 = NULL;
junk_map = NULL;
ast/src/cmpframe.c view on Meta::CPAN
* AstFrame **result, int *status )
* Class Membership:
* CmpFrame member function (over-rides the protected astSubFrame
* method inherited from the Frame class).
* Description:
* This function selects a requested sub-set (or super-set) of the
* axes from a "target" CmpFrame and creates a new Frame with
* copies of the selected axes assembled in the requested order. It
* then optionally overlays the attributes of a "template" Frame on
* to the result. It returns both the resulting Frame and a Mapping
* that describes how to convert between the coordinate systems
* described by the target and result Frames. If necessary, this
* Mapping takes account of any differences in the Frames'
* attributes due to the influence of the template.
* Parameters:
* target
* Pointer to the target CmpFrame, from which axes are to be selected.
* template
* Pointer to the template Frame, from which new attributes for
* the result Frame are to be obtained. Optionally, this may be
* NULL, in which case no overlaying of template attributes will
* be performed.
* result_naxes
* Number of axes to be selected from the target Frame. This
* number may be greater than or less than the number of axes in
* this Frame (or equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving
* a list of the (zero-based) axis indices of the axes to be
* selected from the target CmpFrame. The order in which these
* are given determines the order in which the axes appear in
* the result Frame. If any of the values in this array is set
* to -1, the corresponding result axis will not be derived from
* the target Frame, but will be assigned default attributes
* instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This
* should contain a list of the template axes (given as
* zero-based axis indices) with which the axes of the result
* Frame are to be associated. This array determines which axes
* are used when overlaying axis-dependent attributes of the
* template on to the result. If any element of this array is
* set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not
* used and a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned
* Mapping. The forward transformation of this Mapping will
* describe how to convert coordinates from the coordinate
ast/src/cmpframe.c view on Meta::CPAN
template_axes2[ n2 ] = template_axes[ result_axis ];
}
n2++;
}
}
}
/* Select from first component Frame only. */
/* --------------------------------------- */
/* If all the selected axes come from the first component Frame, use
that Frame's astSubFrame method to select them (and overlay the
template attributes if required). */
if ( astOK ) {
if ( n1 && !n2 ) {
sub_map1 = NULL;
match = astSubFrame( target->frame1, template, n1, target_axes1,
template_axes1, &sub_map1, result );
/* If this is successful, the "result" Frame will be ready to return
and "sub_map1" will point at a Mapping that converts from the first
component Frame to the "result" Frame. We must now modify this
ast/src/cmpframe.c view on Meta::CPAN
/* Free the permutation arrays and annul the original Mapping pointer. */
inperm_pref = astFree( inperm_pref );
outperm_pref = astFree( outperm_pref );
sub_map1 = astAnnul( sub_map1 );
}
/* Select from second component Frame only. */
/* ---------------------------------------- */
/* If all the selected axes come from the second component Frame, use
that Frame's astSubFrame method to select them (and overlay the
template attributes if required). */
} else if ( n2 && !n1 ) {
sub_map2 = NULL;
match = astSubFrame( target->frame2, template, n2, target_axes2,
template_axes2, &sub_map2, result );
/* If this is successful, the "result" Frame will be ready to return
and "sub_map2" will point at a Mapping that converts from the second
component Frame to the "result" Frame. We must now modify this
mapping to account for the CmpFrame's axis permutation array
ast/src/cmpframe.c view on Meta::CPAN
/* Free the permutation arrays and annul the original Mapping pointer. */
inperm_pref = astFree( inperm_pref );
outperm_pref = astFree( outperm_pref );
sub_map2 = astAnnul( sub_map2 );
}
/* Select from both component Frames. */
/* ---------------------------------- */
/* If the selected axes come from both component Frames, then use both
Frames' astSubFrame methods to select the required axes from each
of them (and overlay the template attributes if required). */
} else {
sub_map1 = NULL;
sub_map2 = NULL;
sub_result1 = NULL;
sub_result2 = NULL;
match = astSubFrame( target->frame1, template, n1, target_axes1,
template_axes1, &sub_map1, &sub_result1 );
if ( match ) {
match = astSubFrame( target->frame2, template, n2, target_axes2,
template_axes2, &sub_map2, &sub_result2 );
ast/src/dsbspecframe.c view on Meta::CPAN
static int class_check;
/* Pointers to parent class methods which are extended by this class. */
static const char *(* parent_getattrib)( AstObject *, const char *, int * );
static const char *(* parent_getlabel)( AstFrame *, int, int * );
static int (* parent_match)( AstFrame *, AstFrame *, int, int **, int **, AstMapping **, AstFrame **, int * );
static int (* parent_subframe)( AstFrame *, AstFrame *, int, const int *, const int *, AstMapping **, AstFrame **, int * );
static int (* parent_testattrib)( AstObject *, const char *, int * );
static void (* parent_clearattrib)( AstObject *, const char *, int * );
static void (* parent_setattrib)( AstObject *, const char *, int * );
static void (* parent_overlay)( AstFrame *, const int *, AstFrame *, int * );
static const char *(* parent_getdomain)( AstFrame *, int * );
/* Define macros for accessing each item of thread specific global data. */
#ifdef THREAD_SAFE
/* Define how to initialise thread-specific globals. */
#define GLOBAL_inits \
globals->Class_Init = 0; \
globals->GetAttrib_Buff[ 0 ] = 0; \
globals->GetLabel_Buff[ 0 ] = 0; \
ast/src/dsbspecframe.c view on Meta::CPAN
parent_setattrib = object->SetAttrib;
object->SetAttrib = SetAttrib;
parent_testattrib = object->TestAttrib;
object->TestAttrib = TestAttrib;
parent_getdomain = frame->GetDomain;
frame->GetDomain = GetDomain;
parent_overlay = frame->Overlay;
frame->Overlay = Overlay;
parent_match = frame->Match;
frame->Match = Match;
parent_subframe = frame->SubFrame;
frame->SubFrame = SubFrame;
parent_getlabel = frame->GetLabel;
frame->GetLabel = GetLabel;
ast/src/dsbspecframe.c view on Meta::CPAN
parent Match method above, if the target axis is not a DSBSpecFrame. */
if( astIsADSBSpecFrame( frame0 ) ) {
/* Annul the returned objects, which are not needed, but keep the axis
association arrays which already hold the correct values. */
*map = astAnnul( *map );
*result = astAnnul( *result );
/* Use the target's "astSubFrame" method to create a new Frame (the
result Frame) with a copy of of the target axis. This process also
overlays the template attributes on to the target Frame and returns a
Mapping between the target and result Frames which effects the required
coordinate conversion. */
match = astSubFrame( target, template, 1, *target_axes, *template_axes,
map, result );
}
/* Free resources. */
frame0 = astAnnul( frame0 );
}
ast/src/dsbspecframe.c view on Meta::CPAN
* Synopsis:
* #include "specframe.h"
* void Overlay( AstFrame *template, const int *template_axes,
* AstFrame *result, int *status )
* Class Membership:
* DSBSpecFrame member function (over-rides the protected astOverlay method
* inherited from the SpecFrame class).
* Description:
* This function overlays attributes of a DSBSpecFrame (the "template") on to
* another Frame, so as to over-ride selected attributes of that second
* Frame. Normally only those attributes which have been specifically set
* in the template will be transferred. This implements a form of
* defaulting, in which a Frame acquires attributes from the template, but
* retains its original attributes (as the default) if new values have not
* previously been explicitly set in the template.
*
* Note that if the result Frame is a DSBSpecFrame and a change of spectral
* coordinate system occurs as a result of overlaying its System
* attribute, then some of its original attribute values may no
* longer be appropriate (e.g. the Title, or attributes describing
* its axes). In this case, these will be cleared before overlaying
* any new values.
* Parameters:
* template
* Pointer to the template DSBSpecFrame, for which values should have been
* explicitly set for any attribute which is to be transferred.
* template_axes
* Pointer to an array of int, with one element for each axis of the
* "result" Frame (see below). For each axis in the result frame, the
* corresponding element of this array should contain the (zero-based)
ast/src/dsbspecframe.c view on Meta::CPAN
* template DSBSpecFrame, or from a class derived from it, then attributes may
* exist in the template DSBSpecFrame which do not exist in the result Frame.
* In this case, these attributes will not be transferred.
*/
/* Check the global error status. */
if ( !astOK ) return;
/* Invoke the parent class astOverlay method to transfer attributes inherited
from the parent class. */
(*parent_overlay)( template, template_axes, result, status );
/* Check if the result Frame is a DSBSpecFrame or from a class derived from
DSBSpecFrame. If not, we cannot transfer DSBSpecFrame attributes to it as it is
insufficiently specialised. In this case simply omit these attributes. */
if( astIsADSBSpecFrame( result ) && astOK ) {
/* Define macros that test whether an attribute is set in the template and,
if so, transfers its value to the result. */
#define OVERLAY(attribute) \
if ( astTest##attribute( template ) ) { \
ast/src/dsbspecframe.c view on Meta::CPAN
* AstFrame **result, int *status )
* Class Membership:
* DSBSpecFrame member function (over-rides the protected astSubFrame
* method inherited from the SpecFrame class).
* Description:
* This function selects a requested sub-set (or super-set) of the axes
* from a "target" DSBSpecFrame and creates a new Frame with copies of
* the selected axes assembled in the requested order. It then
* optionally overlays the attributes of a "template" Frame on to the
* result. It returns both the resulting Frame and a Mapping that
* describes how to convert between the coordinate systems described by
* the target and result Frames. If necessary, this Mapping takes
* account of any differences in the Frames' attributes due to the
* influence of the template.
* Parameters:
* target
* Pointer to the target DSBSpecFrame, from which axes are to be
* selected.
* template
* Pointer to the template Frame, from which new attributes for the
* result Frame are to be obtained. Optionally, this may be NULL, in
* which case no overlaying of template attributes will be performed.
* result_naxes
* Number of axes to be selected from the target Frame. This number may
* be greater than or less than the number of axes in this Frame (or
* equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving a list
* of the (zero-based) axis indices of the axes to be selected from the
* target DSBSpecFrame. The order in which these are given determines
* the order in which the axes appear in the result Frame. If any of the
* values in this array is set to -1, the corresponding result axis will
* not be derived from the target Frame, but will be assigned default
* attributes instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This should
* contain a list of the template axes (given as zero-based axis indices)
* with which the axes of the result Frame are to be associated. This
* array determines which axes are used when overlaying axis-dependent
* attributes of the template on to the result. If any element of this
* array is set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not used and
* a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned Mapping.
* The forward transformation of this Mapping will describe how to
* convert coordinates from the coordinate system described by the target
ast/src/dsbspecframe.c view on Meta::CPAN
* - A NULL pointer will be returned if this function is invoked
* with the global error status set, or if it should fail for any
* reason.
*/
/* Local Variables: */
AstMapping *result; /* The returned Mapping */
AstFrameSet *fs; /* FrameSet connecting tf1 and tf2 */
AstSpecFrame *tf1; /* SpecFrame corresponding to this DSBSpecFrame */
AstSpecFrame *tf2; /* Topocentric frequency SpecFrame */
int template_axis; /* The axis to overlay */
/* Initialise. */
result = NULL;
/* Check the global error status. */
if ( !astOK ) return result;
/* Make a SpecFrame and then overlay the SpecFrame attributes of this
DSBSpecFrame onto the new SpecFrame. This means it inherits the current
values of things like ObsLon and ObsLat. */
tf1 = astSpecFrame( "", status );
template_axis = 0;
(*parent_overlay)( (AstFrame *) this, &template_axis, (AstFrame *) tf1, status );
/* Copy this new SpecFrame and set its attributes to describe topocentric
frequency in Hz. Ensure that alignment occurs in the topocentric Frame. */
astSetAlignStdOfRest( tf1, AST__TPSOR);
tf2 = astCopy( tf1 );
astSetSystem( tf2, AST__FREQ );
astSetStdOfRest( tf2, AST__TPSOR );
astSetUnit( tf2, 0, "Hz" );
/* Find the Mapping from the spectral system described by this SpecFrame to
ast/src/fluxframe.c view on Meta::CPAN
* Modified so that a FluxFrame can be used as a template to find a
* FluxFrame contained within a CmpFrame. This involves changes in
* Match and the removal of the local versions of SetMaxAxes and
* SetMinAxes.
* 3-SEP-2007 (DSB):
* In SubFrame, since AlignSystem is extended by the FluxFrame class
* it needs to be cleared before invoking the parent SubFrame
* method in cases where the result Frame is not a FluxFrame.
* 2-OCT-2007 (DSB):
* In Overlay, clear AlignSystem as well as System before calling
* the parent overlay method.
* 29-APR-2011 (DSB):
* Prevent astFindFrame from matching a subclass template against a
* superclass target.
*class--
*/
/* Module Macros. */
/* ============== */
/* Set the name of the class we are implementing. This indicates to
the header files that define class interfaces that they should make
ast/src/fluxframe.c view on Meta::CPAN
static const char *(* parent_getdomain)( AstFrame *, int * );
static const char *(* parent_getlabel)( AstFrame *, int, int * );
static const char *(* parent_getsymbol)( AstFrame *, int, int * );
static const char *(* parent_gettitle)( AstFrame *, int * );
static const char *(* parent_getunit)( AstFrame *, int, int * );
static int (* parent_match)( AstFrame *, AstFrame *, int, int **, int **, AstMapping **, AstFrame **, int * );
static int (* parent_subframe)( AstFrame *, AstFrame *, int, const int *, const int *, AstMapping **, AstFrame **, int * );
static int (* parent_testattrib)( AstObject *, const char *, int * );
static void (* parent_setunit)( AstFrame *, int, const char *, int * );
static void (* parent_clearattrib)( AstObject *, const char *, int * );
static void (* parent_overlay)( AstFrame *, const int *, AstFrame *, int * );
static void (* parent_setattrib)( AstObject *, const char *, int * );
static void (* parent_setsystem)( AstFrame *, AstSystemType, int * );
static void (* parent_clearsystem)( AstFrame *, int * );
static void (* parent_clearunit)( AstFrame *, int, int * );
#if defined(THREAD_SAFE)
static int (* parent_managelock)( AstObject *, int, int, AstObject **, int * );
#endif
/* Define macros for accessing each item of thread specific global data. */
ast/src/fluxframe.c view on Meta::CPAN
parent_getunit = frame->GetUnit;
frame->GetUnit = GetUnit;
parent_setunit = frame->SetUnit;
frame->SetUnit = SetUnit;
parent_match = frame->Match;
frame->Match = Match;
parent_overlay = frame->Overlay;
frame->Overlay = Overlay;
parent_subframe = frame->SubFrame;
frame->SubFrame = SubFrame;
/* Store replacement pointers for methods which will be over-ridden by new
member functions implemented here. */
frame->GetActiveUnit = GetActiveUnit;
frame->TestActiveUnit = TestActiveUnit;
frame->ValidateSystem = ValidateSystem;
ast/src/fluxframe.c view on Meta::CPAN
}
/* Check at least one FluxFrame axis was found it the target. Store the
axis associataions. */
if( match && astOK ) {
(*template_axes)[ 0 ] = 0;
(*target_axes)[ 0 ] = target_axis0;
/* Use the target's "astSubFrame" method to create a new Frame (the
result Frame) with copies of the target axes in the required
order. This process also overlays the template attributes on to the
target Frame and returns a Mapping between the target and result
Frames which effects the required coordinate conversion. */
match = astSubFrame( target, template, 1, *target_axes, *template_axes,
map, result );
}
/* If an error occurred, or conversion to the result Frame's
coordinate system was not possible, then free all memory, annul the
returned objects, and reset the returned value. */
if ( !astOK || !match ) {
ast/src/fluxframe.c view on Meta::CPAN
* Synopsis:
* #include "fluxframe.h"
* void Overlay( AstFrame *template, const int *template_axes,
* AstFrame *result, int *status )
* Class Membership:
* FluxFrame member function (over-rides the protected astOverlay method
* inherited from the Frame class).
* Description:
* This function overlays attributes of a FluxFrame (the "template") on to
* another Frame, so as to over-ride selected attributes of that second
* Frame. Normally only those attributes which have been specifically set
* in the template will be transferred. This implements a form of
* defaulting, in which a Frame acquires attributes from the template, but
* retains its original attributes (as the default) if new values have not
* previously been explicitly set in the template.
*
* Note that if the result Frame is a FluxFrame and a change of flux
* coordinate system occurs as a result of overlaying its System
* attribute, then some of its original attribute values may no
* longer be appropriate (e.g. the Title, or attributes describing
* its axes). In this case, these will be cleared before overlaying
* any new values.
* Parameters:
* template
* Pointer to the template FluxFrame, for which values should have been
* explicitly set for any attribute which is to be transferred.
* template_axes
* Pointer to an array of int, with one element for each axis of the
* "result" Frame (see below). For each axis in the result frame, the
* corresponding element of this array should contain the (zero-based)
ast/src/fluxframe.c view on Meta::CPAN
/* Initialise strings used in error messages. */
new_class = astGetClass( template );
old_class = astGetClass( result );
method = "astOverlay";
/* Get the old and new systems. */
old_system = astGetSystem( result );
new_system = astGetSystem( template );
/* If the result Frame is a FluxFrame, we must test to see if overlaying its
System attribute will change the type of coordinate system it describes.
Determine the value of this attribute for the result and template
FluxFrames. */
resetSystem = 0;
fluxframe = astIsAFluxFrame( result );
if( fluxframe ) {
/* If the coordinate system will change, any value already set for the result
FluxFrame's Title will no longer be appropriate, so clear it. */
if ( ( new_system != old_system ) && astTestSystem( template ) ) {
ast/src/fluxframe.c view on Meta::CPAN
new_alignsystem = astGetAlignSystem( template );
astClearAlignSystem( template );
resetSystem = 1;
}
}
/* Invoke the parent class astOverlay method to transfer attributes inherited
from the parent class. */
(*parent_overlay)( template, template_axes, result, status );
/* Reset the System and AlignSystem values if necessary */
if( resetSystem ) {
astSetSystem( template, new_system );
astSetAlignSystem( template, new_alignsystem );
}
/* Check if the result Frame is a FluxFrame or from a class derived from
FluxFrame. If not, we cannot transfer FluxFrame attributes to it as it is
insufficiently specialised. In this case simply omit these attributes. */
ast/src/fluxframe.c view on Meta::CPAN
* AstFrame **result, int *status )
* Class Membership:
* FluxFrame member function (over-rides the protected astSubFrame
* method inherited from the Frame class).
* Description:
* This function selects a requested sub-set (or super-set) of the axes
* from a "target" FluxFrame and creates a new Frame with copies of
* the selected axes assembled in the requested order. It then
* optionally overlays the attributes of a "template" Frame on to the
* result. It returns both the resulting Frame and a Mapping that
* describes how to convert between the coordinate systems described by
* the target and result Frames. If necessary, this Mapping takes
* account of any differences in the Frames' attributes due to the
* influence of the template.
* Parameters:
* target
* Pointer to the target FluxFrame, from which axes are to be
* selected.
* template
* Pointer to the template Frame, from which new attributes for the
* result Frame are to be obtained. Optionally, this may be NULL, in
* which case no overlaying of template attributes will be performed.
* result_naxes
* Number of axes to be selected from the target Frame. This number may
* be greater than or less than the number of axes in this Frame (or
* equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving a list
* of the (zero-based) axis indices of the axes to be selected from the
* target FluxFrame. The order in which these are given determines
* the order in which the axes appear in the result Frame. If any of the
* values in this array is set to -1, the corresponding result axis will
* not be derived from the target Frame, but will be assigned default
* attributes instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This should
* contain a list of the template axes (given as zero-based axis indices)
* with which the axes of the result Frame are to be associated. This
* array determines which axes are used when overlaying axis-dependent
* attributes of the template on to the result. If any element of this
* array is set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not used and
* a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned Mapping.
* The forward transformation of this Mapping will describe how to
* convert coordinates from the coordinate system described by the target
ast/src/fluxframe.c view on Meta::CPAN
a FluxFrame. */
if ( ( result_naxes == 1 ) && ( target_axes[ 0 ] == 0 ) ) {
/* Form the result from a copy of the target. */
*result = astCopy( target );
/* Initialise a flag to indicate that MakeFluxMapping should not report
errors if no Mapping can be created. */
report = 0;
/* If required, overlay the template attributes on to the result FluxFrame.
Also get the system in which to align the two FluxFrames. These are the
values from the template (if there is a template). */
if ( template ) {
astOverlay( template, template_axes, *result );
if( astIsAFluxFrame( template ) ) {
align_sys = astGetAlignSystem( template );
/* Since we now know that both the template and target are FluxFrames, it
should usually be possible to convert betwen them. If conversion is
*not* possible then the user will probably be interested in knowing the
ast/src/fluxframe.c view on Meta::CPAN
SET_AXIS(Symbol)
SET_AXIS(Unit)
/* Clear attributes which have an extended range of values allowed by
this class. */
astClearSystem( temp );
astClearAlignSystem( temp );
/* Invoke the astSubFrame method inherited from the Frame class to
produce the result Frame by selecting the required set of axes and
overlaying the template Frame's attributes. */
match = (*parent_subframe)( (AstFrame *) temp, template,
result_naxes, target_axes, template_axes,
map, result, status );
/* Delete the temporary copy of the target FluxFrame. */
temp = astDelete( temp );
}
/* If an error occurred or no match was found, annul the returned
objects and reset the returned result. */
ast/src/frame.c view on Meta::CPAN
( (*template_axes)[ result_axis ] >= template_naxes ) ) {
(*template_axes)[ result_axis ] = -1;
}
if ( ( (*target_axes)[ result_axis ] < 0 ) ||
( (*target_axes)[ result_axis ] >= target_naxes ) ) {
(*target_axes)[ result_axis ] = -1;
}
}
/* Use the target's astSubFrame method to select the required axes from it,
overlaying the template's attributes on to the resulting Frame. This process
also generates the required Mapping between the target and result Frames. */
match = astSubFrame( target, template,
result_naxes, *target_axes, *template_axes,
map, result );
}
}
/* If an error occurred, free any allocated memory and reset the result. */
if ( !astOK || !match ) {
*template_axes = astFree( *template_axes );
ast/src/frame.c view on Meta::CPAN
* Synopsis:
* #include "frame.h"
* void astOverlay( AstFrame *template, const int *template_axes,
* AstFrame *result )
* Class Membership:
* Frame method.
* Description:
* This function overlays attributes of one Frame (the "template") on to
* another Frame, so as to over-ride selected attributes of that second
* Frame. Normally only those attributes which have been specifically set
* in the template will be transferred. This implements a form of
* defaulting, in which a Frame acquires attributes from the template, but
* retains its original attributes (as the default) if new values have not
* previously been explicitly set in the template.
* Parameters:
* template
* Pointer to the template Frame, for which values should have been
ast/src/frame.c view on Meta::CPAN
OVERLAY(Domain);
OVERLAY(Epoch);
OVERLAY(Title);
OVERLAY(ObsLat)
OVERLAY(ObsLon)
OVERLAY(ObsAlt)
/* Transfer the ActiveUnit flag. */
astSetActiveUnit( result, astGetActiveUnit( template ) );
/* Only overlay the System and AlignSystem attribute if the values are
valid for the result class. */
if( astTestSystem( template ) ) {
sys = astGetSystem( template );
if( astValidateSystem( result, sys, "astOverlay" ) ) {
astSetSystem( result, sys );
}
}
if( astTestAlignSystem( template ) ) {
sys = astGetAlignSystem( template );
ast/src/frame.c view on Meta::CPAN
if ( astOK ) {
/* Loop through all the axes in the result Frame and determine to which
template axis each one corresponds. Check that the resulting axis index is
valid. If not, then the axis will not receive new attributes. */
for ( result_axis = 0; result_axis < result_naxes; result_axis++ ) {
template_axis = template_axes ? template_axes[ result_axis ] : result_axis;
if ( ( template_axis >= 0 ) && ( template_axis < template_naxes ) ) {
/* Obtain pointers to the relevant Axis objects of each Frame and use the
astAxisOverlay method of the template Axis to overlay attributes on to
the result Axis. Annul the Axis pointers afterwards. */
template_ax = astGetAxis( template, template_axis );
result_ax = astGetAxis( result, result_axis );
astAxisOverlay( template_ax, result_ax );
template_ax = astAnnul( template_ax );
result_ax = astAnnul( result_ax );
/* Quit looping if an error occurs. */
if ( !astOK ) break;
}
ast/src/frame.c view on Meta::CPAN
* int result_naxes, const int *target_axes,
* const int *template_axes, AstMapping **map,
* AstFrame **result )
* Class Membership:
* Frame method.
* Description:
* This function selects a requested sub-set (or super-set) of the axes from
* a "target" Frame and creates a new Frame with copies of the selected
* axes assembled in the requested order. It then optionally overlays the
* attributes of a "template" Frame on to the result. It returns both the
* resulting Frame and a Mapping that describes how to convert between the
* coordinate systems described by the target and result Frames. If
* necessary, this Mapping takes account of any differences in the Frames'
* attributes due to the influence of the template.
* Parameters:
* target
* Pointer to the target Frame, from which axes are to be selected.
* template
* Pointer to the template Frame, from which new attributes for the
* result Frame are to be obtained. Optionally, this may be NULL, in
* which case no overlaying of template attributes will be performed.
* result_naxes
* Number of axes to be selected from the target Frame. This number may
* be greater than or less than the number of axes in this Frame (or
* equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving a list
* of the (zero-based) axis indices of the axes to be selected from the
* target Frame. The order in which these are given determines the order
* in which the axes appear in the result Frame. If any of the values in
* this array is set to -1, the corresponding result axis will not be
* derived from the target Frame, but will be assigned default attributes
* instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This should
* contain a list of the template axes (given as zero-based axis indices)
* with which the axes of the result Frame are to be associated. This
* array determines which axes are used when overlaying axis-dependent
* attributes of the template on to the result. If any element of this
* array is set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not used and
* a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned Mapping.
* The forward transformation of this Mapping will describe how to
* convert coordinates from the coordinate system described by the target
ast/src/frame.c view on Meta::CPAN
/* So far, we have only modified pointers in the temporary Frame to refer to
the target Frame's Axis objects. Since we will next modify these objects'
attributes, we must make a deep copy of the entire temporary Frame so that
we do not modify the target's axes. This copy now becomes our result Frame.
Annul the temporary one. */
if ( astOK ) {
*result = astCopy( tempframe );
tempframe = astAnnul( tempframe );
/* Invoke the target "astOverlay" method to overlay any remaining
attributes from the target Frame which are not associated with
individual axes (e.g. the Frame's Title and Domain). */
astOverlay( target, target_axes, *result );
/* If a template Frame was supplied, also invoke its astOverlay method to
overlay its attributes on the result Frame. (Note that in this particular
case this has no effect other than transferring attributes. In general,
however, i.e. in derived classes, this process is vital to determining the
mapping below, whose main purpose is to convert between the target and
result Frames. These will have different attributes as a result of the
influence that the template has here.) */
if ( template ) astOverlay( template, template_axes, *result );
/* We will next generate the Mapping that relates the target and result
Frames. If appropriate this should be a unit Mapping (UnitMap), so test if
the number of axes in both Frames is equal. */
ast/src/frameset.c view on Meta::CPAN
* Synopsis:
* #include "frameset.h"
* void Overlay( AstFrame *template, const int *template_axes,
* AstFrame *result, int *status )
* Class Membership:
* FrameSet member function (over-rides the protected astOverlay
* method inherited from the Frame class).
* Description:
* This function overlays attributes from the current Frame of a
* FrameSet on to another Frame, so as to over-ride selected
* attributes of that second Frame. Normally only those attributes
* which have been specifically set in the template will be
* transferred. This implements a form of defaulting, in which a
* Frame acquires attributes from the template, but retains its
* original attributes (as the default) if new values have not
* previously been explicitly set in the template.
* Parameters:
* template
ast/src/frameset.c view on Meta::CPAN
AstFrame *fr; /* Pointer to current Frame */
AstFrameSet *template; /* Pointer to the FrameSet structure */
/* Check the global error status. */
if ( !astOK ) return;
/* Obtain a pointer to the FrameSet structure. */
template = (AstFrameSet *) template_frame;
/* Obtain a pointer to the current Frame and invoke its astOverlay
method to overlay its attributes. Annul the Frame pointer
afterwards. */
fr = astGetFrame( template, AST__CURRENT );
astOverlay( fr, template_axes, result );
fr = astAnnul( fr );
}
static void PermAxes( AstFrame *this_frame, const int perm[], int *status ) {
/*
* Name:
* PermAxes
ast/src/frameset.c view on Meta::CPAN
* AstMapping **map, AstFrame **result, int *status )
* Class Membership:
* FrameSet member function (over-rides the protected astSubFrame
* method inherited from the Frame class).
* Description:
* This function selects a requested sub-set (or super-set) of the
* axes from the current Frame of a "target" FrameSet and creates a
* new Frame with copies of the selected axes assembled in the
* requested order. It then optionally overlays the attributes of a
* "template" Frame on to the result. It returns both the resulting
* Frame and a Mapping that describes how to convert between the
* coordinate systems described by the current Frame of the target
* FrameSet and the result Frame. If necessary, this Mapping takes
* account of any differences in the Frames' attributes due to the
* influence of the template.
* Parameters:
* target
* Pointer to the target FrameSet, from whose current Frame the
* axes are to be selected.
* template
* Pointer to the template Frame, from which new attributes for
* the result Frame are to be obtained. Optionally, this may be
* NULL, in which case no overlaying of template attributes will
* be performed.
* result_naxes
* Number of axes to be selected from the target FrameSet. This
* number may be greater than or less than the number of axes in
* the FrameSet's current Frame (or equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving
* a list of the (zero-based) axis indices of the axes to be
* selected from the current Frame of the target FrameSet. The
* order in which these are given determines the order in which
* the axes appear in the result Frame. If any of the values in
* this array is set to -1, the corresponding result axis will
* not be derived from the target FrameSet, but will be assigned
* default attributes instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This
* should contain a list of the template axes (given as
* zero-based axis indices) with which the axes of the result
* Frame are to be associated. This array determines which axes
* are used when overlaying axis-dependent attributes of the
* template on to the result. If any element of this array is
* set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not
* used and a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned
* Mapping. The forward transformation of this Mapping will
* describe how to convert coordinates from the coordinate
ast/src/region.c view on Meta::CPAN
* Synopsis:
* #include "region.h"
* void Overlay( AstFrame *template, const int *template_axes,
* AstFrame *result, int *status )
* Class Membership:
* Region member function (over-rides the protected astOverlay
* method inherited from the Frame class).
* Description:
* This function overlays attributes from the current Frame of a
* Region on to another Frame, so as to over-ride selected
* attributes of that second Frame. Normally only those attributes
* which have been specifically set in the template will be
* transferred. This implements a form of defaulting, in which a
* Frame acquires attributes from the template, but retains its
* original attributes (as the default) if new values have not
* previously been explicitly set in the template.
* Parameters:
* template
ast/src/region.c view on Meta::CPAN
* Pointer to the inherited status variable.
*/
/* Local Variables: */
AstFrame *fr; /* Pointer to current Frame */
/* Check the global error status. */
if ( !astOK ) return;
/* Obtain a pointer to the current Frame in the Region and invoke its
astOverlay method to overlay its attributes. Annul the Frame pointer
afterwards. */
fr = astGetFrame( ((AstRegion *) template_frame)->frameset, AST__CURRENT );
astOverlay( fr, template_axes, result );
fr = astAnnul( fr );
}
static void PermAxes( AstFrame *this_frame, const int perm[], int *status ) {
/*
* Name:
* PermAxes
ast/src/region.c view on Meta::CPAN
* AstMapping **map, AstFrame **result, int *status )
* Class Membership:
* Region member function (over-rides the protected astSubFrame
* method inherited from the Frame class).
* Description:
* This function selects a requested sub-set (or super-set) of the
* axes from the current Frame of a "target" Region and creates a
* new Frame with copies of the selected axes assembled in the
* requested order. It then optionally overlays the attributes of a
* "template" Frame on to the result. It returns both the resulting
* Frame and a Mapping that describes how to convert between the
* coordinate systems described by the current Frame of the target
* Region and the result Frame. If necessary, this Mapping takes
* account of any differences in the Frames' attributes due to the
* influence of the template.
* Parameters:
* target
* Pointer to the target Region, from whose current Frame the
* axes are to be selected.
* template
* Pointer to the template Frame, from which new attributes for
* the result Frame are to be obtained. Optionally, this may be
* NULL, in which case no overlaying of template attributes will
* be performed.
* result_naxes
* Number of axes to be selected from the target Region. This
* number may be greater than or less than the number of axes in
* the Region's current Frame (or equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving
* a list of the (zero-based) axis indices of the axes to be
* selected from the current Frame of the target Region. The
* order in which these are given determines the order in which
* the axes appear in the result Frame. If any of the values in
* this array is set to -1, the corresponding result axis will
* not be derived from the target Region, but will be assigned
* default attributes instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This
* should contain a list of the template axes (given as
* zero-based axis indices) with which the axes of the result
* Frame are to be associated. This array determines which axes
* are used when overlaying axis-dependent attributes of the
* template on to the result. If any element of this array is
* set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not
* used and a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned
* Mapping. The forward transformation of this Mapping will
* describe how to convert coordinates from the coordinate
ast/src/skyaxis.c view on Meta::CPAN
static int class_check;
/* Pointers to parent class methods which are extended by this class. */
static size_t (* parent_getobjsize)( AstObject *, int * );
static const char *(* parent_getattrib)( AstObject *, const char *, int * );
static const char *(* parent_getaxislabel)( AstAxis *, int * );
static const char *(* parent_getaxissymbol)( AstAxis *, int * );
static const char *(* parent_getaxisunit)( AstAxis *, int * );
static int (* parent_testattrib)( AstObject *, const char *, int * );
static int (*parent_getaxisdirection)( AstAxis *this, int * );
static void (* parent_axisoverlay)( AstAxis *, AstAxis *, int * );
static void (* parent_clearattrib)( AstObject *, const char *, int * );
static void (* parent_setattrib)( AstObject *, const char *, int * );
static double (*parent_getaxisbottom)( AstAxis *this, int * );
static double (*parent_getaxistop)( AstAxis *this, int * );
static const char *(* parent_axisformat)( AstAxis *, double, int * );
static double (*parent_axisgap)( AstAxis *, double, int *, int * );
static int (*parent_axisunformat)( AstAxis *, const char *, double *, int * );
static int (*parent_axisfields)( AstAxis *, const char *, const char *, int, char **, int *, double *, int * );
/* Factors for converting between hours, degrees and radians. */
ast/src/skyaxis.c view on Meta::CPAN
* Synopsis:
* #include "skyaxis.h"
* void AxisOverlay( AstAxis *template, AstAxis *result, int *status )
* Class Membership:
* SkyAxis member function (over-rides the astAxisOverlay method inherited
* from the Axis class).
* Description:
* This function overlays attributes of a SkyAxis (the "template") on to
* another Axis, so as to over-ride selected attributes of that second
* Axis. Normally only those attributes which have been specifically set
* in the template will be transferred. This implements a form of
* defaulting, in which an Axis acquires attributes from the template, but
* retains its original attributes (as the default) if new values have not
* previously been explicitly set in the template.
* Parameters:
* template
* Pointer to the template SkyAxis, for which values should have been
ast/src/skyaxis.c view on Meta::CPAN
/* Local Variables: */
AstSkyAxis *template; /* Pointer to the SkyAxis structure */
/* Check the global error status. */
if ( !astOK ) return;
/* Obtain a pointer to the template SkyAxis structure. */
template = (AstSkyAxis *) template_axis;
/* Invoke the parent astAstOverlay method to overlay inherited attributes. */
(*parent_axisoverlay)( template_axis, result, status );
/* Test if the "result" Axis is a SkyAxis (if not, it cannot acquire any
further attributes, so there is nothing more to do). */
if ( astIsASkyAxis( result ) && astOK ) {
/* Overlay the Format attribute if it is set in the template. Note that we
use private member functions (not methods) to access the Format value, since
derived classes may extend the syntax of this string and we should not
overlay a string whose syntax cannot be interpreted by the result Axis. */
if ( TestAxisFormat( template_axis, status ) ) {
SetAxisFormat( result, GetAxisFormat( template_axis, status ), status );
}
/* Overlay the AsTime attribute in the same way, but this time using methods
to access it. */
if ( astTestAxisAsTime( template ) ) {
astSetAxisAsTime( result, astGetAxisAsTime( template ) );
}
/* Also overlay the IsLatitude attribute. */
if ( astTestAxisIsLatitude( template ) ) {
astSetAxisIsLatitude( result, astGetAxisIsLatitude( template ) );
}
/* Also overlay the CentreZero attribute. */
if ( astTestAxisCentreZero( template ) ) {
astSetAxisCentreZero( result, astGetAxisCentreZero( template ) );
}
}
}
static void ClearAttrib( AstObject *this_object, const char *attrib, int *status ) {
/*
* Name:
* ClearAttrib
ast/src/skyaxis.c view on Meta::CPAN
parent_clearattrib = object->ClearAttrib;
object->ClearAttrib = ClearAttrib;
parent_getattrib = object->GetAttrib;
object->GetAttrib = GetAttrib;
parent_setattrib = object->SetAttrib;
object->SetAttrib = SetAttrib;
parent_testattrib = object->TestAttrib;
object->TestAttrib = TestAttrib;
parent_axisoverlay = axis->AxisOverlay;
axis->AxisOverlay = AxisOverlay;
parent_getaxisdirection = axis->GetAxisDirection;
axis->GetAxisDirection = GetAxisDirection;
parent_getaxislabel = axis->GetAxisLabel;
axis->GetAxisLabel = GetAxisLabel;
parent_getaxissymbol = axis->GetAxisSymbol;
axis->GetAxisSymbol = GetAxisSymbol;
parent_getaxisunit = axis->GetAxisUnit;
axis->GetAxisUnit = GetAxisUnit;
ast/src/skyframe.c view on Meta::CPAN
* - Modify the azel conversions to include correction for diurnal
* aberration.
* - Override astClearObsLat and astSetObsLat by implementations which
* reset the magnitude of the diurnal aberration vector.
* 3-SEP-2007 (DSB):
* In SubFrame, since AlignSystem is extended by the SkyFrame class
* it needs to be cleared before invoking the parent SubFrame
* method in cases where the result Frame is not a SkyFrame.
* 2-OCT-2007 (DSB):
* In Overlay, clear AlignSystem as well as System before calling
* the parent overlay method.
* 10-OCT-2007 (DSB):
* In MakeSkyMapping, correct the usage of variables "system" and
* "align_sys" when aligning in AZEL.
* 18-OCT-2007 (DSB):
* Compare target and template AlignSystem values in Match, rather
* than comparing target and result AlignSystem values in MakeSkyMapping
* (since result is basically a copy of target).
* 27-NOV-2007 (DSB):
* - Modify SetSystem to ensure that SkyRef and SkyRefP position are
* always transformed as absolute values, rather than as offset
ast/src/skyframe.c view on Meta::CPAN
static int (* parent_testformat)( AstFrame *, int, int * );
static int (* parent_unformat)( AstFrame *, int, const char *, double *, int * );
static void (* parent_clearattrib)( AstObject *, const char *, int * );
static void (* parent_cleardtai)( AstFrame *, int * );
static void (* parent_cleardut1)( AstFrame *, int * );
static void (* parent_clearformat)( AstFrame *, int, int * );
static void (* parent_clearobsalt)( AstFrame *, int * );
static void (* parent_clearobslat)( AstFrame *, int * );
static void (* parent_clearobslon)( AstFrame *, int * );
static void (* parent_clearsystem)( AstFrame *, int * );
static void (* parent_overlay)( AstFrame *, const int *, AstFrame *, int * );
static void (* parent_setattrib)( AstObject *, const char *, int * );
static void (* parent_setdtai)( AstFrame *, double, int * );
static void (* parent_setdut1)( AstFrame *, double, int * );
static void (* parent_setformat)( AstFrame *, int, const char *, int * );
static void (* parent_setobsalt)( AstFrame *, double, int * );
static void (* parent_setobslat)( AstFrame *, double, int * );
static void (* parent_setobslon)( AstFrame *, double, int * );
static void (* parent_setsystem)( AstFrame *, AstSystemType, int * );
/* Factors for converting between hours, degrees and radians. */
ast/src/skyframe.c view on Meta::CPAN
parent_getlabel = frame->GetLabel;
frame->GetLabel = GetLabel;
parent_getsymbol = frame->GetSymbol;
frame->GetSymbol = GetSymbol;
parent_gettitle = frame->GetTitle;
frame->GetTitle = GetTitle;
parent_getunit = frame->GetUnit;
frame->GetUnit = GetUnit;
parent_match = frame->Match;
frame->Match = Match;
parent_overlay = frame->Overlay;
frame->Overlay = Overlay;
parent_subframe = frame->SubFrame;
frame->SubFrame = SubFrame;
parent_unformat = frame->Unformat;
frame->Unformat = Unformat;
parent_setdtai = frame->SetDtai;
frame->SetDtai = SetDtai;
parent_setdut1 = frame->SetDut1;
frame->SetDut1 = SetDut1;
ast/src/skyframe.c view on Meta::CPAN
instead. */
} else {
(*template_axes)[ 0 ] = 0;
(*template_axes)[ 1 ] = 1;
(*target_axes)[ 0 ] = swap ? target_axis1 : target_axis0;
(*target_axes)[ 1 ] = swap ? target_axis0 : target_axis1;
}
/* Use the target's "astSubFrame" method to create a new Frame (the
result Frame) with copies of the target axes in the required
order. This process also overlays the template attributes on to the
target Frame and returns a Mapping between the target and result
Frames which effects the required coordinate conversion. */
match = astSubFrame( target, template, 2, *target_axes, *template_axes,
map, result );
}
/* If an error occurred, or conversion to the result Frame's
coordinate system was not possible, then free all memory, annul the
returned objects, and reset the returned value. */
if ( !astOK || !match ) {
ast/src/skyframe.c view on Meta::CPAN
* Synopsis:
* #include "skyframe.h"
* void Overlay( AstFrame *template, const int *template_axes,
* AstFrame *result, int *status )
* Class Membership:
* SkyFrame member function (over-rides the protected astOverlay method
* inherited from the Frame class).
* Description:
* This function overlays attributes of a SkyFrame (the "template") on to
* another Frame, so as to over-ride selected attributes of that second
* Frame. Normally only those attributes which have been specifically set
* in the template will be transferred. This implements a form of
* defaulting, in which a Frame acquires attributes from the template, but
* retains its original attributes (as the default) if new values have not
* previously been explicitly set in the template.
*
* Note that if the result Frame is a SkyFrame and a change of sky
* coordinate system occurs as a result of overlaying its System
* attribute, then some of its original attribute values may no
* longer be appropriate (e.g. the Title, or attributes describing
* its axes). In this case, these will be cleared before overlaying
* any new values.
* Parameters:
* template
* Pointer to the template SkyFrame, for which values should have been
* explicitly set for any attribute which is to be transferred.
* template_axes
* Pointer to an array of int, with one element for each axis of the
* "result" Frame (see below). For each axis in the result frame, the
* corresponding element of this array should contain the (zero-based)
ast/src/skyframe.c view on Meta::CPAN
int tax1; /* Template axis for result axis 1 */
/* Check the global error status. */
if ( !astOK ) return;
/* Indicate that we do not need to reset the System attribute of the
template. */
reset_system = 0;
new_system = AST__UNKNOWN;
/* If the result Frame is a SkyFrame, we must test to see if overlaying its
System attribute will change the type of sky coordinate system it
describes. Determine the value of this attribute for the result and template
SkyFrames. We also need to do this if either SkyRef attribute would
change. */
skyframe = astIsASkyFrame( result );
if ( skyframe ) {
old_system = astGetSystem( result );
new_system = astGetSystem( template );
skyref_changed = ( astGetSkyRef( result, 0 ) !=
astGetSkyRef( template, 0 ) ) ||
ast/src/skyframe.c view on Meta::CPAN
new_system = astGetSystem( template );
astClearSystem( template );
new_alignsystem = astGetAlignSystem( template );
astClearAlignSystem( template );
reset_system = 1;
}
}
/* Invoke the parent class astOverlay method to transfer attributes inherited
from the parent class. */
(*parent_overlay)( template, template_axes, result, status );
/* Reset the System and AlignSystem values if necessary */
if( reset_system ) {
astSetSystem( template, new_system );
astSetAlignSystem( template, new_alignsystem );
}
/* Check if the result Frame is a SkyFrame or from a class derived from
SkyFrame. If not, we cannot transfer SkyFrame attributes to it as it is
insufficiently specialised. In this case simply omit these attributes. */
ast/src/skyframe.c view on Meta::CPAN
/* Validate the axis index. */
(void) astValidateAxis( this, axis, 1, "astSetAsTime" );
/* Obtain a pointer to the Axis object. */
ax = astGetAxis( this, axis );
/* Check if the Axis object is a SkyAxis. If not, we will replace it with
one. */
if ( !astIsASkyAxis( ax ) ) {
/* Create a new SkyAxis and overlay the attributes of the original Axis. */
new_ax = astSkyAxis( "", status );
astAxisOverlay( ax, new_ax );
/* Modify the SkyFrame to use the new Skyaxis and annul the original Axis
pointer. Retain a pointer to the new SkyAxis. */
astSetAxis( this, axis, new_ax );
ax = astAnnul( ax );
ax = (AstAxis *) new_ax;
}
ast/src/skyframe.c view on Meta::CPAN
* const int *template_axes, AstMapping **map,
* AstFrame **result, int *status )
* Class Membership:
* SkyFrame member function (over-rides the protected astSubFrame method
* inherited from the Frame class).
* Description:
* This function selects a requested sub-set (or super-set) of the axes from
* a "target" SkyFrame and creates a new Frame with copies of the selected
* axes assembled in the requested order. It then optionally overlays the
* attributes of a "template" Frame on to the result. It returns both the
* resulting Frame and a Mapping that describes how to convert between the
* coordinate systems described by the target and result Frames. If
* necessary, this Mapping takes account of any differences in the Frames'
* attributes due to the influence of the template.
* Parameters:
* target
* Pointer to the target SkyFrame, from which axes are to be selected.
* template
* Pointer to the template Frame, from which new attributes for the
* result Frame are to be obtained. Optionally, this may be NULL, in
* which case no overlaying of template attributes will be performed.
* result_naxes
* Number of axes to be selected from the target Frame. This number may
* be greater than or less than the number of axes in this Frame (or
* equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving a list
* of the (zero-based) axis indices of the axes to be selected from the
* target SkyFrame. The order in which these are given determines the
* order in which the axes appear in the result Frame. If any of the
* values in this array is set to -1, the corresponding result axis will
* not be derived from the target Frame, but will be assigned default
* attributes instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This should
* contain a list of the template axes (given as zero-based axis indices)
* with which the axes of the result Frame are to be associated. This
* array determines which axes are used when overlaying axis-dependent
* attributes of the template on to the result. If any element of this
* array is set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not used and
* a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned Mapping.
* The forward transformation of this Mapping will describe how to
* convert coordinates from the coordinate system described by the target
ast/src/skyframe.c view on Meta::CPAN
astClearUseDefs( target );
set_usedefs = 1;
}
}
/* Form the result from a copy of the target and then permute its axes
into the order required. */
*result = astCopy( target );
astPermAxes( *result, target_axes );
/* If required, overlay the template attributes on to the result SkyFrame.
Also get the system in which to align the two SkyFrames. This is the
value of the AlignSystem attribute from the template (if there is a
template). */
if ( template ) {
astOverlay( template, template_axes, *result );
align_sys = astGetAlignSystem( template );
} else {
align_sys = astGetAlignSystem( target );
}
ast/src/skyframe.c view on Meta::CPAN
ax = astAnnul( ax );
}
/* Clear attributes which have an extended range of values allowed by
this class. */
astClearSystem( temp );
astClearAlignSystem( temp );
/* Invoke the astSubFrame method inherited from the Frame class to
produce the result Frame by selecting the required set of axes and
overlaying the template Frame's attributes. */
match = (*parent_subframe)( (AstFrame *) temp, template,
result_naxes, target_axes, template_axes,
map, result, status );
/* Delete the temporary copy of the target SkyFrame. */
temp = astDelete( temp );
}
/* Ensure the returned Frame does not have active units. */
astSetActiveUnit( *result, 0 );
ast/src/specfluxframe.c view on Meta::CPAN
instead. */
} else {
(*template_axes)[ 0 ] = 0;
(*template_axes)[ 1 ] = 1;
(*target_axes)[ 0 ] = swap;
(*target_axes)[ 1 ] = !swap;
}
/* Use the target's "astSubFrame" method to create a new Frame (the
result Frame) with copies of the target axes in the required
order. This process also overlays the template attributes on to the
target Frame and returns a Mapping between the target and result
Frames which effects the required coordinate conversion. */
match = astSubFrame( target, template, 2, *target_axes, *template_axes,
map, result );
/* If an error occurred, or conversion to the result Frame's
coordinate system was not possible, then free all memory, annul the
returned objects, and reset the returned value. */
if ( !astOK || !match ) {
*template_axes = astFree( *template_axes );
ast/src/specfluxframe.c view on Meta::CPAN
* AstFrame **result, int *status )
* Class Membership:
* SpecFluxFrame member function (over-rides the protected astSubFrame
* method inherited from the Frame class).
* Description:
* This function selects a requested sub-set (or super-set) of the
* axes from a "target" SpecFluxFrame and creates a new Frame with
* copies of the selected axes assembled in the requested order. It
* then optionally overlays the attributes of a "template" Frame on
* to the result. It returns both the resulting Frame and a Mapping
* that describes how to convert between the coordinate systems
* described by the target and result Frames. If necessary, this
* Mapping takes account of any differences in the Frames'
* attributes due to the influence of the template.
* Parameters:
* target
* Pointer to the target SpecFluxFrame, from which axes are to be selected.
* template
* Pointer to the template Frame, from which new attributes for
* the result Frame are to be obtained. Optionally, this may be
* NULL, in which case no overlaying of template attributes will
* be performed.
* result_naxes
* Number of axes to be selected from the target Frame. This
* number may be greater than or less than the number of axes in
* this Frame (or equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving
* a list of the (zero-based) axis indices of the axes to be
* selected from the target SpecFluxFrame. The order in which these
* are given determines the order in which the axes appear in
* the result Frame. If any of the values in this array is set
* to -1, the corresponding result axis will not be derived from
* the target Frame, but will be assigned default attributes
* instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This
* should contain a list of the template axes (given as
* zero-based axis indices) with which the axes of the result
* Frame are to be associated. This array determines which axes
* are used when overlaying axis-dependent attributes of the
* template on to the result. If any element of this array is
* set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not
* used and a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned
* Mapping. The forward transformation of this Mapping will
* describe how to convert coordinates from the coordinate
ast/src/specframe.c view on Meta::CPAN
* SetMinAxes.
* 8-AUG-2007 (DSB):
* Changed Overlay to avoid the possibility of making permanent
* changes to the supplied template Frame.
* 3-SEP-2007 (DSB):
* In SubFrame, since AlignSystem is extended by the SpecFrame class
* it needs to be cleared before invoking the parent SubFrame
* method in cases where the result Frame is not a SkyFrame.
* 2-OCT-2007 (DSB):
* In Overlay, clear AlignSystem as well as System before calling
* the parent overlay method.
* 4-SEP-2009 (DSB):
* In MakeSpecMapping, in order to produce alignment that is not
* affected by the epoch or reference position, make the alignment
* frame adapt to the epoch and reference position of the target
* and result Frames.
* 14-SEP-2009 (DSB):
* In MakeSpecMapping, extend the 4-SEP-2009 fix to cover other
* attributes that define the available rest frames (e.g.
* SourceVRF, SourceVel, ObsLat, ObsLon, ObsAlt).
* 16-SEP-2009 (DSB):
ast/src/specframe.c view on Meta::CPAN
static const char *(* parent_getdomain)( AstFrame *, int * );
static const char *(* parent_getlabel)( AstFrame *, int, int * );
static const char *(* parent_getsymbol)( AstFrame *, int, int * );
static const char *(* parent_gettitle)( AstFrame *, int * );
static const char *(* parent_getunit)( AstFrame *, int, int * );
static int (* parent_match)( AstFrame *, AstFrame *, int, int **, int **, AstMapping **, AstFrame **, int * );
static int (* parent_subframe)( AstFrame *, AstFrame *, int, const int *, const int *, AstMapping **, AstFrame **, int * );
static int (* parent_testattrib)( AstObject *, const char *, int * );
static void (* parent_setunit)( AstFrame *, int, const char *, int * );
static void (* parent_clearattrib)( AstObject *, const char *, int * );
static void (* parent_overlay)( AstFrame *, const int *, AstFrame *, int * );
static void (* parent_setattrib)( AstObject *, const char *, int * );
static void (* parent_setsystem)( AstFrame *, AstSystemType, int * );
static void (* parent_clearsystem)( AstFrame *, int * );
static void (* parent_clearunit)( AstFrame *, int, int * );
/* Define a variable to hold a SkyFrame which will be used for formatting
and unformatting sky positions, etc. */
static AstSkyFrame *skyframe;
/* Define macros for accessing each item of thread specific global data. */
ast/src/specframe.c view on Meta::CPAN
parent_getunit = frame->GetUnit;
frame->GetUnit = GetUnit;
parent_setunit = frame->SetUnit;
frame->SetUnit = SetUnit;
parent_match = frame->Match;
frame->Match = Match;
parent_overlay = frame->Overlay;
frame->Overlay = Overlay;
parent_subframe = frame->SubFrame;
frame->SubFrame = SubFrame;
/* Store replacement pointers for methods which will be over-ridden by new
member functions implemented here. */
frame->GetActiveUnit = GetActiveUnit;
frame->TestActiveUnit = TestActiveUnit;
frame->ValidateSystem = ValidateSystem;
ast/src/specframe.c view on Meta::CPAN
}
/* Check at least one SpecFrame axis was found it the target. Store the
axis associataions. */
if( match && astOK ) {
(*template_axes)[ 0 ] = 0;
(*target_axes)[ 0 ] = target_axis0;
/* Use the target's "astSubFrame" method to create a new Frame (the
result Frame) with copies of the target axes in the required
order. This process also overlays the template attributes on to the
target Frame and returns a Mapping between the target and result
Frames which effects the required coordinate conversion. */
match = astSubFrame( target, template, 1, *target_axes, *template_axes,
map, result );
}
/* If an error occurred, or conversion to the result Frame's
coordinate system was not possible, then free all memory, annul the
returned objects, and reset the returned value. */
ast/src/specframe.c view on Meta::CPAN
* Synopsis:
* #include "specframe.h"
* void Overlay( AstFrame *template, const int *template_axes,
* AstFrame *result, int *status )
* Class Membership:
* SpecFrame member function (over-rides the protected astOverlay method
* inherited from the Frame class).
* Description:
* This function overlays attributes of a SpecFrame (the "template") on to
* another Frame, so as to over-ride selected attributes of that second
* Frame. Normally only those attributes which have been specifically set
* in the template will be transferred. This implements a form of
* defaulting, in which a Frame acquires attributes from the template, but
* retains its original attributes (as the default) if new values have not
* previously been explicitly set in the template.
*
* Note that if the result Frame is a SpecFrame and a change of spectral
* coordinate system occurs as a result of overlaying its System
* attribute, then some of its original attribute values may no
* longer be appropriate (e.g. the Title, or attributes describing
* its axes). In this case, these will be cleared before overlaying
* any new values.
* Parameters:
* template
* Pointer to the template SpecFrame, for which values should have been
* explicitly set for any attribute which is to be transferred.
* template_axes
* Pointer to an array of int, with one element for each axis of the
* "result" Frame (see below). For each axis in the result frame, the
* corresponding element of this array should contain the (zero-based)
ast/src/specframe.c view on Meta::CPAN
/* It may be necessary to make temporary changes to the template Frame
below. In order to ensure that we make no permanent changes to the
supplied frame, we will, if necessary, take a deep copy of the
supplied Frame, storing a pointer to the copy in "templt". If it is
not necessary to make any changes to the template, we still want
"templt" to hold a usable pointer, so we initialise it now to hold a
clone of the supplied pointer. This pointer will be replaced by a
pointer to a deep copy (if required) below. */
templt = astClone( template );
/* If the result Frame is a SpecFrame, we must test to see if overlaying its
System attribute will change the type of coordinate system it describes.
Determine the value of this attribute for the result and template
SpecFrames. */
specframe = astIsASpecFrame( result );
if( specframe ) {
/* If the coordinate system will change, any value already set for the result
SpecFrame's Title will no longer be appropriate, so clear it. But note
the coordinate system will change only if the system values are
different AND the system has been set explicitly in the template. If
ast/src/specframe.c view on Meta::CPAN
if( astTestSystem( template ) ) {
templt = astAnnul( templt );
templt = astCopy( template );
astClearSystem( templt );
astClearAlignSystem( templt );
}
}
/* Invoke the parent class astOverlay method to transfer attributes inherited
from the parent class. */
(*parent_overlay)( templt, template_axes, result, status );
/* Check if the result Frame is a SpecFrame or from a class derived from
SpecFrame. If not, we cannot transfer SpecFrame attributes to it as it is
insufficiently specialised. In this case simply omit these attributes. */
if ( specframe && astOK ) {
/* Define macros that test whether an attribute is set in the template and,
if so, transfers its value to the result. */
#define OVERLAY(attribute) \
if ( astTest##attribute( template ) ) { \
astSet##attribute( result, astGet##attribute( template ) ); \
}
/* Use the macro to transfer each SpecFrame attribute in turn. Note,
SourceVRF must be overlayed before SourceVel. Otherwise the stored value
for SourceVel would be changed from the default SourceVRF to the specified
SourceVRF when SourceVRF was overlayed. */
OVERLAY(AlignStdOfRest)
OVERLAY(AlignSpecOffset);
OVERLAY(RefDec)
OVERLAY(RefRA)
OVERLAY(RestFreq)
OVERLAY(SourceSys)
OVERLAY(SourceVRF)
OVERLAY(SourceVel)
OVERLAY(StdOfRest)
OVERLAY(SpecOrigin)
ast/src/specframe.c view on Meta::CPAN
* AstFrame **result, int *status )
* Class Membership:
* SpecFrame member function (over-rides the protected astSubFrame
* method inherited from the Frame class).
* Description:
* This function selects a requested sub-set (or super-set) of the axes
* from a "target" SpecFrame and creates a new Frame with copies of
* the selected axes assembled in the requested order. It then
* optionally overlays the attributes of a "template" Frame on to the
* result. It returns both the resulting Frame and a Mapping that
* describes how to convert between the coordinate systems described by
* the target and result Frames. If necessary, this Mapping takes
* account of any differences in the Frames' attributes due to the
* influence of the template.
* Parameters:
* target
* Pointer to the target SpecFrame, from which axes are to be
* selected.
* template
* Pointer to the template Frame, from which new attributes for the
* result Frame are to be obtained. Optionally, this may be NULL, in
* which case no overlaying of template attributes will be performed.
* result_naxes
* Number of axes to be selected from the target Frame. This number may
* be greater than or less than the number of axes in this Frame (or
* equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving a list
* of the (zero-based) axis indices of the axes to be selected from the
* target SpecFrame. The order in which these are given determines
* the order in which the axes appear in the result Frame. If any of the
* values in this array is set to -1, the corresponding result axis will
* not be derived from the target Frame, but will be assigned default
* attributes instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This should
* contain a list of the template axes (given as zero-based axis indices)
* with which the axes of the result Frame are to be associated. This
* array determines which axes are used when overlaying axis-dependent
* attributes of the template on to the result. If any element of this
* array is set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not used and
* a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned Mapping.
* The forward transformation of this Mapping will describe how to
* convert coordinates from the coordinate system described by the target
ast/src/specframe.c view on Meta::CPAN
a SpecFrame. */
if ( ( result_naxes == 1 ) && ( target_axes[ 0 ] == 0 ) ) {
/* Form the result from a copy of the target. */
*result = astCopy( target );
/* Initialise a flag to indicate that MakeSpecMapping should not report
errors if no Mapping can be created. */
report = 0;
/* If required, overlay the template attributes on to the result SpecFrame.
Also get the system and standard of rest in which to align the two
SpecFrames. These are the values from the template (if there is a
template). */
if ( template ) {
astOverlay( template, template_axes, *result );
if( astIsASpecFrame( template ) ) {
align_frm = astCopy( template );
/* Since we now know that both the template and target are SpecFrames, it
should usually be possible to convert betwen them. If conversion is
ast/src/specframe.c view on Meta::CPAN
SET_AXIS(Symbol)
SET_AXIS(Unit)
/* Clear attributes which have an extended range of values allowed by
this class. */
astClearSystem( temp );
astClearAlignSystem( temp );
/* Invoke the astSubFrame method inherited from the Frame class to
produce the result Frame by selecting the required set of axes and
overlaying the template Frame's attributes. */
match = (*parent_subframe)( (AstFrame *) temp, template,
result_naxes, target_axes, template_axes,
map, result, status );
/* Delete the temporary copy of the target SpecFrame. */
temp = astDelete( temp );
}
/* If an error occurred or no match was found, annul the returned
objects and reset the returned result. */
ast/src/timeframe.c view on Meta::CPAN
* Modified so that a TimeFrame can be used as a template to find a
* TimeFrame contained within a CmpFrame. This involves changes in
* Match and the removal of the local versions of SetMaxAxes and
* SetMinAxes.
* 3-SEP-2007 (DSB):
* In SubFrame, since AlignSystem is extended by the TimeFrame class
* it needs to be cleared before invoking the parent SubFrame
* method in cases where the result Frame is not a TimeFrame.
* 2-OCT-2007 (DSB):
* In Overlay, clear AlignSystem as well as System before calling
* the parent overlay method.
* 2-OCT-2007 (DSB):
* Added "LT" (Local Time) time scale.
* 9-DEC-2008 (DSB):
* Ensure Format string pointer is used correctly.
* 19-JAN-2009 (DSB):
* Ensure "<bad>" is returned by astFormat if the axis value is bad.
* 31-MAR-2009 (DSB):
* Extend TimeFrame "iso" Format to allow it to specify the character to
* place between the time and date strings.
* 15-APR-2009 (DSB):
ast/src/timeframe.c view on Meta::CPAN
static const char *(* parent_gettitle)( AstFrame *, int * );
static const char *(* parent_getunit)( AstFrame *, int, int * );
static double (* parent_getepoch)( AstFrame *, int * );
static int (* parent_fields)( AstFrame *, int, const char *, const char *, int, char **, int *, double *, int * );
static int (* parent_match)( AstFrame *, AstFrame *, int, int **, int **, AstMapping **, AstFrame **, int * );
static int (* parent_subframe)( AstFrame *, AstFrame *, int, const int *, const int *, AstMapping **, AstFrame **, int * );
static int (* parent_testattrib)( AstObject *, const char *, int * );
static int (* parent_unformat)( AstFrame *, int, const char *, double *, int * );
static void (* parent_clearattrib)( AstObject *, const char *, int * );
static void (* parent_clearsystem)( AstFrame *, int * );
static void (* parent_overlay)( AstFrame *, const int *, AstFrame *, int * );
static void (* parent_setattrib)( AstObject *, const char *, int * );
static void (* parent_setsystem)( AstFrame *, AstSystemType, int * );
static void (* parent_setunit)( AstFrame *, int, const char *, int * );
/* Define macros for accessing each item of thread specific global data. */
#ifdef THREAD_SAFE
/* Define how to initialise thread-specific globals. */
#define GLOBAL_inits \
globals->Class_Init = 0; \
ast/src/timeframe.c view on Meta::CPAN
parent_getunit = frame->GetUnit;
frame->GetUnit = GetUnit;
parent_setunit = frame->SetUnit;
frame->SetUnit = SetUnit;
parent_match = frame->Match;
frame->Match = Match;
parent_overlay = frame->Overlay;
frame->Overlay = Overlay;
parent_subframe = frame->SubFrame;
frame->SubFrame = SubFrame;
parent_format = frame->Format;
frame->Format = Format;
parent_unformat = frame->Unformat;
frame->Unformat = Unformat;
ast/src/timeframe.c view on Meta::CPAN
}
/* Check at least one TimeFrame axis was found it the target. Store the
axis associataions. */
if( match && astOK ) {
(*template_axes)[ 0 ] = 0;
(*target_axes)[ 0 ] = target_axis0;
/* Use the target's "astSubFrame" method to create a new Frame (the
result Frame) with copies of the target axes in the required
order. This process also overlays the template attributes on to the
target Frame and returns a Mapping between the target and result
Frames which effects the required coordinate conversion. */
match = astSubFrame( target, template, 1, *target_axes, *template_axes,
map, result );
}
/* If an error occurred, or conversion to the result Frame's coordinate
system was not possible, then free all memory, annul the returned
objects, and reset the returned value. */
if ( !astOK || !match ) {
ast/src/timeframe.c view on Meta::CPAN
* Synopsis:
* #include "timeframe.h"
* void Overlay( AstFrame *template, const int *template_axes,
* AstFrame *result, int *status )
* Class Membership:
* TimeFrame member function (over-rides the protected astOverlay method
* inherited from the Frame class).
* Description:
* This function overlays attributes of a TimeFrame (the "template") on to
* another Frame, so as to over-ride selected attributes of that second
* Frame. Normally only those attributes which have been specifically set
* in the template will be transferred. This implements a form of
* defaulting, in which a Frame acquires attributes from the template, but
* retains its original attributes (as the default) if new values have not
* previously been explicitly set in the template.
*
* Note that if the result Frame is a TimeFrame and a change of time
* coordinate system occurs as a result of overlaying its System
* attribute, then some of its original attribute values may no
* longer be appropriate (e.g. the Title, or attributes describing
* its axes). In this case, these will be cleared before overlaying
* any new values.
* Parameters:
* template
* Pointer to the template TimeFrame, for which values should have been
* explicitly set for any attribute which is to be transferred.
* template_axes
* Pointer to an array of int, with one element for each axis of the
* "result" Frame (see below). For each axis in the result frame, the
* corresponding element of this array should contain the (zero-based)
ast/src/timeframe.c view on Meta::CPAN
int resetSystem; /* Was the template System value cleared? */
int timeframe; /* Result Frame is a TimeFrame? */
/* Check the global error status. */
if ( !astOK ) return;
/* Get the old and new systems. */
old_system = astGetSystem( result );
new_system = astGetSystem( template );
/* If the result Frame is a TimeFrame, we must test to see if overlaying its
System attribute will change the type of coordinate system it describes.
Determine the value of this attribute for the result and template
TimeFrames. */
resetSystem = 0;
timeframe = astIsATimeFrame( result );
if( timeframe ) {
/* If the coordinate system will change, any value already set for the result
TimeFrame's Title, etc, will no longer be appropriate, so clear it. But
note, the coordinate system will change only if the system values are
ast/src/timeframe.c view on Meta::CPAN
new_alignsystem = astGetAlignSystem( template );
astClearAlignSystem( template );
resetSystem = 1;
}
}
/* Invoke the parent class astOverlay method to transfer attributes inherited
from the parent class. */
(*parent_overlay)( template, template_axes, result, status );
/* Reset the System and AlignSystem values if necessary */
if( resetSystem ) {
astSetSystem( template, new_system );
astSetAlignSystem( template, new_alignsystem );
}
/* Check if the result Frame is a TimeFrame or from a class derived from
TimeFrame. If not, we cannot transfer TimeFrame attributes to it as it is
insufficiently specialised. In this case simply omit these attributes. */
if ( timeframe && astOK ) {
/* Define macros that test whether an attribute is set in the template and,
if so, transfers its value to the result. */
#define OVERLAY(attribute) \
if ( astTest##attribute( template ) ) { \
astSet##attribute( result, astGet##attribute( template ) ); \
}
/* Use the macro to transfer each TimeFrame attribute in turn. Note,
SourceVRF must be overlayed before SourceVel. Otherwise the stored value
for SourceVel would be changed from the default SourceVRF to the specified
SourceVRF when SourceVRF was overlayed. */
OVERLAY(AlignTimeScale)
OVERLAY(LTOffset)
OVERLAY(TimeOrigin)
OVERLAY(TimeScale)
}
/* Undefine macros local to this function. */
#undef OVERLAY
}
ast/src/timeframe.c view on Meta::CPAN
* AstFrame **result, int *status )
* Class Membership:
* TimeFrame member function (over-rides the protected astSubFrame
* method inherited from the Frame class).
* Description:
* This function selects a requested sub-set (or super-set) of the axes
* from a "target" TimeFrame and creates a new Frame with copies of
* the selected axes assembled in the requested order. It then
* optionally overlays the attributes of a "template" Frame on to the
* result. It returns both the resulting Frame and a Mapping that
* describes how to convert between the coordinate systems described by
* the target and result Frames. If necessary, this Mapping takes
* account of any differences in the Frames' attributes due to the
* influence of the template.
* Parameters:
* target
* Pointer to the target TimeFrame, from which axes are to be
* selected.
* template
* Pointer to the template Frame, from which new attributes for the
* result Frame are to be obtained. Optionally, this may be NULL, in
* which case no overlaying of template attributes will be performed.
* result_naxes
* Number of axes to be selected from the target Frame. This number may
* be greater than or less than the number of axes in this Frame (or
* equal).
* target_axes
* Pointer to an array of int with result_naxes elements, giving a list
* of the (zero-based) axis indices of the axes to be selected from the
* target TimeFrame. The order in which these are given determines
* the order in which the axes appear in the result Frame. If any of the
* values in this array is set to -1, the corresponding result axis will
* not be derived from the target Frame, but will be assigned default
* attributes instead.
* template_axes
* Pointer to an array of int with result_naxes elements. This should
* contain a list of the template axes (given as zero-based axis indices)
* with which the axes of the result Frame are to be associated. This
* array determines which axes are used when overlaying axis-dependent
* attributes of the template on to the result. If any element of this
* array is set to -1, the corresponding result axis will not receive any
* template attributes.
*
* If the template argument is given as NULL, this array is not used and
* a NULL pointer may also be supplied here.
* map
* Address of a location to receive a pointer to the returned Mapping.
* The forward transformation of this Mapping will describe how to
* convert coordinates from the coordinate system described by the target
ast/src/timeframe.c view on Meta::CPAN
/* Result is a TimeFrame. */
/* -------------------------- */
/* Check if the result Frame is to have one axis obtained by selecting
the single target TimeFrame axis. If so, the result will also be
a TimeFrame. */
if ( ( result_naxes == 1 ) && ( target_axes[ 0 ] == 0 ) ) {
/* Form the result from a copy of the target. */
*result = astCopy( target );
/* If required, overlay the template attributes on to the result TimeFrame.
Also choose the Frame which defined the alignment system and time scale
(via its AlignSystem and AlignTimeScale attributes) in which to align the
two TimeFrames. This is the template (if there is a template). */
if ( template ) {
astOverlay( template, template_axes, *result );
if( astIsATimeFrame( template ) ) {
align_frm = astClone( template );
} else {
align_frm = astClone( target );
}
ast/src/timeframe.c view on Meta::CPAN
SET_AXIS(Symbol)
SET_AXIS(Unit)
/* Clear attributes which have an extended range of values allowed by
this class. */
astClearSystem( temp );
astClearAlignSystem( temp );
/* Invoke the astSubFrame method inherited from the Frame class to
produce the result Frame by selecting the required set of axes and
overlaying the template Frame's attributes. */
match = (*parent_subframe)( (AstFrame *) temp, template,
result_naxes, target_axes, template_axes,
map, result, status );
/* Delete the temporary copy of the target TimeFrame. */
temp = astDelete( temp );
}
/* If an error occurred or no match was found, annul the returned
objects and reset the returned result. */