class CTioga2::Graphics::Styles::ParametricPlotStyle

This class defines how the Z values are converted into stylistic information

Public Class Methods

new() click to toggle source
# File lib/ctioga2/graphics/styles/plot-types.rb, line 60
def initialize
  @z1 = :marker_color
end

Public Instance Methods

marker_style(curve_style, zvalue, zmin, zmax) click to toggle source

Returns the marker style for the given Z values.

This will only work if prepare has been called first !

# File lib/ctioga2/graphics/styles/plot-types.rb, line 84
def marker_style(curve_style, zvalue, zmin, zmax)

  style = curve_style.marker.dup

  if @reversed[:marker_scale]
    idx = @reversed[:marker_scale]
    if idx < zvalue.size
      max_scale = curve_style.marker.scale || 1.0

      ## @todo Later on, when a min_marker_scale is provided,
      ## then the scale will be constrained between the min
      ## and max. For now, it is simply proportionnal to the
      ## absolute value of the largest.
      min_scale = curve_style.marker_min_scale

      zm = zmin[idx]
      zM = zmax[idx] 
      
      mm = zM.abs
      m2 = zm.abs
      mm = m2 if m2 > mm

      z = zvalue[idx]

      style.scale = if min_scale
                      min_scale + (max_scale - min_scale) * 
                        (z - zm)/(zM - zm)
                    else
                      zvalue[idx].abs/mm * max_scale
                    end
    end

  end

  for bs in [:color, :line_color, :fill_color]
    stl = "marker_#{bs}".to_sym
    if @reversed[stl]
      idx = @reversed[stl]
      if idx < zvalue.size
        map = curve_style.send("#{stl}_map")
        if map
          style.send("#{bs}=",map.z_color(zvalue[idx], 
                                          zmin[idx], 
                                          zmax[idx]))
        end
      end
    end
  end

  return style

end
prepare() click to toggle source
# File lib/ctioga2/graphics/styles/plot-types.rb, line 64
def prepare
  @reversed = {}

  4.times do |i|
    val = self.send("z#{i+1}")
    if val
      @reversed[val] = i
      @needed = i+1
    end
  end
end
z_columns_needed() click to toggle source

The number of Z columns needed for the style.

# File lib/ctioga2/graphics/styles/plot-types.rb, line 77
def z_columns_needed
  return @needed || 0
end