Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2020-01-17 13:38:52 +0300
committerYuSanka <yusanka@gmail.com>2020-01-17 14:24:58 +0300
commit2259f7b3e8648b408e51d501ebe424a72f13c283 (patch)
tree4129ebebaa9e12863a63d2db5b3291a0f3b40920 /src
parentcc19e9c48f36da2484fea8cebb1074fad342f7fa (diff)
Code refactoring to mode comparison
Diffstat (limited to 'src')
-rw-r--r--src/libslic3r/GCode.cpp2
-rw-r--r--src/libslic3r/GCode/ToolOrdering.cpp2
-rw-r--r--src/libslic3r/GCodeWriter.hpp2
-rw-r--r--src/libslic3r/Model.cpp2
-rw-r--r--src/libslic3r/Model.hpp5
-rw-r--r--src/libslic3r/Print.cpp10
-rw-r--r--src/slic3r/GUI/GLCanvas3D.cpp8
-rw-r--r--src/slic3r/GUI/GUI_Preview.cpp17
-rw-r--r--src/slic3r/GUI/wxExtensions.cpp127
-rw-r--r--src/slic3r/GUI/wxExtensions.hpp44
10 files changed, 126 insertions, 93 deletions
diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp
index 7627f581d..bd22c29e5 100644
--- a/src/libslic3r/GCode.cpp
+++ b/src/libslic3r/GCode.cpp
@@ -1738,7 +1738,7 @@ namespace ProcessLayer
if (custom_gcode != nullptr) {
// Extruder switches are processed by LayerTools, they should be filtered out.
- assert(custom_gcode->gcode != ExtruderChangeCode);
+ assert(custom_gcode->gcode != ToolChangeCode);
const std::string &custom_code = custom_gcode->gcode;
std::string pause_print_msg;
diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp
index fe8c93c9a..3e01e2594 100644
--- a/src/libslic3r/GCode/ToolOrdering.cpp
+++ b/src/libslic3r/GCode/ToolOrdering.cpp
@@ -478,7 +478,7 @@ void ToolOrdering::assign_custom_gcodes(const Print &print)
for (unsigned int i : lt.extruders)
extruder_printing_above[i] = true;
// Skip all custom G-codes above this layer and skip all extruder switches.
- for (; custom_gcode_it != custom_gcode_per_print_z.gcodes.rend() && (custom_gcode_it->print_z > lt.print_z + EPSILON || custom_gcode_it->gcode == ExtruderChangeCode); ++ custom_gcode_it);
+ for (; custom_gcode_it != custom_gcode_per_print_z.gcodes.rend() && (custom_gcode_it->print_z > lt.print_z + EPSILON || custom_gcode_it->gcode == ToolChangeCode); ++ custom_gcode_it);
if (custom_gcode_it == custom_gcode_per_print_z.gcodes.rend())
// Custom G-codes were processed.
break;
diff --git a/src/libslic3r/GCodeWriter.hpp b/src/libslic3r/GCodeWriter.hpp
index 667c1ef95..abeaf0024 100644
--- a/src/libslic3r/GCodeWriter.hpp
+++ b/src/libslic3r/GCodeWriter.hpp
@@ -13,7 +13,7 @@ namespace Slic3r {
// Additional Codes which can be set by user using DoubleSlider
static constexpr char ColorChangeCode[] = "M600";
static constexpr char PausePrintCode[] = "M601";
-static constexpr char ExtruderChangeCode[] = "tool_change";
+static constexpr char ToolChangeCode[] = "tool_change";
class GCodeWriter {
public:
diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp
index ead2c95ca..8699eed7f 100644
--- a/src/libslic3r/Model.cpp
+++ b/src/libslic3r/Model.cpp
@@ -1847,7 +1847,7 @@ std::vector<std::pair<double, unsigned int>> custom_tool_changes(const Model &mo
{
std::vector<std::pair<double, unsigned int>> custom_tool_changes;
for (const Model::CustomGCode &custom_gcode : model.custom_gcode_per_print_z.gcodes)
- if (custom_gcode.gcode == ExtruderChangeCode) {
+ if (custom_gcode.gcode == ToolChangeCode) {
// If extruder count in PrinterSettings was changed, use default (0) extruder for extruders, more than num_extruders
custom_tool_changes.emplace_back(custom_gcode.print_z, static_cast<unsigned int>(custom_gcode.extruder > num_extruders ? 1 : custom_gcode.extruder));
}
diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp
index 4c1a914c3..d7c813113 100644
--- a/src/libslic3r/Model.hpp
+++ b/src/libslic3r/Model.hpp
@@ -763,8 +763,9 @@ public:
double print_z;
std::string gcode;
- int extruder; // 0 - "gcode" will be applied for whole print
- // else - "gcode" will be applied only for "extruder" print
+ int extruder; // Informative value for ColorChangeCode and ToolChangeCode
+ // "gcode" == ColorChangeCode => M600 will be applied for "extruder" extruder
+ // "gcode" == ToolChangeCode => for whole print tool will be switched to "extruder" extruder
std::string color; // if gcode is equal to PausePrintCode,
// this field is used for save a short message shown on Printer display
};
diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp
index 08e43564f..1cb16b4de 100644
--- a/src/libslic3r/Print.cpp
+++ b/src/libslic3r/Print.cpp
@@ -493,18 +493,18 @@ static bool layer_height_ranges_equal(const t_layer_config_ranges &lr1, const t_
return true;
}
-// Returns true if va == vb when all CustomGCode items that are not ExtruderChangeCode are ignored.
+// Returns true if va == vb when all CustomGCode items that are not ToolChangeCode are ignored.
static bool custom_per_printz_gcodes_tool_changes_differ(const std::vector<Model::CustomGCode> &va, const std::vector<Model::CustomGCode> &vb)
{
auto it_a = va.begin();
auto it_b = vb.begin();
while (it_a != va.end() && it_b != vb.end()) {
- if (it_a != va.end() && it_a->gcode != ExtruderChangeCode) {
+ if (it_a != va.end() && it_a->gcode != ToolChangeCode) {
// Skip any CustomGCode items, which are not tool changes.
++ it_a;
continue;
}
- if (it_b != vb.end() && it_b->gcode != ExtruderChangeCode) {
+ if (it_b != vb.end() && it_b->gcode != ToolChangeCode) {
// Skip any CustomGCode items, which are not tool changes.
++ it_b;
continue;
@@ -512,8 +512,8 @@ static bool custom_per_printz_gcodes_tool_changes_differ(const std::vector<Model
if (it_a == va.end() || it_b == vb.end())
// va or vb contains more Tool Changes than the other.
return true;
- assert(it_a->gcode == ExtruderChangeCode);
- assert(it_b->gcode == ExtruderChangeCode);
+ assert(it_a->gcode == ToolChangeCode);
+ assert(it_b->gcode == ToolChangeCode);
if (*it_a != *it_b)
// The two Tool Changes differ.
return true;
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index bb24d5f12..ce4908c38 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -5263,11 +5263,11 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
const std::string& code = it->gcode;
// pause print or custom Gcode
if (code == PausePrintCode ||
- (code != ColorChangeCode && code != ExtruderChangeCode))
+ (code != ColorChangeCode && code != ToolChangeCode))
return number_tools()-1; // last color item is a gray color for pause print or custom G-code
// change tool (extruder)
- if (code == ExtruderChangeCode)
+ if (code == ToolChangeCode)
return get_color_idx_for_tool_change(it, extruder);
// change color for current extruder
if (code == ColorChangeCode) {
@@ -5289,7 +5289,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
return color_idx;
}
// change tool (extruder)
- if (it->gcode == ExtruderChangeCode)
+ if (it->gcode == ToolChangeCode)
return get_color_idx_for_tool_change(it, extruder);
}
@@ -5333,7 +5333,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
bool is_tool_change = false;
while (it_n != color_print_values->begin()) {
--it_n;
- if (it_n->gcode == ExtruderChangeCode) {
+ if (it_n->gcode == ToolChangeCode) {
is_tool_change = true;
if (it_n->extruder == it->extruder || (it_n->extruder == 0 && it->extruder == extruder))
return get_m600_color_idx(it);
diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp
index dda875ced..f7010a503 100644
--- a/src/slic3r/GUI/GUI_Preview.cpp
+++ b/src/slic3r/GUI/GUI_Preview.cpp
@@ -597,7 +597,7 @@ void Preview::create_double_slider()
Bind(wxCUSTOMEVT_TICKSCHANGED, [this](wxEvent&) {
Model& model = wxGetApp().plater()->model();
- model.custom_gcode_per_print_z.gcodes = m_slider->GetTicksValues();
+ model.custom_gcode_per_print_z = m_slider->GetTicksValues();
m_schedule_background_process();
update_view_type(false);
@@ -666,8 +666,11 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee
bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min();
bool snap_to_max = force_sliders_full_range || m_slider->is_higher_at_max();
- std::vector<Model::CustomGCode> &ticks_from_model = wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes;
- check_slider_values(ticks_from_model, layers_z);
+ // Detect and set manipulation mode for double slider
+ update_double_slider_mode();
+
+ Model::CustomGCodeInfo &ticks_info_from_model = wxGetApp().plater()->model().custom_gcode_per_print_z;
+ check_slider_values(ticks_info_from_model.gcodes, layers_z);
m_slider->SetSliderValues(layers_z);
assert(m_slider->GetMinValue() == 0);
@@ -689,13 +692,9 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee
}
m_slider->SetSelectionSpan(idx_low, idx_high);
- m_slider->SetTicksValues(ticks_from_model);
+ m_slider->SetTicksValues(ticks_info_from_model);
- bool color_print_enable = (wxGetApp().plater()->printer_technology() == ptFFF);
-
- m_slider->EnableTickManipulation(color_print_enable);
- // Detect and set manipulation mode for double slider
- update_double_slider_mode();
+ m_slider->EnableTickManipulation(wxGetApp().plater()->printer_technology() == ptFFF);
}
void Preview::update_double_slider_mode()
diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp
index f2fed3bf7..7689e31cb 100644
--- a/src/slic3r/GUI/wxExtensions.cpp
+++ b/src/slic3r/GUI/wxExtensions.cpp
@@ -2532,9 +2532,10 @@ double DoubleSlider::get_double_value(const SelectedSlider& selection)
}
using t_custom_code = Slic3r::Model::CustomGCode;
-std::vector<t_custom_code> DoubleSlider::GetTicksValues() const
+Slic3r::Model::CustomGCodeInfo DoubleSlider::GetTicksValues() const
{
- std::vector<t_custom_code> values;
+ Slic3r::Model::CustomGCodeInfo custom_gcode_per_print_z;
+ std::vector<t_custom_code>& values = custom_gcode_per_print_z.gcodes;
const int val_size = m_values.size();
if (!m_values.empty())
@@ -2544,17 +2545,23 @@ std::vector<t_custom_code> DoubleSlider::GetTicksValues() const
values.emplace_back(t_custom_code{m_values[tick.tick], tick.gcode, tick.extruder, tick.color});
}
- return values;
+ custom_gcode_per_print_z.mode = m_mode;
+
+ return custom_gcode_per_print_z;
}
-void DoubleSlider::SetTicksValues(const std::vector<t_custom_code>& heights)
+void DoubleSlider::SetTicksValues(const Slic3r::Model::CustomGCodeInfo& custom_gcode_per_print_z)
{
if (m_values.empty())
+ {
+ m_ticks_mode = m_mode;
return;
+ }
const bool was_empty = m_ticks.empty();
m_ticks.clear();
+ const std::vector<t_custom_code>& heights = custom_gcode_per_print_z.gcodes;
for (auto h : heights) {
auto it = std::lower_bound(m_values.begin(), m_values.end(), h.print_z - epsilon());
@@ -2566,7 +2573,9 @@ void DoubleSlider::SetTicksValues(const std::vector<t_custom_code>& heights)
if (!was_empty && m_ticks.empty())
// Switch to the "Feature type"/"Tool" from the very beginning of a new object slicing after deleting of the old one
- wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
+ post_ticks_changed_event();
+
+ m_ticks_mode = custom_gcode_per_print_z.mode;
Refresh();
Update();
@@ -2793,7 +2802,7 @@ void DoubleSlider::draw_ticks(wxDC& dc)
dc.DrawLine(mid + 14, pos/* - 1*/, mid + 9, pos/* - 1*/);
// Draw icon for "Pause print" or "Custom Gcode"
- if (tick.gcode != Slic3r::ColorChangeCode && tick.gcode != Slic3r::ExtruderChangeCode)
+ if (tick.gcode != Slic3r::ColorChangeCode && tick.gcode != Slic3r::ToolChangeCode)
{
wxBitmap icon = create_scaled_bitmap(this, tick.gcode == Slic3r::PausePrintCode ? "pause_print" : "edit_gcode");
@@ -2827,7 +2836,7 @@ std::string DoubleSlider::get_color_for_color_change_tick(std::set<TICK_CODE>::c
bool is_tool_change = false;
while (it_n != m_ticks.begin()) {
--it_n;
- if (it_n->gcode == Slic3r::ExtruderChangeCode) {
+ if (it_n->gcode == Slic3r::ToolChangeCode) {
is_tool_change = true;
if (it_n->extruder == it->extruder)
return it->color;
@@ -2863,28 +2872,28 @@ void DoubleSlider::draw_colored_band(wxDC& dc)
};
// don't color a band for MultiExtruder mode
- if (m_ticks.empty() || m_mode == mmMultiExtruder)
+ if (m_ticks.empty() || m_mode == t_mode::MultiExtruder)
{
draw_band(dc, GetParent()->GetBackgroundColour(), main_band);
return;
}
- const int default_color_idx = m_mode==mmMultiAsSingle ? std::max<int>(m_only_extruder - 1, 0) : 0;
+ const int default_color_idx = m_mode==t_mode::MultiAsSingle ? std::max<int>(m_only_extruder - 1, 0) : 0;
draw_band(dc, wxColour(Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config()[default_color_idx]), main_band);
std::set<TICK_CODE>::const_iterator tick_it = m_ticks.begin();
while (tick_it != m_ticks.end())
{
- if ( (m_mode == mmSingleExtruder && tick_it->gcode == Slic3r::ColorChangeCode ) ||
- (m_mode == mmMultiAsSingle && (tick_it->gcode == Slic3r::ExtruderChangeCode || tick_it->gcode == Slic3r::ColorChangeCode)) )
+ if ( (m_mode == t_mode::SingleExtruder && tick_it->gcode == Slic3r::ColorChangeCode ) ||
+ (m_mode == t_mode::MultiAsSingle && (tick_it->gcode == Slic3r::ToolChangeCode || tick_it->gcode == Slic3r::ColorChangeCode)) )
{
const wxCoord pos = get_position_from_value(tick_it->tick);
is_horizontal() ? main_band.SetLeft(SLIDER_MARGIN + pos) :
main_band.SetBottom(pos - 1);
- const std::string clr_str = m_mode == mmSingleExtruder ? tick_it->color :
- tick_it->gcode == Slic3r::ExtruderChangeCode ?
+ const std::string clr_str = m_mode == t_mode::SingleExtruder ? tick_it->color :
+ tick_it->gcode == Slic3r::ToolChangeCode ?
get_color_for_tool_change_tick(tick_it) :
get_color_for_color_change_tick(tick_it);
@@ -2934,7 +2943,7 @@ void DoubleSlider::draw_revert_icon(wxDC& dc)
void DoubleSlider::draw_cog_icon(wxDC& dc)
{
- if (m_mode != mmMultiExtruder)
+ if (m_mode != t_mode::MultiExtruder)
return;
int width, height;
@@ -3046,9 +3055,9 @@ void DoubleSlider::OnLeftDown(wxMouseEvent& event)
if (!m_selection) m_selection = ssHigher;
m_ticks.clear();
- wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
+ post_ticks_changed_event();
}
- else if (is_point_in_rect(pos, m_rect_cog_icon) && m_mode == mmMultiExtruder) {
+ else if (is_point_in_rect(pos, m_rect_cog_icon) && m_mode == t_mode::MultiExtruder) {
// show dialog for set extruder sequence
m_edit_extruder_sequence = true;
}
@@ -3119,17 +3128,17 @@ wxString DoubleSlider::get_tooltip(IconFocus icon_focus)
{
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
const auto tick_code_it = m_ticks.find(TICK_CODE{tick});
- tooltip = tick_code_it == m_ticks.end() ? (m_mode == mmMultiAsSingle ?
+ tooltip = tick_code_it == m_ticks.end() ? (m_mode == t_mode::MultiAsSingle ?
_(L("For add change extruder use left mouse button click")) :
_(L("For add color change use left mouse button click")) ) + "\n" +
_(L("For add another code use right mouse button click")) :
- tick_code_it->gcode == Slic3r::ColorChangeCode ? ( m_mode == mmSingleExtruder ?
+ tick_code_it->gcode == Slic3r::ColorChangeCode ? ( m_mode == t_mode::SingleExtruder ?
_(L("For Delete color change use left mouse button click\n"
"For Edit color use right mouse button click")) :
from_u8((boost::format(_utf8(L("Delete color change for Extruder %1%"))) % tick_code_it->extruder).str()) ):
tick_code_it->gcode == Slic3r::PausePrintCode ?
_(L("Delete pause")) :
- tick_code_it->gcode == Slic3r::ExtruderChangeCode ?
+ tick_code_it->gcode == Slic3r::ToolChangeCode ?
from_u8((boost::format(_utf8(L("Delete extruder change to \"%1%\""))) % tick_code_it->extruder).str()) :
from_u8((boost::format(_utf8(L("For Delete \"%1%\" code use left mouse button click\n"
"For Edit \"%1%\" code use right mouse button click"))) % tick_code_it->gcode ).str());
@@ -3200,7 +3209,7 @@ void DoubleSlider::append_change_extruder_menu_item(wxMenu* menu)
const wxString item_name = wxString::Format(_(L("Extruder %d")), i) +
(is_active_extruder ? " (" + _(L("active")) + ")" : "");
- if (m_mode == mmMultiAsSingle)
+ if (m_mode == t_mode::MultiAsSingle)
append_menu_item(change_extruder_menu, wxID_ANY, item_name, "",
[this, i](wxCommandEvent&) { change_extruder(i); }, "", menu,
[is_active_extruder]() { return !is_active_extruder; }, Slic3r::GUI::wxGetApp().plater());
@@ -3208,13 +3217,13 @@ void DoubleSlider::append_change_extruder_menu_item(wxMenu* menu)
// [this, i](wxCommandEvent&) { change_extruder(i); }, menu)->Check(i == initial_extruder);
}
- const wxString change_extruder_menu_name = m_mode == mmMultiAsSingle ? _(L("Change extruder")) : _(L("Change extruder (N/A)"));
+ const wxString change_extruder_menu_name = m_mode == t_mode::MultiAsSingle ? _(L("Change extruder")) : _(L("Change extruder (N/A)"));
wxMenuItem* change_extruder_menu_item = menu->AppendSubMenu(change_extruder_menu, change_extruder_menu_name, _(L("Use another extruder")));
change_extruder_menu_item->SetBitmap(create_scaled_bitmap(this, "change_extruder"));
Slic3r::GUI::wxGetApp().plater()->Bind(wxEVT_UPDATE_UI, [this, change_extruder_menu_item](wxUpdateUIEvent& evt) {
- enable_menu_item(evt, [this]() {return m_mode == mmMultiAsSingle; }, change_extruder_menu_item, this); },
+ enable_menu_item(evt, [this]() {return m_mode == t_mode::MultiAsSingle; }, change_extruder_menu_item, this); },
change_extruder_menu_item->GetId());
}
}
@@ -3255,13 +3264,13 @@ void DoubleSlider::OnLeftUp(wxMouseEvent& event)
if (m_show_context_menu)
{
- if (m_mode == mmSingleExtruder)
+ if (m_mode == t_mode::SingleExtruder)
add_code(Slic3r::ColorChangeCode);
else
{
wxMenu menu;
- if (m_mode == mmMultiAsSingle)
+ if (m_mode == t_mode::MultiAsSingle)
append_change_extruder_menu_item(&menu);
else
append_add_color_change_menu_item(&menu);
@@ -3335,7 +3344,7 @@ void DoubleSlider::action_tick(const TicksAction action)
return;
m_ticks.erase(TICK_CODE{tick});
- wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
+ post_ticks_changed_event(it->gcode);
Refresh();
Update();
return;
@@ -3350,7 +3359,7 @@ void DoubleSlider::action_tick(const TicksAction action)
if (m_suppress_add_code)
return;
m_suppress_add_code = true;
- if (m_mode == mmSingleExtruder) // if (m_mode != mmMultiExtruder)
+ if (m_mode == t_mode::SingleExtruder) // if (m_mode != t_mode::MultiExtruder)
add_code(Slic3r::ColorChangeCode);
m_suppress_add_code = false;
return;
@@ -3444,7 +3453,7 @@ void DoubleSlider::OnRightDown(wxMouseEvent& event)
m_show_context_menu = true;
return;
}
- if (it->gcode != Slic3r::ExtruderChangeCode)
+ if (it->gcode != Slic3r::ToolChangeCode)
{
// show "Edit" and "Delete" menu on OnRightUp()
m_show_edit_menu = true;
@@ -3471,14 +3480,14 @@ void DoubleSlider::OnRightDown(wxMouseEvent& event)
int DoubleSlider::get_extruder_for_tick(int tick)
{
- int default_initial_extruder = m_mode == mmMultiAsSingle ? m_only_extruder : 0;
+ int default_initial_extruder = m_mode == t_mode::MultiAsSingle ? m_only_extruder : 0;
if (m_ticks.empty())
return default_initial_extruder;
auto it = m_ticks.lower_bound(TICK_CODE{tick});
while (it != m_ticks.begin()) {
--it;
- if(it->gcode == Slic3r::ExtruderChangeCode)
+ if(it->gcode == Slic3r::ToolChangeCode)
return it->extruder;
}
@@ -3487,7 +3496,7 @@ int DoubleSlider::get_extruder_for_tick(int tick)
std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
{
- if (m_mode == mmMultiExtruder)
+ if (m_mode == t_mode::MultiExtruder)
{
// #ys_FIXME: get tool ordering from _correct_ place
const Slic3r::ToolOrdering& tool_ordering = Slic3r::GUI::wxGetApp().plater()->fff_print().get_tool_ordering();
@@ -3508,7 +3517,7 @@ std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
return used_extruders;
}
- const int default_initial_extruder = m_mode == mmMultiAsSingle ? std::max(m_only_extruder, 1) : 1;
+ const int default_initial_extruder = m_mode == t_mode::MultiAsSingle ? std::max(m_only_extruder, 1) : 1;
if (m_ticks.empty())
return {default_initial_extruder};
@@ -3516,7 +3525,7 @@ std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
auto it_start = m_ticks.lower_bound(TICK_CODE{tick});
auto it = it_start;
- if (it == m_ticks.begin() && it->gcode == Slic3r::ExtruderChangeCode) {
+ if (it == m_ticks.begin() && it->gcode == Slic3r::ToolChangeCode) {
used_extruders.emplace(it->extruder);
if (tick < it->tick)
used_extruders.emplace(default_initial_extruder);
@@ -3524,7 +3533,7 @@ std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
while (it != m_ticks.begin()) {
--it;
- if(it->gcode == Slic3r::ExtruderChangeCode)
+ if(it->gcode == Slic3r::ToolChangeCode)
{
used_extruders.emplace(it->extruder);
break;
@@ -3536,7 +3545,7 @@ std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
it = it_start;
while (it != m_ticks.end()) {
- if(it->gcode == Slic3r::ExtruderChangeCode)
+ if(it->gcode == Slic3r::ToolChangeCode)
used_extruders.emplace(it->extruder);
++it;
}
@@ -3554,7 +3563,7 @@ void DoubleSlider::OnRightUp(wxMouseEvent& event)
if (m_show_context_menu) {
wxMenu menu;
- if (m_mode == mmSingleExtruder)
+ if (m_mode == t_mode::SingleExtruder)
append_menu_item(&menu, wxID_ANY, _(L("Add color change")) + " (M600)", "",
[this](wxCommandEvent&) { add_code(Slic3r::ColorChangeCode); }, "colorchange_add_m", &menu,
[](){return true;}, this);
@@ -3703,7 +3712,7 @@ void DoubleSlider::add_code(std::string code, int selected_extruder/* = -1*/)
m_ticks.emplace(TICK_CODE{tick, code, extruder, color});
- wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
+ post_ticks_changed_event(code);
Refresh();
Update();
}
@@ -3741,7 +3750,7 @@ void DoubleSlider::edit_tick()
m_ticks.erase(it);
m_ticks.emplace(changed_tick);
- wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
+ post_ticks_changed_event(changed_tick.gcode);
}
}
@@ -3754,9 +3763,9 @@ void DoubleSlider::change_extruder(int extruder)
// if on this Y doesn't exist tick
if (m_ticks.find(TICK_CODE{tick}) == m_ticks.end())
{
- m_ticks.emplace(TICK_CODE{tick, Slic3r::ExtruderChangeCode, extruder, extruder == 0 ? "" : colors[extruder-1]});
+ m_ticks.emplace(TICK_CODE{tick, Slic3r::ToolChangeCode, extruder, extruder == 0 ? "" : colors[extruder-1]});
- wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
+ post_ticks_changed_event(Slic3r::ToolChangeCode);
Refresh();
Update();
}
@@ -3776,7 +3785,7 @@ void DoubleSlider::edit_extruder_sequence()
auto it = m_ticks.begin();
while (it != m_ticks.end()) {
- if (it->gcode == Slic3r::ExtruderChangeCode)
+ if (it->gcode == Slic3r::ToolChangeCode)
it = m_ticks.erase(it);
else
++it;
@@ -3792,7 +3801,7 @@ void DoubleSlider::edit_extruder_sequence()
while (tick <= m_max_value)
{
int cur_extruder = m_extruders_sequence.extruders[extruder];
- m_ticks.emplace(TICK_CODE{tick, Slic3r::ExtruderChangeCode, cur_extruder + 1, colors[cur_extruder]});
+ m_ticks.emplace(TICK_CODE{tick, Slic3r::ToolChangeCode, cur_extruder + 1, colors[cur_extruder]});
extruder++;
if (extruder == extr_cnt)
@@ -3811,6 +3820,42 @@ void DoubleSlider::edit_extruder_sequence()
tick += m_extruders_sequence.interval_by_layers;
}
+ post_ticks_changed_event(Slic3r::ToolChangeCode);
+}
+
+void DoubleSlider::post_ticks_changed_event(const std::string& gcode /*= ""*/)
+{
+ if ( m_ticks_mode == m_mode ||
+ (gcode != Slic3r::ColorChangeCode && gcode != Slic3r::ToolChangeCode) )
+ {
+ wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
+ return;
+ }
+
+ if (m_ticks_mode == t_mode::SingleExtruder && m_mode == t_mode::MultiAsSingle)
+ {
+ }
+
+ if (m_ticks_mode == t_mode::SingleExtruder && m_mode == t_mode::MultiExtruder)
+ {
+ }
+
+ if (m_ticks_mode == t_mode::MultiAsSingle && m_mode == t_mode::SingleExtruder)
+ {
+ }
+
+ if (m_ticks_mode == t_mode::MultiAsSingle && m_mode == t_mode::MultiExtruder)
+ {
+ }
+
+ if (m_ticks_mode == t_mode::MultiExtruder && m_mode == t_mode::SingleExtruder)
+ {
+ }
+
+ if (m_ticks_mode == t_mode::MultiExtruder && m_mode == t_mode::MultiAsSingle)
+ {
+ }
+
wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
}
diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp
index 81f4d7342..5b9f6db0b 100644
--- a/src/slic3r/GUI/wxExtensions.hpp
+++ b/src/slic3r/GUI/wxExtensions.hpp
@@ -782,6 +782,8 @@ public:
const wxString& name = wxEmptyString);
~DoubleSlider() {}
+ using t_mode = Slic3r::Model::CustomGCodeInfo::MODE;
+
/* For exporting GCode in GCodeWriter is used XYZF_NUM(val) = PRECISION(val, 3) for XYZ values.
* So, let use same value as a permissible error for layer height.
*/
@@ -805,37 +807,22 @@ public:
// Set low and high slider position. If the span is non-empty, disable the "one layer" mode.
void SetSelectionSpan(const int lower_val, const int higher_val);
void SetMaxValue(const int max_value);
- void SetKoefForLabels(const double koef) {
- m_label_koef = koef;
- }
- void SetSliderValues(const std::vector<double>& values) {
- m_values = values;
- }
+ void SetKoefForLabels(const double koef) { m_label_koef = koef; }
+ void SetSliderValues(const std::vector<double>& values) { m_values = values; }
void ChangeOneLayerLock();
- std::vector<Slic3r::Model::CustomGCode> GetTicksValues() const;
- void SetTicksValues(const std::vector<Slic3r::Model::CustomGCode> &heights);
- void EnableTickManipulation(bool enable = true) {
- m_is_enabled_tick_manipulation = enable;
- }
- void DisableTickManipulation() {
- EnableTickManipulation(false);
- }
+ Slic3r::Model::CustomGCodeInfo GetTicksValues() const;
+ void SetTicksValues(const Slic3r::Model::CustomGCodeInfo &custom_gcode_per_print_z);
+ void EnableTickManipulation(bool enable = true) { m_is_enabled_tick_manipulation = enable; }
+ void DisableTickManipulation() { EnableTickManipulation(false); }
- enum ManipulationMode {
- mmSingleExtruder, // single extruder printer preset is selected
- mmMultiAsSingle, // multiple extruder printer preset is selected, but
- // this mode works just for Single extruder print
- // (For all print from objects settings is used just one extruder)
- mmMultiExtruder // multiple extruder printer preset is selected
- };
- void SetManipulationMode(ManipulationMode mode) { m_mode = mode; }
- ManipulationMode GetManipulationMode() const { return m_mode; }
+ void SetManipulationMode(t_mode mode) { m_mode = mode; }
+ t_mode GetManipulationMode() const { return m_mode; }
void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder)
{
- m_mode = !is_one_extruder_printed_model ? mmMultiExtruder :
- only_extruder < 0 ? mmSingleExtruder :
- mmMultiAsSingle;
+ m_mode = !is_one_extruder_printed_model ? t_mode::MultiExtruder :
+ only_extruder < 0 ? t_mode::SingleExtruder :
+ t_mode::MultiAsSingle;
m_only_extruder = only_extruder;
}
@@ -918,7 +905,7 @@ private:
int get_extruder_for_tick(int tick);
std::set<int> get_used_extruders_for_tick(int tick);
-
+ void post_ticks_changed_event(const std::string& gcode = "");
void append_change_extruder_menu_item(wxMenu*);
void append_add_color_change_menu_item(wxMenu*);
@@ -952,7 +939,7 @@ private:
bool m_show_edit_menu = false;
bool m_edit_extruder_sequence = false;
bool m_suppress_add_code = false;
- ManipulationMode m_mode = mmSingleExtruder;
+ t_mode m_mode = t_mode::SingleExtruder;
std::string m_custom_gcode = "";
std::string m_pause_print_msg;
int m_only_extruder = -1;
@@ -986,6 +973,7 @@ private:
std::vector<wxPen*> m_segm_pens;
std::vector<double> m_values;
std::set<TICK_CODE> m_ticks;
+ t_mode m_ticks_mode;
public:
struct ExtrudersSequence