diff options
Diffstat (limited to 'src/slic3r/GUI/3DBed.hpp')
-rw-r--r-- | src/slic3r/GUI/3DBed.hpp | 82 |
1 files changed, 31 insertions, 51 deletions
diff --git a/src/slic3r/GUI/3DBed.hpp b/src/slic3r/GUI/3DBed.hpp index 07b9f1758..639dc6c16 100644 --- a/src/slic3r/GUI/3DBed.hpp +++ b/src/slic3r/GUI/3DBed.hpp @@ -5,6 +5,8 @@ #include "3DScene.hpp" #include "GLModel.hpp" +#include <libslic3r/BuildVolume.hpp> + #include <tuple> #include <array> @@ -62,41 +64,22 @@ class Bed3D }; public: -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - enum class EType : unsigned char + enum class Type : unsigned char { + // The print bed model and texture are available from some printer preset. System, + // The print bed model is unknown, thus it is rendered procedurally. Custom }; - enum class EShapeType : unsigned char - { - Rectangle, - Circle, - Custom, - Invalid - }; -#else - enum EType : unsigned char - { - System, - Custom, - Num_Types - }; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - private: -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - EType m_type{ EType::Custom }; - EShapeType m_shape_type{ EShapeType::Invalid }; -#else - EType m_type{ Custom }; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - Pointfs m_shape; + BuildVolume m_build_volume; + Type m_type{ Type::Custom }; std::string m_texture_filename; std::string m_model_filename; - BoundingBoxf3 m_bounding_box; + // Print volume bounding box exteded with axes and model. BoundingBoxf3 m_extended_bounding_box; + // Slightly expanded print bed polygon, for collision detection. Polygon m_polygon; GeometryBuffer m_triangles; GeometryBuffer m_gridlines; @@ -112,42 +95,39 @@ private: public: Bed3D() = default; - ~Bed3D() { reset(); } - - EType get_type() const { return m_type; } -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - EShapeType get_shape_type() const { return m_shape_type; } - bool is_custom() const { return m_type == EType::Custom; } -#else - bool is_custom() const { return m_type == Custom; } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS + ~Bed3D() { release_VBOs(); } - const Pointfs& get_shape() const { return m_shape; } + // Update print bed model from configuration. // Return true if the bed shape changed, so the calee will update the UI. - bool set_shape(const Pointfs& shape, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom = false); + //FIXME if the build volume max print height is updated, this function still returns zero + // as this class does not use it, thus there is no need to update the UI. + bool set_shape(const Pointfs& bed_shape, const double max_print_height, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom = false); + + // Build volume geometry for various collision detection tasks. + const BuildVolume& build_volume() const { return m_build_volume; } - const BoundingBoxf3& get_bounding_box(bool extended) const { return extended ? m_extended_bounding_box : m_bounding_box; } + // Was the model provided, or was it generated procedurally? + Type get_type() const { return m_type; } + // Was the model generated procedurally? + bool is_custom() const { return m_type == Type::Custom; } + // Bounding box around the print bed, axes and model, for rendering. + const BoundingBoxf3& extended_bounding_box() const { return m_extended_bounding_box; } + + // Check against an expanded 2d bounding box. + //FIXME shall one check against the real build volume? bool contains(const Point& point) const; Point point_projection(const Point& point) const; - void render(GLCanvas3D& canvas, bool bottom, float scale_factor, - bool show_axes, bool show_texture); - + void render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture); void render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_factor); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - static bool is_rectangle(const Pointfs& shape, Vec2d* min = nullptr, Vec2d* max = nullptr); - static bool is_circle(const Pointfs& shape, Vec2d* center = nullptr, double* radius = nullptr); - static bool is_convex(const Pointfs& shape); - static EShapeType detect_shape_type(const Pointfs& shape); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - private: - void calc_bounding_boxes() const; + // Calculate an extended bounding box from axes and current model for visualization purposes. + BoundingBoxf3 calc_extended_bounding_box() const; void calc_triangles(const ExPolygon& poly); void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox); - std::tuple<EType, std::string, std::string> detect_type(const Pointfs& shape) const; + static std::tuple<Type, std::string, std::string> detect_type(const Pointfs& shape); void render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture, bool picking); void render_axes() const; @@ -156,7 +136,7 @@ private: void render_model() const; void render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking) const; void render_default(bool bottom, bool picking) const; - void reset(); + void release_VBOs(); }; } // GUI |