Merge branch 'main' into dev/update-bbs-network

This commit is contained in:
SoftFever
2025-01-28 21:57:04 +08:00
committed by GitHub
161 changed files with 3726 additions and 2734 deletions
+2
View File
@@ -147,6 +147,8 @@ int main(int argc, char* argv[])
std::cout << "Validation failed" << std::endl;
return 1;
}
// Report loaded presets
std::cout << "Total loaded vendors: " << preset_bundle->vendors.size() << std::endl;
if (generate_user_preset) {
generate_custom_presets(preset_bundle, app_config);
+2 -1
View File
@@ -550,7 +550,7 @@ set(OCCT_LIBS
TKernel
)
find_package(libnoise REQUIRED)
target_link_libraries(libslic3r
libnest2d
admesh
@@ -576,6 +576,7 @@ target_link_libraries(libslic3r
JPEG::JPEG
qoi
opencv_world
noise::noise
)
if(NOT WIN32)
+3 -2
View File
@@ -839,8 +839,9 @@ int ConfigBase::load_from_json(const std::string &file, ConfigSubstitutionContex
}
else if (!load_inherits_to_config && boost::iequals(it.key(), BBL_JSON_KEY_INHERITS)) {
key_values.emplace(BBL_JSON_KEY_INHERITS, it.value());
}
else {
} else if (boost::iequals(it.key(), ORCA_JSON_KEY_RENAMED_FROM)) {
key_values.emplace(ORCA_JSON_KEY_RENAMED_FROM, it.value());
} else {
t_config_option_key opt_key = it.key();
std::string value_str;
+1
View File
@@ -87,6 +87,7 @@ void LayerRegion::make_perimeters(const SurfaceCollection &slices, const LayerRe
&slices,
&compatible_regions,
this->layer()->height,
this->layer()->slice_z,
this->flow(frPerimeter),
&region_config,
&this->layer()->object()->config(),
+65 -15
View File
@@ -22,6 +22,7 @@
#include "libslic3r/AABBTreeLines.hpp"
#include "Print.hpp"
#include "Algorithm/LineSplit.hpp"
#include "libnoise/noise.h"
static const int overhang_sampling_number = 6;
static const double narrow_loop_length_threshold = 10;
static const double min_degree_gap = 0.1;
@@ -44,6 +45,14 @@ static double random_value() {
return dist(gen);
}
class UniformNoise: public noise::module::Module {
public:
UniformNoise(): Module (GetSourceModuleCount ()) {};
virtual int GetSourceModuleCount() const { return 0; }
virtual double GetValue(double x, double y, double z) const { return random_value() * 2 - 1; }
};
// Hierarchy of perimeters.
class PerimeterGeneratorLoop {
public:
@@ -66,9 +75,39 @@ public:
bool is_internal_contour() const;
};
static std::unique_ptr<noise::module::Module> get_noise_module(const FuzzySkinConfig& cfg) {
if (cfg.noise_type == NoiseType::Perlin) {
auto perlin_noise = noise::module::Perlin();
perlin_noise.SetFrequency(1 / cfg.noise_scale);
perlin_noise.SetOctaveCount(cfg.noise_octaves);
perlin_noise.SetPersistence(cfg.noise_persistence);
return std::make_unique<noise::module::Perlin>(perlin_noise);
} else if (cfg.noise_type == NoiseType::Billow) {
auto billow_noise = noise::module::Billow();
billow_noise.SetFrequency(1 / cfg.noise_scale);
billow_noise.SetOctaveCount(cfg.noise_octaves);
billow_noise.SetPersistence(cfg.noise_persistence);
return std::make_unique<noise::module::Billow>(billow_noise);
} else if (cfg.noise_type == NoiseType::RidgedMulti) {
auto ridged_multi_noise = noise::module::RidgedMulti();
ridged_multi_noise.SetFrequency(1 / cfg.noise_scale);
ridged_multi_noise.SetOctaveCount(cfg.noise_octaves);
return std::make_unique<noise::module::RidgedMulti>(ridged_multi_noise);
} else if (cfg.noise_type == NoiseType::Voronoi) {
auto voronoi_noise = noise::module::Voronoi();
voronoi_noise.SetFrequency(1 / cfg.noise_scale);
voronoi_noise.SetDisplacement(1.0);
return std::make_unique<noise::module::Voronoi>(voronoi_noise);
} else {
return std::make_unique<UniformNoise>();
}
}
// Thanks Cura developers for this function.
static void fuzzy_polyline(Points& poly, bool closed, const FuzzySkinConfig& cfg)
static void fuzzy_polyline(Points& poly, bool closed, coordf_t slice_z, const FuzzySkinConfig& cfg)
{
std::unique_ptr<noise::module::Module> noise = get_noise_module(cfg);
const double min_dist_between_points = cfg.point_distance * 3. / 4.; // hardcoded: the point distance may vary between 3/4 and 5/4 the supplied value
const double range_random_point_dist = cfg.point_distance / 2.;
double dist_left_over = random_value() * (min_dist_between_points / 2.); // the distance to be traversed on the line before making the first new point
@@ -90,8 +129,9 @@ static void fuzzy_polyline(Points& poly, bool closed, const FuzzySkinConfig& cfg
for (; p0pa_dist < p0p1_size;
p0pa_dist += min_dist_between_points + random_value() * range_random_point_dist)
{
double r = random_value() * (cfg.thickness * 2.) - cfg.thickness;
out.emplace_back(*p0 + (p0p1 * (p0pa_dist / p0p1_size) + perp(p0p1).cast<double>().normalized() * r).cast<coord_t>());
Point pa = *p0 + (p0p1 * (p0pa_dist / p0p1_size)).cast<coord_t>();
double r = noise->GetValue(unscale_(pa.x()), unscale_(pa.y()), slice_z) * cfg.thickness;
out.emplace_back(pa + (perp(p0p1).cast<double>().normalized() * r).cast<coord_t>());
}
dist_left_over = p0pa_dist - p0p1_size;
p0 = &p1;
@@ -108,8 +148,10 @@ static void fuzzy_polyline(Points& poly, bool closed, const FuzzySkinConfig& cfg
}
// Thanks Cura developers for this function.
static void fuzzy_extrusion_line(std::vector<Arachne::ExtrusionJunction>& ext_lines, const FuzzySkinConfig& cfg)
static void fuzzy_extrusion_line(std::vector<Arachne::ExtrusionJunction>& ext_lines, coordf_t slice_z, const FuzzySkinConfig& cfg)
{
std::unique_ptr<noise::module::Module> noise = get_noise_module(cfg);
const double min_dist_between_points = cfg.point_distance * 3. / 4.; // hardcoded: the point distance may vary between 3/4 and 5/4 the supplied value
const double range_random_point_dist = cfg.point_distance / 2.;
double dist_left_over = random_value() * (min_dist_between_points / 2.); // the distance to be traversed on the line before making the first new point
@@ -128,8 +170,9 @@ static void fuzzy_extrusion_line(std::vector<Arachne::ExtrusionJunction>& ext_li
double p0p1_size = p0p1.norm();
double p0pa_dist = dist_left_over;
for (; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + random_value() * range_random_point_dist) {
double r = random_value() * (cfg.thickness * 2.) - cfg.thickness;
out.emplace_back(p0->p + (p0p1 * (p0pa_dist / p0p1_size) + perp(p0p1).cast<double>().normalized() * r).cast<coord_t>(), p1.w, p1.perimeter_index);
Point pa = p0->p + (p0p1 * (p0pa_dist / p0p1_size)).cast<coord_t>();
double r = noise->GetValue(unscale_(pa.x()), unscale_(pa.y()), slice_z) * cfg.thickness;
out.emplace_back(pa + (perp(p0p1).cast<double>().normalized() * r).cast<coord_t>(), p1.w, p1.perimeter_index);
}
dist_left_over = p0pa_dist - p0p1_size;
p0 = &p1;
@@ -544,7 +587,7 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
}
fuzzified = loop.polygon;
fuzzy_polyline(fuzzified.points, true, config);
fuzzy_polyline(fuzzified.points, true, perimeter_generator.slice_z, config);
return &fuzzified;
}
@@ -589,16 +632,17 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
// Fuzzy splitted polygon
if (std::all_of(splitted.begin(), splitted.end(), [](const Algorithm::SplitLineJunction& j) { return j.clipped; })) {
// The entire polygon is fuzzified
fuzzy_polyline(fuzzified.points, true, r.first);
fuzzy_polyline(fuzzified.points, true, perimeter_generator.slice_z, r.first);
} else {
Points segment;
segment.reserve(splitted.size());
fuzzified.points.clear();
const auto fuzzy_current_segment = [&segment, &fuzzified, &r]() {
const auto slice_z = perimeter_generator.slice_z;
const auto fuzzy_current_segment = [&segment, &fuzzified, &r, slice_z]() {
fuzzified.points.push_back(segment.front());
const auto back = segment.back();
fuzzy_polyline(segment, false, r.first);
fuzzy_polyline(segment, false, slice_z, r.first);
fuzzified.points.insert(fuzzified.points.end(), segment.begin(), segment.end());
fuzzified.points.push_back(back);
segment.clear();
@@ -970,6 +1014,8 @@ static void smooth_overhang_level(ExtrusionPaths &paths)
static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& perimeter_generator, std::vector<PerimeterGeneratorArachneExtrusion>& pg_extrusions,
bool &steep_overhang_contour, bool &steep_overhang_hole)
{
const auto slice_z = perimeter_generator.slice_z;
// Detect steep overhangs
bool overhangs_reverse = perimeter_generator.config->overhang_reverse &&
perimeter_generator.layer_id % 2 == 1; // Only calculate overhang degree on even (from GUI POV) layers
@@ -989,7 +1035,7 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p
const auto& config = regions.begin()->first;
const bool fuzzify = should_fuzzify(config, perimeter_generator.layer_id, extrusion->inset_idx, is_contour);
if (fuzzify)
fuzzy_extrusion_line(extrusion->junctions, config);
fuzzy_extrusion_line(extrusion->junctions, slice_z, config);
} else {
// Find all affective regions
std::vector<std::pair<const FuzzySkinConfig&, const ExPolygons&>> fuzzified_regions;
@@ -1011,17 +1057,17 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p
// Fuzzy splitted extrusion
if (std::all_of(splitted.begin(), splitted.end(), [](const Algorithm::SplitLineJunction& j) { return j.clipped; })) {
// The entire polygon is fuzzified
fuzzy_extrusion_line(extrusion->junctions, r.first);
fuzzy_extrusion_line(extrusion->junctions, slice_z, r.first);
} else {
const auto current_ext = extrusion->junctions;
std::vector<Arachne::ExtrusionJunction> segment;
segment.reserve(current_ext.size());
extrusion->junctions.clear();
const auto fuzzy_current_segment = [&segment, extrusion, &r]() {
const auto fuzzy_current_segment = [&segment, &extrusion, &r, slice_z]() {
extrusion->junctions.push_back(segment.front());
const auto back = segment.back();
fuzzy_extrusion_line(segment, r.first);
fuzzy_extrusion_line(segment, slice_z, r.first);
extrusion->junctions.insert(extrusion->junctions.end(), segment.begin(), segment.end());
extrusion->junctions.push_back(back);
segment.clear();
@@ -1858,7 +1904,11 @@ static void group_region_by_fuzzify(PerimeterGenerator& g)
region_config.fuzzy_skin,
scaled<coord_t>(region_config.fuzzy_skin_thickness.value),
scaled<coord_t>(region_config.fuzzy_skin_point_distance.value),
region_config.fuzzy_skin_first_layer
region_config.fuzzy_skin_first_layer,
region_config.fuzzy_skin_noise_type,
region_config.fuzzy_skin_scale,
region_config.fuzzy_skin_octaves,
region_config.fuzzy_skin_persistence
};
auto& surfaces = regions[cfg];
for (const auto& surface : region->slices.surfaces) {
+19 -2
View File
@@ -16,10 +16,21 @@ struct FuzzySkinConfig
coord_t thickness;
coord_t point_distance;
bool fuzzy_first_layer;
NoiseType noise_type;
double noise_scale;
int noise_octaves;
double noise_persistence;
bool operator==(const FuzzySkinConfig& r) const
{
return type == r.type && thickness == r.thickness && point_distance == r.point_distance && fuzzy_first_layer == r.fuzzy_first_layer;
return type == r.type
&& thickness == r.thickness
&& point_distance == r.point_distance
&& fuzzy_first_layer == r.fuzzy_first_layer
&& noise_type == r.noise_type
&& noise_scale == r.noise_scale
&& noise_octaves == r.noise_octaves
&& noise_persistence == r.noise_persistence;
}
bool operator!=(const FuzzySkinConfig& r) const { return !(*this == r); }
@@ -35,6 +46,10 @@ template<> struct hash<Slic3r::FuzzySkinConfig>
boost::hash_combine(seed, std::hash<coord_t>{}(c.thickness));
boost::hash_combine(seed, std::hash<coord_t>{}(c.point_distance));
boost::hash_combine(seed, std::hash<bool>{}(c.fuzzy_first_layer));
boost::hash_combine(seed, std::hash<Slic3r::NoiseType>{}(c.noise_type));
boost::hash_combine(seed, std::hash<double>{}(c.noise_scale));
boost::hash_combine(seed, std::hash<int>{}(c.noise_octaves));
boost::hash_combine(seed, std::hash<double>{}(c.noise_persistence));
return seed;
}
};
@@ -51,6 +66,7 @@ public:
const ExPolygons *lower_slices;
double layer_height;
int layer_id;
coordf_t slice_z;
Flow perimeter_flow;
Flow ext_perimeter_flow;
Flow overhang_flow;
@@ -83,6 +99,7 @@ public:
const SurfaceCollection* slices,
const LayerRegionPtrs *compatible_regions,
double layer_height,
coordf_t slice_z,
Flow flow,
const PrintRegionConfig* config,
const PrintObjectConfig* object_config,
@@ -98,7 +115,7 @@ public:
//BBS
ExPolygons* fill_no_overlap)
: slices(slices), compatible_regions(compatible_regions), upper_slices(nullptr), lower_slices(nullptr), layer_height(layer_height),
layer_id(-1), perimeter_flow(flow), ext_perimeter_flow(flow),
slice_z(slice_z), layer_id(-1), perimeter_flow(flow), ext_perimeter_flow(flow),
overhang_flow(flow), solid_infill_flow(flow),
config(config), object_config(object_config), print_config(print_config),
m_spiral_vase(spiral_mode),
+74 -12
View File
@@ -576,9 +576,10 @@ std::string Preset::label(bool no_alias) const
bool is_compatible_with_print(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_print, const PresetWithVendorProfile &active_printer)
{
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
// The current profile has a vendor assigned and it is different from the active print's vendor.
return false;
// Orca: we allow cross vendor compatibility
// if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
// // The current profile has a vendor assigned and it is different from the active print's vendor.
// return false;
auto &condition = preset.preset.compatible_prints_condition();
auto *compatible_prints = dynamic_cast<const ConfigOptionStrings*>(preset.preset.config.option("compatible_prints"));
bool has_compatible_prints = compatible_prints != nullptr && ! compatible_prints->values.empty();
@@ -613,9 +614,19 @@ bool is_compatible_with_parent_printer(const PresetWithVendorProfile& preset, co
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer, const DynamicPrintConfig *extra_config)
{
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
// The current profile has a vendor assigned and it is different from the active print's vendor.
return false;
// Orca: we allow cross vendor compatibility
// if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
// // The current profile has a vendor assigned and it is different from the active print's vendor.
// return false;
// Orca: check excluded printers
if (preset.vendor != nullptr && preset.preset.type == Preset::TYPE_FILAMENT) {
const auto& excluded_printers = preset.preset.m_excluded_from;
const auto excluded = preset.vendor->name == PresetBundle::ORCA_FILAMENT_LIBRARY &&
excluded_printers.find(active_printer.preset.name) != excluded_printers.end();
if (excluded)
return false;
}
auto &condition = preset.preset.compatible_printers_condition();
auto *compatible_printers = dynamic_cast<const ConfigOptionStrings*>(preset.preset.config.option("compatible_printers"));
bool has_compatible_printers = compatible_printers != nullptr && ! compatible_printers->values.empty();
@@ -629,10 +640,9 @@ bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const Pre
}
}
return preset.preset.is_default || active_printer.preset.name.empty() || !has_compatible_printers ||
std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.preset.name) !=
compatible_printers->values.end()
//BBS
|| (!active_printer.preset.is_system && is_compatible_with_parent_printer(preset, active_printer));
std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.preset.name) !=
compatible_printers->values.end() ||
(!active_printer.preset.is_system && is_compatible_with_parent_printer(preset, active_printer));
}
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer)
@@ -779,7 +789,7 @@ static std::vector<std::string> s_Preset_print_options {
"minimum_sparse_infill_area", "reduce_infill_retraction","internal_solid_infill_pattern","gap_fill_target",
"ironing_type", "ironing_pattern", "ironing_flow", "ironing_speed", "ironing_spacing", "ironing_angle", "ironing_inset",
"max_travel_detour_distance",
"fuzzy_skin", "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer",
"fuzzy_skin", "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer", "fuzzy_skin_noise_type", "fuzzy_skin_scale", "fuzzy_skin_octaves", "fuzzy_skin_persistence",
"max_volumetric_extrusion_rate_slope", "max_volumetric_extrusion_rate_slope_segment_length","extrusion_rate_smoothing_external_perimeter_only",
"inner_wall_speed", "outer_wall_speed", "sparse_infill_speed", "internal_solid_infill_speed",
"top_surface_speed", "support_speed", "support_object_xy_distance", "support_interface_speed",
@@ -1145,7 +1155,7 @@ void PresetCollection::load_presets(
if (key_values.find("instantiation") != key_values.end())
preset.is_visible = key_values["instantiation"] != "false";
//BBS: use inherit config as the base
//Orca: find and use the inherit config as the base
Preset* inherit_preset = nullptr;
ConfigOption* inherits_config = config.option(BBL_JSON_KEY_INHERITS);
@@ -1154,6 +1164,12 @@ void PresetCollection::load_presets(
ConfigOptionString * option_str = dynamic_cast<ConfigOptionString *> (inherits_config);
std::string inherits_value = option_str->value;
inherit_preset = this->find_preset(inherits_value, false, true);
// Orca: try to find if the parent preset has been renamed
if (inherit_preset == nullptr) {
auto it = this->find_preset_renamed(inherits_value);
if (it != m_presets.end())
inherit_preset = &(*it);
}
} else {
;
}
@@ -2123,6 +2139,7 @@ bool PresetCollection::clone_presets(std::vector<Preset const *> const &presets,
auto &preset = new_presets.back();
preset.vendor = nullptr;
preset.renamed_from.clear();
preset.m_excluded_from.clear();
preset.setting_id.clear();
preset.inherits().clear();
preset.is_default = false;
@@ -2251,6 +2268,7 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
preset.inherits().clear();
preset.alias.clear();
preset.renamed_from.clear();
preset.m_excluded_from.clear();
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": save preset %1% , with detach")%new_name;
}
//BBS: add lock logic for sync preset in background
@@ -2278,6 +2296,7 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
preset.vendor = nullptr;
preset.alias.clear();
preset.renamed_from.clear();
preset.m_excluded_from.clear();
preset.setting_id.clear();
if (detach) {
// Clear the link to the parent profile.
@@ -2525,6 +2544,17 @@ Preset* PresetCollection::find_preset(const std::string &name, bool first_visibl
first_visible_if_not_found ? &this->first_visible() : nullptr;
}
const Preset* PresetCollection::find_preset2(const std::string& name) const
{
auto preset = const_cast<PresetCollection*>(this)->find_preset(name, false, true);
if (preset == nullptr) {
auto _name = get_preset_name_renamed(name);
if(_name != nullptr)
preset = const_cast<PresetCollection*>(this)->find_preset(*_name, false, true);
}
return preset;
}
// Return index of the first visible preset. Certainly at least the '- default -' preset shall be visible.
size_t PresetCollection::first_visible_idx() const
{
@@ -2859,6 +2889,38 @@ void PresetCollection::update_map_alias_to_profile_name()
//std::sort(m_map_alias_to_profile_name.begin(), m_map_alias_to_profile_name.end(), [](auto &l, auto &r) { return l.first < r.first; });
}
void PresetCollection::update_library_profile_excluded_from()
{
// Orca: Collect all filament presets that has empty compatible_printers and belongs to the Orca Filament Library.
std::map<std::string, std::set<std::string>*> excluded_froms;
for (Preset& preset : m_presets) {
if (preset.vendor != nullptr && preset.vendor->name == PresetBundle::ORCA_FILAMENT_LIBRARY) {
// check if the preset has empty compatible_printers
const auto* compatible_printers = dynamic_cast<const ConfigOptionStrings*>(preset.config.option("compatible_printers"));
if (compatible_printers == nullptr || compatible_printers->values.empty())
excluded_froms[preset.alias] = &preset.m_excluded_from;
}
}
// Check all presets that has the same alias as the filament presets with empty compatible_printers in Orca Filament Library.
for (const Preset& preset : m_presets) {
if (preset.vendor == nullptr || preset.vendor->name == PresetBundle::ORCA_FILAMENT_LIBRARY)
continue;
const auto* compatible_printers = dynamic_cast<const ConfigOptionStrings*>(preset.config.option("compatible_printers"));
// All profiles in concrete vendor profile shouldn't have empty compatible_printers, but here we check it for safety.
if (compatible_printers == nullptr || compatible_printers->values.empty())
continue;
auto itr = excluded_froms.find(preset.alias);
if (itr != excluded_froms.end()) {
// Add the printer models to the excluded_from list.
for (const std::string& printer_name : compatible_printers->values) {
itr->second->insert(printer_name);
}
}
}
}
void PresetCollection::update_map_system_profile_renamed()
{
m_map_system_profile_renamed.clear();
+14 -1
View File
@@ -3,6 +3,7 @@
#include <deque>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <functional>
@@ -63,7 +64,8 @@
#define BBL_JSON_KEY_DEFAULT_MATERIALS "default_materials"
#define BBL_JSON_KEY_MODEL_ID "model_id"
//BBL: json path
// Orca extension
#define ORCA_JSON_KEY_RENAMED_FROM "renamed_from"
namespace Slic3r {
@@ -232,6 +234,11 @@ public:
// and to match the "inherits" field of user profiles with updated system profiles.
std::vector<std::string> renamed_from;
// Orca: maintain a list of printer models that are excluded from this preset, designed for filaments without compatible_printer defined
// (hence they are visible to all printer models by default) in Orca Filament Library. However, we might have speciliazed filament for
// certain printer models defined in the vendor profile as well, in this case we want to hide this generic preset for these printer models.
std::set<std::string> m_excluded_from;
//BBS
Semver version; // version of preset
std::string ini_str; // ini string of preset
@@ -595,6 +602,8 @@ public:
Preset* find_preset(const std::string &name, bool first_visible_if_not_found = false, bool real = false);
const Preset* find_preset(const std::string &name, bool first_visible_if_not_found = false) const
{ return const_cast<PresetCollection*>(this)->find_preset(name, first_visible_if_not_found); }
// Orca: find preset, if not found, keep searching in the renamed history
const Preset* find_preset2(const std::string &name) const;
size_t first_visible_idx() const;
// Return index of the first compatible preset. Certainly at least the '- default -' preset shall be compatible.
@@ -718,6 +727,10 @@ protected:
// Update m_map_system_profile_renamed from loaded system profiles.
void update_map_system_profile_renamed();
// Orca: update m_excluded_from loaded system profiles.
void update_library_profile_excluded_from();
void set_custom_preset_alias(Preset &preset);
private:
File diff suppressed because it is too large Load Diff
+15 -8
View File
@@ -160,7 +160,12 @@ public:
// and the system profiles will point to the VendorProfile instances owned by PresetBundle::vendors.
VendorMap vendors;
struct ObsoletePresets {
// Orca: for OrcaFilamentLibrary
std::map<std::string, DynamicPrintConfig> m_config_maps;
std::map<std::string, std::string> m_filament_id_maps;
struct ObsoletePresets
{
std::vector<std::string> prints;
std::vector<std::string> sla_prints;
std::vector<std::string> filaments;
@@ -212,9 +217,9 @@ public:
// Don't do any config substitutions when loading a system profile, perform and report substitutions otherwise.
/*std::pair<PresetsConfigSubstitutions, size_t> load_configbundle(
const std::string &path, LoadConfigBundleAttributes flags, ForwardCompatibilitySubstitutionRule compatibility_rule);*/
//BBS: add json related logic
//Orca: load config bundle from json, pass the base bundle to support cross vendor inheritance
std::pair<PresetsConfigSubstitutions, size_t> load_vendor_configs_from_json(
const std::string &path, const std::string &vendor_name, LoadConfigBundleAttributes flags, ForwardCompatibilitySubstitutionRule compatibility_rule);
const std::string &path, const std::string &vendor_name, LoadConfigBundleAttributes flags, ForwardCompatibilitySubstitutionRule compatibility_rule, const PresetBundle* base_bundle = nullptr);
// Export a config bundle file containing all the presets and the names of the active presets.
//void export_configbundle(const std::string &path, bool export_system_settings = false, bool export_physical_printers = false);
@@ -261,11 +266,13 @@ public:
std::pair<PresetsConfigSubstitutions, std::string> load_system_filaments_json(ForwardCompatibilitySubstitutionRule compatibility_rule);
VendorProfile get_custom_vendor_models() const;
//BBS: add BBL as default
static const char *BBL_BUNDLE;
static const char *BBL_DEFAULT_PRINTER_MODEL;
static const char *BBL_DEFAULT_PRINTER_VARIANT;
static const char *BBL_DEFAULT_FILAMENT;
//orca: add 'custom' as default
static const char *ORCA_DEFAULT_BUNDLE;
static const char *ORCA_DEFAULT_PRINTER_MODEL;
static const char *ORCA_DEFAULT_PRINTER_VARIANT;
static const char *ORCA_DEFAULT_FILAMENT;
static const char *ORCA_FILAMENT_LIBRARY;
static std::array<Preset::Type, 3> types_list(PrinterTechnology pt) {
if (pt == ptFFF)
+71 -11
View File
@@ -123,6 +123,15 @@ static t_config_enum_values s_keys_map_FuzzySkinType {
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(FuzzySkinType)
static t_config_enum_values s_keys_map_NoiseType {
{ "classic", int(NoiseType::Classic) },
{ "perlin", int(NoiseType::Perlin) },
{ "billow", int(NoiseType::Billow) },
{ "ridgedmulti", int(NoiseType::RidgedMulti) },
{ "voronoi", int(NoiseType::Voronoi) }
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(NoiseType)
static t_config_enum_values s_keys_map_InfillPattern {
{ "concentric", ipConcentric },
{ "zig-zag", ipRectilinear },
@@ -1262,38 +1271,38 @@ void PrintConfigDef::init_fff_params()
def = this->add("compatible_printers", coStrings);
def->label = L("Compatible machine");
def->mode = comDevelop;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionStrings());
def->cli = ConfigOptionDef::nocli;
//BBS.
def = this->add("upward_compatible_machine", coStrings);
def->label = L("upward compatible machine");
def->mode = comDevelop;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionStrings());
def->cli = ConfigOptionDef::nocli;
def = this->add("compatible_printers_condition", coString);
def->label = L("Compatible machine condition");
//def->tooltip = L("A boolean expression using the configuration values of an active printer profile. "
// "If this expression evaluates to true, this profile is considered compatible "
// "with the active printer profile.");
def->mode = comDevelop;
def->tooltip = L("A boolean expression using the configuration values of an active printer profile. "
"If this expression evaluates to true, this profile is considered compatible "
"with the active printer profile.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionString());
def->cli = ConfigOptionDef::nocli;
def = this->add("compatible_prints", coStrings);
def->label = L("Compatible process profiles");
def->mode = comDevelop;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionStrings());
def->cli = ConfigOptionDef::nocli;
def = this->add("compatible_prints_condition", coString);
def->label = L("Compatible process profiles condition");
//def->tooltip = L("A boolean expression using the configuration values of an active print profile. "
// "If this expression evaluates to true, this profile is considered compatible "
// "with the active print profile.");
def->mode = comDevelop;
def->tooltip = L("A boolean expression using the configuration values of an active print profile. "
"If this expression evaluates to true, this profile is considered compatible "
"with the active print profile.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionString());
def->cli = ConfigOptionDef::nocli;
@@ -2632,6 +2641,57 @@ void PrintConfigDef::init_fff_params()
def->mode = comSimple;
def->set_default_value(new ConfigOptionBool(0));
def = this->add("fuzzy_skin_noise_type", coEnum);
def->label = L("Fuzzy skin noise type");
def->category = L("Others");
def->tooltip = L("Noise type to use for fuzzy skin generation.\n"
"Classic: Classic uniform random noise.\n"
"Perlin: Perlin noise, which gives a more consistent texture.\n"
"Billow: Similar to perlin noise, but clumpier.\n"
"Ridged Multifractal: Ridged noise with sharp, jagged features. Creates marble-like textures.\n"
"Voronoi: Divides the surface into voronoi cells, and displaces each one by a random amount. Creates a patchwork texture.");
def->enum_keys_map = &ConfigOptionEnum<NoiseType>::get_enum_values();
def->enum_values.push_back("classic");
def->enum_values.push_back("perlin");
def->enum_values.push_back("billow");
def->enum_values.push_back("ridgedmulti");
def->enum_values.push_back("voronoi");
def->enum_labels.push_back(L("Classic"));
def->enum_labels.push_back(L("Perlin"));
def->enum_labels.push_back(L("Billow"));
def->enum_labels.push_back(L("Ridged Multifractal"));
def->enum_labels.push_back(L("Voronoi"));
def->mode = comSimple;
def->set_default_value(new ConfigOptionEnum<NoiseType>(NoiseType::Classic));
def = this->add("fuzzy_skin_scale", coFloat);
def->label = L("Fuzzy skin feature size");
def->category = L("Others");
def->tooltip = L("The base size of the coherent noise features, in mm. Higher values will result in larger features.");
def->sidetext = L("mm");
def->min = 0.1;
def->max = 500;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(1.0));
def = this->add("fuzzy_skin_octaves", coInt);
def->label = L("Fuzzy Skin Noise Octaves");
def->category = L("Others");
def->tooltip = L("The number of octaves of coherent noise to use. Higher values increase the detail of the noise, but also increase computation time.");
def->min = 1;
def->max = 10;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionInt(4));
def = this->add("fuzzy_skin_persistence", coFloat);
def->label = L("Fuzzy skin noise persistence");
def->category = L("Others");
def->tooltip = L("The decay rate for higher octaves of the coherent noise. Lower values will result in smoother noise.");
def->min = 0.01;
def->max = 1;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0.5));
def = this->add("filter_out_gap_fill", coFloat);
def->label = L("Filter out tiny gaps");
def->category = L("Layers and Perimeters");
+13
View File
@@ -41,6 +41,14 @@ enum class FuzzySkinType {
AllWalls,
};
enum class NoiseType {
Classic,
Perlin,
Billow,
RidgedMulti,
Voronoi,
};
enum PrintHostType {
htPrusaLink, htPrusaConnect, htOctoPrint, htDuet, htFlashAir, htAstroBox, htRepetier, htMKS, htESP3D, htCrealityPrint, htObico, htFlashforge, htSimplyPrint
};
@@ -402,6 +410,7 @@ static std::string get_bed_temp_1st_layer_key(const BedType type)
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(PrinterTechnology)
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(GCodeFlavor)
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(FuzzySkinType)
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(NoiseType)
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(InfillPattern)
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(IroningType)
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(SlicingMode)
@@ -917,6 +926,10 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloat, fuzzy_skin_thickness))
((ConfigOptionFloat, fuzzy_skin_point_distance))
((ConfigOptionBool, fuzzy_skin_first_layer))
((ConfigOptionEnum<NoiseType>, fuzzy_skin_noise_type))
((ConfigOptionFloat, fuzzy_skin_scale))
((ConfigOptionInt, fuzzy_skin_octaves))
((ConfigOptionFloat, fuzzy_skin_persistence))
((ConfigOptionFloat, gap_infill_speed))
((ConfigOptionInt, sparse_infill_filament))
((ConfigOptionFloatOrPercent, sparse_infill_line_width))
+4
View File
@@ -1117,6 +1117,10 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "fuzzy_skin_thickness"
|| opt_key == "fuzzy_skin_point_distance"
|| opt_key == "fuzzy_skin_first_layer"
|| opt_key == "fuzzy_skin_noise_type"
|| opt_key == "fuzzy_skin_scale"
|| opt_key == "fuzzy_skin_octaves"
|| opt_key == "fuzzy_skin_persistence"
|| opt_key == "detect_overhang_wall"
|| opt_key == "overhang_reverse"
|| opt_key == "overhang_reverse_internal_only"
+2 -1
View File
@@ -616,7 +616,8 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SLIC3R_GUI_SOURCES})
encoding_check(libslic3r_gui)
target_link_libraries(libslic3r_gui libslic3r cereal::cereal imgui imguizmo minilzo GLEW::GLEW OpenGL::GL hidapi ${wxWidgets_LIBRARIES} glfw libcurl OpenSSL::SSL OpenSSL::Crypto)
find_package(libnoise REQUIRED)
target_link_libraries(libslic3r_gui libslic3r cereal::cereal imgui imguizmo minilzo GLEW::GLEW OpenGL::GL hidapi ${wxWidgets_LIBRARIES} glfw libcurl OpenSSL::SSL OpenSSL::Crypto noise::noise)
if (MSVC)
target_link_libraries(libslic3r_gui Setupapi.lib)
+2 -2
View File
@@ -246,7 +246,7 @@ void Bed3D::Axes::render()
//BBS: add part plate logic
bool Bed3D::set_shape(const Pointfs& printable_area, const double printable_height, const std::string& custom_model, bool force_as_custom,
const Vec2d position, bool with_reset)
const Vec2d& position, bool with_reset)
{
/*auto check_texture = [](const std::string& texture) {
boost::system::error_code ec; // so the exists call does not throw (e.g. after a permission problem)
@@ -612,7 +612,7 @@ void Bed3D::render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, co
void Bed3D::update_model_offset()
{
// move the model so that its origin (0.0, 0.0, 0.0) goes into the bed shape center and a bit down to avoid z-fighting with the texture quad
Vec3d shift = m_extended_bounding_box.center();
Vec3d shift = m_build_volume.bounding_volume().center();
shift(2) = -0.03;
Vec3d* model_offset_ptr = const_cast<Vec3d*>(&m_model_offset);
*model_offset_ptr = shift;
+1 -1
View File
@@ -121,7 +121,7 @@ public:
// as this class does not use it, thus there is no need to update the UI.
// BBS
bool set_shape(const Pointfs& printable_area, const double printable_height, const std::string& custom_model, bool force_as_custom = false,
const Vec2d position = Vec2d::Zero(), bool with_reset = true);
const Vec2d& position = Vec2d::Zero(), bool with_reset = true);
void set_position(Vec2d& position);
void set_axes_mode(bool origin);
+18 -18
View File
@@ -219,7 +219,7 @@ AboutDialog::AboutDialog()
std::string icon_path = (boost::format("%1%/images/OrcaSlicerTitle.ico") % resources_dir()).str();
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
wxPanel *m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(560), FromDIP(237)), wxTAB_TRAVERSAL);
wxPanel* m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(560), FromDIP(125)), wxTAB_TRAVERSAL);
wxBoxSizer *panel_versizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *vesizer = new wxBoxSizer(wxVERTICAL);
@@ -232,8 +232,10 @@ AboutDialog::AboutDialog()
main_sizer->Add(m_panel, 1, wxEXPAND | wxALL, 0);
main_sizer->Add(ver_sizer, 0, wxEXPAND | wxALL, 0);
bool is_dark = wxGetApp().app_config->get("dark_color_mode") == "1";
// logo
m_logo_bitmap = ScalableBitmap(this, "OrcaSlicer_about", 250);
m_logo_bitmap = ScalableBitmap(this, is_dark ? "OrcaSlicer_about" : "OrcaSlicer_about_dark", FromDIP(125));
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bitmap.bmp(), wxDefaultPosition,wxDefaultSize, 0);
m_logo->SetSizer(vesizer);
@@ -242,33 +244,31 @@ AboutDialog::AboutDialog()
// version
{
auto _build_string_font = Label::Body_10;
auto _build_string_font = Label::Body_12;
// _build_string_font.SetStyle(wxFONTSTYLE_ITALIC);
vesizer->Add(0, FromDIP(165), 1, wxEXPAND, FromDIP(5));
auto version_string = _L("Orca Slicer") + " " + std::string(SoftFever_VERSION);
vesizer->Add(0, 0, 1, wxEXPAND, FromDIP(5));
auto version_string = std::string(SoftFever_VERSION); // _L("Orca Slicer ") + " " + std::string(SoftFever_VERSION);
wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize);
wxStaticText* credits_string = new wxStaticText(this, wxID_ANY,
wxString::Format("Build %s.\nOrcaSlicer is based on PrusaSlicer and BambuStudio",
std::string(GIT_COMMIT_HASH)),
wxDefaultPosition, wxDefaultSize);
wxStaticText* credits_string = new wxStaticText(this, wxID_ANY, wxString::Format("Build %s", std::string(GIT_COMMIT_HASH)), wxDefaultPosition, wxDefaultSize);
credits_string->SetFont(_build_string_font);
wxFont version_font = GetFont();
#ifdef __WXMSW__
version_font.SetPointSize(version_font.GetPointSize()-1);
version_font.SetPointSize(version_font.GetPointSize()-1);
#else
version_font.SetPointSize(11);
#endif
version_font.SetPointSize(FromDIP(16));
version_font.SetPointSize(FromDIP(20));
version->SetFont(version_font);
version->SetForegroundColour(wxColour("#FFFFFD"));
credits_string->SetForegroundColour(wxColour("#FFFFFD"));
version->SetBackgroundColour(wxColour("#4d4d4d"));
credits_string->SetBackgroundColour(wxColour("#4d4d4d"));
version->SetForegroundColour(wxColour("#949494"));
credits_string->SetForegroundColour(wxColour("#949494"));
version->SetBackgroundColour(wxColour("#FFFFFF"));
credits_string->SetBackgroundColour(wxColour("#FFFFFF"));
vesizer->Add(version, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, FromDIP(5));
vesizer->Add(credits_string, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, FromDIP(5));
// #if BBL_INTERNAL_TESTING
vesizer->Add(version, 0, wxRIGHT | wxALIGN_RIGHT, FromDIP(20));
vesizer->AddSpacer(FromDIP(5));
vesizer->Add(credits_string, 0, wxRIGHT | wxALIGN_RIGHT, FromDIP(20));
// #if BBL_INTERNAL_TESTING
// wxString build_time = wxString::Format("Build Time: %s", std::string(SLIC3R_BUILD_TIME));
// wxStaticText* build_time_text = new wxStaticText(this, wxID_ANY, build_time, wxDefaultPosition, wxDefaultSize);
// build_time_text->SetForegroundColour(wxColour("#FFFFFE"));
+6 -1
View File
@@ -708,9 +708,14 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
toggle_line("support_interface_not_for_body",config->opt_int("support_interface_filament")&&!config->opt_int("support_filament"));
bool has_fuzzy_skin = (config->opt_enum<FuzzySkinType>("fuzzy_skin") != FuzzySkinType::None);
for (auto el : { "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer"})
for (auto el : { "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer", "fuzzy_skin_noise_type"})
toggle_line(el, has_fuzzy_skin);
NoiseType fuzzy_skin_noise_type = config->opt_enum<NoiseType>("fuzzy_skin_noise_type");
toggle_line("fuzzy_skin_scale", has_fuzzy_skin && fuzzy_skin_noise_type != NoiseType::Classic);
toggle_line("fuzzy_skin_octaves", has_fuzzy_skin && fuzzy_skin_noise_type != NoiseType::Classic && fuzzy_skin_noise_type != NoiseType::Voronoi);
toggle_line("fuzzy_skin_persistence", has_fuzzy_skin && (fuzzy_skin_noise_type == NoiseType::Perlin || fuzzy_skin_noise_type == NoiseType::Billow));
bool have_arachne = config->opt_enum<PerimeterGeneratorType>("wall_generator") == PerimeterGeneratorType::Arachne;
for (auto el : { "wall_transition_length", "wall_transition_filter_deviation", "wall_transition_angle",
"min_feature_size", "min_length_factor", "min_bead_width", "wall_distribution_count", "initial_layer_min_bead_width"})
+16 -17
View File
@@ -123,18 +123,18 @@ BundleMap BundleMap::load()
const auto vendor_dir = (boost::filesystem::path(Slic3r::data_dir()) / PRESET_SYSTEM_DIR).make_preferred();
const auto rsrc_vendor_dir = (boost::filesystem::path(resources_dir()) / "profiles").make_preferred();
//BBS: add BBL as default
//BBS: add json logic for vendor bundle
auto bbl_bundle_path = (vendor_dir / PresetBundle::BBL_BUNDLE).replace_extension(".json");
auto bbl_bundle_rsrc = false;
if (!boost::filesystem::exists(bbl_bundle_path)) {
bbl_bundle_path = (rsrc_vendor_dir / PresetBundle::BBL_BUNDLE).replace_extension(".json");
bbl_bundle_rsrc = true;
//Orca: add custom as default
//Orca: add json logic for vendor bundle
auto orca_bundle_path = (vendor_dir / PresetBundle::ORCA_DEFAULT_BUNDLE).replace_extension(".json");
auto orca_bundle_rsrc = false;
if (!boost::filesystem::exists(orca_bundle_path)) {
orca_bundle_path = (rsrc_vendor_dir / PresetBundle::ORCA_DEFAULT_BUNDLE).replace_extension(".json");
orca_bundle_rsrc = true;
}
{
Bundle bbl_bundle;
if (bbl_bundle.load(std::move(bbl_bundle_path), bbl_bundle_rsrc, true))
res.emplace(PresetBundle::BBL_BUNDLE, std::move(bbl_bundle));
if (bbl_bundle.load(std::move(orca_bundle_path), orca_bundle_rsrc, true))
res.emplace(PresetBundle::ORCA_DEFAULT_BUNDLE, std::move(bbl_bundle));
}
// Load the other bundles in the datadir/vendor directory
@@ -163,10 +163,10 @@ BundleMap BundleMap::load()
Bundle& BundleMap::bbl_bundle()
{
//BBS: add BBL as default
auto it = find(PresetBundle::BBL_BUNDLE);
//Orca: add custom as default
auto it = find(PresetBundle::ORCA_DEFAULT_BUNDLE);
if (it == end()) {
throw Slic3r::RuntimeError("ConfigWizard: Internal error in BundleMap: BBL_BUNDLE not loaded");
throw Slic3r::RuntimeError("ConfigWizard: Internal error in BundleMap: ORCA_DEFAULT_BUNDLE not loaded");
}
return it->second;
@@ -625,12 +625,11 @@ std::set<std::string> PagePrinters::get_selected_models()
void PagePrinters::set_run_reason(ConfigWizard::RunReason run_reason)
{
//BBS: add BBL as default
//Orca: add custom as default
if (is_primary_printer_page
&& (run_reason == ConfigWizard::RR_DATA_EMPTY || run_reason == ConfigWizard::RR_DATA_LEGACY)
&& printer_pickers.size() > 0
&& printer_pickers[0]->vendor_id == PresetBundle::BBL_BUNDLE) {
//BBS: select alll bbs machine by default
&& printer_pickers[0]->vendor_id == PresetBundle::ORCA_DEFAULT_BUNDLE) {
//printer_pickers[0]->select_one(0, true);
printer_pickers[0]->select_all(true);
}
@@ -1941,8 +1940,8 @@ void ConfigWizard::priv::create_3rdparty_pages()
{
for (const auto &pair : bundles) {
const VendorProfile *vendor = pair.second.vendor_profile;
//BBS: add BBL as default
if (vendor->id == PresetBundle::BBL_BUNDLE) { continue; }
//Orca: add custom as default
if (vendor->id == PresetBundle::ORCA_DEFAULT_BUNDLE) { continue; }
bool is_fff_technology = false;
bool is_sla_technology = false;
+4 -6
View File
@@ -845,7 +845,7 @@ void GCodeViewer::init(ConfigOptionMode mode, PresetBundle* preset_bundle)
}
if (filename.empty()) {
filename = preset_bundle->get_hotend_model_for_printer_model(PresetBundle::BBL_DEFAULT_PRINTER_MODEL);
filename = preset_bundle->get_hotend_model_for_printer_model(PresetBundle::ORCA_DEFAULT_PRINTER_MODEL);
}
}
}
@@ -1056,8 +1056,6 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
set_view_type(EViewType::ColorPrint);
}
m_fold = false;
bool only_gcode_3mf = false;
PartPlate* current_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate();
bool current_has_print_instances = current_plate->has_printable_instances();
@@ -4644,15 +4642,15 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGui::SameLine();
std::wstring btn_name;
if (m_fold)
btn_name = ImGui::UnfoldButtonIcon + boost::nowide::widen(std::string(""));
btn_name = ImGui::UnfoldButtonIcon;
else
btn_name = ImGui::FoldButtonIcon + boost::nowide::widen(std::string(""));
btn_name = ImGui::FoldButtonIcon;
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.0f, 0.59f, 0.53f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.0f, 0.59f, 0.53f, 0.78f));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f));
//ImGui::PushItemWidth(
float button_width = ImGui::CalcTextSize(into_u8(btn_name).c_str()).x;
float button_width = 34.0f;
if (ImGui::Button(into_u8(btn_name).c_str(), ImVec2(button_width, 0))) {
m_fold = !m_fold;
}
+1 -1
View File
@@ -4782,7 +4782,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
m_sync_update_thread = Slic3r::create_thread(
[this, progressFn, cancelFn, finishFn, t = std::weak_ptr<int>(m_user_sync_token)] {
// get setting list, update setting list
std::string version = preset_bundle->get_vendor_profile_version(PresetBundle::BBL_BUNDLE).to_string();
std::string version = preset_bundle->get_vendor_profile_version(PresetBundle::ORCA_DEFAULT_BUNDLE).to_string();
int ret = m_agent->get_setting_list2(version, [this](auto info) {
auto type = info[BBL_JSON_KEY_TYPE];
auto name = info[BBL_JSON_KEY_NAME];
-5
View File
@@ -692,11 +692,6 @@ public:
m_height_limit_mode = mode;
}
// SoftFever
const std::string& get_logo_texture_filename() const {
return m_logo_texture_filename;
}
int get_curr_plate_index() const { return m_current_plate; }
PartPlate* get_curr_plate() { return m_plate_list[m_current_plate]; }
const PartPlate* get_curr_plate() const { return m_plate_list[m_current_plate]; }
+4 -3
View File
@@ -8167,13 +8167,14 @@ void Plater::priv::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_ar
float prev_height_lid, prev_height_rod;
partplate_list.get_height_limits(prev_height_lid, prev_height_rod);
auto prev_logo = partplate_list.get_logo_texture_filename();
double height_to_lid = config->opt_float("extruder_clearance_height_to_lid");
double height_to_rod = config->opt_float("extruder_clearance_height_to_rod");
auto custom_bed_texture = config->opt_string("bed_custom_texture");
Pointfs prev_exclude_areas = partplate_list.get_exclude_area();
new_shape |= (height_to_lid != prev_height_lid) || (height_to_rod != prev_height_rod) || (prev_exclude_areas != exclude_areas) || (prev_logo != custom_bed_texture);
new_shape |= (height_to_lid != prev_height_lid) || (height_to_rod != prev_height_rod) || (prev_exclude_areas != exclude_areas);
if (!new_shape && partplate_list.get_logo_texture_filename() != custom_texture) {
partplate_list.update_logo_texture_filename(custom_texture);
}
if (new_shape) {
if (view3D) view3D->bed_shape_changed();
if (preview) preview->bed_shape_changed();
+12 -11
View File
@@ -2352,8 +2352,12 @@ page = add_options_page(L("Others"), "custom-gcode_other"); // ORCA: icon only v
optgroup->append_single_option_line("timelapse_type", "Timelapse");
optgroup->append_single_option_line("fuzzy_skin");
optgroup->append_single_option_line("fuzzy_skin_noise_type");
optgroup->append_single_option_line("fuzzy_skin_point_distance");
optgroup->append_single_option_line("fuzzy_skin_thickness");
optgroup->append_single_option_line("fuzzy_skin_scale");
optgroup->append_single_option_line("fuzzy_skin_octaves");
optgroup->append_single_option_line("fuzzy_skin_persistence");
optgroup->append_single_option_line("fuzzy_skin_first_layer");
optgroup = page->new_optgroup(L("G-code output"), L"param_gcode");
@@ -2382,7 +2386,6 @@ page = add_options_page(L("Others"), "custom-gcode_other"); // ORCA: icon only v
option.opt.height = 25;//250;
optgroup->append_single_option_line(option);
#if 1
page = add_options_page(L("Dependencies"), "custom-gcode_advanced");
optgroup = page->new_optgroup(L("Profile dependencies"));
@@ -2395,7 +2398,6 @@ page = add_options_page(L("Others"), "custom-gcode_other"); // ORCA: icon only v
optgroup->append_single_option_line(option);
build_preset_description_line(optgroup.get());
#endif
}
// Reload current config (aka presets->edited_preset->config) into the UI fields.
@@ -3528,14 +3530,6 @@ void TabFilament::build()
optgroup->append_single_option_line("filament_multitool_ramming_volume");
optgroup->append_single_option_line("filament_multitool_ramming_flow");
page = add_options_page(L("Notes"), "custom-gcode_note"); // ORCA: icon only visible on placeholders
optgroup = page->new_optgroup(L("Notes"),"note", 0);
optgroup->label_width = 0;
option = optgroup->get_option("filament_notes");
option.opt.full_width = true;
option.opt.height = notes_field_height;// 250;
optgroup->append_single_option_line(option);
#if 1
page = add_options_page(L("Dependencies"), "advanced");
optgroup = page->new_optgroup(L("Profile dependencies"));
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@@ -3554,8 +3548,15 @@ void TabFilament::build()
option.opt.full_width = true;
optgroup->append_single_option_line(option);
page = add_options_page(L("Notes"), "custom-gcode_note"); // ORCA: icon only visible on placeholders
optgroup = page->new_optgroup(L("Notes"),"note", 0);
optgroup->label_width = 0;
option = optgroup->get_option("filament_notes");
option.opt.full_width = true;
option.opt.height = notes_field_height;// 250;
optgroup->append_single_option_line(option);
//build_preset_description_line(optgroup.get());
#endif
}
// Reload current config (aka presets->edited_preset->config) into the UI fields.
+50 -354
View File
@@ -1,9 +1,13 @@
#include "WebGuideDialog.hpp"
#include "ConfigWizard.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/iostreams/detail/select.hpp>
#include <string.h>
#include "I18N.hpp"
#include "libslic3r/AppConfig.hpp"
#include "libslic3r/PresetBundle.hpp"
#include "slic3r/GUI/wxExtensions.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "libslic3r_version.h"
@@ -576,13 +580,6 @@ void GuideFrame::OnError(wxWebViewEvent &evt)
void GuideFrame::OnScriptResponseMessage(wxCommandEvent &WXUNUSED(evt))
{
// if (!m_response_js.empty())
//{
// RunScript(m_response_js);
//}
// RunScript("This is a message to Web!");
// RunScript("postMessage(\"AABBCCDD\");");
}
bool GuideFrame::IsFirstUse()
@@ -592,30 +589,12 @@ bool GuideFrame::IsFirstUse()
if (strVal == "1")
return false;
if (bbl_bundle_rsrc == true)
if (orca_bundle_rsrc == true)
return true;
return true;
}
/*int GuideFrame::CopyDir(const boost::filesystem::path &from_dir, const boost::filesystem::path &to_dir)
{
if (!boost::filesystem::is_directory(from_dir)) return -1;
// i assume to_dir.parent surely exists
if (!boost::filesystem::is_directory(to_dir)) boost::filesystem::create_directory(to_dir);
for (auto &dir_entry : boost::filesystem::directory_iterator(from_dir)) {
if (!boost::filesystem::is_directory(dir_entry.path())) {
std::string em;
CopyFileResult cfr = copy_file(dir_entry.path().string(), (to_dir / dir_entry.path().filename()).string(), em, false);
if (cfr != SUCCESS) { BOOST_LOG_TRIVIAL(error) << "Error when copying files from " << from_dir << " to " << to_dir << ": " << em; }
} else {
CopyDir(dir_entry.path(), to_dir / dir_entry.path().filename());
}
}
return 0;
}*/
int GuideFrame::SaveProfile()
{
// SoftFever: don't collect info
@@ -633,77 +612,6 @@ int GuideFrame::SaveProfile()
m_MainPtr->app_config->save();
//Load BBS Conf
/*wxString strConfPath = wxGetApp().app_config->config_path();
json jCfg;
std::ifstream(w2s(strConfPath)) >> jCfg;
//model
jCfg["models"] = json::array();
int nM = m_ProfileJson["model"].size();
int nModelChoose = 0;
for (int m = 0; m < nM; m++)
{
json amodel = m_ProfileJson["model"][m];
amodel["nozzle_diameter"] = amodel["nozzle_selected"];
amodel.erase("nozzle_selected");
amodel.erase("preview");
amodel.erase("sub_path");
amodel.erase("cover");
amodel.erase("materials");
std::string ss = amodel["nozzle_diameter"];
if (ss.compare("") != 0) {
nModelChoose++;
jCfg["models"].push_back(amodel);
}
}
if (nModelChoose == 0)
jCfg.erase("models");
if (nModelChoose > 0) {
// filament
jCfg["filaments"] = json::array();
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it) {
if (it.value()["selected"] == 1) { jCfg["filaments"].push_back(it.key()); }
}
// Preset
jCfg["presets"]["filaments"] = json::array();
jCfg["presets"]["filaments"].push_back(jCfg["filaments"][0]);
std::string PresetMachine = m_ProfileJson["machine"][0]["name"];
jCfg["presets"]["machine"] = PresetMachine;
int nTotal = m_ProfileJson["process"].size();
int nSet = nTotal / 2;
if (nSet > 0) nSet--;
std::string sMode = m_ProfileJson["process"][nSet]["name"];
jCfg["presets"]["process"] = sMode;
} else {
jCfg["presets"]["filaments"] = json::array();
jCfg["presets"]["filaments"].push_back("Default Filament");
jCfg["presets"]["machine"] = "Default Printer";
jCfg["presets"]["process"] = "Default Setting";
}
std::string sOut = jCfg.dump(4, ' ', false);
std::ofstream output_file(w2s(strConfPath));
output_file << sOut;
output_file.close();
//Copy Profiles
if (bbl_bundle_rsrc)
{
CopyDir(rsrc_vendor_dir,vendor_dir);
}*/
std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "before save to app_config: "<< std::endl<<strAll;
@@ -881,11 +789,11 @@ bool GuideFrame::apply_config(AppConfig *app_config, PresetBundle *preset_bundle
variant.clear();
return std::string();
};
// Prusa printers are considered first, then 3rd party.
if (preferred_model = get_preferred_printer_model(PresetBundle::BBL_BUNDLE, preferred_variant);
// Orca "custom" printers are considered first, then 3rd party.
if (preferred_model = get_preferred_printer_model(PresetBundle::ORCA_DEFAULT_BUNDLE, preferred_variant);
preferred_model.empty()) {
for (const auto& bundle : enabled_vendors) {
if (bundle.first == PresetBundle::BBL_BUNDLE) { continue; }
if (bundle.first == PresetBundle::ORCA_DEFAULT_BUNDLE) { continue; }
if (preferred_model = get_preferred_printer_model(bundle.first, preferred_variant);
!preferred_model.empty())
break;
@@ -962,10 +870,10 @@ bool GuideFrame::run()
//we install the default here
bool apply_keeped_changes = false;
//clear filament section and use default materials
app.app_config->set_variant(PresetBundle::BBL_BUNDLE,
PresetBundle::BBL_DEFAULT_PRINTER_MODEL, PresetBundle::BBL_DEFAULT_PRINTER_VARIANT, "true");
app.app_config->set_variant(PresetBundle::ORCA_DEFAULT_BUNDLE,
PresetBundle::ORCA_DEFAULT_PRINTER_MODEL, PresetBundle::ORCA_DEFAULT_PRINTER_VARIANT, "true");
app.app_config->clear_section(AppConfig::SECTION_FILAMENTS);
app.preset_bundle->load_selections(*app.app_config, {PresetBundle::BBL_DEFAULT_PRINTER_MODEL, PresetBundle::BBL_DEFAULT_PRINTER_VARIANT, PresetBundle::BBL_DEFAULT_FILAMENT, std::string()});
app.preset_bundle->load_selections(*app.app_config, {PresetBundle::ORCA_DEFAULT_PRINTER_MODEL, PresetBundle::ORCA_DEFAULT_PRINTER_VARIANT, PresetBundle::ORCA_DEFAULT_FILAMENT, std::string()});
app.app_config->set_legacy_datadir(false);
app.update_mode();
@@ -1025,6 +933,8 @@ int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList,
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " Before Format Inherits Path: VendorDirectory - " << VendorDirectory << ", sub_path - " << FPath;
wxString strNewFile = wxString::Format("%s%c%s", wxString(VendorDirectory.c_str(), wxConvUTF8), boost::filesystem::path::preferred_separator, FPath);
boost::filesystem::path inherits_path(w2s(strNewFile));
if (!boost::filesystem::exists(inherits_path))
inherits_path = (boost::filesystem::path(m_OrcaFilaLibPath) / boost::filesystem::path(FPath)).make_preferred();
//boost::filesystem::path nf(strNewFile.c_str());
if (boost::filesystem::exists(inherits_path))
@@ -1066,31 +976,7 @@ int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList,
int GuideFrame::LoadProfile()
{
try {
//wxString ExePath = boost::dll::program_location().parent_path().string();
//wxString TargetFolder = ExePath + "\\resources\\profiles\\";
//wxString TargetFolderSearch = ExePath + "\\resources\\profiles\\*.json";
//intptr_t handle;
//_finddata_t findData;
//handle = _findfirst(TargetFolderSearch.mb_str(), &findData); // ???????????
//if (handle == -1) { return -1; }
//do {
// if (findData.attrib & _A_SUBDIR && strcmp(findData.name, ".") == 0 && strcmp(findData.name, "..") == 0) // ??????????"."?".."
// {
// // cout << findData.name << "\t<dir>\n";
// } else {
// wxString strVendor = wxString(findData.name).BeforeLast('.');
// LoadProfileFamily(strVendor, TargetFolder + findData.name);
// }
//} while (_findnext(handle, &findData) == 0); // ???????????
// BBS: change directories by design
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", will load config from %1%.") % bbl_bundle_path;
m_ProfileJson = json::parse("{}");
//m_ProfileJson["configpath"] = Slic3r::data_dir();
m_ProfileJson["model"] = json::array();
m_ProfileJson["machine"] = json::object();
m_ProfileJson["filament"] = json::object();
@@ -1099,76 +985,63 @@ int GuideFrame::LoadProfile()
vendor_dir = (boost::filesystem::path(Slic3r::data_dir()) / PRESET_SYSTEM_DIR ).make_preferred();
rsrc_vendor_dir = (boost::filesystem::path(resources_dir()) / "profiles").make_preferred();
// BBS: add BBL as default
// BBS: add json logic for vendor bundle
auto bbl_bundle_path = vendor_dir;
bbl_bundle_rsrc = false;
if (!boost::filesystem::exists((vendor_dir / PresetBundle::BBL_BUNDLE).replace_extension(".json"))) {
bbl_bundle_path = rsrc_vendor_dir;
bbl_bundle_rsrc = true;
}
// Orca: add custom as default
// Orca: add json logic for vendor bundle
orca_bundle_rsrc = true;
// intptr_t handle;
//_finddata_t findData;
// search if there exists a .json file in vendor_dir folder, if exists, set orca_bundle_rsrc to false
for (const auto& entry : boost::filesystem::directory_iterator(vendor_dir)) {
if (!boost::filesystem::is_directory(entry) && boost::iequals(entry.path().extension().string(), ".json") && !boost::iequals(entry.path().stem().string(), PresetBundle::ORCA_FILAMENT_LIBRARY)) {
orca_bundle_rsrc = false;
break;
}
}
//handle = _findfirst((bbl_bundle_path / "*.json").make_preferred().string().c_str(), &findData); // ???????????
// if (handle == -1) { return -1; }
// load the default filament library first
std::set<std::string> loaded_vendors;
auto filament_library_name = boost::filesystem::path(PresetBundle::ORCA_FILAMENT_LIBRARY).replace_extension(".json");
if (boost::filesystem::exists(vendor_dir / filament_library_name)) {
LoadProfileFamily(PresetBundle::ORCA_FILAMENT_LIBRARY, (vendor_dir / filament_library_name).string());
m_OrcaFilaLibPath = (vendor_dir / PresetBundle::ORCA_FILAMENT_LIBRARY).string();
} else {
LoadProfileFamily(PresetBundle::ORCA_FILAMENT_LIBRARY, (rsrc_vendor_dir / filament_library_name).string());
m_OrcaFilaLibPath = (rsrc_vendor_dir / PresetBundle::ORCA_FILAMENT_LIBRARY).string();
}
loaded_vendors.insert(PresetBundle::ORCA_FILAMENT_LIBRARY);
// do {
// if (findData.attrib & _A_SUBDIR && strcmp(findData.name, ".") == 0 && strcmp(findData.name, "..") == 0) // ??????????"."?".."
// {
// // cout << findData.name << "\t<dir>\n";
// } else {
// wxString strVendor = wxString(findData.name).BeforeLast('.');
// LoadProfileFamily(w2s(strVendor), vendor_dir.make_preferred().string() + "\\"+ findData.name);
// }
//} while (_findnext(handle, &findData) == 0); // ???????????
//load BBL bundle from user data path
string targetPath = bbl_bundle_path.make_preferred().string();
boost::filesystem::path myPath(targetPath);
//load custom bundle from user data path
boost::filesystem::directory_iterator endIter;
for (boost::filesystem::directory_iterator iter(myPath); iter != endIter; iter++) {
if (boost::filesystem::is_directory(*iter)) {
//cout << "is dir" << endl;
//cout << iter->path().string() << endl;
} else {
//cout << "is a file" << endl;
//cout << iter->path().string() << endl;
for (boost::filesystem::directory_iterator iter(vendor_dir); iter != endIter; iter++) {
if (!boost::filesystem::is_directory(*iter)) {
wxString strVendor = from_u8(iter->path().string()).BeforeLast('.');
strVendor = strVendor.AfterLast('\\');
strVendor = strVendor.AfterLast('/');
wxString strExtension = from_u8(iter->path().string()).AfterLast('.').Lower();
if(strExtension.CmpNoCase("json") != 0 || loaded_vendors.find(w2s(strVendor)) != loaded_vendors.end())
continue;
if (w2s(strVendor) == PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json") == 0)
LoadProfileFamily(w2s(strVendor), iter->path().string());
LoadProfileFamily(w2s(strVendor), iter->path().string());
loaded_vendors.insert(w2s(strVendor));
}
}
//string others_targetPath = rsrc_vendor_dir.string();
boost::filesystem::directory_iterator others_endIter;
for (boost::filesystem::directory_iterator iter(rsrc_vendor_dir); iter != others_endIter; iter++) {
if (boost::filesystem::is_directory(*iter)) {
//cout << "is dir" << endl;
//cout << iter->path().string() << endl;
} else {
//cout << "is a file" << endl;
//cout << iter->path().string() << endl;
if (!boost::filesystem::is_directory(*iter)) {
wxString strVendor = from_u8(iter->path().string()).BeforeLast('.');
strVendor = strVendor.AfterLast('\\');
strVendor = strVendor.AfterLast('/');
wxString strExtension = from_u8(iter->path().string()).AfterLast('.').Lower();
if (strExtension.CmpNoCase("json") != 0 || loaded_vendors.find(w2s(strVendor)) != loaded_vendors.end())
continue;
if (w2s(strVendor) != PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json")==0)
LoadProfileFamily(w2s(strVendor), iter->path().string());
LoadProfileFamily(w2s(strVendor), iter->path().string());
loaded_vendors.insert(w2s(strVendor));
}
}
//LoadProfileFamily(PresetBundle::BBL_BUNDLE, bbl_bundle_path.string());
const auto enabled_filaments = wxGetApp().app_config->has_section(AppConfig::SECTION_FILAMENTS) ? wxGetApp().app_config->get_section(AppConfig::SECTION_FILAMENTS) : std::map<std::string, std::string>();
m_appconfig_new.set_vendors(*wxGetApp().app_config);
@@ -1264,185 +1137,6 @@ void StringReplace(string &strBase, string strSrc, string strDes)
}
//int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath)
//{
// //wxString strFolder = strFilePath.BeforeLast(boost::filesystem::path::preferred_separator);
// boost::filesystem::path file_path(strFilePath);
// boost::filesystem::path vendor_dir = boost::filesystem::absolute(file_path.parent_path()/ strVendor).make_preferred();
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", vendor path %1%.")% vendor_dir.string();
// try {
//
// //wxLogMessage("GUIDE: json_path1 %s", w2s(strFilePath));
//
// std::string contents;
// LoadFile(strFilePath, contents);
// //wxLogMessage("GUIDE: json_path1 content: %s", contents);
// json jLocal=json::parse(contents);
// //wxLogMessage("GUIDE: json_path1 Loaded");
//
// // BBS:models
// json pmodels = jLocal["machine_model_list"];
// int nsize = pmodels.size();
//
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% machine models")%nsize;
//
// for (int n = 0; n < nsize; n++) {
// json OneModel = pmodels.at(n);
//
// OneModel["model"] = OneModel["name"];
// OneModel.erase("name");
//
// std::string s1 = OneModel["model"];
// std::string s2 = OneModel["sub_path"];
//
// boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
// std::string sub_file = sub_path.string();
//
// //wxLogMessage("GUIDE: json_path2 %s", w2s(ModelFilePath));
// LoadFile(sub_file, contents);
// //wxLogMessage("GUIDE: json_path2 content: %s", contents);
// json pm=json::parse(contents);
// //wxLogMessage("GUIDE: json_path2 loaded");
//
// OneModel["vendor"] = strVendor;
// std::string NozzleOpt = pm["nozzle_diameter"];
// StringReplace(NozzleOpt, " ", "");
// OneModel["nozzle_diameter"] = NozzleOpt;
// OneModel["materials"] = pm["default_materials"];
//
// //wxString strCoverPath = wxString::Format("%s\\%s\\%s_cover.png", strFolder, strVendor, std::string(s1.mb_str()));
// std::string cover_file = s1+"_cover.png";
// boost::filesystem::path cover_path = boost::filesystem::absolute(vendor_dir / cover_file).make_preferred();
// OneModel["cover"] = cover_path.string();
//
// OneModel["nozzle_selected"] = "";
//
// m_ProfileJson["model"].push_back(OneModel);
// }
//
// // BBS:Machine
// json pmachine = jLocal["machine_list"];
// nsize = pmachine.size();
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% machines")%nsize;
// for (int n = 0; n < nsize; n++) {
// json OneMachine = pmachine.at(n);
//
// std::string s1 = OneMachine["name"];
// std::string s2 = OneMachine["sub_path"];
//
// //wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
// boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
// std::string sub_file = sub_path.string();
// LoadFile(sub_file, contents);
// json pm = json::parse(contents);
//
// std::string strInstant = pm["instantiation"];
// if (strInstant.compare("true") == 0) {
// OneMachine["model"] = pm["printer_model"];
//
// m_ProfileJson["machine"].push_back(OneMachine);
// }
// }
//
// // BBS:Filament
// json pFilament = jLocal["filament_list"];
// nsize = pFilament.size();
//
// int nFalse = 0;
// int nModel = 0;
// int nFinish = 0;
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% filaments")%nsize;
// for (int n = 0; n < nsize; n++) {
// json OneFF = pFilament.at(n);
//
// std::string s1 = OneFF["name"];
// std::string s2 = OneFF["sub_path"];
//
// if (!m_ProfileJson["filament"].contains(s1))
// {
// //wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
// boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
// std::string sub_file = sub_path.string();
// LoadFile(sub_file, contents);
// json pm = json::parse(contents);
//
// std::string strInstant = pm["instantiation"];
// if (strInstant == "true") {
// std::string sV;
// std::string sT;
//
// int nRet = GetFilamentInfo(sub_file, sV, sT);
// if (nRet != 0) continue;
//
// OneFF["vendor"] = sV;
// OneFF["type"] = sT;
//
// OneFF["models"] = "";
// OneFF["selected"] = 0;
// }
// else
// continue;
//
// } else {
// OneFF = m_ProfileJson["filament"][s1];
// }
//
// std::string vModel = "";
// int nm = m_ProfileJson["model"].size();
// int bFind = 0;
// for (int m = 0; m < nm; m++) {
// std::string strFF = m_ProfileJson["model"][m]["materials"];
// strFF = (boost::format(";%1%;")%strFF).str();
// std::string strTT = (boost::format(";%1%;")%s1).str();
// if (strFF.find(strTT) != std::string::npos) {
// std::string sModel = m_ProfileJson["model"][m]["model"];
//
// vModel = (boost::format("%1%[%2%]")%vModel %sModel).str();
// bFind = 1;
// }
// }
//
// OneFF["models"] = vModel;
//
// m_ProfileJson["filament"][s1] = OneFF;
// }
//
// //process
// json pProcess = jLocal["process_list"];
// nsize = pProcess.size();
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% processes")%nsize;
// for (int n = 0; n < nsize; n++) {
// json OneProcess = pProcess.at(n);
//
// std::string s2 = OneProcess["sub_path"];
// //wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
// boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
// std::string sub_file = sub_path.string();
// LoadFile(sub_file, contents);
// json pm = json::parse(contents);
//
// std::string bInstall = pm["instantiation"];
// if (bInstall == "true")
// {
// m_ProfileJson["process"].push_back(OneProcess);
// }
// }
//
// }
// catch(nlohmann::detail::parse_error &err) {
// BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<strFilePath <<" got a nlohmann::detail::parse_error, reason = " << err.what();
// return -1;
// }
// catch (std::exception &e) {
// // wxMessageBox(e.what(), "", MB_OK);
// //wxLogMessage("GUIDE: LoadFamily Error: %s", e.what());
// BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse " << strFilePath << " got exception: " << e.what();
// return -1;
// }
//
// return 0;
//}
int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath)
{
// wxString strFolder = strFilePath.BeforeLast(boost::filesystem::path::preferred_separator);
@@ -1531,7 +1225,7 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
// BBS:Filament
json pFilament = jLocal["filament_list"];
json tFilaList = json::object();
json tFilaList = m_OrcaFilaList;
nsize = pFilament.size();
for (int n = 0; n < nsize; n++) {
@@ -1604,6 +1298,8 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
}
}
if(strVendor == PresetBundle::ORCA_FILAMENT_LIBRARY)
m_OrcaFilaList = tFilaList;
// process
json pProcess = jLocal["process_list"];
+4 -1
View File
@@ -103,7 +103,7 @@ private:
wxString m_SectionName;
bool bbl_bundle_rsrc;
bool orca_bundle_rsrc;
boost::filesystem::path vendor_dir;
boost::filesystem::path rsrc_vendor_dir;
@@ -115,6 +115,9 @@ private:
bool InstallNetplugin;
bool network_plugin_ready {false};
json m_OrcaFilaList;
std::string m_OrcaFilaLibPath;
#if wxUSE_WEBVIEW_IE
wxMenuItem *m_script_object_el;
wxMenuItem *m_script_date_el;
+1 -1
View File
@@ -205,7 +205,7 @@ std::string Duet::get_connect_url(const bool dsfUrl) const
} else {
return (boost::format("%1%rr_connect?password=%2%&%3%")
% get_base_url()
% (password.empty() ? "reprap" : password)
% Http::url_encode(password.empty() ? "reprap" : password) // url_encode is needed because password can contain special characters like `&`, "#", etc.
% timestamp_str()).str();
}
}
+19 -14
View File
@@ -226,7 +226,7 @@ struct PresetUpdater::priv
bool get_cached_plugins_version(std::string &cached_version, bool& force);
//BBS: refine preset update logic
bool install_bundles_rsrc(std::vector<std::string> bundles, bool snapshot) const;
bool install_bundles_rsrc(const std::vector<std::string>& bundles, bool snapshot) const;
void check_installed_vendor_profiles() const;
Updates get_printer_config_updates(bool update = false) const;
Updates get_config_updates(const Semver& old_slic3r_version) const;
@@ -1042,7 +1042,7 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url)
}
}
bool PresetUpdater::priv::install_bundles_rsrc(std::vector<std::string> bundles, bool snapshot) const
bool PresetUpdater::priv::install_bundles_rsrc(const std::vector<std::string>& bundles, bool snapshot) const
{
Updates updates;
@@ -1071,8 +1071,7 @@ bool PresetUpdater::priv::install_bundles_rsrc(std::vector<std::string> bundles,
}
//BBS: refine preset update logic
// Install indicies from resources. Only installs those that are either missing or older than in resources.
// Orca: copy/update the vendor profiles from resource to system folder
void PresetUpdater::priv::check_installed_vendor_profiles() const
{
BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:Checking whether the profile from resource is newer";
@@ -1080,8 +1079,9 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
AppConfig *app_config = GUI::wxGetApp().app_config;
const auto enabled_vendors = app_config->vendors();
//BBS: refine the init check logic
std::vector<std::string> bundles;
std::set<std::string> bundles;
// Orca: always install filament library
bundles.insert(PresetBundle::ORCA_FILAMENT_LIBRARY);
for (auto &dir_entry : boost::filesystem::directory_iterator(rsrc_path)) {
const auto &path = dir_entry.path();
std::string file_path = path.string();
@@ -1090,9 +1090,13 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
std::string vendor_name = path.filename().string();
// Remove the .json suffix.
vendor_name.erase(vendor_name.size() - 5);
if (bundles.find(vendor_name) != bundles.end())continue;
const auto is_vendor_enabled = (vendor_name == PresetBundle::ORCA_DEFAULT_BUNDLE) // always update configs from resource to vendor for ORCA_DEFAULT_BUNDLE
|| (enabled_vendors.find(vendor_name) != enabled_vendors.end());
if (enabled_config_update) {
if ( fs::exists(path_in_vendor)) {
if (enabled_vendors.find(vendor_name) != enabled_vendors.end()) {
if (is_vendor_enabled) {
Semver resource_ver = get_version_from_json(file_path);
Semver vendor_ver = get_version_from_json(path_in_vendor.string());
@@ -1100,7 +1104,7 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
if (!version_match || (vendor_ver < resource_ver)) {
BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:found vendor "<<vendor_name<<" newer version "<<resource_ver.to_string() <<" from resource, old version "<<vendor_ver.to_string();
bundles.push_back(vendor_name);
bundles.insert(vendor_name);
}
}
else {
@@ -1111,18 +1115,19 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
fs::remove_all(path_of_vendor);
}
}
else if ((vendor_name == PresetBundle::BBL_BUNDLE) || (enabled_vendors.find(vendor_name) != enabled_vendors.end())) {//if vendor has no file, copy it from resource for BBL
bundles.push_back(vendor_name);
else if (is_vendor_enabled) {
bundles.insert(vendor_name);
}
}
else if ((vendor_name == PresetBundle::BBL_BUNDLE) || (enabled_vendors.find(vendor_name) != enabled_vendors.end())) { //always update configs from resource to vendor for BBL
bundles.push_back(vendor_name);
else if (is_vendor_enabled) {
bundles.insert(vendor_name);
}
}
}
if (bundles.size() > 0)
install_bundles_rsrc(bundles, false);
if (bundles.size() > 0) {
install_bundles_rsrc(std::vector(bundles.begin(), bundles.end()), false);
}
}
Updates PresetUpdater::priv::get_printer_config_updates(bool update) const