Refactoring - Shared members of GLCanvas3D as references instead of pointers
This commit is contained in:
parent
b5217918cf
commit
fc70b73f45
9 changed files with 97 additions and 193 deletions
|
@ -2002,9 +2002,9 @@ std::string _3DScene::get_gl_info(bool format_as_html, bool extensions)
|
||||||
return s_canvas_mgr.get_gl_info(format_as_html, extensions);
|
return s_canvas_mgr.get_gl_info(format_as_html, extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _3DScene::add_canvas(wxGLCanvas* canvas)
|
bool _3DScene::add_canvas(wxGLCanvas* canvas, GUI::Bed3D& bed, GUI::Camera& camera, GUI::GLToolbar& view_toolbar)
|
||||||
{
|
{
|
||||||
return s_canvas_mgr.add(canvas);
|
return s_canvas_mgr.add(canvas, bed, camera, view_toolbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _3DScene::remove_canvas(wxGLCanvas* canvas)
|
bool _3DScene::remove_canvas(wxGLCanvas* canvas)
|
||||||
|
|
|
@ -25,6 +25,11 @@ inline void glAssertRecentCall() { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
namespace GUI {
|
||||||
|
class Bed3D;
|
||||||
|
struct Camera;
|
||||||
|
class GLToolbar;
|
||||||
|
} // namespace GUI
|
||||||
|
|
||||||
class Print;
|
class Print;
|
||||||
class PrintObject;
|
class PrintObject;
|
||||||
|
@ -563,7 +568,7 @@ class _3DScene
|
||||||
public:
|
public:
|
||||||
static std::string get_gl_info(bool format_as_html, bool extensions);
|
static std::string get_gl_info(bool format_as_html, bool extensions);
|
||||||
|
|
||||||
static bool add_canvas(wxGLCanvas* canvas);
|
static bool add_canvas(wxGLCanvas* canvas, GUI::Bed3D& bed, GUI::Camera& camera, GUI::GLToolbar& view_toolbar);
|
||||||
static bool remove_canvas(wxGLCanvas* canvas);
|
static bool remove_canvas(wxGLCanvas* canvas);
|
||||||
static void remove_all_canvases();
|
static void remove_all_canvases();
|
||||||
|
|
||||||
|
|
|
@ -3153,7 +3153,7 @@ void GLCanvas3D::Gizmos::do_render_overlay(const GLCanvas3D& canvas, const GLCan
|
||||||
GLTexture::render_sub_texture(icons_texture_id, top_x, top_x + scaled_icons_size, top_y - scaled_icons_size, top_y, { { left, bottom }, { right, bottom }, { right, top }, { left, top } });
|
GLTexture::render_sub_texture(icons_texture_id, top_x, top_x + scaled_icons_size, top_y - scaled_icons_size, top_y, { { left, bottom }, { right, bottom }, { right, top }, { left, top } });
|
||||||
#if ENABLE_IMGUI
|
#if ENABLE_IMGUI
|
||||||
if (it->second->get_state() == GLGizmoBase::On) {
|
if (it->second->get_state() == GLGizmoBase::On) {
|
||||||
float toolbar_top = (float)cnv_h - canvas.m_view_toolbar->get_height();
|
float toolbar_top = (float)cnv_h - canvas.m_view_toolbar.get_height();
|
||||||
#if ENABLE_SVG_ICONS
|
#if ENABLE_SVG_ICONS
|
||||||
it->second->render_input_window(2.0f * m_overlay_border + m_overlay_icons_size, 0.5f * cnv_h - top_y * zoom, toolbar_top, selection);
|
it->second->render_input_window(2.0f * m_overlay_border + m_overlay_icons_size, 0.5f * cnv_h - top_y * zoom, toolbar_top, selection);
|
||||||
#else
|
#else
|
||||||
|
@ -3673,21 +3673,21 @@ wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent);
|
||||||
|
|
||||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar)
|
||||||
: m_canvas(canvas)
|
: m_canvas(canvas)
|
||||||
, m_context(nullptr)
|
, m_context(nullptr)
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
, m_retina_helper(nullptr)
|
, m_retina_helper(nullptr)
|
||||||
#endif
|
#endif
|
||||||
, m_in_render(false)
|
, m_in_render(false)
|
||||||
, m_camera(nullptr)
|
, m_bed(bed)
|
||||||
, m_bed(nullptr)
|
, m_camera(camera)
|
||||||
|
, m_view_toolbar(view_toolbar)
|
||||||
#if ENABLE_SVG_ICONS
|
#if ENABLE_SVG_ICONS
|
||||||
, m_toolbar(GLToolbar::Normal, "Top")
|
, m_toolbar(GLToolbar::Normal, "Top")
|
||||||
#else
|
#else
|
||||||
, m_toolbar(GLToolbar::Normal)
|
, m_toolbar(GLToolbar::Normal)
|
||||||
#endif // ENABLE_SVG_ICONS
|
#endif // ENABLE_SVG_ICONS
|
||||||
, m_view_toolbar(nullptr)
|
|
||||||
, m_use_clipping_planes(false)
|
, m_use_clipping_planes(false)
|
||||||
, m_sidebar_field("")
|
, m_sidebar_field("")
|
||||||
, m_config(nullptr)
|
, m_config(nullptr)
|
||||||
|
@ -3909,12 +3909,8 @@ void GLCanvas3D::set_model(Model* model)
|
||||||
|
|
||||||
void GLCanvas3D::bed_shape_changed()
|
void GLCanvas3D::bed_shape_changed()
|
||||||
{
|
{
|
||||||
if (m_camera != nullptr)
|
m_camera.set_scene_box(scene_bounding_box());
|
||||||
{
|
m_camera.requires_zoom_to_bed = true;
|
||||||
m_camera->set_scene_box(scene_bounding_box());
|
|
||||||
m_camera->requires_zoom_to_bed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3925,7 +3921,7 @@ void GLCanvas3D::set_color_by(const std::string& value)
|
||||||
|
|
||||||
float GLCanvas3D::get_camera_zoom() const
|
float GLCanvas3D::get_camera_zoom() const
|
||||||
{
|
{
|
||||||
return (m_camera != nullptr) ? m_camera->zoom : 0.0f;
|
return m_camera.zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxf3 GLCanvas3D::volumes_bounding_box() const
|
BoundingBoxf3 GLCanvas3D::volumes_bounding_box() const
|
||||||
|
@ -3942,8 +3938,7 @@ BoundingBoxf3 GLCanvas3D::volumes_bounding_box() const
|
||||||
BoundingBoxf3 GLCanvas3D::scene_bounding_box() const
|
BoundingBoxf3 GLCanvas3D::scene_bounding_box() const
|
||||||
{
|
{
|
||||||
BoundingBoxf3 bb = volumes_bounding_box();
|
BoundingBoxf3 bb = volumes_bounding_box();
|
||||||
if (m_bed != nullptr)
|
bb.merge(m_bed.get_bounding_box());
|
||||||
bb.merge(m_bed->get_bounding_box());
|
|
||||||
|
|
||||||
if (m_config != nullptr)
|
if (m_config != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -4032,8 +4027,7 @@ bool GLCanvas3D::is_toolbar_item_pressed(const std::string& name) const
|
||||||
|
|
||||||
void GLCanvas3D::zoom_to_bed()
|
void GLCanvas3D::zoom_to_bed()
|
||||||
{
|
{
|
||||||
if (m_bed != nullptr)
|
_zoom_to_bounding_box(m_bed.get_bounding_box());
|
||||||
_zoom_to_bounding_box(m_bed->get_bounding_box());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::zoom_to_volumes()
|
void GLCanvas3D::zoom_to_volumes()
|
||||||
|
@ -4070,12 +4064,8 @@ void GLCanvas3D::select_view(const std::string& direction)
|
||||||
|
|
||||||
if (dir_vec != nullptr)
|
if (dir_vec != nullptr)
|
||||||
{
|
{
|
||||||
if (m_camera != nullptr)
|
m_camera.phi = dir_vec[0];
|
||||||
{
|
m_camera.set_theta(dir_vec[1], false);
|
||||||
m_camera->phi = dir_vec[0];
|
|
||||||
m_camera->set_theta(dir_vec[1], false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
@ -4135,18 +4125,16 @@ void GLCanvas3D::render()
|
||||||
if (!_set_current() || !_3DScene::init(m_canvas))
|
if (!_set_current() || !_3DScene::init(m_canvas))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((m_bed != nullptr) && m_bed->get_shape().empty())
|
if (m_bed.get_shape().empty())
|
||||||
{
|
|
||||||
// this happens at startup when no data is still saved under <>\AppData\Roaming\Slic3rPE
|
// this happens at startup when no data is still saved under <>\AppData\Roaming\Slic3rPE
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_UPDATE_BED_SHAPE));
|
post_event(SimpleEvent(EVT_GLCANVAS_UPDATE_BED_SHAPE));
|
||||||
}
|
|
||||||
|
|
||||||
if ((m_camera != nullptr) && m_camera->requires_zoom_to_bed)
|
if (m_camera.requires_zoom_to_bed)
|
||||||
{
|
{
|
||||||
zoom_to_bed();
|
zoom_to_bed();
|
||||||
const Size& cnv_size = get_canvas_size();
|
const Size& cnv_size = get_canvas_size();
|
||||||
_resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
|
_resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
|
||||||
m_camera->requires_zoom_to_bed = false;
|
m_camera.requires_zoom_to_bed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_camera_tranform();
|
_camera_tranform();
|
||||||
|
@ -4156,13 +4144,11 @@ void GLCanvas3D::render()
|
||||||
GLfloat position_top[4] = { -0.5f, -0.5f, 1.0f, 0.0f };
|
GLfloat position_top[4] = { -0.5f, -0.5f, 1.0f, 0.0f };
|
||||||
::glLightfv(GL_LIGHT0, GL_POSITION, position_top);
|
::glLightfv(GL_LIGHT0, GL_POSITION, position_top);
|
||||||
|
|
||||||
float theta = (m_camera != nullptr) ? m_camera->get_theta() : 0.0f;
|
float theta = m_camera.get_theta();
|
||||||
if (theta > 180.f)
|
if (theta > 180.f)
|
||||||
// absolute value of the rotation
|
// absolute value of the rotation
|
||||||
theta = 360.f - theta;
|
theta = 360.f - theta;
|
||||||
|
|
||||||
bool is_custom_bed = (m_bed == nullptr) || m_bed->is_custom();
|
|
||||||
|
|
||||||
#if ENABLE_IMGUI
|
#if ENABLE_IMGUI
|
||||||
wxGetApp().imgui()->new_frame();
|
wxGetApp().imgui()->new_frame();
|
||||||
#endif // ENABLE_IMGUI
|
#endif // ENABLE_IMGUI
|
||||||
|
@ -4175,7 +4161,7 @@ void GLCanvas3D::render()
|
||||||
_render_background();
|
_render_background();
|
||||||
|
|
||||||
// textured bed needs to be rendered after objects if the texture is transparent
|
// textured bed needs to be rendered after objects if the texture is transparent
|
||||||
bool early_bed_render = is_custom_bed || (theta <= 90.0f);
|
bool early_bed_render = m_bed.is_custom() || (theta <= 90.0f);
|
||||||
if (early_bed_render)
|
if (early_bed_render)
|
||||||
_render_bed(theta);
|
_render_bed(theta);
|
||||||
|
|
||||||
|
@ -4593,8 +4579,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||||
// restore to default value
|
// restore to default value
|
||||||
m_regenerate_volumes = true;
|
m_regenerate_volumes = true;
|
||||||
|
|
||||||
if (m_camera != nullptr)
|
m_camera.set_scene_box(scene_bounding_box());
|
||||||
m_camera->set_scene_box(scene_bounding_box());
|
|
||||||
|
|
||||||
if (m_selection.is_empty())
|
if (m_selection.is_empty())
|
||||||
{
|
{
|
||||||
|
@ -5048,7 +5033,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
m_layers_editing.select_object(*m_model, layer_editing_object_idx);
|
m_layers_editing.select_object(*m_model, layer_editing_object_idx);
|
||||||
bool gizmos_overlay_contains_mouse = m_gizmos.overlay_contains_mouse(*this, m_mouse.position);
|
bool gizmos_overlay_contains_mouse = m_gizmos.overlay_contains_mouse(*this, m_mouse.position);
|
||||||
int toolbar_contains_mouse = m_toolbar.contains_mouse(m_mouse.position, *this);
|
int toolbar_contains_mouse = m_toolbar.contains_mouse(m_mouse.position, *this);
|
||||||
int view_toolbar_contains_mouse = (m_view_toolbar != nullptr) ? m_view_toolbar->contains_mouse(m_mouse.position, *this) : -1;
|
int view_toolbar_contains_mouse = m_view_toolbar.contains_mouse(m_mouse.position, *this);
|
||||||
|
|
||||||
#if ENABLE_MOVE_MIN_THRESHOLD
|
#if ENABLE_MOVE_MIN_THRESHOLD
|
||||||
if (m_mouse.drag.move_requires_threshold && m_mouse.is_move_start_threshold_position_2D_defined() && m_mouse.is_move_threshold_met(pos))
|
if (m_mouse.drag.move_requires_threshold && m_mouse.is_move_start_threshold_position_2D_defined() && m_mouse.is_move_threshold_met(pos))
|
||||||
|
@ -5160,10 +5145,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
// event was taken care of by the SlaSupports gizmo
|
// event was taken care of by the SlaSupports gizmo
|
||||||
}
|
}
|
||||||
else if (evt.LeftDown() && (view_toolbar_contains_mouse != -1))
|
else if (evt.LeftDown() && (view_toolbar_contains_mouse != -1))
|
||||||
{
|
m_view_toolbar.do_action((unsigned int)view_toolbar_contains_mouse, *this);
|
||||||
if (m_view_toolbar != nullptr)
|
|
||||||
m_view_toolbar->do_action((unsigned int)view_toolbar_contains_mouse, *this);
|
|
||||||
}
|
|
||||||
else if (evt.LeftDown() && (toolbar_contains_mouse != -1))
|
else if (evt.LeftDown() && (toolbar_contains_mouse != -1))
|
||||||
{
|
{
|
||||||
m_toolbar_action_running = true;
|
m_toolbar_action_running = true;
|
||||||
|
@ -5281,7 +5263,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
// we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag
|
// we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag
|
||||||
if (m_selection.contains_volume(m_hover_volume_id))
|
if (m_selection.contains_volume(m_hover_volume_id))
|
||||||
{
|
{
|
||||||
if ((m_camera != nullptr) && (m_camera->get_theta() == 90.0f))
|
if (m_camera.get_theta() == 90.0f)
|
||||||
{
|
{
|
||||||
// side view -> move selected volumes orthogonally to camera view direction
|
// side view -> move selected volumes orthogonally to camera view direction
|
||||||
Linef3 ray = mouse_ray(pos);
|
Linef3 ray = mouse_ray(pos);
|
||||||
|
@ -5392,12 +5374,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
||||||
{
|
{
|
||||||
const Vec3d& orig = m_mouse.drag.start_position_3D;
|
const Vec3d& orig = m_mouse.drag.start_position_3D;
|
||||||
if (m_camera != nullptr)
|
m_camera.phi += (((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE);
|
||||||
{
|
m_camera.set_theta(m_camera.get_theta() - ((float)pos(1) - (float)orig(1)) * TRACKBALLSIZE, wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||||
m_camera->phi += (((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE);
|
|
||||||
m_camera->set_theta(m_camera->get_theta() - ((float)pos(1) - (float)orig(1)) * TRACKBALLSIZE, wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
m_mouse.drag.start_position_3D = Vec3d((double)pos(0), (double)pos(1), 0.0);
|
m_mouse.drag.start_position_3D = Vec3d((double)pos(0), (double)pos(1), 0.0);
|
||||||
|
@ -5411,9 +5389,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
float z = 0.0f;
|
float z = 0.0f;
|
||||||
const Vec3d& cur_pos = _mouse_to_3d(pos, &z);
|
const Vec3d& cur_pos = _mouse_to_3d(pos, &z);
|
||||||
Vec3d orig = _mouse_to_3d(m_mouse.drag.start_position_2D, &z);
|
Vec3d orig = _mouse_to_3d(m_mouse.drag.start_position_2D, &z);
|
||||||
if (m_camera != nullptr)
|
m_camera.set_target(m_camera.get_target() + orig - cur_pos);
|
||||||
m_camera->set_target(m_camera->get_target() + orig - cur_pos);
|
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5490,7 +5466,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
// Let the platter know that the dragging finished, so a delayed refresh
|
// Let the platter know that the dragging finished, so a delayed refresh
|
||||||
// of the scene with the background processing data should be performed.
|
// of the scene with the background processing data should be performed.
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED));
|
post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED));
|
||||||
m_camera->set_scene_box(scene_bounding_box());
|
m_camera.set_scene_box(scene_bounding_box());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_moving = false;
|
m_moving = false;
|
||||||
|
@ -5520,9 +5496,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
tooltip = m_toolbar.update_hover_state(m_mouse.position, *this);
|
tooltip = m_toolbar.update_hover_state(m_mouse.position, *this);
|
||||||
|
|
||||||
// updates view toolbar overlay
|
// updates view toolbar overlay
|
||||||
if (tooltip.empty() && (m_view_toolbar != nullptr))
|
if (tooltip.empty())
|
||||||
{
|
{
|
||||||
tooltip = m_view_toolbar->update_hover_state(m_mouse.position, *this);
|
tooltip = m_view_toolbar.update_hover_state(m_mouse.position, *this);
|
||||||
if (!tooltip.empty())
|
if (!tooltip.empty())
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
@ -5835,9 +5811,7 @@ void GLCanvas3D::set_camera_zoom(float zoom)
|
||||||
// Don't allow to zoom too close to the scene.
|
// Don't allow to zoom too close to the scene.
|
||||||
zoom = std::min(zoom, 100.0f);
|
zoom = std::min(zoom, 100.0f);
|
||||||
|
|
||||||
if (m_camera != nullptr)
|
m_camera.zoom = zoom;
|
||||||
m_camera->zoom = zoom;
|
|
||||||
|
|
||||||
_refresh_if_shown_on_screen();
|
_refresh_if_shown_on_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5872,11 +5846,8 @@ void GLCanvas3D::update_ui_from_settings()
|
||||||
if (new_scaling != orig_scaling) {
|
if (new_scaling != orig_scaling) {
|
||||||
BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Scaling factor: " << new_scaling;
|
BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Scaling factor: " << new_scaling;
|
||||||
|
|
||||||
if (m_camera != nullptr)
|
m_camera.zoom /= orig_scaling;
|
||||||
{
|
m_camera.zoom *= new_scaling;
|
||||||
m_camera->zoom /= orig_scaling;
|
|
||||||
m_camera->zoom *= new_scaling;
|
|
||||||
}
|
|
||||||
_refresh_if_shown_on_screen();
|
_refresh_if_shown_on_screen();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -6063,8 +6034,7 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
||||||
|
|
||||||
const BoundingBoxf3& bbox = _max_bounding_box();
|
const BoundingBoxf3& bbox = _max_bounding_box();
|
||||||
|
|
||||||
Camera::EType camera_type = (m_camera != nullptr) ? m_camera->type : Camera::Unknown;
|
switch (m_camera.type)
|
||||||
switch (camera_type)
|
|
||||||
{
|
{
|
||||||
case Camera::Ortho:
|
case Camera::Ortho:
|
||||||
{
|
{
|
||||||
|
@ -6121,8 +6091,7 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
||||||
BoundingBoxf3 GLCanvas3D::_max_bounding_box() const
|
BoundingBoxf3 GLCanvas3D::_max_bounding_box() const
|
||||||
{
|
{
|
||||||
BoundingBoxf3 bb = volumes_bounding_box();
|
BoundingBoxf3 bb = volumes_bounding_box();
|
||||||
if (m_bed != nullptr)
|
bb.merge(m_bed.get_bounding_box());
|
||||||
bb.merge(m_bed->get_bounding_box());
|
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6132,13 +6101,9 @@ void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox)
|
||||||
float zoom = _get_zoom_to_bounding_box_factor(bbox);
|
float zoom = _get_zoom_to_bounding_box_factor(bbox);
|
||||||
if (zoom > 0.0f)
|
if (zoom > 0.0f)
|
||||||
{
|
{
|
||||||
if (m_camera != nullptr)
|
m_camera.zoom = zoom;
|
||||||
{
|
// center view around bounding box center
|
||||||
m_camera->zoom = zoom;
|
m_camera.set_target(bbox.center());
|
||||||
// center view around bounding box center
|
|
||||||
m_camera->set_target(bbox.center());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6228,13 +6193,9 @@ void GLCanvas3D::_camera_tranform() const
|
||||||
::glMatrixMode(GL_MODELVIEW);
|
::glMatrixMode(GL_MODELVIEW);
|
||||||
::glLoadIdentity();
|
::glLoadIdentity();
|
||||||
|
|
||||||
Vec3d target = Vec3d::Zero();
|
::glRotatef(-m_camera.get_theta(), 1.0f, 0.0f, 0.0f); // pitch
|
||||||
if (m_camera != nullptr)
|
::glRotatef(m_camera.phi, 0.0f, 0.0f, 1.0f); // yaw
|
||||||
{
|
Vec3d target = -m_camera.get_target();
|
||||||
::glRotatef(-m_camera->get_theta(), 1.0f, 0.0f, 0.0f); // pitch
|
|
||||||
::glRotatef(m_camera->phi, 0.0f, 0.0f, 1.0f); // yaw
|
|
||||||
target = -m_camera->get_target();
|
|
||||||
}
|
|
||||||
::glTranslated(target(0), target(1), target(2));
|
::glTranslated(target(0), target(1), target(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6329,16 +6290,13 @@ void GLCanvas3D::_render_bed(float theta) const
|
||||||
float scale_factor = 1.0;
|
float scale_factor = 1.0;
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
scale_factor = m_retina_helper->get_scale_factor();
|
scale_factor = m_retina_helper->get_scale_factor();
|
||||||
#endif
|
#endif // ENABLE_RETINA_GL
|
||||||
|
m_bed.render(theta, m_use_VBOs, scale_factor);
|
||||||
if (m_bed != nullptr)
|
|
||||||
m_bed->render(theta, m_use_VBOs, scale_factor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_axes() const
|
void GLCanvas3D::_render_axes() const
|
||||||
{
|
{
|
||||||
if (m_bed != nullptr)
|
m_bed.render_axes();
|
||||||
m_bed->render_axes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_objects() const
|
void GLCanvas3D::_render_objects() const
|
||||||
|
@ -6356,9 +6314,9 @@ void GLCanvas3D::_render_objects() const
|
||||||
// Update the layer editing selection to the first object selected, update the current object maximum Z.
|
// Update the layer editing selection to the first object selected, update the current object maximum Z.
|
||||||
const_cast<LayersEditing&>(m_layers_editing).select_object(*m_model, this->is_layers_editing_enabled() ? m_selection.get_object_idx() : -1);
|
const_cast<LayersEditing&>(m_layers_editing).select_object(*m_model, this->is_layers_editing_enabled() ? m_selection.get_object_idx() : -1);
|
||||||
|
|
||||||
if ((m_config != nullptr) && (m_bed != nullptr))
|
if (m_config != nullptr)
|
||||||
{
|
{
|
||||||
const BoundingBoxf3& bed_bb = m_bed->get_bounding_box();
|
const BoundingBoxf3& bed_bb = m_bed.get_bounding_box();
|
||||||
m_volumes.set_print_box((float)bed_bb.min(0), (float)bed_bb.min(1), 0.0f, (float)bed_bb.max(0), (float)bed_bb.max(1), (float)m_config->opt_float("max_print_height"));
|
m_volumes.set_print_box((float)bed_bb.min(0), (float)bed_bb.min(1), 0.0f, (float)bed_bb.max(0), (float)bed_bb.max(1), (float)m_config->opt_float("max_print_height"));
|
||||||
m_volumes.check_outside_state(m_config, nullptr);
|
m_volumes.check_outside_state(m_config, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -6540,7 +6498,7 @@ void GLCanvas3D::_render_toolbar() const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar->get_height()) * inv_zoom;
|
top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar.get_height()) * inv_zoom;
|
||||||
left = -0.5f * m_toolbar.get_width() * inv_zoom;
|
left = -0.5f * m_toolbar.get_width() * inv_zoom;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -6575,31 +6533,29 @@ void GLCanvas3D::_render_toolbar() const
|
||||||
|
|
||||||
void GLCanvas3D::_render_view_toolbar() const
|
void GLCanvas3D::_render_view_toolbar() const
|
||||||
{
|
{
|
||||||
if (m_view_toolbar != nullptr) {
|
|
||||||
#if ENABLE_SVG_ICONS
|
#if ENABLE_SVG_ICONS
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
m_view_toolbar->set_scale(m_retina_helper->get_scale_factor());
|
m_view_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||||
#else
|
#else
|
||||||
m_view_toolbar->set_scale(m_canvas->GetContentScaleFactor());
|
m_view_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
|
||||||
Size cnv_size = get_canvas_size();
|
Size cnv_size = get_canvas_size();
|
||||||
float zoom = get_camera_zoom();
|
float zoom = get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
|
||||||
// places the toolbar on the bottom-left corner of the 3d scene
|
// places the toolbar on the bottom-left corner of the 3d scene
|
||||||
float top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar->get_height()) * inv_zoom;
|
float top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar.get_height()) * inv_zoom;
|
||||||
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
||||||
m_view_toolbar->set_position(top, left);
|
m_view_toolbar.set_position(top, left);
|
||||||
#else
|
#else
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
m_view_toolbar->set_icons_scale(m_retina_helper->get_scale_factor());
|
m_view_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
|
||||||
#else
|
#else
|
||||||
m_view_toolbar->set_icons_scale(m_canvas->GetContentScaleFactor());
|
m_view_toolbar.set_icons_scale(m_canvas->GetContentScaleFactor());
|
||||||
#endif /* __WXMSW__ */
|
#endif /* __WXMSW__ */
|
||||||
#endif // ENABLE_SVG_ICONS
|
#endif // ENABLE_SVG_ICONS
|
||||||
m_view_toolbar->render(*this);
|
m_view_toolbar.render(*this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_SHOW_CAMERA_TARGET
|
#if ENABLE_SHOW_CAMERA_TARGET
|
||||||
|
@ -6611,7 +6567,7 @@ void GLCanvas3D::_render_camera_target() const
|
||||||
|
|
||||||
::glLineWidth(2.0f);
|
::glLineWidth(2.0f);
|
||||||
::glBegin(GL_LINES);
|
::glBegin(GL_LINES);
|
||||||
Vec3d target = (m_camera != nullptr) ? m_camera->get_target() : Vec3d::Zero();
|
const Vec3d& target = m_camera.get_target();
|
||||||
// draw line for x axis
|
// draw line for x axis
|
||||||
::glColor3f(1.0f, 0.0f, 0.0f);
|
::glColor3f(1.0f, 0.0f, 0.0f);
|
||||||
::glVertex3d(target(0) - half_length, target(1), target(2));
|
::glVertex3d(target(0) - half_length, target(1), target(2));
|
||||||
|
@ -8115,7 +8071,7 @@ void GLCanvas3D::_resize_toolbars() const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar->get_height()) * inv_zoom;
|
top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar.get_height()) * inv_zoom;
|
||||||
left = -0.5f * m_toolbar.get_width() * inv_zoom;
|
left = -0.5f * m_toolbar.get_width() * inv_zoom;
|
||||||
}
|
}
|
||||||
m_toolbar.set_position(top, left);
|
m_toolbar.set_position(top, left);
|
||||||
|
@ -8143,15 +8099,15 @@ void GLCanvas3D::_resize_toolbars() const
|
||||||
if (m_view_toolbar != nullptr)
|
if (m_view_toolbar != nullptr)
|
||||||
{
|
{
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
m_view_toolbar->set_icons_scale(m_retina_helper->get_scale_factor());
|
m_view_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
|
||||||
#else
|
#else
|
||||||
m_view_toolbar->set_icons_scale(m_canvas->GetContentScaleFactor());
|
m_view_toolbar.set_icons_scale(m_canvas->GetContentScaleFactor());
|
||||||
#endif /* __WXMSW__ */
|
#endif /* __WXMSW__ */
|
||||||
|
|
||||||
// places the toolbar on the bottom-left corner of the 3d scene
|
// places the toolbar on the bottom-left corner of the 3d scene
|
||||||
float top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar->get_height()) * inv_zoom;
|
float top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar.get_height()) * inv_zoom;
|
||||||
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
||||||
m_view_toolbar->set_position(top, left);
|
m_view_toolbar.set_position(top, left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // !ENABLE_SVG_ICONS
|
#endif // !ENABLE_SVG_ICONS
|
||||||
|
|
|
@ -850,14 +850,14 @@ private:
|
||||||
LegendTexture m_legend_texture;
|
LegendTexture m_legend_texture;
|
||||||
WarningTexture m_warning_texture;
|
WarningTexture m_warning_texture;
|
||||||
wxTimer m_timer;
|
wxTimer m_timer;
|
||||||
Camera* m_camera;
|
Bed3D& m_bed;
|
||||||
Bed3D* m_bed;
|
Camera& m_camera;
|
||||||
|
GLToolbar& m_view_toolbar;
|
||||||
LayersEditing m_layers_editing;
|
LayersEditing m_layers_editing;
|
||||||
Shader m_shader;
|
Shader m_shader;
|
||||||
Mouse m_mouse;
|
Mouse m_mouse;
|
||||||
mutable Gizmos m_gizmos;
|
mutable Gizmos m_gizmos;
|
||||||
mutable GLToolbar m_toolbar;
|
mutable GLToolbar m_toolbar;
|
||||||
GLToolbar* m_view_toolbar;
|
|
||||||
ClippingPlane m_clipping_planes[2];
|
ClippingPlane m_clipping_planes[2];
|
||||||
bool m_use_clipping_planes;
|
bool m_use_clipping_planes;
|
||||||
mutable SlaCap m_sla_caps[2];
|
mutable SlaCap m_sla_caps[2];
|
||||||
|
@ -898,7 +898,7 @@ private:
|
||||||
#endif // not ENABLE_IMGUI
|
#endif // not ENABLE_IMGUI
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLCanvas3D(wxGLCanvas* canvas);
|
GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar);
|
||||||
~GLCanvas3D();
|
~GLCanvas3D();
|
||||||
|
|
||||||
void set_context(wxGLContext* context) { m_context = context; }
|
void set_context(wxGLContext* context) { m_context = context; }
|
||||||
|
@ -906,11 +906,6 @@ public:
|
||||||
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
|
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
|
||||||
const wxGLCanvas* get_wxglcanvas() const { return m_canvas; }
|
const wxGLCanvas* get_wxglcanvas() const { return m_canvas; }
|
||||||
|
|
||||||
void set_camera(Camera* camera) { m_camera = camera; }
|
|
||||||
void set_bed(Bed3D* bed) { m_bed = bed; }
|
|
||||||
|
|
||||||
void set_view_toolbar(GLToolbar* toolbar) { m_view_toolbar = toolbar; }
|
|
||||||
|
|
||||||
bool init(bool useVBOs, bool use_legacy_opengl);
|
bool init(bool useVBOs, bool use_legacy_opengl);
|
||||||
void post_event(wxEvent &&event);
|
void post_event(wxEvent &&event);
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ GLCanvas3DManager::~GLCanvas3DManager()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3DManager::add(wxGLCanvas* canvas)
|
bool GLCanvas3DManager::add(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar)
|
||||||
{
|
{
|
||||||
if (canvas == nullptr)
|
if (canvas == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -137,7 +137,7 @@ bool GLCanvas3DManager::add(wxGLCanvas* canvas)
|
||||||
if (_get_canvas(canvas) != m_canvases.end())
|
if (_get_canvas(canvas) != m_canvases.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
GLCanvas3D* canvas3D = new GLCanvas3D(canvas);
|
GLCanvas3D* canvas3D = new GLCanvas3D(canvas, bed, camera, view_toolbar);
|
||||||
if (canvas3D == nullptr)
|
if (canvas3D == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ class PrintObject;
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class GLCanvas3D;
|
class GLCanvas3D;
|
||||||
|
class Bed3D;
|
||||||
|
class GLToolbar;
|
||||||
|
struct Camera;
|
||||||
|
|
||||||
class GLCanvas3DManager
|
class GLCanvas3DManager
|
||||||
{
|
{
|
||||||
|
@ -62,7 +65,7 @@ public:
|
||||||
GLCanvas3DManager();
|
GLCanvas3DManager();
|
||||||
~GLCanvas3DManager();
|
~GLCanvas3DManager();
|
||||||
|
|
||||||
bool add(wxGLCanvas* canvas);
|
bool add(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar);
|
||||||
bool remove(wxGLCanvas* canvas);
|
bool remove(wxGLCanvas* canvas);
|
||||||
void remove_all();
|
void remove_all();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
View3D::View3D(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process)
|
View3D::View3D(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process)
|
||||||
: m_canvas_widget(nullptr)
|
: m_canvas_widget(nullptr)
|
||||||
, m_canvas(nullptr)
|
, m_canvas(nullptr)
|
||||||
#if !ENABLE_IMGUI
|
#if !ENABLE_IMGUI
|
||||||
|
@ -37,7 +37,7 @@ View3D::View3D(wxWindow* parent, Model* model, DynamicPrintConfig* config, Backg
|
||||||
, m_config(nullptr)
|
, m_config(nullptr)
|
||||||
, m_process(nullptr)
|
, m_process(nullptr)
|
||||||
{
|
{
|
||||||
init(parent, model, config, process);
|
init(parent, bed, camera, view_toolbar, model, config, process);
|
||||||
}
|
}
|
||||||
|
|
||||||
View3D::~View3D()
|
View3D::~View3D()
|
||||||
|
@ -50,13 +50,13 @@ View3D::~View3D()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process)
|
bool View3D::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process)
|
||||||
{
|
{
|
||||||
if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */))
|
if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);
|
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);
|
||||||
_3DScene::add_canvas(m_canvas_widget);
|
_3DScene::add_canvas(m_canvas_widget, bed, camera, view_toolbar);
|
||||||
m_canvas = _3DScene::get_canvas(this->m_canvas_widget);
|
m_canvas = _3DScene::get_canvas(this->m_canvas_widget);
|
||||||
|
|
||||||
m_canvas->allow_multisample(GLCanvas3DManager::can_multisample());
|
m_canvas->allow_multisample(GLCanvas3DManager::can_multisample());
|
||||||
|
@ -89,24 +89,6 @@ bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, Ba
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void View3D::set_bed(Bed3D* bed)
|
|
||||||
{
|
|
||||||
if (m_canvas != nullptr)
|
|
||||||
m_canvas->set_bed(bed);
|
|
||||||
}
|
|
||||||
|
|
||||||
void View3D::set_camera(Camera* camera)
|
|
||||||
{
|
|
||||||
if (m_canvas != nullptr)
|
|
||||||
m_canvas->set_camera(camera);
|
|
||||||
}
|
|
||||||
|
|
||||||
void View3D::set_view_toolbar(GLToolbar* toolbar)
|
|
||||||
{
|
|
||||||
if (m_canvas != nullptr)
|
|
||||||
m_canvas->set_view_toolbar(toolbar);
|
|
||||||
}
|
|
||||||
|
|
||||||
void View3D::set_as_dirty()
|
void View3D::set_as_dirty()
|
||||||
{
|
{
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
|
@ -199,7 +181,7 @@ void View3D::render()
|
||||||
m_canvas->set_as_dirty();
|
m_canvas->set_as_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
Preview::Preview(wxWindow* parent, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process_func)
|
Preview::Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process_func)
|
||||||
: m_canvas_widget(nullptr)
|
: m_canvas_widget(nullptr)
|
||||||
, m_canvas(nullptr)
|
, m_canvas(nullptr)
|
||||||
, m_double_slider_sizer(nullptr)
|
, m_double_slider_sizer(nullptr)
|
||||||
|
@ -220,14 +202,14 @@ Preview::Preview(wxWindow* parent, DynamicPrintConfig* config, BackgroundSlicing
|
||||||
, m_enabled(false)
|
, m_enabled(false)
|
||||||
, m_schedule_background_process(schedule_background_process_func)
|
, m_schedule_background_process(schedule_background_process_func)
|
||||||
{
|
{
|
||||||
if (init(parent, config, process, gcode_preview_data))
|
if (init(parent, bed, camera, view_toolbar, config, process, gcode_preview_data))
|
||||||
{
|
{
|
||||||
show_hide_ui_elements("none");
|
show_hide_ui_elements("none");
|
||||||
load_print();
|
load_print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Preview::init(wxWindow* parent, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data)
|
bool Preview::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data)
|
||||||
{
|
{
|
||||||
if ((config == nullptr) || (process == nullptr) || (gcode_preview_data == nullptr))
|
if ((config == nullptr) || (process == nullptr) || (gcode_preview_data == nullptr))
|
||||||
return false;
|
return false;
|
||||||
|
@ -236,8 +218,8 @@ bool Preview::init(wxWindow* parent, DynamicPrintConfig* config, BackgroundSlici
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);
|
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);
|
||||||
_3DScene::add_canvas(m_canvas_widget);
|
_3DScene::add_canvas(m_canvas_widget, bed, camera, view_toolbar);
|
||||||
m_canvas = _3DScene::get_canvas(this->m_canvas_widget);
|
m_canvas = _3DScene::get_canvas(this->m_canvas_widget);
|
||||||
m_canvas->allow_multisample(GLCanvas3DManager::can_multisample());
|
m_canvas->allow_multisample(GLCanvas3DManager::can_multisample());
|
||||||
m_canvas->set_config(m_config);
|
m_canvas->set_config(m_config);
|
||||||
m_canvas->set_process(process);
|
m_canvas->set_process(process);
|
||||||
|
@ -348,24 +330,6 @@ Preview::~Preview()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preview::set_bed(Bed3D* bed)
|
|
||||||
{
|
|
||||||
if (m_canvas != nullptr)
|
|
||||||
m_canvas->set_bed(bed);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Preview::set_camera(Camera* camera)
|
|
||||||
{
|
|
||||||
if (m_canvas != nullptr)
|
|
||||||
m_canvas->set_camera(camera);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Preview::set_view_toolbar(GLToolbar* toolbar)
|
|
||||||
{
|
|
||||||
if (m_canvas != nullptr)
|
|
||||||
m_canvas->set_view_toolbar(toolbar);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Preview::set_number_extruders(unsigned int number_extruders)
|
void Preview::set_number_extruders(unsigned int number_extruders)
|
||||||
{
|
{
|
||||||
if (m_number_extruders != number_extruders)
|
if (m_number_extruders != number_extruders)
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace GUI {
|
||||||
class GLCanvas3D;
|
class GLCanvas3D;
|
||||||
class GLToolbar;
|
class GLToolbar;
|
||||||
class Bed3D;
|
class Bed3D;
|
||||||
class Camera;
|
struct Camera;
|
||||||
|
|
||||||
class View3D : public wxPanel
|
class View3D : public wxPanel
|
||||||
{
|
{
|
||||||
|
@ -44,17 +44,12 @@ class View3D : public wxPanel
|
||||||
BackgroundSlicingProcess* m_process;
|
BackgroundSlicingProcess* m_process;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
View3D(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
View3D(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
||||||
virtual ~View3D();
|
virtual ~View3D();
|
||||||
|
|
||||||
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
||||||
GLCanvas3D* get_canvas3d() { return m_canvas; }
|
GLCanvas3D* get_canvas3d() { return m_canvas; }
|
||||||
|
|
||||||
void set_bed(Bed3D* bed);
|
|
||||||
void set_camera(Camera* camera);
|
|
||||||
|
|
||||||
void set_view_toolbar(GLToolbar* toolbar);
|
|
||||||
|
|
||||||
void set_as_dirty();
|
void set_as_dirty();
|
||||||
void bed_shape_changed();
|
void bed_shape_changed();
|
||||||
|
|
||||||
|
@ -78,7 +73,7 @@ public:
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool init(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Preview : public wxPanel
|
class Preview : public wxPanel
|
||||||
|
@ -111,17 +106,12 @@ class Preview : public wxPanel
|
||||||
PrusaDoubleSlider* m_slider {nullptr};
|
PrusaDoubleSlider* m_slider {nullptr};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Preview(wxWindow* parent, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = [](){});
|
Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = [](){});
|
||||||
virtual ~Preview();
|
virtual ~Preview();
|
||||||
|
|
||||||
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
||||||
GLCanvas3D* get_canvas3d() { return m_canvas; }
|
GLCanvas3D* get_canvas3d() { return m_canvas; }
|
||||||
|
|
||||||
void set_bed(Bed3D* bed);
|
|
||||||
void set_camera(Camera* camera);
|
|
||||||
|
|
||||||
void set_view_toolbar(GLToolbar* toolbar);
|
|
||||||
|
|
||||||
void set_number_extruders(unsigned int number_extruders);
|
void set_number_extruders(unsigned int number_extruders);
|
||||||
void set_canvas_as_dirty();
|
void set_canvas_as_dirty();
|
||||||
void set_enabled(bool enabled);
|
void set_enabled(bool enabled);
|
||||||
|
@ -134,7 +124,7 @@ public:
|
||||||
void refresh_print();
|
void refresh_print();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool init(wxWindow* parent, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data);
|
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, DynamicPrintConfig* config, BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data);
|
||||||
|
|
||||||
void bind_event_handlers();
|
void bind_event_handlers();
|
||||||
void unbind_event_handlers();
|
void unbind_event_handlers();
|
||||||
|
|
|
@ -1203,14 +1203,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||||
sla_print.set_status_callback(statuscb);
|
sla_print.set_status_callback(statuscb);
|
||||||
this->q->Bind(EVT_SLICING_UPDATE, &priv::on_slicing_update, this);
|
this->q->Bind(EVT_SLICING_UPDATE, &priv::on_slicing_update, this);
|
||||||
|
|
||||||
view3D = new View3D(q, &model, config, &background_process);
|
view3D = new View3D(q, bed, camera, view_toolbar, &model, config, &background_process);
|
||||||
preview = new Preview(q, config, &background_process, &gcode_preview_data, [this](){ schedule_background_process(); });
|
preview = new Preview(q, bed, camera, view_toolbar, config, &background_process, &gcode_preview_data, [this](){ schedule_background_process(); });
|
||||||
|
|
||||||
view3D->set_bed(&bed);
|
|
||||||
preview->set_bed(&bed);
|
|
||||||
|
|
||||||
view3D->set_camera(&camera);
|
|
||||||
preview->set_camera(&camera);
|
|
||||||
|
|
||||||
panels.push_back(view3D);
|
panels.push_back(view3D);
|
||||||
panels.push_back(preview);
|
panels.push_back(preview);
|
||||||
|
@ -2674,9 +2668,6 @@ void Plater::priv::init_view_toolbar()
|
||||||
|
|
||||||
view_toolbar.select_item("3D");
|
view_toolbar.select_item("3D");
|
||||||
view_toolbar.set_enabled(true);
|
view_toolbar.set_enabled(true);
|
||||||
|
|
||||||
view3D->set_view_toolbar(&view_toolbar);
|
|
||||||
preview->set_view_toolbar(&view_toolbar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plater::priv::can_delete_object() const
|
bool Plater::priv::can_delete_object() const
|
||||||
|
|
Loading…
Reference in a new issue