Class: CTioga2::Graphics::CurveGenerator
- Inherits:
-
Object
- Object
- CTioga2::Graphics::CurveGenerator
- Defined in:
- lib/ctioga2/graphics/generator.rb
Overview
This class is in charge of generating Elements::TiogaElement, such as Elements::Curve2D, from a dataset. It takes care of generating the appropriate style and of transforming the coordinates.
Constant Summary collapse
- PlotOptions =
{ 'bypass-transforms' => CmdArg.new('boolean') }
Instance Attribute Summary collapse
-
#current_curves ⇒ Object
The current kind of generated.
-
#legend_provider ⇒ Object
The provider of legends, a Legends::LegendProvider object.
-
#style_factory ⇒ Object
A Styles::CurveStyleFactory object that handles the styles for every single curve that will be drawn.
Instance Method Summary collapse
-
#curve_from_dataset(plot, dataset, options = {}) ⇒ Object
Creates a Elements::TiogaElement representing the dataset and returns it.
-
#initialize ⇒ CurveGenerator
constructor
Creates a CurveGenerator object.
Constructor Details
#initialize ⇒ CurveGenerator
Creates a CurveGenerator object.
45 46 47 48 49 |
# File 'lib/ctioga2/graphics/generator.rb', line 45 def initialize @legend_provider = Legends::LegendProvider.new @style_factory = Styles::CurveStyleFactory.new @current_curves = :xy_plot end |
Instance Attribute Details
#current_curves ⇒ Object
The current kind of generated. It is a symbol
42 43 44 |
# File 'lib/ctioga2/graphics/generator.rb', line 42 def current_curves @current_curves end |
#legend_provider ⇒ Object
The provider of legends, a Legends::LegendProvider object.
39 40 41 |
# File 'lib/ctioga2/graphics/generator.rb', line 39 def legend_provider @legend_provider end |
#style_factory ⇒ Object
A Styles::CurveStyleFactory object that handles the styles for every single curve that will be drawn.
35 36 37 |
# File 'lib/ctioga2/graphics/generator.rb', line 35 def style_factory @style_factory end |
Instance Method Details
#curve_from_dataset(plot, dataset, options = {}) ⇒ Object
Creates a Elements::TiogaElement representing the dataset and returns it.
todo
-
other kinds of coordinate transformations
-
other kinds of curves (pseudo-3D, surfaces, histograms…)
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ctioga2/graphics/generator.rb', line 62 def curve_from_dataset(plot, dataset, = {}) # Does coordinate transforms first ? # @todo copy datasets here rather than overwriting them ! # -> this should be an option ! if ! ['bypass-transforms'] plot.style.apply_transforms!(dataset) end # Now, we trim options unrelated to the plotting .delete_if { |k,v| ! Graphics::Styles:: CurveStyleFactory::PlotCommandOptions.key?(k) } return send(@current_curves, plot, dataset, ) end |