mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-31 23:02:06 +00:00
Exposing STEP import values (#14484)
Co-authored-by: yw4z <ywsyildiz@gmail.com>
This commit is contained in:
@@ -579,9 +579,16 @@ void AppConfig::set_defaults()
|
|||||||
if (get("enable_step_mesh_setting").empty()) {
|
if (get("enable_step_mesh_setting").empty()) {
|
||||||
set_bool("enable_step_mesh_setting", true);
|
set_bool("enable_step_mesh_setting", true);
|
||||||
}
|
}
|
||||||
if (get("linear_defletion", "angle_defletion").empty()) {
|
// Migrate legacy misspelled keys (linear_defletion/angle_defletion) to the corrected spelling.
|
||||||
set("linear_defletion", "0.003");
|
if (get("linear_deflection").empty() && !get("linear_defletion").empty())
|
||||||
set("angle_defletion", "0.5");
|
set("linear_deflection", get("linear_defletion"));
|
||||||
|
if (get("angle_deflection").empty() && !get("angle_defletion").empty())
|
||||||
|
set("angle_deflection", get("angle_defletion"));
|
||||||
|
if (get("linear_deflection").empty()) {
|
||||||
|
set("linear_deflection", "0.003");
|
||||||
|
}
|
||||||
|
if (get("angle_deflection").empty()) {
|
||||||
|
set("angle_deflection", "0.5");
|
||||||
}
|
}
|
||||||
if (get("is_split_compound").empty()) {
|
if (get("is_split_compound").empty()) {
|
||||||
set_bool("is_split_compound", false);
|
set_bool("is_split_compound", false);
|
||||||
|
|||||||
@@ -230,8 +230,8 @@ static void getNamedSolids(const TopLoc_Location& location,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//bool load_step(const char *path, Model *model, bool& is_cancel,
|
//bool load_step(const char *path, Model *model, bool& is_cancel,
|
||||||
// double linear_defletion/*=0.003*/,
|
// double linear_deflection/*=0.003*/,
|
||||||
// double angle_defletion/*= 0.5*/,
|
// double angle_deflection/*= 0.5*/,
|
||||||
// bool isSplitCompound,
|
// bool isSplitCompound,
|
||||||
// ImportStepProgressFn stepFn, StepIsUtf8Fn isUtf8Fn, long& mesh_face_num)
|
// ImportStepProgressFn stepFn, StepIsUtf8Fn isUtf8Fn, long& mesh_face_num)
|
||||||
//{
|
//{
|
||||||
@@ -288,7 +288,7 @@ static void getNamedSolids(const TopLoc_Location& location,
|
|||||||
// stl.resize(namedSolids.size());
|
// stl.resize(namedSolids.size());
|
||||||
// tbb::parallel_for(tbb::blocked_range<size_t>(0, namedSolids.size()), [&](const tbb::blocked_range<size_t> &range) {
|
// tbb::parallel_for(tbb::blocked_range<size_t>(0, namedSolids.size()), [&](const tbb::blocked_range<size_t> &range) {
|
||||||
// for (size_t i = range.begin(); i < range.end(); i++) {
|
// for (size_t i = range.begin(); i < range.end(); i++) {
|
||||||
// BRepMesh_IncrementalMesh mesh(namedSolids[i].solid, linear_defletion, false, angle_defletion, true);
|
// BRepMesh_IncrementalMesh mesh(namedSolids[i].solid, linear_deflection, false, angle_deflection, true);
|
||||||
// // BBS: calculate total number of the nodes and triangles
|
// // BBS: calculate total number of the nodes and triangles
|
||||||
// int aNbNodes = 0;
|
// int aNbNodes = 0;
|
||||||
// int aNbTriangles = 0;
|
// int aNbTriangles = 0;
|
||||||
@@ -511,8 +511,8 @@ Step::Step_Status Step::load()
|
|||||||
Step::Step_Status Step::mesh(Model* model,
|
Step::Step_Status Step::mesh(Model* model,
|
||||||
bool& is_cancel,
|
bool& is_cancel,
|
||||||
bool isSplitCompound,
|
bool isSplitCompound,
|
||||||
double linear_defletion/*=0.003*/,
|
double linear_deflection/*=0.003*/,
|
||||||
double angle_defletion/*= 0.5*/)
|
double angle_deflection/*= 0.5*/)
|
||||||
|
|
||||||
{
|
{
|
||||||
bool task_result = false;
|
bool task_result = false;
|
||||||
@@ -544,7 +544,7 @@ Step::Step_Status Step::mesh(Model* model,
|
|||||||
stl.resize(namedSolids.size());
|
stl.resize(namedSolids.size());
|
||||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, namedSolids.size()), [&](const tbb::blocked_range<size_t>& range) {
|
tbb::parallel_for(tbb::blocked_range<size_t>(0, namedSolids.size()), [&](const tbb::blocked_range<size_t>& range) {
|
||||||
for (size_t i = range.begin(); i < range.end(); i++) {
|
for (size_t i = range.begin(); i < range.end(); i++) {
|
||||||
BRepMesh_IncrementalMesh mesh(namedSolids[i].solid, linear_defletion, false, angle_defletion, true);
|
BRepMesh_IncrementalMesh mesh(namedSolids[i].solid, linear_deflection, false, angle_deflection, true);
|
||||||
// BBS: calculate total number of the nodes and triangles
|
// BBS: calculate total number of the nodes and triangles
|
||||||
int aNbNodes = 0;
|
int aNbNodes = 0;
|
||||||
int aNbTriangles = 0;
|
int aNbTriangles = 0;
|
||||||
@@ -689,15 +689,15 @@ void Step::clean_mesh_data()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Step::get_triangle_num(double linear_defletion, double angle_defletion)
|
unsigned int Step::get_triangle_num(double linear_deflection, double angle_deflection)
|
||||||
{
|
{
|
||||||
unsigned int tri_num = 0;
|
unsigned int tri_num = 0;
|
||||||
try {
|
try {
|
||||||
Handle(StepProgressIncdicator) progress = new StepProgressIncdicator(m_stop_mesh);
|
Handle(StepProgressIncdicator) progress = new StepProgressIncdicator(m_stop_mesh);
|
||||||
clean_mesh_data();
|
clean_mesh_data();
|
||||||
IMeshTools_Parameters param;
|
IMeshTools_Parameters param;
|
||||||
param.Deflection = linear_defletion;
|
param.Deflection = linear_deflection;
|
||||||
param.Angle = angle_defletion;
|
param.Angle = angle_deflection;
|
||||||
param.InParallel = true;
|
param.InParallel = true;
|
||||||
for (int i = 0; i < m_name_solids.size(); ++i) {
|
for (int i = 0; i < m_name_solids.size(); ++i) {
|
||||||
BRepMesh_IncrementalMesh mesh(m_name_solids[i].solid, param, progress->Start());
|
BRepMesh_IncrementalMesh mesh(m_name_solids[i].solid, param, progress->Start());
|
||||||
@@ -719,7 +719,7 @@ unsigned int Step::get_triangle_num(double linear_defletion, double angle_deflet
|
|||||||
return tri_num;
|
return tri_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Step::get_triangle_num_tbb(double linear_defletion, double angle_defletion)
|
unsigned int Step::get_triangle_num_tbb(double linear_deflection, double angle_deflection)
|
||||||
{
|
{
|
||||||
unsigned int tri_num = 0;
|
unsigned int tri_num = 0;
|
||||||
clean_mesh_data();
|
clean_mesh_data();
|
||||||
@@ -727,7 +727,7 @@ unsigned int Step::get_triangle_num_tbb(double linear_defletion, double angle_de
|
|||||||
[&](const tbb::blocked_range<size_t>& range) {
|
[&](const tbb::blocked_range<size_t>& range) {
|
||||||
for (size_t i = range.begin(); i < range.end(); i++) {
|
for (size_t i = range.begin(); i < range.end(); i++) {
|
||||||
unsigned int solids_tri_num = 0;
|
unsigned int solids_tri_num = 0;
|
||||||
BRepMesh_IncrementalMesh mesh(m_name_solids[i].solid, linear_defletion, false, angle_defletion, true);
|
BRepMesh_IncrementalMesh mesh(m_name_solids[i].solid, linear_deflection, false, angle_deflection, true);
|
||||||
for (TopExp_Explorer anExpSF(m_name_solids[i].solid, TopAbs_FACE); anExpSF.More(); anExpSF.Next()) {
|
for (TopExp_Explorer anExpSF(m_name_solids[i].solid, TopAbs_FACE); anExpSF.More(); anExpSF.Next()) {
|
||||||
TopLoc_Location aLoc;
|
TopLoc_Location aLoc;
|
||||||
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(TopoDS::Face(anExpSF.Current()), aLoc);
|
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(TopoDS::Face(anExpSF.Current()), aLoc);
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ struct NamedSolid
|
|||||||
//BBS: Load an step file into a provided model.
|
//BBS: Load an step file into a provided model.
|
||||||
extern bool load_step(const char *path, Model *model,
|
extern bool load_step(const char *path, Model *model,
|
||||||
bool& is_cancel,
|
bool& is_cancel,
|
||||||
double linear_defletion = 0.003,
|
double linear_deflection = 0.003,
|
||||||
double angle_defletion = 0.5,
|
double angle_deflection = 0.5,
|
||||||
bool isSplitCompound = false,
|
bool isSplitCompound = false,
|
||||||
ImportStepProgressFn proFn = nullptr,
|
ImportStepProgressFn proFn = nullptr,
|
||||||
StepIsUtf8Fn isUtf8Fn = nullptr,
|
StepIsUtf8Fn isUtf8Fn = nullptr,
|
||||||
@@ -98,14 +98,14 @@ public:
|
|||||||
Step(std::string path, ImportStepProgressFn stepFn = nullptr, StepIsUtf8Fn isUtf8Fn = nullptr);
|
Step(std::string path, ImportStepProgressFn stepFn = nullptr, StepIsUtf8Fn isUtf8Fn = nullptr);
|
||||||
~Step();
|
~Step();
|
||||||
Step_Status load();
|
Step_Status load();
|
||||||
unsigned int get_triangle_num(double linear_defletion, double angle_defletion);
|
unsigned int get_triangle_num(double linear_deflection, double angle_deflection);
|
||||||
unsigned int get_triangle_num_tbb(double linear_defletion, double angle_defletion);
|
unsigned int get_triangle_num_tbb(double linear_deflection, double angle_deflection);
|
||||||
void clean_mesh_data();
|
void clean_mesh_data();
|
||||||
Step_Status mesh(Model* model,
|
Step_Status mesh(Model* model,
|
||||||
bool& is_cancel,
|
bool& is_cancel,
|
||||||
bool isSplitCompound,
|
bool isSplitCompound,
|
||||||
double linear_defletion = 0.003,
|
double linear_deflection = 0.003,
|
||||||
double angle_defletion = 0.5);
|
double angle_deflection = 0.5);
|
||||||
|
|
||||||
std::atomic<bool> m_stop_mesh{false};
|
std::atomic<bool> m_stop_mesh{false};
|
||||||
void update_process(int load_stage, int current, int total, bool& cancel);
|
void update_process(int load_stage, int current, int total, bool& cancel);
|
||||||
|
|||||||
@@ -187,8 +187,8 @@ Model Model::read_from_step(const std::string&
|
|||||||
ImportStepProgressFn stepFn,
|
ImportStepProgressFn stepFn,
|
||||||
StepIsUtf8Fn stepIsUtf8Fn,
|
StepIsUtf8Fn stepIsUtf8Fn,
|
||||||
std::function<int(Slic3r::Step&, double&, double&, bool&)> step_mesh_fn,
|
std::function<int(Slic3r::Step&, double&, double&, bool&)> step_mesh_fn,
|
||||||
double linear_defletion,
|
double linear_deflection,
|
||||||
double angle_defletion,
|
double angle_deflection,
|
||||||
bool is_split_compound)
|
bool is_split_compound)
|
||||||
{
|
{
|
||||||
Model model;
|
Model model;
|
||||||
@@ -201,13 +201,13 @@ Model Model::read_from_step(const std::string&
|
|||||||
goto _finished;
|
goto _finished;
|
||||||
}
|
}
|
||||||
if (step_mesh_fn) {
|
if (step_mesh_fn) {
|
||||||
if (step_mesh_fn(step_file, linear_defletion, angle_defletion, is_split_compound) == -1) {
|
if (step_mesh_fn(step_file, linear_deflection, angle_deflection, is_split_compound) == -1) {
|
||||||
status = Step::Step_Status::CANCEL;
|
status = Step::Step_Status::CANCEL;
|
||||||
goto _finished;
|
goto _finished;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status = step_file.mesh(&model, is_cb_cancel, is_split_compound, linear_defletion, angle_defletion);
|
status = step_file.mesh(&model, is_cb_cancel, is_split_compound, linear_deflection, angle_deflection);
|
||||||
|
|
||||||
_finished:
|
_finished:
|
||||||
|
|
||||||
|
|||||||
@@ -1588,8 +1588,8 @@ public:
|
|||||||
ImportStepProgressFn stepFn,
|
ImportStepProgressFn stepFn,
|
||||||
StepIsUtf8Fn stepIsUtf8Fn,
|
StepIsUtf8Fn stepIsUtf8Fn,
|
||||||
std::function<int(Slic3r::Step&, double&, double&, bool&)> step_mesh_fn,
|
std::function<int(Slic3r::Step&, double&, double&, bool&)> step_mesh_fn,
|
||||||
double linear_defletion,
|
double linear_deflection,
|
||||||
double angle_defletion,
|
double angle_deflection,
|
||||||
bool is_split_compound);
|
bool is_split_compound);
|
||||||
|
|
||||||
//BBS: add part plate related logic
|
//BBS: add part plate related logic
|
||||||
|
|||||||
@@ -2316,9 +2316,9 @@ void ObjectList::load_modifier(const wxArrayString& input_files, ModelObject& mo
|
|||||||
try {
|
try {
|
||||||
if (boost::iends_with(input_file, ".stp") ||
|
if (boost::iends_with(input_file, ".stp") ||
|
||||||
boost::iends_with(input_file, ".step")) {
|
boost::iends_with(input_file, ".step")) {
|
||||||
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_defletion"));
|
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_deflection"));
|
||||||
if (linear <= 0) linear = 0.003;
|
if (linear <= 0) linear = 0.003;
|
||||||
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_defletion"));
|
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_deflection"));
|
||||||
if (angle <= 0) angle = 0.5;
|
if (angle <= 0) angle = 0.5;
|
||||||
bool split_compound = wxGetApp().app_config->get_bool("is_split_compound");
|
bool split_compound = wxGetApp().app_config->get_bool("is_split_compound");
|
||||||
model = Model::read_from_step(
|
model = Model::read_from_step(
|
||||||
@@ -2328,8 +2328,8 @@ void ObjectList::load_modifier(const wxArrayString& input_files, ModelObject& mo
|
|||||||
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
|
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
|
||||||
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
|
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
|
||||||
if (mesh_dlg.ShowModal() == wxID_OK) {
|
if (mesh_dlg.ShowModal() == wxID_OK) {
|
||||||
linear_value = mesh_dlg.get_linear_defletion();
|
linear_value = mesh_dlg.get_linear_deflection();
|
||||||
angle_value = mesh_dlg.get_angle_defletion();
|
angle_value = mesh_dlg.get_angle_deflection();
|
||||||
is_split = mesh_dlg.get_split_compound_value();
|
is_split = mesh_dlg.get_split_compound_value();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6637,9 +6637,9 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||||||
};
|
};
|
||||||
if (boost::iends_with(path.string(), ".stp") ||
|
if (boost::iends_with(path.string(), ".stp") ||
|
||||||
boost::iends_with(path.string(), ".step")) {
|
boost::iends_with(path.string(), ".step")) {
|
||||||
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_defletion"));
|
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_deflection"));
|
||||||
if (linear <= 0) linear = 0.003;
|
if (linear <= 0) linear = 0.003;
|
||||||
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_defletion"));
|
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_deflection"));
|
||||||
if (angle <= 0) angle = 0.5;
|
if (angle <= 0) angle = 0.5;
|
||||||
bool split_compound = wxGetApp().app_config->get_bool("is_split_compound");
|
bool split_compound = wxGetApp().app_config->get_bool("is_split_compound");
|
||||||
model = Slic3r::Model:: read_from_step(path.string(), strategy,
|
model = Slic3r::Model:: read_from_step(path.string(), strategy,
|
||||||
@@ -6671,8 +6671,8 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||||||
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
|
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
|
||||||
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
|
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
|
||||||
if (mesh_dlg.ShowModal() == wxID_OK) {
|
if (mesh_dlg.ShowModal() == wxID_OK) {
|
||||||
linear_value = mesh_dlg.get_linear_defletion();
|
linear_value = mesh_dlg.get_linear_deflection();
|
||||||
angle_value = mesh_dlg.get_angle_defletion();
|
angle_value = mesh_dlg.get_angle_deflection();
|
||||||
is_split = mesh_dlg.get_split_compound_value();
|
is_split = mesh_dlg.get_split_compound_value();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -8418,8 +8418,8 @@ bool Plater::priv::replace_volume_with_stl(int object_idx, int volume_idx, const
|
|||||||
const bool is_step = boost::algorithm::iends_with(path, ".stp") || boost::algorithm::iends_with(path, ".step");
|
const bool is_step = boost::algorithm::iends_with(path, ".stp") || boost::algorithm::iends_with(path, ".step");
|
||||||
if (is_step) {
|
if (is_step) {
|
||||||
auto config = wxGetApp().app_config;
|
auto config = wxGetApp().app_config;
|
||||||
double linear = std::max(0.003, string_to_double_decimal_point(config->get("linear_defletion")));
|
double linear = std::max(0.003, string_to_double_decimal_point(config->get("linear_deflection")));
|
||||||
double angle = std::max(0.5, string_to_double_decimal_point(config->get("angle_defletion")));
|
double angle = std::max(0.5, string_to_double_decimal_point(config->get("angle_deflection")));
|
||||||
bool split_compound = config->get_bool("is_split_compound");
|
bool split_compound = config->get_bool("is_split_compound");
|
||||||
bool is_user_cancel = false;
|
bool is_user_cancel = false;
|
||||||
|
|
||||||
@@ -8427,8 +8427,8 @@ bool Plater::priv::replace_volume_with_stl(int object_idx, int volume_idx, const
|
|||||||
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
|
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
|
||||||
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
|
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
|
||||||
if (mesh_dlg.ShowModal() == wxID_OK) {
|
if (mesh_dlg.ShowModal() == wxID_OK) {
|
||||||
linear_value = mesh_dlg.get_linear_defletion();
|
linear_value = mesh_dlg.get_linear_deflection();
|
||||||
angle_value = mesh_dlg.get_angle_defletion();
|
angle_value = mesh_dlg.get_angle_deflection();
|
||||||
is_split = mesh_dlg.get_split_compound_value();
|
is_split = mesh_dlg.get_split_compound_value();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -8911,8 +8911,8 @@ void Plater::priv::reload_from_disk()
|
|||||||
// BBS: backup
|
// BBS: backup
|
||||||
if (boost::iends_with(path, ".stp") ||
|
if (boost::iends_with(path, ".stp") ||
|
||||||
boost::iends_with(path, ".step")) {
|
boost::iends_with(path, ".step")) {
|
||||||
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_defletion"));
|
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_deflection"));
|
||||||
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_defletion"));
|
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_deflection"));
|
||||||
bool is_split = wxGetApp().app_config->get_bool("is_split_compound");
|
bool is_split = wxGetApp().app_config->get_bool("is_split_compound");
|
||||||
new_model = Model::read_from_step(path, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, nullptr, nullptr, nullptr, linear, angle, is_split);
|
new_model = Model::read_from_step(path, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, nullptr, nullptr, nullptr, linear, angle, is_split);
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -783,6 +783,47 @@ wxBoxSizer *PreferencesDialog::create_camera_orbit_mult_input(wxString title, wx
|
|||||||
return m_sizer;
|
return m_sizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxBoxSizer *PreferencesDialog::create_item_decimal_input(wxString title, wxString title2, wxString tooltip, std::string param, double min, double max, int decimals, const wxString wiki_url)
|
||||||
|
{
|
||||||
|
auto tip = tooltip.IsEmpty() ? title : tooltip; // auto fill tooltips with title if its empty
|
||||||
|
|
||||||
|
wxBoxSizer *m_sizer = create_item_label(title, tip, wiki_url);
|
||||||
|
|
||||||
|
auto input = new ::TextInput(m_parent, wxEmptyString, title2, wxEmptyString, wxDefaultPosition, DESIGN_INPUT_SIZE, wxTE_PROCESS_ENTER);
|
||||||
|
StateColor input_bg(std::pair<wxColour, int>(wxColour("#F0F0F1"), StateColor::Disabled), std::pair<wxColour, int>(*wxWHITE, StateColor::Enabled));
|
||||||
|
input->SetBackgroundColor(input_bg);
|
||||||
|
input->GetTextCtrl()->SetValue(app_config->get(param));
|
||||||
|
wxTextValidator validator(wxFILTER_NUMERIC);
|
||||||
|
input->SetToolTip(tooltip);
|
||||||
|
input->GetTextCtrl()->SetValidator(validator);
|
||||||
|
|
||||||
|
m_sizer->Add(input, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(5));
|
||||||
|
|
||||||
|
auto apply_value = [this, param, input, min, max, decimals]() {
|
||||||
|
auto value = input->GetTextCtrl()->GetValue();
|
||||||
|
double conv = min;
|
||||||
|
if (value.ToCDouble(&conv)) {
|
||||||
|
conv = conv < min ? min : conv > max ? max : conv;
|
||||||
|
auto strval = std::string(wxString::FromCDouble(conv, decimals).mb_str());
|
||||||
|
input->GetTextCtrl()->SetValue(strval);
|
||||||
|
app_config->set(param, strval);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
input->GetTextCtrl()->Bind(wxEVT_TEXT_ENTER, [apply_value](wxCommandEvent &e) {
|
||||||
|
apply_value();
|
||||||
|
wxGetApp().app_config->save();
|
||||||
|
e.Skip();
|
||||||
|
});
|
||||||
|
|
||||||
|
input->GetTextCtrl()->Bind(wxEVT_KILL_FOCUS, [apply_value](wxFocusEvent &e) {
|
||||||
|
apply_value();
|
||||||
|
e.Skip();
|
||||||
|
});
|
||||||
|
|
||||||
|
return m_sizer;
|
||||||
|
}
|
||||||
|
|
||||||
wxBoxSizer *PreferencesDialog::create_item_backup(wxString title, wxString tooltip)
|
wxBoxSizer *PreferencesDialog::create_item_backup(wxString title, wxString tooltip)
|
||||||
{
|
{
|
||||||
auto tip = tooltip.IsEmpty() ? title : tooltip; // auto fill tooltips with title if its empty
|
auto tip = tooltip.IsEmpty() ? title : tooltip; // auto fill tooltips with title if its empty
|
||||||
@@ -1605,6 +1646,15 @@ void PreferencesDialog::create_items()
|
|||||||
);
|
);
|
||||||
g_sizer->Add(item_step_dialog);
|
g_sizer->Add(item_step_dialog);
|
||||||
|
|
||||||
|
auto item_step_linear = create_item_decimal_input(_L("STEP importing: linear deflection"), "mm", _L("Linear deflection used when meshing imported STEP files.\nSmaller values produce higher-quality meshes but increase processing time.\nUsed as the default in the import dialog, or directly when the import dialog is disabled.\nDefault: 0.003 mm."), "linear_deflection", 0.001, 0.1, 3);
|
||||||
|
g_sizer->Add(item_step_linear);
|
||||||
|
|
||||||
|
auto item_step_angle = create_item_decimal_input(_L("STEP importing: angle deflection"), "", _L("Angle deflection used when meshing imported STEP files.\nSmaller values produce higher-quality meshes but increase processing time.\nUsed as the default in the import dialog, or directly when the import dialog is disabled.\nDefault: 0.5."), "angle_deflection", 0.01, 1.0, 2);
|
||||||
|
g_sizer->Add(item_step_angle);
|
||||||
|
|
||||||
|
auto item_step_split = create_item_checkbox(_L("STEP importing: Split into multiple objects"), _L("If enabled, compound and compsolid shapes in imported STEP files are split into multiple objects.\nUsed as the default in the import dialog, or directly when the import dialog is disabled.\nDefault: disabled."), "is_split_compound");
|
||||||
|
g_sizer->Add(item_step_split);
|
||||||
|
|
||||||
auto item_draco_bits = create_item_spinctrl(_L("Quality level for Draco export"), "",
|
auto item_draco_bits = create_item_spinctrl(_L("Quality level for Draco export"), "",
|
||||||
_L("bits"),
|
_L("bits"),
|
||||||
_L("Controls the quantization bit depth used when compressing the mesh to Draco format.\n"
|
_L("Controls the quantization bit depth used when compressing the mesh to Draco format.\n"
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ public:
|
|||||||
wxBoxSizer *create_item_input(wxString title, wxString title2, wxString tooltip, std::string param, std::function<void(wxString)> onchange = {}, const wxString wiki_url = "");
|
wxBoxSizer *create_item_input(wxString title, wxString title2, wxString tooltip, std::string param, std::function<void(wxString)> onchange = {}, const wxString wiki_url = "");
|
||||||
wxBoxSizer *create_item_spinctrl(wxString title, wxString title2, wxString side_label, wxString tooltip, std::string param, int min, int max, std::function<void(int)> onchange = nullptr, const wxString wiki_url = "");
|
wxBoxSizer *create_item_spinctrl(wxString title, wxString title2, wxString side_label, wxString tooltip, std::string param, int min, int max, std::function<void(int)> onchange = nullptr, const wxString wiki_url = "");
|
||||||
wxBoxSizer *create_camera_orbit_mult_input(wxString title, wxString tooltip);
|
wxBoxSizer *create_camera_orbit_mult_input(wxString title, wxString tooltip);
|
||||||
|
wxBoxSizer *create_item_decimal_input(wxString title, wxString title2, wxString tooltip, std::string param, double min, double max, int decimals, const wxString wiki_url = "");
|
||||||
wxBoxSizer *create_item_backup(wxString title, wxString tooltip);
|
wxBoxSizer *create_item_backup(wxString title, wxString tooltip);
|
||||||
wxBoxSizer *create_item_auto_reslice(wxString title, wxString checkbox_tooltip, wxString delay_tooltip);
|
wxBoxSizer *create_item_auto_reslice(wxString title, wxString checkbox_tooltip, wxString delay_tooltip);
|
||||||
wxBoxSizer *create_item_bambu_cloud(wxString title, wxString tooltip);
|
wxBoxSizer *create_item_bambu_cloud(wxString title, wxString tooltip);
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line
|
|||||||
linear_sizer->Add(linear_title, 0, wxALIGN_LEFT);
|
linear_sizer->Add(linear_title, 0, wxALIGN_LEFT);
|
||||||
linear_sizer->AddStretchSpacer(1);
|
linear_sizer->AddStretchSpacer(1);
|
||||||
wxSlider* linear_slider = new wxSlider(this, wxID_ANY,
|
wxSlider* linear_slider = new wxSlider(this, wxID_ANY,
|
||||||
SLIDER_SCALE(get_linear_defletion()),
|
SLIDER_SCALE(get_linear_deflection()),
|
||||||
1, 100, wxDefaultPosition,
|
1, 100, wxDefaultPosition,
|
||||||
wxSize(SLIDER_WIDTH, SLIDER_HEIGHT),
|
wxSize(SLIDER_WIDTH, SLIDER_HEIGHT),
|
||||||
wxSL_HORIZONTAL);
|
wxSL_HORIZONTAL);
|
||||||
@@ -199,7 +199,7 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line
|
|||||||
angle_sizer->Add(angle_title, 0, wxALIGN_LEFT);
|
angle_sizer->Add(angle_title, 0, wxALIGN_LEFT);
|
||||||
angle_sizer->AddStretchSpacer(1);
|
angle_sizer->AddStretchSpacer(1);
|
||||||
wxSlider* angle_slider = new wxSlider(this, wxID_ANY,
|
wxSlider* angle_slider = new wxSlider(this, wxID_ANY,
|
||||||
SLIDER_SCALE_10(get_angle_defletion()),
|
SLIDER_SCALE_10(get_angle_deflection()),
|
||||||
1, 100, wxDefaultPosition,
|
1, 100, wxDefaultPosition,
|
||||||
wxSize(SLIDER_WIDTH, SLIDER_HEIGHT),
|
wxSize(SLIDER_WIDTH, SLIDER_HEIGHT),
|
||||||
wxSL_HORIZONTAL);
|
wxSL_HORIZONTAL);
|
||||||
@@ -265,6 +265,14 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line
|
|||||||
mesh_face_number_sizer->Add(mesh_face_number_text, 0, wxALIGN_LEFT);
|
mesh_face_number_sizer->Add(mesh_face_number_text, 0, wxALIGN_LEFT);
|
||||||
bSizer->Add(mesh_face_number_sizer, 0, wxEXPAND | wxALL, LEFT_RIGHT_PADING);
|
bSizer->Add(mesh_face_number_sizer, 0, wxEXPAND | wxALL, LEFT_RIGHT_PADING);
|
||||||
|
|
||||||
|
wxBoxSizer* save_default_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
m_save_default_checkbox = new wxCheckBox(this, wxID_ANY, _L("Save these settings as default"), wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_save_default_checkbox->SetFont(::Label::Body_14);
|
||||||
|
m_save_default_checkbox->SetForegroundColour(StateColor::darkModeColorFor(FONT_COLOR));
|
||||||
|
m_save_default_checkbox->SetToolTip(_L("If enabled, the values above are stored as the defaults used for future STEP imports (and shown in Preferences)."));
|
||||||
|
save_default_sizer->Add(m_save_default_checkbox, 0, wxALIGN_LEFT);
|
||||||
|
bSizer->Add(save_default_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, LEFT_RIGHT_PADING);
|
||||||
|
|
||||||
wxBoxSizer* bSizer_button = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer* bSizer_button = new wxBoxSizer(wxHORIZONTAL);
|
||||||
bSizer_button->SetMinSize(wxSize(FromDIP(100), -1));
|
bSizer_button->SetMinSize(wxSize(FromDIP(100), -1));
|
||||||
m_checkbox = new wxCheckBox(this, wxID_ANY, _L("Don't show again"), wxDefaultPosition, wxDefaultSize, 0);
|
m_checkbox = new wxCheckBox(this, wxID_ANY, _L("Don't show again"), wxDefaultPosition, wxDefaultSize, 0);
|
||||||
@@ -284,9 +292,11 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line
|
|||||||
if (m_checkbox->IsChecked()) {
|
if (m_checkbox->IsChecked()) {
|
||||||
wxGetApp().app_config->set_bool("enable_step_mesh_setting", false);
|
wxGetApp().app_config->set_bool("enable_step_mesh_setting", false);
|
||||||
}
|
}
|
||||||
wxGetApp().app_config->set_bool("is_split_compound", m_split_compound_checkbox->GetValue());
|
if (m_save_default_checkbox->IsChecked()) {
|
||||||
wxGetApp().app_config->set("linear_defletion", float_to_string_decimal_point(get_linear_defletion(), 3));
|
wxGetApp().app_config->set_bool("is_split_compound", m_split_compound_checkbox->GetValue());
|
||||||
wxGetApp().app_config->set("angle_defletion", float_to_string_decimal_point(get_angle_defletion(), 2));
|
wxGetApp().app_config->set("linear_deflection", float_to_string_decimal_point(get_linear_deflection(), 3));
|
||||||
|
wxGetApp().app_config->set("angle_deflection", float_to_string_decimal_point(get_angle_deflection(), 2));
|
||||||
|
}
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
}
|
}
|
||||||
@@ -354,21 +364,21 @@ void StepMeshDialog::stop_task()
|
|||||||
|
|
||||||
void StepMeshDialog::update_mesh_number_text()
|
void StepMeshDialog::update_mesh_number_text()
|
||||||
{
|
{
|
||||||
if ((m_last_linear == get_linear_defletion()) && (m_last_angle == get_angle_defletion()) && (m_mesh_number != 0))
|
if ((m_last_linear == get_linear_deflection()) && (m_last_angle == get_angle_deflection()) && (m_mesh_number != 0))
|
||||||
return;
|
return;
|
||||||
wxString newText = wxString::Format(_L("Calculating, please wait..."));
|
wxString newText = wxString::Format(_L("Calculating, please wait..."));
|
||||||
mesh_face_number_text->SetLabel(newText);
|
mesh_face_number_text->SetLabel(newText);
|
||||||
stop_task();
|
stop_task();
|
||||||
if (!m_task) {
|
if (!m_task) {
|
||||||
m_task = new boost::thread(Slic3r::create_thread([this]() -> void {
|
m_task = new boost::thread(Slic3r::create_thread([this]() -> void {
|
||||||
m_mesh_number = m_file.get_triangle_num(get_linear_defletion(), get_angle_defletion());
|
m_mesh_number = m_file.get_triangle_num(get_linear_deflection(), get_angle_deflection());
|
||||||
if (m_mesh_number != 0) {
|
if (m_mesh_number != 0) {
|
||||||
wxString number_text = wxString::Format("%d", m_mesh_number);
|
wxString number_text = wxString::Format("%d", m_mesh_number);
|
||||||
wxCommandEvent event(wxEVT_THREAD_DONE);
|
wxCommandEvent event(wxEVT_THREAD_DONE);
|
||||||
event.SetString(number_text);
|
event.SetString(number_text);
|
||||||
wxPostEvent(this, event);
|
wxPostEvent(this, event);
|
||||||
m_last_linear = get_linear_defletion();
|
m_last_linear = get_linear_deflection();
|
||||||
m_last_angle = get_angle_defletion();
|
m_last_angle = get_angle_deflection();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double linear_init, double angle_init);
|
StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double linear_init, double angle_init);
|
||||||
~StepMeshDialog() override;
|
~StepMeshDialog() override;
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
inline double get_linear_defletion() {
|
inline double get_linear_deflection() {
|
||||||
double value;
|
double value;
|
||||||
if (m_linear_last.ToDouble(&value)) {
|
if (m_linear_last.ToDouble(&value)) {
|
||||||
return value;
|
return value;
|
||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
return m_last_linear;
|
return m_last_linear;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline double get_angle_defletion() {
|
inline double get_angle_deflection() {
|
||||||
double value;
|
double value;
|
||||||
if (m_angle_last.ToDouble(&value)) {
|
if (m_angle_last.ToDouble(&value)) {
|
||||||
return value;
|
return value;
|
||||||
@@ -37,6 +37,7 @@ private:
|
|||||||
Slic3r::Step& m_file;
|
Slic3r::Step& m_file;
|
||||||
wxCheckBox* m_checkbox = nullptr;
|
wxCheckBox* m_checkbox = nullptr;
|
||||||
wxCheckBox* m_split_compound_checkbox = nullptr;
|
wxCheckBox* m_split_compound_checkbox = nullptr;
|
||||||
|
wxCheckBox* m_save_default_checkbox = nullptr;
|
||||||
wxString m_linear_last;
|
wxString m_linear_last;
|
||||||
wxString m_angle_last;
|
wxString m_angle_last;
|
||||||
wxStaticText* mesh_face_number_text;
|
wxStaticText* mesh_face_number_text;
|
||||||
|
|||||||
Reference in New Issue
Block a user