Get name of both the G-code and project file from the 1st printable

object's name or file path.
Fixed some compilation warnings.
This commit is contained in:
bubnikv 2019-02-01 11:44:08 +01:00
parent 405d18a7fa
commit 3b973e01dd
4 changed files with 14 additions and 18 deletions

View File

@ -13,7 +13,7 @@ class SpiralVase {
SpiralVase(const PrintConfig &config)
: enable(false), _config(&config)
{
this->_reader.z() = this->_config->z_offset;
this->_reader.z() = (float)this->_config->z_offset;
this->_reader.apply_config(*this->_config);
};
std::string process_layer(const std::string &gcode);

View File

@ -43,7 +43,7 @@ public:
}
bool cmd_is(const char *cmd_test) const {
const char *cmd = GCodeReader::skip_whitespaces(m_raw.c_str());
int len = strlen(cmd_test);
size_t len = strlen(cmd_test);
return strncmp(cmd, cmd_test, len) == 0 && GCodeReader::is_end_of_word(cmd[len]);
}
bool extruding(const GCodeReader &reader) const { return this->cmd_is("G1") && this->dist_E(reader) > 0; }

View File

@ -549,11 +549,18 @@ void Model::reset_auto_extruder_id()
std::string Model::propose_export_file_name() const
{
std::string input_file;
for (const ModelObject *model_object : this->objects)
for (ModelInstance *model_instance : model_object->instances)
if (model_instance->is_printable())
return model_object->name.empty() ? model_object->input_file : model_object->name;
return std::string();
if (model_instance->is_printable()) {
input_file = model_object->name.empty() ? model_object->input_file : model_object->name;
if (! input_file.empty())
goto end;
// Other instances will produce the same name, skip them.
break;
}
end:
return input_file;
}
ModelObject::~ModelObject()

View File

@ -67,20 +67,9 @@ std::string PrintBase::output_filename(const std::string &format, const std::str
std::string PrintBase::output_filepath(const std::string &path) const
{
// if we were supplied no path, generate an automatic one based on our first object's input file
if (path.empty()) {
if (path.empty())
// get the first input file name
std::string input_file;
for (const ModelObject *model_object : m_model.objects) {
for (ModelInstance *model_instance : model_object->instances)
if (model_instance->is_printable()) {
input_file = model_object->input_file;
break;
}
if (! input_file.empty())
break;
}
return (boost::filesystem::path(input_file).parent_path() / this->output_filename()).make_preferred().string();
}
return (boost::filesystem::path(m_model.propose_export_file_name()).parent_path() / this->output_filename()).make_preferred().string();
// if we were supplied a directory, use it and append our automatically generated filename
boost::filesystem::path p(path);