Class: Sketchup::Overlay
- Inherits:
-
Object
- Object
- Sketchup::Overlay
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: "") ⇒ Object constructor
-
#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: "") ⇒ Object
Instance Method Details
↑ #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. Set this before adding to the Sketchup::OverlaysManager.
↑ #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.
↑ #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.
↑ #enabled? ⇒ Boolean
↑ #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.
↑ #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.
↑ #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.
↑ #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.
↑ #source ⇒ String
Describes the source associated with the overlay. This is automatically inferred when the overlay instance is initialized.
↑ #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.
↑ #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.
↑ #valid? ⇒ Boolean
Indicates whether the overlay is valid. An overlay becomes invalid after being removed from the model and cannot be reused.