GCodeViewer -> Allow to switch to gcode viewer state when an sla printer is selected

This commit is contained in:
enricoturri1966 2020-08-21 11:36:08 +02:00
parent 34759f9a70
commit 99a15af03d
4 changed files with 34 additions and 2 deletions

View File

@ -434,6 +434,10 @@ void MainFrame::shutdown()
// restore sidebar if it was hidden when switching to gcode viewer mode // restore sidebar if it was hidden when switching to gcode viewer mode
if (m_restore_from_gcode_viewer.collapsed_sidebar) if (m_restore_from_gcode_viewer.collapsed_sidebar)
m_plater->collapse_sidebar(false); m_plater->collapse_sidebar(false);
// restore sla printer if it was deselected when switching to gcode viewer mode
if (m_restore_from_gcode_viewer.sla_technology)
m_plater->set_printer_technology(ptSLA);
#endif // ENABLE_GCODE_VIEWER #endif // ENABLE_GCODE_VIEWER
// Stop the background thread (Windows and Linux). // Stop the background thread (Windows and Linux).
// Disconnect from a 3DConnextion driver (OSX). // Disconnect from a 3DConnextion driver (OSX).
@ -1010,8 +1014,7 @@ void MainFrame::init_menubar()
wxMessageDialog((wxWindow*)this, _L("Switching to G-code preview mode will remove all objects, continue?"), wxMessageDialog((wxWindow*)this, _L("Switching to G-code preview mode will remove all objects, continue?"),
wxString(SLIC3R_APP_NAME) + " - " + _L("Switch to G-code preview mode"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION | wxCENTRE).ShowModal() == wxID_YES) wxString(SLIC3R_APP_NAME) + " - " + _L("Switch to G-code preview mode"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION | wxCENTRE).ShowModal() == wxID_YES)
set_mode(EMode::GCodeViewer); set_mode(EMode::GCodeViewer);
}, "", nullptr, }, "", nullptr);
[this]() { return m_plater != nullptr && m_plater->printer_technology() != ptSLA; }, this);
#endif // ENABLE_GCODE_VIEWER #endif // ENABLE_GCODE_VIEWER
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
append_menu_item(fileMenu, wxID_EXIT, _L("&Quit"), wxString::Format(_L("Quit %s"), SLIC3R_APP_NAME), append_menu_item(fileMenu, wxID_EXIT, _L("&Quit"), wxString::Format(_L("Quit %s"), SLIC3R_APP_NAME),
@ -1329,6 +1332,12 @@ void MainFrame::set_mode(EMode mode)
m_plater->clear_undo_redo_stack_main(); m_plater->clear_undo_redo_stack_main();
m_plater->take_snapshot(_L("New Project")); m_plater->take_snapshot(_L("New Project"));
// restore sla printer if it was deselected when switching to gcode viewer mode
if (m_restore_from_gcode_viewer.sla_technology) {
m_plater->set_printer_technology(ptSLA);
m_restore_from_gcode_viewer.sla_technology = false;
}
// switch view // switch view
m_plater->select_view_3D("3D"); m_plater->select_view_3D("3D");
m_plater->select_view("iso"); m_plater->select_view("iso");
@ -1371,6 +1380,9 @@ void MainFrame::set_mode(EMode mode)
m_plater->clear_undo_redo_stack_main(); m_plater->clear_undo_redo_stack_main();
m_plater->take_snapshot(_L("New Project")); m_plater->take_snapshot(_L("New Project"));
// switch to FFF printer mode
m_restore_from_gcode_viewer.sla_technology = m_plater->set_printer_technology(ptFFF);
// switch view // switch view
m_plater->select_view_3D("Preview"); m_plater->select_view_3D("Preview");
m_plater->select_view("iso"); m_plater->select_view("iso");

View File

@ -76,6 +76,7 @@ class MainFrame : public DPIFrame
{ {
bool collapsed_sidebar{ false }; bool collapsed_sidebar{ false };
bool collapse_toolbar_enabled{ false }; bool collapse_toolbar_enabled{ false };
bool sla_technology{ false };
}; };
RestoreFromGCodeViewer m_restore_from_gcode_viewer; RestoreFromGCodeViewer m_restore_from_gcode_viewer;

View File

@ -5596,12 +5596,23 @@ PrinterTechnology Plater::printer_technology() const
const DynamicPrintConfig * Plater::config() const { return p->config; } const DynamicPrintConfig * Plater::config() const { return p->config; }
#if ENABLE_GCODE_VIEWER
bool Plater::set_printer_technology(PrinterTechnology printer_technology)
#else
void Plater::set_printer_technology(PrinterTechnology printer_technology) void Plater::set_printer_technology(PrinterTechnology printer_technology)
#endif // ENABLE_GCODE_VIEWER
{ {
p->printer_technology = printer_technology; p->printer_technology = printer_technology;
#if ENABLE_GCODE_VIEWER
bool ret = p->background_process.select_technology(printer_technology);
if (ret) {
// Update the active presets.
}
#else
if (p->background_process.select_technology(printer_technology)) { if (p->background_process.select_technology(printer_technology)) {
// Update the active presets. // Update the active presets.
} }
#endif // ENABLE_GCODE_VIEWER
//FIXME for SLA synchronize //FIXME for SLA synchronize
//p->background_process.apply(Model)! //p->background_process.apply(Model)!
@ -5618,6 +5629,10 @@ void Plater::set_printer_technology(PrinterTechnology printer_technology)
p->update_main_toolbar_tooltips(); p->update_main_toolbar_tooltips();
p->sidebar->get_searcher().set_printer_technology(printer_technology); p->sidebar->get_searcher().set_printer_technology(printer_technology);
#if ENABLE_GCODE_VIEWER
return ret;
#endif // ENABLE_GCODE_VIEWER
} }
void Plater::changed_object(int obj_idx) void Plater::changed_object(int obj_idx)

View File

@ -263,7 +263,11 @@ public:
PrinterTechnology printer_technology() const; PrinterTechnology printer_technology() const;
const DynamicPrintConfig * config() const; const DynamicPrintConfig * config() const;
#if ENABLE_GCODE_VIEWER
bool set_printer_technology(PrinterTechnology printer_technology);
#else
void set_printer_technology(PrinterTechnology printer_technology); void set_printer_technology(PrinterTechnology printer_technology);
#endif // ENABLE_GCODE_VIEWER
void copy_selection_to_clipboard(); void copy_selection_to_clipboard();
void paste_from_clipboard(); void paste_from_clipboard();