PLplot  5.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
gcw.h
Go to the documentation of this file.
1 // gcw - PLplot Gnome Canvas Widget device driver.
2 //
3 // Copyright (C) 2004, 2005 Thomas J. Duck
4 // Copyright (C) 2004 Rafael Laboissiere
5 // All rights reserved.
6 //
7 // NOTICE
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
22 // USA
23 //
24 
25 #ifndef __GCW_H__
26 #define __GCW_H__
27 
28 #include "plDevs.h"
29 #include "plplotP.h"
30 #include "drivers.h"
31 
32 #include <math.h>
33 #include <stdio.h>
34 #include <sys/stat.h>
35 
36 #include <glib.h>
37 #include <gtk/gtk.h>
38 #include <libgnomecanvas/libgnomecanvas.h>
39 #include <libart_lgpl/libart.h>
40 #include <libgnomeprint/gnome-print.h>
41 
42 
43 // #define DEBUG_GCW_1
44 // #define DEBUG_GCW_2
45 // #define ASSERT_GCW
46 
47 
48 //--------------------------------------------------------------------------
49 // GcwPLdev - the PLplot device structure for the GCW driver
50 
51 typedef struct
52 {
53  GnomeCanvas * canvas; // The canvas to draw on
54  GdkPixmap * background; // The background
55  GdkGC * gc; // A graphics context for the pixmap
56 
57  GnomeCanvasGroup* group_visible; // Visible group, removed at next eop
58  GnomeCanvasGroup* group_hidden; // Hidden group --> visible at eop
59  GnomeCanvasGroup* group_persistent; // Persistent group, at from and never erased
60 
61  gboolean use_persistence; // Flags the persistent group should be used,
62  // and that it and the background should not be
63  // erased when the page is advanced.
64  //
65 
66  GtkWidget * window; // A window used in standalone mode
67  GtkWidget * notebook; // A notebook pager in the window
68  GtkWidget * statusbar; // A statusbar for the window
69  GtkWidget * filew; // A file widget chooser when Save is pressed
70 
71  guint32 color; // Current pen color
72  GdkColor bgcolor; // Background color (shouldn't change)
73  GdkColormap* colormap; // The gdk colormap for the canvas
74 
75  PLINT width; // Width of the canvas in device pixels
76  PLINT height; // Height of the canvas in device pixels
77 
78  PLINT pen_color; // Current pen color
79  PLINT pen_width; // Current pen width
80 
81  gboolean use_pixmap; // Flags pixmap use for lines and fills
82  gboolean pixmap_has_data; // Flags that the pixmap has data
83 
84  gboolean plstate_width; // Flags indicating change of state before
85  gboolean plstate_color0; // device is fully initialized
86  gboolean plstate_color1;
87 
88  gboolean allow_resize; // Flags whether device resizing is allowed
89 } GcwPLdev;
90 
91 
92 //--------------------------------------------------------------------------
93 // Physical dimension constants used by the driver
94 
95 // Virtual coordinate scaling parameter, used to do calculations at
96 // higher resolution. Chosen to be 32 for consistency with the PLplot
97 // metafile (see plplotP.h).
98 //
99 // The trick here is to do everything in device coordinates on the driver
100 // side, but report/receive everything in virtual coordinates to/from the
101 // PLplot core.
102 //
103 #define VSCALE ( 32. )
104 
105 // pixels per mm
106 #define DEVICE_PIXELS_PER_MM ( 3.4 )
107 #define VIRTUAL_PIXELS_PER_MM ( DEVICE_PIXELS_PER_MM * VSCALE )
108 
109 // mm per inch
110 #define MM_PER_IN ( 25.4 )
111 
112 // pixels per inch
113 #define DEVICE_PIXELS_PER_IN ( DEVICE_PIXELS_PER_MM * MM_PER_IN )
114 #define VIRTUAL_PIXELS_PER_IN ( VIRTUAL_PIXELS_PER_MM * MM_PER_IN )
115 
116 // Default dimensions of the canvas (in inches)
117 #define CANVAS_WIDTH ( 10. )
118 #define CANVAS_HEIGHT ( 7.5 )
119 
120 // The zoom factor for 100% zoom in
121 #define ZOOM100 ( 1.0 )
122 #define ZOOMSTEP ( 1.25 )
123 
124 
125 //--------------------------------------------------------------------------
126 // GCW "Gnome Canvas Widget" Library prototypes (see gcw-lib.c)
127 
128 // Public_functions
129 
130 void gcw_use_text( PLINT use_text );
131 void gcw_use_pixmap( PLINT use_pixmap );
132 void gcw_use_hrshsym( PLINT use_hrshsym );
133 
134 // Private functions
135 
136 void gcw_debug( char* msg );
139 PLDLLIMPEXP_GNOME2 void gcw_init_canvas( GnomeCanvas* canvas );
140 PLDLLIMPEXP_GNOME2 void gcw_install_canvas( GnomeCanvas *canvas );
141 PLDLLIMPEXP_GNOME2 void gcw_set_device_size( PLINT width, PLINT height );
142 void gcw_set_canvas_size( GnomeCanvas* canvas, PLINT width, PLINT height );
143 void gcw_set_canvas_zoom( GnomeCanvas* canvas, PLFLT magnification );
144 void gcw_use_persistence( PLINT use_persistence );
145 
146 #endif // __GCW_H__