Module: CTioga2::Graphics
- Defined in:
- lib/ctioga2/graphics/root.rb,
lib/ctioga2/graphics/types.rb,
lib/ctioga2/graphics/legends.rb,
lib/ctioga2/graphics/elements.rb,
lib/ctioga2/graphics/geometry.rb,
lib/ctioga2/graphics/generator.rb,
lib/ctioga2/graphics/styles/box.rb,
lib/ctioga2/graphics/types/fill.rb,
lib/ctioga2/graphics/types/grid.rb,
lib/ctioga2/graphics/coordinates.rb,
lib/ctioga2/graphics/styles/axes.rb,
lib/ctioga2/graphics/styles/base.rb,
lib/ctioga2/graphics/styles/fill.rb,
lib/ctioga2/graphics/styles/plot.rb,
lib/ctioga2/graphics/styles/sets.rb,
lib/ctioga2/graphics/types/boxes.rb,
lib/ctioga2/graphics/types/point.rb,
lib/ctioga2/graphics/legends/area.rb,
lib/ctioga2/graphics/styles/curve.rb,
lib/ctioga2/graphics/styles/image.rb,
lib/ctioga2/graphics/styles/scope.rb,
lib/ctioga2/graphics/styles/texts.rb,
lib/ctioga2/graphics/styles/ticks.rb,
lib/ctioga2/graphics/legends/items.rb,
lib/ctioga2/graphics/styles/arrows.rb,
lib/ctioga2/graphics/styles/legend.rb,
lib/ctioga2/graphics/styles/styles.rb,
lib/ctioga2/graphics/styles/carrays.rb,
lib/ctioga2/graphics/styles/contour.rb,
lib/ctioga2/graphics/styles/factory.rb,
lib/ctioga2/graphics/types/location.rb,
lib/ctioga2/graphics/elements/region.rb,
lib/ctioga2/graphics/legends/storage.rb,
lib/ctioga2/graphics/styles/colormap.rb,
lib/ctioga2/graphics/styles/drawable.rb,
lib/ctioga2/graphics/styles/errorbar.rb,
lib/ctioga2/graphics/styles/location.rb,
lib/ctioga2/graphics/styles/map-axes.rb,
lib/ctioga2/graphics/types/bijection.rb,
lib/ctioga2/graphics/elements/contour.rb,
lib/ctioga2/graphics/elements/curve2d.rb,
lib/ctioga2/graphics/elements/element.rb,
lib/ctioga2/graphics/elements/subplot.rb,
lib/ctioga2/graphics/elements/tangent.rb,
lib/ctioga2/graphics/elements/xyz-map.rb,
lib/ctioga2/graphics/legends/provider.rb,
lib/ctioga2/graphics/styles/gradients.rb,
lib/ctioga2/graphics/subplot-commands.rb,
lib/ctioga2/graphics/types/boundaries.rb,
lib/ctioga2/graphics/types/dimensions.rb,
lib/ctioga2/graphics/legends/multicols.rb,
lib/ctioga2/graphics/styles/background.rb,
lib/ctioga2/graphics/styles/plot-types.rb,
lib/ctioga2/graphics/styles/stylesheet.rb,
lib/ctioga2/graphics/elements/histogram.rb,
lib/ctioga2/graphics/elements/primitive.rb,
lib/ctioga2/graphics/styles/colorbrewer.rb,
lib/ctioga2/graphics/elements/containers.rb,
lib/ctioga2/graphics/elements/style-lists.rb,
lib/ctioga2/graphics/elements/xyz-contour.rb,
lib/ctioga2/graphics/elements/parametric2d.rb,
lib/ctioga2/graphics/elements/plot-elements.rb,
lib/ctioga2/graphics/elements/gradient-region.rb,
lib/ctioga2/graphics/elements/redirecting-container.rb
Overview
This module contains all graphical elements of CTioga2
Defined Under Namespace
Modules: Elements, Legends, LineStyles, Styles, Types Classes: CoordinateTransforms, CurveGenerator, Line, RootObject, Segment
Constant Summary collapse
- NoRE =
/no(ne)?|off|false/i
- ColorType =
CmdType.new('color', { :type => :tioga_color, :namespace => Tioga::ColorConstants, }, <<EOD) A color. It can take three forms: * a named color, see {url: http://tioga.rubyforge.org/doc/classes/Tioga/ColorConstants.html} for the list of color names. * an HTML color: for instance, @#f00@ or @#ff0000@ is red; * a list of three numbers between 0 and 1: @1,0,0@ is red too. EOD
- ColorOrFalseType =
CmdType.new('color-or-false', { :type => :tioga_color, :namespace => Tioga::ColorConstants, :shortcuts => { NoRE => false } }, <<EOD) A {type: color}, or none to say that nothing should be drawn. EOD
- RegionSideType =
CmdType.new('region-side', { :type => :list, :list => {}, :shortcuts => { 'above' => :above, 'below' => :below, 'ignore' => false, } }, <<EOD) Within a {command: region}, designates the position of the curve with respect to the region: * @above@ * @below@ * @ignore@ if this curve is not to be taken into account EOD
- LineStyleType =
CmdType.new('line-style', { :type => :tioga_line_style, :namespace => LineStyles, :shortcuts => { NoRE => false, } }, <<EOD) A line style, which is one of @solid@, @dots@, @dashes@, @small_dots@, a series of comma-separated numbers which are the length of the strokes and gaps, or @no@, @none@ or @off@ to mean no line. EOD
- MarkerType =
CmdType.new('marker', { :type => :tioga_marker, :namespace => Tioga::MarkerConstants, :shortcuts => { NoRE => false } }, <<EOD) A Tioga Marker, ie either a name from the list at {url: http://tioga.rubyforge.org/doc/Tioga/MarkerConstants.html}, such as @Box@, @Star@, @Spade@ or two or three comma-separated numbers, _font_, _number_ and _width_. _font_ defines the font (standard PDF fonts, from 1 to 14), _number_ the number of the character within the font (between 0 and 255), and if _width_ is specified, the marker is stroked and not filled, and the number is the line width for the stroke. EOD
- PointType =
CmdType.new('point', :point, <<EOD) A given point on a figure. EOD
- LevelType =
We need a very specific type for that as we want to have a reference to the level too !
CmdType.new('level', :level, <<EOD) A level on a XYZ map (that is, just a Z value). EOD
- JustificationRE =
{ /l(eft)?/i => Tioga::FigureConstants::LEFT_JUSTIFIED, /c(enter)?/i => Tioga::FigureConstants::CENTERED, /r(ight)?/i => Tioga::FigureConstants::RIGHT_JUSTIFIED }
- JustificationType =
CmdType.new('justification', {:type => :re_list, :list => JustificationRE}, <<EOD) Horizontal aligment of the (with respect to its location). Can be one of: * @l@ or @left@ * @c@, @center@ * @r@, @right@ EOD
- TextAlignType =
CmdType.new('text-align', {:type => :re_list, :list => JustificationRE, :shortcut => { NoRE => :no } }, <<EOD) Horizontal aligment for text within its box. Only of use for texts with a given text width. Can be one of: * @l@ or @left@ * @c@, @center@ * @r@, @right@ * @no@ or @none@ to not issue aligning commands, in which case you get full LaTeX-justified paragraphs (probably with a lot of hyphens). EOD
- AlignmentRE =
Regular expression for vertical alignment
{ /t(op)?/i => Tioga::FigureConstants::ALIGNED_AT_TOP, /c(enter)|m(idheight)/i => Tioga::FigureConstants::ALIGNED_AT_MIDHEIGHT, /B|Baseline|baseline/ => Tioga::FigureConstants::ALIGNED_AT_BASELINE, /b(ottom)?/ => Tioga::FigureConstants::ALIGNED_AT_BOTTOM }
- AlignmentType =
CmdType.new('alignment', {:type => :re_list, :list => AlignmentRE}, <<EOD) Vertical aligment for text. Can be one of: * @t@ or @top@ * @c@, @center@, @m@ or @midheight@ (vertically centered) * @B@, @Baseline@ or @baseline@ to align at the baseline * @b@ or @bottom@ EOD
- PDFFont =
CmdType.new('pdf-font', :integer, <<EOD) A number between 1 and 14 that designates one of the 14 standard PDF fonts. (see for instance {url: http://tioga.rubyforge.org/doc/classes/Tioga/MarkerConstants.html} for more information). EOD
- AlignedPointType =
CmdType.new('aligned-point', {:type => :aligned_point, :default => :frame}, <<EOD) A point together with alignment specifications, used to place some elements such as legends for instance, that require alignment information. The first two letters represent the alignment: * @t@ for top * @b@ for bottom * @c@ for center * @l@ for left and * @r@ for right These letters can optionally be followed by the exact location of the point in frame coordinates. If not provided, a reasonable default value is chosen. Examples: * @tl@ is a point at the top left of the frame aligned to the top and left; * @cl:0.1,0.6@ is vertically centered and aligned to the left, and positioned 10% from the left and 60% from the bottom. EOD
- FrameMarginsType =
CmdType.new('frame-margins', {:type => :frame_margins, :shortcuts => { /^\s*auto\s*$/i => nil}}, <<EOD) Margins around a plot, ie the distance from the side of the plot to the corresponding side of the container (most likely the whole PDF). It can take three forms: * @dimension@ (applies to all sides) * @left_right, top_bottom@ * @left, right, top, bottom@ Each of these elements is a valid {type: dimension}. It can also be @auto@, in which case the position of the margins is computed automatically to accomodate the various labels/ticks. EOD
- AxisDecorationType =
Now, axes stuff:
CmdType.new('axis-decoration', :tioga_axis_type, <<EOD) Kinds of decoration on a axis line, such as nothing, lines, ticks, tick labels. Possible values: * @hidden@, @off@, @no@, @none@: no axis at all * @line@: only a line * @ticks@: only ticks * @major@: only major ticks * @major-num@: major ticks along with their labels * @full@: major ticks and labels + minor ticks EOD
- TicksSideRE =
{ /i(nside)?/i => {'ticks_inside' => true, 'ticks_outside' => false}, /o(utside)?/i => {'ticks_outside' => true, 'ticks_inside' => false}, /b(oth)?/i => {'ticks_outside' => true, 'ticks_inside' => true} }
- TicksSideType =
CmdType.new('ticks-side', {:type => :re_list, :list => TicksSideRE}, <<EOD) On what side of an axis line are the ticks positioned: * @inside@: on the inside * @outside@: on the outside * @both@: on both the inside and the outside EOD
- DimensionType =
Dimensions
CmdType.new('dimension', { :type => :dimension, :default => :dy }, <<EOD) A dimension, in absolute units, or in units of text height, figure, frame or page coordinates. It is in the form @value unit@ where @value@ is a number and unit can be one of @pt@, @bp@, @in@, @cm@ (absolute units, same meaning as in TeX), @dy@ (@1.0 dy@ is the height of a text line), @figure@ or @f@ (for figure coordinates, i.e. the coordinates of the plot), @frame@ or @F@ (@1.0 frame@ is the full size of the current subplot) and @page@ or @p@ (@1.0 page@ is the whole height/width of the output file). It can also be @auto@, which is 1.0 in frame units (ie the width or the height of the current plot). EOD
- DimensionOrNoType =
CmdType.new('dimension-or-no', { :type => :dimension, :default => :dy, :shortcuts => { NoRE => false } }, <<EOD) A {type: dimension}, or @no@ or @none@. EOD
- BoxType =
Boxes
CmdType.new('box', :box, <<EOD) The specification for a box, such as an inset. It can be a grid specification, such as @grid:0,1@. For this to work, a grid must have been setup beforehand using {command: setup-grid}. It can also be an {type: aligned-point} together with a width and optionally a height in frame coordinates, such as: * @cc:0.3@: a box in the center of size 30% width and 30% height; * @bl:0.1,0.2:0.7,0.2@ a box starting from the point at 10% from the left and 20% from the bottom, with a width of 70% and a height of 20%. EOD
- BijectionType =
Coordinate transformations
CmdType.new('bijection', :bijection, <<EOD) A pair of functions of x specifying a bidirectional coordinate transformation separated by a double colon (@::@), in the order @from::to@. Each of the functions must be valid Ruby code - it is not exactly mathematical functions, in particular Ruby does not like floats which are missing digits on either side of the dot : for instance, @.3@ and @1.@ are not valid. Sorry. In most of the usual cases, the coordinate transform is an involution, that is from and to is the same function (this is the case for a/x). In this case, you can omit the second function. EOD
- LegendGroup =
Now, various commands pertaining to legends
CmdGroup.new('legends', "Legends", <<EOD, 1) Commands to specify legends and tweak their look. EOD
- NextLegendCommand =
Cmd.new("legend",'-l',"--legend", [ CmdArg.new('text') ]) do |plotmaker, legend| plotmaker.curve_generator.legend_provider.current_legend = legend end
- LegendLineCommand =
Cmd.new("legend-line",nil,"--legend-line", [ CmdArg.new('text') ], Styles::FullTextStyleOptions) do |plotmaker, legend, opts| l = Legends::LegendLine.new(legend, opts) plotmaker.root_object.current_plot.add_legend_item(l) end
- AutoLegendCommand =
Cmd.new("auto-legend",nil,"--auto-legend", [ CmdArg.new('boolean') ]) do |plotmaker, value| plotmaker.curve_generator.legend_provider.auto_legend = value end
- LegendStyleOptions =
Styles::LegendStorageStyle.()
- LegendStyleCommand =
Cmd.new("legend-style",nil,"--legend-style", [], LegendStyleOptions) do |plotmaker, | plotmaker.root_object.current_legend_area. legend_style.set_from_hash() end
- LegendInsideCommand =
Cmd.new("legend-inside", nil, "--legend-inside", [ CmdArg.new('aligned-point')], opts) do |plotmaker, point, | l = Legends::LegendArea.new(:inside, plotmaker.root_object.current_plot, ) l.legend_position = point plotmaker.root_object.current_plot.legend_area = l l.legend_style.set_from_hash() end
- LegendMulticolOptions =
Styles::MultiColumnLegendStyle.()
- LegendMultiColCommand =
Cmd.new("legend-multicol", nil, "--legend-multicol", [], LegendMulticolOptions) do |plotmaker, | multicol = Legends::MultiColumnLegend.new multicol.style.set_from_hash() plotmaker.root_object.current_plot. enter_legend_subcontainer(multicol) end
- LegendMultiColEndCommand =
Cmd.new("legend-multicol-end", nil, "--legend-multicol-end", [], {}) do |plotmaker, | plotmaker.root_object.current_plot. enter_legend_subcontainer(nil) end
- PlotCoordinatesGroup =
Now, various commands pertaining to various drawables
CmdGroup.new('coordinates', "Plot coordinates", "Plot coordinates", 2)
- PlotMarginCommand =
Cmd.new("margin",nil,"--margin", [ CmdArg.new('float') ]) do |plotmaker, margin| plotmaker.root_object.current_plot.style.plot_margin = margin end
- CoordinateRelatedCommands =
TODO:
All these commands should be axis-dependent, and not
Various coordinate-related commands:
plot-dependent.
[]
- PlotTypesGroup =
The group for chosing plot types.
CmdGroup.new('plot-types', "Switch between different kinds of plots", "How to switch between different kinds of plot types", 01)
- XYParametricPlotCommand =
Cmd.new("xy-parametric",nil,"--xy-parametric", [], Styles::ParametricPlotStyle.) do |plotmaker, opts| plotmaker.curve_generator.current_curves = :xy_parametric plotmaker.curve_generator. xy_parametric_parameters.set_from_hash(opts) end
- HistogramPlotCommand =
Cmd.new("histogram",nil,"--histogram", [], Styles::HistogramStyle.) do |plotmaker, opts| plotmaker.curve_generator.current_curves = :histogram plotmaker.curve_generator. histogram_parameters.set_from_hash(opts) end
- ContourPlotCommand =
Cmd.new("contour",nil,"--contour") do |plotmaker| plotmaker.curve_generator.current_curves = :xyz_contour end
- XYPlotCommand =
Cmd.new("xy-plot",nil,"--xy-plot") do |plotmaker| plotmaker.curve_generator.current_curves = :xy_plot end
- XYZMapCommand =
Cmd.new("xyz-map",nil,"--xyz-map") do |plotmaker| plotmaker.curve_generator.current_curves = :xyz_map end
- SubplotsGroup =
The group containing all commands linked to subplots and other insets, frame margin selections…
CmdGroup.new('subplots', "Subplots and assimilated", "Subplots and assimilated", 31)
- SFMOpts =
{}
- SetFrameMarginsCommand =
Cmd.new("frame-margins",nil,"--frame-margins", [ CmdArg.new('frame-margins'), ], SFMOpts) do |plotmaker, margins, opts| if margins for w in SFMOpts.keys if opts.key? w dim = margins.send(w) dim.copy_from(opts[w]) end end end plotmaker.root_object.current_plot.subframe = margins end
- PaddingCommand =
Cmd.new("padding",nil,"--padding", [ CmdArg.new('dimension'), ]) do |plotmaker, dim| Styles::PlotStyle.current_plot_style(plotmaker).padding = dim end
- TARE =
{ /^\s*old/i => :old, /^\s*both/i => :both, /^\s*measure/i => :measure, }
- TEType =
CmdType.new('text-adjust-mode', {:type => :re_list, :list => TARE}, <<EOD) Mode for text size adjustment * @old@ for the old style heuristics * @both@ for both the old style heuristics and the measures, taking whichever of those is the biggest * @measure@ for only measured text size (but watch out for axis ticks !) EOD
- TAACommand =
Cmd.new("text-adjust-mode",nil,"--text-adjust-mode", [ CmdArg.new('text-adjust-mode'), ]) do |plotmaker, tf| Styles::PlotStyle.current_plot_style(plotmaker).text_auto_adjust = tf end
- RootPlotCommand =
Cmd.new("root-plot",nil,"--root-plot", [ ], Elements::TiogaElement::StyleBaseOptions) do |plotmaker, opts| Log::debug { "Starting a subplot with specs #{box.inspect}" } opts['id'] ||= 'root' plotmaker.root_object. enter_subobject(Elements::Subplot.new(nil,plotmaker.root_object, opts)) end
- InsetCommand =
Cmd.new("inset",nil,"--inset", [ CmdArg.new('box'), ], Elements::TiogaElement::StyleBaseOptions) do |plotmaker, box, opts| Log::debug { "Starting a subplot with specs #{box.inspect}" } subplot = plotmaker.root_object.subplot(opts) subplot.subframe = box end
- NextInsetCommand =
Cmd.new("next-inset",nil,"--next-inset", [ CmdArg.new('box'), ], Elements::TiogaElement::StyleBaseOptions) do |plotmaker, box,opts| plotmaker.root_object.leave_subobject subplot = plotmaker.root_object.subplot(opts) subplot.subframe = box end
- EndCommand =
Cmd.new("end",nil,"--end", []) do |plotmaker| plotmaker.root_object.leave_subobject end
- RegionOptions =
{ 'color' => CmdArg.new('color'), 'pattern' => CmdArg.new('fill-pattern'), 'reversed_pattern' => CmdArg.new('fill-pattern'), 'transparency' => CmdArg.new('float'), 'reversed_color' => CmdArg.new('color'), 'reversed_transparency' => CmdArg.new('float'), }
- RegionCommand =
Cmd.new("region",nil,"--region", [ ], RegionOptions) do |plotmaker, | r = plotmaker.root_object.enter_region() r.set_from_hash() end
- GradientCommand =
Cmd.new("gradient",nil,"--gradient", [CmdArg.new('color'), CmdArg.new('color') ], Elements::TiogaElement::StyleBaseOptions) do |plotmaker, s, e, | r = plotmaker.root_object.enter_gradient() r.start_color = s r.end_color = e r.set_from_hash() end
- RescaleCommand =
Cmd.new("plot-scale",nil,"--plot-scale", [CmdArg.new('float')], {'what' => CmdArg.new('text')}) do |plotmaker, scale, | what = ['what'] || 'text' case what when /text/i Styles::PlotStyle.current_plot_style(plotmaker).text_scale = scale when /lines/i Styles::PlotStyle.current_plot_style(plotmaker).lines_scale = scale when /both/i Styles::PlotStyle.current_plot_style(plotmaker).text_scale = scale Styles::PlotStyle.current_plot_style(plotmaker).lines_scale = scale else CTioga2::Log::error { "Unkown 'what' option for plot-scale: #{what}" } end end
- SetupGridOptions =
Options for the SetupGrid command:
{}
- SetupGridCommand =
Cmd.new('setup-grid', nil, '--setup-grid', [ CmdArg.new('text') ], SetupGridOptions ) do |plotmaker, nup, | grd = Types::GridLayout.new(nup) for f in %w(left right top bottom) if .key? f grd.outer_margins[f] = [f] end end grd.delta_x = ['dx'] if ['dx'] grd.delta_y = ['dy'] if ['dy'] Types::GridLayout.current_grid = grd end
- ReopenCommand =
Cmd.new("reopen",nil,"--reopen", [CmdArg.new('object')], {}) do |plotmaker, obj, | plotmaker.root_object.enter_subobject(obj, false) end
- HideCommand =
Cmd.new("hide",nil,"--hide", [CmdArg.new('objects')], { 'show' => CmdArg.new('boolean') }) do |plotmaker, objs, opts| hidden = if opts.key? 'show' ! opts['show'] else true end for o in objs o.hidden = hidden end end