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, XYZMap

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

#locationObject

Makes sure there is a location when one asks for it.



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

def location
  @location ||= Styles::LocationStyle.new
  return @location
end

#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.



51
52
53
54
# File 'lib/ctioga2/graphics/elements/element.rb', line 51

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)



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ctioga2/graphics/elements/element.rb', line 58

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