mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge branch 'master' into lm_fdm_custom_supports_polishing
This commit is contained in:
commit
b046eb4fc9
42 changed files with 919 additions and 1200 deletions
|
@ -19,9 +19,7 @@
|
|||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/Tab.hpp"
|
||||
#include "slic3r/GUI/GUI_Preview.hpp"
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
#include "slic3r/GUI/GLCanvas3DManager.hpp"
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
#include "slic3r/GUI/OpenGLManager.hpp"
|
||||
#include "slic3r/GUI/3DBed.hpp"
|
||||
#include "slic3r/GUI/Camera.hpp"
|
||||
|
||||
|
@ -360,13 +358,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
|||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
float half_w = 0.5f * (float)cnv_size.get_width();
|
||||
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();
|
||||
#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);
|
||||
}
|
||||
|
||||
|
@ -864,11 +856,7 @@ 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))
|
||||
{
|
||||
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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
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 right = left + (float)m_original_width * inv_zoom;
|
||||
|
@ -1235,11 +1223,7 @@ 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))
|
||||
{
|
||||
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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
float left = (-0.5f * (float)cnv_size.get_width()) * inv_zoom;
|
||||
float top = (0.5f * (float)cnv_size.get_height()) * inv_zoom;
|
||||
float right = left + (float)m_original_width * inv_zoom;
|
||||
|
@ -1265,11 +1249,7 @@ void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_
|
|||
if (!m_enabled || !is_shown())
|
||||
return;
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
#else
|
||||
const Camera& camera = m_canvas.get_camera();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
const Model* model = m_canvas.get_model();
|
||||
if (model == nullptr)
|
||||
return;
|
||||
|
@ -1551,22 +1531,13 @@ wxDEFINE_EVENT(EVT_GLCANVAS_RELOAD_FROM_DISK, SimpleEvent);
|
|||
|
||||
const double GLCanvas3D::DefaultCameraZoomToBoxMarginFactor = 1.25;
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
||||
#else
|
||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar)
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
: m_canvas(canvas)
|
||||
, m_context(nullptr)
|
||||
#if ENABLE_RETINA_GL
|
||||
, m_retina_helper(nullptr)
|
||||
#endif
|
||||
, m_in_render(false)
|
||||
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
, m_bed(bed)
|
||||
, m_camera(camera)
|
||||
, m_view_toolbar(view_toolbar)
|
||||
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
, m_main_toolbar(GLToolbar::Normal, "Top")
|
||||
, m_undoredo_toolbar(GLToolbar::Normal, "Top")
|
||||
, m_collapse_toolbar(GLToolbar::Normal, "Top")
|
||||
|
@ -1603,10 +1574,6 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar
|
|||
m_timer.SetOwner(m_canvas);
|
||||
#if ENABLE_RETINA_GL
|
||||
m_retina_helper.reset(new RetinaHelper(canvas));
|
||||
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
// set default view_toolbar icons size equal to GLGizmosManager::Default_Icons_Size
|
||||
m_view_toolbar.set_icons_size(GLGizmosManager::Default_Icons_Size);
|
||||
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
#endif // ENABLE_RETINA_GL
|
||||
}
|
||||
|
||||
|
@ -1720,7 +1687,6 @@ void GLCanvas3D::reset_volumes()
|
|||
if (!m_initialized)
|
||||
return;
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
if (m_volumes.empty())
|
||||
return;
|
||||
|
||||
|
@ -1731,18 +1697,6 @@ void GLCanvas3D::reset_volumes()
|
|||
m_dirty = true;
|
||||
|
||||
_set_warning_texture(WarningTexture::ObjectOutside, false);
|
||||
#else
|
||||
_set_current();
|
||||
|
||||
if (!m_volumes.empty())
|
||||
{
|
||||
m_selection.clear();
|
||||
m_volumes.clear();
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
_set_warning_texture(WarningTexture::ObjectOutside, false);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
}
|
||||
|
||||
int GLCanvas3D::check_volumes_outside_state() const
|
||||
|
@ -1831,11 +1785,7 @@ void GLCanvas3D::set_model(Model* model)
|
|||
void GLCanvas3D::bed_shape_changed()
|
||||
{
|
||||
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;
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
|
@ -1844,12 +1794,10 @@ void GLCanvas3D::set_color_by(const std::string& 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
|
||||
{
|
||||
|
@ -1865,12 +1813,7 @@ BoundingBoxf3 GLCanvas3D::volumes_bounding_box() const
|
|||
BoundingBoxf3 GLCanvas3D::scene_bounding_box() const
|
||||
{
|
||||
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));
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
if (m_config != nullptr)
|
||||
{
|
||||
double h = m_config->opt_float("max_print_height");
|
||||
|
@ -1992,11 +1935,7 @@ void GLCanvas3D::allow_multisample(bool allow)
|
|||
|
||||
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));
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
}
|
||||
|
||||
void GLCanvas3D::zoom_to_volumes()
|
||||
|
@ -2014,11 +1953,7 @@ void GLCanvas3D::zoom_to_selection()
|
|||
|
||||
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);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
if (m_canvas != nullptr)
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
@ -2046,26 +1981,17 @@ void GLCanvas3D::render()
|
|||
return;
|
||||
|
||||
// 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))
|
||||
return;
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
#if ENABLE_RENDER_STATISTICS
|
||||
auto start_time = std::chrono::high_resolution_clock::now();
|
||||
#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())
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
{
|
||||
// this happens at startup when no data is still saved under <>\AppData\Roaming\Slic3rPE
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_UPDATE_BED_SHAPE));
|
||||
|
@ -2077,7 +2003,6 @@ void GLCanvas3D::render()
|
|||
// 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
|
||||
// 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()));
|
||||
|
||||
|
@ -2090,19 +2015,6 @@ void GLCanvas3D::render()
|
|||
|
||||
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()));
|
||||
|
||||
if (m_camera.requires_zoom_to_bed)
|
||||
{
|
||||
zoom_to_bed();
|
||||
_resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
|
||||
m_camera.requires_zoom_to_bed = false;
|
||||
}
|
||||
|
||||
m_camera.apply_view_matrix();
|
||||
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 };
|
||||
glsafe(::glLightfv(GL_LIGHT1, GL_POSITION, position_cam));
|
||||
|
@ -2132,11 +2044,7 @@ void GLCanvas3D::render()
|
|||
_render_objects();
|
||||
_render_sla_slices();
|
||||
_render_selection();
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
_render_bed(!camera.is_looking_downward(), true);
|
||||
#else
|
||||
_render_bed(!m_camera.is_looking_downward(), true);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
_render_selection_center();
|
||||
|
@ -2174,10 +2082,10 @@ void GLCanvas3D::render()
|
|||
ImGui::Separator();
|
||||
imgui.text("Compressed textures: ");
|
||||
ImGui::SameLine();
|
||||
imgui.text(GLCanvas3DManager::are_compressed_textures_supported() ? "supported" : "not supported");
|
||||
imgui.text(OpenGLManager::are_compressed_textures_supported() ? "supported" : "not supported");
|
||||
imgui.text("Max texture size: ");
|
||||
ImGui::SameLine();
|
||||
imgui.text(std::to_string(GLCanvas3DManager::get_gl_info().get_max_tex_size()));
|
||||
imgui.text(std::to_string(OpenGLManager::get_gl_info().get_max_tex_size()));
|
||||
imgui.end();
|
||||
#endif // ENABLE_RENDER_STATISTICS
|
||||
|
||||
|
@ -2208,16 +2116,13 @@ void GLCanvas3D::render()
|
|||
tooltip = m_collapse_toolbar.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
tooltip = wxGetApp().plater()->get_view_toolbar().get_tooltip();
|
||||
#else
|
||||
tooltip = m_view_toolbar.get_tooltip();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
}
|
||||
|
||||
set_tooltip(tooltip);
|
||||
|
||||
m_tooltip.render(m_mouse.position, *this);
|
||||
if (m_tooltip_enabled)
|
||||
m_tooltip.render(m_mouse.position, *this);
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
|
||||
wxGetApp().plater()->get_mouse3d_controller().render_settings_dialog(*this);
|
||||
|
@ -2258,15 +2163,10 @@ void GLCanvas3D::render()
|
|||
|
||||
void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const
|
||||
{
|
||||
switch (GLCanvas3DManager::get_framebuffers_type())
|
||||
switch (OpenGLManager::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_Ext: { _render_thumbnail_framebuffer_ext(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
case OpenGLManager::EFramebufferType::Arb: { _render_thumbnail_framebuffer(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
|
||||
case OpenGLManager::EFramebufferType::Ext: { _render_thumbnail_framebuffer_ext(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; }
|
||||
}
|
||||
}
|
||||
|
@ -2371,15 +2271,10 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
if ((m_canvas == nullptr) || (m_config == nullptr) || (m_model == nullptr))
|
||||
return;
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
if (!m_initialized)
|
||||
return;
|
||||
|
||||
_set_current();
|
||||
#else
|
||||
if (m_initialized)
|
||||
_set_current();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
struct ModelVolumeState {
|
||||
ModelVolumeState(const GLVolume* volume) :
|
||||
|
@ -2933,6 +2828,9 @@ void GLCanvas3D::bind_event_handlers()
|
|||
m_canvas->Bind(wxEVT_MIDDLE_DCLICK, &GLCanvas3D::on_mouse, this);
|
||||
m_canvas->Bind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this);
|
||||
m_canvas->Bind(wxEVT_PAINT, &GLCanvas3D::on_paint, this);
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
m_canvas->Bind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this);
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2960,6 +2858,9 @@ void GLCanvas3D::unbind_event_handlers()
|
|||
m_canvas->Unbind(wxEVT_MIDDLE_DCLICK, &GLCanvas3D::on_mouse, this);
|
||||
m_canvas->Unbind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this);
|
||||
m_canvas->Unbind(wxEVT_PAINT, &GLCanvas3D::on_paint, this);
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
m_canvas->Unbind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this);
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2976,13 +2877,8 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
|||
m_dirty |= m_main_toolbar.update_items_state();
|
||||
m_dirty |= m_undoredo_toolbar.update_items_state();
|
||||
m_dirty |= m_collapse_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();
|
||||
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(m_camera);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
m_dirty |= mouse3d_controller_applied;
|
||||
|
||||
if (!m_dirty)
|
||||
|
@ -3146,11 +3042,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
|||
case 'I':
|
||||
case 'i': { _update_camera_zoom(1.0); break; }
|
||||
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; }
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
case 'O':
|
||||
case 'o': { _update_camera_zoom(-1.0); break; }
|
||||
#if ENABLE_RENDER_PICKING_PASS
|
||||
|
@ -3277,11 +3169,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
|||
Vec3d displacement;
|
||||
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);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
displacement = multiplier * (inv_view_3x3 * direction);
|
||||
displacement(2) = 0.0;
|
||||
}
|
||||
|
@ -3624,11 +3512,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
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))
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
{
|
||||
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
|
||||
mouse_up_cleanup();
|
||||
|
@ -3676,12 +3560,18 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
if (top_level_wnd && top_level_wnd->IsActive())
|
||||
m_canvas->SetFocus();
|
||||
m_mouse.position = pos.cast<double>();
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
m_tooltip_enabled = false;
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
// 1) forces a frame render to ensure that m_hover_volume_idxs is updated even when the user right clicks while
|
||||
// the context menu is shown, ensuring it to disappear if the mouse is outside any volume and to
|
||||
// change the volume hover state if any is under the mouse
|
||||
// 2) when switching between 3d view and preview the size of the canvas changes if the side panels are visible,
|
||||
// so forces a resize to avoid multiple renders with different sizes (seen as flickering)
|
||||
_refresh_if_shown_on_screen();
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
m_tooltip_enabled = true;
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
}
|
||||
m_mouse.set_start_position_2D_as_invalid();
|
||||
//#endif
|
||||
|
@ -3689,7 +3579,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
else if (evt.Leaving())
|
||||
{
|
||||
_deactivate_undo_redo_toolbar_items();
|
||||
_deactivate_search_toolbar_item();
|
||||
|
||||
// to remove hover on objects when the mouse goes out of this canvas
|
||||
m_mouse.position = Vec2d(-1.0, -1.0);
|
||||
|
@ -3793,12 +3682,8 @@ 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
|
||||
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)
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
{
|
||||
// side view -> move selected volumes orthogonally to camera view direction
|
||||
Linef3 ray = mouse_ray(pos);
|
||||
|
@ -3811,13 +3696,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
// vector from the starting position to the found intersection
|
||||
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_up = m_camera.get_dir_up();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
// finds projection of the vector along the camera axes
|
||||
double projection_x = inters_vec.dot(camera_right);
|
||||
|
@ -3867,25 +3747,16 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.);
|
||||
if (wxGetApp().app_config->get("use_free_camera") == "1")
|
||||
// Virtual track ball (similar to the 3DConnexion mouse).
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
wxGetApp().plater()->get_camera().rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.));
|
||||
#else
|
||||
m_camera.rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.));
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
else
|
||||
{
|
||||
// Forces camera right vector to be parallel to XY plane in case it has been misaligned using the 3D mouse free rotation.
|
||||
// It is cheaper to call this function right away instead of testing wxGetApp().plater()->get_mouse3d_controller().connected(),
|
||||
// which checks an atomics (flushes CPU caches).
|
||||
// See GH issue #3816.
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
Camera& camera = wxGetApp().plater()->get_camera();
|
||||
camera.recover_from_free_camera();
|
||||
camera.rotate_on_sphere(rot.x(), rot.y(), wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||
#else
|
||||
m_camera.recover_from_free_camera();
|
||||
m_camera.rotate_on_sphere(rot.x(), rot.y(), wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
}
|
||||
|
||||
m_dirty = true;
|
||||
|
@ -3901,23 +3772,15 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
float z = 0.0f;
|
||||
const Vec3d& cur_pos = _mouse_to_3d(pos, &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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
if (wxGetApp().app_config->get("use_free_camera") != "1")
|
||||
// Forces camera right vector to be parallel to XY plane in case it has been misaligned using the 3D mouse free rotation.
|
||||
// It is cheaper to call this function right away instead of testing wxGetApp().plater()->get_mouse3d_controller().connected(),
|
||||
// which checks an atomics (flushes CPU caches).
|
||||
// See GH issue #3816.
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
camera.recover_from_free_camera();
|
||||
|
||||
camera.set_target(camera.get_target() + orig - cur_pos);
|
||||
#else
|
||||
m_camera.recover_from_free_camera();
|
||||
|
||||
m_camera.set_target(m_camera.get_target() + orig - cur_pos);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
|
@ -4022,6 +3885,15 @@ void GLCanvas3D::on_paint(wxPaintEvent& evt)
|
|||
this->render();
|
||||
}
|
||||
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
void GLCanvas3D::on_set_focus(wxFocusEvent& evt)
|
||||
{
|
||||
m_tooltip_enabled = false;
|
||||
_refresh_if_shown_on_screen();
|
||||
m_tooltip_enabled = true;
|
||||
}
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
|
||||
Size GLCanvas3D::get_canvas_size() const
|
||||
{
|
||||
int w = 0;
|
||||
|
@ -4366,15 +4238,14 @@ void GLCanvas3D::update_ui_from_settings()
|
|||
if (new_scaling != orig_scaling) {
|
||||
BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Scaling factor: " << new_scaling;
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
Camera& camera = wxGetApp().plater()->get_camera();
|
||||
camera.set_zoom(camera.get_zoom() * new_scaling / orig_scaling);
|
||||
#else
|
||||
m_camera.set_zoom(m_camera.get_zoom() * new_scaling / orig_scaling);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
_refresh_if_shown_on_screen();
|
||||
}
|
||||
#endif
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
bool enable_collapse = wxGetApp().app_config->get("show_collapse_button") == "1";
|
||||
enable_collapse_toolbar(enable_collapse);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4406,11 +4277,7 @@ Linef3 GLCanvas3D::mouse_ray(const Point& mouse_pos)
|
|||
|
||||
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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_cursor(ECursorType type)
|
||||
|
@ -4432,6 +4299,16 @@ void GLCanvas3D::msw_rescale()
|
|||
m_warning_texture.msw_rescale(*this);
|
||||
}
|
||||
|
||||
void GLCanvas3D::update_tooltip_for_settings_item_in_main_toolbar()
|
||||
{
|
||||
std::string new_tooltip = _u8L("Switch to Settings") +
|
||||
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") +
|
||||
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "3] - " + (m_process->current_printer_technology() == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab")) +
|
||||
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab") ;
|
||||
|
||||
m_main_toolbar.set_tooltip(get_main_toolbar_item_id("settings"), new_tooltip);
|
||||
}
|
||||
|
||||
bool GLCanvas3D::has_toolpaths_to_export() const
|
||||
{
|
||||
return m_volumes.has_toolpaths_to_export();
|
||||
|
@ -4473,11 +4350,7 @@ bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x) const
|
|||
|
||||
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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
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");
|
||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
@ -4518,22 +4391,17 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
|
|||
bool action_taken = false;
|
||||
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();
|
||||
#endif
|
||||
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
std::string title = L("Search");
|
||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
int selected = -1;
|
||||
bool edited = false;
|
||||
bool check_changed = false;
|
||||
float em = static_cast<float>(wxGetApp().em_unit());
|
||||
#if ENABLE_RETINA_GL
|
||||
em *= m_retina_helper->get_scale_factor();
|
||||
#endif
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
Sidebar& sidebar = wxGetApp().sidebar();
|
||||
|
||||
|
@ -4543,7 +4411,7 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
|
|||
|
||||
imgui->search_list(ImVec2(45 * em, 30 * em), &search_string_getter, s,
|
||||
sidebar.get_searcher().view_params,
|
||||
selected, edited, m_mouse_wheel);
|
||||
selected, edited, m_mouse_wheel, wxGetApp().is_localized());
|
||||
|
||||
search_line = s;
|
||||
delete [] s;
|
||||
|
@ -4553,11 +4421,12 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
|
|||
if (edited)
|
||||
sidebar.search();
|
||||
|
||||
if (selected != size_t(-1)) {
|
||||
if (selected >= 0) {
|
||||
// selected == 9999 means that Esc kye was pressed
|
||||
if (selected != 9999)
|
||||
if (selected == 9999)
|
||||
action_taken = true;
|
||||
else
|
||||
sidebar.jump_to_option(selected);
|
||||
action_taken = true;
|
||||
}
|
||||
|
||||
imgui->end();
|
||||
|
@ -4635,11 +4504,7 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, bool
|
|||
// extends the near and far z of the frustrum to avoid the bed being clipped
|
||||
|
||||
// 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());
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
near_z = -t_bed_box.max(2);
|
||||
far_z = -t_bed_box.min(2);
|
||||
}
|
||||
|
@ -4916,11 +4781,7 @@ void GLCanvas3D::_render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigne
|
|||
#endif // ENABLE_THUMBNAIL_GENERATOR_DEBUG_OUTPUT
|
||||
|
||||
// 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());
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_init_toolbars()
|
||||
|
@ -5075,10 +4936,26 @@ bool GLCanvas3D::_init_main_toolbar()
|
|||
if (!m_main_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
item.name = "settings";
|
||||
item.icon_filename = "cog.svg";
|
||||
item.tooltip = _u8L("Switch to Settings") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") +
|
||||
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "3] - " + (m_process->current_printer_technology() == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab")) +
|
||||
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab") ;
|
||||
item.sprite_id = 10;
|
||||
item.enabling_callback = GLToolbarItem::Default_Enabling_Callback;
|
||||
item.visibility_callback = [this]() { return (wxGetApp().app_config->get("new_settings_layout_mode") == "1" ||
|
||||
wxGetApp().app_config->get("dlg_settings_layout_mode") == "1"); };
|
||||
item.left.action_callback = [this]() { wxGetApp().mainframe->select_tab(); };
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_main_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
item.name = "layersediting";
|
||||
item.icon_filename = "layers_white.svg";
|
||||
item.tooltip = _utf8(L("Variable layer height"));
|
||||
item.sprite_id = 10;
|
||||
item.sprite_id = 11;
|
||||
item.left.toggable = true;
|
||||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); };
|
||||
item.visibility_callback = [this]()->bool
|
||||
|
@ -5100,7 +4977,7 @@ bool GLCanvas3D::_init_main_toolbar()
|
|||
item.name = "search";
|
||||
item.icon_filename = "search_.svg";
|
||||
item.tooltip = _utf8(L("Search")) + " [" + GUI::shortkey_ctrl_prefix() + "F]";
|
||||
item.sprite_id = 11;
|
||||
item.sprite_id = 12;
|
||||
item.left.render_callback = [this](float left, float right, float, float) {
|
||||
if (m_canvas != nullptr)
|
||||
{
|
||||
|
@ -5236,7 +5113,7 @@ bool GLCanvas3D::_init_view_toolbar()
|
|||
|
||||
bool GLCanvas3D::_init_collapse_toolbar()
|
||||
{
|
||||
if (!m_collapse_toolbar.is_enabled())
|
||||
if (!m_collapse_toolbar.is_enabled() && m_collapse_toolbar.get_items_count() > 0)
|
||||
return true;
|
||||
|
||||
BackgroundTexture::Metadata background_data;
|
||||
|
@ -5277,61 +5154,10 @@ bool GLCanvas3D::_init_collapse_toolbar()
|
|||
wxGetApp().plater()->collapse_sidebar(!wxGetApp().plater()->is_sidebar_collapsed());
|
||||
};
|
||||
|
||||
if (!m_collapse_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_collapse_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
item.name = "print";
|
||||
item.icon_filename = "cog.svg";
|
||||
item.tooltip = _utf8(L("Switch to Print Settings")) + " [" + GUI::shortkey_ctrl_prefix() + "2]";
|
||||
item.sprite_id = 1;
|
||||
item.left.action_callback = [this]() { wxGetApp().mainframe->select_tab(/*0*/1); };
|
||||
|
||||
if (!m_collapse_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "filament";
|
||||
item.icon_filename = "spool.svg";
|
||||
item.tooltip = _utf8(L("Switch to Filament Settings")) + " [" + GUI::shortkey_ctrl_prefix() + "3]";
|
||||
item.sprite_id = 2;
|
||||
item.left.action_callback = [this]() { wxGetApp().mainframe->select_tab(/*1*/2); };
|
||||
item.visibility_callback = [this]() { return wxGetApp().plater()->printer_technology() == ptFFF; };
|
||||
|
||||
if (!m_collapse_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "printer";
|
||||
item.icon_filename = "printer.svg";
|
||||
item.tooltip = _utf8(L("Switch to Printer Settings")) + " [" + GUI::shortkey_ctrl_prefix() + "4]";
|
||||
item.sprite_id = 3;
|
||||
item.left.action_callback = [this]() { wxGetApp().mainframe->select_tab(/*2*/3); };
|
||||
|
||||
if (!m_collapse_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "resin";
|
||||
item.icon_filename = "resin.svg";
|
||||
item.tooltip = _utf8(L("Switch to SLA Material Settings")) + " [" + GUI::shortkey_ctrl_prefix() + "3]";
|
||||
item.sprite_id = 4;
|
||||
item.left.action_callback = [this]() { wxGetApp().mainframe->select_tab(/*1*/2); };
|
||||
item.visibility_callback = [this]() { return m_process->current_printer_technology() == ptSLA; };
|
||||
|
||||
if (!m_collapse_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "sla_printer";
|
||||
item.icon_filename = "sla_printer.svg";
|
||||
item.tooltip = _utf8(L("Switch to Printer Settings")) + " [" + GUI::shortkey_ctrl_prefix() + "4]";
|
||||
item.sprite_id = 5;
|
||||
item.left.action_callback = [this]() { wxGetApp().mainframe->select_tab(/*2*/3); };
|
||||
|
||||
if (!m_collapse_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_set_current()
|
||||
|
@ -5371,31 +5197,19 @@ BoundingBoxf3 GLCanvas3D::_max_bounding_box(bool include_gizmos, bool include_be
|
|||
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));
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
return bb;
|
||||
}
|
||||
|
||||
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);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
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);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
|
@ -5591,11 +5405,7 @@ void GLCanvas3D::_render_bed(bool bottom, bool show_axes) const
|
|||
(m_gizmos.get_current_type() != GLGizmosManager::FdmSupports
|
||||
&& m_gizmos.get_current_type() != GLGizmosManager::SlaSupports);
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
wxGetApp().plater()->get_bed().render(const_cast<GLCanvas3D&>(*this), bottom, scale_factor, show_axes, show_texture);
|
||||
#else
|
||||
m_bed.render(const_cast<GLCanvas3D&>(*this), theta, scale_factor, show_axes);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_objects() const
|
||||
|
@ -5614,11 +5424,7 @@ void GLCanvas3D::_render_objects() const
|
|||
|
||||
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);
|
||||
#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.check_outside_state(m_config, nullptr);
|
||||
}
|
||||
|
@ -5634,37 +5440,20 @@ void GLCanvas3D::_render_objects() const
|
|||
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)) {
|
||||
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) {
|
||||
// Which volume to paint without the layer height profile shader?
|
||||
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.
|
||||
m_layers_editing.render_volumes(*this, this->m_volumes);
|
||||
} else {
|
||||
// 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) {
|
||||
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());
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
m_shader.stop_using();
|
||||
|
||||
m_camera_clipping_plane = ClippingPlane::ClipsNothing();
|
||||
|
@ -5675,7 +5464,7 @@ void GLCanvas3D::_render_selection() const
|
|||
float scale_factor = 1.0;
|
||||
#if ENABLE_RETINA_GL
|
||||
scale_factor = m_retina_helper->get_scale_factor();
|
||||
#endif
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
if (!m_gizmos.is_running())
|
||||
m_selection.render(scale_factor);
|
||||
|
@ -5694,16 +5483,10 @@ void GLCanvas3D::_render_overlays() const
|
|||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
// 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)));
|
||||
// ensure that the overlay fits the frustrum near z plane
|
||||
double gui_scale = m_camera.get_gui_scale();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
glsafe(::glScaled(gui_scale, gui_scale, 1.0));
|
||||
|
||||
_render_gizmos_overlay();
|
||||
|
@ -5773,11 +5556,7 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
|||
glsafe(::glEnableClientState(GL_VERTEX_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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
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);
|
||||
for (const GLVolumeWithIdAndZ& volume : to_render)
|
||||
|
@ -5826,11 +5605,7 @@ void GLCanvas3D::_render_main_toolbar() const
|
|||
return;
|
||||
|
||||
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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
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;
|
||||
|
@ -5845,11 +5620,7 @@ void GLCanvas3D::_render_undoredo_toolbar() const
|
|||
return;
|
||||
|
||||
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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
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;
|
||||
|
@ -5863,11 +5634,7 @@ void GLCanvas3D::_render_collapse_toolbar() const
|
|||
return;
|
||||
|
||||
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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
float band = m_layers_editing.is_enabled() ? (wxGetApp().imgui()->get_style_scaling() * LayersEditing::THICKNESS_BAR_WIDTH) : 0.0;
|
||||
|
||||
|
@ -5880,50 +5647,27 @@ void GLCanvas3D::_render_collapse_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
|
||||
// m_view_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||
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
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
#else
|
||||
// m_view_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
// m_view_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
||||
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
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
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();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
// 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;
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
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.render(*this);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
}
|
||||
|
||||
#if ENABLE_SHOW_CAMERA_TARGET
|
||||
|
@ -6202,16 +5946,10 @@ Vec3d GLCanvas3D::_mouse_to_3d(const Point& mouse_pos, float* z)
|
|||
if (m_canvas == nullptr)
|
||||
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 Transform3d& modelview_matrix = m_camera.get_view_matrix();
|
||||
const Transform3d& projection_matrix = m_camera.get_projection_matrix();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
GLint y = viewport[3] - (GLint)mouse_pos(1);
|
||||
GLfloat mouse_z;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue