Merge branch 'feature/calib_pa' into SoftFever

This commit is contained in:
SoftFever 2022-12-25 14:25:32 +08:00
commit 473b1805ed
73 changed files with 1776 additions and 668 deletions

View file

@ -3,7 +3,6 @@
#include <string>
#include <sstream>
#include <iostream>
#include <mutex>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/log/trivial.hpp>

View file

@ -9,7 +9,7 @@
bool write_to_pot(boost::filesystem::path path, const std::vector<std::pair<std::string, std::string>>& data)
{
boost::nowide::ofstream file(path.string(), std::ios_base::app);
boost::filesystem::ofstream file(std::move(path), std::ios_base::app);
for (const auto& element : data)
{
//Example of .pot element

View file

@ -369,6 +369,8 @@ set(lisbslic3r_sources
Arachne/WallToolPaths.cpp
Shape/TextShape.hpp
Shape/TextShape.cpp
calib.hpp
calib.cpp
)
if (APPLE)

View file

@ -1,6 +1,6 @@
#ifndef slic3r_Format_3mf_hpp_
#define slic3r_Format_3mf_hpp_
#include <expat.h>
#include "../expat.h"
namespace Slic3r {
// PrusaFileParser is used to check 3mf file is from Prusa

View file

@ -23,7 +23,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/string_file.hpp>
#include <boost/nowide/fstream.hpp>
#include <boost/nowide/cstdio.hpp>
#include <boost/spirit/include/karma.hpp>

View file

@ -36,7 +36,7 @@
#include "SVG.hpp"
#include <tbb/parallel_for.h>
#include "calib.hpp"
// Intel redesigned some TBB interface considerably when merging TBB with their oneAPI set of libraries, see GH #7332.
// We are using quite an old TBB 2017 U7. Before we update our build servers, let's use the old API, which is deprecated in up to date TBB.
#if ! defined(TBB_VERSION_MAJOR)
@ -1633,73 +1633,165 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
this->m_objSupportsWithBrim.insert(iter->first);
}
if (this->m_objsWithBrim.empty() && this->m_objSupportsWithBrim.empty()) m_brim_done = true;
if (print.is_calib_mode() == Calib_PA_DDE || print.is_calib_mode() == Calib_PA_Bowden) {
std::string gcode;
auto s = m_config.inner_wall_speed.value;
gcode += m_writer.set_acceleration((unsigned int)floor(m_config.outer_wall_acceleration.value + 0.5));
//BBS: open spaghetti detector
if (is_bbl_printers) {
// if (print.config().spaghetti_detector.value)
file.write("M981 S1 P20000 ;open spaghetti detector\n");
if (m_config.default_jerk.value > 0) {
double jerk = m_config.outer_wall_jerk.value;
gcode += m_writer.set_jerk_xy((unsigned int)floor(jerk + 0.5));
}
m_config.outer_wall_speed = print.default_region_config().outer_wall_speed;
m_config.inner_wall_speed = print.default_region_config().inner_wall_speed;
calib_pressure_advance pa_test(this);
if(print.is_calib_mode() == Calib_PA_DDE)
gcode += pa_test.generate_test();
else
gcode +=pa_test.generate_test(0.0,0.02);
file.write(gcode);
}
else {
//BBS: open spaghetti detector
if (is_bbl_printers) {
// if (print.config().spaghetti_detector.value)
file.write("M981 S1 P20000 ;open spaghetti detector\n");
}
// Do all objects for each layer.
if (print.config().print_sequence == PrintSequence::ByObject) {
size_t finished_objects = 0;
const PrintObject *prev_object = (*print_object_instance_sequential_active)->print_object;
for (; print_object_instance_sequential_active != print_object_instances_ordering.end(); ++ print_object_instance_sequential_active) {
const PrintObject &object = *(*print_object_instance_sequential_active)->print_object;
if (&object != prev_object || tool_ordering.first_extruder() != final_extruder_id) {
tool_ordering = ToolOrdering(object, final_extruder_id);
unsigned int new_extruder_id = tool_ordering.first_extruder();
if (new_extruder_id == (unsigned int)-1)
// Skip this object.
continue;
initial_extruder_id = new_extruder_id;
final_extruder_id = tool_ordering.last_extruder();
assert(final_extruder_id != (unsigned int)-1);
}
print.throw_if_canceled();
this->set_origin(unscale((*print_object_instance_sequential_active)->shift));
// Do all objects for each layer.
if (print.config().print_sequence == PrintSequence::ByObject) {
size_t finished_objects = 0;
const PrintObject* prev_object = (*print_object_instance_sequential_active)->print_object;
for (; print_object_instance_sequential_active != print_object_instances_ordering.end(); ++print_object_instance_sequential_active) {
const PrintObject& object = *(*print_object_instance_sequential_active)->print_object;
if (&object != prev_object || tool_ordering.first_extruder() != final_extruder_id) {
tool_ordering = ToolOrdering(object, final_extruder_id);
unsigned int new_extruder_id = tool_ordering.first_extruder();
if (new_extruder_id == (unsigned int)-1)
// Skip this object.
continue;
initial_extruder_id = new_extruder_id;
final_extruder_id = tool_ordering.last_extruder();
assert(final_extruder_id != (unsigned int)-1);
}
print.throw_if_canceled();
this->set_origin(unscale((*print_object_instance_sequential_active)->shift));
// BBS: prime extruder if extruder change happens before this object instance
bool prime_extruder = false;
if (finished_objects > 0) {
// Move to the origin position for the copy we're going to print.
// This happens before Z goes down to layer 0 again, so that no collision happens hopefully.
m_enable_cooling_markers = false; // we're not filtering these moves through CoolingBuffer
m_avoid_crossing_perimeters.use_external_mp_once();
// BBS. change tool before moving to origin point.
if (m_writer.need_toolchange(initial_extruder_id)) {
const PrintObjectConfig& object_config = object.config();
coordf_t initial_layer_print_height = print.config().initial_layer_print_height.value;
file.write(this->set_extruder(initial_extruder_id, initial_layer_print_height));
prime_extruder = true;
// BBS: prime extruder if extruder change happens before this object instance
bool prime_extruder = false;
if (finished_objects > 0) {
// Move to the origin position for the copy we're going to print.
// This happens before Z goes down to layer 0 again, so that no collision happens hopefully.
m_enable_cooling_markers = false; // we're not filtering these moves through CoolingBuffer
m_avoid_crossing_perimeters.use_external_mp_once();
// BBS. change tool before moving to origin point.
if (m_writer.need_toolchange(initial_extruder_id)) {
const PrintObjectConfig& object_config = object.config();
coordf_t initial_layer_print_height = print.config().initial_layer_print_height.value;
file.write(this->set_extruder(initial_extruder_id, initial_layer_print_height));
prime_extruder = true;
}
else {
file.write(this->retract());
}
file.write(m_writer.travel_to_z(m_max_layer_z));
file.write(this->travel_to(Point(0, 0), erNone, "move to origin position for next object"));
m_enable_cooling_markers = true;
// Disable motion planner when traveling to first object point.
m_avoid_crossing_perimeters.disable_once();
// Ff we are printing the bottom layer of an object, and we have already finished
// another one, set first layer temperatures. This happens before the Z move
// is triggered, so machine has more time to reach such temperatures.
m_placeholder_parser.set("current_object_idx", int(finished_objects));
//BBS: remove printing_by_object_gcode
//std::string printing_by_object_gcode = this->placeholder_parser_process("printing_by_object_gcode", print.config().printing_by_object_gcode.value, initial_extruder_id);
std::string printing_by_object_gcode;
// Set first layer bed and extruder temperatures, don't wait for it to reach the temperature.
this->_print_first_layer_bed_temperature(file, print, printing_by_object_gcode, initial_extruder_id, false);
this->_print_first_layer_extruder_temperatures(file, print, printing_by_object_gcode, initial_extruder_id, false);
file.writeln(printing_by_object_gcode);
}
else {
file.write(this->retract());
// Reset the cooling buffer internal state (the current position, feed rate, accelerations).
m_cooling_buffer->reset(this->writer().get_position());
m_cooling_buffer->set_current_extruder(initial_extruder_id);
// Process all layers of a single object instance (sequential mode) with a parallel pipeline:
// Generate G-code, run the filters (vase mode, cooling buffer), run the G-code analyser
// and export G-code into file.
this->process_layers(print, tool_ordering, collect_layers_to_print(object), *print_object_instance_sequential_active - object.instances().data(), file, prime_extruder);
//BBS: close powerlost recovery
{
if (is_bbl_printers && m_second_layer_things_done) {
file.write("; close powerlost recovery\n");
file.write("M1003 S0\n");
}
}
file.write(m_writer.travel_to_z(m_max_layer_z));
file.write(this->travel_to(Point(0, 0), erNone, "move to origin position for next object"));
m_enable_cooling_markers = true;
// Disable motion planner when traveling to first object point.
m_avoid_crossing_perimeters.disable_once();
// Ff we are printing the bottom layer of an object, and we have already finished
// another one, set first layer temperatures. This happens before the Z move
// is triggered, so machine has more time to reach such temperatures.
m_placeholder_parser.set("current_object_idx", int(finished_objects));
//BBS: remove printing_by_object_gcode
//std::string printing_by_object_gcode = this->placeholder_parser_process("printing_by_object_gcode", print.config().printing_by_object_gcode.value, initial_extruder_id);
std::string printing_by_object_gcode;
// Set first layer bed and extruder temperatures, don't wait for it to reach the temperature.
this->_print_first_layer_bed_temperature(file, print, printing_by_object_gcode, initial_extruder_id, false);
this->_print_first_layer_extruder_temperatures(file, print, printing_by_object_gcode, initial_extruder_id, false);
file.writeln(printing_by_object_gcode);
#ifdef HAS_PRESSURE_EQUALIZER
if (m_pressure_equalizer)
file.write(m_pressure_equalizer->process("", true));
#endif /* HAS_PRESSURE_EQUALIZER */
++finished_objects;
// Flag indicating whether the nozzle temperature changes from 1st to 2nd layer were performed.
// Reset it when starting another object from 1st layer.
m_second_layer_things_done = false;
prev_object = &object;
}
// Reset the cooling buffer internal state (the current position, feed rate, accelerations).
m_cooling_buffer->reset(this->writer().get_position());
m_cooling_buffer->set_current_extruder(initial_extruder_id);
// Process all layers of a single object instance (sequential mode) with a parallel pipeline:
}
else {
// Sort layers by Z.
// All extrusion moves with the same top layer height are extruded uninterrupted.
std::vector<std::pair<coordf_t, std::vector<LayerToPrint>>> layers_to_print = collect_layers_to_print(print);
// Prusa Multi-Material wipe tower.
if (has_wipe_tower && !layers_to_print.empty()) {
m_wipe_tower.reset(new WipeTowerIntegration(print.config(), print.get_plate_index(), print.get_plate_origin(), *print.wipe_tower_data().priming.get(), print.wipe_tower_data().tool_changes, *print.wipe_tower_data().final_purge.get()));
//BBS
//file.write(m_writer.travel_to_z(initial_layer_print_height + m_config.z_offset.value, "Move to the first layer height"));
file.write(m_writer.travel_to_z(initial_layer_print_height, "Move to the first layer height"));
#if 0
if (print.config().single_extruder_multi_material_priming) {
file.write(m_wipe_tower->prime(*this));
// Verify, whether the print overaps the priming extrusions.
BoundingBoxf bbox_print(get_print_extrusions_extents(print));
coordf_t twolayers_printz = ((layers_to_print.size() == 1) ? layers_to_print.front() : layers_to_print[1]).first + EPSILON;
for (const PrintObject* print_object : print.objects())
bbox_print.merge(get_print_object_extrusions_extents(*print_object, twolayers_printz));
bbox_print.merge(get_wipe_tower_extrusions_extents(print, twolayers_printz));
BoundingBoxf bbox_prime(get_wipe_tower_priming_extrusions_extents(print));
bbox_prime.offset(0.5f);
bool overlap = bbox_prime.overlap(bbox_print);
if (print.config().gcode_flavor == gcfMarlinLegacy || print.config().gcode_flavor == gcfMarlinFirmware) {
file.write(this->retract());
file.write("M300 S800 P500\n"); // Beep for 500ms, tone 800Hz.
if (overlap) {
// Wait for the user to remove the priming extrusions.
file.write("M1 Remove priming towers and click button.\n");
}
else {
// Just wait for a bit to let the user check, that the priming succeeded.
//TODO Add a message explaining what the printer is waiting for. This needs a firmware fix.
file.write("M1 S10\n");
}
}
//BBS: only support Marlin
//else {
// This is not Marlin, M1 command is probably not supported.
//if (overlap) {
// print.active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL,
// _(L("Your print is very close to the priming regions. "
// "Make sure there is no collision.")));
//} else {
// // Just continue printing, no action necessary.
//}
//}
}
#endif
print.throw_if_canceled();
}
// Process all layers of all objects (non-sequential mode) with a parallel pipeline:
// Generate G-code, run the filters (vase mode, cooling buffer), run the G-code analyser
// and export G-code into file.
this->process_layers(print, tool_ordering, collect_layers_to_print(object), *print_object_instance_sequential_active - object.instances().data(), file, prime_extruder);
this->process_layers(print, tool_ordering, print_object_instances_ordering, layers_to_print, file);
//BBS: close powerlost recovery
{
if (is_bbl_printers && m_second_layer_things_done) {
@ -1711,82 +1803,11 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
if (m_pressure_equalizer)
file.write(m_pressure_equalizer->process("", true));
#endif /* HAS_PRESSURE_EQUALIZER */
++ finished_objects;
// Flag indicating whether the nozzle temperature changes from 1st to 2nd layer were performed.
// Reset it when starting another object from 1st layer.
m_second_layer_things_done = false;
prev_object = &object;
if (m_wipe_tower)
// Purge the extruder, pull out the active filament.
file.write(m_wipe_tower->finalize(*this));
}
} else {
// Sort layers by Z.
// All extrusion moves with the same top layer height are extruded uninterrupted.
std::vector<std::pair<coordf_t, std::vector<LayerToPrint>>> layers_to_print = collect_layers_to_print(print);
// Prusa Multi-Material wipe tower.
if (has_wipe_tower && ! layers_to_print.empty()) {
m_wipe_tower.reset(new WipeTowerIntegration(print.config(), print.get_plate_index(), print.get_plate_origin(), * print.wipe_tower_data().priming.get(), print.wipe_tower_data().tool_changes, *print.wipe_tower_data().final_purge.get()));
//BBS
//file.write(m_writer.travel_to_z(initial_layer_print_height + m_config.z_offset.value, "Move to the first layer height"));
file.write(m_writer.travel_to_z(initial_layer_print_height, "Move to the first layer height"));
#if 0
if (print.config().single_extruder_multi_material_priming) {
file.write(m_wipe_tower->prime(*this));
// Verify, whether the print overaps the priming extrusions.
BoundingBoxf bbox_print(get_print_extrusions_extents(print));
coordf_t twolayers_printz = ((layers_to_print.size() == 1) ? layers_to_print.front() : layers_to_print[1]).first + EPSILON;
for (const PrintObject *print_object : print.objects())
bbox_print.merge(get_print_object_extrusions_extents(*print_object, twolayers_printz));
bbox_print.merge(get_wipe_tower_extrusions_extents(print, twolayers_printz));
BoundingBoxf bbox_prime(get_wipe_tower_priming_extrusions_extents(print));
bbox_prime.offset(0.5f);
bool overlap = bbox_prime.overlap(bbox_print);
if (print.config().gcode_flavor == gcfMarlinLegacy || print.config().gcode_flavor == gcfMarlinFirmware) {
file.write(this->retract());
file.write("M300 S800 P500\n"); // Beep for 500ms, tone 800Hz.
if (overlap) {
// Wait for the user to remove the priming extrusions.
file.write("M1 Remove priming towers and click button.\n");
} else {
// Just wait for a bit to let the user check, that the priming succeeded.
//TODO Add a message explaining what the printer is waiting for. This needs a firmware fix.
file.write("M1 S10\n");
}
}
//BBS: only support Marlin
//else {
// This is not Marlin, M1 command is probably not supported.
//if (overlap) {
// print.active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL,
// _(L("Your print is very close to the priming regions. "
// "Make sure there is no collision.")));
//} else {
// // Just continue printing, no action necessary.
//}
//}
}
#endif
print.throw_if_canceled();
}
// Process all layers of all objects (non-sequential mode) with a parallel pipeline:
// Generate G-code, run the filters (vase mode, cooling buffer), run the G-code analyser
// and export G-code into file.
this->process_layers(print, tool_ordering, print_object_instances_ordering, layers_to_print, file);
//BBS: close powerlost recovery
{
if (is_bbl_printers && m_second_layer_things_done) {
file.write("; close powerlost recovery\n");
file.write("M1003 S0\n");
}
}
#ifdef HAS_PRESSURE_EQUALIZER
if (m_pressure_equalizer)
file.write(m_pressure_equalizer->process("", true));
#endif /* HAS_PRESSURE_EQUALIZER */
if (m_wipe_tower)
// Purge the extruder, pull out the active filament.
file.write(m_wipe_tower->finalize(*this));
}
//BBS: the last retraction
// Write end commands to file.
file.write(this->retract(false, true));

View file

@ -194,6 +194,12 @@ public:
void set_layer_count(unsigned int value) { m_layer_count = value; }
void apply_print_config(const PrintConfig &print_config);
std::string travel_to(const Point& point, ExtrusionRole role, std::string comment);
bool needs_retraction(const Polyline& travel, ExtrusionRole role = erNone);
std::string retract(bool toolchange = false, bool is_last_retraction = false);
std::string unretract() { return m_writer.unlift() + m_writer.unretract(); }
std::string set_extruder(unsigned int extruder_id, double print_z);
// append full config to the given string
static void append_full_config(const Print& print, std::string& str);
@ -398,15 +404,9 @@ private:
// For sequential print, the instance of the object to be printing has to be defined.
const size_t single_object_instance_idx);
std::string extrude_perimeters(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region);
std::string extrude_infill(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region, bool ironing);
std::string extrude_support(const ExtrusionEntityCollection &support_fills);
std::string travel_to(const Point &point, ExtrusionRole role, std::string comment);
bool needs_retraction(const Polyline &travel, ExtrusionRole role = erNone);
std::string retract(bool toolchange = false, bool is_last_retraction = false);
std::string unretract() { return m_writer.unlift() + m_writer.unretract(); }
std::string set_extruder(unsigned int extruder_id, double print_z);
std::string extrude_perimeters(const Print& print, const std::vector<ObjectByExtruder::Island::Region>& by_region);
std::string extrude_infill(const Print& print, const std::vector<ObjectByExtruder::Island::Region>& by_region, bool ironing);
std::string extrude_support(const ExtrusionEntityCollection& support_fills);
std::set<ObjectID> m_objsWithBrim; // indicates the objs with brim
std::set<ObjectID> m_objSupportsWithBrim; // indicates the objs' supports with brim
// Cache for custom seam enforcers/blockers for each layer.

View file

@ -10,7 +10,6 @@
#include <cstdint>
#include <array>
#include <vector>
#include <mutex>
#include <string>
#include <string_view>
#include <optional>

View file

@ -25,7 +25,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/string_file.hpp>
#include <boost/log/trivial.hpp>
#include <boost/nowide/iostream.hpp>

View file

@ -88,6 +88,12 @@ enum PrintObjectStep {
posInfill, posIroning, posSupportMaterial, posSimplifyPath, posSimplifySupportPath, posCount,
};
enum CalibMode {
Calib_None = 0,
Calib_PA_DDE,
Calib_PA_Bowden
};
// A PrintRegion object represents a group of volumes to print
// sharing the same config (including the same assigned extruder(s))
class PrintRegion
@ -735,7 +741,8 @@ public:
//SoftFever
bool &is_BBL_printer() { return m_isBBLPrinter; }
const bool is_BBL_printer() const { return m_isBBLPrinter; }
CalibMode& is_calib_mode() { return m_calib_mode; }
const CalibMode is_calib_mode() const { return m_calib_mode; }
protected:
// Invalidates the step, and its depending steps in Print.
bool invalidate_step(PrintStep step);
@ -787,6 +794,9 @@ private:
Vec3d m_origin;
//BBS: modified_count
int m_modified_count {0};
//SoftFever: calibration mode, change to enum later
CalibMode m_calib_mode;
// To allow GCode to set the Print's GCodeExport step status.
friend class GCode;

View file

@ -2889,7 +2889,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::raft_and_int
// Generate intermediate layers.
// The first intermediate layer is the same as the 1st layer if there is no raft,
// or the bottom of the first intermediate layer is aligned with the bottom of the raft contact layer.
// Intermediate layers are always printed with a normal extrusion flow (non-bridging).
// Intermediate layers are always printed with a normal etrusion flow (non-bridging).
size_t idx_layer_object = 0;
size_t idx_extreme_first = 0;
if (! extremes.empty() && std::abs(extremes.front()->extreme_z() - m_slicing_params.raft_interface_top_z) < EPSILON) {

View file

@ -29,7 +29,7 @@
#define TAU (2.0 * M_PI)
#define NO_INDEX (std::numeric_limits<unsigned int>::max())
// #define SUPPORT_TREE_DEBUG_TO_SVG
//#define SUPPORT_TREE_DEBUG_TO_SVG
namespace Slic3r
{
@ -1399,6 +1399,7 @@ void TreeSupport::generate_toolpaths()
const size_t wall_count = object_config.tree_support_wall_count.value;
const bool with_infill = object_config.support_base_pattern != smpNone && object_config.support_base_pattern != smpDefault;
auto m_support_material_flow = support_material_flow(m_object, float(m_slicing_params.layer_height));
// coconut: use same intensity settings as SupportMaterial.cpp
auto m_support_material_interface_flow = support_material_interface_flow(m_object, float(m_slicing_params.layer_height));
@ -1406,6 +1407,8 @@ void TreeSupport::generate_toolpaths()
coordf_t bottom_interface_spacing = object_config.support_bottom_interface_spacing.value + m_support_material_interface_flow.spacing();
coordf_t interface_density = std::min(1., m_support_material_interface_flow.spacing() / interface_spacing);
coordf_t bottom_interface_density = std::min(1., m_support_material_interface_flow.spacing() / bottom_interface_spacing);
coordf_t support_spacing = object_config.support_base_pattern_spacing.value + m_support_material_flow.spacing();
coordf_t support_density = std::min(1., m_support_material_flow.spacing() / support_spacing);
const coordf_t branch_radius = object_config.tree_support_branch_diameter.value / 2;
const coordf_t branch_radius_scaled = scale_(branch_radius);
@ -1515,9 +1518,6 @@ void TreeSupport::generate_toolpaths()
TreeSupportLayer* ts_layer = m_object->get_tree_support_layer(layer_id);
Flow support_flow(support_extrusion_width, ts_layer->height, nozzle_diameter);
coordf_t support_spacing = object_config.support_base_pattern_spacing.value + support_flow.spacing();
coordf_t support_density = std::min(1., support_flow.spacing() / support_spacing);
ts_layer->support_fills.no_sort = false;
for (auto& area_group : ts_layer->area_groups) {
@ -1569,11 +1569,12 @@ void TreeSupport::generate_toolpaths()
}
else {
// base_areas
filler_support->spacing = support_flow.spacing();
Flow flow = (layer_id == 0 && m_raft_layers == 0) ? m_object->print()->brim_flow() : support_flow;
if (area_group.dist_to_top < 10 / layer_height && !with_infill) {
// at least 2 walls for the top tips
make_perimeter_and_inner_brim(ts_layer->support_fills.entities, *m_object->print(), poly, std::max(wall_count, size_t(2)), flow, false);
filler_support->spacing = m_support_material_flow.spacing();
Flow flow = (layer_id == 0 && m_raft_layers == 0) ? m_object->print()->brim_flow() :
(m_support_params.base_fill_pattern == ipRectilinear && (layer_id % num_layers_to_change_infill_direction == 0) ? support_transition_flow(m_object) : support_flow);
if (area_group.dist_to_top < 10 / layer_height) {
// extra 2 walls for the top tips
make_perimeter_and_inner_brim(ts_layer->support_fills.entities, *m_object->print(), poly, wall_count + 2, flow, false);
} else {
if (with_infill && layer_id > 0 && m_support_params.base_fill_pattern != ipLightning) {
filler_support->angle = Geometry::deg2rad(object_config.support_angle.value);
@ -1892,7 +1893,7 @@ void TreeSupport::generate_support_areas()
profiler.stage_finish(STAGE_DROP_DOWN_NODES);
// Adjust support layer heights
// adjust_layer_heights(contact_nodes);
adjust_layer_heights(contact_nodes);
//Generate support areas.
profiler.stage_start(STAGE_DRAW_CIRCLES);
@ -2022,24 +2023,20 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
{
if (print->canceled())
break;
const std::vector<Node*>& curr_layer_nodes = contact_nodes[layer_nr];
TreeSupportLayer* ts_layer = m_object->get_tree_support_layer(layer_nr + m_raft_layers);
assert(ts_layer != nullptr);
// skip if current layer has no points. This fixes potential crash in get_collision (see jira BBL001-355)
if (curr_layer_nodes.empty()) {
ts_layer->print_z = 0.0;
ts_layer->height = 0.0;
if (curr_layer_nodes.empty())
continue;
}
Node* first_node = curr_layer_nodes.front();
ts_layer->print_z = first_node->print_z;
ts_layer->height = first_node->height;
if (ts_layer->height < EPSILON) {
if (ts_layer->height < EPSILON)
continue;
}
ExPolygons& base_areas = ts_layer->base_areas;
ExPolygons& roof_areas = ts_layer->roof_areas;
@ -2060,16 +2057,16 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
const Node& node = *p_node;
ExPolygon area;
// Generate directly from overhang polygon if one of the following is true:
// 1) node is a normal part of hybrid support
// 2) top interface layers are enabled
// 3) node is virtual
// 直接从overhang多边形生成如果<EFBFBD>?
// 1) 是混合支撑里的普通部分,
// 2) 启用了顶部接触层<EFBFBD>?
// 3) 是顶部空<EFBFBD>?
if (node.type == ePolygon || (top_interface_layers>0 &&node.support_roof_layers_below > 0) || node.distance_to_top<0) {
if (node.overhang->contour.size() > 100 || node.overhang->holes.size()>1)
area = *node.overhang;
else {
auto tmp = offset_ex({ *node.overhang }, scale_(m_ts_data->m_xy_distance));
if(!tmp.empty()) // can be empty for non-manifold models
if(!tmp.empty()) // 对于有缺陷的模型overhang膨胀以后可能是空的
area = tmp[0];
}
}
@ -2399,22 +2396,7 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
char fname[10]; sprintf(fname, "%d_%.2f", layer_nr, ts_layer->print_z);
draw_contours_and_nodes_to_svg(-1, base_areas, roof_areas, roof_1st_layer, {}, {}, get_svg_filename(fname, "circles"), { "base", "roof", "roof1st" });
}
// export layer & print_z log
std::ofstream draw_circles_layer_out;
draw_circles_layer_out.open("./SVG/layer_heights_draw_circles.txt");
if (draw_circles_layer_out.is_open()) {
for (int layer_nr = m_object->layer_count() - 1; layer_nr > 0; layer_nr--) {
TreeSupportLayer* ts_layer = m_object->get_tree_support_layer(layer_nr + m_raft_layers);
ExPolygons& base_areas = ts_layer->base_areas;
ExPolygons& roof_areas = ts_layer->roof_areas;
ExPolygons& roof_1st_layer = ts_layer->roof_1st_layer;
ExPolygons& floor_areas = ts_layer->floor_areas;
if (base_areas.empty() && roof_areas.empty() && roof_1st_layer.empty()) continue;
draw_circles_layer_out << layer_nr << " " << ts_layer->print_z << " " << ts_layer->height << std::endl;
}
}
#endif // SUPPORT_TREE_DEBUG_TO_SVG
#endif
TreeSupportLayerPtrs& ts_layers = m_object->tree_support_layers();
auto iter = std::remove_if(ts_layers.begin(), ts_layers.end(), [](TreeSupportLayer* ts_layer) { return ts_layer->height < EPSILON; });
@ -2428,7 +2410,7 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
{
const PrintObjectConfig &config = m_object->config();
// Use Minimum Spanning Tree to connect the points on each layer and move them while dropping them down.
//Use Minimum Spanning Tree to connect the points on each layer and move them while dropping them down.
const coordf_t layer_height = config.layer_height.value;
const double angle = config.tree_support_branch_angle.value * M_PI / 180.;
const int wall_count = std::max(1, config.tree_support_wall_count.value);
@ -2442,7 +2424,6 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
const bool support_on_buildplate_only = config.support_on_build_plate_only.value;
const size_t bottom_interface_layers = config.support_interface_bottom_layers.value;
const size_t top_interface_layers = config.support_interface_top_layers.value;
std::vector<std::pair<coordf_t, coordf_t>> layer_heights = plan_layer_heights(contact_nodes);
std::unordered_set<Node*> to_free_node_set;
m_spanning_trees.resize(contact_nodes.size());
@ -2486,22 +2467,16 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
BOOST_LOG_TRIVIAL(debug) << "before m_avoidance_cache.size()=" << m_ts_data->m_avoidance_cache.size();
}
for (size_t layer_nr = contact_nodes.size() - 1; layer_nr > 0; layer_nr--) // Skip layer 0, since we can't drop down the vertices there.
for (size_t layer_nr = contact_nodes.size() - 1; layer_nr > 0; layer_nr--) //Skip layer 0, since we can't drop down the vertices there.
{
if (m_object->print()->canceled())
break;
auto& layer_contact_nodes = contact_nodes[layer_nr];
if (layer_contact_nodes.empty())
continue;
int jump_nr = 1;
while (layer_heights[layer_nr - jump_nr].second < EPSILON)
jump_nr++;
std::deque<std::pair<size_t, Node*>> unsupported_branch_leaves; // All nodes that are leaves on this layer that would result in unsupported ('mid-air') branches.
const Layer* ts_layer = m_object->get_tree_support_layer(layer_nr);
if (layer_contact_nodes.empty())
continue;
m_object->print()->set_status(60, (boost::format(_L("Support: propagate branches at layer %d")) % layer_nr).str());
Polygons layer_contours = std::move(m_ts_data->get_contours_with_holes(layer_nr));
@ -2537,8 +2512,8 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
if (node.distance_to_top < 0) {
// virtual node do not merge or move
Node* next_node = new Node(p_node->position, p_node->distance_to_top + 1, p_node->skin_direction, p_node->support_roof_layers_below - 1, p_node->to_buildplate, p_node,
layer_heights[layer_nr - jump_nr].first, layer_heights[layer_nr - jump_nr].second);
contact_nodes[layer_nr - jump_nr].emplace_back(next_node);
m_object->get_layer(layer_nr - 1)->print_z, m_object->get_layer(layer_nr - 1)->height);
contact_nodes[layer_nr - 1].emplace_back(next_node);
continue;
}
if (support_on_buildplate_only && !node.to_buildplate) //Can't rest on model and unable to reach the build plate. Then we must drop the node and leave parts unsupported.
@ -2555,8 +2530,8 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
// polygon node do not merge or move
const bool to_buildplate = !is_inside_ex(m_ts_data->m_layer_outlines[layer_nr], p_node->position);
Node *next_node = new Node(p_node->position, p_node->distance_to_top + 1, p_node->skin_direction, p_node->support_roof_layers_below - 1, to_buildplate, p_node,
layer_heights[layer_nr - jump_nr].first, layer_heights[layer_nr - jump_nr].second);
contact_nodes[layer_nr - jump_nr].emplace_back(next_node);
m_object->get_layer(layer_nr - 1)->print_z, m_object->get_layer(layer_nr - 1)->height);
contact_nodes[layer_nr - 1].emplace_back(next_node);
continue;
}
/* Find which part this node is located in and group the nodes in
@ -2633,7 +2608,7 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
const coordf_t branch_radius_node = calc_branch_radius(branch_radius, node.distance_to_top, tip_layers, diameter_angle_scale_factor);
auto avoid_layer = m_ts_data->get_avoidance(branch_radius_node, layer_nr - jump_nr);
auto avoid_layer = m_ts_data->get_avoidance(branch_radius_node, layer_nr - 1);
if (group_index == 0)
{
//Avoid collisions.
@ -2645,11 +2620,11 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
size_t new_distance_to_top = std::max(node.distance_to_top, neighbour->distance_to_top) + 1;
size_t new_support_roof_layers_below = std::max(node.support_roof_layers_below, neighbour->support_roof_layers_below) - 1;
const bool to_buildplate = !is_inside_ex(m_ts_data->get_avoidance(0, layer_nr - jump_nr), next_position);
const bool to_buildplate = !is_inside_ex(m_ts_data->get_avoidance(0, layer_nr - 1), next_position);
Node * next_node = new Node(next_position, new_distance_to_top, node.skin_direction, new_support_roof_layers_below, to_buildplate, p_node,
layer_heights[layer_nr - jump_nr].first, layer_heights[layer_nr - jump_nr].second);
m_object->get_layer(layer_nr - 1)->print_z, p_node->height);
next_node->movement = next_position - node.position;
contact_nodes[layer_nr - jump_nr].push_back(next_node);
contact_nodes[layer_nr - 1].push_back(next_node);
// Make sure the next pass doesn't drop down either of these (since that already happened).
node.merged_neighbours.push_front(neighbour);
@ -2733,8 +2708,8 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
Point direction = neighbour - node.position;
Node *neighbour_node = nodes_per_part[group_index][neighbour];
coordf_t branch_bottom_radius = calc_branch_radius(branch_radius, node.distance_to_top + 1, tip_layers, diameter_angle_scale_factor);
coordf_t neighbour_bottom_radius = calc_branch_radius(branch_radius, neighbour_node->distance_to_top + 1, tip_layers, diameter_angle_scale_factor);
coordf_t branch_bottom_radius = calc_branch_radius(branch_radius, node.distance_to_top + layer_nr, tip_layers, diameter_angle_scale_factor);
coordf_t neighbour_bottom_radius = calc_branch_radius(branch_radius, neighbour_node->distance_to_top + layer_nr, tip_layers, diameter_angle_scale_factor);
const coordf_t min_overlap = branch_radius;
double max_converge_distance = tan_angle * (ts_layer->print_z - DO_NOT_MOVER_UNDER_MM) + branch_bottom_radius + neighbour_bottom_radius - min_overlap;
if (vsize2_with_unscale(direction) > max_converge_distance * max_converge_distance)
@ -2765,7 +2740,7 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
branch_radius_temp = branch_radius_node;
}
#endif
auto avoid_layer = m_ts_data->get_avoidance(branch_radius_node, layer_nr - jump_nr);
auto avoid_layer = m_ts_data->get_avoidance(branch_radius_node, layer_nr - 1);
Point to_outside = projection_onto_ex(avoid_layer, node.position);
Point movement = to_outside - node.position;
@ -2810,15 +2785,15 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
const bool to_buildplate = !is_inside_ex(m_ts_data->m_layer_outlines[layer_nr], next_layer_vertex);// !is_inside_ex(m_ts_data->get_avoidance(m_ts_data->m_xy_distance, layer_nr - 1), next_layer_vertex);
Node * next_node = new Node(next_layer_vertex, node.distance_to_top + 1, node.skin_direction, node.support_roof_layers_below - 1, to_buildplate, p_node,
layer_heights[layer_nr - jump_nr].first, layer_heights[layer_nr - jump_nr].second);
m_object->get_layer(layer_nr - 1)->print_z, m_object->get_layer(layer_nr-1)->height);
next_node->movement = movement;
contact_nodes[layer_nr - jump_nr].push_back(next_node);
contact_nodes[layer_nr - 1].push_back(next_node);
}
}
#ifdef SUPPORT_TREE_DEBUG_TO_SVG
draw_contours_and_nodes_to_svg(layer_nr, m_ts_data->get_avoidance(0, layer_nr), m_ts_data->get_avoidance(branch_radius_temp, layer_nr), m_ts_data->m_layer_outlines_below[layer_nr],
contact_nodes[layer_nr], contact_nodes[layer_nr - jump_nr], "contact_points", { "overhang","avoid","outline" }, { "blue","red","yellow" });
contact_nodes[layer_nr], contact_nodes[layer_nr - 1], "contact_points", { "overhang","avoid","outline" }, { "blue","red","yellow" });
#endif
// Prune all branches that couldn't find support on either the model or the buildplate (resulting in 'mid-air' branches).
@ -2865,27 +2840,6 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
delete node;
}
to_free_node_set.clear();
// Merge empty contact_nodes layers
#ifdef SUPPORT_TREE_DEBUG_TO_SVG
// export all print_z and layer height into .txt
std::ofstream layer_heights_out;
layer_heights_out.open("./SVG/layer_heights_drop_nodes.txt");
//layer_heights_out.open("layer_heights_out.txt");
if (layer_heights_out.is_open()) {
for (int i = 0; i < layer_heights.size(); i++) {
if (contact_nodes[i].empty()) {
layer_heights_out << 0 << " " << 0 << std::endl;
}
else {
layer_heights_out << contact_nodes[i][0]->print_z << " " << contact_nodes[i][0]->height << std::endl;
}
}
layer_heights_out.close();
}
#endif
}
void TreeSupport::adjust_layer_heights(std::vector<std::vector<Node*>>& contact_nodes)
@ -2895,7 +2849,6 @@ void TreeSupport::adjust_layer_heights(std::vector<std::vector<Node*>>& contact_
const PrintConfig& print_config = m_object->print()->config();
const PrintObjectConfig& config = m_object->config();
if (!print_config.independent_support_layer_height) {
for (int layer_nr = 0; layer_nr < contact_nodes.size(); layer_nr++) {
std::vector<Node*>& curr_layer_nodes = contact_nodes[layer_nr];
@ -2979,108 +2932,6 @@ void TreeSupport::adjust_layer_heights(std::vector<std::vector<Node*>>& contact_
}
}
std::vector<std::pair<coordf_t, coordf_t>> TreeSupport::plan_layer_heights(std::vector<std::vector<Node*>>& contact_nodes)
{
const PrintObjectConfig& config = m_object->config();
const coordf_t max_layer_height = m_slicing_params.max_layer_height;
const coordf_t layer_height = config.layer_height.value;
coordf_t z_distance_top = m_slicing_params.gap_support_object;
// BBS: add extra distance if thick bridge is enabled
// Note: normal support uses print_z, but tree support uses integer layers, so we need to subtract layer_height
if (!m_slicing_params.soluble_interface && m_object_config->thick_bridges) {
z_distance_top += m_object->layers()[0]->regions()[0]->region().bridging_height_avg(m_object->print()->config()) - layer_height;
}
const size_t support_roof_layers = config.support_interface_top_layers.value;
const int z_distance_top_layers = round_up_divide(scale_(z_distance_top), scale_(layer_height)) + 1;
std::vector<std::pair<coordf_t, coordf_t>> layer_heights(contact_nodes.size(), std::pair<coordf_t, coordf_t>(0.0, 0.0));
std::vector<int> bounds;
if (layer_height == max_layer_height)
return std::vector<std::pair<coordf_t, coordf_t>>();
bounds.push_back(0);
// Keep first layer still
layer_heights[0].first = m_object->get_layer(0)->print_z;
layer_heights[0].second = m_object->get_layer(0)->height;
// Collect top contact layers
for (int layer_nr = 1; layer_nr < contact_nodes.size(); layer_nr++)
{
if (!contact_nodes[layer_nr].empty())
for (int i = 0; i < support_roof_layers + z_distance_top_layers + 1; i++) {
if (layer_nr - i > 0) {
bounds.push_back(layer_nr - i);
layer_heights[layer_nr - i].first = m_object->get_layer(layer_nr - i)->print_z;
layer_heights[layer_nr - i].second = m_object->get_layer(layer_nr - i)->height;
}
else {
break;
}
}
}
std::set<int> s(bounds.begin(), bounds.end());
bounds.assign(s.begin(), s.end());
for (size_t idx_extreme = 0; idx_extreme < bounds.size(); idx_extreme++) {
int extr2_layer_nr = bounds[idx_extreme];
coordf_t extr2z = m_object->get_layer(extr2_layer_nr)->bottom_z();
int extr1_layer_nr = idx_extreme == 0 ? -1 : bounds[idx_extreme - 1];
coordf_t extr1z = idx_extreme == 0 ? 0.f : m_object->get_layer(extr1_layer_nr)->print_z;
coordf_t dist = extr2z - extr1z;
// Insert intermediate layers.
size_t n_layers_extra = size_t(ceil(dist / (m_slicing_params.max_suport_layer_height + EPSILON)));
int actual_internel_layers = extr2_layer_nr - extr1_layer_nr - 1;
int extr_layers_left = extr2_layer_nr - extr1_layer_nr - n_layers_extra - 1;
if (n_layers_extra < 1)
continue;
coordf_t step = dist / coordf_t(n_layers_extra);
coordf_t print_z = extr1z + step;
assert(step >= layer_height - EPSILON);
for (int layer_nr = extr1_layer_nr + 1; layer_nr < extr2_layer_nr; layer_nr++) {
// if (curr_layer_nodes.empty()) continue;
if (std::abs(print_z - m_object->get_layer(layer_nr)->print_z) < step / 2 + EPSILON || extr_layers_left < 1) {
layer_heights[layer_nr].first = print_z;
layer_heights[layer_nr].second = step;
print_z += step;
}
else {
// can't clear curr_layer_nodes, or the model will have empty layers
layer_heights[layer_nr].first = 0.0;
layer_heights[layer_nr].second = 0.0;
extr_layers_left--;
}
}
}
#ifdef SUPPORT_TREE_DEBUG_TO_SVG
// export all print_z and layer height into .txt
std::ofstream layer_heights_out;
layer_heights_out.open("./SVG/layer_heights_out.txt");
//layer_heights_out.open("layer_heights_out.txt");
if (layer_heights_out.is_open()) {
for (int i = 0; i < layer_heights.size(); i++) {
layer_heights_out << layer_heights[i].first << " " << layer_heights[i].second << std::endl;
}
layer_heights_out.close();
}
// check bounds
if (1)
{
std::ofstream bounds_out;
bounds_out.open("bounds.txt");
if (bounds_out.is_open()) {
for (int i = 0; i < bounds.size(); i++) {
bounds_out << bounds[i] << std::endl;
}
}
}
#endif
return layer_heights;
}
void TreeSupport::generate_contact_points(std::vector<std::vector<TreeSupport::Node*>>& contact_nodes)
{
const PrintObjectConfig &config = m_object->config();
@ -3267,16 +3118,6 @@ void TreeSupport::generate_contact_points(std::vector<std::vector<TreeSupport::N
BOOST_LOG_TRIVIAL(info) << "avg_node_per_layer=" << avg_node_per_layer << ", nodes_angle=" << nodes_angle;
}
#ifdef SUPPORT_TREE_DEBUG_TO_SVG
std::ofstream contact_nodes_out;
contact_nodes_out.open("./SVG/contact_nodes.txt");
if (contact_nodes_out.is_open()) {
for (int i = 0; i < contact_nodes.size(); i++) {
if (!contact_nodes[i].empty())
contact_nodes_out << i << std::endl;
}
}
#endif // SUPPORT_TREE_DEBUG_TO_SVG
}
void TreeSupport::insert_dropped_node(std::vector<Node*>& nodes_layer, Node* p_node)

View file

@ -170,7 +170,7 @@ public:
struct LineHash {
size_t operator()(const Line& line) const {
return (std::hash<coord_t>()(line.a(0)) ^ std::hash<coord_t>()(line.b(1))) * 102 +
(std::hash<coord_t>()(line.a(1)) ^ std::hash<coord_t>()(line.b(0))) * 10222;
(std::hash<coord_t>()(line.a(0)) ^ std::hash<coord_t>()(line.b(1))) * 10222;
}
};
@ -401,12 +401,6 @@ private:
void adjust_layer_heights(std::vector<std::vector<Node*>>& contact_nodes);
/*! BBS: MusangKing: maximum layer height
* \brief Optimize the generation of tree support by pre-planning the layer_heights
*
*/
std::vector<std::pair<coordf_t, coordf_t>> plan_layer_heights(std::vector<std::vector<Node*>>& contact_nodes);
/*!
* \brief Creates points where support contacts the model.
*

202
src/libslic3r/calib.cpp Normal file
View file

@ -0,0 +1,202 @@
#include "calib.hpp"
#include "Point.hpp"
#include "PrintConfig.hpp"
#include "GCodeWriter.hpp"
#include "GCode.hpp"
#include <map>
namespace Slic3r {
calib_pressure_advance::calib_pressure_advance(GCode* gcodegen) :mp_gcodegen(gcodegen), m_length_short(20.0), m_length_long(40.0), m_space_y(3.5) {}
std::string calib_pressure_advance::generate_test(double start_pa/*= 0*/, double step_pa /*= 0.005*/, int count/*= 10*/) {
auto bed_sizes = mp_gcodegen->config().printable_area.values;
auto w = bed_sizes[2].x() - bed_sizes[0].x();
auto h = bed_sizes[2].y() - bed_sizes[0].y();
count = std::min(count, int((h - 10) / m_space_y));
auto startx = (w - 100) / 2;
auto starty = (h - count * m_space_y) / 2;
m_length_long = 40 + std::min(w - 120.0, 30.0);
return print_pa_lines(startx, starty, start_pa, step_pa, count);
}
std::string calib_pressure_advance::move_to(Vec2d pt) {
std::stringstream gcode;
gcode << mp_gcodegen->retract();
gcode << mp_gcodegen->writer().travel_to_xyz(Vec3d(pt.x(), pt.y(), 0.2));
gcode << mp_gcodegen->unretract();
return gcode.str();
}
std::string calib_pressure_advance::print_pa_lines(double start_x, double start_y, double start_pa, double step_pa, int num) {
auto& writer = mp_gcodegen->writer();
const double e_calib = 0.05; // filament_mm/extrusion_mm
const double e = 0.038; // filament_mm/extrusion_mm
const double fast = mp_gcodegen->config().get_abs_value("outer_wall_speed") * 60.0;
const double slow = std::max(1200.0, fast * 0.1);
std::stringstream gcode;
gcode << mp_gcodegen->writer().travel_to_z(0.2);
double y_pos = start_y;
// prime line
auto prime_x = std::max(start_x - 5, 0.5);
gcode << move_to(Vec2d(prime_x, y_pos + (num - 4) * m_space_y));
gcode << writer.set_speed(slow);
gcode << writer.extrude_to_xy(Vec2d(prime_x, y_pos + 3 * m_space_y), e_calib * m_space_y * num * 1.1);
for (int i = 0; i < num; ++i) {
gcode << writer.set_pressure_advance(start_pa + i * step_pa);
gcode << move_to(Vec2d(start_x, y_pos + i * m_space_y));
gcode << writer.set_speed(slow);
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short, y_pos + i * m_space_y), e_calib * m_length_short);
gcode << writer.set_speed(fast);
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short + m_length_long, y_pos + i * m_space_y), e_calib * m_length_long);
gcode << writer.set_speed(slow);
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short + m_length_long + m_length_short, y_pos + i * m_space_y), e_calib * m_length_short);
}
gcode << writer.set_pressure_advance(0.0);
// draw indicator lines
gcode << writer.set_speed(fast);
gcode << move_to(Vec2d(start_x + m_length_short, y_pos + (num - 1) * m_space_y + 2));
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short, y_pos + (num - 1) * m_space_y + 7), e * 7);
gcode << move_to(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 7));
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 2), e * 7);
for (int i = 0; i < num; i += 2) {
gcode << draw_number(start_x + m_length_short + m_length_long + m_length_short + 3, y_pos + i * m_space_y + m_space_y / 2, start_pa + i * step_pa);
}
return gcode.str();
}
std::string calib_pressure_advance::draw_digit(double startx, double starty, char c) {
auto& writer = mp_gcodegen->writer();
std::stringstream gcode;
const double lw = 0.48;
const double len = 2;
const double gap = lw / 2.0;
const double e = 0.04; // filament_mm/extrusion_mm
// 0-------1
// | |
// 3-------2
// | |
// 4-------5
const Vec2d p0(startx, starty);
const Vec2d p1(startx + len, starty);
const Vec2d p2(startx + len, starty - len);
const Vec2d p3(startx, starty - len);
const Vec2d p4(startx, starty - len * 2);
const Vec2d p5(startx + len, starty - len * 2);
switch (c)
{
case '0':
gcode << move_to(p0);
gcode << writer.extrude_to_xy(p1, e * len);
gcode << writer.extrude_to_xy(p5, e * len * 2);
gcode << writer.extrude_to_xy(p4, e * len);
gcode << writer.extrude_to_xy(p0 - Vec2d(0, gap), e * len * 2);
break;
case '1':
gcode << move_to(p0 + Vec2d(len / 2, 0));
gcode << writer.extrude_to_xy(p4 + Vec2d(len / 2, 0), e * len * 2);
break;
case '2':
gcode << move_to(p0);
gcode << writer.extrude_to_xy(p1, e * len);
gcode << writer.extrude_to_xy(p2, e * len);
gcode << writer.extrude_to_xy(p3, e * len);
gcode << writer.extrude_to_xy(p4, e * len);
gcode << writer.extrude_to_xy(p5, e * len);
break;
case '3':
gcode << move_to(p0);
gcode << writer.extrude_to_xy(p1, e * len);
gcode << writer.extrude_to_xy(p5, e * len * 2);
gcode << writer.extrude_to_xy(p4, e * len);
gcode << move_to(p2 - Vec2d(gap, 0));
gcode << writer.extrude_to_xy(p3, e * len);
break;
case '4':
gcode << move_to(p0);
gcode << writer.extrude_to_xy(p3, e * len);
gcode << writer.extrude_to_xy(p2, e * len);
gcode << move_to(p1);
gcode << writer.extrude_to_xy(p5, e * len * 2);
break;
case '5':
gcode << move_to(p1);
gcode << writer.extrude_to_xy(p0, e * len);
gcode << writer.extrude_to_xy(p3, e * len);
gcode << writer.extrude_to_xy(p2, e * len);
gcode << writer.extrude_to_xy(p5, e * len);
gcode << writer.extrude_to_xy(p4, e * len);
break;
case '6':
gcode << move_to(p1);
gcode << writer.extrude_to_xy(p0, e * len);
gcode << writer.extrude_to_xy(p4, e * len * 2);
gcode << writer.extrude_to_xy(p5, e * len);
gcode << writer.extrude_to_xy(p2, e * len);
gcode << writer.extrude_to_xy(p3, e * len);
break;
case '7':
gcode << move_to(p0);
gcode << writer.extrude_to_xy(p1, e * len);
gcode << writer.extrude_to_xy(p5, e * len * 2);
break;
case '8':
gcode << move_to(p2);
gcode << writer.extrude_to_xy(p3, e * len);
gcode << writer.extrude_to_xy(p4, e * len);
gcode << writer.extrude_to_xy(p5, e * len);
gcode << writer.extrude_to_xy(p1, e * len * 2);
gcode << writer.extrude_to_xy(p0, e * len);
gcode << writer.extrude_to_xy(p3, e * len);
break;
case '9':
gcode << move_to(p5);
gcode << writer.extrude_to_xy(p1, e * len * 2);
gcode << writer.extrude_to_xy(p0, e * len);
gcode << writer.extrude_to_xy(p3, e * len);
gcode << writer.extrude_to_xy(p2, e * len);
break;
case '.':
gcode << move_to(p4 + Vec2d(len / 2, 0));
gcode << writer.extrude_to_xy(p4 + Vec2d(len / 2, len / 2), e * len);
break;
default:
break;
}
return gcode.str();
}
// draw number
std::string calib_pressure_advance::draw_number(double startx, double starty, double value) {
double spacing = 3.0;
auto sNumber = std::to_string(value);
sNumber.erase(sNumber.find_last_not_of('0') + 1, std::string::npos);
sNumber.erase(sNumber.find_last_not_of('.') + 1, std::string::npos);
std::stringstream gcode;
gcode << mp_gcodegen->writer().set_speed(3600);
for (int i = 0; i < sNumber.length(); ++i) {
if (i > 5)
break;
gcode << draw_digit(startx + i * spacing, starty, sNumber[i]);
}
return gcode.str();
}
} // namespace Slic3r

26
src/libslic3r/calib.hpp Normal file
View file

@ -0,0 +1,26 @@
#pragma once
#include <string>
#include "Point.hpp"
namespace Slic3r {
class GCode;
class calib_pressure_advance
{
public:
calib_pressure_advance(GCode* gcodegen);
~calib_pressure_advance() {}
std::string generate_test(double start_pa = 0, double step_pa = 0.002, int count = 50);
private:
std::string move_to(Vec2d pt);
std::string print_pa_lines(double start_x, double start_y, double start_pa, double step_pa, int num);
std::string draw_digit(double startx, double starty, char c);
std::string draw_number(double startx, double starty, double value);
private:
GCode* mp_gcodegen;
double m_length_short, m_length_long;
double m_space_y;
};
} // namespace Slic3r

View file

@ -1405,7 +1405,7 @@ bool bbl_calc_md5(std::string &filename, std::string &md5_out)
unsigned char digest[16];
MD5_CTX ctx;
MD5_Init(&ctx);
boost::nowide::ifstream ifs(filename, std::ios::binary);
boost::filesystem::ifstream ifs(filename, std::ios::binary);
std::string buf(64 * 1024, 0);
const std::size_t & size = boost::filesystem::file_size(filename);
std::size_t left_size = size;

View file

@ -41,7 +41,11 @@ export LD_LIBRARY_PATH="\$DIR/bin"
# FIXME: BambuStudio segfault workarounds
# 1) BambuStudio will segfault on systems where locale info is not as expected (i.e. Holo-ISO arch-based distro)
# 2) BambuStudio will segfault with a boost logging error if ~/.config/BambuStudio doesn't exist on first run
export LC_ALL=C
# FIXME: BambuStudio doesn't respect dark mode; use GTK_THEME workaround from sigxcpu76 │
export GTK_THEME=Adwaita:light
mkdir -p \${HOME}/.config/BambuStudio/ 2> /dev/null
exec "\$DIR/bin/@SLIC3R_APP_CMD@" "\$@"
EOF

View file

@ -64,7 +64,7 @@ void AMSMaterialsSetting::create()
m_clrData->SetChooseFull(true);
m_clrData->SetChooseAlpha(false);
m_clr_picker = new Button(this, wxEmptyString, wxEmptyString, wxBU_AUTODRAW);
m_clr_picker = new Button(this, "", "");
m_clr_picker->SetCanFocus(false);
m_clr_picker->SetSize(FromDIP(50), FromDIP(25));
m_clr_picker->SetMinSize(wxSize(FromDIP(50), FromDIP(25)));
@ -364,12 +364,7 @@ void AMSMaterialsSetting::on_clr_picker(wxCommandEvent & event)
show_flag = true;
if (clr_dialog->ShowModal() == wxID_OK) {
m_clrData = &(clr_dialog->GetColourData());
m_clr_picker->SetBackgroundColor(wxColour(
m_clrData->GetColour().Red(),
m_clrData->GetColour().Green(),
m_clrData->GetColour().Blue(),
254
));
m_clr_picker->SetBackgroundColor(m_clrData->GetColour());
}
}
@ -379,19 +374,13 @@ bool AMSMaterialsSetting::Show(bool show)
m_button_confirm->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
m_input_nozzle_min->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
m_clr_picker->SetBackgroundColour(m_clr_picker->GetParent()->GetBackgroundColour());
}
return DPIDialog::Show(show);
}
void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_min, wxString temp_max)
{
m_clr_picker->SetBackgroundColor(wxColour(
m_clrData->GetColour().Red(),
m_clrData->GetColour().Green(),
m_clrData->GetColour().Blue(),
254
));
m_clr_picker->SetBackgroundColor(m_clrData->GetColour());
if (!m_is_third) {
m_button_confirm->Hide();

View file

@ -83,7 +83,7 @@ protected:
Button * m_button_confirm;
wxStaticText* m_tip_readonly;
Button * m_button_close;
Button * m_clr_picker;
Button * m_clr_picker;
wxColourData * m_clrData;
#ifdef __APPLE__
wxComboBox *m_comboBox_filament_mac;

View file

@ -200,11 +200,6 @@ void AMSSetting::create()
m_panel_img->Layout();
m_sizer_img->Fit(m_panel_img);
m_sizer_remain_block = new wxBoxSizer(wxVERTICAL);
m_sizer_remain_block->Add(m_sizer_remain, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizer_remain_block->Add(0, 0, 0, wxTOP, 8);
m_sizer_remain_block->Add(m_sizer_remain_tip, 0, wxLEFT, 18);
m_sizer_remain_block->Add(0, 0, 0, wxTOP, 15);
m_sizerl_body->Add(m_sizer_Insert_material, 0, wxEXPAND, 0);
m_sizerl_body->Add(0, 0, 0, wxTOP, 8);
@ -214,7 +209,10 @@ void AMSSetting::create()
m_sizerl_body->Add(0, 0, 0, wxTOP, 8);
m_sizerl_body->Add(m_sizer_starting_tip, 0, wxLEFT, 18);
m_sizerl_body->Add(0, 0, 0, wxTOP, 15);
m_sizerl_body->Add(m_sizer_remain_block, 0, wxEXPAND, 0);
m_sizerl_body->Add(m_sizer_remain, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizerl_body->Add(0, 0, 0, wxTOP, 8);
m_sizerl_body->Add(m_sizer_remain_tip, 0, wxLEFT, 18);
m_sizerl_body->Add(0, 0, 0, wxTOP, 15);
m_sizerl_body->Add(m_sizer_switch_filament, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizerl_body->Add(0, 0, 0, wxTOP, 8);
m_sizerl_body->Add(m_sizer_switch_filament_tip, 0, wxLEFT, 18);
@ -233,17 +231,6 @@ void AMSSetting::create()
this->Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
Bind(wxEVT_SHOW, [this](auto& e) {
if (this->IsShown()) {
if (ams_support_remain) {
m_sizer_remain_block->Show(true);
}
else {
m_sizer_remain_block->Show(false);
}
}
});
}
void AMSSetting::update_insert_material_read_mode(bool selected)

View file

@ -39,7 +39,6 @@ public:
wxString append_title(wxString text);
wxStaticText *append_text(wxString text);
MachineObject *obj{nullptr};
bool ams_support_remain{false};
int ams_id { 0 };
protected:
@ -73,7 +72,6 @@ protected:
wxBoxSizer *m_sizer_starting_tip_inline;
wxBoxSizer *m_sizer_remain_inline;
wxBoxSizer *m_sizer_switch_filament_inline;
wxBoxSizer *m_sizer_remain_block;
};
}} // namespace Slic3r::GUI

View file

@ -456,9 +456,7 @@ void AuFile::on_set_cover()
{
if (wxGetApp().plater()->model().model_info == nullptr) { wxGetApp().plater()->model().model_info = std::make_shared<ModelInfo>(); }
fs::path path(into_path(m_file_name));
wxGetApp().plater()->model().model_info->cover_file = path.string();
//wxGetApp().plater()->model().model_info->cover_file = m_file_name.ToStdString();
wxGetApp().plater()->model().model_info->cover_file = m_file_name.ToStdString();
auto full_path = m_file_path.branch_path();
auto full_root_path = full_path.branch_path();
@ -698,8 +696,7 @@ void AuFolderPanel::update_cover()
if (wxGetApp().plater()->model().model_info != nullptr) {
for (auto i = 0; i < m_aufiles_list.GetCount(); i++) {
AuFiles *aufile = m_aufiles_list[i];
if (wxString::FromUTF8(wxGetApp().plater()->model().model_info->cover_file) == aufile->file->m_file_name) {
if (wxGetApp().plater()->model().model_info->cover_file == aufile->file->m_file_name) {
aufile->file->set_cover(true);
} else {
aufile->file->set_cover(false);

View file

@ -24,6 +24,7 @@ enum CUSTOM_ID
ID_TITLE,
ID_MODEL_STORE,
ID_PUBLISH,
ID_CALIB,
ID_TOOL_BAR = 3200,
ID_AMS_NOTEBOOK,
};
@ -194,7 +195,7 @@ void BBLTopbar::Init(wxFrame* parent)
m_frame = parent;
m_skip_popup_file_menu = false;
m_skip_popup_dropdown_menu = false;
m_skip_popup_calib_menu = false;
wxInitAllImageHandlers();
this->AddSpacer(5);
@ -241,6 +242,13 @@ void BBLTopbar::Init(wxFrame* parent)
wxBitmap redo_inactive_bitmap = create_scaled_bitmap("topbar_redo_inactive", nullptr, TOPBAR_ICON_SIZE);
m_redo_item->SetDisabledBitmap(redo_inactive_bitmap);
this->AddSpacer(FromDIP(10));
wxBitmap calib_bitmap = create_scaled_bitmap("calib_sf", nullptr, TOPBAR_ICON_SIZE);
wxBitmap calib_bitmap_inactive = create_scaled_bitmap("calib_sf_inactive", nullptr, TOPBAR_ICON_SIZE);
m_calib_item = this->AddTool(ID_CALIB, "Calibration", calib_bitmap);
m_calib_item->SetDisabledBitmap(calib_bitmap_inactive);
this->AddSpacer(FromDIP(10));
this->AddStretchSpacer(1);
@ -298,6 +306,7 @@ void BBLTopbar::Init(wxFrame* parent)
this->Bind(wxEVT_MENU_CLOSE, &BBLTopbar::OnMenuClose, this);
this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnFileToolItem, this, ID_TOP_FILE_MENU);
this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnDropdownToolItem, this, ID_TOP_DROPDOWN_MENU);
this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnCalibToolItem, this, ID_CALIB);
this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnIconize, this, wxID_ICONIZE_FRAME);
this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnFullScreen, this, wxID_MAXIMIZE_FRAME);
this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnCloseFrame, this, wxID_CLOSE_FRAME);
@ -353,17 +362,19 @@ void BBLTopbar::OnRedo(wxAuiToolBarEvent& event)
plater->redo();
}
void BBLTopbar::EnableUndoRedoItems()
void BBLTopbar::Enable3DEditorItems()
{
this->EnableTool(m_undo_item->GetId(), true);
this->EnableTool(m_redo_item->GetId(), true);
this->EnableTool(m_calib_item->GetId(), true);
Refresh();
}
void BBLTopbar::DisableUndoRedoItems()
void BBLTopbar::Disable3DEditorItems()
{
this->EnableTool(m_undo_item->GetId(), false);
this->EnableTool(m_redo_item->GetId(), false);
this->EnableTool(m_calib_item->GetId(), false);
Refresh();
}
@ -416,6 +427,11 @@ wxMenu* BBLTopbar::GetTopMenu()
return &m_top_menu;
}
wxMenu* BBLTopbar::GetCalibMenu()
{
return &m_calib_menu;
}
void BBLTopbar::SetTitle(wxString title)
{
wxGCDC dc(this);
@ -468,6 +484,9 @@ void BBLTopbar::Rescale() {
item->SetBitmap(create_scaled_bitmap("topbar_redo", this, TOPBAR_ICON_SIZE));
item->SetDisabledBitmap(create_scaled_bitmap("topbar_redo_inactive", nullptr, TOPBAR_ICON_SIZE));
item = this->FindTool(ID_CALIB);
item->SetBitmap(create_scaled_bitmap("ams_readonly", this, TOPBAR_ICON_SIZE));
item = this->FindTool(ID_TITLE);
/*item = this->FindTool(ID_PUBLISH);
@ -581,6 +600,24 @@ void BBLTopbar::OnDropdownToolItem(wxAuiToolBarEvent& evt)
tb->SetToolSticky(evt.GetId(), false);
}
void BBLTopbar::OnCalibToolItem(wxAuiToolBarEvent& evt)
{
wxAuiToolBar* tb = static_cast<wxAuiToolBar*>(evt.GetEventObject());
tb->SetToolSticky(evt.GetId(), true);
if (!m_skip_popup_calib_menu) {
auto rec = this->GetToolRect(ID_CALIB);
PopupMenu(&m_calib_menu, wxPoint(rec.GetLeft(), this->GetSize().GetHeight() - 2));
}
else {
m_skip_popup_calib_menu = false;
}
// make sure the button is "un-stuck"
tb->SetToolSticky(evt.GetId(), false);
}
void BBLTopbar::OnMouseLeftDown(wxMouseEvent& event)
{
wxPoint mouse_pos = ::wxGetMousePosition();

View file

@ -24,6 +24,7 @@ public:
void OnCloseFrame(wxAuiToolBarEvent& event);
void OnFileToolItem(wxAuiToolBarEvent& evt);
void OnDropdownToolItem(wxAuiToolBarEvent& evt);
void OnCalibToolItem(wxAuiToolBarEvent& evt);
void OnMouseLeftDClock(wxMouseEvent& mouse);
void OnMouseLeftDown(wxMouseEvent& event);
void OnMouseLeftUp(wxMouseEvent& event);
@ -42,13 +43,14 @@ public:
void SetFileMenu(wxMenu* file_menu);
void AddDropDownSubMenu(wxMenu* sub_menu, const wxString& title);
void AddDropDownMenuItem(wxMenuItem* menu_item);
wxMenu *GetTopMenu();
wxMenu* GetTopMenu();
wxMenu *GetCalibMenu();
void SetTitle(wxString title);
void SetMaximizedSize();
void SetWindowSize();
void EnableUndoRedoItems();
void DisableUndoRedoItems();
void Enable3DEditorItems();
void Disable3DEditorItems();
void SaveNormalRect();
@ -60,6 +62,7 @@ private:
wxPoint m_delta;
wxMenu m_top_menu;
wxMenu* m_file_menu;
wxMenu m_calib_menu;
wxAuiToolBarItem* m_title_item;
wxAuiToolBarItem* m_account_item;
wxAuiToolBarItem* m_model_store_item;
@ -67,6 +70,7 @@ private:
wxAuiToolBarItem *m_publish_item;
wxAuiToolBarItem* m_undo_item;
wxAuiToolBarItem* m_redo_item;
wxAuiToolBarItem* m_calib_item;
wxAuiToolBarItem* maximize_btn;
wxBitmap m_publish_bitmap;
@ -78,4 +82,5 @@ private:
int m_toolbar_h;
bool m_skip_popup_file_menu;
bool m_skip_popup_dropdown_menu;
bool m_skip_popup_calib_menu;
};

View file

@ -120,6 +120,7 @@ public:
// Get the current print. It is either m_fff_print or m_sla_print.
const PrintBase* current_print() const { return m_print; }
const Print* fff_print() const { return m_fff_print; }
Print* fff_print() { 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().

View file

@ -271,7 +271,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
}
double sparse_infill_density = config->option<ConfigOptionPercent>("sparse_infill_density")->value;
auto timelapse_type = config->opt_enum<TimelapseType>("timelapse_type");
if (config->opt_bool("spiral_mode") &&
! (config->opt_int("wall_loops") == 1 &&
@ -280,12 +279,12 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
! config->opt_bool("enable_support") &&
config->opt_int("enforce_support_layers") == 0 &&
config->opt_bool("ensure_vertical_shell_thickness") &&
! config->opt_bool("detect_thin_wall") &&
config->opt_enum<TimelapseType>("timelapse_type") == TimelapseType::tlTraditional))
! config->opt_bool("detect_thin_wall")))
{
wxString msg_text = _(L("Spiral mode only works when wall loops is 1, support is disabled, top shell layers is 0, sparse infill density is 0 and timelapse type is traditional"));
wxString msg_text = _(L("Spiral mode only works when wall loops is 1, \n"
"support is disabled, top shell layers is 0 and sparse infill density is 0\n"));
if (is_global_config)
msg_text += "\n\n" + _(L("Change these settings automatically? \n"
msg_text += "\n" + _(L("Change these settings automatically? \n"
"Yes - Change these settings and enable spiral mode automatically\n"
"No - Give up using spiral mode this time"));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "",
@ -302,9 +301,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
new_conf.set_key_value("enforce_support_layers", new ConfigOptionInt(0));
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(true));
new_conf.set_key_value("detect_thin_wall", new ConfigOptionBool(false));
new_conf.set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
sparse_infill_density = 0;
timelapse_type = TimelapseType::tlTraditional;
support = false;
}
else {
@ -313,7 +310,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
apply(config, &new_conf);
if (cb_value_change) {
cb_value_change("sparse_infill_density", sparse_infill_density);
cb_value_change("timelapse_type", timelapse_type);
if (!support)
cb_value_change("enable_support", false);
}

View file

@ -1259,29 +1259,6 @@ bool MachineObject::is_recording()
return camera_recording;
}
void MachineObject::parse_version_func()
{
auto ota_version = module_vers.find("ota");
if (printer_type == "BL-P001" ||
printer_type == "BL-P002") {
if (ota_version != module_vers.end()) {
if (ota_version->second.sw_ver.compare("01.01.01.00") <= 0) {
ams_support_remain = false;
ams_support_auto_switch_filament_flag = false;
is_xcam_buildplate_supported = false;
xcam_support_recovery_step_loss = false;
is_support_send_to_sdcard = false;
} else {
ams_support_remain = true;
ams_support_auto_switch_filament_flag = true;
is_xcam_buildplate_supported = true;
xcam_support_recovery_step_loss = true;
is_support_send_to_sdcard = true;
}
}
}
}
int MachineObject::command_get_version(bool with_retry)
{
BOOST_LOG_TRIVIAL(info) << "command_get_version";
@ -2013,15 +1990,9 @@ bool MachineObject::is_function_supported(PrinterFunction func)
func_name = "FUNC_AI_MONITORING";
break;
case FUNC_BUILDPLATE_MARKER_DETECT:
parse_version_func();
if (!is_xcam_buildplate_supported)
return false;
func_name = "FUNC_BUILDPLATE_MARKER_DETECT";
break;
case FUNC_AUTO_RECOVERY_STEP_LOSS:
parse_version_func();
if (!xcam_support_recovery_step_loss)
return false;
func_name = "FUNC_AUTO_RECOVERY_STEP_LOSS";
break;
case FUNC_FLOW_CALIBRATION:
@ -2055,15 +2026,9 @@ bool MachineObject::is_function_supported(PrinterFunction func)
func_name = "FUNC_ALTER_RESOLUTION";
break;
case FUNC_SEND_TO_SDCARD:
parse_version_func();
if (!is_support_send_to_sdcard)
return false;
func_name = "FUNC_SEND_TO_SDCARD";
break;
case FUNC_AUTO_SWITCH_FILAMENT:
parse_version_func();
if (!ams_support_auto_switch_filament_flag)
return false;
func_name = "FUNC_AUTO_SWITCH_FILAMENT";
break;
case FUNC_VIRTUAL_CAMERA:
@ -2650,9 +2615,6 @@ int MachineObject::parse_json(std::string payload)
else {
if (jj["xcam"].contains("buildplate_marker_detector")) {
xcam_buildplate_marker_detector = jj["xcam"]["buildplate_marker_detector"].get<bool>();
is_xcam_buildplate_supported = true;
} else {
is_xcam_buildplate_supported = false;
}
}
}
@ -2912,8 +2874,6 @@ int MachineObject::parse_json(std::string payload)
}
if (tray_it->contains("remain")) {
curr_tray->remain = (*tray_it)["remain"].get<int>();
} else {
curr_tray->remain = -1;
}
try {
if (!ams_id.empty() && !curr_tray->id.empty()) {
@ -3061,7 +3021,6 @@ int MachineObject::parse_json(std::string payload)
ver_info.hw_ver = (*it)["hw_ver"].get<std::string>();
module_vers.emplace(ver_info.name, ver_info);
}
parse_version_func();
bool get_version_result = true;
if (j["info"].contains("result"))
if (j["info"]["result"].get<std::string>() == "fail")

View file

@ -423,10 +423,8 @@ public:
bool ams_insert_flag { false };
bool ams_power_on_flag { false };
bool ams_calibrate_remain_flag { false };
bool ams_support_auto_switch_filament_flag { true };
bool ams_auto_switch_filament_flag { false };
bool ams_support_use_ams { false };
bool ams_support_remain { true };
int ams_humidity;
int ams_user_setting_hold_count = 0;
AmsStatusMain ams_status_main;
@ -581,10 +579,8 @@ public:
bool xcam_ai_monitoring{ false };
int xcam_ai_monitoring_hold_count = 0;
std::string xcam_ai_monitoring_sensitivity;
bool is_xcam_buildplate_supported { true };
bool xcam_buildplate_marker_detector{ false };
int xcam_buildplate_marker_hold_count = 0;
bool xcam_support_recovery_step_loss { true };
bool xcam_auto_recovery_step_loss{ false };
int xcam_auto_recovery_hold_count = 0;
int ams_print_option_count = 0;
@ -592,7 +588,6 @@ public:
/* sdcard */
MachineObject::SdcardState sdcard_state { NO_SDCARD };
MachineObject::SdcardState get_sdcard_state();
bool is_support_send_to_sdcard { true };
/* HMS */
std::vector<HMSItem> hms_list;
@ -627,8 +622,6 @@ public:
MachineObject(NetworkAgent* agent, std::string name, std::string id, std::string ip);
~MachineObject();
void parse_version_func();
/* command commands */
int command_get_version(bool with_retry = true);
int command_request_push_all();

View file

@ -32,6 +32,7 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent);

View file

@ -32,6 +32,7 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent);

View file

@ -728,7 +728,7 @@ static const FileWildcards file_wildcards_by_type[FT_SIZE] = {
/* FT_OBJ */ { "OBJ files"sv, { ".obj"sv } },
/* FT_AMF */ { "AMF files"sv, { ".amf"sv, ".zip.amf"sv, ".xml"sv } },
/* FT_3MF */ { "3MF files"sv, { ".3mf"sv } },
/* FT_GCODE */ { "G-code files"sv, { ".gcode"sv } },
/* FT_GCODE */ { "G-code files"sv, { ".gcode"sv, ".3mf"sv } },
/* FT_MODEL */ {"Supported files"sv, {".3mf"sv, ".stl"sv, ".stp"sv, ".step"sv, ".svg"sv, ".amf"sv, ".obj"sv }},
/* FT_PROJECT */ { "Project files"sv, { ".3mf"sv} },
/* FT_GALLERY */ { "Known files"sv, { ".stl"sv, ".obj"sv } },
@ -1699,7 +1699,7 @@ void GUI_App::init_networking_callbacks()
wxCommandEvent event(EVT_CONNECT_LAN_MODE_PRINT);
if (obj) {
if (obj->is_lan_mode_printer()) {
if (state == ConnectStatus::ConnectStatusOk) {
obj->command_request_push_all();
@ -1892,9 +1892,6 @@ void GUI_App::init_app_config()
if (! wxGetEnv(wxS("XDG_CONFIG_HOME"), &dir) || dir.empty() )
dir = wxFileName::GetHomeDir() + wxS("/.config");
set_data_dir((dir + "/" + GetAppName()).ToUTF8().data());
boost::filesystem::path data_dir_path(data_dir());
if (!boost::filesystem::exists(data_dir_path))
boost::filesystem::create_directory(data_dir_path);
#endif
} else {
m_datadir_redefined = true;
@ -2732,7 +2729,7 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
/*if (m_is_dark_mode != dark_mode() )
m_is_dark_mode = dark_mode();*/
if (m_is_dark_mode) {
auto original_col = window->GetBackgroundColour();
@ -3238,7 +3235,7 @@ void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const
{
input_file.Clear();
wxFileDialog dialog(parent ? parent : GetTopWindow(),
_L("Choose one file (gcode/.gco/.g/.ngc/ngc):"),
_L("Choose one file (gcode/3mf):"),
app_config->get_last_dir(), "",
file_wildcards(FT_GCODE), wxFD_OPEN | wxFD_FILE_MUST_EXIST);

View file

@ -201,7 +201,7 @@ void GridCellFilamentsEditor::BeginEdit(int row, int col, wxGrid* grid)
{
// This event handler is needed to properly dismiss the editor when the popup is closed
m_control->Bind(wxEVT_COMBOBOX_CLOSEUP, &GridCellFilamentsEditor::OnComboCloseUp, this);
evtHandler = static_cast<wxGridCellEditorEvtHandler*>(m_control->GetEventHandler());
evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler);
}
// Don't immediately end if we get a kill focus event within BeginEdit
@ -403,7 +403,7 @@ void GridCellChoiceEditor::BeginEdit(int row, int col, wxGrid *grid)
if (m_control) {
// This event handler is needed to properly dismiss the editor when the popup is closed
m_control->Bind(wxEVT_COMBOBOX_CLOSEUP, &GridCellChoiceEditor::OnComboCloseUp, this);
evtHandler = static_cast<wxGridCellEditorEvtHandler*>(m_control->GetEventHandler());
evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler);
}
// Don't immediately end if we get a kill focus event within BeginEdit

View file

@ -904,10 +904,10 @@ void MainFrame::init_tabpanel()
#ifndef __APPLE__
if (sel == tp3DEditor) {
m_topbar->EnableUndoRedoItems();
m_topbar->Enable3DEditorItems();
}
else {
m_topbar->DisableUndoRedoItems();
m_topbar->Disable3DEditorItems();
}
#endif
@ -1360,6 +1360,9 @@ wxBoxSizer* MainFrame::create_side_tools()
m_print_option_btn = new SideButton(this, "", "sidebutton_dropdown", 0, FromDIP(14));
update_side_button_style();
m_print_option_btn->Enable();
sizer->Add(FromDIP(15), 0, 0, 0, 0);
m_slice_option_btn->Enable();
m_print_option_btn->Enable();
sizer->Add(m_slice_option_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, FromDIP(1));
@ -1556,6 +1559,7 @@ wxBoxSizer* MainFrame::create_side_tools()
p->append_button(send_to_printer_btn);
p->append_button(send_to_printer_all_btn);
p->append_button(export_sliced_file_btn);
//p->append_button(export_gcode_btn);
p->append_button(export_all_sliced_file_btn);
}
@ -1702,7 +1706,8 @@ void MainFrame::update_side_button_style()
{
// BBS
int em = em_unit();
m_slice_btn->SetLayoutStyle(1);
/*m_slice_btn->SetLayoutStyle(1);
m_slice_btn->SetTextLayout(SideButton::EHorizontalOrientation::HO_Center, FromDIP(15));
m_slice_btn->SetMinSize(wxSize(-1, FromDIP(24)));
@ -2454,6 +2459,14 @@ void MainFrame::init_menubar_as_editor()
//m_topbar->AddDropDownMenuItem(language_item);
//m_topbar->AddDropDownMenuItem(config_item);
m_topbar->AddDropDownSubMenu(helpMenu, _L("Help"));
// SoftFever calibrations
append_menu_item(m_topbar->GetCalibMenu(), wxID_ANY, _L("PA - DDE"), _L("Calibrate PA - DDE"),
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(false); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this);
append_menu_item(m_topbar->GetCalibMenu(), wxID_ANY, _L("PA - Bowden"), _L("Calibrate PA - Bowden"),
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(true); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this);
#else
m_menubar->Append(fileMenu, wxString::Format("&%s", _L("File")));
if (editMenu)

View file

@ -8,7 +8,6 @@
#include "MsgDialog.hpp"
#include "DownloadProgressDialog.hpp"
#include <boost/filesystem/string_file.hpp>
#undef pid_t
#include <boost/process.hpp>
#ifdef __WIN32__

View file

@ -1198,28 +1198,6 @@ std::vector<int> PartPlate::get_extruders() const
return plate_extruders;
}
std::vector<int> PartPlate::get_used_extruders()
{
std::vector<int> used_extruders;
// if gcode.3mf file
if (m_model->objects.empty()) {
for (int i = 0; i < slice_filaments_info.size(); i++) {
used_extruders.push_back(slice_filaments_info[i].id + 1);
}
return used_extruders;
}
GCodeProcessorResult* result = get_slice_result();
if (!result)
return used_extruders;
PrintEstimatedStatistics& ps = result->print_statistics;
for (auto it = ps.volumes_per_extruder.begin(); it != ps.volumes_per_extruder.end(); it++) {
used_extruders.push_back(it->first + 1);
}
return used_extruders;
}
Vec3d PartPlate::estimate_wipe_tower_size(const double w, const double wipe_volume) const
{
Vec3d wipe_tower_size;

View file

@ -259,7 +259,6 @@ public:
Vec3d get_origin() { return m_origin; }
Vec3d estimate_wipe_tower_size(const double w, const double wipe_volume) const;
std::vector<int> get_extruders() const;
std::vector<int> get_used_extruders();
/* instance related operations*/
//judge whether instance is bound in plate or not

View file

@ -7398,7 +7398,7 @@ Print& Plater::fff_print() { return p->fff_print; }
const SLAPrint& Plater::sla_print() const { return p->sla_print; }
SLAPrint& Plater::sla_print() { return p->sla_print; }
int Plater::new_project(bool skip_confirm, bool silent)
int Plater::new_project(bool skip_confirm, bool silent, const wxString& project_name)
{
bool transfer_preset_changes = false;
// BBS: save confirm
@ -7438,7 +7438,10 @@ int Plater::new_project(bool skip_confirm, bool silent)
//reset project
p->project.reset();
//set project name
p->set_project_name(_L("Untitled"));
if (project_name.empty())
p->set_project_name(_L("Untitled"));
else
p->set_project_name(project_name);
Plater::TakeSnapshot snapshot(this, "New Project", UndoRedo::SnapshotType::ProjectSeparator);
@ -7800,16 +7803,22 @@ bool Plater::up_to_date(bool saved, bool backup)
!Slic3r::has_other_changes(backup));
}
void Plater::add_model(bool imperial_units/* = false*/)
void Plater::add_model(bool imperial_units/* = false*/, std::string fname/* = ""*/)
{
wxArrayString input_files;
wxGetApp().import_model(this, input_files);
if (input_files.empty())
return;
std::vector<fs::path> paths;
for (const auto &file : input_files)
paths.emplace_back(into_path(file));
if(fname.empty()){
wxArrayString input_files;
wxGetApp().import_model(this, input_files);
if (input_files.empty())
return;
for (const auto &file : input_files)
paths.emplace_back(into_path(file));
}
else{
paths.emplace_back(fname);
}
std::string snapshot_label;
assert(! paths.empty());
@ -7856,6 +7865,16 @@ void Plater::add_model(bool imperial_units/* = false*/)
}
}
void Plater::calib_pa(bool bowden) {
const auto calib_pa_name = "Pressure Advance Test";
new_project(false, false, calib_pa_name);
add_model(false, Slic3r::resources_dir() + "/calib/pressure_advance_test.stl");
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
p->background_process.fff_print()->is_calib_mode() = bowden ? Calib_PA_Bowden : Calib_PA_DDE;
}
void Plater::import_sl1_archive()
{
if (!p->m_ui_jobs.is_any_running())
@ -8627,6 +8646,9 @@ void Plater::add_file()
break;
default:break;
}
// SoftFever: ugly fix so we can exist pa calib mode
p->background_process.fff_print()->is_calib_mode() = Calib_None;
}
void Plater::update() { p->update(); }

View file

@ -202,7 +202,7 @@ public:
const SLAPrint& sla_print() const;
SLAPrint& sla_print();
int new_project(bool skip_confirm = false, bool silent = false);
int new_project(bool skip_confirm = false, bool silent = false, const wxString& project_name = wxString());
// BBS: save & backup
void load_project(wxString const & filename = "", wxString const & originfile = "-");
int save_project(bool saveAs = false);
@ -217,7 +217,7 @@ public:
bool open_3mf_file(const fs::path &file_path);
int get_3mf_file_count(std::vector<fs::path> paths);
void add_file();
void add_model(bool imperial_units = false);
void add_model(bool imperial_units = false, std::string fname = "");
void import_sl1_archive();
void extract_config_from_project();
void load_gcode();
@ -225,6 +225,9 @@ public:
void reload_gcode_from_disk();
void refresh_print();
// SoftFever
void calib_pa(bool bowden = false);
//BBS: add only gcode mode
bool only_gcode_mode() { return m_only_gcode; }
void set_only_gcode(bool only_gcode) { m_only_gcode = only_gcode; }

View file

@ -2930,7 +2930,7 @@ void SelectMachineDialog::set_default()
}
// material info
auto extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_extruders();
auto extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_extruders();
BitmapCache bmcache;
MaterialHash::iterator iter = m_materialList.begin();

View file

@ -2707,7 +2707,7 @@ void Selection::paste_objects_from_clipboard()
auto start_offset = in_current ? src_object->instances.front()->get_offset() : plate->get_build_volume().center();
auto point_offset = start_offset - start_point;
auto empty_cell = wxGetApp().plater()->canvas3D()->get_nearest_empty_cell({start_point(0), start_point(1)}, {bbox.size()(0)+1, bbox.size()(1)+1});
displacement = {empty_cell.x() + point_offset.x(), empty_cell.y() + point_offset.y(), start_offset(2)};
displacement = {empty_cell.x() + point_offset.x(), empty_cell.y() + point_offset.y(), start_point(2)};
}
for (ModelInstance* inst : dst_object->instances)

View file

@ -1807,7 +1807,6 @@ void StatusPanel::update_ams(MachineObject *obj)
// update obj in sub dlg
if (m_ams_setting_dlg) {
m_ams_setting_dlg->obj = obj;
if (obj && m_ams_setting_dlg->IsShown()) {
m_ams_setting_dlg->update_insert_material_read_mode(obj->ams_insert_flag);
m_ams_setting_dlg->update_starting_read_mode(obj->ams_power_on_flag);
@ -2446,7 +2445,6 @@ void StatusPanel::on_ams_setting_click(SimpleEvent &event)
try {
int ams_id_int = atoi(ams_id.c_str());
m_ams_setting_dlg->ams_id = ams_id_int;
m_ams_setting_dlg->ams_support_remain = obj->ams_support_remain;
m_ams_setting_dlg->Show();
} catch (...) {
;

View file

@ -4,13 +4,9 @@
#include <wx/webviewarchivehandler.h>
#include <wx/webviewfshandler.h>
#if wxUSE_WEBVIEW_EDGE
#include <wx/msw/webview_edge.h>
#endif
#include <wx/uri.h>
#if defined(__WIN32__) || defined(__WXMAC__)
#include "wx/private/jsscriptwrapper.h"
#endif
#ifdef __WIN32__
#include "../WebView2.h"

View file

@ -33,7 +33,6 @@
#include <cstdint> // uint8_t
#include <ctype.h> // ::tolower, ::toupper
#include <cwctype> // ::towlower
#include <cstring> // memcpy
#include <cstdio>

View file

@ -9,7 +9,6 @@
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/string_file.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/log/trivial.hpp>