1
# element.rb: base class of all drawable elements
2
# copyright (c) 2006, 2007, 2008, 2009 by Vincent Fourmond:
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
# General Public License for more details (in the COPYING file).
15
require 'ctioga2/utils'
18
# This module contains all the classes used by ctioga
21
Version::register_svn_info('$Revision: 151 $', '$Date: 2010-06-19 23:45:20 +0200 (Sat, 19 Jun 2010) $')
23
# This module contains all graphical elements of CTioga2
26
# All elements that can be drawn onto a FigureMaker object
29
# The base class for every single object that is drawn on
34
# The parent Container.
37
# Details pertaining to the location of the object, as a
38
# LocationStyle object
41
# Makes sure there is a location when one asks for it.
43
@location ||= Styles::LocationStyle.new
47
# This function must be called with a FigureMaker object to
48
# draw the contents of the TiogaElement onto it. It calls
49
# #real_do, which should be redefined by the children. You can
50
# redefine _do_ too if you need another debugging output.
52
debug { "plotting #{self.inspect}" }
56
# We plot everything but parent. If a prefix is given, it is prepended
57
# to all lines but the first (for indentation)
58
def inspect(prefix="")
59
ret = "#<#{self.class.name}:\n"
60
for i in instance_variables
61
next if i == "@parent"
62
var = instance_variable_get(i)
63
ret += "#{prefix} - #{i} -> "
64
if var.is_a? TiogaElement
65
ret += "#{var.inspect("#{prefix} ")}\n"
67
ret += "#{var.inspect}\n"
77
raise "Should be reimplemented by children"
82
# # A unique method call to a FigureMaker object.
83
# class TiogaFuncall < TiogaElement
85
# # _symbol_ is the symbol to be called, and the remainder will
86
# # be used as arguments for the call.
87
# def initialize(symbol, *args)
95
# f.send(@symbol, *@args)