mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-11 02:57:39 +00:00
FIX:Fix the crash that occurred when importing G-code file
Jira:STUDIO-13408 (cherry picked from commit 3810f4edfe086b9500860e59baf35e5568b56977)
This commit is contained in:
@@ -2316,6 +2316,16 @@ static inline const char* remove_eols(const char *begin, const char *end) {
|
|||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DynamicConfig GCodeProcessor::export_config_for_render() const
|
||||||
|
{
|
||||||
|
DynamicConfig config;
|
||||||
|
config.set_key_value("filament_colour", new ConfigOptionStrings(m_parser.get_config().filament_colour.values));
|
||||||
|
config.set_key_value("filament_is_support", new ConfigOptionBools(m_parser.get_config().filament_is_support.values));
|
||||||
|
config.set_key_value("filament_type", new ConfigOptionStrings(m_parser.get_config().filament_type.values));
|
||||||
|
config.set_key_value("filament_map", new ConfigOptionInts(m_parser.get_config().filament_map.values));
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
// Load a G-code into a stand-alone G-code viewer.
|
// Load a G-code into a stand-alone G-code viewer.
|
||||||
// throws CanceledException through print->throw_if_canceled() (sent by the caller as callback).
|
// throws CanceledException through print->throw_if_canceled() (sent by the caller as callback).
|
||||||
void GCodeProcessor::process_file(const std::string& filename, std::function<void()> cancel_callback)
|
void GCodeProcessor::process_file(const std::string& filename, std::function<void()> cancel_callback)
|
||||||
|
|||||||
@@ -847,6 +847,9 @@ class Print;
|
|||||||
const std::vector<std::set<int>>& unprintable_filament_types );
|
const std::vector<std::set<int>>& unprintable_filament_types );
|
||||||
void apply_config(const PrintConfig& config);
|
void apply_config(const PrintConfig& config);
|
||||||
void set_print(Print* print) { m_print = print; }
|
void set_print(Print* print) { m_print = print; }
|
||||||
|
|
||||||
|
DynamicConfig export_config_for_render() const;
|
||||||
|
|
||||||
void enable_stealth_time_estimator(bool enabled);
|
void enable_stealth_time_estimator(bool enabled);
|
||||||
bool is_stealth_time_estimator_enabled() const {
|
bool is_stealth_time_estimator_enabled() const {
|
||||||
return m_time_processor.machines[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].enabled;
|
return m_time_processor.machines[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].enabled;
|
||||||
|
|||||||
@@ -162,6 +162,11 @@ public:
|
|||||||
float& j() { return m_position[J]; }
|
float& j() { return m_position[J]; }
|
||||||
float j() const { return m_position[J]; }
|
float j() const { return m_position[J]; }
|
||||||
|
|
||||||
|
GCodeConfig get_config() const
|
||||||
|
{
|
||||||
|
return m_config;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename ParseLineCallback, typename LineEndCallback>
|
template<typename ParseLineCallback, typename LineEndCallback>
|
||||||
bool parse_file_raw_internal(const std::string &filename, ParseLineCallback parse_line_callback, LineEndCallback line_end_callback);
|
bool parse_file_raw_internal(const std::string &filename, ParseLineCallback parse_line_callback, LineEndCallback line_end_callback);
|
||||||
|
|||||||
@@ -2798,6 +2798,10 @@ void Print::update_filament_maps_to_config(std::vector<int> f_maps)
|
|||||||
m_has_auto_filament_map_result = true;
|
m_has_auto_filament_map_result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Print::apply_config_for_render(const DynamicConfig &config)
|
||||||
|
{
|
||||||
|
m_config.apply(config);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<int> Print::get_filament_maps() const
|
std::vector<int> Print::get_filament_maps() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -986,6 +986,8 @@ public:
|
|||||||
const ToolOrdering& tool_ordering() const { return m_tool_ordering; }
|
const ToolOrdering& tool_ordering() const { return m_tool_ordering; }
|
||||||
|
|
||||||
void update_filament_maps_to_config(std::vector<int> f_maps);
|
void update_filament_maps_to_config(std::vector<int> f_maps);
|
||||||
|
void apply_config_for_render(const DynamicConfig &config);
|
||||||
|
|
||||||
// 1 based group ids
|
// 1 based group ids
|
||||||
std::vector<int> get_filament_maps() const;
|
std::vector<int> get_filament_maps() const;
|
||||||
FilamentMapMode get_filament_map_mode() const;
|
FilamentMapMode get_filament_map_mode() const;
|
||||||
|
|||||||
@@ -1236,6 +1236,7 @@ PRINT_CONFIG_CLASS_DEFINE(
|
|||||||
((ConfigOptionStrings, filament_type))
|
((ConfigOptionStrings, filament_type))
|
||||||
((ConfigOptionBools, filament_soluble))
|
((ConfigOptionBools, filament_soluble))
|
||||||
((ConfigOptionStrings, filament_ids))
|
((ConfigOptionStrings, filament_ids))
|
||||||
|
((ConfigOptionStrings, filament_colour))
|
||||||
((ConfigOptionStrings, filament_vendor))
|
((ConfigOptionStrings, filament_vendor))
|
||||||
((ConfigOptionBools, filament_is_support))
|
((ConfigOptionBools, filament_is_support))
|
||||||
((ConfigOptionInts, filament_printable))
|
((ConfigOptionInts, filament_printable))
|
||||||
@@ -1410,7 +1411,6 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
|
|||||||
((ConfigOptionBools, reduce_fan_stop_start_freq))
|
((ConfigOptionBools, reduce_fan_stop_start_freq))
|
||||||
((ConfigOptionBools, dont_slow_down_outer_wall))
|
((ConfigOptionBools, dont_slow_down_outer_wall))
|
||||||
((ConfigOptionFloats, fan_cooling_layer_time))
|
((ConfigOptionFloats, fan_cooling_layer_time))
|
||||||
((ConfigOptionStrings, filament_colour))
|
|
||||||
((ConfigOptionBools, activate_air_filtration))
|
((ConfigOptionBools, activate_air_filtration))
|
||||||
((ConfigOptionInts, during_print_exhaust_fan_speed))
|
((ConfigOptionInts, during_print_exhaust_fan_speed))
|
||||||
((ConfigOptionInts, complete_print_exhaust_fan_speed))
|
((ConfigOptionInts, complete_print_exhaust_fan_speed))
|
||||||
|
|||||||
@@ -12431,6 +12431,8 @@ void Plater::load_gcode(const wxString& filename)
|
|||||||
|
|
||||||
current_print.apply(this->model(), wxGetApp().preset_bundle->full_config());
|
current_print.apply(this->model(), wxGetApp().preset_bundle->full_config());
|
||||||
|
|
||||||
|
current_print.apply_config_for_render(processor.export_config_for_render());
|
||||||
|
|
||||||
//BBS: add cost info when drag in gcode
|
//BBS: add cost info when drag in gcode
|
||||||
auto& ps = current_result->print_statistics;
|
auto& ps = current_result->print_statistics;
|
||||||
double total_cost = 0.0;
|
double total_cost = 0.0;
|
||||||
|
|||||||
Reference in New Issue
Block a user