Class: CTioga2::Graphics::Elements::TiogaElement

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/ctioga2/graphics/elements/element.rb

Overview

The base class for every single object that is drawn on Tioga’s output.

Direct Known Subclasses

Container, Curve2D, TiogaPrimitiveCall

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

debug, error, fatal, #format_exception, #identify, info, init_logger, logger, set_level, #spawn, warn

Instance Attribute Details

#parentObject

The parent Container.



35
36
37
# File 'lib/ctioga2/graphics/elements/element.rb', line 35

def parent
  @parent
end

Instance Method Details

#do(f) ⇒ Object

This function must be called with a FigureMaker object to draw the contents of the TiogaElement onto it. It calls #real_do, which should be redefined by the children. You can redefine do too if you need another debugging output.



41
42
43
44
# File 'lib/ctioga2/graphics/elements/element.rb', line 41

def do(f)
  debug "plotting #{self.inspect}"
  real_do(f)
end

#inspect(prefix = "") ⇒ Object

We plot everything but parent. If a prefix is given, it is prepended to all lines but the first (for indentation)



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ctioga2/graphics/elements/element.rb', line 48

def inspect(prefix="")
  ret = "#<#{self.class.name}:\n"
  for i in instance_variables
    next if i == "@parent"
    var = instance_variable_get(i)
    ret += "#{prefix}  - #{i} -> "
    if var.is_a? TiogaElement
      ret += "#{var.inspect("#{prefix}  ")}\n"
    else
      ret += "#{var.inspect}\n"
    end
  end
  ret += "#{prefix}>"
  return ret
end