3DScene bed origin moved to c++
This commit is contained in:
parent
7519e34507
commit
75f1f832aa
8 changed files with 108 additions and 12 deletions
|
@ -53,7 +53,6 @@ __PACKAGE__->mk_accessors( qw(_quat init
|
||||||
bed_grid_lines
|
bed_grid_lines
|
||||||
bed_polygon
|
bed_polygon
|
||||||
background
|
background
|
||||||
origin
|
|
||||||
_mouse_pos
|
_mouse_pos
|
||||||
_hover_volume_idx
|
_hover_volume_idx
|
||||||
|
|
||||||
|
@ -997,7 +996,10 @@ sub set_auto_bed_shape {
|
||||||
[ $center->x - $max_size, $center->y + $max_size ], #++
|
[ $center->x - $max_size, $center->y + $max_size ], #++
|
||||||
]);
|
]);
|
||||||
# Set the origin for painting of the coordinate system axes.
|
# Set the origin for painting of the coordinate system axes.
|
||||||
$self->origin(Slic3r::Pointf->new(@$center[X,Y]));
|
#==============================================================================================================================
|
||||||
|
Slic3r::GUI::_3DScene::set_bed_origin($self, Slic3r::Pointf->new(@$center[X,Y]));
|
||||||
|
# $self->origin(Slic3r::Pointf->new(@$center[X,Y]));
|
||||||
|
#==============================================================================================================================
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set the bed shape to a single closed 2D polygon (array of two element arrays),
|
# Set the bed shape to a single closed 2D polygon (array of two element arrays),
|
||||||
|
@ -1048,7 +1050,10 @@ sub set_bed_shape {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set the origin for painting of the coordinate system axes.
|
# Set the origin for painting of the coordinate system axes.
|
||||||
$self->origin(Slic3r::Pointf->new(0,0));
|
#==============================================================================================================================
|
||||||
|
Slic3r::GUI::_3DScene::set_bed_origin($self, Slic3r::Pointf->new(0,0));
|
||||||
|
# $self->origin(Slic3r::Pointf->new(0,0));
|
||||||
|
#==============================================================================================================================
|
||||||
|
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
@ -1548,7 +1553,10 @@ sub Render {
|
||||||
# draw axes
|
# draw axes
|
||||||
# disable depth testing so that axes are not covered by ground
|
# disable depth testing so that axes are not covered by ground
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
my $origin = $self->origin;
|
#==============================================================================================================================
|
||||||
|
my $origin = Slic3r::GUI::_3DScene::get_bed_origin($self);
|
||||||
|
# my $origin = $self->origin;
|
||||||
|
#==============================================================================================================================
|
||||||
my $axis_len = $self->use_plain_shader ? 0.3 * max(@{ $self->bed_bounding_box->size }) : 2 * max(@{ $volumes_bb->size });
|
my $axis_len = $self->use_plain_shader ? 0.3 * max(@{ $self->bed_bounding_box->size }) : 2 * max(@{ $volumes_bb->size });
|
||||||
glLineWidth(2);
|
glLineWidth(2);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
@ -1906,10 +1914,18 @@ sub draw_legend {
|
||||||
|
|
||||||
my ($cw, $ch) = $self->GetSizeWH;
|
my ($cw, $ch) = $self->GetSizeWH;
|
||||||
|
|
||||||
my $l = (-0.5 * $cw) / $self->_zoom;
|
#==============================================================================================================================
|
||||||
my $t = (0.5 * $ch) / $self->_zoom;
|
my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self);
|
||||||
my $r = $l + $tex_w / $self->_zoom;
|
my $l = (-0.5 * $cw) / $zoom;
|
||||||
my $b = $t - $tex_h / $self->_zoom;
|
my $t = (0.5 * $ch) / $zoom;
|
||||||
|
my $r = $l + $tex_w / $zoom;
|
||||||
|
my $b = $t - $tex_h / $zoom;
|
||||||
|
|
||||||
|
# my $l = (-0.5 * $cw) / $self->_zoom;
|
||||||
|
# my $t = (0.5 * $ch) / $self->_zoom;
|
||||||
|
# my $r = $l + $tex_w / $self->_zoom;
|
||||||
|
# my $b = $t - $tex_h / $self->_zoom;
|
||||||
|
#==============================================================================================================================
|
||||||
$self->_render_texture($tex_id, $l, $r, $b, $t);
|
$self->_render_texture($tex_id, $l, $r, $b, $t);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -1939,10 +1955,18 @@ sub draw_warning {
|
||||||
|
|
||||||
my ($cw, $ch) = $self->GetSizeWH;
|
my ($cw, $ch) = $self->GetSizeWH;
|
||||||
|
|
||||||
my $l = (-0.5 * $tex_w) / $self->_zoom;
|
#==============================================================================================================================
|
||||||
my $t = (-0.5 * $ch + $tex_h) / $self->_zoom;
|
my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self);
|
||||||
my $r = $l + $tex_w / $self->_zoom;
|
my $l = (-0.5 * $tex_w) / $zoom;
|
||||||
my $b = $t - $tex_h / $self->_zoom;
|
my $t = (-0.5 * $ch + $tex_h) / $zoom;
|
||||||
|
my $r = $l + $tex_w / $zoom;
|
||||||
|
my $b = $t - $tex_h / $zoom;
|
||||||
|
|
||||||
|
# my $l = (-0.5 * $tex_w) / $self->_zoom;
|
||||||
|
# my $t = (-0.5 * $ch + $tex_h) / $self->_zoom;
|
||||||
|
# my $r = $l + $tex_w / $self->_zoom;
|
||||||
|
# my $b = $t - $tex_h / $self->_zoom;
|
||||||
|
#==============================================================================================================================
|
||||||
$self->_render_texture($tex_id, $l, $r, $b, $t);
|
$self->_render_texture($tex_id, $l, $r, $b, $t);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
|
@ -1767,6 +1767,17 @@ void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
|
||||||
return s_canvas_mgr.set_bed_shape(canvas, shape);
|
return s_canvas_mgr.set_bed_shape(canvas, shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pointf _3DScene::get_bed_origin(wxGLCanvas* canvas)
|
||||||
|
{
|
||||||
|
return s_canvas_mgr.get_bed_origin(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _3DScene::set_bed_origin(wxGLCanvas* canvas, const Pointf* origin)
|
||||||
|
{
|
||||||
|
if (origin != nullptr)
|
||||||
|
s_canvas_mgr.set_bed_origin(canvas, *origin);
|
||||||
|
}
|
||||||
|
|
||||||
BoundingBoxf3 _3DScene::get_bed_bounding_box(wxGLCanvas* canvas)
|
BoundingBoxf3 _3DScene::get_bed_bounding_box(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
return s_canvas_mgr.get_bed_bounding_box(canvas);
|
return s_canvas_mgr.get_bed_bounding_box(canvas);
|
||||||
|
|
|
@ -551,6 +551,9 @@ public:
|
||||||
|
|
||||||
static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
||||||
|
|
||||||
|
static Pointf get_bed_origin(wxGLCanvas* canvas);
|
||||||
|
static void set_bed_origin(wxGLCanvas* canvas, const Pointf* origin);
|
||||||
|
|
||||||
static BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas);
|
static BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas);
|
||||||
static BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas);
|
static BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas);
|
||||||
static BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas);
|
static BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas);
|
||||||
|
|
|
@ -119,6 +119,16 @@ const BoundingBoxf3& GLCanvas3D::Bed::get_bounding_box() const
|
||||||
return m_bounding_box;
|
return m_bounding_box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Pointf& GLCanvas3D::Bed::get_origin() const
|
||||||
|
{
|
||||||
|
return m_origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::Bed::set_origin(const Pointf& origin)
|
||||||
|
{
|
||||||
|
m_origin = origin;
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::Bed::_calc_bounding_box()
|
void GLCanvas3D::Bed::_calc_bounding_box()
|
||||||
{
|
{
|
||||||
m_bounding_box = BoundingBoxf3();
|
m_bounding_box = BoundingBoxf3();
|
||||||
|
@ -235,6 +245,16 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape)
|
||||||
m_bed.set_shape(shape);
|
m_bed.set_shape(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Pointf& GLCanvas3D::get_bed_origin() const
|
||||||
|
{
|
||||||
|
return m_bed.get_origin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::set_bed_origin(const Pointf& origin)
|
||||||
|
{
|
||||||
|
m_bed.set_origin(origin);
|
||||||
|
}
|
||||||
|
|
||||||
bool GLCanvas3D::is_dirty() const
|
bool GLCanvas3D::is_dirty() const
|
||||||
{
|
{
|
||||||
return m_dirty;
|
return m_dirty;
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
{
|
{
|
||||||
Pointfs m_shape;
|
Pointfs m_shape;
|
||||||
BoundingBoxf3 m_bounding_box;
|
BoundingBoxf3 m_bounding_box;
|
||||||
|
Pointf m_origin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Pointfs& get_shape() const;
|
const Pointfs& get_shape() const;
|
||||||
|
@ -71,6 +72,9 @@ public:
|
||||||
|
|
||||||
const BoundingBoxf3& get_bounding_box() const;
|
const BoundingBoxf3& get_bounding_box() const;
|
||||||
|
|
||||||
|
const Pointf& get_origin() const;
|
||||||
|
void set_origin(const Pointf& origin);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _calc_bounding_box();
|
void _calc_bounding_box();
|
||||||
};
|
};
|
||||||
|
@ -103,6 +107,9 @@ public:
|
||||||
|
|
||||||
void set_bed_shape(const Pointfs& shape);
|
void set_bed_shape(const Pointfs& shape);
|
||||||
|
|
||||||
|
const Pointf& get_bed_origin() const;
|
||||||
|
void set_bed_origin(const Pointf& origin);
|
||||||
|
|
||||||
bool is_dirty() const;
|
bool is_dirty() const;
|
||||||
void set_dirty(bool dirty);
|
void set_dirty(bool dirty);
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,19 @@ void GLCanvas3DManager::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
|
||||||
it->second->set_bed_shape(shape);
|
it->second->set_bed_shape(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pointf GLCanvas3DManager::get_bed_origin(wxGLCanvas* canvas) const
|
||||||
|
{
|
||||||
|
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||||
|
return (it != m_canvases.end()) ? it->second->get_bed_origin() : Pointf();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas3DManager::set_bed_origin(wxGLCanvas* canvas, const Pointf& origin)
|
||||||
|
{
|
||||||
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
if (it != m_canvases.end())
|
||||||
|
it->second->set_bed_origin(origin);
|
||||||
|
}
|
||||||
|
|
||||||
BoundingBoxf3 GLCanvas3DManager::get_bed_bounding_box(wxGLCanvas* canvas)
|
BoundingBoxf3 GLCanvas3DManager::get_bed_bounding_box(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||||
|
|
|
@ -61,6 +61,9 @@ public:
|
||||||
|
|
||||||
void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
||||||
|
|
||||||
|
Pointf get_bed_origin(wxGLCanvas* canvas) const;
|
||||||
|
void set_bed_origin(wxGLCanvas* canvas, const Pointf& origin);
|
||||||
|
|
||||||
BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas);
|
BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas);
|
||||||
BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas);
|
BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas);
|
||||||
BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas);
|
BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas);
|
||||||
|
|
|
@ -215,6 +215,21 @@ set_bed_shape(canvas, shape)
|
||||||
CODE:
|
CODE:
|
||||||
_3DScene::set_bed_shape((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), shape);
|
_3DScene::set_bed_shape((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), shape);
|
||||||
|
|
||||||
|
Clone<Pointf>
|
||||||
|
get_bed_origin(canvas)
|
||||||
|
SV *canvas;
|
||||||
|
CODE:
|
||||||
|
RETVAL = _3DScene::get_bed_origin((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||||
|
OUTPUT:
|
||||||
|
RETVAL
|
||||||
|
|
||||||
|
void
|
||||||
|
set_bed_origin(canvas, origin)
|
||||||
|
SV *canvas;
|
||||||
|
Pointf *origin
|
||||||
|
CODE:
|
||||||
|
_3DScene::set_bed_origin((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), origin);
|
||||||
|
|
||||||
Clone<BoundingBoxf3>
|
Clone<BoundingBoxf3>
|
||||||
get_bed_bounding_box(canvas)
|
get_bed_bounding_box(canvas)
|
||||||
SV *canvas;
|
SV *canvas;
|
||||||
|
|
Loading…
Reference in a new issue