diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 2571c3950..bc38148e8 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -687,6 +687,17 @@ void MainFrame::update_layout() m_tabpanel->InsertPage(tp3DEditor, m_plater, _L("Prepare"), std::string("tab_3d_active"), std::string("tab_3d_active")); m_tabpanel->InsertPage(tpPreview, m_plater, _L("Preview"), std::string("tab_preview_active"), std::string("tab_preview_active")); m_main_sizer->Add(m_tabpanel, 1, wxEXPAND | wxTOP, 0); + + m_tabpanel->Bind(wxCUSTOMEVT_NOTEBOOK_SEL_CHANGED, [this](wxCommandEvent& evt) + { + // jump to 3deditor under preview_only mode + if (evt.GetId() == tp3DEditor){ + if (!preview_only_hint()) + return; + } + evt.Skip(); + }); + m_plater->Show(); m_tabpanel->Show(); @@ -860,14 +871,6 @@ void MainFrame::init_tabpanel() } } } - else if (new_sel == tp3DEditor) { - if (m_plater && (m_plater->only_gcode_mode() || (m_plater->using_exported_file()))) { - e.Veto(); - BOOST_LOG_TRIVIAL(info) << boost::format("skipped tab switch from %1% to %2% in preview mode")%old_sel %new_sel; - wxCommandEvent *evt = new wxCommandEvent(EVT_PREVIEW_ONLY_MODE_HINT); - wxQueueEvent(m_plater, evt); - } - } }); #ifdef __WXMSW__ @@ -965,6 +968,30 @@ void MainFrame::init_tabpanel() } } +bool MainFrame::preview_only_hint() +{ + if (m_plater && (m_plater->only_gcode_mode() || (m_plater->using_exported_file()))) { + BOOST_LOG_TRIVIAL(info) << boost::format("skipped tab switch from %1% to %2% in preview mode")%m_tabpanel->GetSelection() %tp3DEditor; + + ConfirmBeforeSendDialog confirm_dlg(this, wxID_ANY, _L("Warning")); + confirm_dlg.Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent& e) { + preview_only_to_editor = true; + }); + confirm_dlg.update_btn_label(_L("Yes"), _L("No")); + auto filename = wxString((m_plater->get_preview_only_filename()).c_str(), wxConvUTF8); + confirm_dlg.update_text(filename + _L(" needs to be closed before creating a new model. Do you want to continue?")); + confirm_dlg.on_show(); + if (preview_only_to_editor) { + m_plater->new_project(); + preview_only_to_editor = false; + } + + return false; + } + + return true; +} + #ifdef WIN32 void MainFrame::register_win32_callbacks() { diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 9eafa803e..1412daee0 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -178,6 +178,9 @@ class MainFrame : public DPIFrame eSlicePlate = 1, }; + //jump to editor under preview only mode + bool preview_only_to_editor = false; + protected: virtual void on_dpi_changed(const wxRect &suggested_rect) override; virtual void on_sys_color_changed() override; @@ -289,6 +292,8 @@ public: void load_config(const DynamicPrintConfig& config); //BBS: jump to monitor void jump_to_monitor(std::string dev_id = ""); + //BBS: hint when jump to 3Deditor under preview only mode + bool preview_only_hint(); // Select tab in m_tabpanel // When tab == -1, will be selected last selected tab //BBS: GUI refactor diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 3f10c2450..5da8756e9 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2772,8 +2772,7 @@ void Plater::priv::select_view_3D(const std::string& name, bool no_slice) if (name == "3D") { BOOST_LOG_TRIVIAL(info) << "select view3D"; if (q->only_gcode_mode() || q->using_exported_file()) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": can not goto preview page when loading gcode/exported_3mf"); - return; + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("goto preview page when loading gcode/exported_3mf"); } set_current_panel(view3D, no_slice); } @@ -6478,6 +6477,8 @@ void Plater::priv::set_project_filename(const wxString& filename) //BBS wxString project_name = from_u8(full_path.filename().string()); set_project_name(project_name); + if (q->m_only_gcode) + q->m_preview_only_filename = std::string((project_name + ".gcode").mb_str()); wxGetApp().mainframe->update_title(); @@ -8496,6 +8497,10 @@ bool Plater::open_3mf_file(const fs::path &file_path) break; } } + + // record filename for hint when open exported file + m_preview_only_filename = filename; + return true; } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 5cfb0b451..9402b8877 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -665,6 +665,8 @@ public: static bool has_illegal_filename_characters(const std::string& name); static void show_illegal_characters_warning(wxWindow* parent); + std::string get_preview_only_filename() { return m_preview_only_filename; }; + private: struct priv; std::unique_ptr p; @@ -680,6 +682,7 @@ private: bool m_only_gcode { false }; bool m_exported_file { false }; bool skip_thumbnail_invalid { false }; + std::string m_preview_only_filename; int m_valid_plates_count { 0 }; void suppress_snapshots(); diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 4e3ce2d6c..f8afc7ef5 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -563,8 +563,8 @@ ConfirmBeforeSendDialog::ConfirmBeforeSendDialog(wxWindow* parent, wxWindowID id m_button_ok->SetBorderColor(*wxWHITE); m_button_ok->SetTextColor(wxColour("#FFFFFE")); m_button_ok->SetFont(Label::Body_12); - m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24))); - m_button_ok->SetMinSize(wxSize(-1, FromDIP(24))); + m_button_ok->SetSize(wxSize(-1, FromDIP(24))); + m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24))); m_button_ok->SetCornerRadius(FromDIP(12)); m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) { @@ -578,8 +578,8 @@ ConfirmBeforeSendDialog::ConfirmBeforeSendDialog(wxWindow* parent, wxWindowID id m_button_cancel->SetBackgroundColor(btn_bg_white); m_button_cancel->SetBorderColor(wxColour(38, 46, 48)); m_button_cancel->SetFont(Label::Body_12); - m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24))); - m_button_cancel->SetMinSize(wxSize(-1, FromDIP(24))); + m_button_cancel->SetSize(wxSize(-1, FromDIP(24))); + m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24))); m_button_cancel->SetCornerRadius(FromDIP(12)); m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {