Skip to content

Commit

Permalink
ENH:brim ears prompt to set manual type [STUDIO-8407]
Browse files Browse the repository at this point in the history
[STUDIO-8401]slicer failed

[STUDIO-8402]unable to save modified brim data

jira: details
Change-Id: I354bbf2c55bad41e09a1558cb6bddf49fc87f7c7
  • Loading branch information
MackBambu authored and lanewei120 committed Oct 15, 2024
1 parent 4651bec commit 754198c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/libslic3r/Brim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ double configBrimWidthByVolumeGroups(double adhension, double maxSpeed, const st
return brim_width;
}

static ExPolygons make_brim_ears(const PrintObject* object, double flowWidth, float brim_offset, Flow &flow, bool is_outer_brim)
static ExPolygons make_brim_ears(const PrintObject* object, const double& flowWidth, float brim_offset, Flow &flow, bool is_outer_brim)
{
ExPolygons mouse_ears_ex;
BrimPoints brim_ear_points = object->model_object()->brim_points;
Expand All @@ -815,15 +815,14 @@ static ExPolygons make_brim_ears(const PrintObject* object, double flowWidth, fl
Transform3d model_trsf = trsf.get_matrix(true);
const Point &center_offset = object->center_offset();
model_trsf = model_trsf.pretranslate(Vec3d(- unscale<double>(center_offset.x()), - unscale<double>(center_offset.y()), 0));

for (auto &pt : brim_ear_points) {
Vec3f world_pos = pt.transform(trsf.get_matrix());
if ( world_pos.z() > 0) continue;
Polygon point_round;
float brim_width = floor(scale_(pt.head_front_radius) / flowWidth / 2) * flowWidth * 2;
if (is_outer_brim) {
flowWidth = flowWidth / SCALING_FACTOR;
brim_width = floor(brim_width / flowWidth / 2) * flowWidth * 2;
double flowWidthScale = flowWidth / SCALING_FACTOR;
brim_width = floor(brim_width / flowWidthScale / 2) * flowWidthScale * 2;
}
coord_t size_ear = (brim_width - brim_offset - flow.scaled_spacing());
for (size_t i = 0; i < POLY_SIDE_COUNT; i++) {
Expand Down
43 changes: 42 additions & 1 deletion src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ void GLGizmoBrimEars::on_render_input_window(float x, float y, float bottom_limi

if (!mo) return;

const DynamicPrintConfig& obj_cfg = mo->config.get();
const DynamicPrintConfig& glb_cfg = wxGetApp().preset_bundle->prints.get_edited_preset().config;
const float win_h = ImGui::GetWindowHeight();
y = std::min(y, bottom_limit - win_h);
GizmoImguiSetNextWIndowPos(x, y, ImGuiCond_Always, 0.0f, 0.0f);
Expand Down Expand Up @@ -620,6 +622,44 @@ void GLGizmoBrimEars::on_render_input_window(float x, float y, float bottom_limi
}
ImGui::PopStyleVar(1);

if (glb_cfg.opt_enum<BrimType>("brim_type") != btBrimEars) {
auto link_text = [&]() {
ImColor HyperColor = ImColor(48, 221, 114, 255).Value;
ImGui::PushStyleColor(ImGuiCol_Text, ImGuiWrapper::to_ImVec4(ColorRGB::WARNING()));
float parent_width = ImGui::GetContentRegionAvail().x;
m_imgui->text(_L("Warning: The brim type is not set to manual,"));
m_imgui->text(_L("the brim ears will not take effect !"));
ImGui::PopStyleColor();
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, HyperColor.Value);
m_imgui->text(_L("(set)"));
ImGui::PopStyleColor();
if (ImGui::IsMouseHoveringRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), true)) {
// underline
ImVec2 lineEnd = ImGui::GetItemRectMax();
lineEnd.y -= 2.0f;
ImVec2 lineStart = lineEnd;
lineStart.x = ImGui::GetItemRectMin().x;
ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, HyperColor);

if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
DynamicPrintConfig new_conf = obj_cfg;
new_conf.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btBrimEars));
mo->config.assign_config(new_conf);
}
}
};

if (obj_cfg.option("brim_type")) {
if (obj_cfg.opt_enum<BrimType>("brim_type") != btBrimEars){
link_text();
}
}else {
link_text();
}

}

if (!m_single_brim.empty()) {
wxString out = _L("Warning") + ": " + std::to_string(m_single_brim.size()) + _L(" invalid brim ears");
m_imgui->warning_text(out);
Expand Down Expand Up @@ -675,7 +715,7 @@ bool GLGizmoBrimEars::on_is_activable() const
return true;
}

std::string GLGizmoBrimEars::on_get_name() const
std::string GLGizmoBrimEars::on_get_name() const
{
if (!on_is_activable() && m_state == EState::Off) {
return _u8L("Brim Ears") + ":\n" + _u8L("Please select single object.");
Expand Down Expand Up @@ -708,6 +748,7 @@ void GLGizmoBrimEars::on_set_state()
if (mo) {
mo->brim_points.clear();
for (const CacheEntry& ce : m_editing_cache) mo->brim_points.emplace_back(ce.brim_point);
wxGetApp().plater()->set_plater_dirty(true);
}
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
wxGetApp().plater()->leave_gizmos_stack();
Expand Down

0 comments on commit 754198c

Please sign in to comment.