Tech ENABLE_CANVAS_GUI_REFACTORING set as default

This commit is contained in:
Enrico Turri 2019-03-20 09:33:30 +01:00
parent da1feb2741
commit df250039df
9 changed files with 1 additions and 540 deletions

View file

@ -1227,7 +1227,6 @@ struct Plater::priv
// Sets m_bed.m_polygon to limit the object placement.
void set_bed_shape(const Pointfs& shape);
#if ENABLE_CANVAS_GUI_REFACTORING
bool can_delete() const;
bool can_delete_all() const;
bool can_increase_instances() const;
@ -1236,7 +1235,6 @@ struct Plater::priv
bool can_split_to_volumes() const;
bool can_arrange() const;
bool can_layers_editing() const;
#endif // ENABLE_CANVAS_GUI_REFACTORING
private:
bool init_object_menu();
@ -1246,22 +1244,9 @@ private:
bool complit_init_part_menu();
void init_view_toolbar();
#if !ENABLE_CANVAS_GUI_REFACTORING
bool can_delete_object() const;
bool can_increase_instances() const;
bool can_decrease_instances() const;
#endif // !ENABLE_CANVAS_GUI_REFACTORING
bool can_set_instance_to_object() const;
#if !ENABLE_CANVAS_GUI_REFACTORING
bool can_split_to_objects() const;
bool can_split_to_volumes() const;
#endif // !ENABLE_CANVAS_GUI_REFACTORING
bool can_split() const;
bool layers_height_allowed() const;
#if !ENABLE_CANVAS_GUI_REFACTORING
bool can_delete_all() const;
bool can_arrange() const;
#endif // !ENABLE_CANVAS_GUI_REFACTORING
bool can_mirror() const;
void update_fff_scene();
@ -1821,14 +1806,6 @@ int Plater::priv::get_selected_volume_idx() const
void Plater::priv::selection_changed()
{
#if !ENABLE_CANVAS_GUI_REFACTORING
view3D->enable_toolbar_item("delete", can_delete_object());
view3D->enable_toolbar_item("more", can_increase_instances());
view3D->enable_toolbar_item("fewer", can_decrease_instances());
view3D->enable_toolbar_item("splitobjects", can_split());
view3D->enable_toolbar_item("splitvolumes", printer_technology == ptFFF && can_split());
#endif // !ENABLE_CANVAS_GUI_REFACTORING
// if the selection is not valid to allow for layer editing, we need to turn off the tool if it is running
bool enable_layer_editing = layers_height_allowed();
if (!enable_layer_editing && view3D->is_layers_editing_enabled()) {
@ -1836,22 +1813,12 @@ void Plater::priv::selection_changed()
on_action_layersediting(evt);
}
#if !ENABLE_CANVAS_GUI_REFACTORING
view3D->enable_toolbar_item("layersediting", enable_layer_editing);
#endif // !ENABLE_CANVAS_GUI_REFACTORING
// forces a frame render to update the view (to avoid a missed update if, for example, the context menu appears)
view3D->render();
}
void Plater::priv::object_list_changed()
{
#if !ENABLE_CANVAS_GUI_REFACTORING
// 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());
#endif // !ENABLE_CANVAS_GUI_REFACTORING
const bool export_in_progress = this->background_process.is_export_scheduled(); // || ! send_gcode_file.empty());
// XXX: is this right?
const bool model_fits = view3D->check_volumes_outside_state() == ModelInstance::PVS_Inside;
@ -1930,11 +1897,6 @@ void Plater::priv::arrange()
wxBusyCursor wait;
#if !ENABLE_CANVAS_GUI_REFACTORING
// Disable the arrange button (to prevent reentrancies, we will call wxYied)
view3D->enable_toolbar_item("arrange", can_arrange());
#endif // !ENABLE_CANVAS_GUI_REFACTORING
this->background_process.stop();
unsigned count = 0;
for(auto obj : model.objects) count += obj->instances.size();
@ -2005,11 +1967,6 @@ void Plater::priv::arrange()
statusbar()->set_cancel_callback(); // remove cancel button
arranging.store(false);
#if !ENABLE_CANVAS_GUI_REFACTORING
// We enable back the arrange button
view3D->enable_toolbar_item("arrange", can_arrange());
#endif // !ENABLE_CANVAS_GUI_REFACTORING
// Do a full refresh of scene tree, including regenerating all the GLVolumes.
//FIXME The update function shall just reload the modified matrices.
update(true);
@ -2570,12 +2527,6 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
void Plater::priv::on_layer_editing_toggled(bool enable)
{
view3D->enable_layers_editing(enable);
#if !ENABLE_CANVAS_GUI_REFACTORING
if (enable && !view3D->is_layers_editing_enabled()) {
// Initialization of the OpenGL shaders failed. Disable the tool.
view3D->enable_toolbar_item("layersediting", false);
}
#endif // !ENABLE_CANVAS_GUI_REFACTORING
view3D->set_as_dirty();
}
@ -2597,14 +2548,7 @@ void Plater::priv::on_action_split_volumes(SimpleEvent&)
void Plater::priv::on_action_layersediting(SimpleEvent&)
{
#if ENABLE_CANVAS_GUI_REFACTORING
view3D->enable_layers_editing(!view3D->is_layers_editing_enabled());
#else
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);
#endif // ENABLE_CANVAS_GUI_REFACTORING
}
void Plater::priv::on_object_select(SimpleEvent& evt)
@ -2764,11 +2708,7 @@ bool Plater::priv::init_common_menu(wxMenu* menu, const bool is_part/* = false*/
if (q != nullptr)
{
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_mirror()); }, item_mirror->GetId());
#if ENABLE_CANVAS_GUI_REFACTORING
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete()); }, item_delete->GetId());
#else
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete_object()); }, item_delete->GetId());
#endif // ENABLE_CANVAS_GUI_REFACTORING
}
return true;
@ -2873,11 +2813,7 @@ void Plater::priv::init_view_toolbar()
#endif // ENABLE_SVG_ICONS
item.tooltip = GUI::L_str("3D editor view") + " [" + GUI::shortkey_ctrl_prefix() + "5]";
item.sprite_id = 0;
#if ENABLE_CANVAS_GUI_REFACTORING
item.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_3D)); };
#else
item.action_event = EVT_GLVIEWTOOLBAR_3D;
#endif // ENABLE_CANVAS_GUI_REFACTORING
item.is_toggable = false;
if (!view_toolbar.add_item(item))
return;
@ -2888,67 +2824,21 @@ void Plater::priv::init_view_toolbar()
#endif // ENABLE_SVG_ICONS
item.tooltip = GUI::L_str("Preview") + " [" + GUI::shortkey_ctrl_prefix() + "6]";
item.sprite_id = 1;
#if ENABLE_CANVAS_GUI_REFACTORING
item.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW)); };
#else
item.action_event = EVT_GLVIEWTOOLBAR_PREVIEW;
#endif // ENABLE_CANVAS_GUI_REFACTORING
item.is_toggable = false;
if (!view_toolbar.add_item(item))
return;
#if !ENABLE_CANVAS_GUI_REFACTORING
view_toolbar.enable_item("3D");
view_toolbar.enable_item("Preview");
#endif // !ENABLE_CANVAS_GUI_REFACTORING
view_toolbar.select_item("3D");
view_toolbar.set_enabled(true);
}
#if !ENABLE_CANVAS_GUI_REFACTORING
bool Plater::priv::can_delete_object() const
{
int obj_idx = get_selected_object_idx();
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size());
}
bool Plater::priv::can_increase_instances() const
{
int obj_idx = get_selected_object_idx();
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size());
}
#endif // !ENABLE_CANVAS_GUI_REFACTORING
bool Plater::priv::can_set_instance_to_object() const
{
const int obj_idx = get_selected_object_idx();
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && (model.objects[obj_idx]->instances.size() > 1);
}
#if !ENABLE_CANVAS_GUI_REFACTORING
bool Plater::priv::can_decrease_instances() const
{
int obj_idx = get_selected_object_idx();
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && (model.objects[obj_idx]->instances.size() > 1);
}
bool Plater::priv::can_split_to_objects() const
{
int obj_idx = get_selected_object_idx();
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && !model.objects[obj_idx]->is_multiparts();
}
bool Plater::priv::can_split_to_volumes() const
{
if (printer_technology == ptSLA)
return false;
// int obj_idx = get_selected_object_idx();
// return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && !model.objects[obj_idx]->is_multiparts();
return sidebar->obj_list()->is_splittable();
}
#endif // !ENABLE_CANVAS_GUI_REFACTORING
bool Plater::priv::can_split() const
{
return sidebar->obj_list()->is_splittable();
@ -2960,18 +2850,6 @@ bool Plater::priv::layers_height_allowed() const
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && config->opt_bool("variable_layer_height") && view3D->is_layers_editing_allowed();
}
#if !ENABLE_CANVAS_GUI_REFACTORING
bool Plater::priv::can_delete_all() const
{
return !model.objects.empty();
}
bool Plater::priv::can_arrange() const
{
return !model.objects.empty() && !arranging.load();
}
#endif // !ENABLE_CANVAS_GUI_REFACTORING
bool Plater::priv::can_mirror() const
{
return get_selection().is_from_single_instance();
@ -2987,7 +2865,6 @@ void Plater::priv::set_bed_shape(const Pointfs& shape)
}
}
#if ENABLE_CANVAS_GUI_REFACTORING
bool Plater::priv::can_delete() const
{
return !get_selection().is_empty();
@ -3029,15 +2906,10 @@ bool Plater::priv::can_layers_editing() const
{
return layers_height_allowed();
}
#endif // ENABLE_CANVAS_GUI_REFACTORING
void Plater::priv::update_object_menu()
{
sidebar->obj_list()->append_menu_items_add_volume(&object_menu);
#if !ENABLE_CANVAS_GUI_REFACTORING
if (view3D != nullptr)
view3D->update_toolbar_items_visibility();
#endif // !ENABLE_CANVAS_GUI_REFACTORING
}
void Plater::priv::show_action_buttons(const bool is_ready_to_slice) const
@ -3520,17 +3392,9 @@ 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_CANVAS_GUI_REFACTORING
p->view3D->enable_toolbar_item("layersediting", false);
#endif // !ENABLE_CANVAS_GUI_REFACTORING
p->view3D->enable_layers_editing(false);
p->view3D->set_as_dirty();
}
#if !ENABLE_CANVAS_GUI_REFACTORING
else if (p->view3D->is_layers_editing_allowed()) {
p->view3D->enable_toolbar_item("layersediting", true);
}
#endif // !ENABLE_CANVAS_GUI_REFACTORING
}
else if(opt_key == "extruder_colour") {
update_scheduled = true;
@ -3652,7 +3516,6 @@ void Plater::fix_through_netfabb(const int obj_idx, const int vol_idx/* = -1*/)
void Plater::update_object_menu() { p->update_object_menu(); }
#if ENABLE_CANVAS_GUI_REFACTORING
bool Plater::can_delete() const { return p->can_delete(); }
bool Plater::can_delete_all() const { return p->can_delete_all(); }
bool Plater::can_increase_instances() const { return p->can_increase_instances(); }
@ -3661,6 +3524,5 @@ bool Plater::can_split_to_objects() const { return p->can_split_to_objects(); }
bool Plater::can_split_to_volumes() const { return p->can_split_to_volumes(); }
bool Plater::can_arrange() const { return p->can_arrange(); }
bool Plater::can_layers_editing() const { return p->can_layers_editing(); }
#endif // ENABLE_CANVAS_GUI_REFACTORING
}} // namespace Slic3r::GUI