~ubuntu-branches/debian/sid/genius/sid

« back to all changes in this revision

Viewing changes to gtkextra/gtkplotprint.c

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2014-04-07 15:43:04 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20140407154304-21r03zdnfc571kz0
Tags: 1.0.17-1
* Take over package from pkg-gnome
* New upstream release. Closes: #716731
* Bump standards version.
* Update Vcs fields to Git.
* Move to single-debian-patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * Boston, MA 02111-1307, USA.
18
18
 */
19
19
 
 
20
/**
 
21
 * SECTION: gtkplotprint
 
22
 * @short_description: 
 
23
 *
 
24
 * FIXME:: Need long description.
 
25
 */
 
26
 
20
27
#include <stdio.h>
21
28
#include <stdlib.h>
22
29
#include <string.h>
34
41
#include "gtkplotps.h"
35
42
#include "gtkplotdt.h"
36
43
#include "gtkplotsurface.h"
 
44
#include "gtkplotcairo.h"
37
45
#include "gtkplotcanvas.h"
38
46
 
39
47
static void recalc_pixels(GtkPlot *plot);
40
48
 
 
49
 
 
50
 
 
51
/**
 
52
 * gtk_plot_export_ps:
 
53
 * @plot: a #GtkPlot
 
54
 * @file_name:
 
55
 * @orient:
 
56
 * @epsflag:
 
57
 * @page_size:
 
58
 *
 
59
 * 
 
60
 *
 
61
 * Return value: 
 
62
 */
41
63
gboolean
42
64
gtk_plot_export_ps                              (GtkPlot *plot,
43
 
                                                 char *psname,
 
65
                                                 char *file_name,
44
66
                                                 GtkPlotPageOrientation orient,
45
67
                                                 gboolean epsflag,
46
68
                                                 GtkPlotPageSize page_size)
49
71
  GtkPlotPS *ps;
50
72
  gdouble scalex, scaley;
51
73
  gdouble m;
 
74
  GtkAllocation allocation;
52
75
 
53
76
 
54
77
  m = plot->magnification;
55
78
 
56
 
  ps = GTK_PLOT_PS(gtk_plot_ps_new(psname, orient, epsflag, page_size, 1.0, 1.0));
 
79
  ps = GTK_PLOT_PS(gtk_plot_ps_new(file_name, orient, epsflag, page_size, 1.0, 1.0));
 
80
 
 
81
  gtk_widget_get_allocation(GTK_WIDGET(plot), &allocation);
57
82
 
58
83
  if(orient == GTK_PLOT_PORTRAIT){
59
84
    scalex = (gfloat)ps->page_width /
60
 
                                (gfloat)GTK_WIDGET(plot)->allocation.width;
 
85
                                (gfloat)allocation.width;
61
86
    scaley = (gfloat)ps->page_height /
62
 
                                (gfloat)GTK_WIDGET(plot)->allocation.height;
 
87
                                (gfloat)allocation.height;
63
88
  }else{
64
89
    scalex = (gfloat)ps->page_width /
65
 
                                (gfloat)GTK_WIDGET(plot)->allocation.height;
 
90
                                (gfloat)allocation.height;
66
91
    scaley = (gfloat)ps->page_height /
67
 
                                (gfloat)GTK_WIDGET(plot)->allocation.width;
 
92
                                (gfloat)allocation.width;
68
93
  }
69
94
 
70
95
  gtk_plot_ps_set_scale(ps, scalex, scaley);
85
110
  return TRUE;
86
111
}
87
112
 
 
113
/**
 
114
 * gtk_plot_export_ps_with_size:
 
115
 * @plot: a #GtkPlot
 
116
 * @file_name:
 
117
 * @orient:
 
118
 * @epsflag:
 
119
 * @units:
 
120
 * @width:
 
121
 * @height:
 
122
 *
 
123
 * 
 
124
 *
 
125
 * Return value: 
 
126
 */
88
127
gboolean
89
128
gtk_plot_export_ps_with_size                    (GtkPlot *plot,
90
 
                                                 char *psname,
 
129
                                                 char *file_name,
91
130
                                                 GtkPlotPageOrientation orient,
92
131
                                                 gboolean epsflag,
93
132
                                                 GtkPlotUnits units,
98
137
  GtkPlotPS *ps;
99
138
  gdouble scalex, scaley;
100
139
  gdouble m;
 
140
  GtkAllocation allocation;
101
141
 
102
142
  m = plot->magnification;
103
143
 
104
 
  ps = GTK_PLOT_PS(gtk_plot_ps_new_with_size(psname, orient, epsflag, 
 
144
  ps = GTK_PLOT_PS(gtk_plot_ps_new_with_size(file_name, orient, epsflag, 
105
145
                                             units, 
106
146
                                             width, height, 
107
147
                                             1.0 , 1.0));
108
148
 
 
149
  gtk_widget_get_allocation(GTK_WIDGET(plot), &allocation);
109
150
  if(orient == GTK_PLOT_PORTRAIT){
110
151
    scalex = (gfloat)ps->page_width /
111
 
                                (gfloat)GTK_WIDGET(plot)->allocation.width;
 
152
                                (gfloat)allocation.width;
112
153
    scaley = (gfloat)ps->page_height /
113
 
                                (gfloat)GTK_WIDGET(plot)->allocation.height;
 
154
                                (gfloat)allocation.height;
114
155
  }else{
115
156
    scalex = (gfloat)ps->page_width /
116
 
                                (gfloat)GTK_WIDGET(plot)->allocation.height;
 
157
                                (gfloat)allocation.height;
117
158
    scaley = (gfloat)ps->page_height /
118
 
                                (gfloat)GTK_WIDGET(plot)->allocation.width;
 
159
                                (gfloat)allocation.width;
119
160
  }
120
161
 
121
162
  gtk_plot_ps_set_scale(ps, scalex, scaley);
136
177
  return TRUE;
137
178
}
138
179
 
 
180
/**
 
181
 * gtk_plot_canvas_export_ps:
 
182
 * @canvas: a #GtkPlotCanvas .
 
183
 * @file_name:
 
184
 * @orient:
 
185
 * @epsflag:
 
186
 * @page_size:
 
187
 *
 
188
 * 
 
189
 *
 
190
 * Return value: 
 
191
 */
139
192
gboolean
140
193
gtk_plot_canvas_export_ps                       (GtkPlotCanvas *canvas,
141
 
                                                 char *psname,
 
194
                                                 char *file_name,
142
195
                                                 GtkPlotPageOrientation orient,
143
196
                                                 gboolean epsflag,
144
197
                                                 GtkPlotPageSize page_size)
145
198
{
146
199
  GtkPlotPC *pc;
147
200
  GtkPlotPS *ps;
148
 
  gint old_width, old_height;
149
201
  gdouble scalex, scaley;
150
202
  gdouble m;
151
203
  GdkPixmap *pixmap;
152
204
 
153
205
  m = canvas->magnification;
154
206
 
155
 
  ps = GTK_PLOT_PS(gtk_plot_ps_new(psname, orient, epsflag, page_size, 1.0, 1.0));
 
207
  ps = GTK_PLOT_PS(gtk_plot_ps_new(file_name, orient, epsflag, page_size, 1.0, 1.0));
156
208
 
157
209
  if(orient == GTK_PLOT_PORTRAIT){
158
210
    scalex = (gfloat)ps->page_width / (gfloat)canvas->width;
164
216
 
165
217
  gtk_plot_ps_set_scale(ps, scalex, scaley);
166
218
 
167
 
  old_width = canvas->pixmap_width;
168
 
  old_height = canvas->pixmap_height;
169
 
 
170
219
  pc = canvas->pc;
171
 
  canvas->pc = GTK_PLOT_PC(ps);
172
220
 
173
221
  pixmap = canvas->pixmap;
174
222
  canvas->pixmap = NULL;
 
223
  canvas->pc = NULL;
175
224
  gtk_plot_canvas_set_magnification(canvas, 1.0);
 
225
  canvas->pc = GTK_PLOT_PC(ps);
 
226
  canvas->pixmap = pixmap;
176
227
 
177
228
  gtk_plot_canvas_paint(canvas);
 
229
 
 
230
  canvas->pixmap = NULL;
 
231
  canvas->pc = NULL;
178
232
  gtk_plot_canvas_set_magnification(canvas, m);
179
 
  gdk_pixmap_unref(canvas->pixmap);
180
233
  canvas->pixmap = pixmap;
181
 
 
182
234
  canvas->pc = pc;
 
235
 
183
236
  gtk_object_destroy(GTK_OBJECT(ps));
184
237
 
185
238
  return TRUE;
186
239
}
187
240
 
 
241
/**
 
242
 * gtk_plot_canvas_export_ps_with_size:
 
243
 * @canvas: a #GtkPlotCanvas .
 
244
 * @file_name:
 
245
 * @orient:
 
246
 * @epsflag:
 
247
 * @units:
 
248
 * @width:
 
249
 * @height:
 
250
 *
 
251
 * 
 
252
 *
 
253
 * Return value: 
 
254
 */
188
255
gboolean
189
256
gtk_plot_canvas_export_ps_with_size             (GtkPlotCanvas *canvas,
190
 
                                                 char *psname,
 
257
                                                 char *file_name,
191
258
                                                 GtkPlotPageOrientation orient,
192
259
                                                 gboolean epsflag,
193
260
                                                 GtkPlotUnits units,
202
269
 
203
270
  m = canvas->magnification;
204
271
 
205
 
  ps = GTK_PLOT_PS(gtk_plot_ps_new_with_size(psname, orient, epsflag, 
 
272
  ps = GTK_PLOT_PS(gtk_plot_ps_new_with_size(file_name, orient, epsflag, 
206
273
                                             units, 
207
274
                                             width, height, 
208
275
                                             1.0 , 1.0));
218
285
  gtk_plot_ps_set_scale(ps, scalex, scaley);
219
286
 
220
287
  pc = canvas->pc;
221
 
  canvas->pc = GTK_PLOT_PC(ps);
222
288
 
223
289
  pixmap = canvas->pixmap;
224
290
  canvas->pixmap = NULL;
 
291
  canvas->pc = NULL;
225
292
  gtk_plot_canvas_set_magnification(canvas, 1.0);
 
293
  canvas->pc = GTK_PLOT_PC(ps);
 
294
  canvas->pixmap = pixmap;
 
295
 
226
296
  gtk_plot_canvas_paint(canvas);
 
297
 
 
298
  canvas->pixmap = NULL;
 
299
  canvas->pc = NULL;
227
300
  gtk_plot_canvas_set_magnification(canvas, m);
228
 
  gdk_pixmap_unref(canvas->pixmap);
229
301
  canvas->pixmap = pixmap;
230
 
 
231
302
  canvas->pc = pc;
232
303
 
233
304
  gtk_object_destroy(GTK_OBJECT(ps));
234
305
 
235
306
  return TRUE;
236
307
}
 
308
 
237
309
static void
238
310
recalc_pixels(GtkPlot *plot)
239
311
{
266
338
  }
267
339
}
268
340
 
 
341
/**
 
342
 * gtk_plot_canvas_export_cairo:
 
343
 * @canvas: a #GtkPlotCanvas .
 
344
 * @cairo:
 
345
 *
 
346
 * 
 
347
 *
 
348
 * Return value: 
 
349
 */
 
350
 
 
351
gboolean
 
352
gtk_plot_canvas_export_cairo                    (GtkPlotCanvas *canvas,
 
353
                                                 cairo_t *cairo)
 
354
{
 
355
  GdkPixmap *pixmap;
 
356
  GtkPlotPC *pc, *new_pc;
 
357
  gdouble m;
 
358
 
 
359
  m = canvas->magnification;
 
360
  pc = canvas->pc;
 
361
  new_pc = GTK_PLOT_PC(gtk_plot_cairo_new(cairo));
 
362
 
 
363
  pixmap = canvas->pixmap;
 
364
  canvas->pixmap = NULL;
 
365
  canvas->pc = NULL;
 
366
  gtk_plot_canvas_set_magnification(canvas, 1.);
 
367
  canvas->pc = new_pc;
 
368
  canvas->pixmap = pixmap;
 
369
  gtk_plot_canvas_paint(canvas);
 
370
  canvas->pc = pc;
 
371
  gtk_plot_canvas_set_magnification(canvas, m);
 
372
  g_object_unref(new_pc);
 
373
 
 
374
  return TRUE;
 
375
}
 
376
 
 
377