Merge branch 'dev' of https://github.com/prusa3d/PrusaSlicer into et_color_class

This commit is contained in:
enricoturri1966 2022-01-03 09:33:05 +01:00
commit 34a640a4a9
62 changed files with 105759 additions and 126795 deletions

View File

@ -13,6 +13,8 @@ This guide describes building PrusaSlicer statically against dependencies pulled
#### 0. Prerequisities
You need at least 8GB of RAM on your system. Linking on a 4GB RAM system will likely fail and you may need to limit the number of compiler processes with the '-j xxx' make or ninja parameter, where 'xxx' is the number of compiler processes launched if running on low RAM multi core system, for example on Raspberry PI.
GNU build tools, CMake, git and other libraries have to be installed on the build machine.
Unless that's already the case, install them as usual from your distribution packages.
E.g. on Ubuntu 20.10, run
@ -87,6 +89,7 @@ And that's it. It is now possible to run the freshly built PrusaSlicer binary:
- `-DSLIC3R_STATIC=ON` for static build (defaults to `OFF`)
- `-DSLIC3R_WX_STABLE=ON` to look for wxWidgets 3.0 (defaults to `OFF`)
- `-DCMAKE_BUILD_TYPE=Debug` to build in debug mode (defaults to `Release`)
- `-DSLIC3R_GUI=no` to build the console variant of PrusaSlicer
See the CMake files to get the complete list.

View File

@ -34,7 +34,7 @@
#
# Open preferences (might add item to highlight)
# hypertext_type = preferences
# hypertext_preferences_page = 2 (values 0-2 according to prefernces tab to be opened)
# hypertext_preferences_page = name of the prefernces tab
# hypertext_preferences_item = show_collapse_button (name of variable saved in prusaslicer.ini connected to the setting in preferences)
#
# Open gallery (no aditional var)
@ -97,7 +97,7 @@ documentation_link = https://help.prusa3d.com/en/article/reload-from-disk_120427
[hint:Hiding sidebar]
text = Hiding sidebar\nDid you know that you can hide the right sidebar using the shortcut <b>Shift+Tab</b>? You can also enable the icon for this from the<a>Preferences</a>.
hypertext_type = preferences
hypertext_preferences_page = 2
hypertext_preferences_page = GUI
hypertext_preferences_item = show_collapse_button
[hint:Perspective camera]
@ -214,7 +214,7 @@ disabled_tags = SLA
[hint:Settings in non-modal window]
text = Settings in non-modal window\nDid you know that you can open the Settings in a new non-modal window? This means you can have settings open on one screen and the G-code Preview on the other. Go to the<a>Preferences</a>and select Settings in non-modal window.
hypertext_type = preferences
hypertext_preferences_page = 2
hypertext_preferences_page = GUI
hypertext_preferences_item = dlg_settings_layout_mode
[hint:Adaptive infills]

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -450,7 +450,6 @@ msgid "First layer height"
msgstr "Laagdikte eerste laag"
#: src/slic3r/GUI/ConfigManipulation.cpp:82
#, fuzzy, c-format, boost-format
msgid ""
"The Spiral Vase mode requires:\n"
"- one perimeter\n"
@ -11363,7 +11362,6 @@ msgid "Extra perimeters if needed"
msgstr "Extra perimeters indien nodig"
#: src/libslic3r/PrintConfig.cpp:761
#, fuzzy, c-format, boost-format
msgid ""
"Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r "
"keeps adding perimeters, until more than 70% of the loop immediately above "
@ -12546,7 +12544,6 @@ msgid "This setting represents the maximum speed of your fan."
msgstr "Deze instelling gaat over de maximale snelheid van uw ventilator."
#: src/libslic3r/PrintConfig.cpp:1753
#, fuzzy, c-format, boost-format
msgid ""
"This is the highest printable layer height for this extruder, used to cap "
"the variable layer height and support layer height. Maximum recommended "

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -10736,7 +10736,6 @@ msgid "Extra perimeters if needed"
msgstr "Gerekirse fazladan duvar ekle"
#: src/libslic3r/PrintConfig.cpp:761
#, fuzzy, c-format, boost-format
msgid ""
"Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r "
"keeps adding perimeters, until more than 70% of the loop immediately above "
@ -11853,7 +11852,6 @@ msgid "This setting represents the maximum speed of your fan."
msgstr "Bu ayar, fanınızın en fazla hızını gösterir."
#: src/libslic3r/PrintConfig.cpp:1753
#, fuzzy, c-format, boost-format
msgid ""
"This is the highest printable layer height for this extruder, used to cap "
"the variable layer height and support layer height. Maximum recommended "

View File

@ -440,7 +440,6 @@ msgid "First layer height"
msgstr "Висота першого шару"
#: src/slic3r/GUI/ConfigManipulation.cpp:82
#, fuzzy, c-format, boost-format
msgid ""
"The Spiral Vase mode requires:\n"
"- one perimeter\n"
@ -11111,7 +11110,6 @@ msgid "Extra perimeters if needed"
msgstr "Додаткові периметри, якщо необхідно"
#: src/libslic3r/PrintConfig.cpp:761
#, fuzzy, c-format, boost-format
msgid ""
"Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r "
"keeps adding perimeters, until more than 70% of the loop immediately above "
@ -12272,7 +12270,6 @@ msgid "This setting represents the maximum speed of your fan."
msgstr "Цей параметр відображає максимальну швидкість вашого вентилятора."
#: src/libslic3r/PrintConfig.cpp:1753
#, fuzzy, c-format, boost-format
msgid ""
"This is the highest printable layer height for this extruder, used to cap "
"the variable layer height and support layer height. Maximum recommended "

View File

@ -10592,7 +10592,6 @@ msgid "Extra perimeters if needed"
msgstr "如果需要,打印额外轮廓"
#: src/libslic3r/PrintConfig.cpp:761
#, fuzzy, c-format, boost-format
msgid ""
"Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r "
"keeps adding perimeters, until more than 70% of the loop immediately above "
@ -11653,7 +11652,6 @@ msgid "This setting represents the maximum speed of your fan."
msgstr "此设置表示风扇的最大速度。"
#: src/libslic3r/PrintConfig.cpp:1753
#, fuzzy, c-format, boost-format
msgid ""
"This is the highest printable layer height for this extruder, used to cap "
"the variable layer height and support layer height. Maximum recommended "

View File

@ -10533,7 +10533,6 @@ msgid "Extra perimeters if needed"
msgstr "如果需要的話,擴展外圍輪廓"
#: src/libslic3r/PrintConfig.cpp:761
#, fuzzy, c-format, boost-format
msgid ""
"Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r "
"keeps adding perimeters, until more than 70% of the loop immediately above "
@ -11587,7 +11586,6 @@ msgid "This setting represents the maximum speed of your fan."
msgstr "該值表示風扇的最大速度。"
#: src/libslic3r/PrintConfig.cpp:1753
#, fuzzy, c-format, boost-format
msgid ""
"This is the highest printable layer height for this extruder, used to cap "
"the variable layer height and support layer height. Maximum recommended "

View File

@ -1,4 +1,5 @@
min_slic3r_version = 2.4.0-rc
0.1.3 Ender-3 S1 improvements.
0.1.2 Added alpha Ender 3 S1 profiles.
min_slic3r_version = 2.4.0-beta4
0.1.1 Added Ender 2 Pro

View File

@ -5,7 +5,7 @@
name = Creality
# Configuration version of this file. Config file will only be installed, if the config_version differs.
# This means, the server may force the PrusaSlicer configuration to be downgraded.
config_version = 0.1.2
config_version = 0.1.3
# Where to get the updates from?
config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/Creality/
# changelog_url = https://files.prusa3d.com/?latest=slicer-profiles&lng=%1%
@ -914,6 +914,13 @@ pause_print_gcode = M25 ; pause print
[printer:*descendingz*]
end_gcode = {if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+2, max_print_height)} F600{endif} ; Move print bed down\nG1 X50 Y50 F{travel_speed*60} ; move print head out of the way\n{if max_layer_z < max_print_height-10}G1 Z{z_offset+max_print_height-10} F600{endif} ; Move print bed close to the bottom\nM140 S0 ; turn off heatbed\nM104 S0 ; turn off temperature\nM107 ; turn off fan\nM84 X Y E ; disable motors
[printer:*spriteextruder*]
retract_length = 0.8
retract_speed = 30
deretract_speed = 30
retract_before_travel = 1
retract_before_wipe = 0%
# Intended for printers with dual extruders and a single hotend/nozzle, like the CR-X series
[printer:*dualextruder*]
single_extruder_multi_material = 1
@ -962,8 +969,7 @@ printer_model = ENDER3V2
printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_ENDER3V2\nPRINTER_HAS_BOWDEN
[printer:Creality Ender-3 S1]
inherits = *common*; *fastabl*
retract_length = 1
inherits = *common*; *spriteextruder*
bed_shape = 5x0,215x0,215x220,5x220
max_print_height = 270
printer_model = ENDER3S1

File diff suppressed because it is too large Load Diff

View File

@ -1212,6 +1212,9 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
if ((initial_extruder_id = tool_ordering.first_extruder()) != static_cast<unsigned int>(-1))
break;
}
if (initial_extruder_id == static_cast<unsigned int>(-1))
// No object to print was found, cancel the G-code export.
throw Slic3r::SlicingError(_(L("No extrusions were generated for objects.")));
// We don't allow switching of extruders per layer by Model::custom_gcode_per_print_z in sequential mode.
// Use the extruder IDs collected from Regions.
this->set_extruders(print.extruders());
@ -1220,6 +1223,9 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
// If the tool ordering has been pre-calculated by Print class for wipe tower already, reuse it.
tool_ordering = print.tool_ordering();
tool_ordering.assign_custom_gcodes(print);
if (tool_ordering.all_extruders().empty())
// No object to print was found, cancel the G-code export.
throw Slic3r::SlicingError(_(L("No extrusions were generated for objects.")));
has_wipe_tower = print.has_wipe_tower() && tool_ordering.has_wipe_tower();
initial_extruder_id = (has_wipe_tower && ! print.config().single_extruder_multi_material_priming) ?
// The priming towers will be skipped.

View File

@ -101,7 +101,7 @@ std::string GCodeWriter::set_temperature(unsigned int temperature, bool wait, in
}
gcode << temperature;
bool multiple_tools = this->multiple_extruders && ! m_single_extruder_multi_material;
if (tool != -1 && (multiple_tools || FLAVOR_IS(gcfMakerWare) || FLAVOR_IS(gcfSailfish)) ) {
if (tool != -1 && (multiple_tools || FLAVOR_IS(gcfMakerWare) || FLAVOR_IS(gcfSailfish) || FLAVOR_IS(gcfRepRapFirmware)) ) {
if (FLAVOR_IS(gcfRepRapFirmware)) {
gcode << " P" << tool;
} else {

View File

@ -116,6 +116,8 @@ public:
// This type is here to support PresetConfigSubstitutions for physical printers, however it does not belong to the Preset class,
// PhysicalPrinter class is used instead.
TYPE_PHYSICAL_PRINTER,
// This type is here to support search through the Preferences
TYPE_PREFERENCES,
};
Type type = TYPE_INVALID;

View File

@ -336,6 +336,8 @@ PrintObjectSupportMaterial::PrintObjectSupportMaterial(const PrintObject *object
m_support_params.support_layer_height_min = 1000000.;
for (auto lh : m_print_config->min_layer_height.values)
m_support_params.support_layer_height_min = std::min(m_support_params.support_layer_height_min, std::max(0.01, lh));
for (auto layer : m_object->layers())
m_support_params.support_layer_height_min = std::min(m_support_params.support_layer_height_min, std::max(0.01, layer->height));
if (m_object_config->support_material_interface_layers.value == 0) {
// No interface layers allowed, print everything with the base support pattern.

View File

@ -336,7 +336,8 @@ protected:
int m_orig_size_indices = 0;
std::unique_ptr<Cursor> m_cursor;
float m_old_cursor_radius_sqr;
// Zero indicates an uninitialized state.
float m_old_cursor_radius_sqr = 0;
// Private functions:
private:

View File

@ -2919,8 +2919,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
}
p->any_sla_selected = p->check_sla_selected();
if (p->only_sla_mode)
p->any_fff_selected = p->check_fff_selected();
p->any_fff_selected = ! p->only_sla_mode && p->check_fff_selected();
p->update_materials(T_ANY);
if (!p->only_sla_mode)

View File

@ -75,9 +75,19 @@ static std::vector<std::array<float, 4>> decode_colors(const std::vector<std::st
}
#endif // !ENABLE_COLOR_CLASSES
static float round_to_nearest_percent(float value)
// Round to a bin with minimum two digits resolution.
// Equivalent to conversion to string with sprintf(buf, "%.2g", value) and conversion back to float, but faster.
static float round_to_bin(const float value)
{
return std::round(value * 100.f) * 0.01f;
// assert(value > 0);
constexpr float const scale [5] = { 100.f, 1000.f, 10000.f, 100000.f, 1000000.f };
constexpr float const invscale [5] = { 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f };
constexpr float const threshold[5] = { 0.095f, 0.0095f, 0.00095f, 0.000095f, 0.0000095f };
// Scaling factor, pointer to the tables above.
int i = 0;
// While the scaling factor is not yet large enough to get two integer digits after scaling and rounding:
for (; value < threshold[i] && i < 4; ++ i) ;
return std::round(value * scale[i]) * invscale[i];
}
void GCodeViewer::VBuffer::reset()
@ -140,7 +150,7 @@ bool GCodeViewer::Path::matches(const GCodeProcessorResult::MoveVertex& move) co
// use rounding to reduce the number of generated paths
return type == move.type && extruder_id == move.extruder_id && cp_color_id == move.cp_color_id && role == move.extrusion_role &&
move.position.z() <= sub_paths.front().first.position.z() && feedrate == move.feedrate && fan_speed == move.fan_speed &&
height == round_to_nearest_percent(move.height) && width == round_to_nearest_percent(move.width) &&
height == round_to_bin(move.height) && width == round_to_bin(move.width) &&
matches_percent(volumetric_rate, move.volumetric_rate(), 0.05f);
}
case EMoveType::Travel: {
@ -173,7 +183,7 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessorResult::MoveVertex& move
Path::Endpoint endpoint = { b_id, i_id, s_id, move.position };
// use rounding to reduce the number of generated paths
paths.push_back({ move.type, move.extrusion_role, move.delta_extruder,
round_to_nearest_percent(move.height), round_to_nearest_percent(move.width),
round_to_bin(move.height), round_to_bin(move.width),
move.feedrate, move.fan_speed, move.temperature,
move.volumetric_rate(), move.extruder_id, move.cp_color_id, { { endpoint, endpoint } } });
}
@ -799,12 +809,12 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
{
case EMoveType::Extrude:
{
m_extrusions.ranges.height.update_from(round_to_nearest_percent(curr.height));
m_extrusions.ranges.width.update_from(round_to_nearest_percent(curr.width));
m_extrusions.ranges.height.update_from(round_to_bin(curr.height));
m_extrusions.ranges.width.update_from(round_to_bin(curr.width));
m_extrusions.ranges.fan_speed.update_from(curr.fan_speed);
m_extrusions.ranges.temperature.update_from(curr.temperature);
if (curr.extrusion_role != erCustom || is_visible(erCustom))
m_extrusions.ranges.volumetric_rate.update_from(round_to_nearest_percent(curr.volumetric_rate()));
m_extrusions.ranges.volumetric_rate.update_from(round_to_bin(curr.volumetric_rate()));
[[fallthrough]];
}
case EMoveType::Travel:

View File

@ -4022,8 +4022,11 @@ bool GLCanvas3D::_render_search_list(float pos_x)
action_taken = true;
else
sidebar.jump_to_option(selected);*/
if (selected != 9999)
if (selected != 9999) {
imgui->end(); // end imgui before the jump to option
sidebar.jump_to_option(selected);
return true;
}
action_taken = true;
}

View File

@ -1391,24 +1391,41 @@ void GUI_App::update_label_colours()
tab->update_label_colours();
}
static bool is_focused(HWND hWnd)
{
HWND hFocusedWnd = ::GetFocus();
return hFocusedWnd && hWnd == hFocusedWnd;
}
void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool just_font/* = false*/)
{
#ifdef _WIN32
bool is_focused_button = false;
if (wxButton* btn = dynamic_cast<wxButton*>(window)) {
if (!(btn->GetWindowStyle() & wxNO_BORDER)) {
btn->SetWindowStyle(btn->GetWindowStyle() | wxNO_BORDER);
highlited = true;
}
// hovering for buttons
// button marking
{
auto focus_button = [this, btn](const bool focus) {
btn->SetForegroundColour(focus ? m_color_hovered_btn_label : m_color_label_default);
auto mark_button = [this, btn, highlited](const bool mark) {
if (btn->GetLabel().IsEmpty())
btn->SetBackgroundColour(mark ? m_color_selected_btn_bg : highlited ? m_color_highlight_default : m_color_window_default);
else
btn->SetForegroundColour(mark ? m_color_hovered_btn_label : m_color_label_default);
btn->Refresh();
btn->Update();
};
btn->Bind(wxEVT_ENTER_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(true); event.Skip(); });
btn->Bind(wxEVT_LEAVE_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(false); event.Skip(); });
// hovering
btn->Bind(wxEVT_ENTER_WINDOW, [mark_button](wxMouseEvent& event) { mark_button(true); event.Skip(); });
btn->Bind(wxEVT_LEAVE_WINDOW, [mark_button, btn](wxMouseEvent& event) { mark_button(is_focused(btn->GetHWND())); event.Skip(); });
// focusing
btn->Bind(wxEVT_SET_FOCUS, [mark_button](wxFocusEvent& event) { mark_button(true); event.Skip(); });
btn->Bind(wxEVT_KILL_FOCUS, [mark_button](wxFocusEvent& event) { mark_button(false); event.Skip(); });
if (is_focused_button = is_focused(btn->GetHWND()))
mark_button(true);
}
}
else if (wxTextCtrl* text = dynamic_cast<wxTextCtrl*>(window)) {
@ -1430,7 +1447,8 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
if (!just_font)
window->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
window->SetForegroundColour(m_color_label_default);
if (!is_focused_button)
window->SetForegroundColour(m_color_label_default);
#endif
}
@ -1746,6 +1764,7 @@ void GUI_App::update_ui_from_settings()
m_force_colors_update = false;
mainframe->force_color_changed();
mainframe->diff_dialog.force_color_changed();
mainframe->preferences_dialog->force_color_changed();
mainframe->printhost_queue_dlg()->force_color_changed();
#ifdef _MSW_DARK_MODE
update_scrolls(mainframe);
@ -2266,40 +2285,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
break;
case ConfigMenuPreferences:
{
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);
dlg.ShowModal();
app_layout_changed = dlg.settings_layout_changed();
if (dlg.seq_top_layer_only_changed())
this->plater_->refresh_print();
if (dlg.recreate_GUI()) {
recreate_GUI(_L("Restart application") + dots);
return;
}
#ifdef _WIN32
if (is_editor()) {
if (app_config->get("associate_3mf") == "1")
associate_3mf_files();
if (app_config->get("associate_stl") == "1")
associate_stl_files();
}
else {
if (app_config->get("associate_gcode") == "1")
associate_gcode_files();
}
#endif // _WIN32
}
if (app_layout_changed) {
// hide full main_sizer for mainFrame
mainframe->GetSizer()->Show(false);
mainframe->update_layout();
mainframe->select_tab(size_t(0));
}
open_preferences();
break;
}
case ConfigMenuLanguage:
@ -2347,36 +2333,34 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
menu->Append(local_menu, _L("&Configuration"));
}
void GUI_App::open_preferences(size_t open_on_tab, const std::string& highlight_option)
void GUI_App::open_preferences(const std::string& highlight_option /*= std::string()*/, const std::string& tab_name/*= std::string()*/)
{
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, highlight_option);
dlg.ShowModal();
app_layout_changed = dlg.settings_layout_changed();
mainframe->preferences_dialog->show(highlight_option, tab_name);
if (mainframe->preferences_dialog->recreate_GUI())
recreate_GUI(_L("Restart application") + dots);
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
#else
if (dlg.seq_top_layer_only_changed())
if (mainframe->preferences_dialog->seq_top_layer_only_changed())
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
this->plater_->refresh_print();
this->plater_->refresh_print();
#ifdef _WIN32
if (is_editor()) {
if (app_config->get("associate_3mf") == "1")
associate_3mf_files();
if (app_config->get("associate_stl") == "1")
associate_stl_files();
}
else {
if (app_config->get("associate_gcode") == "1")
associate_gcode_files();
}
#endif // _WIN32
if (is_editor()) {
if (app_config->get("associate_3mf") == "1")
associate_3mf_files();
if (app_config->get("associate_stl") == "1")
associate_stl_files();
}
if (app_layout_changed) {
else {
if (app_config->get("associate_gcode") == "1")
associate_gcode_files();
}
#endif // _WIN32
if (mainframe->preferences_dialog->settings_layout_changed()) {
// hide full main_sizer for mainFrame
mainframe->GetSizer()->Show(false);
mainframe->update_layout();

View File

@ -264,7 +264,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, const std::string& highlight_option = std::string());
void open_preferences(const std::string& highlight_option = std::string(), const std::string& tab_name = std::string());
virtual bool OnExceptionInMainLoop() override;
// Calls wxLaunchDefaultBrowser if user confirms in dialog.

View File

@ -1398,6 +1398,18 @@ void ObjectList::load_subobject(ModelVolumeType type, bool from_galery/* = false
if (m_objects_model->GetItemType(item)&itInstance)
item = m_objects_model->GetItemById(obj_idx);
wxArrayString input_files;
if (from_galery) {
GalleryDialog dlg(this);
if (dlg.ShowModal() != wxID_CLOSE)
dlg.get_input_files(input_files);
}
else
wxGetApp().import_model(wxGetApp().tab_panel()->GetPage(0), input_files);
if (input_files.IsEmpty())
return;
take_snapshot((type == ModelVolumeType::MODEL_PART) ? _L("Load Part") : _L("Load Modifier"));
std::vector<ModelVolume*> volumes;
@ -1406,7 +1418,7 @@ void ObjectList::load_subobject(ModelVolumeType type, bool from_galery/* = false
if (type == ModelVolumeType::MODEL_PART)
load_part(*(*m_objects)[obj_idx], volumes, type, from_galery);
else*/
load_modifier(*(*m_objects)[obj_idx], volumes, type, from_galery);
load_modifier(input_files, *(*m_objects)[obj_idx], volumes, type, from_galery);
if (volumes.empty())
return;
@ -1486,7 +1498,7 @@ void ObjectList::load_part(ModelObject& model_object, std::vector<ModelVolume*>&
}
}
*/
void ObjectList::load_modifier(ModelObject& model_object, std::vector<ModelVolume*>& added_volumes, ModelVolumeType type, bool from_galery)
void ObjectList::load_modifier(const wxArrayString& input_files, ModelObject& model_object, std::vector<ModelVolume*>& added_volumes, ModelVolumeType type, bool from_galery)
{
// ! ysFIXME - delete commented code after testing and rename "load_modifier" to something common
//if (type == ModelVolumeType::MODEL_PART)
@ -1494,19 +1506,6 @@ void ObjectList::load_modifier(ModelObject& model_object, std::vector<ModelVolum
wxWindow* parent = wxGetApp().tab_panel()->GetPage(0);
wxArrayString input_files;
if (from_galery) {
GalleryDialog dlg(this);
if (dlg.ShowModal() == wxID_CLOSE)
return;
dlg.get_input_files(input_files);
if (input_files.IsEmpty())
return;
}
else
wxGetApp().import_model(parent, input_files);
wxProgressDialog dlg(_L("Loading") + dots, "", 100, wxGetApp().mainframe, wxPD_AUTO_HIDE);
wxBusyCursor busy;

View File

@ -251,7 +251,7 @@ public:
void load_subobject(ModelVolumeType type, bool from_galery = false);
// ! ysFIXME - delete commented code after testing and rename "load_modifier" to something common
//void load_part(ModelObject& model_object, std::vector<ModelVolume*>& added_volumes, ModelVolumeType type, bool from_galery = false);
void load_modifier(ModelObject& model_object, std::vector<ModelVolume*>& added_volumes, ModelVolumeType type, bool from_galery = false);
void load_modifier(const wxArrayString& input_files, ModelObject& model_object, std::vector<ModelVolume*>& added_volumes, ModelVolumeType type, bool from_galery = false);
void load_generic_subobject(const std::string& type_name, const ModelVolumeType type);
void load_shape_object(const std::string &type_name);
void load_shape_object_from_gallery();

View File

@ -417,9 +417,9 @@ void HintDatabase::load_hints_from_file(const boost::filesystem::path& path)
m_loaded_hints.emplace_back(hint_data);
// open preferences
} else if(dict["hypertext_type"] == "preferences") {
int page = static_cast<Preset::Type>(std::atoi(dict["hypertext_preferences_page"].c_str()));
std::string page = dict["hypertext_preferences_page"];
std::string item = dict["hypertext_preferences_item"];
HintData hint_data{ id_string, text1, weight, was_displayed, hypertext_text, follow_text, disabled_tags, enabled_tags, false, documentation_link, [page, item]() { wxGetApp().open_preferences(page, item); } };
HintData hint_data{ id_string, text1, weight, was_displayed, hypertext_text, follow_text, disabled_tags, enabled_tags, false, documentation_link, [page, item]() { wxGetApp().open_preferences(item, page); } };
m_loaded_hints.emplace_back(hint_data);
} else if (dict["hypertext_type"] == "plater") {
std::string item = dict["hypertext_plater_item"];
@ -924,7 +924,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, "show_hints");
wxGetApp().open_preferences("show_hints", "GUI");
}
ImGui::PopStyleColor(5);

View File

@ -47,6 +47,7 @@
#include "GUI_ObjectList.hpp"
#include "GalleryDialog.hpp"
#include "NotificationManager.hpp"
#include "Preferences.hpp"
#ifdef _WIN32
#include <dbt.h>
@ -272,6 +273,8 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
if (m_plater != nullptr) {
m_plater->get_collapse_toolbar().set_enabled(wxGetApp().app_config->get("show_collapse_button") == "1");
m_plater->show_action_buttons(true);
preferences_dialog = new PreferencesDialog(this);
}
}

View File

@ -32,6 +32,7 @@ class Tab;
class PrintHostQueueDialog;
class Plater;
class MainFrame;
class PreferencesDialog;
enum QuickSlice
{
@ -203,6 +204,7 @@ public:
DiffPresetDialog diff_dialog;
wxWindow* m_plater_page{ nullptr };
// wxProgressDialog* m_progress_dialog { nullptr };
PreferencesDialog* preferences_dialog { nullptr };
PrintHostQueueDialog* m_printhost_queue_dlg;
// std::shared_ptr<ProgressStatusBar> m_statusbar;

View File

@ -78,8 +78,13 @@ void MsgDialog::SetButtonLabel(wxWindowID btn_id, const wxString& label, bool se
wxButton* MsgDialog::add_button(wxWindowID btn_id, bool set_focus /*= false*/, const wxString& label/* = wxString()*/)
{
wxButton* btn = new wxButton(this, btn_id, label);
if (set_focus)
if (set_focus) {
btn->SetFocus();
// For non-MSW platforms SetFocus is not enought to use it as default, when the dialog is closed by ENTER
// We have to set this button as the (permanently) default one in its dialog
// See https://twitter.com/ZMelmed/status/1472678454168539146
btn->SetDefault();
}
btn_sizer->Add(btn, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, HORIZ_SPACING);
btn->Bind(wxEVT_BUTTON, [this, btn_id](wxCommandEvent&) { this->EndModal(btn_id); });
return btn;

View File

@ -74,6 +74,12 @@ public:
label(_(label)), label_tooltip(_(tooltip)) {}
Line() : m_is_separator(true) {}
Line(const std::string& opt_key, const wxString& label, const wxString& tooltip) :
label(_(label)), label_tooltip(_(tooltip))
{
m_options.push_back(Option({ opt_key, coNone }, opt_key));
}
bool is_separator() const { return m_is_separator; }
const std::vector<widget_t>& get_extra_widgets() const {return m_extra_widgets;}
@ -180,6 +186,8 @@ public:
// if we have to set the same control alignment for different option groups,
// we have to set same max contrtol width to all of them
void set_max_win_width(int max_win_width);
void set_use_custom_ctrl(bool use_custom_ctrl) { m_use_custom_ctrl = use_custom_ctrl; }
const std::map<t_config_option_key, Option>& get_optioms_map() { return m_options; }
bool is_activated() { return sizer != nullptr; }

View File

@ -1185,10 +1185,10 @@ void Sidebar::jump_to_option(const std::string& opt_key, Preset::Type type, cons
void Sidebar::jump_to_option(size_t selected)
{
const Search::Option& opt = p->searcher.get_option(selected);
wxGetApp().get_tab(opt.type)->activate_option(opt.opt_key(), boost::nowide::narrow(opt.category));
// Switch to the Settings NotePad
// wxGetApp().mainframe->select_tab();
if (opt.type == Preset::TYPE_PREFERENCES)
wxGetApp().open_preferences(opt.opt_key(), boost::nowide::narrow(opt.group));
else
wxGetApp().get_tab(opt.type)->activate_option(opt.opt_key(), boost::nowide::narrow(opt.category));
}
ObjectManipulation* Sidebar::obj_manipul()

View File

@ -42,22 +42,37 @@ namespace Slic3r {
namespace GUI {
PreferencesDialog::PreferencesDialog(wxWindow* parent, int selected_tab, const std::string& highlight_opt_key) :
PreferencesDialog::PreferencesDialog(wxWindow* parent) :
DPIDialog(parent, wxID_ANY, _L("Preferences"), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
{
#ifdef __WXOSX__
isOSX = true;
#endif
build(selected_tab);
build();
m_highlighter.set_timer_owner(this, 0);
}
void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::string()*/, const std::string& tab_name/*= std::string()*/)
{
int selected_tab = 0;
for (selected_tab; selected_tab < tabs->GetPageCount(); selected_tab++)
if (tabs->GetPageText(selected_tab) == _(tab_name))
break;
if (selected_tab < tabs->GetPageCount())
tabs->SetSelection(selected_tab);
if (!highlight_opt_key.empty())
init_highlighter(highlight_opt_key);
this->ShowModal();
}
static std::shared_ptr<ConfigOptionsGroup>create_options_tab(const wxString& title, wxBookCtrlBase* tabs)
{
wxPanel* tab = new wxPanel(tabs, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
tabs->AddPage(tab, title);
tabs->AddPage(tab, _(title));
tab->SetFont(wxGetApp().normal_font());
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
@ -66,6 +81,7 @@ static std::shared_ptr<ConfigOptionsGroup>create_options_tab(const wxString& tit
std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(tab);
optgroup->label_width = 40;
optgroup->set_config_category_and_type(title, int(Preset::TYPE_PREFERENCES));
return optgroup;
}
@ -75,9 +91,67 @@ static void activate_options_tab(std::shared_ptr<ConfigOptionsGroup> optgroup)
optgroup->update_visibility(comSimple);
wxBoxSizer* sizer = static_cast<wxBoxSizer*>(static_cast<wxPanel*>(optgroup->parent())->GetSizer());
sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
// apply sercher
wxGetApp().sidebar().get_searcher().append_preferences_options(optgroup->get_lines());
}
void PreferencesDialog::build(size_t selected_tab)
static void append_bool_option( std::shared_ptr<ConfigOptionsGroup> optgroup,
const std::string& opt_key,
const std::string& label,
const std::string& tooltip,
bool def_val,
ConfigOptionMode mode = comSimple)
{
ConfigOptionDef def = {opt_key, coBool};
def.label = label;
def.tooltip = tooltip;
def.mode = mode;
def.set_default_value(new ConfigOptionBool{ def_val });
Option option(def, opt_key);
optgroup->append_single_option_line(option);
// fill data to the Search Dialog
wxGetApp().sidebar().get_searcher().add_key(opt_key, Preset::TYPE_PREFERENCES, optgroup->config_category(), L("Preferences"));
}
static void append_enum_option( std::shared_ptr<ConfigOptionsGroup> optgroup,
const std::string& opt_key,
const std::string& label,
const std::string& tooltip,
const ConfigOption* def_val,
const t_config_enum_values *enum_keys_map,
std::initializer_list<std::string> enum_values,
std::initializer_list<std::string> enum_labels,
ConfigOptionMode mode = comSimple)
{
ConfigOptionDef def = {opt_key, coEnum };
def.label = label;
def.tooltip = tooltip;
def.mode = mode;
def.enum_keys_map = enum_keys_map;
def.enum_values = std::vector<std::string>(enum_values);
def.enum_labels = std::vector<std::string>(enum_labels);
def.set_default_value(def_val);
Option option(def, opt_key);
optgroup->append_single_option_line(option);
// fill data to the Search Dialog
wxGetApp().sidebar().get_searcher().add_key(opt_key, Preset::TYPE_PREFERENCES, optgroup->config_category(), L("Preferences"));
}
static void append_preferences_option_to_searcer(std::shared_ptr<ConfigOptionsGroup> optgroup,
const std::string& opt_key,
const wxString& label)
{
// fill data to the Search Dialog
wxGetApp().sidebar().get_searcher().add_key(opt_key, Preset::TYPE_PREFERENCES, optgroup->config_category(), L("Preferences"));
// apply sercher
wxGetApp().sidebar().get_searcher().append_preferences_option(Line(opt_key, label, ""));
}
void PreferencesDialog::build()
{
#ifdef _WIN32
wxGetApp().UpdateDarkUI(this);
@ -90,20 +164,14 @@ void PreferencesDialog::build(size_t selected_tab)
auto app_config = get_app_config();
#ifdef _MSW_DARK_MODE
wxBookCtrlBase* tabs;
// if (wxGetApp().dark_mode())
tabs = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME | wxNB_DEFAULT);
/* else {
tabs = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME | wxNB_DEFAULT);
tabs->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
}*/
tabs = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME | wxNB_DEFAULT);
#else
wxNotebook* tabs = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL |wxNB_NOPAGETHEME | wxNB_DEFAULT );
tabs = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL |wxNB_NOPAGETHEME | wxNB_DEFAULT );
tabs->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
#endif
// Add "General" tab
m_optgroup_general = create_options_tab(_L("General"), tabs);
m_optgroup_general = create_options_tab(L("General"), tabs);
m_optgroup_general->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
if (opt_key == "default_action_on_close_application" || opt_key == "default_action_on_select_preset" || opt_key == "default_action_on_new_project")
m_values[opt_key] = boost::any_cast<bool>(value) ? "none" : "discard";
@ -113,215 +181,167 @@ void PreferencesDialog::build(size_t selected_tab)
bool is_editor = wxGetApp().is_editor();
ConfigOptionDef def;
Option option(def, "");
if (is_editor) {
def.label = L("Remember output directory");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory "
"instead of the one containing the input files.");
def.set_default_value(new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true });
option = Option(def, "remember_output_path");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "remember_output_path",
L("Remember output directory"),
L("If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files."),
app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true);
def.label = L("Auto-center parts");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will auto-center objects "
"around the print bed center.");
def.set_default_value(new ConfigOptionBool{ app_config->get("autocenter") == "1" });
option = Option(def, "autocenter");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "autocenter",
L("Auto-center parts"),
L("If this is enabled, Slic3r will auto-center objects around the print bed center."),
app_config->get("autocenter") == "1");
def.label = L("Background processing");
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will pre-process objects as soon "
"as they\'re loaded in order to save time when exporting G-code.");
def.set_default_value(new ConfigOptionBool{ app_config->get("background_processing") == "1" });
option = Option(def, "background_processing");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "background_processing",
L("Background processing"),
L("If this is enabled, Slic3r will pre-process objects as soon "
"as they\'re loaded in order to save time when exporting G-code."),
app_config->get("background_processing") == "1");
m_optgroup_general->append_separator();
// Please keep in sync with ConfigWizard
def.label = L("Export sources full pathnames to 3mf and amf");
def.type = coBool;
def.tooltip = L("If enabled, allows the Reload from disk command to automatically find and load the files when invoked.");
def.set_default_value(new ConfigOptionBool(app_config->get("export_sources_full_pathnames") == "1"));
option = Option(def, "export_sources_full_pathnames");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "export_sources_full_pathnames",
L("Export sources full pathnames to 3mf and amf"),
L("If enabled, allows the Reload from disk command to automatically find and load the files when invoked."),
app_config->get("export_sources_full_pathnames") == "1");
#ifdef _WIN32
// Please keep in sync with ConfigWizard
def.label = L("Associate .3mf files to PrusaSlicer");
def.type = coBool;
def.tooltip = L("If enabled, sets PrusaSlicer as default application to open .3mf files.");
def.set_default_value(new ConfigOptionBool(app_config->get("associate_3mf") == "1"));
option = Option(def, "associate_3mf");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "associate_3mf",
L("Associate .3mf files to PrusaSlicer"),
L("If enabled, sets PrusaSlicer as default application to open .3mf files."),
app_config->get("associate_3mf") == "1");
def.label = L("Associate .stl files to PrusaSlicer");
def.type = coBool;
def.tooltip = L("If enabled, sets PrusaSlicer as default application to open .stl files.");
def.set_default_value(new ConfigOptionBool(app_config->get("associate_stl") == "1"));
option = Option(def, "associate_stl");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "associate_stl",
L("Associate .stl files to PrusaSlicer"),
L("If enabled, sets PrusaSlicer as default application to open .stl files."),
app_config->get("associate_stl") == "1");
#endif // _WIN32
m_optgroup_general->append_separator();
// Please keep in sync with ConfigWizard
def.label = L("Update built-in Presets automatically");
def.type = coBool;
def.tooltip = L("If enabled, Slic3r downloads updates of built-in system presets in the background. These updates are downloaded into a separate temporary location. When a new preset version becomes available it is offered at application startup.");
def.set_default_value(new ConfigOptionBool(app_config->get("preset_update") == "1"));
option = Option(def, "preset_update");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "preset_update",
L("Update built-in Presets automatically"),
L("If enabled, Slic3r downloads updates of built-in system presets in the background. These updates are downloaded "
"into a separate temporary location. When a new preset version becomes available it is offered at application startup."),
app_config->get("preset_update") == "1");
def.label = L("Suppress \" - default - \" presets");
def.type = coBool;
def.tooltip = L("Suppress \" - default - \" presets in the Print / Filament / Printer "
"selections once there are any other valid presets available.");
def.set_default_value(new ConfigOptionBool{ app_config->get("no_defaults") == "1" });
option = Option(def, "no_defaults");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "no_defaults",
L("Suppress \" - default - \" presets"),
L("Suppress \" - default - \" presets in the Print / Filament / Printer selections once there are any other valid presets available."),
app_config->get("no_defaults") == "1");
def.label = L("Show incompatible print and filament presets");
def.type = coBool;
def.tooltip = L("When checked, the print and filament presets are shown in the preset editor "
"even if they are marked as incompatible with the active printer");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_incompatible_presets") == "1" });
option = Option(def, "show_incompatible_presets");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "show_incompatible_presets",
L("Show incompatible print and filament presets"),
L("When checked, the print and filament presets are shown in the preset editor "
"even if they are marked as incompatible with the active printer"),
app_config->get("show_incompatible_presets") == "1");
m_optgroup_general->append_separator();
def.label = L("Show drop project dialog");
def.type = coBool;
def.tooltip = L("When checked, whenever dragging and dropping a project file on the application, shows a dialog asking to select the action to take on the file to load.");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_drop_project_dialog") == "1" });
option = Option(def, "show_drop_project_dialog");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "show_drop_project_dialog",
L("Show drop project dialog"),
L("When checked, whenever dragging and dropping a project file on the application, shows a dialog asking to select the action to take on the file to load."),
app_config->get("show_drop_project_dialog") == "1");
append_bool_option(m_optgroup_general, "single_instance",
#if __APPLE__
def.label = L("Allow just a single PrusaSlicer instance");
def.type = coBool;
def.tooltip = L("On OSX there is always only one instance of app running by default. However it is allowed to run multiple instances of same app from the command line. In such case this settings will allow only one instance.");
L("Allow just a single PrusaSlicer instance"),
L("On OSX there is always only one instance of app running by default. However it is allowed to run multiple instances "
"of same app from the command line. In such case this settings will allow only one instance."),
#else
def.label = L("Allow just a single PrusaSlicer instance");
def.type = coBool;
def.tooltip = L("If this is enabled, when starting PrusaSlicer and another instance of the same PrusaSlicer is already running, that instance will be reactivated instead.");
L("Allow just a single PrusaSlicer instance"),
L("If this is enabled, when starting PrusaSlicer and another instance of the same PrusaSlicer is already running, that instance will be reactivated instead."),
#endif
def.set_default_value(new ConfigOptionBool{ app_config->has("single_instance") ? app_config->get("single_instance") == "1" : false });
option = Option(def, "single_instance");
m_optgroup_general->append_single_option_line(option);
app_config->has("single_instance") ? app_config->get("single_instance") == "1" : false );
m_optgroup_general->append_separator();
def.label = L("Ask to save unsaved changes when closing the application or when loading a new project");
def.type = coBool;
def.tooltip = L("Always ask for unsaved changes, when: \n"
append_bool_option(m_optgroup_general, "default_action_on_close_application",
L("Ask to save unsaved changes when closing the application or when loading a new project"),
L("Always ask for unsaved changes, when: \n"
"- Closing PrusaSlicer while some presets are modified,\n"
"- Loading a new project while some presets are modified");
def.set_default_value(new ConfigOptionBool{ app_config->get("default_action_on_close_application") == "none" });
option = Option(def, "default_action_on_close_application");
m_optgroup_general->append_single_option_line(option);
"- Loading a new project while some presets are modified"),
app_config->get("default_action_on_close_application") == "none");
def.label = L("Ask for unsaved changes when selecting new preset");
def.type = coBool;
def.tooltip = L("Always ask for unsaved changes when selecting new preset or resetting a preset");
def.set_default_value(new ConfigOptionBool{ app_config->get("default_action_on_select_preset") == "none" });
option = Option(def, "default_action_on_select_preset");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "default_action_on_select_preset",
L("Ask for unsaved changes when selecting new preset"),
L("Always ask for unsaved changes when selecting new preset or resetting a preset"),
app_config->get("default_action_on_select_preset") == "none");
def.label = L("Ask for unsaved changes when creating new project");
def.type = coBool;
def.tooltip = L("Always ask for unsaved changes when creating new project");
def.set_default_value(new ConfigOptionBool{ app_config->get("default_action_on_new_project") == "none" });
option = Option(def, "default_action_on_new_project");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "default_action_on_new_project",
L("Ask for unsaved changes when creating new project"),
L("Always ask for unsaved changes when creating new project"),
app_config->get("default_action_on_new_project") == "none");
}
#ifdef _WIN32
else {
def.label = L("Associate .gcode files to PrusaSlicer G-code Viewer");
def.type = coBool;
def.tooltip = L("If enabled, sets PrusaSlicer G-code Viewer as default application to open .gcode files.");
def.set_default_value(new ConfigOptionBool(app_config->get("associate_gcode") == "1"));
option = Option(def, "associate_gcode");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "associate_gcode",
L("Associate .gcode files to PrusaSlicer G-code Viewer"),
L("If enabled, sets PrusaSlicer G-code Viewer as default application to open .gcode files."),
app_config->get("associate_gcode") == "1");
}
#endif // _WIN32
#if __APPLE__
def.label = L("Use Retina resolution for the 3D scene");
def.type = coBool;
def.tooltip = L("If enabled, the 3D scene will be rendered in Retina resolution. "
"If you are experiencing 3D performance problems, disabling this option may help.");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_retina_opengl") == "1" });
option = Option (def, "use_retina_opengl");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "use_retina_opengl",
L("Use Retina resolution for the 3D scene"),
L("If enabled, the 3D scene will be rendered in Retina resolution. "
"If you are experiencing 3D performance problems, disabling this option may help."),
app_config->get("use_retina_opengl") == "1");
#endif
m_optgroup_general->append_separator();
// Show/Hide splash screen
def.label = L("Show splash screen");
def.type = coBool;
def.tooltip = L("Show splash screen");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_splash_screen") == "1" });
option = Option(def, "show_splash_screen");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "show_splash_screen",
L("Show splash screen"),
L("Show splash screen"),
app_config->get("show_splash_screen") == "1");
// Clear Undo / Redo stack on new project
def.label = L("Clear Undo / Redo stack on new project");
def.type = coBool;
def.tooltip = L("Clear Undo / Redo stack on new project or when an existing project is loaded.");
def.set_default_value(new ConfigOptionBool{ app_config->get("clear_undo_redo_stack_on_new_project") == "1" });
option = Option(def, "clear_undo_redo_stack_on_new_project");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "clear_undo_redo_stack_on_new_project",
L("Clear Undo / Redo stack on new project"),
L("Clear Undo / Redo stack on new project or when an existing project is loaded."),
app_config->get("clear_undo_redo_stack_on_new_project") == "1");
#if defined(_WIN32) || defined(__APPLE__)
def.label = L("Enable support for legacy 3DConnexion devices");
def.type = coBool;
def.tooltip = L("If enabled, the legacy 3DConnexion devices settings dialog is available by pressing CTRL+M");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_legacy_3DConnexion") == "1" });
option = Option(def, "use_legacy_3DConnexion");
m_optgroup_general->append_single_option_line(option);
append_bool_option(m_optgroup_general, "use_legacy_3DConnexion",
L("Enable support for legacy 3DConnexion devices"),
L("If enabled, the legacy 3DConnexion devices settings dialog is available by pressing CTRL+M"),
app_config->get("use_legacy_3DConnexion") == "1");
#endif // _WIN32 || __APPLE__
activate_options_tab(m_optgroup_general);
// Add "Camera" tab
m_optgroup_camera = create_options_tab(_L("Camera"), tabs);
m_optgroup_camera = create_options_tab(L("Camera"), tabs);
m_optgroup_camera->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
};
def.label = L("Use perspective camera");
def.type = coBool;
def.tooltip = L("If enabled, use perspective camera. If not enabled, use orthographic camera.");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_perspective_camera") == "1" });
option = Option(def, "use_perspective_camera");
m_optgroup_camera->append_single_option_line(option);
append_bool_option(m_optgroup_camera, "use_perspective_camera",
L("Use perspective camera"),
L("If enabled, use perspective camera. If not enabled, use orthographic camera."),
app_config->get("use_perspective_camera") == "1");
def.label = L("Use free camera");
def.type = coBool;
def.tooltip = L("If enabled, use free camera. If not enabled, use constrained camera.");
def.set_default_value(new ConfigOptionBool(app_config->get("use_free_camera") == "1"));
option = Option(def, "use_free_camera");
m_optgroup_camera->append_single_option_line(option);
append_bool_option(m_optgroup_camera, "use_free_camera",
L("Use free camera"),
L("If enabled, use free camera. If not enabled, use constrained camera."),
app_config->get("use_free_camera") == "1");
def.label = L("Reverse direction of zoom with mouse wheel");
def.type = coBool;
def.tooltip = L("If enabled, reverses the direction of zoom with mouse wheel");
def.set_default_value(new ConfigOptionBool(app_config->get("reverse_mouse_wheel_zoom") == "1"));
option = Option(def, "reverse_mouse_wheel_zoom");
m_optgroup_camera->append_single_option_line(option);
append_bool_option(m_optgroup_camera, "reverse_mouse_wheel_zoom",
L("Reverse direction of zoom with mouse wheel"),
L("If enabled, reverses the direction of zoom with mouse wheel"),
app_config->get("reverse_mouse_wheel_zoom") == "1");
activate_options_tab(m_optgroup_camera);
// Add "GUI" tab
m_optgroup_gui = create_options_tab(_L("GUI"), tabs);
m_optgroup_gui->m_on_change = [this, tabs](t_config_option_key opt_key, boost::any value) {
m_optgroup_gui = create_options_tab(L("GUI"), tabs);
m_optgroup_gui->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
if (opt_key == "suppress_hyperlinks")
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "";
else if (opt_key == "notify_release") {
@ -343,165 +363,123 @@ void PreferencesDialog::build(size_t selected_tab)
}
};
def.label = L("Sequential slider applied only to top layer");
def.type = coBool;
def.tooltip = L("If enabled, changes made using the sequential slider, in preview, apply only to gcode top layer. "
"If disabled, changes made using the sequential slider, in preview, apply to the whole gcode.");
def.set_default_value(new ConfigOptionBool{ app_config->get("seq_top_layer_only") == "1" });
option = Option(def, "seq_top_layer_only");
m_optgroup_gui->append_single_option_line(option);
append_bool_option(m_optgroup_gui, "seq_top_layer_only",
L("Sequential slider applied only to top layer"),
L("If enabled, changes made using the sequential slider, in preview, apply only to gcode top layer."
"If disabled, changes made using the sequential slider, in preview, apply to the whole gcode."),
app_config->get("seq_top_layer_only") == "1");
if (is_editor) {
def.label = L("Show sidebar collapse/expand button");
def.type = coBool;
def.tooltip = L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_collapse_button") == "1" });
option = Option(def, "show_collapse_button");
m_optgroup_gui->append_single_option_line(option);
append_bool_option(m_optgroup_gui, "show_collapse_button",
L("Show sidebar collapse/expand button"),
L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene"),
app_config->get("show_collapse_button") == "1");
def.label = L("Suppress to open hyperlink in browser");
def.type = coBool;
def.tooltip = L("If enabled, the descriptions of configuration parameters in settings tabs wouldn't work as hyperlinks. "
"If disabled, the descriptions of configuration parameters in settings tabs will work as hyperlinks.");
def.set_default_value(new ConfigOptionBool{ app_config->get("suppress_hyperlinks") == "1" });
option = Option(def, "suppress_hyperlinks");
m_optgroup_gui->append_single_option_line(option);
append_bool_option(m_optgroup_gui, "suppress_hyperlinks",
L("Suppress to open hyperlink in browser"),
L("If enabled, the descriptions of configuration parameters in settings tabs wouldn't work as hyperlinks. "
"If disabled, the descriptions of configuration parameters in settings tabs will work as hyperlinks."),
app_config->get("suppress_hyperlinks") == "1");
def.label = L("Use colors for axes values in Manipulation panel");
def.type = coBool;
def.tooltip = L("If enabled, the axes names and axes values will be colorized according to the axes colors. "
"If disabled, old UI will be used.");
def.set_default_value(new ConfigOptionBool{ app_config->get("color_mapinulation_panel") == "1" });
option = Option(def, "color_mapinulation_panel");
m_optgroup_gui->append_single_option_line(option);
append_bool_option(m_optgroup_gui, "color_mapinulation_panel",
L("Use colors for axes values in Manipulation panel"),
L("If enabled, the axes names and axes values will be colorized according to the axes colors. "
"If disabled, old UI will be used."),
app_config->get("color_mapinulation_panel") == "1");
def.label = L("Order object volumes by types");
def.type = coBool;
def.tooltip = L("If enabled, volumes will be always ordered inside the object. Correct order is Model Part, Negative Volume, Modifier, Support Blocker and Support Enforcer. "
"If disabled, you can reorder Model Parts, Negative Volumes and Modifiers. But one of the model parts have to be on the first place.");
def.set_default_value(new ConfigOptionBool{ app_config->get("order_volumes") == "1" });
option = Option(def, "order_volumes");
m_optgroup_gui->append_single_option_line(option);
append_bool_option(m_optgroup_gui, "order_volumes",
L("Order object volumes by types"),
L("If enabled, volumes will be always ordered inside the object. Correct order is Model Part, Negative Volume, Modifier, Support Blocker and Support Enforcer. "
"If disabled, you can reorder Model Parts, Negative Volumes and Modifiers. But one of the model parts have to be on the first place."),
app_config->get("order_volumes") == "1");
#ifdef _MSW_DARK_MODE
def.label = L("Set settings tabs as menu items (experimental)");
def.type = coBool;
def.tooltip = L("If enabled, Settings Tabs will be placed as menu items. "
"If disabled, old UI will be used.");
def.set_default_value(new ConfigOptionBool{ app_config->get("tabs_as_menu") == "1" });
option = Option(def, "tabs_as_menu");
m_optgroup_gui->append_single_option_line(option);
append_bool_option(m_optgroup_gui, "tabs_as_menu",
L("Set settings tabs as menu items (experimental)"),
L("If enabled, Settings Tabs will be placed as menu items. If disabled, old UI will be used."),
app_config->get("tabs_as_menu") == "1");
#endif
m_optgroup_gui->append_separator();
def.label = L("Show \"Tip of the day\" notification after start");
def.type = coBool;
def.tooltip = L("If enabled, useful hints are displayed at startup.");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_hints") == "1" });
option = Option(def, "show_hints");
m_optgroup_gui->append_single_option_line(option);
append_bool_option(m_optgroup_gui, "show_hints",
L("Show \"Tip of the day\" notification after start"),
L("If enabled, useful hints are displayed at startup."),
app_config->get("show_hints") == "1");
ConfigOptionDef def_enum;
def_enum.label = L("Notify about new releases");
def_enum.type = coEnum;
def_enum.tooltip = L("You will be notified about new release after startup acordingly: All = Regular release and alpha / beta releases. Release only = regular release.");
def_enum.enum_keys_map = &ConfigOptionEnum<NotifyReleaseMode>::get_enum_values();
def_enum.enum_values.push_back("all");
def_enum.enum_values.push_back("release");
def_enum.enum_values.push_back("none");
def_enum.enum_labels.push_back(L("All"));
def_enum.enum_labels.push_back(L("Release only"));
def_enum.enum_labels.push_back(L("None"));
def_enum.mode = comSimple;
def_enum.set_default_value(new ConfigOptionEnum<NotifyReleaseMode>(static_cast<NotifyReleaseMode>(s_keys_map_NotifyReleaseMode.at(app_config->get("notify_release")))));
option = Option(def_enum, "notify_release");
m_optgroup_gui->append_single_option_line(option);
append_enum_option(m_optgroup_gui, "notify_release",
L("Notify about new releases"),
L("You will be notified about new release after startup acordingly: All = Regular release and alpha / beta releases. Release only = regular release."),
new ConfigOptionEnum<NotifyReleaseMode>(static_cast<NotifyReleaseMode>(s_keys_map_NotifyReleaseMode.at(app_config->get("notify_release")))),
&ConfigOptionEnum<NotifyReleaseMode>::get_enum_values(),
{"all", "release", "none"},
{L("All"), L("Release only"), L("None")});
m_optgroup_gui->append_separator();
def.label = L("Use custom size for toolbar icons");
def.type = coBool;
def.tooltip = L("If enabled, you can change size of toolbar icons manually.");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_custom_toolbar_size") == "1" });
option = Option(def, "use_custom_toolbar_size");
m_optgroup_gui->append_single_option_line(option);
append_bool_option(m_optgroup_gui, "use_custom_toolbar_size",
L("Use custom size for toolbar icons"),
L("If enabled, you can change size of toolbar icons manually."),
app_config->get("use_custom_toolbar_size") == "1");
}
activate_options_tab(m_optgroup_gui);
// set Field for notify_release to its value to activate the object
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) {
// 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);
create_icon_size_slider();
m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1");
create_settings_mode_widget();
create_settings_text_color_widget();
}
#if ENABLE_ENVIRONMENT_MAP
if (is_editor) {
// Add "Render" tab
m_optgroup_render = create_options_tab(_L("Render"), tabs);
m_optgroup_render = create_options_tab(L("Render"), tabs);
m_optgroup_render->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
};
def.label = L("Use environment map");
def.type = coBool;
def.tooltip = L("If enabled, renders object using the environment map.");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_environment_map") == "1" });
option = Option(def, "use_environment_map");
m_optgroup_render->append_single_option_line(option);
append_bool_option(m_optgroup_render, "use_environment_map",
L("Use environment map"),
L("If enabled, renders object using the environment map."),
app_config->get("use_environment_map") == "1");
activate_options_tab(m_optgroup_render);
}
#endif // ENABLE_ENVIRONMENT_MAP
#ifdef _WIN32
// Add "Dark Mode" tab
{
// Add "Dark Mode" tab
m_optgroup_dark_mode = create_options_tab(_L("Dark mode (experimental)"), tabs);
m_optgroup_dark_mode->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
};
def.label = L("Enable dark mode");
def.type = coBool;
def.tooltip = L("If enabled, UI will use Dark mode colors. "
"If disabled, old UI will be used.");
def.set_default_value(new ConfigOptionBool{ app_config->get("dark_color_mode") == "1" });
option = Option(def, "dark_color_mode");
m_optgroup_dark_mode->append_single_option_line(option);
append_bool_option(m_optgroup_dark_mode, "dark_color_mode",
L("Enable dark mode"),
L("If enabled, UI will use Dark mode colors. If disabled, old UI will be used."),
app_config->get("dark_color_mode") == "1");
if (wxPlatformInfo::Get().GetOSMajorVersion() >= 10) // Use system menu just for Window newer then Windows 10
// Use menu with ownerdrawn items by default on systems older then Windows 10
{
def.label = L("Use system menu for application");
def.type = coBool;
def.tooltip = L("If enabled, application will use the standard Windows system menu,\n"
"but on some combination of display scales it can looks ugly. If disabled, old UI will be used.");
def.set_default_value(new ConfigOptionBool{ app_config->get("sys_menu_enabled") == "1" });
option = Option(def, "sys_menu_enabled");
m_optgroup_dark_mode->append_single_option_line(option);
append_bool_option(m_optgroup_dark_mode, "sys_menu_enabled",
L("Use system menu for application"),
L("If enabled, application will use the standart Windows system menu,\n"
"but on some combination od display scales it can look ugly. If disabled, old UI will be used."),
app_config->get("sys_menu_enabled") == "1");
}
activate_options_tab(m_optgroup_dark_mode);
}
#endif //_WIN32
}
// update alignment of the controls for all tabs
update_ctrls_alignment();
if (selected_tab < tabs->GetPageCount())
tabs->SetSelection(selected_tab);
auto sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(tabs, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
@ -526,7 +504,10 @@ std::vector<ConfigOptionsGroup*> PreferencesDialog::optgroups()
#ifdef _WIN32
, m_optgroup_dark_mode.get()
#endif // _WIN32
})
#if ENABLE_ENVIRONMENT_MAP
, m_optgroup_render.get()
#endif // ENABLE_ENVIRONMENT_MAP
})
if (opt)
out.emplace_back(opt);
return out;
@ -546,9 +527,6 @@ void PreferencesDialog::update_ctrls_alignment()
void PreferencesDialog::accept(wxEvent&)
{
// if (m_values.find("no_defaults") != m_values.end()
// warning_catcher(this, wxString::Format(_L("You need to restart %s to make the changes effective."), SLIC3R_APP_NAME));
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "tabs_as_menu", "sys_menu_enabled" };
for (const std::string& option : options_to_recreate_GUI) {
@ -627,16 +605,29 @@ void PreferencesDialog::accept(wxEvent&)
wxGetApp().update_ui_from_settings();
}
void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect)
void PreferencesDialog::msw_rescale()
{
for (ConfigOptionsGroup* og : this->optgroups())
og->msw_rescale();
#ifdef _WIN32
m_optgroup_dark_mode->msw_rescale();
#endif //_WIN32
#if ENABLE_ENVIRONMENT_MAP
m_optgroup_render->msw_rescale();
#endif // ENABLE_ENVIRONMENT_MAP
msw_buttons_rescale(this, em_unit(), { wxID_OK, wxID_CANCEL });
layout();
}
void PreferencesDialog::on_sys_color_changed()
{
#ifdef _WIN32
wxGetApp().UpdateDlgDarkUI(this);
#endif
}
void PreferencesDialog::layout()
{
const int em = em_unit();
@ -732,7 +723,8 @@ void PreferencesDialog::create_settings_mode_widget()
wxWindow* parent = m_optgroup_gui->parent();
wxGetApp().UpdateDarkUI(parent);
wxStaticBox* stb = new wxStaticBox(parent, wxID_ANY, _L("Layout Options"));
wxString title = L("Layout Options");
wxStaticBox* stb = new wxStaticBox(parent, wxID_ANY, _(title));
wxGetApp().UpdateDarkUI(stb);
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
stb->SetFont(wxGetApp().normal_font());
@ -766,36 +758,58 @@ void PreferencesDialog::create_settings_mode_widget()
id++;
}
std::string opt_key = "settings_layout_mode";
m_blinkers[opt_key] = new BlinkingBitmap(this);
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(m_blinkers[opt_key], 0, wxALIGN_CENTER_VERTICAL);
sizer->Add(stb_sizer, 1, wxALIGN_CENTER_VERTICAL);
m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND | wxTOP, em_unit());
append_preferences_option_to_searcer(m_optgroup_gui, opt_key, title);
}
void PreferencesDialog::create_settings_text_color_widget()
{
wxWindow* parent = m_optgroup_gui->parent();
wxStaticBox* stb = new wxStaticBox(parent, wxID_ANY, _L("Text colors"));
wxString title = L("Text colors");
wxStaticBox* stb = new wxStaticBox(parent, wxID_ANY, _(title));
wxGetApp().UpdateDarkUI(stb);
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
wxSizer* sizer = new wxStaticBoxSizer(stb, wxVERTICAL);
ButtonsDescription::FillSizerWithTextColorDescriptions(sizer, parent, &m_sys_colour, &m_mod_colour);
std::string opt_key = "text_colors";
m_blinkers[opt_key] = new BlinkingBitmap(this);
wxSizer* stb_sizer = new wxStaticBoxSizer(stb, wxVERTICAL);
ButtonsDescription::FillSizerWithTextColorDescriptions(stb_sizer, parent, &m_sys_colour, &m_mod_colour);
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(m_blinkers[opt_key], 0, wxALIGN_CENTER_VERTICAL);
sizer->Add(stb_sizer, 1, wxALIGN_CENTER_VERTICAL);
m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND | wxTOP, em_unit());
append_preferences_option_to_searcer(m_optgroup_gui, opt_key, title);
}
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();
});
if (m_blinkers.find(opt_key) != m_blinkers.end())
if (BlinkingBitmap* blinker = m_blinkers.at(opt_key); blinker) {
m_highlighter.init(blinker);
return;
}
std::pair<OG_CustomCtrl*, bool*> ctrl = { nullptr, nullptr };
for (ConfigOptionsGroup* opt_group : this->optgroups()) {
ctrl = opt_group->get_custom_ctrl_with_blinking_ptr(opt_key, -1);
for (auto opt_group : { m_optgroup_general, m_optgroup_camera, m_optgroup_gui
#ifdef _WIN32
, m_optgroup_dark_mode
#endif // _WIN32
#if ENABLE_ENVIRONMENT_MAP
, m_optgroup_render
#endif // ENABLE_ENVIRONMENT_MAP
}) {
std::pair<OG_CustomCtrl*, bool*> ctrl = opt_group->get_custom_ctrl_with_blinking_ptr(opt_key, -1);
if (ctrl.first && ctrl.second) {
m_highlighter.init(ctrl);
break;
@ -803,53 +817,5 @@ void PreferencesDialog::init_highlighter(const t_config_option_key& opt_key)
}
}
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

View File

@ -3,6 +3,7 @@
#include "GUI.hpp"
#include "GUI_Utils.hpp"
#include "wxExtensions.hpp"
#include <wx/dialog.h>
#include <wx/timer.h>
@ -10,6 +11,7 @@
#include <map>
class wxColourPickerCtrl;
class wxBookCtrlBase;
namespace Slic3r {
@ -39,24 +41,29 @@ class PreferencesDialog : public DPIDialog
wxSizer* m_icon_size_sizer;
wxColourPickerCtrl* m_sys_colour {nullptr};
wxColourPickerCtrl* m_mod_colour {nullptr};
wxBookCtrlBase* tabs {nullptr};
bool isOSX {false};
bool m_settings_layout_changed {false};
bool m_seq_top_layer_only_changed{ false };
bool m_recreate_GUI{false};
public:
explicit PreferencesDialog(wxWindow* parent, int selected_tab = 0, const std::string& highlight_opt_key = std::string());
explicit PreferencesDialog(wxWindow* paren);
~PreferencesDialog() = default;
bool settings_layout_changed() const { return m_settings_layout_changed; }
bool seq_top_layer_only_changed() const { return m_seq_top_layer_only_changed; }
bool recreate_GUI() const { return m_recreate_GUI; }
void build(size_t selected_tab = 0);
void build();
void update_ctrls_alignment();
void accept(wxEvent&);
void show(const std::string& highlight_option = std::string(), const std::string& tab_name = std::string());
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
void msw_rescale();
void on_dpi_changed(const wxRect& suggested_rect) override { msw_rescale(); }
void on_sys_color_changed() override;
void layout();
void create_icon_size_slider();
void create_settings_mode_widget();
@ -64,20 +71,8 @@ protected:
void init_highlighter(const t_config_option_key& opt_key);
std::vector<ConfigOptionsGroup*> optgroups();
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;
HighlighterForWx m_highlighter;
std::map<std::string, BlinkingBitmap*> m_blinkers;
};
} // GUI

View File

@ -43,6 +43,8 @@ static char marker_by_type(Preset::Type type, PrinterTechnology pt)
return ImGui::MaterialIconMarker;
case Preset::TYPE_PRINTER:
return pt == ptSLA ? ImGui::PrinterSlaIconMarker : ImGui::PrinterIconMarker;
case Preset::TYPE_PREFERENCES:
return ImGui::PreferencesButton;
default:
return ' ';
}
@ -302,6 +304,9 @@ void OptionsSearcher::init(std::vector<InputInfo> input_values)
options.clear();
for (auto i : input_values)
append_options(i.config, i.type, i.mode);
options.insert(options.end(), preferences_options.begin(), preferences_options.end());
sort_options();
search(search_line, true);
@ -323,6 +328,47 @@ void OptionsSearcher::apply(DynamicPrintConfig* config, Preset::Type type, Confi
search(search_line, true);
}
void OptionsSearcher::append_preferences_option(const GUI::Line& opt_line)
{
Preset::Type type = Preset::TYPE_PREFERENCES;
wxString label = opt_line.label;
if (label.IsEmpty())
return;
std::string key = get_key(opt_line.get_options().front().opt_id, type);
const GroupAndCategory& gc = groups_and_categories[key];
if (gc.group.IsEmpty() || gc.category.IsEmpty())
return;
preferences_options.emplace_back(Search::Option{ boost::nowide::widen(key), type,
label.ToStdWstring(), _(label).ToStdWstring(),
gc.group.ToStdWstring(), _(gc.group).ToStdWstring(),
gc.category.ToStdWstring(), _(gc.category).ToStdWstring() });
}
void OptionsSearcher::append_preferences_options(const std::vector<GUI::Line>& opt_lines)
{
//Preset::Type type = Preset::TYPE_PREFERENCES;
for (const GUI::Line& line : opt_lines) {
if (line.is_separator())
continue;
append_preferences_option(line);
//wxString label = line.label;
//if (label.IsEmpty())
// continue;
//std::string key = get_key(line.get_options().front().opt_id, type);
//const GroupAndCategory& gc = groups_and_categories[key];
//if (gc.group.IsEmpty() || gc.category.IsEmpty())
// continue;
//
//preferences_options.emplace_back(Search::Option{ boost::nowide::widen(key), type,
// label.ToStdWstring(), _(label).ToStdWstring(),
// gc.group.ToStdWstring(), _(gc.group).ToStdWstring(),
// gc.category.ToStdWstring(), _(gc.category).ToStdWstring() });
}
}
const Option& OptionsSearcher::get_option(size_t pos_in_filter) const
{
assert(pos_in_filter != size_t(-1) && found[pos_in_filter].option_idx != size_t(-1));
@ -429,6 +475,7 @@ static const std::map<const char, int> icon_idxs = {
{ImGui::PrinterSlaIconMarker, 2},
{ImGui::FilamentIconMarker , 3},
{ImGui::MaterialIconMarker , 4},
{ImGui::PreferencesButton , 5},
};
SearchDialog::SearchDialog(OptionsSearcher* searcher)
@ -717,7 +764,7 @@ void SearchDialog::on_sys_color_changed()
SearchListModel::SearchListModel(wxWindow* parent) : wxDataViewVirtualListModel(0)
{
int icon_id = 0;
for (const std::string& icon : { "cog", "printer", "sla_printer", "spool", "resin" })
for (const std::string& icon : { "cog", "printer", "sla_printer", "spool", "resin", "notification_preferences" })
m_icon[icon_id++] = ScalableBitmap(parent, icon);
}

View File

@ -17,6 +17,7 @@
#include "GUI_Utils.hpp"
#include "wxExtensions.hpp"
#include "OptionsGroup.hpp"
#include "libslic3r/Preset.hpp"
@ -85,6 +86,7 @@ class OptionsSearcher
PrinterTechnology printer_technology;
std::vector<Option> options {};
std::vector<Option> preferences_options {};
std::vector<FoundOption> found {};
void append_options(DynamicPrintConfig* config, Preset::Type type, ConfigOptionMode mode);
@ -113,6 +115,8 @@ public:
void apply(DynamicPrintConfig *config,
Preset::Type type,
ConfigOptionMode mode);
void append_preferences_option(const GUI::Line& opt_line);
void append_preferences_options(const std::vector<GUI::Line>& opt_lines);
bool search();
bool search(const std::string& search, bool force = false);
@ -197,7 +201,7 @@ protected:
class SearchListModel : public wxDataViewVirtualListModel
{
std::vector<std::pair<wxString, int>> m_values;
ScalableBitmap m_icon[5];
ScalableBitmap m_icon[6];
public:
enum {

View File

@ -559,8 +559,8 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
std::string app_name;
{
Semver semver(SLIC3R_VERSION);
bool is_alpha = std::string{semver.prerelease()}.find("alpha") != std::string::npos;
bool is_beta = std::string{semver.prerelease()}.find("beta") != std::string::npos;
bool is_alpha = semver.prerelease() && std::string{semver.prerelease()}.find("alpha") != std::string::npos;
bool is_beta = semver.prerelease() && std::string{semver.prerelease()}.find("beta") != std::string::npos;
app_name = std::string(SLIC3R_APP_NAME) + " " + std::to_string(semver.maj())
+ "." + std::to_string(semver.min()) + " "
+ (is_alpha ? "Alpha" : is_beta ? "Beta" : "");

View File

@ -51,55 +51,6 @@
namespace Slic3r {
namespace GUI {
void Tab::Highlighter::set_timer_owner(wxEvtHandler* owner, int timerid/* = wxID_ANY*/)
{
m_timer.SetOwner(owner, timerid);
}
void Tab::Highlighter::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 Tab::Highlighter::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 Tab::Highlighter::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();
}
Tab::Tab(wxBookCtrlBase* parent, const wxString& title, Preset::Type type) :
m_parent(parent), m_title(title), m_type(type)
{
@ -134,10 +85,6 @@ Tab::Tab(wxBookCtrlBase* parent, const wxString& title, Preset::Type type) :
}));
m_highlighter.set_timer_owner(this, 0);
this->Bind(wxEVT_TIMER, [this](wxTimerEvent&)
{
m_highlighter.blink();
});
}
void Tab::set_type()
@ -1743,7 +1690,7 @@ void TabPrint::update_description_lines()
if (m_active_page && m_active_page->title() == "Output options" && m_post_process_explanation) {
m_post_process_explanation->SetText(
_u8L("Post processing scripts shall modify G-code file in place."));
_L("Post processing scripts shall modify G-code file in place."));
#ifndef __linux__
m_post_process_explanation->SetPathEnd("post-processing-scripts_283913");
#endif // __linux__

View File

@ -218,20 +218,7 @@ protected:
bool m_completed { false };
ConfigOptionMode m_mode = comExpert; // to correct first Tab update_visibility() set mode to Expert
struct Highlighter
{
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;
HighlighterForWx m_highlighter;
DynamicPrintConfig m_cache_config;

View File

@ -16,6 +16,7 @@
#include "Plater.hpp"
#include "../Utils/MacDarkMode.hpp"
#include "BitmapComboBox.hpp"
#include "OG_CustomCtrl.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp"
@ -993,6 +994,103 @@ void BlinkingBitmap::blink()
this->SetBitmap(show ? bmp.bmp() : wxNullBitmap);
}
namespace Slic3r {
namespace GUI {
void Highlighter::set_timer_owner(wxWindow* owner, int timerid/* = wxID_ANY*/)
{
m_timer.SetOwner(owner, timerid);
bind_timer(owner);
}
bool Highlighter::init(bool input_failed)
{
if (input_failed)
return false;
m_timer.Start(300, false);
return true;
}
void Highlighter::invalidate()
{
if (m_timer.IsRunning())
m_timer.Stop();
m_blink_counter = 0;
}
void Highlighter::blink()
{
if ((++m_blink_counter) == 11)
invalidate();
}
// HighlighterForWx
void HighlighterForWx::bind_timer(wxWindow* owner)
{
owner->Bind(wxEVT_TIMER, [this](wxTimerEvent&) {
blink();
});
}
// using OG_CustomCtrl where arrow will be rendered and flag indicated "show/hide" state of this arrow
void HighlighterForWx::init(std::pair<OG_CustomCtrl*, bool*> params)
{
invalidate();
if (!Highlighter::init(!params.first && !params.second))
return;
m_custom_ctrl = params.first;
m_show_blink_ptr = params.second;
*m_show_blink_ptr = true;
m_custom_ctrl->Refresh();
}
// - using a BlinkingBitmap. Change state of this bitmap
void HighlighterForWx::init(BlinkingBitmap* blinking_bmp)
{
invalidate();
if (!Highlighter::init(!blinking_bmp))
return;
m_blinking_bitmap = blinking_bmp;
m_blinking_bitmap->activate();
}
void HighlighterForWx::invalidate()
{
Highlighter::invalidate();
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;
}
else if (m_blinking_bitmap) {
m_blinking_bitmap->invalidate();
m_blinking_bitmap = nullptr;
}
}
void HighlighterForWx::blink()
{
if (m_custom_ctrl && m_show_blink_ptr) {
*m_show_blink_ptr = !*m_show_blink_ptr;
m_custom_ctrl->Refresh();
}
else if (m_blinking_bitmap)
m_blinking_bitmap->blink();
else
return;
Highlighter::blink();
}
}// GUI
}//Slicer

View File

@ -374,6 +374,67 @@ private:
bool show {false};
};
// ----------------------------------------------------------------------------
// Highlighter
// ----------------------------------------------------------------------------
namespace Slic3r {
namespace GUI {
class OG_CustomCtrl;
// Highlighter is used as an instrument to put attention to some UI control
class Highlighter
{
int m_blink_counter { 0 };
wxTimer m_timer;
public:
Highlighter() {}
~Highlighter() {}
void set_timer_owner(wxWindow* owner, int timerid = wxID_ANY);
virtual void bind_timer(wxWindow* owner) = 0;
bool init(bool input_failed);
void blink();
void invalidate();
};
class HighlighterForWx : public Highlighter
{
// There are 2 possible cases to use HighlighterForWx:
// - using a BlinkingBitmap. Change state of this bitmap
BlinkingBitmap* m_blinking_bitmap { nullptr };
// - using OG_CustomCtrl where arrow will be rendered and flag indicated "show/hide" state of this arrow
OG_CustomCtrl* m_custom_ctrl { nullptr };
bool* m_show_blink_ptr { nullptr };
public:
HighlighterForWx() {}
~HighlighterForWx() {}
void bind_timer(wxWindow* owner) override;
void init(BlinkingBitmap* blinking_bitmap);
void init(std::pair<OG_CustomCtrl*, bool*>);
void blink();
void invalidate();
};
/*
class HighlighterForImGUI : public Highlighter
{
public:
HighlighterForImGUI() {}
~HighlighterForImGUI() {}
void init();
void blink();
void invalidate();
};
*/
} // GUI
} // Slic3r
#endif // slic3r_GUI_wxExtensions_hpp_

View File

@ -3,7 +3,7 @@
set(SLIC3R_APP_NAME "PrusaSlicer")
set(SLIC3R_APP_KEY "PrusaSlicer")
set(SLIC3R_VERSION "2.4.0-rc")
set(SLIC3R_VERSION "2.4.0")
set(SLIC3R_BUILD_ID "PrusaSlicer-${SLIC3R_VERSION}+UNKNOWN")
set(SLIC3R_RC_VERSION "2,4,0,0")
set(SLIC3R_RC_VERSION_DOTS "2.4.0.0")