mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge branch 'master' into tm_arrange_selection
This commit is contained in:
commit
8d66b51e8c
31 changed files with 1156 additions and 441 deletions
|
@ -1202,7 +1202,8 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar
|
|||
, m_bed(bed)
|
||||
, m_camera(camera)
|
||||
, m_view_toolbar(view_toolbar)
|
||||
, m_toolbar(GLToolbar::Normal, "Top")
|
||||
, m_main_toolbar(GLToolbar::Normal, "Top")
|
||||
, m_undoredo_toolbar(GLToolbar::Normal, "Top")
|
||||
, m_gizmos(*this)
|
||||
, m_use_clipping_planes(false)
|
||||
, m_sidebar_field("")
|
||||
|
@ -1309,7 +1310,7 @@ bool GLCanvas3D::init()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (m_toolbar.is_enabled() && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs"))
|
||||
if (m_main_toolbar.is_enabled() && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs"))
|
||||
{
|
||||
std::cout << "Unable to initialize variable_layer_height shader: please, check that the files variable_layer_height.vs and variable_layer_height.fs are available" << std::endl;
|
||||
return false;
|
||||
|
@ -1323,7 +1324,7 @@ bool GLCanvas3D::init()
|
|||
if (m_gizmos.is_enabled() && !m_gizmos.init())
|
||||
std::cout << "Unable to initialize gizmos: please, check that all the required textures are available" << std::endl;
|
||||
|
||||
if (!_init_toolbar())
|
||||
if (!_init_toolbars())
|
||||
return false;
|
||||
|
||||
if (m_selection.is_enabled() && !m_selection.init())
|
||||
|
@ -1514,9 +1515,14 @@ void GLCanvas3D::enable_selection(bool enable)
|
|||
m_selection.set_enabled(enable);
|
||||
}
|
||||
|
||||
void GLCanvas3D::enable_toolbar(bool enable)
|
||||
void GLCanvas3D::enable_main_toolbar(bool enable)
|
||||
{
|
||||
m_toolbar.set_enabled(enable);
|
||||
m_main_toolbar.set_enabled(enable);
|
||||
}
|
||||
|
||||
void GLCanvas3D::enable_undoredo_toolbar(bool enable)
|
||||
{
|
||||
m_undoredo_toolbar.set_enabled(enable);
|
||||
}
|
||||
|
||||
void GLCanvas3D::enable_dynamic_background(bool enable)
|
||||
|
@ -1852,6 +1858,10 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
PrinterTechnology printer_technology = m_process->current_printer_technology();
|
||||
int volume_idx_wipe_tower_old = -1;
|
||||
|
||||
if (printer_technology == ptSLA)
|
||||
// Always do the full refresh in SLA mode to show / hide SLA support structures when an object is moved outside / inside the build volume.
|
||||
m_regenerate_volumes = true;
|
||||
|
||||
if (m_regenerate_volumes)
|
||||
{
|
||||
// Release invalidated volumes to conserve GPU memory in case of delayed refresh (see m_reload_delayed).
|
||||
|
@ -1884,7 +1894,10 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
state.step[istep].state = PrintStateBase::INVALID;
|
||||
else
|
||||
for (const ModelInstance *model_instance : print_object->model_object()->instances)
|
||||
aux_volume_state.emplace_back(state.step[istep].timestamp, model_instance->id());
|
||||
// Only the instances, which are currently printable, will have the SLA support structures kept.
|
||||
// The instances outside the print bed will have the GLVolumes of their support structures released.
|
||||
if (model_instance->is_printable())
|
||||
aux_volume_state.emplace_back(state.step[istep].timestamp, model_instance->id());
|
||||
}
|
||||
}
|
||||
sla_support_state.emplace_back(state);
|
||||
|
@ -2036,7 +2049,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
|
||||
// Shift-up all volumes of the object so that it has the right elevation with respect to the print bed
|
||||
for (GLVolume* volume : m_volumes.volumes)
|
||||
volume->set_sla_shift_z(shift_zs[volume->object_idx()]);
|
||||
if (volume->object_idx() < m_model->objects.size() && m_model->objects[volume->object_idx()]->instances[volume->instance_idx()]->is_printable())
|
||||
volume->set_sla_shift_z(shift_zs[volume->object_idx()]);
|
||||
}
|
||||
|
||||
if (printer_technology == ptFFF && m_config->has("nozzle_diameter"))
|
||||
|
@ -2192,7 +2206,8 @@ void GLCanvas3D::load_sla_preview()
|
|||
if ((m_canvas != nullptr) && (print != nullptr))
|
||||
{
|
||||
_set_current();
|
||||
_load_sla_shells();
|
||||
// Reload the SLA support structures into GLVolumes.
|
||||
this->reload_scene(true, true);
|
||||
_update_sla_shells_outside_state();
|
||||
_show_warning_texture_if_needed(WarningTexture::SlaSupportsOutside);
|
||||
}
|
||||
|
@ -2295,7 +2310,8 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
|||
if (!m_initialized)
|
||||
return;
|
||||
|
||||
m_dirty |= m_toolbar.update_items_state();
|
||||
m_dirty |= m_main_toolbar.update_items_state();
|
||||
m_dirty |= m_undoredo_toolbar.update_items_state();
|
||||
m_dirty |= m_view_toolbar.update_items_state();
|
||||
|
||||
if (!m_dirty)
|
||||
|
@ -2674,7 +2690,15 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
#endif /* SLIC3R_DEBUG_MOUSE_EVENTS */
|
||||
}
|
||||
|
||||
if (m_toolbar.on_mouse(evt, *this))
|
||||
if (m_main_toolbar.on_mouse(evt, *this))
|
||||
{
|
||||
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
|
||||
mouse_up_cleanup();
|
||||
m_mouse.set_start_position_3D_as_invalid();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_undoredo_toolbar.on_mouse(evt, *this))
|
||||
{
|
||||
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
|
||||
mouse_up_cleanup();
|
||||
|
@ -3015,7 +3039,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
tooltip = m_gizmos.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_toolbar.get_tooltip();
|
||||
tooltip = m_main_toolbar.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_undoredo_toolbar.get_tooltip();
|
||||
|
||||
if (tooltip.empty())
|
||||
tooltip = m_view_toolbar.get_tooltip();
|
||||
|
@ -3468,16 +3495,19 @@ void GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
|
|||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||
|
||||
const float x = pos_x * (float)get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width();
|
||||
imgui->set_next_window_pos(x, m_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
imgui->set_next_window_bg_alpha(0.5f);
|
||||
imgui->begin(wxString::Format(_(L("%s Stack")), stack_name),
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
int hovered = m_imgui_undo_redo_hovered_pos;
|
||||
int selected = -1;
|
||||
const float em = static_cast<float>(wxGetApp().em_unit());
|
||||
float em = static_cast<float>(wxGetApp().em_unit());
|
||||
#if ENABLE_RETINA_GL
|
||||
em *= m_retina_helper->get_scale_factor();
|
||||
#endif
|
||||
|
||||
if (imgui->undo_redo_list(ImVec2(12 * em, 20 * em), is_undo, &string_getter, hovered, selected))
|
||||
if (imgui->undo_redo_list(ImVec2(18 * em, 26 * em), is_undo, &string_getter, hovered, selected))
|
||||
m_imgui_undo_redo_hovered_pos = hovered;
|
||||
else
|
||||
m_imgui_undo_redo_hovered_pos = -1;
|
||||
|
@ -3490,9 +3520,20 @@ void GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
|
|||
imgui->end();
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_init_toolbar()
|
||||
bool GLCanvas3D::_init_toolbars()
|
||||
{
|
||||
if (!m_toolbar.is_enabled())
|
||||
if (!_init_main_toolbar())
|
||||
return false;
|
||||
|
||||
if (!_init_undoredo_toolbar())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_init_main_toolbar()
|
||||
{
|
||||
if (!m_main_toolbar.is_enabled())
|
||||
return true;
|
||||
|
||||
BackgroundTexture::Metadata background_data;
|
||||
|
@ -3502,19 +3543,19 @@ bool GLCanvas3D::_init_toolbar()
|
|||
background_data.right = 16;
|
||||
background_data.bottom = 16;
|
||||
|
||||
if (!m_toolbar.init(background_data))
|
||||
if (!m_main_toolbar.init(background_data))
|
||||
{
|
||||
// unable to init the toolbar texture, disable it
|
||||
m_toolbar.set_enabled(false);
|
||||
m_main_toolbar.set_enabled(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// m_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
m_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
||||
m_toolbar.set_layout_orientation(GLToolbar::Layout::Top);
|
||||
m_toolbar.set_border(5.0f);
|
||||
m_toolbar.set_separator_size(5);
|
||||
m_toolbar.set_gap_size(2);
|
||||
// m_main_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
m_main_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
||||
m_main_toolbar.set_layout_orientation(GLToolbar::Layout::Top);
|
||||
m_main_toolbar.set_border(5.0f);
|
||||
m_main_toolbar.set_separator_size(5);
|
||||
m_main_toolbar.set_gap_size(2);
|
||||
|
||||
GLToolbarItem::Data item;
|
||||
|
||||
|
@ -3523,7 +3564,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.tooltip = _utf8(L("Add...")) + " [" + GUI::shortkey_ctrl_prefix() + "I]";
|
||||
item.sprite_id = 0;
|
||||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "delete";
|
||||
|
@ -3532,7 +3573,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.sprite_id = 1;
|
||||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE)); };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "deleteall";
|
||||
|
@ -3541,7 +3582,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.sprite_id = 2;
|
||||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete_all(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "arrange";
|
||||
|
@ -3550,10 +3591,10 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.sprite_id = 3;
|
||||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ARRANGE)); };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_arrange(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_toolbar.add_separator())
|
||||
if (!m_main_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
item.name = "copy";
|
||||
|
@ -3562,7 +3603,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.sprite_id = 4;
|
||||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_COPY)); };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_copy_to_clipboard(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "paste";
|
||||
|
@ -3571,10 +3612,10 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.sprite_id = 5;
|
||||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_PASTE)); };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_paste_from_clipboard(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_toolbar.add_separator())
|
||||
if (!m_main_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
item.name = "more";
|
||||
|
@ -3585,7 +3626,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_increase_instances(); };
|
||||
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "fewer";
|
||||
|
@ -3595,10 +3636,10 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_FEWER)); };
|
||||
item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_decrease_instances(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_toolbar.add_separator())
|
||||
if (!m_main_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
item.name = "splitobjects";
|
||||
|
@ -3608,7 +3649,7 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_OBJECTS)); };
|
||||
item.visibility_callback = GLToolbarItem::Default_Visibility_Callback;
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_objects(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "splitvolumes";
|
||||
|
@ -3618,10 +3659,10 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_VOLUMES)); };
|
||||
item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_volumes(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_toolbar.add_separator())
|
||||
if (!m_main_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
item.name = "layersediting";
|
||||
|
@ -3632,16 +3673,44 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); };
|
||||
item.visibility_callback = [this]()->bool { return m_process->current_printer_technology() == ptFFF; };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_layers_editing(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_toolbar.add_separator())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_init_undoredo_toolbar()
|
||||
{
|
||||
if (!m_undoredo_toolbar.is_enabled())
|
||||
return true;
|
||||
|
||||
BackgroundTexture::Metadata background_data;
|
||||
background_data.filename = "toolbar_background.png";
|
||||
background_data.left = 16;
|
||||
background_data.top = 16;
|
||||
background_data.right = 16;
|
||||
background_data.bottom = 16;
|
||||
|
||||
if (!m_undoredo_toolbar.init(background_data))
|
||||
{
|
||||
// unable to init the toolbar texture, disable it
|
||||
m_undoredo_toolbar.set_enabled(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
||||
m_undoredo_toolbar.set_layout_orientation(GLToolbar::Layout::Top);
|
||||
m_undoredo_toolbar.set_border(5.0f);
|
||||
m_undoredo_toolbar.set_separator_size(5);
|
||||
m_undoredo_toolbar.set_gap_size(2);
|
||||
|
||||
GLToolbarItem::Data item;
|
||||
|
||||
item.name = "undo";
|
||||
item.icon_filename = "undo_toolbar.svg";
|
||||
item.tooltip = _utf8(L("Undo")) + " [" + GUI::shortkey_ctrl_prefix() + "Z]";
|
||||
item.sprite_id = 11;
|
||||
item.sprite_id = 0;
|
||||
item.left.toggable = false;
|
||||
item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_UNDO)); };
|
||||
item.right.toggable = true;
|
||||
|
@ -3649,18 +3718,18 @@ bool GLCanvas3D::_init_toolbar()
|
|||
item.right.render_callback = [this](float left, float right, float, float) { if (m_canvas != nullptr) _render_undo_redo_stack(true, 0.5f * (left + right)); };
|
||||
item.visibility_callback = []()->bool { return true; };
|
||||
item.enabling_callback = [this]()->bool { return wxGetApp().plater()->can_undo(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_undoredo_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
item.name = "redo";
|
||||
item.icon_filename = "redo_toolbar.svg";
|
||||
item.tooltip = _utf8(L("Redo")) + " [" + GUI::shortkey_ctrl_prefix() + "Y]";
|
||||
item.sprite_id = 12;
|
||||
item.sprite_id = 1;
|
||||
item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_REDO)); };
|
||||
item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; };
|
||||
item.right.render_callback = [this](float left, float right, float, float) { if (m_canvas != nullptr) _render_undo_redo_stack(false, 0.5f * (left + right)); };
|
||||
item.enabling_callback = [this]()->bool { return wxGetApp().plater()->can_redo(); };
|
||||
if (!m_toolbar.add_item(item))
|
||||
if (!m_undoredo_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -3991,7 +4060,8 @@ void GLCanvas3D::_render_overlays() const
|
|||
_render_gizmos_overlay();
|
||||
_render_warning_texture();
|
||||
_render_legend_texture();
|
||||
_render_toolbar();
|
||||
_render_main_toolbar();
|
||||
_render_undoredo_toolbar();
|
||||
_render_view_toolbar();
|
||||
|
||||
if ((m_layers_editing.last_object_id >= 0) && (m_layers_editing.object_max_z() > 0.0f))
|
||||
|
@ -4081,64 +4151,57 @@ void GLCanvas3D::_render_gizmos_overlay() const
|
|||
m_gizmos.render_overlay();
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_toolbar() const
|
||||
void GLCanvas3D::_render_main_toolbar() const
|
||||
{
|
||||
if (!m_main_toolbar.is_enabled())
|
||||
return;
|
||||
|
||||
#if ENABLE_RETINA_GL
|
||||
// m_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||
// m_main_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true);
|
||||
m_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
||||
m_main_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
||||
#else
|
||||
// m_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
// m_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
||||
// m_main_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
// m_main_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
||||
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true));
|
||||
m_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
||||
m_main_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
Size cnv_size = get_canvas_size();
|
||||
float zoom = (float)m_camera.get_zoom();
|
||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
|
||||
GLToolbar::Layout::EOrientation orientation = m_toolbar.get_layout_orientation();
|
||||
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width()) * inv_zoom;
|
||||
|
||||
float top = 0.0f;
|
||||
float left = 0.0f;
|
||||
switch (m_toolbar.get_layout_type())
|
||||
{
|
||||
default:
|
||||
case GLToolbar::Layout::Horizontal:
|
||||
{
|
||||
// centers the toolbar on the top edge of the 3d scene
|
||||
if (orientation == GLToolbar::Layout::Top)
|
||||
{
|
||||
top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
left = -0.5f * m_toolbar.get_width() * inv_zoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar.get_height()) * inv_zoom;
|
||||
left = -0.5f * m_toolbar.get_width() * inv_zoom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GLToolbar::Layout::Vertical:
|
||||
{
|
||||
// centers the toolbar on the right edge of the 3d scene
|
||||
if (orientation == GLToolbar::Layout::Left)
|
||||
{
|
||||
top = 0.5f * m_toolbar.get_height() * inv_zoom;
|
||||
left = (-0.5f * (float)cnv_size.get_width()) * inv_zoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
top = 0.5f * m_toolbar.get_height() * inv_zoom;
|
||||
left = (0.5f * (float)cnv_size.get_width() - m_toolbar.get_width()) * inv_zoom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_toolbar.set_position(top, left);
|
||||
m_main_toolbar.set_position(top, left);
|
||||
m_main_toolbar.render(*this);
|
||||
}
|
||||
|
||||
m_toolbar.render(*this);
|
||||
void GLCanvas3D::_render_undoredo_toolbar() const
|
||||
{
|
||||
if (!m_undoredo_toolbar.is_enabled())
|
||||
return;
|
||||
|
||||
#if ENABLE_RETINA_GL
|
||||
// m_undoredo_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true);
|
||||
m_undoredo_toolbar.set_scale(scale); //! #ys_FIXME_experiment
|
||||
#else
|
||||
// m_undoredo_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
// m_undoredo_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
|
||||
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true));
|
||||
m_undoredo_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
Size cnv_size = get_canvas_size();
|
||||
float zoom = (float)m_camera.get_zoom();
|
||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
|
||||
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
float left = (m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width())) * inv_zoom;
|
||||
m_undoredo_toolbar.set_position(top, left);
|
||||
m_undoredo_toolbar.render(*this);
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_view_toolbar() const
|
||||
|
@ -5395,56 +5458,6 @@ void GLCanvas3D::_load_fff_shells()
|
|||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::_load_sla_shells()
|
||||
{
|
||||
//FIXME use reload_scene
|
||||
#if 1
|
||||
const SLAPrint* print = this->sla_print();
|
||||
if (print->objects().empty())
|
||||
// nothing to render, return
|
||||
return;
|
||||
|
||||
auto add_volume = [this](const SLAPrintObject &object, int volume_id, const SLAPrintObject::Instance& instance,
|
||||
const TriangleMesh &mesh, const float color[4], bool outside_printer_detection_enabled) {
|
||||
m_volumes.volumes.emplace_back(new GLVolume(color));
|
||||
GLVolume& v = *m_volumes.volumes.back();
|
||||
v.indexed_vertex_array.load_mesh(mesh);
|
||||
v.shader_outside_printer_detection_enabled = outside_printer_detection_enabled;
|
||||
v.composite_id.volume_id = volume_id;
|
||||
v.set_instance_offset(unscale(instance.shift(0), instance.shift(1), 0));
|
||||
v.set_instance_rotation(Vec3d(0.0, 0.0, (double)instance.rotation));
|
||||
v.set_instance_mirror(X, object.is_left_handed() ? -1. : 1.);
|
||||
v.set_convex_hull(mesh.convex_hull_3d());
|
||||
};
|
||||
|
||||
// adds objects' volumes
|
||||
for (const SLAPrintObject* obj : print->objects())
|
||||
if (obj->is_step_done(slaposSliceSupports)) {
|
||||
unsigned int initial_volumes_count = (unsigned int)m_volumes.volumes.size();
|
||||
for (const SLAPrintObject::Instance& instance : obj->instances()) {
|
||||
add_volume(*obj, 0, instance, obj->transformed_mesh(), GLVolume::MODEL_COLOR[0], true);
|
||||
// Set the extruder_id and volume_id to achieve the same color as in the 3D scene when
|
||||
// through the update_volumes_colors_by_extruder() call.
|
||||
m_volumes.volumes.back()->extruder_id = obj->model_object()->volumes.front()->extruder_id();
|
||||
if (obj->is_step_done(slaposSupportTree) && obj->has_mesh(slaposSupportTree))
|
||||
add_volume(*obj, -int(slaposSupportTree), instance, obj->support_mesh(), GLVolume::SLA_SUPPORT_COLOR, true);
|
||||
if (obj->is_step_done(slaposBasePool) && obj->has_mesh(slaposBasePool))
|
||||
add_volume(*obj, -int(slaposBasePool), instance, obj->pad_mesh(), GLVolume::SLA_PAD_COLOR, false);
|
||||
}
|
||||
double shift_z = obj->get_current_elevation();
|
||||
for (unsigned int i = initial_volumes_count; i < m_volumes.volumes.size(); ++ i) {
|
||||
GLVolume& v = *m_volumes.volumes[i];
|
||||
// apply shift z
|
||||
v.set_sla_shift_z(shift_z);
|
||||
}
|
||||
}
|
||||
|
||||
update_volumes_colors_by_extruder();
|
||||
#else
|
||||
this->reload_scene(true, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLCanvas3D::_update_gcode_volumes_visibility(const GCodePreviewData& preview_data)
|
||||
{
|
||||
unsigned int size = (unsigned int)m_gcode_preview_volume_index.first_volumes.size();
|
||||
|
@ -5660,14 +5673,14 @@ void GLCanvas3D::_update_selection_from_hover()
|
|||
|
||||
bool GLCanvas3D::_deactivate_undo_redo_toolbar_items()
|
||||
{
|
||||
if (m_toolbar.is_item_pressed("undo"))
|
||||
if (m_undoredo_toolbar.is_item_pressed("undo"))
|
||||
{
|
||||
m_toolbar.force_right_action(m_toolbar.get_item_id("undo"), *this);
|
||||
m_undoredo_toolbar.force_right_action(m_undoredo_toolbar.get_item_id("undo"), *this);
|
||||
return true;
|
||||
}
|
||||
else if (m_toolbar.is_item_pressed("redo"))
|
||||
else if (m_undoredo_toolbar.is_item_pressed("redo"))
|
||||
{
|
||||
m_toolbar.force_right_action(m_toolbar.get_item_id("redo"), *this);
|
||||
m_undoredo_toolbar.force_right_action(m_undoredo_toolbar.get_item_id("redo"), *this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue