Class: CTioga::RulerSemiPrimitive

Inherits:
TiogaPrimitiveMaker show all
Includes:
Tioga::FigureConstants
Defined in:
lib/CTioga/elements/tioga_primitives.rb

Overview

A ruler

Constant Summary

Constants inherited from TiogaPrimitiveMaker

TiogaPrimitiveMaker::Alignment, TiogaPrimitiveMaker::Boolean, TiogaPrimitiveMaker::Color, TiogaPrimitiveMaker::FloatArray, TiogaPrimitiveMaker::Justification, TiogaPrimitiveMaker::LineStyle, TiogaPrimitiveMaker::Marker, TiogaPrimitiveMaker::Number, TiogaPrimitiveMaker::PRIMITIVES, TiogaPrimitiveMaker::Point

Instance Attribute Summary

Attributes inherited from TiogaPrimitiveMaker

#compulsory, #optional, #symbol

Instance Method Summary collapse

Methods inherited from TiogaPrimitiveMaker

#initialize, introspect, #parse_args, parse_spec

Methods included from Debug

#debug_figmaker, #debug_patterns, #debug_puts, #figmaker_options, #test_pattern, #test_pattern_right

Methods included from Log

#identify, #init_logger, #logger, #logger_options, #spawn

Constructor Details

This class inherits a constructor from CTioga::TiogaPrimitiveMaker

Instance Method Details

#make_funcall(args, plotmaker) ⇒ Object



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/CTioga/elements/tioga_primitives.rb', line 357

def make_funcall(args, plotmaker)
  dict = parse_args(args)

  ret = []

  line_dict = dict.dup
  line_dict['head_marker'] ||= Tioga::FigureConstants::BarThin
  line_dict['tail_marker'] ||= Tioga::FigureConstants::BarThin

  line_dict['tail_scale'] ||= 0.5
  line_dict['head_scale'] ||= 0.5

  
  line_dict['tail'] = dict['point']
  # We start from point and go on
  line_dict['head'] = dict['point'].dup
  if @symbol == :vrule
    line_dict['head'][1] += dict['size']
  else
    line_dict['head'][0] += dict['size']
  end

  for k in %w(label size point)
    line_dict.delete k
  end

  ret << TiogaFuncall.new(:show_arrow, line_dict)

  # For the label, we tweak the aligment
  if dict.key? 'label'
    label = {}
    label['at'] = (Dobjects::Dvector.new(line_dict['head']) + 
                   Dobjects::Dvector.new(line_dict['tail'])) * 0.5
    label['text'] = dict['label']
    # We place the label on the left/bottom
    if @symbol == :vrule
      label['justification'] = RIGHT_JUSTIFIED
      label['alignment'] = ALIGNED_AT_MIDHEIGHT
    else
      label['justification'] = CENTERED
      label['alignment'] = ALIGNED_AT_TOP
    end
    ret << TiogaFuncall.new(:show_text, label)
  end
  
                         
  # And we return the Funcall(s)...
  return ret
end