1
# elements.rb: all drawable objects
2
# copyright (c) 2009 by Vincent Fourmond
4
# This program 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.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
# General Public License for more details (in the COPYING file).
15
require 'ctioga2/graphics/types'
16
require 'ctioga2/graphics/elements/element'
17
require 'ctioga2/graphics/elements/containers'
18
require 'ctioga2/graphics/elements/subplot'
19
require 'ctioga2/graphics/elements/region'
20
require 'ctioga2/graphics/elements/gradient-region'
21
require 'ctioga2/graphics/elements/curve2d'
22
require 'ctioga2/graphics/elements/parametric2d'
23
require 'ctioga2/graphics/elements/xyz-map'
24
require 'ctioga2/graphics/elements/primitive'
26
require 'ctioga2/graphics/elements/tangent'
27
require 'ctioga2/graphics/elements/contour'
31
Version::register_svn_info('$Revision: 187 $', '$Date: 2010-11-07 11:02:25 +0100 (Sun, 07 Nov 2010) $')
35
# Now, various commands pertaining to various drawables
37
PlotCoordinatesGroup = CmdGroup.new('coordinates',
39
"Plot coordinates", 2)
41
Cmd.new("margin",nil,"--margin",
42
[ CmdArg.new('float') ]) do |plotmaker, margin|
43
plotmaker.root_object.current_plot.style.plot_margin = margin
46
PlotMarginCommand.describe("Leaves a margin around data points",
47
<<EOH, PlotCoordinatesGroup)
48
Leaves a margin around the data points. Expressed in relative size of the
53
# Various coordinate-related commands:
55
# @todo All these commands should be axis-dependent, and not
57
CoordinateRelatedCommands = []
60
Cmd.new("#{x}range",nil,"--#{x}range",
61
[ CmdArg.new('partial-float-range') ]) do |plotmaker, range|
62
plotmaker.root_object.current_plot.
63
set_user_boundaries(x.to_s,range)
65
cmd.describe("Sets the #{x.to_s.upcase} range",
66
<<EOH, PlotCoordinatesGroup)
67
Sets the range of the #{x.to_s.upcase} coordinates.
69
CoordinateRelatedCommands << cmd
72
Cmd.new("#{x}offset",nil,"--#{x}offset",
73
[ CmdArg.new('float') ]) do |plotmaker, val|
74
plotmaker.root_object.current_plot.
75
style.transforms.send("#{x}_offset=", val)
77
cmd.describe("Offset #{x.to_s.upcase} data",
78
<<EOH, PlotCoordinatesGroup)
79
Adds the given offset to all #{x.to_s.upcase} coordinates.
81
CoordinateRelatedCommands << cmd
84
Cmd.new("#{x}scale",nil,"--#{x}scale",
85
[ CmdArg.new('float') ]) do |plotmaker, val|
86
plotmaker.root_object.current_plot.
87
style.transforms.send("#{x}_scale=", val)
89
cmd.describe("Scale #{x.to_s.upcase} data",
90
<<EOH, PlotCoordinatesGroup)
91
Multiplies the #{x.to_s.upcase} coordinates by this factor.
93
CoordinateRelatedCommands << cmd
97
Cmd.new("#{x}fact",nil,"--#{x}fact",
98
[ CmdArg.new('float') ]) do |plotmaker, val|
99
plotmaker.root_object.current_plot.
100
style.transforms.send("#{x}_scale=", val)
102
cmd.describe("Alias for #{x}scale",
103
<<EOH, PlotCoordinatesGroup)
104
Alias for {command: #{x}scale}.
106
CoordinateRelatedCommands << cmd
109
Cmd.new("#{x}log",nil,"--#{x}log",
110
[ CmdArg.new('boolean') ]) do |plotmaker, val|
111
plotmaker.root_object.current_plot.
112
style.send("set_log_scale", x, val)
114
cmd.describe("Use log scale for #{x.to_s.upcase}",
115
<<EOH, PlotCoordinatesGroup)
116
Uses a logarithmic scale for the #{x.to_s.upcase} axis.
118
CoordinateRelatedCommands << cmd