mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 09:11:23 -06:00
Fixed conflicts after merge with master and ported changes into gouraud shaders to gouraud_mod shaders
This commit is contained in:
commit
2c0815f537
72 changed files with 1750 additions and 1043 deletions
|
|
@ -334,19 +334,7 @@ void GLVolume::SinkingContours::update()
|
|||
MeshSlicingParams slicing_params;
|
||||
slicing_params.trafo = m_parent.world_matrix();
|
||||
Polygons polygons = union_(slice_mesh(mesh.its, 0.0f, slicing_params));
|
||||
for (Polygon& polygon : polygons) {
|
||||
if (polygon.is_clockwise())
|
||||
polygon.reverse();
|
||||
Polygons outer_polys = offset(polygon, float(scale_(HalfWidth)));
|
||||
assert(outer_polys.size() == 1);
|
||||
if (outer_polys.empty())
|
||||
// no outer contour, skip
|
||||
continue;
|
||||
|
||||
ExPolygon expoly(std::move(outer_polys.front()));
|
||||
expoly.holes = offset(polygon, -float(scale_(HalfWidth)));
|
||||
polygons_reverse(expoly.holes);
|
||||
|
||||
for (ExPolygon &expoly : diff_ex(expand(polygons, float(scale_(HalfWidth))), shrink(polygons, float(scale_(HalfWidth))))) {
|
||||
GUI::GLModel::InitializationData::Entity entity;
|
||||
entity.type = GUI::GLModel::PrimitiveType::Triangles;
|
||||
const std::vector<Vec3d> triangulation = triangulate_expolygon_3d(expoly);
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ private:
|
|||
GLGizmosManager m_gizmos;
|
||||
GLToolbar m_main_toolbar;
|
||||
GLToolbar m_undoredo_toolbar;
|
||||
ClippingPlane m_clipping_planes[2];
|
||||
std::array<ClippingPlane, 2> m_clipping_planes;
|
||||
ClippingPlane m_camera_clipping_plane;
|
||||
bool m_use_clipping_planes;
|
||||
SlaCap m_sla_caps[2];
|
||||
|
|
@ -661,6 +661,9 @@ public:
|
|||
void reset_clipping_planes_cache() { m_sla_caps[0].triangles.clear(); m_sla_caps[1].triangles.clear(); }
|
||||
void set_use_clipping_planes(bool use) { m_use_clipping_planes = use; }
|
||||
|
||||
bool get_use_clipping_planes() const { return m_use_clipping_planes; }
|
||||
const std::array<ClippingPlane, 2> &get_clipping_planes() const { return m_clipping_planes; };
|
||||
|
||||
void set_color_by(const std::string& value);
|
||||
|
||||
void refresh_camera_scene_box();
|
||||
|
|
|
|||
|
|
@ -61,39 +61,28 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
// used to render extrusion and travel paths as lines in gcode preview
|
||||
valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" });
|
||||
// used to render objects in 3d editor
|
||||
// For Apple's on Arm CPU computed triangle normals inside fragment shader using dFdx and dFdy has the opposite direction.
|
||||
// Because of this, objects had darker colors inside the multi-material gizmo.
|
||||
// Based on https://stackoverflow.com/a/66206648, the similar behavior was also spotted on some other devices with Arm CPU.
|
||||
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
|
||||
if (platform_flavor() == PlatformFlavor::OSXOnArm)
|
||||
valid &= append_shader("gouraud_mod", { "gouraud_mod.vs", "gouraud_mod.fs" }, { "FLIP_TRIANGLE_NORMALS"sv
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
, "ENABLE_ENVIRONMENT_MAP"sv
|
||||
#endif
|
||||
});
|
||||
else
|
||||
valid &= append_shader("gouraud_mod", { "gouraud_mod.vs", "gouraud_mod.fs" }
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
, { "ENABLE_ENVIRONMENT_MAP"sv }
|
||||
#endif
|
||||
// When setting this technology to default rename the following from "gouraud_mod" to "gouraud"
|
||||
valid &= append_shader("gouraud_mod", { "gouraud_mod.vs", "gouraud_mod.fs" }
|
||||
#else
|
||||
if (platform_flavor() == PlatformFlavor::OSXOnArm)
|
||||
valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" }, { "FLIP_TRIANGLE_NORMALS"sv
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
, "ENABLE_ENVIRONMENT_MAP"sv
|
||||
#endif
|
||||
});
|
||||
else
|
||||
valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" }
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
, { "ENABLE_ENVIRONMENT_MAP"sv }
|
||||
#endif
|
||||
valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" }
|
||||
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
, { "ENABLE_ENVIRONMENT_MAP"sv }
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
);
|
||||
// used to render variable layers heights in 3d editor
|
||||
valid &= append_shader("variable_layer_height", { "variable_layer_height.vs", "variable_layer_height.fs" });
|
||||
// used to render highlight contour around selected triangles inside the multi-material gizmo
|
||||
valid &= append_shader("mm_contour", { "mm_contour.vs", "mm_contour.fs" });
|
||||
// Used to render painted triangles inside the multi-material gizmo. Triangle normals are computed inside fragment shader.
|
||||
// For Apple's on Arm CPU computed triangle normals inside fragment shader using dFdx and dFdy has the opposite direction.
|
||||
// Because of this, objects had darker colors inside the multi-material gizmo.
|
||||
// Based on https://stackoverflow.com/a/66206648, the similar behavior was also spotted on some other devices with Arm CPU.
|
||||
if (platform_flavor() == PlatformFlavor::OSXOnArm)
|
||||
valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"}, {"FLIP_TRIANGLE_NORMALS"sv});
|
||||
else
|
||||
valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"});
|
||||
|
||||
return { valid, error };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -676,16 +676,18 @@ void GUI_App::post_init()
|
|||
if (this->preset_updater) {
|
||||
this->check_updates(false);
|
||||
CallAfter([this] {
|
||||
this->config_wizard_startup();
|
||||
bool cw_showed = this->config_wizard_startup();
|
||||
this->preset_updater->slic3r_update_notify();
|
||||
this->preset_updater->sync(preset_bundle);
|
||||
if (! cw_showed) {
|
||||
// The CallAfter is needed as well, without it, GL extensions did not show.
|
||||
// Also, we only want to show this when the wizard does not, so the new user
|
||||
// sees something else than "we want something" on the first start.
|
||||
show_send_system_info_dialog_if_needed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 'Send system info' dialog. Again, a CallAfter is needed on mac.
|
||||
// Without it, GL extensions did not show.
|
||||
CallAfter([] { show_send_system_info_dialog_if_needed(); });
|
||||
|
||||
#ifdef _WIN32
|
||||
// Sets window property to mainframe so other instances can indentify it.
|
||||
OtherInstanceMessageHandler::init_windows_properties(mainframe, m_instance_hash_int);
|
||||
|
|
@ -2020,14 +2022,14 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||
menu->Append(local_menu, _L("&Configuration"));
|
||||
}
|
||||
|
||||
void GUI_App::open_preferences(size_t open_on_tab)
|
||||
void GUI_App::open_preferences(size_t open_on_tab, const std::string& highlight_option)
|
||||
{
|
||||
bool app_layout_changed = false;
|
||||
{
|
||||
// the dialog needs to be destroyed before the call to recreate_GUI()
|
||||
// or sometimes the application crashes into wxDialogBase() destructor
|
||||
// so we put it into an inner scope
|
||||
PreferencesDialog dlg(mainframe, open_on_tab);
|
||||
PreferencesDialog dlg(mainframe, open_on_tab, highlight_option);
|
||||
dlg.ShowModal();
|
||||
app_layout_changed = dlg.settings_layout_changed();
|
||||
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ public:
|
|||
wxString current_language_code_safe() const;
|
||||
bool is_localized() const { return m_wxLocale->GetLocale() != "English"; }
|
||||
|
||||
void open_preferences(size_t open_on_tab = 0);
|
||||
void open_preferences(size_t open_on_tab = 0, const std::string& highlight_option = std::string());
|
||||
|
||||
virtual bool OnExceptionInMainLoop() override;
|
||||
// Calls wxLaunchDefaultBrowser if user confirms in dialog.
|
||||
|
|
|
|||
|
|
@ -77,8 +77,10 @@ GalleryDialog::GalleryDialog(wxWindow* parent, bool modify_gallery/* = false*/)
|
|||
|
||||
m_list_ctrl = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(50 * wxGetApp().em_unit(), 35 * wxGetApp().em_unit()),
|
||||
wxLC_ICON | wxSIMPLE_BORDER);
|
||||
m_list_ctrl->Bind(wxEVT_LIST_ITEM_SELECTED, &GalleryDialog::select, this);
|
||||
m_list_ctrl->Bind(wxEVT_LIST_ITEM_DESELECTED, &GalleryDialog::deselect, this);
|
||||
m_list_ctrl->Bind(wxEVT_LIST_ITEM_SELECTED, &GalleryDialog::select, this);
|
||||
m_list_ctrl->Bind(wxEVT_LIST_ITEM_DESELECTED, &GalleryDialog::deselect, this);
|
||||
m_list_ctrl->Bind(wxEVT_LIST_KEY_DOWN, &GalleryDialog::key_down, this);
|
||||
m_list_ctrl->Bind(wxEVT_LIST_ITEM_RIGHT_CLICK, &GalleryDialog::show_context_menu, this);
|
||||
m_list_ctrl->Bind(wxEVT_LIST_ITEM_ACTIVATED, [this](wxListEvent& event) {
|
||||
m_selected_items.clear();
|
||||
select(event);
|
||||
|
|
@ -111,19 +113,11 @@ GalleryDialog::GalleryDialog(wxWindow* parent, bool modify_gallery/* = false*/)
|
|||
this->Bind(wxEVT_BUTTON, method, this, ID);
|
||||
};
|
||||
|
||||
auto enable_del_fn = [this]() {
|
||||
if (m_selected_items.empty())
|
||||
return false;
|
||||
for (const Item& item : m_selected_items)
|
||||
if (item.is_system)
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
add_btn(0, ID_BTN_ADD_CUSTOM_SHAPE, _L("Add"), _L("Add one or more custom shapes"), &GalleryDialog::add_custom_shapes);
|
||||
add_btn(1, ID_BTN_DEL_CUSTOM_SHAPE, _L("Delete"), _L("Delete one or more custom shape. You can't delete system shapes"), &GalleryDialog::del_custom_shapes, enable_del_fn);
|
||||
add_btn(2, ID_BTN_REPLACE_CUSTOM_PNG, _L("Replace PNG"), _L("Replace PNG for custom shape. You can't raplace PNG for system shape"),&GalleryDialog::replace_custom_png, [this]() { return (m_selected_items.size() == 1 && !m_selected_items[0].is_system); });
|
||||
buttons->InsertStretchSpacer(3, 2* BORDER_W);
|
||||
size_t btn_pos = 0;
|
||||
add_btn(btn_pos++, ID_BTN_ADD_CUSTOM_SHAPE, _L("Add"), _L("Add one or more custom shapes"), &GalleryDialog::add_custom_shapes);
|
||||
add_btn(btn_pos++, ID_BTN_DEL_CUSTOM_SHAPE, _L("Delete"), _L("Delete one or more custom shape. You can't delete system shapes"), &GalleryDialog::del_custom_shapes, [this](){ return can_delete(); });
|
||||
//add_btn(btn_pos++, ID_BTN_REPLACE_CUSTOM_PNG, _L("Change thumbnail"), _L("Replace PNG for custom shape. You can't raplace thimbnail for system shape"), &GalleryDialog::change_thumbnail, [this](){ return can_change_thumbnail(); });
|
||||
buttons->InsertStretchSpacer(btn_pos, 2* BORDER_W);
|
||||
|
||||
load_label_icon_list();
|
||||
|
||||
|
|
@ -146,6 +140,21 @@ GalleryDialog::~GalleryDialog()
|
|||
{
|
||||
}
|
||||
|
||||
bool GalleryDialog::can_delete()
|
||||
{
|
||||
if (m_selected_items.empty())
|
||||
return false;
|
||||
for (const Item& item : m_selected_items)
|
||||
if (item.is_system)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GalleryDialog::can_change_thumbnail()
|
||||
{
|
||||
return (m_selected_items.size() == 1 && !m_selected_items[0].is_system);
|
||||
}
|
||||
|
||||
void GalleryDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
const int& em = em_unit();
|
||||
|
|
@ -405,7 +414,7 @@ void GalleryDialog::add_custom_shapes(wxEvent& event)
|
|||
load_files(input_files);
|
||||
}
|
||||
|
||||
void GalleryDialog::del_custom_shapes(wxEvent& event)
|
||||
void GalleryDialog::del_custom_shapes()
|
||||
{
|
||||
auto custom_dir = get_dir(false);
|
||||
|
||||
|
|
@ -438,7 +447,7 @@ static void show_warning(const wxString& title, const std::string& error_file_ty
|
|||
dialog.ShowModal();
|
||||
}
|
||||
|
||||
void GalleryDialog::replace_custom_png(wxEvent& event)
|
||||
void GalleryDialog::change_thumbnail()
|
||||
{
|
||||
if (m_selected_items.size() != 1 || m_selected_items[0].is_system)
|
||||
return;
|
||||
|
|
@ -494,6 +503,23 @@ void GalleryDialog::deselect(wxListEvent& event)
|
|||
m_selected_items.erase(std::remove_if(m_selected_items.begin(), m_selected_items.end(), [name](Item item) { return item.name == name; }));
|
||||
}
|
||||
|
||||
void GalleryDialog::show_context_menu(wxListEvent& event)
|
||||
{
|
||||
wxMenu* menu = new wxMenu();
|
||||
if (can_delete())
|
||||
append_menu_item(menu, wxID_ANY, _L("Delete"), "", [this](wxCommandEvent&) { del_custom_shapes(); });
|
||||
if (can_change_thumbnail())
|
||||
append_menu_item(menu, wxID_ANY, _L("Change thumbnail"), "", [this](wxCommandEvent&) { change_thumbnail(); });
|
||||
|
||||
this->PopupMenu(menu);
|
||||
}
|
||||
|
||||
void GalleryDialog::key_down(wxListEvent& event)
|
||||
{
|
||||
if (can_delete() && (event.GetKeyCode() == WXK_DELETE || event.GetKeyCode() == WXK_BACK))
|
||||
del_custom_shapes();
|
||||
}
|
||||
|
||||
void GalleryDialog::update()
|
||||
{
|
||||
m_selected_items.clear();
|
||||
|
|
|
|||
|
|
@ -33,10 +33,17 @@ class GalleryDialog : public DPIDialog
|
|||
|
||||
void load_label_icon_list();
|
||||
void add_custom_shapes(wxEvent& event);
|
||||
void del_custom_shapes(wxEvent& event);
|
||||
void replace_custom_png(wxEvent& event);
|
||||
void del_custom_shapes();
|
||||
void del_custom_shapes(wxEvent& event) { del_custom_shapes(); }
|
||||
void change_thumbnail();
|
||||
void change_thumbnail(wxEvent& event) { change_thumbnail(); }
|
||||
void select(wxListEvent& event);
|
||||
void deselect(wxListEvent& event);
|
||||
void show_context_menu(wxListEvent& event);
|
||||
void key_down(wxListEvent& event);
|
||||
|
||||
bool can_delete();
|
||||
bool can_change_thumbnail();
|
||||
|
||||
void update();
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "slic3r/GUI/ImGuiWrapper.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/format.hpp"
|
||||
#include "slic3r/Utils/UndoRedo.hpp"
|
||||
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ namespace Slic3r::GUI {
|
|||
|
||||
void GLGizmoFdmSupports::on_shutdown()
|
||||
{
|
||||
m_angle_threshold_deg = 0.f;
|
||||
m_highlight_by_angle_threshold_deg = 0.f;
|
||||
m_parent.use_slope(false);
|
||||
m_parent.toggle_model_objects_visibility(true);
|
||||
}
|
||||
|
|
@ -52,7 +53,7 @@ bool GLGizmoFdmSupports::on_init()
|
|||
m_desc["circle"] = _L("Circle");
|
||||
m_desc["sphere"] = _L("Sphere");
|
||||
m_desc["pointer"] = _L("Triangles");
|
||||
m_desc["highlight_by_angle"] = _L("Highlight by angle");
|
||||
m_desc["highlight_by_angle"] = _L("Highlight overhang by angle");
|
||||
m_desc["enforce_button"] = _L("Enforce");
|
||||
m_desc["cancel"] = _L("Cancel");
|
||||
|
||||
|
|
@ -62,6 +63,9 @@ bool GLGizmoFdmSupports::on_init()
|
|||
|
||||
m_desc["smart_fill_angle"] = _L("Smart fill angle");
|
||||
|
||||
m_desc["split_triangles"] = _L("Split triangles");
|
||||
m_desc["on_overhangs_only"] = _L("On overhangs only");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -89,18 +93,19 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
if (! m_c->selection_info()->model_object())
|
||||
return;
|
||||
|
||||
const float approx_height = m_imgui->scaled(20.5f);
|
||||
const float approx_height = m_imgui->scaled(23.f);
|
||||
y = std::min(y, bottom_limit - approx_height);
|
||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||
|
||||
m_imgui->begin(get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
// First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that:
|
||||
const float clipping_slider_left = std::max(m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x,
|
||||
m_imgui->calc_text_size(m_desc.at("reset_direction")).x) + m_imgui->scaled(1.5f);
|
||||
const float cursor_slider_left = m_imgui->calc_text_size(m_desc.at("cursor_size")).x + m_imgui->scaled(1.f);
|
||||
const float autoset_slider_left = m_imgui->calc_text_size(m_desc.at("highlight_by_angle")).x + m_imgui->scaled(1.f);
|
||||
const float smart_fill_slider_left = m_imgui->calc_text_size(m_desc.at("smart_fill_angle")).x + m_imgui->scaled(1.f);
|
||||
const float clipping_slider_left = std::max(m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x,
|
||||
m_imgui->calc_text_size(m_desc.at("reset_direction")).x) + m_imgui->scaled(1.5f);
|
||||
const float cursor_slider_left = m_imgui->calc_text_size(m_desc.at("cursor_size")).x + m_imgui->scaled(1.f);
|
||||
const float smart_fill_slider_left = m_imgui->calc_text_size(m_desc.at("smart_fill_angle")).x + m_imgui->scaled(1.f);
|
||||
const float autoset_slider_label_max_width = m_imgui->scaled(7.5f);
|
||||
const float autoset_slider_left = m_imgui->calc_text_size(m_desc.at("highlight_by_angle"), autoset_slider_label_max_width).x + m_imgui->scaled(1.f);
|
||||
|
||||
const float cursor_type_radio_circle = m_imgui->calc_text_size(m_desc["circle"]).x + m_imgui->scaled(2.5f);
|
||||
const float cursor_type_radio_sphere = m_imgui->calc_text_size(m_desc["sphere"]).x + m_imgui->scaled(2.5f);
|
||||
|
|
@ -116,6 +121,9 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
const float tool_type_radio_brush = m_imgui->calc_text_size(m_desc["tool_brush"]).x + m_imgui->scaled(2.5f);
|
||||
const float tool_type_radio_smart_fill = m_imgui->calc_text_size(m_desc["tool_smart_fill"]).x + m_imgui->scaled(2.5f);
|
||||
|
||||
const float split_triangles_checkbox_width = m_imgui->calc_text_size(m_desc["split_triangles"]).x + m_imgui->scaled(2.5f);
|
||||
const float on_overhangs_only_checkbox_width = m_imgui->calc_text_size(m_desc["on_overhangs_only"]).x + m_imgui->scaled(2.5f);
|
||||
|
||||
float caption_max = 0.f;
|
||||
float total_text_max = 0.f;
|
||||
for (const auto &t : std::array<std::string, 3>{"enforce", "block", "remove"}) {
|
||||
|
|
@ -125,10 +133,12 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
total_text_max += caption_max + m_imgui->scaled(1.f);
|
||||
caption_max += m_imgui->scaled(1.f);
|
||||
|
||||
float sliders_width = std::max(std::max(autoset_slider_left, smart_fill_slider_left), std::max(cursor_slider_left, clipping_slider_left));
|
||||
float window_width = minimal_slider_width + sliders_width;
|
||||
float sliders_left_width = std::max(std::max(autoset_slider_left, smart_fill_slider_left), std::max(cursor_slider_left, clipping_slider_left));
|
||||
float window_width = minimal_slider_width + sliders_left_width;
|
||||
window_width = std::max(window_width, total_text_max);
|
||||
window_width = std::max(window_width, button_width);
|
||||
window_width = std::max(window_width, split_triangles_checkbox_width);
|
||||
window_width = std::max(window_width, on_overhangs_only_checkbox_width);
|
||||
window_width = std::max(window_width, cursor_type_radio_circle + cursor_type_radio_sphere + cursor_type_radio_pointer);
|
||||
window_width = std::max(window_width, tool_type_radio_left + tool_type_radio_brush + tool_type_radio_smart_fill);
|
||||
window_width = std::max(window_width, 2.f * buttons_width + m_imgui->scaled(1.f));
|
||||
|
|
@ -144,38 +154,53 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
|
||||
ImGui::Separator();
|
||||
|
||||
float position_before_text_y = ImGui::GetCursorPos().y;
|
||||
ImGui::AlignTextToFramePadding();
|
||||
m_imgui->text(m_desc["highlight_by_angle"] + ":");
|
||||
m_imgui->text_wrapped(m_desc["highlight_by_angle"] + ":", autoset_slider_label_max_width);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
float position_after_text_y = ImGui::GetCursorPos().y;
|
||||
std::string format_str = std::string("%.f") + I18N::translate_utf8("°",
|
||||
"Degree sign to use in the respective slider in FDM supports gizmo,"
|
||||
"placed after the number with no whitespace in between.");
|
||||
ImGui::SameLine(sliders_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_width);
|
||||
if (m_imgui->slider_float("##angle_threshold_deg", &m_angle_threshold_deg, 0.f, 90.f, format_str.data())) {
|
||||
m_parent.set_slope_normal_angle(90.f - m_angle_threshold_deg);
|
||||
ImGui::SameLine(sliders_left_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_left_width);
|
||||
|
||||
float slider_height = m_imgui->get_slider_float_height();
|
||||
// Makes slider to be aligned to bottom of the multi-line text.
|
||||
float slider_start_position = std::max(position_before_text_y, position_after_text_y - slider_height);
|
||||
ImGui::SetCursorPosY(slider_start_position);
|
||||
|
||||
if (m_imgui->slider_float("##angle_threshold_deg", &m_highlight_by_angle_threshold_deg, 0.f, 90.f, format_str.data())) {
|
||||
m_parent.set_slope_normal_angle(90.f - m_highlight_by_angle_threshold_deg);
|
||||
if (! m_parent.is_using_slope()) {
|
||||
m_parent.use_slope(true);
|
||||
m_parent.set_as_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
m_imgui->disabled_begin(m_angle_threshold_deg == 0.f);
|
||||
// Restores the cursor position to be below the multi-line text.
|
||||
ImGui::SetCursorPosY(std::max(position_before_text_y + slider_height, position_after_text_y));
|
||||
|
||||
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(format_wxstr(_L("Preselects faces by overhang angle. It is possible to restrict paintable facets to only preselected faces when "
|
||||
"the option \"%1%\" is enabled."), m_desc["on_overhangs_only"]), max_tooltip_width);
|
||||
|
||||
m_imgui->disabled_begin(m_highlight_by_angle_threshold_deg == 0.f);
|
||||
ImGui::NewLine();
|
||||
ImGui::SameLine(window_width - 2.f*buttons_width - m_imgui->scaled(0.5f));
|
||||
if (m_imgui->button(m_desc["enforce_button"], buttons_width, 0.f)) {
|
||||
select_facets_by_angle(m_angle_threshold_deg, false);
|
||||
m_angle_threshold_deg = 0.f;
|
||||
select_facets_by_angle(m_highlight_by_angle_threshold_deg, false);
|
||||
m_highlight_by_angle_threshold_deg = 0.f;
|
||||
m_parent.use_slope(false);
|
||||
}
|
||||
ImGui::SameLine(window_width - buttons_width);
|
||||
if (m_imgui->button(m_desc["cancel"], buttons_width, 0.f)) {
|
||||
m_angle_threshold_deg = 0.f;
|
||||
m_highlight_by_angle_threshold_deg = 0.f;
|
||||
m_parent.use_slope(false);
|
||||
}
|
||||
m_imgui->disabled_end();
|
||||
|
||||
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
|
@ -188,26 +213,20 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
if (m_imgui->radio_button(m_desc["tool_brush"], m_tool_type == ToolType::BRUSH))
|
||||
m_tool_type = ToolType::BRUSH;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints facets according to the chosen painting brush.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints facets according to the chosen painting brush."), max_tooltip_width);
|
||||
|
||||
ImGui::SameLine(tool_type_offset + tool_type_radio_brush);
|
||||
ImGui::PushItemWidth(tool_type_radio_smart_fill);
|
||||
if (m_imgui->radio_button(m_desc["tool_smart_fill"], m_tool_type == ToolType::SMART_FILL))
|
||||
m_tool_type = ToolType::SMART_FILL;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints neighboring facets whose relative angle is less or equal to set angle.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints neighboring facets whose relative angle is less or equal to set angle."), max_tooltip_width);
|
||||
|
||||
m_imgui->checkbox(m_desc["on_overhangs_only"], m_paint_on_overhangs_only);
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(format_wxstr(_L("Allows painting only on facets selected by: \"%1%\""), m_desc["highlight_by_angle"]), max_tooltip_width);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
|
@ -221,13 +240,8 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
if (m_imgui->radio_button(m_desc["sphere"], m_cursor_type == TriangleSelector::CursorType::SPHERE))
|
||||
m_cursor_type = TriangleSelector::CursorType::SPHERE;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints all facets inside, regardless of their orientation.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints all facets inside, regardless of their orientation."), max_tooltip_width);
|
||||
|
||||
ImGui::SameLine(cursor_type_offset + cursor_type_radio_sphere);
|
||||
ImGui::PushItemWidth(cursor_type_radio_circle);
|
||||
|
|
@ -235,13 +249,8 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
if (m_imgui->radio_button(m_desc["circle"], m_cursor_type == TriangleSelector::CursorType::CIRCLE))
|
||||
m_cursor_type = TriangleSelector::CursorType::CIRCLE;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Ignores facets facing away from the camera.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Ignores facets facing away from the camera."), max_tooltip_width);
|
||||
|
||||
ImGui::SameLine(cursor_type_offset + cursor_type_radio_sphere + cursor_type_radio_circle);
|
||||
ImGui::PushItemWidth(cursor_type_radio_pointer);
|
||||
|
|
@ -249,61 +258,40 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
if (m_imgui->radio_button(m_desc["pointer"], m_cursor_type == TriangleSelector::CursorType::POINTER))
|
||||
m_cursor_type = TriangleSelector::CursorType::POINTER;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints only one facet.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints only one facet."), max_tooltip_width);
|
||||
|
||||
m_imgui->disabled_begin(m_cursor_type != TriangleSelector::CursorType::SPHERE && m_cursor_type != TriangleSelector::CursorType::CIRCLE);
|
||||
|
||||
ImGui::AlignTextToFramePadding();
|
||||
m_imgui->text(m_desc.at("cursor_size"));
|
||||
ImGui::SameLine(sliders_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_width);
|
||||
ImGui::SameLine(sliders_left_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_left_width);
|
||||
m_imgui->slider_float("##cursor_radius", &m_cursor_radius, CursorRadiusMin, CursorRadiusMax, "%.2f");
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Alt + Mouse wheel").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Alt + Mouse wheel"), max_tooltip_width);
|
||||
|
||||
m_imgui->checkbox(_L("Split triangles"), m_triangle_splitting_enabled);
|
||||
m_imgui->checkbox(m_desc["split_triangles"], m_triangle_splitting_enabled);
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Split bigger facets into smaller ones while the object is painted.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Split bigger facets into smaller ones while the object is painted."), max_tooltip_width);
|
||||
|
||||
m_imgui->disabled_end();
|
||||
} else {
|
||||
assert(m_tool_type == ToolType::SMART_FILL);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
m_imgui->text(m_desc["smart_fill_angle"] + ":");
|
||||
std::string format_str = std::string("%.f") + I18N::translate_utf8("°", "Degree sign to use in the respective slider in MMU gizmo,"
|
||||
"placed after the number with no whitespace in between.");
|
||||
ImGui::SameLine(sliders_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_width);
|
||||
|
||||
ImGui::SameLine(sliders_left_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_left_width);
|
||||
if (m_imgui->slider_float("##smart_fill_angle", &m_smart_fill_angle, SmartFillAngleMin, SmartFillAngleMax, format_str.data()))
|
||||
for (auto &triangle_selector : m_triangle_selectors) {
|
||||
triangle_selector->seed_fill_unselect_all_triangles();
|
||||
triangle_selector->request_update_render_data();
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Alt + Mouse wheel").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Alt + Mouse wheel"), max_tooltip_width);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
|
@ -319,19 +307,14 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
}
|
||||
}
|
||||
|
||||
ImGui::SameLine(sliders_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_width);
|
||||
ImGui::SameLine(sliders_left_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_left_width);
|
||||
auto clp_dist = float(m_c->object_clipper()->get_position());
|
||||
if (m_imgui->slider_float("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f"))
|
||||
m_c->object_clipper()->set_position(clp_dist, true);
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Ctrl + Mouse wheel").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Ctrl + Mouse wheel"), max_tooltip_width);
|
||||
|
||||
ImGui::Separator();
|
||||
if (m_imgui->button(m_desc.at("remove_all"))) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ private:
|
|||
PainterGizmoType get_painter_type() const override;
|
||||
|
||||
void select_facets_by_angle(float threshold, bool block);
|
||||
float m_angle_threshold_deg = 0.f;
|
||||
|
||||
// This map holds all translated description texts, so they can be easily referenced during layout calculations
|
||||
// etc. When language changes, GUI is recreated and this class constructed again, so the change takes effect.
|
||||
|
|
|
|||
|
|
@ -547,13 +547,9 @@ RENDER_AGAIN:
|
|||
ImGui::SameLine(settings_sliders_left);
|
||||
ImGui::PushItemWidth(window_width - settings_sliders_left);
|
||||
m_imgui->slider_float(" ", &offset, offset_min, offset_max, "%.1f mm");
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted((_utf8(opts[0].second->tooltip)).c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip((_utf8(opts[0].second->tooltip)).c_str(), max_tooltip_width);
|
||||
|
||||
bool slider_clicked = ImGui::IsItemClicked(); // someone clicked the slider
|
||||
bool slider_edited = ImGui::IsItemEdited(); // someone is dragging the slider
|
||||
bool slider_released = ImGui::IsItemDeactivatedAfterEdit(); // someone has just released the slider
|
||||
|
|
@ -563,13 +559,9 @@ RENDER_AGAIN:
|
|||
m_imgui->text(m_desc.at("quality"));
|
||||
ImGui::SameLine(settings_sliders_left);
|
||||
m_imgui->slider_float(" ", &quality, quality_min, quality_max, "%.1f");
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted((_utf8(opts[1].second->tooltip)).c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip((_utf8(opts[1].second->tooltip)).c_str(), max_tooltip_width);
|
||||
|
||||
slider_clicked |= ImGui::IsItemClicked();
|
||||
slider_edited |= ImGui::IsItemEdited();
|
||||
slider_released |= ImGui::IsItemDeactivatedAfterEdit();
|
||||
|
|
@ -580,13 +572,9 @@ RENDER_AGAIN:
|
|||
m_imgui->text(m_desc.at("closing_distance"));
|
||||
ImGui::SameLine(settings_sliders_left);
|
||||
m_imgui->slider_float(" ", &closing_d, closing_d_min, closing_d_max, "%.1f mm");
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted((_utf8(opts[2].second->tooltip)).c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip((_utf8(opts[2].second->tooltip)).c_str(), max_tooltip_width);
|
||||
|
||||
slider_clicked |= ImGui::IsItemClicked();
|
||||
slider_edited |= ImGui::IsItemEdited();
|
||||
slider_released |= ImGui::IsItemDeactivatedAfterEdit();
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ bool GLGizmoMmuSegmentation::on_init()
|
|||
m_desc["tool_bucket_fill"] = _L("Bucket fill");
|
||||
|
||||
m_desc["smart_fill_angle"] = _L("Smart fill angle");
|
||||
m_desc["split_triangles"] = _L("Split triangles");
|
||||
|
||||
init_extruders_data();
|
||||
|
||||
|
|
@ -142,7 +143,7 @@ void GLGizmoMmuSegmentation::render_painter_gizmo() const
|
|||
glsafe(::glEnable(GL_BLEND));
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
render_triangles(selection, false);
|
||||
render_triangles(selection);
|
||||
|
||||
m_c->object_clipper()->render_cut();
|
||||
m_c->instances_hider()->render_cut();
|
||||
|
|
@ -173,6 +174,43 @@ void GLGizmoMmuSegmentation::set_painter_gizmo_data(const Selection &selection)
|
|||
}
|
||||
}
|
||||
|
||||
void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
|
||||
{
|
||||
ClippingPlaneDataWrapper clp_data = this->get_clipping_plane_data();
|
||||
auto *shader = wxGetApp().get_shader("mm_gouraud");
|
||||
if (!shader)
|
||||
return;
|
||||
shader->start_using();
|
||||
shader->set_uniform("clipping_plane", clp_data.clp_dataf);
|
||||
shader->set_uniform("z_range", clp_data.z_range);
|
||||
ScopeGuard guard([shader]() { if (shader) shader->stop_using(); });
|
||||
|
||||
const ModelObject *mo = m_c->selection_info()->model_object();
|
||||
int mesh_id = -1;
|
||||
for (const ModelVolume *mv : mo->volumes) {
|
||||
if (!mv->is_model_part())
|
||||
continue;
|
||||
|
||||
++mesh_id;
|
||||
|
||||
const Transform3d trafo_matrix = mo->instances[selection.get_instance_idx()]->get_transformation().get_matrix() * mv->get_matrix();
|
||||
|
||||
bool is_left_handed = trafo_matrix.matrix().determinant() < 0.;
|
||||
if (is_left_handed)
|
||||
glsafe(::glFrontFace(GL_CW));
|
||||
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixd(trafo_matrix.data()));
|
||||
|
||||
shader->set_uniform("volume_world_matrix", trafo_matrix);
|
||||
m_triangle_selectors[mesh_id]->render(m_imgui);
|
||||
|
||||
glsafe(::glPopMatrix());
|
||||
if (is_left_handed)
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
}
|
||||
}
|
||||
|
||||
static void render_extruders_combo(const std::string &label,
|
||||
const std::vector<std::string> &extruders,
|
||||
const std::vector<std::array<float, 4>> &extruders_colors,
|
||||
|
|
@ -261,6 +299,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
const float tool_type_radio_bucket_fill = m_imgui->calc_text_size(m_desc["tool_bucket_fill"]).x + m_imgui->scaled(2.5f);
|
||||
const float tool_type_radio_smart_fill = m_imgui->calc_text_size(m_desc["tool_smart_fill"]).x + m_imgui->scaled(2.5f);
|
||||
|
||||
const float split_triangles_checkbox_width = m_imgui->calc_text_size(m_desc["split_triangles"]).x + m_imgui->scaled(2.5f);
|
||||
|
||||
float caption_max = 0.f;
|
||||
float total_text_max = 0.f;
|
||||
for (const auto &t : std::array<std::string, 3>{"first_color", "second_color", "remove"}) {
|
||||
|
|
@ -274,6 +314,7 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
float window_width = minimal_slider_width + sliders_width;
|
||||
window_width = std::max(window_width, total_text_max);
|
||||
window_width = std::max(window_width, button_width);
|
||||
window_width = std::max(window_width, split_triangles_checkbox_width);
|
||||
window_width = std::max(window_width, cursor_type_radio_circle + cursor_type_radio_sphere + cursor_type_radio_pointer);
|
||||
window_width = std::max(window_width, tool_type_radio_brush + tool_type_radio_bucket_fill + tool_type_radio_smart_fill);
|
||||
window_width = std::max(window_width, 2.f * buttons_width + m_imgui->scaled(1.f));
|
||||
|
|
@ -331,13 +372,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints facets according to the chosen painting brush.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints facets according to the chosen painting brush."), max_tooltip_width);
|
||||
|
||||
ImGui::SameLine(tool_type_offset + tool_type_radio_brush);
|
||||
ImGui::PushItemWidth(tool_type_radio_smart_fill);
|
||||
|
|
@ -349,13 +385,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints neighboring facets whose relative angle is less or equal to set angle.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints neighboring facets whose relative angle is less or equal to set angle."), max_tooltip_width);
|
||||
|
||||
ImGui::SameLine(tool_type_offset + tool_type_radio_brush + tool_type_radio_smart_fill);
|
||||
ImGui::PushItemWidth(tool_type_radio_bucket_fill);
|
||||
|
|
@ -367,13 +398,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints neighboring facets that have the same color.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints neighboring facets that have the same color."), max_tooltip_width);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
|
@ -387,13 +413,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
if (m_imgui->radio_button(m_desc["sphere"], m_cursor_type == TriangleSelector::CursorType::SPHERE))
|
||||
m_cursor_type = TriangleSelector::CursorType::SPHERE;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints all facets inside, regardless of their orientation.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints all facets inside, regardless of their orientation."), max_tooltip_width);
|
||||
|
||||
ImGui::SameLine(cursor_type_offset + cursor_type_radio_sphere);
|
||||
ImGui::PushItemWidth(cursor_type_radio_circle);
|
||||
|
|
@ -401,13 +422,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
if (m_imgui->radio_button(m_desc["circle"], m_cursor_type == TriangleSelector::CursorType::CIRCLE))
|
||||
m_cursor_type = TriangleSelector::CursorType::CIRCLE;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Ignores facets facing away from the camera.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Ignores facets facing away from the camera."), max_tooltip_width);
|
||||
|
||||
ImGui::SameLine(cursor_type_offset + cursor_type_radio_sphere + cursor_type_radio_circle);
|
||||
ImGui::PushItemWidth(cursor_type_radio_pointer);
|
||||
|
|
@ -415,13 +431,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
if (m_imgui->radio_button(m_desc["pointer"], m_cursor_type == TriangleSelector::CursorType::POINTER))
|
||||
m_cursor_type = TriangleSelector::CursorType::POINTER;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints only one facet.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints only one facet."), max_tooltip_width);
|
||||
|
||||
m_imgui->disabled_begin(m_cursor_type != TriangleSelector::CursorType::SPHERE && m_cursor_type != TriangleSelector::CursorType::CIRCLE);
|
||||
|
||||
|
|
@ -430,23 +441,13 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
ImGui::SameLine(sliders_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_width);
|
||||
m_imgui->slider_float("##cursor_radius", &m_cursor_radius, CursorRadiusMin, CursorRadiusMax, "%.2f");
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Alt + Mouse wheel").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Alt + Mouse wheel"), max_tooltip_width);
|
||||
|
||||
m_imgui->checkbox(_L("Split triangles"), m_triangle_splitting_enabled);
|
||||
m_imgui->checkbox(m_desc["split_triangles"], m_triangle_splitting_enabled);
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Split bigger facets into smaller ones while the object is painted.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Split bigger facets into smaller ones while the object is painted."), max_tooltip_width);
|
||||
|
||||
m_imgui->disabled_end();
|
||||
|
||||
|
|
@ -464,13 +465,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
triangle_selector->request_update_render_data();
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Alt + Mouse wheel").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Alt + Mouse wheel"), max_tooltip_width);
|
||||
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
|
@ -490,13 +486,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
if (m_imgui->slider_float("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f"))
|
||||
m_c->object_clipper()->set_position(clp_dist, true);
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Ctrl + Mouse wheel").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Ctrl + Mouse wheel"), max_tooltip_width);
|
||||
|
||||
ImGui::Separator();
|
||||
if (m_imgui->button(m_desc.at("remove_all"))) {
|
||||
|
|
@ -600,13 +591,7 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
|
|||
auto *shader = wxGetApp().get_current_shader();
|
||||
if (!shader)
|
||||
return;
|
||||
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
|
||||
assert(shader->get_name() == "gouraud_mod");
|
||||
#else
|
||||
assert(shader->get_name() == "gouraud");
|
||||
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
|
||||
ScopeGuard guard([shader]() { if (shader) shader->set_uniform("compute_triangle_normals_in_fs", false);});
|
||||
shader->set_uniform("compute_triangle_normals_in_fs", true);
|
||||
assert(shader->get_name() == "mm_gouraud");
|
||||
|
||||
for (size_t color_idx = 0; color_idx < m_gizmo_scene.triangle_indices.size(); ++color_idx)
|
||||
if (m_gizmo_scene.has_VBOs(color_idx)) {
|
||||
|
|
@ -619,7 +604,7 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
|
|||
}
|
||||
|
||||
if (m_paint_contour.has_VBO()) {
|
||||
ScopeGuard guard_gouraud([shader]() { shader->start_using(); });
|
||||
ScopeGuard guard_mm_gouraud([shader]() { shader->start_using(); });
|
||||
shader->stop_using();
|
||||
|
||||
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ public:
|
|||
|
||||
void set_painter_gizmo_data(const Selection& selection) override;
|
||||
|
||||
void render_triangles(const Selection& selection) const override;
|
||||
|
||||
// TriangleSelector::serialization/deserialization has a limit to store 19 different states.
|
||||
// EXTRUDER_LIMIT + 1 states are used to storing the painting because also uncolored triangles are stored.
|
||||
// When increasing EXTRUDER_LIMIT, it needs to ensure that TriangleSelector::serialization/deserialization
|
||||
|
|
|
|||
|
|
@ -43,36 +43,33 @@ void GLGizmoPainterBase::set_painter_gizmo_data(const Selection& selection)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLGizmoPainterBase::render_triangles(const Selection& selection, const bool use_polygon_offset_fill) const
|
||||
GLGizmoPainterBase::ClippingPlaneDataWrapper GLGizmoPainterBase::get_clipping_plane_data() const
|
||||
{
|
||||
const ModelObject* mo = m_c->selection_info()->model_object();
|
||||
|
||||
ScopeGuard offset_fill_guard([&use_polygon_offset_fill]() {
|
||||
if (use_polygon_offset_fill)
|
||||
glsafe(::glDisable(GL_POLYGON_OFFSET_FILL));
|
||||
});
|
||||
if (use_polygon_offset_fill) {
|
||||
glsafe(::glEnable(GL_POLYGON_OFFSET_FILL));
|
||||
glsafe(::glPolygonOffset(-5.0, -5.0));
|
||||
}
|
||||
|
||||
ClippingPlaneDataWrapper clp_data_out{{0.f, 0.f, 1.f, FLT_MAX}, {-FLT_MAX, FLT_MAX}};
|
||||
// Take care of the clipping plane. The normal of the clipping plane is
|
||||
// saved with opposite sign than we need to pass to OpenGL (FIXME)
|
||||
bool clipping_plane_active = m_c->object_clipper()->get_position() != 0.;
|
||||
float clp_dataf[4] = {0.f, 0.f, 1.f, FLT_MAX};
|
||||
if (clipping_plane_active) {
|
||||
const ClippingPlane* clp = m_c->object_clipper()->get_clipping_plane();
|
||||
for (size_t i=0; i<3; ++i)
|
||||
clp_dataf[i] = -1.f * float(clp->get_data()[i]);
|
||||
clp_dataf[3] = float(clp->get_data()[3]);
|
||||
if (bool clipping_plane_active = m_c->object_clipper()->get_position() != 0.; clipping_plane_active) {
|
||||
const ClippingPlane *clp = m_c->object_clipper()->get_clipping_plane();
|
||||
for (size_t i = 0; i < 3; ++i)
|
||||
clp_data_out.clp_dataf[i] = -1.f * float(clp->get_data()[i]);
|
||||
clp_data_out.clp_dataf[3] = float(clp->get_data()[3]);
|
||||
}
|
||||
|
||||
// z_range is calculated in the same way as in GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
||||
if (m_c->get_canvas()->get_use_clipping_planes()) {
|
||||
const std::array<ClippingPlane, 2> &clps = m_c->get_canvas()->get_clipping_planes();
|
||||
clp_data_out.z_range = {float(-clps[0].get_data()[3]), float(clps[1].get_data()[3])};
|
||||
}
|
||||
|
||||
return clp_data_out;
|
||||
}
|
||||
|
||||
void GLGizmoPainterBase::render_triangles(const Selection& selection) const
|
||||
{
|
||||
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
|
||||
auto* shader = wxGetApp().get_shader("gouraud_mod");
|
||||
#else
|
||||
auto *shader = wxGetApp().get_shader("gouraud");
|
||||
auto* shader = wxGetApp().get_shader("gouraud");
|
||||
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
|
||||
if (! shader)
|
||||
return;
|
||||
|
|
@ -83,10 +80,11 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection, const bool
|
|||
#else
|
||||
shader->set_uniform("print_box.actived", false);
|
||||
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
|
||||
shader->set_uniform("clipping_plane", clp_dataf, 4);
|
||||
shader->set_uniform("clipping_plane", this->get_clipping_plane_data().clp_dataf);
|
||||
ScopeGuard guard([shader]() { if (shader) shader->stop_using(); });
|
||||
|
||||
int mesh_id = -1;
|
||||
const ModelObject *mo = m_c->selection_info()->model_object();
|
||||
int mesh_id = -1;
|
||||
for (const ModelVolume* mv : mo->volumes) {
|
||||
if (! mv->is_model_part())
|
||||
continue;
|
||||
|
|
@ -265,7 +263,12 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
: std::min(m_smart_fill_angle + SmartFillAngleStep, SmartFillAngleMax);
|
||||
m_parent.set_as_dirty();
|
||||
if (m_rr.mesh_id != -1) {
|
||||
m_triangle_selectors[m_rr.mesh_id]->seed_fill_select_triangles(m_rr.hit, int(m_rr.facet), m_smart_fill_angle, true);
|
||||
const Selection &selection = m_parent.get_selection();
|
||||
const ModelObject *mo = m_c->selection_info()->model_object();
|
||||
const ModelInstance *mi = mo->instances[selection.get_instance_idx()];
|
||||
const Transform3d trafo_matrix_not_translate = mi->get_transformation().get_matrix(true) * mo->volumes[m_rr.mesh_id]->get_matrix(true);
|
||||
m_triangle_selectors[m_rr.mesh_id]->seed_fill_select_triangles(m_rr.hit, int(m_rr.facet), trafo_matrix_not_translate, m_smart_fill_angle,
|
||||
m_paint_on_overhangs_only ? m_highlight_by_angle_threshold_deg : 0.f, true);
|
||||
m_triangle_selectors[m_rr.mesh_id]->request_update_render_data();
|
||||
m_seed_fill_last_mesh_id = m_rr.mesh_id;
|
||||
}
|
||||
|
|
@ -296,11 +299,12 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
new_state = action == SLAGizmoEventType::LeftDown ? this->get_left_button_state_type() : this->get_right_button_state_type();
|
||||
}
|
||||
|
||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||
const Selection &selection = m_parent.get_selection();
|
||||
const ModelObject *mo = m_c->selection_info()->model_object();
|
||||
const ModelInstance *mi = mo->instances[selection.get_instance_idx()];
|
||||
const Transform3d &instance_trafo = mi->get_transformation().get_matrix();
|
||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||
const Selection &selection = m_parent.get_selection();
|
||||
const ModelObject *mo = m_c->selection_info()->model_object();
|
||||
const ModelInstance *mi = mo->instances[selection.get_instance_idx()];
|
||||
const Transform3d instance_trafo = mi->get_transformation().get_matrix();
|
||||
const Transform3d instance_trafo_not_translate = mi->get_transformation().get_matrix(true);
|
||||
|
||||
// List of mouse positions that will be used as seeds for painting.
|
||||
std::vector<Vec2d> mouse_positions{mouse_position};
|
||||
|
|
@ -326,10 +330,12 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
|
||||
// Precalculate transformations of individual meshes.
|
||||
std::vector<Transform3d> trafo_matrices;
|
||||
for (const ModelVolume* mv : mo->volumes) {
|
||||
if (mv->is_model_part())
|
||||
std::vector<Transform3d> trafo_matrices_not_translate;
|
||||
for (const ModelVolume *mv : mo->volumes)
|
||||
if (mv->is_model_part()) {
|
||||
trafo_matrices.emplace_back(instance_trafo * mv->get_matrix());
|
||||
}
|
||||
trafo_matrices_not_translate.emplace_back(instance_trafo_not_translate * mv->get_matrix(true));
|
||||
}
|
||||
|
||||
// Now "click" into all the prepared points and spill paint around them.
|
||||
for (const Vec2d& mp : mouse_positions) {
|
||||
|
|
@ -351,7 +357,8 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
return dragging_while_painting;
|
||||
}
|
||||
|
||||
const Transform3d& trafo_matrix = trafo_matrices[m_rr.mesh_id];
|
||||
const Transform3d &trafo_matrix = trafo_matrices[m_rr.mesh_id];
|
||||
const Transform3d &trafo_matrix_not_translate = trafo_matrices_not_translate[m_rr.mesh_id];
|
||||
|
||||
// Calculate direction from camera to the hit (in mesh coords):
|
||||
Vec3f camera_pos = (trafo_matrix.inverse() * camera.get_position()).cast<float>();
|
||||
|
|
@ -360,7 +367,8 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
if (m_tool_type == ToolType::SMART_FILL || m_tool_type == ToolType::BUCKET_FILL || (m_tool_type == ToolType::BRUSH && m_cursor_type == TriangleSelector::CursorType::POINTER)) {
|
||||
m_triangle_selectors[m_rr.mesh_id]->seed_fill_apply_on_triangles(new_state);
|
||||
if (m_tool_type == ToolType::SMART_FILL)
|
||||
m_triangle_selectors[m_rr.mesh_id]->seed_fill_select_triangles(m_rr.hit, int(m_rr.facet), m_smart_fill_angle, true);
|
||||
m_triangle_selectors[m_rr.mesh_id]->seed_fill_select_triangles(m_rr.hit, int(m_rr.facet), trafo_matrix_not_translate, m_smart_fill_angle,
|
||||
m_paint_on_overhangs_only ? m_highlight_by_angle_threshold_deg : 0.f, true);
|
||||
else if (m_tool_type == ToolType::BRUSH && m_cursor_type == TriangleSelector::CursorType::POINTER)
|
||||
m_triangle_selectors[m_rr.mesh_id]->bucket_fill_select_triangles(m_rr.hit, int(m_rr.facet), false, true);
|
||||
else if (m_tool_type == ToolType::BUCKET_FILL)
|
||||
|
|
@ -369,7 +377,8 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
m_seed_fill_last_mesh_id = -1;
|
||||
} else if (m_tool_type == ToolType::BRUSH)
|
||||
m_triangle_selectors[m_rr.mesh_id]->select_patch(m_rr.hit, int(m_rr.facet), camera_pos, m_cursor_radius, m_cursor_type,
|
||||
new_state, trafo_matrix, m_triangle_splitting_enabled);
|
||||
new_state, trafo_matrix, trafo_matrix_not_translate, m_triangle_splitting_enabled,
|
||||
m_paint_on_overhangs_only ? m_highlight_by_angle_threshold_deg : 0.f);
|
||||
|
||||
m_triangle_selectors[m_rr.mesh_id]->request_update_render_data();
|
||||
m_last_mouse_click = mouse_position;
|
||||
|
|
@ -382,17 +391,21 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
if (m_triangle_selectors.empty())
|
||||
return false;
|
||||
|
||||
const Camera & camera = wxGetApp().plater()->get_camera();
|
||||
const Selection & selection = m_parent.get_selection();
|
||||
const ModelObject * mo = m_c->selection_info()->model_object();
|
||||
const ModelInstance *mi = mo->instances[selection.get_instance_idx()];
|
||||
const Transform3d & instance_trafo = mi->get_transformation().get_matrix();
|
||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||
const Selection &selection = m_parent.get_selection();
|
||||
const ModelObject *mo = m_c->selection_info()->model_object();
|
||||
const ModelInstance *mi = mo->instances[selection.get_instance_idx()];
|
||||
const Transform3d instance_trafo = mi->get_transformation().get_matrix();
|
||||
const Transform3d instance_trafo_not_translate = mi->get_transformation().get_matrix(true);
|
||||
|
||||
// Precalculate transformations of individual meshes.
|
||||
std::vector<Transform3d> trafo_matrices;
|
||||
std::vector<Transform3d> trafo_matrices_not_translate;
|
||||
for (const ModelVolume *mv : mo->volumes)
|
||||
if (mv->is_model_part())
|
||||
if (mv->is_model_part()) {
|
||||
trafo_matrices.emplace_back(instance_trafo * mv->get_matrix());
|
||||
trafo_matrices_not_translate.emplace_back(instance_trafo_not_translate * mv->get_matrix(true));
|
||||
}
|
||||
|
||||
// Now "click" into all the prepared points and spill paint around them.
|
||||
update_raycast_cache(mouse_position, camera, trafo_matrices);
|
||||
|
|
@ -417,9 +430,12 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
if(m_rr.mesh_id != m_seed_fill_last_mesh_id)
|
||||
seed_fill_unselect_all();
|
||||
|
||||
const Transform3d &trafo_matrix_not_translate = trafo_matrices_not_translate[m_rr.mesh_id];
|
||||
|
||||
assert(m_rr.mesh_id < int(m_triangle_selectors.size()));
|
||||
if (m_tool_type == ToolType::SMART_FILL)
|
||||
m_triangle_selectors[m_rr.mesh_id]->seed_fill_select_triangles(m_rr.hit, int(m_rr.facet), m_smart_fill_angle);
|
||||
m_triangle_selectors[m_rr.mesh_id]->seed_fill_select_triangles(m_rr.hit, int(m_rr.facet), trafo_matrix_not_translate, m_smart_fill_angle,
|
||||
m_paint_on_overhangs_only ? m_highlight_by_angle_threshold_deg : 0.f);
|
||||
else if (m_tool_type == ToolType::BRUSH && m_cursor_type == TriangleSelector::CursorType::POINTER)
|
||||
m_triangle_selectors[m_rr.mesh_id]->bucket_fill_select_triangles(m_rr.hit, int(m_rr.facet), false);
|
||||
else if (m_tool_type == ToolType::BUCKET_FILL)
|
||||
|
|
@ -576,7 +592,8 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
|||
#else
|
||||
assert(shader->get_name() == "gouraud");
|
||||
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
|
||||
|
||||
ScopeGuard guard([shader]() { if (shader) shader->set_uniform("offset_depth_buffer", false);});
|
||||
shader->set_uniform("offset_depth_buffer", true);
|
||||
for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color),
|
||||
std::make_pair(&m_iva_blockers, blockers_color)}) {
|
||||
if (iva.first->has_VBOs()) {
|
||||
|
|
@ -602,7 +619,7 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
|||
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
||||
contour_shader->start_using();
|
||||
|
||||
glsafe(::glDepthFunc(GL_GEQUAL));
|
||||
glsafe(::glDepthFunc(GL_LEQUAL));
|
||||
m_paint_contour.render();
|
||||
glsafe(::glDepthFunc(GL_LESS));
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public:
|
|||
virtual bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
|
||||
|
||||
protected:
|
||||
void render_triangles(const Selection& selection, const bool use_polygon_offset_fill = true) const;
|
||||
virtual void render_triangles(const Selection& selection) const;
|
||||
void render_cursor() const;
|
||||
void render_cursor_circle() const;
|
||||
void render_cursor_sphere(const Transform3d& trafo) const;
|
||||
|
|
@ -159,6 +159,9 @@ protected:
|
|||
ToolType m_tool_type = ToolType::BRUSH;
|
||||
float m_smart_fill_angle = 30.f;
|
||||
|
||||
bool m_paint_on_overhangs_only = false;
|
||||
float m_highlight_by_angle_threshold_deg = 0.f;
|
||||
|
||||
static constexpr float SmartFillAngleMin = 0.0f;
|
||||
static constexpr float SmartFillAngleMax = 90.f;
|
||||
static constexpr float SmartFillAngleStep = 1.f;
|
||||
|
|
@ -173,6 +176,14 @@ protected:
|
|||
Right
|
||||
};
|
||||
|
||||
struct ClippingPlaneDataWrapper
|
||||
{
|
||||
std::array<float, 4> clp_dataf;
|
||||
std::array<float, 2> z_range;
|
||||
};
|
||||
|
||||
ClippingPlaneDataWrapper get_clipping_plane_data() const;
|
||||
|
||||
private:
|
||||
bool is_mesh_point_clipped(const Vec3d& point, const Transform3d& trafo) const;
|
||||
void update_raycast_cache(const Vec2d& mouse_position,
|
||||
|
|
|
|||
|
|
@ -129,13 +129,8 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
|
|||
ImGui::SameLine(sliders_width);
|
||||
ImGui::PushItemWidth(window_width - sliders_width);
|
||||
m_imgui->slider_float("##cursor_radius", &m_cursor_radius, CursorRadiusMin, CursorRadiusMax, "%.2f");
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Alt + Mouse wheel").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Alt + Mouse wheel"), max_tooltip_width);
|
||||
|
||||
ImGui::AlignTextToFramePadding();
|
||||
m_imgui->text(m_desc.at("cursor_type"));
|
||||
|
|
@ -146,26 +141,16 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
|
|||
if (m_imgui->radio_button(m_desc["sphere"], m_cursor_type == TriangleSelector::CursorType::SPHERE))
|
||||
m_cursor_type = TriangleSelector::CursorType::SPHERE;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Paints all facets inside, regardless of their orientation.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Paints all facets inside, regardless of their orientation."), max_tooltip_width);
|
||||
|
||||
ImGui::SameLine(cursor_type_offset + cursor_type_radio_sphere);
|
||||
ImGui::PushItemWidth(cursor_type_radio_circle);
|
||||
if (m_imgui->radio_button(m_desc["circle"], m_cursor_type == TriangleSelector::CursorType::CIRCLE))
|
||||
m_cursor_type = TriangleSelector::CursorType::CIRCLE;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Ignores facets facing away from the camera.").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Ignores facets facing away from the camera."), max_tooltip_width);
|
||||
|
||||
ImGui::Separator();
|
||||
if (m_c->object_clipper()->get_position() == 0.f) {
|
||||
|
|
@ -186,13 +171,8 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
|
|||
if (m_imgui->slider_float("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f"))
|
||||
m_c->object_clipper()->set_position(clp_dist, true);
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(max_tooltip_width);
|
||||
ImGui::TextUnformatted(_L("Ctrl + Mouse wheel").ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Ctrl + Mouse wheel"), max_tooltip_width);
|
||||
|
||||
ImGui::Separator();
|
||||
if (m_imgui->button(m_desc.at("remove_all"))) {
|
||||
|
|
|
|||
|
|
@ -24,15 +24,16 @@ GLGizmoSimplify::GLGizmoSimplify(GLCanvas3D & parent,
|
|||
, m_obj_index(0)
|
||||
, m_need_reload(false)
|
||||
, m_show_wireframe(false)
|
||||
|
||||
// translation for GUI size
|
||||
, tr_mesh_name(_u8L("Mesh name"))
|
||||
, tr_triangles(_u8L("Triangles"))
|
||||
, tr_preview(_u8L("Preview"))
|
||||
, tr_detail_level(_u8L("Detail level"))
|
||||
, tr_decimate_ratio(_u8L("Decimate ratio"))
|
||||
|
||||
// for wireframe
|
||||
, m_wireframe_VBO_id(0)
|
||||
, m_wireframe_IBO_id(0)
|
||||
, m_wireframe_IBO_size(0)
|
||||
{}
|
||||
|
||||
GLGizmoSimplify::~GLGizmoSimplify() {
|
||||
|
|
@ -41,10 +42,11 @@ GLGizmoSimplify::~GLGizmoSimplify() {
|
|||
free_gpu();
|
||||
}
|
||||
|
||||
bool GLGizmoSimplify::on_init()
|
||||
{
|
||||
//m_grabbers.emplace_back();
|
||||
//m_shortcut_key = WXK_CONTROL_C;
|
||||
bool GLGizmoSimplify::on_esc_key_down() {
|
||||
if (m_state == State::settings || m_state == State::canceling)
|
||||
return false;
|
||||
|
||||
m_state = State::canceling;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -53,10 +55,6 @@ std::string GLGizmoSimplify::on_get_name() const
|
|||
return _u8L("Simplify");
|
||||
}
|
||||
|
||||
void GLGizmoSimplify::on_render() { }
|
||||
|
||||
void GLGizmoSimplify::on_render_for_picking() {}
|
||||
|
||||
void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limit)
|
||||
{
|
||||
create_gui_cfg();
|
||||
|
|
@ -143,8 +141,8 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||
ImGui::Separator();
|
||||
|
||||
if(ImGui::RadioButton("##use_error", !m_configuration.use_count)) {
|
||||
m_is_valid_result = false;
|
||||
m_configuration.use_count = !m_configuration.use_count;
|
||||
live_preview();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
m_imgui->disabled_begin(m_configuration.use_count);
|
||||
|
|
@ -160,7 +158,6 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||
ImGui::SetNextItemWidth(m_gui_cfg->input_width);
|
||||
static int reduction = 2;
|
||||
if(ImGui::SliderInt("##ReductionLevel", &reduction, 0, 4, reduce_captions[reduction].c_str())) {
|
||||
m_is_valid_result = false;
|
||||
if (reduction < 0) reduction = 0;
|
||||
if (reduction > 4) reduction = 4;
|
||||
switch (reduction) {
|
||||
|
|
@ -170,12 +167,13 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||
case 3: m_configuration.max_error = 0.5f; break;
|
||||
case 4: m_configuration.max_error = 1.f; break;
|
||||
}
|
||||
live_preview();
|
||||
}
|
||||
m_imgui->disabled_end(); // !use_count
|
||||
|
||||
if (ImGui::RadioButton("##use_count", m_configuration.use_count)) {
|
||||
m_is_valid_result = false;
|
||||
m_configuration.use_count = !m_configuration.use_count;
|
||||
live_preview();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
|
|
@ -192,13 +190,14 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||
ImGui::SetNextItemWidth(m_gui_cfg->input_width);
|
||||
const char * format = (m_configuration.decimate_ratio > 10)? "%.0f %%":
|
||||
((m_configuration.decimate_ratio > 1)? "%.1f %%":"%.2f %%");
|
||||
|
||||
if (ImGui::SliderFloat("##decimate_ratio", &m_configuration.decimate_ratio, 0.f, 100.f, format)) {
|
||||
m_is_valid_result = false;
|
||||
if (m_configuration.decimate_ratio < 0.f)
|
||||
m_configuration.decimate_ratio = 0.01f;
|
||||
if (m_configuration.decimate_ratio > 100.f)
|
||||
m_configuration.decimate_ratio = 100.f;
|
||||
m_configuration.fix_count_by_ratio(triangle_count);
|
||||
live_preview();
|
||||
}
|
||||
|
||||
ImGui::NewLine();
|
||||
|
|
@ -206,43 +205,48 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||
ImGui::Text(_L("%d triangles").c_str(), m_configuration.wanted_count);
|
||||
m_imgui->disabled_end(); // use_count
|
||||
|
||||
if (ImGui::Checkbox(_L("Show wireframe").c_str(), &m_show_wireframe)) {
|
||||
if (ImGui::Checkbox(_u8L("Show wireframe").c_str(), &m_show_wireframe)) {
|
||||
if (m_show_wireframe) init_wireframe();
|
||||
else free_gpu();
|
||||
}
|
||||
|
||||
if (m_state == State::settings) {
|
||||
if (m_imgui->button(_L("Cancel"))) {
|
||||
if (m_original_its.has_value()) {
|
||||
bool is_canceling = m_state == State::canceling;
|
||||
m_imgui->disabled_begin(is_canceling);
|
||||
if (m_imgui->button(_L("Cancel"))) {
|
||||
if (m_state == State::settings) {
|
||||
if (m_original_its.has_value()) {
|
||||
set_its(*m_original_its);
|
||||
m_state = State::close_on_end;
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
} else {
|
||||
m_state = State::canceling;
|
||||
}
|
||||
ImGui::SameLine(m_gui_cfg->bottom_left_width);
|
||||
if (m_imgui->button(_L("Preview"))) {
|
||||
m_state = State::preview;
|
||||
// simplify but not apply on mesh
|
||||
process();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (m_imgui->button(_L("Apply"))) {
|
||||
if (!m_is_valid_result) {
|
||||
m_state = State::close_on_end;
|
||||
process();
|
||||
} else if (m_exist_preview) {
|
||||
// use preview and close
|
||||
after_apply();
|
||||
} else { // no changes made
|
||||
close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_imgui->disabled_begin(m_state == State::canceling);
|
||||
if (m_imgui->button(_L("Cancel"))) m_state = State::canceling;
|
||||
m_imgui->disabled_end();
|
||||
} else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && is_canceling)
|
||||
ImGui::SetTooltip("%s", _u8L("Operation already canceling. Please wait few seconds.").c_str());
|
||||
m_imgui->disabled_end(); // state canceling
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
bool is_processing = m_state != State::settings;
|
||||
m_imgui->disabled_begin(is_processing);
|
||||
if (m_imgui->button(_L("Apply"))) {
|
||||
if (!m_is_valid_result) {
|
||||
m_state = State::close_on_end;
|
||||
process();
|
||||
} else if (m_exist_preview) {
|
||||
// use preview and close
|
||||
after_apply();
|
||||
} else { // no changes made
|
||||
close();
|
||||
}
|
||||
} else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && is_processing)
|
||||
ImGui::SetTooltip("%s", _u8L("Can't apply when proccess preview.").c_str());
|
||||
m_imgui->disabled_end(); // state !settings
|
||||
|
||||
// draw progress bar
|
||||
if (is_processing) { // apply or preview
|
||||
ImGui::SameLine(m_gui_cfg->bottom_left_width);
|
||||
// draw progress bar
|
||||
char buf[32];
|
||||
|
|
@ -251,6 +255,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||
}
|
||||
m_imgui->end();
|
||||
|
||||
// refresh view when needed
|
||||
if (m_need_reload) {
|
||||
m_need_reload = false;
|
||||
bool close_on_end = (m_state == State::close_on_end);
|
||||
|
|
@ -280,6 +285,22 @@ void GLGizmoSimplify::close() {
|
|||
gizmos_mgr.open_gizmo(GLGizmosManager::EType::Simplify);
|
||||
}
|
||||
|
||||
void GLGizmoSimplify::live_preview() {
|
||||
m_is_valid_result = false;
|
||||
if (m_state != State::settings) {
|
||||
// already canceling process
|
||||
if (m_state == State::canceling) return;
|
||||
|
||||
// wait until cancel
|
||||
if (m_worker.joinable()) {
|
||||
m_state = State::canceling;
|
||||
m_worker.join();
|
||||
}
|
||||
}
|
||||
|
||||
m_state = State::preview;
|
||||
process();
|
||||
}
|
||||
|
||||
void GLGizmoSimplify::process()
|
||||
{
|
||||
|
|
@ -408,6 +429,7 @@ void GLGizmoSimplify::create_gui_cfg() {
|
|||
cfg.input_width = cfg.bottom_left_width * 1.5;
|
||||
cfg.window_offset_x = (cfg.bottom_left_width + cfg.input_width)/2;
|
||||
cfg.window_offset_y = ImGui::GetTextLineHeightWithSpacing() * 5;
|
||||
|
||||
m_gui_cfg = cfg;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,21 +24,25 @@ class GLGizmoSimplify: public GLGizmoBase, public GLGizmoTransparentRender // GL
|
|||
public:
|
||||
GLGizmoSimplify(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
virtual ~GLGizmoSimplify();
|
||||
bool on_esc_key_down();
|
||||
protected:
|
||||
virtual bool on_init() override;
|
||||
virtual std::string on_get_name() const override;
|
||||
virtual void on_render() override;
|
||||
virtual void on_render_for_picking() override;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
|
||||
virtual bool on_is_activable() const override;
|
||||
virtual bool on_is_selectable() const override { return false; }
|
||||
virtual void on_set_state() override;
|
||||
|
||||
// must implement
|
||||
virtual bool on_init() override { return true;};
|
||||
virtual void on_render() override{};
|
||||
virtual void on_render_for_picking() override{};
|
||||
|
||||
// GLGizmoPainterBase
|
||||
virtual void render_painter_gizmo() const override{ render_wireframe(); }
|
||||
private:
|
||||
void after_apply();
|
||||
void close();
|
||||
void live_preview();
|
||||
void process();
|
||||
void set_its(indexed_triangle_set &its);
|
||||
void create_gui_cfg();
|
||||
|
|
|
|||
|
|
@ -924,6 +924,10 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
|||
case WXK_NUMPAD_DOWN: case WXK_DOWN: { do_move(-1.0); break; }
|
||||
default: { break; }
|
||||
}
|
||||
} else if (m_current == Simplify && keyCode == WXK_ESCAPE) {
|
||||
GLGizmoSimplify *simplify = dynamic_cast<GLGizmoSimplify *>(get_current());
|
||||
if (simplify != nullptr)
|
||||
processed = simplify->on_esc_key_down();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -919,7 +919,7 @@ void NotificationManager::HintNotification::render_preferences_button(ImGuiWrapp
|
|||
}
|
||||
if (imgui.button(button_text.c_str(), button_size.x, button_size.y))
|
||||
{
|
||||
wxGetApp().open_preferences(2);
|
||||
wxGetApp().open_preferences(2, "show_hints");
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(5);
|
||||
|
|
|
|||
|
|
@ -280,10 +280,10 @@ void ImGuiWrapper::render()
|
|||
m_new_frame_open = false;
|
||||
}
|
||||
|
||||
ImVec2 ImGuiWrapper::calc_text_size(const wxString &text)
|
||||
ImVec2 ImGuiWrapper::calc_text_size(const wxString &text, float wrap_width)
|
||||
{
|
||||
auto text_utf8 = into_u8(text);
|
||||
ImVec2 size = ImGui::CalcTextSize(text_utf8.c_str());
|
||||
ImVec2 size = ImGui::CalcTextSize(text_utf8.c_str(), NULL, false, wrap_width);
|
||||
|
||||
/*#ifdef __linux__
|
||||
size.x *= m_style_scaling;
|
||||
|
|
@ -293,6 +293,13 @@ ImVec2 ImGuiWrapper::calc_text_size(const wxString &text)
|
|||
return size;
|
||||
}
|
||||
|
||||
float ImGuiWrapper::get_slider_float_height() const
|
||||
{
|
||||
const ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
return g.FontSize + style.FramePadding.y * 2.0f + style.ItemSpacing.y;
|
||||
}
|
||||
|
||||
void ImGuiWrapper::set_next_window_pos(float x, float y, int flag, float pivot_x, float pivot_y)
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2(x, y), (ImGuiCond)flag, ImVec2(pivot_x, pivot_y));
|
||||
|
|
@ -425,6 +432,42 @@ void ImGuiWrapper::text_colored(const ImVec4& color, const wxString& label)
|
|||
this->text_colored(color, label_utf8.c_str());
|
||||
}
|
||||
|
||||
void ImGuiWrapper::text_wrapped(const char *label, float wrap_width)
|
||||
{
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width);
|
||||
this->text(label);
|
||||
ImGui::PopTextWrapPos();
|
||||
}
|
||||
|
||||
void ImGuiWrapper::text_wrapped(const std::string &label, float wrap_width)
|
||||
{
|
||||
this->text_wrapped(label.c_str(), wrap_width);
|
||||
}
|
||||
|
||||
void ImGuiWrapper::text_wrapped(const wxString &label, float wrap_width)
|
||||
{
|
||||
auto label_utf8 = into_u8(label);
|
||||
this->text_wrapped(label_utf8.c_str(), wrap_width);
|
||||
}
|
||||
|
||||
void ImGuiWrapper::tooltip(const char *label, float wrap_width)
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(wrap_width);
|
||||
ImGui::TextUnformatted(label);
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
void ImGuiWrapper::tooltip(const wxString &label, float wrap_width)
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::PushTextWrapPos(wrap_width);
|
||||
ImGui::TextUnformatted(label.ToUTF8().data());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
bool ImGuiWrapper::slider_float(const char* label, float* v, float v_min, float v_max, const char* format/* = "%.3f"*/, float power/* = 1.0f*/, bool clamp /*= true*/)
|
||||
{
|
||||
bool ret = ImGui::SliderFloat(label, v, v_min, v_max, format, power);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,9 @@ public:
|
|||
|
||||
float scaled(float x) const { return x * m_font_size; }
|
||||
ImVec2 scaled(float x, float y) const { return ImVec2(x * m_font_size, y * m_font_size); }
|
||||
ImVec2 calc_text_size(const wxString &text);
|
||||
ImVec2 calc_text_size(const wxString &text, float wrap_width = -1.0f);
|
||||
|
||||
float get_slider_float_height() const;
|
||||
|
||||
void set_next_window_pos(float x, float y, int flag, float pivot_x = 0.0f, float pivot_y = 0.0f);
|
||||
void set_next_window_bg_alpha(float alpha);
|
||||
|
|
@ -79,6 +81,11 @@ public:
|
|||
void text_colored(const ImVec4& color, const char* label);
|
||||
void text_colored(const ImVec4& color, const std::string& label);
|
||||
void text_colored(const ImVec4& color, const wxString& label);
|
||||
void text_wrapped(const char *label, float wrap_width);
|
||||
void text_wrapped(const std::string &label, float wrap_width);
|
||||
void text_wrapped(const wxString &label, float wrap_width);
|
||||
void tooltip(const char *label, float wrap_width);
|
||||
void tooltip(const wxString &label, float wrap_width);
|
||||
|
||||
// Float sliders: Manually inserted values aren't clamped by ImGui.Using this wrapper function does (when clamp==true).
|
||||
bool slider_float(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f, bool clamp = true);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ const NotificationManager::NotificationData NotificationManager::basic_notificat
|
|||
_u8L("Undo desktop integration was successful.") },
|
||||
{NotificationType::UndoDesktopIntegrationFail, NotificationLevel::WarningNotificationLevel, 10,
|
||||
_u8L("Undo desktop integration failed.") },
|
||||
{NotificationType::ExportOngoing, NotificationLevel::RegularNotificationLevel, 0, _u8L("Exporting.") },
|
||||
//{NotificationType::NewAppAvailable, NotificationLevel::ImportantNotificationLevel, 20, _u8L("New vesion of PrusaSlicer is available.", _u8L("Download page.") },
|
||||
//{NotificationType::LoadingFailed, NotificationLevel::RegularNotificationLevel, 20, _u8L("Loading of model has Failed") },
|
||||
//{NotificationType::DeviceEjected, NotificationLevel::RegularNotificationLevel, 10, _u8L("Removable device has been safely ejected")} // if we want changeble text (like here name of device), we need to do it as CustomNotification
|
||||
|
|
@ -214,7 +215,8 @@ void NotificationManager::PopNotification::render(GLCanvas3D& canvas, float init
|
|||
}
|
||||
|
||||
if (mouse_pos.x < win_pos.x && mouse_pos.x > win_pos.x - m_window_width && mouse_pos.y > win_pos.y && mouse_pos.y < win_pos.y + m_window_height) {
|
||||
ImGui::SetNextWindowFocus();
|
||||
// Uncomment if imgui window focus is needed on hover. I cant find any case.
|
||||
//ImGui::SetNextWindowFocus();
|
||||
set_hovered();
|
||||
}
|
||||
|
||||
|
|
@ -1151,6 +1153,8 @@ bool NotificationManager::SlicingProgressNotification::set_progress_state(Notifi
|
|||
m_sp_state = state;
|
||||
return true;
|
||||
case Slic3r::GUI::NotificationManager::SlicingProgressNotification::SlicingProgressState::SP_COMPLETED:
|
||||
if (m_sp_state != SlicingProgressState::SP_BEGAN && m_sp_state != SlicingProgressState::SP_PROGRESS)
|
||||
return false;
|
||||
set_percentage(1);
|
||||
m_has_cancel_button = false;
|
||||
m_has_print_info = false;
|
||||
|
|
@ -1508,6 +1512,16 @@ void NotificationManager::push_notification(NotificationType type,
|
|||
int duration = get_standart_duration(level);
|
||||
push_notification_data({ type, level, duration, text, hypertext, callback }, timestamp);
|
||||
}
|
||||
|
||||
void NotificationManager::push_delayed_notification(const NotificationType type, std::function<bool(void)> condition_callback, int64_t initial_delay, int64_t delay_interval)
|
||||
{
|
||||
auto it = std::find_if(std::begin(basic_notifications), std::end(basic_notifications),
|
||||
boost::bind(&NotificationData::type, boost::placeholders::_1) == type);
|
||||
assert(it != std::end(basic_notifications));
|
||||
if (it != std::end(basic_notifications))
|
||||
push_delayed_notification_data(std::make_unique<PopNotification>(*it, m_id_provider, m_evt_handler), condition_callback, initial_delay, delay_interval);
|
||||
}
|
||||
|
||||
void NotificationManager::push_validate_error_notification(const std::string& text)
|
||||
{
|
||||
push_notification_data({ NotificationType::ValidateError, NotificationLevel::ErrorNotificationLevel, 0, _u8L("ERROR:") + "\n" + text }, 0);
|
||||
|
|
@ -1911,7 +1925,7 @@ void NotificationManager::push_hint_notification(bool open_next)
|
|||
auto condition = [&self = std::as_const(*this)]() {
|
||||
return self.get_notification_count() == 0;
|
||||
};
|
||||
push_delayed_notification(std::make_unique<NotificationManager::HintNotification>(data, m_id_provider, m_evt_handler, open_next), condition, 500, 30000);
|
||||
push_delayed_notification_data(std::make_unique<NotificationManager::HintNotification>(data, m_id_provider, m_evt_handler, open_next), condition, 500, 30000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1974,7 +1988,7 @@ bool NotificationManager::push_notification_data(std::unique_ptr<NotificationMan
|
|||
return retval;
|
||||
}
|
||||
|
||||
void NotificationManager::push_delayed_notification(std::unique_ptr<NotificationManager::PopNotification> notification, std::function<bool(void)> condition_callback, int64_t initial_delay, int64_t delay_interval)
|
||||
void NotificationManager::push_delayed_notification_data(std::unique_ptr<NotificationManager::PopNotification> notification, std::function<bool(void)> condition_callback, int64_t initial_delay, int64_t delay_interval)
|
||||
{
|
||||
if (initial_delay == 0 && condition_callback()) {
|
||||
if( push_notification_data(std::move(notification), 0))
|
||||
|
|
|
|||
|
|
@ -109,8 +109,10 @@ enum class NotificationType
|
|||
// Give user advice to simplify object with big amount of triangles
|
||||
// Contains ObjectID for closing when object is deleted
|
||||
SimplifySuggestion,
|
||||
// information about netfabb is finished repairing model (blocking proccess)
|
||||
NetfabbFinished
|
||||
// information about netfabb is finished repairing model (blocking proccess)
|
||||
NetfabbFinished,
|
||||
// Short meesage to fill space between start and finish of export
|
||||
ExportOngoing
|
||||
};
|
||||
|
||||
class NotificationManager
|
||||
|
|
@ -151,6 +153,10 @@ public:
|
|||
// ErrorNotificationLevel and ImportantNotificationLevel are never faded out.
|
||||
void push_notification(NotificationType type, NotificationLevel level, const std::string& text, const std::string& hypertext = "",
|
||||
std::function<bool(wxEvtHandler*)> callback = std::function<bool(wxEvtHandler*)>(), int timestamp = 0);
|
||||
// Pushes basic_notification with delay. See push_delayed_notification_data.
|
||||
void push_delayed_notification(const NotificationType type, std::function<bool(void)> condition_callback, int64_t initial_delay, int64_t delay_interval);
|
||||
// Removes all notifications of type from m_waiting_notifications
|
||||
void stop_delayed_notifications_of_type(const NotificationType type);
|
||||
// Creates Validate Error notification with a custom text and no fade out.
|
||||
void push_validate_error_notification(const std::string& text);
|
||||
// Creates Slicing Error notification with a custom text and no fade out.
|
||||
|
|
@ -699,10 +705,8 @@ private:
|
|||
// and condition callback is success, notification is regular pushed from update function.
|
||||
// Otherwise another delay interval waiting. Timestamp is 0.
|
||||
// Note that notification object is constructed when being added to the waiting list, but there are no updates called on it and its timer is reset at regular push.
|
||||
// Also note that no control of same notification is done during push_delayed_notification but if waiting notif fails to push, it continues waiting.
|
||||
void push_delayed_notification(std::unique_ptr<NotificationManager::PopNotification> notification, std::function<bool(void)> condition_callback, int64_t initial_delay, int64_t delay_interval);
|
||||
// Removes all notifications of type from m_waiting_notifications
|
||||
void stop_delayed_notifications_of_type(const NotificationType type);
|
||||
// Also note that no control of same notification is done during push_delayed_notification_data but if waiting notif fails to push, it continues waiting.
|
||||
void push_delayed_notification_data(std::unique_ptr<NotificationManager::PopNotification> notification, std::function<bool(void)> condition_callback, int64_t initial_delay, int64_t delay_interval);
|
||||
//finds older notification of same type and moves it to the end of queue. returns true if found
|
||||
bool activate_existing(const NotificationManager::PopNotification* notification);
|
||||
// Put the more important notifications to the bottom of the list.
|
||||
|
|
|
|||
|
|
@ -597,6 +597,8 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
|
|||
{
|
||||
if (field && field->undo_to_sys_bitmap())
|
||||
h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(), field->undo_bitmap()->bmp(), field->blink()) + ctrl->m_h_gap;
|
||||
else if (field && !field->undo_to_sys_bitmap() && field->blink())
|
||||
draw_blinking_bmp(dc, wxPoint(h_pos, v_pos), field->blink());
|
||||
// update width for full_width fields
|
||||
if (option_set.front().opt.full_width && field->getWindow())
|
||||
field->getWindow()->SetSize(ctrl->GetSize().x - h_pos, -1);
|
||||
|
|
|
|||
|
|
@ -4032,6 +4032,7 @@ void Plater::priv::on_export_began(wxCommandEvent& evt)
|
|||
{
|
||||
if (show_warning_dialog)
|
||||
warnings_dialog();
|
||||
notification_manager->push_delayed_notification(NotificationType::ExportOngoing, [](){return true;}, 1000, 1000);
|
||||
}
|
||||
void Plater::priv::on_slicing_began()
|
||||
{
|
||||
|
|
@ -4164,6 +4165,10 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt)
|
|||
if(wxGetApp().get_mode() == comSimple) {
|
||||
show_action_buttons(false);
|
||||
}
|
||||
if (exporting_status != ExportingStatus::NOT_EXPORTING && !has_error) {
|
||||
notification_manager->stop_delayed_notifications_of_type(NotificationType::ExportOngoing);
|
||||
notification_manager->close_notification_of_type(NotificationType::ExportOngoing);
|
||||
}
|
||||
// If writing to removable drive was scheduled, show notification with eject button
|
||||
if (exporting_status == ExportingStatus::EXPORTING_TO_REMOVABLE && !has_error) {
|
||||
show_action_buttons(false);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Slic3r {
|
|||
|
||||
namespace GUI {
|
||||
|
||||
PreferencesDialog::PreferencesDialog(wxWindow* parent, int selected_tab) :
|
||||
PreferencesDialog::PreferencesDialog(wxWindow* parent, int selected_tab, const std::string& highlight_opt_key) :
|
||||
DPIDialog(parent, wxID_ANY, _L("Preferences"), wxDefaultPosition,
|
||||
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
|
||||
{
|
||||
|
|
@ -51,6 +51,8 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent, int selected_tab) :
|
|||
isOSX = true;
|
||||
#endif
|
||||
build(selected_tab);
|
||||
if (!highlight_opt_key.empty())
|
||||
init_highlighter(highlight_opt_key);
|
||||
}
|
||||
|
||||
static std::shared_ptr<ConfigOptionsGroup>create_options_tab(const wxString& title, wxBookCtrlBase* tabs)
|
||||
|
|
@ -450,8 +452,10 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
|
||||
activate_options_tab(m_optgroup_gui);
|
||||
// set Field for notify_release to its value to activate the object
|
||||
boost::any val = s_keys_map_NotifyReleaseMode.at(app_config->get("notify_release"));
|
||||
m_optgroup_gui->get_field("notify_release")->set_value(val, false);
|
||||
if (is_editor) {
|
||||
boost::any val = s_keys_map_NotifyReleaseMode.at(app_config->get("notify_release"));
|
||||
m_optgroup_gui->get_field("notify_release")->set_value(val, false);
|
||||
}
|
||||
|
||||
if (is_editor) {
|
||||
create_icon_size_slider();
|
||||
|
|
@ -755,6 +759,71 @@ void PreferencesDialog::create_settings_text_color_widget()
|
|||
m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND | wxTOP, em_unit());
|
||||
}
|
||||
|
||||
void PreferencesDialog::init_highlighter(const t_config_option_key& opt_key)
|
||||
{
|
||||
m_highlighter.set_timer_owner(this, 0);
|
||||
this->Bind(wxEVT_TIMER, [this](wxTimerEvent&)
|
||||
{
|
||||
m_highlighter.blink();
|
||||
});
|
||||
|
||||
std::pair<OG_CustomCtrl*, bool*> ctrl = { nullptr, nullptr };
|
||||
for (auto opt_group : { m_optgroup_general, m_optgroup_camera, m_optgroup_gui }) {
|
||||
ctrl = opt_group->get_custom_ctrl_with_blinking_ptr(opt_key, -1);
|
||||
if (ctrl.first && ctrl.second) {
|
||||
m_highlighter.init(ctrl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDialog::PreferencesHighlighter::set_timer_owner(wxEvtHandler* owner, int timerid/* = wxID_ANY*/)
|
||||
{
|
||||
m_timer.SetOwner(owner, timerid);
|
||||
}
|
||||
|
||||
void PreferencesDialog::PreferencesHighlighter::init(std::pair<OG_CustomCtrl*, bool*> params)
|
||||
{
|
||||
if (m_timer.IsRunning())
|
||||
invalidate();
|
||||
if (!params.first || !params.second)
|
||||
return;
|
||||
|
||||
m_timer.Start(300, false);
|
||||
|
||||
m_custom_ctrl = params.first;
|
||||
m_show_blink_ptr = params.second;
|
||||
|
||||
*m_show_blink_ptr = true;
|
||||
m_custom_ctrl->Refresh();
|
||||
}
|
||||
|
||||
void PreferencesDialog::PreferencesHighlighter::invalidate()
|
||||
{
|
||||
m_timer.Stop();
|
||||
|
||||
if (m_custom_ctrl && m_show_blink_ptr) {
|
||||
*m_show_blink_ptr = false;
|
||||
m_custom_ctrl->Refresh();
|
||||
m_show_blink_ptr = nullptr;
|
||||
m_custom_ctrl = nullptr;
|
||||
}
|
||||
|
||||
m_blink_counter = 0;
|
||||
}
|
||||
|
||||
void PreferencesDialog::PreferencesHighlighter::blink()
|
||||
{
|
||||
if (m_custom_ctrl && m_show_blink_ptr) {
|
||||
*m_show_blink_ptr = !*m_show_blink_ptr;
|
||||
m_custom_ctrl->Refresh();
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
if ((++m_blink_counter) == 11)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
} // GUI
|
||||
} // Slic3r
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "GUI_Utils.hpp"
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/timer.h>
|
||||
#include <map>
|
||||
|
||||
class wxColourPickerCtrl;
|
||||
|
|
@ -20,6 +21,7 @@ namespace Slic3r {
|
|||
namespace GUI {
|
||||
|
||||
class ConfigOptionsGroup;
|
||||
class OG_CustomCtrl;
|
||||
|
||||
class PreferencesDialog : public DPIDialog
|
||||
{
|
||||
|
|
@ -39,7 +41,7 @@ class PreferencesDialog : public DPIDialog
|
|||
bool m_recreate_GUI{false};
|
||||
|
||||
public:
|
||||
explicit PreferencesDialog(wxWindow* parent, int selected_tab = 0);
|
||||
explicit PreferencesDialog(wxWindow* parent, int selected_tab = 0, const std::string& highlight_opt_key = std::string());
|
||||
~PreferencesDialog() = default;
|
||||
|
||||
bool settings_layout_changed() const { return m_settings_layout_changed; }
|
||||
|
|
@ -55,6 +57,22 @@ protected:
|
|||
void create_icon_size_slider();
|
||||
void create_settings_mode_widget();
|
||||
void create_settings_text_color_widget();
|
||||
void init_highlighter(const t_config_option_key& opt_key);
|
||||
|
||||
struct PreferencesHighlighter
|
||||
{
|
||||
void set_timer_owner(wxEvtHandler* owner, int timerid = wxID_ANY);
|
||||
void init(std::pair<OG_CustomCtrl*, bool*>);
|
||||
void blink();
|
||||
void invalidate();
|
||||
|
||||
private:
|
||||
OG_CustomCtrl* m_custom_ctrl{ nullptr };
|
||||
bool* m_show_blink_ptr{ nullptr };
|
||||
int m_blink_counter{ 0 };
|
||||
wxTimer m_timer;
|
||||
}
|
||||
m_highlighter;
|
||||
};
|
||||
|
||||
} // GUI
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "slic3r/GUI/format.hpp"
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
#include "slic3r/Utils/PresetUpdater.hpp"
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
|
|
@ -17,6 +18,7 @@
|
|||
#include <boost/algorithm/hex.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/trim_all.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/uuid/detail/md5.hpp>
|
||||
|
||||
|
|
@ -36,12 +38,17 @@
|
|||
#include <Iphlpapi.h>
|
||||
#pragma comment(lib, "iphlpapi.lib")
|
||||
#elif __APPLE__
|
||||
#import <IOKit/IOKitLib.h>
|
||||
#import <IOKit/IOKitLib.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#else // Linux/BSD
|
||||
#include <charconv>
|
||||
#endif
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
static const std::string SEND_SYSTEM_INFO_DOMAIN = "prusa3d.com";
|
||||
static const std::string SEND_SYSTEM_INFO_URL = "https://files." + SEND_SYSTEM_INFO_DOMAIN + "/wp-json/v1/ps";
|
||||
|
||||
|
||||
// Declaration of a free function defined in OpenGLManager.cpp:
|
||||
|
|
@ -52,8 +59,8 @@ std::string gl_get_string_safe(GLenum param, const std::string& default_value);
|
|||
class SendSystemInfoDialog : public DPIDialog
|
||||
{
|
||||
enum {
|
||||
MIN_WIDTH = 80,
|
||||
MIN_HEIGHT = 50
|
||||
MIN_WIDTH = 70,
|
||||
MIN_HEIGHT = 34
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
@ -129,20 +136,36 @@ public:
|
|||
// current version is newer. Only major and minor versions are compared.
|
||||
static bool should_dialog_be_shown()
|
||||
{
|
||||
return false;
|
||||
|
||||
std::string last_sent_version = wxGetApp().app_config->get("version_system_info_sent");
|
||||
Semver semver_current(SLIC3R_VERSION);
|
||||
Semver semver_last_sent;
|
||||
if (! last_sent_version.empty())
|
||||
semver_last_sent = Semver(last_sent_version);
|
||||
|
||||
if (semver_current.prerelease() && std::string(semver_current.prerelease()) == "alpha")
|
||||
return false; // Don't show in alphas.
|
||||
// set whether to show in alpha builds, or only betas/rcs/finals:
|
||||
const bool show_in_alphas = true;
|
||||
|
||||
// Show the dialog if current > last, but they differ in more than just patch.
|
||||
return ((semver_current.maj() > semver_last_sent.maj())
|
||||
if (! show_in_alphas && semver_current.prerelease()
|
||||
&& std::string(semver_current.prerelease()).find("alpha") != std::string::npos)
|
||||
return false;
|
||||
|
||||
// New version means current > last, but they must differ in more than just patch.
|
||||
bool new_version = ((semver_current.maj() > semver_last_sent.maj())
|
||||
|| (semver_current.maj() == semver_last_sent.maj() && semver_current.min() > semver_last_sent.min() ));
|
||||
|
||||
if (! new_version)
|
||||
return false;
|
||||
|
||||
// We'll misuse the version check to check internet connection here.
|
||||
bool is_internet = false;
|
||||
Http::get(wxGetApp().app_config->version_check_url())
|
||||
.size_limit(SLIC3R_VERSION_BODY_MAX)
|
||||
.timeout_max(2)
|
||||
.on_complete([&](std::string, unsigned) {
|
||||
is_internet = true;
|
||||
})
|
||||
.perform_sync();
|
||||
return is_internet;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -162,9 +185,10 @@ static std::map<std::string, std::string> get_cpu_info_from_registry()
|
|||
std::map<std::string, std::string> out;
|
||||
|
||||
int idx = -1;
|
||||
constexpr DWORD bufsize_ = 200;
|
||||
DWORD bufsize = bufsize_;
|
||||
constexpr DWORD bufsize_ = 500;
|
||||
DWORD bufsize = bufsize_-1; // Ensure a terminating zero.
|
||||
char buf[bufsize_] = "";
|
||||
memset(buf, 0, bufsize_);
|
||||
const std::string reg_dir = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\";
|
||||
std::string reg_path = reg_dir;
|
||||
|
||||
|
|
@ -186,7 +210,7 @@ static std::map<std::string, std::string> get_cpu_info_from_registry()
|
|||
}
|
||||
++idx;
|
||||
reg_path = reg_dir + std::to_string(idx) + "\\";
|
||||
bufsize = bufsize_;
|
||||
bufsize = bufsize_-1;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
@ -194,7 +218,7 @@ static std::map<std::string, std::string> get_cpu_info_from_registry()
|
|||
static std::map<std::string, std::string> parse_lscpu_etc(const std::string& name, char delimiter)
|
||||
{
|
||||
std::map<std::string, std::string> out;
|
||||
constexpr size_t max_len = 100;
|
||||
constexpr size_t max_len = 1000;
|
||||
char cline[max_len] = "";
|
||||
FILE* fp = popen(name.data(), "r");
|
||||
if (fp != NULL) {
|
||||
|
|
@ -260,10 +284,12 @@ static std::string get_unique_id()
|
|||
char buf[buf_size] = "";
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
|
||||
CFStringRef uuidCf = (CFStringRef)IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
|
||||
IOObjectRelease(ioRegistryRoot);
|
||||
CFStringGetCString(uuidCf, buf, buf_size, kCFStringEncodingMacRoman);
|
||||
CFRelease(uuidCf);
|
||||
if (ioRegistryRoot != MACH_PORT_NULL) {
|
||||
CFStringRef uuidCf = (CFStringRef)IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
|
||||
IOObjectRelease(ioRegistryRoot);
|
||||
CFStringGetCString(uuidCf, buf, buf_size, kCFStringEncodingMacRoman);
|
||||
CFRelease(uuidCf);
|
||||
}
|
||||
// Now convert the string to std::vector<unsigned char>.
|
||||
for (char* c = buf; *c != 0; ++c)
|
||||
unique.emplace_back((unsigned char)(*c));
|
||||
|
|
@ -318,11 +344,20 @@ static std::string generate_system_info_json()
|
|||
std::string unique_id = get_unique_id();
|
||||
|
||||
// Get system language.
|
||||
std::string sys_language = "Unknown";
|
||||
const wxLanguage lang_system = wxLanguage(wxLocale::GetSystemLanguage());
|
||||
if (lang_system != wxLANGUAGE_UNKNOWN)
|
||||
sys_language = wxLocale::GetLanguageInfo(lang_system)->CanonicalName.ToUTF8().data();
|
||||
|
||||
std::string sys_language = "Unknown"; // important to init, see the __APPLE__ block.
|
||||
#ifndef __APPLE__
|
||||
// Following apparently does not work on macOS.
|
||||
const wxLanguage lang_system = wxLanguage(wxLocale::GetSystemLanguage());
|
||||
if (lang_system != wxLANGUAGE_UNKNOWN)
|
||||
sys_language = wxLocale::GetLanguageInfo(lang_system)->CanonicalName.ToUTF8().data();
|
||||
#else // __APPLE__
|
||||
CFLocaleRef cflocale = CFLocaleCopyCurrent();
|
||||
CFStringRef value = (CFStringRef)CFLocaleGetValue(cflocale, kCFLocaleLanguageCode);
|
||||
char temp[10] = "";
|
||||
CFStringGetCString(value, temp, 10, kCFStringEncodingUTF8);
|
||||
sys_language = temp;
|
||||
CFRelease(cflocale);
|
||||
#endif
|
||||
// Build a property tree with all the information.
|
||||
namespace pt = boost::property_tree;
|
||||
|
||||
|
|
@ -364,9 +399,13 @@ static std::string generate_system_info_json()
|
|||
data_node.put("SystemLanguage", sys_language);
|
||||
data_node.put("TranslationLanguage: ", wxGetApp().app_config->get("translation_language"));
|
||||
|
||||
|
||||
pt::ptree hw_node;
|
||||
hw_node.put("ArchName", wxPlatformInfo::Get().GetArchName());
|
||||
hw_node.put("RAM_MB", size_t(Slic3r::total_physical_memory()/1000000));
|
||||
{
|
||||
hw_node.put("ArchName", wxPlatformInfo::Get().GetArchName());
|
||||
size_t num = std::round(Slic3r::total_physical_memory()/107374100.);
|
||||
hw_node.put("RAM_GiB", std::to_string(num / 10) + "." + std::to_string(num % 10));
|
||||
}
|
||||
|
||||
// Now get some CPU info:
|
||||
pt::ptree cpu_node;
|
||||
|
|
@ -381,31 +420,32 @@ static std::string generate_system_info_json()
|
|||
cpu_node.put("Model", sysctl["machdep.cpu.brand_string"]);
|
||||
cpu_node.put("Vendor", sysctl["machdep.cpu.vendor"]);
|
||||
#else // linux/BSD
|
||||
std::map<std::string, std::string> lscpu = parse_lscpu_etc("lscpu", ':');
|
||||
cpu_node.put("Arch", lscpu["Architecture"]);
|
||||
cpu_node.put("Cores", lscpu["CPU(s)"]);
|
||||
cpu_node.put("Model", lscpu["Model name"]);
|
||||
cpu_node.put("Vendor", lscpu["Vendor ID"]);
|
||||
std::map<std::string, std::string> lscpu = parse_lscpu_etc("cat /proc/cpuinfo", ':');
|
||||
if (auto ncpu_it = lscpu.find("processor"); ncpu_it != lscpu.end()) {
|
||||
std::string& ncpu = ncpu_it->second;
|
||||
if (int num=0; std::from_chars(ncpu.data(), ncpu.data() + ncpu.size(), num).ec != std::errc::invalid_argument)
|
||||
ncpu = std::to_string(num + 1);
|
||||
}
|
||||
cpu_node.put("Cores", lscpu["processor"]);
|
||||
cpu_node.put("Model", lscpu["model name"]);
|
||||
cpu_node.put("Vendor", lscpu["vendor_id"]);
|
||||
#endif
|
||||
hw_node.add_child("CPU", cpu_node);
|
||||
|
||||
pt::ptree monitors_node;
|
||||
for (int i=0; i<int(wxDisplay::GetCount()); ++i) {
|
||||
wxDisplay display(i);
|
||||
double scaling = -1.;
|
||||
#if wxCHECK_VERSION(3, 1, 2) // we have wxDisplag::GetPPI
|
||||
int std_ppi = 96;
|
||||
#ifdef __WXOSX__ // see impl of wxDisplay::GetStdPPIValue from 3.1.5
|
||||
std_ppi = 72;
|
||||
#endif
|
||||
scaling = double(display.GetPPI().GetWidth()) / std_ppi;
|
||||
#endif
|
||||
pt::ptree monitor_node; // Create an unnamed node containing the value
|
||||
monitor_node.put("width", display.GetGeometry().GetWidth());
|
||||
monitor_node.put("height", display.GetGeometry().GetHeight());
|
||||
std::stringstream ss;
|
||||
ss << std::setprecision(3) << scaling;
|
||||
monitor_node.put("scaling", ss.str() );
|
||||
|
||||
// Only get the scaling on Win, it is not reliable on other platforms.
|
||||
#if defined(_WIN32) && wxCHECK_VERSION(3, 1, 2)
|
||||
double scaling = display.GetPPI().GetWidth() / 96.;
|
||||
std::stringstream ss;
|
||||
ss << std::setprecision(3) << scaling;
|
||||
monitor_node.put("scaling", ss.str() );
|
||||
#endif
|
||||
monitors_node.push_back(std::make_pair("", monitor_node));
|
||||
}
|
||||
hw_node.add_child("Monitors", monitors_node);
|
||||
|
|
@ -435,15 +475,23 @@ static std::string generate_system_info_json()
|
|||
pt::ptree root;
|
||||
root.add_child("data", data_node);
|
||||
|
||||
// Now go through all the values and trim leading/trailing whitespace.
|
||||
// Some CPU names etc apparently have trailing spaces...
|
||||
std::function<void(pt::ptree&)> remove_whitespace;
|
||||
remove_whitespace = [&remove_whitespace](pt::ptree& t) -> void
|
||||
{
|
||||
if (t.empty()) // Trim whitespace
|
||||
boost::algorithm::trim(t.data());
|
||||
else
|
||||
for (auto it = t.begin(); it != t.end(); ++it)
|
||||
remove_whitespace(it->second);
|
||||
};
|
||||
remove_whitespace(root);
|
||||
|
||||
// Serialize the tree into JSON and return it.
|
||||
std::stringstream ss;
|
||||
pt::write_json(ss, root);
|
||||
return ss.str();
|
||||
|
||||
// FURTHER THINGS TO CONSIDER:
|
||||
//std::cout << wxPlatformInfo::Get().GetOperatingSystemFamilyName() << std::endl; // Unix
|
||||
// ? CPU, GPU, UNKNOWN ?
|
||||
// printers? will they be installed already?
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -453,6 +501,8 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
|
|||
GUI::DPIDialog(parent, wxID_ANY, _L("Send system info"), wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE)
|
||||
{
|
||||
const int em = GUI::wxGetApp().em_unit();
|
||||
|
||||
// Get current PrusaSliver version info.
|
||||
std::string app_name;
|
||||
{
|
||||
|
|
@ -500,7 +550,7 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
|
|||
std::string("<i>") + filename + "</i>");
|
||||
wxString label3 = _L("Show verbatim data that will be sent");
|
||||
|
||||
auto* html_window = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER);
|
||||
auto* html_window = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxSize(70*em, 34*em), wxHW_SCROLLBAR_NEVER);
|
||||
wxString html = GUI::format_wxstr(
|
||||
"<html><body bgcolor=%1%><font color=%2%>"
|
||||
"<table><tr><td>"
|
||||
|
|
@ -514,7 +564,7 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
|
|||
+ "<b><a href=\"show\">" + label3 + "</a></b><br />"
|
||||
+ "</font></body></html>", bgr_clr_str, text_clr_str);
|
||||
html_window->SetPage(html);
|
||||
html_window->Bind(wxEVT_HTML_LINK_CLICKED, [this](wxHtmlLinkEvent &evt) {
|
||||
html_window->Bind(wxEVT_HTML_LINK_CLICKED, [this](wxHtmlLinkEvent&) {
|
||||
ShowJsonDialog dlg(this, m_system_info_json, GetSize().Scale(0.9, 0.7));
|
||||
dlg.ShowModal();
|
||||
});
|
||||
|
|
@ -526,7 +576,6 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
|
|||
m_btn_send = new wxButton(this, wxID_ANY, _L("Send system info"));
|
||||
|
||||
auto* hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
const int em = GUI::wxGetApp().em_unit();
|
||||
hsizer->Add(m_btn_ask_later);
|
||||
hsizer->AddSpacer(em);
|
||||
hsizer->Add(m_btn_dont_send);
|
||||
|
|
@ -548,6 +597,8 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
|
|||
SetSize(std::max(size.GetWidth(), MIN_WIDTH * em),
|
||||
std::max(size.GetHeight(), MIN_HEIGHT * em));
|
||||
|
||||
CenterOnParent();
|
||||
|
||||
m_btn_send->Bind(wxEVT_BUTTON, [this](const wxEvent&)
|
||||
{
|
||||
if (send_info()) {
|
||||
|
|
@ -592,15 +643,16 @@ bool SendSystemInfoDialog::send_info()
|
|||
} result; // No synchronization needed, UI thread reads only after worker is joined.
|
||||
|
||||
auto send = [&job_done, &result](const std::string& data) {
|
||||
const std::string url = "https://files.prusa3d.com/wp-json/v1/ps";
|
||||
Http http = Http::post(url);
|
||||
Http http = Http::post(SEND_SYSTEM_INFO_URL);
|
||||
http.header("Content-Type", "application/json")
|
||||
.timeout_max(6) // seconds
|
||||
.set_post_body(data)
|
||||
.on_complete([&result](std::string body, unsigned status) {
|
||||
result = { Result::Success, _L("System info sent successfully. Thank you.") };
|
||||
})
|
||||
.on_error([&result](std::string body, std::string error, unsigned status) {
|
||||
result = { Result::Error, GUI::format_wxstr(_L("Sending system info failed! Status: %1%"), status) };
|
||||
result = { Result::Error, _L("Sending system info failed!") };
|
||||
BOOST_LOG_TRIVIAL(error) << "Sending system info failed! STATUS: " << status;
|
||||
})
|
||||
.on_progress([&job_done, &result](Http::Progress, bool &cancel) {
|
||||
if (job_done) // UI thread wants us to cancel.
|
||||
|
|
@ -622,8 +674,10 @@ bool SendSystemInfoDialog::send_info()
|
|||
job_done = true; // In case the user closed the dialog, let the other thread know
|
||||
sending_thread.join(); // and wait until it terminates.
|
||||
|
||||
InfoDialog info_dlg(wxGetApp().mainframe, wxEmptyString, result.str);
|
||||
info_dlg.ShowModal();
|
||||
if (result.value != Result::Cancelled) { // user knows he cancelled, no need to tell him.
|
||||
InfoDialog info_dlg(wxGetApp().mainframe, wxEmptyString, result.str);
|
||||
info_dlg.ShowModal();
|
||||
}
|
||||
return result.value == Result::Success;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ struct Http::priv
|
|||
{
|
||||
enum {
|
||||
DEFAULT_TIMEOUT_CONNECT = 10,
|
||||
DEFAULT_TIMEOUT_MAX = 0,
|
||||
DEFAULT_SIZE_LIMIT = 5 * 1024 * 1024,
|
||||
};
|
||||
|
||||
|
|
@ -137,6 +138,7 @@ struct Http::priv
|
|||
static size_t form_file_read_cb(char *buffer, size_t size, size_t nitems, void *userp);
|
||||
|
||||
void set_timeout_connect(long timeout);
|
||||
void set_timeout_max(long timeout);
|
||||
void form_add_file(const char *name, const fs::path &path, const char* filename);
|
||||
void set_post_body(const fs::path &path);
|
||||
void set_post_body(const std::string &body);
|
||||
|
|
@ -163,6 +165,7 @@ Http::priv::priv(const std::string &url)
|
|||
}
|
||||
|
||||
set_timeout_connect(DEFAULT_TIMEOUT_CONNECT);
|
||||
set_timeout_max(DEFAULT_TIMEOUT_MAX);
|
||||
::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); // curl makes a copy internally
|
||||
::curl_easy_setopt(curl, CURLOPT_USERAGENT, SLIC3R_APP_NAME "/" SLIC3R_VERSION);
|
||||
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer.front());
|
||||
|
|
@ -253,6 +256,11 @@ void Http::priv::set_timeout_connect(long timeout)
|
|||
::curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, timeout);
|
||||
}
|
||||
|
||||
void Http::priv::set_timeout_max(long timeout)
|
||||
{
|
||||
::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
|
||||
}
|
||||
|
||||
void Http::priv::form_add_file(const char *name, const fs::path &path, const char* filename)
|
||||
{
|
||||
// We can't use CURLFORM_FILECONTENT, because curl doesn't support Unicode filenames on Windows
|
||||
|
|
@ -409,6 +417,13 @@ Http& Http::timeout_connect(long timeout)
|
|||
return *this;
|
||||
}
|
||||
|
||||
Http& Http::timeout_max(long timeout)
|
||||
{
|
||||
if (timeout < 1) { timeout = priv::DEFAULT_TIMEOUT_MAX; }
|
||||
if (p) { p->set_timeout_max(timeout); }
|
||||
return *this;
|
||||
}
|
||||
|
||||
Http& Http::size_limit(size_t sizeLimit)
|
||||
{
|
||||
if (p) { p->limit = sizeLimit; }
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ public:
|
|||
|
||||
// Sets a maximum connection timeout in seconds
|
||||
Http& timeout_connect(long timeout);
|
||||
// Sets a maximum total request timeout in seconds
|
||||
Http& timeout_max(long timeout);
|
||||
// Sets a maximum size of the data that can be received.
|
||||
// A value of zero sets the default limit, which is is 5MB.
|
||||
Http& size_limit(size_t sizeLimit);
|
||||
|
|
|
|||
|
|
@ -46,10 +46,6 @@ using Slic3r::GUI::Config::SnapshotDB;
|
|||
namespace Slic3r {
|
||||
|
||||
|
||||
enum {
|
||||
SLIC3R_VERSION_BODY_MAX = 256,
|
||||
};
|
||||
|
||||
static const char *INDEX_FILENAME = "index.idx";
|
||||
static const char *TMP_EXTENSION = ".download";
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ class AppConfig;
|
|||
class PresetBundle;
|
||||
class Semver;
|
||||
|
||||
const int SLIC3R_VERSION_BODY_MAX = 256;
|
||||
|
||||
class PresetUpdater
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue