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/generator.rb,
lib/ctioga2/graphics/coordinates.rb,
lib/ctioga2/graphics/styles/axes.rb,
lib/ctioga2/graphics/styles/base.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/texts.rb,
lib/ctioga2/graphics/legends/items.rb,
lib/ctioga2/graphics/styles/legend.rb,
lib/ctioga2/graphics/styles/carrays.rb,
lib/ctioga2/graphics/styles/factory.rb,
lib/ctioga2/graphics/legends/storage.rb,
lib/ctioga2/graphics/styles/drawable.rb,
lib/ctioga2/graphics/types/bijection.rb,
lib/ctioga2/graphics/elements/curve2d.rb,
lib/ctioga2/graphics/elements/element.rb,
lib/ctioga2/graphics/elements/subplot.rb,
lib/ctioga2/graphics/legends/provider.rb,
lib/ctioga2/graphics/subplot-commands.rb,
lib/ctioga2/graphics/types/boundaries.rb,
lib/ctioga2/graphics/types/dimensions.rb,
lib/ctioga2/graphics/styles/background.rb,
lib/ctioga2/graphics/elements/primitive.rb,
lib/ctioga2/graphics/elements/containers.rb

Overview

This module contains all graphical elements of CTioga2

Defined Under Namespace

Modules: Elements, Legends, LineStyles, Styles, Types Classes: CoordinateTransforms, CurveGenerator, RootObject

Constant Summary collapse

ColorType =
CmdType.new('color', {
                              :type => :tioga_color,
                              :namespace => Tioga::ColorConstants
                            }, <<EOD)
A color. It can take three forms:
 * the name of a named color; see 
http://tioga.rubyforge.org/doc/classes/Tioga/ColorConstants.html
for the list of colors.
 * 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 => {'none' => false }
                  }, <<EOD)
A {type: color}, or false to say that nothing should be drawn.
EOD
LineStyleType =
CmdType.new('line-style', {
                    :type => :tioga_line_style,
                    :namespace => LineStyles
                  }, <<EOD)
A line style.
EOD
MarkerType =
CmdType.new('marker', {
                    :type => :tioga_marker,
                    :namespace => Tioga::MarkerConstants,
                    :shortcuts => {
                      'None' => 'None',
                      'no' => 'None',
                      'none' => 'None',
                      'off' => 'None', 
                    },}, <<EOD)
A Tioga Marker.
EOD
PointType =
CmdType.new('point', :point, <<EOD)
A given point on a figure.
EOD
JustificationType =
CmdType.new('justification', :tioga_justification, <<EOD)
Horizontal aligment for text.
EOD
AlignmentType =
CmdType.new('alignment', :tioga_align, <<EOD)
Vertical aligment for text.
EOD
PDFFont =
CmdType.new('pdf-font', :integer, <<EOD)
A number between 1 and 14 that designates one of the 14 standard 
PDF fonts.
EOD
AlignedPointType =
CmdType.new('aligned-point', {:type => :aligned_point, 
                    :default => :frame}, <<EOD)
A point together with alignment specifications.
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 the 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...
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 (for figure coordinates, i.e. the coordinates of the
plot), frame (1.0 frame is the full size of the current subplot) and
page (1.0 page is the whole height/width of the output file).

figure can be abbreviated as f, frame as F and page as p.
EOD
BoxType =

Boxes

CmdType.new('box', :box, <<EOD)
The specification for a box, such as an inset. Specifications vary for
now... 

TODO: to be written later on.
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
LegendInsideCommand =
Cmd.new("legend-inside", nil, "--legend-inside",
          [ CmdArg.new('aligned-point')]) do |plotmaker, point|
  l = Legends::LegendArea.new(:inside)
  l.legend_position = point
  plotmaker.root_object.current_plot.legend_area = 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 =
{
  'dy' => CmdArg.new('dimension'),
  'scale' => CmdArg.new('float'),
  'text_scale' => CmdArg.new('float'),
}
LegendStyleCommand =
Cmd.new("legend-style",nil,"--legend-style", 
          [], LegendStyleOptions) do |plotmaker, options|
  plotmaker.root_object.current_legend_area.
    legend_style.set_from_hash(options)
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 =

Various coordinate-related commands:

[]
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)
SetFrameMarginsCommand =
Cmd.new("frame-margins",nil,"--frame-margins", 
          [
           CmdArg.new('frame-margins'),
          ]) do |plotmaker, margins|
  
  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
InsetCommand =
Cmd.new("inset",nil,"--inset", 
          [
           CmdArg.new('box'),
          ]) do |plotmaker, box|
  subplot = plotmaker.root_object.subplot
  subplot.subframe = box
end
NextInsetCommand =
Cmd.new("next-inset",nil,"--next-inset", 
          [
           CmdArg.new('box'),
          ]) do |plotmaker, box|
  plotmaker.root_object.leave_subobject
  subplot = plotmaker.root_object.subplot
  subplot.subframe = box
end
EndCommand =
Cmd.new("end",nil,"--end", 
          []) do |plotmaker|
  plotmaker.root_object.leave_subobject
end
RescaleCommand =
Cmd.new("plot-scale",nil,"--plot-scale", 
          [CmdArg.new('float')], 
          {'what' => CmdArg.new('text')}) do |plotmaker, scale, options|
  what = options['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