Class: Tracksperanto::Import::MatchMoverRZML::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/import/match_mover_rzml.rb

Instance Method Summary collapse

Constructor Details

#initialize(from_parser, tracker_callback) ⇒ Listener

Returns a new instance of Listener.



19
20
21
22
23
24
# File 'lib/import/match_mover_rzml.rb', line 19

def initialize(from_parser, tracker_callback)
  @cb = tracker_callback
  @path = []
  @parser = from_parser
  @trackers = []
end

Instance Method Details

#depthObject



26
27
28
# File 'lib/import/match_mover_rzml.rb', line 26

def depth
  @path.length
end

#in?(path_elems) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/import/match_mover_rzml.rb', line 71

def in?(path_elems)
  File.join(@path).include?(path_elems)
end

#tag_end(element_name) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/import/match_mover_rzml.rb', line 59

def tag_end(element_name)
  @path.pop
  if element_name.downcase == "rzml"
    @trackers.reject!{|e| e.empty? }
    
    @trackers.each do | recovered_tracker |
      @parser.report_progress "Pushing tracker #{recovered_tracker.name.inspect}"
      @cb.call(recovered_tracker)
    end
  end
end

#tag_start(element_name, attrs) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/import/match_mover_rzml.rb', line 30

def tag_start(element_name, attrs)
  @path << element_name.downcase
  
  if element_name.downcase == 'shot'
    @parser.width = attrs["w"]
    @parser.height = attrs["h"]
  end
  
  return unless @path.include?("ipln")
  
  #  <IPLN img="/home/torsten/some_local_nuke_scripts/render_tmp/md_145_1070_right.####.jpg" b="1" e="71">
  #		<IFRM>
  #			<M i="1" k="i" x="626.68" y="488.56" tt="0.8000000119" cf="0">
  if element_name.downcase == 'm'
    @parser.report_progress "Adding tracker"
    @trackers.push(Tracksperanto::Tracker.new(:name => attrs["i"]))
  end
  
  if element_name.downcase == "ifrm" && attrs["t"]
    @frame = attrs["t"].to_i
  end
  
  if element_name.downcase == "m"
    target_marker = @trackers.find{|e| e.name == attrs["i"] }
    @parser.report_progress "Recovering keyframe at #{@frame}"
    target_marker.keyframe!(:frame => @frame, :abs_x => attrs["x"], :abs_y => (@parser.height - attrs["y"].to_f), :residual => attrs["tt"])
  end
end

#text(t) ⇒ Object



76
# File 'lib/import/match_mover_rzml.rb', line 76

def text(t); end

#xmldecl(*a) ⇒ Object



75
# File 'lib/import/match_mover_rzml.rb', line 75

def xmldecl(*a); end