Class: CTioga2::Graphics::Elements::XYZMap

Inherits:
PlotBasedElement show all
Includes:
Log, Dobjects
Defined in:
lib/ctioga2/graphics/elements/xyz-map.rb

Overview

TODO:

There should be a way to automatically display level

This class represents a XY map of Z values, ie something that is represented using an image

lines, and possibly only that.

Constant Summary

Constants inherited from TiogaElement

TiogaElement::StyleBaseOptions

Instance Attribute Summary collapse

Attributes inherited from PlotBasedElement

#curve_style, #dataset

Attributes inherited from TiogaElement

#clipped, #depth, #hidden, #location, #object_classes, #object_id, #object_parent, #parent

Instance Method Summary collapse

Methods included from Log

context, debug, error, fatal, #format_exception, #identify, info, init_logger, log_to, logger, set_level, #spawn, warn

Methods inherited from PlotBasedElement

#clipped, #depth, #location

Methods inherited from TiogaElement

all_styles, base_style, #check_styled, define_style, #do, find_object, #get_style, #has_style?, inherited, #inspect, register_object, register_style, #setup_style, #style_class, style_class, style_name, #style_name, styled_classes, #update_style

Constructor Details

#initialize(dataset, style = nil) ⇒ XYZMap

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



42
43
44
45
46
# File 'lib/ctioga2/graphics/elements/xyz-map.rb', line 42

def initialize(dataset, style = nil)
  @dataset = dataset
  @curve_style = style
  prepare_data
end

Instance Attribute Details

#tableObject

The IndexedTable object representing the underlying data



37
38
39
# File 'lib/ctioga2/graphics/elements/xyz-map.rb', line 37

def table
  @table
end

Instance Method Details

#get_boundariesObject

Returns the Types::Boundaries of this curve.



56
57
58
# File 'lib/ctioga2/graphics/elements/xyz-map.rb', line 56

def get_boundaries
  return @table.xy_boundaries
end

#real_do(t) ⇒ Object

Actually draws the curve



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/ctioga2/graphics/elements/xyz-map.rb', line 62

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")
    
    dict = @curve_style.color_map.
      prepare_data_display(t,@table.table,
                           @table.table.min,
                           @table.table.max)
    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

    dict.update(@table.corner_positions)
    dict.update('width' => @table.width,
                'height' => @table.height)
    dict.update('interpolate' => false)
    if (! @curve_style.fill.transparency) || 
        (@curve_style.fill.transparency < 0.99) 
      t.show_image(dict)
    else
      info { 'Not showing map as transparency is over 0.99' }
    end
  end
end