class CTioga2::Graphics::Elements::XYZMap
This class represents a XY map of Z values, ie something that is represented using an image
@todo There should be a way to automatically display level lines, and possibly only that.
Attributes
tables[RW]
The IndexedTable object representing the underlying data
Public Class Methods
new(dataset, style = nil)
click to toggle source
Creates a new XYZMap
object with the given dataset and style.
# File lib/ctioga2/graphics/elements/xyz-map.rb, line 42 def initialize(dataset, style = nil) @dataset = dataset @curve_style = style prepare_data @boundaries = nil end
Public Instance Methods
get_boundaries()
click to toggle source
Returns the Types::Boundaries
of this curve.
# File lib/ctioga2/graphics/elements/xyz-map.rb, line 65 def get_boundaries if @boundaries return @boundaries end bnds = Graphics::Types::Boundaries.bounds(@dataset.x.values, @dataset.y.values) @boundaries = bnds return bnds end
real_do(t)
click to toggle source
Actually draws the curve
# File lib/ctioga2/graphics/elements/xyz-map.rb, line 77 def real_do(t) debug { "Plotting curve #{inspect}" } t.context do # Of course, there are still quite a few things to do # ;-)... # Ideas: for leaving things out, I may have to use min_gt # along with masking. ## @todo handle non-homogeneous XY maps. @curve_style.color_map ||= Styles::ColorMap.from_text("Red--Green") zmin = @dataset.z.values.min zmax = @dataset.z.values.max for tbl in @tables dict = @curve_style.color_map. prepare_data_display(t,tbl.table, zmin, zmax) if @curve_style.zaxis begin @parent.style.get_axis_style(@curve_style.zaxis). set_color_map(@curve_style.color_map, zmin, zmax) rescue error { "Could not set Z info to non-existent axis #{@curve_style.zaxis}" } end end dict.update(tbl.corner_positions) dict.update('width' => tbl.width, 'height' => tbl.height) dict.update('interpolate' => false) if (! @curve_style.fill.transparency) || (@curve_style.fill.transparency < 0.99) t.show_image(dict) # t.stroke_rect(dict['ul'][0], dict['ul'][1], dict['lr'][0] - dict['ul'][0], dict['lr'][1] - dict['ul'][1]) else info { 'Not showing map as transparency is over 0.99' } end end end end
Protected Instance Methods
prepare_data()
click to toggle source
Prepares the internal storage of the data, from the @dataset
# File lib/ctioga2/graphics/elements/xyz-map.rb, line 50 def prepare_data @tables = @dataset.homogeneous_dtables info { str = "" for tbl in @tables str << " - #{tbl.x_values.min}, #{tbl.y_values.min} -> #{tbl.x_values.max}, #{tbl.y_values.max} #{tbl.width}x#{tbl.height}\n" end "There are #{@tables.size} different homogeneous submaps in #{@dataset.name}\n#{str}" } end