Class: Sketchup::Overlay
Relationships | |
Inherits: | Object |
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.
Class Method Summary
- .new(id, name, description: "") ⇒ Overlay constructor
Instance Attribute Summary
-
#description ⇒ String
rw
This is a short user facing description of the overlay that will appear in the
::UI
. -
#description=(description) ⇒ String
rw
Sets a short user facing description of the overlay that will appear in the
::UI
. - #enabled=(enabled) rw
- #enabled? ⇒ Boolean rw
-
#valid? ⇒ Boolean
readonly
Indicates whether the overlay is valid.
Instance Method Summary
- #draw(view) abstract
-
#getExtents ⇒ Geom::BoundingBox
abstract
In order to accurately draw things, SketchUp needs to know the extents of what it is drawing.
-
#name ⇒ String
This is a user facing display name that will appear in the
::UI
. -
#onMouseEnter(flags, x, y, view)
abstract
The #onMouseEnter method is called by SketchUp when the mouse enters the viewport.
-
#onMouseLeave(view)
abstract
The #onMouseLeave method is called by SketchUp when the mouse enters the viewport.
-
#onMouseMove(flags, x, y, view)
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 abstract
- #stop abstract
Constructor Details
.new(id, name, description: "") ⇒ Overlay
Instance Attribute Details
#description ⇒ String (rw)
This is a short user facing description of the overlay that will appear in the ::UI
.
#description=(description) ⇒ String (rw)
Sets a short user facing description of the overlay that will appear in the ::UI
. Set
this before adding to the OverlaysManager
.
#enabled=(enabled) (rw)
#enabled? ⇒ Boolean
(rw)
#valid? ⇒ Boolean
(readonly)
Indicates whether the overlay is valid. An overlay becomes invalid after being removed from the model and cannot be reused.
Instance Method Details
#draw(view)
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.
#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.
#name ⇒ String
This is a user facing display name that will appear in the ::UI
.
#onMouseEnter(flags, x, y, view)
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.
#onMouseLeave(view)
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.
#onMouseMove(flags, x, y, view)
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.
#overlay_id ⇒ String
#source ⇒ String
Describes the source associated with the overlay. This is automatically inferred when the overlay instance is initialized.
#start
It can be used by implementing sub-classes to react when the overlay becomes active, for instance when the user turns it on.
#stop
It can be used by implementing sub-classes to react when the overlay becomes inactive, for instance when the user turns it off.