sketchup-api-stubs 0.7.9 → 0.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sketchup-api-stubs/sketchup.rb +157 -151
  3. data/lib/sketchup-api-stubs/stubs/Array.rb +741 -741
  4. data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +322 -322
  5. data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +182 -172
  6. data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +111 -126
  7. data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +102 -102
  8. data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +423 -400
  9. data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +693 -661
  10. data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +535 -509
  11. data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +500 -476
  12. data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +267 -263
  13. data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +133 -141
  14. data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +547 -522
  15. data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +678 -693
  16. data/lib/sketchup-api-stubs/stubs/Geom.rb +351 -351
  17. data/lib/sketchup-api-stubs/stubs/LanguageHandler.rb +93 -93
  18. data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +595 -595
  19. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +751 -747
  20. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +183 -183
  21. data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
  22. data/lib/sketchup-api-stubs/stubs/Layout/Dictionary.rb +234 -0
  23. data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +683 -517
  24. data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
  25. data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +148 -148
  26. data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +464 -353
  27. data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +354 -354
  28. data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +311 -311
  29. data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +261 -261
  30. data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +91 -91
  31. data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +370 -370
  32. data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +218 -218
  33. data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +128 -128
  34. data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +225 -225
  35. data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +614 -567
  36. data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +10 -10
  37. data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +11 -11
  38. data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +282 -183
  39. data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +458 -387
  40. data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +209 -209
  41. data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +346 -344
  42. data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +174 -174
  43. data/lib/sketchup-api-stubs/stubs/Layout/ReferenceEntity.rb +82 -82
  44. data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +714 -692
  45. data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1565 -1519
  46. data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +290 -290
  47. data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +149 -149
  48. data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +139 -139
  49. data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +135 -135
  50. data/lib/sketchup-api-stubs/stubs/Layout.rb +25 -25
  51. data/lib/sketchup-api-stubs/stubs/Length.rb +286 -278
  52. data/lib/sketchup-api-stubs/stubs/Numeric.rb +249 -249
  53. data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +196 -144
  54. data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +169 -169
  55. data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +226 -209
  56. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +145 -150
  57. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +294 -281
  58. data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
  59. data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +296 -302
  60. data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +473 -478
  61. data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
  62. data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +121 -121
  63. data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +294 -294
  64. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +673 -659
  65. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +600 -593
  66. data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +76 -76
  67. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +252 -257
  68. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +32 -32
  69. data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +201 -201
  70. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +443 -449
  71. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +74 -74
  72. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +104 -104
  73. data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +167 -165
  74. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +306 -306
  75. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +42 -42
  76. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
  77. data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +403 -406
  78. data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +397 -397
  79. data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
  80. data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1282 -1239
  81. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesBuilder.rb +261 -261
  82. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +127 -127
  83. data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +519 -545
  84. data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +60 -60
  85. data/lib/sketchup-api-stubs/stubs/Sketchup/Environment.rb +406 -0
  86. data/lib/sketchup-api-stubs/stubs/Sketchup/Environments.rb +185 -0
  87. data/lib/sketchup-api-stubs/stubs/Sketchup/EnvironmentsObserver.rb +113 -0
  88. data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +122 -125
  89. data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +1006 -937
  90. data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +102 -102
  91. data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +740 -750
  92. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +289 -282
  93. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +64 -62
  94. data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
  95. data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +405 -468
  96. data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +266 -266
  97. data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +189 -189
  98. data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +432 -406
  99. data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +84 -84
  100. data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +307 -306
  101. data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +332 -326
  102. data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +380 -422
  103. data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +409 -427
  104. data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +241 -249
  105. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
  106. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +55 -48
  107. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
  108. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +114 -114
  109. data/lib/sketchup-api-stubs/stubs/Sketchup/LoadHandler.rb +70 -0
  110. data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
  111. data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +1115 -414
  112. data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +330 -317
  113. data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +142 -142
  114. data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +93 -93
  115. data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1714 -1652
  116. data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +372 -357
  117. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +133 -130
  118. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +271 -271
  119. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
  120. data/lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb +463 -490
  121. data/lib/sketchup-api-stubs/stubs/Sketchup/OverlaysManager.rb +104 -116
  122. data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +939 -797
  123. data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +388 -361
  124. data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +77 -77
  125. data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +501 -478
  126. data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
  127. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +385 -361
  128. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +45 -45
  129. data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
  130. data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +451 -458
  131. data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +115 -115
  132. data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +211 -212
  133. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +259 -255
  134. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +59 -59
  135. data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -40
  136. data/lib/sketchup-api-stubs/stubs/Sketchup/Snap.rb +125 -0
  137. data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +88 -69
  138. data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +263 -217
  139. data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +283 -262
  140. data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +199 -217
  141. data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
  142. data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +924 -834
  143. data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
  144. data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +156 -156
  145. data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +75 -75
  146. data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +143 -142
  147. data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1566 -1311
  148. data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +71 -45
  149. data/lib/sketchup-api-stubs/stubs/Sketchup.rb +1429 -1377
  150. data/lib/sketchup-api-stubs/stubs/SketchupExtension.rb +353 -353
  151. data/lib/sketchup-api-stubs/stubs/String.rb +24 -24
  152. data/lib/sketchup-api-stubs/stubs/UI/Command.rb +399 -389
  153. data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +580 -494
  154. data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +280 -269
  155. data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +258 -241
  156. data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +636 -635
  157. data/lib/sketchup-api-stubs/stubs/UI.rb +791 -683
  158. data/lib/sketchup-api-stubs/stubs/_top_level.rb +303 -303
  159. data/lib/sketchup-api-stubs.rb +1 -1
  160. metadata +10 -24
@@ -1,490 +1,463 @@
1
- # Copyright:: Copyright 2023 Trimble Inc.
2
- # License:: The MIT License (MIT)
3
-
4
- # An Overlay provides contextual model information directly in the viewport.
5
- # This can be presented in 2D and 3D.
6
- #
7
- # Examples can be annotations or analytical model information such as geometry
8
- # analysis, energy analysis, etc.
9
- #
10
- # The overlay feature is not intended as a mechanism to provide custom entities
11
- # to SketchUp. Whatever overlays draw is not pickable nor exportable.
12
- #
13
- # It is also not allowed to perform model changes from overlay events. Doing
14
- # so will result in a +RuntimeError+ being thrown.
15
- #
16
- # @api Overlays
17
- #
18
- # @example
19
- # class ExampleOverlay < Sketchup::Overlay
20
- #
21
- # def initialize
22
- # super('example_inc.my_overlay', 'Example Overlay')
23
- # end
24
- #
25
- # def draw(view)
26
- # rectangle = [
27
- # [100, 100, 0], [300, 100, 0], [300, 200, 0], [100, 200, 0]
28
- # ]
29
- # view.drawing_color = 'blue'
30
- # view.draw2d(GL_QUADS, rectangle)
31
- # point = Geom::Point3d.new(120, 120, 0)
32
- # view.draw_text(point, "Hello Overlay", size: 20, bold: true, color: 'white')
33
- # end
34
- #
35
- # end
36
- #
37
- # # Using an observer to create a new overlay per model.
38
- # class ExampleAppObserver < Sketchup::AppObserver
39
- #
40
- # def expectsStartupModelNotifications
41
- # true
42
- # end
43
- #
44
- # def register_overlay(model)
45
- # overlay = ExampleOverlay.new
46
- # model.overlays.add(overlay)
47
- # end
48
- # alias_method :onNewModel, :register_overlay
49
- # alias_method :onOpenModel, :register_overlay
50
- #
51
- # end
52
- #
53
- # observer = ExampleAppObserver.new
54
- # Sketchup.add_observer(observer)
55
- #
56
- # # The following line is needed if you copy+paste in the Ruby Console or
57
- # # at the moment the extension is installed:
58
- # observer.register_overlay(Sketchup.active_model)
59
- #
60
- # @version SketchUp 2023.0
61
- class Sketchup::Overlay
62
-
63
- # Instance Methods
64
-
65
- # This is a short user facing description of the overlay that will appear in the UI.
66
- #
67
- # @api Overlays
68
- #
69
- # @example
70
- # Sketchup.active_model.overlays.each { |overlay|
71
- # puts "#{overlay.name}: #{overlay.description}"
72
- # }
73
- #
74
- # @return [String]
75
- #
76
- # @version SketchUp 2023.0
77
- def description
78
- end
79
-
80
- # Sets a short user facing description of the overlay that will appear in the UI.
81
- # Set this before adding to the {Sketchup::OverlaysManager}.
82
- #
83
- # @api Overlays
84
- #
85
- # @example
86
- # Sketchup.active_model.overlays.each { |overlay|
87
- # puts "#{overlay.name}: #{overlay.description}"
88
- # }
89
- #
90
- # @return [String]
91
- #
92
- # @version SketchUp 2023.0
93
- def description=(description)
94
- end
95
-
96
- #
97
- # @abstract It is called whenever the view updates.
98
- #
99
- # @api Overlays
100
- #
101
- # @example
102
- # class ExampleOverlay < Sketchup::Overlay
103
- #
104
- # def initialize
105
- # super('example_inc.my_overlay', 'Example Overlay')
106
- # end
107
- #
108
- # def draw(view)
109
- # # Draw a square.
110
- # points = [
111
- # Geom::Point3d.new(0, 0, 0),
112
- # Geom::Point3d.new(9, 0, 0),
113
- # Geom::Point3d.new(9, 9, 0),
114
- # Geom::Point3d.new(0, 9, 0)
115
- # ]
116
- # # Fill
117
- # view.drawing_color = Sketchup::Color.new(255, 128, 128)
118
- # view.draw(GL_QUADS, points)
119
- # # Outline
120
- # view.line_stipple = '' # Solid line
121
- # view.drawing_color = Sketchup::Color.new(64, 0, 0)
122
- # view.draw(GL_LINE_LOOP, points)
123
- # end
124
- #
125
- # end
126
- #
127
- # @note This is called very often. Perform minimal amount of computation in
128
- # this event. Cache the data needed to draw what the overlay needs whenever
129
- # possible.
130
- #
131
- # @note If you draw outside the model bounds you need to implement
132
- # {Sketchup::Overlay#getExtents} which return a bounding box large enough to
133
- # include the points you draw. Otherwise your drawing will be clipped.
134
- #
135
- # @param [Sketchup::View] view
136
- # A View object where the method was invoked.
137
- #
138
- # @see getExtents
139
- #
140
- # @see Sketchup::View#draw
141
- #
142
- # @version SketchUp 2023.0
143
- def draw(view)
144
- end
145
-
146
- #
147
- # @api Overlays
148
- #
149
- # @note In most cases, extensions doesn't need to expose any new UI for
150
- # enabling them. This can be done from the Overlays panel. However, in some
151
- # cases the extension might have additional UI related to the overlays and
152
- # might want to offer a way to toggle its overlays along with the rest of
153
- # the UI.
154
- #
155
- # @param [Boolean] enabled
156
- #
157
- # @raise [RuntimeError] if the overlay is not added to a model.
158
- #
159
- # @version SketchUp 2023.0
160
- def enabled=(enabled)
161
- end
162
-
163
- #
164
- # @api Overlays
165
- #
166
- # @example
167
- # Sketchup.active_model.overlays.each { |overlay|
168
- # puts "#{overlay.name} (#{overlay.overlay_id}) Enabled: #{overlay.enabled?}"
169
- # }
170
- #
171
- # @return [Boolean]
172
- #
173
- # @version SketchUp 2023.0
174
- def enabled?
175
- end
176
-
177
- # In order to accurately draw things, SketchUp needs to know the extents of
178
- # what it is drawing. If the overlay is doing its own drawing, it may need to
179
- # implement this method to tell SketchUp the extents of what it will be
180
- # drawing. If you don't implement this method, you may find that part of what
181
- # the overlay is drawing gets clipped to the extents of the rest of the
182
- # model.
183
- #
184
- # This must return a {Geom::BoundingBox}. In a typical implementation, you
185
- # will create a new {Geom::BoundingBox}, add points to set the extents of the
186
- # drawing that the overlay will do and then return it.
187
- #
188
- # @abstract The method should be implementing sub-classes ensure what is drawn
189
- # in 3D space doesn't appear clipped. If the overlay only draws in 2D this
190
- # isn't needed.
191
- #
192
- # @api Overlays
193
- #
194
- # @example
195
- # class ExampleOverlay < Sketchup::Overlay
196
- #
197
- # def initialize
198
- # super('example_inc.my_overlay', 'Example Overlay')
199
- # @points = [ [0, 0, 0], [9, 0, 0], [9, 9, 0], [0, 9, 0] ]
200
- # end
201
- #
202
- # def getExtents
203
- # bb = Sketchup.active_model.bounds
204
- # bb.add(@points)
205
- # return bb
206
- # end
207
- #
208
- # def draw(view)
209
- # view.draw(GL_QUADS, @points)
210
- # end
211
- #
212
- # end
213
- #
214
- # @note This is called very often. Perform minimal amount of computation in
215
- # this event. Cache the data needed to compute the bounds of what the overlay
216
- # draws whenever possible.
217
- #
218
- # @return [Geom::BoundingBox]
219
- #
220
- # @version SketchUp 2023.0
221
- def getExtents
222
- end
223
-
224
- #
225
- # @api Overlays
226
- #
227
- # @example
228
- # class ExampleOverlay < Sketchup::Overlay
229
- #
230
- # def initialize
231
- # description = "A short sentence describing the overlay."
232
- # super('example_inc.my_overlay', 'Example Overlay', description: description)
233
- # end
234
- #
235
- # end
236
- #
237
- # overlay = ExampleOverlay.new
238
- #
239
- # @param [String] id
240
- # The string should be unique per overlay subclass.
241
- # A good pattern would be something like: +"company_name.extension_name.overlay_name"+.
242
- #
243
- # @param [String] name
244
- # This is a user facing display name that will appear in the UI.
245
- # Make it short and representative for what the overlay does.
246
- #
247
- # @param [String] description
248
- # This is a user facing description that will appear in the UI.
249
- # Make it short and representative for what the overlay does.
250
- #
251
- # @raise [ArgumentError] if +id+ or +name+ is an empty string
252
- #
253
- # @version SketchUp 2023.0
254
- def initialize(id, name, description: "")
255
- end
256
-
257
- # This is a user facing display name that will appear in the UI.
258
- #
259
- # @api Overlays
260
- #
261
- # @example
262
- # Sketchup.active_model.overlays.each { |overlay|
263
- # puts "#{overlay.name} (#{overlay.overlay_id}) Enabled: #{overlay.enabled?}"
264
- # }
265
- #
266
- # @return [String]
267
- #
268
- # @version SketchUp 2023.0
269
- def name
270
- end
271
-
272
- # The {#onMouseEnter} method is called by SketchUp when the mouse enters the
273
- # viewport.
274
- #
275
- # @abstract It can be used by implementing sub-classes to react to
276
- # mouse movement in the viewport.
277
- #
278
- # @api Overlays
279
- #
280
- # @example
281
- # class ExampleOverlay < Sketchup::Overlay
282
- #
283
- # def initialize
284
- # super('example_inc.my_overlay', 'Example Overlay')
285
- # end
286
- #
287
- # def onMouseEnter(flags, x, y, view)
288
- # puts "onMouseEnter: flags = #{flags}"
289
- # puts " x = #{x}"
290
- # puts " y = #{y}"
291
- # puts " view = #{view}"
292
- # end
293
- #
294
- # end
295
- #
296
- # @param [Integer] flags
297
- # A bit mask that tells the state of the modifier
298
- # keys and other mouse buttons at the time.
299
- #
300
- # @param [Integer] x
301
- # The X coordinate on the screen where the event occurred.
302
- #
303
- # @param [Integer] y
304
- # The Y coordinate on the screen where the event occurred.
305
- #
306
- # @param [Sketchup::View] view
307
- #
308
- # @version SketchUp 2023.0
309
- def onMouseEnter(flags, x, y, view)
310
- end
311
-
312
- # The {#onMouseLeave} method is called by SketchUp when the mouse enters the
313
- # viewport.
314
- #
315
- # @abstract It can be used by implementing sub-classes to react to
316
- # mouse movement in the viewport.
317
- #
318
- # @api Overlays
319
- #
320
- # @example
321
- # class ExampleOverlay < Sketchup::Overlay
322
- #
323
- # def initialize
324
- # super('example_inc.my_overlay', 'Example Overlay')
325
- # end
326
- #
327
- # def onMouseLeave(view)
328
- # puts "onMouseLeave"
329
- # end
330
- #
331
- # end
332
- #
333
- # @param [Sketchup::View] view
334
- #
335
- # @version SketchUp 2023.0
336
- def onMouseLeave(view)
337
- end
338
-
339
- # Try to make this method as efficient as possible because this method is
340
- # called often.
341
- #
342
- # @abstract It can be used by implementing sub-classes to react to
343
- # mouse movement in the viewport.
344
- #
345
- # @api Overlays
346
- #
347
- # @example
348
- # class ExampleOverlay < Sketchup::Overlay
349
- #
350
- # def initialize
351
- # super('example_inc.my_overlay', 'Example Overlay')
352
- # end
353
- #
354
- # def onMouseMove(flags, x, y, view)
355
- # puts "onMouseMove: flags = #{flags}"
356
- # puts " x = #{x}"
357
- # puts " y = #{y}"
358
- # puts " view = #{view}"
359
- # end
360
- #
361
- # end
362
- #
363
- # @param [Integer] flags
364
- # A bit mask that tells the state of the modifier
365
- # keys and other mouse buttons at the time.
366
- #
367
- # @param [Integer] x
368
- # The X coordinate on the screen where the event occurred.
369
- #
370
- # @param [Integer] y
371
- # The Y coordinate on the screen where the event occurred.
372
- #
373
- # @param [Sketchup::View] view
374
- #
375
- # @version SketchUp 2023.0
376
- def onMouseMove(flags, x, y, view)
377
- end
378
-
379
- #
380
- # @api Overlays
381
- #
382
- # @example Implementing
383
- # class ExampleOverlay < Sketchup::Overlay
384
- #
385
- # def initialize
386
- # super('example_inc.my_overlay', 'Example Overlay')
387
- # end
388
- #
389
- # end
390
- #
391
- # @example Accessing
392
- # Sketchup.active_model.overlays.each { |overlay|
393
- # puts "#{overlay.name} (#{overlay.overlay_id}) Enabled: #{overlay.enabled?}"
394
- # }
395
- #
396
- # @return [String]
397
- #
398
- # @version SketchUp 2023.0
399
- def overlay_id
400
- end
401
-
402
- # Describes the source associated with the overlay. This is automatically inferred
403
- # when the overlay instance is initialized.
404
- #
405
- # @api Overlays
406
- #
407
- # @example
408
- # Sketchup.active_model.overlays.each { |overlay|
409
- # puts "#{overlay.name} (Extension: #{overlay.source})"
410
- # }
411
- #
412
- # @return [String]
413
- #
414
- # @version SketchUp 2023.0
415
- def source
416
- end
417
-
418
- #
419
- # @abstract It can be used by implementing sub-classes to react when the overlay
420
- # becomes active, for instance when the user turns it on.
421
- #
422
- # @api Overlays
423
- #
424
- # @example
425
- # class ExampleOverlay < Sketchup::Overlay
426
- #
427
- # def initialize
428
- # super('example_inc.my_overlay', 'Example Overlay')
429
- # end
430
- #
431
- # def start
432
- # puts "Overlay #{self} started"
433
- # end
434
- #
435
- # end
436
- #
437
- # @version SketchUp 2023.0
438
- def start
439
- end
440
-
441
- #
442
- # @abstract It can be used by implementing sub-classes to react when the overlay
443
- # becomes inactive, for instance when the user turns it off.
444
- #
445
- # @api Overlays
446
- #
447
- # @example
448
- # class ExampleOverlay < Sketchup::Overlay
449
- #
450
- # def initialize
451
- # super('example_inc.my_overlay', 'Example Overlay')
452
- # end
453
- #
454
- # def stop(view)
455
- # puts "Overlay #{self} stopped"
456
- # end
457
- #
458
- # end
459
- #
460
- # @version SketchUp 2023.0
461
- def stop
462
- end
463
-
464
- # Indicates whether the overlay is valid. An overlay becomes invalid after
465
- # being removed from the model and cannot be reused.
466
- #
467
- # @api Overlays
468
- #
469
- # @example
470
- # class ExampleOverlay < Sketchup::Overlay
471
- # def initialize
472
- # super('example_inc.my_overlay', 'Example Overlay')
473
- # end
474
- # end
475
- #
476
- # overlay = ExampleOverlay.new
477
- # p overlay.valid? # => true
478
- # Sketchup.active_model.overlays.add(overlay)
479
- # p overlay.valid? # => true
480
- #
481
- # Sketchup.active_model.overlays.remove(overlay)
482
- # p overlay.valid? # => false
483
- #
484
- # @return [Boolean]
485
- #
486
- # @version SketchUp 2023.0
487
- def valid?
488
- end
489
-
490
- end
1
+ # Copyright:: Copyright 2026 Trimble Inc.
2
+ # License:: The MIT License (MIT)
3
+
4
+ # An Overlay provides contextual model information directly in the viewport.
5
+ # This can be presented in 2D and 3D.
6
+ #
7
+ # Examples can be annotations or analytical model information such as geometry
8
+ # analysis, energy analysis, etc.
9
+ #
10
+ # The overlay feature is not intended as a mechanism to provide custom entities
11
+ # to SketchUp. Whatever overlays draw is not pickable nor exportable.
12
+ #
13
+ # It is also not allowed to perform model changes from overlay events. Doing
14
+ # so will result in a +RuntimeError+ being thrown.
15
+ #
16
+ # @example
17
+ # class ExampleOverlay < Sketchup::Overlay
18
+ #
19
+ # def initialize
20
+ # super('example_inc.my_overlay', 'Example Overlay')
21
+ # end
22
+ #
23
+ # def draw(view)
24
+ # rectangle = [
25
+ # [100, 100, 0], [300, 100, 0], [300, 200, 0], [100, 200, 0]
26
+ # ]
27
+ # view.drawing_color = 'blue'
28
+ # view.draw2d(GL_QUADS, rectangle)
29
+ # point = Geom::Point3d.new(120, 120, 0)
30
+ # view.draw_text(point, "Hello Overlay", size: 20, bold: true, color: 'white')
31
+ # end
32
+ #
33
+ # end
34
+ #
35
+ # # Using an observer to create a new overlay per model.
36
+ # class ExampleAppObserver < Sketchup::AppObserver
37
+ #
38
+ # def expectsStartupModelNotifications
39
+ # true
40
+ # end
41
+ #
42
+ # def register_overlay(model)
43
+ # overlay = ExampleOverlay.new
44
+ # model.overlays.add(overlay)
45
+ # end
46
+ # alias_method :onNewModel, :register_overlay
47
+ # alias_method :onOpenModel, :register_overlay
48
+ #
49
+ # end
50
+ #
51
+ # observer = ExampleAppObserver.new
52
+ # Sketchup.add_observer(observer)
53
+ #
54
+ # # The following line is needed if you copy+paste in the Ruby Console or
55
+ # # at the moment the extension is installed:
56
+ # observer.register_overlay(Sketchup.active_model)
57
+ #
58
+ # @version SketchUp 2023.0
59
+ class Sketchup::Overlay
60
+
61
+ # Instance Methods
62
+
63
+ # This is a short user facing description of the overlay that will appear in the UI.
64
+ #
65
+ # @example
66
+ # Sketchup.active_model.overlays.each { |overlay|
67
+ # puts "#{overlay.name}: #{overlay.description}"
68
+ # }
69
+ #
70
+ # @return [String]
71
+ #
72
+ # @version SketchUp 2023.0
73
+ def description
74
+ end
75
+
76
+ # Sets a short user facing description of the overlay that will appear in the UI.
77
+ # Set this before adding to the {Sketchup::OverlaysManager}.
78
+ #
79
+ # @example
80
+ # Sketchup.active_model.overlays.each { |overlay|
81
+ # puts "#{overlay.name}: #{overlay.description}"
82
+ # }
83
+ #
84
+ # @return [String]
85
+ #
86
+ # @version SketchUp 2023.0
87
+ def description=(description)
88
+ end
89
+
90
+ #
91
+ # @abstract It is called whenever the view updates.
92
+ #
93
+ # @example
94
+ # class ExampleOverlay < Sketchup::Overlay
95
+ #
96
+ # def initialize
97
+ # super('example_inc.my_overlay', 'Example Overlay')
98
+ # end
99
+ #
100
+ # def draw(view)
101
+ # # Draw a square.
102
+ # points = [
103
+ # Geom::Point3d.new(0, 0, 0),
104
+ # Geom::Point3d.new(9, 0, 0),
105
+ # Geom::Point3d.new(9, 9, 0),
106
+ # Geom::Point3d.new(0, 9, 0)
107
+ # ]
108
+ # # Fill
109
+ # view.drawing_color = Sketchup::Color.new(255, 128, 128)
110
+ # view.draw(GL_QUADS, points)
111
+ # # Outline
112
+ # view.line_stipple = '' # Solid line
113
+ # view.drawing_color = Sketchup::Color.new(64, 0, 0)
114
+ # view.draw(GL_LINE_LOOP, points)
115
+ # end
116
+ #
117
+ # end
118
+ #
119
+ # @note This is called very often. Perform minimal amount of computation in
120
+ # this event. Cache the data needed to draw what the overlay needs whenever
121
+ # possible.
122
+ #
123
+ # @note If you draw outside the model bounds you need to implement
124
+ # {Sketchup::Overlay#getExtents} which return a bounding box large enough to
125
+ # include the points you draw. Otherwise your drawing will be clipped.
126
+ #
127
+ # @param [Sketchup::View] view
128
+ # A View object where the method was invoked.
129
+ #
130
+ # @see getExtents
131
+ #
132
+ # @see Sketchup::View#draw
133
+ #
134
+ # @version SketchUp 2023.0
135
+ def draw(view)
136
+ end
137
+
138
+ #
139
+ # @note In most cases, extensions doesn't need to expose any new UI for
140
+ # enabling them. This can be done from the Overlays panel. However, in some
141
+ # cases the extension might have additional UI related to the overlays and
142
+ # might want to offer a way to toggle its overlays along with the rest of
143
+ # the UI.
144
+ #
145
+ # @param [Boolean] enabled
146
+ #
147
+ # @raise [RuntimeError] if the overlay is not added to a model.
148
+ #
149
+ # @version SketchUp 2023.0
150
+ def enabled=(enabled)
151
+ end
152
+
153
+ #
154
+ # @example
155
+ # Sketchup.active_model.overlays.each { |overlay|
156
+ # puts "#{overlay.name} (#{overlay.overlay_id}) Enabled: #{overlay.enabled?}"
157
+ # }
158
+ #
159
+ # @return [Boolean]
160
+ #
161
+ # @version SketchUp 2023.0
162
+ def enabled?
163
+ end
164
+
165
+ # In order to accurately draw things, SketchUp needs to know the extents of
166
+ # what it is drawing. If the overlay is doing its own drawing, it may need to
167
+ # implement this method to tell SketchUp the extents of what it will be
168
+ # drawing. If you don't implement this method, you may find that part of what
169
+ # the overlay is drawing gets clipped to the extents of the rest of the
170
+ # model.
171
+ #
172
+ # This must return a {Geom::BoundingBox}. In a typical implementation, you
173
+ # will create a new {Geom::BoundingBox}, add points to set the extents of the
174
+ # drawing that the overlay will do and then return it.
175
+ #
176
+ # @abstract The method should be implementing sub-classes ensure what is drawn
177
+ # in 3D space doesn't appear clipped. If the overlay only draws in 2D this
178
+ # isn't needed.
179
+ #
180
+ # @example
181
+ # class ExampleOverlay < Sketchup::Overlay
182
+ #
183
+ # def initialize
184
+ # super('example_inc.my_overlay', 'Example Overlay')
185
+ # @points = [ [0, 0, 0], [9, 0, 0], [9, 9, 0], [0, 9, 0] ]
186
+ # end
187
+ #
188
+ # def getExtents
189
+ # bb = Sketchup.active_model.bounds
190
+ # bb.add(@points)
191
+ # return bb
192
+ # end
193
+ #
194
+ # def draw(view)
195
+ # view.draw(GL_QUADS, @points)
196
+ # end
197
+ #
198
+ # end
199
+ #
200
+ # @note This is called very often. Perform minimal amount of computation in
201
+ # this event. Cache the data needed to compute the bounds of what the overlay
202
+ # draws whenever possible.
203
+ #
204
+ # @return [Geom::BoundingBox]
205
+ #
206
+ # @version SketchUp 2023.0
207
+ def getExtents
208
+ end
209
+
210
+ #
211
+ # @example
212
+ # class ExampleOverlay < Sketchup::Overlay
213
+ #
214
+ # def initialize
215
+ # description = "A short sentence describing the overlay."
216
+ # super('example_inc.my_overlay', 'Example Overlay', description: description)
217
+ # end
218
+ #
219
+ # end
220
+ #
221
+ # overlay = ExampleOverlay.new
222
+ #
223
+ # @param [String] id
224
+ # The string should be unique per overlay subclass.
225
+ # A good pattern would be something like: +"company_name.extension_name.overlay_name"+.
226
+ #
227
+ # @param [String] name
228
+ # This is a user facing display name that will appear in the UI.
229
+ # Make it short and representative for what the overlay does.
230
+ #
231
+ # @param [String] description
232
+ # This is a user facing description that will appear in the UI.
233
+ # Make it short and representative for what the overlay does.
234
+ #
235
+ # @raise [ArgumentError] if +id+ or +name+ is an empty string
236
+ #
237
+ # @version SketchUp 2023.0
238
+ def initialize(id, name, description: "")
239
+ end
240
+
241
+ # This is a user facing display name that will appear in the UI.
242
+ #
243
+ # @example
244
+ # Sketchup.active_model.overlays.each { |overlay|
245
+ # puts "#{overlay.name} (#{overlay.overlay_id}) Enabled: #{overlay.enabled?}"
246
+ # }
247
+ #
248
+ # @return [String]
249
+ #
250
+ # @version SketchUp 2023.0
251
+ def name
252
+ end
253
+
254
+ # The {#onMouseEnter} method is called by SketchUp when the mouse enters the
255
+ # viewport.
256
+ #
257
+ # @abstract It can be used by implementing sub-classes to react to
258
+ # mouse movement in the viewport.
259
+ #
260
+ # @example
261
+ # class ExampleOverlay < Sketchup::Overlay
262
+ #
263
+ # def initialize
264
+ # super('example_inc.my_overlay', 'Example Overlay')
265
+ # end
266
+ #
267
+ # def onMouseEnter(flags, x, y, view)
268
+ # puts "onMouseEnter: flags = #{flags}"
269
+ # puts " x = #{x}"
270
+ # puts " y = #{y}"
271
+ # puts " view = #{view}"
272
+ # end
273
+ #
274
+ # end
275
+ #
276
+ # @param [Integer] flags
277
+ # A bit mask that tells the state of the modifier
278
+ # keys and other mouse buttons at the time.
279
+ #
280
+ # @param [Integer] x
281
+ # The X coordinate on the screen where the event occurred.
282
+ #
283
+ # @param [Integer] y
284
+ # The Y coordinate on the screen where the event occurred.
285
+ #
286
+ # @param [Sketchup::View] view
287
+ #
288
+ # @version SketchUp 2023.0
289
+ def onMouseEnter(flags, x, y, view)
290
+ end
291
+
292
+ # The {#onMouseLeave} method is called by SketchUp when the mouse enters the
293
+ # viewport.
294
+ #
295
+ # @abstract It can be used by implementing sub-classes to react to
296
+ # mouse movement in the viewport.
297
+ #
298
+ # @example
299
+ # class ExampleOverlay < Sketchup::Overlay
300
+ #
301
+ # def initialize
302
+ # super('example_inc.my_overlay', 'Example Overlay')
303
+ # end
304
+ #
305
+ # def onMouseLeave(view)
306
+ # puts "onMouseLeave"
307
+ # end
308
+ #
309
+ # end
310
+ #
311
+ # @param [Sketchup::View] view
312
+ #
313
+ # @version SketchUp 2023.0
314
+ def onMouseLeave(view)
315
+ end
316
+
317
+ # Try to make this method as efficient as possible because this method is
318
+ # called often.
319
+ #
320
+ # @abstract It can be used by implementing sub-classes to react to
321
+ # mouse movement in the viewport.
322
+ #
323
+ # @example
324
+ # class ExampleOverlay < Sketchup::Overlay
325
+ #
326
+ # def initialize
327
+ # super('example_inc.my_overlay', 'Example Overlay')
328
+ # end
329
+ #
330
+ # def onMouseMove(flags, x, y, view)
331
+ # puts "onMouseMove: flags = #{flags}"
332
+ # puts " x = #{x}"
333
+ # puts " y = #{y}"
334
+ # puts " view = #{view}"
335
+ # end
336
+ #
337
+ # end
338
+ #
339
+ # @overload onMouseMove(flags, x, y, view)
340
+ #
341
+ # @note Signature for versions prior to SketchUp 2025.0
342
+ # @version SketchUp 2023.0
343
+ # @param [Integer] flags A bit mask that tells the state of the modifier
344
+ # keys and other mouse buttons at the time.
345
+ # @param [Integer] x Screen coordinate in physical pixels.
346
+ # @param [Integer] y Screen coordinate in physical pixels.
347
+ # @param [Sketchup::View] view
348
+ #
349
+ # @overload onMouseMove(flags, x, y, view)
350
+ #
351
+ # @version SketchUp 2025.0
352
+ # @param [Integer] flags A bit mask that tells the state of the modifier
353
+ # keys and other mouse buttons at the time.
354
+ # @param [Float] x Screen coordinate in logical pixels.
355
+ # @param [Float] y Screen coordinate in logical pixels.
356
+ # @param [Sketchup::View] view
357
+ #
358
+ # @version SketchUp 2023.0
359
+ def onMouseMove
360
+ end
361
+
362
+ #
363
+ # @example Implementing
364
+ # class ExampleOverlay < Sketchup::Overlay
365
+ #
366
+ # def initialize
367
+ # super('example_inc.my_overlay', 'Example Overlay')
368
+ # end
369
+ #
370
+ # end
371
+ #
372
+ # @example Accessing
373
+ # Sketchup.active_model.overlays.each { |overlay|
374
+ # puts "#{overlay.name} (#{overlay.overlay_id}) Enabled: #{overlay.enabled?}"
375
+ # }
376
+ #
377
+ # @return [String]
378
+ #
379
+ # @version SketchUp 2023.0
380
+ def overlay_id
381
+ end
382
+
383
+ # Describes the source associated with the overlay. This is automatically inferred
384
+ # when the overlay instance is initialized.
385
+ #
386
+ # @example
387
+ # Sketchup.active_model.overlays.each { |overlay|
388
+ # puts "#{overlay.name} (Extension: #{overlay.source})"
389
+ # }
390
+ #
391
+ # @return [String]
392
+ #
393
+ # @version SketchUp 2023.0
394
+ def source
395
+ end
396
+
397
+ #
398
+ # @abstract It can be used by implementing sub-classes to react when the overlay
399
+ # becomes active, for instance when the user turns it on.
400
+ #
401
+ # @example
402
+ # class ExampleOverlay < Sketchup::Overlay
403
+ #
404
+ # def initialize
405
+ # super('example_inc.my_overlay', 'Example Overlay')
406
+ # end
407
+ #
408
+ # def start
409
+ # puts "Overlay #{self} started"
410
+ # end
411
+ #
412
+ # end
413
+ #
414
+ # @version SketchUp 2023.0
415
+ def start
416
+ end
417
+
418
+ #
419
+ # @abstract It can be used by implementing sub-classes to react when the overlay
420
+ # becomes inactive, for instance when the user turns it off.
421
+ #
422
+ # @example
423
+ # class ExampleOverlay < Sketchup::Overlay
424
+ #
425
+ # def initialize
426
+ # super('example_inc.my_overlay', 'Example Overlay')
427
+ # end
428
+ #
429
+ # def stop(view)
430
+ # puts "Overlay #{self} stopped"
431
+ # end
432
+ #
433
+ # end
434
+ #
435
+ # @version SketchUp 2023.0
436
+ def stop
437
+ end
438
+
439
+ # Indicates whether the overlay is valid. An overlay becomes invalid after
440
+ # being removed from the model and cannot be reused.
441
+ #
442
+ # @example
443
+ # class ExampleOverlay < Sketchup::Overlay
444
+ # def initialize
445
+ # super('example_inc.my_overlay', 'Example Overlay')
446
+ # end
447
+ # end
448
+ #
449
+ # overlay = ExampleOverlay.new
450
+ # p overlay.valid? # => true
451
+ # Sketchup.active_model.overlays.add(overlay)
452
+ # p overlay.valid? # => true
453
+ #
454
+ # Sketchup.active_model.overlays.remove(overlay)
455
+ # p overlay.valid? # => false
456
+ #
457
+ # @return [Boolean]
458
+ #
459
+ # @version SketchUp 2023.0
460
+ def valid?
461
+ end
462
+
463
+ end