Class: Sketchup::Overlay
- Inherits:
-
Object
- Object
- Sketchup::Overlay
- Defined in:
- lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb
Overview
An Overlay provides contextual model information directly in the viewport. This can be presented in 2D and 3D.
Examples can be annotations or analytical model information such as geometry analysis, energy analysis, etc.
The overlay feature is not intended as a mechanism to provide custom entities to SketchUp. Whatever overlays draw is not pickable nor exportable.
It is also not allowed to perform model changes from overlay events. Doing so will result in a RuntimeError
being thrown.
Instance Method Summary collapse
-
#description ⇒ String
This is a short user facing description of the overlay that will appear in the UI.
-
#description=(description) ⇒ String
Sets a short user facing description of the overlay that will appear in the UI.
- #draw(view) ⇒ Object abstract
- #enabled=(enabled) ⇒ Object
- #enabled? ⇒ Boolean
-
#getExtents ⇒ Geom::BoundingBox
abstract
In order to accurately draw things, SketchUp needs to know the extents of what it is drawing.
-
#initialize(id, name, description: "") ⇒ Overlay
constructor
A new instance of Overlay.
-
#name ⇒ String
This is a user facing display name that will appear in the UI.
-
#onMouseEnter(flags, x, y, view) ⇒ Object
abstract
The #onMouseEnter method is called by SketchUp when the mouse enters the viewport.
-
#onMouseLeave(view) ⇒ Object
abstract
The #onMouseLeave method is called by SketchUp when the mouse enters the viewport.
-
#onMouseMove(flags, x, y, view) ⇒ Object
abstract
Try to make this method as efficient as possible because this method is called often.
- #overlay_id ⇒ String
-
#source ⇒ String
Describes the source associated with the overlay.
- #start ⇒ Object abstract
- #stop ⇒ Object abstract
-
#valid? ⇒ Boolean
Indicates whether the overlay is valid.
Constructor Details
#initialize(id, name, description: "") ⇒ Overlay
Returns a new instance of Overlay.
254 255 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 254 def initialize(id, name, description: "") end |
Instance Method Details
#description ⇒ String
This is a short user facing description of the overlay that will appear in the UI.
77 78 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 77 def description end |
#description=(description) ⇒ String
Sets a short user facing description of the overlay that will appear in the UI. Set this before adding to the Sketchup::OverlaysManager.
93 94 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 93 def description=(description) end |
#draw(view) ⇒ Object
It is called whenever the view updates.
This is called very often. Perform minimal amount of computation in this event. Cache the data needed to draw what the overlay needs whenever possible.
If you draw outside the model bounds you need to implement #getExtents which return a bounding box large enough to include the points you draw. Otherwise your drawing will be clipped.
143 144 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 143 def draw(view) end |
#enabled=(enabled) ⇒ Object
In most cases, extensions doesn’t need to expose any new UI for enabling them. This can be done from the Overlays panel. However, in some cases the extension might have additional UI related to the overlays and might want to offer a way to toggle its overlays along with the rest of the UI.
160 161 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 160 def enabled=(enabled) end |
#enabled? ⇒ Boolean
174 175 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 174 def enabled? end |
#getExtents ⇒ Geom::BoundingBox
The method should be implementing sub-classes ensure what is drawn in 3D space doesn’t appear clipped. If the overlay only draws in 2D this isn’t needed.
This is called very often. Perform minimal amount of computation in this event. Cache the data needed to compute the bounds of what the overlay draws whenever possible.
In order to accurately draw things, SketchUp needs to know the extents of what it is drawing. If the overlay is doing its own drawing, it may need to implement this method to tell SketchUp the extents of what it will be drawing. If you don’t implement this method, you may find that part of what the overlay is drawing gets clipped to the extents of the rest of the model.
This must return a Geom::BoundingBox. In a typical implementation, you will create a new Geom::BoundingBox, add points to set the extents of the drawing that the overlay will do and then return it.
221 222 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 221 def getExtents end |
#name ⇒ String
This is a user facing display name that will appear in the UI.
269 270 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 269 def name end |
#onMouseEnter(flags, x, y, view) ⇒ Object
It can be used by implementing sub-classes to react to mouse movement in the viewport.
The #onMouseEnter method is called by SketchUp when the mouse enters the viewport.
309 310 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 309 def onMouseEnter(flags, x, y, view) end |
#onMouseLeave(view) ⇒ Object
It can be used by implementing sub-classes to react to mouse movement in the viewport.
The #onMouseLeave method is called by SketchUp when the mouse enters the viewport.
336 337 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 336 def onMouseLeave(view) end |
#onMouseMove(flags, x, y, view) ⇒ Object
It can be used by implementing sub-classes to react to mouse movement in the viewport.
Try to make this method as efficient as possible because this method is called often.
376 377 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 376 def onMouseMove(flags, x, y, view) end |
#overlay_id ⇒ String
399 400 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 399 def end |
#source ⇒ String
Describes the source associated with the overlay. This is automatically inferred when the overlay instance is initialized.
415 416 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 415 def source end |
#start ⇒ Object
It can be used by implementing sub-classes to react when the overlay becomes active, for instance when the user turns it on.
438 439 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 438 def start end |
#stop ⇒ Object
It can be used by implementing sub-classes to react when the overlay becomes inactive, for instance when the user turns it off.
461 462 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 461 def stop end |
#valid? ⇒ Boolean
Indicates whether the overlay is valid. An overlay becomes invalid after being removed from the model and cannot be reused.
487 488 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb', line 487 def valid? end |