mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-05 21:14:01 -06:00
Changed the G-code export and send to OctoPrint GUI code
to store the G-code next to the project file if it exists, and to process the project name with the PlaceholderParser.
This commit is contained in:
parent
e358dd9c01
commit
04397c7948
10 changed files with 55 additions and 31 deletions
|
@ -67,6 +67,14 @@ PrinterTechnology BackgroundSlicingProcess::current_printer_technology() const
|
|||
return m_print->technology();
|
||||
}
|
||||
|
||||
std::string BackgroundSlicingProcess::output_filepath_for_project(const boost::filesystem::path &project_path)
|
||||
{
|
||||
assert(m_print != nullptr);
|
||||
if (project_path.empty())
|
||||
return m_print->output_filepath("");
|
||||
return m_print->output_filepath(project_path.parent_path().string(), project_path.stem().string());
|
||||
}
|
||||
|
||||
// This function may one day be merged into the Print, but historically the print was separated
|
||||
// from the G-code generator.
|
||||
void BackgroundSlicingProcess::process_fff()
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <wx/event.h>
|
||||
|
||||
#include "libslic3r/Print.hpp"
|
||||
|
@ -65,6 +67,9 @@ public:
|
|||
const PrintBase* current_print() const { return m_print; }
|
||||
const Print* fff_print() const { return m_fff_print; }
|
||||
const SLAPrint* sla_print() const { return m_sla_print; }
|
||||
// Take the project path (if provided), extract the name of the project, run it through the macro processor and save it next to the project file.
|
||||
// If the project_path is empty, just run output_filepath().
|
||||
std::string output_filepath_for_project(const boost::filesystem::path &project_path);
|
||||
|
||||
// Start the background processing. Returns false if the background processing was already running.
|
||||
bool start();
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <regex>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
|
@ -2971,9 +2969,16 @@ wxString Plater::priv::get_project_filename(const wxString& extension) const
|
|||
void Plater::priv::set_project_filename(const wxString& filename)
|
||||
{
|
||||
boost::filesystem::path full_path = into_path(filename);
|
||||
// remove extension
|
||||
while (full_path.has_extension())
|
||||
{
|
||||
boost::filesystem::path ext = full_path.extension();
|
||||
if (boost::iequals(ext.string(), ".amf")) {
|
||||
// Remove the first extension.
|
||||
full_path.replace_extension("");
|
||||
// It may be ".zip.amf".
|
||||
if (boost::iequals(full_path.extension().string(), ".zip"))
|
||||
// Remove the 2nd extension.
|
||||
full_path.replace_extension("");
|
||||
} else {
|
||||
// Remove just one extension.
|
||||
full_path.replace_extension("");
|
||||
}
|
||||
|
||||
|
@ -3492,7 +3497,7 @@ void Plater::export_gcode()
|
|||
unsigned int state = this->p->update_restart_background_process(false, false);
|
||||
if (state & priv::UPDATE_BACKGROUND_PROCESS_INVALID)
|
||||
return;
|
||||
default_output_file = this->p->background_process.current_print()->output_filepath(into_path(get_project_filename()).string());
|
||||
default_output_file = this->p->background_process.output_filepath_for_project(into_path(get_project_filename(".3mf")));
|
||||
}
|
||||
catch (const std::exception &ex) {
|
||||
show_error(this, ex.what());
|
||||
|
@ -3737,7 +3742,7 @@ void Plater::send_gcode()
|
|||
unsigned int state = this->p->update_restart_background_process(false, false);
|
||||
if (state & priv::UPDATE_BACKGROUND_PROCESS_INVALID)
|
||||
return;
|
||||
default_output_file = this->p->background_process.current_print()->output_filepath(into_path(get_project_filename(".3mf")).string());
|
||||
default_output_file = this->p->background_process.output_filepath_for_project(into_path(get_project_filename(".3mf")));
|
||||
}
|
||||
catch (const std::exception &ex) {
|
||||
show_error(this, ex.what());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue