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..d81db8f 100644 --- a/hostapp/dummy_objects.hpp +++ b/hostapp/dummy_objects.hpp @@ -1,5 +1,38 @@ #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: + 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,17 +132,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: 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..67676bd --- /dev/null +++ b/hostapp/view.cc @@ -0,0 +1,589 @@ +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, (Sketchup::ViewObserver 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, (Sketchup::View::GLOptions openglenum, RubyUtils::Enumerable points), draw, static_cast(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, (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 + * + * @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, (Sketchup::View::GLOptions openglenum, RubyUtils::Enumerable points), draw2d, static_cast(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, (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 + * + * @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, const 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, const 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, (Sketchup::Color 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, (const 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, (Sketchup::ViewObserver 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, const 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, (const 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 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, 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 + */ + 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.0 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, 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 + */ + IMPLEMENT_WRAPPED_METHOD_0(Sketchup::View, 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 + */ + 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 + * + * @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..41f3fcf --- /dev/null +++ b/hostapp/view.hpp @@ -0,0 +1,667 @@ +#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; + + 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) + { + } + + /** + * @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, (Sketchup::ViewObserver 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, (GLOptions openglenum, RubyUtils::Enumerable points), draw, static_cast(openglnum), 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, (GLOptions openglenum, RubyUtils::Enumerable points, DrawOptions options), draw, static_cast(openglnum), 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, (GLOptions openglenum, RubyUtils::Enumerable points), draw2d, static_cast(openglnum), 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, (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 + * + * @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, const 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, const 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, (Sketchup::Color 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, (const 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, (Sketchup::ViewObserver 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, const 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, (const 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, (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 + * + * @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..13545ab 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,14 +25,14 @@ 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()); - 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); @@ -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; }