Class: CTioga2::Graphics::Elements::TiogaPrimitiveCall
- Inherits:
-
TiogaElement
- Object
- TiogaElement
- CTioga2::Graphics::Elements::TiogaPrimitiveCall
- Defined in:
- lib/ctioga2/graphics/elements/primitive.rb
Overview
A TiogaElement that represents a graphics primitive.
Defined Under Namespace
Classes: TiogaPrimitive
Constant Summary collapse
- PrimitiveCommands =
{}
- PrimitiveGroup =
CmdGroup.new('tioga-primitives', "Graphics primitives", "Tioga graphics primitives", 3)
- MarkerOptions =
TODO: add rendering mode !!
{ 'color' => 'color', 'stroke_color' => 'color', 'fill_color' => 'color', 'scale' => 'float', 'horizontal_scale' => 'float', 'vertical_scale' => 'float', 'angle' => 'float', 'justification' => 'justification', 'alignment' => 'alignment', }
Instance Attribute Summary collapse
-
#arguments ⇒ Object
An array containing the values of the compulsory arguments.
-
#options ⇒ Object
A hash containing the values of the optional arguments.
-
#primitive ⇒ Object
A TiogaPrimitive object describing the current primitive.
Attributes inherited from TiogaElement
Class Method Summary collapse
-
.get_primitive(name) ⇒ Object
Returns a pair primitive/primitive command for the named primitive, or [ nil, nil ].
-
.primitive(name, long_name, comp, opts = {}, &code) ⇒ Object
Creates a new primitive with the given parameters, and makes it immediately available as a command.
Instance Method Summary collapse
-
#initialize(primitive, arguments, options) ⇒ TiogaPrimitiveCall
constructor
Creates a new TiogaPrimitiveCall object.
Methods inherited from TiogaElement
Methods included from Log
debug, error, fatal, #format_exception, #identify, info, init_logger, logger, set_level, #spawn, warn
Constructor Details
#initialize(primitive, arguments, options) ⇒ TiogaPrimitiveCall
Creates a new TiogaPrimitiveCall object.
70 71 72 73 74 |
# File 'lib/ctioga2/graphics/elements/primitive.rb', line 70 def initialize(primitive, arguments, ) @primitive = primitive @arguments = arguments @options = end |
Instance Attribute Details
#arguments ⇒ Object
An array containing the values of the compulsory arguments
63 64 65 |
# File 'lib/ctioga2/graphics/elements/primitive.rb', line 63 def arguments @arguments end |
#options ⇒ Object
A hash containing the values of the optional arguments
66 67 68 |
# File 'lib/ctioga2/graphics/elements/primitive.rb', line 66 def @options end |
#primitive ⇒ Object
A TiogaPrimitive object describing the current primitive
60 61 62 |
# File 'lib/ctioga2/graphics/elements/primitive.rb', line 60 def primitive @primitive end |
Class Method Details
.get_primitive(name) ⇒ Object
Returns a pair primitive/primitive command for the named primitive, or [ nil, nil ]
118 119 120 |
# File 'lib/ctioga2/graphics/elements/primitive.rb', line 118 def self.get_primitive(name) return [@known_primitives[name], PrimitiveCommands[name]] end |
.primitive(name, long_name, comp, opts = {}, &code) ⇒ Object
Creates a new primitive with the given parameters, and makes it immediately available as a command.
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 |
# File 'lib/ctioga2/graphics/elements/primitive.rb', line 86 def self.primitive(name, long_name, comp, opts = {}, &code) primitive = TiogaPrimitive.new(name, comp, opts, &code) @known_primitives[name] = primitive # Now, create the command cmd_args = comp.map do |x| CmdArg.new(x) end cmd_opts = {} for k,v in opts cmd_opts[k] = CmdArg.new(v) end cmd = Cmd.new("draw-#{name}",nil,"--draw-#{name}", cmd_args, cmd_opts) do |plotmaker, *rest| = rest.pop call = Elements:: TiogaPrimitiveCall.new(primitive, rest, ) plotmaker.root_object.current_plot. add_element(call) end cmd.describe("Draws #{long_name}", "Directly draws #{long_name} on the current plot", PrimitiveGroup) PrimitiveCommands[name] = cmd end |