GTK+ IOStream  Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PlotTest.C
Go to the documentation of this file.
1 /* Copyright 2000-2013 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 #include "gtkInterface.H"
18 #include "Plot.H"
19 
20 // setup the possible plot colours ...
21 int ColourLineSpec::colourCnt=10; // match this number with the number of colours below
22 const char *ColourLineSpec::shortColours[]= {(char *)"y",(char *)"m",(char *)"c",(char *)"r",(char *)"g",(char *)"b",(char *)"w",(char *)"k",(char *)"o",(char *)"a"}; // standard colours
23 const char *ColourLineSpec::X11Colours[]= {(char *)"yellow", (char *)"magenta", (char *)"cyan", (char *)"red", (char *)"green", (char *)"blue", (char *)"white", (char *)"black", (char *)"orange", (char *)"gray"};
24 
25 // Quit button callback
26 static void quit(void *wid, gpointer data) {
27  gtk_main_quit();
28 }
29 
30 // some definitions
31 #define cnt 4
32 float x[cnt]={0.0, 1., 2., 3.};
33 float y1[cnt]={0.0, 1., 2., 3.};
34 float y2[cnt]={1.0, 2., 3., 4.};
35 
36 #define TYPE float
37 
38 int main(int argc, char *argv[]) {
39 
40  gtk_init( &argc, &argv );
41 
42  GtkInterface topWindow;
43 
44  gtk_widget_set_size_request (topWindow.win, 1000, 500);
45 
46  /* ////////////////////////////////////////////////////////*/
47  // The actual plotting
48 
49  Plot figure; // create and show a Figure
50  figure.plot(x,y1,cnt); // Plot the first line with default colours
51  figure.hold(true); // hold the current curve and add another
52  figure.plot(x,y2,cnt, "r1"); // plot this one as a red line
53 
54  // Changing the style of the plot
55  figure.limits(-1.0,4.0,-1.,5.0); // open the window out to be able to see all
56  figure.grid(true); // show a grid
57  figure.title("Figure 1 title"); // add the title, x label and y label
58  figure.xLabel("X axis label");
59  figure.yLabel("Y axis label");
60 // figure.show(); // finally show the plot
61  /* /////////////////////////////////////////////////////////*/
62 
63  HBox hBox;
64  hBox << BoxIS(TRUE, TRUE)<<figure.getWidget(); // show the figure
65  hBox.show(); // show the horizontal box
66  topWindow<< hBox; // add it to the top window
67 
68  gtk_main();
69 }