OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::UnsavedChangesDialog Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/UnsavedChangesDialog.hpp>

Inheritance diagram for Slic3r::GUI::UnsavedChangesDialog:
Collaboration diagram for Slic3r::GUI::UnsavedChangesDialog:

Classes

struct  PresetData
struct  SyncExtruderParams

Public Member Functions

int getUpdateItemCount ()
 UnsavedChangesDialog (Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, bool no_transfer=false)
 UnsavedChangesDialog (const wxString &caption, const wxString &header, const std::string &app_config_key, int act_buttons)
 UnsavedChangesDialog (const wxString &caption, const wxString &header, DynamicConfig *config, int from, int to, bool left_to_right, NozzleVolumeType nozzle)
 ~UnsavedChangesDialog () override=default
int ShowModal () override
void build (Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, const wxString &header="")
void update (Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, const wxString &header)
void update_list (SyncExtruderParams *params=nullptr)
std::string subreplace (std::string resource_str, std::string sub_str, std::string new_str)
void update_tree (Preset::Type type, PresetCollection *presets)
void update_tree (Preset::Type type, DynamicConfig *config, int from, int to)
void show_info_line (Action action, std::string preset_name="")
void update_config (Action action)
void close (Action action)
bool save (PresetCollection *dependent_presets, bool show_save_preset_dialog=true)
bool save_preset () const
bool transfer_changes () const
bool discard () const
const std::vector< UnsavedChangesDialog::PresetData > & get_names_and_types ()
bool get_save_to_project_option ()
std::string get_preset_name ()
std::vector< std::string > get_unselected_options (Preset::Type type)
std::vector< std::string > get_selected_options (Preset::Type type)
std::vector< std::string > get_selected_options ()
bool has_unselected_options ()
void EndModal (int retCode) override
float scale_factor () const
float prev_scale_factor () const
void set_scale_factor (float v)
void set_prev_scale_factor (float v)
void set_em_unit (int v)
bool force_rescale () const
int em_unit () const
const wxFont & normal_font () const
void enable_force_rescale ()

Protected Member Functions

void on_dpi_changed (const wxRect &suggested_rect) override
void on_sys_color_changed () override
bool check_option_valid ()

Protected Attributes

wxPanel * m_top_line
wxPanel * m_panel_tab
wxPanel * m_table_top
wxPanel * title_block_middle
wxPanel * title_block_right
wxStaticText * static_temp_title
wxStaticText * static_oldv_title
wxStaticText * static_newv_title
wxBoxSizer * m_sizer_bottom
Button * m_save_btn { nullptr }
Button * m_transfer_btn { nullptr }
Button * m_discard_btn { nullptr }
Button * m_cancel_btn { nullptr }
wxStaticText * m_action_line { nullptr }
wxStaticText * m_info_line { nullptr }
wxScrolledWindow * m_scrolledWindow { nullptr }
bool m_has_long_strings { false }
int m_save_btn_id { wxID_ANY }
int m_move_btn_id { wxID_ANY }
int m_continue_btn_id { wxID_ANY }
std::string m_app_config_key
Action m_exit_action {Action::Undef}

Static Protected Attributes

static constexpr char ActTransfer [] = "transfer"
static constexpr char ActDiscard [] = "discard"
static constexpr char ActSave [] = "save"

Private Member Functions

void update_em_unit ()
bool is_new_scale_factor () const
void rescale (const wxRect &suggested_rect)

Private Attributes

std::vector< PresetItem > m_presetitems
std::vector< PresetData > names_and_types
int m_buttons { ActionButtons::TRANSFER | ActionButtons::SAVE }
std::string m_new_selected_preset_name
float m_scale_factor
int m_em_unit
wxFont m_normal_font
float m_prev_scale_factor
bool m_can_rescale
bool m_force_rescale
int m_new_font_point_size

Detailed Description


Class Documentation

◆ Slic3r::GUI::UnsavedChangesDialog::SyncExtruderParams

struct Slic3r::GUI::UnsavedChangesDialog::SyncExtruderParams
Collaboration diagram for Slic3r::GUI::UnsavedChangesDialog::SyncExtruderParams:
Class Members
DynamicConfig * config
int from
bool left_to_right
NozzleVolumeType nozzle
int to

Constructor & Destructor Documentation

◆ UnsavedChangesDialog() [1/3]

Slic3r::GUI::UnsavedChangesDialog::UnsavedChangesDialog ( Preset::Type type,
PresetCollection * dependent_presets,
const std::string & new_selected_preset,
bool no_transfer = false )
850 : m_new_selected_preset_name(new_selected_preset)
851 , DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe),
852 wxID_ANY,
853 _L("Transfer or discard changes"),
854 wxDefaultPosition,
855 wxDefaultSize,
856 wxCAPTION | wxCLOSE_BOX)
857{
858 if (new_selected_preset.empty() || no_transfer)
859 m_buttons &= ~ActionButtons::TRANSFER;
860 build(type, dependent_presets, new_selected_preset);
861 this->CenterOnScreen();
862 wxGetApp().UpdateDlgDarkUI(this);
863}
#define _L(s)
Definition OBJ.cpp:34
std::string m_new_selected_preset_name
Definition UnsavedChangesDialog.hpp:342
int m_buttons
Definition UnsavedChangesDialog.hpp:340
void build(Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, const wxString &header="")
Definition UnsavedChangesDialog.cpp:882
@ TRANSFER
Definition UnsavedChangesDialog.hpp:251

References _L, build(), m_buttons, m_new_selected_preset_name, and Slic3r::GUI::TRANSFER.

Here is the call graph for this function:

◆ UnsavedChangesDialog() [2/3]

Slic3r::GUI::UnsavedChangesDialog::UnsavedChangesDialog ( const wxString & caption,
const wxString & header,
const std::string & app_config_key,
int act_buttons )
820 : DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe),
821 wxID_ANY,
822 caption + ": " + _L("unsaved changes"),
823 wxDefaultPosition,
824 wxDefaultSize,
825 wxCAPTION | wxCLOSE_BOX)
826 , m_app_config_key(app_config_key)
827 , m_buttons(act_buttons)
828{
829 build(Preset::TYPE_INVALID, nullptr, "", header);
830 this->CenterOnScreen();
831 wxGetApp().UpdateDlgDarkUI(this);
832}
std::string m_app_config_key
Definition UnsavedChangesDialog.hpp:309
@ TYPE_INVALID
Definition Preset.hpp:245

References _L, build(), m_app_config_key, m_buttons, and Slic3r::Preset::TYPE_INVALID.

Here is the call graph for this function:

◆ UnsavedChangesDialog() [3/3]

Slic3r::GUI::UnsavedChangesDialog::UnsavedChangesDialog ( const wxString & caption,
const wxString & header,
DynamicConfig * config,
int from,
int to,
bool left_to_right,
NozzleVolumeType nozzle )
835 : DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe),
836 wxID_ANY,
837 caption,
838 wxDefaultPosition,
839 wxDefaultSize,
840 wxCAPTION | wxCLOSE_BOX)
842{
843 SyncExtruderParams params { config, from, to, left_to_right, nozzle };
844 build(Preset::TYPE_PRINT, reinterpret_cast<PresetCollection*>(&params), "SyncExtruderParams", header);
845 this->CenterOnScreen();
846 wxGetApp().UpdateDlgDarkUI(this);
847}
Definition UnsavedChangesDialog.hpp:347
@ TYPE_PRINT
Definition Preset.hpp:246
@ DONT_SAVE
Definition UnsavedChangesDialog.hpp:254
@ SAVE
Definition UnsavedChangesDialog.hpp:253

References build(), Slic3r::GUI::DONT_SAVE, m_buttons, Slic3r::GUI::SAVE, and Slic3r::Preset::TYPE_PRINT.

Here is the call graph for this function:

◆ ~UnsavedChangesDialog()

Slic3r::GUI::UnsavedChangesDialog::~UnsavedChangesDialog ( )
overridedefault

Member Function Documentation

◆ build()

void Slic3r::GUI::UnsavedChangesDialog::build ( Preset::Type type,
PresetCollection * dependent_presets,
const std::string & new_selected_preset,
const wxString & header = "" )
883{
884 SetBackgroundColour(*wxWHITE);
885
886 wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL);
887
888 m_top_line = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
889 m_top_line->SetBackgroundColour(wxColour(166, 169, 170));
890
891 m_sizer_main->Add(m_top_line, 0, wxEXPAND, 0);
892
893 m_sizer_main->Add(0, 0, 0, wxTOP, 20);
894
895 m_action_line = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, UNSAVE_CHANGE_DIALOG_ACTION_LINE_SIZE, 0);
897 m_action_line->SetForegroundColour(wxColour("#363636"));
898 m_action_line->Wrap(-1);
899 m_sizer_main->Add(m_action_line, 0, wxLEFT | wxRIGHT, 20);
900
901 m_sizer_main->Add(0, 0, 0, wxTOP, 12);
902
903 SyncExtruderParams *params = nullptr;
904 if (new_selected_preset == "SyncExtruderParams") {
905 params = reinterpret_cast<SyncExtruderParams *>(dependent_presets);
906 dependent_presets = nullptr;
907 }
908
909 m_panel_tab = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(UNSAVE_CHANGE_DIALOG_SCROLL_WINDOW_SIZE.x, -1), wxTAB_TRAVERSAL);
910 m_panel_tab->SetBackgroundColour(wxColour("#D9D9D9"));
911 wxBoxSizer *m_sizer_tab = new wxBoxSizer(wxVERTICAL);
912
913 m_table_top = new wxPanel(m_panel_tab, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
914 m_table_top->SetBackgroundColour(wxColour("#D9D9D9"));
915
916 wxBoxSizer *m_sizer_top = new wxBoxSizer(wxHORIZONTAL);
917
918 // m_sizer_top->Add(0, 0, 0, wxLEFT, UNSAVE_CHANGE_DIALOG_FIRST_VALUE_WIDTH);
919 auto m_panel_temp = new wxPanel(m_table_top, wxID_ANY, wxDefaultPosition, wxSize(UNSAVE_CHANGE_DIALOG_FIRST_VALUE_WIDTH, -1), wxTAB_TRAVERSAL);
920 wxBoxSizer *top_title_temp_v = new wxBoxSizer(wxVERTICAL);
921 top_title_temp_v->SetMinSize(wxSize(UNSAVE_CHANGE_DIALOG_VALUE_WIDTH, -1));
922 wxBoxSizer *top_title_temp_h = new wxBoxSizer(wxHORIZONTAL);
923 static_temp_title = new wxStaticText(m_panel_temp, wxID_ANY, _L("Settings"), wxDefaultPosition, wxDefaultSize, 0);
925 static_temp_title->Wrap(-1);
926 static_temp_title->SetForegroundColour(wxColour("#363636"));
927 top_title_temp_h->Add(static_temp_title, 0, wxALIGN_CENTER | wxBOTTOM | wxTOP, 5);
928 top_title_temp_v->Add(top_title_temp_h, 1, wxALIGN_CENTER, 0);
929 m_panel_temp->SetSizer(top_title_temp_v);
930 m_panel_temp->Layout();
931 m_sizer_top->Add(m_panel_temp, 1, wxALIGN_CENTER, 0);
932
933 title_block_middle = new wxPanel(m_table_top, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
934 title_block_middle->SetBackgroundColour(wxColour(172, 172, 172));
935
936 m_sizer_top->Add(title_block_middle, 0, wxBOTTOM | wxEXPAND | wxTOP, 2);
937 auto m_panel_oldv = new wxPanel( m_table_top, wxID_ANY, wxDefaultPosition, wxSize(UNSAVE_CHANGE_DIALOG_VALUE_WIDTH,-1), wxTAB_TRAVERSAL );
938 wxBoxSizer *top_title_oldv = new wxBoxSizer(wxVERTICAL);
939 wxBoxSizer *top_title_oldv_h = new wxBoxSizer(wxHORIZONTAL);
940
941 std::string ucd_pt = wxGetApp().preset_bundle->printers.get_edited_preset().get_printer_type(wxGetApp().preset_bundle);
942 static_oldv_title = new wxStaticText(m_panel_oldv, wxID_ANY, params ? _L(DevPrinterConfigUtil::get_toolhead_display_name(ucd_pt, DEPUTY_EXTRUDER_ID, ToolHeadComponent::Nozzle, ToolHeadNameCase::SentenceCase)) + ": " + get_nozzle_volume_type_name(params->nozzle) : _L("Old Value"), wxDefaultPosition, wxDefaultSize, 0);
944 static_oldv_title->Wrap(-1);
945 static_oldv_title->SetForegroundColour(params && params->left_to_right ? wxGetApp().get_label_clr_modified() : wxColour("#363636"));
946 top_title_oldv_h->Add(static_oldv_title, 0, wxALIGN_CENTER | wxBOTTOM | wxTOP, 5);
947 top_title_oldv->Add(top_title_oldv_h, 1, wxALIGN_CENTER, 0);
948 m_panel_oldv->SetSizer(top_title_oldv);
949 m_panel_oldv->Layout();
950 m_sizer_top->Add(m_panel_oldv, 0, wxALIGN_CENTER, 0);
951
952 title_block_right = new wxPanel(m_table_top, wxID_ANY, wxDefaultPosition, wxSize(1, -1), wxTAB_TRAVERSAL);
953 title_block_right->SetBackgroundColour(wxColour(172, 172, 172));
954
955 m_sizer_top->Add(title_block_right, 0, wxBOTTOM | wxEXPAND | wxTOP, 2);
956
957 auto m_panel_newv = new wxPanel( m_table_top, wxID_ANY, wxDefaultPosition, wxSize( UNSAVE_CHANGE_DIALOG_VALUE_WIDTH,-1 ), wxTAB_TRAVERSAL );
958 wxBoxSizer *top_title_newv = new wxBoxSizer(wxVERTICAL);
959 wxBoxSizer *top_title_newv_h = new wxBoxSizer(wxHORIZONTAL);
960
962 wxDefaultPosition, wxDefaultSize, 0);
964 static_newv_title->Wrap(-1);
965 static_newv_title->SetForegroundColour(params && !params->left_to_right ? wxGetApp().get_label_clr_modified() : wxColour("#363636"));
966
967 top_title_newv_h->Add(static_newv_title, 0, wxALIGN_CENTER | wxBOTTOM | wxTOP, 5);
968
969 top_title_newv->Add(top_title_newv_h, 1, wxALIGN_CENTER, 0);
970
971 m_panel_newv->SetSizer(top_title_newv);
972 m_panel_newv->Layout();
973 m_sizer_top->Add(m_panel_newv, 0, wxALIGN_CENTER, 0);
974 //m_sizer_top->Add(top_title_newv, 1, wxALIGN_CENTER, 0);
975
976 m_table_top->SetSizer(m_sizer_top);
977 m_table_top->Layout();
978 m_sizer_top->Fit(m_table_top);
979 m_sizer_tab->Add(m_table_top, 1, 0, 0);
980
981 m_scrolledWindow = new wxScrolledWindow(m_panel_tab, wxID_ANY, wxDefaultPosition, UNSAVE_CHANGE_DIALOG_SCROLL_WINDOW_SIZE, wxNO_BORDER|wxVSCROLL);
982 m_scrolledWindow->SetScrollRate(0, FromDIP(20));
983 m_scrolledWindow->SetBackgroundColour(GREY200);
984 m_sizer_bottom = new wxBoxSizer(wxVERTICAL);
985 m_sizer_bottom->Add(m_scrolledWindow, 1, wxEXPAND, 0);
986 m_sizer_tab->Add(m_sizer_bottom, 0, wxEXPAND, 0);
987
988 m_panel_tab->SetSizer(m_sizer_tab);
989 m_panel_tab->Layout();
990 m_sizer_tab->Fit(m_panel_tab);
991 m_sizer_main->Add(m_panel_tab, 0, wxEXPAND | wxLEFT | wxRIGHT, 20);
992
993 m_sizer_main->Add(0, 0, 0, wxTOP, 9);
994
995 /* m_info_line = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1, 44), 0);
996 m_info_line->SetFont(::Label::Body_13);
997 m_info_line->Wrap(-1);
998 m_info_line->SetForegroundColour(wxColour(255, 111, 0));
999 m_sizer_main->Add(m_info_line, 0, wxLEFT | wxRIGHT, 20);*/
1000
1001 wxBoxSizer *m_sizer_button = new wxBoxSizer(wxHORIZONTAL);
1002
1003 auto checkbox_sizer = new wxBoxSizer(wxHORIZONTAL);
1004 auto checkbox = new ::CheckBox(this, wxID_APPLY);
1005 checkbox_sizer->Add(checkbox, 0, wxALL | wxALIGN_CENTER, FromDIP(2));
1006
1007 auto checkbox_text = new wxStaticText(this, wxID_ANY, _L("Remember my choice."), wxDefaultPosition, wxDefaultSize, 0);
1008 checkbox_sizer->Add(checkbox_text, 0, wxALL | wxALIGN_CENTER, FromDIP(2));
1009 checkbox_text->SetFont(::Label::Body_13);
1010 checkbox_text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#323A3D")));
1011 m_sizer_button->Add(checkbox_sizer, 0, wxLEFT, FromDIP(22));
1012 checkbox_sizer->Show(bool(m_buttons & REMEMBER_CHOISE));
1013
1014 if (dependent_presets != nullptr) {
1015 auto wiki_btn = new Button(this, "", "toolbar_wiki", 0, 15);
1016 auto wiki_url = "https://www.orcaslicer.com/wiki/transfer_discard_changes";
1017 wiki_btn->SetToolTip(_L("Wiki Guide") + "\n" + wiki_url);
1018 wiki_btn->SetStyle(ButtonStyle::Confirm, ButtonType::Circle);
1019 wiki_btn->SetCanFocus(false);
1020 wiki_btn->Bind(wxEVT_LEFT_DOWN, ([wiki_url](auto& e) {wxLaunchDefaultBrowser(wiki_url);}));
1021
1022 m_sizer_button->Add(wiki_btn, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, FromDIP(22));
1023 }
1024
1025 m_sizer_button->Add(0, 0, 1, 0, 0);
1026
1027 // Add Buttons
1028 auto add_btn = [this, m_sizer_button, dependent_presets](Button **btn, int &btn_id, const std::string &icon_name, Action close_act, const wxString &label,
1029 bool focus, bool process_enable = true) {
1030 *btn = new Button(this, _L(label));
1031
1033
1034 (*btn)->Bind(wxEVT_BUTTON, [this, close_act, dependent_presets](wxEvent &) {
1035 bool save_names_and_types = close_act == Action::Save || (close_act == Action::Transfer && ActionButtons::KEEP & m_buttons);
1036 if (save_names_and_types && !save(dependent_presets, close_act == Action::Save)) return;
1037 close(close_act);
1038 });
1039
1040 // if (process_enable) (*btn)->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent &evt) { evt.Enable(m_tree->has_selection()); });
1041 (*btn)->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent &e) {
1043 e.Skip();
1044 });
1045
1046 m_sizer_button->Add(*btn, 0, wxLEFT, FromDIP(ButtonProps::ChoiceButtonGap()));
1047 };
1048
1049 // "Transfer" / "Keep" button
1051 const PresetCollection* switched_presets = type == Preset::TYPE_INVALID ? nullptr : wxGetApp().get_tab(type)->get_presets();
1052 if (dependent_presets && switched_presets && (type == dependent_presets->type() ?
1053 dependent_presets->get_edited_preset().printer_technology() == dependent_presets->find_preset(new_selected_preset)->printer_technology() :
1054 switched_presets->get_edited_preset().printer_technology() == switched_presets->find_preset(new_selected_preset)->printer_technology()))
1055 add_btn(&m_transfer_btn, m_move_btn_id, "menu_paste", Action::Transfer, switched_presets->get_edited_preset().name == new_selected_preset ? _L("Transfer") : _L("Transfer"), true);
1056 }
1058 add_btn(&m_transfer_btn, m_move_btn_id, "menu_paste", Action::Transfer, _L("Transfer"), true);
1059
1060 bool is_copy = new_selected_preset == "SyncExtruderParams";
1061 { // "Don't save" / "Discard" button
1062 std::string btn_icon = (ActionButtons::DONT_SAVE & m_buttons) ? "" : (dependent_presets || (ActionButtons::KEEP & m_buttons)) ? "blank_16" : "exit";
1063 wxString btn_label = (ActionButtons::DONT_SAVE & m_buttons) ? (is_copy ? _L("No") : _L("Don't save")) : _L("Discard");
1064 add_btn(&m_discard_btn, m_continue_btn_id, btn_icon, Action::Discard, btn_label, false);
1065 }
1066
1067 // "Save" button
1068 if (ActionButtons::SAVE & m_buttons) add_btn(&m_save_btn, m_save_btn_id, "save", is_copy ? Action::Transfer : Action::Save, is_copy ? _L("Yes") : _L("Save"), false);
1069
1070 if (dependent_presets != nullptr) {
1071 const wxString previous_profile = from_u8(dependent_presets->get_edited_preset().name);
1072 const wxString new_profile = new_selected_preset.empty() ? _L("the new profile") : from_u8(new_selected_preset);
1073
1074 if (m_discard_btn) {
1075 m_discard_btn->SetToolTip(format_wxstr(
1076 _L("Switch to\n\"%1%\"\ndiscarding any changes made in\n\"%2%\"."),
1077 new_profile,
1078 previous_profile));
1079 }
1080
1081 if (m_transfer_btn) {
1082 m_transfer_btn->SetToolTip(format_wxstr(
1083 _L("All \"New Value\" settings modified in\n\"%1%\"\nwill be transferred to\n\"%2%\"."),
1084 previous_profile,
1085 new_profile));
1086 }
1087
1088 if (m_save_btn) {
1089 m_save_btn->SetToolTip(format_wxstr(
1090 _L("All \"New Value\" settings are saved in\n\"%1%\"\nand \"%2%\" will open without any changes."),
1091 previous_profile,
1092 new_profile));
1093 }
1094 }
1095
1096 /* ScalableButton *cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, true, 24);
1097 buttons->Add(cancel_btn, 1, wxLEFT | wxRIGHT, 5);
1098 cancel_btn->SetFont(btn_font);*/
1099 /* m_cancel_btn = new Button(this, _L("Cancel"));
1100 m_cancel_btn->SetTextColor(wxColour(107, 107, 107));
1101 m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [this](wxEvent &) { this->EndModal(wxID_CANCEL); });
1102 m_cancel_btn->SetMinSize(UNSAVE_CHANGE_DIALOG_BUTTON_SIZE);
1103 m_cancel_btn->SetCornerRadius(12);
1104 m_sizer_button->Add(m_cancel_btn, 0, wxLEFT, 5);
1105 m_sizer_button->Add(0,0,0,wxRIGHT,20);*/
1106
1107 if (!m_app_config_key.empty()) {}
1108
1109 m_sizer_button->Add(0, 0, 0, wxRIGHT, 20);
1110 m_sizer_main->Add(m_sizer_button, 0, wxEXPAND | wxTOP, 6);
1111 m_sizer_main->Add(0, 0, 1, wxTOP, 18);
1112
1113 if (params) {
1114 if (params->left_to_right)
1115 update_tree(type, params->config, params->from, params->to);
1116 else
1117 update_tree(type, params->config, params->to, params->from);
1118 m_action_line->SetLabel(header);
1120 update_list(params);
1121 } else {
1122 update(type, dependent_presets, new_selected_preset, header);
1123 }
1124 //SetSizer(topSizer);
1125 //topSizer->SetSizeHints(this);
1126
1128
1129 SetSizerAndFit(m_sizer_main);
1130 Layout();
1131 Fit();
1132 // Centre(wxBOTH);
1133}
@ Confirm
Definition Button.hpp:25
@ Regular
Definition Button.hpp:24
@ Circle
Definition Button.hpp:37
@ Choice
Definition Button.hpp:33
#define DEPUTY_EXTRUDER_ID
Definition DevDefs.h:102
#define MAIN_EXTRUDER_ID
Definition DevDefs.h:101
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
#define UNSAVE_CHANGE_DIALOG_ACTION_LINE_SIZE
Definition UnsavedChangesDialog.cpp:805
#define UNSAVE_CHANGE_DIALOG_SCROLL_WINDOW_SIZE
Definition UnsavedChangesDialog.cpp:804
#define GREY200
Definition UnsavedChangesDialog.cpp:816
#define UNSAVE_CHANGE_DIALOG_FIRST_VALUE_WIDTH
Definition UnsavedChangesDialog.cpp:806
#define UNSAVE_CHANGE_DIALOG_VALUE_WIDTH
Definition UnsavedChangesDialog.cpp:807
static int ChoiceButtonGap()
Definition Button.hpp:19
static wxFont Body_13
Definition Label.hpp:54
static std::string get_toolhead_display_name(const std::string &type_str, int ext_id, ToolHeadComponent component, ToolHeadNameCase name_case=ToolHeadNameCase::TitleCase, bool short_name=false)
Definition DevConfigUtil.cpp:379
Button * m_transfer_btn
Definition UnsavedChangesDialog.hpp:297
void update_tree(Preset::Type type, PresetCollection *presets)
Definition UnsavedChangesDialog.cpp:1554
int m_continue_btn_id
Definition UnsavedChangesDialog.hpp:307
void update_list(SyncExtruderParams *params=nullptr)
Definition UnsavedChangesDialog.cpp:1329
wxBoxSizer * m_sizer_bottom
Definition UnsavedChangesDialog.hpp:293
bool save(PresetCollection *dependent_presets, bool show_save_preset_dialog=true)
Definition UnsavedChangesDialog.cpp:1176
int m_save_btn_id
Definition UnsavedChangesDialog.hpp:305
wxStaticText * m_action_line
Definition UnsavedChangesDialog.hpp:300
wxScrolledWindow * m_scrolledWindow
Definition UnsavedChangesDialog.hpp:302
wxPanel * title_block_right
Definition UnsavedChangesDialog.hpp:289
int m_move_btn_id
Definition UnsavedChangesDialog.hpp:306
wxPanel * title_block_middle
Definition UnsavedChangesDialog.hpp:288
void update(Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, const wxString &header)
Definition UnsavedChangesDialog.cpp:1263
wxPanel * m_top_line
Definition UnsavedChangesDialog.hpp:285
void close(Action action)
Definition UnsavedChangesDialog.cpp:1167
wxStaticText * static_temp_title
Definition UnsavedChangesDialog.hpp:290
wxStaticText * static_newv_title
Definition UnsavedChangesDialog.hpp:292
Button * m_discard_btn
Definition UnsavedChangesDialog.hpp:298
void show_info_line(Action action, std::string preset_name="")
Definition UnsavedChangesDialog.cpp:1135
wxPanel * m_panel_tab
Definition UnsavedChangesDialog.hpp:286
wxPanel * m_table_top
Definition UnsavedChangesDialog.hpp:287
wxStaticText * static_oldv_title
Definition UnsavedChangesDialog.hpp:291
Button * m_save_btn
Definition UnsavedChangesDialog.hpp:296
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
wxMouseEvent
Definition CameraPopup.cpp:47
wxString format_wxstr(const char *fmt, TArgs &&... args)
Definition format.hpp:22
Action
Definition UnsavedChangesDialog.hpp:258
@ Transfer
Definition UnsavedChangesDialog.hpp:260
@ Undef
Definition UnsavedChangesDialog.hpp:259
@ Save
Definition UnsavedChangesDialog.hpp:262
@ Discard
Definition UnsavedChangesDialog.hpp:261
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
wxString get_nozzle_volume_type_name(NozzleVolumeType type)
Definition CalibUtils.cpp:138
ActionButtons
Definition UnsavedChangesDialog.hpp:250
@ KEEP
Definition UnsavedChangesDialog.hpp:252
@ REMEMBER_CHOISE
Definition UnsavedChangesDialog.hpp:255
@ Nozzle
Definition DevConfigUtil.h:35
@ SentenceCase
Definition DevConfigUtil.h:42

References _L, Label::Body_13, Choice, ButtonProps::ChoiceButtonGap(), Circle, close(), Slic3r::GUI::UnsavedChangesDialog::SyncExtruderParams::config, Confirm, StateColor::darkModeColorFor(), DEPUTY_EXTRUDER_ID, Slic3r::GUI::Discard, Slic3r::GUI::DONT_SAVE, Slic3r::PresetCollection::find_preset(), Slic3r::GUI::format_wxstr(), Slic3r::GUI::UnsavedChangesDialog::SyncExtruderParams::from, Slic3r::GUI::from_u8(), Slic3r::PresetCollection::get_edited_preset(), Slic3r::GUI::get_nozzle_volume_type_name(), Slic3r::DevPrinterConfigUtil::get_toolhead_display_name(), GREY200, Slic3r::GUI::KEEP, Slic3r::GUI::UnsavedChangesDialog::SyncExtruderParams::left_to_right, m_action_line, m_app_config_key, m_buttons, m_continue_btn_id, m_discard_btn, m_move_btn_id, m_panel_tab, m_save_btn, m_save_btn_id, m_scrolledWindow, m_sizer_bottom, m_table_top, m_top_line, m_transfer_btn, MAIN_EXTRUDER_ID, Slic3r::Preset::name, Slic3r::Nozzle, Slic3r::GUI::UnsavedChangesDialog::SyncExtruderParams::nozzle, Slic3r::Preset::printer_technology(), Regular, Slic3r::GUI::REMEMBER_CHOISE, Slic3r::GUI::SAVE, Slic3r::GUI::Save, save(), Slic3r::SentenceCase, show_info_line(), static_newv_title, static_oldv_title, static_temp_title, title_block_middle, title_block_right, Slic3r::GUI::UnsavedChangesDialog::SyncExtruderParams::to, Slic3r::GUI::TRANSFER, Slic3r::GUI::Transfer, Slic3r::PresetCollection::type(), Slic3r::Preset::TYPE_INVALID, Slic3r::GUI::Undef, UNSAVE_CHANGE_DIALOG_ACTION_LINE_SIZE, UNSAVE_CHANGE_DIALOG_FIRST_VALUE_WIDTH, UNSAVE_CHANGE_DIALOG_SCROLL_WINDOW_SIZE, UNSAVE_CHANGE_DIALOG_VALUE_WIDTH, update(), update_list(), update_tree(), Slic3r::GUI::wxMouseEvent, and wxStaticText.

Referenced by UnsavedChangesDialog(), UnsavedChangesDialog(), and UnsavedChangesDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_option_valid()

bool Slic3r::GUI::UnsavedChangesDialog::check_option_valid ( )
protected
1686{
1687 return true;
1688}

Referenced by close().

Here is the caller graph for this function:

◆ close()

void Slic3r::GUI::UnsavedChangesDialog::close ( Action action)
1168{
1169 if (action == Action::Transfer) {
1171 }
1172 m_exit_action = action;
1173 this->EndModal(wxID_CLOSE);
1174}
void EndModal(int retCode) override
Definition GUI_Utils.hpp:305
Action m_exit_action
Definition UnsavedChangesDialog.hpp:316
bool check_option_valid()
Definition UnsavedChangesDialog.cpp:1685

References check_option_valid(), Slic3r::GUI::DPIDialog::EndModal(), m_exit_action, and Slic3r::GUI::Transfer.

Referenced by build().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ discard()

bool Slic3r::GUI::UnsavedChangesDialog::discard ( ) const
inline
378{ return m_exit_action == Action::Discard; }

References Slic3r::GUI::Discard, and m_exit_action.

Referenced by Slic3r::GUI::GUI_App::check_and_keep_current_preset_changes().

Here is the caller graph for this function:

◆ em_unit()

int Slic3r::GUI::DPIAware< wxDialog >::em_unit ( ) const
inlineinherited
203{ return m_em_unit; }
Definition GUI_Utils.hpp:107

Referenced by Slic3r::GUI::AuxiliaryDialog::AuxiliaryDialog(), Slic3r::GUI::CopyrightsDialog::CopyrightsDialog(), Slic3r::GUI::DesignTextDialog::DesignTextDialog(), Slic3r::GUI::EditGCodeDialog::EditGCodeDialog(), Slic3r::GUI::FileArchiveDialog::FileArchiveDialog(), Slic3r::GUI::MsgNoUpdates::MsgNoUpdates(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::OAuthDialog::OAuthDialog(), Slic3r::GUI::ParamsDialog::ParamsDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::SettingsDialog::SettingsDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), anonymous_namespace{3DPrinterOS.cpp}::UploadOptionsDialog::UploadOptionsDialog(), Slic3r::GUI::PublishSettingsDialog::add_row_ui(), Slic3r::GUI::DiffPresetDialog::complete_dialog_creation(), Slic3r::GUI::DiffPresetDialog::create_edit_sizer(), Slic3r::GUI::DiffPresetDialog::create_presets_sizer(), Slic3r::GUI::DiffPresetDialog::create_tree(), Slic3r::GUI::ElegooPrintHostSendDialog::init(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::GUI::PrintHostSendDialog::init(), Slic3r::GUI::AboutDialog::on_dpi_changed(), Slic3r::GUI::AuxiliaryDialog::on_dpi_changed(), Slic3r::GUI::BedShapeDialog::on_dpi_changed(), Slic3r::GUI::ConfigWizard::on_dpi_changed(), Slic3r::GUI::CopyrightsDialog::on_dpi_changed(), Slic3r::GUI::DiffPresetDialog::on_dpi_changed(), Slic3r::GUI::EditGCodeDialog::on_dpi_changed(), Slic3r::GUI::FileArchiveDialog::on_dpi_changed(), Slic3r::GUI::OAuthDialog::on_dpi_changed(), Slic3r::GUI::ObjectTableDialog::on_dpi_changed(), Slic3r::GUI::ParamsDialog::on_dpi_changed(), Slic3r::GUI::PhysicalPrinterDialog::on_dpi_changed(), Slic3r::GUI::PrintHostQueueDialog::on_dpi_changed(), Slic3r::GUI::PurgeModeDialog::on_dpi_changed(), Slic3r::GUI::SavePresetDialog::on_dpi_changed(), Slic3r::GUI::SendSystemInfoDialog::on_dpi_changed(), Slic3r::GUI::SettingsDialog::on_dpi_changed(), and Slic3r::GUI::UnsavedChangesDialog::on_dpi_changed().

Here is the caller graph for this function:

◆ enable_force_rescale()

void Slic3r::GUI::DPIAware< wxDialog >::enable_force_rescale ( )
inlineinherited
206{ m_force_rescale = true; }

◆ EndModal()

void Slic3r::GUI::DPIDialog::EndModal ( int retCode)
inlineoverrideinherited
306 {
307 if (!dialogStack.empty() && dialogStack.front() != this) {
308 // This is a bug in wxWidgets
309 // when the dialog is not top modal dialog, EndModal() just hide dialog without quit
310 // the modal event loop. And the modal event loop blocks us from bottom widgets.
311 // Solution: let user click it manually or close outside. FIXME
312 BOOST_LOG_TRIVIAL(warning) << "DPIAware::EndModal Error: dialogStack is not empty, but top dialog is not this one. retCode=" << retCode;
313 return;
314 }
315
316 return wxDialog::EndModal(retCode);
317 }
std::deque< wxDialog * > dialogStack
Definition GUI_Utils.cpp:549

References Slic3r::GUI::dialogStack.

Referenced by Slic3r::GUI::CloneDialog::CloneDialog(), Slic3r::GUI::ConfigWizard::ConfigWizard(), Slic3r::GUI::CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(), Slic3r::GUI::DeleteConfirmDialog::DeleteConfirmDialog(), Slic3r::GUI::DesignVariableDialog::DesignVariableDialog(), Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::FlashforgeSlotDialog(), Slic3r::GUI::GuideFrame::GuideFrame(), Slic3r::GUI::InputIpAddressDialog::InputIpAddressDialog(), Slic3r::GUI::ManualNozzleCountDialog::ManualNozzleCountDialog(), Slic3r::GUI::MsgUpdateConfig::MsgUpdateConfig(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::MultiChoiceDialog::MultiChoiceDialog(), Slic3r::GUI::NetworkErrorDialog::NetworkErrorDialog(), Slic3r::GUI::NetworkPluginRestartDialog::NetworkPluginRestartDialog(), Slic3r::GUI::PartSkipConfirmDialog::PartSkipConfirmDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::PlateNameEditDialog::PlateNameEditDialog(), Slic3r::GUI::PlateSettingsDialog::PlateSettingsDialog(), Slic3r::GUI::PublishSettingsDialog::PublishSettingsDialog(), Slic3r::GUI::SelectMachineDialog::SelectMachineDialog(), Slic3r::GUI::SendFailedConfirm::SendFailedConfirm(), Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), Slic3r::GUI::SingleChoiceDialog::SingleChoiceDialog(), StepMeshDialog::StepMeshDialog(), Slic3r::GUI::SyncAmsInfoDialog::SyncAmsInfoDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), Slic3r::GUI::UpdatePluginDialog::UpdatePluginDialog(), Slic3r::GUI::UpdateVersionDialog::UpdateVersionDialog(), Slic3r::GUI::wgtDeviceNozzleRackUpgradeDlg::wgtDeviceNozzleRackUpgradeDlg(), Slic3r::GUI::SavePresetDialog::accept(), Slic3r::GUI::MsgDialog::add_button(), Slic3r::GUI::TipsDialog::add_button(), Slic3r::GUI::FilamentPickerDialog::BindEvents(), Slic3r::GUI::PluginPickerDialog::build_capability_ui(), Slic3r::GUI::BedShapeDialog::build_dialog(), Slic3r::GUI::PluginPickerDialog::build_ui(), Slic3r::GUI::UnsavedChangesDialog::close(), Slic3r::GUI::FileArchiveDialog::create_btn_sizer(), Slic3r::GUI::ColorDecomposeDialog::create_button_panel(), Slic3r::GUI::MixedFilamentDialog::create_button_panel(), Slic3r::GUI::CreateFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::CreatePresetForPrinterDialog::create_dialog_buttons(), Slic3r::GUI::EditFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::create_dialog_buttons(), Slic3r::GUI::PreferencesDialog::create_item_language_combobox(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), Slic3r::GUI::PreferencesDialog::create_items(), Slic3r::GUI::CreatePrinterPresetDialog::create_page1_dialog_buttons(), Slic3r::GUI::CreatePrinterPresetDialog::create_page2_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::data_init(), Slic3r::GUI::WebDialog::destroy_silently(), Slic3r::GUI::EditFilamentPresetDialog::edit_preset(), Slic3r::GUI::ConnectPrinterDialog::end_modal(), Slic3r::GUI::PrintHostSendDialog::EndModal(), Slic3r::GUI::ColorPickerDialog::finish(), Slic3r::GUI::WebDialog::finish(), Slic3r::GUI::Newer3mfVersionDialog::get_btn_sizer(), Slic3r::GUI::ScoreDialog::get_button_sizer(), Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), Slic3r::GUI::ExportPresetBundleDialog::InitExportData(), Slic3r::GUI::SelectMachineDialog::navigate_to_timelapse_page(), Slic3r::GUI::BindMachineDialog::on_bind_success(), Slic3r::GUI::ConnectPrinterDialog::on_button_confirm(), Slic3r::GUI::RecenterDialog::on_button_confirm(), Slic3r::GUI::BindMachineDialog::on_cancel(), Slic3r::GUI::EditCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::InputIpAddressDialog::on_cancel(), Slic3r::GUI::NewCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::OAuthDialog::on_cancel(), Slic3r::GUI::PingCodeBindDialog::on_cancel(), Slic3r::GUI::SelectMachineDialog::on_cancel(), Slic3r::GUI::SendToPrinterDialog::on_cancel(), Slic3r::GUI::SyncAmsInfoDialog::on_cancel(), Slic3r::GUI::UnBindMachineDialog::on_cancel(), Slic3r::GUI::WebDialog::on_close_window(), Slic3r::GUI::NetworkPluginDownloadDialog::on_dont_ask(), Slic3r::GUI::NetworkPluginDownloadDialog::on_download(), Slic3r::GUI::EditDevNameDialog::on_edit_name(), Slic3r::GUI::ConfirmBeforeSendDialog::on_hide(), Slic3r::GUI::PrivacyUpdateDialog::on_hide(), Slic3r::GUI::ShortcutCaptureDialog::on_key(), Slic3r::GUI::TextureImportDialog::on_ok_clicked(), Slic3r::GUI::FileArchiveDialog::on_open_button(), Slic3r::GUI::NetworkPluginDownloadDialog::on_remind_later(), Slic3r::GUI::ProjectDropDialog::on_select_cancel(), Slic3r::GUI::SavePresetDialog::on_select_cancel(), Slic3r::GUI::ProjectDropDialog::on_select_ok(), Slic3r::GUI::SendMultiMachinePage::on_send(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip(), Slic3r::GUI::TextureImportDialog::on_skip_clicked(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip_version(), Slic3r::GUI::Cornering_Test_Dlg::on_start(), Slic3r::GUI::FlowRateCalibrationDialog::on_start(), Slic3r::GUI::Input_Shaping_Damp_Test_Dlg::on_start(), Slic3r::GUI::Input_Shaping_Freq_Test_Dlg::on_start(), Slic3r::GUI::MaxVolumetricSpeed_Test_Dlg::on_start(), Slic3r::GUI::PA_Calibration_Dlg::on_start(), Slic3r::GUI::Retraction_Test_Dlg::on_start(), Slic3r::GUI::Temp_Calibration_Dlg::on_start(), Slic3r::GUI::VFA_Test_Dlg::on_start(), Slic3r::GUI::CalibrationDialog::on_start_calibration(), Slic3r::GUI::UnBindMachineDialog::on_unbind_printer(), Slic3r::GUI::PartSkipDialog::OnApplyDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::OnCancel(), Slic3r::GUI::AboutDialog::onCloseDialog(), Slic3r::GUI::CopyrightsDialog::onCloseDialog(), Slic3r::GUI::MultiNozzleSyncDialog::OnRackStatusReadingFinished(), Slic3r::GUI::GuideFrame::OnScriptMessage(), Slic3r::GUI::InputIpAddressDialog::OnTimer(), Slic3r::GUI::KBShortcutsDialog::open_mouse_preferences(), Slic3r::GUI::TroubleshootDialog::PackAll(), Slic3r::GUI::TroubleshootDialog::RebuildSystemProfiles(), Slic3r::GUI::SpeedDialWebDialog::run_action(), Slic3r::GUI::OAuthDialog::Show(), Slic3r::GUI::MultiNozzleSyncDialog::UpdateButton(), and Slic3r::GUI::CreatePrinterPresetDialog::validate_input_valid().

◆ force_rescale()

bool Slic3r::GUI::DPIAware< wxDialog >::force_rescale ( ) const
inlineinherited
201{ return m_force_rescale; }

◆ get_names_and_types()

const std::vector< UnsavedChangesDialog::PresetData > & Slic3r::GUI::UnsavedChangesDialog::get_names_and_types ( )
inline
382{ return names_and_types; }
std::vector< PresetData > names_and_types
Definition UnsavedChangesDialog.hpp:337

References names_and_types.

Referenced by Slic3r::GUI::GUI_App::check_and_keep_current_preset_changes(), and Slic3r::GUI::GUI_App::check_and_save_current_preset_changes().

Here is the caller graph for this function:

◆ get_preset_name()

std::string Slic3r::GUI::UnsavedChangesDialog::get_preset_name ( )
inline
386{ return names_and_types[0].name; }

References names_and_types.

Referenced by Slic3r::GUI::Tab::may_discard_current_dirty_preset().

Here is the caller graph for this function:

◆ get_save_to_project_option()

bool Slic3r::GUI::UnsavedChangesDialog::get_save_to_project_option ( )
inline
383{ return names_and_types[0].save_to_project; }

References names_and_types.

Referenced by Slic3r::GUI::Tab::may_discard_current_dirty_preset().

Here is the caller graph for this function:

◆ get_selected_options() [1/2]

std::vector< std::string > Slic3r::GUI::UnsavedChangesDialog::get_selected_options ( )
inline
400 {
401 //return m_tree->selected_options();
402
403 std::vector<std::string> tmp;
404 for (int i = 0; i < m_presetitems.size(); i++)
405 {
406 tmp.push_back(m_presetitems[i].opt_key);
407 }
408
409 return tmp;
410 }
std::vector< PresetItem > m_presetitems
Definition UnsavedChangesDialog.hpp:335

References m_presetitems.

◆ get_selected_options() [2/2]

std::vector< std::string > Slic3r::GUI::UnsavedChangesDialog::get_selected_options ( Preset::Type type)
inline
389 {
390 //return m_tree->options(type, true);
391 std::vector<std::string> tmp;
392 for (int i = 0; i < m_presetitems.size(); i++) {
393 if (m_presetitems[i].type == type) {
394 tmp.push_back(m_presetitems[i].opt_key);
395 }
396 }
397
398 return tmp;
399 }

References m_presetitems.

Referenced by Slic3r::GUI::GUI_App::check_and_keep_current_preset_changes(), and Slic3r::GUI::Tab::may_discard_current_dirty_preset().

Here is the caller graph for this function:

◆ get_unselected_options()

std::vector< std::string > Slic3r::GUI::UnsavedChangesDialog::get_unselected_options ( Preset::Type type)
inline
388{ /* return m_tree->options(type, false);*/return std::vector<std::string>();}

Referenced by Slic3r::GUI::GUI_App::check_and_keep_current_preset_changes(), Slic3r::GUI::GUI_App::check_and_save_current_preset_changes(), and Slic3r::GUI::Tab::may_discard_current_dirty_preset().

Here is the caller graph for this function:

◆ getUpdateItemCount()

int Slic3r::GUI::UnsavedChangesDialog::getUpdateItemCount ( )
inline
332{ return m_presetitems.size(); }

References m_presetitems.

Referenced by Slic3r::GUI::GUI_App::check_and_keep_current_preset_changes(), and Slic3r::GUI::GUI_App::check_and_save_current_preset_changes().

Here is the caller graph for this function:

◆ has_unselected_options()

bool Slic3r::GUI::UnsavedChangesDialog::has_unselected_options ( )
inline
411{ /*return m_tree->has_unselected_options();*/return false;}

Referenced by Slic3r::GUI::GUI_App::check_and_keep_current_preset_changes().

Here is the caller graph for this function:

◆ is_new_scale_factor()

bool Slic3r::GUI::DPIAware< wxDialog >::is_new_scale_factor ( ) const
inlineprivateinherited
262{ return fabs(m_scale_factor - m_prev_scale_factor) > 0.001; }

◆ normal_font()

◆ on_dpi_changed()

void Slic3r::GUI::UnsavedChangesDialog::on_dpi_changed ( const wxRect & suggested_rect)
overrideprotectedvirtual

Implements Slic3r::GUI::DPIAware< wxDialog >.

1659{
1660 int em = em_unit();
1661
1662 //msw_buttons_rescale(this, em, { wxID_CANCEL, m_move_btn_id, m_continue_btn_id });
1663 for (auto btn : {m_transfer_btn, m_discard_btn, m_save_btn})
1664 if (btn) btn->Rescale();
1665
1666 //m_cancel_btn->SetMinSize(UNSAVE_CHANGE_DIALOG_BUTTON_SIZE);
1667 const wxSize& size = wxSize(70 * em, 30 * em);
1668 SetMinSize(size);
1669 //m_tree->Rescale(em);
1670
1671 Fit();
1672 Refresh();
1673}
int em_unit() const
Definition GUI_Utils.hpp:203

References Slic3r::GUI::DPIAware< wxDialog >::em_unit(), m_discard_btn, m_save_btn, and m_transfer_btn.

Here is the call graph for this function:

◆ on_sys_color_changed()

void Slic3r::GUI::UnsavedChangesDialog::on_sys_color_changed ( )
overrideprotectedvirtual

Reimplemented from Slic3r::GUI::DPIAware< wxDialog >.

1676{
1677 //for (auto btn : { m_save_btn, m_transfer_btn, m_discard_btn } )
1678 //btn->msw_rescale();
1679 // msw_rescale updates just icons, so use it
1680 //m_tree->Rescale();
1681
1682 Refresh();
1683}

◆ prev_scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::prev_scale_factor ( ) const
inlineinherited
196{ return m_prev_scale_factor; }

◆ rescale()

void Slic3r::GUI::DPIAware< wxDialog >::rescale ( const wxRect & suggested_rect)
inlineprivateinherited
265 {
266 this->Freeze();
267
268 m_force_rescale = false;
269
270 // set normal application font as a current window font
271 m_normal_font = this->GetFont();
272
274
275 // rescale missed controls sizes and images
277
278 this->Layout();
279 this->Thaw();
280
281 // reset previous scale factor from current scale factor value
283 }
virtual void on_dpi_changed(const wxRect &suggested_rect)=0
void update_em_unit()
Definition GUI_Utils.hpp:249

◆ save()

bool Slic3r::GUI::UnsavedChangesDialog::save ( PresetCollection * dependent_presets,
bool show_save_preset_dialog = true )
1177{
1178 names_and_types.clear();
1179
1180 // save one preset
1181 if (dependent_presets) {
1182 const Preset& preset = dependent_presets->get_edited_preset();
1183 std::string name = preset.name;
1184
1185 // for system/default/external presets we should take an edited name
1186 //BBS: add project embedded preset logic and refine is_external
1187 bool save_to_project = false;
1188 if (!preset.can_overwrite()) {
1189 //if (preset.is_system || preset.is_default || preset.is_external) {
1190 SavePresetDialog save_dlg(this, preset.type);
1191 if (save_dlg.ShowModal() != wxID_OK) {
1193 return false;
1194 }
1195 name = save_dlg.get_name();
1196 save_to_project = save_dlg.get_save_to_project_selection(preset.type);
1197 }
1198
1199 //BBS: add project embedded preset relate logic
1200 PresetData preset_data(name, preset.type, save_to_project);
1201 names_and_types.emplace_back(preset_data);
1202 //names_and_types.emplace_back(make_pair(name, preset.type));
1203 }
1204 // save all presets
1205 else
1206 {
1207 std::vector<Preset::Type> types_for_save;
1208
1209 PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
1210
1211 for (Tab* tab : wxGetApp().tabs_list)
1212 if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty()) {
1213 const Preset& preset = tab->get_presets()->get_edited_preset();
1214 //BBS: add project embedded preset logic and refine is_external
1215 if (!preset.can_overwrite())
1216 //if (preset.is_system || preset.is_default || preset.is_external)
1217 types_for_save.emplace_back(preset.type);
1218
1219 //BBS: add project embedded preset relate logic
1220 PresetData preset_data(preset.name, preset.type, preset.is_project_embedded);
1221 names_and_types.emplace_back(preset_data);
1222 //names_and_types.emplace_back(make_pair(preset.name, preset.type));
1223 }
1224
1225
1226 if (show_save_preset_dialog && !types_for_save.empty()) {
1227 SavePresetDialog save_dlg(this, types_for_save);
1228 if (save_dlg.ShowModal() != wxID_OK) {
1230 return false;
1231 }
1232
1233 //BBS: add project embedded preset relate logic
1234 for (PresetData& nt : names_and_types) {
1235 const std::string& name = save_dlg.get_name(nt.type);
1236 if (!name.empty())
1237 nt.name = name;
1238 nt.save_to_project = save_dlg.get_save_to_project_selection(nt.type);
1239 }
1240 //for (std::pair<std::string, Preset::Type>& nt : names_and_types) {
1241 // const std::string& name = save_dlg.get_name(nt.second);
1242 // if (!name.empty())
1243 // nt.first = name;
1244 //}
1245 }
1246 }
1247 return true;
1248}
static PrinterTechnology printer_technology()
Definition GUI_Factories.cpp:60
PrinterTechnology
Definition Config.hpp:229
@ Preset
Definition calib.hpp:39
Definition UnsavedChangesDialog.hpp:321

References Slic3r::Preset::can_overwrite(), Slic3r::GUI::Discard, Slic3r::PresetCollection::get_edited_preset(), Slic3r::GUI::SavePresetDialog::get_name(), Slic3r::GUI::SavePresetDialog::get_save_to_project_selection(), Slic3r::Preset::is_project_embedded, m_exit_action, Slic3r::Preset::name, names_and_types, Slic3r::GUI::printer_technology(), Slic3r::GUI::DPIAware< P >::ShowModal(), and Slic3r::Preset::type.

Referenced by build().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_preset()

bool Slic3r::GUI::UnsavedChangesDialog::save_preset ( ) const
inline
376{ return m_exit_action == Action::Save; }

References m_exit_action, and Slic3r::GUI::Save.

Referenced by Slic3r::GUI::GUI_App::check_and_keep_current_preset_changes(), Slic3r::GUI::GUI_App::check_and_save_current_preset_changes(), and Slic3r::GUI::Tab::may_discard_current_dirty_preset().

Here is the caller graph for this function:

◆ scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::scale_factor ( ) const
inlineinherited
195{ return m_scale_factor; }

◆ set_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::set_em_unit ( int v)
inlineinherited
200{ m_em_unit = v; }

◆ set_prev_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_prev_scale_factor ( float v)
inlineinherited

◆ set_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_scale_factor ( float v)
inlineinherited
198{ m_scale_factor = v; }

◆ show_info_line()

void Slic3r::GUI::UnsavedChangesDialog::show_info_line ( Action action,
std::string preset_name = "" )
1136{
1137 return;
1138 if (action == Action::Undef && !m_has_long_strings)
1139 m_info_line->SetLabel(wxEmptyString);
1140 else {
1141 wxString text;
1142 if (action == Action::Undef)
1143 text = _L("Click the right mouse button to display the full text.");
1144 else if (action == Action::Discard)
1145 text = ActionButtons::DONT_SAVE & m_buttons ? _L("No changes will be saved.") :_L("All changes will be discarded.");
1146 else {
1147 if (preset_name.empty())
1148 text = action == Action::Save ? _L("Save the selected options.") :
1149 ActionButtons::KEEP & m_buttons ? _L("Keep the selected options.") :
1150 _L("Transfer the selected options to the newly selected preset.");
1151 else
1152 text = format_wxstr(
1153 action == Action::Save ?
1154 _L("Save the selected options to preset \n\"%1%\".") :
1155 _L("Transfer the selected options to the newly selected preset \n\"%1%\"."),
1156 preset_name);
1157 //text += "\n" + _L("Unselected options will be reverted.");
1158 }
1159 m_info_line->SetLabel(text);
1160 m_info_line->Show();
1161 }
1162
1163 //Layout();
1164 //Refresh();
1165}
bool m_has_long_strings
Definition UnsavedChangesDialog.hpp:304
wxStaticText * m_info_line
Definition UnsavedChangesDialog.hpp:301

References _L, Slic3r::GUI::Discard, Slic3r::GUI::DONT_SAVE, Slic3r::GUI::format_wxstr(), Slic3r::GUI::KEEP, m_buttons, m_has_long_strings, m_info_line, Slic3r::GUI::Save, and Slic3r::GUI::Undef.

Referenced by build(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowModal()

int Slic3r::GUI::UnsavedChangesDialog::ShowModal ( )
inlineoverride
867{
868 auto choise_key = "save_preset_choise";
869 auto choise = wxGetApp().app_config->get(choise_key);
870 long result = 0;
871 if ((m_buttons & REMEMBER_CHOISE) && !choise.empty() && wxString(choise).ToLong(&result) && (1 << result) & (m_buttons | DONT_SAVE)) {
872 m_exit_action = Action(result);
873 return 0;
874 }
875 int r = DPIDialog::ShowModal();
876 if (r != wxID_CANCEL && dynamic_cast<::CheckBox*>(FindWindowById(wxID_APPLY))->GetValue()) {
877 wxGetApp().app_config->set(choise_key, std::to_string(int(m_exit_action)));
878 }
879 return r;
880}
int ShowModal()
Definition GUI_Utils.hpp:216

References Slic3r::GUI::DONT_SAVE, m_buttons, m_exit_action, Slic3r::GUI::REMEMBER_CHOISE, and Slic3r::GUI::DPIAware< wxDialog >::ShowModal().

Referenced by Slic3r::GUI::GUI_App::check_and_keep_current_preset_changes(), Slic3r::GUI::GUI_App::check_and_save_current_preset_changes(), Slic3r::GUI::Tab::may_discard_current_dirty_preset(), and Slic3r::GUI::Tab::sync_excluder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subreplace()

std::string Slic3r::GUI::UnsavedChangesDialog::subreplace ( std::string resource_str,
std::string sub_str,
std::string new_str )
1519{
1520 std::string dst_str = resource_str;
1521 std::string::size_type pos = 0;
1522 while ((pos = dst_str.find(sub_str)) != std::string::npos)
1523 {
1524 dst_str.replace(pos, sub_str.length(), new_str);
1525 }
1526 return dst_str;
1527}
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

Referenced by update_list().

Here is the caller graph for this function:

◆ transfer_changes()

bool Slic3r::GUI::UnsavedChangesDialog::transfer_changes ( ) const
inline
377{ return m_exit_action == Action::Transfer; }

References m_exit_action, and Slic3r::GUI::Transfer.

Referenced by Slic3r::GUI::GUI_App::check_and_keep_current_preset_changes(), Slic3r::GUI::Tab::may_discard_current_dirty_preset(), and Slic3r::GUI::Tab::sync_excluder().

Here is the caller graph for this function:

◆ update()

void Slic3r::GUI::UnsavedChangesDialog::update ( Preset::Type type,
PresetCollection * dependent_presets,
const std::string & new_selected_preset,
const wxString & header )
1264{
1265 PresetCollection* presets = dependent_presets;
1266
1267 // activate buttons and labels
1268 if (m_save_btn)
1269 m_save_btn->Bind(wxEVT_ENTER_WINDOW, [this, presets](wxMouseEvent &e) {
1270 show_info_line(Action::Save, presets ? presets->get_selected_preset().name : "");
1271 e.Skip();
1272 });
1273
1274
1275 if (m_transfer_btn) {
1276 bool is_empty_name = dependent_presets && type != dependent_presets->type();
1277 m_transfer_btn->Bind(wxEVT_ENTER_WINDOW, [this, new_selected_preset, is_empty_name](wxMouseEvent& e) { show_info_line(Action::Transfer, is_empty_name ? "" : new_selected_preset); e.Skip(); });
1278 }
1279 if (m_discard_btn)
1280 m_discard_btn ->Bind(wxEVT_ENTER_WINDOW, [this] (wxMouseEvent& e) { show_info_line(Action::Discard); e.Skip(); });
1281
1282 if (type == Preset::TYPE_INVALID) {
1283 PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
1284 int presets_cnt = 0;
1285 for (Tab* tab : wxGetApp().tabs_list)
1286 if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty())
1287 presets_cnt++;
1288 /*m_action_line->SetLabel((header.IsEmpty() ? "" : header + "\n\n") +
1289 _L_PLURAL("The following preset was modified",
1290 "The following presets were modified", presets_cnt));*/
1291 }
1292 else {
1293 wxString action_msg;
1294 if (type == dependent_presets->type()) {
1295 action_msg = format_wxstr(_L("Preset \"%1%\" contains the following unsaved changes:"), presets->get_edited_preset().name);
1296 }
1297 else {
1298 action_msg = format_wxstr(type == Preset::TYPE_PRINTER ?
1299 _L("Preset \"%1%\" is not compatible with the new printer profile and it contains the following unsaved changes:") :
1300 _L("Preset \"%1%\" is not compatible with the new process profile and it contains the following unsaved changes:"),
1301 presets->get_edited_preset().name);
1302 }
1303 //m_action_line->SetLabel(action_msg);
1304 }
1305
1306 wxString action_msg;
1307 if (dependent_presets) {
1308 action_msg = format_wxstr(_L("You have changed some settings of preset \"%1%\"."), dependent_presets->get_edited_preset().name);
1309 if (!m_transfer_btn) {
1310 action_msg += _L("\nYou can save or discard the preset values you have modified.");
1311 } else {
1312 action_msg += _L("\nYou can save or discard the preset values you have modified, or choose to transfer the values you have modified to the new preset.");
1313 }
1314 } else {
1315 action_msg = _L("You have previously modified your settings.");
1316 if (m_transfer_btn)
1317 action_msg += _L("\nYou can discard the preset values you have modified, or choose to transfer the modified values to the new project");
1318 else
1319 action_msg += _L("\nYou can save or discard the preset values you have modified.");
1320 }
1321
1322 m_action_line->SetLabel(action_msg);
1324
1325 update_tree(type, presets);
1326 update_list();
1327}
@ TYPE_PRINTER
Definition Preset.hpp:250

References _L, Slic3r::GUI::Discard, Slic3r::GUI::format_wxstr(), Slic3r::PresetCollection::get_edited_preset(), Slic3r::PresetCollection::get_selected_preset(), m_action_line, m_discard_btn, m_save_btn, m_transfer_btn, Slic3r::Preset::name, Slic3r::GUI::printer_technology(), Slic3r::GUI::Save, show_info_line(), Slic3r::GUI::Transfer, Slic3r::PresetCollection::type(), Slic3r::Preset::TYPE_INVALID, Slic3r::Preset::TYPE_PRINTER, UNSAVE_CHANGE_DIALOG_SCROLL_WINDOW_SIZE, update_list(), update_tree(), and Slic3r::GUI::wxMouseEvent.

Referenced by build().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_config()

void Slic3r::GUI::UnsavedChangesDialog::update_config ( Action action)

◆ update_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::update_em_unit ( )
inlineprivateinherited
250 {
251 // Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
252 // So, calculate the m_em_unit value from the font size, as before
253#if !defined(__WXGTK__)
255#else
256 // initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
257 m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
258#endif // __WXGTK__
259 }

◆ update_list()

void Slic3r::GUI::UnsavedChangesDialog::update_list ( SyncExtruderParams * params = nullptr)
1330{
1331 if (!m_scrolledWindow) {
1332 Layout();
1333 Fit();
1334 return;
1335 }
1336
1337 std::map<wxString, std::vector<PresetItem>> class_g_list;
1338 std::map<wxString, std::vector<wxString>> class_c_list;
1339 std::vector<wxString> category_list;
1340
1341 // group
1342 for (auto i = 0; i < m_presetitems.size(); i++) {
1343 auto name = m_presetitems[i].category_name + ":" + m_presetitems[i].group_name;
1344 if (class_g_list.count(name) <= 0) {
1345 std::vector<PresetItem> vp;
1346 vp.push_back(m_presetitems[i]);
1347 class_g_list.emplace(name, vp);
1348 } else {
1349 //for (auto iter = class_g_list.begin(); iter != class_g_list.end(); iter++) iter->second.push_back(m_presetitems[i]);
1350 class_g_list[name].push_back(m_presetitems[i]);
1351 }
1352 }
1353
1354 // category
1355 for (auto i = 0; i < m_presetitems.size(); i++) {
1356 auto name = m_presetitems[i].category_name + ":" + m_presetitems[i].group_name;
1357 if (class_c_list.count(m_presetitems[i].category_name) <= 0) {
1358 std::vector<wxString> vp;
1359 vp.push_back(name);
1360 class_c_list.emplace(m_presetitems[i].category_name, vp);
1361 category_list.push_back(m_presetitems[i].category_name);
1362 } else {
1363 /*for (auto iter = class_c_list.begin(); iter != class_c_list.end(); iter++)
1364 iter->second.push_back(m_presetitems[i].group_name);*/
1365 //class_c_list[m_presetitems[i].category_name].push_back(m_presetitems[i].group_name);
1366 std::vector<wxString>::iterator it;
1367 it = find(class_c_list[m_presetitems[i].category_name].begin(), class_c_list[m_presetitems[i].category_name].end(), name);
1368 if (it == class_c_list[m_presetitems[i].category_name].end()) {
1369 class_c_list[m_presetitems[i].category_name].push_back(name);
1370 }
1371 }
1372 }
1373
1374
1375 auto m_listsizer = new wxBoxSizer(wxVERTICAL);
1376 for (auto category : category_list) {
1377 auto iter = class_c_list.find(category);
1378 //category
1379 auto panel_category = new wxPanel(m_scrolledWindow, wxID_ANY, wxDefaultPosition, wxSize(-1, UNSAVE_CHANGE_DIALOG_ITEM_HEIGHT), wxTAB_TRAVERSAL);
1380 panel_category->SetBackgroundColour(GREY300);
1381
1382 wxBoxSizer *sizer_category = new wxBoxSizer(wxHORIZONTAL);
1383 wxBoxSizer *sizer_category_v = new wxBoxSizer(wxHORIZONTAL);
1384
1385 auto text_category = new wxStaticText(panel_category, wxID_ANY, iter->first, wxDefaultPosition, wxSize(-1, -1), 0);
1386 text_category->SetFont(::Label::Head_13);
1387 text_category->SetForegroundColour(GREY900);
1388 text_category->Wrap(-1);
1389
1390 sizer_category_v->Add(text_category, 0, wxALIGN_CENTER | wxLEFT, 23);
1391
1392 sizer_category->Add(sizer_category_v, 1, wxEXPAND, 0);
1393
1394 panel_category->SetSizer(sizer_category);
1395 panel_category->Layout();
1396 m_listsizer->Add(panel_category, 0, wxEXPAND, 0);
1397
1398 /*auto item_line = new wxStaticLine(list, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
1399 item_line->SetForegroundColour(wxColour(206, 206, 206));
1400 item_line->SetBackgroundColour(wxColour(206, 206, 206));
1401 sizer_list->Add(item_line, 0, wxALL, 0); */
1402
1403 // isset group
1404 for (auto i = 0; i < iter->second.size(); i++) {
1405 auto gname = iter->second[i];
1406 for (auto g = 0; g < class_g_list[gname].size(); g++) {
1407
1408 //first group
1409 if (g == 0) {
1410 auto panel_item = new wxWindow(m_scrolledWindow, -1, wxDefaultPosition, wxSize(-1, UNSAVE_CHANGE_DIALOG_ITEM_HEIGHT));
1411 panel_item->SetBackgroundColour(GREY200);
1412
1413 wxBoxSizer *sizer_item = new wxBoxSizer(wxHORIZONTAL);
1414
1415 auto panel_left = new wxPanel(panel_item, wxID_ANY, wxDefaultPosition, wxSize(UNSAVE_CHANGE_DIALOG_FIRST_VALUE_WIDTH, -1), wxTAB_TRAVERSAL);
1416 panel_left->SetBackgroundColour(GREY200);
1417
1418 wxBoxSizer *sizer_left_v = new wxBoxSizer(wxVERTICAL);
1419
1420 auto text_left = new wxStaticText(panel_left, wxID_ANY, class_g_list[gname][0].group_name, wxDefaultPosition, wxSize(-1, -1), 0);
1421 text_left->SetFont(::Label::Head_13);
1422 text_left->Wrap(-1);
1423 text_left->SetForegroundColour(GREY700);
1424
1425 sizer_left_v->Add(text_left, 0, wxLEFT, 37);
1426
1427 panel_left->SetSizer(sizer_left_v);
1428 panel_left->Layout();
1429 sizer_item->Add(panel_left, 0, wxALIGN_CENTER, 0);
1430
1431 panel_item->SetSizer(sizer_item);
1432 panel_item->Layout();
1433 m_listsizer->Add(panel_item, 0, wxEXPAND, 0);
1434 }
1435
1436 auto data = class_g_list[gname][g];
1437
1438 auto panel_item = new wxWindow(m_scrolledWindow, -1, wxDefaultPosition, wxSize(-1, UNSAVE_CHANGE_DIALOG_ITEM_HEIGHT));
1439 panel_item->SetBackgroundColour(GREY200);
1440
1441 wxBoxSizer *sizer_item = new wxBoxSizer(wxHORIZONTAL);
1442
1443 auto panel_left = new wxPanel(panel_item, wxID_ANY, wxDefaultPosition, wxSize(UNSAVE_CHANGE_DIALOG_FIRST_VALUE_WIDTH , -1), wxTAB_TRAVERSAL);
1444 panel_left->SetBackgroundColour(GREY200);
1445
1446 wxBoxSizer *sizer_left_v = new wxBoxSizer(wxVERTICAL);
1447
1448 auto text_left = new wxStaticText(panel_left, wxID_ANY, data.option_name, wxDefaultPosition, wxSize(-1, -1), 0);
1449 text_left->SetFont(::Label::Body_13);
1450 text_left->Wrap(-1);
1451 text_left->SetForegroundColour(GREY700);
1452
1453 sizer_left_v->Add(text_left, 0, wxLEFT, 51 );
1454
1455 panel_left->SetSizer(sizer_left_v);
1456 panel_left->Layout();
1457 sizer_item->Add(panel_left, 0, wxALIGN_CENTER, 0);
1458
1459 auto panel_oldv = new wxPanel(panel_item, wxID_ANY, wxDefaultPosition, wxSize(UNSAVE_CHANGE_DIALOG_VALUE_WIDTH, -1), wxTAB_TRAVERSAL);
1460 wxBoxSizer *sizer_old_v = new wxBoxSizer(wxVERTICAL);
1461
1462
1463 data.old_value = subreplace(data.old_value.ToStdString(), "\n", " ");
1464 auto text_oldv = new wxStaticText(panel_oldv, wxID_ANY, data.old_value, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
1465 text_oldv->SetFont(::Label::Body_13);
1466 text_oldv->Wrap(-1);
1467 text_oldv->SetForegroundColour(params && params->left_to_right ? wxGetApp().get_label_clr_modified() : GREY700);
1468 sizer_old_v->Add(text_oldv, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5);
1469
1470 panel_oldv->SetSizer(sizer_old_v);
1471 panel_oldv->Layout();
1472 sizer_item->Add(panel_oldv, 0, wxALIGN_CENTER, 0);
1473
1474 auto panel_newv = new wxPanel(panel_item, wxID_ANY, wxDefaultPosition, wxSize(UNSAVE_CHANGE_DIALOG_VALUE_WIDTH, -1), wxTAB_TRAVERSAL);
1475 wxBoxSizer *sizer_new_v = new wxBoxSizer(wxVERTICAL);
1476
1477 data.new_value = subreplace(data.new_value.ToStdString(), "\n", " ");
1478 auto text_newv = new wxStaticText(panel_newv, wxID_ANY, data.new_value, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
1479 text_newv->SetFont(::Label::Body_13);
1480 text_newv->Wrap(-1);
1481 text_newv->SetForegroundColour(params && !params->left_to_right ? wxGetApp().get_label_clr_modified() : GREY700);
1482
1483 sizer_new_v->Add(text_newv, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5);
1484
1485 panel_newv->SetSizer(sizer_new_v);
1486 panel_newv->Layout();
1487 sizer_item->Add(panel_newv, 0, wxALIGN_CENTER, 0);
1488
1489 panel_item->SetSizer(sizer_item);
1490 panel_item->Layout();
1491 m_listsizer->Add(panel_item, 0, wxEXPAND, 0);
1492
1493
1494
1496 // auto item_line = new wxStaticLine(list, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
1497 // item_line->SetForegroundColour(wxColour(206, 206, 206));
1498 // item_line->SetBackgroundColour(wxColour(206, 206, 206));
1499 // sizer_list->Add(item_line, 0, wxALL, 0);
1501 }
1502 }
1503 }
1504
1505 m_scrolledWindow->SetSizer(m_listsizer);
1506 m_scrolledWindow->Layout();
1507 /*wxSize text_size = m_action_line->GetTextExtent(m_action_line->GetLabel());
1508 int width = UNSAVE_CHANGE_DIALOG_ACTION_LINE_SIZE.GetWidth();
1509 // +2: Ensure that there is at least one line and that the content contains '\n'
1510 int rows = int(text_size.GetWidth() / width) + 2;
1511 int height = rows * text_size.GetHeight();
1512 m_action_line->SetMinSize(wxSize(width, height));
1513 m_action_line->Wrap(UNSAVE_CHANGE_DIALOG_ACTION_LINE_SIZE.GetWidth());*/
1514 Layout();
1515 Fit();
1516}
#define UNSAVE_CHANGE_DIALOG_ITEM_HEIGHT
Definition UnsavedChangesDialog.cpp:808
#define GREY900
Definition UnsavedChangesDialog.cpp:812
#define GREY700
Definition UnsavedChangesDialog.cpp:813
#define GREY300
Definition UnsavedChangesDialog.cpp:815
static wxFont Head_13
Definition Label.hpp:46
std::string subreplace(std::string resource_str, std::string sub_str, std::string new_str)
Definition UnsavedChangesDialog.cpp:1518
T * begin(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:838
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
static const char * category_name(AuditEventCategory category)
Definition PluginAuditManager.cpp:348
RaycastManager::TrItems::iterator find(RaycastManager::TrItems &items, const RaycastManager::TrKey &key)
Definition RaycastManager.cpp:298

References Label::Body_13, Slic3r::category_name(), GREY200, GREY300, GREY700, GREY900, Label::Head_13, Slic3r::GUI::UnsavedChangesDialog::SyncExtruderParams::left_to_right, m_presetitems, m_scrolledWindow, subreplace(), UNSAVE_CHANGE_DIALOG_FIRST_VALUE_WIDTH, UNSAVE_CHANGE_DIALOG_ITEM_HEIGHT, UNSAVE_CHANGE_DIALOG_VALUE_WIDTH, and wxStaticText.

Referenced by build(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_tree() [1/2]

void Slic3r::GUI::UnsavedChangesDialog::update_tree ( Preset::Type type,
DynamicConfig * config,
int from,
int to )
1530{
1531 Search::SettingsIndex &index = wxGetApp().sidebar().settings_index();
1532 index.sort_options_by_key();
1533
1534 for (const std::string &opt_key : config->keys()) {
1535 int variant_index = -2;
1536 Search::Option option = index.get_option(opt_key, type, variant_index);
1537 if (variant_index == -2) {
1538 // Orca: Every transferred setting must remain visible even when it is absent from the search index.
1539 const ConfigOptionDef* def = print_config_def.get(opt_key);
1540 const std::string label = def ? (def->full_label.empty() ? def->label : def->full_label) : std::string();
1541 option.label_local = (label.empty() ? from_u8(opt_key) : _L(label)).ToStdWstring();
1542 option.category_local = (def && !def->category.empty() ?
1543 Tab::translate_category(from_u8(def->category), type) : _L("Others")).ToStdWstring();
1544 }
1545 auto category = option.category_local;
1546 auto opt = dynamic_cast<ConfigOptionVectorBase*>(config->option(opt_key));
1547 std::string value_from = opt->vserialize()[from];
1548 std::string value_to = opt->vserialize()[to];
1549 PresetItem pi = {type, opt_key, category, option.group_local, option.label_local, into_u8(value_from), into_u8(value_to)};
1550 m_presetitems.push_back(pi);
1551 }
1552}
const ConfigOptionDef * get(const t_config_option_key &opt_key) const
Definition Config.hpp:2662
static wxString translate_category(const wxString &title, Preset::Type preset_type, bool translate=true)
Definition Tab.cpp:823
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
const PrintConfigDef print_config_def
Definition PrintConfig.cpp:10099

References _L, Slic3r::ConfigOptionDef::category, Slic3r::Search::Option::category_local, Slic3r::GUI::from_u8(), Slic3r::ConfigOptionDef::full_label, Slic3r::Search::SettingsIndex::get_option(), Slic3r::Search::Option::group_local, Slic3r::GUI::into_u8(), Slic3r::DynamicConfig::keys(), Slic3r::ConfigOptionDef::label, Slic3r::Search::Option::label_local, m_presetitems, Slic3r::ConfigBase::option(), Slic3r::print_config_def, Slic3r::Search::SettingsIndex::sort_options_by_key(), and Slic3r::GUI::Tab::translate_category().

Here is the call graph for this function:

◆ update_tree() [2/2]

void Slic3r::GUI::UnsavedChangesDialog::update_tree ( Preset::Type type,
PresetCollection * presets )
1555{
1556 Search::SettingsIndex& index = wxGetApp().sidebar().settings_index();
1557 index.sort_options_by_key();
1558
1559 // list of the presets with unsaved changes
1560 std::vector<PresetCollection*> presets_list;
1561 if (type == Preset::TYPE_INVALID)
1562 {
1563 PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
1564
1565 for (Tab* tab : wxGetApp().tabs_list)
1566 if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty())
1567 presets_list.emplace_back(tab->get_presets());
1568 }
1569 else
1570 presets_list.emplace_back(presets_);
1571
1572 const bool multiple_extruders = wxGetApp().preset_bundle->get_printer_extruder_count() > 1;
1573
1574 // Display a dialog showing the dirty options in a human readable form.
1575 for (PresetCollection* presets : presets_list)
1576 {
1577 const DynamicPrintConfig& old_config = presets->get_selected_preset().config;
1578 const PrinterTechnology& old_pt = presets->get_selected_preset().printer_technology();
1579 const DynamicPrintConfig& new_config = presets->get_edited_preset().config;
1580 type = presets->type();
1581
1582 const std::map<wxString, std::string>& category_icon_map = wxGetApp().get_tab(type)->get_category_icon_map();
1583
1584 //m_tree->model->AddPreset(type, from_u8(presets->get_edited_preset().name), old_pt);
1585
1586 // Collect dirty options.
1587 const bool deep_compare = (type == Preset::TYPE_PRINTER || type == Preset::TYPE_PRINT || type == Preset::TYPE_FILAMENT || type == Preset::TYPE_SLA_MATERIAL);
1588 auto dirty_options = presets->current_dirty_options(deep_compare);
1589
1590 // process changes of extruders count
1591 if (type == Preset::TYPE_PRINTER && old_pt == ptFFF &&
1592 old_config.opt<ConfigOptionFloats>("nozzle_diameter")->values.size() != new_config.opt<ConfigOptionFloats>("nozzle_diameter")->values.size()) {
1593 wxString local_label = _L("Extruder count");
1594 wxString old_val = from_u8((boost::format("%1%") % old_config.opt<ConfigOptionFloats>("nozzle_diameter")->values.size()).str());
1595 wxString new_val = from_u8((boost::format("%1%") % new_config.opt<ConfigOptionFloats>("nozzle_diameter")->values.size()).str());
1596
1597 //BBS: the page "General" changed to "Basic information" instead
1598 //m_tree->Append("extruders_count", type, _L("General"), _L("Capabilities"), local_label, old_val, new_val, category_icon_map.at("Basic information"));
1599 //m_tree->Append("extruders_count", type, _L("General"), _L("Capabilities"), local_label, old_val, new_val, category_icon_map.at("General"));
1600
1601 if (old_val != new_val) {
1602 PresetItem pi = {type, "extruders_count", _L("General"), _L("Capabilities"), local_label, old_val, new_val};
1603 m_presetitems.push_back(pi);
1604 }
1605 }
1606
1607 auto variant_key = Preset::get_iot_type_string(type) + "_extruder_variant";
1608 auto id_key = Preset::get_iot_type_string(type) + "_extruder_id";
1609 // Orca: Dirty indices belong to the edited config, which may contain newly added variants.
1610 auto extruder_variant = dynamic_cast<ConfigOptionStrings const *>(new_config.option(variant_key));
1611 auto extruder_id = dynamic_cast<ConfigOptionInts const *>(new_config.option(id_key));
1612
1613 for (const std::string& opt_key : dirty_options) {
1614 int variant_index = -2;
1615 const Search::Option &option = index.get_option(opt_key, type, variant_index);
1616 if (variant_index == -2) {
1617 // When founded option isn't the correct one.
1618 // It can be for dirty_options: "default_print_profile", "printer_model", "printer_settings_id",
1619 // because of they don't exist in the index
1620 continue;
1621 }
1622 wxString category = option.category_local;
1623 wxString label = option.label_local;
1624 if (type == Preset::TYPE_PRINTER && variant_index >= 0 &&
1626 variant_index /= 2;
1627 }
1628 if (variant_index >= 0 && extruder_variant && variant_index < extruder_variant->size()) {
1629 // Orca: Match the untranslated category and use the same extruder names as the printer tabs.
1630 if (option.category.compare(0, 9, L"Extruder ") == 0)
1631 category = _L("Extruder");
1632 wxString variant_label = L(extruder_variant->values[variant_index]);
1633 // Orca: An extruder name only disambiguates variants on printers with multiple extruders.
1634 if (multiple_extruders && extruder_id && variant_index < extruder_id->size() && extruder_id->values[variant_index] > 0) {
1635 const wxString extruder_name = Tab::translate_category(
1636 wxString::Format("Extruder %d", extruder_id->values[variant_index]), Preset::TYPE_PRINTER);
1637 variant_label = extruder_name + " (" + variant_label + ")";
1638 }
1639 category = variant_label + ": " + category;
1640 }
1641
1642 /*m_tree->Append(opt_key, type, option.category_local, option.group_local, option.label_local,
1643 get_string_value(opt_key, old_config), get_string_value(opt_key, new_config), category_icon_map.at(option.category));*/
1644
1645
1646 //PresetItem pi = {opt_key, type, 1983};
1647 //m_presetitems.push_back()
1648 PresetItem pi = {type, opt_key, category, option.group_local, label, get_string_value(opt_key, old_config), get_string_value(opt_key, new_config)};
1649 m_presetitems.push_back(pi);
1650
1651 }
1652 }
1653
1654 // Revert sort of index back
1655 index.sort_options_by_label();
1656}
#define L(s)
Definition ExtrusionEntity.cpp:25
std::vector< double > values
Definition Config.hpp:418
static std::string get_iot_type_string(Preset::Type type)
Definition Preset.cpp:641
@ TYPE_SLA_MATERIAL
Definition Preset.hpp:249
@ TYPE_FILAMENT
Definition Preset.hpp:248
wxString get_string_value(const std::string &opt_key, const DynamicPrintConfig &config)
Definition ConfigValueFormatter.cpp:73
std::string get_pure_opt_key(const std::string &opt_key)
Definition ConfigValueFormatter.cpp:24
@ ptFFF
Definition Config.hpp:231
ConfigOptionIntsTempl< false > ConfigOptionInts
Definition Config.hpp:1154
std::set< std::string > printer_options_with_variant_2
Definition PrintConfig.cpp:10270
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:1015

References _L, Slic3r::Search::Option::category, Slic3r::Search::Option::category_local, Slic3r::GUI::from_u8(), Slic3r::Preset::get_iot_type_string(), Slic3r::Search::SettingsIndex::get_option(), Slic3r::GUI::get_pure_opt_key(), Slic3r::GUI::get_string_value(), Slic3r::Search::Option::group_local, L, Slic3r::Search::Option::label_local, m_presetitems, Slic3r::DynamicConfig::opt(), Slic3r::ConfigBase::option(), Slic3r::printer_options_with_variant_2, Slic3r::GUI::printer_technology(), Slic3r::ptFFF, Slic3r::Search::SettingsIndex::sort_options_by_key(), Slic3r::Search::SettingsIndex::sort_options_by_label(), Slic3r::GUI::Tab::translate_category(), Slic3r::Preset::TYPE_FILAMENT, Slic3r::Preset::TYPE_INVALID, Slic3r::Preset::TYPE_PRINT, Slic3r::Preset::TYPE_PRINTER, and Slic3r::Preset::TYPE_SLA_MATERIAL.

Referenced by build(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ActDiscard

char Slic3r::GUI::UnsavedChangesDialog::ActDiscard[] = "discard"
staticconstexprprotected

◆ ActSave

char Slic3r::GUI::UnsavedChangesDialog::ActSave[] = "save"
staticconstexprprotected

◆ ActTransfer

char Slic3r::GUI::UnsavedChangesDialog::ActTransfer[] = "transfer"
staticconstexprprotected

◆ m_action_line

wxStaticText* Slic3r::GUI::UnsavedChangesDialog::m_action_line { nullptr }
protected
300{ nullptr };

Referenced by build(), and update().

◆ m_app_config_key

std::string Slic3r::GUI::UnsavedChangesDialog::m_app_config_key
protected

Referenced by UnsavedChangesDialog(), and build().

◆ m_buttons

◆ m_can_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_can_rescale
privateinherited
235{ true };

◆ m_cancel_btn

Button* Slic3r::GUI::UnsavedChangesDialog::m_cancel_btn { nullptr }
protected
299{ nullptr };

◆ m_continue_btn_id

int Slic3r::GUI::UnsavedChangesDialog::m_continue_btn_id { wxID_ANY }
protected
307{ wxID_ANY };

Referenced by build().

◆ m_discard_btn

Button* Slic3r::GUI::UnsavedChangesDialog::m_discard_btn { nullptr }
protected
298{ nullptr };

Referenced by build(), on_dpi_changed(), and update().

◆ m_em_unit

int Slic3r::GUI::DPIAware< wxDialog >::m_em_unit
privateinherited

◆ m_exit_action

Action Slic3r::GUI::UnsavedChangesDialog::m_exit_action {Action::Undef}
protected

◆ m_force_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_force_rescale
privateinherited
236{ false };

◆ m_has_long_strings

bool Slic3r::GUI::UnsavedChangesDialog::m_has_long_strings { false }
protected
304{ false };

Referenced by show_info_line().

◆ m_info_line

wxStaticText* Slic3r::GUI::UnsavedChangesDialog::m_info_line { nullptr }
protected
301{ nullptr };

Referenced by show_info_line().

◆ m_move_btn_id

int Slic3r::GUI::UnsavedChangesDialog::m_move_btn_id { wxID_ANY }
protected
306{ wxID_ANY };

Referenced by build().

◆ m_new_font_point_size

int Slic3r::GUI::DPIAware< wxDialog >::m_new_font_point_size
privateinherited

◆ m_new_selected_preset_name

std::string Slic3r::GUI::UnsavedChangesDialog::m_new_selected_preset_name
private

Referenced by UnsavedChangesDialog().

◆ m_normal_font

wxFont Slic3r::GUI::DPIAware< wxDialog >::m_normal_font
privateinherited

◆ m_panel_tab

wxPanel* Slic3r::GUI::UnsavedChangesDialog::m_panel_tab
protected

Referenced by build().

◆ m_presetitems

std::vector<PresetItem> Slic3r::GUI::UnsavedChangesDialog::m_presetitems
private

◆ m_prev_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_prev_scale_factor
privateinherited

◆ m_save_btn

Button* Slic3r::GUI::UnsavedChangesDialog::m_save_btn { nullptr }
protected
296{ nullptr };

Referenced by build(), on_dpi_changed(), and update().

◆ m_save_btn_id

int Slic3r::GUI::UnsavedChangesDialog::m_save_btn_id { wxID_ANY }
protected
305{ wxID_ANY };

Referenced by build().

◆ m_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_scale_factor
privateinherited

◆ m_scrolledWindow

wxScrolledWindow* Slic3r::GUI::UnsavedChangesDialog::m_scrolledWindow { nullptr }
protected
302{ nullptr };

Referenced by build(), and update_list().

◆ m_sizer_bottom

wxBoxSizer* Slic3r::GUI::UnsavedChangesDialog::m_sizer_bottom
protected

Referenced by build().

◆ m_table_top

wxPanel* Slic3r::GUI::UnsavedChangesDialog::m_table_top
protected

Referenced by build().

◆ m_top_line

wxPanel* Slic3r::GUI::UnsavedChangesDialog::m_top_line
protected

Referenced by build().

◆ m_transfer_btn

Button* Slic3r::GUI::UnsavedChangesDialog::m_transfer_btn { nullptr }
protected
297{ nullptr };

Referenced by build(), on_dpi_changed(), and update().

◆ names_and_types

std::vector<PresetData> Slic3r::GUI::UnsavedChangesDialog::names_and_types
private

◆ static_newv_title

wxStaticText* Slic3r::GUI::UnsavedChangesDialog::static_newv_title
protected

Referenced by build().

◆ static_oldv_title

wxStaticText* Slic3r::GUI::UnsavedChangesDialog::static_oldv_title
protected

Referenced by build().

◆ static_temp_title

wxStaticText* Slic3r::GUI::UnsavedChangesDialog::static_temp_title
protected

Referenced by build().

◆ title_block_middle

wxPanel* Slic3r::GUI::UnsavedChangesDialog::title_block_middle
protected

Referenced by build().

◆ title_block_right

wxPanel* Slic3r::GUI::UnsavedChangesDialog::title_block_right
protected

Referenced by build().


The documentation for this class was generated from the following files: