mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-10 16:27:54 -06:00
GLCanvas3DManager moved from being a static member of _3DScene to be a normal member of GUI_App
This commit is contained in:
parent
47604b6326
commit
0b629eb905
24 changed files with 738 additions and 24 deletions
|
@ -527,8 +527,10 @@ int CLI::run(int argc, char **argv)
|
||||||
gui->mainframe->load_config(m_extra_config);
|
gui->mainframe->load_config(m_extra_config);
|
||||||
});
|
});
|
||||||
int result = wxEntry(argc, argv);
|
int result = wxEntry(argc, argv);
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
//FIXME this is a workaround for the PrusaSlicer 2.1 release.
|
//FIXME this is a workaround for the PrusaSlicer 2.1 release.
|
||||||
_3DScene::destroy();
|
_3DScene::destroy();
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
return result;
|
return result;
|
||||||
#else /* SLIC3R_GUI */
|
#else /* SLIC3R_GUI */
|
||||||
// No GUI support. Just print out a help.
|
// No GUI support. Just print out a help.
|
||||||
|
|
|
@ -43,9 +43,12 @@
|
||||||
|
|
||||||
|
|
||||||
//==================
|
//==================
|
||||||
// 2.2.0.beta1 techs
|
// 2.2.0.final techs
|
||||||
//==================
|
//==================
|
||||||
#define ENABLE_2_2_0_BETA1 1
|
#define ENABLE_2_2_0_FINAL 1
|
||||||
|
|
||||||
|
// Moves GLCanvas3DManager from being a static member of _3DScene to be a normal member of GUI_App
|
||||||
|
#define ENABLE_NON_STATIC_CANVAS_MANAGER (1 && ENABLE_2_2_0_FINAL)
|
||||||
|
|
||||||
|
|
||||||
#endif // _technologies_h_
|
#endif // _technologies_h_
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
#include "PresetBundle.hpp"
|
#include "PresetBundle.hpp"
|
||||||
#include "Gizmos/GLGizmoBase.hpp"
|
#include "Gizmos/GLGizmoBase.hpp"
|
||||||
#include "GLCanvas3D.hpp"
|
#include "GLCanvas3D.hpp"
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
#include "GLCanvas3DManager.hpp"
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
|
|
@ -1822,7 +1822,9 @@ void _3DScene::point3_to_verts(const Vec3crd& point, double width, double height
|
||||||
thick_point_to_verts(point, width, height, volume);
|
thick_point_to_verts(point, width, height, volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
GUI::GLCanvas3DManager _3DScene::s_canvas_mgr;
|
GUI::GLCanvas3DManager _3DScene::s_canvas_mgr;
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
GLModel::GLModel()
|
GLModel::GLModel()
|
||||||
: m_filename("")
|
: m_filename("")
|
||||||
|
@ -2105,6 +2107,7 @@ bool GLBed::on_init_from_file(const std::string& filename)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
std::string _3DScene::get_gl_info(bool format_as_html, bool extensions)
|
std::string _3DScene::get_gl_info(bool format_as_html, bool extensions)
|
||||||
{
|
{
|
||||||
return Slic3r::GUI::GLCanvas3DManager::get_gl_info().to_string(format_as_html, extensions);
|
return Slic3r::GUI::GLCanvas3DManager::get_gl_info().to_string(format_as_html, extensions);
|
||||||
|
@ -2139,5 +2142,6 @@ GUI::GLCanvas3D* _3DScene::get_canvas(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
return s_canvas_mgr.get_canvas(canvas);
|
return s_canvas_mgr.get_canvas(canvas);
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#include "libslic3r/TriangleMesh.hpp"
|
#include "libslic3r/TriangleMesh.hpp"
|
||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
#include "slic3r/GUI/GLCanvas3DManager.hpp"
|
#include "slic3r/GUI/GLCanvas3DManager.hpp"
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -645,10 +647,17 @@ protected:
|
||||||
bool on_init_from_file(const std::string& filename) override;
|
bool on_init_from_file(const std::string& filename) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
struct _3DScene
|
||||||
|
#else
|
||||||
class _3DScene
|
class _3DScene
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
static GUI::GLCanvas3DManager s_canvas_mgr;
|
static GUI::GLCanvas3DManager s_canvas_mgr;
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
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);
|
||||||
|
|
||||||
|
@ -660,6 +669,7 @@ public:
|
||||||
static void destroy();
|
static void destroy();
|
||||||
|
|
||||||
static GUI::GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
static GUI::GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
static void thick_lines_to_verts(const Lines& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, double top_z, GLVolume& volume);
|
static void thick_lines_to_verts(const Lines& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, double top_z, GLVolume& volume);
|
||||||
static void thick_lines_to_verts(const Lines3& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, GLVolume& volume);
|
static void thick_lines_to_verts(const Lines3& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed, GLVolume& volume);
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
#include "slic3r/GUI/PresetBundle.hpp"
|
#include "slic3r/GUI/PresetBundle.hpp"
|
||||||
#include "slic3r/GUI/Tab.hpp"
|
#include "slic3r/GUI/Tab.hpp"
|
||||||
#include "slic3r/GUI/GUI_Preview.hpp"
|
#include "slic3r/GUI/GUI_Preview.hpp"
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
#include "slic3r/GUI/GLCanvas3DManager.hpp"
|
||||||
|
#include "slic3r/GUI/Camera.hpp"
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "GUI_ObjectList.hpp"
|
#include "GUI_ObjectList.hpp"
|
||||||
|
@ -357,7 +361,11 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
||||||
float half_w = 0.5f * (float)cnv_size.get_width();
|
float half_w = 0.5f * (float)cnv_size.get_width();
|
||||||
float half_h = 0.5f * (float)cnv_size.get_height();
|
float half_h = 0.5f * (float)cnv_size.get_height();
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)canvas.get_camera().get_inv_zoom();
|
float inv_zoom = (float)canvas.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
return Rect((half_w - thickness_bar_width(canvas)) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom);
|
return Rect((half_w - thickness_bar_width(canvas)) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom);
|
||||||
}
|
}
|
||||||
|
@ -849,7 +857,11 @@ void GLCanvas3D::WarningTexture::render(const GLCanvas3D& canvas) const
|
||||||
if ((m_id > 0) && (m_original_width > 0) && (m_original_height > 0) && (m_width > 0) && (m_height > 0))
|
if ((m_id > 0) && (m_original_width > 0) && (m_original_height > 0) && (m_width > 0) && (m_height > 0))
|
||||||
{
|
{
|
||||||
const Size& cnv_size = canvas.get_canvas_size();
|
const Size& cnv_size = canvas.get_canvas_size();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)canvas.get_camera().get_inv_zoom();
|
float inv_zoom = (float)canvas.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float left = (-0.5f * (float)m_original_width) * inv_zoom;
|
float left = (-0.5f * (float)m_original_width) * inv_zoom;
|
||||||
float top = (-0.5f * (float)cnv_size.get_height() + (float)m_original_height + 2.0f) * inv_zoom;
|
float top = (-0.5f * (float)cnv_size.get_height() + (float)m_original_height + 2.0f) * inv_zoom;
|
||||||
float right = left + (float)m_original_width * inv_zoom;
|
float right = left + (float)m_original_width * inv_zoom;
|
||||||
|
@ -1216,7 +1228,11 @@ void GLCanvas3D::LegendTexture::render(const GLCanvas3D& canvas) const
|
||||||
if ((m_id > 0) && (m_original_width > 0) && (m_original_height > 0) && (m_width > 0) && (m_height > 0))
|
if ((m_id > 0) && (m_original_width > 0) && (m_original_height > 0) && (m_width > 0) && (m_height > 0))
|
||||||
{
|
{
|
||||||
const Size& cnv_size = canvas.get_canvas_size();
|
const Size& cnv_size = canvas.get_canvas_size();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)canvas.get_camera().get_inv_zoom();
|
float inv_zoom = (float)canvas.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float left = (-0.5f * (float)cnv_size.get_width()) * inv_zoom;
|
float left = (-0.5f * (float)cnv_size.get_width()) * inv_zoom;
|
||||||
float top = (0.5f * (float)cnv_size.get_height()) * inv_zoom;
|
float top = (0.5f * (float)cnv_size.get_height()) * inv_zoom;
|
||||||
float right = left + (float)m_original_width * inv_zoom;
|
float right = left + (float)m_original_width * inv_zoom;
|
||||||
|
@ -1242,7 +1258,11 @@ void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_
|
||||||
if (!m_enabled || !is_shown())
|
if (!m_enabled || !is_shown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
#else
|
||||||
const Camera& camera = m_canvas.get_camera();
|
const Camera& camera = m_canvas.get_camera();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
const Model* model = m_canvas.get_model();
|
const Model* model = m_canvas.get_model();
|
||||||
if (model == nullptr)
|
if (model == nullptr)
|
||||||
return;
|
return;
|
||||||
|
@ -1403,16 +1423,22 @@ wxDEFINE_EVENT(EVT_GLCANVAS_RELOAD_FROM_DISK, SimpleEvent);
|
||||||
const double GLCanvas3D::DefaultCameraZoomToBoxMarginFactor = 1.25;
|
const double GLCanvas3D::DefaultCameraZoomToBoxMarginFactor = 1.25;
|
||||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
||||||
|
#else
|
||||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar)
|
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar)
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
: 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)
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
, m_bed(bed)
|
, m_bed(bed)
|
||||||
, m_camera(camera)
|
, m_camera(camera)
|
||||||
, m_view_toolbar(view_toolbar)
|
, m_view_toolbar(view_toolbar)
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
, m_main_toolbar(GLToolbar::Normal, "Top")
|
, m_main_toolbar(GLToolbar::Normal, "Top")
|
||||||
, m_undoredo_toolbar(GLToolbar::Normal, "Top")
|
, m_undoredo_toolbar(GLToolbar::Normal, "Top")
|
||||||
, m_gizmos(*this)
|
, m_gizmos(*this)
|
||||||
|
@ -1560,6 +1586,18 @@ void GLCanvas3D::reset_volumes()
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (m_volumes.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_set_current();
|
||||||
|
|
||||||
|
m_selection.clear();
|
||||||
|
m_volumes.clear();
|
||||||
|
m_dirty = true;
|
||||||
|
|
||||||
|
_set_warning_texture(WarningTexture::ObjectOutside, false);
|
||||||
|
#else
|
||||||
_set_current();
|
_set_current();
|
||||||
|
|
||||||
if (!m_volumes.empty())
|
if (!m_volumes.empty())
|
||||||
|
@ -1570,6 +1608,7 @@ void GLCanvas3D::reset_volumes()
|
||||||
}
|
}
|
||||||
|
|
||||||
_set_warning_texture(WarningTexture::ObjectOutside, false);
|
_set_warning_texture(WarningTexture::ObjectOutside, false);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
int GLCanvas3D::check_volumes_outside_state() const
|
int GLCanvas3D::check_volumes_outside_state() const
|
||||||
|
@ -1651,7 +1690,11 @@ void GLCanvas3D::set_model(Model* model)
|
||||||
void GLCanvas3D::bed_shape_changed()
|
void GLCanvas3D::bed_shape_changed()
|
||||||
{
|
{
|
||||||
refresh_camera_scene_box();
|
refresh_camera_scene_box();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
wxGetApp().plater()->get_camera().requires_zoom_to_bed = true;
|
||||||
|
#else
|
||||||
m_camera.requires_zoom_to_bed = true;
|
m_camera.requires_zoom_to_bed = true;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1660,6 +1703,13 @@ void GLCanvas3D::set_color_by(const std::string& value)
|
||||||
m_color_by = value;
|
m_color_by = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
void GLCanvas3D::refresh_camera_scene_box()
|
||||||
|
{
|
||||||
|
wxGetApp().plater()->get_camera().set_scene_box(scene_bounding_box());
|
||||||
|
}
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
BoundingBoxf3 GLCanvas3D::volumes_bounding_box() const
|
BoundingBoxf3 GLCanvas3D::volumes_bounding_box() const
|
||||||
{
|
{
|
||||||
BoundingBoxf3 bb;
|
BoundingBoxf3 bb;
|
||||||
|
@ -1674,7 +1724,11 @@ 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 ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bb.merge(wxGetApp().plater()->get_bed().get_bounding_box(true));
|
||||||
|
#else
|
||||||
bb.merge(m_bed.get_bounding_box(true));
|
bb.merge(m_bed.get_bounding_box(true));
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
if (m_config != nullptr)
|
if (m_config != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -1787,7 +1841,11 @@ void GLCanvas3D::allow_multisample(bool allow)
|
||||||
|
|
||||||
void GLCanvas3D::zoom_to_bed()
|
void GLCanvas3D::zoom_to_bed()
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
_zoom_to_box(wxGetApp().plater()->get_bed().get_bounding_box(false));
|
||||||
|
#else
|
||||||
_zoom_to_box(m_bed.get_bounding_box(false));
|
_zoom_to_box(m_bed.get_bounding_box(false));
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::zoom_to_volumes()
|
void GLCanvas3D::zoom_to_volumes()
|
||||||
|
@ -1805,7 +1863,11 @@ void GLCanvas3D::zoom_to_selection()
|
||||||
|
|
||||||
void GLCanvas3D::select_view(const std::string& direction)
|
void GLCanvas3D::select_view(const std::string& direction)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
wxGetApp().plater()->get_camera().select_view(direction);
|
||||||
|
#else
|
||||||
m_camera.select_view(direction);
|
m_camera.select_view(direction);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
@ -1833,14 +1895,26 @@ void GLCanvas3D::render()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// ensures this canvas is current and initialized
|
// ensures this canvas is current and initialized
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (!_is_shown_on_screen() || !_set_current() || !wxGetApp().init_opengl())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!is_initialized() && !init())
|
||||||
|
return;
|
||||||
|
#else
|
||||||
if (! _is_shown_on_screen() || !_set_current() || !_3DScene::init(m_canvas))
|
if (! _is_shown_on_screen() || !_set_current() || !_3DScene::init(m_canvas))
|
||||||
return;
|
return;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#if ENABLE_RENDER_STATISTICS
|
#if ENABLE_RENDER_STATISTICS
|
||||||
auto start_time = std::chrono::high_resolution_clock::now();
|
auto start_time = std::chrono::high_resolution_clock::now();
|
||||||
#endif // ENABLE_RENDER_STATISTICS
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (wxGetApp().plater()->get_bed().get_shape().empty())
|
||||||
|
#else
|
||||||
if (m_bed.get_shape().empty())
|
if (m_bed.get_shape().empty())
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
// 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));
|
||||||
|
@ -1852,6 +1926,20 @@ void GLCanvas3D::render()
|
||||||
// to preview, this was called before canvas had its final size. It reported zero width
|
// to preview, this was called before canvas had its final size. It reported zero width
|
||||||
// and the viewport was set incorrectly, leading to tripping glAsserts further down
|
// and the viewport was set incorrectly, leading to tripping glAsserts further down
|
||||||
// the road (in apply_projection). That's why the minimum size is forced to 10.
|
// the road (in apply_projection). That's why the minimum size is forced to 10.
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
camera.apply_viewport(0, 0, std::max(10u, (unsigned int)cnv_size.get_width()), std::max(10u, (unsigned int)cnv_size.get_height()));
|
||||||
|
|
||||||
|
if (camera.requires_zoom_to_bed)
|
||||||
|
{
|
||||||
|
zoom_to_bed();
|
||||||
|
_resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
|
||||||
|
camera.requires_zoom_to_bed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
camera.apply_view_matrix();
|
||||||
|
camera.apply_projection(_max_bounding_box(true, true));
|
||||||
|
#else
|
||||||
m_camera.apply_viewport(0, 0, std::max(10u, (unsigned int)cnv_size.get_width()), std::max(10u, (unsigned int)cnv_size.get_height()));
|
m_camera.apply_viewport(0, 0, std::max(10u, (unsigned int)cnv_size.get_width()), std::max(10u, (unsigned int)cnv_size.get_height()));
|
||||||
|
|
||||||
if (m_camera.requires_zoom_to_bed)
|
if (m_camera.requires_zoom_to_bed)
|
||||||
|
@ -1863,6 +1951,7 @@ void GLCanvas3D::render()
|
||||||
|
|
||||||
m_camera.apply_view_matrix();
|
m_camera.apply_view_matrix();
|
||||||
m_camera.apply_projection(_max_bounding_box(true, true));
|
m_camera.apply_projection(_max_bounding_box(true, true));
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
GLfloat position_cam[4] = { 1.0f, 0.0f, 1.0f, 0.0f };
|
GLfloat position_cam[4] = { 1.0f, 0.0f, 1.0f, 0.0f };
|
||||||
glsafe(::glLightfv(GL_LIGHT1, GL_POSITION, position_cam));
|
glsafe(::glLightfv(GL_LIGHT1, GL_POSITION, position_cam));
|
||||||
|
@ -1892,7 +1981,11 @@ void GLCanvas3D::render()
|
||||||
_render_objects();
|
_render_objects();
|
||||||
_render_sla_slices();
|
_render_sla_slices();
|
||||||
_render_selection();
|
_render_selection();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
_render_bed(!camera.is_looking_downward(), true);
|
||||||
|
#else
|
||||||
_render_bed(!m_camera.is_looking_downward(), true);
|
_render_bed(!m_camera.is_looking_downward(), true);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#if ENABLE_RENDER_SELECTION_CENTER
|
#if ENABLE_RENDER_SELECTION_CENTER
|
||||||
_render_selection_center();
|
_render_selection_center();
|
||||||
|
@ -1958,8 +2051,13 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w,
|
||||||
{
|
{
|
||||||
switch (GLCanvas3DManager::get_framebuffers_type())
|
switch (GLCanvas3DManager::get_framebuffers_type())
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
case GLCanvas3DManager::EFramebufferType::Arb: { _render_thumbnail_framebuffer(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
||||||
|
case GLCanvas3DManager::EFramebufferType::Ext: { _render_thumbnail_framebuffer_ext(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
||||||
|
#else
|
||||||
case GLCanvas3DManager::FB_Arb: { _render_thumbnail_framebuffer(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
case GLCanvas3DManager::FB_Arb: { _render_thumbnail_framebuffer(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
||||||
case GLCanvas3DManager::FB_Ext: { _render_thumbnail_framebuffer_ext(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
case GLCanvas3DManager::FB_Ext: { _render_thumbnail_framebuffer_ext(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
default: { _render_thumbnail_legacy(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
default: { _render_thumbnail_legacy(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2065,8 +2163,15 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||||
if ((m_canvas == nullptr) || (m_config == nullptr) || (m_model == nullptr))
|
if ((m_canvas == nullptr) || (m_config == nullptr) || (m_model == nullptr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (!m_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_set_current();
|
||||||
|
#else
|
||||||
if (m_initialized)
|
if (m_initialized)
|
||||||
_set_current();
|
_set_current();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
struct ModelVolumeState {
|
struct ModelVolumeState {
|
||||||
ModelVolumeState(const GLVolume* volume) :
|
ModelVolumeState(const GLVolume* volume) :
|
||||||
|
@ -2662,8 +2767,13 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
||||||
|
|
||||||
m_dirty |= m_main_toolbar.update_items_state();
|
m_dirty |= m_main_toolbar.update_items_state();
|
||||||
m_dirty |= m_undoredo_toolbar.update_items_state();
|
m_dirty |= m_undoredo_toolbar.update_items_state();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
m_dirty |= wxGetApp().plater()->get_view_toolbar().update_items_state();
|
||||||
|
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(wxGetApp().plater()->get_camera());
|
||||||
|
#else
|
||||||
m_dirty |= m_view_toolbar.update_items_state();
|
m_dirty |= m_view_toolbar.update_items_state();
|
||||||
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(m_camera);
|
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(m_camera);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
m_dirty |= mouse3d_controller_applied;
|
m_dirty |= mouse3d_controller_applied;
|
||||||
|
|
||||||
if (!m_dirty)
|
if (!m_dirty)
|
||||||
|
@ -2809,7 +2919,11 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||||
case 'I':
|
case 'I':
|
||||||
case 'i': { _update_camera_zoom(1.0); break; }
|
case 'i': { _update_camera_zoom(1.0); break; }
|
||||||
case 'K':
|
case 'K':
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
case 'k': { wxGetApp().plater()->get_camera().select_next_type(); m_dirty = true; break; }
|
||||||
|
#else
|
||||||
case 'k': { m_camera.select_next_type(); m_dirty = true; break; }
|
case 'k': { m_camera.select_next_type(); m_dirty = true; break; }
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
case 'O':
|
case 'O':
|
||||||
case 'o': { _update_camera_zoom(-1.0); break; }
|
case 'o': { _update_camera_zoom(-1.0); break; }
|
||||||
#if ENABLE_RENDER_PICKING_PASS
|
#if ENABLE_RENDER_PICKING_PASS
|
||||||
|
@ -2936,7 +3050,11 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
||||||
Vec3d displacement;
|
Vec3d displacement;
|
||||||
if (camera_space)
|
if (camera_space)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> inv_view_3x3 = wxGetApp().plater()->get_camera().get_view_matrix().inverse().matrix().block(0, 0, 3, 3);
|
||||||
|
#else
|
||||||
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> inv_view_3x3 = m_camera.get_view_matrix().inverse().matrix().block(0, 0, 3, 3);
|
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> inv_view_3x3 = m_camera.get_view_matrix().inverse().matrix().block(0, 0, 3, 3);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
displacement = multiplier * (inv_view_3x3 * direction);
|
displacement = multiplier * (inv_view_3x3 * direction);
|
||||||
displacement(2) = 0.0;
|
displacement(2) = 0.0;
|
||||||
}
|
}
|
||||||
|
@ -3190,6 +3308,11 @@ std::string format_mouse_event_debug_message(const wxMouseEvent &evt)
|
||||||
|
|
||||||
void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (!m_initialized)
|
||||||
|
return;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
const float scale = m_retina_helper->get_scale_factor();
|
const float scale = m_retina_helper->get_scale_factor();
|
||||||
evt.SetX(evt.GetX() * scale);
|
evt.SetX(evt.GetX() * scale);
|
||||||
|
@ -3242,7 +3365,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (wxGetApp().plater()->get_view_toolbar().on_mouse(evt, *this))
|
||||||
|
#else
|
||||||
if (m_view_toolbar.on_mouse(evt, *this))
|
if (m_view_toolbar.on_mouse(evt, *this))
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
|
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
|
||||||
mouse_up_cleanup();
|
mouse_up_cleanup();
|
||||||
|
@ -3405,7 +3532,12 @@ 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(get_first_hover_volume_idx()))
|
if (m_selection.contains_volume(get_first_hover_volume_idx()))
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
if (std::abs(camera.get_dir_forward()(2)) < EPSILON)
|
||||||
|
#else
|
||||||
if (std::abs(m_camera.get_dir_forward()(2)) < EPSILON)
|
if (std::abs(m_camera.get_dir_forward()(2)) < EPSILON)
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
|
@ -3418,8 +3550,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
// vector from the starting position to the found intersection
|
// vector from the starting position to the found intersection
|
||||||
Vec3d inters_vec = inters - m_mouse.drag.start_position_3D;
|
Vec3d inters_vec = inters - m_mouse.drag.start_position_3D;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Vec3d camera_right = camera.get_dir_right();
|
||||||
|
Vec3d camera_up = camera.get_dir_up();
|
||||||
|
#else
|
||||||
Vec3d camera_right = m_camera.get_dir_right();
|
Vec3d camera_right = m_camera.get_dir_right();
|
||||||
Vec3d camera_up = m_camera.get_dir_up();
|
Vec3d camera_up = m_camera.get_dir_up();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
// finds projection of the vector along the camera axes
|
// finds projection of the vector along the camera axes
|
||||||
double projection_x = inters_vec.dot(camera_right);
|
double projection_x = inters_vec.dot(camera_right);
|
||||||
|
@ -3467,10 +3604,17 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
const Vec3d& orig = m_mouse.drag.start_position_3D;
|
const Vec3d& orig = m_mouse.drag.start_position_3D;
|
||||||
double x = Geometry::deg2rad(pos(0) - orig(0)) * (double)TRACKBALLSIZE;
|
double x = Geometry::deg2rad(pos(0) - orig(0)) * (double)TRACKBALLSIZE;
|
||||||
double y = Geometry::deg2rad(pos(1) - orig(1)) * (double)TRACKBALLSIZE;
|
double y = Geometry::deg2rad(pos(1) - orig(1)) * (double)TRACKBALLSIZE;
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||||
|
wxGetApp().plater()->get_camera().rotate_local_around_target(Vec3d(y, x, 0.0));
|
||||||
|
else
|
||||||
|
wxGetApp().plater()->get_camera().rotate_on_sphere(x, y, wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||||
|
#else
|
||||||
if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||||
m_camera.rotate_local_around_target(Vec3d(y, x, 0.0));
|
m_camera.rotate_local_around_target(Vec3d(y, x, 0.0));
|
||||||
else
|
else
|
||||||
m_camera.rotate_on_sphere(x, y, wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
m_camera.rotate_on_sphere(x, y, wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
@ -3485,7 +3629,12 @@ 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 ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
camera.set_target(camera.get_target() + orig - cur_pos);
|
||||||
|
#else
|
||||||
m_camera.set_target(m_camera.get_target() + orig - cur_pos);
|
m_camera.set_target(m_camera.get_target() + orig - cur_pos);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3578,7 +3727,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
tooltip = m_undoredo_toolbar.get_tooltip();
|
tooltip = m_undoredo_toolbar.get_tooltip();
|
||||||
|
|
||||||
if (tooltip.empty())
|
if (tooltip.empty())
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
tooltip = wxGetApp().plater()->get_view_toolbar().get_tooltip();
|
||||||
|
#else
|
||||||
tooltip = m_view_toolbar.get_tooltip();
|
tooltip = m_view_toolbar.get_tooltip();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
set_tooltip(tooltip);
|
set_tooltip(tooltip);
|
||||||
|
|
||||||
|
@ -3932,7 +4085,12 @@ void GLCanvas3D::handle_layers_data_focus_event(const t_layer_height_range range
|
||||||
|
|
||||||
void GLCanvas3D::update_ui_from_settings()
|
void GLCanvas3D::update_ui_from_settings()
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
||||||
|
#else
|
||||||
m_camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
m_camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
|
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
|
@ -3946,7 +4104,11 @@ 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 ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
camera.set_zoom(camera.get_zoom() * new_scaling / orig_scaling);
|
||||||
|
#else
|
||||||
m_camera.set_zoom(m_camera.get_zoom() * new_scaling / orig_scaling);
|
m_camera.set_zoom(m_camera.get_zoom() * new_scaling / orig_scaling);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
_refresh_if_shown_on_screen();
|
_refresh_if_shown_on_screen();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3981,7 +4143,11 @@ Linef3 GLCanvas3D::mouse_ray(const Point& mouse_pos)
|
||||||
|
|
||||||
double GLCanvas3D::get_size_proportional_to_max_bed_size(double factor) const
|
double GLCanvas3D::get_size_proportional_to_max_bed_size(double factor) const
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
return factor * wxGetApp().plater()->get_bed().get_bounding_box(false).max_size();
|
||||||
|
#else
|
||||||
return factor * m_bed.get_bounding_box(false).max_size();
|
return factor * m_bed.get_bounding_box(false).max_size();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::set_cursor(ECursorType type)
|
void GLCanvas3D::set_cursor(ECursorType type)
|
||||||
|
@ -4042,7 +4208,11 @@ void GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x) const
|
||||||
{
|
{
|
||||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const float x = pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width();
|
||||||
|
#else
|
||||||
const float x = pos_x * (float)get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width();
|
const float x = pos_x * (float)get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||||
std::string title = is_undo ? L("Undo History") : L("Redo History");
|
std::string title = is_undo ? L("Undo History") : L("Redo History");
|
||||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||||
|
@ -4138,7 +4308,11 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, bool
|
||||||
// extends the near and far z of the frustrum to avoid the bed being clipped
|
// extends the near and far z of the frustrum to avoid the bed being clipped
|
||||||
|
|
||||||
// box in eye space
|
// box in eye space
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
BoundingBoxf3 t_bed_box = wxGetApp().plater()->get_bed().get_bounding_box(true).transformed(camera.get_view_matrix());
|
||||||
|
#else
|
||||||
BoundingBoxf3 t_bed_box = m_bed.get_bounding_box(true).transformed(camera.get_view_matrix());
|
BoundingBoxf3 t_bed_box = m_bed.get_bounding_box(true).transformed(camera.get_view_matrix());
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
near_z = -t_bed_box.max(2);
|
near_z = -t_bed_box.max(2);
|
||||||
far_z = -t_bed_box.min(2);
|
far_z = -t_bed_box.min(2);
|
||||||
}
|
}
|
||||||
|
@ -4415,7 +4589,11 @@ void GLCanvas3D::_render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigne
|
||||||
#endif // ENABLE_THUMBNAIL_GENERATOR_DEBUG_OUTPUT
|
#endif // ENABLE_THUMBNAIL_GENERATOR_DEBUG_OUTPUT
|
||||||
|
|
||||||
// restore the default framebuffer size to avoid flickering on the 3D scene
|
// restore the default framebuffer size to avoid flickering on the 3D scene
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
wxGetApp().plater()->get_camera().apply_viewport(0, 0, cnv_size.get_width(), cnv_size.get_height());
|
||||||
|
#else
|
||||||
m_camera.apply_viewport(0, 0, cnv_size.get_width(), cnv_size.get_height());
|
m_camera.apply_viewport(0, 0, cnv_size.get_width(), cnv_size.get_height());
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
|
||||||
|
@ -4729,14 +4907,22 @@ BoundingBoxf3 GLCanvas3D::_max_bounding_box(bool include_gizmos, bool include_be
|
||||||
bb.merge(BoundingBoxf3(sel_bb_center - extend_by, sel_bb_center + extend_by));
|
bb.merge(BoundingBoxf3(sel_bb_center - extend_by, sel_bb_center + extend_by));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bb.merge(wxGetApp().plater()->get_bed().get_bounding_box(include_bed_model));
|
||||||
|
#else
|
||||||
bb.merge(m_bed.get_bounding_box(include_bed_model));
|
bb.merge(m_bed.get_bounding_box(include_bed_model));
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_THUMBNAIL_GENERATOR
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
void GLCanvas3D::_zoom_to_box(const BoundingBoxf3& box, double margin_factor)
|
void GLCanvas3D::_zoom_to_box(const BoundingBoxf3& box, double margin_factor)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
wxGetApp().plater()->get_camera().zoom_to_box(box, margin_factor);
|
||||||
|
#else
|
||||||
m_camera.zoom_to_box(box, margin_factor);
|
m_camera.zoom_to_box(box, margin_factor);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -4750,7 +4936,11 @@ void GLCanvas3D::_zoom_to_box(const BoundingBoxf3& box)
|
||||||
|
|
||||||
void GLCanvas3D::_update_camera_zoom(double zoom)
|
void GLCanvas3D::_update_camera_zoom(double zoom)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
wxGetApp().plater()->get_camera().update_zoom(zoom);
|
||||||
|
#else
|
||||||
m_camera.update_zoom(zoom);
|
m_camera.update_zoom(zoom);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4941,7 +5131,11 @@ void GLCanvas3D::_render_bed(float theta, bool show_axes) const
|
||||||
#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 // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
wxGetApp().plater()->get_bed().render(const_cast<GLCanvas3D&>(*this), theta, scale_factor, show_axes);
|
||||||
|
#else
|
||||||
m_bed.render(const_cast<GLCanvas3D&>(*this), theta, scale_factor, show_axes);
|
m_bed.render(const_cast<GLCanvas3D&>(*this), theta, scale_factor, show_axes);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_objects() const
|
void GLCanvas3D::_render_objects() const
|
||||||
|
@ -4963,7 +5157,11 @@ void GLCanvas3D::_render_objects() const
|
||||||
|
|
||||||
if (m_config != nullptr)
|
if (m_config != nullptr)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const BoundingBoxf3& bed_bb = wxGetApp().plater()->get_bed().get_bounding_box(false);
|
||||||
|
#else
|
||||||
const BoundingBoxf3& bed_bb = m_bed.get_bounding_box(false);
|
const BoundingBoxf3& bed_bb = m_bed.get_bounding_box(false);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -4979,19 +5177,37 @@ void GLCanvas3D::_render_objects() const
|
||||||
m_shader.start_using();
|
m_shader.start_using();
|
||||||
if (m_picking_enabled && !m_gizmos.is_dragging() && m_layers_editing.is_enabled() && (m_layers_editing.last_object_id != -1) && (m_layers_editing.object_max_z() > 0.0f)) {
|
if (m_picking_enabled && !m_gizmos.is_dragging() && m_layers_editing.is_enabled() && (m_layers_editing.last_object_id != -1) && (m_layers_editing.object_max_z() > 0.0f)) {
|
||||||
int object_id = m_layers_editing.last_object_id;
|
int object_id = m_layers_editing.last_object_id;
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
m_volumes.render(GLVolumeCollection::Opaque, false, wxGetApp().plater()->get_camera().get_view_matrix(), [object_id](const GLVolume& volume) {
|
||||||
|
// Which volume to paint without the layer height profile shader?
|
||||||
|
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
|
||||||
|
});
|
||||||
|
#else
|
||||||
m_volumes.render(GLVolumeCollection::Opaque, false, m_camera.get_view_matrix(), [object_id](const GLVolume& volume) {
|
m_volumes.render(GLVolumeCollection::Opaque, false, m_camera.get_view_matrix(), [object_id](const GLVolume& volume) {
|
||||||
// Which volume to paint without the layer height profile shader?
|
// Which volume to paint without the layer height profile shader?
|
||||||
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
|
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
|
||||||
});
|
});
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
// Let LayersEditing handle rendering of the active object using the layer height profile shader.
|
// Let LayersEditing handle rendering of the active object using the layer height profile shader.
|
||||||
m_layers_editing.render_volumes(*this, this->m_volumes);
|
m_layers_editing.render_volumes(*this, this->m_volumes);
|
||||||
} else {
|
} else {
|
||||||
// do not cull backfaces to show broken geometry, if any
|
// do not cull backfaces to show broken geometry, if any
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
m_volumes.render(GLVolumeCollection::Opaque, m_picking_enabled, wxGetApp().plater()->get_camera().get_view_matrix(), [this](const GLVolume& volume) {
|
||||||
|
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
||||||
|
});
|
||||||
|
#else
|
||||||
m_volumes.render(GLVolumeCollection::Opaque, m_picking_enabled, m_camera.get_view_matrix(), [this](const GLVolume& volume) {
|
m_volumes.render(GLVolumeCollection::Opaque, m_picking_enabled, m_camera.get_view_matrix(), [this](const GLVolume& volume) {
|
||||||
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
||||||
});
|
});
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
m_volumes.render(GLVolumeCollection::Transparent, false, wxGetApp().plater()->get_camera().get_view_matrix());
|
||||||
|
#else
|
||||||
m_volumes.render(GLVolumeCollection::Transparent, false, m_camera.get_view_matrix());
|
m_volumes.render(GLVolumeCollection::Transparent, false, m_camera.get_view_matrix());
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
m_shader.stop_using();
|
m_shader.stop_using();
|
||||||
|
|
||||||
m_camera_clipping_plane = ClippingPlane::ClipsNothing();
|
m_camera_clipping_plane = ClippingPlane::ClipsNothing();
|
||||||
|
@ -5024,9 +5240,16 @@ void GLCanvas3D::_render_overlays() const
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
glsafe(::glLoadIdentity());
|
glsafe(::glLoadIdentity());
|
||||||
// ensure that the textures are renderered inside the frustrum
|
// ensure that the textures are renderered inside the frustrum
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
glsafe(::glTranslated(0.0, 0.0, -(camera.get_near_z() + 0.005)));
|
||||||
|
// ensure that the overlay fits the frustrum near z plane
|
||||||
|
double gui_scale = camera.get_gui_scale();
|
||||||
|
#else
|
||||||
glsafe(::glTranslated(0.0, 0.0, -(m_camera.get_near_z() + 0.005)));
|
glsafe(::glTranslated(0.0, 0.0, -(m_camera.get_near_z() + 0.005)));
|
||||||
// ensure that the overlay fits the frustrum near z plane
|
// ensure that the overlay fits the frustrum near z plane
|
||||||
double gui_scale = m_camera.get_gui_scale();
|
double gui_scale = m_camera.get_gui_scale();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
glsafe(::glScaled(gui_scale, gui_scale, 1.0));
|
glsafe(::glScaled(gui_scale, gui_scale, 1.0));
|
||||||
|
|
||||||
_render_gizmos_overlay();
|
_render_gizmos_overlay();
|
||||||
|
@ -5076,7 +5299,11 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
||||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Transform3d& view_matrix = wxGetApp().plater()->get_camera().get_view_matrix();
|
||||||
|
#else
|
||||||
const Transform3d& view_matrix = m_camera.get_view_matrix();
|
const Transform3d& view_matrix = m_camera.get_view_matrix();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
for (size_t type = 0; type < 2; ++ type) {
|
for (size_t type = 0; type < 2; ++ type) {
|
||||||
GLVolumeWithIdAndZList to_render = volumes_to_render(m_volumes.volumes, (type == 0) ? GLVolumeCollection::Opaque : GLVolumeCollection::Transparent, view_matrix);
|
GLVolumeWithIdAndZList to_render = volumes_to_render(m_volumes.volumes, (type == 0) ? GLVolumeCollection::Opaque : GLVolumeCollection::Transparent, view_matrix);
|
||||||
for (const GLVolumeWithIdAndZ& volume : to_render)
|
for (const GLVolumeWithIdAndZ& volume : to_render)
|
||||||
|
@ -5136,7 +5363,11 @@ void GLCanvas3D::_render_main_toolbar() const
|
||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
|
||||||
Size cnv_size = get_canvas_size();
|
Size cnv_size = get_canvas_size();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)m_camera.get_inv_zoom();
|
float inv_zoom = (float)m_camera.get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||||
float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width()) * inv_zoom;
|
float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width()) * inv_zoom;
|
||||||
|
@ -5162,7 +5393,11 @@ void GLCanvas3D::_render_undoredo_toolbar() const
|
||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
|
||||||
Size cnv_size = get_canvas_size();
|
Size cnv_size = get_canvas_size();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)m_camera.get_inv_zoom();
|
float inv_zoom = (float)m_camera.get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||||
float left = (m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width())) * inv_zoom;
|
float left = (m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width())) * inv_zoom;
|
||||||
|
@ -5172,25 +5407,50 @@ void GLCanvas3D::_render_undoredo_toolbar() const
|
||||||
|
|
||||||
void GLCanvas3D::_render_view_toolbar() const
|
void GLCanvas3D::_render_view_toolbar() const
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
GLToolbar& view_toolbar = wxGetApp().plater()->get_view_toolbar();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#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());
|
||||||
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale();
|
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
view_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
||||||
|
#else
|
||||||
m_view_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
m_view_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
#else
|
#else
|
||||||
// m_view_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
// m_view_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||||
// m_view_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
// m_view_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
||||||
const float size = int(GLGizmosManager::Default_Icons_Size * wxGetApp().toolbar_icon_scale());
|
const float size = int(GLGizmosManager::Default_Icons_Size * wxGetApp().toolbar_icon_scale());
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
view_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
||||||
|
#else
|
||||||
m_view_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
m_view_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
|
||||||
Size cnv_size = get_canvas_size();
|
Size cnv_size = get_canvas_size();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)m_camera.get_inv_zoom();
|
float inv_zoom = (float)m_camera.get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
// places the toolbar on the bottom-left corner of the 3d scene
|
// places the toolbar on the bottom-left corner of the 3d scene
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float top = (-0.5f * (float)cnv_size.get_height() + view_toolbar.get_height()) * inv_zoom;
|
||||||
|
#else
|
||||||
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;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
view_toolbar.set_position(top, left);
|
||||||
|
view_toolbar.render(*this);
|
||||||
|
#else
|
||||||
m_view_toolbar.set_position(top, left);
|
m_view_toolbar.set_position(top, left);
|
||||||
m_view_toolbar.render(*this);
|
m_view_toolbar.render(*this);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_SHOW_CAMERA_TARGET
|
#if ENABLE_SHOW_CAMERA_TARGET
|
||||||
|
@ -5469,10 +5729,16 @@ Vec3d GLCanvas3D::_mouse_to_3d(const Point& mouse_pos, float* z)
|
||||||
if (m_canvas == nullptr)
|
if (m_canvas == nullptr)
|
||||||
return Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
return Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
const std::array<int, 4>& viewport = camera.get_viewport();
|
||||||
|
const Transform3d& modelview_matrix = camera.get_view_matrix();
|
||||||
|
const Transform3d& projection_matrix = camera.get_projection_matrix();
|
||||||
|
#else
|
||||||
const std::array<int, 4>& viewport = m_camera.get_viewport();
|
const std::array<int, 4>& viewport = m_camera.get_viewport();
|
||||||
const Transform3d& modelview_matrix = m_camera.get_view_matrix();
|
const Transform3d& modelview_matrix = m_camera.get_view_matrix();
|
||||||
const Transform3d& projection_matrix = m_camera.get_projection_matrix();
|
const Transform3d& projection_matrix = m_camera.get_projection_matrix();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
GLint y = viewport[3] - (GLint)mouse_pos(1);
|
GLint y = viewport[3] - (GLint)mouse_pos(1);
|
||||||
GLfloat mouse_z;
|
GLfloat mouse_z;
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
#include "GLToolbar.hpp"
|
#include "GLToolbar.hpp"
|
||||||
#include "Event.hpp"
|
#include "Event.hpp"
|
||||||
#include "3DBed.hpp"
|
#include "3DBed.hpp"
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
#include "Camera.hpp"
|
#include "Camera.hpp"
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
#include "Selection.hpp"
|
#include "Selection.hpp"
|
||||||
#include "Gizmos/GLGizmosManager.hpp"
|
#include "Gizmos/GLGizmosManager.hpp"
|
||||||
#include "GUI_ObjectLayers.hpp"
|
#include "GUI_ObjectLayers.hpp"
|
||||||
|
@ -26,6 +28,9 @@ class wxMouseEvent;
|
||||||
class wxTimerEvent;
|
class wxTimerEvent;
|
||||||
class wxPaintEvent;
|
class wxPaintEvent;
|
||||||
class wxGLCanvas;
|
class wxGLCanvas;
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
class wxGLContext;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
// Support for Retina OpenGL on Mac OS
|
// Support for Retina OpenGL on Mac OS
|
||||||
#define ENABLE_RETINA_GL __APPLE__
|
#define ENABLE_RETINA_GL __APPLE__
|
||||||
|
@ -406,9 +411,11 @@ private:
|
||||||
LegendTexture m_legend_texture;
|
LegendTexture m_legend_texture;
|
||||||
WarningTexture m_warning_texture;
|
WarningTexture m_warning_texture;
|
||||||
wxTimer m_timer;
|
wxTimer m_timer;
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
Bed3D& m_bed;
|
Bed3D& m_bed;
|
||||||
Camera& m_camera;
|
Camera& m_camera;
|
||||||
GLToolbar& m_view_toolbar;
|
GLToolbar& m_view_toolbar;
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
LayersEditing m_layers_editing;
|
LayersEditing m_layers_editing;
|
||||||
Shader m_shader;
|
Shader m_shader;
|
||||||
Mouse m_mouse;
|
Mouse m_mouse;
|
||||||
|
@ -469,9 +476,17 @@ private:
|
||||||
Labels m_labels;
|
Labels m_labels;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
explicit GLCanvas3D(wxGLCanvas* canvas);
|
||||||
|
#else
|
||||||
GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar);
|
GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
~GLCanvas3D();
|
~GLCanvas3D();
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bool is_initialized() const { return m_initialized; }
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
void set_context(wxGLContext* context) { m_context = context; }
|
void set_context(wxGLContext* context) { m_context = context; }
|
||||||
|
|
||||||
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
|
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
|
||||||
|
@ -518,9 +533,14 @@ public:
|
||||||
|
|
||||||
void set_color_by(const std::string& value);
|
void set_color_by(const std::string& value);
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
void refresh_camera_scene_box();
|
||||||
|
#else
|
||||||
|
void refresh_camera_scene_box() { m_camera.set_scene_box(scene_bounding_box()); }
|
||||||
const Camera& get_camera() const { return m_camera; }
|
const Camera& get_camera() const { return m_camera; }
|
||||||
const Shader& get_shader() const { return m_shader; }
|
|
||||||
Camera& get_camera() { return m_camera; }
|
Camera& get_camera() { return m_camera; }
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Shader& get_shader() const { return m_shader; }
|
||||||
|
|
||||||
BoundingBoxf3 volumes_bounding_box() const;
|
BoundingBoxf3 volumes_bounding_box() const;
|
||||||
BoundingBoxf3 scene_bounding_box() const;
|
BoundingBoxf3 scene_bounding_box() const;
|
||||||
|
@ -614,7 +634,9 @@ public:
|
||||||
|
|
||||||
void update_ui_from_settings();
|
void update_ui_from_settings();
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float get_view_toolbar_height() const { return m_view_toolbar.get_height(); }
|
float get_view_toolbar_height() const { return m_view_toolbar.get_height(); }
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
int get_move_volume_id() const { return m_mouse.drag.move_volume_idx; }
|
int get_move_volume_id() const { return m_mouse.drag.move_volume_idx; }
|
||||||
int get_first_hover_volume_idx() const { return m_hover_volume_idxs.empty() ? -1 : m_hover_volume_idxs.front(); }
|
int get_first_hover_volume_idx() const { return m_hover_volume_idxs.empty() ? -1 : m_hover_volume_idxs.front(); }
|
||||||
|
@ -646,7 +668,6 @@ public:
|
||||||
Linef3 mouse_ray(const Point& mouse_pos);
|
Linef3 mouse_ray(const Point& mouse_pos);
|
||||||
|
|
||||||
void set_mouse_as_dragging() { m_mouse.dragging = true; }
|
void set_mouse_as_dragging() { m_mouse.dragging = true; }
|
||||||
void refresh_camera_scene_box() { m_camera.set_scene_box(scene_bounding_box()); }
|
|
||||||
bool is_mouse_dragging() const { return m_mouse.dragging; }
|
bool is_mouse_dragging() const { return m_mouse.dragging; }
|
||||||
|
|
||||||
double get_size_proportional_to_max_bed_size(double factor) const;
|
double get_size_proportional_to_max_bed_size(double factor) const;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "libslic3r/libslic3r.h"
|
||||||
#include "GLCanvas3DManager.hpp"
|
#include "GLCanvas3DManager.hpp"
|
||||||
#include "../../slic3r/GUI/GUI.hpp"
|
#include "../../slic3r/GUI/GUI.hpp"
|
||||||
#include "../../slic3r/GUI/AppConfig.hpp"
|
#include "../../slic3r/GUI/AppConfig.hpp"
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
GLCanvas3DManager::GLInfo::GLInfo()
|
GLCanvas3DManager::GLInfo::GLInfo()
|
||||||
: m_detected(false)
|
: m_detected(false)
|
||||||
, m_version("")
|
, m_version("")
|
||||||
|
@ -33,6 +35,7 @@ GLCanvas3DManager::GLInfo::GLInfo()
|
||||||
, m_max_anisotropy(0.0f)
|
, m_max_anisotropy(0.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
const std::string& GLCanvas3DManager::GLInfo::get_version() const
|
const std::string& GLCanvas3DManager::GLInfo::get_version() const
|
||||||
{
|
{
|
||||||
|
@ -188,22 +191,35 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas3DManager::MS_Unknown;
|
|
||||||
bool GLCanvas3DManager::s_compressed_textures_supported = false;
|
|
||||||
GLCanvas3DManager::EFramebufferType GLCanvas3DManager::s_framebuffers_type = GLCanvas3DManager::FB_None;
|
|
||||||
GLCanvas3DManager::GLInfo GLCanvas3DManager::s_gl_info;
|
GLCanvas3DManager::GLInfo GLCanvas3DManager::s_gl_info;
|
||||||
|
bool GLCanvas3DManager::s_compressed_textures_supported = false;
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas3DManager::EMultisampleState::Unknown;
|
||||||
|
GLCanvas3DManager::EFramebufferType GLCanvas3DManager::s_framebuffers_type = GLCanvas3DManager::EFramebufferType::None;
|
||||||
|
#else
|
||||||
|
GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas3DManager::MS_Unknown;
|
||||||
|
GLCanvas3DManager::EFramebufferType GLCanvas3DManager::s_framebuffers_type = GLCanvas3DManager::FB_None;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
GLCanvas3DManager::GLCanvas3DManager()
|
GLCanvas3DManager::GLCanvas3DManager()
|
||||||
: m_context(nullptr)
|
: m_context(nullptr)
|
||||||
, m_gl_initialized(false)
|
, m_gl_initialized(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
GLCanvas3DManager::~GLCanvas3DManager()
|
GLCanvas3DManager::~GLCanvas3DManager()
|
||||||
{
|
{
|
||||||
this->destroy();
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (m_context != nullptr)
|
||||||
|
delete m_context;
|
||||||
|
#else
|
||||||
|
this->destroy();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
bool GLCanvas3DManager::add(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar)
|
bool GLCanvas3DManager::add(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar)
|
||||||
{
|
{
|
||||||
if (canvas == nullptr)
|
if (canvas == nullptr)
|
||||||
|
@ -255,28 +271,50 @@ void GLCanvas3DManager::remove_all()
|
||||||
m_canvases.clear();
|
m_canvases.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GLCanvas3DManager::count() const
|
size_t GLCanvas3DManager::count() const
|
||||||
{
|
{
|
||||||
return (unsigned int)m_canvases.size();
|
return m_canvases.size();
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bool GLCanvas3DManager::init_gl()
|
||||||
|
#else
|
||||||
void GLCanvas3DManager::init_gl()
|
void GLCanvas3DManager::init_gl()
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
if (!m_gl_initialized)
|
if (!m_gl_initialized)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (glewInit() != GLEW_OK)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "Unable to init glew library";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
glewInit();
|
glewInit();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
m_gl_initialized = true;
|
m_gl_initialized = true;
|
||||||
if (GLEW_EXT_texture_compression_s3tc)
|
if (GLEW_EXT_texture_compression_s3tc)
|
||||||
s_compressed_textures_supported = true;
|
s_compressed_textures_supported = true;
|
||||||
else
|
else
|
||||||
s_compressed_textures_supported = false;
|
s_compressed_textures_supported = false;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (GLEW_ARB_framebuffer_object)
|
||||||
|
s_framebuffers_type = EFramebufferType::Arb;
|
||||||
|
else if (GLEW_EXT_framebuffer_object)
|
||||||
|
s_framebuffers_type = EFramebufferType::Ext;
|
||||||
|
else
|
||||||
|
s_framebuffers_type = EFramebufferType::None;
|
||||||
|
#else
|
||||||
if (GLEW_ARB_framebuffer_object)
|
if (GLEW_ARB_framebuffer_object)
|
||||||
s_framebuffers_type = FB_Arb;
|
s_framebuffers_type = FB_Arb;
|
||||||
else if (GLEW_EXT_framebuffer_object)
|
else if (GLEW_EXT_framebuffer_object)
|
||||||
s_framebuffers_type = FB_Ext;
|
s_framebuffers_type = FB_Ext;
|
||||||
else
|
else
|
||||||
s_framebuffers_type = FB_None;
|
s_framebuffers_type = FB_None;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
if (! s_gl_info.is_version_greater_or_equal_to(2, 0)) {
|
if (! s_gl_info.is_version_greater_or_equal_to(2, 0)) {
|
||||||
// Complain about the OpenGL version.
|
// Complain about the OpenGL version.
|
||||||
|
@ -292,8 +330,21 @@ void GLCanvas3DManager::init_gl()
|
||||||
wxMessageBox(message, wxString("PrusaSlicer - ") + _(L("Unsupported OpenGL version")), wxOK | wxICON_ERROR);
|
wxMessageBox(message, wxString("PrusaSlicer - ") + _(L("Unsupported OpenGL version")), wxOK | wxICON_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
return true;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
wxGLContext* GLCanvas3DManager::init_glcontext(wxGLCanvas& canvas)
|
||||||
|
{
|
||||||
|
if (m_context == nullptr)
|
||||||
|
m_context = new wxGLContext(&canvas);
|
||||||
|
|
||||||
|
return m_context;
|
||||||
|
}
|
||||||
|
#else
|
||||||
bool GLCanvas3DManager::init(wxGLCanvas* canvas)
|
bool GLCanvas3DManager::init(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
CanvasesMap::const_iterator it = do_get_canvas(canvas);
|
CanvasesMap::const_iterator it = do_get_canvas(canvas);
|
||||||
|
@ -311,14 +362,21 @@ void GLCanvas3DManager::destroy()
|
||||||
m_context = nullptr;
|
m_context = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
GLCanvas3D* GLCanvas3DManager::get_canvas(wxGLCanvas* canvas)
|
GLCanvas3D* GLCanvas3DManager::get_canvas(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
CanvasesMap::const_iterator it = do_get_canvas(canvas);
|
CanvasesMap::const_iterator it = do_get_canvas(canvas);
|
||||||
return (it != m_canvases.end()) ? it->second : nullptr;
|
return (it != m_canvases.end()) ? it->second : nullptr;
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
wxGLCanvas* GLCanvas3DManager::create_wxglcanvas(wxWindow& parent)
|
||||||
|
#else
|
||||||
wxGLCanvas* GLCanvas3DManager::create_wxglcanvas(wxWindow *parent)
|
wxGLCanvas* GLCanvas3DManager::create_wxglcanvas(wxWindow *parent)
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
int attribList[] = {
|
int attribList[] = {
|
||||||
WX_GL_RGBA,
|
WX_GL_RGBA,
|
||||||
|
@ -336,7 +394,11 @@ wxGLCanvas* GLCanvas3DManager::create_wxglcanvas(wxWindow *parent)
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (s_multisample == EMultisampleState::Unknown)
|
||||||
|
#else
|
||||||
if (s_multisample == MS_Unknown)
|
if (s_multisample == MS_Unknown)
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
detect_multisample(attribList);
|
detect_multisample(attribList);
|
||||||
// // debug output
|
// // debug output
|
||||||
|
@ -346,9 +408,14 @@ wxGLCanvas* GLCanvas3DManager::create_wxglcanvas(wxWindow *parent)
|
||||||
if (! can_multisample())
|
if (! can_multisample())
|
||||||
attribList[12] = 0;
|
attribList[12] = 0;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
return new wxGLCanvas(&parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
|
||||||
|
#else
|
||||||
return new wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
|
return new wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
GLCanvas3DManager::CanvasesMap::iterator GLCanvas3DManager::do_get_canvas(wxGLCanvas* canvas)
|
GLCanvas3DManager::CanvasesMap::iterator GLCanvas3DManager::do_get_canvas(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
return (canvas == nullptr) ? m_canvases.end() : m_canvases.find(canvas);
|
return (canvas == nullptr) ? m_canvases.end() : m_canvases.find(canvas);
|
||||||
|
@ -366,12 +433,17 @@ bool GLCanvas3DManager::init(GLCanvas3D& canvas)
|
||||||
|
|
||||||
return canvas.init();
|
return canvas.init();
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
void GLCanvas3DManager::detect_multisample(int* attribList)
|
void GLCanvas3DManager::detect_multisample(int* attribList)
|
||||||
{
|
{
|
||||||
int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
|
int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
|
||||||
bool enable_multisample = wxVersion >= 30003;
|
bool enable_multisample = wxVersion >= 30003;
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
s_multisample = (enable_multisample && wxGLCanvas::IsDisplaySupported(attribList)) ? EMultisampleState::Enabled : EMultisampleState::Disabled;
|
||||||
|
#else
|
||||||
s_multisample = (enable_multisample && wxGLCanvas::IsDisplaySupported(attribList)) ? MS_Enabled : MS_Disabled;
|
s_multisample = (enable_multisample && wxGLCanvas::IsDisplaySupported(attribList)) ? MS_Enabled : MS_Disabled;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
// Alternative method: it was working on previous version of wxWidgets but not with the latest, at least on Windows
|
// Alternative method: it was working on previous version of wxWidgets but not with the latest, at least on Windows
|
||||||
// s_multisample = enable_multisample && wxGLCanvas::IsExtensionSupported("WGL_ARB_multisample");
|
// s_multisample = enable_multisample && wxGLCanvas::IsExtensionSupported("WGL_ARB_multisample");
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,22 +23,43 @@ class PrintObject;
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class GLCanvas3D;
|
class GLCanvas3D;
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
class Bed3D;
|
class Bed3D;
|
||||||
class GLToolbar;
|
class GLToolbar;
|
||||||
struct Camera;
|
struct Camera;
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
class GLCanvas3DManager
|
class GLCanvas3DManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
enum class EFramebufferType : unsigned char
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Arb,
|
||||||
|
Ext
|
||||||
|
};
|
||||||
|
#else
|
||||||
enum EFramebufferType : unsigned char
|
enum EFramebufferType : unsigned char
|
||||||
{
|
{
|
||||||
FB_None,
|
FB_None,
|
||||||
FB_Arb,
|
FB_Arb,
|
||||||
FB_Ext
|
FB_Ext
|
||||||
};
|
};
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
class GLInfo
|
class GLInfo
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
mutable bool m_detected{ false };
|
||||||
|
mutable int m_max_tex_size{ 0 };
|
||||||
|
mutable float m_max_anisotropy{ 0.0f };
|
||||||
|
|
||||||
|
mutable std::string m_version;
|
||||||
|
mutable std::string m_glsl_version;
|
||||||
|
mutable std::string m_vendor;
|
||||||
|
mutable std::string m_renderer;
|
||||||
|
#else
|
||||||
mutable bool m_detected;
|
mutable bool m_detected;
|
||||||
|
|
||||||
mutable std::string m_version;
|
mutable std::string m_version;
|
||||||
|
@ -48,9 +69,14 @@ public:
|
||||||
|
|
||||||
mutable int m_max_tex_size;
|
mutable int m_max_tex_size;
|
||||||
mutable float m_max_anisotropy;
|
mutable float m_max_anisotropy;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
GLInfo() = default;
|
||||||
|
#else
|
||||||
GLInfo();
|
GLInfo();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
const std::string& get_version() const;
|
const std::string& get_version() const;
|
||||||
const std::string& get_glsl_version() const;
|
const std::string& get_glsl_version() const;
|
||||||
|
@ -69,6 +95,14 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
enum class EMultisampleState : unsigned char
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
Enabled,
|
||||||
|
Disabled
|
||||||
|
};
|
||||||
|
#else
|
||||||
enum EMultisampleState : unsigned char
|
enum EMultisampleState : unsigned char
|
||||||
{
|
{
|
||||||
MS_Unknown,
|
MS_Unknown,
|
||||||
|
@ -77,46 +111,79 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
CanvasesMap m_canvases;
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bool m_gl_initialized{ false };
|
||||||
|
wxGLContext* m_context{ nullptr };
|
||||||
|
#else
|
||||||
wxGLContext* m_context;
|
wxGLContext* m_context;
|
||||||
static GLInfo s_gl_info;
|
|
||||||
bool m_gl_initialized;
|
bool m_gl_initialized;
|
||||||
static EMultisampleState s_multisample;
|
CanvasesMap m_canvases;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
static GLInfo s_gl_info;
|
||||||
static bool s_compressed_textures_supported;
|
static bool s_compressed_textures_supported;
|
||||||
|
static EMultisampleState s_multisample;
|
||||||
static EFramebufferType s_framebuffers_type;
|
static EFramebufferType s_framebuffers_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
GLCanvas3DManager() = default;
|
||||||
|
#else
|
||||||
GLCanvas3DManager();
|
GLCanvas3DManager();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
~GLCanvas3DManager();
|
~GLCanvas3DManager();
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
bool add(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar);
|
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();
|
||||||
|
|
||||||
unsigned int count() const;
|
size_t count() const;
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bool init_gl();
|
||||||
|
#else
|
||||||
void init_gl();
|
void init_gl();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
wxGLContext* init_glcontext(wxGLCanvas& canvas);
|
||||||
|
#else
|
||||||
bool init(wxGLCanvas* canvas);
|
bool init(wxGLCanvas* canvas);
|
||||||
void destroy();
|
void destroy();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
static bool can_multisample() { return s_multisample == MS_Enabled; }
|
|
||||||
static bool are_compressed_textures_supported() { return s_compressed_textures_supported; }
|
static bool are_compressed_textures_supported() { return s_compressed_textures_supported; }
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
static bool can_multisample() { return s_multisample == EMultisampleState::Enabled; }
|
||||||
|
static bool are_framebuffers_supported() { return (s_framebuffers_type != EFramebufferType::None); }
|
||||||
|
#else
|
||||||
|
static bool can_multisample() { return s_multisample == MS_Enabled; }
|
||||||
static bool are_framebuffers_supported() { return (s_framebuffers_type != FB_None); }
|
static bool are_framebuffers_supported() { return (s_framebuffers_type != FB_None); }
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
static EFramebufferType get_framebuffers_type() { return s_framebuffers_type; }
|
static EFramebufferType get_framebuffers_type() { return s_framebuffers_type; }
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
static wxGLCanvas* create_wxglcanvas(wxWindow& parent);
|
||||||
|
#else
|
||||||
static wxGLCanvas* create_wxglcanvas(wxWindow *parent);
|
static wxGLCanvas* create_wxglcanvas(wxWindow *parent);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
static const GLInfo& get_gl_info() { return s_gl_info; }
|
static const GLInfo& get_gl_info() { return s_gl_info; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
CanvasesMap::iterator do_get_canvas(wxGLCanvas* canvas);
|
CanvasesMap::iterator do_get_canvas(wxGLCanvas* canvas);
|
||||||
CanvasesMap::const_iterator do_get_canvas(wxGLCanvas* canvas) const;
|
CanvasesMap::const_iterator do_get_canvas(wxGLCanvas* canvas) const;
|
||||||
|
|
||||||
bool init(GLCanvas3D& canvas);
|
bool init(GLCanvas3D& canvas);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
static void detect_multisample(int* attribList);
|
static void detect_multisample(int* attribList);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#include "Camera.hpp"
|
#include "Camera.hpp"
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
#include "GLCanvas3D.hpp"
|
#include "GLCanvas3D.hpp"
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
#include "GUI_App.hpp"
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
@ -35,7 +38,11 @@ namespace GUI {
|
||||||
|
|
||||||
m_state = Off;
|
m_state = Off;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
#else
|
||||||
const Camera& camera = canvas.get_camera();
|
const Camera& camera = canvas.get_camera();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
const std::array<int, 4>& viewport = camera.get_viewport();
|
const std::array<int, 4>& viewport = camera.get_viewport();
|
||||||
const Transform3d& modelview_matrix = camera.get_view_matrix();
|
const Transform3d& modelview_matrix = camera.get_view_matrix();
|
||||||
const Transform3d& projection_matrix = camera.get_projection_matrix();
|
const Transform3d& projection_matrix = camera.get_projection_matrix();
|
||||||
|
@ -68,7 +75,11 @@ namespace GUI {
|
||||||
if (!is_dragging())
|
if (!is_dragging())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
#else
|
||||||
const Camera& camera = canvas.get_camera();
|
const Camera& camera = canvas.get_camera();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float inv_zoom = (float)camera.get_inv_zoom();
|
float inv_zoom = (float)camera.get_inv_zoom();
|
||||||
|
|
||||||
Size cnv_size = canvas.get_canvas_size();
|
Size cnv_size = canvas.get_canvas_size();
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#include "GLTexture.hpp"
|
#include "GLTexture.hpp"
|
||||||
|
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
#include "GLCanvas3DManager.hpp"
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,13 @@
|
||||||
|
|
||||||
#include "GLToolbar.hpp"
|
#include "GLToolbar.hpp"
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||||
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
|
#include "slic3r/GUI/Camera.hpp"
|
||||||
|
#else
|
||||||
#include "../../slic3r/GUI/GLCanvas3D.hpp"
|
#include "../../slic3r/GUI/GLCanvas3D.hpp"
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
@ -16,7 +22,6 @@
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
|
||||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent);
|
||||||
|
@ -626,7 +631,11 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
|
||||||
{
|
{
|
||||||
// NB: mouse_pos is already scaled appropriately
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float factor = m_layout.scale * inv_zoom;
|
float factor = m_layout.scale * inv_zoom;
|
||||||
|
|
||||||
Size cnv_size = parent.get_canvas_size();
|
Size cnv_size = parent.get_canvas_size();
|
||||||
|
@ -730,7 +739,11 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
|
||||||
{
|
{
|
||||||
// NB: mouse_pos is already scaled appropriately
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float factor = m_layout.scale * inv_zoom;
|
float factor = m_layout.scale * inv_zoom;
|
||||||
|
|
||||||
Size cnv_size = parent.get_canvas_size();
|
Size cnv_size = parent.get_canvas_size();
|
||||||
|
@ -846,7 +859,11 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3
|
||||||
{
|
{
|
||||||
// NB: mouse_pos is already scaled appropriately
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float factor = m_layout.scale * inv_zoom;
|
float factor = m_layout.scale * inv_zoom;
|
||||||
|
|
||||||
Size cnv_size = parent.get_canvas_size();
|
Size cnv_size = parent.get_canvas_size();
|
||||||
|
@ -919,7 +936,11 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D&
|
||||||
{
|
{
|
||||||
// NB: mouse_pos is already scaled appropriately
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float factor = m_layout.scale * inv_zoom;
|
float factor = m_layout.scale * inv_zoom;
|
||||||
|
|
||||||
Size cnv_size = parent.get_canvas_size();
|
Size cnv_size = parent.get_canvas_size();
|
||||||
|
@ -1071,7 +1092,11 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
|
||||||
int tex_width = m_icons_texture.get_width();
|
int tex_width = m_icons_texture.get_width();
|
||||||
int tex_height = m_icons_texture.get_height();
|
int tex_height = m_icons_texture.get_height();
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float factor = inv_zoom * m_layout.scale;
|
float factor = inv_zoom * m_layout.scale;
|
||||||
|
|
||||||
float scaled_icons_size = m_layout.icons_size * factor;
|
float scaled_icons_size = m_layout.icons_size * factor;
|
||||||
|
@ -1119,7 +1144,11 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const
|
||||||
int tex_width = m_icons_texture.get_width();
|
int tex_width = m_icons_texture.get_width();
|
||||||
int tex_height = m_icons_texture.get_height();
|
int tex_height = m_icons_texture.get_height();
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
float inv_zoom = (float)parent.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
float factor = inv_zoom * m_layout.scale;
|
float factor = inv_zoom * m_layout.scale;
|
||||||
|
|
||||||
float scaled_icons_size = m_layout.icons_size * factor;
|
float scaled_icons_size = m_layout.icons_size * factor;
|
||||||
|
|
|
@ -169,6 +169,23 @@ GUI_App::~GUI_App()
|
||||||
delete preset_updater;
|
delete preset_updater;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
std::string GUI_App::get_gl_info(bool format_as_html, bool extensions)
|
||||||
|
{
|
||||||
|
return GLCanvas3DManager::get_gl_info().to_string(format_as_html, extensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGLContext* GUI_App::init_glcontext(wxGLCanvas& canvas)
|
||||||
|
{
|
||||||
|
return m_canvas_mgr.init_glcontext(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GUI_App::init_opengl()
|
||||||
|
{
|
||||||
|
return m_canvas_mgr.init_gl();
|
||||||
|
}
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
bool GUI_App::OnInit()
|
bool GUI_App::OnInit()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -575,7 +592,9 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
|
||||||
bool GUI_App::switch_language()
|
bool GUI_App::switch_language()
|
||||||
{
|
{
|
||||||
if (select_language()) {
|
if (select_language()) {
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
_3DScene::remove_all_canvases();
|
_3DScene::remove_all_canvases();
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
recreate_GUI();
|
recreate_GUI();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -744,7 +763,7 @@ bool GUI_App::load_language(wxString language, bool initial)
|
||||||
wxTranslations::Get()->SetLanguage(language_dict);
|
wxTranslations::Get()->SetLanguage(language_dict);
|
||||||
m_wxLocale->AddCatalog(SLIC3R_APP_KEY);
|
m_wxLocale->AddCatalog(SLIC3R_APP_KEY);
|
||||||
m_imgui->set_language(into_u8(language_info->CanonicalName));
|
m_imgui->set_language(into_u8(language_info->CanonicalName));
|
||||||
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
|
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
|
||||||
wxSetlocale(LC_NUMERIC, "C");
|
wxSetlocale(LC_NUMERIC, "C");
|
||||||
Preset::update_suffix_modified();
|
Preset::update_suffix_modified();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#include "MainFrame.hpp"
|
#include "MainFrame.hpp"
|
||||||
#include "ImGuiWrapper.hpp"
|
#include "ImGuiWrapper.hpp"
|
||||||
#include "ConfigWizard.hpp"
|
#include "ConfigWizard.hpp"
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
#include "GLCanvas3DManager.hpp"
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
#include <wx/app.h>
|
#include <wx/app.h>
|
||||||
#include <wx/colour.h>
|
#include <wx/colour.h>
|
||||||
|
@ -96,6 +99,9 @@ class GUI_App : public wxApp
|
||||||
// Best translation language, provided by Windows or OSX, owned by wxWidgets.
|
// Best translation language, provided by Windows or OSX, owned by wxWidgets.
|
||||||
const wxLanguageInfo *m_language_info_best = nullptr;
|
const wxLanguageInfo *m_language_info_best = nullptr;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
GLCanvas3DManager m_canvas_mgr;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
std::unique_ptr<ImGuiWrapper> m_imgui;
|
std::unique_ptr<ImGuiWrapper> m_imgui;
|
||||||
std::unique_ptr<PrintHostJobQueue> m_printhost_job_queue;
|
std::unique_ptr<PrintHostJobQueue> m_printhost_job_queue;
|
||||||
ConfigWizard* m_wizard; // Managed by wxWindow tree
|
ConfigWizard* m_wizard; // Managed by wxWindow tree
|
||||||
|
@ -107,6 +113,12 @@ public:
|
||||||
GUI_App();
|
GUI_App();
|
||||||
~GUI_App() override;
|
~GUI_App() override;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
static std::string get_gl_info(bool format_as_html, bool extensions);
|
||||||
|
wxGLContext* init_glcontext(wxGLCanvas& canvas);
|
||||||
|
bool init_opengl();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
static unsigned get_colour_approx_luma(const wxColour &colour);
|
static unsigned get_colour_approx_luma(const wxColour &colour);
|
||||||
static bool dark_mode();
|
static bool dark_mode();
|
||||||
void init_label_colours();
|
void init_label_colours();
|
||||||
|
|
|
@ -27,31 +27,64 @@
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
View3D::View3D(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process)
|
||||||
|
: m_canvas_widget(nullptr)
|
||||||
|
, m_canvas(nullptr)
|
||||||
|
{
|
||||||
|
init(parent, model, config, process);
|
||||||
|
}
|
||||||
|
#else
|
||||||
View3D::View3D(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, 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)
|
||||||
{
|
{
|
||||||
init(parent, bed, camera, view_toolbar, model, config, process);
|
init(parent, bed, camera, view_toolbar, model, config, process);
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
View3D::~View3D()
|
View3D::~View3D()
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (m_canvas != nullptr)
|
||||||
|
{
|
||||||
|
m_canvas->unbind_event_handlers();
|
||||||
|
delete m_canvas;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
if (m_canvas_widget != nullptr)
|
if (m_canvas_widget != nullptr)
|
||||||
{
|
{
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
_3DScene::remove_canvas(m_canvas_widget);
|
_3DScene::remove_canvas(m_canvas_widget);
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
delete m_canvas_widget;
|
delete m_canvas_widget;
|
||||||
m_canvas = nullptr;
|
m_canvas = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process)
|
||||||
|
#else
|
||||||
bool View3D::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process)
|
bool View3D::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process)
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(*this);
|
||||||
|
if (m_canvas_widget == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_canvas = new GLCanvas3D(m_canvas_widget);
|
||||||
|
m_canvas->set_context(wxGetApp().init_glcontext(*m_canvas_widget));
|
||||||
|
m_canvas->bind_event_handlers();
|
||||||
|
#else
|
||||||
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);
|
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);
|
||||||
_3DScene::add_canvas(m_canvas_widget, bed, camera, view_toolbar);
|
_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);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
m_canvas->allow_multisample(GLCanvas3DManager::can_multisample());
|
m_canvas->allow_multisample(GLCanvas3DManager::can_multisample());
|
||||||
// XXX: If have OpenGL
|
// XXX: If have OpenGL
|
||||||
|
@ -163,9 +196,15 @@ void View3D::render()
|
||||||
m_canvas->set_as_dirty();
|
m_canvas->set_as_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Preview::Preview(
|
||||||
|
wxWindow* parent, Model* model, DynamicPrintConfig* config,
|
||||||
|
BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process_func)
|
||||||
|
#else
|
||||||
Preview::Preview(
|
Preview::Preview(
|
||||||
wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config,
|
wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config,
|
||||||
BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process_func)
|
BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process_func)
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
: m_canvas_widget(nullptr)
|
: m_canvas_widget(nullptr)
|
||||||
, m_canvas(nullptr)
|
, m_canvas(nullptr)
|
||||||
, m_double_slider_sizer(nullptr)
|
, m_double_slider_sizer(nullptr)
|
||||||
|
@ -190,21 +229,39 @@ Preview::Preview(
|
||||||
, m_volumes_cleanup_required(false)
|
, m_volumes_cleanup_required(false)
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
{
|
{
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (init(parent, model))
|
||||||
|
#else
|
||||||
if (init(parent, bed, camera, view_toolbar, model))
|
if (init(parent, bed, camera, view_toolbar, model))
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
show_hide_ui_elements("none");
|
show_hide_ui_elements("none");
|
||||||
load_print();
|
load_print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bool Preview::init(wxWindow* parent, Model* model)
|
||||||
|
#else
|
||||||
bool Preview::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model)
|
bool Preview::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model)
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(*this);
|
||||||
|
if (m_canvas_widget == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_canvas = new GLCanvas3D(m_canvas_widget);
|
||||||
|
m_canvas->set_context(wxGetApp().init_glcontext(*m_canvas_widget));
|
||||||
|
m_canvas->bind_event_handlers();
|
||||||
|
#else
|
||||||
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);
|
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);
|
||||||
_3DScene::add_canvas(m_canvas_widget, bed, camera, view_toolbar);
|
_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);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
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_model(model);
|
m_canvas->set_model(model);
|
||||||
|
@ -313,9 +370,19 @@ Preview::~Preview()
|
||||||
{
|
{
|
||||||
unbind_event_handlers();
|
unbind_event_handlers();
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
if (m_canvas != nullptr)
|
||||||
|
{
|
||||||
|
m_canvas->unbind_event_handlers();
|
||||||
|
delete m_canvas;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
if (m_canvas_widget != nullptr)
|
if (m_canvas_widget != nullptr)
|
||||||
{
|
{
|
||||||
_3DScene::remove_canvas(m_canvas_widget);
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
_3DScene::remove_canvas(m_canvas_widget);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
delete m_canvas_widget;
|
delete m_canvas_widget;
|
||||||
m_canvas = nullptr;
|
m_canvas = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ class GLCanvas3D;
|
||||||
class GLToolbar;
|
class GLToolbar;
|
||||||
class Bed3D;
|
class Bed3D;
|
||||||
struct Camera;
|
struct Camera;
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
class Plater;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
class View3D : public wxPanel
|
class View3D : public wxPanel
|
||||||
{
|
{
|
||||||
|
@ -41,7 +44,11 @@ class View3D : public wxPanel
|
||||||
GLCanvas3D* m_canvas;
|
GLCanvas3D* m_canvas;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
View3D(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
||||||
|
#else
|
||||||
View3D(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
View3D(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
virtual ~View3D();
|
virtual ~View3D();
|
||||||
|
|
||||||
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
||||||
|
@ -69,7 +76,11 @@ public:
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bool init(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
||||||
|
#else
|
||||||
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
};
|
};
|
||||||
|
|
||||||
class Preview : public wxPanel
|
class Preview : public wxPanel
|
||||||
|
@ -109,8 +120,13 @@ class Preview : public wxPanel
|
||||||
DoubleSlider::Control* m_slider {nullptr};
|
DoubleSlider::Control* m_slider {nullptr};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config,
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config,
|
||||||
|
BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = []() {});
|
||||||
|
#else
|
||||||
|
Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config,
|
||||||
BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = [](){});
|
BackgroundSlicingProcess* process, GCodePreviewData* gcode_preview_data, std::function<void()> schedule_background_process = [](){});
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
virtual ~Preview();
|
virtual ~Preview();
|
||||||
|
|
||||||
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
||||||
|
@ -137,7 +153,11 @@ public:
|
||||||
bool is_loaded() const { return m_loaded; }
|
bool is_loaded() const { return m_loaded; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
bool init(wxWindow* parent, Model* model);
|
||||||
|
#else
|
||||||
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model);
|
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
void bind_event_handlers();
|
void bind_event_handlers();
|
||||||
void unbind_event_handlers();
|
void unbind_event_handlers();
|
||||||
|
@ -170,7 +190,6 @@ private:
|
||||||
void load_print_as_sla();
|
void load_print_as_sla();
|
||||||
|
|
||||||
void on_sliders_scroll_changed(wxCommandEvent& event);
|
void on_sliders_scroll_changed(wxCommandEvent& event);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||||
#include "slic3r/GUI/MeshUtils.hpp"
|
#include "slic3r/GUI/MeshUtils.hpp"
|
||||||
#include "slic3r/GUI/Plater.hpp"
|
#include "slic3r/GUI/Plater.hpp"
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
#include "slic3r/GUI/Camera.hpp"
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
#include "slic3r/GUI/PresetBundle.hpp"
|
#include "slic3r/GUI/PresetBundle.hpp"
|
||||||
#include "libslic3r/SLAPrint.hpp"
|
#include "libslic3r/SLAPrint.hpp"
|
||||||
#include "libslic3r/TriangleMesh.hpp"
|
#include "libslic3r/TriangleMesh.hpp"
|
||||||
|
@ -345,7 +348,11 @@ bool GLGizmoHollow::unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec3f, V
|
||||||
// !!! is it really necessary?
|
// !!! is it really necessary?
|
||||||
//m_c->update_from_backend(m_parent, m_c->m_model_object);
|
//m_c->update_from_backend(m_parent, m_c->m_model_object);
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
#else
|
||||||
const Camera& camera = m_parent.get_camera();
|
const Camera& camera = m_parent.get_camera();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||||
Geometry::Transformation trafo = volume->get_instance_transformation();
|
Geometry::Transformation trafo = volume->get_instance_transformation();
|
||||||
|
@ -460,7 +467,11 @@ bool GLGizmoHollow::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_pos
|
||||||
points_inside.push_back(points[idx].cast<float>());
|
points_inside.push_back(points[idx].cast<float>());
|
||||||
|
|
||||||
// Only select/deselect points that are actually visible
|
// Only select/deselect points that are actually visible
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
for (size_t idx : m_c->m_mesh_raycaster->get_unobscured_idxs(trafo, wxGetApp().plater()->get_camera(), points_inside, m_c->m_clipping_plane.get()))
|
||||||
|
#else
|
||||||
for (size_t idx : m_c->m_mesh_raycaster->get_unobscured_idxs(trafo, m_parent.get_camera(), points_inside, m_c->m_clipping_plane.get()))
|
for (size_t idx : m_c->m_mesh_raycaster->get_unobscured_idxs(trafo, m_parent.get_camera(), points_inside, m_c->m_clipping_plane.get()))
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
if (rectangle_status == GLSelectionRectangle::Deselect)
|
if (rectangle_status == GLSelectionRectangle::Deselect)
|
||||||
unselect_point(points_idxs[idx]);
|
unselect_point(points_idxs[idx]);
|
||||||
|
@ -1137,8 +1148,13 @@ void GLGizmoHollow::update_clipping_plane(bool keep_normal) const
|
||||||
{
|
{
|
||||||
if (! m_c->m_model_object)
|
if (! m_c->m_model_object)
|
||||||
return;
|
return;
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Vec3d normal = (keep_normal && m_c->m_clipping_plane->get_normal() != Vec3d::Zero() ?
|
||||||
|
m_c->m_clipping_plane->get_normal() : -wxGetApp().plater()->get_camera().get_dir_forward());
|
||||||
|
#else
|
||||||
Vec3d normal = (keep_normal && m_c->m_clipping_plane->get_normal() != Vec3d::Zero() ?
|
Vec3d normal = (keep_normal && m_c->m_clipping_plane->get_normal() != Vec3d::Zero() ?
|
||||||
m_c->m_clipping_plane->get_normal() : -m_parent.get_camera().get_dir_forward());
|
m_c->m_clipping_plane->get_normal() : -m_parent.get_camera().get_dir_forward());
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
const Vec3d& center = m_c->m_model_object->instances[m_c->m_active_instance]->get_offset() + Vec3d(0., 0., m_z_shift);
|
const Vec3d& center = m_c->m_model_object->instances[m_c->m_active_instance]->get_offset() + Vec3d(0., 0., m_z_shift);
|
||||||
float dist = normal.dot(center);
|
float dist = normal.dot(center);
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
#include "slic3r/GUI/GUI.hpp"
|
#include "slic3r/GUI/GUI.hpp"
|
||||||
#include "slic3r/GUI/GUI_ObjectSettings.hpp"
|
#include "slic3r/GUI/GUI_ObjectSettings.hpp"
|
||||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
#include "slic3r/GUI/Camera.hpp"
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
#include "slic3r/GUI/MeshUtils.hpp"
|
#include "slic3r/GUI/MeshUtils.hpp"
|
||||||
#include "slic3r/GUI/Plater.hpp"
|
#include "slic3r/GUI/Plater.hpp"
|
||||||
#include "slic3r/GUI/PresetBundle.hpp"
|
#include "slic3r/GUI/PresetBundle.hpp"
|
||||||
|
@ -414,7 +417,11 @@ bool GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec
|
||||||
if (! m_c->m_mesh_raycaster)
|
if (! m_c->m_mesh_raycaster)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
#else
|
||||||
const Camera& camera = m_parent.get_camera();
|
const Camera& camera = m_parent.get_camera();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||||
Geometry::Transformation trafo = volume->get_instance_transformation();
|
Geometry::Transformation trafo = volume->get_instance_transformation();
|
||||||
|
@ -524,7 +531,11 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
||||||
points_inside.push_back(points[idx].cast<float>());
|
points_inside.push_back(points[idx].cast<float>());
|
||||||
|
|
||||||
// Only select/deselect points that are actually visible
|
// Only select/deselect points that are actually visible
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
for (size_t idx : m_c->m_mesh_raycaster->get_unobscured_idxs(trafo, wxGetApp().plater()->get_camera(), points_inside, m_c->m_clipping_plane.get()))
|
||||||
|
#else
|
||||||
for (size_t idx : m_c->m_mesh_raycaster->get_unobscured_idxs(trafo, m_parent.get_camera(), points_inside, m_c->m_clipping_plane.get()))
|
for (size_t idx : m_c->m_mesh_raycaster->get_unobscured_idxs(trafo, m_parent.get_camera(), points_inside, m_c->m_clipping_plane.get()))
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
{
|
{
|
||||||
if (rectangle_status == GLSelectionRectangle::Deselect)
|
if (rectangle_status == GLSelectionRectangle::Deselect)
|
||||||
unselect_point(points_idxs[idx]);
|
unselect_point(points_idxs[idx]);
|
||||||
|
@ -1321,8 +1332,14 @@ void GLGizmoSlaSupports::update_clipping_plane(bool keep_normal) const
|
||||||
{
|
{
|
||||||
if (! m_c->m_model_object)
|
if (! m_c->m_model_object)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
Vec3d normal = (keep_normal && m_c->m_clipping_plane->get_normal() != Vec3d::Zero() ?
|
Vec3d normal = (keep_normal && m_c->m_clipping_plane->get_normal() != Vec3d::Zero() ?
|
||||||
m_c->m_clipping_plane->get_normal() : -m_parent.get_camera().get_dir_forward());
|
m_c->m_clipping_plane->get_normal() : -wxGetApp().plater()->get_camera().get_dir_forward());
|
||||||
|
#else
|
||||||
|
Vec3d normal = (keep_normal && m_c->m_clipping_plane->get_normal() != Vec3d::Zero() ?
|
||||||
|
m_c->m_clipping_plane->get_normal() : -m_parent.get_camera().get_dir_forward());
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
const Vec3d& center = m_c->m_model_object->instances[m_c->m_active_instance]->get_offset() + Vec3d(0., 0., m_z_shift);
|
const Vec3d& center = m_c->m_model_object->instances[m_c->m_active_instance]->get_offset() + Vec3d(0., 0., m_z_shift);
|
||||||
float dist = normal.dot(center);
|
float dist = normal.dot(center);
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#include "GLGizmosManager.hpp"
|
#include "GLGizmosManager.hpp"
|
||||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||||
#include "slic3r/GUI/3DScene.hpp"
|
#include "slic3r/GUI/3DScene.hpp"
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
#include "slic3r/GUI/Camera.hpp"
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
#include "slic3r/GUI/GUI_App.hpp"
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
|
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
|
||||||
#include "slic3r/GUI/PresetBundle.hpp"
|
#include "slic3r/GUI/PresetBundle.hpp"
|
||||||
|
@ -884,8 +887,13 @@ void GLGizmosManager::do_render_overlay() const
|
||||||
|
|
||||||
float cnv_w = (float)m_parent.get_canvas_size().get_width();
|
float cnv_w = (float)m_parent.get_canvas_size().get_width();
|
||||||
float cnv_h = (float)m_parent.get_canvas_size().get_height();
|
float cnv_h = (float)m_parent.get_canvas_size().get_height();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float zoom = (float)wxGetApp().plater()->get_camera().get_zoom();
|
||||||
|
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||||
|
#else
|
||||||
float zoom = (float)m_parent.get_camera().get_zoom();
|
float zoom = (float)m_parent.get_camera().get_zoom();
|
||||||
float inv_zoom = (float)m_parent.get_camera().get_inv_zoom();
|
float inv_zoom = (float)m_parent.get_camera().get_inv_zoom();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
float height = get_scaled_total_height();
|
float height = get_scaled_total_height();
|
||||||
float width = get_scaled_total_width();
|
float width = get_scaled_total_width();
|
||||||
|
@ -936,7 +944,11 @@ void GLGizmosManager::do_render_overlay() const
|
||||||
|
|
||||||
GLTexture::render_sub_texture(icons_texture_id, zoomed_top_x, zoomed_top_x + zoomed_icons_size, zoomed_top_y - zoomed_icons_size, zoomed_top_y, { { u_left, v_bottom }, { u_right, v_bottom }, { u_right, v_top }, { u_left, v_top } });
|
GLTexture::render_sub_texture(icons_texture_id, zoomed_top_x, zoomed_top_x + zoomed_icons_size, zoomed_top_y - zoomed_icons_size, zoomed_top_y, { { u_left, v_bottom }, { u_right, v_bottom }, { u_right, v_top }, { u_left, v_top } });
|
||||||
if (idx == m_current) {
|
if (idx == m_current) {
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
float toolbar_top = cnv_h - wxGetApp().plater()->get_view_toolbar().get_height();
|
||||||
|
#else
|
||||||
float toolbar_top = cnv_h - m_parent.get_view_toolbar_height();
|
float toolbar_top = cnv_h - m_parent.get_view_toolbar_height();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
gizmo->render_input_window(width, 0.5f * cnv_h - zoomed_top_y * zoom, toolbar_top);
|
gizmo->render_input_window(width, 0.5f * cnv_h - zoomed_top_y * zoom, toolbar_top);
|
||||||
}
|
}
|
||||||
zoomed_top_y -= zoomed_stride_y;
|
zoomed_top_y -= zoomed_stride_y;
|
||||||
|
|
|
@ -122,7 +122,9 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
||||||
wxGetApp().app_config->save();
|
wxGetApp().app_config->save();
|
||||||
// if (m_plater)
|
// if (m_plater)
|
||||||
// m_plater->print = undef;
|
// m_plater->print = undef;
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
_3DScene::remove_all_canvases();
|
_3DScene::remove_all_canvases();
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
// Slic3r::GUI::deregister_on_request_update_callback();
|
// Slic3r::GUI::deregister_on_request_update_callback();
|
||||||
|
|
||||||
// set to null tabs and a plater
|
// set to null tabs and a plater
|
||||||
|
|
|
@ -2031,8 +2031,13 @@ 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);
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
view3D = new View3D(q, &model, config, &background_process);
|
||||||
|
preview = new Preview(q, &model, config, &background_process, &gcode_preview_data, [this]() { schedule_background_process(); });
|
||||||
|
#else
|
||||||
view3D = new View3D(q, bed, camera, view_toolbar, &model, config, &background_process);
|
view3D = new View3D(q, bed, camera, view_toolbar, &model, config, &background_process);
|
||||||
preview = new Preview(q, bed, camera, view_toolbar, &model, config, &background_process, &gcode_preview_data, [this](){ schedule_background_process(); });
|
preview = new Preview(q, bed, camera, view_toolbar, &model, config, &background_process, &gcode_preview_data, [this](){ schedule_background_process(); });
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
panels.push_back(view3D);
|
panels.push_back(view3D);
|
||||||
panels.push_back(preview);
|
panels.push_back(preview);
|
||||||
|
@ -2132,7 +2137,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||||
// Drop target:
|
// Drop target:
|
||||||
q->SetDropTarget(new PlaterDropTarget(q)); // if my understanding is right, wxWindow takes the owenership
|
q->SetDropTarget(new PlaterDropTarget(q)); // if my understanding is right, wxWindow takes the owenership
|
||||||
|
|
||||||
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
update_ui_from_settings();
|
update_ui_from_settings();
|
||||||
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
q->Layout();
|
q->Layout();
|
||||||
|
|
||||||
set_current_panel(view3D);
|
set_current_panel(view3D);
|
||||||
|
@ -4530,7 +4537,8 @@ void Sidebar::set_btn_label(const ActionButtonType btn_type, const wxString& lab
|
||||||
// Plater / Public
|
// Plater / Public
|
||||||
|
|
||||||
Plater::Plater(wxWindow *parent, MainFrame *main_frame)
|
Plater::Plater(wxWindow *parent, MainFrame *main_frame)
|
||||||
: wxPanel(parent), p(new priv(this, main_frame))
|
: wxPanel(parent)
|
||||||
|
, p(new priv(this, main_frame))
|
||||||
{
|
{
|
||||||
// Initialization performed in the private c-tor
|
// Initialization performed in the private c-tor
|
||||||
}
|
}
|
||||||
|
@ -5626,6 +5634,33 @@ const Camera& Plater::get_camera() const
|
||||||
return p->camera;
|
return p->camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Camera& Plater::get_camera()
|
||||||
|
{
|
||||||
|
return p->camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Bed3D& Plater::get_bed() const
|
||||||
|
{
|
||||||
|
return p->bed;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bed3D& Plater::get_bed()
|
||||||
|
{
|
||||||
|
return p->bed;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GLToolbar& Plater::get_view_toolbar() const
|
||||||
|
{
|
||||||
|
return p->view_toolbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLToolbar& Plater::get_view_toolbar()
|
||||||
|
{
|
||||||
|
return p->view_toolbar;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
const Mouse3DController& Plater::get_mouse3d_controller() const
|
const Mouse3DController& Plater::get_mouse3d_controller() const
|
||||||
{
|
{
|
||||||
return p->mouse3d_controller;
|
return p->mouse3d_controller;
|
||||||
|
|
|
@ -280,12 +280,22 @@ public:
|
||||||
bool init_view_toolbar();
|
bool init_view_toolbar();
|
||||||
|
|
||||||
const Camera& get_camera() const;
|
const Camera& get_camera() const;
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
Camera& get_camera();
|
||||||
|
|
||||||
|
const Bed3D& get_bed() const;
|
||||||
|
Bed3D& get_bed();
|
||||||
|
|
||||||
|
const GLToolbar& get_view_toolbar() const;
|
||||||
|
GLToolbar& get_view_toolbar();
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
const Mouse3DController& get_mouse3d_controller() const;
|
const Mouse3DController& get_mouse3d_controller() const;
|
||||||
Mouse3DController& get_mouse3d_controller();
|
Mouse3DController& get_mouse3d_controller();
|
||||||
|
|
||||||
void set_bed_shape() const;
|
void set_bed_shape() const;
|
||||||
|
|
||||||
// ROII wrapper for suppressing the Undo / Redo snapshot to be taken.
|
// ROII wrapper for suppressing the Undo / Redo snapshot to be taken.
|
||||||
class SuppressSnapshots
|
class SuppressSnapshots
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -439,6 +439,12 @@ void Selection::clear()
|
||||||
update_type();
|
update_type();
|
||||||
this->set_bounding_boxes_dirty();
|
this->set_bounding_boxes_dirty();
|
||||||
|
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
// this happens while the application is closing
|
||||||
|
if (wxGetApp().obj_manipul() == nullptr)
|
||||||
|
return;
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
|
||||||
// resets the cache in the sidebar
|
// resets the cache in the sidebar
|
||||||
wxGetApp().obj_manipul()->reset_cache();
|
wxGetApp().obj_manipul()->reset_cache();
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,11 @@ SysInfoDialog::SysInfoDialog()
|
||||||
"</font>"
|
"</font>"
|
||||||
"</body>"
|
"</body>"
|
||||||
"</html>", bgr_clr_str, text_clr_str, text_clr_str,
|
"</html>", bgr_clr_str, text_clr_str, text_clr_str,
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
get_mem_info(true) + "<br>" + wxGetApp().get_gl_info(true, true));
|
||||||
|
#else
|
||||||
get_mem_info(true) + "<br>" + _3DScene::get_gl_info(true, true));
|
get_mem_info(true) + "<br>" + _3DScene::get_gl_info(true, true));
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
m_opengl_info_html->SetPage(text);
|
m_opengl_info_html->SetPage(text);
|
||||||
main_sizer->Add(m_opengl_info_html, 1, wxEXPAND | wxBOTTOM, 15);
|
main_sizer->Add(m_opengl_info_html, 1, wxEXPAND | wxBOTTOM, 15);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +202,11 @@ void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
void SysInfoDialog::onCopyToClipboard(wxEvent &)
|
void SysInfoDialog::onCopyToClipboard(wxEvent &)
|
||||||
{
|
{
|
||||||
wxTheClipboard->Open();
|
wxTheClipboard->Open();
|
||||||
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
|
const auto text = get_main_info(false) + "\n" + wxGetApp().get_gl_info(false, true);
|
||||||
|
#else
|
||||||
const auto text = get_main_info(false)+"\n"+_3DScene::get_gl_info(false, true);
|
const auto text = get_main_info(false)+"\n"+_3DScene::get_gl_info(false, true);
|
||||||
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue