mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
GCodeViewer -> Show printbed model and texture for system printers detected when loading gcode files produced by PrusaSlicer
This commit is contained in:
parent
992d7065b2
commit
7a093b08fd
6 changed files with 51 additions and 2 deletions
|
@ -541,6 +541,10 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
|
||||||
if (bed_shape != nullptr)
|
if (bed_shape != nullptr)
|
||||||
m_result.bed_shape = bed_shape->values;
|
m_result.bed_shape = bed_shape->values;
|
||||||
|
|
||||||
|
const ConfigOptionString* printer_settings_id = config.option<ConfigOptionString>("printer_settings_id");
|
||||||
|
if (printer_settings_id != nullptr)
|
||||||
|
m_result.printer_settings_id = printer_settings_id->value;
|
||||||
|
|
||||||
const ConfigOptionFloats* filament_diameters = config.option<ConfigOptionFloats>("filament_diameter");
|
const ConfigOptionFloats* filament_diameters = config.option<ConfigOptionFloats>("filament_diameter");
|
||||||
if (filament_diameters != nullptr) {
|
if (filament_diameters != nullptr) {
|
||||||
for (double diam : filament_diameters->values) {
|
for (double diam : filament_diameters->values) {
|
||||||
|
|
|
@ -261,6 +261,7 @@ namespace Slic3r {
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
std::vector<MoveVertex> moves;
|
std::vector<MoveVertex> moves;
|
||||||
Pointfs bed_shape;
|
Pointfs bed_shape;
|
||||||
|
std::string printer_settings_id;
|
||||||
std::vector<std::string> extruder_colors;
|
std::vector<std::string> extruder_colors;
|
||||||
PrintEstimatedTimeStatistics time_statistics;
|
PrintEstimatedTimeStatistics time_statistics;
|
||||||
|
|
||||||
|
|
|
@ -1812,6 +1812,26 @@ namespace PresetUtils {
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
std::string system_printer_bed_model(const Preset& preset)
|
||||||
|
{
|
||||||
|
std::string out;
|
||||||
|
const VendorProfile::PrinterModel* pm = PresetUtils::system_printer_model(preset);
|
||||||
|
if (pm != nullptr && !pm->bed_model.empty())
|
||||||
|
out = Slic3r::resources_dir() + "/profiles/" + preset.vendor->id + "/" + pm->bed_model;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string system_printer_bed_texture(const Preset& preset)
|
||||||
|
{
|
||||||
|
std::string out;
|
||||||
|
const VendorProfile::PrinterModel* pm = PresetUtils::system_printer_model(preset);
|
||||||
|
if (pm != nullptr && !pm->bed_texture.empty())
|
||||||
|
out = Slic3r::resources_dir() + "/profiles/" + preset.vendor->id + "/" + pm->bed_texture;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
} // namespace PresetUtils
|
} // namespace PresetUtils
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
|
@ -527,6 +527,10 @@ public:
|
||||||
namespace PresetUtils {
|
namespace PresetUtils {
|
||||||
// PrinterModel of a system profile, from which this preset is derived, or null if it is not derived from a system profile.
|
// PrinterModel of a system profile, from which this preset is derived, or null if it is not derived from a system profile.
|
||||||
const VendorProfile::PrinterModel* system_printer_model(const Preset &preset);
|
const VendorProfile::PrinterModel* system_printer_model(const Preset &preset);
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
std::string system_printer_bed_model(const Preset& preset);
|
||||||
|
std::string system_printer_bed_texture(const Preset& preset);
|
||||||
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
} // namespace PresetUtils
|
} // namespace PresetUtils
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -414,6 +414,7 @@ void Bed3D::calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox)
|
||||||
printf("Unable to create bed grid lines\n");
|
printf("Unable to create bed grid lines\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_GCODE_VIEWER
|
||||||
static std::string system_print_bed_model(const Preset &preset)
|
static std::string system_print_bed_model(const Preset &preset)
|
||||||
{
|
{
|
||||||
std::string out;
|
std::string out;
|
||||||
|
@ -431,6 +432,7 @@ static std::string system_print_bed_texture(const Preset &preset)
|
||||||
out = Slic3r::resources_dir() + "/profiles/" + preset.vendor->id + "/" + pm->bed_texture;
|
out = Slic3r::resources_dir() + "/profiles/" + preset.vendor->id + "/" + pm->bed_texture;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
std::tuple<Bed3D::EType, std::string, std::string> Bed3D::detect_type(const Pointfs& shape) const
|
std::tuple<Bed3D::EType, std::string, std::string> Bed3D::detect_type(const Pointfs& shape) const
|
||||||
{
|
{
|
||||||
|
@ -440,8 +442,13 @@ std::tuple<Bed3D::EType, std::string, std::string> Bed3D::detect_type(const Poin
|
||||||
while (curr != nullptr) {
|
while (curr != nullptr) {
|
||||||
if (curr->config.has("bed_shape")) {
|
if (curr->config.has("bed_shape")) {
|
||||||
if (shape == dynamic_cast<const ConfigOptionPoints*>(curr->config.option("bed_shape"))->values) {
|
if (shape == dynamic_cast<const ConfigOptionPoints*>(curr->config.option("bed_shape"))->values) {
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
std::string model_filename = PresetUtils::system_printer_bed_model(*curr);
|
||||||
|
std::string texture_filename = PresetUtils::system_printer_bed_texture(*curr);
|
||||||
|
#else
|
||||||
std::string model_filename = system_print_bed_model(*curr);
|
std::string model_filename = system_print_bed_model(*curr);
|
||||||
std::string texture_filename = system_print_bed_texture(*curr);
|
std::string texture_filename = system_print_bed_texture(*curr);
|
||||||
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
if (!model_filename.empty() && !texture_filename.empty())
|
if (!model_filename.empty() && !texture_filename.empty())
|
||||||
return { System, model_filename, texture_filename };
|
return { System, model_filename, texture_filename };
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,9 +335,21 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print&
|
||||||
load_shells(print, initialized);
|
load_shells(print, initialized);
|
||||||
else {
|
else {
|
||||||
Pointfs bed_shape;
|
Pointfs bed_shape;
|
||||||
if (!gcode_result.bed_shape.empty())
|
std::string texture;
|
||||||
|
std::string model;
|
||||||
|
|
||||||
|
if (!gcode_result.bed_shape.empty()) {
|
||||||
// bed shape detected in the gcode
|
// bed shape detected in the gcode
|
||||||
bed_shape = gcode_result.bed_shape;
|
bed_shape = gcode_result.bed_shape;
|
||||||
|
auto bundle = wxGetApp().preset_bundle;
|
||||||
|
if (bundle != nullptr && !gcode_result.printer_settings_id.empty()) {
|
||||||
|
const Preset* preset = bundle->printers.find_preset(gcode_result.printer_settings_id);
|
||||||
|
if (preset != nullptr) {
|
||||||
|
model = PresetUtils::system_printer_bed_model(*preset);
|
||||||
|
texture = PresetUtils::system_printer_bed_texture(*preset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// adjust printbed size in dependence of toolpaths bbox
|
// adjust printbed size in dependence of toolpaths bbox
|
||||||
const double margin = 10.0;
|
const double margin = 10.0;
|
||||||
|
@ -359,7 +371,8 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print&
|
||||||
{ min(0) + 0.442265 * size[0], max(1)},
|
{ min(0) + 0.442265 * size[0], max(1)},
|
||||||
{ min(0), max(1) } };
|
{ min(0), max(1) } };
|
||||||
}
|
}
|
||||||
wxGetApp().plater()->set_bed_shape(bed_shape, "", "", true);
|
|
||||||
|
wxGetApp().plater()->set_bed_shape(bed_shape, texture, model, gcode_result.bed_shape.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue