1
# contour.rb: contouring code for XYZ data
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/elements/primitive'
17
# This module contains all the classes used by ctioga
20
Version::register_svn_info('$Revision: 192 $', '$Date: 2010-11-07 18:07:01 +0100 (Sun, 07 Nov 2010) $')
31
'style' => 'line-style',
32
'closed' => 'boolean',
35
## @todo Maybe this cumbersome level/point thing along with the
36
# $last_curve_style calls for a context for the primitive, ie
37
# which was the state of the dataset/curve stack at the moment
38
# when the primitive was drawn ?
40
primitive("contour", "contour", [ 'level'],
41
ContoursOptions) do |t, level,options|
43
# table = PlotMaker.plotmaker.data_stack.last.indexed_table
45
table = d.indexed_table
46
contour = table.make_contour(l)
47
contour << options['closed']
49
## @todo This $last_curve_style isn't beautiful.
51
## Worse, it won't work !
52
options['color'] ||= $last_curve_style.line.color
54
stroke_style = Styles::StrokeStyle.from_hash(options, '%s')
58
stroke_style.set_stroke_style(t)
59
t.append_points_with_gaps_to_path(*contour)