1 #ifndef SIRIL_H 2 #define SIRIL_H 3 #ifdef HAVE_CONFIG_H 4 # include <config.h> 5 #endif 6 7 #include <glib.h> 8 #include <glib/gstdio.h> 9 #include <glib/gprintf.h> 10 #include <gtk/gtk.h> 11 #include <fitsio.h> // fitsfile 12 #include <gsl/gsl_histogram.h> 13 #ifdef _OPENMP 14 #include <omp.h> 15 #endif 16 #include <libintl.h> 17 18 19 #include "gui/preferences.h" 20 #include "core/atomic.h" 21 22 #define _(String) gettext (String) 23 #define gettext_noop(String) String 24 #define N_(String) gettext_noop (String) 25 26 #ifdef SIRIL_OUTPUT_DEBUG 27 #define DEBUG_TEST 1 28 #else 29 #define DEBUG_TEST 0 30 #endif 31 32 #define GLADE_FILE "siril3.glade" 33 34 /* https://stackoverflow.com/questions/1644868/define-macro-for-debug-printing-in-c */ 35 #define siril_debug_print(fmt, ...) \ 36 do { if (DEBUG_TEST) fprintf(stdout, fmt, ##__VA_ARGS__); } while (0) 37 38 #define PRINT_ALLOC_ERR fprintf(stderr, "Out of memory in %s (%s:%d) - aborting\n", __func__, __FILE__, __LINE__) 39 #define PRINT_ANOTHER_THREAD_RUNNING siril_log_message(_("Another task is already in progress, ignoring new request.\n")) 40 41 #ifndef RT_INCLUDE 42 #undef max 43 #define max(a,b) \ 44 ({ __typeof__ (a) _a = (a); \ 45 __typeof__ (b) _b = (b); \ 46 _a > _b ? _a : _b; }) 47 48 #undef min 49 #define min(a,b) \ 50 ({ __typeof__ (a) _a = (a); \ 51 __typeof__ (b) _b = (b); \ 52 _a < _b ? _a : _b; }) 53 54 #define SWAP(a,b) { double temp = (a); (a) = (b); (b) = temp; } 55 56 #define SQR(x) ((x)*(x)) 57 #endif 58 #define RADCONV ((3600.0 * 180.0) / M_PI) / 1.0E3 59 60 #define USHRT_MAX_DOUBLE ((double)USHRT_MAX) 61 #define SHRT_MAX_DOUBLE ((double)SHRT_MAX) 62 #define USHRT_MAX_SINGLE ((float)USHRT_MAX) 63 #define SHRT_MAX_SINGLE ((float)SHRT_MAX) 64 #define UCHAR_MAX_DOUBLE ((double)UCHAR_MAX) 65 #define UCHAR_MAX_SINGLE ((float)UCHAR_MAX) 66 #define INV_USHRT_MAX_SINGLE .000015259022f // 1/65535 67 #define INV_UCHAR_MAX_SINGLE .0039215686f // 1/255 68 69 #define BYTES_IN_A_MB 1048576 // 1024 70 71 #define SEQUENCE_DEFAULT_INCLUDE TRUE // select images by default 72 73 typedef unsigned char BYTE; // default type for image display data 74 typedef unsigned short WORD; // default type for internal image data 75 76 #define MAX_SEQPSF 7 // max number of stars for which seqpsf can be run 77 78 #define CMD_HISTORY_SIZE 50 // size of the command line history 79 80 #define ZOOM_MAX 128 81 #define ZOOM_MIN 0.03125 82 #define ZOOM_IN 1.5 83 #define ZOOM_OUT 1.0 / ZOOM_IN 84 #define ZOOM_NONE 1.0 85 #define ZOOM_FIT -1.0 // or any value < 0 86 #define ZOOM_DEFAULT ZOOM_FIT 87 88 /* Some statistic constants */ 89 #define SIGMA_PER_FWHM 2.35482 90 #define AVGDEV_NORM 1.2533 91 #define MAD_NORM 1.4826 92 #define BWMV_NORM 0.9901 93 #define PBMV_NORM 0.9709 94 #define SN_NORM 1.1926 95 #define QN_NORM 2.2191 96 97 typedef struct _SirilDialogEntry SirilDialogEntry; 98 99 /* used for open and savedialog */ 100 typedef GtkWidget SirilWidget; 101 102 #if (defined _WIN32) || (defined(OS_OSX)) 103 #define SIRIL_EOL "\r\n" 104 #else 105 #define SIRIL_EOL "\n" 106 #endif 107 108 /* when requesting an image redraw, it can be asked to remap its data before redrawing it. 109 * REMAP_NONE doesn't remaps the data, 110 * REMAP_ONLY remaps only the current viewport (color channel) and the mixed (RGB) image 111 * REMAP_ALL remaps all view ports, useful when all the colors come from the same file. 112 */ 113 #define REMAP_NONE 0 114 #define REMAP_ONLY 1 115 #define REMAP_ALL 2 116 117 typedef enum { 118 TYPEUNDEF = (1 << 1), 119 TYPEFITS = (1 << 2), 120 TYPETIFF = (1 << 3), 121 TYPEBMP = (1 << 4), 122 TYPEPNG = (1 << 5), 123 TYPEJPG = (1 << 6), 124 TYPEHEIF = (1 << 7), 125 TYPEPNM = (1 << 8), 126 TYPEPIC = (1 << 9), 127 TYPERAW = (1 << 10), 128 TYPEAVI = (1 << 20), 129 TYPESER = (1 << 21), 130 } image_type; 131 132 /* indices of the image data layers */ 133 #define BW_LAYER 0 134 #define RLAYER 0 135 #define GLAYER 1 136 #define BLAYER 2 137 #define RGB_LAYER 3 138 139 /* indices of the viewports (graphical elements) */ 140 #define BW_VPORT 0 141 #define RED_VPORT 0 142 #define GREEN_VPORT 1 143 #define BLUE_VPORT 2 144 #define RGB_VPORT 3 145 #define MAXGRAYVPORT 3 // 3 gray vports supported only (R, G, B) 146 #define MAXCOLORVPORT 1 // 1 color vport supported only (RGB) 147 #define MAXVPORT MAXGRAYVPORT + MAXCOLORVPORT 148 149 /* defines for copyfits actions */ 150 #define CP_INIT 0x01 // initialize data array with 0s 151 #define CP_ALLOC 0x02 // reallocs data array 152 #define CP_COPYA 0x04 // copy data array content 153 #define CP_FORMAT 0x08 // copy metadata 154 #define CP_EXPAND 0x20 // expands a one-channel to a three channels 155 156 #define PREVIEW_NB 2 157 158 /* special values for com.seq.current, the currently loaded image of the 159 * sequence. Negative values can be used to indicate that a specific image is 160 * loaded while there is a sequence or not in com.seq */ 161 #define RESULT_IMAGE -1 // used as current image index in a sequence 162 // when the result of a processing is displayed 163 #define UNRELATED_IMAGE -2 // image loaded while a sequence was loaded too 164 #define SCALED_IMAGE -3 // the single image has a different size than 165 // the loaded sequence 166 167 #define MAX_STARS 200000 // maximum length of com.stars 168 169 #define INDEX_MAX 100000 // maximum index for images 170 171 typedef struct imdata imgdata; 172 typedef struct registration_data regdata; 173 typedef struct layer_info_struct layer_info; 174 typedef struct sequ sequence; 175 typedef struct single_image single; 176 typedef struct wcs_struct wcs_info; 177 typedef struct dft_struct dft_info; 178 typedef struct ffit fits; 179 typedef struct libraw_config libraw; 180 typedef struct phot_config phot; 181 typedef struct stack_config stackconf; 182 typedef struct comp_config compconf; 183 typedef struct cominf cominfo; 184 typedef struct image_stats imstats; 185 typedef struct rectangle_struct rectangle; 186 typedef struct point_struct point; 187 typedef struct pointf_struct pointf; 188 typedef struct pointi_struct pointi; 189 typedef struct historic_struct historic; 190 typedef struct fwhm_struct fitted_PSF; 191 typedef struct star_finder_struct star_finder_params; 192 typedef struct pref_struct preferences; 193 typedef struct save_config_struct save_config; 194 195 /* global structures */ 196 197 typedef enum { 198 LINEAR_DISPLAY, 199 LOG_DISPLAY, 200 SQRT_DISPLAY, 201 SQUARED_DISPLAY, 202 ASINH_DISPLAY, 203 STF_DISPLAY, 204 HISTEQ_DISPLAY 205 } display_mode; // used in the layer_info_struct below 206 #define DISPLAY_MODE_MAX HISTEQ_DISPLAY 207 208 typedef enum { 209 NORMAL_COLOR, 210 RAINBOW_COLOR 211 } color_map; 212 213 typedef enum { 214 MIPSLOHI, 215 MINMAX, 216 USER 217 } sliders_mode; 218 219 typedef enum { 220 OPEN_IMAGE_ERROR = -1, 221 OPEN_IMAGE_OK = 0, 222 OPEN_IMAGE_CANCEL = 10, 223 } open_image_status; 224 225 typedef enum { 226 BAYER_BILINEAR, 227 BAYER_VNG, 228 BAYER_AHD, 229 BAYER_AMAZE, 230 BAYER_DCB, 231 BAYER_HPHD, 232 BAYER_IGV, 233 BAYER_LMMSE, 234 BAYER_RCD, 235 BAYER_SUPER_PIXEL, 236 XTRANS 237 } interpolation_method; 238 239 typedef enum { 240 OPENCV_NEAREST = 0, 241 OPENCV_LINEAR = 1, 242 OPENCV_CUBIC = 2, 243 OPENCV_AREA = 3, 244 OPENCV_LANCZOS4 = 4, 245 OPENCV_INTER_MAX = 7 246 } opencv_interpolation; 247 248 typedef enum { 249 BAYER_FILTER_RGGB, 250 BAYER_FILTER_BGGR, 251 BAYER_FILTER_GBRG, 252 BAYER_FILTER_GRBG, 253 XTRANS_FILTER, 254 BAYER_FILTER_NONE = -1 //case where pattern is undefined or untested 255 } sensor_pattern; 256 #define BAYER_FILTER_MIN BAYER_FILTER_RGGB 257 #define BAYER_FILTER_MAX BAYER_FILTER_GRBG 258 259 struct layer_info_struct { 260 char *name; // name of the layer (a filter name) 261 double wavelength; // the wavelength of the filter, in nanometres 262 WORD lo, hi; // the values of the cutoff sliders 263 //WORD min, max; // the min and max values of the sliders 264 gboolean cut_over, cut_under; // display values over hi or under lo as negative 265 display_mode rendering_mode; // defaults to LINEAR_DISPLAY 266 }; 267 268 typedef enum { SEQ_REGULAR, SEQ_SER, SEQ_FITSEQ, 269 #ifdef HAVE_FFMS2 270 SEQ_AVI, 271 #endif 272 SEQ_INTERNAL 273 } sequence_type; 274 275 /* image data, exists once for each image */ 276 struct imdata { 277 int filenum; /* real file index in the sequence, i.e. for mars9.fit = 9 */ 278 gboolean incl; /* selected in the sequence, included for future processings? */ 279 GDateTime *date_obs;/* date of the observation, processed and copied from the header */ 280 }; 281 282 /* registration data, exists once for each image and each layer */ 283 struct registration_data { 284 float shiftx, shifty; // we could have a subpixel precision, but is it needed? saved 285 fitted_PSF *fwhm_data; // used in PSF/FWHM registration, not saved 286 float fwhm; // copy of fwhm->fwhmx, used as quality indicator, saved data 287 float weighted_fwhm; // used to exclude spurious images. 288 float roundness; // fwhm->fwhmy / fwhm->fwhmx, 0 when uninit, ]0, 1] when set 289 double quality; 290 }; 291 292 /* see explanation about sequence and single image management in io/sequence.c */ 293 294 struct sequ { 295 char *seqname; // name of the sequence, as in name.seq 296 int number; // number of images in the sequence 297 int selnum; // number of selected images in the sequence 298 int fixed; // fixed length of image index in filename (like %3d) 299 int nb_layers; // number of layers embedded in each image file, -1 if unknown 300 unsigned int rx; // first image width 301 unsigned int ry; // first image height 302 int bitpix; // image pixel format, from fits 303 layer_info *layers; // info about layers, may be null if nb_layers is unknown 304 int reference_image; // reference image for registration 305 imgdata *imgparam; // a structure for each image of the sequence 306 regdata **regparam; // *regparam[nb_layers], may be null if nb_layers is unknown 307 imstats ***stats; // statistics of the images for each layer, may be null too 308 /* in the case of a CFA sequence, depending on the opening mode, we cannot store 309 * and use everything that was in the seqfile, so we back them up here */ 310 regdata **regparam_bkp; // *regparam[3], null if nothing to back up 311 imstats ***stats_bkp; // statistics of the images for 3 layers, may be null too 312 313 /* beg and end are used prior to imgparam allocation, hence their usefulness */ 314 int beg; // imgparam[0]->filenum 315 int end; // imgparam[number-1]->filenum 316 double exposure; // exposure of frames (we assume they are all identical) 317 318 sequence_type type; 319 struct ser_struct *ser_file; 320 gboolean cfa_opened_monochrome; // in case the CFA SER was opened in monochrome mode 321 struct fits_sequence *fitseq_file; // FITS sequence data structure 322 #ifdef HAVE_FFMS2 323 struct film_struct *film_file; 324 char *ext; // extension of video, NULL if not video 325 #endif 326 fits **internal_fits; // for INTERNAL sequences: images references. Length: number 327 fitsfile **fptr; // file descriptors for open-mode operations 328 #ifdef _OPENMP 329 omp_lock_t *fd_lock; // locks for open-mode threaded operations 330 #endif 331 332 int current; // file number currently loaded in gfit (or displayed) 333 334 /* registration previsualisation and manual alignment data */ 335 int previewX[PREVIEW_NB], previewY[PREVIEW_NB]; // center, -1 is uninitialized value 336 int previewW[PREVIEW_NB], previewH[PREVIEW_NB]; // 0 is uninitialized value 337 338 double upscale_at_stacking;// up-scale factor during stacking (see #215) 339 340 gboolean needs_saving; // a dirty flag for the sequence, avoid saving it too often 341 342 fitted_PSF **photometry[MAX_SEQPSF];// psf for multiple stars for all images 343 int reference_star; // reference star for apparent magnitude (index of photometry) 344 double reference_mag; // reference magnitude for the reference star 345 double photometry_colors[MAX_SEQPSF][3]; // colors for each photometry curve 346 }; 347 348 /* this struct is used to manage data associated with a single image loaded, outside a sequence */ 349 struct single_image { 350 char *filename; // the name of the file 351 gboolean fileexist;// flag of existing file 352 char *comment; // comment on how the file got there (user load, result...) 353 int nb_layers; // number of layers embedded in each image file 354 layer_info *layers; // info about layers 355 fits *fit; // the fits is still gfit, but a reference doesn't hurt 356 }; 357 358 struct wcs_struct { 359 double equinox; 360 double crpix[2]; 361 double crval[2]; 362 double cdelt[2]; 363 double cd[2][2]; 364 double crota[2]; 365 char objctra[FLEN_VALUE]; 366 char objctdec[FLEN_VALUE]; 367 }; 368 369 struct dft_struct { 370 double norm[3]; // Normalization value 371 char type[FLEN_VALUE]; // spectrum, phase 372 char ord[FLEN_VALUE]; // regular, centered 373 }; 374 375 typedef enum { DATA_USHORT, DATA_FLOAT, DATA_UNSUPPORTED } data_type; 376 377 struct ffit { 378 unsigned int rx; // image width (naxes[0]) 379 unsigned int ry; // image height (naxes[1]) 380 int bitpix; // current bitpix of loaded data 381 int orig_bitpix; // original bitpix of the file 382 /* bitpix can take the following values: 383 * BYTE_IMG (8-bit byte pixels, 0 - 255) 384 * SHORT_IMG (16 bit signed integer pixels) 385 * USHORT_IMG (16 bit unsigned integer pixels) (used by Siril, a bit unusual) 386 * LONG_IMG (32-bit integer pixels) 387 * FLOAT_IMG (32-bit floating point pixels) 388 * DOUBLE_IMG (64-bit floating point pixels) 389 * http://heasarc.nasa.gov/docs/software/fitsio/quick/node9.html 390 */ 391 int naxis; // number of dimensions of the image 392 long naxes[3]; // size of each dimension 393 /* naxes[0] is rx, naxes[1] is ry 394 * Then, for gray images, naxes[2] is unused in FITS but set to 1, and naxis is 2. 395 * For RGB images, naxes[2] is 3 and naxis is 3. 396 * */ 397 398 /* data obtained from the FITS file */ 399 char *header; // entire header of the FITS file. NULL for non-FITS file. 400 WORD lo; // MIPS-LO key in FITS file, which is "Lower visualization cutoff" 401 WORD hi; // MIPS-HI key in FITS file, which is "Upper visualization cutoff" 402 double data_max; // used to check if 32b float is in the [0, 1] range 403 float pixel_size_x, pixel_size_y; // XPIXSZ and YPIXSZ keys 404 unsigned int binning_x, binning_y; // XBINNING and YBINNING keys 405 gboolean unbinned; 406 char row_order[FLEN_VALUE]; 407 GDateTime *date, *date_obs; 408 double expstart, expend; 409 char instrume[FLEN_VALUE]; // INSTRUME key 410 char telescop[FLEN_VALUE]; // TELESCOP key 411 char observer[FLEN_VALUE]; // OBSERVER key 412 char bayer_pattern[FLEN_VALUE]; // BAYERPAT key Bayer Pattern if available 413 int bayer_xoffset, bayer_yoffset; 414 /* data obtained from FITS or RAW files */ 415 double focal_length, iso_speed, exposure, aperture, ccd_temp; 416 double cvf; // Conversion factor (e-/adu) 417 int key_gain, key_offset; // Gain, Offset values read in camera headers. 418 419 /* Plate Solving data */ 420 wcs_info wcsdata; // data from the header 421 #ifdef HAVE_WCSLIB 422 struct wcsprm *wcslib; // struct of the lib 423 #endif 424 425 /* data used in the Fourier space */ 426 dft_info dft; 427 428 /* data computed or set by Siril */ 429 imstats **stats; // stats of fit for each layer, null if naxes[2] is unknown 430 double mini, maxi; // min and max of the stats->max[3] 431 432 fitsfile *fptr; // file descriptor. Only used for file read and write. 433 434 data_type type; // use of data or fdata is managed by this 435 WORD *data; // 16-bit image data (depending on image type) 436 WORD *pdata[3]; // pointers on data, per layer data access (RGB) 437 float *fdata; // same with float 438 float *fpdata[3]; // same with float 439 440 gboolean top_down; // image data is stored top-down, normally false for FITS, true for SER 441 442 GSList *history; // Former HISTORY comments of FITS file 443 }; 444 445 /* This structure is used for all the elements in the box libraw_settings. 446 * Don't forget to update conversion.c:initialize_libraw_settings() data when 447 * modifying the glade settings */ 448 struct libraw_config { 449 double mul[3], bright; // Color & brightness adjustement mul[0] = red, mul[1] = green = 1, mul[2] = blue 450 int auto_mul, use_camera_wb, use_auto_wb; // White Balance parameters 451 int user_qual; // Index of the Matrix interpolation set in dcraw, 0: bilinear, 1: VNG, 2: PPG, 3: AHD 452 int user_black; // black point correction 453 double gamm[3]; // Gamma correction 454 }; 455 456 /* This structure is used for storing all parameters used in photometry module */ 457 struct phot_config { 458 double gain; // A/D converter gain in electrons per ADU 459 double inner; // Inner radius of the annulus used to measure local background. 460 double outer; // Outer radius of the annulus used to measure local background. 461 int minval, maxval; 462 }; 463 464 struct debayer_config { 465 gboolean open_debayer; // debayer images being opened 466 gboolean use_bayer_header; // use the pattern given in the file header 467 sensor_pattern bayer_pattern; // user-defined Bayer pattern 468 interpolation_method bayer_inter; // interpolation method for non-libraw debayer 469 gboolean top_down; // debayer top-down orientation 470 int xbayeroff, ybayeroff; // x and y Bayer offsets 471 }; 472 473 struct stack_config { 474 int method; // 0=sum, 1=median, 2=average, 3=pixel max, 4=pixel min - Use to save preferences in the init file 475 int normalisation_method; 476 int rej_method; 477 double sigma_low, sigma_high; 478 double linear_low, linear_high; 479 double percentile_low, percentile_high; 480 double esdt_outliers, esdt_significance; 481 enum { RATIO, AMOUNT } mem_mode; // mode of memory management 482 double memory_ratio; // ratio of available memory to use for stacking (and others) 483 double memory_amount; // amount of memory in GB to use for stacking (and others) 484 }; 485 486 struct comp_config { 487 gboolean fits_enabled; // true enabled 488 int fits_method; // 0=Rice, 1=GZIP1, 2=GZIP2, 3=Hcompress 489 double fits_quantization; // quantization factor for floating point compression 490 double fits_hcompress_scale; // scale factor for Hcompress compression 491 }; 492 493 struct rectangle_struct { 494 int x, y, w, h; 495 }; 496 497 struct point_struct { 498 double x, y; 499 }; 500 501 struct pointf_struct { 502 float x, y; 503 }; 504 505 struct pointi_struct { 506 int x, y; 507 }; 508 509 struct historic_struct { 510 char *filename; 511 char history[FLEN_VALUE]; 512 int rx, ry; 513 data_type type; 514 }; 515 516 struct star_finder_struct { 517 int radius; 518 int adj_radius; 519 gboolean adjust; 520 double sigma; 521 double roundness; 522 523 /** internal variable **/ 524 gboolean no_guess; // TRUE means no guess about resolution 525 }; 526 527 struct save_config_struct { 528 gboolean quit; 529 gboolean warn_script; 530 }; 531 532 /** 533 * This is the preference structure. 534 * WARNING!! 535 * If you update something in this structure you absolutely need to 536 * update pref_init in preferences.c 537 */ 538 struct pref_struct { 539 gboolean first_start; // use to display information at first use 540 /* state of window */ 541 gboolean remember_windows; 542 rectangle main_w_pos; 543 gboolean is_maximized; 544 545 gboolean prepro_cfa; // Use to save type of sensor for cosmetic correction in preprocessing 546 gboolean prepro_equalize_cfa; // Use to save if flat will be equalized in preprocessing 547 gboolean fix_xtrans; // Use to fix xtrans darks and biases with the AF square 548 rectangle xtrans_af; // if no xtrans model found, use these values 549 rectangle xtrans_sample; // if no xtrans model found, use these values 550 gchar *prepro_bias_lib; 551 gboolean use_bias_lib; 552 gchar *prepro_bias_synth; 553 gboolean use_bias_synth; 554 gchar *prepro_dark_lib; 555 gboolean use_dark_lib; 556 gchar *prepro_flat_lib; 557 gboolean use_flat_lib; 558 559 save_config save; 560 gboolean show_thumbnails; // show or don't show thumbnails in open dialog box 561 gint thumbnail_size; 562 gboolean check_update; // check update at startup 563 gboolean script_check_requires; // check the requires command in scripts 564 565 gint combo_theme; // value of the combobox theme 566 gdouble font_scale; // font scale 567 gboolean icon_symbolic; // icon style 568 gchar *combo_lang; // string value of the combobox lang 569 570 gchar *ext; // FITS extension used in SIRIL 571 572 gchar *swap_dir; // swap directory 573 GSList *script_path; // script path directories 574 575 gdouble focal; // focal length saved in config file 576 gdouble pitch; // pixel pitch saved in config file 577 578 libraw raw_set; // the libraw settings 579 struct debayer_config debayer; // debayer settings 580 phot phot_set; // photometry settings 581 gboolean catalog[6]; // Yet 6 catalogs 582 583 stackconf stack; // stacking option 584 compconf comp; // compression option 585 gboolean rgb_aladin; // Add CTYPE3='RGB' in the FITS header 586 587 gboolean force_to_16bit; 588 589 gint selection_guides; // number of elements of the grid guides (2 for a simple cross, 3 for the 3 thirds rule, etc.) 590 591 gchar *copyright; // User copyright when saving image as TIFF 592 }; 593 /** 594 * End of preference structure. Read above. 595 */ 596 597 /* The global data structure of siril, the only with gfit and the gtk builder, 598 * declared in main.c */ 599 struct cominf { 600 /* current version of GTK, through GdkPixmap, doesn't handle gray images, so 601 * graybufs are the same size than the rgbbuf with 3 times the same value */ 602 guchar *graybuf[MAXGRAYVPORT]; // one B/W display buffer per viewport (R,G,B) 603 guchar *rgbbuf; // one rgb display buffer 604 /* cairo image surface related data */ 605 int surface_stride[MAXVPORT]; // allocated stride 606 int surface_height[MAXVPORT]; // allocated height 607 cairo_surface_t *surface[MAXVPORT]; 608 gboolean buf_is_dirty[MAXVPORT];// dirtyness of each buffer (= need to redraw) 609 610 /* Color map */ 611 color_map color; 612 613 GtkWidget *vport[MAXVPORT]; // one drawingarea per layer, one rgb drawingarea 614 int cvport; // current viewport, index in the list vport above 615 GtkAdjustment *hadj[MAXVPORT]; // adjustments of vport scrollbars 616 GtkAdjustment *vadj[MAXVPORT]; // adjustments of vport scrollbars 617 sliders_mode sliders; // 0: min/max, 1: MIPS-LO/HI, 2: user 618 gboolean show_excluded; // show excluded images in sequences 619 620 cairo_matrix_t display_matrix; // matrix used for image rendering (convert image to display coordinates) 621 cairo_matrix_t image_matrix; // inverse of display_matrix (convert display to image coordinates) 622 double zoom_value; // 1.0 is normal zoom, use get_zoom_val() to access it 623 point display_offset; // image display offset 624 gboolean translating; // true we are in display transating mode 625 626 preferences pref; // saved variable in preferences 627 628 /* selection rectangle for registration, FWHM, PSF */ 629 gboolean drawing; // true if the rectangle is being set (clicked motion) 630 pointi start; // where the mouse was originally clicked to 631 pointi origin; // where the selection was originally located 632 gboolean freezeX, freezeY; // locked axis during modification of a selection 633 rectangle selection; // coordinates of the selection rectangle 634 double ratio; // enforced ratio of the selection (default is 0: none) 635 636 /* alignment preview data */ 637 //guchar *preview_buf[PREVIEW_NB]; 638 cairo_surface_t *preview_surface[PREVIEW_NB]; 639 GtkWidget *preview_area[PREVIEW_NB]; 640 guchar *refimage_regbuffer; // the graybuf[registration_layer] of the reference image 641 cairo_surface_t *refimage_surface; 642 643 gchar *wd; // working directory, where images and sequences are 644 gchar *initfile; // the path of the init file 645 646 int reg_settings; // Use to save registration method in the init file 647 648 gboolean cache_upscaled; // keep up-scaled files for 'drizzle' (only used by developers) 649 650 int filter; // file extension filter for open/save dialogs 651 652 /* history of the command line. This is a circular buffer (cmd_history) 653 * of size cmd_hist_size, position to be written is cmd_hist_current and 654 * position being browser for display of the history is cmd_hist_display. 655 */ 656 char **cmd_history; // the history of the command line 657 int cmd_hist_size; // allocated size 658 int cmd_hist_current; // current command index 659 int cmd_hist_display; // displayed command index 660 661 /* history of operations */ 662 historic *history; // the history of all operations 663 int hist_size; // allocated size 664 int hist_current; // current index 665 int hist_display; // displayed index 666 667 sequence seq; // currently loaded sequence TODO: *seq 668 single *uniq; // currently loaded image, if outside sequence 669 670 gsl_histogram *layers_hist[MAXVPORT]; // current image's histograms 671 672 star_finder_params starfinder_conf; // star finder settings, from GUI or init file 673 fitted_PSF **stars; // list of stars detected in the current image 674 gboolean star_is_seqdata; // the only star in stars belongs to seq, don't free it 675 int selected_star; // current selected star in the GtkListStore 676 double magOffset; // offset to reduce the real magnitude, single image 677 678 GSList *grad_samples; 679 GSList *found_object; 680 681 int max_thread; // maximum of thread used for parallel execution 682 683 GThread *thread; // the thread for processing 684 GMutex mutex; // a mutex we use for this thread 685 gboolean run_thread; // the main thread loop condition 686 687 gboolean headless; // pure console, no GUI 688 gboolean script; // scripts execution 689 gboolean stop_script; // abort script execution 690 GThread *script_thread; // reads a script and executes its commands 691 }; 692 693 /* this structure is used to characterize the statistics of the image */ 694 struct image_stats { 695 long total, // number of pixels 696 ngoodpix; // number of non-zero pixels 697 double mean, median, sigma, avgDev, mad, sqrtbwmv, 698 location, scale, min, max, normValue, bgnoise; 699 700 atomic_int* _nb_refs; // reference counting for data management 701 }; 702 703 typedef struct Homo { 704 double h00, h01, h02; 705 double h10, h11, h12; 706 double h20, h21, h22; 707 int pair_matched; 708 int Inliers; 709 } Homography; 710 711 #if 0 712 /* TODO: this structure aims to allow the composition of several 1-channel images and make 713 * more easy the management of RGB compositing */ 714 typedef struct image_layer_struct image_layer; 715 struct image_layer_struct { 716 char *layer_name; /* the name of the layer (the color or band name) */ 717 fits *fit; /* fits data of the layer */ 718 int naxis; /* this image is naxis in fits */ 719 guchar *graybuf; /* mapped image for display purposes */ 720 int stride; /* Cairo data width */ 721 cairo_surface_t *surface; /* Cairo image surface */ 722 GtkWidget *vport; /* the viewport */ 723 double wavelength; /* the wavelength associated with the channel */ 724 guchar rmap, gmap, bmap; /* mapping to rgb colors, initialized function of the wavelength */ 725 unsigned int hi, lo; /* same as fits_data->{hi,lo} but for display/compositing purposes */ 726 char *filename; /* the filename of the fits_data file */ 727 int naxis; /* axis number of the fits file filename, may not be 0 if it's an RGB fits for example */ 728 }; 729 #endif 730 731 #ifndef MAIN 732 extern GtkBuilder *builder; // get widget references anywhere 733 extern cominfo com; // the main data struct 734 extern fits gfit; // currently loaded image 735 #endif 736 737 #endif /*SIRIL */ 738