Class: CTioga2::Graphics::Styles::ParametricPlotStyle
- Inherits:
-
BasicStyle
- Object
- BasicStyle
- CTioga2::Graphics::Styles::ParametricPlotStyle
- Defined in:
- lib/ctioga2/graphics/styles/plot-types.rb
Overview
This class defines how the Z values are converted into stylistic information
Constant Summary
Constants inherited from BasicStyle
BasicStyle::AllStyles, BasicStyle::OldAttrAccessor
Instance Method Summary collapse
-
#initialize ⇒ ParametricPlotStyle
constructor
A new instance of ParametricPlotStyle.
-
#marker_style(curve_style, zvalue, zmin, zmax) ⇒ Object
Returns the marker style for the given Z values.
- #prepare ⇒ Object
-
#z_columns_needed ⇒ Object
The number of Z columns needed for the style.
Methods inherited from BasicStyle
alias_for, aliases, attr_accessor, attribute_type, attribute_types, attributes, convert_string_hash, defined_aliases, deprecated_attribute, from_hash, inherited, #instance_variable_defined?, normalize_hash, normalize_in, normalize_out, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other
Constructor Details
#initialize ⇒ ParametricPlotStyle
Returns a new instance of ParametricPlotStyle.
51 52 53 |
# File 'lib/ctioga2/graphics/styles/plot-types.rb', line 51 def initialize @z1 = :marker_color end |
Instance Method Details
#marker_style(curve_style, zvalue, zmin, zmax) ⇒ Object
Returns the marker style for the given Z values.
This will only work if #prepare has been called first !
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ctioga2/graphics/styles/plot-types.rb', line 75 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 if @reversed[:marker_color] idx = @reversed[:marker_color] if idx < zvalue.size style.color = curve_style.marker_color_map.z_color(zvalue[idx], zmin[idx], zmax[idx]) end end return style end |
#prepare ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ctioga2/graphics/styles/plot-types.rb', line 55 def prepare @reversed = {} 2.times do |i| val = self.send("z#{i+1}") if val @reversed[val] = i @needed = i+1 end end end |
#z_columns_needed ⇒ Object
The number of Z columns needed for the style.
68 69 70 |
# File 'lib/ctioga2/graphics/styles/plot-types.rb', line 68 def z_columns_needed return @needed || 0 end |