1 /* Manage display conversion parameters. 2 */ 3 4 /* 5 6 Copyright (C) 1991-2003 The National Gallery 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License along 19 with this program; if not, write to the Free Software Foundation, Inc., 20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 22 */ 23 24 /* 25 26 These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk 27 28 */ 29 30 #define TYPE_CONVERSION (conversion_get_type()) 31 #define CONVERSION( obj ) \ 32 (G_TYPE_CHECK_INSTANCE_CAST( (obj), TYPE_CONVERSION, Conversion )) 33 #define CONVERSION_CLASS( klass ) \ 34 (G_TYPE_CHECK_CLASS_CAST( (klass), TYPE_CONVERSION, ConversionClass)) 35 #define IS_CONVERSION( obj ) \ 36 (G_TYPE_CHECK_INSTANCE_TYPE( (obj), TYPE_CONVERSION )) 37 #define IS_CONVERSION_CLASS( klass ) \ 38 (G_TYPE_CHECK_CLASS_TYPE( (klass), TYPE_CONVERSION )) 39 #define CONVERSION_GET_CLASS( obj ) \ 40 (G_TYPE_INSTANCE_GET_CLASS( (obj), TYPE_CONVERSION, ConversionClass )) 41 42 struct _Conversion { 43 Model parent_class; 44 45 /* Image. 46 */ 47 Imageinfo *ii; /* Underlying image */ 48 guint changed_sid; /* Watch ii with these two */ 49 guint area_changed_sid; 50 REGION *reg; /* Region for input from underlying image */ 51 gboolean synchronous; /* TRUE to disable BG stuff */ 52 int priority; /* render priority */ 53 54 Imageinfo *visual_ii; /* Visualisation image ... eg. histplot */ 55 Imageinfo *display_ii; /* Sized and cached */ 56 int display_mag; /* What mag the display_ii is built for */ 57 IMAGE *mask; /* Read display mask from here */ 58 Imageinfo *repaint_ii; /* Colour converted for screen */ 59 REGION *ireg; /* Region for input from repaint image */ 60 REGION *mreg; /* Region for input from repaint mask */ 61 int tile_size; /* Set smaller for thumbnails */ 62 63 /* Basic geometry. 64 */ 65 Rect underlay; /* Size of underlying image (at 0,0) */ 66 Rect image; /* Size of visualisation image (at 0,0) */ 67 Rect canvas; /* Size of image we display (always at 0,0) */ 68 Rect visible; /* hint ... visible region of display image */ 69 int mag; /* -ve for shrink, +ve for expand */ 70 71 /* Visualisation controls. If enabled is set, we built the pipeline 72 * using these params. 73 */ 74 gboolean enabled; 75 gboolean changed; /* Trigger a rebuild with these */ 76 double scale; /* Contrast/brightness */ 77 double offset; 78 gboolean falsecolour; /* False colour display on */ 79 gboolean type; /* Interpret type field */ 80 }; 81 82 typedef struct _ConversionClass { 83 ModelClass parent_class; 84 85 /* My methods. 86 87 area_changed we forward the "area" changed signal off the 88 ii we are holding ... in repaint coordinates 89 90 */ 91 void (*area_changed)( Conversion *, Rect * ); 92 93 /* The imageinfo has been swapped for a new one. 94 */ 95 void (*imageinfo_changed)( Conversion * ); 96 } ConversionClass; 97 98 GType conversion_get_type( void ); 99 Conversion *conversion_new( Imageinfo *ii ); 100 101 void conversion_set_image( Conversion *conv, Imageinfo *ii ); 102 gboolean conversion_refresh_text( Conversion *conv ); 103 104 double conversion_dmag( int mag ); 105 int conversion_double( int mag ); 106 int conversion_halve( int mag ); 107 108 void conversion_disp_to_im( Conversion *conv, 109 int dx, int dy, int *ix, int *iy ); 110 void conversion_im_to_disp( Conversion *conv, 111 int ix, int iy, int *dx, int *dy ); 112 void conversion_disp_to_im_rect( Conversion *conv, Rect *dr, Rect *ir ); 113 void conversion_im_to_disp_rect( Conversion *conv, Rect *ir, Rect *dr ); 114 115 void conversion_set_mag( Conversion *conv, int mag ); 116 void conversion_set_synchronous( Conversion *conv, gboolean synchronous ); 117 void conversion_set_params( Conversion *conv, gboolean enabled, 118 double scale, double offset, gboolean falsecolour, gboolean type ); 119