NEW:Revert "add pause print message"

This reverts commit f24178896e2e9701165a3a5df8e711489beb34e5.

Reason for revert: pause

Change-Id: Ie55d14143a9e5ea9d593cb2ff0196688f3b0345e
This commit is contained in:
梨子 2023-07-11 19:59:52 +08:00 committed by Lane.Wei
parent 28ed757701
commit bc469bdcb6
5 changed files with 19 additions and 117 deletions

View File

@ -2574,8 +2574,8 @@ namespace ProcessLayer
// add tag for processor
gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Pause_Print) + "\n";
//! FIXME_in_fw show message during print pause
if (!pause_print_msg.empty())
gcode += "M117 " + pause_print_msg + "\n";
//if (!pause_print_msg.empty())
// gcode += "M117 " + pause_print_msg + "\n";
gcode += gcodegen.placeholder_parser_process("machine_pause_gcode", config.machine_pause_gcode, current_extruder_id) + "\n";
}
else {

View File

@ -334,7 +334,6 @@ void IMSlider::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model,
// close opened menu window after reslice
m_show_menu = false;
m_show_pause_print_window = false;
m_show_custom_gcode_window = false;
m_show_go_to_layer_dialog = false;
}
@ -362,20 +361,6 @@ void IMSlider::post_ticks_changed_event(Type type)
m_is_need_post_tick_changed_event = true;
}
void IMSlider::add_pause_print(std::string pause_print_msg) {
if (m_selection == ssUndef) return;
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
const auto it = m_ticks.ticks.find(TickCode{ tick });
if (it != m_ticks.ticks.end()) {
m_ticks.ticks.erase(it);
}
m_ticks.ticks.emplace(TickCode{ tick, PausePrint, std::max<int>(1, m_only_extruder), "", pause_print_msg });
post_ticks_changed_event(PausePrint);
}
void IMSlider::add_custom_gcode(std::string custom_gcode)
{
if (m_selection == ssUndef) return;
@ -455,7 +440,7 @@ bool IMSlider::check_ticks_changed_event(Type type)
// switch on/off one layer mode
bool IMSlider::switch_one_layer_mode()
{
if (m_show_custom_gcode_window || m_show_pause_print_window)
if (m_show_custom_gcode_window)
return false;
m_is_one_layer = !m_is_one_layer;
@ -1047,85 +1032,6 @@ bool IMSlider::render(int canvas_width, int canvas_height)
return result;
}
void IMSlider::render_add_pause_msg_dialog(std::string pause_print_msg) {
if (m_show_pause_print_window)
ImGui::OpenPopup((_u8L("Pause Print")).c_str());
ImGuiWrapper& imgui = *wxGetApp().imgui();
ImGuiStyle& style = ImGui::GetStyle();
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
static bool set_focus = true;
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
imgui.push_menu_style(m_scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 10) * m_scale);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.f * m_scale);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 3) * m_scale);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10, 7) * m_scale);
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, m_is_dark ? ImVec4(54 / 255.0f, 54 / 255.0f, 60 / 255.0f, 1.00f) : ImVec4(245 / 255.0f, 245 / 255.0f, 245 / 255.0f, 1.00f));
ImGui::GetCurrentContext()->DimBgRatio = 1.0f;
int windows_flag =
ImGuiWindowFlags_NoCollapse
| ImGuiWindowFlags_AlwaysAutoResize
| ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoScrollbar
| ImGuiWindowFlags_NoScrollWithMouse;
if (ImGui::BeginPopupModal((_u8L("Pause Print")).c_str(), NULL, windows_flag))
{
const std::string text = "Please enter the brief message displayed on the printer screen when printer is paused:";
imgui.text(_u8L(text));
if (ImGui::IsMouseClicked(0)) {
set_focus = false;
}
if (set_focus && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)) {
wxGetApp().plater()->get_current_canvas3D()->force_set_focus();
ImGui::SetKeyboardFocusHere(0);
strncpy(m_pause_print_msg, pause_print_msg.c_str(), sizeof(m_pause_print_msg));
}
ImGui::PushItemWidth(ImGui::CalcTextSize(_u8L(text).c_str()).x);
ImGui::InputText("##text_pause_message", m_pause_print_msg, sizeof(m_pause_print_msg), ImGuiInputTextFlags_AutoSelectAll);
float button_width = ImGui::CalcTextSize(_u8L("OK").c_str()).x + ImGui::CalcTextSize(_u8L("Cancel").c_str()).x + style.FramePadding.x * 4;
ImGui::NewLine();
ImGui::SameLine(ImGui::GetWindowWidth() - button_width - style.WindowPadding.x - style.ItemSpacing.x);
imgui.push_confirm_button_style();
bool disable_button = false;
if (strlen(m_pause_print_msg) == 0)
disable_button = true;
if (disable_button) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
imgui.push_button_disable_style();
}
if (imgui.bbl_button(_L("OK") + "##id_pause") || (!disable_button && ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Enter)))) {
add_pause_print(m_pause_print_msg);
m_show_pause_print_window = false;
ImGui::CloseCurrentPopup();
set_focus = true;
}
if (disable_button) {
ImGui::PopItemFlag();
imgui.pop_button_disable_style();
}
imgui.pop_confirm_button_style();
ImGui::SameLine();
imgui.push_cancel_button_style();
if (imgui.bbl_button(_L("Cancel") + "##id_pause") || ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
m_show_pause_print_window = false;
ImGui::CloseCurrentPopup();
set_focus = true;
}
imgui.pop_cancel_button_style();
ImGui::EndPopup();
}
ImGui::PopStyleVar(4);
ImGui::PopStyleColor();
imgui.pop_menu_style();
}
void IMSlider::render_input_custom_gcode(std::string custom_gcode)
{
if (m_show_custom_gcode_window)
@ -1158,11 +1064,13 @@ void IMSlider::render_input_custom_gcode(std::string custom_gcode)
if (set_focus && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)) {
wxGetApp().plater()->get_current_canvas3D()->force_set_focus();
ImGui::SetKeyboardFocusHere(0);
strncpy(m_custom_gcode, custom_gcode.c_str(), sizeof(m_pause_print_msg));
strcpy(m_custom_gcode, custom_gcode.c_str());
}
const int text_height = 6;
ImGui::InputTextMultiline("##text_custom_gcode", m_custom_gcode, sizeof(m_custom_gcode), ImVec2(-1, ImGui::GetTextLineHeight() * text_height), ImGuiInputTextFlags_AutoSelectAll);
ImGui::InputTextMultiline("##text", m_custom_gcode, sizeof(m_custom_gcode), ImVec2(-1, ImGui::GetTextLineHeight() * text_height), ImGuiInputTextFlags_CallbackAlways, [](ImGuiInputTextCallbackData* data) {
return data->CursorPos = data->BufTextLen;
});
ImGui::NewLine();
ImGui::SameLine(ImGui::GetStyle().WindowPadding.x * 14);
@ -1175,7 +1083,7 @@ void IMSlider::render_input_custom_gcode(std::string custom_gcode)
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
imgui.push_button_disable_style();
}
if (imgui.bbl_button(_L("OK") + "##id_custom")) {
if (imgui.bbl_button(_L("OK"))) {
add_custom_gcode(m_custom_gcode);
m_show_custom_gcode_window = false;
ImGui::CloseCurrentPopup();
@ -1189,7 +1097,7 @@ void IMSlider::render_input_custom_gcode(std::string custom_gcode)
ImGui::SameLine();
imgui.push_cancel_button_style();
if (imgui.bbl_button(_L("Cancel") + "##id_custom") || ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
if (imgui.bbl_button(_L("Cancel")) || ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
m_show_custom_gcode_window = false;
ImGui::CloseCurrentPopup();
set_focus = true;
@ -1260,7 +1168,7 @@ void IMSlider::render_go_to_layer_dialog()
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
imgui.push_button_disable_style();
}
if (imgui.bbl_button(_L("OK") + "##id_jump") || (!disable_button && ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Enter)))) {
if (imgui.bbl_button(_L("OK")) || (!disable_button && ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Enter)))) {
do_go_to_layer(atoi(m_layer_number) - 1);
m_show_go_to_layer_dialog = false;
ImGui::CloseCurrentPopup();
@ -1274,7 +1182,7 @@ void IMSlider::render_go_to_layer_dialog()
ImGui::SameLine();
imgui.push_cancel_button_style();
if (imgui.bbl_button(_L("Cancel") + "##id_jump") || ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
if (imgui.bbl_button(_L("Cancel")) || ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
m_show_go_to_layer_dialog = false;
ImGui::CloseCurrentPopup();
set_focus = true;
@ -1299,12 +1207,9 @@ void IMSlider::render_menu() {
GetSelection() == ssLower ? m_ticks.ticks.find(TickCode{ GetLowerValue() }) :
m_ticks.ticks.end();
std::string custom_code;
std::string pause_print_msg;
if (tick_it != m_ticks.ticks.end()) {
if (tick_it->type == CustomGCode::Custom)
custom_code = tick_it->extra;
if (tick_it->type == CustomGCode::PausePrint)
pause_print_msg = tick_it->extra;
render_edit_menu(*tick_it);
}
else {
@ -1315,7 +1220,6 @@ void IMSlider::render_menu() {
ImGuiWrapper::pop_menu_style();
render_input_custom_gcode(custom_code);
render_add_pause_msg_dialog(pause_print_msg);
render_go_to_layer_dialog();
}
@ -1330,7 +1234,7 @@ void IMSlider::render_add_menu()
bool hovered = false;
{
if (menu_item_with_icon(_u8L("Add Pause").c_str(), "", ImVec2(0, 0), 0, false, menu_item_enable, &hovered)) {
m_show_pause_print_window = true;
add_code_as_tick(PausePrint);
}
if (hovered) { show_tooltip(_u8L("Insert a pause command at the beginning of this layer.")); }
@ -1382,10 +1286,7 @@ void IMSlider::render_edit_menu(const TickCode& tick)
switch (tick.type)
{
case CustomGCode::PausePrint:
if (menu_item_with_icon(_u8L("Edit Pause Print Message").c_str(), "")) {
m_show_pause_print_window = true;
}
if (menu_item_with_icon(_u8L("Delete Pause Print").c_str(), "")) {
if (menu_item_with_icon(_u8L("Delete Pause").c_str(), "")) {
delete_tick(tick);
}
break;

View File

@ -4,6 +4,9 @@
#include "TickCode.hpp"
#include <imgui/imgui.h>
#include <set>
class wxMenu;
struct IMGUI_API ImRect;
namespace Slic3r {
@ -128,7 +131,6 @@ public:
void set_menu_enable(bool enable = true) { m_menu_enable = enable; }
protected:
void add_pause_print(std::string pause_print_msg);
void add_custom_gcode(std::string custom_gcode);
void add_code_as_tick(Type type, int selected_extruder = -1);
void delete_tick(const TickCode& tick);
@ -138,7 +140,6 @@ protected:
bool horizontal_slider(const char* str_id, int* v, int v_min, int v_max, const ImVec2& size, float scale = 1.0);
void render_go_to_layer_dialog(); //menu
void render_input_custom_gcode(std::string custom_gcode = ""); //menu
void render_add_pause_msg_dialog(std::string pause_print_msg = ""); //menu
void render_menu();
void render_add_menu(); //menu
void render_edit_menu(const TickCode& tick); //menu
@ -183,7 +184,6 @@ private:
bool m_menu_enable = true; //menu
bool m_show_menu = false; //menu
bool m_show_custom_gcode_window = false; //menu
bool m_show_pause_print_window = false; //menu
bool m_show_go_to_layer_dialog = false; //menu
bool m_force_mode_apply = true;
bool m_is_wipe_tower = false; // This flag indicates that there is multiple extruder print with wipe tower
@ -228,7 +228,6 @@ private:
std::vector<double> m_alternate_values;
char m_custom_gcode[1024] = { 0 }; //menu
char m_pause_print_msg[256] = { 0 }; //menu
char m_layer_number[64] = { 0 }; //menu
};

View File

@ -93,7 +93,7 @@ bool TickCodeInfo::add_tick(const int tick, Type type, const int extruder, doubl
//BBS do not set pause extra message
//extra = get_pause_print_msg(pause_print_msg, print_z);
//if (extra.empty()) return false;
//pause_print_msg = extra;
pause_print_msg = extra;
}
else {
color = get_color_for_tick(TickCode{ tick }, type, extruder);

View File

@ -23,6 +23,7 @@ struct TickCode
class TickCodeInfo
{
std::string pause_print_msg;
bool m_suppress_plus = false;
bool m_suppress_minus = false;
bool m_use_default_colors = false;
@ -37,6 +38,7 @@ public:
Mode mode = Undef;
bool empty() const { return ticks.empty(); }
void set_pause_print_msg(const std::string& message) { pause_print_msg = message; }
bool add_tick(const int tick, Type type, int extruder, double print_z);
bool edit_tick(std::set<TickCode>::iterator it, double print_z);