From fe0094a5a35ff4f52ed9b8a7892707905f98004b Mon Sep 17 00:00:00 2001 From: Ian Bassi Date: Wed, 18 Nov 2026 23:38:53 -0300 Subject: [PATCH] Open the preview on the view each calibration tests After slicing a calibration, the preview shows the value it varies: Pressure Advance for the PA line, pattern and tower, Temperature for the temperature tower, Flow for the max flowrate and flow rate tests, Speed for VFA and Jerk for the cornering test. Retraction and input shaping have no matching view and keep the normal default. It goes through apply_default_view_type, so it takes precedence over the default view type preference and a view picked by hand survives a reslice. The flow rate test sets no calibration mode on the print, because that would change its G-code, so the Plater remembers it until other files are loaded. --- src/slic3r/GUI/GCodeViewer.cpp | 29 ++++++++++++++++++++++++++--- src/slic3r/GUI/GCodeViewer.hpp | 4 ++-- src/slic3r/GUI/Plater.cpp | 6 ++++++ src/slic3r/GUI/Plater.hpp | 2 ++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 0330bcb47e..15cb3230a8 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -3,6 +3,7 @@ #include "libslic3r/BuildVolume.hpp" #include "libslic3r/Print.hpp" +#include "libslic3r/calib.hpp" #include "libslic3r/Geometry.hpp" #include "libslic3r/TriangleMesh.hpp" #include "libslic3r/Model.hpp" @@ -206,6 +207,22 @@ static const std::vector>& view_typ return map; } +// ORCA: the view type showing the value a calibration varies, when the preview has one. +static std::optional calibration_view_type(CalibMode mode) +{ + switch (mode) { + case CalibMode::Calib_PA_Line: + case CalibMode::Calib_PA_Pattern: + case CalibMode::Calib_PA_Tower: return libvgcode::EViewType::PressureAdvance; + case CalibMode::Calib_Temp_Tower: return libvgcode::EViewType::Temperature; + case CalibMode::Calib_Flow_Rate: + case CalibMode::Calib_Vol_speed_Tower: return libvgcode::EViewType::VolumetricFlowRate; + case CalibMode::Calib_VFA_Tower: return libvgcode::EViewType::Speed; + case CalibMode::Calib_Cornering: return libvgcode::EViewType::Jerk; + default: return std::nullopt; + } +} + // Find an index of a value in a sorted vector, which is in . // Returns -1 if there is no such member. static int find_close_layer_idx(const std::vector &zs, double &z, double eps) @@ -1286,14 +1303,19 @@ void GCodeViewer::select_view_type(libvgcode::EViewType type) // ORCA: Pick the view type the preview opens with, following the "preview_default_view_type" preference: // a fixed view type, the one the user picked last ("last"), or the automatic choice ("auto", the default) // which shows Filament for multi material prints and Line Type for single material ones. +// A calibration's view, when given, takes precedence over the preference. // The default is only (re)applied when it actually changes, so a view type picked by hand survives a reslice. -void GCodeViewer::apply_default_view_type() +void GCodeViewer::apply_default_view_type(std::optional calibration_view) { const std::string preference = wxGetApp().app_config->get("preview_default_view_type"); std::string key = preference; libvgcode::EViewType type = libvgcode::EViewType::FeatureType; - if (preference == "last") { + if (calibration_view) { + type = *calibration_view; + key = "calibration_" + view_type_to_config_name(type); + } + else if (preference == "last") { if (!view_type_from_config_name(wxGetApp().app_config->get("preview_last_view_type"), type)) type = libvgcode::EViewType::FeatureType; } @@ -1765,7 +1787,8 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const // load_toolpaths(gcode_result, build_volume, exclude_bounding_box); // ORCA: Apply the default view type now that we know how many tools the G-code actually uses. - apply_default_view_type(); + const bool flowrate_calib = print.calib_mode() == CalibMode::Calib_None && wxGetApp().plater()->is_flowrate_calib(); + apply_default_view_type(calibration_view_type(flowrate_calib ? CalibMode::Calib_Flow_Rate : print.calib_mode())); // BBS: data for rendering color arrangement recommendation m_nozzle_nums = print.config().option("nozzle_diameter")->values.size(); diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 6755fae341..1ecdb72e97 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -533,8 +533,8 @@ public: } // ORCA: select a view type in the preview combo box and apply it void select_view_type(libvgcode::EViewType type); - // ORCA: apply the "preview_default_view_type" preference, see the definition for the supported values - void apply_default_view_type(); + // ORCA: apply the "preview_default_view_type" preference, or the view of the calibration being previewed + void apply_default_view_type(std::optional calibration_view = std::nullopt); // ORCA: stable, locale independent name of a view type, as stored in the application config static std::string view_type_to_config_name(libvgcode::EViewType type); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f41e867a3a..bc8334f7c4 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7298,6 +7298,8 @@ struct Plater::priv int m_cur_slice_plate; //BBS: m_slice_all in .gcode.3mf file case, set true when slice all bool m_slice_all_only_has_gcode{ false }; + // Orca: the flow rate test sets no calibration mode on the print, as that would change its G-code + bool m_flowrate_calib{ false }; bool m_need_update{false}; //BBS: add popup object table logic @@ -9287,6 +9289,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ q->m_3mf_path = input_files.front().string(); // Leave the previous calibration mode intact when preparation was cancelled. background_process.fff_print()->calib_mode() = CalibMode::Calib_None; + m_flowrate_calib = false; for (size_t i = 0; i < input_files.size(); ++i) { int project_filament_count = 1; @@ -17780,8 +17783,11 @@ void Plater::calib_flowrate(bool is_linear, int pass, InfillPattern pattern, int // Refresh object after scaling const std::vector object_idx(boost::counting_iterator(0), boost::counting_iterator(model().objects.size())); changed_objects(object_idx); + p->m_flowrate_calib = true; } +bool Plater::is_flowrate_calib() const { return p->m_flowrate_calib; } + // The belt provini tower (Calib_Params::test_model 1) is one embossed model per // temperature range. diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 0eb65ad872..c5d5ddcc05 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -414,6 +414,8 @@ public: void calib_pa(const Calib_Params& params); //ORCA: Add pattern parameter to calib_flowrate void calib_flowrate(bool is_linear, int pass, InfillPattern pattern = ipArchimedeanChords, int filament_id = 0, int extruder_id = 0); + // True from calib_flowrate() until other files are loaded, like the print's calibration mode + bool is_flowrate_calib() const; void calib_temp(const Calib_Params& params); void calib_max_vol_speed(const Calib_Params& params); void calib_retraction(const Calib_Params& params);