3DScene _first_selected_object_id_for_variable_layer_height_editing method moved to c++
This commit is contained in:
parent
951e8528b4
commit
994222c317
@ -360,21 +360,21 @@ sub Destroy {
|
|||||||
# # or if the initialization was done already and it failed.
|
# # or if the initialization was done already and it failed.
|
||||||
# return ! (defined($self->{layer_editing_initialized}) && $self->{layer_editing_initialized} == 2);
|
# return ! (defined($self->{layer_editing_initialized}) && $self->{layer_editing_initialized} == 2);
|
||||||
#}
|
#}
|
||||||
|
#
|
||||||
|
#sub _first_selected_object_id_for_variable_layer_height_editing {
|
||||||
|
# my ($self) = @_;
|
||||||
|
# for my $i (0..$#{$self->volumes}) {
|
||||||
|
# if ($self->volumes->[$i]->selected) {
|
||||||
|
# my $object_id = int($self->volumes->[$i]->select_group_id / 1000000);
|
||||||
|
# # Objects with object_id >= 1000 have a specific meaning, for example the wipe tower proxy.
|
||||||
|
# return ($object_id >= $self->{print}->object_count) ? -1 : $object_id
|
||||||
|
# if $object_id < 10000;
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# return -1;
|
||||||
|
#}
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
|
|
||||||
sub _first_selected_object_id_for_variable_layer_height_editing {
|
|
||||||
my ($self) = @_;
|
|
||||||
for my $i (0..$#{$self->volumes}) {
|
|
||||||
if ($self->volumes->[$i]->selected) {
|
|
||||||
my $object_id = int($self->volumes->[$i]->select_group_id / 1000000);
|
|
||||||
# Objects with object_id >= 1000 have a specific meaning, for example the wipe tower proxy.
|
|
||||||
return ($object_id >= $self->{print}->object_count) ? -1 : $object_id
|
|
||||||
if $object_id < 10000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Returns an array with (left, top, right, bottom) of the variable layer thickness bar on the screen.
|
# Returns an array with (left, top, right, bottom) of the variable layer thickness bar on the screen.
|
||||||
sub _variable_layer_thickness_bar_rect_screen {
|
sub _variable_layer_thickness_bar_rect_screen {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
@ -498,7 +498,7 @@ sub mouse_event {
|
|||||||
|
|
||||||
my $pos = Slic3r::Pointf->new($e->GetPositionXY);
|
my $pos = Slic3r::Pointf->new($e->GetPositionXY);
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
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;
|
my $object_idx_selected = (Slic3r::GUI::_3DScene::is_layers_editing_enabled($self) && $self->{print}) ? Slic3r::GUI::_3DScene::get_layers_editing_first_selected_object_id($self, $self->{print}->object_count) : -1;
|
||||||
Slic3r::GUI::_3DScene::set_layers_editing_last_object_id($self, $object_idx_selected);
|
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;
|
# 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;
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
@ -732,9 +732,10 @@ sub mouse_wheel_event {
|
|||||||
}
|
}
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
if (Slic3r::GUI::_3DScene::is_layers_editing_enabled($self) && $self->{print}) {
|
if (Slic3r::GUI::_3DScene::is_layers_editing_enabled($self) && $self->{print}) {
|
||||||
|
my $object_idx_selected = Slic3r::GUI::_3DScene::get_layers_editing_first_selected_object_id($self, $self->{print}->object_count);
|
||||||
# if ($self->layer_editing_enabled && $self->{print}) {
|
# if ($self->layer_editing_enabled && $self->{print}) {
|
||||||
|
# my $object_idx_selected = $self->_first_selected_object_id_for_variable_layer_height_editing;
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
my $object_idx_selected = $self->_first_selected_object_id_for_variable_layer_height_editing;
|
|
||||||
if ($object_idx_selected != -1) {
|
if ($object_idx_selected != -1) {
|
||||||
# A volume is selected. Test, whether hovering over a layer thickness bar.
|
# A volume is selected. Test, whether hovering over a layer thickness bar.
|
||||||
if ($self->_variable_layer_thickness_bar_rect_mouse_inside($e)) {
|
if ($self->_variable_layer_thickness_bar_rect_mouse_inside($e)) {
|
||||||
|
@ -2075,6 +2075,11 @@ float _3DScene::get_layers_editing_cursor_z_relative(wxGLCanvas* canvas)
|
|||||||
return s_canvas_mgr.get_layers_editing_cursor_z_relative(canvas);
|
return s_canvas_mgr.get_layers_editing_cursor_z_relative(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _3DScene::get_layers_editing_first_selected_object_id(wxGLCanvas* canvas, unsigned int objects_count)
|
||||||
|
{
|
||||||
|
return s_canvas_mgr.get_layers_editing_first_selected_object_id(canvas, objects_count);
|
||||||
|
}
|
||||||
|
|
||||||
void _3DScene::zoom_to_bed(wxGLCanvas* canvas)
|
void _3DScene::zoom_to_bed(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
s_canvas_mgr.zoom_to_bed(canvas);
|
s_canvas_mgr.zoom_to_bed(canvas);
|
||||||
|
@ -637,6 +637,7 @@ public:
|
|||||||
static GLShader* get_layers_editing_shader(wxGLCanvas* canvas);
|
static GLShader* get_layers_editing_shader(wxGLCanvas* canvas);
|
||||||
|
|
||||||
static float get_layers_editing_cursor_z_relative(wxGLCanvas* canvas);
|
static float get_layers_editing_cursor_z_relative(wxGLCanvas* canvas);
|
||||||
|
static int get_layers_editing_first_selected_object_id(wxGLCanvas* canvas, unsigned int objects_count);
|
||||||
|
|
||||||
static void zoom_to_bed(wxGLCanvas* canvas);
|
static void zoom_to_bed(wxGLCanvas* canvas);
|
||||||
static void zoom_to_volumes(wxGLCanvas* canvas);
|
static void zoom_to_volumes(wxGLCanvas* canvas);
|
||||||
|
@ -744,7 +744,7 @@ GLShader* GLCanvas3D::LayersEditing::get_shader()
|
|||||||
return m_shader.get_shader();
|
return m_shader.get_shader();
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas) const
|
float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas)
|
||||||
{
|
{
|
||||||
const Point& mouse_pos = canvas.get_local_mouse_position();
|
const Point& mouse_pos = canvas.get_local_mouse_position();
|
||||||
const Rect& bar_rect = _get_bar_rect_screen(canvas);
|
const Rect& bar_rect = _get_bar_rect_screen(canvas);
|
||||||
@ -760,6 +760,21 @@ float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas)
|
|||||||
-1000.0f;
|
-1000.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GLCanvas3D::LayersEditing::get_first_selected_object_id(const GLVolumeCollection& volumes, unsigned int objects_count)
|
||||||
|
{
|
||||||
|
for (const GLVolume* vol : volumes.volumes)
|
||||||
|
{
|
||||||
|
if ((vol != nullptr) && vol->selected)
|
||||||
|
{
|
||||||
|
int object_id = vol->select_group_id / 1000000;
|
||||||
|
// Objects with object_id >= 1000 have a specific meaning, for example the wipe tower proxy.
|
||||||
|
if (object_id < 10000)
|
||||||
|
return (object_id >= (int)objects_count) ? -1 : object_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
bool GLCanvas3D::LayersEditing::_is_initialized() const
|
bool GLCanvas3D::LayersEditing::_is_initialized() const
|
||||||
{
|
{
|
||||||
return m_shader.is_initialized();
|
return m_shader.is_initialized();
|
||||||
@ -942,7 +957,7 @@ void GLCanvas3D::LayersEditing::_render_profile(const PrintObject& print_object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect GLCanvas3D::LayersEditing::_get_bar_rect_screen(const GLCanvas3D& canvas) const
|
Rect GLCanvas3D::LayersEditing::_get_bar_rect_screen(const GLCanvas3D& canvas)
|
||||||
{
|
{
|
||||||
const Size& cnv_size = canvas.get_canvas_size();
|
const Size& cnv_size = canvas.get_canvas_size();
|
||||||
float w = (float)cnv_size.get_width();
|
float w = (float)cnv_size.get_width();
|
||||||
@ -951,7 +966,7 @@ Rect GLCanvas3D::LayersEditing::_get_bar_rect_screen(const GLCanvas3D& canvas) c
|
|||||||
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, 0.0f, w, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT);
|
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, 0.0f, w, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect GLCanvas3D::LayersEditing::_get_reset_rect_screen(const GLCanvas3D& canvas) const
|
Rect GLCanvas3D::LayersEditing::_get_reset_rect_screen(const GLCanvas3D& canvas)
|
||||||
{
|
{
|
||||||
const Size& cnv_size = canvas.get_canvas_size();
|
const Size& cnv_size = canvas.get_canvas_size();
|
||||||
float w = (float)cnv_size.get_width();
|
float w = (float)cnv_size.get_width();
|
||||||
@ -960,7 +975,7 @@ Rect GLCanvas3D::LayersEditing::_get_reset_rect_screen(const GLCanvas3D& canvas)
|
|||||||
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT, w, h);
|
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect GLCanvas3D::LayersEditing::_get_bar_rect_viewport(const GLCanvas3D& canvas) const
|
Rect GLCanvas3D::LayersEditing::_get_bar_rect_viewport(const GLCanvas3D& canvas)
|
||||||
{
|
{
|
||||||
const Size& cnv_size = canvas.get_canvas_size();
|
const Size& cnv_size = canvas.get_canvas_size();
|
||||||
float half_w = 0.5f * (float)cnv_size.get_width();
|
float half_w = 0.5f * (float)cnv_size.get_width();
|
||||||
@ -972,7 +987,7 @@ Rect GLCanvas3D::LayersEditing::_get_bar_rect_viewport(const GLCanvas3D& canvas)
|
|||||||
return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom);
|
return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect GLCanvas3D::LayersEditing::_get_reset_rect_viewport(const GLCanvas3D& canvas) const
|
Rect GLCanvas3D::LayersEditing::_get_reset_rect_viewport(const GLCanvas3D& canvas)
|
||||||
{
|
{
|
||||||
const Size& cnv_size = canvas.get_canvas_size();
|
const Size& cnv_size = canvas.get_canvas_size();
|
||||||
float half_w = 0.5f * (float)cnv_size.get_width();
|
float half_w = 0.5f * (float)cnv_size.get_width();
|
||||||
@ -1654,6 +1669,11 @@ float GLCanvas3D::get_layers_editing_cursor_z_relative(const GLCanvas3D& canvas)
|
|||||||
return m_layers_editing.get_cursor_z_relative(canvas);
|
return m_layers_editing.get_cursor_z_relative(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GLCanvas3D::get_layers_editing_first_selected_object_id(unsigned int objects_count) const
|
||||||
|
{
|
||||||
|
return (m_volumes != nullptr) ? m_layers_editing.get_first_selected_object_id(*m_volumes, objects_count) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::render_bed() const
|
void GLCanvas3D::render_bed() const
|
||||||
{
|
{
|
||||||
m_bed.render();
|
m_bed.render();
|
||||||
|
@ -256,7 +256,8 @@ public:
|
|||||||
|
|
||||||
GLShader* get_shader();
|
GLShader* get_shader();
|
||||||
|
|
||||||
float get_cursor_z_relative(const GLCanvas3D& canvas) const;
|
static float get_cursor_z_relative(const GLCanvas3D& canvas);
|
||||||
|
static int get_first_selected_object_id(const GLVolumeCollection& volumes, unsigned int objects_count);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _is_initialized() const;
|
bool _is_initialized() const;
|
||||||
@ -265,10 +266,10 @@ public:
|
|||||||
void _render_reset_texture(const GLCanvas3D& canvas, const Rect& reset_rect) const;
|
void _render_reset_texture(const GLCanvas3D& canvas, const Rect& reset_rect) const;
|
||||||
void _render_active_object_annotations(const GLCanvas3D& canvas, const GLVolume& volume, const PrintObject& print_object, const Rect& bar_rect) const;
|
void _render_active_object_annotations(const GLCanvas3D& canvas, const GLVolume& volume, const PrintObject& print_object, const Rect& bar_rect) const;
|
||||||
void _render_profile(const PrintObject& print_object, const Rect& bar_rect) const;
|
void _render_profile(const PrintObject& print_object, const Rect& bar_rect) const;
|
||||||
Rect _get_bar_rect_screen(const GLCanvas3D& canvas) const;
|
static Rect _get_bar_rect_screen(const GLCanvas3D& canvas);
|
||||||
Rect _get_reset_rect_screen(const GLCanvas3D& canvas) const;
|
static Rect _get_reset_rect_screen(const GLCanvas3D& canvas);
|
||||||
Rect _get_bar_rect_viewport(const GLCanvas3D& canvas) const;
|
static Rect _get_bar_rect_viewport(const GLCanvas3D& canvas);
|
||||||
Rect _get_reset_rect_viewport(const GLCanvas3D& canvas) const;
|
static Rect _get_reset_rect_viewport(const GLCanvas3D& canvas);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Mouse
|
class Mouse
|
||||||
@ -416,6 +417,7 @@ public:
|
|||||||
GLShader* get_layers_editing_shader();
|
GLShader* get_layers_editing_shader();
|
||||||
|
|
||||||
float get_layers_editing_cursor_z_relative(const GLCanvas3D& canvas) const;
|
float get_layers_editing_cursor_z_relative(const GLCanvas3D& canvas) const;
|
||||||
|
int get_layers_editing_first_selected_object_id(unsigned int objects_count) const;
|
||||||
|
|
||||||
void zoom_to_bed();
|
void zoom_to_bed();
|
||||||
void zoom_to_volumes();
|
void zoom_to_volumes();
|
||||||
|
@ -556,6 +556,12 @@ float GLCanvas3DManager::get_layers_editing_cursor_z_relative(wxGLCanvas* canvas
|
|||||||
return (it != m_canvases.end()) ? it->second->get_layers_editing_cursor_z_relative(*it->second) : 0.0f;
|
return (it != m_canvases.end()) ? it->second->get_layers_editing_cursor_z_relative(*it->second) : 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GLCanvas3DManager::get_layers_editing_first_selected_object_id(wxGLCanvas* canvas, unsigned int objects_count) const
|
||||||
|
{
|
||||||
|
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||||
|
return (it != m_canvases.end()) ? it->second->get_layers_editing_first_selected_object_id(objects_count) : 0.;
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas)
|
void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
@ -137,6 +137,7 @@ public:
|
|||||||
GLShader* get_layers_editing_shader(wxGLCanvas* canvas);
|
GLShader* get_layers_editing_shader(wxGLCanvas* canvas);
|
||||||
|
|
||||||
float get_layers_editing_cursor_z_relative(wxGLCanvas* canvas) const;
|
float get_layers_editing_cursor_z_relative(wxGLCanvas* canvas) const;
|
||||||
|
int get_layers_editing_first_selected_object_id(wxGLCanvas* canvas, unsigned int objects_count) const;
|
||||||
|
|
||||||
void zoom_to_bed(wxGLCanvas* canvas);
|
void zoom_to_bed(wxGLCanvas* canvas);
|
||||||
void zoom_to_volumes(wxGLCanvas* canvas);
|
void zoom_to_volumes(wxGLCanvas* canvas);
|
||||||
|
@ -670,6 +670,16 @@ get_layers_editing_cursor_z_relative(canvas)
|
|||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
|
|
||||||
|
int
|
||||||
|
get_layers_editing_first_selected_object_id(canvas, objects_count)
|
||||||
|
SV *canvas;
|
||||||
|
unsigned int objects_count;
|
||||||
|
CODE:
|
||||||
|
RETVAL = _3DScene::get_layers_editing_first_selected_object_id((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), objects_count);
|
||||||
|
OUTPUT:
|
||||||
|
RETVAL
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
zoom_to_bed(canvas)
|
zoom_to_bed(canvas)
|
||||||
SV *canvas;
|
SV *canvas;
|
||||||
|
Loading…
Reference in New Issue
Block a user