Class: Metro::UI::ModelLabel

Inherits:
Model
  • Object
show all
Defined in:
lib/metro/models/ui/model_label.rb

Overview

The model label will draw a bounding box and label around another model

The model label is used by the model labeler which is a facet of the edit scene

Constant Summary

Constants included from Metro::Units

Metro::Units::Bounds

Instance Attribute Summary collapse

Attributes inherited from Model

#scene, #window

Instance Method Summary collapse

Methods inherited from Model

#_load, #_save, #after_initialize, #bounds, #create, #draw_completed?, hierarchy, inherited, #initialize, metro_name, #model, model_name, models, #name, #notification, #saveable_to_view, #show, #to_hash, #update, #update_completed?

Methods included from HasEvents

included

Methods included from KeyValueCoding

#get, #set

Methods included from PropertyOwner

included, #properties

Constructor Details

This class inherits a constructor from Metro::Model

Instance Attribute Details

#targetObject

Stores the model that is currently being labeled.



13
14
15
# File 'lib/metro/models/ui/model_label.rb', line 13

def target
  @target
end

Instance Method Details

#bounds=(bounds) ⇒ Object



15
16
17
18
19
# File 'lib/metro/models/ui/model_label.rb', line 15

def bounds=(bounds)
  bounding_box.position = bounds.top_left
  label.position = bounds.top_left + Point.at(4,2,label_z_order)
  label_background.position = label.position - Point.at(2,0,1)
end

#drawObject



49
50
51
52
# File 'lib/metro/models/ui/model_label.rb', line 49

def draw
  draw_bounding_box if should_draw_bounding_box
  draw_label if should_draw_label
end

#draw_bounding_boxObject



54
55
56
# File 'lib/metro/models/ui/model_label.rb', line 54

def draw_bounding_box
  bounding_box.draw
end

#draw_labelObject



58
59
60
61
# File 'lib/metro/models/ui/model_label.rb', line 58

def draw_label
  label_background.draw
  label.draw
end

#label_z_orderObject



39
40
41
# File 'lib/metro/models/ui/model_label.rb', line 39

def label_z_order
  target.respond_to?(:z_order) ? target.z_order + 2 : 0
end