Custom control: Fixed bitmaps layout under OSX

+ Implemented hyperlinks for parameters labels to the help page
This commit is contained in:
YuSanka 2020-10-29 21:53:33 +01:00 committed by Oleksandra Yushchenko
parent 4dc78a424e
commit 32b8be600c
6 changed files with 187 additions and 140 deletions

View file

@ -1,14 +1,10 @@
#include "OG_CustomCtrl.hpp"
#include "OptionsGroup.hpp"
#include "ConfigExceptions.hpp"
#include "Plater.hpp"
#include "GUI_App.hpp"
#include <utility>
#include <wx/numformatter.h>
#include <wx/utils.h>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include "libslic3r/Exception.hpp"
#include "libslic3r/Utils.hpp"
#include "I18N.hpp"
@ -20,15 +16,6 @@ static bool is_point_in_rect(const wxPoint& pt, const wxRect& rect)
rect.GetTop() <= pt.y && pt.y <= rect.GetBottom();
}
static int get_bitmap_height(const wxBitmap& bmp)
{
#ifdef __APPLE__
return bmp.GetScaledHeight();
#else
return bmp.GetHeight();
#endif
}
static wxSize get_bitmap_size(const wxBitmap& bmp)
{
#ifdef __APPLE__
@ -38,6 +25,13 @@ static wxSize get_bitmap_size(const wxBitmap& bmp)
#endif
}
static wxString get_url(const wxString& path_end)
{
if (path_end.IsEmpty())
return wxEmptyString;
return wxString("https://help.prusa3d.com/") + "en" + "/article/" + path_end;
}
OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent,
OptionsGroup* og,
const wxPoint& pos /* = wxDefaultPosition*/,
@ -216,7 +210,13 @@ void OG_CustomCtrl::OnMotion(wxMouseEvent& event)
const wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
wxString tooltip;
for (const CtrlLine& line : ctrl_lines) {
for (CtrlLine& line : ctrl_lines) {
line.is_focused = is_point_in_rect(pos, line.rect_label);
if (line.is_focused) {
tooltip = get_url(line.og_line.label_path);
break;
}
for (size_t opt_idx = 0; opt_idx < line.rects_undo_icon.size(); opt_idx++)
if (is_point_in_rect(pos, line.rects_undo_icon[opt_idx])) {
const std::vector<Option>& option_set = line.og_line.get_options();
@ -250,6 +250,8 @@ void OG_CustomCtrl::OnLeftDown(wxMouseEvent& event)
const wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
for (const CtrlLine& line : ctrl_lines) {
if (line.launch_browser())
return;
for (size_t opt_idx = 0; opt_idx < line.rects_undo_icon.size(); opt_idx++)
if (is_point_in_rect(pos, line.rects_undo_icon[opt_idx])) {
const std::vector<Option>& option_set = line.og_line.get_options();
@ -347,13 +349,8 @@ OG_CustomCtrl::CtrlLine::CtrlLine( wxCoord height,
og_line(og_line),
draw_just_act_buttons(draw_just_act_buttons)
{
if (og_line.widget) {
rects_blinking.emplace_back(wxRect());
return;
}
for (size_t i = 0; i < og_line.get_options().size(); i++) {
rects_blinking.emplace_back(wxRect());
rects_undo_icon.emplace_back(wxRect());
rects_undo_to_sys_icon.emplace_back(wxRect());
}
@ -387,7 +384,7 @@ void OG_CustomCtrl::CtrlLine::msw_rescale()
{
// if we have a single option with no label, no sidetext
if (draw_just_act_buttons)
height = get_bitmap_height(create_scaled_bitmap("empty"));
height = get_bitmap_size(create_scaled_bitmap("empty")).GetHeight();
if (ctrl->opt_group->label_width != 0 && !og_line.label.IsEmpty()) {
wxSize label_sz = ctrl->GetTextExtent(og_line.label);
@ -456,9 +453,11 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
const std::vector<Option>& option_set = og_line.get_options();
wxString label = og_line.label;
bool is_url_string = false;
if (ctrl->opt_group->label_width != 0 && !label.IsEmpty()) {
const wxColour* text_clr = (option_set.size() == 1 && field ? field->label_color() : og_line.full_Label_color);
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label + ":", text_clr, ctrl->opt_group->label_width * ctrl->m_em_unit);
is_url_string = !og_line.label_path.IsEmpty();
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label + ":", text_clr, ctrl->opt_group->label_width * ctrl->m_em_unit, is_url_string);
}
// If there's a widget, build it and set result to the correct position.
@ -481,7 +480,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
}
size_t bmp_rect_id = 0;
for (auto opt : option_set) {
for (const Option& opt : option_set) {
field = ctrl->opt_group->get_field(opt.opt_id);
ConfigOptionDef option = opt.opt;
// add label if any
@ -491,7 +490,11 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
_CTX(option.label, "Layers") : _(option.label);
label += ":";
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label, field ? field->label_color() : nullptr, ctrl->opt_group->sublabel_width * ctrl->m_em_unit);
if (is_url_string)
is_url_string = false;
else if(opt == option_set.front())
is_url_string = !og_line.label_path.IsEmpty();
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label, field ? field->label_color() : nullptr, ctrl->opt_group->sublabel_width * ctrl->m_em_unit, is_url_string);
}
if (field && field->undo_to_sys_bitmap()) {
@ -526,14 +529,14 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_mode_bmp(wxDC& dc, wxCoord v_pos)
const std::string& bmp_name = mode == ConfigOptionMode::comSimple ? "mode_simple" :
mode == ConfigOptionMode::comAdvanced ? "mode_advanced" : "mode_expert";
wxBitmap bmp = create_scaled_bitmap(bmp_name, ctrl, wxOSX ? 10 : 12);
wxCoord y_draw = v_pos + lround((height - get_bitmap_height(bmp)) / 2);
wxCoord y_draw = v_pos + lround((height - get_bitmap_size(bmp).GetHeight()) / 2);
dc.DrawBitmap(bmp, 0, y_draw);
return bmp.GetWidth() + ctrl->m_h_gap;
return get_bitmap_size(bmp).GetWidth() + ctrl->m_h_gap;
}
wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width)
wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url/* = false*/)
{
wxString multiline_text;
if (width > 0 && dc.GetTextExtent(text).x > width) {
@ -560,19 +563,32 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxStr
multiline_text[idx] = '\n';
}
const wxString& out_text = multiline_text.IsEmpty() ? text : multiline_text;
wxCoord text_width, text_height;
dc.GetMultiLineTextExtent(out_text, &text_width, &text_height);
if (!text.IsEmpty()) {
const wxString& out_text = multiline_text.IsEmpty() ? text : multiline_text;
wxCoord text_width, text_height;
dc.GetMultiLineTextExtent(out_text, &text_width, &text_height);
pos.y = pos.y + lround((height - text_height) / 2);
wxColour old_clr = dc.GetTextForeground();
dc.SetTextForeground(color ? *color : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
dc.DrawText(out_text, pos);
dc.SetTextForeground(old_clr);
pos.y = pos.y + lround((height - text_height) / 2);
if (width > 0 && is_url)
rect_label = wxRect(pos, wxSize(text_width, text_height));
if (width < 1)
width = text_width;
wxColour old_clr = dc.GetTextForeground();
wxFont old_font = dc.GetFont();
if (is_focused && is_url)
// temporary workaround for the OSX because of strange Bold font behavior on BigSerf
#ifdef __APPLE__
dc.SetFont(old_font.Underlined());
#else
dc.SetFont(old_font.Bold().Underlined());
#endif
dc.SetTextForeground(color ? *color : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
dc.DrawText(out_text, pos);
dc.SetTextForeground(old_clr);
dc.SetFont(old_font);
if (width < 1)
width = text_width;
}
return pos.x + width + ctrl->m_h_gap;
}
@ -581,12 +597,11 @@ wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool i
{
wxBitmap bmp_blinking = create_scaled_bitmap(is_blinking ? "search_blink" : "empty", ctrl);
wxCoord h_pos = pos.x;
wxCoord v_pos = pos.y + lround((height - get_bitmap_height(bmp_blinking)) / 2);
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking).GetHeight()) / 2);
dc.DrawBitmap(bmp_blinking, h_pos, v_pos);
int bmp_dim = bmp_blinking.GetWidth();
rects_blinking[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
int bmp_dim = get_bitmap_size(bmp_blinking).GetWidth();
h_pos += bmp_dim + ctrl->m_h_gap;
return wxPoint(h_pos, v_pos);
@ -600,13 +615,13 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi
dc.DrawBitmap(bmp_undo_to_sys, h_pos, v_pos);
int bmp_dim = bmp_undo_to_sys.GetWidth();
int bmp_dim = get_bitmap_size(bmp_undo_to_sys).GetWidth();
rects_undo_to_sys_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
h_pos += bmp_dim + ctrl->m_h_gap;
dc.DrawBitmap(bmp_undo, h_pos, v_pos);
bmp_dim = bmp_undo.GetWidth();
bmp_dim = get_bitmap_size(bmp_undo).GetWidth();
rects_undo_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
h_pos += bmp_dim + ctrl->m_h_gap;
@ -614,5 +629,15 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi
return h_pos;
}
bool OG_CustomCtrl::CtrlLine::launch_browser() const
{
if (is_focused && !og_line.label_path.IsEmpty()) {
wxLaunchDefaultBrowser(get_url(og_line.label_path));
return true;
}
return false;
}
} // GUI
} // Slic3r

View file

@ -42,6 +42,7 @@ class OG_CustomCtrl :public wxControl
bool draw_just_act_buttons { false };
bool is_visible { true };
bool is_focused { false };
CtrlLine( wxCoord height,
OG_CustomCtrl* ctrl,
@ -55,13 +56,14 @@ class OG_CustomCtrl :public wxControl
void render(wxDC& dc, wxCoord v_pos);
wxCoord draw_mode_bmp(wxDC& dc, wxCoord v_pos);
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width);
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false);
wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking, size_t rect_id = 0);
wxCoord draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id = 0);
bool launch_browser() const;
std::vector<wxRect> rects_blinking;
std::vector<wxRect> rects_undo_icon;
std::vector<wxRect> rects_undo_to_sys_icon;
wxRect rect_label;
};
std::vector<CtrlLine> ctrl_lines;

View file

@ -471,11 +471,12 @@ void OptionsGroup::clear(bool destroy_custom_ctrl)
m_fields.clear();
}
Line OptionsGroup::create_single_option_line(const Option& option) const {
Line OptionsGroup::create_single_option_line(const Option& option, const wxString& path/* = wxEmptyString*/) const {
// Line retval{ _(option.opt.label), _(option.opt.tooltip) };
wxString tooltip = _(option.opt.tooltip);
edit_tooltip(tooltip);
Line retval{ _(option.opt.label), tooltip };
retval.label_path = path;
Option tmp(option);
tmp.opt.label = std::string("");
retval.append_option(tmp);

View file

@ -41,6 +41,10 @@ struct Option {
widget_t side_widget {nullptr};
bool readonly {false};
bool operator==(const Option& rhs) const {
return (rhs.opt_id == this->opt_id);
}
Option(const ConfigOptionDef& _opt, t_config_option_key id) :
opt(_opt), opt_id(id) {}
};
@ -49,8 +53,10 @@ using t_option = std::unique_ptr<Option>; //!
/// Represents option lines
class Line {
public:
wxString label {wxString("")};
wxString label_tooltip {wxString("")};
wxString label;
wxString label_tooltip;
wxString label_path;
size_t full_width {0};
wxStaticText** full_Label {nullptr};
wxColour* full_Label_color {nullptr};
@ -139,8 +145,8 @@ public:
// delete all controls from the option group
void clear(bool destroy_custom_ctrl = false);
Line create_single_option_line(const Option& option) const;
void append_single_option_line(const Option& option) { append_line(create_single_option_line(option)); }
Line create_single_option_line(const Option& option, const wxString& path = wxEmptyString) const;
void append_single_option_line(const Option& option, const wxString& path = wxEmptyString) { append_line(create_single_option_line(option, path)); }
// return a non-owning pointer reference
inline Field* get_field(const t_config_option_key& id) const{
@ -258,20 +264,20 @@ public:
void set_config_category(const std::string &category) { this->m_config_category = category; }
void set_config(DynamicPrintConfig* config) { m_config = config; m_modelconfig = nullptr; }
Option get_option(const std::string& opt_key, int opt_index = -1);
Line create_single_option_line(const std::string& title, int idx = -1) /*const*/{
Line create_single_option_line(const std::string& title, const wxString& path = wxEmptyString, int idx = -1) /*const*/{
Option option = get_option(title, idx);
return OptionsGroup::create_single_option_line(option);
return OptionsGroup::create_single_option_line(option, path);
}
Line create_single_option_line(const Option& option) const {
return OptionsGroup::create_single_option_line(option);
Line create_single_option_line(const Option& option, const wxString& path = wxEmptyString) const {
return OptionsGroup::create_single_option_line(option, path);
}
void append_single_option_line(const Option& option) {
OptionsGroup::append_single_option_line(option);
void append_single_option_line(const Option& option, const wxString& path = wxEmptyString) {
OptionsGroup::append_single_option_line(option, path);
}
void append_single_option_line(const std::string title, int idx = -1)
void append_single_option_line(const std::string title, const wxString& path = wxEmptyString, int idx = -1)
{
Option option = get_option(title, idx);
append_single_option_line(option);
append_single_option_line(option, path);
}
void on_change_OG(const t_config_option_key& opt_id, const boost::any& value) override;

View file

@ -1428,16 +1428,18 @@ void TabPrint::build()
load_initial_data();
auto page = add_options_page(L("Layers and perimeters"), "layers");
wxString category_path = "layers-and-perimeters_1748#";
auto optgroup = page->new_optgroup(L("Layer height"));
optgroup->append_single_option_line("layer_height");
optgroup->append_single_option_line("first_layer_height");
optgroup->append_single_option_line("layer_height", category_path + "layer-height");
optgroup->append_single_option_line("first_layer_height", category_path + "first-layer-height");
optgroup = page->new_optgroup(L("Vertical shells"));
optgroup->append_single_option_line("perimeters");
optgroup->append_single_option_line("spiral_vase");
optgroup->append_single_option_line("perimeters", category_path + "perimeters");
optgroup->append_single_option_line("spiral_vase", category_path + "spiral-vase");
Line line { "", "" };
line.full_width = 1;
line.label_path = category_path + "recommended-thin-wall-thickness";
line.widget = [this](wxWindow* parent) {
return description_line_widget(parent, &m_recommended_thin_wall_thickness_description_line);
};
@ -1445,6 +1447,7 @@ void TabPrint::build()
optgroup = page->new_optgroup(L("Horizontal shells"));
line = { L("Solid layers"), "" };
line.label_path = category_path + "solid-layers-top-bottom";
line.append_option(optgroup->get_option("top_solid_layers"));
line.append_option(optgroup->get_option("bottom_solid_layers"));
optgroup->append_line(line);
@ -1460,22 +1463,23 @@ void TabPrint::build()
optgroup->append_line(line);
optgroup = page->new_optgroup(L("Quality (slower slicing)"));
optgroup->append_single_option_line("extra_perimeters");
optgroup->append_single_option_line("ensure_vertical_shell_thickness");
optgroup->append_single_option_line("avoid_crossing_perimeters");
optgroup->append_single_option_line("thin_walls");
optgroup->append_single_option_line("overhangs");
optgroup->append_single_option_line("extra_perimeters", category_path + "extra-perimeters-if-needed");
optgroup->append_single_option_line("ensure_vertical_shell_thickness", category_path + "ensure-vertical-shell-thickness");
optgroup->append_single_option_line("avoid_crossing_perimeters", category_path + "avoid-crossing-perimeters");
optgroup->append_single_option_line("thin_walls", category_path + "detect-thin-walls");
optgroup->append_single_option_line("overhangs", category_path + "detect-bridging-perimeters");
optgroup = page->new_optgroup(L("Advanced"));
optgroup->append_single_option_line("seam_position");
optgroup->append_single_option_line("external_perimeters_first");
optgroup->append_single_option_line("seam_position", category_path + "seam-position");
optgroup->append_single_option_line("external_perimeters_first", category_path + "external-perimeters-first");
page = add_options_page(L("Infill"), "infill");
category_path = "infill_42#";
optgroup = page->new_optgroup(L("Infill"));
optgroup->append_single_option_line("fill_density");
optgroup->append_single_option_line("fill_pattern");
optgroup->append_single_option_line("top_fill_pattern");
optgroup->append_single_option_line("bottom_fill_pattern");
optgroup->append_single_option_line("fill_density", category_path + "fill-density");
optgroup->append_single_option_line("fill_pattern", category_path + "fill-pattern");
optgroup->append_single_option_line("top_fill_pattern", category_path + "top-fill-pattern");
optgroup->append_single_option_line("bottom_fill_pattern", category_path + "bottom-fill-pattern");
optgroup = page->new_optgroup(L("Ironing"));
optgroup->append_single_option_line("ironing");
@ -1484,52 +1488,54 @@ void TabPrint::build()
optgroup->append_single_option_line("ironing_spacing");
optgroup = page->new_optgroup(L("Reducing printing time"));
optgroup->append_single_option_line("infill_every_layers");
optgroup->append_single_option_line("infill_only_where_needed");
optgroup->append_single_option_line("infill_every_layers", category_path + "combine-infill-every-x-layers");
optgroup->append_single_option_line("infill_only_where_needed", category_path + "only-infill-where-needed");
optgroup = page->new_optgroup(L("Advanced"));
optgroup->append_single_option_line("solid_infill_every_layers");
optgroup->append_single_option_line("fill_angle");
optgroup->append_single_option_line("solid_infill_below_area");
optgroup->append_single_option_line("solid_infill_every_layers", category_path + "solid-infill-every-x-layers");
optgroup->append_single_option_line("fill_angle", category_path + "fill-angle");
optgroup->append_single_option_line("solid_infill_below_area", category_path + "solid-infill-threshold-area");
optgroup->append_single_option_line("bridge_angle");
optgroup->append_single_option_line("only_retract_when_crossing_perimeters");
optgroup->append_single_option_line("infill_first");
page = add_options_page(L("Skirt and brim"), "skirt+brim");
category_path = "skirt-and-brim_133969#";
optgroup = page->new_optgroup(L("Skirt"));
optgroup->append_single_option_line("skirts");
optgroup->append_single_option_line("skirt_distance");
optgroup->append_single_option_line("skirt_height");
optgroup->append_single_option_line("draft_shield");
optgroup->append_single_option_line("min_skirt_length");
optgroup->append_single_option_line("skirts", category_path + "skirt");
optgroup->append_single_option_line("skirt_distance", category_path + "skirt");
optgroup->append_single_option_line("skirt_height", category_path + "skirt");
optgroup->append_single_option_line("draft_shield", category_path + "skirt");
optgroup->append_single_option_line("min_skirt_length", category_path + "skirt");
optgroup = page->new_optgroup(L("Brim"));
optgroup->append_single_option_line("brim_width");
optgroup->append_single_option_line("brim_width", category_path + "brim");
page = add_options_page(L("Support material"), "support");
category_path = "support-material_1698#";
optgroup = page->new_optgroup(L("Support material"));
optgroup->append_single_option_line("support_material");
optgroup->append_single_option_line("support_material_auto");
optgroup->append_single_option_line("support_material_threshold");
optgroup->append_single_option_line("support_material_enforce_layers");
optgroup->append_single_option_line("support_material", category_path + "generate-support-material");
optgroup->append_single_option_line("support_material_auto", category_path + "auto-generated-supports");
optgroup->append_single_option_line("support_material_threshold", category_path + "overhang-threshold");
optgroup->append_single_option_line("support_material_enforce_layers", category_path + "enforce-support-for-the-first");
optgroup = page->new_optgroup(L("Raft"));
optgroup->append_single_option_line("raft_layers");
optgroup->append_single_option_line("raft_layers", category_path + "raft-layers");
// # optgroup->append_single_option_line(get_option_("raft_contact_distance");
optgroup = page->new_optgroup(L("Options for support material and raft"));
optgroup->append_single_option_line("support_material_contact_distance");
optgroup->append_single_option_line("support_material_pattern");
optgroup->append_single_option_line("support_material_with_sheath");
optgroup->append_single_option_line("support_material_spacing");
optgroup->append_single_option_line("support_material_angle");
optgroup->append_single_option_line("support_material_interface_layers");
optgroup->append_single_option_line("support_material_interface_spacing");
optgroup->append_single_option_line("support_material_interface_contact_loops");
optgroup->append_single_option_line("support_material_buildplate_only");
optgroup->append_single_option_line("support_material_xy_spacing");
optgroup->append_single_option_line("dont_support_bridges");
optgroup->append_single_option_line("support_material_synchronize_layers");
optgroup->append_single_option_line("support_material_contact_distance", category_path + "contact-z-distance");
optgroup->append_single_option_line("support_material_pattern", category_path + "pattern");
optgroup->append_single_option_line("support_material_with_sheath", category_path + "with-sheath-around-the-support");
optgroup->append_single_option_line("support_material_spacing", category_path + "pattern-spacing-0-inf");
optgroup->append_single_option_line("support_material_angle", category_path + "pattern-angle");
optgroup->append_single_option_line("support_material_interface_layers", category_path + "interface-layers");
optgroup->append_single_option_line("support_material_interface_spacing", category_path + "interface-pattern-spacing");
optgroup->append_single_option_line("support_material_interface_contact_loops", category_path + "interface-loops");
optgroup->append_single_option_line("support_material_buildplate_only", category_path + "support-on-build-plate-only");
optgroup->append_single_option_line("support_material_xy_spacing", category_path + "xy-separation-between-an-object-and-its-support");
optgroup->append_single_option_line("dont_support_bridges", category_path + "dont-support-bridges");
optgroup->append_single_option_line("support_material_synchronize_layers", category_path + "synchronize-with-object-layers");
page = add_options_page(L("Speed"), "time");
optgroup = page->new_optgroup(L("Speed for print moves"));
@ -1559,8 +1565,8 @@ void TabPrint::build()
optgroup->append_single_option_line("default_acceleration");
optgroup = page->new_optgroup(L("Autospeed (advanced)"));
optgroup->append_single_option_line("max_print_speed");
optgroup->append_single_option_line("max_volumetric_speed");
optgroup->append_single_option_line("max_print_speed", "max-volumetric-speed_127176");
optgroup->append_single_option_line("max_volumetric_speed", "max-volumetric-speed_127176");
#ifdef HAS_PRESSURE_EQUALIZER
optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_positive");
optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_negative");
@ -1612,14 +1618,14 @@ void TabPrint::build()
optgroup->append_single_option_line("slice_closing_radius");
optgroup->append_single_option_line("resolution");
optgroup->append_single_option_line("xy_size_compensation");
optgroup->append_single_option_line("elefant_foot_compensation");
optgroup->append_single_option_line("elefant_foot_compensation", "elephant-foot-compensation_114487");
optgroup = page->new_optgroup(L("Other"));
optgroup->append_single_option_line("clip_multipart_objects");
page = add_options_page(L("Output options"), "output+page_white");
optgroup = page->new_optgroup(L("Sequential printing"));
optgroup->append_single_option_line("complete_objects");
optgroup->append_single_option_line("complete_objects", "sequential-printing_124589");
line = { L("Extruder clearance (mm)"), "" };
line.append_option(optgroup->get_option("extruder_clearance_radius"));
line.append_option(optgroup->get_option("extruder_clearance_height"));
@ -1648,7 +1654,7 @@ void TabPrint::build()
page = add_options_page(L("Dependencies"), "wrench.png");
optgroup = page->new_optgroup(L("Profile dependencies"));
create_line_with_widget(optgroup.get(), "compatible_printers", [this](wxWindow* parent) {
create_line_with_widget(optgroup.get(), "compatible_printers", wxEmptyString, [this](wxWindow* parent) {
return compatible_widget_create(parent, m_compatible_printers);
});
@ -1848,6 +1854,7 @@ void TabFilament::build()
optgroup->append_line(line);
page = add_options_page(L("Cooling"), "cooling");
wxString category_path = "cooling_127569#";
optgroup = page->new_optgroup(L("Enable"));
optgroup->append_single_option_line("fan_always_on");
optgroup->append_single_option_line("cooling");
@ -1861,17 +1868,18 @@ void TabFilament::build()
optgroup = page->new_optgroup(L("Fan settings"));
line = { L("Fan speed"), "" };
line.label_path = category_path + "fan-settings";
line.append_option(optgroup->get_option("min_fan_speed"));
line.append_option(optgroup->get_option("max_fan_speed"));
optgroup->append_line(line);
optgroup->append_single_option_line("bridge_fan_speed");
optgroup->append_single_option_line("disable_fan_first_layers");
optgroup->append_single_option_line("bridge_fan_speed", category_path + "fan-settings");
optgroup->append_single_option_line("disable_fan_first_layers", category_path + "fan-settings");
optgroup = page->new_optgroup(L("Cooling thresholds"), 25);
optgroup->append_single_option_line("fan_below_layer_time");
optgroup->append_single_option_line("slowdown_below_layer_time");
optgroup->append_single_option_line("min_print_speed");
optgroup->append_single_option_line("fan_below_layer_time", category_path + "cooling-thresholds");
optgroup->append_single_option_line("slowdown_below_layer_time", category_path + "cooling-thresholds");
optgroup->append_single_option_line("min_print_speed", category_path + "cooling-thresholds");
page = add_options_page(L("Advanced"), "wrench");
optgroup = page->new_optgroup(L("Filament properties"));
@ -1882,7 +1890,7 @@ void TabFilament::build()
optgroup->append_single_option_line("filament_soluble");
optgroup = page->new_optgroup(L("Print speed override"));
optgroup->append_single_option_line("filament_max_volumetric_speed");
optgroup->append_single_option_line("filament_max_volumetric_speed", "max-volumetric-speed_127176");
line = { "", "" };
line.full_width = 1;
@ -1906,9 +1914,10 @@ void TabFilament::build()
optgroup->append_single_option_line("filament_cooling_initial_speed");
optgroup->append_single_option_line("filament_cooling_final_speed");
create_line_with_widget(optgroup.get(), "filament_ramming_parameters", [this](wxWindow* parent) {
create_line_with_widget(optgroup.get(), "filament_ramming_parameters", wxEmptyString, [this](wxWindow* parent) {
auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+dots, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
ramming_dialog_btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
ramming_dialog_btn->SetSize(ramming_dialog_btn->GetBestSize());
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(ramming_dialog_btn);
@ -1954,7 +1963,7 @@ void TabFilament::build()
page = add_options_page(L("Dependencies"), "wrench.png");
optgroup = page->new_optgroup(L("Profile dependencies"));
create_line_with_widget(optgroup.get(), "compatible_printers", [this](wxWindow* parent) {
create_line_with_widget(optgroup.get(), "compatible_printers", wxEmptyString, [this](wxWindow* parent) {
return compatible_widget_create(parent, m_compatible_printers);
});
@ -1962,7 +1971,7 @@ void TabFilament::build()
option.opt.full_width = true;
optgroup->append_single_option_line(option);
create_line_with_widget(optgroup.get(), "compatible_prints", [this](wxWindow* parent) {
create_line_with_widget(optgroup.get(), "compatible_prints", wxEmptyString, [this](wxWindow* parent) {
return compatible_widget_create(parent, m_compatible_prints);
});
@ -2118,7 +2127,7 @@ void TabPrinter::build_fff()
auto page = add_options_page(L("General"), "printer");
auto optgroup = page->new_optgroup(L("Size and coordinates"));
create_line_with_widget(optgroup.get(), "bed_shape", [this](wxWindow* parent) {
create_line_with_widget(optgroup.get(), "bed_shape", "custom-svg-and-png-bed-textures_124612", [this](wxWindow* parent) {
return create_bed_shape_widget(parent);
});
@ -2300,7 +2309,7 @@ void TabPrinter::build_sla()
auto page = add_options_page(L("General"), "printer");
auto optgroup = page->new_optgroup(L("Size and coordinates"));
create_line_with_widget(optgroup.get(), "bed_shape", [this](wxWindow* parent) {
create_line_with_widget(optgroup.get(), "bed_shape", "custom-svg-and-png-bed-textures_124612", [this](wxWindow* parent) {
return create_bed_shape_widget(parent);
});
optgroup->append_single_option_line("max_print_height");
@ -2551,7 +2560,7 @@ void TabPrinter::build_unregular_pages()
m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page);
auto optgroup = page->new_optgroup(L("Size"));
optgroup->append_single_option_line("nozzle_diameter", extruder_idx);
optgroup->append_single_option_line("nozzle_diameter", wxEmptyString, extruder_idx);
optgroup->m_on_change = [this, extruder_idx](const t_config_option_key& opt_key, boost::any value)
{
@ -2589,32 +2598,32 @@ void TabPrinter::build_unregular_pages()
};
optgroup = page->new_optgroup(L("Layer height limits"));
optgroup->append_single_option_line("min_layer_height", extruder_idx);
optgroup->append_single_option_line("max_layer_height", extruder_idx);
optgroup->append_single_option_line("min_layer_height", wxEmptyString, extruder_idx);
optgroup->append_single_option_line("max_layer_height", wxEmptyString, extruder_idx);
optgroup = page->new_optgroup(L("Position (for multi-extruder printers)"));
optgroup->append_single_option_line("extruder_offset", extruder_idx);
optgroup->append_single_option_line("extruder_offset", wxEmptyString, extruder_idx);
optgroup = page->new_optgroup(L("Retraction"));
optgroup->append_single_option_line("retract_length", extruder_idx);
optgroup->append_single_option_line("retract_lift", extruder_idx);
optgroup->append_single_option_line("retract_length", wxEmptyString, extruder_idx);
optgroup->append_single_option_line("retract_lift", wxEmptyString, extruder_idx);
Line line = { L("Only lift Z"), "" };
line.append_option(optgroup->get_option("retract_lift_above", extruder_idx));
line.append_option(optgroup->get_option("retract_lift_below", extruder_idx));
optgroup->append_line(line);
optgroup->append_single_option_line("retract_speed", extruder_idx);
optgroup->append_single_option_line("deretract_speed", extruder_idx);
optgroup->append_single_option_line("retract_restart_extra", extruder_idx);
optgroup->append_single_option_line("retract_before_travel", extruder_idx);
optgroup->append_single_option_line("retract_layer_change", extruder_idx);
optgroup->append_single_option_line("wipe", extruder_idx);
optgroup->append_single_option_line("retract_before_wipe", extruder_idx);
optgroup->append_single_option_line("retract_speed", wxEmptyString, extruder_idx);
optgroup->append_single_option_line("deretract_speed", wxEmptyString, extruder_idx);
optgroup->append_single_option_line("retract_restart_extra", wxEmptyString, extruder_idx);
optgroup->append_single_option_line("retract_before_travel", wxEmptyString, extruder_idx);
optgroup->append_single_option_line("retract_layer_change", wxEmptyString, extruder_idx);
optgroup->append_single_option_line("wipe", wxEmptyString, extruder_idx);
optgroup->append_single_option_line("retract_before_wipe", wxEmptyString, extruder_idx);
optgroup = page->new_optgroup(L("Retraction when tool is disabled (advanced settings for multi-extruder setups)"));
optgroup->append_single_option_line("retract_length_toolchange", extruder_idx);
optgroup->append_single_option_line("retract_restart_extra_toolchange", extruder_idx);
optgroup->append_single_option_line("retract_length_toolchange", wxEmptyString, extruder_idx);
optgroup->append_single_option_line("retract_restart_extra_toolchange", wxEmptyString, extruder_idx);
optgroup = page->new_optgroup(L("Preview"));
@ -2625,6 +2634,7 @@ void TabPrinter::build_unregular_pages()
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
ScalableButton* btn = m_reset_to_filament_color;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
btn->SetSize(btn->GetBestSize());
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn);
@ -2643,7 +2653,7 @@ void TabPrinter::build_unregular_pages()
return sizer;
};
line = optgroup->create_single_option_line("extruder_colour", extruder_idx);
line = optgroup->create_single_option_line("extruder_colour", wxEmptyString, extruder_idx);
line.append_widget(reset_to_filament_color);
optgroup->append_line(line);
@ -3562,10 +3572,11 @@ void Tab::update_ui_from_settings()
}
}
void Tab::create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, widget_t widget)
void Tab::create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, const wxString& path, widget_t widget)
{
Line line = optgroup->create_single_option_line(opt_key);
line.widget = widget;
line.label_path = path;
m_colored_Labels[opt_key] = nullptr;
line.full_Label = &m_colored_Labels[opt_key];
@ -3581,9 +3592,10 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
{
deps.checkbox = new wxCheckBox(parent, wxID_ANY, _(L("All")));
deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font());
deps.btn = new ScalableButton(parent, wxID_ANY, "printer_white", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()),
deps.btn = new ScalableButton(parent, wxID_ANY, "printer", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()),
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
deps.btn->SetSize(deps.btn->GetBestSize());
// BlinkingBitmap* bbmp = new BlinkingBitmap(parent);
@ -3660,9 +3672,10 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
// Return a callback to create a TabPrinter widget to edit bed shape
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
{
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "printer_white", " " + _(L("Set")) + " " + dots,
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "printer", " " + _(L("Set")) + " " + dots,
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
btn->SetFont(wxGetApp().normal_font());
btn->SetSize(btn->GetBestSize());
// BlinkingBitmap* bbmp = new BlinkingBitmap(parent);
@ -4040,7 +4053,7 @@ void TabSLAMaterial::build()
page = add_options_page(L("Dependencies"), "wrench.png");
optgroup = page->new_optgroup(L("Profile dependencies"));
create_line_with_widget(optgroup.get(), "compatible_printers", [this](wxWindow* parent) {
create_line_with_widget(optgroup.get(), "compatible_printers", wxEmptyString, [this](wxWindow* parent) {
return compatible_widget_create(parent, m_compatible_printers);
});
@ -4048,7 +4061,7 @@ void TabSLAMaterial::build()
option.opt.full_width = true;
optgroup->append_single_option_line(option);
create_line_with_widget(optgroup.get(), "compatible_prints", [this](wxWindow* parent) {
create_line_with_widget(optgroup.get(), "compatible_prints", wxEmptyString, [this](wxWindow* parent) {
return compatible_widget_create(parent, m_compatible_prints);
});
@ -4171,7 +4184,7 @@ void TabSLAPrint::build()
page = add_options_page(L("Dependencies"), "wrench");
optgroup = page->new_optgroup(L("Profile dependencies"));
create_line_with_widget(optgroup.get(), "compatible_printers", [this](wxWindow* parent) {
create_line_with_widget(optgroup.get(), "compatible_printers", wxEmptyString, [this](wxWindow* parent) {
return compatible_widget_create(parent, m_compatible_printers);
});

View file

@ -363,7 +363,7 @@ public:
const std::map<wxString, std::string>& get_category_icon_map() { return m_category_icon; }
protected:
void create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, widget_t widget);
void create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, const wxString& path, widget_t widget);
wxSizer* compatible_widget_create(wxWindow* parent, PresetDependencies &deps);
void compatible_widget_reload(PresetDependencies &deps);
void load_key_value(const std::string& opt_key, const boost::any& value, bool saved_value = false);