Class: Presentation

Inherits:
Object
  • Object
show all
Includes:
Soby
Defined in:
lib/soby/presentation.rb

Constant Summary

Constants included from Soby

Soby::SLEEP_TIME

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Soby

auto_update, #create_mat4x4, find_files, find_files_except, #get_angle, #get_global_transform, load_presentation, #read_transform, reload_presentation, start_presentation

Constructor Details

#initialize(app) ⇒ Presentation

Returns a new instance of Presentation.



18
19
20
21
22
23
24
25
# File 'lib/soby/presentation.rb', line 18

def initialize (app)
  @app = app
  @graphics = @app.g
  @slides = {}
  @nb_slides = 0
  @playing_videos = []
  @source_files = []
end

Instance Attribute Details

#debugObject (readonly)

Returns the value of attribute debug.



12
13
14
# File 'lib/soby/presentation.rb', line 12

def debug
  @debug
end

#graphicsObject

Returns the value of attribute graphics.



16
17
18
# File 'lib/soby/presentation.rb', line 16

def graphics
  @graphics
end

#heightObject

Returns the value of attribute height.



11
12
13
# File 'lib/soby/presentation.rb', line 11

def height
  @height
end

#matrixObject

Returns the value of attribute matrix.



11
12
13
# File 'lib/soby/presentation.rb', line 11

def matrix
  @matrix
end

#nb_slidesObject (readonly)

Returns the value of attribute nb_slides.



12
13
14
# File 'lib/soby/presentation.rb', line 12

def nb_slides
  @nb_slides
end

#pshapeObject

Returns the value of attribute pshape.



10
11
12
# File 'lib/soby/presentation.rb', line 10

def pshape
  @pshape
end

#slidesObject

Returns the value of attribute slides.



10
11
12
# File 'lib/soby/presentation.rb', line 10

def slides
  @slides
end

#source_filesObject (readonly)

Returns the value of attribute source_files.



13
14
15
# File 'lib/soby/presentation.rb', line 13

def source_files
  @source_files
end

#urlObject

Returns the value of attribute url.



14
15
16
# File 'lib/soby/presentation.rb', line 14

def url
  @url
end

#videosObject

Returns the value of attribute videos.



11
12
13
# File 'lib/soby/presentation.rb', line 11

def videos
  @videos
end

#widthObject

Returns the value of attribute width.



11
12
13
# File 'lib/soby/presentation.rb', line 11

def width
  @width
end

Instance Method Details

#add_slide(new_slide) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/soby/presentation.rb', line 36

def add_slide(new_slide)
  puts "Add slide, id " << new_slide.title << " numero " << new_slide.sequence
  @slides[new_slide.sequence] = new_slide
  @slides[new_slide.title] = new_slide
  @nb_slides = @nb_slides+1

  p "Adding a new slide to the presentation", @nb_slides
end

#add_source(name) ⇒ Object



27
# File 'lib/soby/presentation.rb', line 27

def add_source name ; @source_files << name ;  end

#display_videosObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/soby/presentation.rb', line 46

def display_videos
  if not @app.is_moving

    slide_no = @app.current_slide_no

    # # Display the videos
    if slide_no > 0 and  @slides[slide_no].has_videos?

      # draw the object
      @graphics.imageMode(Processing::App::CORNER)

      @slides[slide_no].videos.each do |my_video|
        @graphics.push_matrix
        @graphics.modelview.apply(my_video.matrix)

        # when the video is loaded it is saved... so that the memory can
        # hopefully be freed
        @playing_videos << my_video if my_video.play

        ## force reading here..
        my_video.video.read if my_video.video.available?
#          my_video.video.read
        @graphics.image(my_video.video, 0, 0, my_video.width, my_video.height)


        @graphics.pop_matrix
      end # videos.each

    else  # has_videos

      ## no video, free some memory
      @playing_videos.each do |my_video|
        puts "Saving memory. "
        my_video.video.stop
        my_video.video = nil
        Java::JavaLang::System.gc
      end
      @playing_videos =  []
    end
  end
end

#drawObject



31
32
33
34
# File 'lib/soby/presentation.rb', line 31

def draw
  @graphics.shape pshape, 0, 0
#    display_videos
end

#to_sObject



89
90
91
# File 'lib/soby/presentation.rb', line 89

def to_s
  "Slides #{@slides.size}"
end