Fixed conflict after merge with master

This commit is contained in:
enricoturri1966 2021-07-29 12:25:28 +02:00
commit 81f4df70dc
22 changed files with 873 additions and 417 deletions

View file

@ -1407,10 +1407,6 @@ void GLCanvas3D::render()
if (!is_initialized() && !init())
return;
#if ENABLE_RENDER_STATISTICS
auto start_time = std::chrono::high_resolution_clock::now();
#endif // ENABLE_RENDER_STATISTICS
if (wxGetApp().plater()->get_bed().get_shape().empty()) {
// this happens at startup when no data is still saved under <>\AppData\Roaming\Slic3rPE
post_event(SimpleEvent(EVT_GLCANVAS_UPDATE_BED_SHAPE));
@ -1505,19 +1501,12 @@ void GLCanvas3D::render()
// draw overlays
_render_overlays();
#if ENABLE_RENDER_STATISTICS
if (wxGetApp().plater()->is_render_statistic_dialog_visible()) {
ImGuiWrapper& imgui = *wxGetApp().imgui();
imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
imgui.text("Last frame:");
imgui.text("FPS (SwapBuffers() calls per second):");
ImGui::SameLine();
int64_t average = m_render_stats.get_average();
imgui.text(std::to_string(average));
ImGui::SameLine();
imgui.text("ms");
imgui.text("FPS:");
ImGui::SameLine();
imgui.text(std::to_string((average == 0) ? 0 : static_cast<int>(1000.0f / static_cast<float>(average))));
imgui.text(std::to_string(m_render_stats.get_fps_and_reset_if_needed()));
ImGui::Separator();
imgui.text("Compressed textures:");
ImGui::SameLine();
@ -1527,7 +1516,6 @@ void GLCanvas3D::render()
imgui.text(std::to_string(OpenGLManager::get_gl_info().get_max_tex_size()));
imgui.end();
}
#endif // ENABLE_RENDER_STATISTICS
#if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
if (wxGetApp().is_editor() && wxGetApp().plater()->is_view3D_shown())
@ -1574,11 +1562,7 @@ void GLCanvas3D::render()
wxGetApp().imgui()->render();
m_canvas->SwapBuffers();
#if ENABLE_RENDER_STATISTICS
auto end_time = std::chrono::high_resolution_clock::now();
m_render_stats.add_frame(std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count());
#endif // ENABLE_RENDER_STATISTICS
m_render_stats.increment_fps_counter();
}
void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params, Camera::EType camera_type)
@ -2592,15 +2576,11 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
{
if (!m_gizmos.on_key(evt)) {
if (evt.GetEventType() == wxEVT_KEY_UP) {
#if ENABLE_RENDER_STATISTICS
if (evt.ShiftDown() && evt.ControlDown() && keyCode == WXK_SPACE) {
wxGetApp().plater()->toggle_render_statistic_dialog();
m_dirty = true;
}
if (m_tab_down && keyCode == WXK_TAB && !evt.HasAnyModifiers()) {
#else
if (m_tab_down && keyCode == WXK_TAB && !evt.HasAnyModifiers()) {
#endif // ENABLE_RENDER_STATISTICS
// Enable switching between 3D and Preview with Tab
// m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux
post_event(SimpleEvent(EVT_GLCANVAS_TAB));
@ -3437,6 +3417,7 @@ void GLCanvas3D::do_move(const std::string& snapshot_type)
m_selection.translate(i.first, i.second, shift);
m->translate_instance(i.second, shift);
}
wxGetApp().obj_list()->update_info_items(static_cast<size_t>(i.first));
}
// if the selection is not valid to allow for layer editing after the move, we need to turn off the tool if it is running
@ -3517,6 +3498,7 @@ void GLCanvas3D::do_rotate(const std::string& snapshot_type)
m_selection.translate(i.first, i.second, shift);
m->translate_instance(i.second, shift);
}
wxGetApp().obj_list()->update_info_items(static_cast<size_t>(i.first));
}
if (!done.empty())
@ -3584,6 +3566,7 @@ void GLCanvas3D::do_scale(const std::string& snapshot_type)
m_selection.translate(i.first, i.second, shift);
m->translate_instance(i.second, shift);
}
wxGetApp().obj_list()->update_info_items(static_cast<size_t>(i.first));
}
if (!done.empty())

View file

@ -305,25 +305,27 @@ class GLCanvas3D
ObjectClashed
};
#if ENABLE_RENDER_STATISTICS
class RenderStats
{
std::queue<std::pair<int64_t, int64_t>> m_frames;
int64_t m_curr_total{ 0 };
private:
std::chrono::time_point<std::chrono::high_resolution_clock> m_measuring_start;
int m_fps_out = -1;
int m_fps_running = 0;
public:
void add_frame(int64_t frame) {
int64_t now = GLCanvas3D::timestamp_now();
if (!m_frames.empty() && now - m_frames.front().first > 1000) {
m_curr_total -= m_frames.front().second;
m_frames.pop();
void increment_fps_counter() { ++m_fps_running; }
int get_fps() { return m_fps_out; }
int get_fps_and_reset_if_needed() {
auto cur_time = std::chrono::high_resolution_clock::now();
int elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(cur_time-m_measuring_start).count();
if (elapsed_ms > 1000 || m_fps_out == -1) {
m_measuring_start = cur_time;
m_fps_out = int (1000. * m_fps_running / elapsed_ms);
m_fps_running = 0;
}
m_curr_total += frame;
m_frames.push({ now, frame });
return m_fps_out;
}
int64_t get_average() const { return m_frames.empty() ? 0 : m_curr_total / m_frames.size(); }
};
#endif // ENABLE_RENDER_STATISTICS
class Labels
{
@ -455,9 +457,7 @@ private:
bool m_show_picking_texture;
#endif // ENABLE_RENDER_PICKING_PASS
#if ENABLE_RENDER_STATISTICS
RenderStats m_render_stats;
#endif // ENABLE_RENDER_STATISTICS
int m_imgui_undo_redo_hovered_pos{ -1 };
int m_mouse_wheel{ 0 };

View file

@ -2386,15 +2386,28 @@ void ObjectList::part_selection_changed()
if (type == itInfo) {
InfoItemType info_type = m_objects_model->GetInfoItemType(item);
if (info_type != InfoItemType::VariableLayerHeight) {
switch (info_type)
{
case InfoItemType::VariableLayerHeight:
{
wxGetApp().plater()->toggle_layers_editing(true);
break;
}
case InfoItemType::CustomSupports:
case InfoItemType::CustomSeam:
case InfoItemType::MmuSegmentation:
{
GLGizmosManager::EType gizmo_type = info_type == InfoItemType::CustomSupports ? GLGizmosManager::EType::FdmSupports :
info_type == InfoItemType::CustomSeam ? GLGizmosManager::EType::Seam :
GLGizmosManager::EType::MmuSegmentation;
info_type == InfoItemType::CustomSeam ? GLGizmosManager::EType::Seam :
GLGizmosManager::EType::MmuSegmentation;
GLGizmosManager& gizmos_mgr = wxGetApp().plater()->canvas3D()->get_gizmos_manager();
if (gizmos_mgr.get_current_type() != gizmo_type)
gizmos_mgr.open_gizmo(gizmo_type);
} else
wxGetApp().plater()->toggle_layers_editing(true);
break;
}
case InfoItemType::Sinking: { break; }
default: { break; }
}
}
}
else {
@ -2520,6 +2533,7 @@ void ObjectList::update_info_items(size_t obj_idx)
for (InfoItemType type : {InfoItemType::CustomSupports,
InfoItemType::CustomSeam,
InfoItemType::MmuSegmentation,
InfoItemType::Sinking,
InfoItemType::VariableLayerHeight}) {
wxDataViewItem item = m_objects_model->GetInfoItemByType(item_obj, type);
bool shows = item.IsOk();
@ -2542,6 +2556,13 @@ void ObjectList::update_info_items(size_t obj_idx)
should_show = printer_technology() == ptFFF
&& ! model_object->layer_height_profile.empty();
break;
case InfoItemType::Sinking:
{
const BoundingBoxf3& box = model_object->bounding_box();
should_show = printer_technology() == ptFFF &&
box.min.z() < SINKING_Z_THRESHOLD && box.max.z() > SINKING_Z_THRESHOLD;
break;
}
default: break;
}

View file

@ -346,7 +346,8 @@ void GLGizmoFdmSupports::update_from_model_object()
const TriangleMesh* mesh = &mv->mesh();
m_triangle_selectors.emplace_back(std::make_unique<TriangleSelectorGUI>(*mesh));
m_triangle_selectors.back()->deserialize(mv->supported_facets.get_data());
// Reset of TriangleSelector is done inside TriangleSelectorGUI's constructor, so we don't need it to perform it again in deserialize().
m_triangle_selectors.back()->deserialize(mv->supported_facets.get_data(), false);
m_triangle_selectors.back()->request_update_render_data();
}
}

View file

@ -544,7 +544,8 @@ void GLGizmoMmuSegmentation::init_model_triangle_selectors()
int extruder_idx = (mv->extruder_id() > 0) ? mv->extruder_id() - 1 : 0;
m_triangle_selectors.emplace_back(std::make_unique<TriangleSelectorMmGui>(*mesh, m_modified_extruders_colors, m_original_extruders_colors[size_t(extruder_idx)]));
m_triangle_selectors.back()->deserialize(mv->mmu_segmentation_facets.get_data());
// Reset of TriangleSelector is done inside TriangleSelectorMmGUI's constructor, so we don't need it to perform it again in deserialize().
m_triangle_selectors.back()->deserialize(mv->mmu_segmentation_facets.get_data(), false);
m_triangle_selectors.back()->request_update_render_data();
}
m_original_volumes_extruder_idxs = get_extruder_id_for_volumes(*mo);

View file

@ -256,7 +256,8 @@ void GLGizmoSeam::update_from_model_object()
const TriangleMesh* mesh = &mv->mesh();
m_triangle_selectors.emplace_back(std::make_unique<TriangleSelectorGUI>(*mesh));
m_triangle_selectors.back()->deserialize(mv->seam_facets.get_data());
// Reset of TriangleSelector is done inside TriangleSelectorGUI's constructor, so we don't need it to perform it again in deserialize().
m_triangle_selectors.back()->deserialize(mv->seam_facets.get_data(), false);
m_triangle_selectors.back()->request_update_render_data();
}
}

View file

@ -65,6 +65,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
m_name = info_type == InfoItemType::CustomSupports ? _L("Paint-on supports") :
info_type == InfoItemType::CustomSeam ? _L("Paint-on seam") :
info_type == InfoItemType::MmuSegmentation ? _L("Paint-on segmentation") :
info_type == InfoItemType::Sinking ? _L("Sinking") :
_L("Variable layer height");
m_info_item_type = info_type;
}

View file

@ -51,6 +51,7 @@ enum class InfoItemType
CustomSupports,
CustomSeam,
MmuSegmentation,
Sinking,
VariableLayerHeight
};

View file

@ -1565,9 +1565,7 @@ struct Plater::priv
std::string label_btn_export;
std::string label_btn_send;
#if ENABLE_RENDER_STATISTICS
bool show_render_statistic_dialog{ false };
#endif // ENABLE_RENDER_STATISTICS
static const std::regex pattern_bundle;
static const std::regex pattern_3mf;
@ -6516,7 +6514,6 @@ void Plater::enter_gizmos_stack() { p->enter_gizmos_stack(); }
void Plater::leave_gizmos_stack() { p->leave_gizmos_stack(); }
bool Plater::inside_snapshot_capture() { return p->inside_snapshot_capture(); }
#if ENABLE_RENDER_STATISTICS
void Plater::toggle_render_statistic_dialog()
{
p->show_render_statistic_dialog = !p->show_render_statistic_dialog;
@ -6526,7 +6523,6 @@ bool Plater::is_render_statistic_dialog_visible() const
{
return p->show_render_statistic_dialog;
}
#endif // ENABLE_RENDER_STATISTICS
// Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
bool Plater::PopupMenu(wxMenu *menu, const wxPoint& pos)

View file

@ -404,10 +404,8 @@ public:
bool inside_snapshot_capture();
#if ENABLE_RENDER_STATISTICS
void toggle_render_statistic_dialog();
bool is_render_statistic_dialog_visible() const;
#endif // ENABLE_RENDER_STATISTICS
// Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition);

View file

@ -841,8 +841,12 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
for (unsigned int i : m_list) {
GLVolume &v = *(*m_volumes)[i];
if (!is_sla)
is_any_volume_sinking |= !v.is_modifier && std::find(m_cache.sinking_volumes.begin(), m_cache.sinking_volumes.end(), i) != m_cache.sinking_volumes.end();
if (!is_sla) {
if (v.is_modifier)
is_any_volume_sinking = true;
else
is_any_volume_sinking |= std::find(m_cache.sinking_volumes.begin(), m_cache.sinking_volumes.end(), i) != m_cache.sinking_volumes.end();
}
if (is_single_full_instance()) {
if (transformation_type.relative()) {
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scale);
@ -2123,7 +2127,7 @@ void Selection::ensure_on_bed()
for (GLVolume* volume : *m_volumes) {
if (!volume->is_wipe_tower && !volume->is_modifier) {
double min_z = volume->transformed_convex_hull_bounding_box().min(2);
const double min_z = volume->transformed_convex_hull_bounding_box().min.z();
std::pair<int, int> instance = std::make_pair(volume->object_idx(), volume->instance_idx());
InstancesToZMap::iterator it = instances_min_z.find(instance);
if (it == instances_min_z.end())

View file

@ -3059,6 +3059,7 @@ void Tab::load_current_preset()
if (!wxGetApp().tabs_as_menu()) {
std::string bmp_name = tab->type() == Slic3r::Preset::TYPE_FILAMENT ? "spool" :
tab->type() == Slic3r::Preset::TYPE_SLA_MATERIAL ? "resin" : "cog";
tab->Hide(); // #ys_WORKAROUND : Hide tab before inserting to avoid unwanted rendering of the tab
dynamic_cast<Notebook*>(wxGetApp().tab_panel())->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title(), bmp_name);
}
else