From 951e8528b4352c8f412dfd8b588b4b614ef87ae5 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 28 May 2018 13:43:29 +0200 Subject: [PATCH] 3DScene layers editing parameters moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 90 +++++++++++------ xs/src/slic3r/GUI/3DScene.cpp | 45 +++++++++ xs/src/slic3r/GUI/3DScene.hpp | 14 +++ xs/src/slic3r/GUI/GLCanvas3D.cpp | 124 ++++++++++++++++++++---- xs/src/slic3r/GUI/GLCanvas3D.hpp | 33 ++++++- xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 58 +++++++++++ xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 14 +++ xs/xsp/GUI_3DScene.xsp | 70 ++++++++++++- xs/xsp/Print.xsp | 3 + 9 files changed, 405 insertions(+), 46 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index b2a572c30..c5626d4bd 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -201,11 +201,11 @@ sub new { # $self->_camera_distance(0.); # $self->layer_editing_enabled(0); # $self->{layer_height_edit_band_width} = 2.; +# $self->{layer_height_edit_strength} = 0.005; +# $self->{layer_height_edit_last_object_id} = -1; +# $self->{layer_height_edit_last_z} = 0.; +# $self->{layer_height_edit_last_action} = 0; #============================================================================================================================== - $self->{layer_height_edit_strength} = 0.005; - $self->{layer_height_edit_last_object_id} = -1; - $self->{layer_height_edit_last_z} = 0.; - $self->{layer_height_edit_last_action} = 0; #============================================================================================================================== Slic3r::GUI::_3DScene::reset_volumes($self); @@ -267,7 +267,9 @@ sub new { EVT_TIMER($self, $self->{layer_height_edit_timer_id}, sub { my ($self, $event) = @_; return if $self->_layer_height_edited != 1; - return if $self->{layer_height_edit_last_object_id} == -1; +#============================================================================================================================== + return if Slic3r::GUI::_3DScene::get_layers_editing_last_object_id($self) == -1; +#============================================================================================================================== $self->_variable_layer_thickness_action(undef); }); @@ -419,40 +421,73 @@ sub _variable_layer_thickness_reset_rect_mouse_inside { return $mouse_evt->GetX >= $bar_left && $mouse_evt->GetX <= $bar_right && $mouse_evt->GetY >= $bar_top && $mouse_evt->GetY <= $bar_bottom; } -sub _variable_layer_thickness_bar_mouse_cursor_z_relative { - my ($self) = @_; - my $mouse_pos = $self->ScreenToClientPoint(Wx::GetMousePosition()); - my ($bar_left, $bar_top, $bar_right, $bar_bottom) = $self->_variable_layer_thickness_bar_rect_screen; - return ($mouse_pos->x >= $bar_left && $mouse_pos->x <= $bar_right && $mouse_pos->y >= $bar_top && $mouse_pos->y <= $bar_bottom) ? - # Inside the bar. - ($bar_bottom - $mouse_pos->y - 1.) / ($bar_bottom - $bar_top - 1) : - # Outside the bar. - -1000.; -} +#============================================================================================================================== +#sub _variable_layer_thickness_bar_mouse_cursor_z_relative { +# my ($self) = @_; +# my $mouse_pos = $self->ScreenToClientPoint(Wx::GetMousePosition()); +# my ($bar_left, $bar_top, $bar_right, $bar_bottom) = $self->_variable_layer_thickness_bar_rect_screen; +# return ($mouse_pos->x >= $bar_left && $mouse_pos->x <= $bar_right && $mouse_pos->y >= $bar_top && $mouse_pos->y <= $bar_bottom) ? +# # Inside the bar. +# ($bar_bottom - $mouse_pos->y - 1.) / ($bar_bottom - $bar_top - 1) : +# # Outside the bar. +# -1000.; +#} +#============================================================================================================================== sub _variable_layer_thickness_action { my ($self, $mouse_event, $do_modification) = @_; +#============================================================================================================================== + my $object_idx_selected = Slic3r::GUI::_3DScene::get_layers_editing_last_object_id($self); # A volume is selected. Test, whether hovering over a layer thickness bar. - return if $self->{layer_height_edit_last_object_id} == -1; + return if ($object_idx_selected == -1); +# return if $self->{layer_height_edit_last_object_id} == -1; +#============================================================================================================================== if (defined($mouse_event)) { my ($bar_left, $bar_top, $bar_right, $bar_bottom) = $self->_variable_layer_thickness_bar_rect_screen; - $self->{layer_height_edit_last_z} = unscale($self->{print}->get_object($self->{layer_height_edit_last_object_id})->size->z) - * ($bar_bottom - $mouse_event->GetY - 1.) / ($bar_bottom - $bar_top); - $self->{layer_height_edit_last_action} = $mouse_event->ShiftDown ? ($mouse_event->RightIsDown ? 3 : 2) : ($mouse_event->RightIsDown ? 0 : 1); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_layers_editing_last_z($self, unscale($self->{print}->get_object($object_idx_selected)->size->z) + * ($bar_bottom - $mouse_event->GetY - 1.) / ($bar_bottom - $bar_top)); + Slic3r::GUI::_3DScene::set_layers_editing_last_action($self, $mouse_event->ShiftDown ? ($mouse_event->RightIsDown ? 3 : 2) : ($mouse_event->RightIsDown ? 0 : 1)); +# $self->{layer_height_edit_last_z} = unscale($self->{print}->get_object($self->{layer_height_edit_last_object_id})->size->z) +# * ($bar_bottom - $mouse_event->GetY - 1.) / ($bar_bottom - $bar_top); +# $self->{layer_height_edit_last_action} = $mouse_event->ShiftDown ? ($mouse_event->RightIsDown ? 3 : 2) : ($mouse_event->RightIsDown ? 0 : 1); +#============================================================================================================================== } # Mark the volume as modified, so Print will pick its layer height profile? Where to mark it? # Start a timer to refresh the print? schedule_background_process() ? # The PrintObject::adjust_layer_height_profile() call adjusts the profile of its associated ModelObject, it does not modify the profile of the PrintObject itself. - $self->{print}->get_object($self->{layer_height_edit_last_object_id})->adjust_layer_height_profile( - $self->{layer_height_edit_last_z}, - $self->{layer_height_edit_strength}, #============================================================================================================================== + $self->{print}->get_object($object_idx_selected)->adjust_layer_height_profile( + Slic3r::GUI::_3DScene::get_layers_editing_last_z($self), + Slic3r::GUI::_3DScene::get_layers_editing_strength($self), Slic3r::GUI::_3DScene::get_layers_editing_band_width($self), + Slic3r::GUI::_3DScene::get_layers_editing_last_action($self)); +# $self->{print}->get_object($self->{layer_height_edit_last_object_id})->adjust_layer_height_profile( +# $self->{layer_height_edit_last_z}, +# $self->{layer_height_edit_strength}, # $self->{layer_height_edit_band_width}, +# $self->{layer_height_edit_last_action}); +#============================================================================================================================== + + #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MERGE FROM SCENE_MANIPULATORS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + # searches the id of the first volume of the selected object + my $volume_idx = 0; + for my $i (0..$object_idx_selected - 1) { + my $obj = $self->{print}->get_object($i); + for my $j (0..$obj->region_volumes_count - 1) { + $volume_idx += scalar @{$obj->get_region_volumes($j)}; + } + } + #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MERGE FROM SCENE_MANIPULATORS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + +#============================================================================================================================== + #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MERGE FROM SCENE_MANIPULATORS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + $self->volumes->[$volume_idx]->generate_layer_height_texture($self->{print}->get_object($object_idx_selected), 1); +# $self->volumes->[$object_idx_selected]->generate_layer_height_texture($self->{print}->get_object($object_idx_selected), 1); + #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MERGE FROM SCENE_MANIPULATORS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +# $self->volumes->[$self->{layer_height_edit_last_object_id}]->generate_layer_height_texture( +# $self->{print}->get_object($self->{layer_height_edit_last_object_id}), 1); #============================================================================================================================== - $self->{layer_height_edit_last_action}); - $self->volumes->[$self->{layer_height_edit_last_object_id}]->generate_layer_height_texture( - $self->{print}->get_object($self->{layer_height_edit_last_object_id}), 1); $self->Refresh; # Automatic action on mouse down with the same coordinate. $self->{layer_height_edit_timer}->Start(100, wxTIMER_CONTINUOUS); @@ -463,7 +498,8 @@ sub mouse_event { my $pos = Slic3r::Pointf->new($e->GetPositionXY); #============================================================================================================================== - my $object_idx_selected = $self->{layer_height_edit_last_object_id} = (Slic3r::GUI::_3DScene::is_layers_editing_enabled($self) && $self->{print}) ? $self->_first_selected_object_id_for_variable_layer_height_editing : -1; + my $object_idx_selected = (Slic3r::GUI::_3DScene::is_layers_editing_enabled($self) && $self->{print}) ? $self->_first_selected_object_id_for_variable_layer_height_editing : -1; + Slic3r::GUI::_3DScene::set_layers_editing_last_object_id($self, $object_idx_selected); # my $object_idx_selected = $self->{layer_height_edit_last_object_id} = ($self->layer_editing_enabled && $self->{print}) ? $self->_first_selected_object_id_for_variable_layer_height_editing : -1; #============================================================================================================================== @@ -1718,7 +1754,7 @@ sub mark_volumes_for_layer_height { if (Slic3r::GUI::_3DScene::is_layers_editing_enabled($self) && $shader && $volume->selected && $volume->has_layer_height_texture && $object_id < $self->{print}->object_count) { $volume->set_layer_height_texture_data(Slic3r::GUI::_3DScene::get_layers_editing_z_texture_id($self), $shader->shader_program_id, - $self->{print}->get_object($object_id), $self->_variable_layer_thickness_bar_mouse_cursor_z_relative, Slic3r::GUI::_3DScene::get_layers_editing_band_width($self)); + $self->{print}->get_object($object_id), Slic3r::GUI::_3DScene::get_layers_editing_cursor_z_relative($self), Slic3r::GUI::_3DScene::get_layers_editing_band_width($self)); # if ($self->layer_editing_enabled && $volume->selected && $self->{layer_height_edit_shader} && # $volume->has_layer_height_texture && $object_id < $self->{print}->object_count) { diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index a9262337b..46b7a5eca 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -2025,11 +2025,56 @@ void _3DScene::set_layers_editing_band_width(wxGLCanvas* canvas, float band_widt s_canvas_mgr.set_layers_editing_band_width(canvas, band_width); } +float _3DScene::get_layers_editing_strength(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_layers_editing_strength(canvas); +} + +void _3DScene::set_layers_editing_strength(wxGLCanvas* canvas, float strength) +{ + s_canvas_mgr.set_layers_editing_strength(canvas, strength); +} + +int _3DScene::get_layers_editing_last_object_id(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_layers_editing_last_object_id(canvas); +} + +void _3DScene::set_layers_editing_last_object_id(wxGLCanvas* canvas, int id) +{ + s_canvas_mgr.set_layers_editing_last_object_id(canvas, id); +} + +float _3DScene::get_layers_editing_last_z(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_layers_editing_last_z(canvas); +} + +void _3DScene::set_layers_editing_last_z(wxGLCanvas* canvas, float z) +{ + s_canvas_mgr.set_layers_editing_last_z(canvas, z); +} + +unsigned int _3DScene::get_layers_editing_last_action(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_layers_editing_last_action(canvas); +} + +void _3DScene::set_layers_editing_last_action(wxGLCanvas* canvas, unsigned int action) +{ + s_canvas_mgr.set_layers_editing_last_action(canvas, action); +} + GLShader* _3DScene::get_layers_editing_shader(wxGLCanvas* canvas) { return s_canvas_mgr.get_layers_editing_shader(canvas); } +float _3DScene::get_layers_editing_cursor_z_relative(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_layers_editing_cursor_z_relative(canvas); +} + void _3DScene::zoom_to_bed(wxGLCanvas* canvas) { s_canvas_mgr.zoom_to_bed(canvas); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 94ce59a3b..73835df2f 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -622,8 +622,22 @@ public: static float get_layers_editing_band_width(wxGLCanvas* canvas); static void set_layers_editing_band_width(wxGLCanvas* canvas, float band_width); + static float get_layers_editing_strength(wxGLCanvas* canvas); + static void set_layers_editing_strength(wxGLCanvas* canvas, float strength); + + static int get_layers_editing_last_object_id(wxGLCanvas* canvas); + static void set_layers_editing_last_object_id(wxGLCanvas* canvas, int id); + + static float get_layers_editing_last_z(wxGLCanvas* canvas); + static void set_layers_editing_last_z(wxGLCanvas* canvas, float z); + + static unsigned int get_layers_editing_last_action(wxGLCanvas* canvas); + static void set_layers_editing_last_action(wxGLCanvas* canvas, unsigned int action); + static GLShader* get_layers_editing_shader(wxGLCanvas* canvas); + static float get_layers_editing_cursor_z_relative(wxGLCanvas* canvas); + static void zoom_to_bed(wxGLCanvas* canvas); static void zoom_to_volumes(wxGLCanvas* canvas); static void select_view(wxGLCanvas* canvas, const std::string& direction); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 95ec9c342..ef82e7f25 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -593,6 +593,10 @@ GLCanvas3D::LayersEditing::LayersEditing() , m_enabled(false) , m_z_texture_id(0) , m_band_width(2.0f) + , m_strength(0.005f) + , m_last_object_id(-1) + , m_last_z(0.0f) + , m_last_action(0) { } @@ -669,6 +673,46 @@ void GLCanvas3D::LayersEditing::set_band_width(float band_width) m_band_width = band_width; } +float GLCanvas3D::LayersEditing::get_strength() const +{ + return m_strength; +} + +void GLCanvas3D::LayersEditing::set_strength(float strength) +{ + m_strength = strength; +} + +int GLCanvas3D::LayersEditing::get_last_object_id() const +{ + return m_last_object_id; +} + +void GLCanvas3D::LayersEditing::set_last_object_id(int id) +{ + m_last_object_id = id; +} + +float GLCanvas3D::LayersEditing::get_last_z() const +{ + return m_last_z; +} + +void GLCanvas3D::LayersEditing::set_last_z(float z) +{ + m_last_z = z; +} + +unsigned int GLCanvas3D::LayersEditing::get_last_action() const +{ + return m_last_action; +} + +void GLCanvas3D::LayersEditing::set_last_action(unsigned int action) +{ + m_last_action = action; +} + void GLCanvas3D::LayersEditing::render(const GLCanvas3D& canvas, const PrintObject& print_object, const GLVolume& volume) const { if (!m_enabled) @@ -700,6 +744,22 @@ GLShader* GLCanvas3D::LayersEditing::get_shader() return m_shader.get_shader(); } +float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas) const +{ + const Point& mouse_pos = canvas.get_local_mouse_position(); + const Rect& bar_rect = _get_bar_rect_screen(canvas); + float x = (float)mouse_pos.x; + float y = (float)mouse_pos.y; + float t = bar_rect.get_top(); + float b = bar_rect.get_bottom(); + + return ((bar_rect.get_left() <= x) && (x <= bar_rect.get_right()) && (t <= y) && (y <= b)) ? + // Inside the bar. + (b - y - 1.0f) / (b - t - 1.0f) : + // Outside the bar. + -1000.0f; +} + bool GLCanvas3D::LayersEditing::_is_initialized() const { return m_shader.is_initialized(); @@ -796,7 +856,7 @@ void GLCanvas3D::LayersEditing::_render_active_object_annotations(const GLCanvas m_shader.set_uniform("z_to_texture_row", (float)volume.layer_height_texture_z_to_row_id()); m_shader.set_uniform("z_texture_row_to_normalized", 1.0f / (float)volume.layer_height_texture_height()); - m_shader.set_uniform("z_cursor", max_z * _cursor_z_relative(canvas)); + m_shader.set_uniform("z_cursor", max_z * get_cursor_z_relative(canvas)); m_shader.set_uniform("z_cursor_band_width", get_band_width()); GLsizei w = (GLsizei)volume.layer_height_texture_width(); @@ -924,21 +984,6 @@ Rect GLCanvas3D::LayersEditing::_get_reset_rect_viewport(const GLCanvas3D& canva return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom); } -float GLCanvas3D::LayersEditing::_cursor_z_relative(const GLCanvas3D& canvas) const -{ - const Point& mouse_pos = canvas.get_local_mouse_position(); - const Rect& bar_rect = _get_bar_rect_screen(canvas); - float x = (float)mouse_pos.x; - float y = (float)mouse_pos.y; - float t = bar_rect.get_top(); - float b = bar_rect.get_bottom(); - return ((bar_rect.get_left() <= x) && (x <= bar_rect.get_right()) && (t <= y) && (y <= b)) ? - // Inside the bar. - (b - y - 1.0f) / (b - t - 1.0f) : - // Outside the bar. - - 1000.0f; -} - GLCanvas3D::Mouse::Mouse() : m_dragging(false) { @@ -1559,11 +1604,56 @@ void GLCanvas3D::set_layers_editing_band_width(float band_width) m_layers_editing.set_band_width(band_width); } +float GLCanvas3D::get_layers_editing_strength() const +{ + return m_layers_editing.get_strength(); +} + +void GLCanvas3D::set_layers_editing_strength(float strength) +{ + m_layers_editing.set_strength(strength); +} + +int GLCanvas3D::get_layers_editing_last_object_id() const +{ + return m_layers_editing.get_last_object_id(); +} + +void GLCanvas3D::set_layers_editing_last_object_id(int id) +{ + m_layers_editing.set_last_object_id(id); +} + +float GLCanvas3D::get_layers_editing_last_z() const +{ + return m_layers_editing.get_last_z(); +} + +void GLCanvas3D::set_layers_editing_last_z(float z) +{ + m_layers_editing.set_last_z(z); +} + +unsigned int GLCanvas3D::get_layers_editing_last_action() const +{ + return m_layers_editing.get_last_action(); +} + +void GLCanvas3D::set_layers_editing_last_action(unsigned int action) +{ + m_layers_editing.set_last_action(action); +} + GLShader* GLCanvas3D::get_layers_editing_shader() { return m_layers_editing.get_shader(); } +float GLCanvas3D::get_layers_editing_cursor_z_relative(const GLCanvas3D& canvas) const +{ + return m_layers_editing.get_cursor_z_relative(canvas); +} + void GLCanvas3D::render_bed() const { m_bed.render(); @@ -1877,7 +1967,7 @@ Point GLCanvas3D::get_local_mouse_position() const return Point(); wxPoint mouse_pos = m_canvas->ScreenToClient(wxGetMousePosition()); - return Point(mouse_pos.x, mouse_pos.x); + return Point(mouse_pos.x, mouse_pos.y); } void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox) diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 2a78ded07..3a83321f5 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -218,6 +218,10 @@ public: mutable GLTextureData m_tooltip_texture; mutable GLTextureData m_reset_texture; float m_band_width; + float m_strength; + int m_last_object_id; + float m_last_z; + unsigned int m_last_action; public: LayersEditing(); @@ -236,10 +240,24 @@ public: float get_band_width() const; void set_band_width(float band_width); + float get_strength() const; + void set_strength(float strength); + + int get_last_object_id() const; + void set_last_object_id(int id); + + float get_last_z() const; + void set_last_z(float z); + + unsigned int get_last_action() const; + void set_last_action(unsigned int action); + void render(const GLCanvas3D& canvas, const PrintObject& print_object, const GLVolume& volume) const; GLShader* get_shader(); + float get_cursor_z_relative(const GLCanvas3D& canvas) const; + private: bool _is_initialized() const; GLTextureData _load_texture_from_file(const std::string& filename) const; @@ -251,7 +269,6 @@ public: Rect _get_reset_rect_screen(const GLCanvas3D& canvas) const; Rect _get_bar_rect_viewport(const GLCanvas3D& canvas) const; Rect _get_reset_rect_viewport(const GLCanvas3D& canvas) const; - float _cursor_z_relative(const GLCanvas3D& canvas) const; }; class Mouse @@ -384,8 +401,22 @@ public: float get_layers_editing_band_width() const; void set_layers_editing_band_width(float band_width); + float get_layers_editing_strength() const; + void set_layers_editing_strength(float strength); + + int get_layers_editing_last_object_id() const; + void set_layers_editing_last_object_id(int id); + + float get_layers_editing_last_z() const; + void set_layers_editing_last_z(float z); + + unsigned int get_layers_editing_last_action() const; + void set_layers_editing_last_action(unsigned int action); + GLShader* get_layers_editing_shader(); + float get_layers_editing_cursor_z_relative(const GLCanvas3D& canvas) const; + void zoom_to_bed(); void zoom_to_volumes(); void select_view(const std::string& direction); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 2406f0094..b2a7f5bad 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -492,12 +492,70 @@ void GLCanvas3DManager::set_layers_editing_band_width(wxGLCanvas* canvas, float it->second->set_layers_editing_band_width(band_width); } +float GLCanvas3DManager::get_layers_editing_strength(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_layers_editing_strength() : 0.0f; +} + +void GLCanvas3DManager::set_layers_editing_strength(wxGLCanvas* canvas, float strength) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_layers_editing_strength(strength); +} + +int GLCanvas3DManager::get_layers_editing_last_object_id(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_layers_editing_last_object_id() : -1; +} + +void GLCanvas3DManager::set_layers_editing_last_object_id(wxGLCanvas* canvas, int id) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_layers_editing_last_object_id(id); +} + +float GLCanvas3DManager::get_layers_editing_last_z(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_layers_editing_last_z() : 0.0f; +} + +void GLCanvas3DManager::set_layers_editing_last_z(wxGLCanvas* canvas, float z) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_layers_editing_last_z(z); +} + +unsigned int GLCanvas3DManager::get_layers_editing_last_action(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_layers_editing_last_action() : 0; +} + +void GLCanvas3DManager::set_layers_editing_last_action(wxGLCanvas* canvas, unsigned int action) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_layers_editing_last_action(action); +} + GLShader* GLCanvas3DManager::get_layers_editing_shader(wxGLCanvas* canvas) { CanvasesMap::const_iterator it = _get_canvas(canvas); return (it != m_canvases.end()) ? it->second->get_layers_editing_shader() : nullptr; } +float GLCanvas3DManager::get_layers_editing_cursor_z_relative(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_layers_editing_cursor_z_relative(*it->second) : 0.0f; +} + void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas) { CanvasesMap::iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 14b857920..4a804e921 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -122,8 +122,22 @@ public: float get_layers_editing_band_width(wxGLCanvas* canvas) const; void set_layers_editing_band_width(wxGLCanvas* canvas, float band_width); + float get_layers_editing_strength(wxGLCanvas* canvas) const; + void set_layers_editing_strength(wxGLCanvas* canvas, float strength); + + int get_layers_editing_last_object_id(wxGLCanvas* canvas) const; + void set_layers_editing_last_object_id(wxGLCanvas* canvas, int id); + + float get_layers_editing_last_z(wxGLCanvas* canvas) const; + void set_layers_editing_last_z(wxGLCanvas* canvas, float z); + + unsigned int get_layers_editing_last_action(wxGLCanvas* canvas) const; + void set_layers_editing_last_action(wxGLCanvas* canvas, unsigned int action); + GLShader* get_layers_editing_shader(wxGLCanvas* canvas); + float get_layers_editing_cursor_z_relative(wxGLCanvas* canvas) const; + void zoom_to_bed(wxGLCanvas* canvas); void zoom_to_volumes(wxGLCanvas* canvas); void select_view(wxGLCanvas* canvas, const std::string& direction); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index bbc8fc2f9..cca3583fb 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -594,6 +594,66 @@ set_layers_editing_band_width(canvas, band_width) CODE: _3DScene::set_layers_editing_band_width((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), band_width); +float +get_layers_editing_strength(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_layers_editing_strength((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_layers_editing_strength(canvas, strength) + SV *canvas; + float strength; + CODE: + _3DScene::set_layers_editing_strength((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), strength); + +int +get_layers_editing_last_object_id(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_layers_editing_last_object_id((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_layers_editing_last_object_id(canvas, id) + SV *canvas; + int id; + CODE: + _3DScene::set_layers_editing_last_object_id((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), id); + +float +get_layers_editing_last_z(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_layers_editing_last_z((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_layers_editing_last_z(canvas, z) + SV *canvas; + float z; + CODE: + _3DScene::set_layers_editing_last_z((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), z); + +unsigned int +get_layers_editing_last_action(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_layers_editing_last_action((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_layers_editing_last_action(canvas, action) + SV *canvas; + unsigned int action; + CODE: + _3DScene::set_layers_editing_last_action((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), action); + Ref get_layers_editing_shader(canvas) SV *canvas; @@ -601,7 +661,15 @@ get_layers_editing_shader(canvas) RETVAL = _3DScene::get_layers_editing_shader((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); OUTPUT: RETVAL - + +float +get_layers_editing_cursor_z_relative(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_layers_editing_cursor_z_relative((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + void zoom_to_bed(canvas) SV *canvas; diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index ef9c5345f..f21923b41 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -52,6 +52,9 @@ _constant() int region_count() %code%{ RETVAL = THIS->print()->regions.size(); %}; + int region_volumes_count() + %code%{ RETVAL = THIS->region_volumes.size(); %}; + Ref print(); Ref model_object(); Ref config()