1 #if !defined( WINMAP_INCLUDED ) /* Include this file only once */ 2 #define WINMAP_INCLUDED 3 /* 4 *+ 5 * Name: 6 * winmap.h 7 8 * Type: 9 * C include file. 10 11 * Purpose: 12 * Define the interface to the WinMap class. 13 14 * Invocation: 15 * #include "winmap.h" 16 17 * Description: 18 * This include file defines the interface to the WinMap class and 19 * provides the type definitions, function prototypes and macros, 20 * etc. needed to use this class. 21 * 22 * The WinMap class implements Mappings which maps one window onto 23 * another window by scaling and shifting the values on each axis. 24 25 * Inheritance: 26 * The WinMap class inherits from the Mapping class. 27 28 * Attributes Over-Ridden: 29 * None. 30 31 * New Attributes Defined: 32 * None. 33 34 * Methods Over-Ridden: 35 * Public: 36 * None. 37 * 38 * Protected: 39 * ClearAttrib 40 * Clear an attribute value for a WinMap. 41 * GetAttrib 42 * Get an attribute value for a WinMap. 43 * SetAttrib 44 * Set an attribute value for a WinMap. 45 * TestAttrib 46 * Test if an attribute value has been set for a WinMap. 47 * astMapMerge 48 * Simplify a sequence of Mappings containing a WinMap. 49 * astTransform 50 * Apply a WinMap to transform a set of points. 51 52 * New Methods Defined: 53 * Public: 54 * None. 55 * 56 * Protected: 57 * astWinTerms 58 * Obtain copies of the shift and scale terms used by a WinMap. 59 60 * Other Class Functions: 61 * Public: 62 * astIsAWinMap 63 * Test class membership. 64 * astWinMap 65 * Create a WinMap. 66 * 67 * Protected: 68 * astCheckWinMap 69 * Validate class membership. 70 * astInitWinMap 71 * Initialise a WinMap. 72 * astInitWinMapVtab 73 * Initialise the virtual function table for the WinMap class. 74 * astLoadWinMap 75 * Load a WinMap. 76 77 * Macros: 78 * None. 79 80 * Type Definitions: 81 * Public: 82 * AstWinMap 83 * WinMap object type. 84 * 85 * Protected: 86 * AstWinMapVtab 87 * WinMap virtual function table type. 88 89 * Feature Test Macros: 90 * astCLASS 91 * If the astCLASS macro is undefined, only public symbols are 92 * made available, otherwise protected symbols (for use in other 93 * class implementations) are defined. This macro also affects 94 * the reporting of error context information, which is only 95 * provided for external calls to the AST library. 96 97 * Copyright: 98 * Copyright (C) 1997-2006 Council for the Central Laboratory of the 99 * Research Councils 100 101 * Licence: 102 * This program is free software: you can redistribute it and/or 103 * modify it under the terms of the GNU Lesser General Public 104 * License as published by the Free Software Foundation, either 105 * version 3 of the License, or (at your option) any later 106 * version. 107 * 108 * This program is distributed in the hope that it will be useful, 109 * but WITHOUT ANY WARRANTY; without even the implied warranty of 110 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 111 * GNU Lesser General Public License for more details. 112 * 113 * You should have received a copy of the GNU Lesser General 114 * License along with this program. If not, see 115 * <http://www.gnu.org/licenses/>. 116 117 * Authors: 118 * DSB: D.S. Berry (Starlink) 119 120 * History: 121 * 23-OCT-1996 (DSB): 122 * Original version. 123 * 8-JAN-2003 (DSB): 124 * Changed private InitVtab method to protected astInitWinMapVtab 125 * method. 126 *- 127 */ 128 129 /* Include files. */ 130 /* ============== */ 131 /* Interface definitions. */ 132 /* ---------------------- */ 133 #include "mapping.h" /* Coordinate mappings (parent class) */ 134 135 #if defined(astCLASS) /* Protected */ 136 #include "pointset.h" /* Sets of points/coordinates */ 137 #include "channel.h" /* I/O channels */ 138 #endif 139 140 /* C header files. */ 141 /* --------------- */ 142 #if defined(astCLASS) /* Protected */ 143 #include <stddef.h> 144 #endif 145 146 /* Macros */ 147 /* ====== */ 148 149 /* Define a dummy __attribute__ macro for use on non-GNU compilers. */ 150 #ifndef __GNUC__ 151 # define __attribute__(x) /*NOTHING*/ 152 #endif 153 154 /* Type Definitions. */ 155 /* ================= */ 156 /* WinMap structure. */ 157 /* ------------------ */ 158 /* This structure contains all information that is unique to each object in 159 the class (e.g. its instance variables). */ 160 typedef struct AstWinMap { 161 162 /* Attributes inherited from the parent class. */ 163 AstMapping mapping; /* Parent class structure */ 164 165 /* Attributes specific to objects in this class. */ 166 double *a; /* Pointer to array of shifts */ 167 double *b; /* Pointer to array of scale factors */ 168 169 } AstWinMap; 170 171 /* Virtual function table. */ 172 /* ----------------------- */ 173 /* This table contains all information that is the same for all 174 objects in the class (e.g. pointers to its virtual functions). */ 175 #if defined(astCLASS) /* Protected */ 176 typedef struct AstWinMapVtab { 177 178 /* Properties (e.g. methods) inherited from the parent class. */ 179 AstMappingVtab mapping_vtab; /* Parent class virtual function table */ 180 181 /* A Unique identifier to determine class membership. */ 182 AstClassIdentifier id; 183 184 /* Properties (e.g. methods) specific to this class. */ 185 int (* WinTerms)( AstWinMap *, double **, double **, int * ); 186 187 } AstWinMapVtab; 188 189 #if defined(THREAD_SAFE) 190 191 /* Define a structure holding all data items that are global within the 192 object.c file. */ 193 194 typedef struct AstWinMapGlobals { 195 AstWinMapVtab Class_Vtab; 196 int Class_Init; 197 } AstWinMapGlobals; 198 199 200 /* Thread-safe initialiser for all global data used by this module. */ 201 void astInitWinMapGlobals_( AstWinMapGlobals * ); 202 203 #endif 204 205 206 #endif 207 208 /* Function prototypes. */ 209 /* ==================== */ 210 /* Prototypes for standard class functions. */ 211 /* ---------------------------------------- */ 212 astPROTO_CHECK(WinMap) /* Check class membership */ 213 astPROTO_ISA(WinMap) /* Test class membership */ 214 215 /* Constructor. */ 216 #if defined(astCLASS) /* Protected. */ 217 AstWinMap *astWinMap_( int, const double [], const double [], const double [], const double [], const char *, int *, ...); 218 #else 219 AstWinMap *astWinMapId_( int, const double [], const double [], const double [], const double [], const char *, ... )__attribute__((format(printf,6,7))); 220 #endif 221 222 #if defined(astCLASS) /* Protected */ 223 224 /* Initialiser. */ 225 AstWinMap *astInitWinMap_( void *, size_t, int, AstWinMapVtab *, 226 const char *, int, const double *, const double *, 227 const double *, const double *, int * ); 228 229 /* Vtab initialiser. */ 230 void astInitWinMapVtab_( AstWinMapVtab *, const char *, int * ); 231 232 /* Loader. */ 233 AstWinMap *astLoadWinMap_( void *, size_t, AstWinMapVtab *, 234 const char *, AstChannel *, int * ); 235 #endif 236 237 /* Prototypes for member functions. */ 238 /* -------------------------------- */ 239 # if defined(astCLASS) /* Protected */ 240 int astWinTerms_( AstWinMap *, double **, double **, int * ); 241 #endif 242 243 /* Function interfaces. */ 244 /* ==================== */ 245 /* These macros are wrap-ups for the functions defined by this class 246 to make them easier to invoke (e.g. to avoid type mis-matches when 247 passing pointers to objects from derived classes). */ 248 249 /* Interfaces to standard class functions. */ 250 /* --------------------------------------- */ 251 /* Some of these functions provide validation, so we cannot use them 252 to validate their own arguments. We must use a cast when passing 253 object pointers (so that they can accept objects from derived 254 classes). */ 255 256 /* Check class membership. */ 257 #define astCheckWinMap(this) astINVOKE_CHECK(WinMap,this,0) 258 #define astVerifyWinMap(this) astINVOKE_CHECK(WinMap,this,1) 259 260 /* Test class membership. */ 261 #define astIsAWinMap(this) astINVOKE_ISA(WinMap,this) 262 263 /* Constructor. */ 264 #if defined(astCLASS) /* Protected. */ 265 #define astWinMap astINVOKE(F,astWinMap_) 266 #else 267 #define astWinMap astINVOKE(F,astWinMapId_) 268 #endif 269 270 #if defined(astCLASS) /* Protected */ 271 272 /* Initialiser. */ 273 #define \ 274 astInitWinMap(mem,size,init,vtab,name,ncoord,c1_in,c2_in,c1_out,c2_out) \ 275 astINVOKE(O,astInitWinMap_(mem,size,init,vtab,name,ncoord,c1_in,c2_in,c1_out,c2_out,STATUS_PTR)) 276 277 /* Vtab Initialiser. */ 278 #define astInitWinMapVtab(vtab,name) astINVOKE(V,astInitWinMapVtab_(vtab,name,STATUS_PTR)) 279 /* Loader. */ 280 #define astLoadWinMap(mem,size,vtab,name,channel) \ 281 astINVOKE(O,astLoadWinMap_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR)) 282 #endif 283 284 /* Interfaces to public member functions. */ 285 /* -------------------------------------- */ 286 /* Here we make use of astCheckWinMap to validate WinMap pointers 287 before use. This provides a contextual error report if a pointer 288 to the wrong sort of Object is supplied. */ 289 290 #if defined(astCLASS) /* Protected */ 291 #define astWinTerms(this,scale,shift) \ 292 astINVOKE(V,astWinTerms_(astCheckWinMap(this),scale,shift,STATUS_PTR)) 293 #endif 294 295 #endif 296 297 298 299 300 301