Implemented a message on Printer display for pause print

+ Added new icons
This commit is contained in:
YuSanka 2019-11-27 14:44:33 +01:00
parent 963969e210
commit 496e09302f
7 changed files with 107 additions and 16 deletions

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="edit_x5F_Gcode">
<g>
<path fill="#808080" d="M8,1.85l5.29,3.53V7v3.62L8,14.15l-5.29-3.53V7V5.38L8,1.85 M8,1L2,5v2v4l6,4l6-4V7V5L8,1L8,1z"/>
</g>
<g>
<path fill="#ED6B21" d="M7.97,7.47h2.65v2.05c0,1.73-0.82,2.48-2.69,2.48S5.3,11.25,5.3,9.55V6.39c0-1.61,0.73-2.36,2.63-2.36
s2.69,0.67,2.69,2.36H9.21c0-0.74-0.18-1.11-1.28-1.11c-1.02,0-1.22,0.46-1.22,1.18v3.09c0,0.75,0.19,1.18,1.22,1.18
c1.02,0,1.38-0.43,1.38-1.21V8.75H7.97V7.47z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 808 B

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="edit_x5F_uni">
<path fill="#808080" d="M8,1.85l5.29,3.53V7v3.62L8,14.15l-5.29-3.53V7V5.38L8,1.85 M8,1L2,5v2v4l6,4l6-4V7V5L8,1L8,1z"/>
<path fill="#ED6B21" d="M11.87,7.36l-0.43-0.22c-0.07-0.04-0.16-0.13-0.18-0.21l-0.2-0.48c-0.04-0.07-0.04-0.2-0.02-0.28l0.15-0.46
c0.03-0.08,0-0.19-0.06-0.25l-0.6-0.6c-0.06-0.06-0.17-0.08-0.25-0.06L9.83,4.97c-0.08,0.03-0.2,0.02-0.28-0.02l-0.48-0.2
C8.99,4.72,8.89,4.64,8.85,4.57L8.64,4.13C8.6,4.06,8.5,4,8.42,4H7.58C7.5,4,7.4,4.06,7.36,4.13L7.15,4.57
C7.11,4.64,7.01,4.72,6.94,4.75l-0.48,0.2c-0.07,0.04-0.2,0.04-0.28,0.02L5.72,4.81c-0.08-0.03-0.19,0-0.25,0.06l-0.6,0.6
C4.82,5.53,4.79,5.64,4.81,5.72l0.15,0.46c0.03,0.08,0.02,0.2-0.02,0.28l-0.2,0.48C4.72,7.01,4.64,7.11,4.57,7.15L4.13,7.36
C4.06,7.4,4,7.5,4,7.58v0.84C4,8.5,4.06,8.6,4.13,8.64l0.43,0.22c0.07,0.04,0.16,0.13,0.18,0.21l0.2,0.48
c0.04,0.07,0.04,0.2,0.02,0.28l-0.15,0.46c-0.03,0.08,0,0.19,0.06,0.25l0.6,0.6c0.06,0.06,0.17,0.08,0.25,0.06l0.46-0.15
c0.08-0.03,0.2-0.02,0.28,0.02l0.48,0.2c0.08,0.03,0.17,0.11,0.21,0.18l0.22,0.43C7.4,11.94,7.5,12,7.58,12h0.84
c0.08,0,0.18-0.06,0.22-0.13l0.22-0.43c0.04-0.07,0.13-0.16,0.21-0.18l0.48-0.2c0.07-0.04,0.2-0.04,0.28-0.02l0.46,0.15
c0.08,0.03,0.19,0,0.25-0.06l0.6-0.6c0.06-0.06,0.08-0.17,0.06-0.25l-0.15-0.46c-0.03-0.08-0.02-0.2,0.02-0.28l0.2-0.48
c0.03-0.08,0.11-0.17,0.18-0.21l0.43-0.22C11.94,8.6,12,8.5,12,8.42V7.58C12,7.5,11.94,7.4,11.87,7.36z M8,10.29
c-1.26,0-2.29-1.03-2.29-2.29c0-1.26,1.03-2.29,2.29-2.29S10.29,6.74,10.29,8C10.29,9.26,9.26,10.29,8,10.29z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="pause_x5F_print">
<g>
<path fill="#808080" d="M8,1.85l5.29,3.53V7v3.62L8,14.15l-5.29-3.53V7V5.38L8,1.85 M8,1L2,5v2v4l6,4l6-4V7V5L8,1L8,1z"/>
</g>
<g>
<path fill="#ED6B21" d="M6,11.71c-0.39,0-0.71-0.32-0.71-0.71V5c0-0.39,0.32-0.71,0.71-0.71S6.71,4.61,6.71,5v6
C6.71,11.39,6.39,11.71,6,11.71z"/>
</g>
<g>
<path fill="#ED6B21" d="M10,11.71c-0.39,0-0.71-0.32-0.71-0.71V5c0-0.39,0.32-0.71,0.71-0.71S10.71,4.61,10.71,5v6
C10.71,11.39,10.39,11.71,10,11.71z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 833 B

View File

@ -1868,11 +1868,16 @@ void GCode::process_layer(
// colorprint_change = true; // colorprint_change = true;
// } // }
std::string custom_code = ""; std::string custom_code = "";
std::string pause_print_msg = "";
int m600_before_extruder = -1; int m600_before_extruder = -1;
while (!m_custom_g_code_heights.empty() && m_custom_g_code_heights.front().height-EPSILON < layer.print_z) { while (!m_custom_g_code_heights.empty() && m_custom_g_code_heights.front().height-EPSILON < layer.print_z) {
custom_code = m_custom_g_code_heights.front().gcode; custom_code = m_custom_g_code_heights.front().gcode;
if (custom_code == ColorChangeCode && m_custom_g_code_heights.front().extruder > 0) if (custom_code == ColorChangeCode && m_custom_g_code_heights.front().extruder > 0)
m600_before_extruder = m_custom_g_code_heights.front().extruder - 1; m600_before_extruder = m_custom_g_code_heights.front().extruder - 1;
if (custom_code == PausePrintCode)
pause_print_msg = m_custom_g_code_heights.front().color;
m_custom_g_code_heights.erase(m_custom_g_code_heights.begin()); m_custom_g_code_heights.erase(m_custom_g_code_heights.begin());
colorprint_change = true; colorprint_change = true;
} }
@ -1903,6 +1908,7 @@ void GCode::process_layer(
if (!single_material_print && m600_before_extruder >= 0 && first_extruder_id != m600_before_extruder if (!single_material_print && m600_before_extruder >= 0 && first_extruder_id != m600_before_extruder
// && !MMU1 // && !MMU1
) { ) {
//! FIXME_in_fw show message during print pause
gcode += "M601\n"; // pause print gcode += "M601\n"; // pause print
gcode += "M117 Change filament for Extruder " + std::to_string(m600_before_extruder) + "\n"; gcode += "M117 Change filament for Extruder " + std::to_string(m600_before_extruder) + "\n";
} }
@ -1915,6 +1921,9 @@ void GCode::process_layer(
{ {
// add tag for analyzer // add tag for analyzer
gcode += "; " + GCodeAnalyzer::Pause_Print_Tag + "\n"; gcode += "; " + GCodeAnalyzer::Pause_Print_Tag + "\n";
//! FIXME_in_fw show message during print pause
if (!pause_print_msg.empty())
gcode += "M117 " + pause_print_msg + "\n";
// add tag for time estimator // add tag for time estimator
//gcode += "; " + GCodeTimeEstimator::Pause_Print_Tag + "\n"; //gcode += "; " + GCodeTimeEstimator::Pause_Print_Tag + "\n";
} }

View File

@ -772,7 +772,8 @@ public:
std::string gcode; std::string gcode;
int extruder; // 0 - "gcode" will be applied for whole print int extruder; // 0 - "gcode" will be applied for whole print
// else - "gcode" will be applied only for "extruder" print // else - "gcode" will be applied only for "extruder" print
std::string color; std::string color; // if gcode is equal to PausePrintCode,
// this field is used for save a short message shown on Printer display
}; };
std::vector<CustomGCode> custom_gcode_per_height; std::vector<CustomGCode> custom_gcode_per_height;

View File

@ -27,6 +27,7 @@
#include "../Utils/MacDarkMode.hpp" #include "../Utils/MacDarkMode.hpp"
using Slic3r::GUI::from_u8; using Slic3r::GUI::from_u8;
using Slic3r::GUI::into_u8;
wxDEFINE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent); wxDEFINE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent);
wxDEFINE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent); wxDEFINE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent);
@ -2321,6 +2322,7 @@ DoubleSlider::DoubleSlider( wxWindow *parent,
m_cog_icon_dim = int((float)m_bmp_cog.bmp().GetSize().x / scale_factor); m_cog_icon_dim = int((float)m_bmp_cog.bmp().GetSize().x / scale_factor);
m_selection = ssUndef; m_selection = ssUndef;
m_pause_print_msg = _utf8(L("Place bearings in slots and resume"));
// slider events // slider events
Bind(wxEVT_PAINT, &DoubleSlider::OnPaint, this); Bind(wxEVT_PAINT, &DoubleSlider::OnPaint, this);
@ -2795,7 +2797,7 @@ void DoubleSlider::draw_ticks(wxDC& dc)
// Draw icon for "Pause print" or "Custom Gcode" // 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::ExtruderChangeCode)
{ {
wxBitmap icon = create_scaled_bitmap(nullptr, tick.gcode == Slic3r::PausePrintCode ? "pause_add.png" : "add_gcode"); wxBitmap icon = create_scaled_bitmap(nullptr, tick.gcode == Slic3r::PausePrintCode ? "pause_print" : "edit_gcode");
wxCoord x_draw, y_draw; wxCoord x_draw, y_draw;
is_horizontal() ? x_draw = pos - 0.5 * m_tick_icon_dim : y_draw = pos - 0.5 * m_tick_icon_dim; is_horizontal() ? x_draw = pos - 0.5 * m_tick_icon_dim : y_draw = pos - 0.5 * m_tick_icon_dim;
@ -3084,19 +3086,17 @@ wxString DoubleSlider::get_tooltip(IconFocus icon_focus)
{ {
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value; const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
const auto tick_code_it = m_ticks_.find(tick); const auto tick_code_it = m_ticks_.find(tick);
tooltip = tick_code_it == m_ticks_.end() ? (m_state == msSingleExtruder ? //_(L("Add color change")) : tooltip = tick_code_it == m_ticks_.end() ? (m_state == msSingleExtruder ?
_(L("For add color change use left mouse button click")) : _(L("For add color change use left mouse button click")) :
_(L("For add change extruder use left mouse button click"))) + "\n" + _(L("For add change extruder use left mouse button click"))) + "\n" +
_(L("For add another code use right mouse button click")) : _(L("For add another code use right mouse button click")) :
// tick_code_it->gcode == Slic3r::ColorChangeCode ? _(L("Delete color change")) : tick_code_it->gcode == Slic3r::ColorChangeCode ? ( m_state == msSingleExtruder ?
tick_code_it->gcode == Slic3r::ColorChangeCode ? ( m_state == msSingleExtruder ? //_(L("Delete color change")) :
_(L("For Delete color change use left mouse button click\n" _(L("For Delete color change use left mouse button click\n"
"For Edit color use right mouse button click")) : "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()) ): 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::PausePrintCode ? _(L("Delete pause")) :
tick_code_it->gcode == Slic3r::ExtruderChangeCode ? //( m_state == msSingleExtruder ? _(L("Delete color change")) : tick_code_it->gcode == Slic3r::ExtruderChangeCode ?
from_u8((boost::format(_utf8(L("Delete extruder change to \"%1%\""))) % tick_code_it->extruder).str()) /*) */: from_u8((boost::format(_utf8(L("Delete extruder change to \"%1%\""))) % tick_code_it->extruder).str()) :
// from_u8((boost::format(_utf8(L("Delete \"%1%\" code"))) % tick_code_it->gcode).str());
from_u8((boost::format(_utf8(L("For Delete \"%1%\" code use left mouse button click\n" 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()); "For Edit \"%1%\" code use right mouse button click"))) % tick_code_it->gcode ).str());
} }
@ -3373,7 +3373,7 @@ void DoubleSlider::OnRightDown(wxMouseEvent& event)
m_show_context_menu = true; m_show_context_menu = true;
return; return;
} }
if (it->gcode != Slic3r::ExtruderChangeCode && it->gcode != Slic3r::PausePrintCode) if (it->gcode != Slic3r::ExtruderChangeCode)
{ {
// show "Edit" and "Delete" menu on OnRightUp() // show "Edit" and "Delete" menu on OnRightUp()
m_show_edit_menu = true; m_show_edit_menu = true;
@ -3459,10 +3459,10 @@ void DoubleSlider::OnRightUp(wxMouseEvent& event)
if (m_state != msMultiExtruder) if (m_state != msMultiExtruder)
append_menu_item(&menu, wxID_ANY, _(L("Add pause print")) + " (M601)", "", append_menu_item(&menu, wxID_ANY, _(L("Add pause print")) + " (M601)", "",
[this](wxCommandEvent&) { add_code(Slic3r::PausePrintCode); }, "pause_add.png", &menu); [this](wxCommandEvent&) { add_code(Slic3r::PausePrintCode); }, "pause_print", &menu);
append_menu_item(&menu, wxID_ANY, _(L("Add custom G-code")), "", append_menu_item(&menu, wxID_ANY, _(L("Add custom G-code")), "",
[this](wxCommandEvent&) { add_code(""); }, "add_gcode", &menu); [this](wxCommandEvent&) { add_code(""); }, "edit_gcode", &menu);
Slic3r::GUI::wxGetApp().plater()->PopupMenu(&menu); Slic3r::GUI::wxGetApp().plater()->PopupMenu(&menu);
@ -3474,10 +3474,14 @@ void DoubleSlider::OnRightUp(wxMouseEvent& event)
std::set<TICK_CODE>::iterator it = m_ticks_.find(m_selection == ssLower ? m_lower_value : m_higher_value); std::set<TICK_CODE>::iterator it = m_ticks_.find(m_selection == ssLower ? m_lower_value : m_higher_value);
const bool is_color_change = it->gcode == Slic3r::ColorChangeCode; const bool is_color_change = it->gcode == Slic3r::ColorChangeCode;
append_menu_item(&menu, wxID_ANY, is_color_change ? _(L("Edit color")) : _(L("Edit custom G-code")), "", append_menu_item(&menu, wxID_ANY, it->gcode == Slic3r::ColorChangeCode ? _(L("Edit color")) :
[this](wxCommandEvent&) { edit_tick(); }, "change_extruder", &menu); it->gcode == Slic3r::PausePrintCode ? _(L("Edit pause print message")) :
_(L("Edit custom G-code")), "",
[this](wxCommandEvent&) { edit_tick(); }, "edit_uni", &menu);
append_menu_item(&menu, wxID_ANY, it->gcode == Slic3r::ColorChangeCode ? _(L("Delete color change")) : _(L("Delete custom G-code")), "", append_menu_item(&menu, wxID_ANY, it->gcode == Slic3r::ColorChangeCode ? _(L("Delete color change")) :
it->gcode == Slic3r::PausePrintCode ? _(L("Delete pause print")) :
_(L("Delete custom G-code")), "",
[this](wxCommandEvent&) { action_tick(taDel); }, "colorchange_delete_off.png", &menu); [this](wxCommandEvent&) { action_tick(taDel); }, "colorchange_delete_off.png", &menu);
Slic3r::GUI::wxGetApp().plater()->PopupMenu(&menu); Slic3r::GUI::wxGetApp().plater()->PopupMenu(&menu);
@ -3521,6 +3525,20 @@ static std::string get_custom_code(const std::string& code_in, double height)
return dlg.GetValue().ToStdString(); return dlg.GetValue().ToStdString();
} }
static std::string get_pause_print_msg(const std::string& msg_in, double height)
{
wxString msg_text = from_u8(_utf8(L("Enter short message shown on Printer display during pause print"))) + " :";
wxString msg_header = from_u8((boost::format(_utf8(L("Message for pause print on current layer (%1% mm)."))) % height).str());
// get custom gcode
wxTextEntryDialog dlg(nullptr, msg_text, msg_header, from_u8(msg_in),
wxTextEntryDialogStyle);
if (dlg.ShowModal() != wxID_OK || dlg.GetValue().IsEmpty())
return "";
return into_u8(dlg.GetValue());
}
void DoubleSlider::add_code(std::string code, int selected_extruder/* = -1*/) void DoubleSlider::add_code(std::string code, int selected_extruder/* = -1*/)
{ {
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value; const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
@ -3553,6 +3571,13 @@ void DoubleSlider::add_code(std::string code, int selected_extruder/* = -1*/)
if (color.empty()) if (color.empty())
return; return;
} }
else if (code == Slic3r::PausePrintCode)
{
/* PausePrintCode doesn't need a color, so
* this field is used for save a short message shown on Printer display
* */
m_pause_print_msg = color = get_pause_print_msg(m_pause_print_msg, m_values[tick]);
}
else if (code.empty()) else if (code.empty())
{ {
m_custom_gcode = code = get_custom_code(m_custom_gcode, m_values[tick]); m_custom_gcode = code = get_custom_code(m_custom_gcode, m_values[tick]);
@ -3586,6 +3611,8 @@ void DoubleSlider::edit_tick()
std::string edited_value; std::string edited_value;
if (it->gcode == Slic3r::ColorChangeCode) if (it->gcode == Slic3r::ColorChangeCode)
edited_value = get_new_color(it->color); edited_value = get_new_color(it->color);
else if (it->gcode == Slic3r::PausePrintCode)
edited_value = get_pause_print_msg(it->color, m_values[it->tick]);
else else
edited_value = get_custom_code(it->gcode, m_values[it->tick]); edited_value = get_custom_code(it->gcode, m_values[it->tick]);
@ -3593,7 +3620,7 @@ void DoubleSlider::edit_tick()
return; return;
TICK_CODE changed_tick = *it; TICK_CODE changed_tick = *it;
if (it->gcode == Slic3r::ColorChangeCode) { if (it->gcode == Slic3r::ColorChangeCode || it->gcode == Slic3r::PausePrintCode) {
if (it->color == edited_value) if (it->color == edited_value)
return; return;
changed_tick.color = edited_value; changed_tick.color = edited_value;

View File

@ -927,6 +927,7 @@ private:
bool m_suppress_add_code = false; bool m_suppress_add_code = false;
ManipulationState m_state = msSingleExtruder; ManipulationState m_state = msSingleExtruder;
std::string m_custom_gcode = ""; std::string m_custom_gcode = "";
std::string m_pause_print_msg;
int m_current_extruder = -1; int m_current_extruder = -1;
wxRect m_rect_lower_thumb; wxRect m_rect_lower_thumb;