scriptup 2026.0.0 → 2026.0.2

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 (489) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -24
  3. data/ext/arc_curve.c +50 -0
  4. data/ext/attribute_dictionaries.c +49 -32
  5. data/ext/attribute_dictionary.c +54 -127
  6. data/ext/axes.c +79 -0
  7. data/ext/behavior.c +100 -9
  8. data/ext/bounding_box.c +195 -0
  9. data/ext/camera.c +178 -0
  10. data/ext/classifications.c +85 -0
  11. data/ext/color.c +91 -163
  12. data/ext/component_definition.c +78 -162
  13. data/ext/component_instance.c +88 -9
  14. data/ext/construction.c +59 -0
  15. data/ext/curve.c +87 -0
  16. data/ext/definition_list.c +89 -109
  17. data/ext/depend +1 -0
  18. data/ext/drawing_element.c +96 -117
  19. data/ext/edge.c +147 -0
  20. data/ext/edge_use.c +37 -0
  21. data/ext/entities.c +573 -16
  22. data/ext/entities_builder.c +145 -0
  23. data/ext/entity.c +175 -212
  24. data/ext/environments.c +149 -0
  25. data/ext/extconf.rb +54 -10
  26. data/ext/face.c +331 -0
  27. data/ext/geom.c +172 -0
  28. data/ext/group.c +86 -0
  29. data/ext/helpers.c +244 -0
  30. data/ext/image.c +182 -0
  31. data/ext/image_rep.c +158 -0
  32. data/ext/instance_path.c +185 -0
  33. data/ext/lat_long.c +88 -0
  34. data/ext/layer.c +98 -0
  35. data/ext/layer_folder.c +99 -0
  36. data/ext/layers.c +122 -0
  37. data/ext/length.c +253 -0
  38. data/ext/line_styles.c +60 -0
  39. data/ext/loop.c +24 -0
  40. data/ext/material.c +144 -197
  41. data/ext/materials.c +49 -60
  42. data/ext/model.c +232 -26
  43. data/ext/options_store.c +188 -0
  44. data/ext/page.c +168 -0
  45. data/ext/pages.c +135 -0
  46. data/ext/point2d.c +195 -0
  47. data/ext/point3d.c +340 -0
  48. data/ext/polygon_mesh.c +253 -0
  49. data/ext/scriptup.h +279 -0
  50. data/ext/section_plane.c +44 -0
  51. data/ext/sketchup.c +102 -76
  52. data/ext/styles.c +91 -0
  53. data/ext/text.c +135 -0
  54. data/ext/texture.c +74 -83
  55. data/ext/texture_writer.c +104 -0
  56. data/ext/transformation.c +309 -0
  57. data/ext/transformation2d.c +190 -0
  58. data/ext/uv_helper.c +41 -0
  59. data/ext/vector2d.c +238 -0
  60. data/ext/vector3d.c +294 -0
  61. data/ext/vertex.c +67 -0
  62. data/lib/sketchup.rb +2 -2
  63. data/sig/_top_level.rbs +188 -0
  64. data/sig/array.rbs +52 -0
  65. data/sig/geom/bounding_box.rbs +28 -0
  66. data/sig/geom/bounds2d.rbs +20 -0
  67. data/sig/geom/lat_long.rbs +13 -0
  68. data/sig/geom/oriented_bounds2d.rbs +10 -0
  69. data/sig/geom/point2d.rbs +32 -0
  70. data/sig/geom/point3d.rbs +46 -0
  71. data/sig/geom/polygon_mesh.rbs +35 -0
  72. data/sig/geom/transformation.rbs +44 -0
  73. data/sig/geom/transformation2d.rbs +26 -0
  74. data/sig/geom/utm.rbs +14 -0
  75. data/sig/geom/vector2d.rbs +40 -0
  76. data/sig/geom/vector3d.rbs +49 -0
  77. data/sig/geom.rbs +25 -0
  78. data/sig/language_handler.rbs +8 -0
  79. data/sig/layout/angular_dimension.rbs +32 -0
  80. data/sig/layout/auto_text_definition.rbs +73 -0
  81. data/sig/layout/auto_text_definitions.rbs +15 -0
  82. data/sig/layout/connection_point.rbs +6 -0
  83. data/sig/layout/dictionary.rbs +18 -0
  84. data/sig/layout/document.rbs +61 -0
  85. data/sig/layout/ellipse.rbs +5 -0
  86. data/sig/layout/entities.rbs +10 -0
  87. data/sig/layout/entity.rbs +28 -0
  88. data/sig/layout/formatted_text.rbs +30 -0
  89. data/sig/layout/grid.rbs +24 -0
  90. data/sig/layout/group.rbs +17 -0
  91. data/sig/layout/image.rbs +7 -0
  92. data/sig/layout/label.rbs +31 -0
  93. data/sig/layout/layer.rbs +21 -0
  94. data/sig/layout/layer_instance.rbs +9 -0
  95. data/sig/layout/layers.rbs +18 -0
  96. data/sig/layout/linear_dimension.rbs +39 -0
  97. data/sig/layout/locked_entity_error.rbs +4 -0
  98. data/sig/layout/locked_layer_error.rbs +4 -0
  99. data/sig/layout/page.rbs +20 -0
  100. data/sig/layout/page_info.rbs +37 -0
  101. data/sig/layout/pages.rbs +17 -0
  102. data/sig/layout/path.rbs +34 -0
  103. data/sig/layout/rectangle.rbs +15 -0
  104. data/sig/layout/reference_entity.rbs +7 -0
  105. data/sig/layout/sketch_up_model.rbs +54 -0
  106. data/sig/layout/style.rbs +150 -0
  107. data/sig/layout/table.rbs +17 -0
  108. data/sig/layout/table_cell.rbs +13 -0
  109. data/sig/layout/table_column.rbs +10 -0
  110. data/sig/layout/table_row.rbs +10 -0
  111. data/sig/layout.rbs +4 -0
  112. data/sig/length.rbs +37 -0
  113. data/sig/numeric.rbs +23 -0
  114. data/sig/sketchup/animation.rbs +8 -0
  115. data/sig/sketchup/app_observer.rbs +11 -0
  116. data/sig/sketchup/arc_curve.rbs +14 -0
  117. data/sig/sketchup/attribute_dictionaries.rbs +11 -0
  118. data/sig/sketchup/attribute_dictionary.rbs +18 -0
  119. data/sig/sketchup/axes.rbs +13 -0
  120. data/sig/sketchup/behavior.rbs +19 -0
  121. data/sig/sketchup/camera.rbs +33 -0
  122. data/sig/sketchup/classification_schema.rbs +8 -0
  123. data/sig/sketchup/classifications.rbs +12 -0
  124. data/sig/sketchup/color.rbs +22 -0
  125. data/sig/sketchup/component_definition.rbs +43 -0
  126. data/sig/sketchup/component_instance.rbs +32 -0
  127. data/sig/sketchup/console.rbs +8 -0
  128. data/sig/sketchup/construction_line.rbs +17 -0
  129. data/sig/sketchup/construction_point.rbs +5 -0
  130. data/sig/sketchup/curve.rbs +13 -0
  131. data/sig/sketchup/definition_list.rbs +26 -0
  132. data/sig/sketchup/definition_observer.rbs +6 -0
  133. data/sig/sketchup/definitions_observer.rbs +8 -0
  134. data/sig/sketchup/dimension.rbs +18 -0
  135. data/sig/sketchup/dimension_linear.rbs +24 -0
  136. data/sig/sketchup/dimension_observer.rbs +5 -0
  137. data/sig/sketchup/dimension_radial.rbs +9 -0
  138. data/sig/sketchup/drawingelement.rbs +18 -0
  139. data/sig/sketchup/edge.rbs +24 -0
  140. data/sig/sketchup/edge_use.rbs +13 -0
  141. data/sig/sketchup/entities.rbs +61 -0
  142. data/sig/sketchup/entities_builder.rbs +15 -0
  143. data/sig/sketchup/entities_observer.rbs +9 -0
  144. data/sig/sketchup/entity.rbs +21 -0
  145. data/sig/sketchup/entity_observer.rbs +6 -0
  146. data/sig/sketchup/environment.rbs +25 -0
  147. data/sig/sketchup/environments.rbs +18 -0
  148. data/sig/sketchup/environments_observer.rbs +8 -0
  149. data/sig/sketchup/extensions_manager.rbs +11 -0
  150. data/sig/sketchup/face.rbs +44 -0
  151. data/sig/sketchup/frame_change_observer.rbs +5 -0
  152. data/sig/sketchup/group.rbs +38 -0
  153. data/sig/sketchup/http/request.rbs +17 -0
  154. data/sig/sketchup/http/response.rbs +7 -0
  155. data/sig/sketchup/http.rbs +27 -0
  156. data/sig/sketchup/image.rbs +23 -0
  157. data/sig/sketchup/image_rep.rbs +17 -0
  158. data/sig/sketchup/importer.rbs +14 -0
  159. data/sig/sketchup/input_point.rbs +25 -0
  160. data/sig/sketchup/instance_observer.rbs +6 -0
  161. data/sig/sketchup/instance_path.rbs +20 -0
  162. data/sig/sketchup/layer.rbs +20 -0
  163. data/sig/sketchup/layer_folder.rbs +26 -0
  164. data/sig/sketchup/layers.rbs +30 -0
  165. data/sig/sketchup/layers_observer.rbs +13 -0
  166. data/sig/sketchup/licensing/extension_license.rbs +8 -0
  167. data/sig/sketchup/licensing.rbs +15 -0
  168. data/sig/sketchup/line_style.rbs +5 -0
  169. data/sig/sketchup/line_styles.rbs +13 -0
  170. data/sig/sketchup/load_handler.rbs +8 -0
  171. data/sig/sketchup/loop.rbs +10 -0
  172. data/sig/sketchup/material.rbs +74 -0
  173. data/sig/sketchup/materials.rbs +22 -0
  174. data/sig/sketchup/materials_observer.rbs +10 -0
  175. data/sig/sketchup/menu.rbs +9 -0
  176. data/sig/sketchup/model.rbs +105 -0
  177. data/sig/sketchup/model_observer.rbs +23 -0
  178. data/sig/sketchup/options_manager.rbs +12 -0
  179. data/sig/sketchup/options_provider.rbs +23 -0
  180. data/sig/sketchup/options_provider_observer.rbs +5 -0
  181. data/sig/sketchup/overlay.rbs +21 -0
  182. data/sig/sketchup/overlays_manager.rbs +10 -0
  183. data/sig/sketchup/page.rbs +55 -0
  184. data/sig/sketchup/pages.rbs +25 -0
  185. data/sig/sketchup/pages_observer.rbs +7 -0
  186. data/sig/sketchup/pick_helper.rbs +28 -0
  187. data/sig/sketchup/regional_settings.rbs +7 -0
  188. data/sig/sketchup/rendering_options.rbs +89 -0
  189. data/sig/sketchup/rendering_options_observer.rbs +5 -0
  190. data/sig/sketchup/section_plane.rbs +12 -0
  191. data/sig/sketchup/selection.rbs +31 -0
  192. data/sig/sketchup/selection_observer.rbs +8 -0
  193. data/sig/sketchup/set.rbs +15 -0
  194. data/sig/sketchup/shadow_info.rbs +18 -0
  195. data/sig/sketchup/shadow_info_observer.rbs +5 -0
  196. data/sig/sketchup/skp.rbs +5 -0
  197. data/sig/sketchup/snap.rbs +10 -0
  198. data/sig/sketchup/style.rbs +9 -0
  199. data/sig/sketchup/styles.rbs +21 -0
  200. data/sig/sketchup/text.rbs +22 -0
  201. data/sig/sketchup/texture.rbs +14 -0
  202. data/sig/sketchup/texture_writer.rbs +14 -0
  203. data/sig/sketchup/tool.rbs +45 -0
  204. data/sig/sketchup/tools.rbs +14 -0
  205. data/sig/sketchup/tools_observer.rbs +6 -0
  206. data/sig/sketchup/uv_helper.rbs +6 -0
  207. data/sig/sketchup/vertex.rbs +11 -0
  208. data/sig/sketchup/view.rbs +87 -0
  209. data/sig/sketchup/view_observer.rbs +6 -0
  210. data/sig/sketchup.rbs +137 -0
  211. data/sig/sketchup_extension.rbs +23 -0
  212. data/sig/string.rbs +5 -0
  213. data/sig/ui/command.rbs +20 -0
  214. data/sig/ui/html_dialog.rbs +29 -0
  215. data/sig/ui/notification.rbs +16 -0
  216. data/sig/ui/toolbar.rbs +18 -0
  217. data/sig/ui/web_dialog.rbs +38 -0
  218. data/sig/ui.rbs +66 -0
  219. metadata +204 -275
  220. data/ext/attribute_dictionaries.h +0 -8
  221. data/ext/attribute_dictionary.h +0 -8
  222. data/ext/behavior.h +0 -8
  223. data/ext/color.h +0 -8
  224. data/ext/component_definition.h +0 -8
  225. data/ext/component_instance.h +0 -8
  226. data/ext/definition_list.h +0 -8
  227. data/ext/drawing_element.h +0 -8
  228. data/ext/entities.h +0 -8
  229. data/ext/entity.h +0 -8
  230. data/ext/material.h +0 -8
  231. data/ext/materials.h +0 -8
  232. data/ext/model.h +0 -8
  233. data/ext/not_implemented.c +0 -88
  234. data/ext/not_implemented.h +0 -20
  235. data/ext/sketchup.h +0 -9
  236. data/ext/texture.h +0 -8
  237. data/ext/typed_value.c +0 -84
  238. data/ext/typed_value.h +0 -11
  239. data/ext/utils.h +0 -111
  240. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/application.h +0 -36
  241. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/model.h +0 -59
  242. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/overlay.h +0 -248
  243. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/ruby_api.h +0 -118
  244. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/color.h +0 -107
  245. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/common.h +0 -178
  246. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/defs.h +0 -19
  247. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/extension_license.h +0 -62
  248. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/bounding_box.h +0 -34
  249. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/plane3d.h +0 -153
  250. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/point2d.h +0 -96
  251. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/point3d.h +0 -98
  252. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/ray3d.h +0 -64
  253. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/transformation.h +0 -321
  254. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/transformation2d.h +0 -163
  255. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/vector2d.h +0 -235
  256. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/vector3d.h +0 -285
  257. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry.h +0 -152
  258. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/modelexporterplugin.h +0 -165
  259. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/modelimporterplugin.h +0 -183
  260. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/pluginprogresscallback.h +0 -84
  261. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/initialize.h +0 -43
  262. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/length_formatter.h +0 -424
  263. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/arccurve.h +0 -244
  264. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/arrow_type.h +0 -17
  265. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/attribute_dictionary.h +0 -161
  266. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/axes.h +0 -242
  267. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/camera.h +0 -398
  268. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classification_attribute.h +0 -89
  269. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classification_info.h +0 -125
  270. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classifications.h +0 -86
  271. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_definition.h +0 -588
  272. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_instance.h +0 -344
  273. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/curve.h +0 -143
  274. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/defs.h +0 -142
  275. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension.h +0 -222
  276. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_linear.h +0 -421
  277. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_radial.h +0 -194
  278. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_style.h +0 -253
  279. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/drawing_element.h +0 -198
  280. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dynamic_component_attribute.h +0 -92
  281. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dynamic_component_info.h +0 -70
  282. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/edge.h +0 -271
  283. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/edge_use.h +0 -214
  284. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entities.h +0 -834
  285. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity.h +0 -186
  286. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity_list.h +0 -80
  287. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity_list_iterator.h +0 -90
  288. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/face.h +0 -686
  289. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/font.h +0 -138
  290. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/geometry.h +0 -20
  291. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/geometry_input.h +0 -685
  292. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/group.h +0 -244
  293. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/guide_line.h +0 -155
  294. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/guide_point.h +0 -153
  295. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/image.h +0 -288
  296. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/image_rep.h +0 -275
  297. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/instancepath.h +0 -266
  298. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/layer.h +0 -265
  299. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/layer_folder.h +0 -301
  300. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/line_style.h +0 -211
  301. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/line_styles.h +0 -81
  302. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/location.h +0 -65
  303. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/loop.h +0 -182
  304. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/material.h +0 -390
  305. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/mesh_helper.h +0 -187
  306. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model.h +0 -1663
  307. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model_version.h +0 -49
  308. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/opening.h +0 -72
  309. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/options_manager.h +0 -79
  310. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/options_provider.h +0 -166
  311. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/polyline3d.h +0 -140
  312. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/rendering_options.h +0 -179
  313. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/scene.h +0 -836
  314. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/schema.h +0 -56
  315. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/schema_type.h +0 -26
  316. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/section_plane.h +0 -212
  317. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/selection.h +0 -156
  318. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/shadow_info.h +0 -147
  319. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/skp.h +0 -45
  320. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/style.h +0 -303
  321. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/styles.h +0 -190
  322. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/text.h +0 -384
  323. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/texture.h +0 -358
  324. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/texture_writer.h +0 -280
  325. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/typed_value.h +0 -390
  326. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/uv_helper.h +0 -79
  327. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/vertex.h +0 -154
  328. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/sketchup.h +0 -122
  329. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/sketchup_info.h +0 -65
  330. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/slapi.h +0 -16
  331. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/transformation.h +0 -16
  332. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/unicodestring.h +0 -239
  333. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/utils/math_helpers.h +0 -124
  334. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonGeometry.dylib +0 -0
  335. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonGeoutils.dylib +0 -0
  336. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonImage.dylib +0 -4
  337. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonPreferences.dylib +0 -0
  338. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonUnits.dylib +0 -0
  339. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonUtils.dylib +0 -0
  340. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Libraries/libCommonZip.dylib +0 -0
  341. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Resources/Info.plist +0 -50
  342. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/SketchUpAPI +0 -0
  343. data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/_CodeSignature/CodeResources +0 -835
  344. data/sketchup-sdk-win/binaries/layout/x64/LayOutAPI.dll +0 -0
  345. data/sketchup-sdk-win/binaries/layout/x64/LayOutAPI.lib +0 -0
  346. data/sketchup-sdk-win/binaries/layout/x64/LayOutControllers.dll +0 -0
  347. data/sketchup-sdk-win/binaries/layout/x64/LayOutModel.dll +0 -0
  348. data/sketchup-sdk-win/binaries/layout/x64/LayOutRTF.dll +0 -0
  349. data/sketchup-sdk-win/binaries/layout/x64/LayOutUtils.dll +0 -0
  350. data/sketchup-sdk-win/binaries/layout/x64/SketchUpCommonPreferences.dll +0 -0
  351. data/sketchup-sdk-win/binaries/layout/x64/SketchUpViewerAPI.dll +0 -0
  352. data/sketchup-sdk-win/binaries/layout/x64/SketchUpViewerAPI.lib +0 -0
  353. data/sketchup-sdk-win/binaries/layout/x64/pdflib.dll +0 -0
  354. data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpAPI.dll +0 -0
  355. data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpAPI.lib +0 -0
  356. data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpCommonPreferences.dll +0 -0
  357. data/sketchup-sdk-win/binaries/sketchup/x64/sketchup.lib +0 -0
  358. data/sketchup-sdk-win/headers/LayOutAPI/application/application.h +0 -117
  359. data/sketchup-sdk-win/headers/LayOutAPI/common.h +0 -22
  360. data/sketchup-sdk-win/headers/LayOutAPI/geometry/geometry.h +0 -78
  361. data/sketchup-sdk-win/headers/LayOutAPI/initialize.h +0 -36
  362. data/sketchup-sdk-win/headers/LayOutAPI/layout.h +0 -49
  363. data/sketchup-sdk-win/headers/LayOutAPI/model/angulardimension.h +0 -468
  364. data/sketchup-sdk-win/headers/LayOutAPI/model/autotextdefinition.h +0 -569
  365. data/sketchup-sdk-win/headers/LayOutAPI/model/autotextdefinitionlist.h +0 -79
  366. data/sketchup-sdk-win/headers/LayOutAPI/model/connectionpoint.h +0 -107
  367. data/sketchup-sdk-win/headers/LayOutAPI/model/defs.h +0 -42
  368. data/sketchup-sdk-win/headers/LayOutAPI/model/dictionary.h +0 -120
  369. data/sketchup-sdk-win/headers/LayOutAPI/model/document.h +0 -864
  370. data/sketchup-sdk-win/headers/LayOutAPI/model/documentexportoptions.h +0 -59
  371. data/sketchup-sdk-win/headers/LayOutAPI/model/ellipse.h +0 -78
  372. data/sketchup-sdk-win/headers/LayOutAPI/model/entity.h +0 -330
  373. data/sketchup-sdk-win/headers/LayOutAPI/model/entityiterator.h +0 -49
  374. data/sketchup-sdk-win/headers/LayOutAPI/model/entitylist.h +0 -114
  375. data/sketchup-sdk-win/headers/LayOutAPI/model/formattedtext.h +0 -397
  376. data/sketchup-sdk-win/headers/LayOutAPI/model/grid.h +0 -251
  377. data/sketchup-sdk-win/headers/LayOutAPI/model/group.h +0 -243
  378. data/sketchup-sdk-win/headers/LayOutAPI/model/image.h +0 -146
  379. data/sketchup-sdk-win/headers/LayOutAPI/model/imagerep.h +0 -109
  380. data/sketchup-sdk-win/headers/LayOutAPI/model/label.h +0 -332
  381. data/sketchup-sdk-win/headers/LayOutAPI/model/layer.h +0 -207
  382. data/sketchup-sdk-win/headers/LayOutAPI/model/layerinstance.h +0 -117
  383. data/sketchup-sdk-win/headers/LayOutAPI/model/layerlist.h +0 -69
  384. data/sketchup-sdk-win/headers/LayOutAPI/model/lineardimension.h +0 -456
  385. data/sketchup-sdk-win/headers/LayOutAPI/model/page.h +0 -261
  386. data/sketchup-sdk-win/headers/LayOutAPI/model/pageinfo.h +0 -372
  387. data/sketchup-sdk-win/headers/LayOutAPI/model/pagelist.h +0 -81
  388. data/sketchup-sdk-win/headers/LayOutAPI/model/path.h +0 -464
  389. data/sketchup-sdk-win/headers/LayOutAPI/model/rectangle.h +0 -240
  390. data/sketchup-sdk-win/headers/LayOutAPI/model/referenceentity.h +0 -120
  391. data/sketchup-sdk-win/headers/LayOutAPI/model/sketchupmodel.h +0 -624
  392. data/sketchup-sdk-win/headers/LayOutAPI/model/skpfilereference.h +0 -94
  393. data/sketchup-sdk-win/headers/LayOutAPI/model/style.h +0 -1080
  394. data/sketchup-sdk-win/headers/LayOutAPI/model/table.h +0 -470
  395. data/sketchup-sdk-win/headers/LayOutAPI/model/typed_value.h +0 -156
  396. data/sketchup-sdk-win/headers/SketchUpAPI/application/application.h +0 -36
  397. data/sketchup-sdk-win/headers/SketchUpAPI/application/model.h +0 -59
  398. data/sketchup-sdk-win/headers/SketchUpAPI/application/overlay.h +0 -248
  399. data/sketchup-sdk-win/headers/SketchUpAPI/application/ruby_api.h +0 -118
  400. data/sketchup-sdk-win/headers/SketchUpAPI/color.h +0 -107
  401. data/sketchup-sdk-win/headers/SketchUpAPI/common.h +0 -178
  402. data/sketchup-sdk-win/headers/SketchUpAPI/defs.h +0 -19
  403. data/sketchup-sdk-win/headers/SketchUpAPI/extension_license.h +0 -62
  404. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/bounding_box.h +0 -34
  405. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/plane3d.h +0 -153
  406. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/point2d.h +0 -96
  407. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/point3d.h +0 -98
  408. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/ray3d.h +0 -64
  409. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/transformation.h +0 -321
  410. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/transformation2d.h +0 -163
  411. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/vector2d.h +0 -235
  412. data/sketchup-sdk-win/headers/SketchUpAPI/geometry/vector3d.h +0 -285
  413. data/sketchup-sdk-win/headers/SketchUpAPI/geometry.h +0 -152
  414. data/sketchup-sdk-win/headers/SketchUpAPI/import_export/modelexporterplugin.h +0 -165
  415. data/sketchup-sdk-win/headers/SketchUpAPI/import_export/modelimporterplugin.h +0 -183
  416. data/sketchup-sdk-win/headers/SketchUpAPI/import_export/pluginprogresscallback.h +0 -84
  417. data/sketchup-sdk-win/headers/SketchUpAPI/initialize.h +0 -43
  418. data/sketchup-sdk-win/headers/SketchUpAPI/length_formatter.h +0 -424
  419. data/sketchup-sdk-win/headers/SketchUpAPI/model/arccurve.h +0 -244
  420. data/sketchup-sdk-win/headers/SketchUpAPI/model/arrow_type.h +0 -17
  421. data/sketchup-sdk-win/headers/SketchUpAPI/model/attribute_dictionary.h +0 -161
  422. data/sketchup-sdk-win/headers/SketchUpAPI/model/axes.h +0 -242
  423. data/sketchup-sdk-win/headers/SketchUpAPI/model/camera.h +0 -398
  424. data/sketchup-sdk-win/headers/SketchUpAPI/model/classification_attribute.h +0 -89
  425. data/sketchup-sdk-win/headers/SketchUpAPI/model/classification_info.h +0 -125
  426. data/sketchup-sdk-win/headers/SketchUpAPI/model/classifications.h +0 -86
  427. data/sketchup-sdk-win/headers/SketchUpAPI/model/component_definition.h +0 -588
  428. data/sketchup-sdk-win/headers/SketchUpAPI/model/component_instance.h +0 -344
  429. data/sketchup-sdk-win/headers/SketchUpAPI/model/curve.h +0 -143
  430. data/sketchup-sdk-win/headers/SketchUpAPI/model/defs.h +0 -142
  431. data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension.h +0 -222
  432. data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_linear.h +0 -421
  433. data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_radial.h +0 -194
  434. data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_style.h +0 -253
  435. data/sketchup-sdk-win/headers/SketchUpAPI/model/drawing_element.h +0 -198
  436. data/sketchup-sdk-win/headers/SketchUpAPI/model/dynamic_component_attribute.h +0 -92
  437. data/sketchup-sdk-win/headers/SketchUpAPI/model/dynamic_component_info.h +0 -70
  438. data/sketchup-sdk-win/headers/SketchUpAPI/model/edge.h +0 -271
  439. data/sketchup-sdk-win/headers/SketchUpAPI/model/edge_use.h +0 -214
  440. data/sketchup-sdk-win/headers/SketchUpAPI/model/entities.h +0 -834
  441. data/sketchup-sdk-win/headers/SketchUpAPI/model/entity.h +0 -186
  442. data/sketchup-sdk-win/headers/SketchUpAPI/model/entity_list.h +0 -80
  443. data/sketchup-sdk-win/headers/SketchUpAPI/model/entity_list_iterator.h +0 -90
  444. data/sketchup-sdk-win/headers/SketchUpAPI/model/face.h +0 -686
  445. data/sketchup-sdk-win/headers/SketchUpAPI/model/font.h +0 -138
  446. data/sketchup-sdk-win/headers/SketchUpAPI/model/geometry.h +0 -20
  447. data/sketchup-sdk-win/headers/SketchUpAPI/model/geometry_input.h +0 -685
  448. data/sketchup-sdk-win/headers/SketchUpAPI/model/group.h +0 -244
  449. data/sketchup-sdk-win/headers/SketchUpAPI/model/guide_line.h +0 -155
  450. data/sketchup-sdk-win/headers/SketchUpAPI/model/guide_point.h +0 -153
  451. data/sketchup-sdk-win/headers/SketchUpAPI/model/image.h +0 -288
  452. data/sketchup-sdk-win/headers/SketchUpAPI/model/image_rep.h +0 -275
  453. data/sketchup-sdk-win/headers/SketchUpAPI/model/instancepath.h +0 -266
  454. data/sketchup-sdk-win/headers/SketchUpAPI/model/layer.h +0 -265
  455. data/sketchup-sdk-win/headers/SketchUpAPI/model/layer_folder.h +0 -301
  456. data/sketchup-sdk-win/headers/SketchUpAPI/model/line_style.h +0 -211
  457. data/sketchup-sdk-win/headers/SketchUpAPI/model/line_styles.h +0 -81
  458. data/sketchup-sdk-win/headers/SketchUpAPI/model/location.h +0 -65
  459. data/sketchup-sdk-win/headers/SketchUpAPI/model/loop.h +0 -182
  460. data/sketchup-sdk-win/headers/SketchUpAPI/model/material.h +0 -390
  461. data/sketchup-sdk-win/headers/SketchUpAPI/model/mesh_helper.h +0 -187
  462. data/sketchup-sdk-win/headers/SketchUpAPI/model/model.h +0 -1663
  463. data/sketchup-sdk-win/headers/SketchUpAPI/model/model_version.h +0 -49
  464. data/sketchup-sdk-win/headers/SketchUpAPI/model/opening.h +0 -72
  465. data/sketchup-sdk-win/headers/SketchUpAPI/model/options_manager.h +0 -79
  466. data/sketchup-sdk-win/headers/SketchUpAPI/model/options_provider.h +0 -166
  467. data/sketchup-sdk-win/headers/SketchUpAPI/model/polyline3d.h +0 -140
  468. data/sketchup-sdk-win/headers/SketchUpAPI/model/rendering_options.h +0 -179
  469. data/sketchup-sdk-win/headers/SketchUpAPI/model/scene.h +0 -836
  470. data/sketchup-sdk-win/headers/SketchUpAPI/model/schema.h +0 -56
  471. data/sketchup-sdk-win/headers/SketchUpAPI/model/schema_type.h +0 -26
  472. data/sketchup-sdk-win/headers/SketchUpAPI/model/section_plane.h +0 -212
  473. data/sketchup-sdk-win/headers/SketchUpAPI/model/selection.h +0 -156
  474. data/sketchup-sdk-win/headers/SketchUpAPI/model/shadow_info.h +0 -147
  475. data/sketchup-sdk-win/headers/SketchUpAPI/model/skp.h +0 -45
  476. data/sketchup-sdk-win/headers/SketchUpAPI/model/style.h +0 -303
  477. data/sketchup-sdk-win/headers/SketchUpAPI/model/styles.h +0 -190
  478. data/sketchup-sdk-win/headers/SketchUpAPI/model/text.h +0 -384
  479. data/sketchup-sdk-win/headers/SketchUpAPI/model/texture.h +0 -358
  480. data/sketchup-sdk-win/headers/SketchUpAPI/model/texture_writer.h +0 -280
  481. data/sketchup-sdk-win/headers/SketchUpAPI/model/typed_value.h +0 -390
  482. data/sketchup-sdk-win/headers/SketchUpAPI/model/uv_helper.h +0 -79
  483. data/sketchup-sdk-win/headers/SketchUpAPI/model/vertex.h +0 -154
  484. data/sketchup-sdk-win/headers/SketchUpAPI/sketchup.h +0 -122
  485. data/sketchup-sdk-win/headers/SketchUpAPI/sketchup_info.h +0 -65
  486. data/sketchup-sdk-win/headers/SketchUpAPI/slapi.h +0 -16
  487. data/sketchup-sdk-win/headers/SketchUpAPI/transformation.h +0 -16
  488. data/sketchup-sdk-win/headers/SketchUpAPI/unicodestring.h +0 -239
  489. data/sketchup-sdk-win/headers/SketchUpAPI/utils/math_helpers.h +0 -124
data/ext/model.c CHANGED
@@ -1,43 +1,249 @@
1
- #include <stdbool.h>
2
- #include <model.h>
3
- #include <utils.h>
4
- #include <SketchUpAPI/sketchup.h>
5
- #include <sketchup.h>
1
+ #include <scriptup.h>
6
2
 
7
- static VALUE Sketchup_Model_close(VALUE self)
3
+ static VALUE model_close(int argc, VALUE* argv, VALUE self)
8
4
  {
5
+ rb_check_arity(argc, 0, 1);
9
6
  SUModelRef model = Sketchup_get_active_model();
10
7
  enum SUResult result = SUModelRelease(&model);
11
8
  Sketchup_set_active_model(model);
12
- if(result != SU_ERROR_NONE)
13
- return false;
14
- return Qnil;
9
+ return result == SU_ERROR_NONE ? Qnil : Qfalse;
15
10
  }
16
11
 
17
- static VALUE Sketchup_Model_materials(VALUE self)
12
+ static VALUE model_entities(VALUE self)
18
13
  {
19
- return Data_Wrap_Struct(rb_path2class(SKETCHUP_MATERIALS), 0, 0, DATA_PTR(self));
14
+ SUEntitiesRef entities = SU_INVALID;
15
+ SUModelGetEntities(SU_REF(SUModelRef, self), &entities);
16
+ return su_entities_new(entities);
20
17
  }
21
18
 
22
- static VALUE Sketchup_Model_definitions(VALUE self)
19
+ static VALUE model_layers(VALUE self)
23
20
  {
24
- return Data_Wrap_Struct(rb_path2class(SKETCHUP_DEFINITIONLIST), 0, 0, DATA_PTR(self));
21
+ return su_wrap(cLayers, DATA_PTR(self));
25
22
  }
26
23
 
27
- static VALUE Sketchup_Model_attribute_dictionaries(VALUE self)
24
+ static VALUE model_line_styles(VALUE self)
28
25
  {
29
- return Data_Wrap_Struct(rb_path2class(SKETCHUP_ATTRIBUTEDICTIONARIES), 0, 0, DATA_PTR(self));
26
+ SULineStylesRef styles = SU_INVALID;
27
+ SUModelGetLineStyles(SU_REF(SUModelRef, self), &styles);
28
+ return su_wrap_or_nil(cLineStyles, styles.ptr);
30
29
  }
31
30
 
32
- VALUE Model_Init(VALUE Sketchup, VALUE rb_cObject)
31
+ static VALUE model_materials(VALUE self)
33
32
  {
34
- VALUE Sketchup_Model = rb_define_class_under(Sketchup, MODEL, rb_cObject);
35
- rb_undef_alloc_func(Sketchup_Model);
36
- rb_define_const(Sketchup_Model, "LOAD_STATUS_SUCCESS", INT2FIX(0));
37
- rb_define_const(Sketchup_Model, "LOAD_STATUS_SUCCESS_MORE_RECENT", INT2FIX(1));
38
- rb_define_method(Sketchup_Model, "close", Sketchup_Model_close, 0);
39
- rb_define_method(Sketchup_Model, "materials", Sketchup_Model_materials, 0);
40
- rb_define_method(Sketchup_Model, "definitions", Sketchup_Model_definitions, 0);
41
- rb_define_method(Sketchup_Model, "attribute_dictionaries", Sketchup_Model_attribute_dictionaries, 0);
42
- return Sketchup_Model;
43
- }
33
+ return su_wrap(cMaterials, DATA_PTR(self));
34
+ }
35
+
36
+ static VALUE model_definitions(VALUE self)
37
+ {
38
+ return su_wrap(cDefinitionList, DATA_PTR(self));
39
+ }
40
+
41
+ static VALUE model_attribute_dictionaries(VALUE self)
42
+ {
43
+ return su_model_attribute_dictionaries(SU_REF(SUModelRef, self));
44
+ }
45
+
46
+ static VALUE model_eq(VALUE self, VALUE other)
47
+ {
48
+ return BOOL2RB(rb_obj_is_kind_of(other, cModel) && DATA_PTR(self) == DATA_PTR(other));
49
+ }
50
+
51
+ static VALUE model_hash(VALUE self)
52
+ {
53
+ return rb_funcall(ULL2NUM((unsigned long long)(uintptr_t)DATA_PTR(self)), (rb_intern)("hash"), 0);
54
+ }
55
+
56
+ static VALUE model_active_entities(VALUE self)
57
+ {
58
+ SUEntitiesRef entities = SU_INVALID;
59
+ SUModelGetActiveEntities(SU_REF(SUModelRef, self), &entities);
60
+ return su_entities_new(entities);
61
+ }
62
+
63
+ DEFINE_REF_GETTER(model_active_layer, SUModelRef, SUModelGetActiveLayer, SULayerRef, cLayer)
64
+ DEFINE_REF_LIST(model_section_list, SUModelRef, SUModelGetNumActiveSectionPlanes, SUModelGetActiveSectionPlanes, SUSectionPlaneRef, cSectionPlane)
65
+ DEFINE_STRING_GETTER(model_name, SUModelRef, SUModelGetName)
66
+ DEFINE_STRING_SETTER(model_set_name, SUModelRef, SUModelSetName)
67
+ DEFINE_STRING_GETTER(model_title, SUModelRef, SUModelGetTitle)
68
+ DEFINE_STRING_GETTER(model_path, SUModelRef, SUModelGetPath)
69
+ DEFINE_STRING_GETTER(model_guid, SUModelRef, SUModelGetGuid)
70
+ DEFINE_STRING_GETTER(model_description, SUModelRef, SUModelGetDescription)
71
+ DEFINE_STRING_SETTER(model_set_description, SUModelRef, SUModelSetDescription)
72
+ DEFINE_BOOL_GETTER(model_georeferenced_p, SUModelRef, SUModelIsGeoReferenced)
73
+
74
+ static VALUE model_set_active_layer(VALUE self, VALUE layer)
75
+ {
76
+ VALUE target = RB_TYPE_P(layer, T_STRING) ? rb_funcall(rb_funcall(self, (rb_intern)("layers"), 0), (rb_intern)("[]"), 1, layer) : layer;
77
+ if (NIL_P(target))
78
+ rb_raise(rb_eArgError, "layer not found: %"PRIsVALUE, layer);
79
+ SUModelSetActiveLayer(SU_REF(SUModelRef, self), (SULayerRef){su_unwrap(target, cLayer)});
80
+ return layer;
81
+ }
82
+
83
+ static VALUE model_active_section_planes(VALUE self)
84
+ {
85
+ return model_section_list(SU_REF(SUModelRef, self));
86
+ }
87
+
88
+ static VALUE model_valid_p(VALUE self)
89
+ {
90
+ return BOOL2RB(DATA_PTR(self) != NULL && DATA_PTR(self) == Sketchup_get_active_model().ptr);
91
+ }
92
+
93
+ static VALUE model_bounds(VALUE self)
94
+ {
95
+ SUEntitiesRef entities = SU_INVALID;
96
+ SUModelGetEntities(SU_REF(SUModelRef, self), &entities);
97
+ struct SUBoundingBox3D bbox;
98
+ SUEntitiesGetBoundingBox(entities, &bbox);
99
+ return su_bounding_box_new(bbox);
100
+ }
101
+
102
+ static VALUE model_number_faces(VALUE self)
103
+ {
104
+ struct SUModelStatistics statistics;
105
+ memset(&statistics, 0, sizeof(statistics));
106
+ SUModelGetStatistics(SU_REF(SUModelRef, self), &statistics);
107
+ return INT2NUM(statistics.entity_counts[SUEntityType_Face]);
108
+ }
109
+
110
+ static VALUE model_attribute_dictionary(int argc, VALUE* argv, VALUE self)
111
+ {
112
+ VALUE name, create;
113
+ rb_scan_args(argc, argv, "11", &name, &create);
114
+ VALUE found = su_find_by(rb_funcall(rb_funcall(self, (rb_intern)("attribute_dictionaries"), 0), (rb_intern)("to_a"), 0),
115
+ "name", StringValue(name));
116
+ if (!NIL_P(found) || !RTEST(create))
117
+ return found;
118
+ SUAttributeDictionaryRef dictionary = SU_INVALID;
119
+ SUModelGetAttributeDictionary(SU_REF(SUModelRef, self), StringValueCStr(name), &dictionary);
120
+ return su_wrap_or_nil(cAttributeDictionary, dictionary.ptr);
121
+ }
122
+
123
+ static VALUE model_get_attribute(int argc, VALUE* argv, VALUE self)
124
+ {
125
+ VALUE name, key, default_value;
126
+ rb_scan_args(argc, argv, "21", &name, &key, &default_value);
127
+ VALUE dictionary = model_attribute_dictionary(1, &name, self);
128
+ VALUE value = NIL_P(dictionary) ? Qnil : rb_funcall(dictionary, (rb_intern)("[]"), 1, key);
129
+ return NIL_P(value) ? default_value : value;
130
+ }
131
+
132
+ static VALUE model_set_attribute(VALUE self, VALUE name, VALUE key, VALUE value)
133
+ {
134
+ VALUE args[2] = {name, Qtrue};
135
+ rb_funcall(model_attribute_dictionary(2, args, self), (rb_intern)("[]="), 2, key, value);
136
+ return value;
137
+ }
138
+
139
+ // One id returns an entity (or nil); several return an array.
140
+ static VALUE model_find_entity_by_persistent_id(int argc, VALUE* argv, VALUE self)
141
+ {
142
+ VALUE ids = argc == 1 && RB_TYPE_P(argv[0], T_ARRAY) ? argv[0] : rb_ary_new_from_values(argc, argv);
143
+ long count = RARRAY_LEN(ids);
144
+ if (count == 0)
145
+ rb_raise(rb_eArgError, "at least one persistent id is required");
146
+ int64_t* pids = ZALLOC_N(int64_t, count);
147
+ SUEntityRef* entities = ZALLOC_N(SUEntityRef, count);
148
+ for (long i = 0; i < count; i++)
149
+ {
150
+ pids[i] = NUM2LL(RARRAY_AREF(ids, i));
151
+ entities[i].ptr = NULL;
152
+ }
153
+ SUModelGetEntitiesOfTypeByPersistentIDs(SU_REF(SUModelRef, self), FLAG_GET_ENTITIES_TYPE_ALL, (size_t)count, pids, entities);
154
+ VALUE result = rb_ary_new_capa(count);
155
+ for (long i = 0; i < count; i++)
156
+ rb_ary_push(result, su_wrap_entity(entities[i]));
157
+ xfree(pids);
158
+ xfree(entities);
159
+ return count == 1 && !RB_TYPE_P(argv[0], T_ARRAY) ? RARRAY_AREF(result, 0) : result;
160
+ }
161
+
162
+ static VALUE model_instance_path_from_pid_path(VALUE self, VALUE pid_path)
163
+ {
164
+ SUStringRef pid = SU_INVALID;
165
+ SUStringCreateFromUTF8(&pid, StringValueCStr(pid_path));
166
+ SUInstancePathRef path = SU_INVALID;
167
+ SUInstancePathCreate(&path);
168
+ enum SUResult result = SUModelGetInstancePathByPid(SU_REF(SUModelRef, self), pid, &path);
169
+ SUStringRelease(&pid);
170
+ VALUE wrapped = result == SU_ERROR_NONE ? su_instance_path_copy(path) : Qnil;
171
+ SUInstancePathRelease(&path);
172
+ if (NIL_P(wrapped))
173
+ rb_raise(rb_eArgError, "no instance path for %"PRIsVALUE, pid_path);
174
+ return wrapped;
175
+ }
176
+
177
+ static VALUE model_drawing_element_visible_p(VALUE self, VALUE instance_path)
178
+ {
179
+ bool visible = false;
180
+ if (SUModelIsDrawingElementVisible(SU_REF(SUModelRef, self), su_to_instance_path(instance_path), &visible) != SU_ERROR_NONE)
181
+ rb_raise(rb_eArgError, "invalid instance path");
182
+ return BOOL2RB(visible);
183
+ }
184
+
185
+ static VALUE model_save(int argc, VALUE* argv, VALUE self)
186
+ {
187
+ VALUE path, version;
188
+ rb_scan_args(argc, argv, "02", &path, &version);
189
+ if (NIL_P(path))
190
+ path = model_path(self);
191
+ if (RSTRING_LEN(StringValue(path)) == 0)
192
+ rb_raise(rb_eArgError, "the model has no path; pass one");
193
+ enum SUResult result = NIL_P(version)
194
+ ? SUModelSaveToFile(SU_REF(SUModelRef, self), StringValueCStr(path))
195
+ : SUModelSaveToFileWithVersion(SU_REF(SUModelRef, self), StringValueCStr(path), (enum SUModelVersion)NUM2INT(version));
196
+ return BOOL2RB(result == SU_ERROR_NONE);
197
+ }
198
+
199
+ static VALUE model_behavior(VALUE self)
200
+ {
201
+ VALUE behavior = su_wrap(cBehavior, DATA_PTR(self));
202
+ rb_ivar_set(behavior, (rb_intern)("__owner_is_model"), Qtrue);
203
+ return behavior;
204
+ }
205
+
206
+ void Init_model(void)
207
+ {
208
+ static const struct { const char* name; VALUE (*fn)(ANYARGS); int argc; } methods[] = {
209
+ {"active_entities", RUBY_METHOD_FUNC(model_active_entities), 0},
210
+ {"active_layer", RUBY_METHOD_FUNC(model_active_layer), 0},
211
+ {"active_layer=", RUBY_METHOD_FUNC(model_set_active_layer), 1},
212
+ {"active_section_planes", RUBY_METHOD_FUNC(model_active_section_planes), 0},
213
+ {"name", RUBY_METHOD_FUNC(model_name), 0},
214
+ {"name=", RUBY_METHOD_FUNC(model_set_name), 1},
215
+ {"title", RUBY_METHOD_FUNC(model_title), 0},
216
+ {"path", RUBY_METHOD_FUNC(model_path), 0},
217
+ {"guid", RUBY_METHOD_FUNC(model_guid), 0},
218
+ {"description", RUBY_METHOD_FUNC(model_description), 0},
219
+ {"description=", RUBY_METHOD_FUNC(model_set_description), 1},
220
+ {"georeferenced?", RUBY_METHOD_FUNC(model_georeferenced_p), 0},
221
+ {"valid?", RUBY_METHOD_FUNC(model_valid_p), 0},
222
+ {"bounds", RUBY_METHOD_FUNC(model_bounds), 0},
223
+ {"number_faces", RUBY_METHOD_FUNC(model_number_faces), 0},
224
+ {"attribute_dictionary", RUBY_METHOD_FUNC(model_attribute_dictionary), -1},
225
+ {"get_attribute", RUBY_METHOD_FUNC(model_get_attribute), -1},
226
+ {"set_attribute", RUBY_METHOD_FUNC(model_set_attribute), 3},
227
+ {"find_entity_by_persistent_id", RUBY_METHOD_FUNC(model_find_entity_by_persistent_id), -1},
228
+ {"instance_path_from_pid_path", RUBY_METHOD_FUNC(model_instance_path_from_pid_path), 1},
229
+ {"drawing_element_visible?", RUBY_METHOD_FUNC(model_drawing_element_visible_p), 1},
230
+ {"save", RUBY_METHOD_FUNC(model_save), -1},
231
+ {"save_copy", RUBY_METHOD_FUNC(model_save), -1},
232
+ {"behavior", RUBY_METHOD_FUNC(model_behavior), 0},
233
+ };
234
+ for (size_t i = 0; i < sizeof(methods) / sizeof(methods[0]); i++)
235
+ rb_define_method(cModel, methods[i].name, methods[i].fn, methods[i].argc);
236
+ rb_define_method(cModel, "==", model_eq, 1);
237
+ rb_define_method(cModel, "eql?", model_eq, 1);
238
+ rb_define_method(cModel, "hash", model_hash, 0);
239
+ rb_define_const(cModel, "LOAD_STATUS_SUCCESS", INT2FIX(SUModelLoadStatus_Success));
240
+ rb_define_const(cModel, "LOAD_STATUS_SUCCESS_MORE_RECENT", INT2FIX(SUModelLoadStatus_Success_MoreRecent));
241
+ rb_define_method(cModel, "close", model_close, -1);
242
+ rb_define_method(cModel, "entities", model_entities, 0);
243
+ rb_define_method(cModel, "layers", model_layers, 0);
244
+ rb_define_method(cModel, "tags", model_layers, 0);
245
+ rb_define_method(cModel, "line_styles", model_line_styles, 0);
246
+ rb_define_method(cModel, "materials", model_materials, 0);
247
+ rb_define_method(cModel, "definitions", model_definitions, 0);
248
+ rb_define_method(cModel, "attribute_dictionaries", model_attribute_dictionaries, 0);
249
+ }
@@ -0,0 +1,188 @@
1
+ #include <scriptup.h>
2
+
3
+ // RenderingOptions and ShadowInfo are both key/value stores of typed values.
4
+ static VALUE store_value(VALUE self, VALUE key, enum SUResult (*get)(void*, const char*, SUTypedValueRef*))
5
+ {
6
+ SUTypedValueRef value = SU_INVALID;
7
+ SUTypedValueCreate(&value);
8
+ VALUE output = Qnil;
9
+ if (get(DATA_PTR(self), StringValueCStr(key), &value) == SU_ERROR_NONE)
10
+ output = su_ruby_from_typed_value(value);
11
+ SUTypedValueRelease(&value);
12
+ return output;
13
+ }
14
+
15
+ // Numbers are stored with the type the key already has (e.g. 40 for a double).
16
+ static VALUE store_set(VALUE self, VALUE key, VALUE object, enum SUResult (*get)(void*, const char*, SUTypedValueRef*),
17
+ enum SUResult (*set)(void*, const char*, SUTypedValueRef))
18
+ {
19
+ const char* name = StringValueCStr(key);
20
+ SUTypedValueRef value = SU_INVALID;
21
+ SUTypedValueCreate(&value);
22
+ enum SUTypedValueType type = SUTypedValueType_Empty;
23
+ if (get(DATA_PTR(self), name, &value) != SU_ERROR_NONE)
24
+ {
25
+ SUTypedValueRelease(&value);
26
+ rb_raise(rb_eArgError, "invalid key: %s", name);
27
+ }
28
+ SUTypedValueGetType(value, &type);
29
+ if (rb_obj_is_kind_of(object, rb_cNumeric) && (type == SUTypedValueType_Double || type == SUTypedValueType_Float))
30
+ SUTypedValueSetDouble(value, NUM2DBL(object));
31
+ else if (rb_obj_is_kind_of(object, rb_cNumeric) && type == SUTypedValueType_Short)
32
+ SUTypedValueSetInt16(value, (int16_t)NUM2INT(object));
33
+ else
34
+ su_typed_value_from_ruby(value, object);
35
+ enum SUResult result = set(DATA_PTR(self), name, value);
36
+ SUTypedValueRelease(&value);
37
+ if (result != SU_ERROR_NONE)
38
+ rb_raise(rb_eArgError, "cannot set %s", name);
39
+ return object;
40
+ }
41
+
42
+ #define DEFINE_STORE(prefix, klass, RefType, NumFn, KeysFn, GetFn, SetFn, ModelFn) \
43
+ DEFINE_STRING_LIST(prefix##_key_list, RefType, NumFn, KeysFn) \
44
+ static enum SUResult prefix##_get(void* ptr, const char* key, SUTypedValueRef* value) { return GetFn((RefType){ptr}, key, value); } \
45
+ static enum SUResult prefix##_put(void* ptr, const char* key, SUTypedValueRef value) { return SetFn((RefType){ptr}, key, value); } \
46
+ static VALUE prefix##_keys(VALUE self) { return prefix##_key_list(SU_REF(RefType, self)); } \
47
+ static VALUE prefix##_length(VALUE self) { return LONG2NUM(RARRAY_LEN(prefix##_keys(self))); } \
48
+ static VALUE prefix##_aref(VALUE self, VALUE key) { return store_value(self, key, prefix##_get); } \
49
+ static VALUE prefix##_aset(VALUE self, VALUE key, VALUE value) { return store_set(self, key, value, prefix##_get, prefix##_put); } \
50
+ static VALUE prefix##_each_key(VALUE self) { su_yield_each(self, prefix##_keys(self)); return Qnil; } \
51
+ static VALUE prefix##_each(VALUE self) \
52
+ { \
53
+ VALUE keys = prefix##_keys(self); \
54
+ for (long i = 0; i < RARRAY_LEN(keys); i++) \
55
+ rb_yield_values(2, RARRAY_AREF(keys, i), prefix##_aref(self, RARRAY_AREF(keys, i))); \
56
+ return Qnil; \
57
+ } \
58
+ static VALUE prefix##_model_store(VALUE model) \
59
+ { \
60
+ RefType ref = SU_INVALID; \
61
+ ModelFn(SU_REF(SUModelRef, model), &ref); \
62
+ return su_wrap_or_nil(klass, ref.ptr); \
63
+ } \
64
+ static VALUE prefix##_active_store(void) \
65
+ { \
66
+ SUModelRef model = Sketchup_get_active_model(); \
67
+ if (SUIsInvalid(model)) \
68
+ rb_raise(rb_eRuntimeError, "no active model"); \
69
+ return prefix##_model_store(su_wrap(cModel, model.ptr)); \
70
+ } \
71
+ static VALUE prefix##_s_keys(VALUE klass) { return prefix##_keys(prefix##_active_store()); } \
72
+ static VALUE prefix##_s_each_key(VALUE klass) { return prefix##_each_key(prefix##_active_store()); } \
73
+ static void prefix##_define(const char* model_method) \
74
+ { \
75
+ rb_include_module(klass, rb_mEnumerable); \
76
+ rb_define_singleton_method(klass, "keys", prefix##_s_keys, 0); \
77
+ rb_define_singleton_method(klass, "each_key", prefix##_s_each_key, 0); \
78
+ rb_define_method(klass, "keys", prefix##_keys, 0); \
79
+ rb_define_method(klass, "[]", prefix##_aref, 1); \
80
+ rb_define_method(klass, "[]=", prefix##_aset, 2); \
81
+ rb_define_method(klass, "each", prefix##_each, 0); \
82
+ rb_define_method(klass, "each_pair", prefix##_each, 0); \
83
+ rb_define_method(klass, "each_key", prefix##_each_key, 0); \
84
+ rb_define_method(klass, "count", prefix##_length, 0); \
85
+ rb_define_method(klass, "length", prefix##_length, 0); \
86
+ rb_define_method(klass, "size", prefix##_length, 0); \
87
+ rb_define_method(cModel, model_method, prefix##_model_store, 0); \
88
+ }
89
+
90
+ DEFINE_STORE(renderingoptions, cRenderingOptions, SURenderingOptionsRef, SURenderingOptionsGetNumKeys,
91
+ SURenderingOptionsGetKeys, SURenderingOptionsGetValue, SURenderingOptionsSetValue, SUModelGetRenderingOptions)
92
+ DEFINE_STORE(shadowinfo, cShadowInfo, SUShadowInfoRef, SUShadowInfoGetNumKeys,
93
+ SUShadowInfoGetKeys, SUShadowInfoGetValue, SUShadowInfoSetValue, SUModelGetShadowInfo)
94
+
95
+ // Sketchup::OptionsProvider: a named store reached through Model#options.
96
+ #define PROVIDER(self) SU_REF(SUOptionsProviderRef, self)
97
+ DEFINE_STRING_LIST(provider_key_list, SUOptionsProviderRef, SUOptionsProviderGetNumKeys, SUOptionsProviderGetKeys)
98
+ DEFINE_STRING_GETTER(provider_name, SUOptionsProviderRef, SUOptionsProviderGetName)
99
+ static enum SUResult provider_get(void* ptr, const char* key, SUTypedValueRef* value) { return SUOptionsProviderGetValue((SUOptionsProviderRef){ptr}, key, value); }
100
+ static enum SUResult provider_put(void* ptr, const char* key, SUTypedValueRef value) { return SUOptionsProviderSetValue((SUOptionsProviderRef){ptr}, key, value); }
101
+ static VALUE provider_keys(VALUE self) { return provider_key_list(PROVIDER(self)); }
102
+ static VALUE provider_length(VALUE self) { return LONG2NUM(RARRAY_LEN(provider_keys(self))); }
103
+ static VALUE provider_aset(VALUE self, VALUE key, VALUE value) { return store_set(self, key, value, provider_get, provider_put); }
104
+ static VALUE provider_has_key_p(VALUE self, VALUE key) { return rb_ary_includes(provider_keys(self), StringValue(key)); }
105
+ static VALUE provider_each_key(VALUE self) { su_yield_each(self, provider_keys(self)); return Qnil; }
106
+
107
+ static VALUE provider_aref(VALUE self, VALUE key)
108
+ {
109
+ if (!RB_TYPE_P(key, T_STRING))
110
+ key = rb_ary_entry(provider_keys(self), NUM2LONG(key));
111
+ return NIL_P(key) ? Qnil : store_value(self, key, provider_get);
112
+ }
113
+
114
+ static VALUE provider_each(VALUE self)
115
+ {
116
+ VALUE keys = provider_keys(self);
117
+ for (long i = 0; i < RARRAY_LEN(keys); i++)
118
+ rb_yield_values(2, RARRAY_AREF(keys, i), provider_aref(self, RARRAY_AREF(keys, i)));
119
+ return Qnil;
120
+ }
121
+
122
+ static VALUE provider_each_value(VALUE self)
123
+ {
124
+ VALUE keys = provider_keys(self);
125
+ for (long i = 0; i < RARRAY_LEN(keys); i++)
126
+ rb_yield(provider_aref(self, RARRAY_AREF(keys, i)));
127
+ return Qnil;
128
+ }
129
+
130
+ // Sketchup::OptionsManager
131
+ #define MANAGER(self) SU_REF(SUOptionsManagerRef, self)
132
+ DEFINE_STRING_LIST(manager_key_list, SUOptionsManagerRef, SUOptionsManagerGetNumOptionsProviders, SUOptionsManagerGetOptionsProviderNames)
133
+ static VALUE manager_keys(VALUE self) { return manager_key_list(MANAGER(self)); }
134
+ static VALUE manager_length(VALUE self) { return LONG2NUM(RARRAY_LEN(manager_keys(self))); }
135
+
136
+ static VALUE manager_aref(VALUE self, VALUE key)
137
+ {
138
+ if (!RB_TYPE_P(key, T_STRING))
139
+ key = rb_ary_entry(manager_keys(self), NUM2LONG(key));
140
+ if (NIL_P(key))
141
+ return Qnil;
142
+ SUOptionsProviderRef provider = SU_INVALID;
143
+ SUOptionsManagerGetOptionsProviderByName(MANAGER(self), StringValueCStr(key), &provider);
144
+ return su_wrap_or_nil(cOptionsProvider, provider.ptr);
145
+ }
146
+
147
+ static VALUE manager_each(VALUE self)
148
+ {
149
+ VALUE keys = manager_keys(self);
150
+ for (long i = 0; i < RARRAY_LEN(keys); i++)
151
+ rb_yield(manager_aref(self, RARRAY_AREF(keys, i)));
152
+ return Qnil;
153
+ }
154
+
155
+ static VALUE model_options(VALUE model)
156
+ {
157
+ SUOptionsManagerRef manager = SU_INVALID;
158
+ SUModelGetOptionsManager(SU_REF(SUModelRef, model), &manager);
159
+ return su_wrap_or_nil(cOptionsManager, manager.ptr);
160
+ }
161
+
162
+ void Init_options_store(void)
163
+ {
164
+ rb_include_module(cOptionsProvider, rb_mEnumerable);
165
+ rb_define_method(cOptionsProvider, "name", provider_name, 0);
166
+ rb_define_method(cOptionsProvider, "keys", provider_keys, 0);
167
+ rb_define_method(cOptionsProvider, "[]", provider_aref, 1);
168
+ rb_define_method(cOptionsProvider, "[]=", provider_aset, 2);
169
+ rb_define_method(cOptionsProvider, "has_key?", provider_has_key_p, 1);
170
+ rb_define_method(cOptionsProvider, "key?", provider_has_key_p, 1);
171
+ rb_define_method(cOptionsProvider, "each", provider_each, 0);
172
+ rb_define_method(cOptionsProvider, "each_pair", provider_each, 0);
173
+ rb_define_method(cOptionsProvider, "each_key", provider_each_key, 0);
174
+ rb_define_method(cOptionsProvider, "each_value", provider_each_value, 0);
175
+ rb_define_method(cOptionsProvider, "count", provider_length, 0);
176
+ rb_define_method(cOptionsProvider, "length", provider_length, 0);
177
+ rb_define_method(cOptionsProvider, "size", provider_length, 0);
178
+ rb_include_module(cOptionsManager, rb_mEnumerable);
179
+ rb_define_method(cOptionsManager, "keys", manager_keys, 0);
180
+ rb_define_method(cOptionsManager, "[]", manager_aref, 1);
181
+ rb_define_method(cOptionsManager, "each", manager_each, 0);
182
+ rb_define_method(cOptionsManager, "count", manager_length, 0);
183
+ rb_define_method(cOptionsManager, "length", manager_length, 0);
184
+ rb_define_method(cOptionsManager, "size", manager_length, 0);
185
+ rb_define_method(cModel, "options", model_options, 0);
186
+ renderingoptions_define("rendering_options");
187
+ shadowinfo_define("shadow_info");
188
+ }
data/ext/page.c ADDED
@@ -0,0 +1,168 @@
1
+ #include <scriptup.h>
2
+
3
+ #define SCENE(self) SU_REF(SUSceneRef, self)
4
+
5
+ DEFINE_STRING_GETTER(page_name, SUSceneRef, SUSceneGetName)
6
+ DEFINE_STRING_SETTER(page_set_name, SUSceneRef, SUSceneSetName)
7
+ DEFINE_STRING_GETTER(page_description, SUSceneRef, SUSceneGetDescription)
8
+ DEFINE_STRING_SETTER(page_set_description, SUSceneRef, SUSceneSetDescription)
9
+ DEFINE_REF_GETTER(page_axes, SUSceneRef, SUSceneGetAxes, SUAxesRef, cAxes)
10
+ DEFINE_REF_GETTER(page_rendering_options, SUSceneRef, SUSceneGetRenderingOptions, SURenderingOptionsRef, cRenderingOptions)
11
+ DEFINE_REF_GETTER(page_shadow_info, SUSceneRef, SUSceneGetShadowInfo, SUShadowInfoRef, cShadowInfo)
12
+ DEFINE_REF_GETTER(page_style, SUSceneRef, SUSceneGetStyle, SUStyleRef, cStyle)
13
+ DEFINE_REF_GETTER(page_environment, SUSceneRef, SUSceneGetEnvironment, SUEnvironmentRef, cEnvironment)
14
+ DEFINE_REF_LIST(page_layer_list, SUSceneRef, SUSceneGetNumLayers, SUSceneGetLayers, SULayerRef, cLayer)
15
+ DEFINE_REF_LIST(page_folder_list, SUSceneRef, SUSceneGetNumLayerFolders, SUSceneGetLayerFolders, SULayerFolderRef, cLayerFolder)
16
+ DEFINE_REF_LIST(page_section_list, SUSceneRef, SUSceneGetNumActiveSectionPlanes, SUSceneGetActiveSectionPlanes, SUSectionPlaneRef, cSectionPlane)
17
+
18
+ #define DEFINE_FLAG(name, GetFn, SetFn) \
19
+ DEFINE_BOOL_GETTER(page_##name##_p, SUSceneRef, GetFn) \
20
+ DEFINE_BOOL_SETTER(page_set_##name, SUSceneRef, SetFn)
21
+ DEFINE_FLAG(include_in_animation, SUSceneGetIncludeInAnimation, SUSceneSetIncludeInAnimation)
22
+ DEFINE_FLAG(use_axes, SUSceneGetUseAxes, SUSceneSetUseAxes)
23
+ DEFINE_FLAG(use_camera, SUSceneGetUseCamera, SUSceneSetUseCamera)
24
+ DEFINE_FLAG(use_environment, SUSceneGetUseEnvironment, SUSceneSetUseEnvironment)
25
+ DEFINE_FLAG(use_hidden, SUSceneGetUseHidden, SUSceneSetUseHidden)
26
+ DEFINE_FLAG(use_hidden_geometry, SUSceneGetUseHiddenGeometry, SUSceneSetUseHiddenGeometry)
27
+ DEFINE_FLAG(use_hidden_layers, SUSceneGetUseHiddenLayers, SUSceneSetUseHiddenLayers)
28
+ DEFINE_FLAG(use_hidden_objects, SUSceneGetUseHiddenObjects, SUSceneSetUseHiddenObjects)
29
+ DEFINE_FLAG(use_rendering_options, SUSceneGetUseRenderingOptions, SUSceneSetUseRenderingOptions)
30
+ DEFINE_FLAG(use_section_planes, SUSceneGetUseSectionPlanes, SUSceneSetUseSectionPlanes)
31
+ DEFINE_FLAG(use_shadow_info, SUSceneGetUseShadowInfo, SUSceneSetUseShadowInfo)
32
+
33
+ // Page-specific lists return nil when empty, like the Ruby API.
34
+ static VALUE nil_if_empty(VALUE ary)
35
+ {
36
+ return RARRAY_LEN(ary) == 0 ? Qnil : ary;
37
+ }
38
+
39
+ static VALUE page_layers(VALUE self) { return nil_if_empty(page_layer_list(SCENE(self))); }
40
+ static VALUE page_layer_folders(VALUE self) { return nil_if_empty(page_folder_list(SCENE(self))); }
41
+ static VALUE page_active_section_planes(VALUE self) { return nil_if_empty(page_section_list(SCENE(self))); }
42
+
43
+ static VALUE page_hidden_entities(VALUE self)
44
+ {
45
+ size_t count = 0;
46
+ SUSceneGetNumHiddenEntities(SCENE(self), &count);
47
+ if (count == 0)
48
+ return Qnil;
49
+ SUEntityRef* entities = ZALLOC_N(SUEntityRef, count);
50
+ SUSceneGetHiddenEntities(SCENE(self), count, entities, &count);
51
+ VALUE ary = rb_ary_new_capa((long)count);
52
+ for (size_t i = 0; i < count; i++)
53
+ rb_ary_push(ary, su_wrap_entity(entities[i]));
54
+ xfree(entities);
55
+ return ary;
56
+ }
57
+
58
+ static VALUE page_camera(VALUE self)
59
+ {
60
+ SUCameraRef camera = SU_INVALID;
61
+ SUSceneGetCamera(SCENE(self), &camera);
62
+ return su_camera_wrap(camera);
63
+ }
64
+
65
+ static VALUE page_set_environment(VALUE self, VALUE environment)
66
+ {
67
+ SUSceneSetEnvironment(SCENE(self), (SUEnvironmentRef){su_unwrap(environment, cEnvironment)});
68
+ return environment;
69
+ }
70
+
71
+ static VALUE page_get_drawingelement_visibility(VALUE self, VALUE element)
72
+ {
73
+ bool hidden = false;
74
+ SUSceneGetDrawingElementHidden(SCENE(self), (SUDrawingElementRef){su_unwrap(element, cDrawingelement)}, &hidden);
75
+ return BOOL2RB(!hidden);
76
+ }
77
+
78
+ static VALUE page_set_drawingelement_visibility(VALUE self, VALUE element, VALUE visible)
79
+ {
80
+ enum SUResult result = SUSceneSetDrawingElementHidden(SCENE(self),
81
+ (SUDrawingElementRef){su_unwrap(element, cDrawingelement)}, !RTEST(visible));
82
+ return BOOL2RB(result == SU_ERROR_NONE);
83
+ }
84
+
85
+ // A page lists the layers and folders whose visibility differs; hiding adds, showing removes.
86
+ static VALUE page_set_visibility(VALUE self, VALUE target, VALUE visible)
87
+ {
88
+ if (rb_obj_is_kind_of(target, cLayerFolder))
89
+ {
90
+ SULayerFolderRef folder = SU_REF(SULayerFolderRef, target);
91
+ RTEST(visible) ? SUSceneRemoveLayerFolder(SCENE(self), folder) : SUSceneAddLayerFolder(SCENE(self), folder);
92
+ }
93
+ else
94
+ {
95
+ SULayerRef layer = {su_unwrap(target, cLayer)};
96
+ RTEST(visible) ? SUSceneRemoveLayer(SCENE(self), layer) : SUSceneAddLayer(SCENE(self), layer);
97
+ }
98
+ return self;
99
+ }
100
+
101
+ static VALUE page_update(int argc, VALUE* argv, VALUE self)
102
+ {
103
+ VALUE flags;
104
+ rb_scan_args(argc, argv, "01", &flags);
105
+ unsigned int f = NIL_P(flags) ? FLAG_USE_ALL : NUM2UINT(flags);
106
+ return BOOL2RB(SUSceneUpdate(SCENE(self), f) == SU_ERROR_NONE);
107
+ }
108
+
109
+ void Init_page(void)
110
+ {
111
+ static const struct { const char* name; int value; } constants[] = {
112
+ {"PAGE_USE_CAMERA", FLAG_USE_CAMERA}, {"PAGE_USE_RENDERING_OPTIONS", FLAG_USE_RENDERING_OPTIONS},
113
+ {"PAGE_USE_SHADOWINFO", FLAG_USE_SHADOWINFO}, {"PAGE_USE_SKETCHCS", FLAG_USE_AXES},
114
+ {"PAGE_USE_HIDDEN", FLAG_USE_HIDDEN}, {"PAGE_USE_LAYER_VISIBILITY", FLAG_USE_LAYER_VISIBILITY},
115
+ {"PAGE_USE_SECTION_PLANES", FLAG_USE_SECTION_PLANES}, {"PAGE_USE_HIDDEN_GEOMETRY", FLAG_USE_HIDDEN_GEOMETRY},
116
+ {"PAGE_USE_HIDDEN_OBJECTS", FLAG_USE_HIDDEN_OBJECTS}, {"PAGE_USE_ENVIRONMENT", FLAG_USE_ENVIRONMENT},
117
+ {"PAGE_USE_ALL", FLAG_USE_ALL}, {"PAGE_NO_CAMERA", FLAG_USE_ALL & ~FLAG_USE_CAMERA},
118
+ };
119
+ for (size_t i = 0; i < sizeof(constants) / sizeof(constants[0]); i++)
120
+ rb_define_const(rb_cObject, constants[i].name, INT2FIX(constants[i].value));
121
+
122
+ static const struct { const char* name; VALUE (*fn)(ANYARGS); int argc; } methods[] = {
123
+ {"name", RUBY_METHOD_FUNC(page_name), 0},
124
+ {"name=", RUBY_METHOD_FUNC(page_set_name), 1},
125
+ {"label", RUBY_METHOD_FUNC(page_name), 0},
126
+ {"description", RUBY_METHOD_FUNC(page_description), 0},
127
+ {"description=", RUBY_METHOD_FUNC(page_set_description), 1},
128
+ {"axes", RUBY_METHOD_FUNC(page_axes), 0},
129
+ {"camera", RUBY_METHOD_FUNC(page_camera), 0},
130
+ {"rendering_options", RUBY_METHOD_FUNC(page_rendering_options), 0},
131
+ {"shadow_info", RUBY_METHOD_FUNC(page_shadow_info), 0},
132
+ {"style", RUBY_METHOD_FUNC(page_style), 0},
133
+ {"environment", RUBY_METHOD_FUNC(page_environment), 0},
134
+ {"environment=", RUBY_METHOD_FUNC(page_set_environment), 1},
135
+ {"layers", RUBY_METHOD_FUNC(page_layers), 0},
136
+ {"layer_folders", RUBY_METHOD_FUNC(page_layer_folders), 0},
137
+ {"active_section_planes", RUBY_METHOD_FUNC(page_active_section_planes), 0},
138
+ {"hidden_entities", RUBY_METHOD_FUNC(page_hidden_entities), 0},
139
+ {"get_drawingelement_visibility", RUBY_METHOD_FUNC(page_get_drawingelement_visibility), 1},
140
+ {"set_drawingelement_visibility", RUBY_METHOD_FUNC(page_set_drawingelement_visibility), 2},
141
+ {"set_visibility", RUBY_METHOD_FUNC(page_set_visibility), 2},
142
+ {"update", RUBY_METHOD_FUNC(page_update), -1},
143
+ {"include_in_animation?", RUBY_METHOD_FUNC(page_include_in_animation_p), 0},
144
+ {"include_in_animation=", RUBY_METHOD_FUNC(page_set_include_in_animation), 1},
145
+ {"use_axes?", RUBY_METHOD_FUNC(page_use_axes_p), 0},
146
+ {"use_axes=", RUBY_METHOD_FUNC(page_set_use_axes), 1},
147
+ {"use_camera?", RUBY_METHOD_FUNC(page_use_camera_p), 0},
148
+ {"use_camera=", RUBY_METHOD_FUNC(page_set_use_camera), 1},
149
+ {"use_environment?", RUBY_METHOD_FUNC(page_use_environment_p), 0},
150
+ {"use_environment=", RUBY_METHOD_FUNC(page_set_use_environment), 1},
151
+ {"use_hidden?", RUBY_METHOD_FUNC(page_use_hidden_p), 0},
152
+ {"use_hidden=", RUBY_METHOD_FUNC(page_set_use_hidden), 1},
153
+ {"use_hidden_geometry?", RUBY_METHOD_FUNC(page_use_hidden_geometry_p), 0},
154
+ {"use_hidden_geometry=", RUBY_METHOD_FUNC(page_set_use_hidden_geometry), 1},
155
+ {"use_hidden_layers?", RUBY_METHOD_FUNC(page_use_hidden_layers_p), 0},
156
+ {"use_hidden_layers=", RUBY_METHOD_FUNC(page_set_use_hidden_layers), 1},
157
+ {"use_hidden_objects?", RUBY_METHOD_FUNC(page_use_hidden_objects_p), 0},
158
+ {"use_hidden_objects=", RUBY_METHOD_FUNC(page_set_use_hidden_objects), 1},
159
+ {"use_rendering_options?", RUBY_METHOD_FUNC(page_use_rendering_options_p), 0},
160
+ {"use_rendering_options=", RUBY_METHOD_FUNC(page_set_use_rendering_options), 1},
161
+ {"use_section_planes?", RUBY_METHOD_FUNC(page_use_section_planes_p), 0},
162
+ {"use_section_planes=", RUBY_METHOD_FUNC(page_set_use_section_planes), 1},
163
+ {"use_shadow_info?", RUBY_METHOD_FUNC(page_use_shadow_info_p), 0},
164
+ {"use_shadow_info=", RUBY_METHOD_FUNC(page_set_use_shadow_info), 1},
165
+ };
166
+ for (size_t i = 0; i < sizeof(methods) / sizeof(methods[0]); i++)
167
+ rb_define_method(cPage, methods[i].name, methods[i].fn, methods[i].argc);
168
+ }