Merge branch 'master' into fs_emboss
This commit is contained in:
commit
35baa70be0
@ -2327,7 +2327,7 @@ void GCode::process_layer_single_object(
|
||||
interface_extruder = dontcare_extruder;
|
||||
}
|
||||
bool extrude_support = has_support && support_extruder == extruder_id;
|
||||
bool extrude_interface = interface_extruder && interface_extruder == extruder_id;
|
||||
bool extrude_interface = has_interface && interface_extruder == extruder_id;
|
||||
if (extrude_support || extrude_interface) {
|
||||
init_layer_delayed();
|
||||
m_layer = layer_to_print.support_layer;
|
||||
|
@ -317,13 +317,16 @@ void Layer::build_up_down_graph(Layer& below, Layer& above)
|
||||
coord_t* end = srcs + 4;
|
||||
std::sort(begin, end);
|
||||
end = std::unique(begin, end);
|
||||
assert(begin + 2 == end);
|
||||
if (begin + 1 == end)
|
||||
if (begin + 1 == end) {
|
||||
// Self intersection may happen on source contour. Just copy the Z value.
|
||||
pt.z() = *begin;
|
||||
else if (begin + 2 <= end) {
|
||||
// store a -1 based negative index into the "intersections" vector here.
|
||||
m_intersections.emplace_back(srcs[0], srcs[1]);
|
||||
pt.z() = -coord_t(m_intersections.size());
|
||||
} else {
|
||||
assert(begin + 2 == end);
|
||||
if (begin + 2 <= end) {
|
||||
// store a -1 based negative index into the "intersections" vector here.
|
||||
m_intersections.emplace_back(srcs[0], srcs[1]);
|
||||
pt.z() = -coord_t(m_intersections.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
const std::vector<std::pair<coord_t, coord_t>>& intersections() const { return m_intersections; }
|
||||
|
@ -397,22 +397,37 @@ static ClipperLib_Z::Paths clip_extrusion(const ClipperLib_Z::Path &subject, con
|
||||
ClipperLib_Z::Clipper clipper;
|
||||
clipper.ZFillFunction([](const ClipperLib_Z::IntPoint &e1bot, const ClipperLib_Z::IntPoint &e1top, const ClipperLib_Z::IntPoint &e2bot,
|
||||
const ClipperLib_Z::IntPoint &e2top, ClipperLib_Z::IntPoint &pt) {
|
||||
// The clipping contour may be simplified by clipping it with a bounding box of "subject" path.
|
||||
// The clipping function used may produce self intersections outside of the "subject" bounding box. Such self intersections are
|
||||
// harmless to the result of the clipping operation,
|
||||
// Both ends of each edge belong to the same source: Either they are from subject or from clipping path.
|
||||
assert(e1bot.z() >= 0 && e1top.z() >= 0);
|
||||
assert(e2bot.z() >= 0 && e2top.z() >= 0);
|
||||
assert((e1bot.z() == 0) == (e1top.z() == 0));
|
||||
assert((e2bot.z() == 0) == (e2top.z() == 0));
|
||||
|
||||
// Start & end points of the clipped polyline (extrusion path with a non-zero width).
|
||||
ClipperLib_Z::IntPoint start = e1bot;
|
||||
ClipperLib_Z::IntPoint end = e1top;
|
||||
|
||||
if (start.z() <= 0 && end.z() <= 0) {
|
||||
start = e2bot;
|
||||
end = e2top;
|
||||
}
|
||||
|
||||
assert(start.z() > 0 && end.z() > 0);
|
||||
if (start.z() <= 0 && end.z() <= 0) {
|
||||
// Self intersection on the source contour.
|
||||
assert(start.z() == 0 && end.z() == 0);
|
||||
pt.z() = 0;
|
||||
} else {
|
||||
// Interpolate extrusion line width.
|
||||
assert(start.z() > 0 && end.z() > 0);
|
||||
|
||||
// Interpolate extrusion line width.
|
||||
double length_sqr = (end - start).cast<double>().squaredNorm();
|
||||
double dist_sqr = (pt - start).cast<double>().squaredNorm();
|
||||
double t = std::sqrt(dist_sqr / length_sqr);
|
||||
double length_sqr = (end - start).cast<double>().squaredNorm();
|
||||
double dist_sqr = (pt - start).cast<double>().squaredNorm();
|
||||
double t = std::sqrt(dist_sqr / length_sqr);
|
||||
|
||||
pt.z() = start.z() + coord_t((end.z() - start.z()) * t);
|
||||
pt.z() = start.z() + coord_t((end.z() - start.z()) * t);
|
||||
}
|
||||
});
|
||||
|
||||
clipper.AddPath(subject, ClipperLib_Z::ptSubject, false);
|
||||
|
@ -1386,6 +1386,45 @@ void PageFirmware::apply_custom_config(DynamicPrintConfig &config)
|
||||
}
|
||||
}
|
||||
|
||||
static void focus_event(wxFocusEvent& e, wxTextCtrl* ctrl, double def_value)
|
||||
{
|
||||
e.Skip();
|
||||
wxString str = ctrl->GetValue();
|
||||
|
||||
const char dec_sep = is_decimal_separator_point() ? '.' : ',';
|
||||
const char dec_sep_alt = dec_sep == '.' ? ',' : '.';
|
||||
// Replace the first incorrect separator in decimal number.
|
||||
bool was_replaced = str.Replace(dec_sep_alt, dec_sep, false) != 0;
|
||||
|
||||
double val = 0.0;
|
||||
if (!str.ToDouble(&val)) {
|
||||
if (val == 0.0)
|
||||
val = def_value;
|
||||
ctrl->SetValue(double_to_string(val));
|
||||
show_error(nullptr, _L("Invalid numeric input."));
|
||||
// On Windows, this SetFocus creates an invisible marker.
|
||||
//ctrl->SetFocus();
|
||||
}
|
||||
else if (was_replaced)
|
||||
ctrl->SetValue(double_to_string(val));
|
||||
}
|
||||
|
||||
class DiamTextCtrl : public wxTextCtrl
|
||||
{
|
||||
public:
|
||||
DiamTextCtrl(wxWindow* parent)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
long style = wxBORDER_SIMPLE;
|
||||
#else
|
||||
long style = 0;
|
||||
#endif
|
||||
Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(Field::def_width_thinner() * wxGetApp().em_unit(), wxDefaultCoord), style);
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
}
|
||||
~DiamTextCtrl() {}
|
||||
};
|
||||
|
||||
PageBedShape::PageBedShape(ConfigWizard *parent)
|
||||
: ConfigWizardPage(parent, _L("Bed Shape and Size"), _L("Bed Shape"), 1)
|
||||
, shape_panel(new BedShapePanel(this))
|
||||
@ -1409,43 +1448,63 @@ void PageBedShape::apply_custom_config(DynamicPrintConfig &config)
|
||||
config.set_key_value("bed_custom_model", new ConfigOptionString(custom_model));
|
||||
}
|
||||
|
||||
static void focus_event(wxFocusEvent& e, wxTextCtrl* ctrl, double def_value)
|
||||
PageBuildVolume::PageBuildVolume(ConfigWizard* parent)
|
||||
: ConfigWizardPage(parent, _L("Build Volume"), _L("Build Volume"), 1)
|
||||
, build_volume(new DiamTextCtrl(this))
|
||||
{
|
||||
e.Skip();
|
||||
wxString str = ctrl->GetValue();
|
||||
append_text(_L("Set verctical size of your printer."));
|
||||
|
||||
const char dec_sep = is_decimal_separator_point() ? '.' : ',';
|
||||
const char dec_sep_alt = dec_sep == '.' ? ',' : '.';
|
||||
// Replace the first incorrect separator in decimal number.
|
||||
bool was_replaced = str.Replace(dec_sep_alt, dec_sep, false) != 0;
|
||||
wxString value = "200";
|
||||
build_volume->SetValue(value);
|
||||
|
||||
double val = 0.0;
|
||||
if (!str.ToDouble(&val)) {
|
||||
if (val == 0.0)
|
||||
build_volume->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent& e) {
|
||||
double def_value = 200.0;
|
||||
double max_value = 1200.0;
|
||||
e.Skip();
|
||||
wxString str = build_volume->GetValue();
|
||||
|
||||
const char dec_sep = is_decimal_separator_point() ? '.' : ',';
|
||||
const char dec_sep_alt = dec_sep == '.' ? ',' : '.';
|
||||
// Replace the first incorrect separator in decimal number.
|
||||
bool was_replaced = str.Replace(dec_sep_alt, dec_sep, false) != 0;
|
||||
|
||||
double val = 0.0;
|
||||
if (!str.ToDouble(&val)) {
|
||||
val = def_value;
|
||||
ctrl->SetValue(double_to_string(val));
|
||||
show_error(nullptr, _L("Invalid numeric input."));
|
||||
ctrl->SetFocus();
|
||||
}
|
||||
else if (was_replaced)
|
||||
ctrl->SetValue(double_to_string(val));
|
||||
build_volume->SetValue(double_to_string(val));
|
||||
show_error(nullptr, _L("Invalid numeric input."));
|
||||
//build_volume->SetFocus();
|
||||
} else if (val < 0.0) {
|
||||
val = def_value;
|
||||
build_volume->SetValue(double_to_string(val));
|
||||
show_error(nullptr, _L("Invalid numeric input."));
|
||||
//build_volume->SetFocus();
|
||||
} else if (val > max_value) {
|
||||
val = max_value;
|
||||
build_volume->SetValue(double_to_string(val));
|
||||
show_error(nullptr, _L("Invalid numeric input."));
|
||||
//build_volume->SetFocus();
|
||||
} else if (was_replaced)
|
||||
build_volume->SetValue(double_to_string(val));
|
||||
}, build_volume->GetId());
|
||||
|
||||
auto* sizer_volume = new wxFlexGridSizer(3, 5, 5);
|
||||
auto* text_volume = new wxStaticText(this, wxID_ANY, _L("Max print height:"));
|
||||
auto* unit_volume = new wxStaticText(this, wxID_ANY, _L("mm"));
|
||||
sizer_volume->AddGrowableCol(0, 1);
|
||||
sizer_volume->Add(text_volume, 0, wxALIGN_CENTRE_VERTICAL);
|
||||
sizer_volume->Add(build_volume);
|
||||
sizer_volume->Add(unit_volume, 0, wxALIGN_CENTRE_VERTICAL);
|
||||
append(sizer_volume);
|
||||
}
|
||||
|
||||
class DiamTextCtrl : public wxTextCtrl
|
||||
void PageBuildVolume::apply_custom_config(DynamicPrintConfig& config)
|
||||
{
|
||||
public:
|
||||
DiamTextCtrl(wxWindow* parent)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
long style = wxBORDER_SIMPLE;
|
||||
#else
|
||||
long style = 0;
|
||||
#endif
|
||||
Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(Field::def_width_thinner() * wxGetApp().em_unit(), wxDefaultCoord), style);
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
}
|
||||
~DiamTextCtrl() {}
|
||||
};
|
||||
double val = 0.0;
|
||||
build_volume->GetValue().ToDouble(&val);
|
||||
auto* opt_volume = new ConfigOptionFloat(val);
|
||||
config.set_key_value("max_print_height", opt_volume);
|
||||
}
|
||||
|
||||
PageDiameters::PageDiameters(ConfigWizard *parent)
|
||||
: ConfigWizardPage(parent, _L("Filament and Nozzle Diameters"), _L("Print Diameters"), 1)
|
||||
@ -1915,6 +1974,7 @@ void ConfigWizard::priv::load_pages()
|
||||
if (page_custom->custom_wanted()) {
|
||||
index->add_page(page_firmware);
|
||||
index->add_page(page_bed);
|
||||
index->add_page(page_bvolume);
|
||||
index->add_page(page_diams);
|
||||
index->add_page(page_temps);
|
||||
}
|
||||
@ -2773,6 +2833,7 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
||||
|
||||
page_firmware->apply_custom_config(*custom_config);
|
||||
page_bed->apply_custom_config(*custom_config);
|
||||
page_bvolume->apply_custom_config(*custom_config);
|
||||
page_diams->apply_custom_config(*custom_config);
|
||||
page_temps->apply_custom_config(*custom_config);
|
||||
|
||||
@ -2923,6 +2984,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
|
||||
p->add_page(p->page_mode = new PageMode(this));
|
||||
p->add_page(p->page_firmware = new PageFirmware(this));
|
||||
p->add_page(p->page_bed = new PageBedShape(this));
|
||||
p->add_page(p->page_bvolume = new PageBuildVolume(this));
|
||||
p->add_page(p->page_diams = new PageDiameters(this));
|
||||
p->add_page(p->page_temps = new PageTemperatures(this));
|
||||
|
||||
|
@ -450,6 +450,14 @@ struct PageBedShape: ConfigWizardPage
|
||||
virtual void apply_custom_config(DynamicPrintConfig &config);
|
||||
};
|
||||
|
||||
struct PageBuildVolume : ConfigWizardPage
|
||||
{
|
||||
wxTextCtrl* build_volume;
|
||||
|
||||
PageBuildVolume(ConfigWizard* parent);
|
||||
virtual void apply_custom_config(DynamicPrintConfig& config);
|
||||
};
|
||||
|
||||
struct PageDiameters: ConfigWizardPage
|
||||
{
|
||||
wxTextCtrl *diam_nozzle;
|
||||
@ -584,6 +592,7 @@ struct ConfigWizard::priv
|
||||
PageBedShape *page_bed = nullptr;
|
||||
PageDiameters *page_diams = nullptr;
|
||||
PageTemperatures *page_temps = nullptr;
|
||||
PageBuildVolume* page_bvolume = nullptr;
|
||||
|
||||
// Pointers to all pages (regardless or whether currently part of the ConfigWizardIndex)
|
||||
std::vector<ConfigWizardPage*> all_pages;
|
||||
|
@ -1418,8 +1418,7 @@ void ColourPicker::sys_color_changed()
|
||||
|
||||
PointCtrl::~PointCtrl()
|
||||
{
|
||||
if (sizer) {
|
||||
sizer->Clear();
|
||||
if (sizer && sizer->IsEmpty()) {
|
||||
delete sizer;
|
||||
sizer = nullptr;
|
||||
}
|
||||
|
@ -970,16 +970,19 @@ void MenuFactory::append_menu_item_edit_text(wxMenu *menu)
|
||||
wxString name = _L("Edit text");
|
||||
|
||||
auto can_edit_text = []() {
|
||||
const auto& sel = plater()->get_selection();
|
||||
if (sel.volumes_count() != 1) return false;
|
||||
auto cid = sel.get_volume(*sel.get_volume_idxs().begin());
|
||||
const ModelVolume* vol = plater()->canvas3D()->get_model()
|
||||
->objects[cid->object_idx()]->volumes[cid->volume_idx()];
|
||||
return vol->text_configuration.has_value();
|
||||
if (plater() != nullptr) {
|
||||
const Selection& sel = plater()->get_selection();
|
||||
if (sel.volumes_count() == 1) {
|
||||
const GLVolume* gl_vol = sel.get_first_volume();
|
||||
const ModelVolume* vol = plater()->model().objects[gl_vol->object_idx()]->volumes[gl_vol->volume_idx()];
|
||||
return vol->text_configuration.has_value();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (menu == &m_object_menu) {
|
||||
auto menu_item_id = menu->FindItem(name);
|
||||
if (menu != &m_text_part_menu) {
|
||||
const int menu_item_id = menu->FindItem(name);
|
||||
if (menu_item_id != wxNOT_FOUND)
|
||||
menu->Destroy(menu_item_id);
|
||||
if (!can_edit_text())
|
||||
|
Loading…
Reference in New Issue
Block a user