Merge remote-tracking branch 'origin/master' into custom_gcodes

This commit is contained in:
YuSanka 2020-06-08 12:27:29 +02:00
commit befbd6b0fe
35 changed files with 821 additions and 262 deletions

View file

@ -40,12 +40,19 @@
#include <Eigen/Dense>
#ifdef HAS_GLSAFE
void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name)
void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char* function_name)
{
#if defined(NDEBUG) && ENABLE_OPENGL_ERROR_LOGGING
// In release mode, if OpenGL debugging was forced by ENABLE_OPENGL_ERROR_LOGGING, only show
// OpenGL errors if sufficiently high loglevel.
if (Slic3r::get_logging_level() < 5)
return;
#endif // ENABLE_OPENGL_ERROR_LOGGING
GLenum err = glGetError();
if (err == GL_NO_ERROR)
return;
const char *sErr = 0;
const char* sErr = 0;
switch (err) {
case GL_INVALID_ENUM: sErr = "Invalid Enum"; break;
case GL_INVALID_VALUE: sErr = "Invalid Value"; break;
@ -56,10 +63,10 @@ void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char
case GL_OUT_OF_MEMORY: sErr = "Out Of Memory"; break;
default: sErr = "Unknown"; break;
}
BOOST_LOG_TRIVIAL(error) << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr;
BOOST_LOG_TRIVIAL(error) << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr;
assert(false);
}
#endif
#endif // HAS_GLSAFE
namespace Slic3r {

View file

@ -10,20 +10,20 @@
#include <functional>
#ifndef NDEBUG
#define HAS_GLSAFE
#if ENABLE_OPENGL_ERROR_LOGGING || ! defined(NDEBUG)
#define HAS_GLSAFE
#endif
#ifdef HAS_GLSAFE
extern void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name);
inline void glAssertRecentCall() { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); }
#define glsafe(cmd) do { cmd; glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
#define glcheck() do { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
#else
inline void glAssertRecentCall() { }
#define glsafe(cmd) cmd
#define glcheck()
#endif
extern void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name);
inline void glAssertRecentCall() { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); }
#define glsafe(cmd) do { cmd; glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
#define glcheck() do { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
#else // HAS_GLSAFE
inline void glAssertRecentCall() { }
#define glsafe(cmd) cmd
#define glcheck()
#endif // HAS_GLSAFE
namespace Slic3r {
namespace GUI {

View file

@ -1534,9 +1534,8 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
, m_retina_helper(nullptr)
#endif
, m_in_render(false)
, m_main_toolbar(GLToolbar::Normal, "Top")
, m_undoredo_toolbar(GLToolbar::Normal, "Top")
, m_collapse_toolbar(GLToolbar::Normal, "Top")
, m_main_toolbar(GLToolbar::Normal, "Main")
, m_undoredo_toolbar(GLToolbar::Normal, "Undo_Redo")
, m_gizmos(*this)
, m_use_clipping_planes(false)
, m_sidebar_field("")
@ -1914,11 +1913,6 @@ void GLCanvas3D::enable_undoredo_toolbar(bool enable)
m_undoredo_toolbar.set_enabled(enable);
}
void GLCanvas3D::enable_collapse_toolbar(bool enable)
{
m_collapse_toolbar.set_enabled(enable);
}
void GLCanvas3D::enable_dynamic_background(bool enable)
{
m_dynamic_background_enabled = enable;
@ -2112,7 +2106,7 @@ void GLCanvas3D::render()
tooltip = m_undoredo_toolbar.get_tooltip();
if (tooltip.empty())
tooltip = m_collapse_toolbar.get_tooltip();
tooltip = wxGetApp().plater()->get_collapse_toolbar().get_tooltip();
if (tooltip.empty())
tooltip = wxGetApp().plater()->get_view_toolbar().get_tooltip();
@ -2854,8 +2848,8 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
m_dirty |= m_main_toolbar.update_items_state();
m_dirty |= m_undoredo_toolbar.update_items_state();
m_dirty |= m_collapse_toolbar.update_items_state();
m_dirty |= wxGetApp().plater()->get_view_toolbar().update_items_state();
m_dirty |= wxGetApp().plater()->get_collapse_toolbar().update_items_state();
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(wxGetApp().plater()->get_camera());
m_dirty |= mouse3d_controller_applied;
@ -3473,7 +3467,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
return;
}
if (m_collapse_toolbar.on_mouse(evt, *this))
if (wxGetApp().plater()->get_collapse_toolbar().on_mouse(evt, *this))
{
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
mouse_up_cleanup();
@ -4187,7 +4181,7 @@ void GLCanvas3D::update_ui_from_settings()
#endif // ENABLE_RETINA_GL
bool enable_collapse = wxGetApp().app_config->get("show_collapse_button") == "1";
enable_collapse_toolbar(enable_collapse);
wxGetApp().plater()->get_collapse_toolbar().set_enabled(enable_collapse);
}
@ -5055,51 +5049,7 @@ bool GLCanvas3D::_init_view_toolbar()
bool GLCanvas3D::_init_collapse_toolbar()
{
if (!m_collapse_toolbar.is_enabled() && m_collapse_toolbar.get_items_count() > 0)
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_collapse_toolbar.init(background_data))
{
// unable to init the toolbar texture, disable it
m_collapse_toolbar.set_enabled(false);
return true;
}
m_collapse_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
m_collapse_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
m_collapse_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
m_collapse_toolbar.set_border(5.0f);
m_collapse_toolbar.set_separator_size(5);
m_collapse_toolbar.set_gap_size(2);
GLToolbarItem::Data item;
item.name = "collapse_sidebar";
item.icon_filename = "collapse.svg";
item.tooltip = wxGetApp().plater()->is_sidebar_collapsed() ? _utf8(L("Expand right panel")) : _utf8(L("Collapse right panel"));
item.sprite_id = 0;
item.left.action_callback = [this, item]() {
std::string new_tooltip = wxGetApp().plater()->is_sidebar_collapsed() ?
_utf8(L("Collapse right panel")) : _utf8(L("Expand right panel"));
int id = m_collapse_toolbar.get_item_id("collapse_sidebar");
m_collapse_toolbar.set_tooltip(id, new_tooltip);
set_tooltip("");
wxGetApp().plater()->collapse_sidebar(!wxGetApp().plater()->is_sidebar_collapsed());
};
if (!m_collapse_toolbar.add_item(item))
return false;
return true;
return wxGetApp().plater()->init_collapse_toolbar();
}
bool GLCanvas3D::_set_current()
@ -5427,20 +5377,21 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() const
float size = GLToolbar::Default_Icons_Size * scale;
// Set current size for all top toolbars. It will be used for next calculations
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
#if ENABLE_RETINA_GL
const float sc = m_retina_helper->get_scale_factor() * scale;
m_main_toolbar.set_scale(sc);
m_undoredo_toolbar.set_scale(sc);
m_collapse_toolbar.set_scale(sc);
collapse_toolbar.set_scale(sc);
size *= m_retina_helper->get_scale_factor();
#else
m_main_toolbar.set_icons_size(size);
m_undoredo_toolbar.set_icons_size(size);
m_collapse_toolbar.set_icons_size(size);
collapse_toolbar.set_icons_size(size);
#endif // ENABLE_RETINA_GL
float top_tb_width = m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + m_collapse_toolbar.get_width();
int items_cnt = m_main_toolbar.get_visible_items_cnt() + m_undoredo_toolbar.get_visible_items_cnt() + m_collapse_toolbar.get_visible_items_cnt();
float top_tb_width = m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar.get_width();
int items_cnt = m_main_toolbar.get_visible_items_cnt() + m_undoredo_toolbar.get_visible_items_cnt() + collapse_toolbar.get_visible_items_cnt();
float noitems_width = top_tb_width - size * items_cnt; // width of separators and borders in top toolbars
// calculate scale needed for items in all top toolbars
@ -5460,7 +5411,6 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() const
wxGetApp().set_auto_toolbar_icon_scale(new_scale);
}
void GLCanvas3D::_render_overlays() const
{
glsafe(::glDisable(GL_DEPTH_TEST));
@ -5485,12 +5435,12 @@ void GLCanvas3D::_render_overlays() const
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(/*true*/);
m_main_toolbar.set_scale(scale);
m_undoredo_toolbar.set_scale(scale);
m_collapse_toolbar.set_scale(scale);
wxGetApp().plater()->get_collapse_toolbar().set_scale(scale);
#else
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(/*true*/));
m_main_toolbar.set_icons_size(size);
m_undoredo_toolbar.set_icons_size(size);
m_collapse_toolbar.set_icons_size(size);
wxGetApp().plater()->get_collapse_toolbar().set_icons_size(size);
#endif // ENABLE_RETINA_GL
_render_main_toolbar();
@ -5594,7 +5544,8 @@ void GLCanvas3D::_render_main_toolbar() const
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
float collapse_toolbar_width = m_collapse_toolbar.is_enabled() ? m_collapse_toolbar.get_width() : 0.0f;
const GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width) * inv_zoom;
m_main_toolbar.set_position(top, left);
@ -5610,7 +5561,8 @@ void GLCanvas3D::_render_undoredo_toolbar() const
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
float collapse_toolbar_width = m_collapse_toolbar.is_enabled() ? m_collapse_toolbar.get_width() : 0.0f;
const GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
float left = (m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width)) * inv_zoom;
m_undoredo_toolbar.set_position(top, left);
m_undoredo_toolbar.render(*this);
@ -5618,8 +5570,7 @@ void GLCanvas3D::_render_undoredo_toolbar() const
void GLCanvas3D::_render_collapse_toolbar() const
{
if (!m_collapse_toolbar.is_enabled())
return;
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
Size cnv_size = get_canvas_size();
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
@ -5627,10 +5578,10 @@ void GLCanvas3D::_render_collapse_toolbar() const
float band = m_layers_editing.is_enabled() ? (wxGetApp().imgui()->get_style_scaling() * LayersEditing::THICKNESS_BAR_WIDTH) : 0.0;
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
float left = (0.5f * (float)cnv_size.get_width() - (float)m_collapse_toolbar.get_width() - band) * inv_zoom;
float left = (0.5f * (float)cnv_size.get_width() - (float)collapse_toolbar.get_width() - band) * inv_zoom;
m_collapse_toolbar.set_position(top, left);
m_collapse_toolbar.render(*this);
collapse_toolbar.set_position(top, left);
collapse_toolbar.render(*this);
}
void GLCanvas3D::_render_view_toolbar() const
@ -7164,9 +7115,10 @@ bool GLCanvas3D::_activate_search_toolbar_item()
bool GLCanvas3D::_deactivate_collapse_toolbar_items()
{
if (m_collapse_toolbar.is_item_pressed("print"))
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
if (collapse_toolbar.is_item_pressed("print"))
{
m_collapse_toolbar.force_left_action(m_collapse_toolbar.get_item_id("print"), *this);
collapse_toolbar.force_left_action(collapse_toolbar.get_item_id("print"), *this);
return true;
}

View file

@ -452,7 +452,6 @@ private:
mutable GLGizmosManager m_gizmos;
mutable GLToolbar m_main_toolbar;
mutable GLToolbar m_undoredo_toolbar;
mutable GLToolbar m_collapse_toolbar;
ClippingPlane m_clipping_planes[2];
mutable ClippingPlane m_camera_clipping_plane;
bool m_use_clipping_planes;
@ -588,7 +587,6 @@ public:
void enable_selection(bool enable);
void enable_main_toolbar(bool enable);
void enable_undoredo_toolbar(bool enable);
void enable_collapse_toolbar(bool enable);
void enable_dynamic_background(bool enable);
void enable_labels(bool enable) { m_labels.enable(enable); }
#if ENABLE_SLOPE_RENDERING

View file

@ -1238,7 +1238,7 @@ bool GLToolbar::generate_icons_texture() const
}
std::vector<std::pair<int, bool>> states;
if (m_name == "Top")
if (m_type == Normal)
{
states.push_back({ 1, false }); // Normal
states.push_back({ 0, false }); // Pressed
@ -1247,7 +1247,7 @@ bool GLToolbar::generate_icons_texture() const
states.push_back({ 0, false }); // HoverPressed
states.push_back({ 2, false }); // HoverDisabled
}
else if (m_name == "View")
else
{
states.push_back({ 1, false }); // Normal
states.push_back({ 1, true }); // Pressed

View file

@ -2506,7 +2506,6 @@ void ObjectList::merge(bool to_multipart_object)
// all objects, created from the instances will be added to the end of list
int new_objects_cnt = 0; // count of this new objects
// std::vector<int> obj_idxs;
for (auto map_item : sel_map)
{
@ -2569,22 +2568,45 @@ void ObjectList::merge(bool to_multipart_object)
new_object->name = _u8L("Merged");
DynamicPrintConfig* config = &new_object->config;
int frst_obj_idx = obj_idxs.front();
const Vec3d& main_offset = (*m_objects)[frst_obj_idx]->instances[0]->get_offset();
for (int obj_idx : obj_idxs)
{
ModelObject* object = (*m_objects)[obj_idx];
Vec3d offset = object->instances[0]->get_offset();
if (object->id() == (*m_objects)[frst_obj_idx]->id())
new_object->add_instance(*object->instances[0]);
const Geometry::Transformation& transformation = object->instances[0]->get_transformation();
Vec3d scale = transformation.get_scaling_factor();
Vec3d mirror = transformation.get_mirror();
Vec3d rotation = transformation.get_rotation();
if (object->id() == (*m_objects)[obj_idxs.front()]->id())
new_object->add_instance();
Transform3d volume_offset_correction = new_object->instances[0]->get_transformation().get_matrix().inverse() * transformation.get_matrix();
// merge volumes
for (const ModelVolume* volume : object->volumes) {
ModelVolume* new_volume = new_object->add_volume(*volume);
//set rotation
Vec3d vol_rot = new_volume->get_rotation() + rotation;
new_volume->set_rotation(vol_rot);
// set scale
Vec3d vol_sc_fact = new_volume->get_scaling_factor().cwiseProduct(scale);
new_volume->set_scaling_factor(vol_sc_fact);
// set mirror
Vec3d vol_mirror = new_volume->get_mirror().cwiseProduct(mirror);
new_volume->set_mirror(vol_mirror);
// set offset
Vec3d vol_offset = volume_offset_correction* new_volume->get_offset();
new_volume->set_offset(vol_offset);
}
// merge settings
auto new_opt_keys = config->keys();
const DynamicPrintConfig& from_config = object->config;
auto opt_keys = from_config.keys();
// merge settings
for (auto& opt_key : opt_keys) {
if (find(new_opt_keys.begin(), new_opt_keys.end(), opt_key) == new_opt_keys.end()) {
const ConfigOption* option = from_config.option(opt_key);
@ -2596,18 +2618,11 @@ void ObjectList::merge(bool to_multipart_object)
config->set_key_value(opt_key, option->clone());
}
}
// merge volumes
for (const ModelVolume* volume : object->volumes) {
ModelVolume* new_volume = new_object->add_volume(*volume);
Vec3d vol_offset = offset - main_offset + new_volume->get_offset();
new_volume->set_offset(vol_offset);
}
// save extruder value if it was set
if (object->volumes.size() == 1 && find(opt_keys.begin(), opt_keys.end(), "extruder") != opt_keys.end()) {
ModelVolume* volume = new_object->volumes.back();
const ConfigOption* option = from_config.option("extruder");
if (option)
if (option)
volume->config.set_key_value("extruder", option->clone());
}

View file

@ -13,6 +13,8 @@
#include "wxExtensions.hpp"
#include "ObjectDataViewModel.hpp"
#include "libslic3r/PrintConfig.hpp"
class wxBoxSizer;
class wxBitmapComboBox;
class wxMenuItem;

View file

@ -68,7 +68,6 @@ bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, Ba
m_canvas->enable_selection(true);
m_canvas->enable_main_toolbar(true);
m_canvas->enable_undoredo_toolbar(true);
m_canvas->enable_collapse_toolbar(true);
m_canvas->enable_labels(true);
#if ENABLE_SLOPE_RENDERING
m_canvas->enable_slope(true);
@ -222,7 +221,6 @@ bool Preview::init(wxWindow* parent, Model* model)
m_canvas->set_process(m_process);
m_canvas->enable_legend_texture(true);
m_canvas->enable_dynamic_background(true);
m_canvas->enable_collapse_toolbar(true);
m_double_slider_sizer = new wxBoxSizer(wxHORIZONTAL);
create_double_slider();

View file

@ -54,18 +54,35 @@ bool GLGizmoFdmSupports::on_init()
return true;
}
void GLGizmoFdmSupports::activate_internal_undo_redo_stack(bool activate)
{
if (activate && ! m_internal_stack_active) {
Plater::TakeSnapshot(wxGetApp().plater(), _L("FDM gizmo turned on"));
wxGetApp().plater()->enter_gizmos_stack();
m_internal_stack_active = true;
}
if (! activate && m_internal_stack_active) {
wxGetApp().plater()->leave_gizmos_stack();
Plater::TakeSnapshot(wxGetApp().plater(), _L("FDM gizmo turned off"));
m_internal_stack_active = false;
}
}
void GLGizmoFdmSupports::set_fdm_support_data(ModelObject* model_object, const Selection& selection)
{
const ModelObject* mo = m_c->selection_info() ? m_c->selection_info()->model_object() : nullptr;
if (! mo)
if (m_state != On)
return;
const ModelObject* mo = m_c->selection_info() ? m_c->selection_info()->model_object() : nullptr;
if (mo && selection.is_from_single_instance()
&& (mo->id() != m_old_mo_id || mo->volumes.size() != m_old_volumes_size))
&& (m_schedule_update || mo->id() != m_old_mo_id || mo->volumes.size() != m_old_volumes_size))
{
update_from_model_object();
m_old_mo_id = mo->id();
m_old_volumes_size = mo->volumes.size();
m_schedule_update = false;
}
}
@ -131,8 +148,10 @@ void GLGizmoFdmSupports::render_triangles(const Selection& selection) const
// Now render both enforcers and blockers.
for (int i=0; i<2; ++i) {
glsafe(::glColor4f(i ? 1.f : 0.2f, 0.2f, i ? 0.2f : 1.0f, 0.5f));
for (const GLIndexedVertexArray& iva : m_ivas[mesh_id][i])
iva.render();
for (const GLIndexedVertexArray& iva : m_ivas[mesh_id][i]) {
if (iva.has_VBOs())
iva.render();
}
}
glsafe(::glPopMatrix());
if (is_left_handed)
@ -493,6 +512,7 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
: (m_button_down == Button::Left
? _L("Add supports")
: _L("Block supports"));
activate_internal_undo_redo_stack(true);
Plater::TakeSnapshot(wxGetApp().plater(), action_name);
update_model_object();
@ -588,6 +608,8 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool overwr
update_vertex_buffers(&mv->mesh(), mesh_id, FacetSupportType::BLOCKER);
}
activate_internal_undo_redo_stack(true);
Plater::TakeSnapshot(wxGetApp().plater(), block ? _L("Block supports by angle")
: _L("Add supports by angle"));
update_model_object();
@ -778,12 +800,9 @@ void GLGizmoFdmSupports::on_set_state()
return;
if (m_state == On && m_old_state != On) { // the gizmo was just turned on
{
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("FDM gizmo turned on")));
}
if (! m_parent.get_gizmos_manager().is_serializing()) {
wxGetApp().CallAfter([]() {
wxGetApp().plater()->enter_gizmos_stack();
wxGetApp().CallAfter([this]() {
activate_internal_undo_redo_stack(true);
});
}
}
@ -793,11 +812,7 @@ void GLGizmoFdmSupports::on_set_state()
m_setting_angle = false;
m_parent.use_slope(false);
}
wxGetApp().plater()->leave_gizmos_stack();
{
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("FDM gizmo turned off")));
}
activate_internal_undo_redo_stack(false);
m_old_mo_id = -1;
m_ivas.clear();
m_selected_facets.clear();
@ -820,14 +835,19 @@ void GLGizmoFdmSupports::on_stop_dragging()
void GLGizmoFdmSupports::on_load(cereal::BinaryInputArchive& ar)
void GLGizmoFdmSupports::on_load(cereal::BinaryInputArchive&)
{
update_from_model_object();
// We should update the gizmo from current ModelObject, but it is not
// possible at this point. That would require having updated selection and
// common gizmos data, which is not done at this point. Instead, save
// a flag to do the update in set_fdm_support_data, which will be called
// soon after.
m_schedule_update = true;
}
void GLGizmoFdmSupports::on_save(cereal::BinaryOutputArchive& ar) const
void GLGizmoFdmSupports::on_save(cereal::BinaryOutputArchive&) const
{
}

View file

@ -64,6 +64,7 @@ private:
void update_model_object() const;
void update_from_model_object();
void activate_internal_undo_redo_stack(bool activate);
void select_facets_by_angle(float threshold, bool overwrite, bool block);
bool m_overwrite_selected = false;
@ -74,6 +75,8 @@ private:
float m_clipping_plane_distance = 0.f;
std::unique_ptr<ClippingPlane> m_clipping_plane;
bool m_setting_angle = false;
bool m_internal_stack_active = false;
bool m_schedule_update = false;
// This map holds all translated description texts, so they can be easily referenced during layout calculations
// etc. When language changes, GUI is recreated and this class constructed again, so the change takes effect.

View file

@ -28,8 +28,7 @@ bool GLGizmoFlatten::on_init()
void GLGizmoFlatten::on_set_state()
{
if (m_state == On && is_plane_update_necessary())
update_planes();
}
CommonGizmosDataID GLGizmoFlatten::on_get_requirements() const
@ -81,7 +80,8 @@ void GLGizmoFlatten::on_render() const
else
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.5f));
m_planes[i].vbo.render();
if (m_planes[i].vbo.has_VBOs())
m_planes[i].vbo.render();
}
glsafe(::glPopMatrix());
}

View file

@ -59,7 +59,7 @@ void GLGizmoHollow::set_sla_support_data(ModelObject*, const Selection&)
return;
const ModelObject* mo = m_c->selection_info()->model_object();
if (mo) {
if (m_state == On && mo) {
if (m_old_mo_id != mo->id()) {
reload_cache();
m_old_mo_id = mo->id();
@ -810,11 +810,6 @@ void GLGizmoHollow::on_set_state()
if (m_state == m_old_state)
return;
if (m_state == On && m_old_state != On) { // the gizmo was just turned on
// we'll now reload support points:
if (m_c->selection_info()->model_object())
reload_cache();
}
if (m_state == Off && m_old_state != Off) // the gizmo was just turned Off
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_FORCE_UPDATE));
m_old_state = m_state;

View file

@ -67,10 +67,11 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const S
ModelObject* mo = m_c->selection_info()->model_object();
if (mo && mo->id() != m_old_mo_id) {
if (m_state == On && mo && mo->id() != m_old_mo_id) {
disable_editing_mode();
reload_cache();
m_old_mo_id = mo->id();
m_c->instances_hider()->show_supports(true);
}
// If we triggered autogeneration before, check backend and fetch results if they are there
@ -884,25 +885,23 @@ CommonGizmosDataID GLGizmoSlaSupports::on_get_requirements() const
void GLGizmoSlaSupports::on_set_state()
{
const ModelObject* mo = m_c->selection_info()->model_object();
if (m_state == m_old_state)
return;
if (m_state == On && m_old_state != On) { // the gizmo was just turned on
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned on")));
// This function can be called from undo/redo, when selection (and hence
// common gizmos data are not yet deserialized. The CallAfter should put
// this off until after the update is done.
wxGetApp().CallAfter([this]() {
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned on")));
// we'll now reload support points:
if (mo)
reload_cache();
// Set default head diameter from config.
const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
m_new_point_head_diameter = static_cast<const ConfigOptionFloat*>(cfg.option("support_head_front_diameter"))->value;
m_c->instances_hider()->show_supports(true);
// Set default head diameter from config.
const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
m_new_point_head_diameter = static_cast<const ConfigOptionFloat*>(cfg.option("support_head_front_diameter"))->value;
});
}
if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off
bool will_ask = mo && m_editing_mode && unsaved_changes();
bool will_ask = m_editing_mode && unsaved_changes();
if (will_ask) {
wxGetApp().CallAfter([this]() {
// Following is called through CallAfter, because otherwise there was a problem
@ -922,7 +921,7 @@ void GLGizmoSlaSupports::on_set_state()
disable_editing_mode(); // so it is not active next time the gizmo opens
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned off")));
m_normal_cache.clear();
m_old_mo_id = -1;
}
}
m_old_state = m_state;

View file

@ -8,6 +8,8 @@
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/PresetBundle.hpp"
#include <GL/glew.h>
namespace Slic3r {
@ -170,7 +172,8 @@ void InstancesHider::show_supports(bool show) {
void HollowedMesh::on_update()
{
const ModelObject* mo = get_pool()->selection_info()->model_object();
if (! mo)
bool is_sla = wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA;
if (! mo || ! is_sla)
return;
const GLCanvas3D* canvas = get_pool()->get_canvas();
@ -376,7 +379,8 @@ void ObjectClipper::set_position(double pos, bool keep_normal)
void SupportsClipper::on_update()
{
const ModelObject* mo = get_pool()->selection_info()->model_object();
if (! mo)
bool is_sla = wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA;
if (! mo || ! is_sla)
return;
const GLCanvas3D* canvas = get_pool()->get_canvas();

View file

@ -1104,9 +1104,16 @@ void GLGizmosManager::activate_gizmo(EType type)
}
m_current = type;
m_common_gizmos_data->update(get_current()
? get_current()->get_requirements()
: CommonGizmosDataID(0));
// Updating common data should be left to the update_data function, which
// is always called after this one. activate_gizmo can be called by undo/redo,
// when selection is not yet deserialized, so the common data would update
// incorrectly (or crash if relying on unempty selection). Undo/redo stack
// will also call update_data, after selection is restored.
//m_common_gizmos_data->update(get_current()
// ? get_current()->get_requirements()
// : CommonGizmosDataID(0));
if (type != Undefined)
m_gizmos[type]->set_state(GLGizmoBase::On);

View file

@ -141,11 +141,6 @@ public:
EType new_current = m_current;
m_current = old_current;
// Update common data. They should be updated when activate_gizmo is
// called, so it can be used in on_set_state which is called from there.
if (new_current != Undefined)
m_common_gizmos_data->update(m_gizmos[new_current]->get_requirements());
// activate_gizmo call sets m_current and calls set_state for the gizmo
// it does nothing in case the gizmo is already activated
// it can safely be called for Undefined gizmo

View file

@ -329,7 +329,7 @@ void MainFrame::init_tabpanel()
Tab* tab = dynamic_cast<Tab*>(panel);
// There shouldn't be a case, when we try to select a tab, which doesn't support a printer technology
if (panel == nullptr || (tab && tab->supports_printer_technology(m_plater->printer_technology())))
if (panel == nullptr || (tab && ! tab->supports_printer_technology(m_plater->printer_technology())))
return;
auto& tabs_list = wxGetApp().tabs_list;

View file

@ -49,7 +49,8 @@ void MeshClipper::render_cut()
if (! m_triangles_valid)
recalculate_triangles();
m_vertex_array.render();
if (m_vertex_array.has_VBOs())
m_vertex_array.render();
}

View file

@ -1589,6 +1589,7 @@ struct Plater::priv
Mouse3DController mouse3d_controller;
View3D* view3D;
GLToolbar view_toolbar;
GLToolbar collapse_toolbar;
Preview *preview;
BackgroundSlicingProcess background_process;
@ -1683,6 +1684,7 @@ struct Plater::priv
void reset_canvas_volumes();
bool init_view_toolbar();
bool init_collapse_toolbar();
void reset_all_gizmos();
void update_ui_from_settings();
@ -1878,6 +1880,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
, m_ui_jobs(this)
, delayed_scene_refresh(false)
, view_toolbar(GLToolbar::Radio, "View")
, collapse_toolbar(GLToolbar::Normal, "Collapse")
, m_project_filename(wxEmptyString)
{
this->q->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -3922,6 +3925,51 @@ bool Plater::priv::init_view_toolbar()
return true;
}
bool Plater::priv::init_collapse_toolbar()
{
if (collapse_toolbar.get_items_count() > 0)
// already initialized
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 (!collapse_toolbar.init(background_data))
return false;
collapse_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
collapse_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
collapse_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
collapse_toolbar.set_border(5.0f);
collapse_toolbar.set_separator_size(5);
collapse_toolbar.set_gap_size(2);
GLToolbarItem::Data item;
item.name = "collapse_sidebar";
item.icon_filename = "collapse.svg";
item.tooltip = wxGetApp().plater()->is_sidebar_collapsed() ? _utf8(L("Expand right panel")) : _utf8(L("Collapse right panel"));
item.sprite_id = 0;
item.left.action_callback = [this, item]() {
std::string new_tooltip = wxGetApp().plater()->is_sidebar_collapsed() ?
_utf8(L("Collapse right panel")) : _utf8(L("Expand right panel"));
int id = collapse_toolbar.get_item_id("collapse_sidebar");
collapse_toolbar.set_tooltip(id, new_tooltip);
wxGetApp().plater()->collapse_sidebar(!wxGetApp().plater()->is_sidebar_collapsed());
};
if (!collapse_toolbar.add_item(item))
return false;
return true;
}
bool Plater::priv::can_set_instance_to_object() const
{
const int obj_idx = get_selected_object_idx();
@ -5531,6 +5579,11 @@ bool Plater::init_view_toolbar()
return p->init_view_toolbar();
}
bool Plater::init_collapse_toolbar()
{
return p->init_collapse_toolbar();
}
const Camera& Plater::get_camera() const
{
return p->camera;
@ -5574,6 +5627,16 @@ GLToolbar& Plater::get_view_toolbar()
return p->view_toolbar;
}
const GLToolbar& Plater::get_collapse_toolbar() const
{
return p->collapse_toolbar;
}
GLToolbar& Plater::get_collapse_toolbar()
{
return p->collapse_toolbar;
}
const Mouse3DController& Plater::get_mouse3d_controller() const
{
return p->mouse3d_controller;

View file

@ -315,6 +315,7 @@ public:
void sys_color_changed();
bool init_view_toolbar();
bool init_collapse_toolbar();
const Camera& get_camera() const;
Camera& get_camera();
@ -330,6 +331,9 @@ public:
const GLToolbar& get_view_toolbar() const;
GLToolbar& get_view_toolbar();
const GLToolbar& get_collapse_toolbar() const;
GLToolbar& get_collapse_toolbar();
const Mouse3DController& get_mouse3d_controller() const;
Mouse3DController& get_mouse3d_controller();