mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-16 13:32:44 +00:00
feat: refactor notebook/tabs to be string based instead of fixed index based
This commit is contained in:
+37
-30
@@ -5787,7 +5787,7 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi
|
||||
#endif // WIN32
|
||||
|
||||
m_mainframe.Raise();
|
||||
m_mainframe.select_tab(size_t(MainFrame::tp3DEditor));
|
||||
m_mainframe.select_tab(TAB_ID_PREPARE);
|
||||
if (wxGetApp().is_editor())
|
||||
m_plater.select_view_3D("3D");
|
||||
|
||||
@@ -6569,9 +6569,9 @@ void Plater::priv::select_next_view_3D()
|
||||
{
|
||||
|
||||
if (current_panel == view3D)
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tpPreview));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREVIEW);
|
||||
else if (current_panel == preview)
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
// else if (current_panel == assemble_view)
|
||||
// set_current_panel(view3D);
|
||||
}
|
||||
@@ -7870,7 +7870,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
q->select_plate(first_plate_index);
|
||||
//set to 3d tab
|
||||
q->select_view_3D("Preview");
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tpPreview);
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREVIEW);
|
||||
}
|
||||
else {
|
||||
//set to 3d tab
|
||||
@@ -7889,7 +7889,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
else {
|
||||
//always set to 3D after loading files
|
||||
q->select_view_3D("3D");
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tp3DEditor);
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
}
|
||||
|
||||
if (load_model) {
|
||||
@@ -8797,7 +8797,7 @@ void Plater::priv::process_validation_warning(StringObjectException const &warni
|
||||
}
|
||||
}
|
||||
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tp3DEditor);
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
|
||||
if (inst_idx != -1) {
|
||||
auto* model = wxGetApp().obj_list()->GetModel();
|
||||
@@ -8826,7 +8826,7 @@ void Plater::priv::process_validation_warning(StringObjectException const &warni
|
||||
} else {
|
||||
auto iter = id.id ? std::find_if(objects.begin(), objects.end(), [id](auto o) { return o->id() == id; }) : objects.end();
|
||||
if (iter != objects.end()) {
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tp3DEditor);
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
wxGetApp().obj_list()->select_items({{*iter, nullptr}});
|
||||
wxGetApp().obj_list()->update_selections_on_canvas();
|
||||
}
|
||||
@@ -11208,13 +11208,20 @@ void Plater::priv::on_tab_selection_changing(wxBookCtrlEvent& e)
|
||||
}
|
||||
|
||||
const int new_sel = e.GetSelection();
|
||||
sidebar_layout.show = new_sel == MainFrame::tp3DEditor || new_sel == MainFrame::tpPreview;
|
||||
if (new_sel == wxNOT_FOUND) {
|
||||
// Guards against new_sel matching FindPageByName's own wxNOT_FOUND sentinel
|
||||
// below when a TAB_ID_* isn't currently present in the tabpanel.
|
||||
e.Skip();
|
||||
return;
|
||||
}
|
||||
sidebar_layout.show = new_sel == main_frame->m_tabpanel->FindPageByName(TAB_ID_PREPARE) ||
|
||||
new_sel == main_frame->m_tabpanel->FindPageByName(TAB_ID_PREVIEW);
|
||||
update_sidebar();
|
||||
int old_sel = e.GetOldSelection();
|
||||
const bool is_printer_agent_plugin = NetworkAgentFactory::is_current_printer_agent_plugin();
|
||||
const bool use_native_device_tab = wxGetApp().preset_bundle &&
|
||||
(wxGetApp().preset_bundle->use_bbl_device_tab() || is_printer_agent_plugin);
|
||||
if (use_native_device_tab && new_sel == MainFrame::tpMonitor) {
|
||||
if (use_native_device_tab && new_sel == main_frame->m_tabpanel->FindPageByName(TAB_ID_MONITOR)) {
|
||||
// BBL network module is only required for BBL-vendor printers.
|
||||
// Non-BBL Python plugins (e.g. moonraker) drive the Device tab without it.
|
||||
if (!is_printer_agent_plugin && wxGetApp().preset_bundle->is_bbl_vendor() && !Slic3r::NetworkAgent::is_network_module_loaded()) {
|
||||
@@ -11226,7 +11233,7 @@ void Plater::priv::on_tab_selection_changing(wxBookCtrlEvent& e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (new_sel == MainFrame::tpMonitor && wxGetApp().preset_bundle != nullptr) {
|
||||
if (new_sel == main_frame->m_tabpanel->FindPageByName(TAB_ID_MONITOR) && wxGetApp().preset_bundle != nullptr) {
|
||||
auto cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
wxString url = cfg.opt_string("print_host_webui").empty() ? cfg.opt_string("print_host") : cfg.opt_string("print_host_webui");
|
||||
if (main_frame->m_printer_view && url.empty()) {
|
||||
@@ -12094,7 +12101,7 @@ bool Plater::priv::check_ams_status_impl(bool is_slice_all)
|
||||
wxPostEvent(q, SimpleEvent(EVT_GLTOOLBAR_SLICE_ALL));
|
||||
else
|
||||
wxPostEvent(q, SimpleEvent(EVT_GLTOOLBAR_SLICE_PLATE));
|
||||
wxGetApp().mainframe->m_tabpanel->SetSelection(MainFrame::TabPosition::tpPreview);
|
||||
wxGetApp().mainframe->m_tabpanel->SelectPageByName(TAB_ID_PREVIEW);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -13051,7 +13058,7 @@ int Plater::new_project(bool skip_confirm, bool silent, const wxString& project_
|
||||
get_notification_manager()->clear_all();
|
||||
|
||||
if (!silent)
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tp3DEditor);
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
|
||||
//get_partplate_list().reinit();
|
||||
//get_partplate_list().update_slice_context_to_current_plate(p->background_process);
|
||||
@@ -13200,7 +13207,7 @@ void Plater::load_project(wxString const& filename2,
|
||||
if (!m_exported_file) {
|
||||
p->select_view("topfront");
|
||||
p->camera.requires_zoom_to_plate = REQUIRES_ZOOM_TO_ALL_PLATE;
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tp3DEditor);
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
}
|
||||
else {
|
||||
p->partplate_list.select_plate_view();
|
||||
@@ -13314,7 +13321,7 @@ void Plater::import_model_id(wxString download_info)
|
||||
const int max_retries = 3;
|
||||
|
||||
/* jump to 3D eidtor */
|
||||
wxGetApp().mainframe->select_tab((size_t)MainFrame::TabPosition::tp3DEditor);
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
|
||||
/* prepare progress dialog */
|
||||
bool cont = true;
|
||||
@@ -13623,7 +13630,7 @@ void Plater::calib_pa(const Calib_Params& params)
|
||||
{
|
||||
const auto calib_pa_name = wxString::Format(L"Pressure Advance Test");
|
||||
new_project(false, false, calib_pa_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
print_config->set_key_value("overhang_reverse", new ConfigOptionBool(false));
|
||||
@@ -14104,7 +14111,7 @@ void Plater::calib_flowrate(bool is_linear, int pass, InfillPattern pattern) {
|
||||
if (new_project(false, false, calib_name) == wxID_CANCEL)
|
||||
return;
|
||||
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
|
||||
if (is_linear) {
|
||||
if (pass == 1)
|
||||
@@ -14141,7 +14148,7 @@ void Plater::calib_temp(const Calib_Params& params) {
|
||||
|
||||
const auto calib_temp_name = wxString::Format(L"Nozzle temperature test");
|
||||
new_project(false, false, calib_temp_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
if (params.mode != CalibMode::Calib_Temp_Tower) return;
|
||||
|
||||
if (!add_model(false, Slic3r::resources_dir() + "/calib/temperature_tower/temperature_tower.drc"))
|
||||
@@ -14218,7 +14225,7 @@ void Plater::calib_max_vol_speed(const Calib_Params& params)
|
||||
{
|
||||
const auto calib_vol_speed_name = wxString::Format(L"Max volumetric speed test");
|
||||
new_project(false, false, calib_vol_speed_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
if (params.mode != CalibMode::Calib_Vol_speed_Tower)
|
||||
return;
|
||||
if (!add_model(false, Slic3r::resources_dir() + "/calib/volumetric_speed/SpeedTestStructure.drc"))
|
||||
@@ -14297,7 +14304,7 @@ void Plater::calib_retraction(const Calib_Params& params)
|
||||
{
|
||||
const auto calib_retraction_name = wxString::Format(L"Retraction");
|
||||
new_project(false, false, calib_retraction_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
if (params.mode != CalibMode::Calib_Retraction_tower)
|
||||
return;
|
||||
|
||||
@@ -14357,7 +14364,7 @@ void Plater::calib_VFA(const Calib_Params& params)
|
||||
{
|
||||
const auto calib_vfa_name = wxString::Format(L"VFA test");
|
||||
new_project(false, false, calib_vfa_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
if (params.mode != CalibMode::Calib_VFA_Tower)
|
||||
return;
|
||||
|
||||
@@ -14403,7 +14410,7 @@ void Plater::calib_input_shaping_freq(const Calib_Params& params)
|
||||
{
|
||||
const auto calib_input_shaping_name = wxString::Format(L"Input shaping Frequency test");
|
||||
new_project(false, false, calib_input_shaping_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
if (params.mode != CalibMode::Calib_Input_shaping_freq)
|
||||
return;
|
||||
|
||||
@@ -14469,7 +14476,7 @@ void Plater::calib_input_shaping_damp(const Calib_Params& params)
|
||||
{
|
||||
const auto calib_input_shaping_name = wxString::Format(L"Input shaping Damping test");
|
||||
new_project(false, false, calib_input_shaping_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
if (params.mode != CalibMode::Calib_Input_shaping_damp)
|
||||
return;
|
||||
|
||||
@@ -14534,7 +14541,7 @@ void Plater::Calib_Cornering(const Calib_Params& params)
|
||||
{
|
||||
const auto Calib_Cornering = wxString::Format(L"Cornering test");
|
||||
new_project(false, false, Calib_Cornering);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
if (params.mode != CalibMode::Calib_Cornering)
|
||||
return;
|
||||
|
||||
@@ -14667,7 +14674,7 @@ void Plater::load_gcode(const wxString& filename)
|
||||
//p->gcode_result.reset();
|
||||
//reset_gcode_toolpaths();
|
||||
p->preview->reload_print(m_only_gcode);
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tpPreview);
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREVIEW);
|
||||
p->set_current_panel(p->preview, true);
|
||||
p->get_current_canvas3D()->render();
|
||||
//p->notification_manager->bbl_show_plateinfo_notification(into_u8(_L("Preview only mode for gcode file.")));
|
||||
@@ -15340,7 +15347,7 @@ LoadType determine_load_type(std::string filename, std::string override_setting)
|
||||
wxGetApp().app_config->set("import_project_action", std::to_string(choice));
|
||||
|
||||
// BBS: jump to plater panel
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tp3DEditor);
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
|
||||
return load_type;
|
||||
}
|
||||
|
||||
@@ -15569,7 +15576,7 @@ void Plater::reset_with_confirm()
|
||||
.ShowModal() == wxID_YES) {
|
||||
reset();
|
||||
// BBS: jump to plater panel
|
||||
wxGetApp().mainframe->select_tab(size_t(0));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_HOME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17383,7 +17390,7 @@ int Plater::export_config_3mf(int plate_idx, Export3mfProgressFn proFn)
|
||||
//BBS
|
||||
void Plater::send_calibration_job_finished(wxCommandEvent & evt)
|
||||
{
|
||||
p->main_frame->request_select_tab(MainFrame::TabPosition::tpCalibration);
|
||||
p->main_frame->request_select_tab(TAB_ID_CALIBRATION);
|
||||
auto calibration_panel = p->main_frame->m_calibration;
|
||||
if (calibration_panel) {
|
||||
auto curr_wizard = static_cast<CalibrationWizard*>(calibration_panel->get_tabpanel()->GetPage(evt.GetInt()));
|
||||
@@ -17415,7 +17422,7 @@ void Plater::print_job_finished(wxCommandEvent &evt)
|
||||
if (!dev) return;
|
||||
|
||||
dev->set_selected_machine(evt.GetString().ToStdString());
|
||||
p->main_frame->request_select_tab(MainFrame::TabPosition::tpMonitor);
|
||||
p->main_frame->request_select_tab(TAB_ID_MONITOR);
|
||||
//jump to monitor and select device status panel
|
||||
MonitorPanel* curr_monitor = p->main_frame->m_monitor;
|
||||
if(curr_monitor)
|
||||
@@ -17430,7 +17437,7 @@ void Plater::send_job_finished(wxCommandEvent& evt)
|
||||
|
||||
send_gcode_finish(evt.GetString());
|
||||
p->hide_send_to_printer_dlg();
|
||||
//p->main_frame->request_select_tab(MainFrame::TabPosition::tpMonitor);
|
||||
//p->main_frame->request_select_tab(TAB_ID_MONITOR);
|
||||
////jump to monitor and select device status panel
|
||||
//MonitorPanel* curr_monitor = p->main_frame->m_monitor;
|
||||
//if (curr_monitor)
|
||||
@@ -18324,7 +18331,7 @@ void Plater::pop_warning_and_go_to_device_page(wxString printer_name, PrinterWar
|
||||
MessageDialog dlg(this, content, title, wxOK | wxFORWARD | wxICON_WARNING, _L("Device Page"));
|
||||
auto result = dlg.ShowModal();
|
||||
if (result == wxFORWARD) {
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tpMonitor));
|
||||
wxGetApp().mainframe->select_tab(TAB_ID_MONITOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user