From 7cb99f8e27ab749b02705c3cb4a436c66f811336 Mon Sep 17 00:00:00 2001
From: Enrico Turri <enricoturri@seznam.cz>
Date: Mon, 19 Nov 2018 14:03:28 +0100
Subject: [PATCH 1/6] Added debug error message when missing icons for gizmos

---
 src/slic3r/GUI/GLCanvas3D.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index 6e47c0867..d45bdf685 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -3219,7 +3219,8 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
 
     if (m_gizmos.is_enabled()) {
         if (! m_gizmos.init(*this)) { 
-            return false; 
+            std::cout << "Unable to initialize gizmos: please, check that all the required textures are available" << std::endl;
+            return false;
         }
 
         if (m_external_gizmo_widgets_parent != nullptr) {

From 2fa055903fcb45da9bb90479b7378dc32b0c1431 Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Fri, 16 Nov 2018 17:36:23 +0100
Subject: [PATCH 2/6] "SLA Print Settings" implementation (start)

---
 src/libslic3r/GCode.cpp         |   5 +-
 src/libslic3r/PrintConfig.cpp   | 114 ++++++++++++++++++++++++++++++++
 src/libslic3r/PrintConfig.hpp   |   4 +-
 src/slic3r/GUI/MainFrame.cpp    |   8 ++-
 src/slic3r/GUI/Plater.cpp       |  24 ++++---
 src/slic3r/GUI/Preset.cpp       |  28 ++++++++
 src/slic3r/GUI/Preset.hpp       |   2 +
 src/slic3r/GUI/PresetBundle.cpp |  64 +++++++++++++++++-
 src/slic3r/GUI/PresetBundle.hpp |   2 +
 src/slic3r/GUI/Tab.cpp          |  52 +++++++++++++--
 src/slic3r/GUI/Tab.hpp          |  13 ++++
 11 files changed, 296 insertions(+), 20 deletions(-)

diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp
index 4f1ec05af..b9625523d 100644
--- a/src/libslic3r/GCode.cpp
+++ b/src/libslic3r/GCode.cpp
@@ -1663,8 +1663,9 @@ void GCode::append_full_config(const Print& print, std::string& str)
     }
     const DynamicConfig &full_config = print.placeholder_parser().config();
 	for (const char *key : {
-		"print_settings_id", "filament_settings_id", "sla_material_settings_id", "printer_settings_id",
-		"printer_model", "printer_variant", "default_print_profile", "default_filament_profile", "default_sla_material_profile",
+		"print_settings_id", "filament_settings_id", "sla_print_settings_id", "sla_material_settings_id", "printer_settings_id",
+		"printer_model", "printer_variant", 
+	    "default_print_profile", "default_filament_profile", "default_sla_print_profile", "default_sla_material_profile",
 		"compatible_printers_condition_cummulative", "inherits_cummulative" }) {
 		const ConfigOption *opt = full_config.option(key);
 		if (opt != nullptr)
diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp
index 8e8a49492..1e8f26d38 100644
--- a/src/libslic3r/PrintConfig.cpp
+++ b/src/libslic3r/PrintConfig.cpp
@@ -2434,6 +2434,120 @@ void PrintConfigDef::init_sla_params()
 
     def = this->add("sla_material_settings_id", coString);
     def->default_value = new ConfigOptionString("");
+
+
+    def = this->add("default_sla_print_profile", coString);
+    def->label = L("Default SLA material profile");
+    def->tooltip = L("Default print profile associated with the current printer profile. "
+                   "On selection of the current printer profile, this print profile will be activated.");
+    def->default_value = new ConfigOptionString();
+
+    def = this->add("sla_print_settings_id", coString);
+    def->default_value = new ConfigOptionString("");
+
+    def = this->add("support_head_front_radius", coFloat);
+    def->label = L("Support head front radius");
+    def->tooltip = L("Radius of the pointing side of the head");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(0.2);
+
+    def = this->add("support_head_penetration", coFloat);
+    def->label = L("Support head penetration");
+    def->tooltip = L("How much the pinhead has to penetrate the model surface");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(0.2);
+
+    def = this->add("support_head_back_radius", coFloat);
+    def->label = L("Support head back radius");
+    def->tooltip = L("Radius of the back side of the 3d arrow");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(0.5);
+
+    def = this->add("support_head_width", coFloat);
+    def->label = L("Support head width");
+    def->tooltip = L("Width from the back sphere center to the front sphere center");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(1.0);
+
+    def = this->add("support_pillar_radius", coFloat);
+    def->label = L("Support pillar radius");
+    def->tooltip = L("Radius in mm of the support pillars");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(0.8);
+
+    def = this->add("support_base_radius", coFloat);
+    def->label = L("Support base radius");
+    def->tooltip = L("Radius in mm of the pillar base");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(2.0);
+
+    def = this->add("support_base_height", coFloat);
+    def->label = L("Support base height");
+    def->tooltip = L("The height of the pillar base cone");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(1.0);
+
+    def = this->add("support_critical_angle", coFloat);
+    def->label = L("Critical angle");
+    def->tooltip = L("The default angle for connecting support sticks and junctions.");
+    def->sidetext = L("°");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(45);
+
+    def = this->add("support_max_bridge_length", coFloat);
+    def->label = L("Max bridge length");
+    def->tooltip = L("The max length of a bridge");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat();
+
+    def = this->add("pad_wall_thickness", coFloat);
+    def->label = L("Pad wall thickness");
+    def->tooltip = L("");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(2.0);
+
+    def = this->add("pad_wall_height", coFloat);
+    def->label = L("Pad wall height");
+    def->tooltip = L("");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(5.0);
+
+    def = this->add("pad_max_merge_distance", coFloat);
+    def->label = L("Max merge distance");
+    def->tooltip = L("");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(50.0);
+
+    def = this->add("pad_edge_radius", coFloat);
+    def->label = L("pad edge radius");
+    def->tooltip = L("");
+    def->sidetext = L("mm");
+    def->cli = "";
+    def->min = 0;
+    def->default_value = new ConfigOptionFloat(1.0);
 }
 
 void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &value)
diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp
index e5b6da0a1..545f6d8be 100644
--- a/src/libslic3r/PrintConfig.hpp
+++ b/src/libslic3r/PrintConfig.hpp
@@ -908,7 +908,7 @@ public:
     ConfigOptionFloat support_head_front_radius /*= 0.2*/;
 
     // How much the pinhead has to penetrate the model surface
-    ConfigOptionFloat support_head_penetraiton /*= 0.2*/;
+    ConfigOptionFloat support_head_penetration /*= 0.2*/;
 
     // Radius of the back side of the 3d arrow.
     ConfigOptionFloat support_head_back_radius /*= 0.5*/;
@@ -951,7 +951,7 @@ protected:
     {
         OPT_PTR(layer_height);
         OPT_PTR(support_head_front_radius);
-        OPT_PTR(support_head_penetraiton);
+        OPT_PTR(support_head_penetration);
         OPT_PTR(support_head_back_radius);
         OPT_PTR(support_head_width);
         OPT_PTR(support_pillar_radius);
diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index 85ac442f7..458c32262 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -140,7 +140,7 @@ void MainFrame::init_tabpanel()
     Bind(EVT_TAB_PRESETS_CHANGED, &MainFrame::on_presets_changed, this);
 
     create_preset_tabs();
-    std::vector<std::string> tab_names = { "print", "filament", "sla_material", "printer" };    
+    std::vector<std::string> tab_names = { "print", "filament", "sla_print", "sla_material", "printer" };    
     for (auto tab_name : tab_names)
         m_options_tabs[tab_name] = get_preset_tab(tab_name.c_str()); 
 
@@ -160,6 +160,7 @@ void MainFrame::init_tabpanel()
 std::vector<PresetTab> preset_tabs = {
     { "print", nullptr, ptFFF },
     { "filament", nullptr, ptFFF },
+    { "sla_print", nullptr, ptSLA },
     { "sla_material", nullptr, ptSLA }
 };
 
@@ -194,6 +195,7 @@ void MainFrame::create_preset_tabs()
 {
     wxGetApp().update_label_colours_from_appconfig();
     add_created_tab(new TabPrint(m_tabpanel));
+    add_created_tab(new TabSLAPrint(m_tabpanel));
     add_created_tab(new TabFilament(m_tabpanel));
     add_created_tab(new TabSLAMaterial(m_tabpanel));
     add_created_tab(new TabPrinter(m_tabpanel));
@@ -202,7 +204,7 @@ void MainFrame::create_preset_tabs()
 void MainFrame::add_created_tab(Tab* panel)
 {
     panel->create_preset_tab();
-
+    /*
     const wxString& tab_name = panel->GetName();
     bool add_panel = true;
 
@@ -214,6 +216,8 @@ void MainFrame::add_created_tab(Tab* panel)
     }
 
     if (add_panel)
+*/    
+    if (panel->supports_printer_technology(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology()))
         m_tabpanel->AddPage(panel, panel->title());
 }
 
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index 3b3e30235..eb0d7cc49 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -424,6 +424,7 @@ struct Sidebar::priv
     PresetComboBox *combo_print;
     std::vector<PresetComboBox*> combos_filament;
     wxBoxSizer *sizer_filaments;
+    PresetComboBox *combo_sla_print;
     PresetComboBox *combo_sla_material;
     PresetComboBox *combo_printer;
 
@@ -454,7 +455,7 @@ void Sidebar::priv::show_preset_comboboxes()
     for (size_t i = 0; i < 4; ++i)
         sizer_presets->Show(i, !showSLA);
 
-    for (size_t i = 4; i < 6; ++i) {
+    for (size_t i = 4; i < 8; ++i) {
         if (sizer_presets->IsShown(i) != showSLA)
             sizer_presets->Show(i, showSLA);
     }
@@ -479,7 +480,7 @@ Sidebar::Sidebar(Plater *parent)
     p->scrolled->SetSizer(scrolled_sizer);
 
     // The preset chooser
-    p->sizer_presets = new wxFlexGridSizer(4, 2, 1, 2);
+    p->sizer_presets = new wxFlexGridSizer(5, 2, 1, 2);
     p->sizer_presets->AddGrowableCol(1, 1);
     p->sizer_presets->SetFlexibleDirection(wxBOTH);
     p->sizer_filaments = new wxBoxSizer(wxVERTICAL);
@@ -502,10 +503,11 @@ Sidebar::Sidebar(Plater *parent)
     };
 
     p->combos_filament.push_back(nullptr);
-    init_combo(&p->combo_print, _(L("Print settings")), Preset::TYPE_PRINT, false);
-    init_combo(&p->combos_filament[0], _(L("Filament")), Preset::TYPE_FILAMENT, true);
-    init_combo(&p->combo_sla_material, _(L("SLA material")), Preset::TYPE_SLA_MATERIAL, false);
-    init_combo(&p->combo_printer, _(L("Printer")), Preset::TYPE_PRINTER, false);
+    init_combo(&p->combo_print,         _(L("Print settings")), Preset::TYPE_PRINT,         false);
+    init_combo(&p->combos_filament[0],  _(L("Filament")),       Preset::TYPE_FILAMENT,      true);
+    init_combo(&p->combo_sla_print,     _(L("SLA print")),      Preset::TYPE_SLA_PRINT,     false);
+    init_combo(&p->combo_sla_material,  _(L("SLA material")),   Preset::TYPE_SLA_MATERIAL,  false);
+    init_combo(&p->combo_printer,       _(L("Printer")),        Preset::TYPE_PRINTER,       false);
 
     // calculate width of the preset labels 
     p->sizer_presets->Layout();
@@ -620,6 +622,10 @@ void Sidebar::update_presets(Preset::Type preset_type)
 		preset_bundle.prints.update_platter_ui(p->combo_print);
         break;
 
+    case Preset::TYPE_SLA_PRINT:
+		preset_bundle.sla_prints.update_platter_ui(p->combo_sla_print);
+        break;
+
     case Preset::TYPE_SLA_MATERIAL:
 		preset_bundle.sla_materials.update_platter_ui(p->combo_sla_material);
         break;
@@ -629,8 +635,10 @@ void Sidebar::update_presets(Preset::Type preset_type)
 		// Update the print choosers to only contain the compatible presets, update the dirty flags.
 		if (p->plater->printer_technology() == ptFFF)
 			preset_bundle.prints.update_platter_ui(p->combo_print);
-		else
-			preset_bundle.sla_materials.update_platter_ui(p->combo_sla_material);
+        else {
+            preset_bundle.sla_prints.update_platter_ui(p->combo_sla_print);
+            preset_bundle.sla_materials.update_platter_ui(p->combo_sla_material);
+        }
 		// Update the printer choosers, update the dirty flags.
 		preset_bundle.printers.update_platter_ui(p->combo_printer);
 		// Update the filament choosers to only contain the compatible presets, update the color preview,
diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp
index b6d19b8ef..1599af0c4 100644
--- a/src/slic3r/GUI/Preset.cpp
+++ b/src/slic3r/GUI/Preset.cpp
@@ -396,6 +396,34 @@ const std::vector<std::string>& Preset::sla_material_options()
     return s_opts;
 }
 
+const std::vector<std::string>& Preset::sla_print_options()
+{    
+    static std::vector<std::string> s_opts;
+    if (s_opts.empty()) {
+        s_opts = {
+            "layer_height",
+            "support_head_front_radius",
+            "support_head_penetration",
+            "support_head_back_radius",
+            "support_head_width",
+            "support_pillar_radius",
+            "support_base_radius",
+            "support_base_height",
+            "support_critical_angle",
+            "support_max_bridge_length",
+            "pad_wall_thickness",
+            "pad_wall_height",
+            "pad_max_merge_distance",
+            "pad_edge_radius",
+            "default_sla_print_profile",
+            "compatible_printers",
+            "compatible_printers_condition", 
+            "inherits"
+        };
+    }
+    return s_opts;
+}
+
 PresetCollection::PresetCollection(Preset::Type type, const std::vector<std::string> &keys, const Slic3r::StaticPrintConfig &defaults, const std::string &default_name) :
     m_type(type),
     m_edited_preset(type, "", false),
diff --git a/src/slic3r/GUI/Preset.hpp b/src/slic3r/GUI/Preset.hpp
index 96c313b1b..fc459d8dd 100644
--- a/src/slic3r/GUI/Preset.hpp
+++ b/src/slic3r/GUI/Preset.hpp
@@ -84,6 +84,7 @@ public:
     {
         TYPE_INVALID,
         TYPE_PRINT,
+        TYPE_SLA_PRINT,
         TYPE_FILAMENT,
         TYPE_SLA_MATERIAL,
         TYPE_PRINTER,
@@ -173,6 +174,7 @@ public:
 
     static const std::vector<std::string>&  sla_printer_options();
     static const std::vector<std::string>&  sla_material_options();
+    static const std::vector<std::string>&  sla_print_options();
 
 	static void                             update_suffix_modified();
     static void                             normalize(DynamicPrintConfig &config);
diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp
index bd7e7ab13..c092cae43 100644
--- a/src/slic3r/GUI/PresetBundle.cpp
+++ b/src/slic3r/GUI/PresetBundle.cpp
@@ -45,6 +45,7 @@ PresetBundle::PresetBundle() :
     prints(Preset::TYPE_PRINT, Preset::print_options(), static_cast<const HostConfig&>(FullPrintConfig::defaults())), 
     filaments(Preset::TYPE_FILAMENT, Preset::filament_options(), static_cast<const HostConfig&>(FullPrintConfig::defaults())), 
     sla_materials(Preset::TYPE_SLA_MATERIAL, Preset::sla_material_options(), static_cast<const SLAMaterialConfig&>(SLAFullPrintConfig::defaults())), 
+    sla_prints(Preset::TYPE_SLA_PRINT, Preset::sla_print_options(), static_cast<const SLAPrintObjectConfig&>(SLAFullPrintConfig::defaults())),
     printers(Preset::TYPE_PRINTER, Preset::printer_options(), static_cast<const HostConfig&>(FullPrintConfig::defaults()), "- default FFF -"),
     m_bitmapCompatible(new wxBitmap),
     m_bitmapIncompatible(new wxBitmap),
@@ -76,6 +77,10 @@ PresetBundle::PresetBundle() :
     this->sla_materials.default_preset().compatible_printers_condition();
     this->sla_materials.default_preset().inherits();
 
+    this->sla_prints.default_preset().config.optptr("sla_print_settings_id", true);
+    this->sla_prints.default_preset().compatible_printers_condition();
+    this->sla_prints.default_preset().inherits();
+
     this->printers.add_default_preset(Preset::sla_printer_options(), static_cast<const SLAMaterialConfig&>(SLAFullPrintConfig::defaults()), "- default SLA -");
     this->printers.preset(1).printer_technology() = ptSLA;
     for (size_t i = 0; i < 2; ++ i) {
@@ -88,14 +93,18 @@ PresetBundle::PresetBundle() :
         if (i == 0) {
             preset.config.optptr("default_print_profile", true);
             preset.config.option<ConfigOptionStrings>("default_filament_profile", true)->values = { "" };
-        } else 
+        }
+        else {
             preset.config.optptr("default_sla_material_profile", true);
+            preset.config.optptr("default_sla_print_profile", true);
+        }
         // default_sla_material_profile
         preset.inherits();
     }
 
 	// Load the default preset bitmaps.
     this->prints       .load_bitmap_default("cog.png");
+    this->sla_prints   .load_bitmap_default("package_green.png");
     this->filaments    .load_bitmap_default("spool.png");
     this->sla_materials.load_bitmap_default("package_green.png");
     this->printers     .load_bitmap_default("printer_empty.png");
@@ -103,6 +112,7 @@ PresetBundle::PresetBundle() :
 
     // Re-activate the default presets, so their "edited" preset copies will be updated with the additional configuration values above.
     this->prints       .select_preset(0);
+    this->sla_prints   .select_preset(0);
     this->filaments    .select_preset(0);
     this->sla_materials.select_preset(0);
     this->printers     .select_preset(0);
@@ -133,12 +143,14 @@ void PresetBundle::reset(bool delete_files)
     // Clear the existing presets, delete their respective files.
     this->vendors.clear();
     this->prints       .reset(delete_files);
+    this->sla_prints   .reset(delete_files);
     this->filaments    .reset(delete_files);
     this->sla_materials.reset(delete_files);
     this->printers     .reset(delete_files);
     this->filament_presets.clear();
     this->filament_presets.emplace_back(this->filaments.get_selected_preset_name());
     this->obsolete_presets.prints.clear();
+    this->obsolete_presets.sla_prints.clear();
     this->obsolete_presets.filaments.clear();
     this->obsolete_presets.sla_materials.clear();
     this->obsolete_presets.printers.clear();
@@ -193,6 +205,11 @@ void PresetBundle::load_presets(const AppConfig &config)
     } catch (const std::runtime_error &err) {
         errors_cummulative += err.what();
     }
+    try {
+        this->sla_prints.load_presets(dir_user_presets, "sla_print");
+    } catch (const std::runtime_error &err) {
+        errors_cummulative += err.what();
+    }
     try {
         this->filaments.load_presets(dir_user_presets, "filament");
     } catch (const std::runtime_error &err) {
@@ -267,13 +284,16 @@ std::vector<std::string> PresetBundle::merge_presets(PresetBundle &&other)
 {
     this->vendors.insert(other.vendors.begin(), other.vendors.end());
     std::vector<std::string> duplicate_prints        = this->prints       .merge_presets(std::move(other.prints),        this->vendors);
+    std::vector<std::string> duplicate_sla_prints    = this->sla_prints   .merge_presets(std::move(other.sla_prints),    this->vendors);
     std::vector<std::string> duplicate_filaments     = this->filaments    .merge_presets(std::move(other.filaments),     this->vendors);
     std::vector<std::string> duplicate_sla_materials = this->sla_materials.merge_presets(std::move(other.sla_materials), this->vendors);
     std::vector<std::string> duplicate_printers      = this->printers     .merge_presets(std::move(other.printers),      this->vendors);
 	append(this->obsolete_presets.prints,        std::move(other.obsolete_presets.prints));
+	append(this->obsolete_presets.sla_prints,    std::move(other.obsolete_presets.sla_prints));
 	append(this->obsolete_presets.filaments,     std::move(other.obsolete_presets.filaments));
     append(this->obsolete_presets.sla_materials, std::move(other.obsolete_presets.sla_materials));
 	append(this->obsolete_presets.printers,      std::move(other.obsolete_presets.printers));
+	append(duplicate_prints, std::move(duplicate_sla_prints));
 	append(duplicate_prints, std::move(duplicate_filaments));
     append(duplicate_prints, std::move(duplicate_sla_materials));
     append(duplicate_prints, std::move(duplicate_printers));
@@ -307,6 +327,7 @@ void PresetBundle::load_selections(const AppConfig &config)
 
     // Parse the initial print / filament / printer profile names.
     std::string initial_print_profile_name        = remove_ini_suffix(config.get("presets", "print"));
+    std::string initial_sla_print_profile_name    = remove_ini_suffix(config.get("presets", "sla_print"));
     std::string initial_filament_profile_name     = remove_ini_suffix(config.get("presets", "filament"));
     std::string initial_sla_material_profile_name = remove_ini_suffix(config.get("presets", "sla_material"));
 	std::string initial_printer_profile_name      = remove_ini_suffix(config.get("presets", "printer"));
@@ -320,10 +341,12 @@ void PresetBundle::load_selections(const AppConfig &config)
     if (printer_technology == ptFFF) {
         prints.select_preset_by_name_strict(initial_print_profile_name);
         filaments.select_preset_by_name_strict(initial_filament_profile_name);
+        sla_prints.select_preset_by_name(initial_sla_material_profile_name, true);
         sla_materials.select_preset_by_name(initial_sla_material_profile_name, true);
     } else {
         prints.select_preset_by_name(initial_print_profile_name, true);
         filaments.select_preset_by_name(initial_filament_profile_name, true);
+        sla_prints.select_preset_by_name_strict(initial_sla_material_profile_name);
         sla_materials.select_preset_by_name_strict(initial_sla_material_profile_name);
     }
 
@@ -358,6 +381,7 @@ void PresetBundle::export_selections(AppConfig &config)
 	assert(this->printers.get_edited_preset().printer_technology() != ptFFF || filament_presets.size() > 1 || filaments.get_selected_preset_name() == filament_presets.front());
     config.clear_section("presets");
     config.set("presets", "print",        prints.get_selected_preset_name());
+    config.set("presets", "sla_print",    sla_prints.get_selected_preset_name());
     config.set("presets", "filament",     filament_presets.front());
 	for (int i = 1; i < filament_presets.size(); ++i) {
         char name[64];
@@ -378,6 +402,7 @@ void PresetBundle::export_selections(PlaceholderParser &pp)
         pp.set("filament_preset",     filament_presets);
         break;
     case ptSLA:
+        pp.set("sla_print_preset",    sla_prints.get_selected_preset().name);
         pp.set("sla_material_preset", sla_materials.get_selected_preset().name);
         break;
     }
@@ -401,24 +426,28 @@ bool PresetBundle::load_compatible_bitmaps()
     if (loaded_compatible) {
         prints       .set_bitmap_compatible(m_bitmapCompatible);
         filaments    .set_bitmap_compatible(m_bitmapCompatible);
+        sla_prints   .set_bitmap_compatible(m_bitmapCompatible);
         sla_materials.set_bitmap_compatible(m_bitmapCompatible);
 //        printers .set_bitmap_compatible(m_bitmapCompatible);
     }
     if (loaded_incompatible) {
         prints       .set_bitmap_incompatible(m_bitmapIncompatible);
         filaments    .set_bitmap_incompatible(m_bitmapIncompatible);
+        sla_prints   .set_bitmap_incompatible(m_bitmapIncompatible);
         sla_materials.set_bitmap_incompatible(m_bitmapIncompatible);
 //        printers .set_bitmap_incompatible(m_bitmapIncompatible);
     }
     if (loaded_lock) {
         prints       .set_bitmap_lock(m_bitmapLock);
         filaments    .set_bitmap_lock(m_bitmapLock);
+        sla_prints   .set_bitmap_lock(m_bitmapLock);
         sla_materials.set_bitmap_lock(m_bitmapLock);
         printers     .set_bitmap_lock(m_bitmapLock);
     }
     if (loaded_lock_open) {
         prints       .set_bitmap_lock_open(m_bitmapLock);
         filaments    .set_bitmap_lock_open(m_bitmapLock);
+        sla_prints   .set_bitmap_lock_open(m_bitmapLock);
         sla_materials.set_bitmap_lock_open(m_bitmapLock);
         printers     .set_bitmap_lock_open(m_bitmapLock);
     }
@@ -533,14 +562,17 @@ DynamicPrintConfig PresetBundle::full_sla_config() const
 {    
     DynamicPrintConfig out;
     out.apply(SLAFullPrintConfig::defaults());
+    out.apply(this->sla_prints.get_edited_preset().config);
     out.apply(this->sla_materials.get_edited_preset().config);
     out.apply(this->printers.get_edited_preset().config);
     // There are no project configuration values as of now, the project_config is reserved for FFF printers.
 //    out.apply(this->project_config);
 
-    // Collect the "compatible_printers_condition" and "inherits" values over all presets (sla_materials, printers) into a single vector.
+    // Collect the "compatible_printers_condition" and "inherits" values over all presets (sla_prints, sla_materials, printers) into a single vector.
     std::vector<std::string> compatible_printers_condition;
     std::vector<std::string> inherits;
+    compatible_printers_condition.emplace_back(this->/*prints*/sla_prints.get_edited_preset().compatible_printers_condition());
+    inherits                     .emplace_back(this->/*prints*/sla_prints.get_edited_preset().inherits());
     compatible_printers_condition.emplace_back(this->/*prints*/sla_materials.get_edited_preset().compatible_printers_condition());
     inherits                     .emplace_back(this->/*prints*/sla_materials.get_edited_preset().inherits());
     inherits                     .emplace_back(this->printers.get_edited_preset().inherits());
@@ -550,6 +582,7 @@ DynamicPrintConfig PresetBundle::full_sla_config() const
     out.erase("compatible_printers_condition");
     out.erase("inherits");
     
+    out.option<ConfigOptionString >("sla_print_settings_id",    true)->value  = this->sla_prints.get_selected_preset().name;
     out.option<ConfigOptionString >("sla_material_settings_id", true)->value  = this->sla_materials.get_selected_preset().name;
     out.option<ConfigOptionString >("printer_settings_id",      true)->value  = this->printers.get_selected_preset().name;
 
@@ -661,6 +694,8 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
 
     // 2) If the loading succeeded, split and load the config into print / filament / printer settings.
     // First load the print and printer presets.
+
+    // #ys_FIXME_SLA_PRINT
     for (size_t i_group = 0; i_group < 2; ++ i_group) {
         PresetCollection &presets = (i_group == 0) ? ((printer_technology == ptFFF) ? this->prints : this->sla_materials) : this->printers;
         // Split the "compatible_printers_condition" and "inherits" values one by one from a single vector to the print & printer profiles.
@@ -794,6 +829,7 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
         return preset_name_dst;
     };
     load_one(this->prints,        tmp_bundle.prints,        tmp_bundle.prints       .get_selected_preset().name, true);
+    load_one(this->sla_prints,    tmp_bundle.sla_prints,    tmp_bundle.sla_prints   .get_selected_preset().name, true);
     load_one(this->filaments,     tmp_bundle.filaments,     tmp_bundle.filaments    .get_selected_preset().name, true);
     load_one(this->sla_materials, tmp_bundle.sla_materials, tmp_bundle.sla_materials.get_selected_preset().name, true);
     load_one(this->printers,      tmp_bundle.printers,      tmp_bundle.printers     .get_selected_preset().name, true);
@@ -919,6 +955,7 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, co
 static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree)
 {
     flatten_configbundle_hierarchy(tree, "print");
+    flatten_configbundle_hierarchy(tree, "sla_print");
     flatten_configbundle_hierarchy(tree, "filament");
     flatten_configbundle_hierarchy(tree, "sla_material");
     flatten_configbundle_hierarchy(tree, "printer");
@@ -957,10 +994,12 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
     // Parse the obsolete preset names, to be deleted when upgrading from the old configuration structure.
     std::vector<std::string> loaded_prints;
     std::vector<std::string> loaded_filaments;
+    std::vector<std::string> loaded_sla_prints;
     std::vector<std::string> loaded_sla_materials;
     std::vector<std::string> loaded_printers;
     std::string              active_print;
     std::vector<std::string> active_filaments;
+    std::string              active_sla_print;
     std::string              active_sla_material;
     std::string              active_printer;
     size_t                   presets_loaded = 0;
@@ -976,6 +1015,10 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
             presets = &this->filaments;
             loaded  = &loaded_filaments;
             preset_name = section.first.substr(9);
+        } else if (boost::starts_with(section.first, "sla_print:")) {
+            presets = &this->sla_prints;
+            loaded  = &loaded_sla_prints;
+            preset_name = section.first.substr(13);
         } else if (boost::starts_with(section.first, "sla_material:")) {
             presets = &this->sla_materials;
             loaded  = &loaded_sla_materials;
@@ -996,6 +1039,8 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
                             active_filaments.resize(idx + 1, std::string());
                         active_filaments[idx] = kvp.second.data();
                     }
+                } else if (kvp.first == "sla_print") {
+                    active_sla_print = kvp.second.data();
                 } else if (kvp.first == "sla_material") {
                     active_sla_material = kvp.second.data();
                 } else if (kvp.first == "printer") {
@@ -1011,6 +1056,8 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
                     dst = &this->obsolete_presets.prints;
                 else if (kvp.first == "filament")
                     dst = &this->obsolete_presets.filaments;
+                else if (kvp.first == "sla_print")
+                    dst = &this->obsolete_presets.sla_prints;
                 else if (kvp.first == "sla_material")
                     dst = &this->obsolete_presets.sla_materials;
                 else if (kvp.first == "printer")
@@ -1113,6 +1160,8 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
     if ((flags & LOAD_CFGBNDLE_SYSTEM) == 0) {
         if (! active_print.empty()) 
             prints.select_preset_by_name(active_print, true);
+        if (! active_sla_print.empty()) 
+            sla_materials.select_preset_by_name(active_sla_print, true);
         if (! active_sla_material.empty()) 
             sla_materials.select_preset_by_name(active_sla_material, true);
         if (! active_printer.empty())
@@ -1217,6 +1266,13 @@ void PresetBundle::update_compatible_with_printer(bool select_other_if_incompati
             this->sla_materials.update_compatible_with_printer(printer_preset, select_other_if_incompatible) :
 			this->sla_materials.update_compatible_with_printer(printer_preset, select_other_if_incompatible,
                 [&prefered_sla_material_profile](const std::string& profile_name){ return profile_name == prefered_sla_material_profile; });
+		
+        const std::string              &prefered_sla_print_profile        = printer_preset.config.opt_string("default_sla_print_profile");
+        prefered_sla_print_profile.empty() ?
+            this->sla_prints.update_compatible_with_printer(printer_preset, select_other_if_incompatible) :
+			this->sla_prints.update_compatible_with_printer(printer_preset, select_other_if_incompatible,
+            [&prefered_sla_print_profile](const std::string& profile_name){ return profile_name == prefered_sla_print_profile; });
+
 		break;
 	}
     }
@@ -1231,6 +1287,8 @@ void PresetBundle::export_configbundle(const std::string &path) //, const Dynami
     c << "# " << Slic3r::header_slic3r_generated() << std::endl;
 
     // Export the print, filament and printer profiles.
+
+    // #ys_FIXME_SLA_PRINT
     for (size_t i_group = 0; i_group < 3; ++ i_group) {
         const PresetCollection &presets = (i_group == 0) ? this->prints : (i_group == 1) ? this->filaments : this->printers;
         for (const Preset &preset : presets()) {
@@ -1246,6 +1304,7 @@ void PresetBundle::export_configbundle(const std::string &path) //, const Dynami
     // Export the names of the active presets.
     c << std::endl << "[presets]" << std::endl;
     c << "print = " << this->prints.get_selected_preset().name << std::endl;
+    c << "sla_print = " << this->sla_prints.get_selected_preset().name << std::endl;
     c << "sla_material = " << this->sla_materials.get_selected_preset().name << std::endl;
     c << "printer = " << this->printers.get_selected_preset().name << std::endl;
     for (size_t i = 0; i < this->filament_presets.size(); ++ i) {
@@ -1401,6 +1460,7 @@ void PresetBundle::set_default_suppressed(bool default_suppressed)
 {
     prints.set_default_suppressed(default_suppressed);
     filaments.set_default_suppressed(default_suppressed);
+    sla_prints.set_default_suppressed(default_suppressed);
     sla_materials.set_default_suppressed(default_suppressed);
     printers.set_default_suppressed(default_suppressed);
 }
diff --git a/src/slic3r/GUI/PresetBundle.hpp b/src/slic3r/GUI/PresetBundle.hpp
index 07f89bc70..06ae95094 100644
--- a/src/slic3r/GUI/PresetBundle.hpp
+++ b/src/slic3r/GUI/PresetBundle.hpp
@@ -39,6 +39,7 @@ public:
     void            export_selections(PlaceholderParser &pp);
 
     PresetCollection            prints;
+    PresetCollection            sla_prints;
     PresetCollection            filaments;
     PresetCollection            sla_materials;
     PrinterPresetCollection     printers;
@@ -57,6 +58,7 @@ public:
 
     struct ObsoletePresets {
         std::vector<std::string> prints;
+        std::vector<std::string> sla_prints;
         std::vector<std::string> filaments;
         std::vector<std::string> sla_materials;
         std::vector<std::string> printers;
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index 307f9fe62..2d42facb7 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -27,7 +27,6 @@
 #include "wxExtensions.hpp"
 #include <wx/wupdlock.h>
 
-#include <chrono>
 #include "GUI_App.hpp"
 
 namespace Slic3r {
@@ -41,6 +40,7 @@ wxDEFINE_EVENT(EVT_TAB_PRESETS_CHANGED, SimpleEvent);
 void Tab::set_type()
 {
     if (m_name == "print")              { m_type = Slic3r::Preset::TYPE_PRINT; }
+    else if (m_name == "sla_print")     { m_type = Slic3r::Preset::TYPE_SLA_PRINT; }
     else if (m_name == "filament")      { m_type = Slic3r::Preset::TYPE_FILAMENT; }
     else if (m_name == "sla_material")  { m_type = Slic3r::Preset::TYPE_SLA_MATERIAL; }
     else if (m_name == "printer")       { m_type = Slic3r::Preset::TYPE_PRINTER; }
@@ -828,6 +828,10 @@ void Tab::update_preset_description_line()
 				const std::string &default_sla_material_profile = preset.config.opt_string("default_sla_material_profile");
 				if (!default_sla_material_profile.empty())
 					description_line += "\n\n\t" + _(L("default SLA material profile")) + ": \n\t\t" + default_sla_material_profile;
+
+				const std::string &default_sla_print_profile = preset.config.opt_string("default_sla_print_profile");
+				if (!default_sla_print_profile.empty())
+					description_line += "\n\n\t" + _(L("default SLA print profile")) + ": \n\t\t" + default_sla_print_profile;
 				break;
 			}
 			}
@@ -2347,6 +2351,7 @@ void Tab::select_preset(std::string preset_name)
 	auto current_dirty = m_presets->current_is_dirty();
 	auto printer_tab   = m_presets->name() == "printer";
 	auto canceled      = false;
+// 	m_reload_dependent_tabs = {};
 	m_dependent_tabs = {};
 	if (current_dirty && !may_discard_current_dirty_preset()) {
 		canceled = true;
@@ -2370,6 +2375,7 @@ void Tab::select_preset(std::string preset_name)
 		};
 		std::vector<PresetUpdate> updates = {
 			{ Preset::Type::TYPE_PRINT,       &m_preset_bundle->prints,			ptFFF },
+			{ Preset::Type::TYPE_SLA_PRINT,   &m_preset_bundle->sla_prints,		ptSLA },
 			{ Preset::Type::TYPE_FILAMENT,    &m_preset_bundle->filaments,		ptFFF },
  			{ Preset::Type::TYPE_SLA_MATERIAL,&m_preset_bundle->sla_materials,	ptSLA }
 		};
@@ -2382,8 +2388,10 @@ void Tab::select_preset(std::string preset_name)
 		if (! canceled) {
 			for (PresetUpdate &pu : updates) {
 				// The preset will be switched to a different, compatible preset, or the '-- default --'.
-                if (pu.technology == new_printer_technology)
+                if (pu.technology == new_printer_technology) {
+// 				    m_reload_dependent_tabs.emplace_back(pu.name);
 					m_dependent_tabs.emplace_back(pu.tab_type);
+				}
 				if (pu.old_preset_dirty)
 					pu.presets->discard_current_changes();
 			}
@@ -2918,7 +2926,7 @@ void TabSLAMaterial::build()
     auto page = add_options_page(_(L("Material")), "package_green.png");
 
     auto optgroup = page->new_optgroup(_(L("Layers")));
-    optgroup->append_single_option_line("layer_height");
+//     optgroup->append_single_option_line("layer_height");
     optgroup->append_single_option_line("initial_layer_height");
 
     optgroup = page->new_optgroup(_(L("Exposure")));
@@ -2973,7 +2981,43 @@ void TabSLAMaterial::build()
 void TabSLAMaterial::update()
 {
     if (m_preset_bundle->printers.get_selected_preset().printer_technology() == ptFFF)
-        return; // ys_FIXME
+        return; // #ys_FIXME
+}
+
+void TabSLAPrint::build()
+{
+    m_presets = &m_preset_bundle->sla_prints;
+    load_initial_data();
+
+    auto page = add_options_page(_(L("Layers and perimeters")), "package_green.png");
+
+    auto optgroup = page->new_optgroup(_(L("Layers")));
+    optgroup->append_single_option_line("layer_height");
+
+    page = add_options_page(_(L("Dependencies")), "wrench.png");
+    optgroup = page->new_optgroup(_(L("Profile dependencies")));
+    Line line = optgroup->create_single_option_line("compatible_printers");//Line { _(L("Compatible printers")), "" };
+    line.widget = [this](wxWindow* parent) {
+        return compatible_printers_widget(parent, &m_compatible_printers_checkbox, &m_compatible_printers_btn);
+    };
+    optgroup->append_line(line, &m_colored_Label);
+
+    Option option = optgroup->get_option("compatible_printers_condition");
+    option.opt.full_width = true;
+    optgroup->append_single_option_line(option);
+
+    line = Line{ "", "" };
+    line.full_width = 1;
+    line.widget = [this](wxWindow* parent) {
+        return description_line_widget(parent, &m_parent_preset_description_line);
+    };
+    optgroup->append_line(line);
+}
+
+void TabSLAPrint::update()
+{
+    if (m_preset_bundle->printers.get_selected_preset().printer_technology() == ptFFF)
+        return; // #ys_FIXME
 }
 
 } // GUI
diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp
index 0f2b1b41c..9b897b6f7 100644
--- a/src/slic3r/GUI/Tab.hpp
+++ b/src/slic3r/GUI/Tab.hpp
@@ -370,6 +370,19 @@ public:
     bool 		supports_printer_technology(const PrinterTechnology tech) override { return tech == ptSLA; }
 };
 
+class TabSLAPrint : public Tab
+{
+public:
+    TabSLAPrint() {}
+    TabSLAPrint(wxNotebook* parent) :
+        Tab(parent, _(L("SLA Print Settings")), "sla_print") {}
+    ~TabSLAPrint() {}
+        void		build() override;
+    void		update() override;
+//     void		init_options_list() override;
+    bool 		supports_printer_technology(const PrinterTechnology tech) override { return tech == ptSLA; }
+};
+
 class SavePresetWindow :public wxDialog
 {
 public:

From ae4f116b460c057f64dbb48d7e6bc40719b77fe9 Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Mon, 19 Nov 2018 09:15:53 +0100
Subject: [PATCH 3/6] Added the context to the TabPrintSLA

---
 src/slic3r/GUI/MainFrame.cpp |  9 ++-------
 src/slic3r/GUI/Tab.cpp       | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index 458c32262..099bec5c5 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -204,19 +204,14 @@ void MainFrame::create_preset_tabs()
 void MainFrame::add_created_tab(Tab* panel)
 {
     panel->create_preset_tab();
-    /*
+
     const wxString& tab_name = panel->GetName();
-    bool add_panel = true;
 
     auto it = std::find_if(preset_tabs.begin(), preset_tabs.end(),
         [tab_name](PresetTab& tab) {return tab.name == tab_name; });
-    if (it != preset_tabs.end()) {
+    if (it != preset_tabs.end())
         it->panel = panel;
-        add_panel = it->technology == wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
-    }
 
-    if (add_panel)
-*/    
     if (panel->supports_printer_technology(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology()))
         m_tabpanel->AddPage(panel, panel->title());
 }
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index 2d42facb7..72147d6c7 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -2994,6 +2994,28 @@ void TabSLAPrint::build()
     auto optgroup = page->new_optgroup(_(L("Layers")));
     optgroup->append_single_option_line("layer_height");
 
+    page = add_options_page(_(L("Supports")), "building.png");
+    optgroup = page->new_optgroup(_(L("Support head")));
+    optgroup->append_single_option_line("support_head_front_radius");
+    optgroup->append_single_option_line("support_head_back_radius");
+    optgroup->append_single_option_line("support_head_penetration");
+    optgroup->append_single_option_line("support_head_width");
+
+    optgroup = page->new_optgroup(_(L("Support pillar")));
+    optgroup->append_single_option_line("support_pillar_radius");
+    optgroup->append_single_option_line("support_base_radius");
+    optgroup->append_single_option_line("support_base_height");
+
+    optgroup = page->new_optgroup(_(L("Connection of the support sticks and junctions")));
+    optgroup->append_single_option_line("support_critical_angle");
+    optgroup->append_single_option_line("support_max_bridge_length");
+
+    optgroup = page->new_optgroup(_(L("Pad")));
+    optgroup->append_single_option_line("pad_wall_thickness");
+    optgroup->append_single_option_line("pad_wall_height");
+    optgroup->append_single_option_line("pad_max_merge_distance");
+    optgroup->append_single_option_line("pad_edge_radius");
+
     page = add_options_page(_(L("Dependencies")), "wrench.png");
     optgroup = page->new_optgroup(_(L("Profile dependencies")));
     Line line = optgroup->create_single_option_line("compatible_printers");//Line { _(L("Compatible printers")), "" };

From 703f367e6961c16cfcd9c0a156eb541ee4548f85 Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Mon, 19 Nov 2018 11:10:22 +0100
Subject: [PATCH 4/6] Fixed preset updating

---
 src/slic3r/GUI/AppConfig.cpp       |  1 +
 src/slic3r/GUI/MainFrame.cpp       | 19 -------------------
 src/slic3r/GUI/Plater.cpp          |  2 --
 src/slic3r/GUI/PresetBundle.cpp    |  8 +++++---
 src/slic3r/Utils/PresetUpdater.cpp |  3 ++-
 5 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp
index d7307cc32..7a277b119 100644
--- a/src/slic3r/GUI/AppConfig.cpp
+++ b/src/slic3r/GUI/AppConfig.cpp
@@ -241,6 +241,7 @@ void AppConfig::reset_selections()
     if (it != m_storage.end()) {
         it->second.erase("print");
         it->second.erase("filament");
+        it->second.erase("sla_print");
         it->second.erase("sla_material");
         it->second.erase("printer");
         m_dirty = true;
diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index 099bec5c5..3e454061f 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -796,7 +796,6 @@ void MainFrame::on_presets_changed(SimpleEvent &event)
     // Update preset combo boxes(Print settings, Filament, Material, Printer) from their respective tabs.
     auto presets = tab->get_presets();
     if (m_plater != nullptr && presets != nullptr) {
-//         auto reload_dependent_tabs = tab->get_dependent_tabs();
 
         // FIXME: The preset type really should be a property of Tab instead
         Slic3r::Preset::Type preset_type = tab->type();
@@ -804,25 +803,7 @@ void MainFrame::on_presets_changed(SimpleEvent &event)
             wxASSERT(false);
             return;
         }
-/*
-        m_plater->sidebar().update_presets(preset_type);
 
-        if (preset_type == Slic3r::Preset::TYPE_PRINTER) {
-            // Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors.
-            // XXX: Do this in a more C++ way
-            for (const auto tab_name_other : { "print", "filament", "sla_material" }) {
-                Tab* cur_tab = m_options_tabs[tab_name_other];
-                // If the printer tells us that the print or filament preset has been switched or invalidated,
-                // refresh the print or filament tab page.Otherwise just refresh the combo box.
-                if (reload_dependent_tabs.empty() ||
-                    find(reload_dependent_tabs.begin(), reload_dependent_tabs.end(), tab_name_other) ==
-                    reload_dependent_tabs.end() )
-                    cur_tab->update_tab_ui();
-                else
-                    cur_tab->load_current_preset();
-            }
-        }
-*/
         m_plater->on_config_change(*tab->get_config());
         m_plater->sidebar().update_presets(preset_type);
     }
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index eb0d7cc49..5bef5deb1 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -1879,8 +1879,6 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
         }
     }
 
-    // Synchronize config.ini with the current selections.
-    wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
     // update plater with new config
     wxGetApp().plater()->on_config_change(wxGetApp().preset_bundle->full_config());
 }
diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp
index c092cae43..55729d7e4 100644
--- a/src/slic3r/GUI/PresetBundle.cpp
+++ b/src/slic3r/GUI/PresetBundle.cpp
@@ -168,12 +168,14 @@ void PresetBundle::setup_directories()
         data_dir / "presets", 
         data_dir / "presets" / "print", 
         data_dir / "presets" / "filament", 
+        data_dir / "presets" / "sla_print",  
         data_dir / "presets" / "sla_material", 
         data_dir / "presets" / "printer" 
 #else
         // Store the print/filament/printer presets at the same location as the upstream Slic3r.
         data_dir / "print", 
         data_dir / "filament", 
+        data_dir / "sla_print", 
         data_dir / "sla_material", 
         data_dir / "printer" 
 #endif
@@ -381,13 +383,13 @@ void PresetBundle::export_selections(AppConfig &config)
 	assert(this->printers.get_edited_preset().printer_technology() != ptFFF || filament_presets.size() > 1 || filaments.get_selected_preset_name() == filament_presets.front());
     config.clear_section("presets");
     config.set("presets", "print",        prints.get_selected_preset_name());
-    config.set("presets", "sla_print",    sla_prints.get_selected_preset_name());
     config.set("presets", "filament",     filament_presets.front());
 	for (int i = 1; i < filament_presets.size(); ++i) {
         char name[64];
         sprintf(name, "filament_%d", i);
         config.set("presets", name, filament_presets[i]);
     }
+    config.set("presets", "sla_print",    sla_prints.get_selected_preset_name());
     config.set("presets", "sla_material", sla_materials.get_selected_preset_name());
     config.set("presets", "printer",  printers.get_selected_preset_name());
 }
@@ -955,8 +957,8 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, co
 static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree)
 {
     flatten_configbundle_hierarchy(tree, "print");
-    flatten_configbundle_hierarchy(tree, "sla_print");
     flatten_configbundle_hierarchy(tree, "filament");
+    flatten_configbundle_hierarchy(tree, "sla_print");
     flatten_configbundle_hierarchy(tree, "sla_material");
     flatten_configbundle_hierarchy(tree, "printer");
 }
@@ -1018,7 +1020,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
         } else if (boost::starts_with(section.first, "sla_print:")) {
             presets = &this->sla_prints;
             loaded  = &loaded_sla_prints;
-            preset_name = section.first.substr(13);
+            preset_name = section.first.substr(10);
         } else if (boost::starts_with(section.first, "sla_material:")) {
             presets = &this->sla_materials;
             loaded  = &loaded_sla_materials;
diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp
index 026e340da..47eece8ab 100644
--- a/src/slic3r/Utils/PresetUpdater.cpp
+++ b/src/slic3r/Utils/PresetUpdater.cpp
@@ -448,7 +448,8 @@ void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons
 
 			for (const auto &name : bundle.obsolete_presets.prints)    { obsolete_remover("print", name); }
 			for (const auto &name : bundle.obsolete_presets.filaments) { obsolete_remover("filament", name); }
-			for (const auto &name : bundle.obsolete_presets.filaments) { obsolete_remover("sla_material", name); }
+			for (const auto &name : bundle.obsolete_presets.sla_prints) { obsolete_remover("sla_print", name); } 
+			for (const auto &name : bundle.obsolete_presets.sla_materials/*filaments*/) { obsolete_remover("sla_material", name); } 
 			for (const auto &name : bundle.obsolete_presets.printers)  { obsolete_remover("printer", name); }
 		}
 	}

From 398f15d54684540220dedc202f9ae87d33ac9413 Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Mon, 19 Nov 2018 13:17:14 +0100
Subject: [PATCH 5/6] Some code rebase

---
 src/slic3r/GUI/MainFrame.cpp | 73 ++++++------------------------------
 src/slic3r/GUI/MainFrame.hpp |  7 ----
 src/slic3r/GUI/Plater.cpp    |  2 +-
 src/slic3r/GUI/Tab.cpp       | 18 ++++-----
 4 files changed, 21 insertions(+), 79 deletions(-)

diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index 3e454061f..94bb0bd5e 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -109,20 +109,15 @@ void MainFrame::init_tabpanel()
 
     m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&) {
         auto panel = m_tabpanel->GetCurrentPage();
-//             panel->OnActivate(); if panel->can('OnActivate');
 
         if (panel == nullptr)
             return;
 
-        for (auto& tab_name : { "print", "filament", "printer" }) {
-            if (tab_name == panel->GetName()) {
-                // On GTK, the wxEVT_NOTEBOOK_PAGE_CHANGED event is triggered
-                // before the MainFrame is fully set up.
-                auto it = m_options_tabs.find(tab_name);
-                assert(it != m_options_tabs.end());
-                if (it != m_options_tabs.end())
-                    it->second->OnActivate();
-            }
+        auto& tabs_list = wxGetApp().tabs_list;
+        if (find(tabs_list.begin(), tabs_list.end(), panel) != tabs_list.end()) {
+            // On GTK, the wxEVT_NOTEBOOK_PAGE_CHANGED event is triggered
+            // before the MainFrame is fully set up.
+            static_cast<Tab*>(panel)->OnActivate();
         }
     });
 
@@ -140,9 +135,6 @@ void MainFrame::init_tabpanel()
     Bind(EVT_TAB_PRESETS_CHANGED, &MainFrame::on_presets_changed, this);
 
     create_preset_tabs();
-    std::vector<std::string> tab_names = { "print", "filament", "sla_print", "sla_material", "printer" };    
-    for (auto tab_name : tab_names)
-        m_options_tabs[tab_name] = get_preset_tab(tab_name.c_str()); 
 
     if (m_plater) {
         // load initial config
@@ -157,46 +149,12 @@ void MainFrame::init_tabpanel()
     }
 }
 
-std::vector<PresetTab> preset_tabs = {
-    { "print", nullptr, ptFFF },
-    { "filament", nullptr, ptFFF },
-    { "sla_print", nullptr, ptSLA },
-    { "sla_material", nullptr, ptSLA }
-};
-
-std::vector<PresetTab>& MainFrame::get_preset_tabs() {
-    return preset_tabs;
-}
-
-Tab* MainFrame::get_tab(const std::string& name)
-{
-    std::vector<PresetTab>::iterator it = std::find_if(preset_tabs.begin(), preset_tabs.end(),
-        [name](PresetTab& tab) { return name == tab.name; });
-    return it != preset_tabs.end() ? it->panel : nullptr;
-}
-
-Tab* MainFrame::get_preset_tab(const std::string& name)
-{
-    Tab* tab = get_tab(name);
-    if (tab) return tab;
-
-    for (size_t i = 0; i < m_tabpanel->GetPageCount(); ++i) {
-        tab = dynamic_cast<Tab*>(m_tabpanel->GetPage(i));
-        if (!tab)
-            continue;
-        if (tab->name() == name) {
-            return tab;
-        }
-    }
-    return nullptr;
-}
-
 void MainFrame::create_preset_tabs()
 {
     wxGetApp().update_label_colours_from_appconfig();
     add_created_tab(new TabPrint(m_tabpanel));
-    add_created_tab(new TabSLAPrint(m_tabpanel));
     add_created_tab(new TabFilament(m_tabpanel));
+    add_created_tab(new TabSLAPrint(m_tabpanel));
     add_created_tab(new TabSLAMaterial(m_tabpanel));
     add_created_tab(new TabPrinter(m_tabpanel));
 }
@@ -205,14 +163,9 @@ void MainFrame::add_created_tab(Tab* panel)
 {
     panel->create_preset_tab();
 
-    const wxString& tab_name = panel->GetName();
+    const auto printer_tech = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
 
-    auto it = std::find_if(preset_tabs.begin(), preset_tabs.end(),
-        [tab_name](PresetTab& tab) {return tab.name == tab_name; });
-    if (it != preset_tabs.end())
-        it->panel = panel;
-
-    if (panel->supports_printer_technology(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology()))
+    if (panel->supports_printer_technology(printer_tech))
         m_tabpanel->AddPage(panel, panel->title());
 }
 
@@ -767,8 +720,8 @@ void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool re
 // Also update the platter with the new presets.
 void MainFrame::load_config(const DynamicPrintConfig& config)
 {
-    for (auto tab : m_options_tabs)
-        tab.second->load_config(config);
+    for (auto tab : wxGetApp().tabs_list)
+        tab->load_config(config);
     if (m_plater) 
         m_plater->on_config_change(config);
 }
@@ -838,11 +791,7 @@ void MainFrame::update_ui_from_settings()
 {
     m_menu_item_reslice_now->Enable(wxGetApp().app_config->get("background_processing") == "1");
 //     if (m_plater) m_plater->update_ui_from_settings();
-    /*
-    std::vector<std::string> tab_names = { "print", "filament", "printer" };
-    for (auto tab_name: tab_names)
-        m_options_tabs[tab_name]->update_ui_from_settings();
-    */
+
     for (auto tab: wxGetApp().tabs_list)
         tab->update_ui_from_settings();
 }
diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp
index b324586c4..8cac3e8e2 100644
--- a/src/slic3r/GUI/MainFrame.hpp
+++ b/src/slic3r/GUI/MainFrame.hpp
@@ -53,8 +53,6 @@ class MainFrame : public wxFrame
     wxString    m_qs_last_output_file = wxEmptyString;
     wxString    m_last_config = wxEmptyString;
 
-    std::map<std::string, Tab*>     m_options_tabs;
-
     wxMenuItem* m_menu_item_repeat { nullptr };
     wxMenuItem* m_menu_item_reslice_now { nullptr };
 #if !ENABLE_NEW_MENU_LAYOUT
@@ -67,7 +65,6 @@ class MainFrame : public wxFrame
 
     void on_presets_changed(SimpleEvent&);
     void on_value_changed(wxCommandEvent&);
-    Tab*         get_tab(const std::string& name);
 
 #if ENABLE_NEW_MENU_LAYOUT
     bool can_save() const;
@@ -84,8 +81,6 @@ public:
     Plater*     plater() { return m_plater; }
 
     void        init_tabpanel();
-    const std::map<std::string, Tab*>& options_tabs() const { return m_options_tabs; }
-    Tab*        get_preset_tab(const std::string& name);
     void        create_preset_tabs();
     void        add_created_tab(Tab* panel);
     void        init_menubar();
@@ -105,8 +100,6 @@ public:
     void        select_tab(size_t tab) const;
     void        select_view(const std::string& direction);
 
-    std::vector<PresetTab>& get_preset_tabs();
-
     Plater*             m_plater { nullptr };
     wxNotebook*         m_tabpanel { nullptr };
     wxProgressDialog*   m_progress_dialog { nullptr };
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index 5bef5deb1..abf58798f 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -2027,7 +2027,7 @@ void Plater::priv::on_wipetower_moved(Vec3dEvent &evt)
     DynamicPrintConfig cfg;
     cfg.opt<ConfigOptionFloat>("wipe_tower_x", true)->value = evt.data(0);
     cfg.opt<ConfigOptionFloat>("wipe_tower_y", true)->value = evt.data(1);
-    main_frame->get_preset_tab("print")->load_config(cfg);
+    wxGetApp().get_tab(Preset::TYPE_PRINT)->load_config(cfg);
 }
 
 void Plater::priv::on_enable_action_buttons(Event<bool>&)
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index 72147d6c7..4c9e56bbd 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -765,9 +765,7 @@ void Tab::on_presets_changed()
         {
             // If the printer tells us that the print or filament/sla_material preset has been switched or invalidated,
             // refresh the print or filament/sla_material tab page.
-            Tab* tab = wxGetApp().get_tab(t);
-            if (tab)
-                tab->load_current_preset();
+            wxGetApp().get_tab(t)->load_current_preset();
         }
     }
 
@@ -2251,14 +2249,16 @@ void Tab::load_current_preset()
             PrinterTechnology& printer_technology = m_presets->get_edited_preset().printer_technology();
             if (printer_technology != static_cast<TabPrinter*>(this)->m_printer_technology)
             {
-                for (auto& tab : wxGetApp().mainframe->get_preset_tabs()) {
-                    if (tab.technology != printer_technology)
-                    {
-                        int page_id = wxGetApp().tab_panel()->FindPage(tab.panel);
+                for (auto tab : wxGetApp().tabs_list) {
+                    if (tab->type() == Preset::TYPE_PRINTER) // Printer tab is shown every time
+                        continue;
+                    if (tab->supports_printer_technology(printer_technology))
+                        wxGetApp().tab_panel()->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title());
+                    else {
+                        int page_id = wxGetApp().tab_panel()->FindPage(tab);
                         wxGetApp().tab_panel()->GetPage(page_id)->Show(false);
                         wxGetApp().tab_panel()->RemovePage(page_id);
-                    } else
-                        wxGetApp().tab_panel()->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab.panel, tab.panel->title());
+                    } 
                 }
                 static_cast<TabPrinter*>(this)->m_printer_technology = printer_technology;
             }

From d658d918d764899b01b9bbb3a4fc11c771185e66 Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Mon, 19 Nov 2018 14:01:14 +0100
Subject: [PATCH 6/6] Fixed crashing when project with modifier is imported

---
 src/slic3r/GUI/GUI_ObjectList.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp
index 25aaf16f2..0d70a7ae5 100644
--- a/src/slic3r/GUI/GUI_ObjectList.cpp
+++ b/src/slic3r/GUI/GUI_ObjectList.cpp
@@ -1123,7 +1123,8 @@ void ObjectList::add_object_to_list(size_t obj_idx)
             m_objects_model->AddVolumeChild(item,
             model_object->volumes[id]->name,
             ModelVolume::MODEL_PART,
-            model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value,
+            !model_object->volumes[id]->config.has("extruder") ? 0 :
+                model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value,
             false);
         Expand(item);
     }