Removed 3DScene volumes from perl

This commit is contained in:
Enrico Turri 2018-06-11 13:48:02 +02:00
parent efe6a29032
commit 085110c4d9
11 changed files with 160 additions and 44 deletions

View File

@ -34,9 +34,6 @@ use Wx::GLCanvas qw(:all);
# volumes: reference to vector of Slic3r::GUI::3DScene::Volume.
#==============================================================================================================================
__PACKAGE__->mk_accessors( qw(
volumes
) );
#__PACKAGE__->mk_accessors( qw(_quat _dirty init
# enable_picking
# enable_moving
@ -165,17 +162,11 @@ sub new {
# $self->use_plain_shader(0);
# $self->_apply_zoom_to_volumes_filter(0);
# $self->_mouse_dragging(0);
#==============================================================================================================================
# Collection of GLVolume objects
$self->volumes(Slic3r::GUI::_3DScene::GLVolume::Collection->new);
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_volumes($self, $self->volumes);
Slic3r::GUI::_3DScene::reset_volumes($self);
#==============================================================================================================================
# 3D point in model space
#==============================================================================================================================
#
# # Collection of GLVolume objects
# $self->volumes(Slic3r::GUI::_3DScene::GLVolume::Collection->new);
#
# # 3D point in model space
# $self->_camera_type('ortho');
## $self->_camera_type('perspective');
# $self->_camera_target(Slic3r::Pointf3->new(0,0,0));

View File

@ -2109,7 +2109,10 @@ sub object_list_changed {
}
my $export_in_progress = $self->{export_gcode_output_file} || $self->{send_gcode_file};
my $model_fits = $self->{canvas3D} ? $self->{canvas3D}->volumes->check_outside_state($self->{config}) : 1;
#==============================================================================================================================
my $model_fits = $self->{canvas3D} ? Slic3r::GUI::_3DScene::check_volumes_outside_state($self->{canvas3D}, $self->{config}) : 1;
# my $model_fits = $self->{canvas3D} ? $self->{canvas3D}->volumes->check_outside_state($self->{config}) : 1;
#==============================================================================================================================
my $method = ($have_objects && ! $export_in_progress && $model_fits) ? 'Enable' : 'Disable';
$self->{"btn_$_"}->$method
for grep $self->{"btn_$_"}, qw(reslice export_gcode print send_gcode);

View File

@ -398,10 +398,11 @@ sub load_print {
# $self->canvas->reset_legend_texture();
#==============================================================================================================================
} else {
$self->{force_sliders_full_range} = (scalar(@{$self->canvas->volumes}) == 0);
#==============================================================================================================================
$self->{force_sliders_full_range} = (Slic3r::GUI::_3DScene::get_volumes_count($self->canvas) == 0);
Slic3r::GUI::_3DScene::set_print($self->canvas, $self->print);
Slic3r::GUI::_3DScene::load_gcode_preview($self->canvas, $self->gcode_preview_data, \@colors);
# $self->{force_sliders_full_range} = (scalar(@{$self->canvas->volumes}) == 0);
# $self->canvas->load_gcode_preview($self->print, $self->gcode_preview_data, \@colors);
#==============================================================================================================================
$self->show_hide_ui_elements('full');

View File

@ -280,7 +280,10 @@ sub selection_changed {
# deselect all meshes
if ($self->{canvas}) {
$_->set_selected(0) for @{$self->{canvas}->volumes};
#==============================================================================================================================
Slic3r::GUI::_3DScene::deselect_volumes($self->{canvas});
# $_->set_selected(0) for @{$self->{canvas}->volumes};
#==============================================================================================================================
}
# disable things as if nothing is selected
@ -308,7 +311,10 @@ sub selection_changed {
if ($itemData->{type} eq 'volume') {
# select volume in 3D preview
if ($self->{canvas}) {
$self->{canvas}->volumes->[ $itemData->{volume_id} ]->set_selected(1);
#==============================================================================================================================
Slic3r::GUI::_3DScene::select_volume($self->{canvas}, $itemData->{volume_id});
# $self->{canvas}->volumes->[ $itemData->{volume_id} ]->set_selected(1);
#==============================================================================================================================
}
$self->{btn_delete}->Enable;
$self->{btn_split}->Enable;
@ -450,7 +456,10 @@ sub on_btn_move_up {
if ($itemData && $itemData->{type} eq 'volume') {
my $volume_id = $itemData->{volume_id};
if ($self->{model_object}->move_volume_up($volume_id)) {
$self->{canvas}->volumes->move_volume_up($volume_id);
#==============================================================================================================================
Slic3r::GUI::_3DScene::move_volume_up($self->{canvas}, $volume_id);
# $self->{canvas}->volumes->move_volume_up($volume_id);
#==============================================================================================================================
$self->{parts_changed} = 1;
$self->reload_tree($volume_id - 1);
}
@ -463,7 +472,10 @@ sub on_btn_move_down {
if ($itemData && $itemData->{type} eq 'volume') {
my $volume_id = $itemData->{volume_id};
if ($self->{model_object}->move_volume_down($volume_id)) {
$self->{canvas}->volumes->move_volume_down($volume_id);
#==============================================================================================================================
Slic3r::GUI::_3DScene::move_volume_down($self->{canvas}, $volume_id);
# $self->{canvas}->volumes->move_volume_down($volume_id);
#==============================================================================================================================
$self->{parts_changed} = 1;
$self->reload_tree($volume_id + 1);
}
@ -570,7 +582,10 @@ sub _update_canvas {
# restore selection, if any
if (my $itemData = $self->get_selection) {
if ($itemData->{type} eq 'volume') {
$self->{canvas}->volumes->[ $itemData->{volume_id} ]->set_selected(1);
#==============================================================================================================================
Slic3r::GUI::_3DScene::select_volume($self->{canvas}, $itemData->{volume_id});
# $self->{canvas}->volumes->[ $itemData->{volume_id} ]->set_selected(1);
#==============================================================================================================================
}
}

View File

@ -1802,9 +1802,9 @@ bool _3DScene::is_shown_on_screen(wxGLCanvas* canvas)
return s_canvas_mgr.is_shown_on_screen(canvas);
}
void _3DScene::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes)
unsigned int _3DScene::get_volumes_count(wxGLCanvas* canvas)
{
s_canvas_mgr.set_volumes(canvas, volumes);
return s_canvas_mgr.get_volumes_count(canvas);
}
void _3DScene::reset_volumes(wxGLCanvas* canvas)
@ -1827,6 +1827,21 @@ void _3DScene::update_volumes_selection(wxGLCanvas* canvas, const std::vector<in
s_canvas_mgr.update_volumes_selection(canvas, selections);
}
bool _3DScene::check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config)
{
return s_canvas_mgr.check_volumes_outside_state(canvas, config);
}
bool _3DScene::move_volume_up(wxGLCanvas* canvas, unsigned int id)
{
return s_canvas_mgr.move_volume_up(canvas, id);
}
bool _3DScene::move_volume_down(wxGLCanvas* canvas, unsigned int id)
{
return s_canvas_mgr.move_volume_down(canvas, id);
}
void _3DScene::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections)
{
s_canvas_mgr.set_objects_selections(canvas, selections);

View File

@ -558,11 +558,14 @@ public:
static bool is_shown_on_screen(wxGLCanvas* canvas);
static void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
static unsigned int get_volumes_count(wxGLCanvas* canvas);
static void reset_volumes(wxGLCanvas* canvas);
static void deselect_volumes(wxGLCanvas* canvas);
static void select_volume(wxGLCanvas* canvas, unsigned int id);
static void update_volumes_selection(wxGLCanvas* canvas, const std::vector<int>& selections);
static bool check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config);
static bool move_volume_up(wxGLCanvas* canvas, unsigned int id);
static bool move_volume_down(wxGLCanvas* canvas, unsigned int id);
static void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections);

View File

@ -24,10 +24,6 @@
#include <iostream>
#include <float.h>
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#include "SVG.hpp"
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
static const float TRACKBALLSIZE = 0.8f;
static const float GIMBALL_LOCK_THETA_MAX = 180.0f;
static const float GROUND_Z = -0.02f;
@ -661,7 +657,6 @@ bool GLCanvas3D::Bed::_are_equal(const Pointfs& bed_1, const Pointfs& bed_2)
return true;
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
GLCanvas3D::Axes::Axes()
: length(0.0f)
@ -1212,15 +1207,18 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
, m_reload_delayed(false)
{
if (m_canvas != nullptr)
{
m_timer = new wxTimer(m_canvas);
m_volumes = new GLVolumeCollection;
}
}
GLCanvas3D::~GLCanvas3D()
{
if (m_volumes != nullptr)
{
set_current();
m_volumes->release_geometry();
reset_volumes();
delete m_volumes;
}
if (m_timer != nullptr)
@ -1317,9 +1315,9 @@ bool GLCanvas3D::is_shown_on_screen() const
return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false;
}
void GLCanvas3D::set_volumes(GLVolumeCollection* volumes)
unsigned int GLCanvas3D::get_volumes_count() const
{
m_volumes = volumes;
return (m_volumes != nullptr) ? (unsigned int)m_volumes->volumes.size() : 0;
}
void GLCanvas3D::reset_volumes()
@ -1372,6 +1370,45 @@ void GLCanvas3D::update_volumes_selection(const std::vector<int>& selections)
}
}
bool GLCanvas3D::check_volumes_outside_state(const DynamicPrintConfig* config) const
{
return (m_volumes != nullptr) ? m_volumes->check_outside_state(config) : false;
}
bool GLCanvas3D::move_volume_up(unsigned int id)
{
if (m_volumes != nullptr)
{
if ((id > 0) && (id < (unsigned int)m_volumes->volumes.size()))
{
std::swap(m_volumes->volumes[id - 1], m_volumes->volumes[id]);
std::swap(m_volumes->volumes[id - 1]->composite_id, m_volumes->volumes[id]->composite_id);
std::swap(m_volumes->volumes[id - 1]->select_group_id, m_volumes->volumes[id]->select_group_id);
std::swap(m_volumes->volumes[id - 1]->drag_group_id, m_volumes->volumes[id]->drag_group_id);
return true;
}
}
return false;
}
bool GLCanvas3D::move_volume_down(unsigned int id)
{
if (m_volumes != nullptr)
{
if ((id >= 0) && (id + 1 < (unsigned int)m_volumes->volumes.size()))
{
std::swap(m_volumes->volumes[id + 1], m_volumes->volumes[id]);
std::swap(m_volumes->volumes[id + 1]->composite_id, m_volumes->volumes[id]->composite_id);
std::swap(m_volumes->volumes[id + 1]->select_group_id, m_volumes->volumes[id]->select_group_id);
std::swap(m_volumes->volumes[id + 1]->drag_group_id, m_volumes->volumes[id]->drag_group_id);
return true;
}
}
return false;
}
void GLCanvas3D::set_objects_selections(const std::vector<int>& selections)
{
m_objects_selections = selections;

View File

@ -419,11 +419,14 @@ public:
bool is_shown_on_screen() const;
void set_volumes(GLVolumeCollection* volumes);
unsigned int get_volumes_count() const;
void reset_volumes();
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;
bool move_volume_up(unsigned int id);
bool move_volume_down(unsigned int id);
void set_objects_selections(const std::vector<int>& selections);

View File

@ -226,11 +226,10 @@ bool GLCanvas3DManager::is_shown_on_screen(wxGLCanvas* canvas) const
return (it != m_canvases.end()) ? it->second->is_shown_on_screen() : false;
}
void GLCanvas3DManager::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes)
unsigned int GLCanvas3DManager::get_volumes_count(wxGLCanvas* canvas) const
{
CanvasesMap::iterator it = _get_canvas(canvas);
if (it != m_canvases.end())
it->second->set_volumes(volumes);
CanvasesMap::const_iterator it = _get_canvas(canvas);
return (it != m_canvases.end()) ? it->second->get_volumes_count() : 0;
}
void GLCanvas3DManager::reset_volumes(wxGLCanvas* canvas)
@ -261,6 +260,24 @@ void GLCanvas3DManager::update_volumes_selection(wxGLCanvas* canvas, const std::
it->second->update_volumes_selection(selections);
}
bool GLCanvas3DManager::check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config) const
{
CanvasesMap::const_iterator it = _get_canvas(canvas);
return (it != m_canvases.end()) ? it->second->check_volumes_outside_state(config) : false;
}
bool GLCanvas3DManager::move_volume_up(wxGLCanvas* canvas, unsigned int id)
{
CanvasesMap::const_iterator it = _get_canvas(canvas);
return (it != m_canvases.end()) ? it->second->move_volume_up(id) : false;
}
bool GLCanvas3DManager::move_volume_down(wxGLCanvas* canvas, unsigned int id)
{
CanvasesMap::const_iterator it = _get_canvas(canvas);
return (it != m_canvases.end()) ? it->second->move_volume_down(id) : false;
}
void GLCanvas3DManager::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections)
{
CanvasesMap::iterator it = _get_canvas(canvas);

View File

@ -53,11 +53,14 @@ public:
bool is_shown_on_screen(wxGLCanvas* canvas) const;
void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
unsigned int get_volumes_count(wxGLCanvas* canvas) const;
void reset_volumes(wxGLCanvas* canvas);
void deselect_volumes(wxGLCanvas* canvas);
void select_volume(wxGLCanvas* canvas, unsigned int id);
void update_volumes_selection(wxGLCanvas* canvas, const std::vector<int>& selections);
bool check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config) const;
bool move_volume_up(wxGLCanvas* canvas, unsigned int id);
bool move_volume_down(wxGLCanvas* canvas, unsigned int id);
void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections);

View File

@ -199,12 +199,13 @@ is_shown_on_screen(canvas)
OUTPUT:
RETVAL
void
set_volumes(canvas, volumes)
SV *canvas;
GLVolumeCollection *volumes;
unsigned int
get_volumes_count(canvas)
SV *canvas;
CODE:
_3DScene::set_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), volumes);
RETVAL = _3DScene::get_volumes_count((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
OUTPUT:
RETVAL
void
reset_volumes(canvas)
@ -232,6 +233,33 @@ update_volumes_selection(canvas, selections)
CODE:
_3DScene::update_volumes_selection((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), selections);
bool
check_volumes_outside_state(canvas, config)
SV *canvas;
DynamicPrintConfig *config;
CODE:
RETVAL = _3DScene::check_volumes_outside_state((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), config);
OUTPUT:
RETVAL
bool
move_volume_up(canvas, id)
SV *canvas;
unsigned int id;
CODE:
RETVAL = _3DScene::move_volume_up((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), id);
OUTPUT:
RETVAL
bool
move_volume_down(canvas, id)
SV *canvas;
unsigned int id;
CODE:
RETVAL = _3DScene::move_volume_down((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), id);
OUTPUT:
RETVAL
void
set_objects_selections(canvas, selections)
SV *canvas;