class CTioga2::Graphics::Elements::XYZContour

This class displays a XYZ element using contour lines.

Attributes

curve_style[RW]

A Styles::CurveStyle object saying how the curve should be drawn.

Some of the elements will be overridden.

table[RW]

The IndexedTable object representing the underlying data

Public Class Methods

new(dataset, style = nil) click to toggle source

Creates a new XYZContour object with the given dataset and style.

Lots of code in common with XYZMap

# File lib/ctioga2/graphics/elements/xyz-contour.rb, line 47
def initialize(dataset, style = nil)
  @dataset = dataset
  @curve_style = style
  prepare_data
end

Public Instance Methods

get_boundaries() click to toggle source

Returns the Types::Boundaries of this curve.

# File lib/ctioga2/graphics/elements/xyz-contour.rb, line 62
def get_boundaries
  return @table.xy_boundaries
end
real_do(t) click to toggle source

Actually draws the curve

# File lib/ctioga2/graphics/elements/xyz-contour.rb, line 68
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")
    
    if @curve_style.zaxis
      begin
        @parent.style.get_axis_style(@curve_style.zaxis).
          set_color_map(@curve_style.color_map, 
                        @table.table.min,
                        @table.table.max)
      rescue
        error { "Could not set Z info to non-existent axis #{@curve_style.zaxis}" }
      end
    end

    # Computation of equally spaced level lines
    nb = 20

    zmin = @table.table.min
    zmax = @table.table.max

    t.context do
      @curve_style.line.set_stroke_style(t)
      @curve_style.contour.plot_contours(t, table,
                                         zmin, zmax,
                                         @curve_style.color_map)
    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-contour.rb, line 54
def prepare_data
  @table = @dataset.indexed_table
end