diff options
Diffstat (limited to 'xs/src/slic3r/GUI/GLCanvas3D.hpp')
-rw-r--r-- | xs/src/slic3r/GUI/GLCanvas3D.hpp | 100 |
1 files changed, 84 insertions, 16 deletions
diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index b0706a05d..f09bd4b20 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -162,7 +162,8 @@ public: bool is_custom() const; const Pointfs& get_shape() const; - void set_shape(const Pointfs& shape); + // Return true if the bed shape changed, so the calee will update the UI. + bool set_shape(const Pointfs& shape); const BoundingBoxf3& get_bounding_box() const; bool contains(const Point& point) const; @@ -225,6 +226,7 @@ public: void stop_using() const; void set_uniform(const std::string& name, float value) const; + void set_uniform(const std::string& name, const float* matrix) const; const GLShader* get_shader() const; @@ -302,7 +304,10 @@ public: Point start_position_2D; Pointf3 start_position_3D; Vectorf3 volume_center_offset; - int volume_idx; + + bool move_with_shift; + int move_volume_idx; + int gizmo_volume_idx; public: Drag(); @@ -323,6 +328,7 @@ public: class Gizmos { + static const float OverlayTexturesScale; static const float OverlayOffsetX; static const float OverlayGapY; @@ -332,8 +338,13 @@ public: Undefined, Scale, Rotate, + Flatten, Num_Types }; + enum RenderOrder : unsigned char { + BeforeBed, + AfterBed + }; private: bool m_enabled; @@ -360,16 +371,26 @@ public: bool overlay_contains_mouse(const GLCanvas3D& canvas, const Pointf& mouse_pos) const; bool grabber_contains_mouse() const; void update(const Pointf& mouse_pos); - void update_data(float scale); + void refresh(); + + EType get_current_type() const; bool is_running() const; + bool is_dragging() const; void start_dragging(); void stop_dragging(); float get_scale() const; + void set_scale(float scale); - void render(const GLCanvas3D& canvas, const BoundingBoxf3& box) const; + float get_angle_z() const; + void set_angle_z(float angle_z); + + void set_flattening_data(const ModelObject* model_object); + Pointf3 get_flattening_normal() const; + + void render(const GLCanvas3D& canvas, const BoundingBoxf3& box, RenderOrder render_order) const; void render_current_gizmo_for_picking_pass(const BoundingBoxf3& box) const; private: @@ -382,9 +403,35 @@ public: GLGizmoBase* _get_current() const; }; + class WarningTexture : public GUI::GLTexture + { + static const unsigned char Background_Color[3]; + static const unsigned char Opacity; + + public: + bool generate(const std::string& msg); + }; + + class LegendTexture : public GUI::GLTexture + { + static const int Px_Title_Offset = 5; + static const int Px_Text_Offset = 5; + static const int Px_Square = 20; + static const int Px_Square_Contour = 1; + static const int Px_Border = Px_Square / 2; + static const unsigned char Squares_Border_Color[3]; + static const unsigned char Background_Color[3]; + static const unsigned char Opacity; + + public: + bool generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors); + }; + private: wxGLCanvas* m_canvas; wxGLContext* m_context; + LegendTexture m_legend_texture; + WarningTexture m_warning_texture; wxTimer* m_timer; Camera m_camera; Bed m_bed; @@ -411,6 +458,7 @@ private: bool m_picking_enabled; bool m_moving_enabled; bool m_shader_enabled; + bool m_dynamic_background_enabled; bool m_multisample_allowed; std::string m_color_by; @@ -439,6 +487,8 @@ private: PerlCallback m_on_wipe_tower_moved_callback; PerlCallback m_on_enable_action_buttons_callback; PerlCallback m_on_gizmo_scale_uniformly_callback; + PerlCallback m_on_gizmo_rotate_callback; + PerlCallback m_on_update_geometry_info_callback; public: GLCanvas3D(wxGLCanvas* canvas); @@ -455,7 +505,7 @@ public: void deselect_volumes(); void select_volume(unsigned int id); void update_volumes_selection(const std::vector<int>& selections); - bool check_volumes_outside_state(const DynamicPrintConfig* config) const; + int check_volumes_outside_state(const DynamicPrintConfig* config) const; bool move_volume_up(unsigned int id); bool move_volume_down(unsigned int id); @@ -499,6 +549,7 @@ public: void enable_gizmos(bool enable); void enable_shader(bool enable); void enable_force_zoom_to_bed(bool enable); + void enable_dynamic_background(bool enable); void allow_multisample(bool allow); void zoom_to_bed(); @@ -507,6 +558,7 @@ public: void set_viewport_from_scene(const GLCanvas3D& other); void update_volumes_colors_by_extruder(); + void update_gizmos_data(); void render(); @@ -518,16 +570,8 @@ public: void reload_scene(bool force); - // Create 3D thick extrusion lines for a skirt and brim. - // Adds a new Slic3r::GUI::3DScene::Volume to volumes. - void load_print_toolpaths(); - // Create 3D thick extrusion lines for object forming extrusions. - // Adds a new Slic3r::GUI::3DScene::Volume to $self->volumes, - // one for perimeters, one for infill and one for supports. - void load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors); - // Create 3D thick extrusion lines for wipe tower extrusions - void load_wipe_tower_toolpaths(const std::vector<std::string>& str_tool_colors); void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector<std::string>& str_tool_colors); + void load_preview(const std::vector<std::string>& str_tool_colors); void register_on_viewport_changed_callback(void* callback); void register_on_double_click_callback(void* callback); @@ -545,6 +589,8 @@ public: void register_on_wipe_tower_moved_callback(void* callback); void register_on_enable_action_buttons_callback(void* callback); void register_on_gizmo_scale_uniformly_callback(void* callback); + void register_on_gizmo_rotate_callback(void* callback); + void register_on_update_geometry_info_callback(void* callback); void bind_event_handlers(); void unbind_event_handlers(); @@ -561,6 +607,8 @@ public: Size get_canvas_size() const; Point get_local_mouse_position() const; + void reset_legend_texture(); + private: bool _is_shown_on_screen() const; void _force_zoom_to_bed(); @@ -589,7 +637,7 @@ private: void _render_legend_texture() const; void _render_layer_editing_overlay() const; void _render_volumes(bool fake_colors) const; - void _render_gizmo() const; + void _render_gizmo(Gizmos::RenderOrder render_order) const; float _get_layers_editing_cursor_z_relative() const; void _perform_layer_editing_action(wxMouseEvent* evt = nullptr); @@ -605,6 +653,17 @@ private: void _stop_timer(); int _get_first_selected_object_id() const; + int _get_first_selected_volume_id(int object_id) const; + + // Create 3D thick extrusion lines for a skirt and brim. + // Adds a new Slic3r::GUI::3DScene::Volume to volumes. + void _load_print_toolpaths(); + // Create 3D thick extrusion lines for object forming extrusions. + // Adds a new Slic3r::GUI::3DScene::Volume to $self->volumes, + // one for perimeters, one for infill and one for supports. + void _load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors); + // Create 3D thick extrusion lines for wipe tower extrusions + void _load_wipe_tower_toolpaths(const std::vector<std::string>& str_tool_colors); // generates gcode extrusion paths geometry void _load_gcode_extrusion_paths(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors); @@ -621,11 +680,20 @@ private: void _load_shells(); // sets gcode geometry visibility according to user selection void _update_gcode_volumes_visibility(const GCodePreviewData& preview_data); + void _update_toolpath_volumes_outside_state(); + void _show_warning_texture_if_needed(); void _on_move(const std::vector<int>& volume_idxs); void _on_select(int volume_idx); - void _update_gizmos_data(); + // generates the legend texture in dependence of the current shown view type + void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors); + + // generates a warning texture containing the given message + void _generate_warning_texture(const std::string& msg); + void _reset_warning_texture(); + + bool _is_any_volume_outside() const; static std::vector<float> _parse_colors(const std::vector<std::string>& colors); }; |