Merge branch 'master' into tm_colldetection_upgr

This commit is contained in:
tamasmeszaros 2019-01-15 15:32:35 +01:00
commit 05861dcacd
18 changed files with 163 additions and 89 deletions

View file

@ -103,8 +103,7 @@ OozePrevention::_get_temp(GCode &gcodegen)
: gcodegen.config().temperature.get_at(gcodegen.writer().extruder()->id());
}
std::string
Wipe::wipe(GCode &gcodegen, bool toolchange)
std::string Wipe::wipe(GCode &gcodegen, bool toolchange)
{
std::string gcode;
@ -137,19 +136,22 @@ Wipe::wipe(GCode &gcodegen, bool toolchange)
wipe_path.clip_end(wipe_path.length() - wipe_dist);
// subdivide the retraction in segments
for (const Line &line : wipe_path.lines()) {
double segment_length = line.length();
/* Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one
due to rounding (TODO: test and/or better math for this) */
double dE = length * (segment_length / wipe_dist) * 0.95;
//FIXME one shall not generate the unnecessary G1 Fxxx commands, here wipe_speed is a constant inside this cycle.
// Is it here for the cooling markers? Or should it be outside of the cycle?
gcode += gcodegen.writer().set_speed(wipe_speed*60, "", gcodegen.enable_cooling_markers() ? ";_WIPE" : "");
gcode += gcodegen.writer().extrude_to_xy(
gcodegen.point_to_gcode(line.b),
-dE,
"wipe and retract"
);
if (! wipe_path.empty()) {
for (const Line &line : wipe_path.lines()) {
double segment_length = line.length();
/* Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one
due to rounding (TODO: test and/or better math for this) */
double dE = length * (segment_length / wipe_dist) * 0.95;
//FIXME one shall not generate the unnecessary G1 Fxxx commands, here wipe_speed is a constant inside this cycle.
// Is it here for the cooling markers? Or should it be outside of the cycle?
gcode += gcodegen.writer().set_speed(wipe_speed*60, "", gcodegen.enable_cooling_markers() ? ";_WIPE" : "");
gcode += gcodegen.writer().extrude_to_xy(
gcodegen.point_to_gcode(line.b),
-dE,
"wipe and retract"
);
}
gcodegen.set_last_pos(wipe_path.points.back());
}
// prevent wiping again on same path
@ -2577,9 +2579,11 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string
// use G1 because we rely on paths being straight (G0 may make round paths)
Lines lines = travel.lines();
for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line)
gcode += m_writer.travel_to_xy(this->point_to_gcode(line->b), comment);
if (! lines.empty()) {
for (const Line &line : lines)
gcode += m_writer.travel_to_xy(this->point_to_gcode(line.b), comment);
this->set_last_pos(lines.back().b);
}
return gcode;
}

View file

@ -155,11 +155,11 @@ public:
void do_export(Print *print, const char *path, GCodePreviewData *preview_data = nullptr);
// Exported for the helper classes (OozePrevention, Wipe) and for the Perl binding for unit tests.
const Vec2d& origin() const { return m_origin; }
const Vec2d& origin() const { return m_origin; }
void set_origin(const Vec2d &pointf);
void set_origin(const coordf_t x, const coordf_t y) { this->set_origin(Vec2d(x, y)); }
const Point& last_pos() const { return m_last_pos; }
Vec2d point_to_gcode(const Point &point) const;
Vec2d point_to_gcode(const Point &point) const;
Point gcode_to_point(const Vec2d &point) const;
const FullPrintConfig &config() const { return m_config; }
const Layer* layer() const { return m_layer; }
@ -360,6 +360,7 @@ protected:
size_t num_objects,
size_t num_islands);
friend class Wipe;
friend class WipeTowerIntegration;
};

View file

@ -1182,15 +1182,17 @@ Transform3d assemble_transform(const Vec3d& translation, const Vec3d& rotation,
Vec3d extract_euler_angles(const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& rotation_matrix)
{
#if ENABLE_NEW_EULER_ANGLES
bool x_only = (rotation_matrix(0, 0) == 1.0) && (rotation_matrix(0, 1) == 0.0) && (rotation_matrix(0, 2) == 0.0) && (rotation_matrix(1, 0) == 0.0) && (rotation_matrix(2, 0) == 0.0);
bool y_only = (rotation_matrix(0, 1) == 0.0) && (rotation_matrix(1, 0) == 0.0) && (rotation_matrix(1, 1) == 1.0) && (rotation_matrix(1, 2) == 0.0) && (rotation_matrix(2, 1) == 0.0);
bool z_only = (rotation_matrix(0, 2) == 0.0) && (rotation_matrix(1, 2) == 0.0) && (rotation_matrix(2, 0) == 0.0) && (rotation_matrix(2, 1) == 0.0) && (rotation_matrix(2, 2) == 1.0);
// bool xy_only = (rotation_matrix(0, 1) == 0.0); // Rx * Ry
bool yx_only = (rotation_matrix(1, 0) == 0.0); // Ry * Rx
// bool xz_only = (rotation_matrix(0, 2) == 0.0); // Rx * Rz
// bool zx_only = (rotation_matrix(2, 0) == 0.0); // Rz * Rx
// bool yz_only = (rotation_matrix(1, 2) == 0.0); // Ry * Rz
// bool zy_only = (rotation_matrix(2, 1) == 0.0); // Rz * Ry
auto is_approx = [](double value, double test_value) -> bool { return std::abs(value - test_value) < EPSILON; };
bool x_only = is_approx(rotation_matrix(0, 0), 1.0) && is_approx(rotation_matrix(0, 1), 0.0) && is_approx(rotation_matrix(0, 2), 0.0) && is_approx(rotation_matrix(1, 0), 0.0) && is_approx(rotation_matrix(2, 0), 0.0);
bool y_only = is_approx(rotation_matrix(0, 1), 0.0) && is_approx(rotation_matrix(1, 0), 0.0) && is_approx(rotation_matrix(1, 1), 1.0) && is_approx(rotation_matrix(1, 2), 0.0) && is_approx(rotation_matrix(2, 1), 0.0);
bool z_only = is_approx(rotation_matrix(0, 2), 0.0) && is_approx(rotation_matrix(1, 2), 0.0) && is_approx(rotation_matrix(2, 0), 0.0) && is_approx(rotation_matrix(2, 1), 0.0) && is_approx(rotation_matrix(2, 2), 1.0);
// bool xy_only = is_approx(rotation_matrix(0, 1), 0.0); // Rx * Ry
bool yx_only = is_approx(rotation_matrix(1, 0), 0.0); // Ry * Rx
// bool xz_only = is_approx(rotation_matrix(0, 2), 0.0); // Rx * Rz
// bool zx_only = is_approx(rotation_matrix(2, 0), 0.0); // Rz * Rx
// bool yz_only = is_approx(rotation_matrix(1, 2), 0.0); // Ry * Rz
// bool zy_only = is_approx(rotation_matrix(2, 1), 0.0); // Rz * Ry
Vec3d angles = Vec3d::Zero();
if (x_only || y_only || z_only)

View file

@ -206,6 +206,26 @@ std::vector<Point> MultiPoint::_douglas_peucker(const std::vector<Point>& pts, c
floater = &pts[floater_idx];
}
}
assert(result_pts.front() == pts.front());
assert(result_pts.back() == pts.back());
#if 0
{
static int iRun = 0;
BoundingBox bbox(pts);
BoundingBox bbox2(result_pts);
bbox.merge(bbox2);
SVG svg(debug_out_path("douglas_peucker_%d.svg", iRun ++).c_str(), bbox);
if (pts.front() == pts.back())
svg.draw(Polygon(pts), "black");
else
svg.draw(Polyline(pts), "black");
if (result_pts.front() == result_pts.back())
svg.draw(Polygon(result_pts), "green", scale_(0.1));
else
svg.draw(Polyline(result_pts), "green", scale_(0.1));
}
#endif
}
return result_pts;
}

View file

@ -1204,8 +1204,8 @@ bool SLASupportTree::generate(const PointSet &points,
// there is no need to bridge them together.
if(pillar_dist > 2*cfg.head_back_radius_mm &&
bridge_distance < cfg.max_bridge_length_mm)
while(sj(Z) > pillar.endpoint(Z) &&
ej(Z) > nextpillar.endpoint(Z))
while(sj(Z) > pillar.endpoint(Z) + cfg.base_radius_mm &&
ej(Z) > nextpillar.endpoint(Z) + + cfg.base_radius_mm)
{
if(chkd >= bridge_distance) {
result.add_bridge(sj, ej, pillar.r);
@ -1702,7 +1702,7 @@ SlicedSupports SLASupportTree::slice(float layerh, float init_layerh) const
const Pad& pad = m_impl->pad();
if(!pad.empty()) gndlvl -= float(get_pad_elevation(pad.cfg));
std::vector<float> heights = {gndlvl};
std::vector<float> heights;
heights.reserve(size_t(modelh/layerh) + 1);
for(float h = gndlvl + init_layerh; h < gndlvl + modelh; h += layerh) {

View file

@ -732,9 +732,7 @@ void SLAPrint::process()
po.m_supportdata->level_ids.reserve(sslices.size());
for(int i = 0; i < int(sslices.size()); ++i) {
int a = i == 0 ? 0 : 1;
int b = i == 0 ? 0 : i - 1;
LevelID h = sminZ + a * sih + b * slh;
LevelID h = sminZ + sih + i * slh;
po.m_supportdata->level_ids.emplace_back(h);
float fh = float(double(h) * SCALING_FACTOR);

View file

@ -148,8 +148,16 @@ private:
// Which steps have to be performed. Implicitly: all
std::vector<bool> m_stepmask;
// Individual 2d slice polygons from lower z to higher z levels
std::vector<ExPolygons> m_model_slices;
// Exact (float) height levels mapped to the slices. Each record contains
// the index to the model and the support slice vectors.
SliceIndex m_slice_index;
// The height levels corrected and scaled up in integer values. This will
// be used at rasterization.
std::vector<LevelID> m_level_ids;
// Caching the transformed (m_trafo) raw mesh of the object

View file

@ -860,12 +860,12 @@ void TriangleMeshSlicer::_slice_do(size_t facet_idx, std::vector<IntersectionLin
// find layer extents
std::vector<float>::const_iterator min_layer, max_layer;
min_layer = std::lower_bound(z.begin(), z.end(), min_z); // first layer whose slice_z is >= min_z
max_layer = std::upper_bound(z.begin() + (min_layer - z.begin()), z.end(), max_z) - 1; // last layer whose slice_z is <= max_z
max_layer = std::upper_bound(min_layer, z.end(), max_z); // first layer whose slice_z is > max_z
#ifdef SLIC3R_TRIANGLEMESH_DEBUG
printf("layers: min = %d, max = %d\n", (int)(min_layer - z.begin()), (int)(max_layer - z.begin()));
#endif /* SLIC3R_TRIANGLEMESH_DEBUG */
for (std::vector<float>::const_iterator it = min_layer; it != max_layer + 1; ++ it) {
for (std::vector<float>::const_iterator it = min_layer; it != max_layer; ++ it) {
std::vector<float>::size_type layer_idx = it - z.begin();
IntersectionLine il;
if (this->slice_facet(*it / SCALING_FACTOR, facet, facet_idx, min_z, max_z, &il) == TriangleMeshSlicer::Slicing) {

View file

@ -114,7 +114,7 @@ AboutDialog::AboutDialog()
this->Bind(wxEVT_BUTTON, &AboutDialog::onCloseDialog, this, wxID_CLOSE);
vsizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3);
this->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this);
// this->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this);
logo->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this);
SetSizer(main_sizer);

View file

@ -775,6 +775,8 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
SetSize(std::max(size.GetWidth(), static_cast<int>(MIN_WIDTH)), std::max(size.GetHeight(), static_cast<int>(MIN_HEIGHT)));
Layout();
SetEscapeId(wxID_CLOSE); // To close the dialog using "Esc" button
// Bind events
p->hex_picker->Bind(wxEVT_FILEPICKER_CHANGED, [this](wxFileDirPickerEvent& evt) {
@ -826,6 +828,7 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
if (this->p->avrdude) {
evt.Veto();
} else {
this->EndModal(wxID_CLOSE);
evt.Skip();
}
});

View file

@ -1609,13 +1609,12 @@ void GLCanvas3D::Selection::rotate(const Vec3d& rotation, bool local)
else if (is_single_volume() || is_single_modifier())
#if ENABLE_WORLD_ROTATIONS
{
if (requires_local_axes())
if (local)
(*m_volumes)[i]->set_volume_rotation(rotation);
else
{
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
const Transform3d& inst_m = m_cache.volumes_data[i].get_instance_rotation_matrix();
Vec3d new_rotation = Geometry::extract_euler_angles(inst_m.inverse() * m * inst_m * m_cache.volumes_data[i].get_volume_rotation_matrix());
Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix());
(*m_volumes)[i]->set_volume_rotation(new_rotation);
}
}
@ -5709,7 +5708,7 @@ void GLCanvas3D::set_camera_zoom(float zoom)
// Don't allow to zoom too far outside the scene.
float zoom_min = _get_zoom_to_bounding_box_factor(_max_bounding_box());
if (zoom_min > 0.0f)
zoom = std::max(zoom, zoom_min * 0.8f);
zoom = std::max(zoom, zoom_min * 0.7f);
m_camera.zoom = zoom;
viewport_changed();

View file

@ -497,7 +497,11 @@ void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
}
canvas->get_selection().start_dragging();
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
canvas->get_selection().rotate(rad_rotation, selection.is_single_full_instance() || selection.requires_local_axes());
#else
canvas->get_selection().rotate(rad_rotation, selection.is_single_full_instance());
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
canvas->do_rotate();
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION

View file

@ -24,7 +24,7 @@ public:
virtual void Hide();
virtual void UpdateAndShow(const bool show);
wxSizer* get_sizer();
virtual wxSizer* get_sizer();
ConfigOptionsGroup* get_og() { return m_og.get(); }
};

View file

@ -751,30 +751,20 @@ void Preview::load_print_as_fff()
if (IsShown())
{
if (gcode_preview_data_valid)
{
// Load the real G-code preview.
m_canvas->load_gcode_preview(*m_gcode_preview_data, colors);
show_hide_ui_elements("full");
// recalculates zs and update sliders accordingly
has_layers = ! m_canvas->get_current_print_zs(true).empty();
if (! has_layers)
{
// all layers filtered out
reset_sliders();
m_canvas_widget->Refresh();
}
}
else
{
// load skirt and brim
// Load the initial preview based on slices, not the final G-code.
m_canvas->load_preview(colors);
show_hide_ui_elements("simple");
}
if (has_layers)
update_sliders(m_canvas->get_current_print_zs(true));
show_hide_ui_elements(gcode_preview_data_valid ? "full" : "simple");
// recalculates zs and update sliders accordingly
std::vector<double> zs = m_canvas->get_current_print_zs(true);
if (zs.empty()) {
// all layers filtered out
reset_sliders();
m_canvas_widget->Refresh();
} else
update_sliders(zs);
m_loaded = true;
}
}

View file

@ -286,12 +286,17 @@ class FreqChangedParams : public OG_Settings
{
double m_brim_width = 0.0;
wxButton* m_wiping_dialog_button{ nullptr };
wxSizer* m_sizer {nullptr};
std::shared_ptr<ConfigOptionsGroup> m_og_sla;
public:
FreqChangedParams(wxWindow* parent, const int label_width);
~FreqChangedParams() {}
wxButton* get_wiping_dialog_button() { return m_wiping_dialog_button; }
void Show(const bool show);
wxSizer* get_sizer() override;
ConfigOptionsGroup* get_og(const bool is_fff);
void Show(const bool is_fff);
};
FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
@ -299,22 +304,13 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
{
DynamicPrintConfig* config = &wxGetApp().preset_bundle->prints.get_edited_preset().config;
// Frequently changed parameters for FFF_technology
m_og->set_config(config);
m_og->label_width = label_width;
m_og->m_on_change = [config, this](t_config_option_key opt_key, boost::any value) {
TabPrint* tab_print = nullptr;
for (size_t i = 0; i < wxGetApp().tab_panel()->GetPageCount(); ++i) {
Tab *tab = dynamic_cast<Tab*>(wxGetApp().tab_panel()->GetPage(i));
if (!tab)
continue;
if (tab->name() == "print") {
tab_print = static_cast<TabPrint*>(tab);
break;
}
}
if (tab_print == nullptr)
return;
Tab* tab_print = wxGetApp().get_tab(Preset::TYPE_PRINT);
if (!tab_print) return;
if (opt_key == "fill_density") {
value = m_og->get_config_value(*config, opt_key);
@ -413,19 +409,56 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
return sizer;
};
m_og->append_line(line);
// Frequently changed parameters for SLA_technology
m_og_sla = std::make_shared<ConfigOptionsGroup>(parent, "");
DynamicPrintConfig* config_sla = &wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
m_og_sla->set_config(config_sla);
m_og_sla->label_width = label_width*2;
m_og_sla->m_on_change = [config_sla, this](t_config_option_key opt_key, boost::any value) {
Tab* tab = wxGetApp().get_tab(Preset::TYPE_SLA_PRINT);
if (!tab) return;
tab->set_value(opt_key, value);
DynamicPrintConfig new_conf = *config_sla;
new_conf.set_key_value(opt_key, new ConfigOptionBool(boost::any_cast<bool>(value)));
tab->load_config(new_conf);
tab->update_dirty();
};
m_og_sla->append_single_option_line("supports_enable");
m_og_sla->append_single_option_line("pad_enable");
m_sizer = new wxBoxSizer(wxVERTICAL);
m_sizer->Add(m_og->sizer, 0, wxEXPAND);
m_sizer->Add(m_og_sla->sizer, 0, wxEXPAND | wxTOP, 5);
}
void FreqChangedParams::Show(const bool show)
wxSizer* FreqChangedParams::get_sizer()
{
bool is_wdb_shown = m_wiping_dialog_button->IsShown();
m_og->Show(show);
return m_sizer;
}
void FreqChangedParams::Show(const bool is_fff)
{
const bool is_wdb_shown = m_wiping_dialog_button->IsShown();
m_og->Show(is_fff);
m_og_sla->Show(!is_fff);
// correct showing of the FreqChangedParams sizer when m_wiping_dialog_button is hidden
if (show && !is_wdb_shown)
if (is_fff && !is_wdb_shown)
m_wiping_dialog_button->Hide();
}
ConfigOptionsGroup* FreqChangedParams::get_og(const bool is_fff)
{
return is_fff ? m_og.get() : m_og_sla.get();
}
// Sidebar / private
struct Sidebar::priv
@ -703,9 +736,9 @@ wxScrolledWindow* Sidebar::scrolled_panel()
return p->scrolled;
}
ConfigOptionsGroup* Sidebar::og_freq_chng_params()
ConfigOptionsGroup* Sidebar::og_freq_chng_params(const bool is_fff)
{
return p->frequently_changed_parameters->get_og();
return p->frequently_changed_parameters->get_og(is_fff);
}
wxButton* Sidebar::get_wiping_dialog_button()

View file

@ -76,7 +76,7 @@ public:
ObjectSettings* obj_settings();
wxScrolledWindow* scrolled_panel();
ConfigOptionsGroup* og_freq_chng_params();
ConfigOptionsGroup* og_freq_chng_params(const bool is_fff);
wxButton* get_wiping_dialog_button();
void update_objects_list_extruder_column(int extruders_count);
void show_info_sizer();

View file

@ -120,7 +120,7 @@ SysInfoDialog::SysInfoDialog()
this->Bind(wxEVT_BUTTON, &SysInfoDialog::onCloseDialog, this, wxID_OK);
main_sizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3);
this->Bind(wxEVT_LEFT_DOWN, &SysInfoDialog::onCloseDialog, this);
// this->Bind(wxEVT_LEFT_DOWN, &SysInfoDialog::onCloseDialog, this);
logo->Bind(wxEVT_LEFT_DOWN, &SysInfoDialog::onCloseDialog, this);
SetSizer(main_sizer);

View file

@ -751,8 +751,8 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
wxPostEvent(this, event);
auto og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params();
if (opt_key == "fill_density")
ConfigOptionsGroup* og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params(supports_printer_technology(ptFFF));
if (opt_key == "fill_density" || opt_key == "supports_enable" || opt_key == "pad_enable")
{
boost::any val = og_freq_chng_params->get_config_value(*m_config, opt_key);
og_freq_chng_params->set_value(opt_key, val);
@ -881,8 +881,20 @@ void Tab::update_preset_description_line()
void Tab::update_frequently_changed_parameters()
{
auto og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params();
auto og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params(supports_printer_technology(ptFFF));
if (!og_freq_chng_params) return;
if (m_type == Preset::TYPE_SLA_PRINT)
{
for (auto opt_key : { "supports_enable", "pad_enable" })
{
boost::any val = og_freq_chng_params->get_config_value(*m_config, opt_key);
og_freq_chng_params->set_value(opt_key, val);
}
return;
}
// for m_type == Preset::TYPE_PRINT
boost::any value = og_freq_chng_params->get_config_value(*m_config, "fill_density");
og_freq_chng_params->set_value("fill_density", value);
@ -2370,7 +2382,7 @@ void Tab::load_current_preset()
}
else {
on_presets_changed();
if (m_name == "print")
if (m_type == Preset::TYPE_SLA_PRINT || m_type == Preset::TYPE_PRINT)// if (m_name == "print")
update_frequently_changed_parameters();
}