IUP

 view release on metacpan or  search on metacpan

examples/0-basic/plot_advanced.pl  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use strict;
 
use IUP ':all';
 
my $MAXPLOT = 6;
my @plot = ();        # Plot controls
my ($dial1, $dial2);  # dials for zooming
my ($tgg1, $tgg2);    # auto scale on|off toggles
my ($tgg3, $tgg4);    # grid show|hide toggles
my $tgg5;             # legend show|hide toggle
my $tabs;             # tabbed control
 
sub delete_cb {
  my ($self, $index, $sample_index, $x, $y) = @_;
  printf("DELETE_CB(%d, %d, %g, %g)\n", $index, $sample_index, $x, $y);
  return IUP_DEFAULT;
}
 
sub select_cb {
my ($self, $index, $sample_index, $x, $y, $select) = @_;

examples/0-basic/plot_advanced.pl  view on Meta::CPAN

304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
    }
    # Y axis
    if ($plot[$ii]->GetAttribute("GRID") eq 'H') {
      $tgg4->VALUE("ON");
    }
    else {
      $tgg4->VALUE("OFF");
    }
  }
 
  # legend
  if ($plot[$ii]->GetAttribute("LEGENDSHOW")) {
    $tgg5->VALUE("ON");
  }
  else {
    $tgg5->VALUE("OFF");
  }
 
  return IUP_DEFAULT;
}

examples/0-basic/plot_advanced.pl  view on Meta::CPAN

372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
      $plot[$ii]->SetAttribute("GRID", "VERTICAL");
    }
  }
 
  $plot[$ii]->SetAttribute("REDRAW", undef);
 
  return IUP_DEFAULT;
}
 
 
# show/hide legend
sub tgg5_cb {
  my ($self, $v) = @_;
  my $ii = tabs_get_index();
 
  $plot[$ii]->SetAttribute("LEGENDSHOW", $v ? "YES" : "NO");
  $plot[$ii]->SetAttribute("REDRAW", undef);
 
  return IUP_DEFAULT;
}

examples/1-apps/app-plot-demo.pl  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use strict;
 
use IUP ':all';
 
my $mainplot;
my $mainfunc;
my ($dial1, $dial2);  # dials for zooming
my ($tgg1, $tgg2);    # auto scale on|off toggles
my ($tgg3, $tgg4);    # grid show|hide toggles
my $tgg5;             # legend show|hide toggle
 
sub delete_cb {
  my ($self, $index, $sample_index, $x, $y) = @_;
  printf STDERR "DELETE_CB(%d, %d, %g, %g)\n", $index, $sample_index, $x, $y;
  return IUP_DEFAULT;
}
 
sub select_cb {
  my ($self, $index, $sample_index, $x, $y, $select) = @_;
  printf STDERR "SELECT_CB(%d, %d, %g, %g, %d)\n", $index, $sample_index, $x, $y, $select;

examples/1-apps/app-plot-demo.pl  view on Meta::CPAN

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
    $mainplot->GRID( ($tgg3->VALUE eq 'ON') ? "YES" : "HORIZONTAL" );
  }
  else {
    #unchecked
    $mainplot->GRID( ($tgg3->VALUE eq 'OFF') ? "NO" : "VERTICAL" );
  }
  $mainplot->REDRAW(1);
  return IUP_DEFAULT;
}
 
# show/hide legend
sub tgg5_cb {
  my ($self, $v) = @_;
  $mainplot->LEGENDSHOW($v ? "YES" : "NO");
  $mainplot->REDRAW(1);
  return IUP_DEFAULT;
}
 
# autoscale Y
sub tgg1_cb {
  my ($self, $v) = @_;

lib/IUP/MglPlot.pod  view on Meta::CPAN

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$plot = IUP::MglPlot->new( TITLE=>"Simple Data", GRID=>"YES" );
 
B<Returns:> the identifier of the created element, or C<undef> if an error occurs.
 
NOTE: You can pass to C<new()> other C<ATTRIBUTE=E<gt>'value'> or C<CALLBACKNAME=E<gt>\&func> pairs relevant
to this element - see L<IUP::Manual::02_Elements|IUP::Manual::02_Elements/"new()">.
 
=head2 Guide
 
Each plot can contain 2 or 3 B<axes> (X and Y and/or Z), a B<title>, a
B< legend> B<box>, a B<colorbar>, a B<grid>, a B<dataset> B<area> and
as many B<datasets> you want.
 
Each dataset is added using the L<PlotAdd1D|/PlotAdd1D>, L<PlotAdd2D|/PlotAdd2D>, L<PlotAdd3D|/PlotAdd3D>,
L<PlotInsert1D|/PlotInsert1D>, L<PlotInsert2D|/PlotInsert2D>, L<PlotInsert3D|/PlotInsert3D>
L<PlotSet1D|/PlotSet1D>, L<PlotSet2D|/PlotSet2D> and L<PlotSet3D|/PlotSet3D> functions. All other plot
parameters are configured by attributes.
 
If no attribute is set, the default values were selected to best
display the plot.
 
B<IMPORTANT>: When setting attributes the plot is NOT redrawn until the
REDRAW attribute is set or a redraw event occurs.
 
The B<dataset area> is delimited by the min/max axis attributes. Data
is only plotted inside the dataset area. This area defines the 2D or 3D
plot coordinate space. The screen area is a 2D pixels coordinate space.
And finally the dataset also defines a normalized space, that means
min/max is converted to 0-1.
 
The B<legend box> is a list of the dataset names, each one drawn with
the same color of the correspondent dataset. The box is located in one
of the four corners of the dataset area.
 
The B<colorbar> is an additional axis showing the the colors used to
pseudo color the data for some plot modes.
 
The B<grid> is automatically spaced accordingly the current axis
displayed values.
 
The B<title> is always centered in the top of the plot.

lib/IUP/MglPlot.pod  view on Meta::CPAN

446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
the background color. Default: "255 255 255".
 
=item B<ERRORMESSAGE>
 
I<(read-only)(non inheritable)> If not C<undef> returns the last error message reported by MathGL.
 
=item L<FONT|IUP::Manual::03_Attributes/FONT>
 
the default font used in all text
elements of the plot: title, legend and labels. Font support is done
using the libraries Freetype and FTGL, so TrueType (*.ttf) and OpenType
(*.otf) font files can be loaded. If the font is not located in the
system, then it will try to find the font file in the current
directory, or in the path from the "IUP_MGLFONTS" environment variable,
or in the path from the "MGLFONTS" global attribute, or in a system
folder. The font name will be combined with the path to compose a file
name. A full path can also be used. If the font load fail, an internal
MathGL font is used.
 
=item L<FGCOLOR|IUP::Manual::03_Attributes/FGCOLOR>
 
the default color used in all
text elements of the plot: title, legend and labels. Default: "0 0 0".
 
=item B<OPENGL>
 
L<(non inheritable)> Enable or disable the rendering in OpenGL.
Default: No. When NO the rendering is slower, but when Yes some
features does not behave as expected. See L<Known Issues|/"Known Issues">.
 
=item B<REDRAW>
 
I<(write-only)(non inheritable)> redraw the plot and update the

lib/IUP/MglPlot.pod  view on Meta::CPAN

542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
Style can be "PLAIN", "BOLD", "ITALIC" or "BOLDITALIC".
 
=back
 
=head3 Legend Configuration (non inheritable)
 
=over
 
=item B<LEGEND>
 
shows or hides the legend box. Can be YES or NO. Default: NO. LEGENDSHOW is also accepted.
 
=item B<LEGENDBOX>
 
draws a box around the legend area. Default: YES.
 
=item B<LEGENDCOLOR>
 
title color. Default: FGCOLOR.
 
=item B<LEGENDFONTSIZE>
 
legend font size factor. It is a multiple of the
FONT size. Default: 0.8
 
=item B<LEGENDFONTSTYLE>
 
legend font style. If not defined the FONT
attribute will be used instead. Set to C<undef>, to use the FONT attribute
values. Style can be "PLAIN", "BOLD", "ITALIC" or "BOLDITALIC".
 
=item B<LEGENDPOS>
 
legend box position. Can be: "TOPLEFT", "TOPRIGHT",
"BOTTOMLEFT", or "BOTTOMRIGHT. Default: "TOPRIGHT".
 
=back
 
=head3 Colorbar Configuration (non inheritable)
 
=over
 
=item B<COLORBAR>

lib/IUP/MglPlot.pod  view on Meta::CPAN

667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
I<(write-only)> removes a dataset given its index.
 
=back
 
=head3 Dataset Configuration (non inheritable)
 
=over
 
=item B<DS_COLOR>
 
color of the current dataset and it legend text. Default
is dynamically generated for the 6 first datasets, others are default
to black "0 0 0". The first 6 are: 0="255 0 0", 1="0 0 255", 2="0 255
0", 3="0 255 255", 4="255 0 255", 5="255 255 0".
 
=item B<DS_COUNT>
 
I<(read-only)> returns the number of samples of the current
dataset. For planar or volumetric datasets returns count_x * count_y * count_z.
 
=item B<DS_DIMENSION>
 
I<(read-only)> returns the number of dimensions of the
data: 1, 2 or 3. For planar and volumetric datasets returns the actual
size of each dimension C<count_x x count_y x count_z>, for example
"600x400x1" (planar) or "512x512x512" (volumetric).
 
=item B<DS_LEGEND>
 
legend text of the current dataset. Default is
dynamically generated: "plot 0", "plot 1", "plot 2", ...
 
=item B<DS_LINESTYLE>
 
line style of the current dataset. Can be:
"CONTINUOUS", "LONGDASHED", "DASHED", "SMALLDASHED", "DOTTED",
"DASH_DOT", "SMALLDASH_DOT". Default is "CONTINUOUS".
 
=item B<DS_LINEWIDTH>

lib/IUP/PPlot.pod  view on Meta::CPAN

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 $pplot = IUP::PPlot->new( TITLE=>"Simple Data", GRID=>"YES" );
 
B<Returns:> the identifier of the created element, or C<undef> if an error occurs.
 
NOTE: You can pass to C<new()> other C<ATTRIBUTE=E<gt>'value'> or C<CALLBACKNAME=E<gt>\&func> pairs relevant
to this element - see L<IUP::Manual::02_Elements|IUP::Manual::02_Elements/"new()">.
 
=head2 Guide
 
Each plot can contain 2 B<axis> (X and Y), a B<title>, a B<legend>
B<box>, a B<grid>, a B<dataset> B<area> and as many B<datasets> you
want.
 
Each data set is added using the L<IUP::PPlotAdd |IUP::PPlotAdd> function. All other plot
parameters are configured by attributes.
 
If no attribute is set, the default values were selected to best
display the plot.
 
When setting attributes the plot is NOT redrawn until the REDRAW
attribute is set or a redraw event occurs.
 
The B<dataset area> is delimited by a margin. Data is only plotted
inside the dataset area. Axis and main title are positioned independent
of this margin. It is very important to set the margins when using axis
automatic scaling or the axis maybe hidden.
 
The B<legend box> is a list of the dataset names, each one drawn with
the same color of the correspondent dataset. The box is located in one
of the four corners of the dataset area.
 
The B<grid> is automatically spaced accordingly the current axis
displayed values.
 
The B<title> is always centered in the top of the plot.
 
The B<axis> are always positioned at the origin, except when
CrossOrigin is disabled, then it is positioned at the left-bottom. If

lib/IUP/PPlot.pod  view on Meta::CPAN

241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
=item B<USE_GDI+>
 
I<[Windows Only] (non inheritable)> Defines if the double
buffer will use GDI+ (YES) for drawing or standard GDI (NO). Default:
NO. The GDI+ driver has anti-aliasing which can improve the line
drawing.
 
=item B<L<FONT|IUP::Manual::03_Attributes/FONT>>
 
The font used in all text elements
of the plot: title, legend and labels.
 
=item B<L<BGCOLOR|IUP::Manual::03_Attributes/BGCOLOR>>
 
The background color. The
default value is white "255 255 255".
 
=item B<L<FGCOLOR|IUP::Manual::03_Attributes/FGCOLOR>>
 
The title color. The default
value is black "0 0 0".

lib/IUP/PPlot.pod  view on Meta::CPAN

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
must be set so the plot is not cropped. Default: "15", "15", "30", "15".
 
=back
 
=head3 Legend Configuration (non inheritable)
 
=over
 
=item B<LEGENDSHOW>
 
Shows or hides the legend box. Can be YES or NO.
Default: NO.
 
=item B<LEGENDPOS>
 
Legend box position. Can be: "TOPLEFT", "TOPRIGHT",
"BOTTOMLEFT", or "BOTTOMRIGHT. Default: "TOPRIGHT".
 
=item B<LEGENDFONTSIZE, LEGENDFONTSTYLE>
 
The legend box text font size and style.
 
=back
 
=head3 Grid Configuration (non inheritable)
 
=over
 
=item B<GRIDLINESTYLE>
 
Line style of the grid. Can be: "CONTINUOUS",

lib/IUP/PPlot.pod  view on Meta::CPAN

341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
added it becomes the current dataset. The index starts at 0. All "DS_*"
attributes are dependent on this value.
 
=item B<DS_LEGEND>
 
Legend text of the current dataset. Default is
dynamically generated: "plot 0", "plot 1", "plot 2", ...
 
=item B<DS_COLOR>
 
Color of the current dataset and it legend text. Default
is dynamically generated for the 6 first datasets, others are default
to black "0 0 0". The first 6 are: 0="255 0 0", 1="0 0 255", 2="0 255
0", 3="0 255 255", 4="255 0 255", 5="255 255 0".
 
=item B<DS_MODE>
 
Drawing mode of the current dataset. Can be: "LINE", "BAR",
"MARK" or "MARKLINE". Default: "LINE". This must be set before other
"DS_*" attributes.



( run in 0.286 second using v1.01-cache-2.11-cpan-ec4f86ec37b )