From d5cfb44156de16dd21ab12eb8545fd5ec00d22ee Mon Sep 17 00:00:00 2001 From: Alex Tsvetanov Date: Wed, 28 May 2025 19:39:33 +0300 Subject: [PATCH 1/7] View class --- .gitignore | 1 + build_utils/README.md | 18 + hostapp/dummy_objects.hpp | 42 ++- hostapp/geom.hpp | 10 + hostapp/implemented_objects.hpp | 10 + hostapp/sketchup.hpp | 1 + hostapp/view.cc | 585 ++++++++++++++++++++++++++++ hostapp/view.hpp | 649 ++++++++++++++++++++++++++++++++ hostapp/view_options.hpp | 71 ++++ ruby/utils/hash.hpp | 8 +- 10 files changed, 1382 insertions(+), 13 deletions(-) create mode 100644 build_utils/README.md create mode 100644 hostapp/view.cc create mode 100644 hostapp/view.hpp create mode 100644 hostapp/view_options.hpp diff --git a/.gitignore b/.gitignore index adbd176..9e04f4f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ hostapp_test.hpp build_utils/output build_utils/class_descriptions/*.txt build_utils/class_descriptions/*.md +build/ diff --git a/build_utils/README.md b/build_utils/README.md new file mode 100644 index 0000000..36842fe --- /dev/null +++ b/build_utils/README.md @@ -0,0 +1,18 @@ +# Instructions how to use the build_utils +## Implement a new class +1. Go to the official SketchUp Ruby API documentation +2. Navigate to your class' page (f.ex. https://ruby.sketchup.com/Sketchup/View.html) +3. Navigate to the text "Instance Method Details" +4. Select every text from that line to the end of the page ("Generated by yard") +5. Copy the selection and paste it into a file named after the class' name (in this case "build_utils/class_descriptions/View.txt") +6. Enter `build_utils/scripts` and execute `./format_files.sh` +7. Create `build_utils/output` directory +8. Build the `parse_ruby_doc` CMake target +9. Enter the directory `build_utils/class_descriptions` and run `{PATH TO parse_ruby_doc}/parse_ruby_doc.exe View.md` (replace "View" with your class' name) +10. Validate the parsing of the documentation, saved in `output/*.hpp` +11. Edit where needed +12. Reuse the header file to craft the source one +- Helpful find & replace regex is `DEFINE_(WRAPPED_METHOD|WRAPPED_METHOD_0)\(` to be replaced with `IMPLEMENT_$1(Sketchup::View, ` (replace "View" with your class' name) +13. Move the header to `hostapp/` +14. Include the header file into `hostapp/implemented_objects.hpp` +14. Include the source file at the bottom of `hostapp/sketchup.hpp` diff --git a/hostapp/dummy_objects.hpp b/hostapp/dummy_objects.hpp index 116fc93..3e26212 100644 --- a/hostapp/dummy_objects.hpp +++ b/hostapp/dummy_objects.hpp @@ -1,5 +1,27 @@ #pragma once +class PickHelper : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::PickHelper"> +{ + public: + inline PickHelper(VALUE obj) : IObject(obj) + { + } + inline PickHelper(const IObject& obj) : IObject(obj) + { + } +}; + +class Camera : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::Camera"> +{ + public: + inline Camera(VALUE obj) : IObject(obj) + { + } + inline Camera(const IObject& obj) : IObject(obj) + { + } +}; + class ImageRep : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::ImageRep"> { public: @@ -99,16 +121,16 @@ class ComponentDefinition : public RubyUtils::details::IObject, public RubyUtils } }; -class View : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::View"> -{ - public: - inline View(VALUE obj) : IObject(obj) - { - } - inline View(const IObject& obj) : IObject(obj) - { - } -}; +// class View : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::View"> +// { +// public: +// inline View(VALUE obj) : IObject(obj) +// { +// } +// inline View(const IObject& obj) : IObject(obj) +// { +// } +// }; class Text : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::Text"> { diff --git a/hostapp/geom.hpp b/hostapp/geom.hpp index c32bd3c..78c9f85 100644 --- a/hostapp/geom.hpp +++ b/hostapp/geom.hpp @@ -36,6 +36,16 @@ class Geom { } }; + class Bounds2d : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Geom::Bounds2d"> + { + public: + inline Bounds2d(VALUE obj) : IObject(obj) + { + } + inline Bounds2d(const IObject& obj) : IObject(obj) + { + } + }; class Point3d : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Geom::Point3d"> { public: diff --git a/hostapp/implemented_objects.hpp b/hostapp/implemented_objects.hpp index 5eed63b..6aa22cd 100644 --- a/hostapp/implemented_objects.hpp +++ b/hostapp/implemented_objects.hpp @@ -37,6 +37,13 @@ class DefinitionsObserver; // https://ruby.sketchup.com/Sketchup/MaterialsObserver.html class MaterialsObserver; +// https://ruby.sketchup.com/Sketchup/View.html +class DrawOptionSet; +class Draw2dOptionSet; +class DrawTextOptionSet; +class WriteImageOptionSet; +class View; + #include "material.hpp" #include "materials.hpp" @@ -51,6 +58,9 @@ class MaterialsObserver; #include "entities.hpp" +#include "view_options.hpp" +#include "view.hpp" + #include "observers/makable_interface.hpp" #include "observers/entities_observer.hpp" diff --git a/hostapp/sketchup.hpp b/hostapp/sketchup.hpp index 5865267..a8b485b 100644 --- a/hostapp/sketchup.hpp +++ b/hostapp/sketchup.hpp @@ -43,6 +43,7 @@ namespace HostApp #include "material.cc" #include "materials.cc" #include "model.cc" +#include "view.cc" #include "entity.cc" #include "definition_list.cc" #include "entities.cc" diff --git a/hostapp/view.cc b/hostapp/view.cc new file mode 100644 index 0000000..8ff5a45 --- /dev/null +++ b/hostapp/view.cc @@ -0,0 +1,585 @@ +namespace HostApp +{ + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#add_observer-instance_method + * + * @param observer read https://ruby.sketchup.com/Sketchup/View.html#add_observer-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#add_observer-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, add_observer, (RubyUtils::details::IObject observer), add_observer, observer) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#animation=-instance_method + * + * @param animation read https://ruby.sketchup.com/Sketchup/View.html#animation=-instance_method + * @return RubyUtils::details::IObject read https://ruby.sketchup.com/Sketchup/View.html#animation=-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, RubyUtils::details::IObject, set_animation, (RubyUtils::details::IObject animation), animation=, animation) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#average_refresh_time-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#average_refresh_time-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, double, average_refresh_time, average_refresh_time) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#camera-instance_method + * + * @return Sketchup::Camera read https://ruby.sketchup.com/Sketchup/View.html#camera-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, Sketchup::Camera, camera, camera) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * + * @param camera read https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * @return RubyUtils::details::IObject read https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, RubyUtils::details::IObject, set_camera, (Sketchup::Camera camera), camera=, camera) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * + * @param camera_and_transition read https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * @return RubyUtils::details::IObject read https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, RubyUtils::details::IObject, set_camera, (RubyUtils::tuple camera_and_transition), camera=, camera_and_transition) + +#if SKETCHUP_VERSION >= 2025 + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#center-instance_method + * + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#center-instance_method + * @min_version SketchUp 2025.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, RubyUtils::tuple, center, center) +#else + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#center-instance_method + * + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#center-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, RubyUtils::tuple, center, center) +#endif + +#if SKETCHUP_VERSION >= 2025 + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * + * @param index read https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * @min_version SketchUp 2025.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, RubyUtils::tuple, corner, (long long index), corner, index) +#else + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * + * @param index read https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, RubyUtils::tuple, corner, (long long index), corner, index) +#endif + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#device_height-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#device_height-instance_method + * @min_version SketchUp 2025.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, long long, device_height, device_height) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#device_width-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#device_width-instance_method + * @min_version SketchUp 2025.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, long long, device_width, device_width) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * + * @param openglenum read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw, (long long openglenum, RubyUtils::Enumerable points), draw, openglenum, points) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * + * @param openglenum read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @param **options read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @min_version SketchUp 2020.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw, (long long openglenum, RubyUtils::Enumerable points, DrawOptions options), draw, openglenum, points, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * + * @param openglenum read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw2d, (long long openglenum, RubyUtils::Enumerable points), draw2d, openglenum, points) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * + * @param openglenum read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @param **options read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @min_version SketchUp 2020.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw2d, (long long openglenum, RubyUtils::Enumerable points, Draw2dOptions options), draw2d, openglenum, points, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_lines-instance_method + * + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw_lines-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_lines-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw_lines, (RubyUtils::Enumerable points), draw_lines, points) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @param size read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @param style read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @param color read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw_points, (RubyUtils::Enumerable points, long long size, long long style, Sketchup::Color color), draw_points, points, size, style, color) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_polyline-instance_method + * + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw_polyline-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_polyline-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw_polyline, (RubyUtils::Enumerable points), draw_polyline, points) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * + * @param point read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @param text read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw_text, (Geom::Point3d point, std::string text), draw_text, point, text) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * + * @param point read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @param text read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @param options read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @min_version SketchUp 2016 + * @note Known Bugs: Prior to SU2022.0, on macOS, the vertical text alignment for some fonts could appear to be offset from their expected positions. As of SU2022.0 the vertical alignment should be more accurate and consistent. + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw_text, (Geom::Point3d point, std::string text, DrawTextOptions options), draw_text, point, text, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method + * + * @param color read https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, set_drawing_color, (RubyUtils::any_of color), drawing_color=, color) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#dynamic=-instance_method + * + * @param value read https://ruby.sketchup.com/Sketchup/View.html#dynamic=-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#dynamic=-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, set_dynamic, (bool value), dynamic=, value) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#field_of_view-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#field_of_view-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, double, field_of_view, field_of_view) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#field_of_view=-instance_method + * + * @param fov read https://ruby.sketchup.com/Sketchup/View.html#field_of_view=-instance_method + * @return double read https://ruby.sketchup.com/Sketchup/View.html#field_of_view=-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, double, set_field_of_view, (double fov), field_of_view=, fov) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#graphics_engine-instance_method + * + * @return Symbol read https://ruby.sketchup.com/Sketchup/View.html#graphics_engine-instance_method + * @min_version SketchUp 2024.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, RubyUtils::Object, graphics_engine, graphics_engine) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * + * @return Geom::Point3d read https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, Geom::Point3d, guess_target, guess_target) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * + * @param screen_point read https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * @return Geom::Point3d read https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Geom::Point3d, guess_target, (Geom::Point3d screen_point), guess_target, screen_point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#inference_locked%3F-instance_method + * + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#inference_locked%3F-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, bool, is_inference_locked, inference_locked?) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @return Sketchup::InputPoint read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @min_version SketchUp 2025.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::InputPoint, inputpoint, (double x, double y), inputpoint, x, y) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @param inputpoint1 read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @return Sketchup::InputPoint read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @min_version SketchUp 2025.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::InputPoint, inputpoint, (double x, double y, Sketchup::InputPoint inputpoint1), inputpoint, x, y, inputpoint1) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#invalidate-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#invalidate-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, Sketchup::View, invalidate, invalidate) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, double, last_refresh_time, last_refresh_time) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * + * @param full read https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * @return double read https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, double, last_refresh_time, (bool full), last_refresh_time, full) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#line_stipple=-instance_method + * + * @param pattern read https://ruby.sketchup.com/Sketchup/View.html#line_stipple=-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#line_stipple=-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, set_line_stipple, (std::string pattern), line_stipple=, pattern) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#line_width=-instance_method + * + * @param width read https://ruby.sketchup.com/Sketchup/View.html#line_width=-instance_method + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#line_width=-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, long long, set_line_width, (long long width), line_width=, width) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#load_texture-instance_method + * + * @param image_rep read https://ruby.sketchup.com/Sketchup/View.html#load_texture-instance_method + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#load_texture-instance_method + * @min_version SketchUp 2020.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, long long, load_texture, (Sketchup::ImageRep image_rep), load_texture, image_rep) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, Sketchup::View, lock_inference, lock_inference) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * + * @param inputpoint read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, lock_inference, (Sketchup::InputPoint inputpoint), lock_inference, inputpoint) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * + * @param inputpoint read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @param inputpoint2 read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, lock_inference, (Sketchup::InputPoint inputpoint, Sketchup::InputPoint inputpoint2), lock_inference, inputpoint, inputpoint2) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#model-instance_method + * + * @return Sketchup::Model read https://ruby.sketchup.com/Sketchup/View.html#model-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, Sketchup::Model, model, model) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * + * @return Sketchup::PickHelper read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, Sketchup::PickHelper, pick_helper, pick_helper) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @param aperture read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @return Sketchup::PickHelper read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::PickHelper, pick_helper, (long long x, long long y, long long aperture), pick_helper, x, y, aperture) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @param aperture read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @return Sketchup::PickHelper read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::PickHelper, pick_helper, (double x, double y, double aperture), pick_helper, x, y, aperture) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * + * @param screen_point read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @return RubyUtils::any_of read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @min_version SketchUp 2025.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, RubyUtils::tuple, pickray, (RubyUtils::tuple screen_point), pickray, screen_point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @return RubyUtils::any_of read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, RubyUtils::tuple, pickray, (double x, double y), pickray, x, y) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * + * @param pixels read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * @param point read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * @return double read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, double, pixels_to_model, (double pixels, Geom::Point3d point), pixels_to_model, pixels, point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#refresh-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#refresh-instance_method + * @min_version SketchUp 7.1 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, Sketchup::View, refresh, refresh) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method + * + * @param texture_id read https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, release_texture, (long long texture_id), release_texture, texture_id) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method + * + * @param observer read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, remove_observer, (RubyUtils::details::IObject observer), remove_observer, observer) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method + * + * @param model_point read https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method + * @return Geom::Point3d read https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Geom::Point3d, screen_coords, (Geom::Point3d model_point), screen_coords, model_point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * + * @param point1 read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * @param point2 read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, set_color_from_line, (Geom::Point3d point1, Geom::Point3d point2), set_color_from_line, point1, point2) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method + * + * @param delay read https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, show_frame, (double delay), show_frame, delay) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * + * @param point read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @param text read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @param options read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @return Geom::Bounds2d read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @min_version SketchUp 2020.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Geom::Bounds2d, text_bounds, (Geom::Point3d point, std::string text, DrawTextOptions options), text_bounds, point, text, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method + * + * @param string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method + * @return std::string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, std::string, set_tooltip, (std::string string), tooltip=, string) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + //IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, double, vpheight, vpheight) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, long long, vpheight, vpheight) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + //IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, double, vpwidth, vpwidth) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, long long, vpwidth, vpwidth) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * + * @param filename read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param width read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param height read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param antialias read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param compression read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, write_image, (std::string filename, long long width, long long height, bool antialias, double compression), write_image, filename, width, height, antialias, compression) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * + * @param options read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @min_version SketchUp 7SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, write_image, (WriteImage1Options options), write_image, options) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, write_image, (WriteImage2Options options), write_image, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method + * + * @param zoom_or_ents read https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method + * @min_version SketchUp 6.0 + */ + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, zoom, (RubyUtils::any_of> zoom_or_ents), zoom, zoom_or_ents) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#zoom_extents-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#zoom_extents-instance_method + * @min_version + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, Sketchup::View, zoom_extents, zoom_extents) + + +} diff --git a/hostapp/view.hpp b/hostapp/view.hpp new file mode 100644 index 0000000..043c560 --- /dev/null +++ b/hostapp/view.hpp @@ -0,0 +1,649 @@ +#pragma once + +#include "../ruby/utils.hpp" +#include "macros.hpp" + +class View : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::View"> +{ +public: + static constexpr int TextAlignLeft = 0; + static constexpr int TextAlignRight = 2; + static constexpr int TextAlignCenter = 1; + static constexpr int TextVerticalAlignBoundsTop = 0; + static constexpr int TextVerticalAlignBaseline = 1; + static constexpr int TextVerticalAlignCapHeight = 2; + static constexpr int TextVerticalAlignCenter = 3; + + using DrawOptions = RubyUtils::Hash< + DrawOptionSet::normals, + DrawOptionSet::texture, + DrawOptionSet::uvs + >; + + using Draw2dOptions = RubyUtils::Hash< + Draw2dOptionSet::texture, + Draw2dOptionSet::uvs + >; + + using DrawTextOptions = RubyUtils::Hash< + DrawTextOptionSet::font, + DrawTextOptionSet::size, + DrawTextOptionSet::pixel_size, + DrawTextOptionSet::point_size, + DrawTextOptionSet::bold, + DrawTextOptionSet::italic, + DrawTextOptionSet::color, + DrawTextOptionSet::align, + DrawTextOptionSet::vertical_align + >; + + using WriteImage1Options = RubyUtils::Hash< + WriteImageOptionSet::filename, + WriteImageOptionSet::width, + WriteImageOptionSet::height, + WriteImageOptionSet::scale_factor, + WriteImageOptionSet::antialias, + WriteImageOptionSet::compression, + WriteImageOptionSet::transparent + >; + + using WriteImage2Options = RubyUtils::Hash< + WriteImageOptionSet::filename, + WriteImageOptionSet::source, + WriteImageOptionSet::compression + >; + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#add_observer-instance_method + * + * @param observer read https://ruby.sketchup.com/Sketchup/View.html#add_observer-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#add_observer-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(bool, add_observer, (RubyUtils::details::IObject observer), add_observer, observer) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#animation=-instance_method + * + * @param animation read https://ruby.sketchup.com/Sketchup/View.html#animation=-instance_method + * @return RubyUtils::details::IObject read https://ruby.sketchup.com/Sketchup/View.html#animation=-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(RubyUtils::details::IObject, set_animation, (RubyUtils::details::IObject animation), animation=, animation) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#average_refresh_time-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#average_refresh_time-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(double, average_refresh_time, average_refresh_time) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#camera-instance_method + * + * @return Sketchup::Camera read https://ruby.sketchup.com/Sketchup/View.html#camera-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(Sketchup::Camera, camera, camera) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * + * @param camera read https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * @return RubyUtils::details::IObject read https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD(RubyUtils::details::IObject, set_camera, (Sketchup::Camera camera), camera=, camera) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * + * @param camera_and_transition read https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * @return RubyUtils::details::IObject read https://ruby.sketchup.com/Sketchup/View.html#camera=-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(RubyUtils::details::IObject, set_camera, (RubyUtils::tuple camera_and_transition), camera=, camera_and_transition) + +#if SKETCHUP_VERSION >= 2025 + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#center-instance_method + * + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#center-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD_0(RubyUtils::tuple, center, center) +#else + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#center-instance_method + * + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#center-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(RubyUtils::tuple, center, center) +#endif + +#if SKETCHUP_VERSION >= 2025 + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * + * @param index read https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD(RubyUtils::tuple, corner, (long long index), corner, index) +#else + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * + * @param index read https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#corner-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(RubyUtils::tuple, corner, (long long index), corner, index) +#endif + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#device_height-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#device_height-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD_0(long long, device_height, device_height) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#device_width-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#device_width-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD_0(long long, device_width, device_width) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * + * @param openglenum read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, draw, (long long openglenum, RubyUtils::Enumerable points), draw, openglenum, points) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * + * @param openglenum read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @param **options read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method + * @min_version SketchUp 2020.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, draw, (long long openglenum, RubyUtils::Enumerable points, DrawOptions options), draw, openglenum, points, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * + * @param openglenum read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, draw2d, (long long openglenum, RubyUtils::Enumerable points), draw2d, openglenum, points) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * + * @param openglenum read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @param **options read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method + * @min_version SketchUp 2020.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, draw2d, (long long openglenum, RubyUtils::Enumerable points, Draw2dOptions options), draw2d, openglenum, points, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_lines-instance_method + * + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw_lines-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_lines-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, draw_lines, (RubyUtils::Enumerable points), draw_lines, points) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @param size read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @param style read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @param color read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD( + Sketchup::View, + draw_points, + (RubyUtils::Enumerable points, long long size = 6, long long style = 3, Sketchup::Color color = RubyUtils::details::IObject("'black'")), + draw_points, + points, + size, + style, + color) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_polyline-instance_method + * + * @param points read https://ruby.sketchup.com/Sketchup/View.html#draw_polyline-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_polyline-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, draw_polyline, (RubyUtils::Enumerable points), draw_polyline, points) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * + * @param point read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @param text read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, draw_text, (Geom::Point3d point, std::string text), draw_text, point, text) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * + * @param point read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @param text read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @param options read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method + * @min_version SketchUp 2016SketchUp 6.0Known Bugs:Prior to SU2022.0, on macOS, the vertical text alignment for some fonts could appear to be offset from + * their expected positions. As of SU2022.0 the vertical alignment should be more accurate and consistent. + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, draw_text, (Geom::Point3d point, std::string text, DrawTextOptions options), draw_text, point, text, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method + * + * @param color read https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, set_drawing_color, (RubyUtils::any_of color), drawing_color=, color) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#dynamic=-instance_method + * + * @param value read https://ruby.sketchup.com/Sketchup/View.html#dynamic=-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#dynamic=-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(bool, set_dynamic, (bool value), dynamic=, value) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#field_of_view-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#field_of_view-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(double, field_of_view, field_of_view) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#field_of_view=-instance_method + * + * @param fov read https://ruby.sketchup.com/Sketchup/View.html#field_of_view=-instance_method + * @return double read https://ruby.sketchup.com/Sketchup/View.html#field_of_view=-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(double, set_field_of_view, (double fov), field_of_view=, fov) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#graphics_engine-instance_method + * + * @return Symbol read https://ruby.sketchup.com/Sketchup/View.html#graphics_engine-instance_method + * @min_version SketchUp 2024.0 + */ + DEFINE_WRAPPED_METHOD_0(RubyUtils::Object, graphics_engine, graphics_engine) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * + * @return Geom::Point3d read https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD_0(Geom::Point3d, guess_target, guess_target) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * + * @param screen_point read https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * @return Geom::Point3d read https://ruby.sketchup.com/Sketchup/View.html#guess_target-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Geom::Point3d, guess_target, (Geom::Point3d screen_point), guess_target, screen_point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#inference_locked%3F-instance_method + * + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#inference_locked%3F-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(bool, is_inference_locked, inference_locked?) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @return Sketchup::InputPoint read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::InputPoint, inputpoint, (double x, double y), inputpoint, x, y) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @param inputpoint1 read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @return Sketchup::InputPoint read https://ruby.sketchup.com/Sketchup/View.html#inputpoint-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::InputPoint, inputpoint, (double x, double y, Sketchup::InputPoint inputpoint1), inputpoint, x, y, inputpoint1) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#invalidate-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#invalidate-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(Sketchup::View, invalidate, invalidate) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD_0(double, last_refresh_time, last_refresh_time) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * + * @param full read https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * @return double read https://ruby.sketchup.com/Sketchup/View.html#last_refresh_time-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(double, last_refresh_time, (bool full), last_refresh_time, full) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#line_stipple=-instance_method + * + * @param pattern read https://ruby.sketchup.com/Sketchup/View.html#line_stipple=-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#line_stipple=-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, set_line_stipple, (std::string pattern), line_stipple=, pattern) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#line_width=-instance_method + * + * @param width read https://ruby.sketchup.com/Sketchup/View.html#line_width=-instance_method + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#line_width=-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(long long, set_line_width, (long long width), line_width=, width) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#load_texture-instance_method + * + * @param image_rep read https://ruby.sketchup.com/Sketchup/View.html#load_texture-instance_method + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#load_texture-instance_method + * @min_version SketchUp 2020.0 + */ + DEFINE_WRAPPED_METHOD(long long, load_texture, (Sketchup::ImageRep image_rep), load_texture, image_rep) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD_0(Sketchup::View, lock_inference, lock_inference) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * + * @param inputpoint read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, lock_inference, (Sketchup::InputPoint inputpoint), lock_inference, inputpoint) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * + * @param inputpoint read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @param inputpoint2 read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#lock_inference-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD( + Sketchup::View, lock_inference, (Sketchup::InputPoint inputpoint, Sketchup::InputPoint inputpoint2), lock_inference, inputpoint, inputpoint2) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#model-instance_method + * + * @return Sketchup::Model read https://ruby.sketchup.com/Sketchup/View.html#model-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(Sketchup::Model, model, model) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * + * @return Sketchup::PickHelper read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD_0(Sketchup::PickHelper, pick_helper, pick_helper) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @param aperture read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @return Sketchup::PickHelper read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::PickHelper, pick_helper, (long long x, long long y, long long aperture), pick_helper, x, y, aperture) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @param aperture read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @return Sketchup::PickHelper read https://ruby.sketchup.com/Sketchup/View.html#pick_helper-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::PickHelper, pick_helper, (double x, double y, double aperture), pick_helper, x, y, aperture) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * + * @param screen_point read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD(RubyUtils::tuple, pickray, (RubyUtils::tuple screen_point), pickray, screen_point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(RubyUtils::tuple, pickray, (double x, double y), pickray, x, y) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * + * @param pixels read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * @param point read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * @return double read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(double, pixels_to_model, (double pixels, Geom::Point3d point), pixels_to_model, pixels, point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#refresh-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#refresh-instance_method + * @min_version SketchUp 7.1 + */ + DEFINE_WRAPPED_METHOD_0(Sketchup::View, refresh, refresh) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method + * + * @param texture_id read https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD(bool, release_texture, (long long texture_id), release_texture, texture_id) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method + * + * @param observer read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(bool, remove_observer, (RubyUtils::details::IObject observer), remove_observer, observer) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method + * + * @param model_point read https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method + * @return Geom::Point3d read https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Geom::Point3d, screen_coords, (Geom::Point3d model_point), screen_coords, model_point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * + * @param point1 read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * @param point2 read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, set_color_from_line, (Geom::Point3d point1, Geom::Point3d point2), set_color_from_line, point1, point2) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method + * + * @param delay read https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, show_frame, (double delay), show_frame, delay) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * + * @param point read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @param text read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @param options read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @return Geom::Bounds2d read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @min_version SketchUp 2020.0 + */ + DEFINE_WRAPPED_METHOD(Geom::Bounds2d, text_bounds, (Geom::Point3d point, std::string text, DrawTextOptions options), text_bounds, point, text, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method + * + * @param string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method + * @return std::string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(std::string, set_tooltip, (std::string string), tooltip=, string) + +#if SKETCHUP_VERSION >= 2025 + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD_0(double, vpheight, vpheight) +#else + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(long long, vpheight, vpheight) +#endif + +#if SKETCHUP_VERSION >= 2025 + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD_0(double, vpwidth, vpwidth) +#else + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(long long, vpwidth, vpwidth) +#endif + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * + * @param filename read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param width read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param height read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param antialias read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param compression read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD(bool, write_image, (std::string filename, long long width, long long height, bool antialias = false, double compression = 0.0), write_image, filename, width, height, antialias, compression) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * + * @param options read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @min_version SketchUp 7SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(bool, write_image, (WriteImage1Options options), write_image, options) + DEFINE_WRAPPED_METHOD(bool, write_image, (WriteImage2Options options), write_image, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method + * + * @param zoom_or_ents read https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, zoom, (RubyUtils::any_of> zoom_or_ents), zoom, zoom_or_ents) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#zoom_extents-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#zoom_extents-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD_0(Sketchup::View, zoom_extents, zoom_extents) +}; diff --git a/hostapp/view_options.hpp b/hostapp/view_options.hpp new file mode 100644 index 0000000..e5f2973 --- /dev/null +++ b/hostapp/view_options.hpp @@ -0,0 +1,71 @@ +#pragma once +#include "../ruby/utils.hpp" +#include "../cpp/utils.hpp" + +class DrawOptionSet : public cpp_utils::DummyClass +{ +public: + using normals = RubyUtils::Key<"normals", RubyUtils::Enumerable>; + using texture = RubyUtils::Key<"texture", int>; + using uvs = RubyUtils::Key<"uvs", RubyUtils::Enumerable>; +}; + +class Draw2dOptionSet : public cpp_utils::DummyClass +{ +public: + using texture = RubyUtils::Key<"texture", int>; + using uvs = RubyUtils::Key<"uvs", RubyUtils::Enumerable>; +}; + +class DrawTextOptionSet : public cpp_utils::DummyClass +{ +public: + /* + :font (String) — The name of the font to use. If it does not exist on the system, a default font will be used instead. + :size (Integer) — Legacy: The size of the font in system-dependent units. On Windows this is in points, on Mac it's in pixels. + :pixel_size (Integer) — Added SketchUp 2025.0: The size of the font in pixels. + :point_size (Integer) — Added SketchUp 2025.0: The size of the font in points. + :bold (Boolean) — Controls the Bold property of the font. + :italic (Boolean) — Controls the Italic property of the font. + :color (Sketchup::Color) — The color to draw the text with. + :align (Integer) — The text alignment, one of the following constants: TextAlignLeft, TextAlignCenter or TextAlignRight. + :vertical_align (Integer) — Added SketchUp 2020.0. The vertical text alignment, one of the following constants: TextVerticalAlignBoundsTop, TextVerticalAlignBaseline, TextVerticalAlignCapHeight or TextVerticalAlignCenter. Note that some fonts on Mac might not align as expected due to the system reporting incorrect font metrics. + */ + using font = RubyUtils::Key<"font", std::string>; + using size = RubyUtils::Key<"size", int>; + using pixel_size = RubyUtils::Key<"pixel_size", int>; + using point_size = RubyUtils::Key<"point_size", int>; + using bold = RubyUtils::Key<"bold", bool>; + using italic = RubyUtils::Key<"italic", bool>; + using color = RubyUtils::Key<"color", Sketchup::Color>; + using align = RubyUtils::Key<"align", int>; + using vertical_align = RubyUtils::Key<"vertical_align", int>; +}; + +class WriteImageOptionSet : public cpp_utils::DummyClass +{ +public: + /* + filename (String) — The filename for the saved image. + width (Integer) — default: #vpwidth — Width in pixels (max 16000). + height (Integer) — default: #vpheight — Height in pixels (max 16000). + scale_factor (Float) — default: 1.0 — Scaling factor for elements that are viewport dependent, such as text heights, arrow heads, line widths, stipple patterns, etc. (Added in SketchUp 2019.2) + antialias (Boolean) — default: false + compression (Float) — default: 1.0 — Compression factor for JPEG, images between 0.0 and 1.0. + transparent (Boolean) — default: false — Added in SketchUp 8. + */ + using filename = RubyUtils::Key<"filename", std::string>; + using width = RubyUtils::Key<"width", int>; + using height = RubyUtils::Key<"height", int>; + using scale_factor = RubyUtils::Key<"scale_factor", double>; + using antialias = RubyUtils::Key<"antialias", bool>; + using compression = RubyUtils::Key<"compression", double>; + using transparent = RubyUtils::Key<"transparent", bool>; + + /* + filename (String) — The filename for the saved image. + source (Boolean) — default: :image — Set to :framebuffer to dump the current framebuffer. + compression (Float) — default: 1.0 — Compression factor for JPEG, images between 0.0 and 1.0. + */ + using source = RubyUtils::Key<"source", bool>; +}; diff --git a/ruby/utils/hash.hpp b/ruby/utils/hash.hpp index 18668ee..2ef0c06 100644 --- a/ruby/utils/hash.hpp +++ b/ruby/utils/hash.hpp @@ -2,6 +2,8 @@ #include "../../cpp/utils/string_literal.hpp" #include +#include +using namespace std::literals::string_view_literals; namespace RubyUtils { @@ -23,13 +25,13 @@ namespace RubyUtils { if (((Ts::key() == key) || ...)) { - rb_hash_aset(value, rb_intern_const(key.data()), RubyUtils::details::IObject::cpp_to_ruby(val)); + rb_hash_aset(value, ID2SYM(rb_intern(key.data())), RubyUtils::details::IObject::cpp_to_ruby(val)); } } template inline void copy_if_exists(VALUE from) noexcept { - ID ruby_key = rb_intern_const(key::key().data()); + ID ruby_key = ID2SYM(rb_intern(key::key().data())); VALUE val = rb_hash_aref(from, ID2SYM(ruby_key)); if (val != Qnil) { @@ -79,7 +81,7 @@ namespace RubyUtils requires(((key.to_sv() == Ts::key()) || ...)) inline Hash& _set(typename key_type::type new_value, std::index_sequence) { - rb_hash_aset(value, rb_intern_const(key.to_sv().data()), IObject::cpp_to_ruby(new_value)); + rb_hash_aset(value, ID2SYM(rb_intern(key.to_sv().data())), IObject::cpp_to_ruby(new_value)); return *this; } From 9e92e4f3b8024a2b6350120edf4cdd3720f6cd99 Mon Sep 17 00:00:00 2001 From: Alex Tsvetanov Date: Wed, 28 May 2025 19:42:33 +0300 Subject: [PATCH 2/7] Update dummy_objects.hpp --- hostapp/dummy_objects.hpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/hostapp/dummy_objects.hpp b/hostapp/dummy_objects.hpp index 3e26212..9ec3999 100644 --- a/hostapp/dummy_objects.hpp +++ b/hostapp/dummy_objects.hpp @@ -121,17 +121,6 @@ class ComponentDefinition : public RubyUtils::details::IObject, public RubyUtils } }; -// class View : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::View"> -// { -// public: -// inline View(VALUE obj) : IObject(obj) -// { -// } -// inline View(const IObject& obj) : IObject(obj) -// { -// } -// }; - class Text : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::Text"> { public: From e2b6186810fb472f3da94372b948a4210140c9d0 Mon Sep 17 00:00:00 2001 From: Alex Tsvetanov Date: Wed, 28 May 2025 19:48:54 +0300 Subject: [PATCH 3/7] Add constructor for the view --- hostapp/view.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hostapp/view.hpp b/hostapp/view.hpp index 043c560..7fa603f 100644 --- a/hostapp/view.hpp +++ b/hostapp/view.hpp @@ -53,6 +53,10 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name WriteImageOptionSet::compression >; + inline View(VALUE arg) : IObject(arg) + { + } + /** * @brief https://ruby.sketchup.com/Sketchup/View.html#add_observer-instance_method * From 175225b4c57ace11b9e6986fbc5ff393a855fb54 Mon Sep 17 00:00:00 2001 From: Alex Tsvetanov Date: Thu, 29 May 2025 15:44:13 +0300 Subject: [PATCH 4/7] Update hash.hpp --- ruby/utils/hash.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ruby/utils/hash.hpp b/ruby/utils/hash.hpp index 2ef0c06..13545ab 100644 --- a/ruby/utils/hash.hpp +++ b/ruby/utils/hash.hpp @@ -31,8 +31,8 @@ namespace RubyUtils template inline void copy_if_exists(VALUE from) noexcept { - ID ruby_key = ID2SYM(rb_intern(key::key().data())); - VALUE val = rb_hash_aref(from, ID2SYM(ruby_key)); + VALUE ruby_key = ID2SYM(rb_intern(key::key().data())); + VALUE val = rb_hash_aref(from, ruby_key); if (val != Qnil) { rb_hash_aset(value, ruby_key, val); From f75447a6e1391194ef00dfefb79b938c1bfdc50d Mon Sep 17 00:00:00 2001 From: Alex Tsvetanov Date: Thu, 29 May 2025 18:37:36 +0300 Subject: [PATCH 5/7] Fix view ifdefs and fomatting --- hostapp/view.cc | 16 +- hostapp/view.hpp | 412 +++++++++++++++++++++++------------------------ 2 files changed, 216 insertions(+), 212 deletions(-) diff --git a/hostapp/view.cc b/hostapp/view.cc index 8ff5a45..4b855c9 100644 --- a/hostapp/view.cc +++ b/hostapp/view.cc @@ -509,14 +509,15 @@ namespace HostApp */ IMPLEMENT_WRAPPED_METHOD(Sketchup::View, std::string, set_tooltip, (std::string string), tooltip=, string) +#if SKETCHUP_VERSION >= 2025 /** * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method * * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method - * @min_version SketchUp 2025.0SketchUp 6.0 + * @min_version SketchUp 2025.0 */ - //IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, double, vpheight, vpheight) - + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, double, vpheight, vpheight) +#else /** * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method * @@ -524,15 +525,17 @@ namespace HostApp * @min_version SketchUp 6.0 */ IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, long long, vpheight, vpheight) +#endif +#if SKETCHUP_VERSION >= 2025 /** * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method * * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method - * @min_version SketchUp 2025.0SketchUp 6.0 + * @min_version SketchUp 2025.0 */ - //IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, double, vpwidth, vpwidth) - + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, double, vpwidth, vpwidth) +#else /** * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method * @@ -540,6 +543,7 @@ namespace HostApp * @min_version SketchUp 6.0 */ IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, long long, vpwidth, vpwidth) +#endif /** * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method diff --git a/hostapp/view.hpp b/hostapp/view.hpp index 7fa603f..1d2d479 100644 --- a/hostapp/view.hpp +++ b/hostapp/view.hpp @@ -6,52 +6,52 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::View"> { public: - static constexpr int TextAlignLeft = 0; - static constexpr int TextAlignRight = 2; - static constexpr int TextAlignCenter = 1; - static constexpr int TextVerticalAlignBoundsTop = 0; - static constexpr int TextVerticalAlignBaseline = 1; - static constexpr int TextVerticalAlignCapHeight = 2; - static constexpr int TextVerticalAlignCenter = 3; - - using DrawOptions = RubyUtils::Hash< - DrawOptionSet::normals, - DrawOptionSet::texture, - DrawOptionSet::uvs - >; - - using Draw2dOptions = RubyUtils::Hash< - Draw2dOptionSet::texture, - Draw2dOptionSet::uvs - >; - - using DrawTextOptions = RubyUtils::Hash< - DrawTextOptionSet::font, - DrawTextOptionSet::size, - DrawTextOptionSet::pixel_size, - DrawTextOptionSet::point_size, - DrawTextOptionSet::bold, - DrawTextOptionSet::italic, - DrawTextOptionSet::color, - DrawTextOptionSet::align, - DrawTextOptionSet::vertical_align - >; - - using WriteImage1Options = RubyUtils::Hash< - WriteImageOptionSet::filename, - WriteImageOptionSet::width, - WriteImageOptionSet::height, - WriteImageOptionSet::scale_factor, - WriteImageOptionSet::antialias, - WriteImageOptionSet::compression, - WriteImageOptionSet::transparent - >; - - using WriteImage2Options = RubyUtils::Hash< - WriteImageOptionSet::filename, - WriteImageOptionSet::source, - WriteImageOptionSet::compression - >; + static constexpr int TextAlignLeft = 0; + static constexpr int TextAlignRight = 2; + static constexpr int TextAlignCenter = 1; + static constexpr int TextVerticalAlignBoundsTop = 0; + static constexpr int TextVerticalAlignBaseline = 1; + static constexpr int TextVerticalAlignCapHeight = 2; + static constexpr int TextVerticalAlignCenter = 3; + + using DrawOptions = RubyUtils::Hash< + DrawOptionSet::normals, + DrawOptionSet::texture, + DrawOptionSet::uvs + >; + + using Draw2dOptions = RubyUtils::Hash< + Draw2dOptionSet::texture, + Draw2dOptionSet::uvs + >; + + using DrawTextOptions = RubyUtils::Hash< + DrawTextOptionSet::font, + DrawTextOptionSet::size, + DrawTextOptionSet::pixel_size, + DrawTextOptionSet::point_size, + DrawTextOptionSet::bold, + DrawTextOptionSet::italic, + DrawTextOptionSet::color, + DrawTextOptionSet::align, + DrawTextOptionSet::vertical_align + >; + + using WriteImage1Options = RubyUtils::Hash< + WriteImageOptionSet::filename, + WriteImageOptionSet::width, + WriteImageOptionSet::height, + WriteImageOptionSet::scale_factor, + WriteImageOptionSet::antialias, + WriteImageOptionSet::compression, + WriteImageOptionSet::transparent + >; + + using WriteImage2Options = RubyUtils::Hash< + WriteImageOptionSet::filename, + WriteImageOptionSet::source, + WriteImageOptionSet::compression + >; inline View(VALUE arg) : IObject(arg) { @@ -481,173 +481,173 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name */ DEFINE_WRAPPED_METHOD(RubyUtils::tuple, pickray, (RubyUtils::tuple screen_point), pickray, screen_point) - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method - * - * @param x read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method - * @param y read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method - * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method - * @min_version SketchUp 2025.0SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD(RubyUtils::tuple, pickray, (double x, double y), pickray, x, y) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method - * - * @param pixels read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method - * @param point read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method - * @return double read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method - * @min_version SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD(double, pixels_to_model, (double pixels, Geom::Point3d point), pixels_to_model, pixels, point) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#refresh-instance_method - * - * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#refresh-instance_method - * @min_version SketchUp 7.1 - */ - DEFINE_WRAPPED_METHOD_0(Sketchup::View, refresh, refresh) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method - * - * @param texture_id read https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method - * @return bool read https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method - * @min_version - */ - DEFINE_WRAPPED_METHOD(bool, release_texture, (long long texture_id), release_texture, texture_id) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method - * - * @param observer read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method - * @return bool read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method - * @min_version SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD(bool, remove_observer, (RubyUtils::details::IObject observer), remove_observer, observer) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method - * - * @param model_point read https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method - * @return Geom::Point3d read https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method - * @min_version SketchUp 2025.0SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD(Geom::Point3d, screen_coords, (Geom::Point3d model_point), screen_coords, model_point) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method - * - * @param point1 read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method - * @param point2 read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method - * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method - * @min_version SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD(Sketchup::View, set_color_from_line, (Geom::Point3d point1, Geom::Point3d point2), set_color_from_line, point1, point2) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method - * - * @param delay read https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method - * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method - * @min_version SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD(Sketchup::View, show_frame, (double delay), show_frame, delay) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method - * - * @param point read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method - * @param text read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method - * @param options read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method - * @return Geom::Bounds2d read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method - * @min_version SketchUp 2020.0 - */ - DEFINE_WRAPPED_METHOD(Geom::Bounds2d, text_bounds, (Geom::Point3d point, std::string text, DrawTextOptions options), text_bounds, point, text, options) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method - * - * @param string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method - * @return std::string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method - * @min_version SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD(std::string, set_tooltip, (std::string string), tooltip=, string) + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * + * @param x read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @param y read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @return RubyUtils::tuple read https://ruby.sketchup.com/Sketchup/View.html#pickray-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(RubyUtils::tuple, pickray, (double x, double y), pickray, x, y) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * + * @param pixels read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * @param point read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * @return double read https://ruby.sketchup.com/Sketchup/View.html#pixels_to_model-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(double, pixels_to_model, (double pixels, Geom::Point3d point), pixels_to_model, pixels, point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#refresh-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#refresh-instance_method + * @min_version SketchUp 7.1 + */ + DEFINE_WRAPPED_METHOD_0(Sketchup::View, refresh, refresh) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method + * + * @param texture_id read https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#release_texture-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD(bool, release_texture, (long long texture_id), release_texture, texture_id) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method + * + * @param observer read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(bool, remove_observer, (RubyUtils::details::IObject observer), remove_observer, observer) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method + * + * @param model_point read https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method + * @return Geom::Point3d read https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method + * @min_version SketchUp 2025.0SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Geom::Point3d, screen_coords, (Geom::Point3d model_point), screen_coords, model_point) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * + * @param point1 read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * @param point2 read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#set_color_from_line-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, set_color_from_line, (Geom::Point3d point1, Geom::Point3d point2), set_color_from_line, point1, point2) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method + * + * @param delay read https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#show_frame-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, show_frame, (double delay), show_frame, delay) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * + * @param point read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @param text read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @param options read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @return Geom::Bounds2d read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method + * @min_version SketchUp 2020.0 + */ + DEFINE_WRAPPED_METHOD(Geom::Bounds2d, text_bounds, (Geom::Point3d point, std::string text, DrawTextOptions options), text_bounds, point, text, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method + * + * @param string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method + * @return std::string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(std::string, set_tooltip, (std::string string), tooltip=, string) #if SKETCHUP_VERSION >= 2025 - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method - * - * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method - * @min_version SketchUp 2025.0 - */ - DEFINE_WRAPPED_METHOD_0(double, vpheight, vpheight) + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD_0(double, vpheight, vpheight) #else - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method - * - * @return long long read https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method - * @min_version SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD_0(long long, vpheight, vpheight) + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#vpheight-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(long long, vpheight, vpheight) #endif #if SKETCHUP_VERSION >= 2025 - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method - * - * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method - * @min_version SketchUp 2025.0 - */ - DEFINE_WRAPPED_METHOD_0(double, vpwidth, vpwidth) + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * + * @return double read https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * @min_version SketchUp 2025.0 + */ + DEFINE_WRAPPED_METHOD_0(double, vpwidth, vpwidth) #else - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method - * - * @return long long read https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method - * @min_version SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD_0(long long, vpwidth, vpwidth) + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * + * @return long long read https://ruby.sketchup.com/Sketchup/View.html#vpwidth-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD_0(long long, vpwidth, vpwidth) #endif - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * - * @param filename read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * @param width read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * @param height read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * @param antialias read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * @param compression read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * @min_version - */ - DEFINE_WRAPPED_METHOD(bool, write_image, (std::string filename, long long width, long long height, bool antialias = false, double compression = 0.0), write_image, filename, width, height, antialias, compression) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * - * @param options read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method - * @min_version SketchUp 7SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD(bool, write_image, (WriteImage1Options options), write_image, options) - DEFINE_WRAPPED_METHOD(bool, write_image, (WriteImage2Options options), write_image, options) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method - * - * @param zoom_or_ents read https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method - * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method - * @min_version SketchUp 6.0 - */ - DEFINE_WRAPPED_METHOD(Sketchup::View, zoom, (RubyUtils::any_of> zoom_or_ents), zoom, zoom_or_ents) - - /** - * @brief https://ruby.sketchup.com/Sketchup/View.html#zoom_extents-instance_method - * - * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#zoom_extents-instance_method - * @min_version - */ - DEFINE_WRAPPED_METHOD_0(Sketchup::View, zoom_extents, zoom_extents) + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * + * @param filename read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param width read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param height read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param antialias read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @param compression read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD(bool, write_image, (std::string filename, long long width, long long height, bool antialias = false, double compression = 0.0), write_image, filename, width, height, antialias, compression) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * + * @param options read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method + * @min_version SketchUp 7SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(bool, write_image, (WriteImage1Options options), write_image, options) + DEFINE_WRAPPED_METHOD(bool, write_image, (WriteImage2Options options), write_image, options) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method + * + * @param zoom_or_ents read https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#zoom-instance_method + * @min_version SketchUp 6.0 + */ + DEFINE_WRAPPED_METHOD(Sketchup::View, zoom, (RubyUtils::any_of> zoom_or_ents), zoom, zoom_or_ents) + + /** + * @brief https://ruby.sketchup.com/Sketchup/View.html#zoom_extents-instance_method + * + * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#zoom_extents-instance_method + * @min_version + */ + DEFINE_WRAPPED_METHOD_0(Sketchup::View, zoom_extents, zoom_extents) }; From 4aae44cea8e7e1ee84402ff5e3d4d8bc78b9c774 Mon Sep 17 00:00:00 2001 From: Alex Tsvetanov Date: Fri, 30 May 2025 17:34:37 +0300 Subject: [PATCH 6/7] Fix comments --- hostapp/dummy_objects.hpp | 11 ++++ hostapp/view.cc | 24 +++---- hostapp/view.hpp | 130 +++++++++++++++++++++----------------- 3 files changed, 95 insertions(+), 70 deletions(-) diff --git a/hostapp/dummy_objects.hpp b/hostapp/dummy_objects.hpp index 9ec3999..d81db8f 100644 --- a/hostapp/dummy_objects.hpp +++ b/hostapp/dummy_objects.hpp @@ -1,5 +1,16 @@ #pragma once +class ViewObserver : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::ViewObserver"> +{ + public: + inline ViewObserver(VALUE obj) : IObject(obj) + { + } + inline ViewObserver(const IObject& obj) : IObject(obj) + { + } +}; + class PickHelper : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::PickHelper"> { public: diff --git a/hostapp/view.cc b/hostapp/view.cc index 4b855c9..aadeba7 100644 --- a/hostapp/view.cc +++ b/hostapp/view.cc @@ -7,7 +7,7 @@ namespace HostApp * @return bool read https://ruby.sketchup.com/Sketchup/View.html#add_observer-instance_method * @min_version SketchUp 6.0 */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, add_observer, (RubyUtils::details::IObject observer), add_observer, observer) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, add_observer, (Sketchup::ViewObserver observer), add_observer, observer) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#animation=-instance_method @@ -114,7 +114,7 @@ namespace HostApp * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method * @min_version */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw, (long long openglenum, RubyUtils::Enumerable points), draw, openglenum, points) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw, (Sketchup::View::GLOptions openglenum, RubyUtils::Enumerable points), draw, static_cast(openglenum), points) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method @@ -125,7 +125,7 @@ namespace HostApp * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method * @min_version SketchUp 2020.0 */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw, (long long openglenum, RubyUtils::Enumerable points, DrawOptions options), draw, openglenum, points, options) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw, (Sketchup::View::GLOptions openglenum, RubyUtils::Enumerable points, DrawOptions options), draw, static_cast(openglenum), points, options) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method @@ -135,7 +135,7 @@ namespace HostApp * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method * @min_version */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw2d, (long long openglenum, RubyUtils::Enumerable points), draw2d, openglenum, points) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw2d, (Sketchup::View::GLOptions openglenum, RubyUtils::Enumerable points), draw2d, static_cast(openglenum), points) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method @@ -146,7 +146,7 @@ namespace HostApp * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method * @min_version SketchUp 2020.0 */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw2d, (long long openglenum, RubyUtils::Enumerable points, Draw2dOptions options), draw2d, openglenum, points, options) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw2d, (Sketchup::View::GLOptions openglenum, RubyUtils::Enumerable points, Draw2dOptions options), draw2d, static_cast(openglenum), points, options) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_lines-instance_method @@ -186,7 +186,7 @@ namespace HostApp * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method * @min_version SketchUp 6.0 */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw_text, (Geom::Point3d point, std::string text), draw_text, point, text) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw_text, (Geom::Point3d point, const std::string& text), draw_text, point, text) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method @@ -198,7 +198,7 @@ namespace HostApp * @min_version SketchUp 2016 * @note Known Bugs: Prior to SU2022.0, on macOS, the vertical text alignment for some fonts could appear to be offset from their expected positions. As of SU2022.0 the vertical alignment should be more accurate and consistent. */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw_text, (Geom::Point3d point, std::string text, DrawTextOptions options), draw_text, point, text, options) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, draw_text, (Geom::Point3d point, const std::string& text, DrawTextOptions options), draw_text, point, text, options) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method @@ -321,7 +321,7 @@ namespace HostApp * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#line_stipple=-instance_method * @min_version SketchUp 6.0 */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, set_line_stipple, (std::string pattern), line_stipple=, pattern) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, set_line_stipple, (const std::string& pattern), line_stipple=, pattern) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#line_width=-instance_method @@ -459,7 +459,7 @@ namespace HostApp * @return bool read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method * @min_version SketchUp 6.0 */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, remove_observer, (RubyUtils::details::IObject observer), remove_observer, observer) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, remove_observer, (Sketchup::ViewObserver observer), remove_observer, observer) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method @@ -498,7 +498,7 @@ namespace HostApp * @return Geom::Bounds2d read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method * @min_version SketchUp 2020.0 */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Geom::Bounds2d, text_bounds, (Geom::Point3d point, std::string text, DrawTextOptions options), text_bounds, point, text, options) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Geom::Bounds2d, text_bounds, (Geom::Point3d point, const std::string& text, DrawTextOptions options), text_bounds, point, text, options) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method @@ -507,7 +507,7 @@ namespace HostApp * @return std::string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method * @min_version SketchUp 6.0 */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, std::string, set_tooltip, (std::string string), tooltip=, string) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, std::string, set_tooltip, (const std::string& string), tooltip=, string) #if SKETCHUP_VERSION >= 2025 /** @@ -556,7 +556,7 @@ namespace HostApp * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method * @min_version */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, write_image, (std::string filename, long long width, long long height, bool antialias, double compression), write_image, filename, width, height, antialias, compression) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, bool, write_image, (const std::string& filename, long long width, long long height, bool antialias, double compression), write_image, filename, width, height, antialias, compression) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method diff --git a/hostapp/view.hpp b/hostapp/view.hpp index 1d2d479..ee4d460 100644 --- a/hostapp/view.hpp +++ b/hostapp/view.hpp @@ -6,52 +6,66 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::NamedRubyWrapper<"Sketchup::View"> { public: - static constexpr int TextAlignLeft = 0; - static constexpr int TextAlignRight = 2; - static constexpr int TextAlignCenter = 1; - static constexpr int TextVerticalAlignBoundsTop = 0; - static constexpr int TextVerticalAlignBaseline = 1; - static constexpr int TextVerticalAlignCapHeight = 2; - static constexpr int TextVerticalAlignCenter = 3; - - using DrawOptions = RubyUtils::Hash< - DrawOptionSet::normals, - DrawOptionSet::texture, - DrawOptionSet::uvs - >; - - using Draw2dOptions = RubyUtils::Hash< - Draw2dOptionSet::texture, - Draw2dOptionSet::uvs - >; - - using DrawTextOptions = RubyUtils::Hash< - DrawTextOptionSet::font, - DrawTextOptionSet::size, - DrawTextOptionSet::pixel_size, - DrawTextOptionSet::point_size, - DrawTextOptionSet::bold, - DrawTextOptionSet::italic, - DrawTextOptionSet::color, - DrawTextOptionSet::align, - DrawTextOptionSet::vertical_align - >; - - using WriteImage1Options = RubyUtils::Hash< - WriteImageOptionSet::filename, - WriteImageOptionSet::width, - WriteImageOptionSet::height, - WriteImageOptionSet::scale_factor, - WriteImageOptionSet::antialias, - WriteImageOptionSet::compression, - WriteImageOptionSet::transparent - >; - - using WriteImage2Options = RubyUtils::Hash< - WriteImageOptionSet::filename, - WriteImageOptionSet::source, - WriteImageOptionSet::compression - >; + static constexpr int TextAlignLeft = 0; + static constexpr int TextAlignRight = 2; + static constexpr int TextAlignCenter = 1; + static constexpr int TextVerticalAlignBoundsTop = 0; + static constexpr int TextVerticalAlignBaseline = 1; + static constexpr int TextVerticalAlignCapHeight = 2; + static constexpr int TextVerticalAlignCenter = 3; + + enum GLOptions : long long + { + GL_POINTS = 0, + GL_LINES = 1, + GL_LINE_STRIP = 3, + GL_LINE_LOOP = 2, + GL_TRIANGLES = 4, + GL_TRIANGLE_STRIP = 5, + GL_TRIANGLE_FAN = 6, + GL_QUADS = 7, + GL_QUAD_STRIP = 8, + GL_POLYGON = 9 + }; + + using DrawOptions = RubyUtils::Hash< + DrawOptionSet::normals, + DrawOptionSet::texture, + DrawOptionSet::uvs + >; + + using Draw2dOptions = RubyUtils::Hash< + Draw2dOptionSet::texture, + Draw2dOptionSet::uvs + >; + + using DrawTextOptions = RubyUtils::Hash< + DrawTextOptionSet::font, + DrawTextOptionSet::size, + DrawTextOptionSet::pixel_size, + DrawTextOptionSet::point_size, + DrawTextOptionSet::bold, + DrawTextOptionSet::italic, + DrawTextOptionSet::color, + DrawTextOptionSet::align, + DrawTextOptionSet::vertical_align + >; + + using WriteImage1Options = RubyUtils::Hash< + WriteImageOptionSet::filename, + WriteImageOptionSet::width, + WriteImageOptionSet::height, + WriteImageOptionSet::scale_factor, + WriteImageOptionSet::antialias, + WriteImageOptionSet::compression, + WriteImageOptionSet::transparent + >; + + using WriteImage2Options = RubyUtils::Hash< + WriteImageOptionSet::filename, + WriteImageOptionSet::source, + WriteImageOptionSet::compression + >; inline View(VALUE arg) : IObject(arg) { @@ -64,7 +78,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return bool read https://ruby.sketchup.com/Sketchup/View.html#add_observer-instance_method * @min_version SketchUp 6.0 */ - DEFINE_WRAPPED_METHOD(bool, add_observer, (RubyUtils::details::IObject observer), add_observer, observer) + DEFINE_WRAPPED_METHOD(bool, add_observer, (Sketchup::ViewObserver observer), add_observer, observer) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#animation=-instance_method @@ -171,7 +185,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method * @min_version */ - DEFINE_WRAPPED_METHOD(Sketchup::View, draw, (long long openglenum, RubyUtils::Enumerable points), draw, openglenum, points) + DEFINE_WRAPPED_METHOD(Sketchup::View, draw, (GLOptions openglenum, RubyUtils::Enumerable points), draw, static_cast(openglnum), points) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method @@ -182,7 +196,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method * @min_version SketchUp 2020.0 */ - DEFINE_WRAPPED_METHOD(Sketchup::View, draw, (long long openglenum, RubyUtils::Enumerable points, DrawOptions options), draw, openglenum, points, options) + DEFINE_WRAPPED_METHOD(Sketchup::View, draw, (GLOptions openglenum, RubyUtils::Enumerable points, DrawOptions options), draw, static_cast(openglnum), points, options) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method @@ -192,7 +206,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method * @min_version */ - DEFINE_WRAPPED_METHOD(Sketchup::View, draw2d, (long long openglenum, RubyUtils::Enumerable points), draw2d, openglenum, points) + DEFINE_WRAPPED_METHOD(Sketchup::View, draw2d, (GLOptions openglenum, RubyUtils::Enumerable points), draw2d, static_cast(openglnum), points) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method @@ -203,7 +217,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method * @min_version SketchUp 2020.0 */ - DEFINE_WRAPPED_METHOD(Sketchup::View, draw2d, (long long openglenum, RubyUtils::Enumerable points, Draw2dOptions options), draw2d, openglenum, points, options) + DEFINE_WRAPPED_METHOD(Sketchup::View, draw2d, (GLOptions openglenum, RubyUtils::Enumerable points, Draw2dOptions options), draw2d, static_cast(openglnum), points, options) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_lines-instance_method @@ -251,7 +265,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method * @min_version */ - DEFINE_WRAPPED_METHOD(Sketchup::View, draw_text, (Geom::Point3d point, std::string text), draw_text, point, text) + DEFINE_WRAPPED_METHOD(Sketchup::View, draw_text, (Geom::Point3d point, const std::string& text), draw_text, point, text) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#draw_text-instance_method @@ -263,7 +277,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @min_version SketchUp 2016SketchUp 6.0Known Bugs:Prior to SU2022.0, on macOS, the vertical text alignment for some fonts could appear to be offset from * their expected positions. As of SU2022.0 the vertical alignment should be more accurate and consistent. */ - DEFINE_WRAPPED_METHOD(Sketchup::View, draw_text, (Geom::Point3d point, std::string text, DrawTextOptions options), draw_text, point, text, options) + DEFINE_WRAPPED_METHOD(Sketchup::View, draw_text, (Geom::Point3d point, const std::string& text, DrawTextOptions options), draw_text, point, text, options) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method @@ -386,7 +400,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#line_stipple=-instance_method * @min_version SketchUp 6.0 */ - DEFINE_WRAPPED_METHOD(Sketchup::View, set_line_stipple, (std::string pattern), line_stipple=, pattern) + DEFINE_WRAPPED_METHOD(Sketchup::View, set_line_stipple, (const std::string& pattern), line_stipple=, pattern) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#line_width=-instance_method @@ -525,7 +539,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return bool read https://ruby.sketchup.com/Sketchup/View.html#remove_observer-instance_method * @min_version SketchUp 6.0 */ - DEFINE_WRAPPED_METHOD(bool, remove_observer, (RubyUtils::details::IObject observer), remove_observer, observer) + DEFINE_WRAPPED_METHOD(bool, remove_observer, (Sketchup::ViewObserver observer), remove_observer, observer) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#screen_coords-instance_method @@ -564,7 +578,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return Geom::Bounds2d read https://ruby.sketchup.com/Sketchup/View.html#text_bounds-instance_method * @min_version SketchUp 2020.0 */ - DEFINE_WRAPPED_METHOD(Geom::Bounds2d, text_bounds, (Geom::Point3d point, std::string text, DrawTextOptions options), text_bounds, point, text, options) + DEFINE_WRAPPED_METHOD(Geom::Bounds2d, text_bounds, (Geom::Point3d point, const std::string& text, DrawTextOptions options), text_bounds, point, text, options) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method @@ -573,7 +587,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return std::string read https://ruby.sketchup.com/Sketchup/View.html#tooltip=-instance_method * @min_version SketchUp 6.0 */ - DEFINE_WRAPPED_METHOD(std::string, set_tooltip, (std::string string), tooltip=, string) + DEFINE_WRAPPED_METHOD(std::string, set_tooltip, (const std::string& string), tooltip=, string) #if SKETCHUP_VERSION >= 2025 /** @@ -622,7 +636,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return bool read https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method * @min_version */ - DEFINE_WRAPPED_METHOD(bool, write_image, (std::string filename, long long width, long long height, bool antialias = false, double compression = 0.0), write_image, filename, width, height, antialias, compression) + DEFINE_WRAPPED_METHOD(bool, write_image, (const std::string& filename, long long width, long long height, bool antialias = false, double compression = 0.0), write_image, filename, width, height, antialias, compression) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#write_image-instance_method From 0cb9dd007c5a0062c8b892e74f5e6896a23b9097 Mon Sep 17 00:00:00 2001 From: Alex Tsvetanov Date: Mon, 2 Jun 2025 11:28:26 +0300 Subject: [PATCH 7/7] Fix color type-safety --- hostapp/view.cc | 2 +- hostapp/view.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hostapp/view.cc b/hostapp/view.cc index aadeba7..67676bd 100644 --- a/hostapp/view.cc +++ b/hostapp/view.cc @@ -207,7 +207,7 @@ namespace HostApp * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method * @min_version SketchUp 6.0 */ - IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, set_drawing_color, (RubyUtils::any_of color), drawing_color=, color) + IMPLEMENT_WRAPPED_METHOD(Sketchup::View, Sketchup::View, set_drawing_color, (Sketchup::Color color), drawing_color=, color) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#dynamic=-instance_method diff --git a/hostapp/view.hpp b/hostapp/view.hpp index ee4d460..41f3fcf 100644 --- a/hostapp/view.hpp +++ b/hostapp/view.hpp @@ -286,7 +286,7 @@ class View : public RubyUtils::details::IObject, public RubyUtils::details::Name * @return Sketchup::View read https://ruby.sketchup.com/Sketchup/View.html#drawing_color=-instance_method * @min_version SketchUp 6.0 */ - DEFINE_WRAPPED_METHOD(Sketchup::View, set_drawing_color, (RubyUtils::any_of color), drawing_color=, color) + DEFINE_WRAPPED_METHOD(Sketchup::View, set_drawing_color, (Sketchup::Color color), drawing_color=, color) /** * @brief https://ruby.sketchup.com/Sketchup/View.html#dynamic=-instance_method