ctioga 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +340 -0
- data/ctioga/bin/ctable +28 -0
- data/ctioga/bin/ctioga +37 -0
- data/ctioga/doc/ctable.1 +156 -0
- data/ctioga/doc/ctioga.1 +2363 -0
- data/ctioga/examples/README +46 -0
- data/ctioga/examples/ctioga.gnuplot +4 -0
- data/ctioga/examples/ctioga_within_tioga.rb +53 -0
- data/ctioga/examples/ctiogarc.rb +24 -0
- data/ctioga/examples/include_1.rb +15 -0
- data/ctioga/examples/noise.dat +100 -0
- data/ctioga/examples/noise.rb +13 -0
- data/ctioga/examples/trig.csv +100 -0
- data/ctioga/examples/trig.dat +100 -0
- data/ctioga/examples/trig.rb +14 -0
- data/ctioga/examples/trigh.dat +100 -0
- data/ctioga/examples/trigh.rb +10 -0
- data/ctioga/examples/tutorial +763 -0
- data/ctioga/examples/tutorial.sh +269 -0
- data/ctioga/tests/README +14 -0
- data/ctioga/tests/axes.sh +40 -0
- data/ctioga/tests/basic.sh +11 -0
- data/ctioga/tests/draw.sh +24 -0
- data/ctioga/tests/histograms.sh +14 -0
- data/ctioga/tests/insets.sh +41 -0
- data/ctioga/tests/layouts.sh +29 -0
- data/ctioga/tests/legends.sh +113 -0
- data/ctioga/tests/styles.sh +43 -0
- data/ctioga/tests/test_style.sh +8 -0
- data/ctioga/tests/tests.sh +24 -0
- data/ctioga/tests/text_backend.sh +83 -0
- data/ctioga/tests/tioga_defaults.rb +18 -0
- data/lib/CTioga/axes.rb +904 -0
- data/lib/CTioga/backends.rb +88 -0
- data/lib/CTioga/boundaries.rb +224 -0
- data/lib/CTioga/ctable.rb +134 -0
- data/lib/CTioga/curve_style.rb +246 -0
- data/lib/CTioga/debug.rb +199 -0
- data/lib/CTioga/dimension.rb +133 -0
- data/lib/CTioga/elements.rb +17 -0
- data/lib/CTioga/elements/base.rb +84 -0
- data/lib/CTioga/elements/containers.rb +578 -0
- data/lib/CTioga/elements/curves.rb +368 -0
- data/lib/CTioga/elements/tioga_primitives.rb +440 -0
- data/lib/CTioga/layout.rb +595 -0
- data/lib/CTioga/legends.rb +29 -0
- data/lib/CTioga/legends/cmdline.rb +187 -0
- data/lib/CTioga/legends/item.rb +164 -0
- data/lib/CTioga/legends/style.rb +257 -0
- data/lib/CTioga/log.rb +73 -0
- data/lib/CTioga/movingarrays.rb +131 -0
- data/lib/CTioga/partition.rb +271 -0
- data/lib/CTioga/plot_style.rb +230 -0
- data/lib/CTioga/plotmaker.rb +1677 -0
- data/lib/CTioga/shortcuts.rb +69 -0
- data/lib/CTioga/structures.rb +82 -0
- data/lib/CTioga/styles.rb +140 -0
- data/lib/CTioga/themes.rb +581 -0
- data/lib/CTioga/themes/classical.rb +82 -0
- data/lib/CTioga/themes/demo.rb +63 -0
- data/lib/CTioga/themes/fits.rb +91 -0
- data/lib/CTioga/themes/mono.rb +33 -0
- data/lib/CTioga/tioga.rb +32 -0
- data/lib/CTioga/utils.rb +173 -0
- data/lib/MetaBuilder/Parameters/dates.rb +38 -0
- data/lib/MetaBuilder/Parameters/lists.rb +132 -0
- data/lib/MetaBuilder/Parameters/numbers.rb +69 -0
- data/lib/MetaBuilder/Parameters/strings.rb +86 -0
- data/lib/MetaBuilder/Parameters/styles.rb +75 -0
- data/lib/MetaBuilder/Qt4/Parameters/dates.rb +51 -0
- data/lib/MetaBuilder/Qt4/Parameters/numbers.rb +65 -0
- data/lib/MetaBuilder/Qt4/Parameters/strings.rb +106 -0
- data/lib/MetaBuilder/Qt4/parameter.rb +172 -0
- data/lib/MetaBuilder/Qt4/parameters.rb +9 -0
- data/lib/MetaBuilder/descriptions.rb +603 -0
- data/lib/MetaBuilder/factory.rb +101 -0
- data/lib/MetaBuilder/group.rb +57 -0
- data/lib/MetaBuilder/metabuilder.rb +10 -0
- data/lib/MetaBuilder/parameter.rb +374 -0
- data/lib/MetaBuilder/parameters.rb +11 -0
- data/lib/MetaBuilder/qt4.rb +8 -0
- data/lib/SciYAG/Backends/backend.rb +379 -0
- data/lib/SciYAG/Backends/binner.rb +168 -0
- data/lib/SciYAG/Backends/cache.rb +102 -0
- data/lib/SciYAG/Backends/dataset.rb +158 -0
- data/lib/SciYAG/Backends/descriptions.rb +469 -0
- data/lib/SciYAG/Backends/filters.rb +25 -0
- data/lib/SciYAG/Backends/filters/average.rb +134 -0
- data/lib/SciYAG/Backends/filters/cumulate.rb +37 -0
- data/lib/SciYAG/Backends/filters/filter.rb +70 -0
- data/lib/SciYAG/Backends/filters/norm.rb +39 -0
- data/lib/SciYAG/Backends/filters/smooth.rb +63 -0
- data/lib/SciYAG/Backends/filters/sort.rb +43 -0
- data/lib/SciYAG/Backends/filters/strip.rb +34 -0
- data/lib/SciYAG/Backends/filters/trim.rb +64 -0
- data/lib/SciYAG/Backends/gnuplot.rb +131 -0
- data/lib/SciYAG/Backends/math.rb +108 -0
- data/lib/SciYAG/Backends/mdb.rb +462 -0
- data/lib/SciYAG/Backends/multitext.rb +96 -0
- data/lib/SciYAG/Backends/source.rb +64 -0
- data/lib/SciYAG/Backends/text.rb +339 -0
- data/lib/SciYAG/backends.rb +16 -0
- metadata +191 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# numbers.rb : Different ParameterTypes to deal with numbers
|
|
2
|
+
# Copyright (C) 2006 Vincent Fourmond
|
|
3
|
+
#
|
|
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.
|
|
8
|
+
#
|
|
9
|
+
# This program 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 should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
require 'time'
|
|
19
|
+
|
|
20
|
+
module MetaBuilder
|
|
21
|
+
|
|
22
|
+
# The module ParameterTypes should be used for all subclasses of
|
|
23
|
+
# ParameterType, to keep the place clean and tidy.
|
|
24
|
+
module ParameterTypes
|
|
25
|
+
|
|
26
|
+
# A combination date/time
|
|
27
|
+
class DateTimeParameter < ParameterType
|
|
28
|
+
|
|
29
|
+
type_name :date_time, 'date', Time.new
|
|
30
|
+
|
|
31
|
+
def string_to_type_internal(str)
|
|
32
|
+
return Time.parse(str)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# lists.rb : Different ParameterTypes to deal with types where
|
|
2
|
+
# you can choose among several possibilities
|
|
3
|
+
# Copyright (C) 2006 Vincent Fourmond
|
|
4
|
+
#
|
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program; if not, write to the Free Software
|
|
17
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module MetaBuilder
|
|
21
|
+
|
|
22
|
+
# The module ParameterTypes should be used for all subclasses of
|
|
23
|
+
# ParameterType, to keep the place clean and tidy.
|
|
24
|
+
module ParameterTypes
|
|
25
|
+
|
|
26
|
+
# A regular expression matching true
|
|
27
|
+
TRUE_RE = /^\s*(true|yes|on)\s*$/i
|
|
28
|
+
|
|
29
|
+
# A regular expression matching false
|
|
30
|
+
FALSE_RE = /^\s*(false|no(ne)?|off)\s*$/i
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# A boolean parameter
|
|
34
|
+
class BooleanParameter < ParameterType
|
|
35
|
+
|
|
36
|
+
type_name :boolean
|
|
37
|
+
|
|
38
|
+
def type_name
|
|
39
|
+
return 'bool'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def string_to_type_internal(str)
|
|
43
|
+
if str == true or str =~ TRUE_RE
|
|
44
|
+
return true
|
|
45
|
+
else
|
|
46
|
+
return false
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def type_to_string_internal(val)
|
|
51
|
+
if val
|
|
52
|
+
return "true"
|
|
53
|
+
else
|
|
54
|
+
return "false"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Booleans are a special case for option parser, as they
|
|
59
|
+
# are handled completely differently
|
|
60
|
+
def option_parser_long_option(name)
|
|
61
|
+
return "--[no-]#{name}"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# A list of symbols. A hash :list must be provided that states
|
|
66
|
+
# the correspondance between the legal symbols that can be
|
|
67
|
+
# accepted by this parameter and their "english" name.
|
|
68
|
+
# This parameter can typically be used to prompt the user
|
|
69
|
+
# for different choices.
|
|
70
|
+
class ListParameter < ParameterType
|
|
71
|
+
|
|
72
|
+
type_name :list
|
|
73
|
+
|
|
74
|
+
def initialize(type)
|
|
75
|
+
super
|
|
76
|
+
raise "type must have a :list key" unless type.has_key?(:list)
|
|
77
|
+
# We make a copy for our own purposes.
|
|
78
|
+
@hash = type[:list].dup
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def type_name
|
|
82
|
+
return 'list'
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def string_to_type_internal(str)
|
|
86
|
+
if @hash.has_key?(str.to_sym)
|
|
87
|
+
return str.to_sym
|
|
88
|
+
else
|
|
89
|
+
raise IncorrectInput, "Invalid input: #{str} should be one of " +
|
|
90
|
+
@hash.keys.map {|s| s.to_s}.join(',')
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def type_to_string_internal(val)
|
|
95
|
+
return val.to_s
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# An array of identical elements of type specified by :subtype. Defaults
|
|
100
|
+
# to String
|
|
101
|
+
class ArrayParameter < ParameterType
|
|
102
|
+
type_name :array
|
|
103
|
+
|
|
104
|
+
def initialize(type)
|
|
105
|
+
super
|
|
106
|
+
# We make a copy for our own purposes.
|
|
107
|
+
subtype = type[:subtype] || {:type => :string}
|
|
108
|
+
@subtype = ParameterType.get_type(subtype)
|
|
109
|
+
@separator = /\s*,\s*/
|
|
110
|
+
@separator_out = ','
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def type_name
|
|
114
|
+
return 'array'
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def string_to_type_internal(str)
|
|
118
|
+
ary = str.split(@separator)
|
|
119
|
+
return ary.map do |a|
|
|
120
|
+
@subtype.string_to_type(a)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def type_to_string_internal(val)
|
|
125
|
+
return val.map do |a|
|
|
126
|
+
@subtype.type_to_string(a)
|
|
127
|
+
end.join(@separator_out)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# numbers.rb : Different ParameterTypes to deal with numbers
|
|
2
|
+
# Copyright (C) 2006 Vincent Fourmond
|
|
3
|
+
#
|
|
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.
|
|
8
|
+
#
|
|
9
|
+
# This program 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 should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
module MetaBuilder
|
|
20
|
+
|
|
21
|
+
# The module ParameterTypes should be used for all subclasses of
|
|
22
|
+
# ParameterType, to keep the place clean and tidy.
|
|
23
|
+
module ParameterTypes
|
|
24
|
+
|
|
25
|
+
# An integer
|
|
26
|
+
class IntegerParameter < ParameterType
|
|
27
|
+
|
|
28
|
+
type_name :integer, 'number', 0
|
|
29
|
+
|
|
30
|
+
def string_to_type_internal(str)
|
|
31
|
+
return Integer(str)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# A float
|
|
37
|
+
class FloatParameter < ParameterType
|
|
38
|
+
|
|
39
|
+
type_name :float, 'number', 0.0
|
|
40
|
+
|
|
41
|
+
def string_to_type_internal(str)
|
|
42
|
+
return Float(str)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# A Float Range
|
|
48
|
+
class FloatRangeParameter < ParameterType
|
|
49
|
+
|
|
50
|
+
RANGE_RE = /([^:]+):([^:]+)/
|
|
51
|
+
|
|
52
|
+
type_name :float_range, 'range'
|
|
53
|
+
|
|
54
|
+
def string_to_type_internal(str)
|
|
55
|
+
raise IncorrectInput, "#{str} is not a valid range" unless
|
|
56
|
+
str =~ RANGE_RE
|
|
57
|
+
s,e = Float($1), Float($2)
|
|
58
|
+
return Range.new(s,e)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def type_to_string_internal(value)
|
|
62
|
+
return "#{value.first.to_s}:#{value.last.to_s}"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# strings.rb : Different ParameterTypes to deal with strings
|
|
2
|
+
# Copyright (C) 2006 Vincent Fourmond
|
|
3
|
+
#
|
|
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.
|
|
8
|
+
#
|
|
9
|
+
# This program 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 should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
module MetaBuilder
|
|
20
|
+
|
|
21
|
+
# The module ParameterTypes should be used for all subclasses of
|
|
22
|
+
# ParameterType, to keep the place clean and tidy.
|
|
23
|
+
module ParameterTypes
|
|
24
|
+
|
|
25
|
+
# A String
|
|
26
|
+
class StringParameter < ParameterType
|
|
27
|
+
|
|
28
|
+
type_name :string
|
|
29
|
+
|
|
30
|
+
def type_name
|
|
31
|
+
return 'text'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def string_to_type(str)
|
|
35
|
+
return str
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# A piece of text representing the path to a file.
|
|
40
|
+
class FileParameter < StringParameter
|
|
41
|
+
|
|
42
|
+
type_name :file
|
|
43
|
+
|
|
44
|
+
# The file filters, Qt style.
|
|
45
|
+
attr_reader :filter
|
|
46
|
+
|
|
47
|
+
def initialize(type)
|
|
48
|
+
super(type)
|
|
49
|
+
@filter = type[:filter]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def type_name
|
|
53
|
+
return 'file'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# A String or a regular expression
|
|
59
|
+
class StringOrRegexpParameter < ParameterType
|
|
60
|
+
|
|
61
|
+
type_name :string_or_regexp
|
|
62
|
+
|
|
63
|
+
def type_name
|
|
64
|
+
return 'regexp'
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def string_to_type(str)
|
|
68
|
+
if str =~ /^\/(.*)\/$/
|
|
69
|
+
return Regexp.new($1)
|
|
70
|
+
else
|
|
71
|
+
return str
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def type_to_string(val)
|
|
76
|
+
if val.is_a? String
|
|
77
|
+
return val
|
|
78
|
+
else
|
|
79
|
+
return "/#{val}/"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# strings.rb : Different ParameterTypes to deal with different styles items,
|
|
2
|
+
# such as colors, line types, fonts ???
|
|
3
|
+
# Copyright (C) 2006 Vincent Fourmond
|
|
4
|
+
#
|
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program; if not, write to the Free Software
|
|
17
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module MetaBuilder
|
|
21
|
+
|
|
22
|
+
# The module ParameterTypes should be used for all subclasses of
|
|
23
|
+
# ParameterType, to keep the place clean and tidy.
|
|
24
|
+
module ParameterTypes
|
|
25
|
+
|
|
26
|
+
# A HTML color: the value is returned in the form of an array
|
|
27
|
+
# of three integers between 0 and 255. Strings can be in the form
|
|
28
|
+
# of a standard HTML color like #FF0000 for red, or it can be a
|
|
29
|
+
# name corresponding to a constant in one of the modules given
|
|
30
|
+
# in the :namespaces array.
|
|
31
|
+
class HTMLColorParameter < ParameterType
|
|
32
|
+
|
|
33
|
+
type_name :html_color, 'color'
|
|
34
|
+
|
|
35
|
+
def string_to_type_internal(str)
|
|
36
|
+
if str =~ /#([0-9a-fA-F]{6})/
|
|
37
|
+
return $1.scan(/../).map {|i| i.to_i(16)}
|
|
38
|
+
elsif @type.has_key?(:namespaces)
|
|
39
|
+
for mod in @type[:namespaces]
|
|
40
|
+
if mod.const_defined?(str)
|
|
41
|
+
return normalize(mod.const_get(str))
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
else
|
|
45
|
+
raise IncorrectInput, "#{str} is not a valid color"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def type_to_string_internal(color)
|
|
50
|
+
return "##{color.map {|i| sprintf("%02x",i)}.join}"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
# Returns a normalized color, that is, if everything is below or equal
|
|
55
|
+
# to 1.0, multiply by 255 -- and always convert to int.
|
|
56
|
+
def normalize(ar)
|
|
57
|
+
if ar.max <= 1.0
|
|
58
|
+
ret = ar.map {|c| c * 255.0}
|
|
59
|
+
else
|
|
60
|
+
ret = ar.dup
|
|
61
|
+
end
|
|
62
|
+
ret.map! {|i| i.to_i}
|
|
63
|
+
return ret
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# A set of margins - that is, four floats representing left top
|
|
68
|
+
# right bottom coordinates.
|
|
69
|
+
class MarginsParameter < ParameterType
|
|
70
|
+
|
|
71
|
+
type_name :margins, 'margins'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# numbers.rb : Different ParameterTypes to deal with numbers
|
|
2
|
+
# Copyright (C) 2006 Vincent Fourmond
|
|
3
|
+
#
|
|
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.
|
|
8
|
+
#
|
|
9
|
+
# This program 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 should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
require 'time'
|
|
19
|
+
|
|
20
|
+
module MetaBuilder
|
|
21
|
+
|
|
22
|
+
# The module ParameterTypes should be used for all subclasses of
|
|
23
|
+
# ParameterType, to keep the place clean and tidy.
|
|
24
|
+
module ParameterTypes
|
|
25
|
+
|
|
26
|
+
# A combination date/time
|
|
27
|
+
class DateTimeParameter < ParameterType
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Converts a Time to a Variant.
|
|
31
|
+
def type_to_variant(val)
|
|
32
|
+
if val.is_a? Qt::DateTime
|
|
33
|
+
return Qt::Variant.new(val)
|
|
34
|
+
else
|
|
35
|
+
epoch = Qt::Date.new(1970, 1, 1)
|
|
36
|
+
date = Qt::DateTime.new(epoch)
|
|
37
|
+
return Qt::Variant.new(date.add_secs(val.to_i))
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Converts back to Time
|
|
42
|
+
def variant_to_type(variant)
|
|
43
|
+
epoch = Qt::DateTime.new(Qt::Date.new(1970, 1, 1))
|
|
44
|
+
nb = epoch.secs_to(variant.value)
|
|
45
|
+
return Time.at(nb)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|