mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-20 01:28:07 +08:00
SLA gizmo - combo replaced by slider, autogeneration uses config value for head_diameter
This commit is contained in:
parent
63b65bb3c8
commit
03beb1870b
@ -496,7 +496,7 @@ void SLAAutoSupports::uniformly_cover(const ExPolygons& islands, Structure& stru
|
|||||||
poisson_samples.erase(poisson_samples.begin() + poisson_samples_target, poisson_samples.end());
|
poisson_samples.erase(poisson_samples.begin() + poisson_samples_target, poisson_samples.end());
|
||||||
}
|
}
|
||||||
for (const Vec2f &pt : poisson_samples) {
|
for (const Vec2f &pt : poisson_samples) {
|
||||||
m_output.emplace_back(float(pt(0)), float(pt(1)), structure.height, 0.2f, is_new_island);
|
m_output.emplace_back(float(pt(0)), float(pt(1)), structure.height, m_config.head_diameter/2.f, is_new_island);
|
||||||
structure.supports_force_this_layer += m_config.support_force();
|
structure.supports_force_this_layer += m_config.support_force();
|
||||||
grid3d.insert(pt, &structure);
|
grid3d.insert(pt, &structure);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public:
|
|||||||
struct Config {
|
struct Config {
|
||||||
float density_relative;
|
float density_relative;
|
||||||
float minimal_distance;
|
float minimal_distance;
|
||||||
|
float head_diameter;
|
||||||
///////////////
|
///////////////
|
||||||
inline float support_force() const { return 10.f / density_relative; } // a force one point can support (arbitrary force unit)
|
inline float support_force() const { return 10.f / density_relative; } // a force one point can support (arbitrary force unit)
|
||||||
inline float tear_pressure() const { return 1.f; } // pressure that the display exerts (the force unit per mm2)
|
inline float tear_pressure() const { return 1.f; } // pressure that the display exerts (the force unit per mm2)
|
||||||
|
@ -673,6 +673,7 @@ void SLAPrint::process()
|
|||||||
// the density config value is in percents:
|
// the density config value is in percents:
|
||||||
config.density_relative = float(cfg.support_points_density_relative / 100.f);
|
config.density_relative = float(cfg.support_points_density_relative / 100.f);
|
||||||
config.minimal_distance = float(cfg.support_points_minimal_distance);
|
config.minimal_distance = float(cfg.support_points_minimal_distance);
|
||||||
|
config.head_diameter = float(cfg.support_head_front_diameter);
|
||||||
|
|
||||||
// Construction of this object does the calculation.
|
// Construction of this object does the calculation.
|
||||||
this->throw_if_canceled();
|
this->throw_if_canceled();
|
||||||
|
@ -2227,15 +2227,15 @@ void GLGizmoSlaSupports::render_tooltip_texture() const {
|
|||||||
#endif // not ENABLE_IMGUI
|
#endif // not ENABLE_IMGUI
|
||||||
|
|
||||||
|
|
||||||
std::vector<ConfigOption*> GLGizmoSlaSupports::get_config_options(const std::vector<std::string>& keys) const
|
std::vector<const ConfigOption*> GLGizmoSlaSupports::get_config_options(const std::vector<std::string>& keys) const
|
||||||
{
|
{
|
||||||
std::vector<ConfigOption*> out;
|
std::vector<const ConfigOption*> out;
|
||||||
|
|
||||||
if (!m_model_object)
|
if (!m_model_object)
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
DynamicPrintConfig& object_cfg = m_model_object->config;
|
const DynamicPrintConfig& object_cfg = m_model_object->config;
|
||||||
DynamicPrintConfig& print_cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
|
const DynamicPrintConfig& print_cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
|
||||||
std::unique_ptr<DynamicPrintConfig> default_cfg = nullptr;
|
std::unique_ptr<DynamicPrintConfig> default_cfg = nullptr;
|
||||||
|
|
||||||
for (const std::string& key : keys) {
|
for (const std::string& key : keys) {
|
||||||
@ -2268,7 +2268,7 @@ RENDER_AGAIN:
|
|||||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||||
|
|
||||||
const float scaling = m_imgui->get_style_scaling();
|
const float scaling = m_imgui->get_style_scaling();
|
||||||
const ImVec2 window_size(285.f * scaling, 260.f * scaling);
|
const ImVec2 window_size(285.f * scaling, 300.f * scaling);
|
||||||
ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) ));
|
ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) ));
|
||||||
ImGui::SetNextWindowSize(ImVec2(window_size));
|
ImGui::SetNextWindowSize(ImVec2(window_size));
|
||||||
|
|
||||||
@ -2287,30 +2287,19 @@ RENDER_AGAIN:
|
|||||||
m_imgui->text(_(L("Shift + Left (+ drag) - select point(s)")));
|
m_imgui->text(_(L("Shift + Left (+ drag) - select point(s)")));
|
||||||
m_imgui->text(" "); // vertical gap
|
m_imgui->text(" "); // vertical gap
|
||||||
|
|
||||||
static const std::vector<float> options = {0.2f, 0.4f, 0.6f, 0.8f, 1.0f};
|
float diameter_upper_cap = static_cast<ConfigOptionFloat*>(wxGetApp().preset_bundle->sla_prints.get_edited_preset().config.option("support_pillar_diameter"))->value;
|
||||||
static const std::vector<std::string> options_str = {"0.2", "0.4", "0.6", "0.8", "1.0"};
|
if (m_new_point_head_diameter > diameter_upper_cap)
|
||||||
int selection = -1;
|
m_new_point_head_diameter = diameter_upper_cap;
|
||||||
for (size_t i = 0; i < options.size(); i++) {
|
|
||||||
if (options[i] == m_new_point_head_diameter) { selection = (int)i; }
|
|
||||||
}
|
|
||||||
|
|
||||||
bool old_combo_state = m_combo_box_open;
|
m_imgui->text(_(L("Head diameter: ")));
|
||||||
// The combo is commented out for now, until the feature is supported by backend.
|
ImGui::SameLine();
|
||||||
m_combo_box_open = m_imgui->combo(_(L("Head diameter")), options_str, selection);
|
if (ImGui::SliderFloat("", &m_new_point_head_diameter, 0.1f, diameter_upper_cap, "%.1f")) {
|
||||||
force_refresh |= (old_combo_state != m_combo_box_open);
|
// value was changed
|
||||||
|
|
||||||
// float current_number = atof(str);
|
|
||||||
const float current_number = selection < options.size() ? options[selection] : m_new_point_head_diameter;
|
|
||||||
if (old_combo_state && !m_combo_box_open) // closing the combo must always change the sizes (even if the selection did not change)
|
|
||||||
for (auto& point_and_selection : m_editing_mode_cache)
|
for (auto& point_and_selection : m_editing_mode_cache)
|
||||||
if (point_and_selection.second) {
|
if (point_and_selection.second) {
|
||||||
point_and_selection.first.head_front_radius = current_number / 2.f;
|
point_and_selection.first.head_front_radius = m_new_point_head_diameter / 2.f;
|
||||||
m_unsaved_changes = true;
|
m_unsaved_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::abs(current_number - m_new_point_head_diameter) > 0.001) {
|
|
||||||
force_refresh = true;
|
|
||||||
m_new_point_head_diameter = current_number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed = m_lock_unique_islands;
|
bool changed = m_lock_unique_islands;
|
||||||
@ -2343,9 +2332,9 @@ RENDER_AGAIN:
|
|||||||
m_imgui->text(_(L("Minimal points distance: ")));
|
m_imgui->text(_(L("Minimal points distance: ")));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
std::vector<ConfigOption*> opts = get_config_options({"support_points_density_relative", "support_points_minimal_distance"});
|
std::vector<const ConfigOption*> opts = get_config_options({"support_points_density_relative", "support_points_minimal_distance"});
|
||||||
float density = static_cast<ConfigOptionInt*>(opts[0])->value;
|
float density = static_cast<const ConfigOptionInt*>(opts[0])->value;
|
||||||
float minimal_point_distance = static_cast<ConfigOptionFloat*>(opts[1])->value;
|
float minimal_point_distance = static_cast<const ConfigOptionFloat*>(opts[1])->value;
|
||||||
|
|
||||||
bool value_changed = ImGui::SliderFloat("", &minimal_point_distance, 0.f, 20.f, "%.f mm");
|
bool value_changed = ImGui::SliderFloat("", &minimal_point_distance, 0.f, 20.f, "%.f mm");
|
||||||
if (value_changed)
|
if (value_changed)
|
||||||
@ -2451,6 +2440,10 @@ void GLGizmoSlaSupports::on_set_state()
|
|||||||
m_parent.toggle_model_objects_visibility(false);
|
m_parent.toggle_model_objects_visibility(false);
|
||||||
if (m_model_object)
|
if (m_model_object)
|
||||||
m_parent.toggle_model_objects_visibility(true, m_model_object, m_active_instance);
|
m_parent.toggle_model_objects_visibility(true, m_model_object, m_active_instance);
|
||||||
|
|
||||||
|
// 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
|
if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off
|
||||||
if (m_model_object) {
|
if (m_model_object) {
|
||||||
@ -2489,10 +2482,14 @@ void GLGizmoSlaSupports::select_point(int i)
|
|||||||
for (auto& point_and_selection : m_editing_mode_cache)
|
for (auto& point_and_selection : m_editing_mode_cache)
|
||||||
point_and_selection.second = ( i == AllPoints );
|
point_and_selection.second = ( i == AllPoints );
|
||||||
m_selection_empty = (i == NoPoints);
|
m_selection_empty = (i == NoPoints);
|
||||||
|
|
||||||
|
if (i == AllPoints)
|
||||||
|
m_new_point_head_diameter = m_editing_mode_cache[0].first.head_front_radius * 2.f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_editing_mode_cache[i].second = true;
|
m_editing_mode_cache[i].second = true;
|
||||||
m_selection_empty = false;
|
m_selection_empty = false;
|
||||||
|
m_new_point_head_diameter = m_editing_mode_cache[i].first.head_front_radius * 2.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ private:
|
|||||||
bool m_lock_unique_islands = false;
|
bool m_lock_unique_islands = false;
|
||||||
bool m_editing_mode = false; // Is editing mode active?
|
bool m_editing_mode = false; // Is editing mode active?
|
||||||
bool m_old_editing_state = false; // To keep track of whether the user toggled between the modes (needed for imgui refreshes).
|
bool m_old_editing_state = false; // To keep track of whether the user toggled between the modes (needed for imgui refreshes).
|
||||||
float m_new_point_head_diameter = 0.4f; // Size of a new point.
|
float m_new_point_head_diameter; // Size of a new point.
|
||||||
float m_minimal_point_distance = 20.f;
|
float m_minimal_point_distance = 20.f;
|
||||||
float m_density = 100.f;
|
float m_density = 100.f;
|
||||||
std::vector<std::pair<sla::SupportPoint, bool>> m_editing_mode_cache; // a support point and whether it is currently selected
|
std::vector<std::pair<sla::SupportPoint, bool>> m_editing_mode_cache; // a support point and whether it is currently selected
|
||||||
@ -536,7 +536,7 @@ private:
|
|||||||
int m_canvas_width;
|
int m_canvas_width;
|
||||||
int m_canvas_height;
|
int m_canvas_height;
|
||||||
|
|
||||||
std::vector<ConfigOption*> get_config_options(const std::vector<std::string>& keys) const;
|
std::vector<const ConfigOption*> get_config_options(const std::vector<std::string>& keys) const;
|
||||||
|
|
||||||
// Methods that do the model_object and editing cache synchronization,
|
// Methods that do the model_object and editing cache synchronization,
|
||||||
// editing mode selection, etc:
|
// editing mode selection, etc:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user