~ubuntu-branches/ubuntu/intrepid/plplot/intrepid

« back to all changes in this revision

Viewing changes to doc/docbook/src/gui.html

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2006-11-04 10:19:34 UTC
  • mfrom: (2.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061104101934-mlirvdg4gpwi6i5q
Tags: 5.6.1-10
* Orphaning the package
* debian/control: Changed the maintainer to the Debian QA Group

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
2
2
<HTML
3
3
><HEAD
4
4
><TITLE
5
 
>Constructing Graphical Interfaces with PLplot</TITLE
 
5
>Embedding Plots in Graphical User Interfaces</TITLE
6
6
><META
7
7
NAME="GENERATOR"
8
 
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
9
9
REL="HOME"
10
10
TITLE="The PLplot Plotting Library"
11
11
HREF="index.html"><LINK
12
12
REL="UP"
13
13
TITLE=" Language Bindings "
14
 
HREF="p2080.html"><LINK
 
14
HREF="p2442.html"><LINK
15
15
REL="PREVIOUS"
16
16
TITLE="Custom Extensions to Tcl"
17
17
HREF="custom-extensions-tcl.html"><LINK
77
77
><A
78
78
NAME="gui"
79
79
></A
80
 
>Chapter 12. Constructing Graphical Interfaces with PLplot</H1
81
 
><P
82
 
>This chapter presents some ideas on how to use PLplot in conjunction
83
 
with Tcl, Tk, and [incr Tcl] to construct graphical interfaces to
84
 
scientific codes.
85
 
 
86
 
blah blah
 
80
>Chapter 13. Embedding Plots in Graphical User Interfaces</H1
 
81
><P
 
82
>This chapter describes how to embed plots in graphical user interfaces.
 
83
</P
 
84
><DIV
 
85
CLASS="sect1"
 
86
><H1
 
87
CLASS="sect1"
 
88
><A
 
89
NAME="plplotcanvas"
 
90
>The PlplotCanvas Widget for Gnome/GTK Applications</A
 
91
></H1
 
92
><P
 
93
>    Plots can be embedded into Gnome/GTK applications by using the
 
94
    PlplotCanvas widget.  Information on the GTK toolkit is provided
 
95
    at http://www.gtk.org/.  PlplotCanvas is a subclass of the GnomeCanvas
 
96
    (see http://developer.gnome.org/doc/API/2.0/libgnomecanvas/index.html), 
 
97
    and so includes all of its functionality.  The specialized C API for 
 
98
    PlplotCanvas is described in
 
99
    <A
 
100
HREF="gui.html#plplotcanvas-api"
 
101
>the Section called <I
 
102
>PlplotCanvas API</I
 
103
></A
 
104
>, and bindings to other languages
 
105
    are described in *** NEEDS DOCUMENTATION ***.
87
106
  </P
 
107
><DIV
 
108
CLASS="sect2"
 
109
><H2
 
110
CLASS="sect2"
 
111
><A
 
112
NAME="plplotcanvas-basics"
 
113
>PlplotCanvas Basics</A
 
114
></H2
 
115
><P
 
116
>      The method declarations and data structures are defined in 
 
117
      <TT
 
118
CLASS="filename"
 
119
>plplotcanvas.h</TT
 
120
>.  Programs using the PlplotCanvas
 
121
      widget must be linked against the 
 
122
      <TT
 
123
CLASS="filename"
 
124
>libplplotgnome2d</TT
 
125
> library 
 
126
      rather than <TT
 
127
CLASS="filename"
 
128
>libplplotd</TT
 
129
>.  This is most easily 
 
130
      accomplished using pkg-config; i.e.,
 
131
 
 
132
      <TABLE
 
133
CLASS="verbatim"
 
134
><TR
 
135
><TD
 
136
><PRE
 
137
CLASS="programlisting"
 
138
>        gcc plplotcanvas_demo.c -o plplotcanvas_demo `pkg-config --cflags --libs plplotd-gnome2`
 
139
      </PRE
 
140
></TD
 
141
></TR
 
142
></TABLE
 
143
>
 
144
 
 
145
      You may need to remind pkg-config where to look for the 
 
146
      <TT
 
147
CLASS="filename"
 
148
>plplotd-gnome2.pc</TT
 
149
> file installed by PLplot; e.g.,
 
150
 
 
151
      <TABLE
 
152
CLASS="verbatim"
 
153
><TR
 
154
><TD
 
155
><PRE
 
156
CLASS="programlisting"
 
157
>        gcc plplotcanvas_demo.c -o plplotcanvas_demo `PKG_CONFIG_PATH=/usr/local/lib/pkgconfig pkg-config --cflags --libs plplotd-gnome2`
 
158
      </PRE
 
159
></TD
 
160
></TR
 
161
></TABLE
 
162
>
 
163
    </P
 
164
><P
 
165
>      A specialized API is provided for PlplotCanvas and is described in
 
166
      <A
 
167
HREF="gui.html#plplotcanvas-api"
 
168
>the Section called <I
 
169
>PlplotCanvas API</I
 
170
></A
 
171
>.  The API provides methods
 
172
      to create and manipulate PlplotCanvas widgets, in addition to
 
173
      object-oriented analogues for each of the PLplot functions.
 
174
    </P
 
175
><P
 
176
>      Example programs are provided that demonstrate the use of the 
 
177
      PlplotCanvas widget in <A
 
178
HREF="gui.html#plplotcanvas-examples"
 
179
>the Section called <I
 
180
>PlplotCanvas Examples</I
 
181
></A
 
182
>.
 
183
    </P
 
184
></DIV
 
185
><DIV
 
186
CLASS="sect2"
 
187
><H2
 
188
CLASS="sect2"
 
189
><A
 
190
NAME="plplotcanvas-api"
 
191
>PlplotCanvas API</A
 
192
></H2
 
193
><P
 
194
>      The PlplotCanvas methods are as follows.  Because PlplotCanvas is a
 
195
      GTK widget, GLib types (gint, gdouble, gboolean, etc) are sometimes 
 
196
      used rather than PLplot types (PLINT, PLFLT, etc).  See 
 
197
      http://developer.gnome.org/doc/API/2.0/glib/index.html for more 
 
198
      information on GLib and GLib types.
 
199
    </P
 
200
><DIV
 
201
CLASS="sect3"
 
202
><H3
 
203
CLASS="sect3"
 
204
><A
 
205
NAME="plplot_canvas_new"
 
206
><CODE
 
207
CLASS="function"
 
208
>plplot_canvas_new</CODE
 
209
>: Creates a new PlplotCanvas.</A
 
210
></H3
 
211
><P
 
212
>        <DIV
 
213
CLASS="funcsynopsis"
 
214
><P
 
215
></P
 
216
><A
 
217
NAME="AEN3061"
 
218
></A
 
219
><TABLE
 
220
CLASS="funcprototype"
 
221
><TR
 
222
><TD
 
223
><CODE
 
224
CLASS="FUNCDEF"
 
225
>            PlplotCanvas* plplot_canvas_new
 
226
          </CODE
 
227
>(void);</TD
 
228
></TR
 
229
></TABLE
 
230
><P
 
231
></P
 
232
></DIV
 
233
>
 
234
      </P
 
235
><P
 
236
>        Returns a pointer to a new PlplotCanvas widget.  Methods that
 
237
        apply to a PlplotCanvas are given next.
 
238
      </P
 
239
><TABLE
 
240
CLASS="variablelist"
 
241
><TR
 
242
><TD
 
243
><DL
 
244
><DT
 
245
><CODE
 
246
CLASS="parameter"
 
247
>void</CODE
 
248
></DT
 
249
><DD
 
250
><P
 
251
>            There are no arguments for this method.
 
252
          </P
 
253
></DD
 
254
></DL
 
255
></TD
 
256
></TR
 
257
></TABLE
 
258
></DIV
 
259
><DIV
 
260
CLASS="sect3"
 
261
><H3
 
262
CLASS="sect3"
 
263
><A
 
264
NAME="plplot_canvas_plfunc"
 
265
><CODE
 
266
CLASS="function"
 
267
>plplot_canvas_plfunc</CODE
 
268
>: PLplot function analogues.</A
 
269
></H3
 
270
><P
 
271
>        <DIV
 
272
CLASS="funcsynopsis"
 
273
><P
 
274
></P
 
275
><A
 
276
NAME="AEN3078"
 
277
></A
 
278
><TABLE
 
279
CLASS="funcprototype"
 
280
><TR
 
281
><TD
 
282
><CODE
 
283
CLASS="FUNCDEF"
 
284
>void plplot_canvas_plfunc</CODE
 
285
>(canvas, ...);</TD
 
286
></TR
 
287
></TABLE
 
288
><P
 
289
></P
 
290
></DIV
 
291
>
 
292
      </P
 
293
><P
 
294
>        The PLplot functions have analogue methods named like
 
295
        <CODE
 
296
CLASS="function"
 
297
>plplot_canvas_plfunc</CODE
 
298
>.  For example, the 
 
299
        PLplot function <A
 
300
HREF="plline.html"
 
301
><CODE
 
302
CLASS="function"
 
303
>plline</CODE
 
304
></A
 
305
> maps to 
 
306
        <CODE
 
307
CLASS="function"
 
308
>plplot_canvas_plline</CODE
 
309
>.  The 
 
310
        <CODE
 
311
CLASS="function"
 
312
>plplot_canvas_plfunc</CODE
 
313
> methods
 
314
        should be used rather than the standard PLplot API when the
 
315
        PlplotCanvas is used.
 
316
      </P
 
317
><P
 
318
>        Lines drawn to the canvas are not shown until the page is
 
319
        advanced using <CODE
 
320
CLASS="function"
 
321
>plplot_canvas_pladv</CODE
 
322
>.  The 
 
323
        plot will remain on the canvas until the next page advance.
 
324
      </P
 
325
><P
 
326
>        The PLplot <A
 
327
HREF="plinit.html"
 
328
><CODE
 
329
CLASS="function"
 
330
>plinit</CODE
 
331
></A
 
332
> and <A
 
333
HREF="plgstrm.html"
 
334
><CODE
 
335
CLASS="function"
 
336
>plgstrm</CODE
 
337
></A
 
338
> functions are not used with 
 
339
        PlplotCanvas because the <CODE
 
340
CLASS="function"
 
341
>plplot_canvas_new</CODE
 
342
>
 
343
        function does the necessary initialization and returns an 
 
344
        object with a unique stream number.
 
345
      </P
 
346
><TABLE
 
347
CLASS="variablelist"
 
348
><TR
 
349
><TD
 
350
><DL
 
351
><DT
 
352
><CODE
 
353
CLASS="parameter"
 
354
>canvas</CODE
 
355
 
356
            (<TT
 
357
CLASS="literal"
 
358
>PlplotCanvas*</TT
 
359
>, input)</DT
 
360
><DD
 
361
><P
 
362
>The canvas on which to operate.</P
 
363
></DD
 
364
><DT
 
365
><CODE
 
366
CLASS="parameter"
 
367
>...</CODE
 
368
></DT
 
369
><DD
 
370
><P
 
371
>            The list of arguments from the PLplot function analogue.  The
 
372
            same types used in the PLplot function are used here.
 
373
          </P
 
374
></DD
 
375
></DL
 
376
></TD
 
377
></TR
 
378
></TABLE
 
379
></DIV
 
380
><DIV
 
381
CLASS="sect3"
 
382
><H3
 
383
CLASS="sect3"
 
384
><A
 
385
NAME="plplot_canvas_dispose"
 
386
><CODE
 
387
CLASS="function"
 
388
>plplot_canvas_dispose</CODE
 
389
>: Disposes the canvas.</A
 
390
></H3
 
391
><P
 
392
>        <DIV
 
393
CLASS="funcsynopsis"
 
394
><P
 
395
></P
 
396
><A
 
397
NAME="AEN3116"
 
398
></A
 
399
><TABLE
 
400
CLASS="funcprototype"
 
401
><TR
 
402
><TD
 
403
><CODE
 
404
CLASS="FUNCDEF"
 
405
>void plplot_canvas_dispose</CODE
 
406
>(canvas);</TD
 
407
></TR
 
408
></TABLE
 
409
><P
 
410
></P
 
411
></DIV
 
412
>
 
413
      </P
 
414
><P
 
415
>        Disposes the Canvas.
 
416
      </P
 
417
><TABLE
 
418
CLASS="variablelist"
 
419
><TR
 
420
><TD
 
421
><DL
 
422
><DT
 
423
><CODE
 
424
CLASS="parameter"
 
425
>canvas</CODE
 
426
 
427
            (<TT
 
428
CLASS="literal"
 
429
>PlplotCanvas*</TT
 
430
>, input)</DT
 
431
><DD
 
432
><P
 
433
>The canvas to dispose.</P
 
434
></DD
 
435
></DL
 
436
></TD
 
437
></TR
 
438
></TABLE
 
439
></DIV
 
440
><DIV
 
441
CLASS="sect3"
 
442
><H3
 
443
CLASS="sect3"
 
444
><A
 
445
NAME="plplot_canvas_set_size"
 
446
><CODE
 
447
CLASS="function"
 
448
>plplot_canvas_set_size</CODE
 
449
>: Sets the canvas size.</A
 
450
></H3
 
451
><P
 
452
>        <DIV
 
453
CLASS="funcsynopsis"
 
454
><P
 
455
></P
 
456
><A
 
457
NAME="AEN3134"
 
458
></A
 
459
><TABLE
 
460
CLASS="funcprototype"
 
461
><TR
 
462
><TD
 
463
><CODE
 
464
CLASS="FUNCDEF"
 
465
>            void plplot_canvas_set_size
 
466
          </CODE
 
467
>(canvas, width, height);</TD
 
468
></TR
 
469
></TABLE
 
470
><P
 
471
></P
 
472
></DIV
 
473
>
 
474
      </P
 
475
><P
 
476
>        Sets the PlplotCanvas widget width and height.
 
477
      </P
 
478
><TABLE
 
479
CLASS="variablelist"
 
480
><TR
 
481
><TD
 
482
><DL
 
483
><DT
 
484
><CODE
 
485
CLASS="parameter"
 
486
>canvas</CODE
 
487
 
488
            (<TT
 
489
CLASS="literal"
 
490
>PlplotCanvas*</TT
 
491
>, input)</DT
 
492
><DD
 
493
><P
 
494
>The PlplotCanvas to size.</P
 
495
></DD
 
496
><DT
 
497
><CODE
 
498
CLASS="parameter"
 
499
>width</CODE
 
500
> (<TT
 
501
CLASS="literal"
 
502
>gint</TT
 
503
>, input)</DT
 
504
><DD
 
505
><P
 
506
>The width, in pixels.</P
 
507
></DD
 
508
><DT
 
509
><CODE
 
510
CLASS="parameter"
 
511
>height</CODE
 
512
> (<TT
 
513
CLASS="literal"
 
514
>gint</TT
 
515
>, input)</DT
 
516
><DD
 
517
><P
 
518
>The height, in pixels.</P
 
519
></DD
 
520
></DL
 
521
></TD
 
522
></TR
 
523
></TABLE
 
524
></DIV
 
525
><DIV
 
526
CLASS="sect3"
 
527
><H3
 
528
CLASS="sect3"
 
529
><A
 
530
NAME="plplot_canvas_use_text"
 
531
><CODE
 
532
CLASS="function"
 
533
>plplot_canvas_use_text</CODE
 
534
>: Sets text handling.</A
 
535
></H3
 
536
><P
 
537
>        <DIV
 
538
CLASS="funcsynopsis"
 
539
><P
 
540
></P
 
541
><A
 
542
NAME="AEN3168"
 
543
></A
 
544
><TABLE
 
545
CLASS="funcprototype"
 
546
><TR
 
547
><TD
 
548
><CODE
 
549
CLASS="FUNCDEF"
 
550
>void plplot_canvas_use_text</CODE
 
551
>(canvas, use_text);</TD
 
552
></TR
 
553
></TABLE
 
554
><P
 
555
></P
 
556
></DIV
 
557
>
 
558
      </P
 
559
><P
 
560
>        Sets whether TrueType text or Hershey fonts are used by the
 
561
        PlplotCanvas widget.
 
562
      </P
 
563
><TABLE
 
564
CLASS="variablelist"
 
565
><TR
 
566
><TD
 
567
><DL
 
568
><DT
 
569
><CODE
 
570
CLASS="parameter"
 
571
>canvas</CODE
 
572
 
573
            (<TT
 
574
CLASS="literal"
 
575
>PlplotCanvas*</TT
 
576
>, input)</DT
 
577
><DD
 
578
><P
 
579
>The PlplotCanvas to set.</P
 
580
></DD
 
581
><DT
 
582
><CODE
 
583
CLASS="parameter"
 
584
>use_text</CODE
 
585
 
586
            (<TT
 
587
CLASS="literal"
 
588
>gboolean</TT
 
589
>, input)</DT
 
590
><DD
 
591
><P
 
592
>            TRUE for TrueType fonts (default), FALSE for Hershey fonts.
 
593
          </P
 
594
></DD
 
595
></DL
 
596
></TD
 
597
></TR
 
598
></TABLE
 
599
></DIV
 
600
><DIV
 
601
CLASS="sect3"
 
602
><H3
 
603
CLASS="sect3"
 
604
><A
 
605
NAME="plplot_canvas_use_pixmap"
 
606
><CODE
 
607
CLASS="function"
 
608
>plplot_canvas_use_pixmap</CODE
 
609
>: Sets pixmap usage.</A
 
610
></H3
 
611
><P
 
612
>        <DIV
 
613
CLASS="funcsynopsis"
 
614
><P
 
615
></P
 
616
><A
 
617
NAME="AEN3194"
 
618
></A
 
619
><TABLE
 
620
CLASS="funcprototype"
 
621
><TR
 
622
><TD
 
623
><CODE
 
624
CLASS="FUNCDEF"
 
625
>void plplot_canvas_use_pixmap</CODE
 
626
>(canvas, use_pixmap);</TD
 
627
></TR
 
628
></TABLE
 
629
><P
 
630
></P
 
631
></DIV
 
632
>
 
633
      </P
 
634
><P
 
635
>        Sets whether lines and shades are drawn to a pixmap,
 
636
        or instead as vector graphics.
 
637
      </P
 
638
><P
 
639
>        Lines and shade drawn to the pixmap are not anti-aliased, and so may
 
640
        appear pixelated.  Vector graphics are fully anti-aliased, but are
 
641
        rendered at a slower speed.
 
642
      </P
 
643
><TABLE
 
644
CLASS="variablelist"
 
645
><TR
 
646
><TD
 
647
><DL
 
648
><DT
 
649
><CODE
 
650
CLASS="parameter"
 
651
>canvas</CODE
 
652
 
653
            (<TT
 
654
CLASS="literal"
 
655
>PlplotCanvas*</TT
 
656
>, input)</DT
 
657
><DD
 
658
><P
 
659
>The PlplotCanvas to set.</P
 
660
></DD
 
661
><DT
 
662
><CODE
 
663
CLASS="parameter"
 
664
>use_pixmap</CODE
 
665
 
666
            (<TT
 
667
CLASS="literal"
 
668
>gboolean</TT
 
669
>, input)</DT
 
670
><DD
 
671
><P
 
672
>            TRUE to use pixmap (default), FALSE for vector graphics instead.
 
673
          </P
 
674
></DD
 
675
></DL
 
676
></TD
 
677
></TR
 
678
></TABLE
 
679
></DIV
 
680
><DIV
 
681
CLASS="sect3"
 
682
><H3
 
683
CLASS="sect3"
 
684
><A
 
685
NAME="plplot_canvas_use_persistence"
 
686
><CODE
 
687
CLASS="function"
 
688
>plplot_canvas_use_persistence</CODE
 
689
>: Sets persistence
 
690
        of subsequent drawing operations.</A
 
691
></H3
 
692
><P
 
693
>        <DIV
 
694
CLASS="funcsynopsis"
 
695
><P
 
696
></P
 
697
><A
 
698
NAME="AEN3221"
 
699
></A
 
700
><TABLE
 
701
CLASS="funcprototype"
 
702
><TR
 
703
><TD
 
704
><CODE
 
705
CLASS="FUNCDEF"
 
706
>            void plplot_canvas_use_persistence
 
707
          </CODE
 
708
>(canvas, use_persistence);</TD
 
709
></TR
 
710
></TABLE
 
711
><P
 
712
></P
 
713
></DIV
 
714
>
 
715
      </P
 
716
><P
 
717
>        Sets whether the subsequent drawing commands are persistent,
 
718
        or refreshed when the PLplot page is advanced.  This feature
 
719
        is useful for plot animations, because the axes can be persistent
 
720
        rather than redrawn for each frame.
 
721
      </P
 
722
><P
 
723
>        Note that lines that are persistent are always anti-aliased and
 
724
        drawn at the front.
 
725
      </P
 
726
><TABLE
 
727
CLASS="variablelist"
 
728
><TR
 
729
><TD
 
730
><DL
 
731
><DT
 
732
><CODE
 
733
CLASS="parameter"
 
734
>canvas</CODE
 
735
 
736
            (<TT
 
737
CLASS="literal"
 
738
>PlplotCanvas*</TT
 
739
>, input)</DT
 
740
><DD
 
741
><P
 
742
>The PlplotCanvas to set.</P
 
743
></DD
 
744
><DT
 
745
><CODE
 
746
CLASS="parameter"
 
747
>use_persistence</CODE
 
748
 
749
            (<TT
 
750
CLASS="literal"
 
751
>gboolean</TT
 
752
>, input)</DT
 
753
><DD
 
754
><P
 
755
>            TRUE for persistence, FALSE for erasing at new page (default).
 
756
          </P
 
757
></DD
 
758
></DL
 
759
></TD
 
760
></TR
 
761
></TABLE
 
762
></DIV
 
763
><DIV
 
764
CLASS="sect3"
 
765
><H3
 
766
CLASS="sect3"
 
767
><A
 
768
NAME="plplot_canvas_get_stream_number"
 
769
><CODE
 
770
CLASS="function"
 
771
>plplot_canvas_get_stream_number</CODE
 
772
>: Retrieves the
 
773
        PLplot stream number.</A
 
774
></H3
 
775
><P
 
776
>        <DIV
 
777
CLASS="funcsynopsis"
 
778
><P
 
779
></P
 
780
><A
 
781
NAME="AEN3248"
 
782
></A
 
783
><TABLE
 
784
CLASS="funcprototype"
 
785
><TR
 
786
><TD
 
787
><CODE
 
788
CLASS="FUNCDEF"
 
789
>            PLINT plplot_canvas_get_stream_number
 
790
          </CODE
 
791
>(canvas);</TD
 
792
></TR
 
793
></TABLE
 
794
><P
 
795
></P
 
796
></DIV
 
797
>
 
798
      </P
 
799
><P
 
800
>        Returns the stream number for the given Canvas.  Although the 
 
801
        concept of streams that exists in the standard PLplot API is not
 
802
        used here, the stream number provides a unique ID number for
 
803
        the given PlplotCanvas widget.
 
804
      </P
 
805
><TABLE
 
806
CLASS="variablelist"
 
807
><TR
 
808
><TD
 
809
><DL
 
810
><DT
 
811
><CODE
 
812
CLASS="parameter"
 
813
>canvas</CODE
 
814
>
 
815
            (<TT
 
816
CLASS="literal"
 
817
>PlplotCanvas*</TT
 
818
>, input)</DT
 
819
><DD
 
820
><P
 
821
>            The canvas to retrieve the stream number from.
 
822
          </P
 
823
></DD
 
824
></DL
 
825
></TD
 
826
></TR
 
827
></TABLE
 
828
></DIV
 
829
></DIV
 
830
><DIV
 
831
CLASS="sect2"
 
832
><H2
 
833
CLASS="sect2"
 
834
><A
 
835
NAME="plplotcanvas-examples"
 
836
>PlplotCanvas Examples</A
 
837
></H2
 
838
><P
 
839
>
 
840
      Two example programs are provided that demonstrate the use of the
 
841
      PlplotCanvas widget.  They are:
 
842
 
 
843
      <P
 
844
></P
 
845
><UL
 
846
><LI
 
847
><P
 
848
>          plplotcanvas_demo: Demonstrates the basic usage of the 
 
849
          PlplotCanvas to embed a plot in a Gnome application.
 
850
        </P
 
851
></LI
 
852
><LI
 
853
><P
 
854
>          plplotcanvas_animation: Demonstrates advanced multi-threaded 
 
855
          dual-stream usage of the PlplotCanvas.
 
856
        </P
 
857
></LI
 
858
></UL
 
859
>
 
860
    </P
 
861
><P
 
862
>      The code from plplotcanvas_demo.c is given below, and is explained
 
863
      in what follows.
 
864
    </P
 
865
><TABLE
 
866
CLASS="verbatim"
 
867
><TR
 
868
><TD
 
869
><PRE
 
870
CLASS="programlisting"
 
871
>
 
872
#include &#60;plplotcanvas.h&#62;
 
873
#include &#60;gtk/gtk.h&#62;
 
874
 
 
875
/* The width and height of the plplot canvas widget */
 
876
#define WIDTH 1000 /* 500 */
 
877
#define HEIGHT 600 /* 300 */
 
878
 
 
879
/* Delete event callback */
 
880
gint delete_event( GtkWidget *widget,GdkEvent *event,gpointer data ) {
 
881
  return FALSE;
 
882
}
 
883
 
 
884
/* Destroy event calback */
 
885
void destroy(GtkWidget *widget,gpointer data) {
 
886
  gtk_main_quit ();
 
887
}
 
888
 
 
889
 
 
890
int main(int argc,char *argv[] )
 
891
{
 
892
 
 
893
  PlplotCanvas* canvas;
 
894
  GtkWidget *window;
 
895
 
 
896
  /* Parse the options */
 
897
  plparseopts(&#38;argc, argv, PL_PARSE_FULL);
 
898
 
 
899
  /* The data to plot */
 
900
  double x[11] = {0,1,2,3,4,5,6,7,8,9,10};
 
901
  double y[11] = {0,0.1,0.4,0.9,1.6,2.6,3.6,4.9,6.4,8.1,10};
 
902
 
 
903
  /* Initialize gtk and the glib type system */
 
904
  gtk_init(&#38;argc, &#38;argv);
 
905
  g_type_init();
 
906
 
 
907
  /* Create the canvas and set its size; during the creation process,
 
908
   * the gcw driver is loaded into plplot, and plinit() is invoked.
 
909
   */
 
910
  canvas=plplot_canvas_new(TRUE);
 
911
  plplot_canvas_set_size(canvas,WIDTH,HEIGHT);
 
912
 
 
913
  /* Create a new window and stuff the canvas into it */
 
914
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
915
  gtk_container_set_border_width(GTK_CONTAINER(window),10);
 
916
  gtk_container_add(GTK_CONTAINER(window),GTK_WIDGET(canvas));
 
917
 
 
918
  /* Connect the signal handlers to the window decorations */
 
919
  g_signal_connect(G_OBJECT(window),"delete_event",
 
920
                   G_CALLBACK(delete_event),NULL);
 
921
  g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy),NULL);
 
922
 
 
923
  /* Display everything */
 
924
  gtk_widget_show_all(window);
 
925
 
 
926
  /* Draw on the canvas with Plplot */
 
927
  plplot_canvas_pladv(canvas,0); /* Advance to first page */
 
928
  plplot_canvas_plcol0(canvas,15); /* Set color to black */
 
929
  plplot_canvas_plwid(canvas,2); /* Set the pen width */
 
930
  plplot_canvas_plvsta(canvas); /* Set the viewport */
 
931
  plplot_canvas_plwind(canvas,0.,10.,0.,10.); /* Set the window */
 
932
  plplot_canvas_plbox(canvas,"bcnst",0.,0,"bcnstv",0.,0); /* Set the box */
 
933
  plplot_canvas_pllab(canvas,"x-axis","y-axis","A Simple Plot"); /* Draw some labels */
 
934
 
 
935
  /* Draw the line */
 
936
  plplot_canvas_plcol0(canvas,1); /* Set the pen color */
 
937
  plplot_canvas_plline(canvas,11,x,y);
 
938
 
 
939
  /* Advancing the page finalizes this plot */
 
940
  plplot_canvas_pladv(canvas,0);
 
941
 
 
942
  /* Start the gtk main loop */
 
943
  gtk_main();
 
944
}
 
945
</PRE
 
946
></TD
 
947
></TR
 
948
></TABLE
 
949
><P
 
950
>      So, what's going on here?  After the preliminaries, the GTK and the 
 
951
      GLib type system are initialized by calls to 
 
952
      <CODE
 
953
CLASS="function"
 
954
>gtk_init</CODE
 
955
> and <CODE
 
956
CLASS="function"
 
957
>g_type_init</CODE
 
958
>.  
 
959
      A PlplotCanvas is created using 
 
960
      <CODE
 
961
CLASS="function"
 
962
>plplot_canvas_new</CODE
 
963
>, and it's size is set using 
 
964
      <CODE
 
965
CLASS="function"
 
966
>plplot_canvas_set_size</CODE
 
967
>.  
 
968
    </P
 
969
><P
 
970
>      Next, a window is created (<CODE
 
971
CLASS="function"
 
972
>gtk_window_new</CODE
 
973
>), 
 
974
      the border is set (<CODE
 
975
CLASS="function"
 
976
>gtk_set_border_width</CODE
 
977
>), 
 
978
      and the canvas is stuffed into the window 
 
979
      (<CODE
 
980
CLASS="function"
 
981
>gtk_container_add</CODE
 
982
>).  
 
983
    </P
 
984
><P
 
985
>      Callback functions are installed using 
 
986
      <CODE
 
987
CLASS="function"
 
988
>g_signal_connect</CODE
 
989
> so that the window 
 
990
      decorations respond. The window is set to display everything using
 
991
      <CODE
 
992
CLASS="function"
 
993
>gtk_widget_show_all</CODE
 
994
>.
 
995
    </P
 
996
><P
 
997
>      Now come the PLplot analogue commands.  First, the page using is
 
998
      advanced using <CODE
 
999
CLASS="function"
 
1000
>plplot_canvas_pladv</CODE
 
1001
>.  The pen 
 
1002
      color and width are set with <CODE
 
1003
CLASS="function"
 
1004
>plplot_canvas_plcol0</CODE
 
1005
 
1006
      and <CODE
 
1007
CLASS="function"
 
1008
>plplot_canvas_plwid</CODE
 
1009
>,respectively.  The PLplot
 
1010
      viewport, window, box and labels are created using 
 
1011
      <CODE
 
1012
CLASS="function"
 
1013
>plplot_canvas_plvpor</CODE
 
1014
>, 
 
1015
      <CODE
 
1016
CLASS="function"
 
1017
>plplot_canvas_plwind</CODE
 
1018
>, 
 
1019
      <CODE
 
1020
CLASS="function"
 
1021
>plplot_canvas_plbox</CODE
 
1022
> and 
 
1023
      <CODE
 
1024
CLASS="function"
 
1025
>plplot_canvas_pllab</CODE
 
1026
>, respectively.  A line is 
 
1027
      drawn on the canvas using <CODE
 
1028
CLASS="function"
 
1029
>plplot_canvas_plline</CODE
 
1030
>, 
 
1031
      the page is advanced with <CODE
 
1032
CLASS="function"
 
1033
>plplot_canvas_pladv</CODE
 
1034
>.
 
1035
    </P
 
1036
><P
 
1037
>      Finally, the GTK main loop is entered using 
 
1038
      <CODE
 
1039
CLASS="function"
 
1040
>gtk_main</CODE
 
1041
>, where it resides until the program
 
1042
      is exited.
 
1043
    </P
 
1044
></DIV
 
1045
></DIV
88
1046
></DIV
89
1047
><DIV
90
1048
CLASS="NAVFOOTER"
136
1094
ALIGN="center"
137
1095
VALIGN="top"
138
1096
><A
139
 
HREF="p2080.html"
 
1097
HREF="p2442.html"
140
1098
ACCESSKEY="U"
141
1099
>Up</A
142
1100
></TD