mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-26 02:01:12 -06:00
Modal estimated printing time dialog
Fixed conflicts after merge with master
This commit is contained in:
commit
48ae8dc9a2
22 changed files with 1301 additions and 264 deletions
|
|
@ -415,8 +415,15 @@ void GCodeViewer::render() const
|
|||
m_statistics.reset_opengl();
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
if (m_roles.empty()) {
|
||||
m_time_estimate_frames_count = 0;
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (m_roles.empty())
|
||||
return;
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
render_toolpaths();
|
||||
|
|
@ -463,7 +470,9 @@ unsigned int GCodeViewer::get_options_visibility_flags() const
|
|||
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::Shells), m_shells.visible);
|
||||
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::ToolMarker), m_sequential_view.marker.is_visible());
|
||||
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::Legend), is_legend_enabled());
|
||||
#if !ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::TimeEstimate), is_time_estimate_enabled());
|
||||
#endif // !ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
|
@ -483,7 +492,9 @@ void GCodeViewer::set_options_visibility_from_flags(unsigned int flags)
|
|||
m_shells.visible = is_flag_set(static_cast<unsigned int>(Preview::OptionType::Shells));
|
||||
m_sequential_view.marker.set_visible(is_flag_set(static_cast<unsigned int>(Preview::OptionType::ToolMarker)));
|
||||
enable_legend(is_flag_set(static_cast<unsigned int>(Preview::OptionType::Legend)));
|
||||
#if !ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
enable_time_estimate(is_flag_set(static_cast<unsigned int>(Preview::OptionType::TimeEstimate)));
|
||||
#endif // !ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
}
|
||||
|
||||
void GCodeViewer::set_layers_z_range(const std::array<double, 2>& layers_z_range)
|
||||
|
|
@ -1717,14 +1728,27 @@ void GCodeViewer::render_legend() const
|
|||
|
||||
void GCodeViewer::render_time_estimate() const
|
||||
{
|
||||
if (!m_time_estimate_enabled)
|
||||
if (!m_time_estimate_enabled) {
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
m_time_estimate_frames_count = 0;
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
return;
|
||||
}
|
||||
|
||||
const PrintStatistics& ps = wxGetApp().plater()->fff_print().print_statistics();
|
||||
if (ps.estimated_normal_print_time <= 0.0f && ps.estimated_silent_print_time <= 0.0f)
|
||||
return;
|
||||
|
||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
// esc
|
||||
if (ImGui::GetIO().KeysDown[27]) {
|
||||
m_time_estimate_enabled = false;
|
||||
return;
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
|
||||
|
||||
using Times = std::pair<float, float>;
|
||||
using TimesList = std::vector<std::pair<CustomGCode::Type, Times>>;
|
||||
|
|
@ -1893,8 +1917,8 @@ void GCodeViewer::render_time_estimate() const
|
|||
|
||||
if (moves_time.empty())
|
||||
return;
|
||||
|
||||
if (!ImGui::CollapsingHeader(_u8L("Moves Time").c_str()))
|
||||
|
||||
if (!ImGui::CollapsingHeader(_u8L("Moves Time").c_str(), ImGuiTreeNodeFlags_DefaultOpen))
|
||||
return;
|
||||
|
||||
append_headers(headers, offsets);
|
||||
|
|
@ -1914,7 +1938,7 @@ void GCodeViewer::render_time_estimate() const
|
|||
if (roles_time.empty())
|
||||
return;
|
||||
|
||||
if (!ImGui::CollapsingHeader(_u8L("Features Time").c_str()))
|
||||
if (!ImGui::CollapsingHeader(_u8L("Features Time").c_str(), ImGuiTreeNodeFlags_DefaultOpen))
|
||||
return;
|
||||
|
||||
append_headers(headers, offsets);
|
||||
|
|
@ -2023,22 +2047,40 @@ void GCodeViewer::render_time_estimate() const
|
|||
};
|
||||
|
||||
Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
std::string title = _u8L("Estimated printing time");
|
||||
ImGui::OpenPopup(title.c_str());
|
||||
|
||||
imgui.set_next_window_pos(0.5f * static_cast<float>(cnv_size.get_width()), 0.5f * static_cast<float>(cnv_size.get_height()), ImGuiCond_Always, 0.5f, 0.5f);
|
||||
ImGui::SetNextWindowSize({ -1.0f, 0.666f * static_cast<float>(cnv_size.get_height()) });
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::SetNextWindowBgAlpha(0.6f);
|
||||
if (ImGui::BeginPopupModal(title.c_str(), &m_time_estimate_enabled, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (m_time_estimate_enabled) {
|
||||
// imgui takes several frames to grayout the content of the canvas
|
||||
if (m_time_estimate_frames_count < 10) {
|
||||
wxGetApp().plater()->get_current_canvas3D()->set_as_dirty();
|
||||
wxGetApp().plater()->get_current_canvas3D()->request_extra_frame();
|
||||
++m_time_estimate_frames_count;
|
||||
}
|
||||
#else
|
||||
imgui.set_next_window_pos(static_cast<float>(cnv_size.get_width()), static_cast<float>(cnv_size.get_height()), ImGuiCond_Always, 1.0f, 1.0f);
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(0.0f, 0.0f), ImVec2(-1.0f, 0.5f * static_cast<float>(cnv_size.get_height())));
|
||||
ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, 0.5f * static_cast<float>(cnv_size.get_height() }));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::SetNextWindowBgAlpha(0.6f);
|
||||
imgui.begin(std::string("Time_estimate"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove);
|
||||
|
||||
// title
|
||||
imgui.title(_u8L("Estimated printing time"));
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
|
||||
// mode tabs
|
||||
// mode tabs
|
||||
ImGui::BeginTabBar("mode_tabs");
|
||||
if (ps.estimated_normal_print_time > 0.0f) {
|
||||
if (ImGui::BeginTabItem(_u8L("Normal").c_str())) {
|
||||
append_mode(ps.estimated_normal_print_time,
|
||||
append_mode(ps.estimated_normal_print_time,
|
||||
generate_partial_times(ps.estimated_normal_custom_gcode_print_times), partial_times_headers,
|
||||
ps.estimated_normal_moves_times, moves_headers,
|
||||
ps.estimated_normal_moves_times, moves_headers,
|
||||
ps.estimated_normal_roles_times, roles_headers);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
|
@ -2054,7 +2096,22 @@ void GCodeViewer::render_time_estimate() const
|
|||
}
|
||||
ImGui::EndTabBar();
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
// this is ugly, but it is the only way to ensure that the dialog is large
|
||||
// enough to show enterely the title
|
||||
// see: https://github.com/ocornut/imgui/issues/3239
|
||||
float width = std::max(ImGui::CalcTextSize(title.c_str()).x + 2.0f * ImGui::GetStyle().WindowPadding.x, 300.0f);
|
||||
ImGui::SetCursorPosX(width);
|
||||
ImGui::SetCursorPosX(0.0f);
|
||||
}
|
||||
else
|
||||
m_time_estimate_enabled = false;
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
#else
|
||||
imgui.end();
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -341,7 +341,12 @@ private:
|
|||
Shells m_shells;
|
||||
EViewType m_view_type{ EViewType::FeatureType };
|
||||
bool m_legend_enabled{ true };
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
mutable bool m_time_estimate_enabled{ false };
|
||||
mutable unsigned int m_time_estimate_frames_count{ 0 };
|
||||
#else
|
||||
bool m_time_estimate_enabled{ false };
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
mutable Statistics m_statistics;
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
|
|
|||
|
|
@ -3401,6 +3401,11 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
|
|||
if (evt.MiddleIsDown())
|
||||
return;
|
||||
|
||||
if (wxGetApp().imgui()->update_mouse_data(evt)) {
|
||||
m_dirty = true;
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLE_RETINA_GL
|
||||
const float scale = m_retina_helper->get_scale_factor();
|
||||
evt.SetX(evt.GetX() * scale);
|
||||
|
|
|
|||
|
|
@ -2364,8 +2364,9 @@ void ObjectList::del_layers_from_object(const int obj_idx)
|
|||
|
||||
bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, const int type)
|
||||
{
|
||||
if (obj_idx == 1000)
|
||||
// Cannot delete a wipe tower.
|
||||
assert(idx >= 0);
|
||||
if (obj_idx == 1000 || idx<0)
|
||||
// Cannot delete a wipe tower or volume with negative id
|
||||
return false;
|
||||
|
||||
ModelObject* object = (*m_objects)[obj_idx];
|
||||
|
|
|
|||
|
|
@ -323,8 +323,12 @@ bool Preview::init(wxWindow* parent, Model* model)
|
|||
get_option_type_string(OptionType::CustomGCodes) + "|0|" +
|
||||
get_option_type_string(OptionType::Shells) + "|0|" +
|
||||
get_option_type_string(OptionType::ToolMarker) + "|0|" +
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
get_option_type_string(OptionType::Legend) + "|1"
|
||||
#else
|
||||
get_option_type_string(OptionType::Legend) + "|1|" +
|
||||
get_option_type_string(OptionType::TimeEstimate) + "|1"
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
);
|
||||
Slic3r::GUI::create_combochecklist(m_combochecklist_options, GUI::into_u8(_L("Options")), options_items);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
static constexpr size_t MaxVertexBuffers = 50;
|
||||
|
||||
GLGizmoFdmSupports::GLGizmoFdmSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
|
|
@ -49,7 +48,7 @@ bool GLGizmoFdmSupports::on_init()
|
|||
m_desc["block"] = _L("Block supports");
|
||||
m_desc["remove_caption"] = _L("Shift + Left mouse button") + ": ";
|
||||
m_desc["remove"] = _L("Remove selection");
|
||||
m_desc["remove_all"] = _L("Remove all");
|
||||
m_desc["remove_all"] = _L("Remove all selection");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -96,6 +95,7 @@ void GLGizmoFdmSupports::on_render() const
|
|||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
render_triangles(selection);
|
||||
|
||||
m_c->object_clipper()->render_cut();
|
||||
render_cursor_circle();
|
||||
|
||||
|
|
@ -145,14 +145,9 @@ void GLGizmoFdmSupports::render_triangles(const Selection& selection) const
|
|||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixd(trafo_matrix.data()));
|
||||
|
||||
// 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]) {
|
||||
if (iva.has_VBOs())
|
||||
iva.render();
|
||||
}
|
||||
}
|
||||
if (! m_setting_angle)
|
||||
m_triangle_selectors[mesh_id]->render(m_imgui);
|
||||
|
||||
glsafe(::glPopMatrix());
|
||||
if (is_left_handed)
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
|
|
@ -209,15 +204,18 @@ void GLGizmoFdmSupports::render_cursor_circle() const
|
|||
|
||||
void GLGizmoFdmSupports::update_model_object() const
|
||||
{
|
||||
bool updated = false;
|
||||
ModelObject* mo = m_c->selection_info()->model_object();
|
||||
int idx = -1;
|
||||
for (ModelVolume* mv : mo->volumes) {
|
||||
++idx;
|
||||
if (! mv->is_model_part())
|
||||
continue;
|
||||
for (int i=0; i<int(m_selected_facets[idx].size()); ++i)
|
||||
mv->m_supported_facets.set_facet(i, m_selected_facets[idx][i]);
|
||||
++idx;
|
||||
updated |= mv->m_supported_facets.set(*m_triangle_selectors[idx].get());
|
||||
}
|
||||
|
||||
if (updated)
|
||||
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -226,19 +224,7 @@ void GLGizmoFdmSupports::update_from_model_object()
|
|||
wxBusyCursor wait;
|
||||
|
||||
const ModelObject* mo = m_c->selection_info()->model_object();
|
||||
size_t num_of_volumes = 0;
|
||||
for (const ModelVolume* mv : mo->volumes)
|
||||
if (mv->is_model_part())
|
||||
++num_of_volumes;
|
||||
m_selected_facets.resize(num_of_volumes);
|
||||
|
||||
m_ivas.clear();
|
||||
m_ivas.resize(num_of_volumes);
|
||||
for (size_t i=0; i<num_of_volumes; ++i) {
|
||||
m_ivas[i][0].reserve(MaxVertexBuffers);
|
||||
m_ivas[i][1].reserve(MaxVertexBuffers);
|
||||
}
|
||||
|
||||
m_triangle_selectors.clear();
|
||||
|
||||
int volume_id = -1;
|
||||
for (const ModelVolume* mv : mo->volumes) {
|
||||
|
|
@ -250,16 +236,8 @@ void GLGizmoFdmSupports::update_from_model_object()
|
|||
// This mesh does not account for the possible Z up SLA offset.
|
||||
const TriangleMesh* mesh = &mv->mesh();
|
||||
|
||||
m_selected_facets[volume_id].assign(mesh->its.indices.size(), FacetSupportType::NONE);
|
||||
|
||||
// Load current state from ModelVolume.
|
||||
for (FacetSupportType type : {FacetSupportType::ENFORCER, FacetSupportType::BLOCKER}) {
|
||||
const std::vector<int>& list = mv->m_supported_facets.get_facets(type);
|
||||
for (int i : list)
|
||||
m_selected_facets[volume_id][i] = type;
|
||||
}
|
||||
update_vertex_buffers(mesh, volume_id, FacetSupportType::ENFORCER);
|
||||
update_vertex_buffers(mesh, volume_id, FacetSupportType::BLOCKER);
|
||||
m_triangle_selectors.emplace_back(std::make_unique<TriangleSelectorGUI>(*mesh));
|
||||
m_triangle_selectors.back()->deserialize(mv->m_supported_facets.get_data());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -315,6 +293,9 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
|| action == SLAGizmoEventType::RightDown
|
||||
|| (action == SLAGizmoEventType::Dragging && m_button_down != Button::None)) {
|
||||
|
||||
if (m_triangle_selectors.empty())
|
||||
return false;
|
||||
|
||||
FacetSupportType new_state = FacetSupportType::NONE;
|
||||
if (! shift_down) {
|
||||
if (action == SLAGizmoEventType::Dragging)
|
||||
|
|
@ -403,103 +384,35 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
|| dragging_while_painting;
|
||||
}
|
||||
|
||||
// Now propagate the hits
|
||||
// Find respective mesh id.
|
||||
// FIXME We need a separate TriangleSelector for each volume mesh.
|
||||
mesh_id = -1;
|
||||
const TriangleMesh* mesh = nullptr;
|
||||
//const TriangleMesh* mesh = nullptr;
|
||||
for (const ModelVolume* mv : mo->volumes) {
|
||||
if (! mv->is_model_part())
|
||||
continue;
|
||||
++mesh_id;
|
||||
if (mesh_id == closest_hit_mesh_id) {
|
||||
mesh = &mv->mesh();
|
||||
//mesh = &mv->mesh();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool update_both = false;
|
||||
|
||||
const Transform3d& trafo_matrix = trafo_matrices[mesh_id];
|
||||
|
||||
// Calculate how far can a point be from the line (in mesh coords).
|
||||
// FIXME: The scaling of the mesh can be non-uniform.
|
||||
const Vec3d sf = Geometry::Transformation(trafo_matrix).get_scaling_factor();
|
||||
const float avg_scaling = (sf(0) + sf(1) + sf(2))/3.;
|
||||
const float limit = pow(m_cursor_radius/avg_scaling , 2.f);
|
||||
|
||||
const std::pair<Vec3f, size_t>& hit_and_facet = { closest_hit, closest_facet };
|
||||
const float limit = m_cursor_radius/avg_scaling;
|
||||
|
||||
// Calculate direction from camera to the hit (in mesh coords):
|
||||
Vec3f dir = ((trafo_matrix.inverse() * camera.get_position()).cast<float>() - hit_and_facet.first).normalized();
|
||||
Vec3f camera_pos = (trafo_matrix.inverse() * camera.get_position()).cast<float>();
|
||||
Vec3f dir = (closest_hit - camera_pos).normalized();
|
||||
|
||||
// A lambda to calculate distance from the centerline:
|
||||
auto squared_distance_from_line = [&hit_and_facet, &dir](const Vec3f& point) -> float {
|
||||
Vec3f diff = hit_and_facet.first - point;
|
||||
return (diff - diff.dot(dir) * dir).squaredNorm();
|
||||
};
|
||||
|
||||
// A lambda to determine whether this facet is potentionally visible (still can be obscured)
|
||||
auto faces_camera = [&dir, &mesh](const size_t& facet) -> bool {
|
||||
return (mesh->stl.facet_start[facet].normal.dot(dir) > 0.);
|
||||
};
|
||||
// Now start with the facet the pointer points to and check all adjacent facets.
|
||||
std::vector<size_t> facets_to_select{hit_and_facet.second};
|
||||
std::vector<bool> visited(m_selected_facets[mesh_id].size(), false); // keep track of facets we already processed
|
||||
size_t facet_idx = 0; // index into facets_to_select
|
||||
while (facet_idx < facets_to_select.size()) {
|
||||
size_t facet = facets_to_select[facet_idx];
|
||||
if (! visited[facet]) {
|
||||
// check all three vertices and in case they're close enough,
|
||||
// add neighboring facets to be proccessed later
|
||||
for (size_t i=0; i<3; ++i) {
|
||||
float dist = squared_distance_from_line(
|
||||
mesh->its.vertices[mesh->its.indices[facet](i)]);
|
||||
if (dist < limit) {
|
||||
for (int n=0; n<3; ++n) {
|
||||
if (faces_camera(mesh->stl.neighbors_start[facet].neighbor[n]))
|
||||
facets_to_select.push_back(mesh->stl.neighbors_start[facet].neighbor[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
visited[facet] = true;
|
||||
}
|
||||
++facet_idx;
|
||||
}
|
||||
|
||||
std::vector<size_t> new_facets;
|
||||
new_facets.reserve(facets_to_select.size());
|
||||
|
||||
// Now just select all facets that passed and remember which
|
||||
// ones have really changed state.
|
||||
for (size_t next_facet : facets_to_select) {
|
||||
FacetSupportType& facet = m_selected_facets[mesh_id][next_facet];
|
||||
|
||||
if (facet != new_state) {
|
||||
if (facet != FacetSupportType::NONE) {
|
||||
// this triangle is currently in the other VBA.
|
||||
// Both VBAs need to be refreshed.
|
||||
update_both = true;
|
||||
}
|
||||
facet = new_state;
|
||||
new_facets.push_back(next_facet);
|
||||
}
|
||||
}
|
||||
|
||||
if (! new_facets.empty()) {
|
||||
if (new_state != FacetSupportType::NONE) {
|
||||
// append triangles into the respective VBA
|
||||
update_vertex_buffers(mesh, mesh_id, new_state, &new_facets);
|
||||
if (update_both) {
|
||||
auto other = new_state == FacetSupportType::ENFORCER
|
||||
? FacetSupportType::BLOCKER
|
||||
: FacetSupportType::ENFORCER;
|
||||
update_vertex_buffers(mesh, mesh_id, other); // regenerate the other VBA
|
||||
}
|
||||
}
|
||||
else {
|
||||
update_vertex_buffers(mesh, mesh_id, FacetSupportType::ENFORCER);
|
||||
update_vertex_buffers(mesh, mesh_id, FacetSupportType::BLOCKER);
|
||||
}
|
||||
}
|
||||
assert(mesh_id < int(m_triangle_selectors.size()));
|
||||
m_triangle_selectors[mesh_id]->select_patch(closest_hit, closest_facet, camera_pos,
|
||||
dir, limit, new_state);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -524,58 +437,8 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
}
|
||||
|
||||
|
||||
void GLGizmoFdmSupports::update_vertex_buffers(const TriangleMesh* mesh,
|
||||
int mesh_id,
|
||||
FacetSupportType type,
|
||||
const std::vector<size_t>* new_facets)
|
||||
{
|
||||
std::vector<GLIndexedVertexArray>& ivas = m_ivas[mesh_id][type == FacetSupportType::ENFORCER ? 0 : 1];
|
||||
|
||||
// lambda to push facet into vertex buffer
|
||||
auto push_facet = [this, &mesh, &mesh_id](size_t idx, GLIndexedVertexArray& iva) {
|
||||
for (int i=0; i<3; ++i)
|
||||
iva.push_geometry(
|
||||
mesh->its.vertices[mesh->its.indices[idx](i)].cast<double>(),
|
||||
m_c->raycaster()->raycasters()[mesh_id]->get_triangle_normal(idx).cast<double>()
|
||||
);
|
||||
size_t num = iva.triangle_indices_size;
|
||||
iva.push_triangle(num, num+1, num+2);
|
||||
};
|
||||
|
||||
|
||||
if (ivas.size() == MaxVertexBuffers || ! new_facets) {
|
||||
// If there are too many or they should be regenerated, make one large
|
||||
// GLVertexBufferArray.
|
||||
ivas.clear(); // destructors release geometry
|
||||
ivas.push_back(GLIndexedVertexArray());
|
||||
|
||||
bool pushed = false;
|
||||
for (size_t facet_idx=0; facet_idx<m_selected_facets[mesh_id].size(); ++facet_idx) {
|
||||
if (m_selected_facets[mesh_id][facet_idx] == type) {
|
||||
push_facet(facet_idx, ivas.back());
|
||||
pushed = true;
|
||||
}
|
||||
}
|
||||
if (pushed)
|
||||
ivas.back().finalize_geometry(true);
|
||||
else
|
||||
ivas.pop_back();
|
||||
} else {
|
||||
// we are only appending - let's make new vertex array and let the old ones live
|
||||
ivas.push_back(GLIndexedVertexArray());
|
||||
for (size_t facet_idx : *new_facets)
|
||||
push_facet(facet_idx, ivas.back());
|
||||
|
||||
if (! new_facets->empty())
|
||||
ivas.back().finalize_geometry(true);
|
||||
else
|
||||
ivas.pop_back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool overwrite, bool block)
|
||||
void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool block)
|
||||
{
|
||||
float threshold = (M_PI/180.)*threshold_deg;
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
|
|
@ -599,13 +462,12 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool overwr
|
|||
int idx = -1;
|
||||
for (const stl_facet& facet : mv->mesh().stl.facet_start) {
|
||||
++idx;
|
||||
if (facet.normal.dot(down) > dot_limit && (overwrite || m_selected_facets[mesh_id][idx] == FacetSupportType::NONE))
|
||||
m_selected_facets[mesh_id][idx] = block
|
||||
? FacetSupportType::BLOCKER
|
||||
: FacetSupportType::ENFORCER;
|
||||
if (facet.normal.dot(down) > dot_limit)
|
||||
m_triangle_selectors[mesh_id]->set_facet(idx,
|
||||
block
|
||||
? FacetSupportType::BLOCKER
|
||||
: FacetSupportType::ENFORCER);
|
||||
}
|
||||
update_vertex_buffers(&mv->mesh(), mesh_id, FacetSupportType::ENFORCER);
|
||||
update_vertex_buffers(&mv->mesh(), mesh_id, FacetSupportType::BLOCKER);
|
||||
}
|
||||
|
||||
activate_internal_undo_redo_stack(true);
|
||||
|
|
@ -669,18 +531,17 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
ImGui::SameLine();
|
||||
|
||||
if (m_imgui->button(m_desc.at("remove_all"))) {
|
||||
Plater::TakeSnapshot(wxGetApp().plater(), wxString(_L("Reset selection")));
|
||||
ModelObject* mo = m_c->selection_info()->model_object();
|
||||
int idx = -1;
|
||||
for (ModelVolume* mv : mo->volumes) {
|
||||
++idx;
|
||||
if (mv->is_model_part()) {
|
||||
m_selected_facets[idx].assign(m_selected_facets[idx].size(), FacetSupportType::NONE);
|
||||
mv->m_supported_facets.clear();
|
||||
update_vertex_buffers(&mv->mesh(), idx, FacetSupportType::ENFORCER);
|
||||
update_vertex_buffers(&mv->mesh(), idx, FacetSupportType::BLOCKER);
|
||||
m_parent.set_as_dirty();
|
||||
++idx;
|
||||
m_triangle_selectors[idx]->reset();
|
||||
}
|
||||
}
|
||||
update_model_object();
|
||||
m_parent.set_as_dirty();
|
||||
}
|
||||
|
||||
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
|
||||
|
|
@ -736,12 +597,11 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
ImGui::SameLine();
|
||||
if (m_imgui->slider_float("", &m_angle_threshold_deg, 0.f, 90.f, "%.f"))
|
||||
m_parent.set_slope_range({90.f - m_angle_threshold_deg, 90.f - m_angle_threshold_deg});
|
||||
m_imgui->checkbox(wxString("Overwrite already selected facets"), m_overwrite_selected);
|
||||
if (m_imgui->button("Enforce"))
|
||||
select_facets_by_angle(m_angle_threshold_deg, m_overwrite_selected, false);
|
||||
select_facets_by_angle(m_angle_threshold_deg, false);
|
||||
ImGui::SameLine();
|
||||
if (m_imgui->button("Block"))
|
||||
select_facets_by_angle(m_angle_threshold_deg, m_overwrite_selected, true);
|
||||
select_facets_by_angle(m_angle_threshold_deg, true);
|
||||
ImGui::SameLine();
|
||||
if (m_imgui->button("Cancel"))
|
||||
m_setting_angle = false;
|
||||
|
|
@ -787,9 +647,7 @@ CommonGizmosDataID GLGizmoFdmSupports::on_get_requirements() const
|
|||
int(CommonGizmosDataID::SelectionInfo)
|
||||
| int(CommonGizmosDataID::InstancesHider)
|
||||
| int(CommonGizmosDataID::Raycaster)
|
||||
| int(CommonGizmosDataID::HollowedMesh)
|
||||
| int(CommonGizmosDataID::ObjectClipper)
|
||||
| int(CommonGizmosDataID::SupportsClipper));
|
||||
| int(CommonGizmosDataID::ObjectClipper));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -813,8 +671,8 @@ void GLGizmoFdmSupports::on_set_state()
|
|||
}
|
||||
activate_internal_undo_redo_stack(false);
|
||||
m_old_mo_id = -1;
|
||||
m_ivas.clear();
|
||||
m_selected_facets.clear();
|
||||
//m_iva.release_geometry();
|
||||
m_triangle_selectors.clear();
|
||||
}
|
||||
m_old_state = m_state;
|
||||
}
|
||||
|
|
@ -852,6 +710,151 @@ void GLGizmoFdmSupports::on_save(cereal::BinaryOutputArchive&) const
|
|||
}
|
||||
|
||||
|
||||
void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
||||
{
|
||||
int enf_cnt = 0;
|
||||
int blc_cnt = 0;
|
||||
|
||||
m_iva_enforcers.release_geometry();
|
||||
m_iva_blockers.release_geometry();
|
||||
|
||||
for (const Triangle& tr : m_triangles) {
|
||||
if (! tr.valid || tr.is_split() || tr.get_state() == FacetSupportType::NONE)
|
||||
continue;
|
||||
|
||||
GLIndexedVertexArray& va = tr.get_state() == FacetSupportType::ENFORCER
|
||||
? m_iva_enforcers
|
||||
: m_iva_blockers;
|
||||
int& cnt = tr.get_state() == FacetSupportType::ENFORCER
|
||||
? enf_cnt
|
||||
: blc_cnt;
|
||||
|
||||
for (int i=0; i<3; ++i)
|
||||
va.push_geometry(double(m_vertices[tr.verts_idxs[i]].v[0]),
|
||||
double(m_vertices[tr.verts_idxs[i]].v[1]),
|
||||
double(m_vertices[tr.verts_idxs[i]].v[2]),
|
||||
0., 0., 1.);
|
||||
va.push_triangle(cnt,
|
||||
cnt+1,
|
||||
cnt+2);
|
||||
cnt += 3;
|
||||
}
|
||||
|
||||
m_iva_enforcers.finalize_geometry(true);
|
||||
m_iva_blockers.finalize_geometry(true);
|
||||
|
||||
if (m_iva_enforcers.has_VBOs()) {
|
||||
::glColor4f(0.f, 0.f, 1.f, 0.2f);
|
||||
m_iva_enforcers.render();
|
||||
}
|
||||
|
||||
|
||||
if (m_iva_blockers.has_VBOs()) {
|
||||
::glColor4f(1.f, 0.f, 0.f, 0.2f);
|
||||
m_iva_blockers.render();
|
||||
}
|
||||
|
||||
|
||||
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
||||
if (imgui)
|
||||
render_debug(imgui);
|
||||
else
|
||||
assert(false); // If you want debug output, pass ptr to ImGuiWrapper.
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
||||
void TriangleSelectorGUI::render_debug(ImGuiWrapper* imgui)
|
||||
{
|
||||
imgui->begin(std::string("TriangleSelector dialog (DEV ONLY)"),
|
||||
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
static float edge_limit = 1.f;
|
||||
imgui->text("Edge limit (mm): ");
|
||||
imgui->slider_float("", &edge_limit, 0.1f, 8.f);
|
||||
set_edge_limit(edge_limit);
|
||||
imgui->checkbox("Show split triangles: ", m_show_triangles);
|
||||
imgui->checkbox("Show invalid triangles: ", m_show_invalid);
|
||||
|
||||
int valid_triangles = m_triangles.size() - m_invalid_triangles;
|
||||
imgui->text("Valid triangles: " + std::to_string(valid_triangles) +
|
||||
"/" + std::to_string(m_triangles.size()));
|
||||
imgui->text("Vertices: " + std::to_string(m_vertices.size()));
|
||||
if (imgui->button("Force garbage collection"))
|
||||
garbage_collect();
|
||||
|
||||
if (imgui->button("Serialize - deserialize")) {
|
||||
auto map = serialize();
|
||||
deserialize(map);
|
||||
}
|
||||
|
||||
imgui->end();
|
||||
|
||||
if (! m_show_triangles)
|
||||
return;
|
||||
|
||||
enum vtype {
|
||||
ORIGINAL = 0,
|
||||
SPLIT,
|
||||
INVALID
|
||||
};
|
||||
|
||||
for (auto& va : m_varrays)
|
||||
va.release_geometry();
|
||||
|
||||
std::array<int, 3> cnts;
|
||||
|
||||
::glScalef(1.01f, 1.01f, 1.01f);
|
||||
|
||||
for (int tr_id=0; tr_id<int(m_triangles.size()); ++tr_id) {
|
||||
const Triangle& tr = m_triangles[tr_id];
|
||||
GLIndexedVertexArray* va = nullptr;
|
||||
int* cnt = nullptr;
|
||||
if (tr_id < m_orig_size_indices) {
|
||||
va = &m_varrays[ORIGINAL];
|
||||
cnt = &cnts[ORIGINAL];
|
||||
}
|
||||
else if (tr.valid) {
|
||||
va = &m_varrays[SPLIT];
|
||||
cnt = &cnts[SPLIT];
|
||||
}
|
||||
else {
|
||||
if (! m_show_invalid)
|
||||
continue;
|
||||
va = &m_varrays[INVALID];
|
||||
cnt = &cnts[INVALID];
|
||||
}
|
||||
|
||||
for (int i=0; i<3; ++i)
|
||||
va->push_geometry(double(m_vertices[tr.verts_idxs[i]].v[0]),
|
||||
double(m_vertices[tr.verts_idxs[i]].v[1]),
|
||||
double(m_vertices[tr.verts_idxs[i]].v[2]),
|
||||
0., 0., 1.);
|
||||
va->push_triangle(*cnt,
|
||||
*cnt+1,
|
||||
*cnt+2);
|
||||
*cnt += 3;
|
||||
}
|
||||
|
||||
::glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
|
||||
for (vtype i : {ORIGINAL, SPLIT, INVALID}) {
|
||||
GLIndexedVertexArray& va = m_varrays[i];
|
||||
va.finalize_geometry(true);
|
||||
if (va.has_VBOs()) {
|
||||
switch (i) {
|
||||
case ORIGINAL : ::glColor3f(0.f, 0.f, 1.f); break;
|
||||
case SPLIT : ::glColor3f(1.f, 0.f, 0.f); break;
|
||||
case INVALID : ::glColor3f(1.f, 1.f, 0.f); break;
|
||||
}
|
||||
va.render();
|
||||
}
|
||||
}
|
||||
::glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
|||
|
|
@ -6,10 +6,13 @@
|
|||
#include "slic3r/GUI/3DScene.hpp"
|
||||
|
||||
#include "libslic3r/ObjectID.hpp"
|
||||
#include "libslic3r/TriangleSelector.hpp"
|
||||
|
||||
#include <cereal/types/vector.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
enum class FacetSupportType : int8_t;
|
||||
|
|
@ -19,6 +22,31 @@ namespace GUI {
|
|||
enum class SLAGizmoEventType : unsigned char;
|
||||
class ClippingPlane;
|
||||
|
||||
|
||||
|
||||
class TriangleSelectorGUI : public TriangleSelector {
|
||||
public:
|
||||
explicit TriangleSelectorGUI(const TriangleMesh& mesh)
|
||||
: TriangleSelector(mesh) {}
|
||||
|
||||
// Render current selection. Transformation matrices are supposed
|
||||
// to be already set.
|
||||
void render(ImGuiWrapper* imgui = nullptr);
|
||||
|
||||
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
||||
void render_debug(ImGuiWrapper* imgui);
|
||||
bool m_show_triangles{false};
|
||||
bool m_show_invalid{false};
|
||||
#endif
|
||||
|
||||
private:
|
||||
GLIndexedVertexArray m_iva_enforcers;
|
||||
GLIndexedVertexArray m_iva_blockers;
|
||||
std::array<GLIndexedVertexArray, 3> m_varrays;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class GLGizmoFdmSupports : public GLGizmoBase
|
||||
{
|
||||
private:
|
||||
|
|
@ -28,24 +56,12 @@ private:
|
|||
GLUquadricObj* m_quadric;
|
||||
|
||||
float m_cursor_radius = 2.f;
|
||||
static constexpr float CursorRadiusMin = 0.f;
|
||||
static constexpr float CursorRadiusMin = 0.4f; // cannot be zero
|
||||
static constexpr float CursorRadiusMax = 8.f;
|
||||
static constexpr float CursorRadiusStep = 0.2f;
|
||||
|
||||
// For each model-part volume, store a list of statuses of
|
||||
// individual facets (one of the enum values above).
|
||||
std::vector<std::vector<FacetSupportType>> m_selected_facets;
|
||||
|
||||
// Vertex buffer arrays for each model-part volume. There is a vector of
|
||||
// arrays so that adding triangles can be done without regenerating all
|
||||
// other triangles. Enforcers and blockers are of course separate.
|
||||
std::vector<std::array<std::vector<GLIndexedVertexArray>, 2>> m_ivas;
|
||||
|
||||
void update_vertex_buffers(const TriangleMesh* mesh,
|
||||
int mesh_id,
|
||||
FacetSupportType type, // enforcers / blockers
|
||||
const std::vector<size_t>* new_facets = nullptr); // nullptr -> regenerate all
|
||||
|
||||
// For each model-part volume, store status and division of the triangles.
|
||||
std::vector<std::unique_ptr<TriangleSelectorGUI>> m_triangle_selectors;
|
||||
|
||||
public:
|
||||
GLGizmoFdmSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
|
|
@ -66,8 +82,7 @@ private:
|
|||
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;
|
||||
void select_facets_by_angle(float threshold, bool block);
|
||||
float m_angle_threshold_deg = 45.f;
|
||||
|
||||
bool is_mesh_point_clipped(const Vec3d& point) const;
|
||||
|
|
|
|||
|
|
@ -182,6 +182,9 @@ bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt)
|
|||
io.MouseDown[0] = evt.LeftIsDown();
|
||||
io.MouseDown[1] = evt.RightIsDown();
|
||||
io.MouseDown[2] = evt.MiddleIsDown();
|
||||
float wheel_delta = static_cast<float>(evt.GetWheelDelta());
|
||||
if (wheel_delta != 0.0f)
|
||||
io.MouseWheel = static_cast<float>(evt.GetWheelRotation()) / wheel_delta;
|
||||
|
||||
unsigned buttons = (evt.LeftIsDown() ? 1 : 0) | (evt.RightIsDown() ? 2 : 0) | (evt.MiddleIsDown() ? 4 : 0);
|
||||
m_mouse_buttons = buttons;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
m_statusbar->embed(this);
|
||||
m_statusbar->set_status_text(_(L("Version")) + " " +
|
||||
SLIC3R_VERSION +
|
||||
_(L(" - Remember to check for updates at http://github.com/prusa3d/PrusaSlicer/releases")));
|
||||
_(L(" - Remember to check for updates at https://github.com/prusa3d/PrusaSlicer/releases")));
|
||||
|
||||
/* Load default preset bitmaps before a tabpanel initialization,
|
||||
* but after filling of an em_unit value
|
||||
|
|
@ -892,8 +892,8 @@ static wxMenu* generate_help_menu()
|
|||
wxMenu* helpMenu = new wxMenu();
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Prusa 3D &Drivers"), _L("Open the Prusa3D drivers download page in your browser"),
|
||||
[](wxCommandEvent&) { wxGetApp().open_web_page_localized("https://www.prusa3d.com/downloads"); });
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Software &Releases"), _L("Open the software releases page in your browser"),
|
||||
[](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/prusa3d/PrusaSlicer/releases"); });
|
||||
append_menu_item(helpMenu, wxID_ANY, _(L("Software &Releases")), _(L("Open the software releases page in your browser")),
|
||||
[](wxCommandEvent&) { wxLaunchDefaultBrowser("https://github.com/prusa3d/PrusaSlicer/releases"); });
|
||||
//# my $versioncheck = $self->_append_menu_item($helpMenu, "Check for &Updates...", "Check for new Slic3r versions", sub{
|
||||
//# wxTheApp->check_version(1);
|
||||
//# });
|
||||
|
|
@ -909,8 +909,8 @@ static wxMenu* generate_help_menu()
|
|||
[](wxCommandEvent&) { wxGetApp().system_info(); });
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Show &Configuration Folder"), _L("Show user configuration folder (datadir)"),
|
||||
[](wxCommandEvent&) { Slic3r::GUI::desktop_open_datadir_folder(); });
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Report an I&ssue"), wxString::Format(_L("Report an issue on %s"), SLIC3R_APP_NAME),
|
||||
[](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/prusa3d/slic3r/issues/new"); });
|
||||
append_menu_item(helpMenu, wxID_ANY, _(L"Report an I&ssue"), wxString::Format(_L("Report an issue on %s"), SLIC3R_APP_NAME),
|
||||
[](wxCommandEvent&) { wxLaunchDefaultBrowser("https://github.com/prusa3d/slic3r/issues/new"); });
|
||||
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_L("&About %s"), SLIC3R_APP_NAME), _L("Show about dialog"),
|
||||
[](wxCommandEvent&) { Slic3r::GUI::about(); });
|
||||
helpMenu->AppendSeparator();
|
||||
|
|
@ -1042,7 +1042,7 @@ void MainFrame::init_menubar()
|
|||
|
||||
wxMenu* export_menu = new wxMenu();
|
||||
wxMenuItem* item_export_gcode = append_menu_item(export_menu, wxID_ANY, _L("Export &G-code") + dots +"\tCtrl+G", _L("Export current plate as G-code"),
|
||||
[this](wxCommandEvent&) { if (m_plater) m_plater->export_gcode(); }, "export_gcode", nullptr,
|
||||
[this](wxCommandEvent&) { if (m_plater) m_plater->export_gcode(false); }, "export_gcode", nullptr,
|
||||
[this](){return can_export_gcode(); }, this);
|
||||
m_changeable_menu_items.push_back(item_export_gcode);
|
||||
wxMenuItem* item_send_gcode = append_menu_item(export_menu, wxID_ANY, _L("S&end G-code") + dots +"\tCtrl+Shift+G", _L("Send to print current plate as G-code"),
|
||||
|
|
@ -1294,7 +1294,7 @@ void MainFrame::init_menubar()
|
|||
append_menu_item(helpMenu, wxID_ANY, _L("Prusa 3D &Drivers"), _L("Open the Prusa3D drivers download page in your browser"),
|
||||
[this](wxCommandEvent&) { wxGetApp().open_web_page_localized("https://www.prusa3d.com/downloads"); });
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Software &Releases"), _L("Open the software releases page in your browser"),
|
||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/prusa3d/PrusaSlicer/releases"); });
|
||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("https://github.com/prusa3d/PrusaSlicer/releases"); });
|
||||
//# my $versioncheck = $self->_append_menu_item($helpMenu, "Check for &Updates...", "Check for new Slic3r versions", sub{
|
||||
//# wxTheApp->check_version(1);
|
||||
//# });
|
||||
|
|
@ -1311,8 +1311,8 @@ void MainFrame::init_menubar()
|
|||
append_menu_item(helpMenu, wxID_ANY, _L("Show &Configuration Folder"), _L("Show user configuration folder (datadir)"),
|
||||
[this](wxCommandEvent&) { Slic3r::GUI::desktop_open_datadir_folder(); });
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Report an I&ssue"), wxString::Format(_L("Report an issue on %s"), SLIC3R_APP_NAME),
|
||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/prusa3d/slic3r/issues/new"); });
|
||||
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_L("&About %s"), SLIC3R_APP_NAME), _L("Show about dialog"),
|
||||
[this](wxCommandEvent&) { wxLaunchDefaultBrowser("https://github.com/prusa3d/slic3r/issues/new"); });
|
||||
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_(L("&About %s")), SLIC3R_APP_NAME), _(L("Show about dialog")),
|
||||
[this](wxCommandEvent&) { Slic3r::GUI::about(); });
|
||||
helpMenu->AppendSeparator();
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Keyboard Shortcuts") + sep + "&?", _L("Show the list of the keyboard shortcuts"),
|
||||
|
|
@ -1849,6 +1849,7 @@ void MainFrame::load_config(const DynamicPrintConfig& config)
|
|||
|
||||
void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
||||
{
|
||||
bool tabpanel_was_hidden = false;
|
||||
#if ENABLE_LAYOUT_NO_RESTART
|
||||
if (m_layout == ESettingsLayout::Dlg) {
|
||||
#else
|
||||
|
|
@ -1879,6 +1880,7 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
|||
if (m_settings_dialog.IsShown())
|
||||
m_settings_dialog.SetFocus();
|
||||
else {
|
||||
tabpanel_was_hidden = true;
|
||||
m_tabpanel->Show();
|
||||
m_settings_dialog.Show();
|
||||
}
|
||||
|
|
@ -1898,6 +1900,7 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
|||
#if ENABLE_LAYOUT_NO_RESTART
|
||||
else if (m_layout == ESettingsLayout::New) {
|
||||
m_main_sizer->Show(m_plater, tab == 0);
|
||||
tabpanel_was_hidden = !m_main_sizer->IsShown(m_tabpanel);
|
||||
m_main_sizer->Show(m_tabpanel, tab != 0);
|
||||
#else
|
||||
else if (m_layout == slNew) {
|
||||
|
|
@ -1911,6 +1914,14 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
|||
Layout();
|
||||
}
|
||||
|
||||
// When we run application in ESettingsLayout::New or ESettingsLayout::Dlg mode, tabpanel is hidden from the very beginning
|
||||
// and as a result Tab::update_changed_tree_ui() function couldn't update m_is_nonsys_values values,
|
||||
// which are used for update TreeCtrl and "revert_buttons".
|
||||
// So, force the call of this function for Tabs, if tab panel was hidden
|
||||
if (tabpanel_was_hidden)
|
||||
for (auto tab : wxGetApp().tabs_list)
|
||||
tab->update_changed_tree_ui();
|
||||
|
||||
// when tab == -1, it means we should show the last selected tab
|
||||
#if ENABLE_LAYOUT_NO_RESTART
|
||||
m_tabpanel->SetSelection(tab == (size_t)(-1) ? m_last_selected_tab : (m_layout == ESettingsLayout::Dlg && tab != 0) ? tab - 1 : tab);
|
||||
|
|
|
|||
|
|
@ -935,7 +935,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||
{
|
||||
const bool export_gcode_after_slicing = wxGetKeyState(WXK_SHIFT);
|
||||
if (export_gcode_after_slicing)
|
||||
p->plater->export_gcode();
|
||||
p->plater->export_gcode(true);
|
||||
else
|
||||
p->plater->reslice();
|
||||
p->plater->select_view_3D("Preview");
|
||||
|
|
@ -3548,7 +3548,7 @@ void Plater::priv::on_slicing_completed(wxCommandEvent &)
|
|||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
||||
{
|
||||
|
|
@ -3608,7 +3608,10 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
|||
show_action_buttons(true);
|
||||
}
|
||||
else if (this->writing_to_removable_device || wxGetApp().get_mode() == comSimple)
|
||||
{
|
||||
wxGetApp().removable_drive_manager()->set_exporting_finished(true);
|
||||
show_action_buttons(false);
|
||||
}
|
||||
this->writing_to_removable_device = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ public:
|
|||
|
||||
void cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false);
|
||||
|
||||
void export_gcode(bool prefer_removable = true);
|
||||
void export_gcode(bool prefer_removable);
|
||||
void export_stl(bool extended = false, bool selection_only = false);
|
||||
void export_amf();
|
||||
void export_3mf(const boost::filesystem::path& output_path = boost::filesystem::path());
|
||||
|
|
|
|||
|
|
@ -393,6 +393,7 @@ bool RemovableDriveManager::set_and_verify_last_save_path(const std::string &pat
|
|||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
m_last_save_path = this->get_removable_drive_from_path(path);
|
||||
m_exporting_finished = false;
|
||||
return ! m_last_save_path.empty();
|
||||
}
|
||||
|
||||
|
|
@ -407,6 +408,7 @@ RemovableDriveManager::RemovableDrivesStatus RemovableDriveManager::status()
|
|||
}
|
||||
if (! out.has_eject)
|
||||
m_last_save_path.clear();
|
||||
out.has_eject = out.has_eject && m_exporting_finished;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public:
|
|||
// Public to be accessible from RemovableDriveManagerMM::on_device_unmount OSX notification handler.
|
||||
// It would be better to make this method private and friend to RemovableDriveManagerMM, but RemovableDriveManagerMM is an ObjectiveC class.
|
||||
void update();
|
||||
|
||||
void set_exporting_finished(bool b) { m_exporting_finished = b; }
|
||||
#ifdef _WIN32
|
||||
// Called by Win32 Volume arrived / detached callback.
|
||||
void volumes_changed();
|
||||
|
|
@ -121,7 +121,9 @@ private:
|
|||
std::vector<DriveData>::const_iterator find_last_save_path_drive_data() const;
|
||||
// Set with set_and_verify_last_save_path() to a removable drive path to be ejected.
|
||||
std::string m_last_save_path;
|
||||
|
||||
// Verifies that exporting was finished so drive can be ejected.
|
||||
// Set false by set_and_verify_last_save_path() that is called just before exporting.
|
||||
bool m_exporting_finished;
|
||||
#if __APPLE__
|
||||
void register_window_osx();
|
||||
void unregister_window_osx();
|
||||
|
|
|
|||
|
|
@ -1595,20 +1595,21 @@ void Selection::update_type()
|
|||
}
|
||||
else
|
||||
{
|
||||
unsigned int sla_volumes_count = 0;
|
||||
// Note: sla_volumes_count is a count of the selected sla_volumes per object instead of per instance, like a model_volumes_count is
|
||||
for (unsigned int i : m_list) {
|
||||
if ((*m_volumes)[i]->volume_idx() < 0)
|
||||
++sla_volumes_count;
|
||||
}
|
||||
|
||||
if (m_cache.content.size() == 1) // single object
|
||||
{
|
||||
const ModelObject* model_object = m_model->objects[m_cache.content.begin()->first];
|
||||
unsigned int model_volumes_count = (unsigned int)model_object->volumes.size();
|
||||
unsigned int sla_volumes_count = 0;
|
||||
for (unsigned int i : m_list)
|
||||
{
|
||||
if ((*m_volumes)[i]->volume_idx() < 0)
|
||||
++sla_volumes_count;
|
||||
}
|
||||
unsigned int volumes_count = model_volumes_count + sla_volumes_count;
|
||||
|
||||
unsigned int instances_count = (unsigned int)model_object->instances.size();
|
||||
unsigned int selected_instances_count = (unsigned int)m_cache.content.begin()->second.size();
|
||||
if (volumes_count * instances_count == (unsigned int)m_list.size())
|
||||
if (model_volumes_count * instances_count + sla_volumes_count == (unsigned int)m_list.size())
|
||||
{
|
||||
m_type = SingleFullObject;
|
||||
// ensures the correct mode is selected
|
||||
|
|
@ -1616,7 +1617,7 @@ void Selection::update_type()
|
|||
}
|
||||
else if (selected_instances_count == 1)
|
||||
{
|
||||
if (volumes_count == (unsigned int)m_list.size())
|
||||
if (model_volumes_count + sla_volumes_count == (unsigned int)m_list.size())
|
||||
{
|
||||
m_type = SingleFullInstance;
|
||||
// ensures the correct mode is selected
|
||||
|
|
@ -1639,7 +1640,7 @@ void Selection::update_type()
|
|||
requires_disable = true;
|
||||
}
|
||||
}
|
||||
else if ((selected_instances_count > 1) && (selected_instances_count * volumes_count == (unsigned int)m_list.size()))
|
||||
else if ((selected_instances_count > 1) && (selected_instances_count * model_volumes_count + sla_volumes_count == (unsigned int)m_list.size()))
|
||||
{
|
||||
m_type = MultipleFullInstance;
|
||||
// ensures the correct mode is selected
|
||||
|
|
@ -1656,7 +1657,7 @@ void Selection::update_type()
|
|||
unsigned int instances_count = (unsigned int)model_object->instances.size();
|
||||
sels_cntr += volumes_count * instances_count;
|
||||
}
|
||||
if (sels_cntr == (unsigned int)m_list.size())
|
||||
if (sels_cntr + sla_volumes_count == (unsigned int)m_list.size())
|
||||
{
|
||||
m_type = MultipleFullObject;
|
||||
// ensures the correct mode is selected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue