3DScene reset_object method moved to c++
This commit is contained in:
parent
5fc8fdee11
commit
a7fc57a176
12 changed files with 135 additions and 31 deletions
|
@ -110,7 +110,9 @@ __PACKAGE__->mk_accessors( qw(_quat init
|
|||
|
||||
use constant TRACKBALLSIZE => 0.8;
|
||||
use constant TURNTABLE_MODE => 1;
|
||||
use constant GROUND_Z => -0.02;
|
||||
#==============================================================================================================================
|
||||
#use constant GROUND_Z => -0.02;
|
||||
#==============================================================================================================================
|
||||
# For mesh selection: Not selected - bright yellow.
|
||||
use constant DEFAULT_COLOR => [1,1,0];
|
||||
# For mesh selection: Selected - bright green.
|
||||
|
@ -127,13 +129,11 @@ use constant HOVER_COLOR => [0.4,0.9,0,1];
|
|||
#use constant VIEW_BOTTOM => [0.0,180.0];
|
||||
#use constant VIEW_FRONT => [0.0,90.0];
|
||||
#use constant VIEW_REAR => [180.0,90.0];
|
||||
#==============================================================================================================================
|
||||
|
||||
use constant MANIPULATION_IDLE => 0;
|
||||
use constant MANIPULATION_DRAGGING => 1;
|
||||
use constant MANIPULATION_LAYER_HEIGHT => 2;
|
||||
|
||||
#==============================================================================================================================
|
||||
#
|
||||
#use constant MANIPULATION_IDLE => 0;
|
||||
#use constant MANIPULATION_DRAGGING => 1;
|
||||
#use constant MANIPULATION_LAYER_HEIGHT => 2;
|
||||
#
|
||||
#use constant GIMBALL_LOCK_THETA_MAX => 180;
|
||||
#==============================================================================================================================
|
||||
|
||||
|
@ -223,7 +223,10 @@ sub new {
|
|||
$self->{layer_height_edit_last_z} = 0.;
|
||||
$self->{layer_height_edit_last_action} = 0;
|
||||
|
||||
$self->reset_objects;
|
||||
#==============================================================================================================================
|
||||
Slic3r::GUI::_3DScene::reset_volumes($self);
|
||||
# $self->reset_objects;
|
||||
#==============================================================================================================================
|
||||
|
||||
EVT_PAINT($self, sub {
|
||||
my $dc = Wx::PaintDC->new($self);
|
||||
|
@ -723,19 +726,18 @@ sub mouse_wheel_event {
|
|||
$self->Refresh;
|
||||
}
|
||||
|
||||
# Reset selection.
|
||||
sub reset_objects {
|
||||
my ($self) = @_;
|
||||
if ($self->GetContext) {
|
||||
$self->SetCurrent($self->GetContext);
|
||||
$self->volumes->release_geometry;
|
||||
}
|
||||
$self->volumes->erase;
|
||||
#==============================================================================================================================
|
||||
Slic3r::GUI::_3DScene::set_dirty($self, 1);
|
||||
## Reset selection.
|
||||
#sub reset_objects {
|
||||
# my ($self) = @_;
|
||||
# if ($self->GetContext) {
|
||||
# $self->SetCurrent($self->GetContext);
|
||||
# $self->volumes->release_geometry;
|
||||
# }
|
||||
# $self->volumes->erase;
|
||||
# $self->_dirty(1);
|
||||
#}
|
||||
#==============================================================================================================================
|
||||
}
|
||||
|
||||
# Setup camera to view all objects.
|
||||
sub set_viewport_from_scene {
|
||||
|
@ -1515,8 +1517,10 @@ sub Render {
|
|||
# draw ground and axes
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
# draw ground
|
||||
my $ground_z = GROUND_Z;
|
||||
#==============================================================================================================================
|
||||
# # draw ground
|
||||
# my $ground_z = GROUND_Z;
|
||||
#==============================================================================================================================
|
||||
#==============================================================================================================================
|
||||
Slic3r::GUI::_3DScene::render_bed($self);
|
||||
|
||||
|
|
|
@ -197,7 +197,10 @@ sub update_volumes_selection {
|
|||
sub reload_scene {
|
||||
my ($self, $force) = @_;
|
||||
|
||||
$self->reset_objects;
|
||||
#==============================================================================================================================
|
||||
Slic3r::GUI::_3DScene::reset_volumes($self);
|
||||
# $self->reset_objects;
|
||||
#==============================================================================================================================
|
||||
$self->update_bed_size;
|
||||
|
||||
if (! $self->IsShown && ! $force) {
|
||||
|
|
|
@ -277,8 +277,11 @@ sub new {
|
|||
|
||||
sub reload_print {
|
||||
my ($self, $force) = @_;
|
||||
|
||||
$self->canvas->reset_objects;
|
||||
|
||||
#==============================================================================================================================
|
||||
Slic3r::GUI::_3DScene::reset_volumes($self->canvas);
|
||||
# $self->canvas->reset_objects;
|
||||
#==============================================================================================================================
|
||||
$self->_loaded(0);
|
||||
|
||||
if (! $self->IsShown && ! $force) {
|
||||
|
|
|
@ -254,8 +254,11 @@ sub _update {
|
|||
for @$expolygon;
|
||||
$expolygon->translate(map Slic3r::Geometry::scale($_), @{ $self->{model_object}->instances->[0]->offset });
|
||||
}
|
||||
|
||||
$self->{canvas}->reset_objects;
|
||||
|
||||
#==============================================================================================================================
|
||||
Slic3r::GUI::_3DScene::reset_volumes($self->{canvas});
|
||||
# $self->{canvas}->reset_objects;
|
||||
#==============================================================================================================================
|
||||
$self->{canvas}->load_object($_, undef, undef, [0]) for @objects;
|
||||
$self->{canvas}->SetCuttingPlane(
|
||||
$self->{cut_options}{z},
|
||||
|
|
|
@ -494,7 +494,10 @@ sub _parts_changed {
|
|||
|
||||
$self->reload_tree;
|
||||
if ($self->{canvas}) {
|
||||
$self->{canvas}->reset_objects;
|
||||
#==============================================================================================================================
|
||||
Slic3r::GUI::_3DScene::reset_volumes($self->{canvas});
|
||||
# $self->{canvas}->reset_objects;
|
||||
#==============================================================================================================================
|
||||
$self->{canvas}->load_object($self->{model_object});
|
||||
$self->{canvas}->zoom_to_volumes;
|
||||
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
|
||||
|
@ -539,7 +542,10 @@ sub _update_canvas {
|
|||
my ($self) = @_;
|
||||
|
||||
if ($self->{canvas}) {
|
||||
$self->{canvas}->reset_objects;
|
||||
#==============================================================================================================================
|
||||
Slic3r::GUI::_3DScene::reset_volumes($self->{canvas});
|
||||
# $self->{canvas}->reset_objects;
|
||||
#==============================================================================================================================
|
||||
$self->{canvas}->load_object($self->{model_object});
|
||||
|
||||
# restore selection, if any
|
||||
|
@ -572,7 +578,10 @@ sub _update {
|
|||
$self->{parts_changed} = 1;
|
||||
my @objects = ();
|
||||
push @objects, $self->{model_object};
|
||||
$self->{canvas}->reset_objects;
|
||||
#==============================================================================================================================
|
||||
Slic3r::GUI::_3DScene::reset_volumes($self->{canvas});
|
||||
# $self->{canvas}->reset_objects;
|
||||
#==============================================================================================================================
|
||||
$self->{canvas}->load_object($_, undef, [0]) for @objects;
|
||||
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
|
||||
$self->{canvas}->Render;
|
||||
|
|
|
@ -1772,6 +1772,11 @@ void _3DScene::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes)
|
|||
s_canvas_mgr.set_volumes(canvas, volumes);
|
||||
}
|
||||
|
||||
void _3DScene::reset_volumes(wxGLCanvas* canvas)
|
||||
{
|
||||
s_canvas_mgr.reset_volumes(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
|
||||
{
|
||||
return s_canvas_mgr.set_bed_shape(canvas, shape);
|
||||
|
@ -1887,6 +1892,11 @@ void _3DScene::set_camera_target(wxGLCanvas* canvas, const Pointf3* target)
|
|||
{
|
||||
s_canvas_mgr.set_camera_target(canvas, target);
|
||||
}
|
||||
|
||||
bool _3DScene::is_layers_editing_enabled(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.is_layers_editing_enabled(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::zoom_to_bed(wxGLCanvas* canvas)
|
||||
{
|
||||
|
|
|
@ -552,6 +552,8 @@ public:
|
|||
static GLVolumeCollection* get_volumes(wxGLCanvas* canvas);
|
||||
static void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
|
||||
|
||||
static void reset_volumes(wxGLCanvas* canvas);
|
||||
|
||||
static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
||||
static void set_auto_bed_shape(wxGLCanvas* canvas);
|
||||
|
||||
|
@ -586,6 +588,8 @@ public:
|
|||
static Pointf3 get_camera_target(wxGLCanvas* canvas);
|
||||
static void set_camera_target(wxGLCanvas* canvas, const Pointf3* target);
|
||||
|
||||
static bool is_layers_editing_enabled(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);
|
||||
|
|
|
@ -395,6 +395,16 @@ void GLCanvas3D::CuttingPlane::render_contour()
|
|||
::glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
GLCanvas3D::LayersEditing::LayersEditing()
|
||||
: m_enabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool GLCanvas3D::LayersEditing::is_enabled() const
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
|
||||
: m_canvas(canvas)
|
||||
, m_context(context)
|
||||
|
@ -409,10 +419,15 @@ GLCanvas3D::~GLCanvas3D()
|
|||
_deregister_callbacks();
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_current()
|
||||
bool GLCanvas3D::set_current()
|
||||
{
|
||||
if ((m_canvas != nullptr) && (m_context != nullptr))
|
||||
{
|
||||
m_canvas->SetCurrent(*m_context);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::is_dirty() const
|
||||
|
@ -507,6 +522,16 @@ void GLCanvas3D::set_volumes(GLVolumeCollection* volumes)
|
|||
m_volumes = volumes;
|
||||
}
|
||||
|
||||
void GLCanvas3D::reset_volumes()
|
||||
{
|
||||
if (set_current() && (m_volumes != nullptr))
|
||||
{
|
||||
m_volumes->release_geometry();
|
||||
m_volumes->clear();
|
||||
set_dirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_bed_shape(const Pointfs& shape)
|
||||
{
|
||||
m_bed.set_shape(shape);
|
||||
|
@ -652,6 +677,11 @@ BoundingBoxf3 GLCanvas3D::max_bounding_box() const
|
|||
return bb;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::is_layers_editing_enabled() const
|
||||
{
|
||||
return m_layers_editing.is_enabled();
|
||||
}
|
||||
|
||||
void GLCanvas3D::zoom_to_bed()
|
||||
{
|
||||
_zoom_to_bounding_box(bed_bounding_box());
|
||||
|
|
|
@ -128,6 +128,16 @@ public:
|
|||
void render_contour();
|
||||
};
|
||||
|
||||
class LayersEditing
|
||||
{
|
||||
bool m_enabled;
|
||||
|
||||
public:
|
||||
LayersEditing();
|
||||
|
||||
bool is_enabled() const;
|
||||
};
|
||||
|
||||
private:
|
||||
wxGLCanvas* m_canvas;
|
||||
wxGLContext* m_context;
|
||||
|
@ -135,6 +145,7 @@ private:
|
|||
Bed m_bed;
|
||||
Axes m_axes;
|
||||
CuttingPlane m_cutting_plane;
|
||||
LayersEditing m_layers_editing;
|
||||
|
||||
GLVolumeCollection* m_volumes;
|
||||
|
||||
|
@ -147,7 +158,7 @@ public:
|
|||
GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
|
||||
~GLCanvas3D();
|
||||
|
||||
void set_current();
|
||||
bool set_current();
|
||||
|
||||
bool is_dirty() const;
|
||||
void set_dirty(bool dirty);
|
||||
|
@ -159,6 +170,8 @@ public:
|
|||
GLVolumeCollection* get_volumes();
|
||||
void set_volumes(GLVolumeCollection* volumes);
|
||||
|
||||
void reset_volumes();
|
||||
|
||||
// Set the bed shape to a single closed 2D polygon(array of two element arrays),
|
||||
// triangulate the bed and store the triangles into m_bed.m_triangles,
|
||||
// fills the m_bed.m_grid_lines and sets m_bed.m_origin.
|
||||
|
@ -198,6 +211,8 @@ public:
|
|||
BoundingBoxf3 volumes_bounding_box() const;
|
||||
BoundingBoxf3 max_bounding_box() const;
|
||||
|
||||
bool is_layers_editing_enabled() const;
|
||||
|
||||
void zoom_to_bed();
|
||||
void zoom_to_volumes();
|
||||
void select_view(const std::string& direction);
|
||||
|
|
|
@ -187,6 +187,13 @@ void GLCanvas3DManager::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volu
|
|||
it->second->set_volumes(volumes);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::reset_volumes(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->reset_volumes();
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
@ -342,6 +349,12 @@ void GLCanvas3DManager::set_camera_target(wxGLCanvas* canvas, const Pointf3* tar
|
|||
it->second->set_camera_target(*target);
|
||||
}
|
||||
|
||||
bool GLCanvas3DManager::is_layers_editing_enabled(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->is_layers_editing_enabled() : false;
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
GLVolumeCollection* get_volumes(wxGLCanvas* canvas);
|
||||
void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
|
||||
|
||||
void reset_volumes(wxGLCanvas* canvas);
|
||||
|
||||
void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
||||
void set_auto_bed_shape(wxGLCanvas* canvas);
|
||||
|
||||
|
@ -96,6 +98,8 @@ public:
|
|||
Pointf3 get_camera_target(wxGLCanvas* canvas) const;
|
||||
void set_camera_target(wxGLCanvas* canvas, const Pointf3* target);
|
||||
|
||||
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
||||
|
||||
void zoom_to_bed(wxGLCanvas* canvas);
|
||||
void zoom_to_volumes(wxGLCanvas* canvas);
|
||||
void select_view(wxGLCanvas* canvas, const std::string& direction);
|
||||
|
|
|
@ -207,6 +207,12 @@ set_volumes(canvas, volumes)
|
|||
GLVolumeCollection *volumes;
|
||||
CODE:
|
||||
_3DScene::set_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), volumes);
|
||||
|
||||
void
|
||||
reset_volumes(canvas)
|
||||
SV *canvas;
|
||||
CODE:
|
||||
_3DScene::reset_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||
|
||||
void
|
||||
set_bed_shape(canvas, shape)
|
||||
|
|
Loading…
Reference in a new issue