Merge remote-tracking branch 'origin/master' into ys_ph_printers

This commit is contained in:
YuSanka 2020-08-06 17:02:48 +02:00
commit a6dc3d37f5
78 changed files with 4309 additions and 2783 deletions

View file

@ -31,6 +31,7 @@
#include "GUI_ObjectManipulation.hpp"
#include "Mouse3DController.hpp"
#include "I18N.hpp"
#include "NotificationManager.hpp"
#if ENABLE_RETINA_GL
#include "slic3r/Utils/RetinaHelper.hpp"
@ -225,56 +226,44 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const
static const ImVec4 ORANGE(1.0f, 0.49f, 0.22f, 1.0f);
const Size& cnv_size = canvas.get_canvas_size();
float canvas_w = (float)cnv_size.get_width();
float canvas_h = (float)cnv_size.get_height();
ImGuiWrapper& imgui = *wxGetApp().imgui();
imgui.set_next_window_pos(canvas_w - imgui.get_style_scaling() * THICKNESS_BAR_WIDTH, canvas_h, ImGuiCond_Always, 1.0f, 1.0f);
imgui.set_next_window_pos(static_cast<float>(cnv_size.get_width()) - imgui.get_style_scaling() * THICKNESS_BAR_WIDTH,
static_cast<float>(cnv_size.get_height()), ImGuiCond_Always, 1.0f, 1.0f);
imgui.begin(_(L("Variable layer height")), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse);
imgui.begin(_L("Variable layer height"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse);
ImGui::PushStyleColor(ImGuiCol_Text, ORANGE);
imgui.text(_(L("Left mouse button:")));
ImGui::PopStyleColor();
imgui.text_colored(ORANGE, _L("Left mouse button:"));
ImGui::SameLine();
imgui.text(_(L("Add detail")));
imgui.text(_L("Add detail"));
ImGui::PushStyleColor(ImGuiCol_Text, ORANGE);
imgui.text(_(L("Right mouse button:")));
ImGui::PopStyleColor();
imgui.text_colored(ORANGE, _L("Right mouse button:"));
ImGui::SameLine();
imgui.text(_(L("Remove detail")));
imgui.text(_L("Remove detail"));
ImGui::PushStyleColor(ImGuiCol_Text, ORANGE);
imgui.text(_(L("Shift + Left mouse button:")));
ImGui::PopStyleColor();
imgui.text_colored(ORANGE, _L("Shift + Left mouse button:"));
ImGui::SameLine();
imgui.text(_(L("Reset to base")));
imgui.text(_L("Reset to base"));
ImGui::PushStyleColor(ImGuiCol_Text, ORANGE);
imgui.text(_(L("Shift + Right mouse button:")));
ImGui::PopStyleColor();
imgui.text_colored(ORANGE, _L("Shift + Right mouse button:"));
ImGui::SameLine();
imgui.text(_(L("Smoothing")));
imgui.text(_L("Smoothing"));
ImGui::PushStyleColor(ImGuiCol_Text, ORANGE);
imgui.text(_(L("Mouse wheel:")));
ImGui::PopStyleColor();
imgui.text_colored(ORANGE, _L("Mouse wheel:"));
ImGui::SameLine();
imgui.text(_(L("Increase/decrease edit area")));
imgui.text(_L("Increase/decrease edit area"));
ImGui::Separator();
if (imgui.button(_(L("Adaptive"))))
if (imgui.button(_L("Adaptive")))
wxPostEvent((wxEvtHandler*)canvas.get_wxglcanvas(), Event<float>(EVT_GLCANVAS_ADAPTIVE_LAYER_HEIGHT_PROFILE, m_adaptive_quality));
ImGui::SameLine();
float text_align = ImGui::GetCursorPosX();
ImGui::AlignTextToFramePadding();
imgui.text(_(L("Quality / Speed")));
if (ImGui::IsItemHovered())
{
imgui.text(_L("Quality / Speed"));
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::TextUnformatted(_(L("Higher print quality versus higher print speed.")).ToUTF8());
ImGui::TextUnformatted(_L("Higher print quality versus higher print speed.").ToUTF8());
ImGui::EndTooltip();
}
@ -285,13 +274,13 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const
ImGui::SliderFloat("", &m_adaptive_quality, 0.0f, 1.f, "%.2f");
ImGui::Separator();
if (imgui.button(_(L("Smooth"))))
if (imgui.button(_L("Smooth")))
wxPostEvent((wxEvtHandler*)canvas.get_wxglcanvas(), HeightProfileSmoothEvent(EVT_GLCANVAS_SMOOTH_LAYER_HEIGHT_PROFILE, m_smooth_params));
ImGui::SameLine();
ImGui::SetCursorPosX(text_align);
ImGui::AlignTextToFramePadding();
imgui.text(_(L("Radius")));
imgui.text(_L("Radius"));
ImGui::SameLine();
ImGui::SetCursorPosX(widget_align);
ImGui::PushItemWidth(imgui.get_style_scaling() * 120.0f);
@ -301,7 +290,7 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const
ImGui::SetCursorPosX(text_align);
ImGui::AlignTextToFramePadding();
imgui.text(_(L("Keep min")));
imgui.text(_L("Keep min"));
ImGui::SameLine();
if (ImGui::GetCursorPosX() < widget_align) // because of line lenght after localization
ImGui::SetCursorPosX(widget_align);
@ -310,7 +299,7 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const
imgui.checkbox("##2", m_smooth_params.keep_min);
ImGui::Separator();
if (imgui.button(_(L("Reset"))))
if (imgui.button(_L("Reset")))
wxPostEvent((wxEvtHandler*)canvas.get_wxglcanvas(), SimpleEvent(EVT_GLCANVAS_RESET_LAYER_HEIGHT_PROFILE));
imgui.end();
@ -663,19 +652,45 @@ void GLCanvas3D::WarningTexture::activate(WarningTexture::Warning warning, bool
m_warnings.emplace_back(warning);
std::sort(m_warnings.begin(), m_warnings.end());
std::string text;
switch (warning) {
case ObjectOutside: text = L("An object outside the print area was detected."); break;
case ToolpathOutside: text = L("A toolpath outside the print area was detected."); break;
case SlaSupportsOutside: text = L("SLA supports outside the print area were detected."); break;
case SomethingNotShown: text = L("Some objects are not visible."); break;
case ObjectClashed: wxGetApp().plater()->get_notification_manager()->push_plater_error_notification(L("An object outside the print area was detected.\n"
"Resolve the current problem to continue slicing."),
*(wxGetApp().plater()->get_current_canvas3D()));
break;
}
if (!text.empty())
wxGetApp().plater()->get_notification_manager()->push_plater_warning_notification(text, *(wxGetApp().plater()->get_current_canvas3D()));
}
else {
if (it == m_warnings.end()) // deactivating something that is not active is an easy task
return;
m_warnings.erase(it);
if (m_warnings.empty()) { // nothing remains to be shown
std::string text;
switch (warning) {
case ObjectOutside: text = L("An object outside the print area was detected."); break;
case ToolpathOutside: text = L("A toolpath outside the print area was detected."); break;
case SlaSupportsOutside: text = L("SLA supports outside the print area were detected."); break;
case SomethingNotShown: text = L("Some objects are not visibl.e"); break;
case ObjectClashed: wxGetApp().plater()->get_notification_manager()->close_plater_error_notification(); break;
}
if (!text.empty())
wxGetApp().plater()->get_notification_manager()->close_plater_warning_notification(text);
/*if (m_warnings.empty()) { // nothing remains to be shown
reset();
m_msg_text = "";// save information for rescaling
return;
}
}*/
}
/*
// Look at the end of our vector and generate proper texture.
std::string text;
bool red_colored = false;
@ -697,6 +712,7 @@ void GLCanvas3D::WarningTexture::activate(WarningTexture::Warning warning, bool
// save information for rescaling
m_msg_text = text;
m_is_colored_red = red_colored;
*/
}
@ -1430,8 +1446,7 @@ void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas
#if ENABLE_SLOPE_RENDERING
void GLCanvas3D::Slope::render() const
{
if (m_dialog_shown)
{
if (m_dialog_shown) {
const std::array<float, 2>& z_range = m_volumes.get_slope_z_range();
std::array<float, 2> angle_range = { Geometry::rad2deg(::acos(z_range[0])) - 90.0f, Geometry::rad2deg(::acos(z_range[1])) - 90.0f };
bool modified = false;
@ -1439,9 +1454,9 @@ void GLCanvas3D::Slope::render() const
ImGuiWrapper& imgui = *wxGetApp().imgui();
const Size& cnv_size = m_canvas.get_canvas_size();
imgui.set_next_window_pos((float)cnv_size.get_width(), (float)cnv_size.get_height(), ImGuiCond_Always, 1.0f, 1.0f);
imgui.begin(_(L("Slope visualization")), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
imgui.begin(_L("Slope visualization"), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
imgui.text(_(L("Facets' slope range (degrees)")) + ":");
imgui.text(_L("Facets' slope range (degrees)") + ":");
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.75f, 0.0f, 0.0f, 0.5f));
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(1.0f, 0.0f, 0.0f, 0.5f));
@ -1453,8 +1468,7 @@ void GLCanvas3D::Slope::render() const
float slope_bound = 90.f - angle_range[1];
bool mod = ImGui::SliderFloat("##red", &slope_bound, 0.0f, 90.0f, "%.1f");
angle_range[1] = 90.f - slope_bound;
if (mod)
{
if (mod) {
modified = true;
if (angle_range[0] > angle_range[1])
angle_range[0] = angle_range[1];
@ -1462,15 +1476,14 @@ void GLCanvas3D::Slope::render() const
ImGui::PopStyleColor(4);
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.75f, 0.75f, 0.0f, 0.5f));
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(1.0f, 1.0f, 0.0f, 0.5f));
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(0.85f, 0.85f, 0.0f, 0.5f));
ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(0.25f, 0.25f, 0.0f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(1.0f, 1.0f, 0.0f, 0.5f));
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(0.85f, 0.85f, 0.0f, 0.5f));
ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(0.25f, 0.25f, 0.0f, 1.0f));
slope_bound = 90.f - angle_range[0];
mod = ImGui::SliderFloat("##yellow", &slope_bound, 0.0f, 90.0f, "%.1f");
angle_range[0] = 90.f - slope_bound;
if (mod)
{
if (mod) {
modified = true;
if (angle_range[1] < angle_range[0])
angle_range[1] = angle_range[0];
@ -2089,6 +2102,8 @@ void GLCanvas3D::render()
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.)
@ -2118,6 +2133,8 @@ void GLCanvas3D::render()
m_tooltip.render(m_mouse.position, *this);
wxGetApp().plater()->get_mouse3d_controller().render_settings_dialog(*this);
wxGetApp().plater()->get_notification_manager()->render_notifications(*this);
wxGetApp().imgui()->render();
@ -3433,6 +3450,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
#ifdef SLIC3R_DEBUG_MOUSE_EVENTS
printf((format_mouse_event_debug_message(evt) + " - Consumed by ImGUI\n").c_str());
#endif /* SLIC3R_DEBUG_MOUSE_EVENTS */
m_dirty = true;
// do not return if dragging or tooltip not empty to allow for tooltip update
if (!m_mouse.dragging && m_tooltip.is_empty())
return;
@ -3826,7 +3844,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_gizmos.reset_all_states();
// Only refresh if picking is enabled, in that case the objects may get highlighted if the mouse cursor hovers over.
if (m_picking_enabled)
//if (m_picking_enabled)
m_dirty = true;
}
else