Skip to content

Commit

Permalink
some little fixes from issues
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Nov 20, 2023
2 parents cb19d69 + 35eb355 commit 7a6e06c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 18 deletions.
10 changes: 8 additions & 2 deletions src/libslic3r/Format/3mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3160,7 +3160,7 @@ namespace Slic3r {
} else {
for (const std::string& key : obj->config.keys()) {
std::string value = obj->config.opt_serialize(key);
if (!value.empty() && key.find("pattern")==std::string::npos) {
if (!value.empty()) {
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << OBJECT_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << value << "\"/>\n";
} else {
std::ofstream log("ERROR_FILE_TO_SEND_TO_MERILL_PLZZZZ.txt", std::ios_base::app);
Expand All @@ -3170,6 +3170,9 @@ namespace Slic3r {
log << "\n";
}
if (obj->config.option(key) != nullptr && obj->config.option(key)->type() == ConfigOptionType::coEnum) {
try{
log << "raw_int_value : " << obj->config.option(key)->getInt() << "\n";
} catch (std::exception ex) {}
log << "enum : " << obj->config.option(key)->getInt();
log << "\n";
const ConfigOptionDef* def = nullptr;
Expand Down Expand Up @@ -3269,12 +3272,15 @@ namespace Slic3r {
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << value << "\"/>\n";
} else {
std::ofstream log("ERROR_FILE_TO_SEND_TO_MERILL_PLZZZZ.txt", std::ios_base::app);
log << "error in model, can't serialize " << key << ": '" << value << "' " << ((volume->config.option(key) != nullptr)?"exist":"doesn't exist") << "\n";
log << "error in volume, can't serialize " << key << ": '" << value << "' " << ((volume->config.option(key) != nullptr)?"exist":"doesn't exist") << "\n";
if (volume->config.option(key) != nullptr) {
log << "type : " << volume->config.option(key)->type();
log << "\n";
}
if (volume->config.option(key) != nullptr && volume->config.option(key)->type() == ConfigOptionType::coEnum) {
try{
log << "raw_int_value : " << volume->config.option(key)->getInt() << "\n";
} catch (std::exception ex) {}
log << "enum : " << volume->config.option(key)->getInt();
log << "\n";
const ConfigOptionDef* def = nullptr;
Expand Down
16 changes: 10 additions & 6 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ std::string Wipe::wipe(GCode& gcodegen, bool toolchange)
wipe_path.clip_end(wipe_path.length() - wipe_dist);

// subdivide the retraction in segments
if (!wipe_path.empty()) {
// add tag for processor
gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_Start) + "\n";
if (!wipe_path.empty()) {
// add tag for processor
gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_Start) + "\n";
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
Expand All @@ -239,8 +239,8 @@ std::string Wipe::wipe(GCode& gcodegen, bool toolchange)
"wipe and retract"
);
}
// add tag for processor
gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_End) + "\n";
// add tag for processor
gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_End) + "\n";
gcodegen.set_last_pos(wipe_path.points.back());
}

Expand Down Expand Up @@ -2333,7 +2333,11 @@ std::string GCode::placeholder_parser_process(const std::string &name, const std
func_add_colour("filament_colour_int", config().filament_colour.values[current_extruder_id]);
func_add_colour("extruder_colour_int", config().extruder_colour.values[current_extruder_id]);
}
default_config.set_key_value("current_position", new ConfigOptionFloats({ unscaled(m_last_pos.x()), unscaled(m_last_pos.y()) }));

// should be the same as Vec2d gcode_pos = point_to_gcode(m_last_pos);
Vec3d gcode_pos = this->writer().get_position();
default_config.set_key_value("current_position", new ConfigOptionFloats( {gcode_pos.x(), gcode_pos.y(), gcode_pos.z()} ));
default_config.set_key_value("current_object_position", new ConfigOptionFloats( {m_origin.x(), m_origin.y()} ));

std::string gcode = m_placeholder_parser.process(templ, current_extruder_id, &default_config, &m_placeholder_parser_context);
if (!gcode.empty() && (m_config.gcode_comments || m_config.fan_speedup_time.value != 0 || m_config.fan_kickstart.value != 0 )) {
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/GCodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ uint16_t GCodeWriter::first_mill() const {
} else return m_millers.front().id();
}
bool GCodeWriter::tool_is_extruder() const {
return m_tool->id() < first_mill();
return m_tool && m_tool->id() < first_mill();
}
const Tool* GCodeWriter::get_tool(uint16_t id) const{
for (const Extruder& e : m_extruders)
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6236,9 +6236,9 @@ void PrintConfigDef::init_fff_params()
def->label = L("Roundness margin");
def->full_label = L("Polyhole detection margin");
def->category = OptionCategory::slicing;
def->tooltip = L("Maximum defection of a point to the estimated radius of the circle."
def->tooltip = L("Maximum deflection of a point to the estimated radius of the circle."
"\nAs cylinders are often exported as triangles of varying size, points may not be on the circle circumference."
" This setting allows you some leway to broaden the detection."
" This setting allows you some leeway to broaden the detection."
"\nIn mm or in % of the radius.");
def->sidetext = L("mm or %");
def->max_literal = { 10, false};
Expand Down
5 changes: 5 additions & 0 deletions src/slic3r/GUI/PhysicalPrinterDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
if(opt_key == "printhost_client_cert_enabled")
this->m_show_cert_fields = boost::any_cast<bool>(value);
if (!this->m_show_cert_fields && !m_config->opt_string("printhost_client_cert").empty()) {
change_opt_value(*m_config, "printhost_client_cert", std::string(""));
//change_opt_value(*m_config, "printhost_client_cert_password", "");
m_config->set_deserialize_strict("printhost_client_cert_password", "");
}
if (opt_key == "host_type" || opt_key == "printhost_authorization_type" || opt_key == "printhost_client_cert_enabled")
this->update();
if (opt_key == "print_host")
Expand Down
25 changes: 18 additions & 7 deletions src/slic3r/Utils/OctoPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ OctoPrint::OctoPrint(DynamicPrintConfig *config) :
m_ssl_revoke_best_effort(config->opt_bool("printhost_ssl_ignore_revoke"))
{}

const char* OctoPrint::get_name() const { return "OctoPrint"; }

constexpr char OctoprintName[] = "OctoPrint";
const char * OctoPrint::get_name() const { return OctoprintName; }

bool OctoPrint::test(wxString &msg) const
{
Expand Down Expand Up @@ -171,13 +173,22 @@ bool OctoPrint::test(wxString &msg) const
return res;
}

wxString OctoPrint::get_test_failed_msg (wxString &msg) const
wxString OctoPrint::get_test_failed_msg(wxString &msg) const
{
return GUI::from_u8((boost::format("%s: %s\n\n%s")
% (boost::format(_u8L("Could not connect to %s")) % get_name())
% std::string(msg.ToUTF8())
% _u8L("Note: OctoPrint version at least 1.1.0 is required.")
).str());
if (get_name() == OctoprintName) {
return GUI::from_u8(
(boost::format("%s: %s\n\n%s") %
(boost::format(_u8L("Could not connect to %s")) % get_name()) %
std::string(msg.ToUTF8()) %
_u8L("Note: OctoPrint version at least 1.1.0 is required."))
.str());
} else {
return GUI::from_u8(
(boost::format("%s: %s") %
(boost::format(_u8L("Could not connect to %s")) % get_name()) %
std::string(msg.ToUTF8()))
.str());
}
}

bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const
Expand Down

0 comments on commit 7a6e06c

Please sign in to comment.