This commit is contained in:
Vojtech Bubnik 2023-05-25 10:02:34 +02:00
commit 5bdde0cf4e
32 changed files with 39035 additions and 36166 deletions

View File

@ -2186,11 +2186,11 @@ msgid "Filament"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2361,11 +2361,11 @@ msgid "Filament"
msgstr "Філамент"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2404,11 +2404,11 @@ msgid "Filament"
msgstr "Filament"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2195,11 +2195,11 @@ msgid "Filament"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2358,11 +2358,11 @@ msgid "Filament"
msgstr "Filament"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2258,11 +2258,11 @@ msgid "Filament"
msgstr "필라멘트"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2285,11 +2285,11 @@ msgid "Filament"
msgstr "필라멘트 설정을 선택"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2285,11 +2285,11 @@ msgid "Filament"
msgstr "필라멘트 설정을 선택"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2363,11 +2363,11 @@ msgid "Filament"
msgstr "Filament"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

File diff suppressed because it is too large Load Diff

View File

@ -2361,11 +2361,11 @@ msgid "Filament"
msgstr "Filamento"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2396,11 +2396,11 @@ msgid "Filament"
msgstr "Профиль прутка"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2366,11 +2366,11 @@ msgid "Filament"
msgstr "Filament"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2311,11 +2311,11 @@ msgid "Filament"
msgstr "Філамент"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2275,11 +2275,11 @@ msgid "Filament"
msgstr "耗材"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -2271,11 +2271,11 @@ msgid "Filament"
msgstr "線材"
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Hide Custom GCode"
msgid "Hide Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3954
msgid "Show Custom GCode"
msgid "Show Custom G-code"
msgstr ""
#: src/slic3r/GUI/GCodeViewer.cpp:3967

View File

@ -3961,7 +3961,7 @@ void GCodeViewer::render_legend(float& legend_height)
const auto custom_it = std::find(m_roles.begin(), m_roles.end(), GCodeExtrusionRole::Custom);
if (custom_it != m_roles.end()) {
const bool custom_visible = is_visible(GCodeExtrusionRole::Custom);
const wxString btn_text = custom_visible ? _u8L("Hide Custom GCode") : _u8L("Show Custom GCode");
const wxString btn_text = custom_visible ? _u8L("Hide Custom G-code") : _u8L("Show Custom G-code");
ImGui::Separator();
if (imgui.button(btn_text, ImVec2(-1.0f, 0.0f), true)) {
m_extrusions.role_visibility_flags = custom_visible ? m_extrusions.role_visibility_flags & ~(1 << int(GCodeExtrusionRole::Custom)) :

View File

@ -22,6 +22,7 @@ namespace GUI {
static const ColorRGBA GRABBER_COLOR = ColorRGBA::YELLOW();
static const ColorRGBA UPPER_PART_COLOR = ColorRGBA::CYAN();
static const ColorRGBA LOWER_PART_COLOR = ColorRGBA::MAGENTA();
static const ColorRGBA MODIFIER_COLOR = ColorRGBA(0.75f, 0.75f, 0.75f, 0.5f);
// connector colors
static const ColorRGBA PLAG_COLOR = ColorRGBA::YELLOW();
@ -1405,7 +1406,7 @@ GLGizmoCut3D::PartSelection::PartSelection(const ModelObject* mo, const Transfor
m_parts.clear();
for (const ModelVolume* volume : volumes) {
assert(volume != nullptr);
m_parts.emplace_back(Part{GLModel(), MeshRaycaster(volume->mesh()), true});
m_parts.emplace_back(Part{GLModel(), MeshRaycaster(volume->mesh()), true, !volume->is_model_part()});
m_parts.back().glmodel.set_color({ 0.f, 0.f, 1.f, 1.f });
m_parts.back().glmodel.init_from(volume->mesh());
@ -1484,13 +1485,19 @@ void GLGizmoCut3D::PartSelection::render(const Vec3d* normal, GLModel& sphere_mo
const bool is_looking_forward = normal && camera.get_dir_forward().dot(*normal) < 0.05;
for (size_t id=0; id<m_parts.size(); ++id) {
if (normal && (( is_looking_forward && m_parts[id].selected) ||
(!is_looking_forward && !m_parts[id].selected) ) )
if (!m_parts[id].is_modifier && normal && ((is_looking_forward && m_parts[id].selected) ||
(!is_looking_forward && !m_parts[id].selected) ) )
continue;
const Vec3d volume_offset = model_object()->volumes[id]->get_offset();
shader->set_uniform("view_model_matrix", view_inst_matrix * translation_transform(volume_offset));
m_parts[id].glmodel.set_color(m_parts[id].selected ? UPPER_PART_COLOR : LOWER_PART_COLOR);
if (m_parts[id].is_modifier) {
glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
}
m_parts[id].glmodel.set_color(m_parts[id].is_modifier ? MODIFIER_COLOR : (m_parts[id].selected ? UPPER_PART_COLOR : LOWER_PART_COLOR));
m_parts[id].glmodel.render();
if (m_parts[id].is_modifier)
glsafe(::glDisable(GL_BLEND));
}
shader->stop_using();
@ -1551,7 +1558,7 @@ bool GLGizmoCut3D::PartSelection::is_one_object() const
if (m_parts.size() < 2)
return true;
return std::all_of(m_parts.begin(), m_parts.end(), [this](const Part& part) {
return part.selected == m_parts.front().selected;
return part.is_modifier || part.selected == m_parts.front().selected;
});
}
@ -2535,29 +2542,66 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
};
const size_t cut_parts_cnt = m_part_selection.parts().size();
bool has_modifiers = false;
// Distribute SolidParts to the Upper/Lower object
for (size_t id = 0; id < cut_parts_cnt; ++id) {
if (ModelObject* obj = (m_part_selection.parts()[id].selected ? upper : lower))
if (m_part_selection.parts()[id].is_modifier)
has_modifiers = true; // modifiers will be added later to the related parts
else if (ModelObject* obj = (m_part_selection.parts()[id].selected ? upper : lower))
obj->add_volume(*(cut_mo->volumes[id]));
}
if (has_modifiers) {
// Distribute Modifiers to the Upper/Lower object
auto upper_bb = upper ? upper->instance_bounding_box(instance_idx) : BoundingBoxf3();
auto lower_bb = lower ? lower->instance_bounding_box(instance_idx) : BoundingBoxf3();
const Transform3d inst_matrix = cut_mo->instances[instance_idx]->get_transformation().get_matrix();
for (size_t id = 0; id < cut_parts_cnt; ++id)
if (m_part_selection.parts()[id].is_modifier) {
ModelVolume* vol = cut_mo->volumes[id];
auto bb = vol->mesh().transformed_bounding_box(inst_matrix * vol->get_matrix());
// Don't add modifiers which are not intersecting with solid parts
if (upper_bb.intersects(bb))
upper->add_volume(*vol);
if (lower_bb.intersects(bb))
lower->add_volume(*vol);
}
}
ModelVolumePtrs& volumes = cut_mo->volumes;
if (volumes.size() == cut_parts_cnt)
if (volumes.size() == cut_parts_cnt) {
// Means that object is cut without connectors
// Just add Upper and Lower objects to cut_object_ptrs and invalidate any cut information
add_cut_objects(cut_object_ptrs, upper, lower);
}
else if (volumes.size() > cut_parts_cnt) {
// Means that object is cut with connectors
// All volumes are distributed to Upper / Lower object,
// So we dont need them anymore
for (size_t id = 0; id < cut_parts_cnt; id++)
delete *(volumes.begin() + id);
volumes.erase(volumes.begin(), volumes.begin() + cut_parts_cnt);
// Perform cut just to get connectors
const ModelObjectPtrs cut_connectors_obj = cut_mo->cut(instance_idx, get_cut_matrix(selection), attributes);
assert(create_dowels_as_separate_object ? cut_connectors_obj.size() >= 3 : cut_connectors_obj.size() == 2);
// Connectors from upper object
for (const ModelVolume* volume : cut_connectors_obj[0]->volumes)
upper->add_volume(*volume, volume->type());
// Connectors from lower object
for (const ModelVolume* volume : cut_connectors_obj[1]->volumes)
lower->add_volume(*volume, volume->type());
// Add Upper and Lower objects to cut_object_ptrs with saved cut information
add_cut_objects(cut_object_ptrs, upper, lower, false);
// Add Dowel-connectors as separate objects to cut_object_ptrs
if (cut_connectors_obj.size() >= 3)
for (size_t id = 2; id < cut_connectors_obj.size(); id++)
cut_object_ptrs.push_back(cut_connectors_obj[id]);
@ -2567,8 +2611,9 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
{
for (ModelObject* mo : cut_object_ptrs) {
TriangleMesh mesh;
// Merge all SolidPart but not Connectors
for (const ModelVolume* mv : mo->volumes) {
if (mv->is_model_part()) {
if (mv->is_model_part() && !mv->is_cut_connector()) {
TriangleMesh m = mv->mesh();
m.transform(mv->get_matrix());
mesh.merge(m);
@ -2576,9 +2621,13 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
}
if (! mesh.empty()) {
ModelVolume* new_volume = mo->add_volume(mesh);
for (int i=int(mo->volumes.size())-2; i>=0; --i)
if (mo->volumes[i]->type() == ModelVolumeType::MODEL_PART)
new_volume->name = mo->name;
// Delete all merged SolidPart but not Connectors
for (int i=int(mo->volumes.size())-2; i>=0; --i) {
const ModelVolume* mv = mo->volumes[i];
if (mv->is_model_part() && !mv->is_cut_connector())
mo->delete_volume(i);
}
}
}
}

View File

@ -149,6 +149,7 @@ class GLGizmoCut3D : public GLGizmoBase
GLModel glmodel;
MeshRaycaster raycaster;
bool selected;
bool is_modifier;
};
void render(const Vec3d* normal, GLModel& sphere_model);