Removal of wxNotebook from plater set as default

This commit is contained in:
Enrico Turri 2019-01-03 12:59:06 +01:00
parent eacb5b9bf9
commit b099d5c05e
10 changed files with 5 additions and 497 deletions

View file

@ -900,28 +900,12 @@ struct Plater::priv
Slic3r::GCodePreviewData gcode_preview_data;
// GUI elements
#if ENABLE_REMOVE_TABS_FROM_PLATER
wxSizer* panel_sizer;
wxPanel* current_panel;
std::vector<wxPanel*> panels;
#else
wxNotebook *notebook;
EventGuard guard_on_notebook_changed;
// Note: ^ The on_notebook_changed is guarded here because the wxNotebook d-tor tends to generate
// wxEVT_NOTEBOOK_PAGE_CHANGED events on some platforms, which causes them to be received by a freed Plater.
// EventGuard unbinds the handler in its d-tor.
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
Sidebar *sidebar;
#if ENABLE_REMOVE_TABS_FROM_PLATER
View3D* view3D;
GLToolbar view_toolbar;
#else
#if !ENABLE_IMGUI
wxPanel *panel3d;
#endif // not ENABLE_IMGUI
wxGLCanvas *canvas3Dwidget; // TODO: Use GLCanvas3D when we can
GLCanvas3D *canvas3D;
#endif // !ENABLE_REMOVE_TABS_FROM_PLATER
Preview *preview;
wxString project_filename;
@ -942,10 +926,8 @@ struct Plater::priv
void update(bool force_full_scene_refresh = false);
void select_view(const std::string& direction);
#if ENABLE_REMOVE_TABS_FROM_PLATER
void select_view_3D(const std::string& name);
void select_next_view_3D();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
void update_ui_from_settings();
ProgressStatusBar* statusbar();
std::string get_config(const std::string &key) const;
@ -999,11 +981,8 @@ struct Plater::priv
void reload_from_disk();
void fix_through_netfabb(const int obj_idx);
#if ENABLE_REMOVE_TABS_FROM_PLATER
void set_current_panel(wxPanel* panel);
#else
void on_notebook_changed(wxBookCtrlEvent&);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
void on_select_preset(wxCommandEvent&);
void on_slicing_update(SlicingStatusEvent&);
void on_slicing_completed(wxCommandEvent&);
@ -1030,9 +1009,7 @@ private:
bool complit_init_object_menu();
bool complit_init_sla_object_menu();
bool complit_init_part_menu();
#if ENABLE_REMOVE_TABS_FROM_PLATER
void init_view_toolbar();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
bool can_delete_object() const;
bool can_increase_instances() const;
@ -1064,20 +1041,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
"wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle",
"extruder_colour", "filament_colour", "max_print_height", "printer_model", "printer_technology"
}))
#if !ENABLE_REMOVE_TABS_FROM_PLATER
, notebook(new wxNotebook(q, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_BOTTOM))
, guard_on_notebook_changed(notebook, wxEVT_NOTEBOOK_PAGE_CHANGED, &priv::on_notebook_changed, this)
#endif // !ENABLE_REMOVE_TABS_FROM_PLATER
, sidebar(new Sidebar(q))
#if !ENABLE_REMOVE_TABS_FROM_PLATER
#if ENABLE_IMGUI
, canvas3Dwidget(GLCanvas3DManager::create_wxglcanvas(notebook))
#else
, panel3d(new wxPanel(notebook, wxID_ANY))
, canvas3Dwidget(GLCanvas3DManager::create_wxglcanvas(panel3d))
#endif // ENABLE_IMGUI
, canvas3D(nullptr)
#endif // !ENABLE_REMOVE_TABS_FROM_PLATER
, delayed_scene_refresh(false)
, project_filename(wxEmptyString)
, view_toolbar(GLToolbar::Radio)
@ -1100,27 +1064,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
sla_print.set_status_callback(statuscb);
this->q->Bind(EVT_SLICING_UPDATE, &priv::on_slicing_update, this);
#if !ENABLE_REMOVE_TABS_FROM_PLATER
_3DScene::add_canvas(canvas3Dwidget);
this->canvas3D = _3DScene::get_canvas(this->canvas3Dwidget);
this->canvas3D->allow_multisample(GLCanvas3DManager::can_multisample());
#if ENABLE_IMGUI
notebook->AddPage(canvas3Dwidget, _(L("3D")));
#else
auto *panel3dsizer = new wxBoxSizer(wxVERTICAL);
panel3dsizer->Add(canvas3Dwidget, 1, wxEXPAND);
auto *panel_gizmo_widgets = new wxPanel(panel3d, wxID_ANY);
panel_gizmo_widgets->SetSizer(new wxBoxSizer(wxVERTICAL));
panel3dsizer->Add(panel_gizmo_widgets, 0, wxEXPAND);
panel3d->SetSizer(panel3dsizer);
notebook->AddPage(panel3d, _(L("3D")));
canvas3D->set_external_gizmo_widgets_parent(panel_gizmo_widgets);
#endif // ENABLE_IMGUI
#endif // !ENABLE_REMOVE_TABS_FROM_PLATER
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D = new View3D(q, &model, config, &background_process);
preview = new Preview(q, config, &background_process, &gcode_preview_data, [this](){ schedule_background_process(); });
// Let the Tab key switch between the 3D view and the layer preview.
@ -1129,51 +1072,24 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
panels.push_back(view3D);
panels.push_back(preview);
#else
preview = new GUI::Preview(notebook, config, &background_process, &gcode_preview_data, [this](){ schedule_background_process(); });
// XXX: If have OpenGL
this->canvas3D->enable_picking(true);
this->canvas3D->enable_moving(true);
// XXX: more config from 3D.pm
this->canvas3D->set_model(&model);
this->canvas3D->set_process(&background_process);
this->canvas3D->set_config(config);
this->canvas3D->enable_gizmos(true);
this->canvas3D->enable_toolbar(true);
this->canvas3D->enable_force_zoom_to_bed(true);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
this->background_process_timer.SetOwner(this->q, 0);
this->q->Bind(wxEVT_TIMER, [this](wxTimerEvent &evt) { this->update_restart_background_process(false, false); });
auto *bed_shape = config->opt<ConfigOptionPoints>("bed_shape");
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->set_bed_shape(bed_shape->values);
#else
this->canvas3D->set_bed_shape(bed_shape->values);
this->canvas3D->zoom_to_bed();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
preview->set_bed_shape(bed_shape->values);
update();
auto *hsizer = new wxBoxSizer(wxHORIZONTAL);
#if ENABLE_REMOVE_TABS_FROM_PLATER
panel_sizer = new wxBoxSizer(wxHORIZONTAL);
panel_sizer->Add(view3D, 1, wxEXPAND | wxALL, 0);
panel_sizer->Add(preview, 1, wxEXPAND | wxALL, 0);
hsizer->Add(panel_sizer, 1, wxEXPAND | wxALL, 0);
#else
hsizer->Add(notebook, 1, wxEXPAND | wxTOP, 1);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
hsizer->Add(sidebar, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
q->SetSizer(hsizer);
//#if ENABLE_REMOVE_TABS_FROM_PLATER
// set_current_panel(view3D);
//#endif // ENABLE_REMOVE_TABS_FROM_PLATER
init_object_menu();
// Events:
@ -1184,7 +1100,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
sidebar->Bind(EVT_OBJ_LIST_OBJECT_SELECT, [this](wxEvent&) { priv::selection_changed(); });
sidebar->Bind(EVT_SCHEDULE_BACKGROUND_PROCESS, [this](SimpleEvent&) { this->schedule_background_process(); });
#if ENABLE_REMOVE_TABS_FROM_PLATER
wxGLCanvas* view3D_canvas = view3D->get_wxglcanvas();
// 3DScene events:
view3D_canvas->Bind(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, [this](SimpleEvent&) { this->schedule_background_process(); });
@ -1217,47 +1132,17 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
view3D_canvas->Bind(EVT_GLTOOLBAR_SPLIT_VOLUMES, &priv::on_action_split_volumes, this);
view3D_canvas->Bind(EVT_GLTOOLBAR_LAYERSEDITING, &priv::on_action_layersediting, this);
view3D_canvas->Bind(EVT_GLCANVAS_INIT, [this](SimpleEvent&) { init_view_toolbar(); });
#else
// 3DScene events:
canvas3Dwidget->Bind(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, [this](SimpleEvent&) { this->schedule_background_process(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_OBJECT_SELECT, &priv::on_object_select, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_RIGHT_CLICK, &priv::on_right_click, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_MODEL_UPDATE, [this](SimpleEvent&) { this->schedule_background_process(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_REMOVE_OBJECT, [q](SimpleEvent&) { q->remove_selected(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_ARRANGE, [this](SimpleEvent&) { arrange(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_INCREASE_INSTANCES, [this](Event<int> &evt)
{ if (evt.data == 1) this->q->increase_instances(); else if (this->can_decrease_instances()) this->q->decrease_instances(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_INSTANCE_MOVED, [this](SimpleEvent&) { update(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_WIPETOWER_MOVED, &priv::on_wipetower_moved, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, [this](Event<bool> &evt) { this->sidebar->enable_buttons(evt.data); });
canvas3Dwidget->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this);
// 3DScene/Toolbar:
canvas3Dwidget->Bind(EVT_GLTOOLBAR_ADD, &priv::on_action_add, this);
canvas3Dwidget->Bind(EVT_GLTOOLBAR_DELETE, [q](SimpleEvent&) { q->remove_selected(); } );
canvas3Dwidget->Bind(EVT_GLTOOLBAR_DELETE_ALL, [this](SimpleEvent&) { reset(); });
canvas3Dwidget->Bind(EVT_GLTOOLBAR_ARRANGE, [this](SimpleEvent&) { arrange(); });
canvas3Dwidget->Bind(EVT_GLTOOLBAR_MORE, [q](SimpleEvent&) { q->increase_instances(); });
canvas3Dwidget->Bind(EVT_GLTOOLBAR_FEWER, [q](SimpleEvent&) { q->decrease_instances(); });
canvas3Dwidget->Bind(EVT_GLTOOLBAR_SPLIT_OBJECTS, &priv::on_action_split_objects, this);
canvas3Dwidget->Bind(EVT_GLTOOLBAR_SPLIT_VOLUMES, &priv::on_action_split_volumes, this);
canvas3Dwidget->Bind(EVT_GLTOOLBAR_LAYERSEDITING, &priv::on_action_layersediting, this);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
// Preview events:
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_QUESTION_MARK, [this](SimpleEvent&) { wxGetApp().keyboard_shortcuts(); });
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D_canvas->Bind(EVT_GLCANVAS_INIT, [this](SimpleEvent&) { init_view_toolbar(); });
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
q->Bind(EVT_SLICING_COMPLETED, &priv::on_slicing_completed, this);
q->Bind(EVT_PROCESS_COMPLETED, &priv::on_process_completed, this);
#if ENABLE_REMOVE_TABS_FROM_PLATER
q->Bind(EVT_GLVIEWTOOLBAR_3D, [q](SimpleEvent&) { q->select_view_3D("3D"); });
q->Bind(EVT_GLVIEWTOOLBAR_PREVIEW, [q](SimpleEvent&) { q->select_view_3D("Preview"); });
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
// Drop target:
q->SetDropTarget(new PlaterDropTarget(q)); // if my understanding is right, wxWindow takes the owenership
@ -1265,9 +1150,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
update_ui_from_settings();
q->Layout();
#if ENABLE_REMOVE_TABS_FROM_PLATER
set_current_panel(view3D);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
void Plater::priv::update(bool force_full_scene_refresh)
@ -1286,11 +1169,7 @@ void Plater::priv::update(bool force_full_scene_refresh)
// Update the SLAPrint from the current Model, so that the reload_scene()
// pulls the correct data.
update_status = this->update_background_process();
#if ENABLE_REMOVE_TABS_FROM_PLATER
this->view3D->reload_scene(false, force_full_scene_refresh);
#else
this->canvas3D->reload_scene(false, force_full_scene_refresh);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
this->preview->reload_print();
if (this->printer_technology == ptSLA)
this->restart_background_process(update_status);
@ -1298,7 +1177,6 @@ void Plater::priv::update(bool force_full_scene_refresh)
this->schedule_background_process();
}
#if ENABLE_REMOVE_TABS_FROM_PLATER
void Plater::priv::select_view(const std::string& direction)
{
if (current_panel == view3D)
@ -1322,20 +1200,6 @@ void Plater::priv::select_next_view_3D()
else if (current_panel == preview)
set_current_panel(view3D);
}
#else
void Plater::priv::select_view(const std::string& direction)
{
int page_id = notebook->GetSelection();
if (page_id != wxNOT_FOUND)
{
const wxString& page_text = notebook->GetPageText(page_id);
if (page_text == _(L("3D")))
this->canvas3D->select_view(direction);
else if (page_text == _(L("Preview")))
preview->select_view(direction);
}
}
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
// Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences.
@ -1641,20 +1505,12 @@ std::unique_ptr<CheckboxFileDialog> Plater::priv::get_export_file(GUI::FileType
const GLCanvas3D::Selection& Plater::priv::get_selection() const
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
return view3D->get_canvas3d()->get_selection();
#else
return canvas3D->get_selection();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
GLCanvas3D::Selection& Plater::priv::get_selection()
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
return view3D->get_canvas3d()->get_selection();
#else
return canvas3D->get_selection();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
int Plater::priv::get_selected_object_idx() const
@ -1677,7 +1533,6 @@ int Plater::priv::get_selected_volume_idx() const
void Plater::priv::selection_changed()
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->enable_toolbar_item("delete", can_delete_object());
view3D->enable_toolbar_item("more", can_increase_instances());
view3D->enable_toolbar_item("fewer", can_decrease_instances());
@ -1686,48 +1541,24 @@ void Plater::priv::selection_changed()
view3D->enable_toolbar_item("layersediting", layers_height_allowed());
// forces a frame render to update the view (to avoid a missed update if, for example, the context menu appears)
view3D->render();
#else
this->canvas3D->enable_toolbar_item("delete", can_delete_object());
this->canvas3D->enable_toolbar_item("more", can_increase_instances());
this->canvas3D->enable_toolbar_item("fewer", can_decrease_instances());
this->canvas3D->enable_toolbar_item("splitobjects", can_split/*_to_objects*/());
this->canvas3D->enable_toolbar_item("splitvolumes", can_split/*_to_volumes*/());
this->canvas3D->enable_toolbar_item("layersediting", layers_height_allowed());
// forces a frame render to update the view (to avoid a missed update if, for example, the context menu appears)
this->canvas3D->render();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
void Plater::priv::object_list_changed()
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
// Enable/disable buttons depending on whether there are any objects on the platter.
view3D->enable_toolbar_item("deleteall", can_delete_all());
view3D->enable_toolbar_item("arrange", can_arrange());
#else
// Enable/disable buttons depending on whether there are any objects on the platter.
this->canvas3D->enable_toolbar_item("deleteall", can_delete_all());
this->canvas3D->enable_toolbar_item("arrange", can_arrange());
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
const bool export_in_progress = this->background_process.is_export_scheduled(); // || ! send_gcode_file.empty());
// XXX: is this right?
#if ENABLE_REMOVE_TABS_FROM_PLATER
const bool model_fits = view3D->check_volumes_outside_state() == ModelInstance::PVS_Inside;
#else
const bool model_fits = this->canvas3D->check_volumes_outside_state(config) == ModelInstance::PVS_Inside;
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
sidebar->enable_buttons(!model.objects.empty() && !export_in_progress && model_fits);
}
void Plater::priv::select_all()
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->select_all();
#else
this->canvas3D->select_all();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
this->sidebar->obj_list()->update_selections();
}
@ -1736,13 +1567,8 @@ void Plater::priv::remove(size_t obj_idx)
// Prevent toolpaths preview from rendering while we modify the Print object
preview->set_enabled(false);
#if ENABLE_REMOVE_TABS_FROM_PLATER
if (view3D->is_layers_editing_enabled())
view3D->enable_layers_editing(false);
#else
if (this->canvas3D->is_layers_editing_enabled())
this->canvas3D->enable_layers_editing(false);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
model.delete_object(obj_idx);
// Delete object from Sidebar list
@ -1767,13 +1593,8 @@ void Plater::priv::reset()
// Prevent toolpaths preview from rendering while we modify the Print object
preview->set_enabled(false);
#if ENABLE_REMOVE_TABS_FROM_PLATER
if (view3D->is_layers_editing_enabled())
view3D->enable_layers_editing(false);
#else
if (this->canvas3D->is_layers_editing_enabled())
this->canvas3D->enable_layers_editing(false);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
// Stop and reset the Print content.
this->background_process.reset();
@ -1791,11 +1612,7 @@ void Plater::priv::reset()
void Plater::priv::mirror(Axis axis)
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->mirror_selection(axis);
#else
this->canvas3D->mirror_selection(axis);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
void Plater::priv::arrange()
@ -1807,11 +1624,7 @@ void Plater::priv::arrange()
arranging.store(true);
// Disable the arrange button (to prevent reentrancies, we will call wxYied)
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->enable_toolbar_item("arrange", can_arrange());
#else
this->canvas3D->enable_toolbar_item("arrange", can_arrange());
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
this->background_process.stop();
unsigned count = 0;
@ -1881,11 +1694,7 @@ void Plater::priv::arrange()
arranging.store(false);
// We enable back the arrange button
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->enable_toolbar_item("arrange", can_arrange());
#else
this->canvas3D->enable_toolbar_item("arrange", can_arrange());
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
// Do a full refresh of scene tree, including regenerating all the GLVolumes.
//FIXME The update function shall just reload the modified matrices.
@ -2022,13 +1831,8 @@ unsigned int Plater::priv::update_background_process()
Print::ApplyStatus invalidated = this->background_process.apply(this->q->model(), wxGetApp().preset_bundle->full_config());
// Just redraw the 3D canvas without reloading the scene to consume the update of the layer height profile.
#if ENABLE_REMOVE_TABS_FROM_PLATER
if (view3D->is_layers_editing_enabled())
view3D->get_wxglcanvas()->Refresh();
#else
if (this->canvas3D->is_layers_editing_enabled())
this->canvas3Dwidget->Refresh();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
if (invalidated == Print::APPLY_STATUS_INVALIDATED) {
// Some previously calculated data on the Print was invalidated.
@ -2111,11 +1915,8 @@ void Plater::priv::export_gcode(fs::path output_path, PrintHostJob upload_job)
// bitmask of UpdateBackgroundProcessReturnState
unsigned int state = update_background_process();
if (state & priv::UPDATE_BACKGROUND_PROCESS_REFRESH_SCENE)
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->reload_scene(false);
#else
canvas3D->reload_scene(false);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
if ((state & priv::UPDATE_BACKGROUND_PROCESS_INVALID) != 0)
return;
@ -2133,11 +1934,8 @@ void Plater::priv::update_restart_background_process(bool force_update_scene, bo
// bitmask of UpdateBackgroundProcessReturnState
unsigned int state = this->update_background_process();
if (force_update_scene || (state & UPDATE_BACKGROUND_PROCESS_REFRESH_SCENE) != 0)
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->reload_scene(false);
#else
this->canvas3D->reload_scene(false);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
if (force_update_preview)
this->preview->reload_print();
this->restart_background_process(state);
@ -2148,11 +1946,7 @@ void Plater::priv::update_fff_scene()
if (this->preview != nullptr)
this->preview->reload_print();
// In case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth:
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->reload_scene(true);
#else
this->canvas3D->reload_scene(true);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
void Plater::priv::update_sla_scene()
@ -2225,7 +2019,6 @@ void Plater::priv::fix_through_netfabb(const int obj_idx)
remove(obj_idx);
}
#if ENABLE_REMOVE_TABS_FROM_PLATER
void Plater::priv::set_current_panel(wxPanel* panel)
{
if (std::find(panels.begin(), panels.end(), panel) == panels.end())
@ -2277,34 +2070,6 @@ void Plater::priv::set_current_panel(wxPanel* panel)
current_panel->SetFocusFromKbd();
}
#else
void Plater::priv::on_notebook_changed(wxBookCtrlEvent&)
{
wxCHECK_RET(canvas3D != nullptr, "on_notebook_changed on freed Plater");
const auto current_id = notebook->GetCurrentPage()->GetId();
#if ENABLE_IMGUI
if (current_id == canvas3Dwidget->GetId()) {
#else
if (current_id == panel3d->GetId()) {
#endif // ENABLE_IMGUI
if (this->canvas3D->is_reload_delayed()) {
// Delayed loading of the 3D scene.
if (this->printer_technology == ptSLA) {
// Update the SLAPrint from the current Model, so that the reload_scene()
// pulls the correct data.
this->update_restart_background_process(true, false);
} else
this->canvas3D->reload_scene(true);
}
// sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
this->canvas3D->set_as_dirty();
} else if (current_id == preview->GetId()) {
preview->reload_print();
preview->set_canvas_as_dirty();
}
}
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
void Plater::priv::on_select_preset(wxCommandEvent &evt)
{
@ -2356,11 +2121,7 @@ void Plater::priv::on_slicing_update(SlicingStatusEvent &evt)
this->update_fff_scene();
break;
case ptSLA:
#if ENABLE_REMOVE_TABS_FROM_PLATER
if (view3D->is_dragging())
#else
if (this->canvas3D->is_dragging())
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
delayed_scene_refresh = true;
else
this->update_sla_scene();
@ -2376,11 +2137,7 @@ void Plater::priv::on_slicing_completed(wxCommandEvent &)
this->update_fff_scene();
break;
case ptSLA:
#if ENABLE_REMOVE_TABS_FROM_PLATER
if (view3D->is_dragging())
#else
if (this->canvas3D->is_dragging())
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
delayed_scene_refresh = true;
else
this->update_sla_scene();
@ -2423,11 +2180,7 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
this->update_fff_scene();
break;
case ptSLA:
#if ENABLE_REMOVE_TABS_FROM_PLATER
if (view3D->is_dragging())
#else
if (this->canvas3D->is_dragging())
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
delayed_scene_refresh = true;
else
this->update_sla_scene();
@ -2437,22 +2190,12 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
void Plater::priv::on_layer_editing_toggled(bool enable)
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
view3D->enable_layers_editing(enable);
if (enable && !view3D->is_layers_editing_enabled()) {
// Initialization of the OpenGL shaders failed. Disable the tool.
view3D->enable_toolbar_item("layersediting", false);
}
view3D->set_as_dirty();
#else
this->canvas3D->enable_layers_editing(enable);
if (enable && !this->canvas3D->is_layers_editing_enabled()) {
// Initialization of the OpenGL shaders failed. Disable the tool.
this->canvas3D->enable_toolbar_item("layersediting", false);
}
canvas3Dwidget->Refresh();
canvas3Dwidget->Update();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
void Plater::priv::on_action_add(SimpleEvent&)
@ -2473,17 +2216,10 @@ void Plater::priv::on_action_split_volumes(SimpleEvent&)
void Plater::priv::on_action_layersediting(SimpleEvent&)
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
bool enable = !view3D->is_layers_editing_enabled();
view3D->enable_layers_editing(enable);
if (enable && !view3D->is_layers_editing_enabled())
view3D->enable_toolbar_item("layersediting", false);
#else
bool enable = !this->canvas3D->is_layers_editing_enabled();
this->canvas3D->enable_layers_editing(enable);
if (enable && !this->canvas3D->is_layers_editing_enabled())
this->canvas3D->enable_toolbar_item("layersediting", false);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
void Plater::priv::on_object_select(SimpleEvent& evt)
@ -2495,17 +2231,10 @@ void Plater::priv::on_object_select(SimpleEvent& evt)
void Plater::priv::on_viewport_changed(SimpleEvent& evt)
{
wxObject* o = evt.GetEventObject();
#if ENABLE_REMOVE_TABS_FROM_PLATER
if (o == preview->get_wxglcanvas())
preview->set_viewport_into_scene(view3D->get_canvas3d());
else if (o == view3D->get_wxglcanvas())
preview->set_viewport_from_scene(view3D->get_canvas3d());
#else
if (o == preview->get_wxglcanvas())
preview->set_viewport_into_scene(canvas3D);
else if (o == canvas3Dwidget)
preview->set_viewport_from_scene(canvas3D);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
void Plater::priv::on_right_click(Vec2dEvent& evt)
@ -2685,7 +2414,6 @@ bool Plater::priv::complit_init_part_menu()
return true;
}
#if ENABLE_REMOVE_TABS_FROM_PLATER
void Plater::priv::init_view_toolbar()
{
ItemsIconsTexture::Metadata icons_data;
@ -2735,7 +2463,6 @@ void Plater::priv::init_view_toolbar()
view3D->set_view_toolbar(&view_toolbar);
preview->set_view_toolbar(&view_toolbar);
}
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
bool Plater::priv::can_delete_object() const
{
@ -2780,11 +2507,7 @@ bool Plater::priv::can_split() const
bool Plater::priv::layers_height_allowed() const
{
int obj_idx = get_selected_object_idx();
#if ENABLE_REMOVE_TABS_FROM_PLATER
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && config->opt_bool("variable_layer_height") && view3D->is_layers_editing_allowed();
#else
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && config->opt_bool("variable_layer_height") && this->canvas3D->is_layers_editing_allowed();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
bool Plater::priv::can_delete_all() const
@ -2817,10 +2540,6 @@ Plater::Plater(wxWindow *parent, MainFrame *main_frame)
Plater::~Plater()
{
#if !ENABLE_REMOVE_TABS_FROM_PLATER
_3DScene::remove_canvas(p->canvas3Dwidget);
p->canvas3D = nullptr;
#endif // !ENABLE_REMOVE_TABS_FROM_PLATER
}
Sidebar& Plater::sidebar() { return *p->sidebar; }
@ -2881,9 +2600,7 @@ void Plater::update_ui_from_settings() { p->update_ui_from_settings(); }
void Plater::select_view(const std::string& direction) { p->select_view(direction); }
#if ENABLE_REMOVE_TABS_FROM_PLATER
void Plater::select_view_3D(const std::string& name) { p->select_view_3D(name); }
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
void Plater::select_all() { p->select_all(); }
@ -2894,11 +2611,7 @@ void Plater::delete_object_from_model(size_t obj_idx) { p->delete_object_from_mo
void Plater::remove_selected()
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
this->p->view3D->delete_selected();
#else
this->p->canvas3D->delete_selected();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
void Plater::increase_instances(size_t num)
@ -3127,11 +2840,7 @@ void Plater::reslice()
// bitmask of UpdateBackgroundProcessReturnState
unsigned int state = this->p->update_background_process();
if (state & priv::UPDATE_BACKGROUND_PROCESS_REFRESH_SCENE)
#if ENABLE_REMOVE_TABS_FROM_PLATER
this->p->view3D->reload_scene(false);
#else
this->p->canvas3D->reload_scene(false);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
// Only restarts if the state is valid.
this->p->restart_background_process(state | priv::UPDATE_BACKGROUND_PROCESS_FORCE_RESTART);
}
@ -3196,11 +2905,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
if (opt_key == "printer_technology")
this->set_printer_technology(config.opt_enum<PrinterTechnology>(opt_key));
else if (opt_key == "bed_shape") {
#if ENABLE_REMOVE_TABS_FROM_PLATER
if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values);
#else
this->p->canvas3D->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values);
update_scheduled = true;
}
@ -3211,24 +2916,12 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
}
else if(opt_key == "variable_layer_height") {
if (p->config->opt_bool("variable_layer_height") != true) {
#if ENABLE_REMOVE_TABS_FROM_PLATER
p->view3D->enable_toolbar_item("layersediting", false);
p->view3D->enable_layers_editing(false);
p->view3D->set_as_dirty();
#else
p->canvas3D->enable_toolbar_item("layersediting", false);
p->canvas3D->enable_layers_editing(0);
p->canvas3Dwidget->Refresh();
p->canvas3Dwidget->Update();
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
#if ENABLE_REMOVE_TABS_FROM_PLATER
else if (p->view3D->is_layers_editing_allowed()) {
p->view3D->enable_toolbar_item("layersediting", true);
#else
else if (p->canvas3D->is_layers_editing_allowed()) {
p->canvas3D->enable_toolbar_item("layersediting", true);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
}
else if(opt_key == "extruder_colour") {
@ -3238,11 +2931,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
update_scheduled = true;
} else if(opt_key == "printer_model") {
// update to force bed selection(for texturing)
#if ENABLE_REMOVE_TABS_FROM_PLATER
if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
#else
p->canvas3D->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
update_scheduled = true;
} else if (opt_key == "host_type" && this->p->printer_technology == ptSLA) {
@ -3284,11 +2973,7 @@ bool Plater::is_single_full_object_selection() const
GLCanvas3D* Plater::canvas3D()
{
#if ENABLE_REMOVE_TABS_FROM_PLATER
return p->view3D->get_canvas3d();
#else
return p->canvas3D;
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
PrinterTechnology Plater::printer_technology() const
@ -3324,11 +3009,7 @@ void Plater::changed_object(int obj_idx)
// pulls the correct data, update the 3D scene.
this->p->update_restart_background_process(true, false);
} else
#if ENABLE_REMOVE_TABS_FROM_PLATER
p->view3D->reload_scene(false);
#else
p->canvas3D->reload_scene(false);
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
}
// update print