3DScene volume selection methods moved to c++
This commit is contained in:
parent
f121817501
commit
bdbc86167c
10 changed files with 96 additions and 22 deletions
|
@ -508,16 +508,21 @@ sub mouse_event {
|
||||||
# during the scene manipulation.
|
# during the scene manipulation.
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
if (Slic3r::GUI::_3DScene::is_picking_enabled($self) && ($volume_idx != -1 || ! $self->layer_editing_enabled)) {
|
if (Slic3r::GUI::_3DScene::is_picking_enabled($self) && ($volume_idx != -1 || ! $self->layer_editing_enabled)) {
|
||||||
|
Slic3r::GUI::_3DScene::deselect_volumes($self);
|
||||||
|
Slic3r::GUI::_3DScene::select_volume($self, $volume_idx);
|
||||||
# if ($self->enable_picking && ($volume_idx != -1 || ! $self->layer_editing_enabled)) {
|
# if ($self->enable_picking && ($volume_idx != -1 || ! $self->layer_editing_enabled)) {
|
||||||
|
# $self->deselect_volumes;
|
||||||
|
# $self->select_volume($volume_idx);
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
$self->deselect_volumes;
|
|
||||||
$self->select_volume($volume_idx);
|
|
||||||
|
|
||||||
if ($volume_idx != -1) {
|
if ($volume_idx != -1) {
|
||||||
my $group_id = $self->volumes->[$volume_idx]->select_group_id;
|
my $group_id = $self->volumes->[$volume_idx]->select_group_id;
|
||||||
my @volumes;
|
my @volumes;
|
||||||
if ($group_id != -1) {
|
if ($group_id != -1) {
|
||||||
$self->select_volume($_)
|
#==============================================================================================================================
|
||||||
|
Slic3r::GUI::_3DScene::select_volume($self, $_)
|
||||||
|
# $self->select_volume($_)
|
||||||
|
#==============================================================================================================================
|
||||||
for grep $self->volumes->[$_]->select_group_id == $group_id,
|
for grep $self->volumes->[$_]->select_group_id == $group_id,
|
||||||
0..$#{$self->volumes};
|
0..$#{$self->volumes};
|
||||||
}
|
}
|
||||||
|
@ -1048,23 +1053,21 @@ sub get_zoom_to_bounding_box_factor {
|
||||||
#
|
#
|
||||||
# $self->bed_polygon(offset_ex([$expolygon->contour], $bed_bb->radius * 1.7, JT_ROUND, scale(0.5))->[0]->contour->clone);
|
# $self->bed_polygon(offset_ex([$expolygon->contour], $bed_bb->radius * 1.7, JT_ROUND, scale(0.5))->[0]->contour->clone);
|
||||||
#}
|
#}
|
||||||
#==============================================================================================================================
|
#
|
||||||
|
#sub deselect_volumes {
|
||||||
sub deselect_volumes {
|
# my ($self) = @_;
|
||||||
my ($self) = @_;
|
# $_->set_selected(0) for @{$self->volumes};
|
||||||
$_->set_selected(0) for @{$self->volumes};
|
#}
|
||||||
}
|
#
|
||||||
|
#sub select_volume {
|
||||||
sub select_volume {
|
# my ($self, $volume_idx) = @_;
|
||||||
my ($self, $volume_idx) = @_;
|
#
|
||||||
|
# return if ($volume_idx >= scalar(@{$self->volumes}));
|
||||||
return if ($volume_idx >= scalar(@{$self->volumes}));
|
#
|
||||||
|
# $self->volumes->[$volume_idx]->set_selected(1)
|
||||||
$self->volumes->[$volume_idx]->set_selected(1)
|
# if $volume_idx != -1;
|
||||||
if $volume_idx != -1;
|
#}
|
||||||
}
|
#
|
||||||
|
|
||||||
#==============================================================================================================================
|
|
||||||
#sub SetCuttingPlane {
|
#sub SetCuttingPlane {
|
||||||
# my ($self, $z, $expolygons) = @_;
|
# my ($self, $z, $expolygons) = @_;
|
||||||
#
|
#
|
||||||
|
|
|
@ -1854,7 +1854,10 @@ sub list_item_deselected {
|
||||||
if ($self->{list}->GetFirstSelected == -1) {
|
if ($self->{list}->GetFirstSelected == -1) {
|
||||||
$self->select_object(undef);
|
$self->select_object(undef);
|
||||||
$self->{canvas}->Refresh;
|
$self->{canvas}->Refresh;
|
||||||
$self->{canvas3D}->deselect_volumes if $self->{canvas3D};
|
#==============================================================================================================================
|
||||||
|
Slic3r::GUI::_3DScene::deselect_volumes($self->{canvas3D}) if $self->{canvas3D};
|
||||||
|
# $self->{canvas3D}->deselect_volumes if $self->{canvas3D};
|
||||||
|
#==============================================================================================================================
|
||||||
$self->{canvas3D}->Render if $self->{canvas3D};
|
$self->{canvas3D}->Render if $self->{canvas3D};
|
||||||
}
|
}
|
||||||
undef $self->{_lecursor};
|
undef $self->{_lecursor};
|
||||||
|
|
|
@ -195,7 +195,10 @@ sub update_volumes_selection {
|
||||||
foreach my $obj_idx (0..$#{$self->{model}->objects}) {
|
foreach my $obj_idx (0..$#{$self->{model}->objects}) {
|
||||||
if ($self->{objects}[$obj_idx]->selected) {
|
if ($self->{objects}[$obj_idx]->selected) {
|
||||||
my $volume_idxs = $self->{objects_volumes_idxs}->[$obj_idx];
|
my $volume_idxs = $self->{objects_volumes_idxs}->[$obj_idx];
|
||||||
$self->select_volume($_) for @{$volume_idxs};
|
#==============================================================================================================================
|
||||||
|
Slic3r::GUI::_3DScene::select_volume($self, $_) for @{$volume_idxs};
|
||||||
|
# $self->select_volume($_) for @{$volume_idxs};
|
||||||
|
#==============================================================================================================================
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1792,6 +1792,16 @@ void _3DScene::reset_volumes(wxGLCanvas* canvas)
|
||||||
s_canvas_mgr.reset_volumes(canvas);
|
s_canvas_mgr.reset_volumes(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _3DScene::deselect_volumes(wxGLCanvas* canvas)
|
||||||
|
{
|
||||||
|
s_canvas_mgr.deselect_volumes(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _3DScene::select_volume(wxGLCanvas* canvas, unsigned int id)
|
||||||
|
{
|
||||||
|
s_canvas_mgr.select_volume(canvas, id);
|
||||||
|
}
|
||||||
|
|
||||||
DynamicPrintConfig* _3DScene::get_config(wxGLCanvas* canvas)
|
DynamicPrintConfig* _3DScene::get_config(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
return s_canvas_mgr.get_config(canvas);
|
return s_canvas_mgr.get_config(canvas);
|
||||||
|
|
|
@ -556,6 +556,8 @@ public:
|
||||||
static GLVolumeCollection* get_volumes(wxGLCanvas* canvas);
|
static GLVolumeCollection* get_volumes(wxGLCanvas* canvas);
|
||||||
static void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
|
static void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
|
||||||
static void reset_volumes(wxGLCanvas* canvas);
|
static void reset_volumes(wxGLCanvas* canvas);
|
||||||
|
static void deselect_volumes(wxGLCanvas* canvas);
|
||||||
|
static void select_volume(wxGLCanvas* canvas, unsigned int id);
|
||||||
|
|
||||||
static DynamicPrintConfig* get_config(wxGLCanvas* canvas);
|
static DynamicPrintConfig* get_config(wxGLCanvas* canvas);
|
||||||
static void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
static void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
||||||
|
|
|
@ -992,6 +992,28 @@ void GLCanvas3D::reset_volumes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::deselect_volumes()
|
||||||
|
{
|
||||||
|
if (m_volumes != nullptr)
|
||||||
|
{
|
||||||
|
for (GLVolume* vol : m_volumes->volumes)
|
||||||
|
{
|
||||||
|
if (vol != nullptr)
|
||||||
|
vol->selected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::select_volume(unsigned int id)
|
||||||
|
{
|
||||||
|
if ((m_volumes != nullptr) && (id < (unsigned int)m_volumes->volumes.size()))
|
||||||
|
{
|
||||||
|
GLVolume* vol = m_volumes->volumes[id];
|
||||||
|
if (vol != nullptr)
|
||||||
|
vol->selected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DynamicPrintConfig* GLCanvas3D::get_config()
|
DynamicPrintConfig* GLCanvas3D::get_config()
|
||||||
{
|
{
|
||||||
return m_config;
|
return m_config;
|
||||||
|
|
|
@ -285,6 +285,8 @@ public:
|
||||||
GLVolumeCollection* get_volumes();
|
GLVolumeCollection* get_volumes();
|
||||||
void set_volumes(GLVolumeCollection* volumes);
|
void set_volumes(GLVolumeCollection* volumes);
|
||||||
void reset_volumes();
|
void reset_volumes();
|
||||||
|
void deselect_volumes();
|
||||||
|
void select_volume(unsigned int id);
|
||||||
|
|
||||||
DynamicPrintConfig* get_config();
|
DynamicPrintConfig* get_config();
|
||||||
void set_config(DynamicPrintConfig* config);
|
void set_config(DynamicPrintConfig* config);
|
||||||
|
|
|
@ -200,6 +200,20 @@ void GLCanvas3DManager::reset_volumes(wxGLCanvas* canvas)
|
||||||
it->second->reset_volumes();
|
it->second->reset_volumes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3DManager::deselect_volumes(wxGLCanvas* canvas)
|
||||||
|
{
|
||||||
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
if (it != m_canvases.end())
|
||||||
|
it->second->deselect_volumes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas3DManager::select_volume(wxGLCanvas* canvas, unsigned int id)
|
||||||
|
{
|
||||||
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
if (it != m_canvases.end())
|
||||||
|
it->second->select_volume(id);
|
||||||
|
}
|
||||||
|
|
||||||
DynamicPrintConfig* GLCanvas3DManager::get_config(wxGLCanvas* canvas)
|
DynamicPrintConfig* GLCanvas3DManager::get_config(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||||
|
|
|
@ -64,6 +64,8 @@ public:
|
||||||
GLVolumeCollection* get_volumes(wxGLCanvas* canvas);
|
GLVolumeCollection* get_volumes(wxGLCanvas* canvas);
|
||||||
void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
|
void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
|
||||||
void reset_volumes(wxGLCanvas* canvas);
|
void reset_volumes(wxGLCanvas* canvas);
|
||||||
|
void deselect_volumes(wxGLCanvas* canvas);
|
||||||
|
void select_volume(wxGLCanvas* canvas, unsigned int id);
|
||||||
|
|
||||||
DynamicPrintConfig* get_config(wxGLCanvas* canvas);
|
DynamicPrintConfig* get_config(wxGLCanvas* canvas);
|
||||||
void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
||||||
|
|
|
@ -251,6 +251,19 @@ reset_volumes(canvas)
|
||||||
CODE:
|
CODE:
|
||||||
_3DScene::reset_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
_3DScene::reset_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||||
|
|
||||||
|
void
|
||||||
|
deselect_volumes(canvas)
|
||||||
|
SV *canvas;
|
||||||
|
CODE:
|
||||||
|
_3DScene::deselect_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||||
|
|
||||||
|
void
|
||||||
|
select_volume(canvas, id)
|
||||||
|
SV *canvas;
|
||||||
|
unsigned int id;
|
||||||
|
CODE:
|
||||||
|
_3DScene::select_volume((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), id);
|
||||||
|
|
||||||
DynamicPrintConfig*
|
DynamicPrintConfig*
|
||||||
get_config(canvas)
|
get_config(canvas)
|
||||||
SV *canvas;
|
SV *canvas;
|
||||||
|
|
Loading…
Reference in a new issue