mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge branch 'master' into dev
This commit is contained in:
commit
97b9de47b4
166 changed files with 13682 additions and 9161 deletions
|
@ -63,9 +63,11 @@
|
|||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include "DoubleSlider.hpp"
|
||||
#if !ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
#if ENABLE_RENDER_STATISTICS
|
||||
#include <chrono>
|
||||
#endif // ENABLE_RENDER_STATISTICS
|
||||
#endif // !ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
|
||||
#include <imgui/imgui_internal.h>
|
||||
|
||||
|
@ -665,7 +667,7 @@ void GLCanvas3D::WarningTexture::activate(WarningTexture::Warning warning, bool
|
|||
if (it != m_warnings.end()) // this warning is already set to be shown
|
||||
return;
|
||||
|
||||
m_warnings.push_back(warning);
|
||||
m_warnings.emplace_back(warning);
|
||||
std::sort(m_warnings.begin(), m_warnings.end());
|
||||
}
|
||||
else {
|
||||
|
@ -1291,7 +1293,7 @@ void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_
|
|||
if (model_object->instances.size() > 1)
|
||||
owner.label += " (" + std::to_string(inst_idx + 1) + ")";
|
||||
owner.selected = volume->selected;
|
||||
owners.push_back(owner);
|
||||
owners.emplace_back(owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1372,6 +1374,88 @@ void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
void GLCanvas3D::Tooltip::set_text(const std::string& text)
|
||||
{
|
||||
// If the mouse is inside an ImGUI dialog, then the tooltip is suppressed.
|
||||
const std::string &new_text = m_in_imgui ? std::string() : text;
|
||||
if (m_text != new_text)
|
||||
{
|
||||
if (m_text.empty())
|
||||
m_start_time = std::chrono::steady_clock::now();
|
||||
|
||||
m_text = new_text;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas) const
|
||||
#else
|
||||
void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position) const
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
{
|
||||
#if ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
static ImVec2 size(0.0f, 0.0f);
|
||||
|
||||
auto validate_position = [](const Vec2d& position, const GLCanvas3D& canvas, const ImVec2& wnd_size) {
|
||||
Size cnv_size = canvas.get_canvas_size();
|
||||
float x = std::clamp((float)position(0), 0.0f, (float)cnv_size.get_width() - wnd_size.x);
|
||||
float y = std::clamp((float)position(1) + 16, 0.0f, (float)cnv_size.get_height() - wnd_size.y);
|
||||
return Vec2f(x, y);
|
||||
};
|
||||
#endif // ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
if (m_text.empty())
|
||||
return;
|
||||
|
||||
// draw the tooltip as hidden until the delay is expired
|
||||
float alpha = (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - m_start_time).count() < 500) ? 0.0f : 1.0;
|
||||
#else
|
||||
if (m_text.empty())
|
||||
return;
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
|
||||
#if ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
Vec2f position = validate_position(mouse_position, canvas, size);
|
||||
#endif // ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
|
||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
#if ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
imgui.set_next_window_pos(position(0), position(1), ImGuiCond_Always, 0.0f, 0.0f);
|
||||
#else
|
||||
imgui.set_next_window_pos(mouse_position(0), mouse_position(1) + 16, ImGuiCond_Always, 0.0f, 0.0f);
|
||||
#endif // ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
|
||||
imgui.begin(_(L("canvas_tooltip")), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow());
|
||||
ImGui::TextUnformatted(m_text.c_str());
|
||||
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
// force re-render while the windows gets to its final size (it may take several frames) or while hidden
|
||||
if (alpha == 0.0f || ImGui::GetWindowContentRegionWidth() + 2.0f * ImGui::GetStyle().WindowPadding.x != ImGui::CalcWindowExpectedSize(ImGui::GetCurrentWindow()).x)
|
||||
canvas.request_extra_frame();
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
|
||||
#if ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
size = ImGui::GetWindowSize();
|
||||
#endif // ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
|
||||
imgui.end();
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
ImGui::PopStyleVar(2);
|
||||
#else
|
||||
ImGui::PopStyleVar();
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
}
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, RBtnEvent);
|
||||
|
@ -1943,6 +2027,38 @@ void GLCanvas3D::render()
|
|||
m_camera.debug_render();
|
||||
#endif // ENABLE_CAMERA_STATISTICS
|
||||
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
std::string tooltip;
|
||||
|
||||
// Negative coordinate means out of the window, likely because the window was deactivated.
|
||||
// In that case the tooltip should be hidden.
|
||||
if (m_mouse.position.x() >= 0. && m_mouse.position.y() >= 0.)
|
||||
{
|
||||
if (tooltip.empty())
|
||||
tooltip = m_layers_editing.get_tooltip(*this);
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_gizmos.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_main_toolbar.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_undoredo_toolbar.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_view_toolbar.get_tooltip();
|
||||
}
|
||||
|
||||
set_tooltip(tooltip);
|
||||
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
m_tooltip.render(m_mouse.position, *this);
|
||||
#else
|
||||
m_tooltip.render(m_mouse.position);
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
|
||||
wxGetApp().plater()->get_mouse3d_controller().render_settings_dialog(*this);
|
||||
|
||||
wxGetApp().imgui()->render();
|
||||
|
@ -1953,6 +2069,27 @@ void GLCanvas3D::render()
|
|||
auto end_time = std::chrono::high_resolution_clock::now();
|
||||
m_render_stats.last_frame = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count();
|
||||
#endif // ENABLE_RENDER_STATISTICS
|
||||
|
||||
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
std::string tooltip = "";
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_layers_editing.get_tooltip(*this);
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_gizmos.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_main_toolbar.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_undoredo_toolbar.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_view_toolbar.get_tooltip();
|
||||
|
||||
set_tooltip(tooltip);
|
||||
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
}
|
||||
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
|
@ -2031,7 +2168,7 @@ std::vector<int> GLCanvas3D::load_object(const ModelObject& model_object, int ob
|
|||
{
|
||||
for (unsigned int i = 0; i < model_object.instances.size(); ++i)
|
||||
{
|
||||
instance_idxs.push_back(i);
|
||||
instance_idxs.emplace_back(i);
|
||||
}
|
||||
}
|
||||
return m_volumes.load_object(&model_object, obj_idx, instance_idxs, m_color_by, m_initialized);
|
||||
|
@ -2471,9 +2608,9 @@ static void load_gcode_retractions(const GCodePreviewData::Retraction& retractio
|
|||
|
||||
for (const GCodePreviewData::Retraction::Position& position : copy)
|
||||
{
|
||||
volume->print_zs.push_back(unscale<double>(position.position(2)));
|
||||
volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
|
||||
volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size());
|
||||
volume->print_zs.emplace_back(unscale<double>(position.position(2)));
|
||||
volume->offsets.emplace_back(volume->indexed_vertex_array.quad_indices.size());
|
||||
volume->offsets.emplace_back(volume->indexed_vertex_array.triangle_indices.size());
|
||||
|
||||
_3DScene::point3_to_verts(position.position, position.width, position.height, *volume);
|
||||
|
||||
|
@ -3084,10 +3221,11 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
|||
|
||||
void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
|
||||
{
|
||||
// try to filter out events coming from mouse 3d
|
||||
Mouse3DController& controller = wxGetApp().plater()->get_mouse3d_controller();
|
||||
if (controller.process_mouse_wheel())
|
||||
#ifdef WIN32
|
||||
// Try to filter out spurious mouse wheel events comming from 3D mouse.
|
||||
if (wxGetApp().plater()->get_mouse3d_controller().process_mouse_wheel())
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (!m_initialized)
|
||||
return;
|
||||
|
@ -3192,22 +3330,33 @@ std::string format_mouse_event_debug_message(const wxMouseEvent &evt)
|
|||
|
||||
void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
{
|
||||
if (!m_initialized || !_set_current())
|
||||
return;
|
||||
|
||||
#if ENABLE_RETINA_GL
|
||||
const float scale = m_retina_helper->get_scale_factor();
|
||||
evt.SetX(evt.GetX() * scale);
|
||||
evt.SetY(evt.GetY() * scale);
|
||||
#endif
|
||||
|
||||
Point pos(evt.GetX(), evt.GetY());
|
||||
Point pos(evt.GetX(), evt.GetY());
|
||||
|
||||
ImGuiWrapper *imgui = wxGetApp().imgui();
|
||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||
m_tooltip.set_in_imgui(false);
|
||||
if (imgui->update_mouse_data(evt)) {
|
||||
m_mouse.position = evt.Leaving() ? Vec2d(-1.0, -1.0) : pos.cast<double>();
|
||||
m_tooltip.set_in_imgui(true);
|
||||
render();
|
||||
#ifdef SLIC3R_DEBUG_MOUSE_EVENTS
|
||||
printf((format_mouse_event_debug_message(evt) + " - Consumed by ImGUI\n").c_str());
|
||||
printf((format_mouse_event_debug_message(evt) + " - Consumed by ImGUI\n").c_str());
|
||||
#endif /* SLIC3R_DEBUG_MOUSE_EVENTS */
|
||||
return;
|
||||
// do not return if dragging or tooltip not empty to allow for tooltip update
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
if (!m_mouse.dragging && m_tooltip.is_empty())
|
||||
#else
|
||||
if (!m_mouse.dragging && m_canvas->GetToolTipText().empty())
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
|
@ -3258,12 +3407,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
mouse_up_cleanup();
|
||||
|
||||
m_mouse.set_start_position_3D_as_invalid();
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
m_mouse.position = pos.cast<double>();
|
||||
#endif /// ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_picking_enabled)
|
||||
_set_current();
|
||||
|
||||
int selected_object_idx = m_selection.get_object_idx();
|
||||
int layer_editing_object_idx = is_layers_editing_enabled() ? selected_object_idx : -1;
|
||||
m_layers_editing.select_object(*m_model, layer_editing_object_idx);
|
||||
|
@ -3467,11 +3616,26 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
if (m_hover_volume_idxs.empty() && m_mouse.is_start_position_3D_defined())
|
||||
{
|
||||
const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.);
|
||||
if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||
#if ENABLE_AUTO_CONSTRAINED_CAMERA
|
||||
if (wxGetApp().app_config->get("use_free_camera") == "1")
|
||||
// Virtual track ball (similar to the 3DConnexion mouse).
|
||||
m_camera.rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.));
|
||||
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.
|
||||
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);
|
||||
}
|
||||
#else
|
||||
if (wxGetApp().plater()->get_mouse3d_controller().connected() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||
// Virtual track ball (similar to the 3DConnexion mouse).
|
||||
m_camera.rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.));
|
||||
else
|
||||
m_camera.rotate_on_sphere(rot.x(), rot.y(), wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||
#endif // ENABLE_AUTO_CONSTRAINED_CAMERA
|
||||
|
||||
m_dirty = true;
|
||||
}
|
||||
|
@ -3486,6 +3650,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_AUTO_CONSTRAINED_CAMERA
|
||||
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.
|
||||
m_camera.recover_from_free_camera();
|
||||
#endif // ENABLE_AUTO_CONSTRAINED_CAMERA
|
||||
|
||||
m_camera.set_target(m_camera.get_target() + orig - cur_pos);
|
||||
m_dirty = true;
|
||||
}
|
||||
|
@ -3564,24 +3737,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
else if (evt.Moving())
|
||||
{
|
||||
m_mouse.position = pos.cast<double>();
|
||||
std::string tooltip = "";
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_layers_editing.get_tooltip(*this);
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_gizmos.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_main_toolbar.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_undoredo_toolbar.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_view_toolbar.get_tooltip();
|
||||
|
||||
set_tooltip(tooltip);
|
||||
|
||||
// updates gizmos overlay
|
||||
if (m_selection.is_empty())
|
||||
|
@ -3656,20 +3811,27 @@ void GLCanvas3D::set_tooltip(const std::string& tooltip) const
|
|||
{
|
||||
if (m_canvas != nullptr)
|
||||
{
|
||||
wxToolTip* t = m_canvas->GetToolTip();
|
||||
if (t != nullptr)
|
||||
{
|
||||
if (tooltip.empty())
|
||||
m_canvas->UnsetToolTip();
|
||||
else
|
||||
t->SetTip(wxString::FromUTF8(tooltip.data()));
|
||||
}
|
||||
else if (!tooltip.empty()) // Avoid "empty" tooltips => unset of the empty tooltip leads to application crash under OSX
|
||||
m_canvas->SetToolTip(wxString::FromUTF8(tooltip.data()));
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
m_tooltip.set_text(tooltip);
|
||||
#else
|
||||
wxString txt = wxString::FromUTF8(tooltip.data());
|
||||
if (m_canvas->GetToolTipText() != txt)
|
||||
m_canvas->SetToolTip(txt);
|
||||
|
||||
// wxToolTip* t = m_canvas->GetToolTip();
|
||||
// if (t != nullptr)
|
||||
// {
|
||||
// if (tooltip.empty())
|
||||
// m_canvas->UnsetToolTip();
|
||||
// else
|
||||
// t->SetTip(wxString::FromUTF8(tooltip.data()));
|
||||
// }
|
||||
// else if (!tooltip.empty()) // Avoid "empty" tooltips => unset of the empty tooltip leads to application crash under OSX
|
||||
// m_canvas->SetToolTip(wxString::FromUTF8(tooltip.data()));
|
||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLCanvas3D::do_move(const std::string& snapshot_type)
|
||||
{
|
||||
if (m_model == nullptr)
|
||||
|
@ -3933,7 +4095,6 @@ void GLCanvas3D::handle_layers_data_focus_event(const t_layer_height_range range
|
|||
|
||||
void GLCanvas3D::update_ui_from_settings()
|
||||
{
|
||||
m_camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
||||
m_dirty = true;
|
||||
|
||||
#if ENABLE_RETINA_GL
|
||||
|
@ -4118,7 +4279,7 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, bool
|
|||
if (!vol->is_modifier && !vol->is_wipe_tower && (!parts_only || (vol->composite_id.volume_id >= 0)))
|
||||
{
|
||||
if (!printable_only || is_visible(*vol))
|
||||
visible_volumes.push_back(vol);
|
||||
visible_volumes.emplace_back(vol);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4822,7 +4983,7 @@ void GLCanvas3D::_picking_pass() const
|
|||
}
|
||||
if ((0 <= volume_id) && (volume_id < (int)m_volumes.volumes.size()))
|
||||
{
|
||||
m_hover_volume_idxs.push_back(volume_id);
|
||||
m_hover_volume_idxs.emplace_back(volume_id);
|
||||
m_gizmos.set_hover_id(-1);
|
||||
}
|
||||
else
|
||||
|
@ -5040,6 +5201,19 @@ void GLCanvas3D::_render_overlays() const
|
|||
_render_gizmos_overlay();
|
||||
_render_warning_texture();
|
||||
_render_legend_texture();
|
||||
|
||||
// main toolbar and undoredo toolbar need to be both updated before rendering because both their sizes are needed
|
||||
// to correctly place them
|
||||
#if ENABLE_RETINA_GL
|
||||
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true);
|
||||
m_main_toolbar.set_scale(scale);
|
||||
m_undoredo_toolbar.set_scale(scale);
|
||||
#else
|
||||
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true));
|
||||
m_main_toolbar.set_icons_size(size);
|
||||
m_undoredo_toolbar.set_icons_size(size);
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
_render_main_toolbar();
|
||||
_render_undoredo_toolbar();
|
||||
_render_view_toolbar();
|
||||
|
@ -5053,7 +5227,7 @@ void GLCanvas3D::_render_overlays() const
|
|||
if (sequential_print) {
|
||||
for (ModelObject* model_object : m_model->objects)
|
||||
for (ModelInstance* model_instance : model_object->instances) {
|
||||
sorted_instances.push_back(model_instance);
|
||||
sorted_instances.emplace_back(model_instance);
|
||||
}
|
||||
}
|
||||
m_labels.render(sorted_instances);
|
||||
|
@ -5132,17 +5306,6 @@ void GLCanvas3D::_render_main_toolbar() const
|
|||
if (!m_main_toolbar.is_enabled())
|
||||
return;
|
||||
|
||||
#if ENABLE_RETINA_GL
|
||||
// m_main_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true);
|
||||
m_main_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
||||
#else
|
||||
// m_main_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
// m_main_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
||||
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true));
|
||||
m_main_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
Size cnv_size = get_canvas_size();
|
||||
float inv_zoom = (float)m_camera.get_inv_zoom();
|
||||
|
||||
|
@ -5158,17 +5321,6 @@ void GLCanvas3D::_render_undoredo_toolbar() const
|
|||
if (!m_undoredo_toolbar.is_enabled())
|
||||
return;
|
||||
|
||||
#if ENABLE_RETINA_GL
|
||||
// m_undoredo_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true);
|
||||
m_undoredo_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
||||
#else
|
||||
// m_undoredo_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
// m_undoredo_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
||||
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true));
|
||||
m_undoredo_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
Size cnv_size = get_canvas_size();
|
||||
float inv_zoom = (float)m_camera.get_inv_zoom();
|
||||
|
||||
|
@ -5533,29 +5685,26 @@ void GLCanvas3D::_load_print_toolpaths()
|
|||
if ((skirt_height == 0) && (print->config().brim_width.value > 0))
|
||||
skirt_height = 1;
|
||||
|
||||
// get first skirt_height layers (maybe this should be moved to a PrintObject method?)
|
||||
const PrintObject* object0 = print->objects().front();
|
||||
// Get first skirt_height layers.
|
||||
//FIXME This code is fishy. It may not work for multiple objects with different layering due to variable layer height feature.
|
||||
// This is not critical as this is just an initial preview.
|
||||
const PrintObject* highest_object = *std::max_element(print->objects().begin(), print->objects().end(), [](auto l, auto r){ return l->layers().size() < r->layers().size(); });
|
||||
std::vector<float> print_zs;
|
||||
print_zs.reserve(skirt_height * 2);
|
||||
for (size_t i = 0; i < std::min(skirt_height, object0->layers().size()); ++i)
|
||||
{
|
||||
print_zs.push_back(float(object0->layers()[i]->print_z));
|
||||
}
|
||||
//FIXME why there are support layers?
|
||||
for (size_t i = 0; i < std::min(skirt_height, object0->support_layers().size()); ++i)
|
||||
{
|
||||
print_zs.push_back(float(object0->support_layers()[i]->print_z));
|
||||
}
|
||||
for (size_t i = 0; i < std::min(skirt_height, highest_object->layers().size()); ++ i)
|
||||
print_zs.emplace_back(float(highest_object->layers()[i]->print_z));
|
||||
// Only add skirt for the raft layers.
|
||||
for (size_t i = 0; i < std::min(skirt_height, std::min(highest_object->slicing_parameters().raft_layers(), highest_object->support_layers().size())); ++ i)
|
||||
print_zs.emplace_back(float(highest_object->support_layers()[i]->print_z));
|
||||
sort_remove_duplicates(print_zs);
|
||||
if (print_zs.size() > skirt_height)
|
||||
print_zs.erase(print_zs.begin() + skirt_height, print_zs.end());
|
||||
|
||||
skirt_height = std::min(skirt_height, print_zs.size());
|
||||
print_zs.erase(print_zs.begin() + skirt_height, print_zs.end());
|
||||
|
||||
GLVolume *volume = m_volumes.new_toolpath_volume(color, VERTEX_BUFFER_RESERVE_SIZE);
|
||||
for (size_t i = 0; i < skirt_height; ++i) {
|
||||
volume->print_zs.push_back(print_zs[i]);
|
||||
volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
|
||||
volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size());
|
||||
for (size_t i = 0; i < skirt_height; ++ i) {
|
||||
volume->print_zs.emplace_back(print_zs[i]);
|
||||
volume->offsets.emplace_back(volume->indexed_vertex_array.quad_indices.size());
|
||||
volume->offsets.emplace_back(volume->indexed_vertex_array.triangle_indices.size());
|
||||
if (i == 0)
|
||||
_3DScene::extrusionentity_to_verts(print->brim(), print_zs[i], Point(0, 0), *volume);
|
||||
_3DScene::extrusionentity_to_verts(print->skirt(), print_zs[i], Point(0, 0), *volume);
|
||||
|
@ -5721,10 +5870,10 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
}
|
||||
if (ctxt.has_perimeters || ctxt.has_infill)
|
||||
for (const Layer *layer : print_object.layers())
|
||||
ctxt.layers.push_back(layer);
|
||||
ctxt.layers.emplace_back(layer);
|
||||
if (ctxt.has_support)
|
||||
for (const Layer *layer : print_object.support_layers())
|
||||
ctxt.layers.push_back(layer);
|
||||
ctxt.layers.emplace_back(layer);
|
||||
std::sort(ctxt.layers.begin(), ctxt.layers.end(), [](const Layer *l1, const Layer *l2) { return l1->print_z < l2->print_z; });
|
||||
|
||||
// Maximum size of an allocation block: 32MB / sizeof(float)
|
||||
|
@ -5793,9 +5942,9 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
|
||||
for (GLVolume *vol : vols)
|
||||
if (vol->print_zs.empty() || vol->print_zs.back() != layer->print_z) {
|
||||
vol->print_zs.push_back(layer->print_z);
|
||||
vol->offsets.push_back(vol->indexed_vertex_array.quad_indices.size());
|
||||
vol->offsets.push_back(vol->indexed_vertex_array.triangle_indices.size());
|
||||
vol->print_zs.emplace_back(layer->print_z);
|
||||
vol->offsets.emplace_back(vol->indexed_vertex_array.quad_indices.size());
|
||||
vol->offsets.emplace_back(vol->indexed_vertex_array.triangle_indices.size());
|
||||
}
|
||||
for (const PrintInstance &instance : *ctxt.shifted_copies) {
|
||||
const Point © = instance.shift;
|
||||
|
@ -5951,9 +6100,9 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const std::vector<std::string>& str_
|
|||
for (size_t i = 0; i < vols.size(); ++i) {
|
||||
GLVolume &vol = *vols[i];
|
||||
if (vol.print_zs.empty() || vol.print_zs.back() != layer.front().print_z) {
|
||||
vol.print_zs.push_back(layer.front().print_z);
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
vol.print_zs.emplace_back(layer.front().print_z);
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
}
|
||||
}
|
||||
for (const WipeTower::ToolChangeResult &extrusions : layer) {
|
||||
|
@ -6166,9 +6315,9 @@ void GLCanvas3D::_load_gcode_extrusion_paths(const GCodePreviewData& preview_dat
|
|||
assert(it_filter != filters.end() && key.first == it_filter->first);
|
||||
|
||||
GLVolume& vol = *it_filter->second;
|
||||
vol.print_zs.push_back(layer.z);
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
vol.print_zs.emplace_back(layer.z);
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
|
||||
_3DScene::extrusionentity_to_verts(path.polyline, path.width, path.height, layer.z, vol);
|
||||
}
|
||||
|
@ -6240,9 +6389,9 @@ inline void travel_paths_internal(
|
|||
assert(it != by_type.end() && it->first == func_value(polyline));
|
||||
|
||||
GLVolume& vol = *it->second;
|
||||
vol.print_zs.push_back(unscale<double>(polyline.polyline.bounding_box().min(2)));
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
vol.print_zs.emplace_back(unscale<double>(polyline.polyline.bounding_box().min(2)));
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
|
||||
_3DScene::polyline3_to_verts(polyline.polyline, preview_data.travel.width, preview_data.travel.height, vol);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue