Class: SkippyLib::DrawingCache
- Inherits:
-
Object
- Object
- SkippyLib::DrawingCache
- Includes:
- ObjectUtils
- Defined in:
- modules/drawing_cache.rb
Overview
Caches drawing instructions so complex calculations for generating the GL data can be reused.
Redirect all Sketchup::View
commands to a DrawingCache object and call
#render
in a Tool's #draw
event.
Instance Method Summary collapse
-
#clear ⇒ Nil
Clears the cache.
-
#initialize(view) ⇒ DrawingCache
constructor
A new instance of DrawingCache.
- #inspect ⇒ String
-
#method_missing(method, *args) ⇒ Object
Pass through methods to
Sketchup::View
so that the drawing cache object can easily replaceSketchup::View
objects in existing codes. -
#render ⇒ Sketchup::View
Draws the cached drawing instructions.
- #respond_to_missing?(method) ⇒ Boolean
Constructor Details
#initialize(view) ⇒ DrawingCache
Returns a new instance of DrawingCache.
40 41 42 43 |
# File 'modules/drawing_cache.rb', line 40 def initialize(view) @view = view @commands = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Pass through methods to Sketchup::View
so that the drawing cache object
can easily replace Sketchup::View
objects in existing codes.
89 90 91 |
# File 'modules/drawing_cache.rb', line 89 def method_missing(method, *args) @view.respond_to?(method) ? @view.send(method, *args) : super end |
Instance Method Details
#clear ⇒ Nil
Clears the cache. All drawing instructions are removed.
49 50 51 52 |
# File 'modules/drawing_cache.rb', line 49 def clear @commands.clear nil end |
#inspect ⇒ String
99 100 101 |
# File 'modules/drawing_cache.rb', line 99 def inspect inspect_object(commands: @commands.size) end |
#render ⇒ Sketchup::View
Draws the cached drawing instructions.
58 59 60 61 62 63 64 |
# File 'modules/drawing_cache.rb', line 58 def render view = @view @commands.each { |command| view.send(*command) } view end |
#respond_to_missing?(method) ⇒ Boolean
93 94 95 |
# File 'modules/drawing_cache.rb', line 93 def respond_to_missing?(method, *) @view.respond_to?(method) | super end |