Merge remote-tracking branch 'remotes/local_62/dev_27_62' into superslicer_2.7.62

This commit is contained in:
supermerill 2026-05-04 22:31:57 +02:00
commit 7dc6a300d2
74 changed files with 1148 additions and 515 deletions

View file

@ -131,7 +131,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nightly_win64
name: nightly_${{ github.event.repository.name }}-win64
path: build/package/
# MSI CREATION
@ -189,5 +189,5 @@ jobs:
- name: Upload MSI artifact
uses: actions/upload-artifact@v4
with:
name: nightly_${{ github.event.repository.name }}-win64-${{ env.InstallerVersion }}.msi
name: nightly_${{ github.event.repository.name }}-win64.msi
path: build/${{ github.event.repository.name }}_${{ env.InstallerVersion }}.msi

View file

@ -174,5 +174,5 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nightly_win64_debug
name: debug_${{ github.event.repository.name }}-win64
path: build/package/

View file

@ -130,7 +130,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rc_win64
name: rc_${{ github.event.repository.name }}-win64
path: build/package/
# MSI CREATION (need files from the slic3r build, can't be its own step)

2
.gitignore vendored
View file

@ -22,6 +22,8 @@ deps/build-linux/*
.pkg_cache
CMakeUserPresets.json
**/bad_*
githubtoken.ini
releases/
# MacOS Ignores
.DS_Store

View file

@ -1,4 +1,5 @@
import os
import sys
from shutil import rmtree
from urllib.request import Request, urlopen, urlretrieve
import json
@ -13,33 +14,87 @@ import time
from datetime import date
import tarfile
import subprocess
import argparse
import re
from pathlib import Path
# function to get a var from version.inc
def get_cmake_var(filepath, var_name):
pattern = rf'set\(\s*{var_name}\s+"([^"]+)"\s*\)'
with open(filepath, "r") as f:
content = f.read()
match = re.search(pattern, content)
if match:
return match.group(1)
return None
parser = argparse.ArgumentParser(
description="Create release folders without overwriting existing ones."
)
parser.add_argument("branch_name", nargs="?", default="rc", help="Branch name")
parser.add_argument("prefix", nargs="?", default="rc", help="Prefix name")
parser.add_argument("date", nargs="?", default="", help="Artifact compile date")
args = parser.parse_args()
branch_name = args.branch_name
prefix = args.prefix
first_day = args.date;
repo = get_cmake_var("version.inc", "SLIC3R_GITHUB")
program_name = get_cmake_var("version.inc", "SLIC3R_APP_KEY")
token = None
repo = "supermerill/SuperSlicer"
program_name = "SuperSlicer"
path_7zip = r"C:\Program Files\7-Zip\7z.exe"
# github classic personal access token, works with [gist, repo, workflow] permissions, should be something like "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"
github_auth_token = ""
# try to fill github_auth_token via file
githubtoken_file = Path("githubtoken.ini")
if githubtoken_file.exists():
with open(githubtoken_file) as f:
for line in f:
if line.startswith("token="):
github_auth_token = line.strip().split("=", 1)[1];
print(f"file githubtoken.ini found, using token:'{github_auth_token}'");
break
else:
print(f"file githubtoken.ini not found, using hardcoded token:'{github_auth_token}'");
if(not github_auth_token):
print("For this scipt to work, please create a 'githubtoken.ini' file, and make at least a line with 'token=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'");
def get_version():
settings_stream = open("./version.inc", mode="r", encoding="utf-8");
lines = settings_stream.read().splitlines();
version = "0.0.0.0";
tag="";
for line in lines:
if("SLIC3R_VERSION_FULL" in line):
if("set(SLIC3R_RC_VERSION_DOTS" in line):
print("found1: " +line)
elems = line.split("\"");
return elems[1];
return "";
version = elems[1];
if("set(SLIC3R_VERSION_TAG" in line):
print("found2: " +line)
elems = line.split("\"");
tag = elems[1];
if("+" in tag):
elems = tag.split("+");
tag = elems[0];
return version+tag;
found_win = False;
found_win_msi = False;
found_linux = False;
found_linux_appimage_gtk2 = False;
found_linux_appimage_gtk3 = False;
found_macos = False;
found_macos_arm = False;
first_day = "";
# return True if he want to cntue new artifacts
def handle_artifact(json_artifact):
global found_win
global found_win_msi
global found_linux
global found_linux_appimage_gtk2
global found_linux_appimage_gtk3
@ -47,17 +102,20 @@ def handle_artifact(json_artifact):
global found_macos_arm
global first_day
if json_artifact["workflow_run"]["head_branch"] == "rc":
if json_artifact["workflow_run"]["head_branch"] == branch_name:
if first_day == "":
print("encounter the first rc at " + json_artifact["created_at"][:10]);
print("encounter the first " + branch_name + " at " + json_artifact["created_at"][:10]);
first_day = json_artifact["created_at"][:10];
if json_artifact["created_at"][:10] == first_day:
print("Next artifact: " + json_artifact["name"]);
elif json_artifact["created_at"][:10] > first_day:
print("Ignored artifact (bad day): ("+json_artifact["name"] + " @ "+json_artifact["created_at"][:10]+")");
return True
else:
print("End of rc artifacts. Closing");
print(f"End of {branch_name} artifacts (date too far away). Closing");
print("("+json_artifact["name"] + " @ "+json_artifact["created_at"][:10]+")");
return False;
if json_artifact["name"] == "rc_win64" and not found_win:
if json_artifact["name"] == prefix + "_" +program_name + "-win64" and not found_win:
found_win = True;
print("Found win64 artifact");
print("ask for: "+json_artifact["archive_download_url"]);
@ -70,7 +128,16 @@ def handle_artifact(json_artifact):
ret = subprocess.check_output([path_7zip, "a", "-tzip", base_name+".zip", base_name]);
except:
print("Failed to zip the win directory, do it yourself");
if json_artifact["name"] == "rc_"+program_name+"-macOS.dmg" and not found_macos:
if json_artifact["name"] == prefix + "_" +program_name + "-win64.msi" and not found_win_msi:
found_win_msi = True;
print("Found win64 msi artifact");
print("ask for: "+json_artifact["archive_download_url"]);
resp = requests.get(json_artifact["archive_download_url"], headers={'Authorization': 'token ' + github_auth_token,}, allow_redirects=True);
print("win: " +str(resp));
z = zipfile.ZipFile(io.BytesIO(resp.content))
z.extractall(release_path);
os.rename(release_path+"/"+prefix + "_" +program_name+"-win64.msi", release_path+"/"+program_name+"_"+version+"_win64_"+date_str+".msi");
if json_artifact["name"] == prefix + "_"+program_name+"-macOS-intel.dmg" and not found_macos:
found_macos = True;
print("Found macos-intel artifact");
print("ask for: "+json_artifact["archive_download_url"]);
@ -79,7 +146,7 @@ def handle_artifact(json_artifact):
z = zipfile.ZipFile(io.BytesIO(resp.content));
z.extractall(release_path);
os.rename(release_path+"/"+program_name+"-macOS-intel.dmg", release_path+"/"+program_name+"_"+version+"_macos_"+date_str+".dmg");
if json_artifact["name"] == "rc_"+program_name+"-macOS-arm.dmg" and not found_macos_arm:
if json_artifact["name"] == prefix + "_"+program_name+"-macOS-arm.dmg" and not found_macos_arm:
found_macos_arm = True;
print("Found macos-arm artifact");
print("ask for: "+json_artifact["archive_download_url"]);
@ -88,7 +155,7 @@ def handle_artifact(json_artifact):
z = zipfile.ZipFile(io.BytesIO(resp.content));
z.extractall(release_path);
os.rename(release_path+"/"+program_name+"-macOS-arm.dmg", release_path+"/"+program_name+"_"+version+"_macos_arm_"+date_str+".dmg");
if json_artifact["name"] == "rc_"+program_name+"-linux-x64-GTK2.AppImage" and not found_linux_appimage_gtk2:
if json_artifact["name"] == prefix + "_"+program_name+"-linux-x64-GTK2.AppImage" and not found_linux_appimage_gtk2:
found_linux_appimage_gtk2 = True;
print("Found ubuntu GTK2 artifact");
print("ask for: "+json_artifact["archive_download_url"]);
@ -97,7 +164,7 @@ def handle_artifact(json_artifact):
z = zipfile.ZipFile(io.BytesIO(resp.content));
z.extractall(release_path);
os.rename(release_path+"/"+program_name+"-linux-x64-GTK2.AppImage", release_path+"/"+program_name+"-ubuntu_22.04-gtk2-" + version + ".AppImage");
if json_artifact["name"] == "rc_"+program_name+"-linux-x64-GTK3.AppImage" and not found_linux_appimage_gtk3:
if json_artifact["name"] == prefix + "_"+program_name+"-linux-x64-GTK3.AppImage" and not found_linux_appimage_gtk3:
found_linux_appimage_gtk3 = True;
print("Found ubuntu GTK3 artifact");
print("ask for: "+json_artifact["archive_download_url"]);
@ -106,7 +173,7 @@ def handle_artifact(json_artifact):
z = zipfile.ZipFile(io.BytesIO(resp.content));
z.extractall(release_path);
os.rename(release_path+"/"+program_name+"-linux-x64-GTK3.AppImage", release_path+"/"+program_name+"-ubuntu_22.04-" + version + ".AppImage");
if json_artifact["name"] == "rc_"+program_name+"-linux-x64-GTK3.tgz" and not found_linux:
if json_artifact["name"] == prefix + "_"+program_name+"-linux-x64-GTK3.tgz" and not found_linux:
found_linux = True;
print("Found ubuntu GTK3 archive artifact");
print("ask for: "+json_artifact["archive_download_url"]);
@ -122,16 +189,23 @@ def handle_artifact(json_artifact):
# except:
# with zipfile.ZipFile(base_path+"_bof.tar.zip", 'w') as myzip:
# myzip.write(base_path+".tar");
return not (found_win and found_linux and found_linux_appimage_gtk2 and found_linux_appimage_gtk3 and found_macos and found_macos_arm);
return not (found_win and found_win_msi and found_linux and found_linux_appimage_gtk2 and found_linux_appimage_gtk3 and found_macos and found_macos_arm);
date_str = date.today().strftime('%y%m%d');
version = get_version();
print("create release for: " + str(version));
release_path = "./build/release_"+str(version);
if(os.path.isdir(release_path)):
rmtree(release_path);
print("deleting old directory");
if(not os.path.isdir("./releases")):
os.mkdir("./releases");
base_path = "./releases/"+branch_name+"_release_"+str(version);
release_path = base_path;
# find a directory that either doesn't exist OR is empty
counter = 2;
while os.path.isdir(release_path) and os.listdir(release_path):
release_path = f"{base_path}_{counter}";
counter += 1;
os.mkdir(release_path);
#urllib.urlretrieve ("https://api.github.com/repos/"+repo+"/actions/artifacts", release_path+"artifacts.json");
need_more = True
page = 1
@ -145,4 +219,4 @@ while need_more and page < 10:
break;
page = page + 1;
print("DONT FORGET TO PUSH YOUR MASTER");
print("DONT FORGET TO PUSH YOUR MAIN/MASTER BRANCH");

View file

@ -823,10 +823,10 @@ bool CLI::setup(int argc, char **argv)
set_install_path(install_path);
set_binary_file(path_to_binary);
set_resources_dir(path_resources.string());
set_var_dir((path_resources / "icons").string());
set_icons_dir((path_resources / "icons").string());
set_local_dir((path_resources / "localization").string());
set_sys_shapes_dir((path_resources / "shapes").string());
set_custom_gcodes_dir((path_resources / "custom_gcodes").string());
//set_custom_gcodes_dir((path_resources / "custom_gcodes").string());
// Parse all command line options into a DynamicConfig.
// If any option is unsupported, print usage and abort immediately.
@ -865,8 +865,10 @@ bool CLI::setup(int argc, char **argv)
for (const t_optiondef_map::value_type &optdef : *options)
m_config.option(optdef.first, true);
set_data_dir(m_config.opt_string("datadir"));
if (std::string datadir = m_config.opt_string("datadir"); !datadir.empty()) {
set_data_dir(boost::filesystem::absolute(datadir).string());
}
//FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet.
if (!validity.empty()) {
boost::nowide::cerr << "error: " << validity << std::endl;
@ -885,9 +887,11 @@ void CLI::print_help(bool include_print_options, PrinterTechnology printer_techn
#else /* SLIC3R_GUI */
<< " (without GUI support)"
#endif /* SLIC3R_GUI */
<< std::endl
<< "https://github.com/" << SLIC3R_GITHUB << std::endl << std::endl
<< "Usage: superslicer [ ACTIONS ] [ TRANSFORM ] [ OPTIONS ] [ file.stl ... ]" << std::endl
<< std::endl;
if (SLIC3R_GITHUB[0] !='h' && SLIC3R_GITHUB[1] != 't' && SLIC3R_GITHUB[2] != 't' && SLIC3R_GITHUB[3] != 'p') {
boost::nowide::cout << "https://github.com/" << SLIC3R_GITHUB << std::endl << std::endl;
}
boost::nowide::cout << "Usage: " SLIC3R_APP_CMD " [ ACTIONS ] [ TRANSFORM ] [ OPTIONS ] [ file.stl ... ]" << std::endl
<< std::endl
<< "Actions:" << std::endl;
cli_actions_config_def.print_cli_help(boost::nowide::cout, false);

View file

@ -42,18 +42,20 @@
namespace Slic3r {
constexpr bool starts_with_http(const char* str) {
return str[0] == 'h' && str[1] == 't' && str[2] == 't' && str[3] == 'p';
}
static const std::string VENDOR_PREFIX = "vendor:";
static const std::string MODEL_PREFIX = "model:";
static const std::string VERSION_CHECK_URL = "https://api.github.com/repos/" "supermerill/superslicer" "/releases";
// Url to index archive zip that contains latest indicies
static const std::string INDEX_ARCHIVE_URL= "https://api.github.com/repos/" SLIC3R_GITHUB "-profiles/releases";
//to get the slic3r idx: look at the json from INDEX_ARCHIVE_URL, and request the assets_url
// then, in t8he json look for an entry with name == "vendor_indices.zip"
static const std::string SLIC3R_GITHUB_ABSOLUTE = starts_with_http(SLIC3R_GITHUB) ?
std::string(SLIC3R_GITHUB) :
"https://github.com/" SLIC3R_GITHUB;
static const std::string VERSION_CHECK_URL = starts_with_http(SLIC3R_GITHUB) ?
std::string(SLIC3R_GITHUB) + "/releases" :
"https://api.github.com/repos/" SLIC3R_GITHUB "/releases";
// Url to folder with vendor profile files. Used when downloading new profiles that are not in resources folder.
static const std::string PROFILE_FOLDER_URL = "https://raw.githubusercontent.com/" SLIC3R_GITHUB "-profiles/main/";
const std::string AppConfig::SECTION_FILAMENTS = "filaments";
const std::string AppConfig::SECTION_FILAMENTS = "materials";
const std::string AppConfig::SECTION_MATERIALS = "sla_materials";
const std::string AppConfig::SECTION_EMBOSS_STYLE = "font";
@ -1371,32 +1373,18 @@ std::string AppConfig::splashscreen(bool is_editor) {
return file_name;
}
std::string AppConfig::github_url() const
{
auto from_settings = get("github_url");
return from_settings.empty() ? SLIC3R_GITHUB_ABSOLUTE : from_settings;
}
std::string AppConfig::version_check_url() const
{
auto from_settings = get("version_check_url");
return from_settings.empty() ? VERSION_CHECK_URL : from_settings;
}
std::string AppConfig::index_archive_url() const
{
#if 0
// this code is for debug & testing purposes only - changed url wont get trough inner checks anyway.
auto from_settings = get("index_archive_url");
return from_settings.empty() ? INDEX_ARCHIVE_URL : from_settings;
#endif
return INDEX_ARCHIVE_URL;
}
std::string AppConfig::profile_folder_url() const
{
#if 0
// this code is for debug & testing purposes only - changed url wont get trough inner checks anyway.
auto from_settings = get("profile_folder_url");
return from_settings.empty() ? PROFILE_FOLDER_URL : from_settings;
#endif
return PROFILE_FOLDER_URL;
}
bool AppConfig::exists() const
{
return boost::filesystem::exists(config_path());

View file

@ -238,10 +238,8 @@ public:
// Get the Slic3r version check url.
// This returns a hardcoded string unless it is overriden by "version_check_url" in the ini file.
std::string version_check_url() const;
// Get the Slic3r url to vendor index archive zip.
std::string index_archive_url() const;
// Get the Slic3r url to folder with vendor profile files.
std::string profile_folder_url() const;
// Get the complete Slic3r github url, starting with http
std::string github_url() const;
// Returns the original Slic3r version found in the ini file before it was overwritten

View file

@ -1100,7 +1100,7 @@ std::unique_ptr<FontFile> Emboss::create_font_file(
std::unique_ptr<FontFile> Emboss::create_font_file(const char *file_path)
{
BOOST_LOG_TRIVIAL(debug) << "open font file: " << file_path;
FILE *file = std::fopen(file_path, "rb");
FILE *file = boost::nowide::fopen(file_path, "rb");
if (file == nullptr) {
assert(false);
BOOST_LOG_TRIVIAL(error) << "Couldn't open " << file_path << " for reading.";

View file

@ -589,7 +589,7 @@ void SimplifyVisitor::use(ExtrusionPath& path) {
m_last_deleted = true;
return;
}
assert(m_scaled_resolution >= SCALED_EPSILON);
assert(m_scaled_resolution + 0.1 >= SCALED_EPSILON);
path.simplify(m_scaled_resolution, m_use_arc_fitting, scale_d(m_arc_fitting_tolearance->get_abs_value(path.width())));
for (int i = 1; i < path.polyline.size(); ++i)
if (path.polyline.get_point(i - 1).coincides_with_epsilon(path.polyline.get_point(i))) {

View file

@ -6800,6 +6800,16 @@ double_t GCodeGenerator::_compute_speed_mm_per_sec(const ExtrusionPath& path, co
float factor = 1;
double speed = set_speed;
ExtrusionRole role = path.role();
// remove overhang role for speed if it's out of has_full_overhangs_speed.
if (role.is_overhang()) {
assert(path.attributes().overhang_attributes.has_value());
if (path.attributes().overhang_attributes.has_value() &&
!path.attributes().overhang_attributes->has_full_overhangs_speed){
role = role & ExtrusionRoleModifier(~ExtrusionRoleModifier::ERM_Bridge);
}
}
// set speed
if (speed < 0) {
//if speed == -1, then it's means "choose yourself, but if it's < SMALL_PERIMETER_SPEED_RATIO_OFFSET, then it's a scaling from small_perimeter.
@ -6807,37 +6817,35 @@ double_t GCodeGenerator::_compute_speed_mm_per_sec(const ExtrusionPath& path, co
factor = float(-speed + SMALL_PERIMETER_SPEED_RATIO_OFFSET);
}
//it's a bit hacky, so if you want to rework it, help yourself.
if ((path.role().is_overhang() && m_config.overhangs) ||
(path.attributes().overhang_attributes.has_value() &&
path.attributes().overhang_attributes->has_full_overhangs_speed)) {
if (role.is_overhang()) {
// OverhangPerimeter or OverhangExternalPerimeter
speed = m_config.get_computed_value("overhangs_speed");
if(comment) *comment = "overhangs_speed";
} else if (path.role() == ExtrusionRole::Perimeter) {
} else if (role == ExtrusionRole::Perimeter) {
speed = m_config.get_computed_value("perimeter_speed");
if(comment) *comment = "perimeter_speed";
} else if (path.role() == ExtrusionRole::ExternalPerimeter) {
} else if (role == ExtrusionRole::ExternalPerimeter) {
speed = m_config.get_computed_value("external_perimeter_speed");
if(comment) *comment = "external_perimeter_speed";
} else if (path.role() == ExtrusionRole::BridgeInfill) {
} else if (role == ExtrusionRole::BridgeInfill) {
speed = m_config.get_computed_value("bridge_speed");
if(comment) *comment = "bridge_speed";
} else if (path.role() == ExtrusionRole::InternalBridgeInfill) {
} else if (role == ExtrusionRole::InternalBridgeInfill) {
speed = m_config.get_computed_value("internal_bridge_speed");
if(comment) *comment = "internal_bridge_speed";
} else if (path.role() == ExtrusionRole::InternalInfill) {
} else if (role == ExtrusionRole::InternalInfill) {
speed = m_config.get_computed_value("infill_speed");
if(comment) *comment = "infill_speed";
} else if (path.role() == ExtrusionRole::SolidInfill) {
} else if (role == ExtrusionRole::SolidInfill) {
speed = m_config.get_computed_value("solid_infill_speed");
if(comment) *comment = "solid_infill_speed";
} else if (path.role() == ExtrusionRole::TopSolidInfill) {
} else if (role == ExtrusionRole::TopSolidInfill) {
speed = m_config.get_computed_value("top_solid_infill_speed");
if(comment) *comment = "top_solid_infill_speed";
} else if (path.role() == ExtrusionRole::ThinWall) {
} else if (role == ExtrusionRole::ThinWall) {
speed = m_config.get_computed_value("thin_walls_speed");
if(comment) *comment = "thin_walls_speed";
} else if (path.role() == ExtrusionRole::GapFill) {
} else if (role == ExtrusionRole::GapFill) {
speed = m_config.get_computed_value("gap_fill_speed");
if(comment) *comment = "gap_fill_speed";
double max_ratio = m_config.gap_fill_flow_match_perimeter.get_abs_value(1.);
@ -6851,23 +6859,23 @@ double_t GCodeGenerator::_compute_speed_mm_per_sec(const ExtrusionPath& path, co
if(comment) *comment = "max_vol_speed (from " + (*comment) + ")";
}
}
} else if (path.role() == ExtrusionRole::Ironing) {
} else if (role == ExtrusionRole::Ironing) {
speed = m_config.get_computed_value("ironing_speed");
if(comment) *comment = "ironing_speed";
} else if (path.role() == ExtrusionRole::None || path.role() == ExtrusionRole::Travel) {
assert(path.role() != ExtrusionRole::None);
} else if (role == ExtrusionRole::None || role == ExtrusionRole::Travel) {
assert(role != ExtrusionRole::None);
speed = m_config.get_computed_value("travel_speed");
if(comment) *comment = "travel_speed";
} else if (path.role() == ExtrusionRole::Milling) {
} else if (role == ExtrusionRole::Milling) {
speed = m_config.get_computed_value("milling_speed");
if(comment) *comment = "milling_speed";
} else if (path.role() == ExtrusionRole::SupportMaterial) {
} else if (role == ExtrusionRole::SupportMaterial) {
speed = m_config.get_computed_value("support_material_speed");
if(comment) *comment = "support_material_speed";
} else if (path.role() == ExtrusionRole::SupportMaterialInterface) {
} else if (role == ExtrusionRole::SupportMaterialInterface) {
speed = m_config.get_computed_value("support_material_interface_speed");
if(comment) *comment = "support_material_interface_speed";
} else if (path.role() == ExtrusionRole::Skirt) {
} else if (role == ExtrusionRole::Skirt) {
speed = m_config.get_computed_value("brim_speed");
if(comment) *comment = "brim_speed";
} else {
@ -6889,39 +6897,39 @@ double_t GCodeGenerator::_compute_speed_mm_per_sec(const ExtrusionPath& path, co
}
// if using a % of an auto speed, use the % over the volumetric speed.
// respect the % hierarchy
if ((path.role().is_overhang() && m_config.overhangs) ||
if (role.is_overhang() &&
(path.attributes().overhang_attributes.has_value() &&
path.attributes().overhang_attributes->has_full_overhangs_speed)) {
speed = m_config.overhangs_speed.get_abs_value(m_config.bridge_speed.get_abs_value(vol_speed));
if(comment) *comment = std::string("overhangs_speed ") + *comment;
} else if (path.role() == ExtrusionRole::Perimeter) {
} else if (role == ExtrusionRole::Perimeter) {
speed = m_config.perimeter_speed.get_abs_value(vol_speed);
if(comment) *comment = std::string("perimeter_speed ") + *comment;
} else if (path.role() == ExtrusionRole::ExternalPerimeter) {
} else if (role == ExtrusionRole::ExternalPerimeter) {
speed = m_config.external_perimeter_speed.get_abs_value(m_config.perimeter_speed.get_abs_value(vol_speed));
if(comment) *comment = std::string("external_perimeter_speed ") + *comment;
} else if (path.role() == ExtrusionRole::BridgeInfill) {
} else if (role == ExtrusionRole::BridgeInfill) {
speed = m_config.bridge_speed.get_abs_value(vol_speed);
if(comment) *comment = std::string("bridge_speed ") + *comment;
} else if (path.role() == ExtrusionRole::InternalBridgeInfill) {
} else if (role == ExtrusionRole::InternalBridgeInfill) {
speed = m_config.internal_bridge_speed.get_abs_value(m_config.bridge_speed.get_abs_value(vol_speed));
if(comment) *comment = std::string("internal_bridge_speed ") + *comment;
} else if (path.role() == ExtrusionRole::InternalInfill) {
} else if (role == ExtrusionRole::InternalInfill) {
speed = m_config.infill_speed.get_abs_value(m_config.solid_infill_speed.get_abs_value(vol_speed));
if(comment) *comment = std::string("infill_speed ") + *comment;
} else if (path.role() == ExtrusionRole::SolidInfill) {
} else if (role == ExtrusionRole::SolidInfill) {
speed = m_config.solid_infill_speed.get_abs_value(vol_speed);
if(comment) *comment = std::string("solid_infill_speed ") + *comment;
} else if (path.role() == ExtrusionRole::TopSolidInfill) {
} else if (role == ExtrusionRole::TopSolidInfill) {
speed = m_config.top_solid_infill_speed.get_abs_value(m_config.solid_infill_speed.get_abs_value(vol_speed));
if(comment) *comment = std::string("top_solid_infill_speed ") + *comment;
} else if (path.role() == ExtrusionRole::ThinWall) {
} else if (role == ExtrusionRole::ThinWall) {
speed = m_config.thin_walls_speed.get_abs_value(m_config.external_perimeter_speed.get_abs_value(m_config.perimeter_speed.get_abs_value(vol_speed)));
if(comment) *comment = std::string("thin_walls_speed ") + *comment;
} else if (path.role() == ExtrusionRole::GapFill) {
} else if (role == ExtrusionRole::GapFill) {
speed = m_config.gap_fill_speed.get_abs_value(m_config.perimeter_speed.get_abs_value(vol_speed));
if(comment) *comment = std::string("gap_fill_speed ") + *comment;
} else if (path.role() == ExtrusionRole::Ironing) {
} else if (role == ExtrusionRole::Ironing) {
speed = m_config.ironing_speed.get_abs_value(m_config.top_solid_infill_speed.get_abs_value(m_config.solid_infill_speed.get_abs_value(vol_speed)));
if(comment) *comment = std::string("ironing_speed ") + *comment;
}
@ -6939,18 +6947,20 @@ double_t GCodeGenerator::_compute_speed_mm_per_sec(const ExtrusionPath& path, co
assert(!path.attributes().overhang_attributes.has_value() || path.attributes().overhang_attributes->has_full_overhangs_speed ||
path.attributes().overhang_attributes->has_dynamic_overhangs_speed);
if (path.attributes().overhang_attributes.has_value() && path.attributes().overhang_attributes->has_dynamic_overhangs_speed) {
if (path.attributes().overhang_attributes.has_value() &&
path.attributes().overhang_attributes->has_dynamic_overhangs_speed) {
assert(this->layer()->id() > 0);
double my_speed = speed;
if(comment) *comment = "overhangs_speed";
auto [speed_ratio, over_fan_speed] = ExtrusionProcessor::calculate_overhang_speed(path.attributes(), this->m_config, m_writer.tool()->id());
if (comment)
*comment = "overhangs_speed";
float speed_ratio = ExtrusionProcessor::calculate_overhang_speed(path.attributes(), this->m_config,
m_writer.tool()->id());
assert(speed_ratio == -1 || (speed_ratio >= 0 && speed_ratio <= 1));
assert(over_fan_speed == -1 || (over_fan_speed >= 0 && over_fan_speed <= 100));
if (speed_ratio >= 0) {
double other_speed = set_speed;
if (path.role().is_overhang()) {
if (role.is_overhang()) {
// external or normal perimeter?
if (path.role() == ExtrusionRole::OverhangExternalPerimeter) {
if (role == ExtrusionRole::OverhangExternalPerimeter) {
other_speed = m_config.get_computed_value("external_perimeter_speed");
} else {
other_speed = m_config.get_computed_value("perimeter_speed");
@ -6958,7 +6968,8 @@ double_t GCodeGenerator::_compute_speed_mm_per_sec(const ExtrusionPath& path, co
} else {
other_speed = m_config.get_computed_value("overhangs_speed");
}
if (m_writer.tool()->id() >= 0 && m_volumetric_speed_mm3_per_s[m_writer.tool()->id()] != 0. && other_speed == 0) {
if (m_writer.tool()->id() >= 0 && m_volumetric_speed_mm3_per_s[m_writer.tool()->id()] != 0. &&
other_speed == 0) {
// copy/paste
// if m_volumetric_speed_mm3_per_s, use the max size for thinwall & gapfill, to avoid variations
double vol_speed = m_volumetric_speed_mm3_per_s[m_writer.tool()->id()] / path.mm3_per_mm();
@ -6966,7 +6977,7 @@ double_t GCodeGenerator::_compute_speed_mm_per_sec(const ExtrusionPath& path, co
if (vol_speed > max_print_speed) {
vol_speed = max_print_speed;
}
if (path.role() == ExtrusionRole::OverhangExternalPerimeter) {
if (role == ExtrusionRole::OverhangExternalPerimeter) {
other_speed = m_config.external_perimeter_speed.get_abs_value(vol_speed);
} else {
other_speed = m_config.perimeter_speed.get_abs_value(vol_speed);
@ -6977,7 +6988,7 @@ double_t GCodeGenerator::_compute_speed_mm_per_sec(const ExtrusionPath& path, co
}
double overhangs_speed;
double perimeter_speed;
if (path.role().is_overhang()) {
if (role.is_overhang()) {
overhangs_speed = my_speed;
perimeter_speed = other_speed;
} else {
@ -6986,6 +6997,13 @@ double_t GCodeGenerator::_compute_speed_mm_per_sec(const ExtrusionPath& path, co
}
speed = overhangs_speed * (1 - speed_ratio) + perimeter_speed * speed_ratio;
}
}
if (path.attributes().overhang_attributes.has_value() &&
m_config.overhangs_dynamic_fan_speed.is_enabled(m_writer.tool()->id())) {
float over_fan_speed = ExtrusionProcessor::calculate_overhang_fan_speed(path.attributes(), this->m_config,
m_writer.tool()->id());
assert(over_fan_speed == -1 || (over_fan_speed >= 0 && over_fan_speed <= 100));
if (over_fan_speed >= 0) {
fan_speed = over_fan_speed;
}
@ -7519,7 +7537,9 @@ std::string GCodeGenerator::_before_extrude(const ExtrusionPath &path, const std
// compensate retraction
if (m_delayed_layer_change.empty()) {
gcode += m_writer.unlift();//this->unretract();
#ifdef _DEBUGINFO
assert(is_approx(m_writer.get_position().z(), m_layer->print_z, EPSILON) || m_loop_vase_mode);
#endif
} else {
//check if an unlift happens
std::string unlift = m_writer.unlift();
@ -7624,6 +7644,7 @@ std::string GCodeGenerator::_before_extrude(const ExtrusionPath &path, const std
m_check_markers++;
}
if (m_overhang_fan_override >= 0) {
gcode += "; overhang speed : SET_MIN_FAN_SPEED" + std::to_string(int(m_overhang_fan_override)) + "\n";
gcode += ";_SET_MIN_FAN_SPEED" + std::to_string(int(m_overhang_fan_override)) + "\n";
}
// comment to be on the same line as the speed command.
@ -7640,6 +7661,7 @@ std::string GCodeGenerator::_after_extrude(const ExtrusionPath &path) {
std::string gcode;
if (m_enable_cooling_markers) {
if (m_overhang_fan_override >= 0) {
gcode += "; end of overhang speed\n";
gcode += ";_RESET_MIN_FAN_SPEED\n";
m_overhang_fan_override = -1.;
}
@ -8081,7 +8103,9 @@ void GCodeGenerator::write_travel_to(std::string &gcode, Polyline& travel, std::
this->writer().set_lift(this->writer().get_position().z() - *m_new_z_target);
m_new_z_target.reset();
}
#ifdef _DEBUGINFO
assert(!m_layer || is_approx(this->writer().get_unlifted_position().z(), m_layer->print_z, EPSILON) || comment == "Travel to a Wipe Tower" || m_loop_vase_mode);
#endif
}
// generate a travel in xyz
@ -8091,7 +8115,7 @@ std::string GCodeGenerator::generate_travel_gcode(
) {
std::string gcode;
const unsigned acceleration =(unsigned)(m_config.travel_acceleration.value + 0.5);
const unsigned acceleration =(unsigned)(get_travel_acceleration(m_config) + 0.5);
if (travel.empty()) {
return "";

View file

@ -1282,6 +1282,8 @@ std::string CoolingBuffer::apply_layer_cooldown(
CoolingLine::TYPE_ADJUSTABLE_MAYBE | CoolingLine::TYPE_WIPE)) {
// Process comments, remove ";_EXTRUDE_SET_SPEED", ";_EXTRUDE_SET_SPEED_MAYBE", ";_WIPE"
std::string comment(end, line_end);
if (comment.back() == '\n')
comment.pop_back();
if (line->type & (CoolingLine::TYPE_ADJUSTABLE_MAYBE)) {
if (comment == ";_EXTRUDE_SET_SPEED_MAYBE") {
comment.clear();
@ -1309,9 +1311,9 @@ std::string CoolingBuffer::apply_layer_cooldown(
boost::replace_all(comment, "_WIPE", "");
}
}
assert((comment.empty() && new_gcode.back() == '\n') ||
(!comment.empty() && comment.back() == '\n' && new_gcode.back() != '\n'));
new_gcode += comment;
if (new_gcode.back() != '\n')
new_gcode += '\n';
} else {
assert((new_gcode.back() == '\n' && line_end == end) ||
(new_gcode.back() != '\n' && (*(line_end - 1)) == '\n'));

View file

@ -16,8 +16,8 @@ ExtrusionPaths calculate_and_split_overhanging_extrusions(const ExtrusionPath
const AABBTreeLines::LinesDistancer<Linef> &unscaled_prev_layer,
const AABBTreeLines::LinesDistancer<CurledLine> &prev_layer_curled_lines,
const double &nozzle_diameter) {
assert(!path.attributes().overhang_attributes.has_value() || path.attributes().overhang_attributes->has_full_overhangs_speed ||
path.attributes().overhang_attributes->has_dynamic_overhangs_speed);
//assert(!path.attributes().overhang_attributes.has_value() || path.attributes().overhang_attributes->has_full_overhangs_speed ||
// path.attributes().overhang_attributes->has_dynamic_overhangs_speed);
if (!path.attributes().overhang_attributes) {
return { path };
} else {
@ -140,7 +140,7 @@ ExtrusionPaths calculate_and_split_overhanging_extrusions(const ExtrusionPath
//remove overhang role, as it prevents placing seams on it.
for (ExtrusionPath &res_path : result) {
assert(res_path.attributes().overhang_attributes);
res_path.attributes_mutable().role = (res_path.role() & ExtrusionRoleModifier(~ExtrusionRoleModifier::ERM_Bridge));
//res_path.attributes_mutable().role = (res_path.role() & ExtrusionRoleModifier(~ExtrusionRoleModifier::ERM_Bridge));
//assert(res_path.role() == ExtrusionRole::Perimeter || res_path.role() == ExtrusionRole::ExternalPerimeter);
}
#ifdef _DEBUG
@ -231,16 +231,15 @@ ExtrusionEntityCollection calculate_and_split_overhanging_extrusions(const Extru
};
std::pair<float,float> calculate_overhang_speed(const ExtrusionAttributes &attributes,
const FullPrintConfig &config,
size_t extruder_id)
{
float calculate_overhang_speed(const ExtrusionAttributes &attributes,
const FullPrintConfig &config,
size_t extruder_id) {
assert(attributes.overhang_attributes.has_value());
if(!attributes.overhang_attributes.has_value())
return {-1, -1};
if (!attributes.overhang_attributes.has_value())
return -1;
float speed_ratio = 0; // 0: overhangs speed, 1= perimeter/externalperimeter speed.
float fan_speed = -1;
if (config.overhangs_dynamic_speed.is_enabled()) {
// enforce config.overhangs_width_speed.is_enabled() to be able to compute overhangs_dynamic_speed, for simplicity sake.
if (config.overhangs_width_speed.is_enabled() && config.overhangs_dynamic_speed.is_enabled()) {
if (attributes.overhang_attributes->start_distance_from_prev_layer == 0 &&
attributes.overhang_attributes->end_distance_from_prev_layer == 0) {
speed_ratio = 1;
@ -265,18 +264,36 @@ std::pair<float,float> calculate_overhang_speed(const ExtrusionAttributes &attri
// interpolate
assert(attributes.overhang_attributes->start_distance_from_prev_layer >= 0);
assert(attributes.overhang_attributes->end_distance_from_prev_layer >= 0);
float extrusion_ratio = std::min(
graph.interpolate(100 - 100 * std::min(1.f, attributes.overhang_attributes->start_distance_from_prev_layer / max_dynamic_distance)),
graph.interpolate(100 - 100 * std::min(1.f, attributes.overhang_attributes->end_distance_from_prev_layer / max_dynamic_distance)));
float extrusion_ratio =
std::min(graph.interpolate(
100 -
100 *
std::min(1.f,
attributes.overhang_attributes->start_distance_from_prev_layer /
max_dynamic_distance)),
graph.interpolate(100 -
100 *
std::min(1.f,
attributes.overhang_attributes->end_distance_from_prev_layer /
max_dynamic_distance)));
assert(attributes.width * attributes.overhang_attributes->proximity_to_curled_lines >= 0 &&
attributes.width * attributes.overhang_attributes->proximity_to_curled_lines <= 1);
float curled_extrusion_ratio = graph.interpolate(100 - 100 * attributes.overhang_attributes->proximity_to_curled_lines);
speed_ratio = std::min(extrusion_ratio, curled_extrusion_ratio) / 100.0;
float curled_extrusion_ratio = graph.interpolate(
100 - 100 * attributes.overhang_attributes->proximity_to_curled_lines);
speed_ratio = std::min(extrusion_ratio, curled_extrusion_ratio) / 100.0;
assert(speed_ratio >= 0 && speed_ratio <= 1);
}
}
return speed_ratio;
}
float calculate_overhang_fan_speed(const ExtrusionAttributes &attributes,
const FullPrintConfig &config,
size_t extruder_id) {
assert(attributes.overhang_attributes.has_value());
if (!attributes.overhang_attributes.has_value())
return -1;
float fan_speed = -1;
std::vector<std::pair<int, ConfigOptionInts>> overhang_with_fan_speeds = {{100, ConfigOptionInts{0}}};
if (config.overhangs_dynamic_fan_speed.is_enabled(extruder_id) &&
attributes.overhang_attributes->start_distance_from_prev_layer > 0 &&
@ -294,7 +311,7 @@ std::pair<float,float> calculate_overhang_speed(const ExtrusionAttributes &attri
graph.interpolate(100 - 100 * std::min(1.f, attributes.overhang_attributes->end_distance_from_prev_layer)));
assert(fan_speed >= 0 && fan_speed <= 100);
}
return {speed_ratio, fan_speed};
return fan_speed;
}

View file

@ -258,9 +258,14 @@ ExtrusionEntityCollection calculate_and_split_overhanging_extrusions(
const AABBTreeLines::LinesDistancer<CurledLine> &prev_layer_curled_lines,
const double &nzl_diam);
std::pair<float, float> calculate_overhang_speed(const ExtrusionAttributes &attributes,
const FullPrintConfig &config,
size_t extruder_id);
float calculate_overhang_speed(const ExtrusionAttributes &attributes,
const FullPrintConfig &config,
size_t extruder_id);
float calculate_overhang_fan_speed(const ExtrusionAttributes &attributes,
const FullPrintConfig &config,
size_t extruder_id);
void apply_overhang_flow(ExtrusionPath &path,
const PrintConfig &print_config,
const LayerRegion &region,

View file

@ -545,8 +545,8 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops_classic(const Para
// detect overhanging/bridging perimeters
ExtrusionPaths paths;
bool can_overhang = (params.config.overhangs_width_speed.is_enabled() ||
params.config.overhangs_width.is_enabled()) &&
bool can_overhang = params.config.overhangs.value &&
(params.config.overhangs_width_speed.is_enabled() || params.config.overhangs_width.is_enabled()) &&
params.layer->id() > 0 && params.layer->id() >= params.object_config.raft_layers;
if (params.object_config.support_material &&
params.object_config.support_material_contact_distance_type.value == zdNone) {
@ -1214,7 +1214,7 @@ void PerimeterGenerator::_sort_overhangs(const Parameters &params,
) const
{
const bool dynamic_enabled = params.config.overhangs &&
(params.config.overhangs_dynamic_speed.is_enabled() ||
(params.config.overhangs_width_speed.is_enabled() && params.config.overhangs_dynamic_speed.is_enabled() ||
(params.config.overhangs_flow_ratio.is_enabled() && params.config.overhangs_dynamic_flow.is_enabled()));
// reapply the nearest point search for starting point
// We allow polyline reversal because Clipper may have randomly reversed polylines during clipping.
@ -1802,7 +1802,8 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_extrusions(const Paramet
ExtrusionPaths paths;
// detect overhanging/bridging perimeters
if ( (params.config.overhangs_width_speed.is_enabled() || params.config.overhangs_width.is_enabled())
if (params.config.overhangs.value &&
(params.config.overhangs_width_speed.is_enabled() || params.config.overhangs_width.is_enabled())
&& params.layer->id() > 0 && params.layer->id() >= params.object_config.raft_layers
&& !((params.object_config.support_material || params.object_config.support_material_enforce_layers > 0) &&
params.object_config.support_material_contact_distance.value == 0)) {
@ -4148,26 +4149,28 @@ void PerimeterGenerator::process(// Input:
full_overhangs = union_ex(full_overhangs);
full_overhangs = diff_ex(full_overhangs, *simplified);
full_overhangs = offset2_ex(full_overhangs, SCALED_EPSILON * 10, SCALED_EPSILON * 10);
// offset2 the params.overhang_areas to remove overhangs that overlap too much (it overlpa inside the not-overhang area so it cna be removed withotu creating holes)
// offset2 the params.overhang_areas to remove overhangs that overlap too much (it overlap inside the
// not-overhang area so it can be removed withotu creating holes)
params.overhang_areas = offset_ex(full_overhangs, double(max_offset));
// intersection to remove the part over the surface
params.overhang_areas = intersection_ex(params.overhang_areas, srf_to_use.expolygon);
//now shrink where needed
// now shrink where needed
ExPolygons all_shrinks;
for (auto const &[opt_values, areas] : params.region_setting.get_areas(&params.config.overhangs)) {
const bool overhang_flow_enabled = opt_values.is_enabled(&params.config.overhangs_flow_ratio);
if (overhang_flow_enabled && opt_values.get_bool(&params.config.overhangs)) {
coord_t overhangs_width_flow = scale_t(
coord_t overhangs_width_flow = scale_t(
opt_values.get_abs_value(this->params.overhang_flow.nozzle_diameter(),
&params.config.overhangs_width));
append(all_shrinks, offset_ex(areas.intersections(params.overhang_areas), double(overhangs_width_flow)));
append(all_shrinks,
offset_ex(areas.intersections(params.overhang_areas), double(overhangs_width_flow)));
}
}
// intersect with full_overhangs, to remove the part that are still inside the not-overhang area
params.overhang_areas = intersection_ex(union_ex(all_shrinks), full_overhangs);
//offset ?
//params.overhang_areas = offset_ex(params.overhang_areas, params.get_overhang_spacing() / 2);
//params.overhang_areas = intersection_ex(params.overhang_areas, srf_to_use.expolygon);
// offset ?
// params.overhang_areas = offset_ex(params.overhang_areas, params.get_overhang_spacing() / 2);
// params.overhang_areas = intersection_ex(params.overhang_areas, srf_to_use.expolygon);
}
const coordf_t half_extperi_offset = (coordf_t)(params.get_ext_perimeter_width() / 2);
@ -4203,11 +4206,27 @@ void PerimeterGenerator::process(// Input:
overhangs_width_speed = scale_t(
opt_values.get_abs_value(this->params.overhang_flow.nozzle_diameter(),
&params.config.overhangs_width_speed));
} else {
} else if(overhang_flow_enabled) {
overhangs_width_speed = scale_t(
opt_values.get_abs_value(this->params.overhang_flow.nozzle_diameter(),
&params.config.overhangs_width));
}
} else {
// no flow, no speed, we only compute the "dynamic" part for possible fan_speed
// no flow: use the biggest and simpliest bb so all the extrusion will be inside.
Polygons offseted;
if (areas.is_accept_all()) {
// only one region, go big.
offseted = {get_extents(srf_to_use.expolygon.contour).polygon()};
} else {
//multiple region, ensure it's inside bounds.
offseted = union_(areas.expolys);
}
params.lower_slices_bridge_speed_small = offseted;
params.lower_slices_bridge_speed_big = offseted;
params.lower_slices_bridge_flow_small = offseted;
params.lower_slices_bridge_flow_big = offseted;
continue;
}
} else {
overhangs_width_speed = overhangs_width_flow;
}

View file

@ -1450,6 +1450,31 @@ namespace client
}
output.it_range = opt.it_range;
}
// Return a boolean value, true if the scalar variable referenced by "opt" or "opt[index]" is enabled.
static void interpolate_graph(const MyContext *ctx, OptWithPos &opt, expr &valeur, expr &output)
{
if (ctx->skipping()) {
} else if (opt.opt->is_vector()) {
if (! opt.has_index())
ctx->throw_exception("Referencing a vector variable when scalar is expected", opt.it_range);
if (opt.opt->size() == 0)
ctx->throw_exception("Indexing an empty vector variable", opt.it_range);
if (opt.opt->type() != ConfigOptionType::coGraphs)
ctx->throw_exception("Interpolate on a variable that isn't a graph", opt.it_range);
expr::throw_if_not_numeric(valeur);
double val_x = valeur.type() == expr::Type::TYPE_DOUBLE ? (valeur.as_d()) : (valeur.as_i() * 1.);
output.set_d(((ConfigOptionGraphs*)opt.opt)->get_at(opt.index).interpolate(val_x));
} else {
assert(opt.opt->is_scalar());
if (opt.opt->type() != ConfigOptionType::coGraph)
ctx->throw_exception("Interpolate on a variable that isn't a graph", opt.it_range);
expr::throw_if_not_numeric(valeur);
double val_x = valeur.type() == expr::Type::TYPE_DOUBLE ? (valeur.as_d()) : (valeur.as_i() * 1.);
output.set_d(((ConfigOptionGraph*)opt.opt)->value.interpolate(val_x));
}
output.it_range = opt.it_range;
}
// Return a boolean value, true if an element of a variable referenced by "opt" or "opt[index]" is disabled.
static void is_nil_test(const MyContext *ctx, OptWithPos &opt, expr &output)
{
@ -2459,6 +2484,8 @@ namespace client
| (kw["ceil"] > '(' > conditional_expression(_r1) > ')') [ px::bind(&FactorActions::ceil, _1, _val) ]
| (kw["is_nil"] > '(' > variable_reference(_r1) > ')') [px::bind(&MyContext::is_nil_test, _r1, _1, _val)] // Deprecated same as !is_enabled
| (kw["is_enabled"] > '(' > variable_reference(_r1) > ')') [px::bind(&MyContext::is_enabled_test, _r1, _1, _val)]
| (kw["interpolate"] > '(' > variable_reference(_r1) > ',' > conditional_expression(_r1) > ')')
[ px::bind(&MyContext::interpolate_graph, _r1, _1, _2, _val) ]
| (kw["one_of"] > '(' > one_of(_r1) > ')') [ _val = _1 ]
| (kw["empty"] > '(' > variable_reference(_r1) > ')') [px::bind(&MyContext::is_vector_empty, _r1, _1, _val)]
| (kw["size"] > '(' > variable_reference(_r1) > ')') [px::bind(&MyContext::vector_size, _r1, _1, _val)]
@ -2542,6 +2569,7 @@ namespace client
("endif")
("false")
("global")
("interpolate")
("interpolate_table")
("min")
("max")
@ -2567,6 +2595,7 @@ namespace client
debug(text_block);
debug(macros);
debug(if_else_output);
debug(interpolate_graph);
debug(interpolate_table);
// debug(switch_output);
debug(legacy_variable_expansion);
@ -2639,6 +2668,7 @@ namespace client
qi::rule<Iterator, expr(const MyContext*), qi::locals<expr>, skipper> one_of;
qi::rule<Iterator, expr(const MyContext*, const expr &param), skipper> one_of_list;
// Evaluating the "interpolate_table" expression.
qi::rule<Iterator, expr(const MyContext*), skipper> interpolate_graph;
qi::rule<Iterator, expr(const MyContext*), qi::locals<expr>, skipper> interpolate_table;
qi::rule<Iterator, InterpolateTableContext(const MyContext*, const expr &param), skipper> interpolate_table_list;

View file

@ -3467,15 +3467,6 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvancedE | comPrusa;
def->set_default_value(new ConfigOptionFloatOrPercent(0,false));
def = this->add("travel_acceleration", coFloat);
def->label = L("Travel");
def->tooltip = L("This is the acceleration your printer will use for travel moves. Set zero to disable "
"acceleration control for travel.");
def->sidetext = L("mm/s²");
def->min = 0;
def->mode = comExpert | comPrusa;
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("infill_every_layers", coInt);
def->label = L("Combine infill every");
def->category = OptionCategory::infill;
@ -4582,11 +4573,12 @@ void PrintConfigDef::init_fff_params()
def = this->add("overhangs_dynamic_fan_speed", coGraphs);
def->label = L("Dynamic overhang speeds");
def->category = OptionCategory::speed;
def->tooltip = L("This setting can only works correctly if dynamic speed is also enabled (overhangs_dynamic_fan_speed)."
"\nOverhang size is expressed as a percentage of overlap of the extrusion with the previous layer: "
"100% would be full overlap (no overhang), while 0% represents full overhang (floating extrusion, bridge)."
"\nFan speeds for overhang sizes in between are calculated via linear interpolation."
"\nIf enabled, overhangs_fan_speed is disabled, as the fan speed for full overhang is used.");
def->tooltip = L("Adjusts the fan speed based on the severity of overhangs."
"\nOverhang size is defined as the percentage of overlap with the previous layer: "
"100% means full overlap (no overhang), while 0% indicates a full overhang (unsupported extrusion, i.e., a bridge)."
"\nFan speeds for intermediate overhang values are calculated using linear interpolation."
"\nWhen this option is enabled, 'overhangs_fan_speed' is ignored, as this setting now control the overhang fan speed."
" For extrusion that not supported at all, the fan spedd for 0% is used.");
def->sidetext = L("%");
def->is_vector_extruder = true;
def->can_be_disabled = true;

View file

@ -2083,7 +2083,7 @@ void generate_support_toolpaths(
base_interface_layer.extrusions.set_entities(),
//base_layer_interface.extrusions,
// Regions to fill
union_safety_offset_ex(base_interface_layer.polygons_to_extrude()),
ensure_valid(union_safety_offset_ex(base_interface_layer.polygons_to_extrude())),
// Filler and its parameters
filler, float(support_params.interface_density),
// Extrusion parameters

View file

@ -82,7 +82,7 @@ void export_print_z_polygons_and_extrusions_to_svg(
const char *path,
SupportGeneratorLayer ** const layers,
int n_layers,
SupportLayer &support_layer)
const SupportLayer &support_layer)
{
BoundingBox bbox;
for (int i = 0; i < n_layers; ++ i)

View file

@ -13,7 +13,7 @@ class SupportLayer;
namespace FFFSupport {
void export_print_z_polygons_to_svg(const char *path, SupportGeneratorLayer ** const layers, size_t n_layers);
void export_print_z_polygons_and_extrusions_to_svg(const char *path, SupportGeneratorLayer ** const layers, size_t n_layers, SupportLayer& support_layer);
void export_print_z_polygons_and_extrusions_to_svg(const char *path, SupportGeneratorLayer ** const layers, size_t n_layers, const SupportLayer& support_layer);
} // namespace FFFSupport

View file

@ -55,6 +55,8 @@
#define DEBUG
#define _DEBUG
#undef NDEBUG
#include "SupportDebug.hpp"
#include "SupportDebug.cpp"
#include "../utils.hpp"
#include "../SVG.hpp"
#endif
@ -670,7 +672,7 @@ public:
// Remove all the pieces, which do not contain any of the island_samples.
Polygons extract_support(const coord_t offset_in_grid, bool fill_holes
#ifdef SLIC3R_DEBUG
, const char *step_name, int iRun, size_t layer_id, double print_z
, const char *step_name, int iRun, size_t layer_id, double print_z_mm
#endif
)
{
@ -748,7 +750,7 @@ public:
bbox.merge(get_extents(out));
if (!support_polygons_simplified.empty())
bbox.merge(get_extents(support_polygons_simplified));
SVG svg(debug_out_path("extract_support_from_grid_trimmed-%s-%d-%d-%lf.svg", step_name, iRun, layer_id, print_z).c_str(), bbox);
SVG svg(debug_out_path("extract_support_from_grid_trimmed-smsGrid-%s-%d-%d-%lf.svg", step_name, iRun, layer_id, print_z_mm).c_str(), bbox);
svg.draw(union_ex(support_polygons_simplified), "gray", 0.25f);
svg.draw(islands, "red", 0.5f);
svg.draw(union_ex(out), "green", 0.5f);
@ -774,7 +776,7 @@ public:
auto closing_distance = scaled<float>(m_support_material_closing_radius);
auto smoothing_distance = scaled<float>(m_extrusion_width);
#ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("extract_support_from_grid_trimmed-%s-%d-%d-%lf.svg", step_name, iRun, layer_id, print_z),
SVG::export_expolygons(debug_out_path("extract_support_from_grid_trimmed-smsSnug-%s-%d-%d-%lf.svg", step_name, iRun, layer_id, print_z_mm),
{ { { diff_ex(expand(*m_support_polygons, closing_distance), closing(*m_support_polygons, closing_distance, SUPPORT_SURFACES_OFFSET_PARAMETERS)) }, { "closed", "blue", 0.5f } },
{ { union_ex(smooth_outward(closing(*m_support_polygons, closing_distance, SUPPORT_SURFACES_OFFSET_PARAMETERS), smoothing_distance)) }, { "regularized", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } },
{ { union_ex(*m_support_polygons) }, { "src", "green", 0.5f } },
@ -791,7 +793,7 @@ public:
#if defined(SLIC3R_DEBUG) && ! defined(SUPPORT_USE_AGG_RASTERIZER)
void serialize(const std::string &path)
{
FILE *file = ::fopen(path.c_str(), "wb");
FILE *file = boost::nowide::fopen(path.c_str(), "wb");
::fwrite(&m_support_spacing, 8, 1, file);
::fwrite(&m_support_angle, 8, 1, file);
uint32_t n_polygons = m_support_polygons->size();
@ -831,7 +833,7 @@ public:
// Deserialization constructor
bool deserialize_(const std::string &path, int which = -1)
{
FILE *file = ::fopen(path.c_str(), "rb");
FILE *file = boost::nowide::fopen(path.c_str(), "rb");
if (file == nullptr)
return false;
@ -1251,6 +1253,7 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
0.;
float no_interface_offset = 0.f;
coord_t max_flow_width = 0;
if (layer_id == 0)
{
// This is the first object layer, so the object is being printed on a raft and
@ -1264,6 +1267,10 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
#endif
// Expand for better stability.
contact_polygons = object_config.raft_expansion.value > 0 ? expand(overhang_polygons, scaled<float>(object_config.raft_expansion.value)) : overhang_polygons;
for (LayerRegion *layerm : layer.regions()) {
max_flow_width = std::max(max_flow_width, (layerm->flow(frExternalPerimeter).scaled_width()));
}
}
else if (! layer.regions().empty())
{
@ -1298,7 +1305,8 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
for (LayerRegion *layerm : layer.regions()) {
// Extrusion width accounts for the roundings of the extrudates.
// It is the maximum widh of the extrudate.
float fw = float(layerm->flow(frExternalPerimeter).scaled_width());
coord_t flow_width = float(layerm->flow(frExternalPerimeter).scaled_width());
max_flow_width = std::max(max_flow_width, flow_width);
lower_layer_offset =
(layer_id < (size_t)object_config.support_material_enforce_layers.value) ?
// Enforce a full possible support, ignore the overhang angle.
@ -1307,7 +1315,7 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
// Overhang defined by an angle.
float(scale_(lower_layer.height / tan(threshold_rad))) :
// Overhang defined by half the extrusion width.
0.5f * fw);
flow_width / 2);
// Overhang polygons for this layer and region.
ExPolygons diff_polygons;
for(auto &srf : layerm->slices().surfaces) srf.expolygon.assert_valid();
@ -1333,10 +1341,10 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
// are not supporting this layer.
// However this may lead to a situation where regions at the current layer that are narrow thus not extrudable will generate unnecessary supports.
// For example, see GH issue #3094
opening_ex(lower_layer_polygons, 0.5f * fw, lower_layer_offset + 0.5f * fw, SUPPORT_SURFACES_OFFSET_PARAMETERS)),
opening_ex(lower_layer_polygons, 0.5f * flow_width, lower_layer_offset + 0.5f * flow_width, SUPPORT_SURFACES_OFFSET_PARAMETERS)),
//FIXME This opening is targeted to reduce very thin regions to support, but it may lead to
// no support at all for not so steep overhangs.
0.1f * fw);
0.1f * fflow_widthw);
#else
diff_polygons =
diff_ex(layerm_expolygons,
@ -1387,7 +1395,7 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
if (object_config.dont_support_bridges) {
// FIXME Expensive, potentially not precise enough. Misses gap fill extrusions, which bridge.
assert_valid(diff_polygons);
remove_bridges_from_contacts(print_config, lower_layer, *layerm, fw, diff_polygons);
remove_bridges_from_contacts(print_config, lower_layer, *layerm, double(flow_width), diff_polygons);
ensure_valid(diff_polygons, resolution);
}
@ -1399,7 +1407,7 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
debug_out_path("support-top-contacts-filtered-run%d-layer%d-region%d-z%f.svg",
iRun, layer_id,
std::find_if(layer.regions().begin(), layer.regions().end(), [layerm](const LayerRegion* other){return other == layerm;}) - layer.regions().begin(),
layer.print_z),
layer.scaled_print_z()),
union_ex(diff_polygons));
#endif /* SLIC3R_DEBUG */
@ -1449,7 +1457,7 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
//note: don't diff with inflated lower_layer_polygons, or the slopes will be unsupported.
enforcer_polygons = intersection(layer.lslices(), enforcer_polygons_src);
#ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-top-contacts-enforcers-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z),
SVG::export_expolygons(debug_out_path("support-top-contacts-enforcers-run%d-layer%d-z%f.svg", iRun, layer_id, layer.scaled_print_z()),
{ { layer.lslices(), { "layer.lslices", "gray", 0.2f } },
{ { union_ex(lower_layer_polygons) }, { "lower_layer_polygons", "green", 0.5f } },
{ enforcers_united, { "enforcers", "blue", 0.5f } },
@ -1466,6 +1474,9 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
}
}
}
overhang_polygons = closing(overhang_polygons, double(max_flow_width) * 0.1);
contact_polygons = closing(contact_polygons, double(max_flow_width) * 0.1);
enforcer_polygons = closing(enforcer_polygons, double(max_flow_width) * 0.1);
return std::make_tuple(std::move(overhang_polygons), std::move(contact_polygons), std::move(enforcer_polygons), no_interface_offset);
}
@ -1891,7 +1902,7 @@ static inline SupportGeneratorLayer* detect_bottom_contacts(
Polygons top = collect_region_slices_by_type(layer, stPosTop | stDensSolid);
assert_valid(top);
#ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-bottom-layers-raw-%d-%lf.svg", iRun, layer.print_z),
SVG::export_expolygons(debug_out_path("support-bottom-layers-raw-%d-%lf.svg", iRun, layer.scaled_print_z()),
{ { { union_ex(top) }, { "top", "blue", 0.5f } },
{ { union_safety_offset_ex(supports_projected) }, { "overhangs", "magenta", 0.5f } },
{ layer.lslices(), { "layer.lslices", "green", 0.5f } },
@ -1930,7 +1941,8 @@ static inline SupportGeneratorLayer* detect_bottom_contacts(
layer_new.height_block = ((object.config().support_material_contact_distance_type.value == zdPlane) ? object.layers()[layer_id + 1]->height : layer_new.height);
layer_new.print_z = slicing_params.soluble_interface ? layer.upper_layer->print_z :
layer.print_z + layer_new.height_block + slicing_params.gap_object_support;
layer_new.bottom_z = layer.print_z;
layer_new.bottom_z = slicing_params.soluble_interface ? layer.print_z :
(layer.print_z + slicing_params.gap_object_support);
//recompute layer height to be in synch with print & bottom
layer_new.height = layer_new.print_z - layer_new.bottom_z;
layer_new.idx_object_layer_below = layer_id;

View file

@ -251,11 +251,11 @@ void parallel_for(size_t begin, size_t size, std::function<void(size_t)> process
//For now, this is just use in debug mode, to be able toswitch from // to sequential withotu recompiling evrything.
// normal step
tbb::parallel_for(begin, size, [&process_one_item](size_t item_idx) { process_one_item(item_idx); });
//tbb::parallel_for(begin, size, [&process_one_item](size_t item_idx) { process_one_item(item_idx); });
// if you need to debug without // stuff
//for (size_t idx = begin; idx < size; ++idx) {
// process_one_item(idx);
//}
for (size_t idx = begin; idx < size; ++idx) {
process_one_item(idx);
}
}
void not_parallel_for(size_t begin, size_t size, std::function<void(size_t)> process_one_item) {
for (size_t idx = begin; idx < size; ++idx) {

View file

@ -37,11 +37,12 @@ extern void enforce_thread_count(std::size_t count);
extern size_t total_physical_memory();
// Set a path with GUI resource files.
void set_var_dir(const std::string &path);
void set_icons_dir(const std::string &path);
// Return a full path to the GUI resource files.
const std::string& var_dir();
const std::string& icons_dir();
const boost::filesystem::path& icons_path();
// Return a full resource path for a file_name.
std::string var(const std::string &file_name);
std::string get_icon_file(const std::string &file_name);
// Set the path of the binary that execute this code
void set_binary_file(const boost::filesystem::path &path);
@ -58,11 +59,13 @@ const boost::filesystem::path& install_path();
void set_resources_dir(const std::string &path);
// Return a full path to the resources directory.
const std::string& resources_dir();
const boost::filesystem::path& resources_path();
// Set a path with GUI localization files.
void set_local_dir(const std::string &path);
// Return a full path to the localization directory.
const std::string& localization_dir();
const boost::filesystem::path& localization_path();
// Set a path with shapes gallery files.
void set_sys_shapes_dir(const std::string &path);
@ -81,6 +84,7 @@ const std::string& custom_gcodes_dir();
void set_data_dir(const std::string &path);
// Return a full path to the GUI resource files.
const std::string& data_dir();
const boost::filesystem::path& data_path();
bool has_data_dir();
// Format an output path for debugging purposes.

View file

@ -159,29 +159,75 @@ void enforce_thread_count(const std::size_t count)
#endif // TBB_HAS_GLOBAL_CONTROL
}
static std::string g_var_dir;
void set_var_dir(const std::string &dir)
boost::filesystem::path clean_absolute_path(const boost::filesystem::path &path)
{
g_var_dir = dir;
assert(path.is_absolute());
// make sure the path is well formed for the os.
boost::filesystem::path fixpath(path);
// note: lexically_normal() already do make_preferred()
fixpath.lexically_normal();
#ifndef _WIN32
fixpath = boost::filesystem::canonical(fixpath);
#else
if (!fixpath.empty() && fixpath.string().front() != '\\') {
if (boost::filesystem::exists(fixpath)) {
// if the path exists, we can canonicalize it and add the long path prefix, which will resolve any ".." or
// "." in the path and give us a proper absolute path.
fixpath = R"(\\?\)" + boost::filesystem::canonical(fixpath).string();
} else if (boost::filesystem::exists(fixpath.parent_path())) {
// if the path doesn't exist, but the parent path exists, we can canonicalize the parent path and then
// append the filename
fixpath = R"(\\?\)" + (boost::filesystem::canonical(fixpath.parent_path()) / fixpath.filename()).string();
} else {
// if the path doesn't exist, we can't canonicalize it, so we just add the long path prefix and hope for the best
fixpath = R"(\\?\)" + fixpath.string();
}
}
#endif
assert(fixpath.string().find("..") == std::string::npos);
assert(fixpath.is_absolute());
return fixpath;
}
const std::string& var_dir()
std::string clean_dir(const std::string &dir_name)
{
return g_var_dir;
// make sure the path is well formed for the os.
boost::filesystem::path fixpath(dir_name);
// note: lexically_normal() already do make_preferred()
fixpath.lexically_normal();
assert(fixpath.string().find("..") == std::string::npos);
return fixpath.string();
}
std::string var(const std::string &file_name)
static std::string g_icons_dir;
static boost::filesystem::path g_icons_path;
void set_icons_dir(const std::string &dir)
{
auto file = (boost::filesystem::path(g_var_dir) / file_name).make_preferred();
return file.string();
g_icons_dir = clean_dir(dir);
g_icons_path = clean_absolute_path(dir);
}
const std::string& icons_dir()
{
return g_icons_dir;
}
const boost::filesystem::path& icons_path()
{
return g_icons_path;
}
std::string get_icon_file(const std::string &file_name)
{
return (g_icons_path / file_name).make_preferred().string();
}
static boost::filesystem::path g_binary_file;
void set_binary_file(const boost::filesystem::path &file)
{
g_binary_file = file;
g_binary_file = clean_absolute_path(file);
}
const boost::filesystem::path& binary_file()
@ -194,7 +240,7 @@ static boost::filesystem::path g_install_path;
void set_install_path(const boost::filesystem::path &file)
{
g_install_path = file;
g_install_path = clean_absolute_path(file);
}
const boost::filesystem::path& install_path()
@ -203,10 +249,12 @@ const boost::filesystem::path& install_path()
}
static std::string g_resources_dir;
static boost::filesystem::path g_resources_path;
void set_resources_dir(const std::string &dir)
{
g_resources_dir = dir;
g_resources_dir = clean_dir(dir);
g_resources_path = clean_absolute_path(dir);
}
const std::string& resources_dir()
@ -214,11 +262,18 @@ const std::string& resources_dir()
return g_resources_dir;
}
const boost::filesystem::path& resources_path()
{
return g_resources_path;
}
static std::string g_local_dir;
static boost::filesystem::path g_local_path;
void set_local_dir(const std::string &dir)
{
g_local_dir = dir;
g_local_dir = clean_dir(dir);
g_local_path = clean_absolute_path(dir);
}
const std::string& localization_dir()
@ -226,11 +281,18 @@ const std::string& localization_dir()
return g_local_dir;
}
const boost::filesystem::path& localization_path()
{
return g_local_path;
}
static std::string g_sys_shapes_dir;
static boost::filesystem::path g_sys_shapes_path;
void set_sys_shapes_dir(const std::string &dir)
{
g_sys_shapes_dir = dir;
g_sys_shapes_dir = clean_dir(dir);
g_sys_shapes_path = clean_absolute_path(dir);
}
const std::string& sys_shapes_dir()
@ -238,36 +300,49 @@ const std::string& sys_shapes_dir()
return g_sys_shapes_dir;
}
static std::string g_custom_gcodes_dir;
void set_custom_gcodes_dir(const std::string &dir)
const boost::filesystem::path& sys_shapes_path()
{
g_custom_gcodes_dir = dir;
return g_sys_shapes_path;
}
const std::string& custom_gcodes_dir()
{
return g_custom_gcodes_dir;
}
// not used
// static std::string g_custom_gcodes_dir;
// void set_custom_gcodes_dir(const std::string &dir)
// {
// g_custom_gcodes_dir = clean_absolute_path(dir).string();
// }
// const std::string& custom_gcodes_dir()
// {
// return g_custom_gcodes_dir;
// }
// Translate function callback, to call wxWidgets translate function to convert non-localized UTF8 string to a localized one.
Slic3r::I18N::translate_fn_type Slic3r::I18N::translate_fn = nullptr;
static std::string g_data_dir;
static boost::filesystem::path g_data_path;
void set_data_dir(const std::string &dir)
{
// make sure the path is well formed for the os.
boost::filesystem::path fixpath(dir);
g_data_dir = fixpath.make_preferred().string();
g_data_dir = clean_dir(dir);
g_data_path = clean_absolute_path(dir);
}
const std::string& data_dir()
{
assert(!g_data_dir.empty());
// this function can be used to check for emptyness
//assert(!g_data_dir.empty());
return g_data_dir;
}
const boost::filesystem::path& data_path()
{
assert(!g_data_path.empty());
return g_data_path;
}
bool has_data_dir() { return !g_data_dir.empty(); }
std::string custom_shapes_dir()
{
@ -280,7 +355,7 @@ std::string debug_out_path(const char *name, ...)
{
static constexpr const char *SLIC3R_DEBUG_OUT_PATH_PREFIX = "out/";
if (!debug_out_path_called.exchange(true)) {
std::string path = boost::filesystem::system_complete(SLIC3R_DEBUG_OUT_PATH_PREFIX).string();
std::string path = clean_absolute_path(boost::filesystem::system_complete(SLIC3R_DEBUG_OUT_PATH_PREFIX)).string();
printf("Debugging output files will be written to %s\n", path.c_str());
}
char buffer[2048];
@ -304,7 +379,7 @@ std::string debug_out_path_uniqueid(std::string name, ...) {
static constexpr const char *SLIC3R_DEBUG_OUT_PATH_PREFIX = "out/";
if (!debug_out_path_called.exchange(true)) {
std::string path = boost::filesystem::system_complete(SLIC3R_DEBUG_OUT_PATH_PREFIX).string();
std::string path = clean_absolute_path(boost::filesystem::system_complete(SLIC3R_DEBUG_OUT_PATH_PREFIX)).string();
printf("Debugging output files will be written to %s\n", path.c_str());
}
char buffer[2048];

View file

@ -3,6 +3,7 @@ import configparser
import shutil
import os
import sys
import pathlib
# list of repositories to download for each release.
all_repositories= [
@ -20,6 +21,8 @@ if not os.path.exists(out_resources):
print("error, the path "+out_resources+" doesn't exists")
sys.exit(1)
os.makedirs(out_resources+"/profiles", exist_ok=True)
for url in all_repositories:
print(f"Cloning {url}...")
try:
@ -28,7 +31,15 @@ for url in all_repositories:
print(f"Failed to clone {url}: {e}")
repo_name_with_git = os.path.basename(url)
repo_name = repo_name_with_git.removesuffix('.git')
# log
print("> Files in {repo_name}:")
for f in pathlib.Path(repo_name).iterdir():
print(f.name)
print("> Files in {repo_name}/profiles:")
for f in pathlib.Path(repo_name + "/profiles").iterdir():
print(f.name)
# get id
config = configparser.ConfigParser()
with open(repo_name+"/description.ini", "r", encoding="utf-8") as f:
@ -36,6 +47,8 @@ for url in all_repositories:
vendor_id = config.get("vendor", "id")
print(f"Vendor ID: {vendor_id}")
# copy into our resources
print(f"copy from: '{repo_name}/profiles/{vendor_id}.ini' to '{out_resources}/profiles/{vendor_id}.ini'")
shutil.copy(repo_name + "/profiles/"+vendor_id+".ini", out_resources+"/profiles/"+vendor_id+".ini");
#copy the icon directory
if os.path.exists(out_resources+"/profiles/"+vendor_id):

View file

@ -505,15 +505,15 @@ semver_satisfies (semver_t x, semver_t y, const char *op) {
void
semver_free (semver_t *x) {
if (x->metadata) {
if (x->metadata != NULL) {
free(x->metadata);
x->metadata = NULL;
}
if (x->prerelease) {
if (x->prerelease != NULL) {
free(x->prerelease);
x->prerelease = NULL;
}
if (x->counters) {
if (x->counters != NULL) {
x->counter_size = 0;
free(x->counters);
x->counters = NULL;
@ -688,8 +688,10 @@ semver_copy(const semver_t *ver) {
if (ver->prerelease != NULL) {
res.prerelease = strdup(ver->prerelease);
}
if (ver->counters) {
if (ver->counters != NULL) {
res.counters = semver_intdup(ver->counters, ver->counter_size);
if (res.counters == NULL)
res.counter_size = 0;
}
return res;
}

View file

@ -19,6 +19,7 @@
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "GLCanvas3D.hpp"
#include "OpenGLManager.hpp"
#include "Plater.hpp"
#include "Camera.hpp"
@ -414,22 +415,22 @@ void Bed3D::render_grid(bool bottom, bool has_model)
grid_color = DEFAULT_SOLID_GRID_COLOR;
else if (bottom)
grid_color = DEFAULT_TRANSPARENT_GRID_COLOR;
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(0.5f * m_scale_factor));
m_gridlines_small.set_color(grid_color);
m_gridlines_small.render();
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.5f * m_scale_factor));
float line_width = OpenGLManager::get_gl_info().get_min_line_width();
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
glsafe(::glLineWidth(line_width * m_scale_factor));
m_gridlines_small.set_color(grid_color);
m_gridlines_small.render();
line_width += 1;
}
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
glsafe(::glLineWidth(line_width * m_scale_factor));
line_width *= 2;
}
m_gridlines.set_color(grid_color);
m_gridlines.render();
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(3.0f * m_scale_factor));
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
glsafe(::glLineWidth(line_width * m_scale_factor));
}
m_gridlines_big.set_color(grid_color);
m_gridlines_big.render();
}
@ -479,10 +480,8 @@ void Bed3D::render_camera_grid(const Transform3d &view_matrix,
grid_color = DEFAULT_SOLID_GRID_COLOR;
else
grid_color = DEFAULT_TRANSPARENT_GRID_COLOR;
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(0.5f * m_scale_factor));
if (OpenGLManager::get_gl_info().get_max_line_width() > 1)
glsafe(::glLineWidth(std::max(OpenGLManager::get_gl_info().get_min_line_width(), 0.5f) * m_scale_factor));
m_gridlines_camera.set_color(grid_color);
m_gridlines_camera.render();
@ -729,10 +728,9 @@ void Bed3D::render_contour(const Transform3d& view_matrix, const Transform3d& pr
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
// draw contour
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.5f * m_scale_factor));
if (OpenGLManager::get_gl_info().get_max_line_width() > 1)
glsafe(::glLineWidth(std::max(OpenGLManager::get_gl_info().get_min_line_width() + 1.f, 1.5f) *
m_scale_factor));
m_contourlines.render();
glsafe(::glDisable(GL_BLEND));

View file

@ -12,11 +12,12 @@
#include <GL/glew.h>
#include "3DScene.hpp"
#include "GLShader.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
#include "BitmapCache.hpp"
#include "Camera.hpp"
#include "GLShader.hpp"
#include "GUI_App.hpp"
#include "OpenGLManager.hpp"
#include "Plater.hpp"
#include "libslic3r/BuildVolume.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
@ -147,10 +148,9 @@ void GLVolume::NonManifoldEdges::render()
{
update();
#if ENABLE_GL_CORE_PROFILE
if (!GUI::OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
if (GUI::OpenGLManager::get_gl_info().get_max_line_width() > 1) {
glsafe(::glLineWidth(2.0f));
}
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
if (shader == nullptr)

View file

@ -27,7 +27,7 @@ AboutDialogLogo::AboutDialogLogo(wxWindow* parent)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
{
this->SetBackgroundColour(*wxWHITE);
this->logo = wxBitmap(from_u8(Slic3r::var(SLIC3R_APP_KEY"_192px.png")), wxBITMAP_TYPE_PNG);
this->logo = get_bmp_bundle(GUI_App::dark_mode() ? wxGetApp().light_icon_name() : wxGetApp().dark_icon_name(), 192)->GetBitmap(wxSize(192, 192));
this->SetMinSize(this->logo.GetSize());
this->Bind(wxEVT_PAINT, &AboutDialogLogo::onRepaint, this);
@ -253,15 +253,16 @@ AboutDialog::AboutDialog()
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
hsizer->Add(vsizer, 2, wxEXPAND|wxLEFT, 20);
// title is in the logo
// title
{
wxStaticText* title = new wxStaticText(this, wxID_ANY, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME, wxDefaultPosition, wxDefaultSize);
wxFont title_font = GUI::wxGetApp().bold_font();
title_font.SetFamily(wxFONTFAMILY_ROMAN);
title_font.SetPointSize(int(2.5 * title_font.GetPointSize()));//title_font.SetPointSize(24);
title->SetFont(title_font);
vsizer->Add(title, 0, wxALIGN_LEFT | wxTOP, 10);
}
//{
// wxStaticText* title = new wxStaticText(this, wxID_ANY, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME, wxDefaultPosition, wxDefaultSize);
// wxFont title_font = GUI::wxGetApp().bold_font();
// title_font.SetFamily(wxFONTFAMILY_ROMAN);
// title_font.SetPointSize(int(2.5 * title_font.GetPointSize()));//title_font.SetPointSize(24);
// title->SetFont(title_font);
// vsizer->Add(title, 0, wxALIGN_LEFT | wxTOP, 10);
//}
// version
{

View file

@ -188,14 +188,15 @@ wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vec
wxBitmapBundle* BitmapCache::insert_bndl(const std::string &bitmap_key, const char* data, size_t width, size_t height)
{
wxBitmapBundle* bndl = nullptr;
wxSize sizeDef(width, height);
auto it = m_bndl_map.find(bitmap_key);
if (it == m_bndl_map.end()) {
bndl = new wxBitmapBundle(wxBitmapBundle::FromSVG(data, wxSize(width, height)));
bndl = new wxBitmapBundle(wxBitmapBundle::FromSVG(data, sizeDef));
m_bndl_map[bitmap_key] = bndl;
}
else {
bndl = it->second;
*bndl = wxBitmapBundle::FromSVG(data, wxSize(width, height));
*bndl = wxBitmapBundle::FromSVG(data, sizeDef);
}
return bndl;
}
@ -375,13 +376,12 @@ wxBitmapBundle* BitmapCache::from_svg(const std::string& bitmap_name, unsigned t
//reduce hash to 16b
color_change_hash = ((color_change_hash >> 16) & 0x0000FFFF) ^ (color_change_hash & 0x0000FFFF);
if (target_width == 0)
target_width = target_height;
std::string bitmap_key = bitmap_name + (target_height != 0 ?
"-h" + std::to_string(target_height) :
"-w" + std::to_string(target_width))
std::string bitmap_key = bitmap_name +
(target_height > 0 ? "-h" + std::to_string(target_height) :
target_width > 0 ? "-w" + std::to_string(target_width) :
"")
//+ (dark_mode ? "-dm" : "")
+ (color_change_hash>0 ? std::string("-") + std::to_string(color_change_hash): "");
+ (color_change_hash > 0 ? std::string("-") + std::to_string(color_change_hash) : "");
auto it = m_bndl_map.find(bitmap_key);
if (it != m_bndl_map.end())
@ -400,9 +400,31 @@ wxBitmapBundle* BitmapCache::from_svg(const std::string& bitmap_name, unsigned t
color_changes.add(std::string("#ButtonBG"), std::string(has_dark_mode ? "#4E4E4E" : "#828282"));
std::string str;
nsvgGetDataFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), str, color_changes);
nsvgGetDataFromFileWithReplace(Slic3r::get_icon_file(bitmap_name + ".svg").c_str(), str, color_changes);
if (str.empty())
return nullptr;
// pre-load the svg to get he width & height to resize correctly
if (target_width == 0 || target_height == 0) {
wxCharBuffer copy(str.data());
NSVGimage *const svgImage = nsvgParse(copy.data(), "px", 96);
if (svgImage) {
// Somewhat unexpectedly, a non-null but empty image is returned even if
// the data is not SVG at all, e.g. without this check creating a bundle
// from any random file with FromSVGFile() would "work".
if (svgImage->width > 0 && svgImage->height > 0) {
if (target_width == 0 && target_height > 0) {
target_width = svgImage->width * target_height / svgImage->height;
} else if (target_width > 0 && target_height == 0) {
target_height = svgImage->height * target_width / svgImage->width;
} else if (target_width == 0 && target_height == 0) {
target_height = svgImage->height;
target_width = svgImage->width;
}
}
nsvgDelete(svgImage);
}
}
return insert_bndl(bitmap_key, str.data(), target_width, target_height);
}
@ -416,10 +438,11 @@ wxBitmapBundle* BitmapCache::from_png(const std::string& bitmap_name, unsigned w
}
color_change_hash = ((color_change_hash >> 16) & 0x0000FFFF) | (color_change_hash & 0x0000FFFF);
std::string bitmap_key = bitmap_name + (height != 0 ?
"-h" + std::to_string(height) :
"-w" + std::to_string(width))
+ (color_change_hash>0 ? std::string("-") + std::to_string(color_change_hash): "");
std::string bitmap_key = bitmap_name +
(height > 0 ? "-h" + std::to_string(height) :
width > 0 ? "-w" + std::to_string(width) :
"") +
(color_change_hash > 0 ? std::string("-") + std::to_string(color_change_hash) : "");
auto it = m_bndl_map.find(bitmap_key);
if (it != m_bndl_map.end())
@ -427,18 +450,20 @@ wxBitmapBundle* BitmapCache::from_png(const std::string& bitmap_name, unsigned w
wxImage image;
BOOST_LOG_TRIVIAL(debug) << "Loading (load_png) image: '"<<bitmap_name<<"'.png";
if (!image.LoadFile(Slic3r::GUI::from_u8(Slic3r::var(bitmap_name + ".png")), wxBITMAP_TYPE_PNG) ||
if (!image.LoadFile(Slic3r::GUI::from_u8(Slic3r::get_icon_file(bitmap_name + ".png")), wxBITMAP_TYPE_PNG) ||
image.GetWidth() == 0 || image.GetHeight() == 0)
return nullptr;
if (height != 0 && unsigned(image.GetHeight()) != height)
if (width <= 0 && height > 0) {
width = unsigned(0.5f + float(image.GetWidth()) * height / image.GetHeight());
else if (width != 0 && unsigned(image.GetWidth()) != width)
} else if (height <= 0 && width > 0) {
height = unsigned(0.5f + float(image.GetHeight()) * width / image.GetWidth());
}
if (height != 0 && width != 0)
if (height > 0 && width > 0 && image.GetWidth() != width && image.GetHeight() != height) {
image.Rescale(width, height, wxIMAGE_QUALITY_BILINEAR);
}
if (color_changes.has_value(int2rgb(9079434))) {
image = image.ConvertToGreyscale(m_gs, m_gs, m_gs);
} else {
@ -501,7 +526,7 @@ wxBitmapBundle* BitmapCache::from_png(const std::string& bitmap_name, unsigned w
// }
// }*/
//
// NSVGimage* image = nsvgParseFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), "px", 96.0f, replaces);
// NSVGimage* image = nsvgParseFromFileWithReplace(Slic3r::get_icon_file(bitmap_name + ".svg").c_str(), "px", 96.0f, replaces);
// if (image == nullptr)
// return nullptr;
//

View file

@ -402,10 +402,13 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
toggle_field("overhangs_reverse", can_have_overhangs_reverse);
toggle_field("overhangs_reverse_threshold", can_have_overhangs_reverse && config->opt_bool("overhangs_reverse"));
toggle_field("overhangs_speed_enforce", have_overhangs && !have_perimeter_loop && have_overhangs);
for (auto el : { "overhangs_speed", "overhangs_width_speed", "overhangs_dynamic_speed", "overhangs_flow_ratio" })
for (auto el : { "overhangs_width_speed", "overhangs_flow_ratio" })
toggle_field(el, have_overhangs);
bool have_overhangs_speed = have_overhangs && config->option("overhangs_width_speed")->is_enabled();
for (auto el : { "overhangs_speed", "overhangs_dynamic_speed", "overhangs_flow_ratio" })
toggle_field(el, have_overhangs_speed);
bool have_overhangs_flow = have_overhangs && config->option("overhangs_flow_ratio")->is_enabled();
for (auto el : { "overhangs_width", "overhangs_dynamic_flow" })
for (auto el : { "overhangs_width", "overhangs_dynamic_flow", "overhangs_type" })
toggle_field(el, have_overhangs_flow);

View file

@ -347,7 +347,7 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
% model.thumbnail
% vendor.id
% model.id;
load_bitmap(Slic3r::var(PRINTER_PLACEHOLDER), bitmap, bitmap_width);
load_bitmap(Slic3r::get_icon_file(PRINTER_PLACEHOLDER), bitmap, bitmap_width);
}
wxStaticText* title = new wxStaticText(this, wxID_ANY, from_u8(model.name), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
@ -1519,7 +1519,7 @@ PageDownloader::PageDownloader(ConfigWizard* parent)
: ConfigWizardPage(parent, _L("Downloads from URL"), _L("Downloads"))
{
const AppConfig* app_config = get_app_config();
auto boldfont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
auto boldfont = wxGetApp().bold_font();
boldfont.SetWeight(wxFONTWEIGHT_BOLD);
append_spacer(VERTICAL_SPACING);
@ -1763,7 +1763,7 @@ PageVendors::PageVendors(ConfigWizard *parent)
append_text(wxString::Format(_L("Pick another vendor supported by %s"), SLIC3R_APP_NAME) + ":");
auto boldfont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
auto boldfont = wxGetApp().bold_font();
boldfont.SetWeight(wxFONTWEIGHT_BOLD);
// Copy vendors from bundle map to vector, so we can sort it without case sensitivity
std::vector<std::pair<std::wstring, const VendorProfile*>> vendors;
@ -1790,7 +1790,7 @@ PageVendors::PageVendors(ConfigWizard *parent)
/*const*/ bool enabled;
{
std::lock_guard<std::recursive_mutex> lk(appconfig.config_lock);
const VendorMap &acvendors = appconfig.vendors();
const AppConfig::VendorMap &acvendors = appconfig.vendors();
enabled = acvendors.find(vendor->id) != acvendors.end();
}
if (enabled) {
@ -2133,7 +2133,7 @@ void PageTemperatures::apply_custom_config(DynamicPrintConfig &config)
ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
: wxScrolledWindow(parent)
, bg(ScalableBitmap(parent, SLIC3R_APP_KEY "_192px_transparent.png", 192))
, bg(ScalableBitmap(parent, get_bmp_bundle(GUI_App::dark_mode() ? wxGetApp().light_icon_name() : wxGetApp().dark_icon_name(), 192)->GetBitmap(wxSize(192, 192)), 192))
, bullet_black(ScalableBitmap(parent, "bullet_black.png"))
, bullet_blue(ScalableBitmap(parent, "bullet_blue.png"))
, bullet_white(ScalableBitmap(parent, "bullet_white.png"))
@ -3362,7 +3362,10 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
app_config->set_vendors(appconfig_new);
app_config->set("notify_release", page_update->version_check ? "all" : "none");
if (app_config->get("notify_release") != std::string(page_update->version_check ? "release" : "none")) {
app_config->set("notify_release", page_update->version_check ? "release" : "none");
app_config->set("version_online_seen", "");
}
app_config->set("preset_update", page_update->preset_update ? "1" : "0");
app_config->set("export_sources_full_pathnames", page_reload_from_disk->full_pathnames ? "1" : "0");

View file

@ -298,7 +298,7 @@ namespace GUI {
void BasicDrawPane::loadImage(std::string path) {
//wxImage image;
//if (!image.LoadFile(Slic3r::GUI::from_u8(Slic3r::var("C:/Users/VR-REMI/Downloads/1649109736.png")), wxBITMAP_TYPE_PNG) ||
//if (!image.LoadFile(Slic3r::GUI::from_u8(Slic3r::get_icon_file("C:/Users/VR-REMI/Downloads/1649109736.png")), wxBITMAP_TYPE_PNG) ||
// image.GetWidth() == 0 || image.GetHeight() == 0)
// return ;
if (boost::filesystem::exists(path))

View file

@ -298,8 +298,8 @@ void DesktopIntegrationDialog::perform_desktop_integration()
// Copy icon PrusaSlicer.png from resources_dir()/icons to target_dir_icons/icons/
if (contains_path_dir(target_candidates[i], "icons")) {
target_dir_icons = target_candidates[i];
std::string icon_path = GUI::format("%1%/icons/" SLIC3R_APP_KEY ".png",resources_dir());
std::string dest_path = GUI::format("%1%/icons/%2%" SLIC3R_APP_KEY "%3%.png", target_dir_icons, icon_theme_path, version_suffix);
std::string icon_path = GUI::format("%1%/icons/%2%.png",resources_dir(), GUI_App::dark_mode() ? wxGetApp().light_icon_name() : wxGetApp().dark_icon_name());
std::string dest_path = GUI::format("%1%/icons/%2%" SLIC3R_APP_KEY "%3%.png", target_dir_icons, icon_theme_path, version_suffix, GUI_App::dark_mode() ? wxGetApp().light_icon_name() : wxGetApp().dark_icon_name());
if (copy_icon(icon_path, dest_path))
break; // success
else
@ -311,7 +311,7 @@ void DesktopIntegrationDialog::perform_desktop_integration()
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/icons" + icon_theme_dirs);
// copy icon
target_dir_icons = GUI::format("%1%/.local/share",wxFileName::GetHomeDir());
std::string icon_path = GUI::format("%1%/icons/" SLIC3R_APP_KEY ".png",resources_dir());
std::string icon_path = GUI::format("%1%/icons/%2%.png",resources_dir(), GUI_App::dark_mode() ? wxGetApp().light_icon_name() : wxGetApp().dark_icon_name());
std::string dest_path = GUI::format("%1%/icons/%2%" SLIC3R_APP_KEY "%3%.png", target_dir_icons, icon_theme_path, version_suffix);
if (!contains_path_dir(target_dir_icons, "icons")
|| !copy_icon(icon_path, dest_path)) {

View file

@ -187,9 +187,9 @@ void FileGet::priv::get_perform()
FILE* file;
// open file for writting
if (m_written == 0)
file = fopen(temp_path_wstring.c_str(), "wb");
file = boost::nowide::fopen(temp_path_wstring.c_str(), "wb");
else
file = fopen(temp_path_wstring.c_str(), "ab");
file = boost::nowide::fopen(temp_path_wstring.c_str(), "ab");
//assert(file != NULL);
if (file == NULL) {

View file

@ -3941,12 +3941,17 @@ void GCodeViewer::render_toolpaths()
switch (buffer.render_primitive_type)
{
case TBuffer::ERenderPrimitiveType::Line: {
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
float lwidth = 1.f;
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
glsafe(::glLineWidth(static_cast<GLfloat>(line_width(camera.get_zoom()))));
lwidth = line_width(camera.get_zoom());
#else
glsafe(::glLineWidth(static_cast<GLfloat>(line_width(zoom))));
lwidth = line_width(zoom);
#endif // ENABLE_GL_CORE_PROFILE
lwidth = std::min(OpenGLManager::get_gl_info().get_max_line_width(), lwidth);
lwidth = std::max(OpenGLManager::get_gl_info().get_min_line_width(), lwidth);
glsafe(::glLineWidth(lwidth));
}
render_as_lines(it_path, buffer.render_paths.end(), *shader, uniform_color);
break;
}

View file

@ -78,9 +78,12 @@ namespace GUI {
#if ENABLE_GL_CORE_PROFILE
const bool core_profile = OpenGLManager::get_gl_info().is_core_profile();
if (!core_profile)
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.5f));
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
float min = std::min(.5f, OpenGLManager::get_gl_info().get_min_line_width());
glsafe(::glLineWidth(min + 1.f));
}
glsafe(::glDisable(GL_DEPTH_TEST));

View file

@ -30,9 +30,10 @@ GLShaderProgram::~GLShaderProgram()
bool GLShaderProgram::init_from_files(const std::string& name, const ShaderFilenames& filenames, const std::initializer_list<std::string_view> &defines)
{
// Load a shader program from file, prepend defs block.
auto load_from_file = [](const std::string& filename, const std::string &defs) {
std::string path = resources_dir() + "/shaders/" + filename;
boost::nowide::ifstream s(path, boost::nowide::ifstream::binary);
auto load_from_file = [](const boost::filesystem::path &filename, const std::string &defs) {
boost::filesystem::path path = resources_path() / "shaders" / filename;
assert(boost::filesystem::exists(path));
boost::nowide::ifstream s(path.generic_string(), boost::nowide::ifstream::binary);
if (!s.good()) {
BOOST_LOG_TRIVIAL(error) << "Couldn't open file: '" << path << "'";
return std::string();

View file

@ -12,6 +12,8 @@
#include <string>
#include <string_view>
#include <boost/filesystem.hpp>
#include "libslic3r/Point.hpp"
namespace Slic3r {
@ -33,7 +35,7 @@ public:
Count
};
typedef std::array<std::string, static_cast<size_t>(EShaderType::Count)> ShaderFilenames;
typedef std::array<boost::filesystem::path, static_cast<size_t>(EShaderType::Count)> ShaderFilenames;
typedef std::array<std::string, static_cast<size_t>(EShaderType::Count)> ShaderSources;
private:

View file

@ -43,50 +43,50 @@ std::pair<bool, std::string> GLShadersManager::init()
#if ENABLE_OPENGL_ES
const std::string prefix = "ES/";
// used to render wireframed triangles
valid &= append_shader("wireframe", { prefix + "wireframe.vs", prefix + "wireframe.fs" });
valid &= append_shader("wireframe", { prefix / "wireframe.vs", prefix / "wireframe.fs" });
#else
const std::string prefix = GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 1) ? "140/" : "110/";
const boost::filesystem::path prefix = GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 1) ? "140" : "110";
#endif // ENABLE_OPENGL_ES
// imgui shader
valid &= append_shader("imgui", { prefix + "imgui.vs", prefix + "imgui.fs" });
valid &= append_shader("imgui", { prefix / "imgui.vs", prefix / "imgui.fs" });
// basic shader, used to render all what was previously rendered using the immediate mode
valid &= append_shader("flat", { prefix + "flat.vs", prefix + "flat.fs" });
valid &= append_shader("flat", { prefix / "flat.vs", prefix / "flat.fs" });
// basic shader with plane clipping, used to render volumes in picking pass
valid &= append_shader("flat_clip", { prefix + "flat_clip.vs", prefix + "flat_clip.fs" });
valid &= append_shader("flat_clip", { prefix / "flat_clip.vs", prefix / "flat_clip.fs" });
// basic shader for textures, used to render textures
valid &= append_shader("flat_texture", { prefix + "flat_texture.vs", prefix + "flat_texture.fs" });
valid &= append_shader("flat_texture", { prefix / "flat_texture.vs", prefix / "flat_texture.fs" });
// used to render 3D scene background
valid &= append_shader("background", { prefix + "background.vs", prefix + "background.fs" });
valid &= append_shader("background", { prefix / "background.vs", prefix / "background.fs" });
#if ENABLE_OPENGL_ES
// used to render dashed lines
valid &= append_shader("dashed_lines", { prefix + "dashed_lines.vs", prefix + "dashed_lines.fs" });
valid &= append_shader("dashed_lines", { prefix / "dashed_lines.vs", prefix / "dashed_lines.fs" });
#elif ENABLE_GL_CORE_PROFILE
if (GUI::OpenGLManager::get_gl_info().is_core_profile())
// used to render thick and/or dashed lines
valid &= append_shader("dashed_thick_lines", { prefix + "dashed_thick_lines.vs", prefix + "dashed_thick_lines.fs", prefix + "dashed_thick_lines.gs" });
valid &= append_shader("dashed_thick_lines", { prefix / "dashed_thick_lines.vs", prefix / "dashed_thick_lines.fs", prefix / "dashed_thick_lines.gs" });
#endif // ENABLE_OPENGL_ES
// used to render toolpaths center of gravity
valid &= append_shader("toolpaths_cog", { prefix + "toolpaths_cog.vs", prefix + "toolpaths_cog.fs" });
valid &= append_shader("toolpaths_cog", { prefix / "toolpaths_cog.vs", prefix / "toolpaths_cog.fs" });
// used to render bed axes and model, selection hints, gcode sequential view marker model, preview shells, options in gcode preview
valid &= append_shader("gouraud_light", { prefix + "gouraud_light.vs", prefix + "gouraud_light.fs" });
valid &= append_shader("gouraud_light", { prefix / "gouraud_light.vs", prefix / "gouraud_light.fs" });
// extend "gouraud_light" by adding clipping, used in sla gizmos
valid &= append_shader("gouraud_light_clip", { prefix + "gouraud_light_clip.vs", prefix + "gouraud_light_clip.fs" });
valid &= append_shader("gouraud_light_clip", { prefix / "gouraud_light_clip.vs", prefix / "gouraud_light_clip.fs" });
// used to render printbed
valid &= append_shader("printbed", { prefix + "printbed.vs", prefix + "printbed.fs" });
valid &= append_shader("printbed", { prefix / "printbed.vs", prefix / "printbed.fs" });
// used to render options in gcode preview
if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) {
valid &= append_shader("gouraud_light_instanced", { prefix + "gouraud_light_instanced.vs", prefix + "gouraud_light_instanced.fs" });
valid &= append_shader("gouraud_light_instanced", { prefix / "gouraud_light_instanced.vs", prefix / "gouraud_light_instanced.fs" });
}
// used to render objects in 3d editor
valid &= append_shader("gouraud", { prefix + "gouraud.vs", prefix + "gouraud.fs" }
valid &= append_shader("gouraud", { prefix / "gouraud.vs", prefix / "gouraud.fs" }
#if ENABLE_ENVIRONMENT_MAP
, { "ENABLE_ENVIRONMENT_MAP"sv }
#endif // ENABLE_ENVIRONMENT_MAP
);
// used to render variable layers heights in 3d editor
valid &= append_shader("variable_layer_height", { prefix + "variable_layer_height.vs", prefix + "variable_layer_height.fs" });
valid &= append_shader("variable_layer_height", { prefix / "variable_layer_height.vs", prefix / "variable_layer_height.fs" });
// used to render highlight contour around selected triangles inside the multi-material gizmo
valid &= append_shader("mm_contour", { prefix + "mm_contour.vs", prefix + "mm_contour.fs" });
valid &= append_shader("mm_contour", { prefix / "mm_contour.vs", prefix / "mm_contour.fs" });
// Used to render painted triangles inside the multi-material gizmo. Triangle normals are computed inside fragment shader.
// For Apple's on Arm CPU computed triangle normals inside fragment shader using dFdx and dFdy has the opposite direction.
// Because of this, objects had darker colors inside the multi-material gizmo.
@ -94,9 +94,9 @@ std::pair<bool, std::string> GLShadersManager::init()
// Since macOS 12 (Monterey), this issue with the opposite direction on Apple's Arm CPU seems to be fixed, and computed
// triangle normals inside fragment shader have the right direction.
if (platform_flavor() == PlatformFlavor::OSXOnArm && wxPlatformInfo::Get().GetOSMajorVersion() < 12)
valid &= append_shader("mm_gouraud", { prefix + "mm_gouraud.vs", prefix + "mm_gouraud.fs" }, { "FLIP_TRIANGLE_NORMALS"sv });
valid &= append_shader("mm_gouraud", { prefix / "mm_gouraud.vs", prefix / "mm_gouraud.fs" }, { "FLIP_TRIANGLE_NORMALS"sv });
else
valid &= append_shader("mm_gouraud", { prefix + "mm_gouraud.vs", prefix + "mm_gouraud.fs" });
valid &= append_shader("mm_gouraud", { prefix / "mm_gouraud.vs", prefix / "mm_gouraud.fs" });
return { valid, error };
}

View file

@ -332,7 +332,7 @@ bool GLTexture::load_from_svg_files_as_sprites_array(const std::vector<std::stri
}
}
std::string out_filename = resources_dir() + "/icons/test_" + std::to_string(pass) + ".png";
std::string out_filename = (icons_path() / (std::string("test_") + std::to_string(pass) + ".png")).string();
output.SaveFile(out_filename, wxBITMAP_TYPE_PNG);
#endif // 0

View file

@ -184,11 +184,10 @@ bool GLToolbar::init(const BackgroundTexture::Metadata& background_texture)
if (m_background_texture.texture.get_id() != 0)
return true;
std::string path = resources_dir() + "/icons/";
bool res = false;
if (!background_texture.filename.empty())
res = m_background_texture.texture.load_from_file(path + background_texture.filename, false, GLTexture::SingleThreaded, false);
res = m_background_texture.texture.load_from_file((icons_path() / background_texture.filename).string(), false, GLTexture::SingleThreaded, false);
if (res)
m_background_texture.metadata = background_texture;
@ -201,8 +200,7 @@ bool GLToolbar::init_arrow(const std::string& filename)
if (m_arrow_texture.get_id() != 0)
return true;
const std::string path = resources_dir() + "/icons/";
return (!filename.empty()) ? m_arrow_texture.load_from_svg_file(path + filename, false, false, false, 512) : false;
return (!filename.empty()) ? m_arrow_texture.load_from_svg_file((icons_path() / filename).string(), false, false, false, 512) : false;
}
GLToolbar::Layout::EType GLToolbar::get_layout_type() const
@ -1297,12 +1295,11 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent)
bool GLToolbar::generate_icons_texture()
{
std::string path = resources_dir() + "/icons/";
std::vector<std::string> filenames;
for (GLToolbarItem* item : m_items) {
const std::string& icon_filename = item->get_icon_filename();
if (!icon_filename.empty())
filenames.push_back(path + icon_filename);
filenames.push_back((icons_path() / icon_filename).string());
}
std::vector<std::pair<int, bool>> states;

View file

@ -417,7 +417,12 @@ std::string into_u8(const wxString &str)
wxString from_path(const boost::filesystem::path &path)
{
#ifdef _WIN32
return wxString(path.string<std::wstring>());
std::wstring wdir = path.string<std::wstring>();
const std::wstring prefix = L"\\\\?\\";
if (wdir.rfind(prefix, 0) == 0) { // starts with prefix
wdir.erase(0, prefix.length());
}
return wxString(wdir);
#else
return from_u8(path.string<std::string>());
#endif
@ -425,7 +430,27 @@ wxString from_path(const boost::filesystem::path &path)
boost::filesystem::path into_path(const wxString &str)
{
return boost::filesystem::path(str.wx_str());
boost::filesystem::path fixpath(str.wx_str());
// note: lexically_normal() already do make_preferred()
fixpath.lexically_normal();
#ifdef _WIN32
// on windows, we need to force long path support when possible/needed, by appedning the R"(\\?\)" to force long path
if (!fixpath.empty() && fixpath.string().front() != '\\' && (fixpath.is_absolute() || fixpath.size() > 250)) {
if (boost::filesystem::exists(fixpath)) {
// if the path exists, we can canonicalize it and add the long path prefix, which will resolve any ".." or
// "." in the path and give us a proper absolute path.
fixpath = R"(\\?\)" + boost::filesystem::canonical(fixpath).string();
} else if (boost::filesystem::exists(fixpath.parent_path())) {
// if the path doesn't exist, but the parent path exists, we can canonicalize the parent path and then
// append the filename
fixpath = R"(\\?\)" + (boost::filesystem::canonical(fixpath.parent_path()) / fixpath.filename()).string();
} else if (fixpath.is_absolute()) {
// if the path doesn't exist, we can't canonicalize it, so we just add the long path prefix and hope for the best
fixpath = R"(\\?\)" + fixpath.string();
}
}
#endif
return fixpath;
}
void about()

View file

@ -91,6 +91,7 @@
#include "CalibrationTempDialog.hpp"
#include "CalibrationRetractionDialog.hpp"
#include "CalibrationPressureAdvDialog.hpp"
#include "ConfigWizard.hpp"
#include "ConfigSnapshotDialog.hpp"
#include "CreateMMUTiledCanvas.hpp"
#include "FreeCADDialog.hpp"
@ -857,6 +858,18 @@ static void generic_exception_handle()
}
}
std::string GUI_App::logo_name() const {
return std::string(is_editor() ? SLIC3R_APP_KEY : GCODEVIEWER_APP_KEY) + std::string("_logo");
}
std::string GUI_App::dark_icon_name() const {
return std::string(is_editor() ? SLIC3R_APP_KEY : GCODEVIEWER_APP_KEY) + std::string("");
}
std::string GUI_App::light_icon_name() const {
return std::string(is_editor() ? SLIC3R_APP_KEY : GCODEVIEWER_APP_KEY) + std::string("");
}
void GUI_App::post_init()
{
assert(initialized());
@ -1072,7 +1085,7 @@ void choose_app_dir(GUI_App &app) {
if (same_version.size() + old_versions.size() == 0) {
choice = 0;
} else {
//need fonts for MessageDialog
// need fonts for MessageDialog
app.init_fonts();
// else, reuse by default
MessageDialog first_dialog(nullptr,
@ -1136,7 +1149,7 @@ void choose_app_dir(GUI_App &app) {
my_default_installation.other_keys["config_path_relative"] = "1";
assert(!boost::filesystem::exists(my_default_installation.get_config_path(app.app_config->get_root_data_dir())));
my_default_installation.version = Semver(SLIC3R_VERSION_FULL);
AppConfig::ConfigurationEntry my_new_installation = my_default_installation;
if (choice > 0) {
choice--;
@ -1607,7 +1620,7 @@ bool GUI_App::on_init_inner()
// make a bitmap with dark grey banner on the left side
if (!bmp.IsOk()) {
bmp = SplashScreen::MakeBitmap(get_bmp_bundle(SLIC3R_APP_KEY, 600)->GetPreferredBitmapSizeAtScale(1.0), scrn_scaling);
bmp = SplashScreen::MakeBitmap(get_bmp_bundle(light_icon_name(), 600)->GetPreferredBitmapSizeAtScale(1.0), scrn_scaling);
}
scrn = new SplashScreen(bmp, scrn_scaling, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, splashscreen_pos, artist);
@ -2273,6 +2286,37 @@ int GUI_App::get_max_font_pt_size()
void GUI_App::init_fonts()
{
static bool first_run = true;
if (first_run) {
first_run = false;
auto copy_and_install_font = [](std::string_view font_filename) -> bool {
assert(boost::filesystem::exists(Slic3r::resources_path() / "fonts"));
boost::filesystem::path cache_path;
if (!Slic3r::data_dir().empty()) {
cache_path = Slic3r::data_path() / "cache";
} else {
cache_path = boost::filesystem::temp_directory_path();
}
// copy fonts into configuration, to avoid blocking them
if (!boost::filesystem::exists(cache_path / "fonts" / font_filename) &&
boost::filesystem::exists(Slic3r::resources_path() / "fonts" / font_filename)) {
if (!boost::filesystem::exists(cache_path / "fonts")) {
boost::filesystem::create_directories(cache_path / "fonts");
}
boost::filesystem::copy(Slic3r::resources_path() / "fonts" / font_filename,
cache_path / "fonts" / font_filename);
}
return wxFont::AddPrivateFont(
(cache_path / "fonts" / font_filename)
.string()); // this needs to be done just once per the application run
};
// Exemple of font add
// if (!copy_and_install_font("comic.ttf")) {
// wxLogError("Could not find Comic Sans MS font");
// }
}
m_small_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
m_bold_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold();
m_normal_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
@ -2297,9 +2341,9 @@ void GUI_App::update_fonts(const MainFrame *main_frame)
*/
if (main_frame == nullptr)
main_frame = this->mainframe;
m_normal_font = main_frame->normal_font();
m_small_font = m_normal_font;
m_bold_font = main_frame->normal_font().Bold();
m_small_font.SetPointSize(main_frame->normal_font().GetPointSize());
m_bold_font.SetPointSize(main_frame->normal_font().GetPointSize());
m_normal_font.SetPointSize(main_frame->normal_font().GetPointSize());
m_link_font = m_bold_font.Underlined();
m_em_unit = main_frame->em_unit();
m_code_font.SetPointSize(m_normal_font.GetPointSize());
@ -4019,7 +4063,8 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
return false;
}
#endif
// if nothing installed, show the installatino dialog first
#ifndef ALLOW_PRUSA_FIRST
// if nothing installed, show the installation dialog first
bool is_synch = this->preset_updater->is_synch;
if (bypass_bundle_install == RVBM_ALWAYS ||
(bypass_bundle_install == RVBM_IF_EMPTY && this->preset_updater->count_installed() == 0)) {
@ -4032,6 +4077,44 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
[&](bool is_ok) { if (is_ok) run_wizard(reason, start_page, RunVendorBundleManage::RVBM_NEVER); });
return false;
}
#else //ALLOW_PRUSA_FIRST
if (this->preset_updater->count_installed() == 0 && bypass_bundle_install != RVBM_NEVER) {
this->preset_updater->reload_all_vendors();
// don't run the bundle manager but just install the vendor version
this->preset_updater->sync_async([this, reason, start_page](int update_count) {
bool found = false;
std::lock_guard<std::recursive_mutex> guard(this->preset_updater->all_vendors_mutex);
for (const auto &[id, vendor] : this->preset_updater->all_vendors) {
if (vendor.profile.id == ALLOW_PRUSA_FIRST) {
found = true;
if (vendor.best != nullptr) {
this->preset_updater->install_vendor(ALLOW_PRUSA_FIRST, *vendor.best,
[this, reason, start_page](const std::string &error_msg) {
run_wizard(reason, start_page,
RunVendorBundleManage::RVBM_NEVER);
});
} else {
//TODO: failsafe
for (auto &vendor_loc : vendor.available_profiles) {
if (vendor_loc.local_file.find(Slic3r::resources_dir()) != std::string::npos) {
this->preset_updater->install_vendor(ALLOW_PRUSA_FIRST, vendor_loc,
[this, reason,
start_page](const std::string &error_msg) {
run_wizard(reason, start_page,
RunVendorBundleManage::RVBM_NEVER);
});
break;
}
}
}
break;
}
}
assert(found);
});
return false;
}
#endif
ConfigWizard *wizard = nullptr;
{
@ -4384,33 +4467,40 @@ void GUI_App::associate_bgcode_files()
void GUI_App::on_version_read(wxCommandEvent& evt)
{
app_config->set("version_online", into_u8(evt.GetString()));
std::optional<Slic3r::Semver> version_online = Semver::parse(into_u8(evt.GetString()));
std::string opt = app_config->get("notify_release");
std::optional<Semver> version_online = Semver::parse(into_u8(evt.GetString()));
if (!version_online || this->plater_ == nullptr) {
return;
} else if (!m_app_updater->get_triggered_by_user() && opt != "all" && (opt != "release" || version_online->prerelease() == nullptr)) {
} else if (!m_app_updater->get_triggered_by_user() &&
(opt == "none" || (opt == "release" && version_online->prerelease()))) {
BOOST_LOG_TRIVIAL(info) << "Version online: " << evt.GetString() << ". User does not wish to be notified.";
return;
}
if (*Semver::parse(SLIC3R_VERSION_FULL) >= *version_online) {
if (m_app_updater->get_triggered_by_user())
{
std::string text = (*version_online == Semver())
? _u8L("Check for application update has failed.")
: Slic3r::format(_u8L("You are currently running the latest released version %1%."), evt.GetString());
std::optional<Semver> lastest_download = Semver::parse(app_config->get("version_online_seen"));
std::optional<Semver> current_version = Semver::parse(SLIC3R_VERSION_FULL);
assert(current_version);
if (m_app_updater->get_triggered_by_user()) {
if (!version_online || *version_online <= *current_version) {
std::string text = (*version_online == Semver()) ?
_u8L("Check for application update has failed.") :
Slic3r::format(_u8L("You are currently running the latest released version %1%."), current_version->to_string());
if (*Semver::parse(SLIC3R_VERSION) > *version_online)
text = Slic3r::format(_u8L("There are no new released versions online. The latest release version is %1%."), evt.GetString());
text = Slic3r::format(
_u8L("There are no new released versions online. The latest release version is %1%."),
evt.GetString());
this->plater_->get_notification_manager()->push_version_notification(NotificationType::NoNewReleaseAvailable
, NotificationManager::NotificationLevel::RegularNotificationLevel
, text
, std::string()
, std::function<bool(wxEvtHandler*)>()
);
this->plater_->get_notification_manager()
->push_version_notification(NotificationType::NoNewReleaseAvailable,
NotificationManager::NotificationLevel::RegularNotificationLevel, text,
std::string(), std::function<bool(wxEvtHandler *)>());
return;
}
} else {
if (!version_online || *version_online <= *current_version ||
(lastest_download && *version_online <= *lastest_download)) {
return;
}
return;
}
// notification
/*
@ -4429,11 +4519,11 @@ void GUI_App::on_version_read(wxCommandEvent& evt)
void GUI_App::app_updater(bool from_user)
{
DownloadAppData app_data = m_app_updater->get_app_data();
if (from_user && (!app_data.version || *app_data.version <= *Semver::parse(SLIC3R_VERSION)))
Semver current_version = *Semver::parse(SLIC3R_VERSION_FULL);
if (from_user && (app_data.version <= current_version || app_data.url.empty()))
{
BOOST_LOG_TRIVIAL(info) << "There is no newer version online.";
MsgNoAppUpdates no_update_dialog;
MsgNoAppUpdates no_update_dialog;
no_update_dialog.ShowModal();
return;
@ -4442,19 +4532,27 @@ void GUI_App::app_updater(bool from_user)
assert(!app_data.url.empty());
assert(!app_data.target_path.empty());
if (app_data.url.empty() || app_data.target_path.empty()) {
return;
}
// dialog with new version info
AppUpdateAvailableDialog dialog(*Semver::parse(SLIC3R_VERSION), *app_data.version, from_user);
AppUpdateAvailableDialog dialog(current_version, app_data.version, from_user);
auto dialog_result = dialog.ShowModal();
// checkbox "do not show again"
if (dialog.disable_version_check()) {
app_config->set("notify_release", "none");
app_config->set("version_online_seen", "");
}
// Doesn't wish to update
if (dialog_result != wxID_OK) {
if (dialog_result == wxID_NO) {
app_config->set("version_online_seen", app_data.version.to_string());
}
return;
}
// dialog with new version download (installer or app dependent on system) including path selection
AppUpdateDownloadDialog dwnld_dlg(*app_data.version, app_data.target_path);
AppUpdateDownloadDialog dwnld_dlg(app_data.version, app_data.target_path);
dialog_result = dwnld_dlg.ShowModal();
// Doesn't wish to download
if (dialog_result != wxID_OK) {
@ -4471,6 +4569,7 @@ void GUI_App::app_updater(bool from_user)
void GUI_App::app_version_check(bool from_user)
{
AppUpdater::clean();
if (from_user) {
if (m_app_updater->get_download_ongoing()) {
MessageDialog msgdlg(nullptr, _L("Downloading of the new version is in progress. Do you want to continue?"), _L("Notice"), wxYES_NO);

View file

@ -193,7 +193,9 @@ public:
bool is_editor() const { return m_app_mode == EAppMode::Editor; }
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
bool is_recreating_gui() const { return m_is_recreating_gui; }
std::string logo_name() const { return is_editor() ? SLIC3R_APP_KEY : GCODEVIEWER_APP_KEY; }
std::string logo_name() const;
std::string dark_icon_name() const;
std::string light_icon_name() const;
// To be called after the GUI is fully built up.
// Process command line parameters cached in this->init_params,

View file

@ -143,18 +143,21 @@ wxFont get_default_font_for_dpi(const wxWindow *window, int dpi)
NONCLIENTMETRICS nm;
memset(&nm, 0, sizeof(NONCLIENTMETRICS));
nm.cbSize = sizeof(NONCLIENTMETRICS);
if (SystemParametersInfoForDpi_fn(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &nm, 0, dpi))
return wxFont(wxNativeFontInfo(nm.lfMessageFont, window));
if (SystemParametersInfoForDpi_fn(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &nm, 0, dpi)) {
wxNativeFontInfo fontinfo(nm.lfMessageFont, window);
fontinfo.SetFaceName(wxGetApp().normal_font().GetFaceName());
return wxFont(fontinfo);
}
}
// Then try to guesstimate the font DPI scaling on Windows 8.
// Let's hope that the font returned by the SystemParametersInfo(), which is used by wxWidgets internally, makes sense.
int dpi_primary = get_dpi_for_window(nullptr);
if (dpi_primary != dpi) {
// Rescale the font.
return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Scaled(float(dpi) / float(dpi_primary));
return wxGetApp().normal_font().Scaled(float(dpi) / float(dpi_primary));
}
#endif
return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
return wxGetApp().normal_font();
}
bool check_dark_mode() {

View file

@ -100,7 +100,7 @@ public:
dpi = DPI_DEFAULT * custom_gui_size / 10.f;
}
m_prev_scale_factor = m_scale_factor;
m_normal_font = get_default_font_for_dpi(this, dpi);
m_normal_font = get_default_font_for_dpi(this, dpi);
if (font_point_size > 0)
m_normal_font.SetPointSize(font_point_size);

View file

@ -1236,7 +1236,7 @@ void GLGizmoEmboss::set_volume_by_selection()
// Have to use some wxFont
if (!wx_font.IsOk())
wx_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wx_font = wxGetApp().normal_font();
}
assert(wx_font.IsOk());

View file

@ -134,10 +134,11 @@ void GLGizmoMove3D::on_render()
m_grabbers[2].center = { 0.0, 0.0, half_box_size.z() + Offset };
m_grabbers[2].color = AXES_COLOR[2];
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
float min = std::min(1.5f, OpenGLManager::get_gl_info().get_min_line_width());
float bigger = min <= 1.5f ? 2.f : min + 1.f;
glsafe(::glLineWidth((m_hover_id != -1) ? bigger : min));
}
auto render_grabber_connection = [this, &zero](unsigned int id) {
if (m_grabbers[id].enabled) {

View file

@ -166,10 +166,9 @@ void GLGizmoPainterBase::render_cursor_circle()
const float radius = m_cursor_radius * float(wxGetApp().plater()->get_camera().get_zoom());
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
glsafe(::glLineWidth(1.5f));
}
glsafe(::glDisable(GL_DEPTH_TEST));
#if !ENABLE_GL_CORE_PROFILE && !ENABLE_OPENGL_ES

View file

@ -153,10 +153,11 @@ void GLGizmoRotate::on_render()
m_grabbers.front().matrix = local_transform(selection);
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
float min = std::min(1.5f, OpenGLManager::get_gl_info().get_min_line_width());
float bigger = min <= 1.5f ? 2.f : min + 1.f;
glsafe(::glLineWidth((m_hover_id != -1) ? bigger : min));
}
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");

View file

@ -164,10 +164,11 @@ void GLGizmoScale3D::on_render()
update_render_data();
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
float min = std::min(1.5f, OpenGLManager::get_gl_info().get_min_line_width());
float bigger = min <= 1.5f ? 2.f : min + 1.f;
glsafe(::glLineWidth((m_hover_id != -1) ? bigger : min));
}
const float grabber_mean_size = (float)((m_bounding_box.size().x() + m_bounding_box.size().y() + m_bounding_box.size().z()) / 3.0);

View file

@ -766,10 +766,9 @@ void GLGizmoSimplify::on_render()
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
const ColorRGBA color = glmodel.get_color();
glmodel.set_color(ColorRGBA::WHITE());
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
glsafe(::glLineWidth(1.0f));
}
#if !ENABLE_OPENGL_ES
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
#endif // !ENABLE_OPENGL_ES

View file

@ -98,7 +98,7 @@ bool GLGizmosManager::init()
if (!m_background_texture.metadata.filename.empty())
{
if (!m_background_texture.texture.load_from_file(resources_dir() + "/icons/" + m_background_texture.metadata.filename, false, GLTexture::SingleThreaded, false))
if (!m_background_texture.texture.load_from_file((resources_path() / "icons" / m_background_texture.metadata.filename).string(), false, GLTexture::SingleThreaded, false))
return false;
}
@ -140,8 +140,8 @@ bool GLGizmosManager::init_arrow(const std::string& filename)
if (m_arrow_texture.get_id() != 0)
return true;
const std::string path = resources_dir() + "/icons/";
return (!filename.empty()) ? m_arrow_texture.load_from_svg_file(path + filename, false, false, false, 512) : false;
const boost::filesystem::path file_path = resources_path() / "icons" / filename;
return (!filename.empty()) ? m_arrow_texture.load_from_svg_file(file_path.string(), false, false, false, 512) : false;
}
void GLGizmosManager::set_overlay_icon_size(float size)
@ -896,7 +896,7 @@ GLGizmosManager::EType GLGizmosManager::get_gizmo_from_name(const std::string& g
bool GLGizmosManager::generate_icons_texture()
{
std::string path = resources_dir() + "/icons/";
boost::filesystem::path path = resources_path() / "icons";
std::vector<std::string> filenames;
for (size_t idx=0; idx<m_gizmos.size(); ++idx)
{
@ -905,7 +905,7 @@ bool GLGizmosManager::generate_icons_texture()
{
const std::string& icon_filename = gizmo->get_icon_filename();
if (!icon_filename.empty())
filenames.push_back(path + icon_filename);
filenames.push_back((path / icon_filename).string());
}
}

View file

@ -1714,7 +1714,7 @@ std::vector<unsigned char> ImGuiWrapper::load_svg(const std::string& bitmap_name
replaces.add("#2172eb", color_int);
// as the platter is quite dark, then this replacment is always active
replaces.add("#808080", "#FFFFFF");
NSVGimage* image = BitmapCache::nsvgParseFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), "px", 96.0f, replaces);
NSVGimage* image = BitmapCache::nsvgParseFromFileWithReplace(Slic3r::get_icon_file(bitmap_name + ".svg").c_str(), "px", 96.0f, replaces);
if (image == nullptr)
return empty_vector;
@ -1773,9 +1773,23 @@ void ImGuiWrapper::init_font(bool compress)
#endif
builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted)
auto copy_and_get_font = [](std::string_view str) -> std::string {
assert(boost::filesystem::exists(Slic3r::resources_path() / "fonts"));
assert(boost::filesystem::exists(Slic3r::data_path()));
// copy fonts into configuration, to avoid blocking them
if (!boost::filesystem::exists(Slic3r::data_path() / "cache" / "fonts" / str) &&
boost::filesystem::exists(Slic3r::resources_path() / "fonts" / str)) {
if (!boost::filesystem::exists(Slic3r::data_path() / "cache" / "fonts")) {
boost::filesystem::create_directories(Slic3r::data_path() / "cache" / "fonts");
}
boost::filesystem::copy(Slic3r::resources_path() / "fonts" / str, Slic3r::data_path() / "cache" / "fonts" / str);
}
return (Slic3r::data_path() / "cache" / "fonts" / str).string();
};
//FIXME replace with io.Fonts->AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, m_font_size, nullptr, ranges.Data);
//https://github.com/ocornut/imgui/issues/220
ImFont* font = io.Fonts->AddFontFromFileTTF((boost::filesystem::path(Slic3r::resources_dir()) / "fonts" / (m_font_cjk ? "NotoSansCJK-Regular.ttc" : "NotoSans-Regular.ttf")).string().c_str(), m_font_size, nullptr, ranges.Data);
ImFont* font = io.Fonts->AddFontFromFileTTF(copy_and_get_font(m_font_cjk ? "NotoSansCJK-Regular.ttc" : "NotoSans-Regular.ttf").c_str(), m_font_size, nullptr, ranges.Data);
if (font == nullptr) {
font = io.Fonts->AddFontDefault();
if (font == nullptr) {
@ -1788,7 +1802,7 @@ void ImGuiWrapper::init_font(bool compress)
config.MergeMode = true;
if (! m_font_cjk) {
// Apple keyboard shortcuts are only contained in the CJK fonts.
[[maybe_unused]]ImFont *font_cjk = io.Fonts->AddFontFromFileTTF((boost::filesystem::path(Slic3r::resources_dir()) / "fonts" / "NotoSansCJK-Regular.ttc").string().c_str(), m_font_size, &config, ranges_keyboard_shortcuts);
[[maybe_unused]]ImFont *font_cjk = io.Fonts->AddFontFromFileTTF(copy_and_get_font("NotoSansCJK-Regular.ttc").c_str(), m_font_size, &config, ranges_keyboard_shortcuts);
assert(font_cjk != nullptr);
}
#endif

View file

@ -132,7 +132,9 @@ static wxIcon main_frame_icon(GUI_App::EAppMode app_mode)
}
return wxIcon(path, wxBITMAP_TYPE_ICO);
#else // _WIN32
return wxIcon(Slic3r::var(app_mode == GUI_App::EAppMode::Editor ? SLIC3R_APP_KEY "_128px.png" : GCODEVIEWER_APP_KEY "_128px.png"), wxBITMAP_TYPE_PNG);
wxIcon icon;
icon.CopyFromBitmap(get_bmp_bundle(GUI_App::dark_mode() ? wxGetApp().light_icon_name() : wxGetApp().dark_icon_name(), 128)->GetBitmap(wxSize(128, 128)));
return icon;
#endif // _WIN32
}
@ -145,6 +147,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
{
// Fonts were created by the DPIFrame constructor for the monitor, on which the window opened.
wxGetApp().update_fonts(this);
this->SetFont(wxGetApp().normal_font());
/*
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
this->SetFont(this->normal_font());
@ -158,11 +161,11 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
default:
case GUI_App::EAppMode::Editor:
m_taskbar_icon = std::make_unique<PrusaSlicerTaskBarIcon>(wxTBI_DOCK);
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var(SLIC3R_APP_KEY "_256_icns.png"), wxBITMAP_TYPE_PNG), SLIC3R_APP_KEY);
m_taskbar_icon->SetIcon(wxIcon(Slic3r::get_icon_file(SLIC3R_APP_KEY "_256_icns.png"), wxBITMAP_TYPE_PNG), SLIC3R_APP_KEY);
break;
case GUI_App::EAppMode::GCodeViewer:
m_taskbar_icon = std::make_unique<GCodeViewerTaskBarIcon>(wxTBI_DOCK);
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var(GCODEVIEWER_APP_KEY "-mac_128px.png"), wxBITMAP_TYPE_PNG), GCODEVIEWER_APP_NAME);
m_taskbar_icon->SetIcon(wxIcon(Slic3r::get_icon_file(GCODEVIEWER_APP_KEY "-mac_128px.png"), wxBITMAP_TYPE_PNG), GCODEVIEWER_APP_NAME);
break;
}
#endif // __APPLE__
@ -1677,7 +1680,7 @@ static wxMenu* generate_help_menu()
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_L("%s Releases"), SLIC3R_APP_NAME), wxString::Format(_L("Open the %s releases page in your browser"), SLIC3R_APP_NAME),
[](wxCommandEvent&) { wxGetApp().open_browser_with_warning_dialog(SLIC3R_DOWNLOAD); });
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_L("%s wiki"), SLIC3R_APP_NAME), wxString::Format(_L("Open the %s wiki in your browser"), SLIC3R_APP_NAME),
[](wxCommandEvent&) { wxGetApp().open_browser_with_warning_dialog("https://github.com/" SLIC3R_GITHUB "/wiki"); });
[](wxCommandEvent&) { wxGetApp().open_browser_with_warning_dialog(get_app_config()->github_url() + "/wiki"); });
//# my $versioncheck = $self->_append_menu_item($helpMenu, "Check for &Updates...", "Check for new Slic3r versions", sub{
//# wxTheApp->check_version(1);
@ -1695,7 +1698,7 @@ static wxMenu* generate_help_menu()
append_menu_item(helpMenu, wxID_ANY, _L("Show &Configuration Folder"), _L("Show user configuration folder (datadir)"),
[](wxCommandEvent&) { Slic3r::GUI::desktop_open_datadir_folder(); });
append_menu_item(helpMenu, wxID_ANY, _L("Report an I&ssue"), wxString::Format(_L("Report an issue on %s"), SLIC3R_APP_NAME),
[](wxCommandEvent&) { wxGetApp().open_browser_with_warning_dialog("http://github.com/" SLIC3R_GITHUB "/issues/new"); });
[](wxCommandEvent&) { wxGetApp().open_browser_with_warning_dialog(get_app_config()->github_url() + "/issues/new"); });
#ifndef __APPLE__
append_about_menu_item(helpMenu);
@ -2919,7 +2922,7 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
SetIcon(wxIcon(szExeFileName, wxBITMAP_TYPE_ICO));
}
#else
SetIcon(wxIcon(var(SLIC3R_APP_KEY "_128px.png"), wxBITMAP_TYPE_PNG));
SetIcon(wxIcon(get_icon_file(SLIC3R_APP_KEY "_128px.png"), wxBITMAP_TYPE_PNG));
#endif // _WIN32
this->Bind(wxEVT_SHOW, [this](wxShowEvent& evt) {

View file

@ -111,7 +111,8 @@ void MsgDialog::apply_style(long style)
std::string icon_name = style & wxICON_WARNING ? "exclamation" :
style & wxICON_INFORMATION ? "info" :
style & wxICON_QUESTION ? "question" : SLIC3R_APP_KEY;
style & wxICON_QUESTION ? "question" :
GUI_App::dark_mode() ? wxGetApp().light_icon_name() : wxGetApp().dark_icon_name();
logo->SetBitmap(*get_bmp_bundle(icon_name, 64));
}
@ -228,7 +229,7 @@ void ErrorDialog::create(const HtmlContent& content, int icon_width)
add_msg_content(this, content_sizer, content);
// Use a small bitmap with monospaced font, as the error text will not be wrapped.
logo->SetBitmap(*get_bmp_bundle(SLIC3R_APP_KEY "_192px.png", icon_width, -1 , "#606060"/*grayscale*/));
logo->SetBitmap(*get_bmp_bundle(GUI_App::dark_mode() ? wxGetApp().light_icon_name() : wxGetApp().dark_icon_name(), icon_width, -1 , "#606060"/*grayscale*/));
SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit()));

View file

@ -959,7 +959,7 @@ private:
} },
//{NotificationType::NewAppAvailable, NotificationLevel::ImportantNotificationLevel, 20, _u8L("New version is available."), _u8L("See Releases page."), [](wxEvtHandler* evnthndlr) {
// wxGetApp().open_browser_with_warning_dialog("https://github.com/" + SLIC3R_GITHUB + "/releases"); return true; }},
// wxGetApp().open_browser_with_warning_dialog(get_app_config()->github_url() + "/releases"); return true; }},
//{NotificationType::NewAppAvailable, NotificationLevel::ImportantNotificationLevel, 20, _u8L("New vesion of PrusaSlicer is available.", _u8L("Download page.") },
//{NotificationType::LoadingFailed, NotificationLevel::RegularNotificationLevel, 20, _u8L("Loading of model has Failed") },
//{NotificationType::DeviceEjected, NotificationLevel::RegularNotificationLevel, 10, _u8L("Removable device has been safely ejected")} // if we want changeble text (like here name of device), we need to do it as CustomNotification

View file

@ -94,6 +94,20 @@ int OpenGLManager::GLInfo::get_max_tex_size() const
#endif // __APPLE__
}
float OpenGLManager::GLInfo::get_max_line_width() const
{
if (!m_detected)
detect();
return m_max_line_width;
}
float OpenGLManager::GLInfo::get_min_line_width() const
{
if (!m_detected)
detect();
return m_min_line_width;
}
float OpenGLManager::GLInfo::get_max_anisotropy() const
{
if (!m_detected)
@ -114,24 +128,27 @@ void OpenGLManager::GLInfo::detect() const
*const_cast<Semver*>(&m_version) = parse_version_string(m_version_string);
*const_cast<bool*>(&m_version_is_mesa) = boost::icontains(m_version_string, "mesa");
*const_cast<Semver*>(&m_glsl_version) = parse_version_string(m_glsl_version_string);
int* max_tex_size = const_cast<int*>(&m_max_tex_size);
glsafe(::glGetIntegerv(GL_MAX_TEXTURE_SIZE, max_tex_size));
*max_tex_size /= 2;
glsafe(::glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_max_tex_size));
m_max_tex_size /= 2;
if (Slic3r::total_physical_memory() / (1024 * 1024 * 1024) < 6)
*max_tex_size /= 2;
m_max_tex_size /= 2;
if (GLEW_EXT_texture_filter_anisotropic) {
float* max_anisotropy = const_cast<float*>(&m_max_anisotropy);
glsafe(::glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy));
glsafe(::glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &m_max_anisotropy));
}
if (!GLEW_ARB_compatibility)
*const_cast<bool*>(&m_core_profile) = true;
m_core_profile = true;
*const_cast<bool*>(&m_detected) = true;
float range[2];
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, range);
m_min_line_width = range[0];
m_max_line_width = range[1];
m_detected = true;
}
static Semver parse_version_string(const std::string& version)

View file

@ -30,10 +30,13 @@ public:
class GLInfo
{
bool m_detected{ false };
bool m_core_profile{ false };
int m_max_tex_size{ 0 };
float m_max_anisotropy{ 0.0f };
// mutable as filled by detect(), which is const
mutable bool m_detected{ false };
mutable bool m_core_profile{ false };
mutable float m_min_line_width{ .1f };
mutable float m_max_line_width{ 1.f };
mutable int m_max_tex_size{ 0 };
mutable float m_max_anisotropy{ 0.0f };
std::string m_version_string;
Semver m_version = Semver::invalid();
@ -64,6 +67,8 @@ public:
#endif // ENABLE_OPENGL_ES
}
float get_max_line_width() const;
float get_min_line_width() const;
int get_max_tex_size() const;
float get_max_anisotropy() const;

View file

@ -150,6 +150,9 @@ OptionsGroup::OptionsGroup( wxWindow* _parent, const wxString& title,
staticbox(title!=""), extra_column(extra_clmn)
{
assert(Tab::fake_build || m_parent);
sidetext_font = wxFont(wxGetApp().normal_font());
label_font = wxFont(wxGetApp().normal_font());
}
Option::Option(const ConfigOptionDef &_opt, int32_t idx /*= -1*/)

View file

@ -147,12 +147,12 @@ public:
std::function<void(wxWindow* win)> rescale_near_label_widget { nullptr };
std::function<void(const OptionKeyIdx& opt_key_idx)> edit_custom_gcode { nullptr };
wxFont sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };
wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };
int sidetext_width{ -1 };
int label_width{ -1 };
//int sublabel_width{ -1 }; //never set
wxFont sidetext_font;
wxFont label_font;
int sidetext_width{ -1 };
int label_width{ -1 };
//int sublabel_width{ -1 }; //never set
/// Returns a copy of the pointer of the parent wxWindow.
/// Accessor function is because users are not allowed to change the parent

View file

@ -1008,19 +1008,22 @@ void Sidebar::init_filament_combo(PlaterPresetComboBox** combo, const int extr_i
auto opt = wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionStrings>("tool_name");
//assert(opt); // sla don't have tool_name
std::string tool_name = opt ? opt->get_at(extr_idx) : "";
int size_panel = get_app_config()->get_int("side_panel_width");
size_t max_letters = size_t(std::max(4, size_panel/4));
if (tool_name.size() > max_letters) {
if (max_letters > 6) {
tool_name = tool_name.substr(0, max_letters-3) + std::string("... ");
} else {
tool_name = tool_name.substr(0, max_letters);
if (!tool_name.empty()) {
int size_panel = get_app_config()->get_int("side_panel_width");
size_t max_letters = size_t(std::max(4, size_panel / 4));
if (tool_name.size() > max_letters) {
if (max_letters > 6) {
tool_name = tool_name.substr(0, max_letters - 3) + std::string("... ");
} else {
tool_name = tool_name.substr(0, max_letters);
}
}
(*combo)->label = new wxStaticText(p->presets_panel, wxID_ANY,
tool_name.empty() ? "" : (tool_name + std::string(": ")));
(*combo)->label->SetFont(wxGetApp().small_font());
(*combo)->label->SetToolTip(tool_name); // doesn't work in msw because static text doesn't get mouse event
combo_and_btn_sizer->Add((*combo)->label, 0, wxALIGN_LEFT | wxEXPAND | wxRIGHT, 4);
}
(*combo)->label = new wxStaticText(p->presets_panel, wxID_ANY, tool_name.empty() ? "" : ( tool_name + std::string(": ")));
(*combo)->label->SetFont(wxGetApp().small_font());
(*combo)->label->SetToolTip(tool_name); //doesn't work in msw because static text doesn't get mouse event
combo_and_btn_sizer->Add((*combo)->label, 0, wxALIGN_LEFT | wxEXPAND | wxRIGHT, 4);
}
combo_and_btn_sizer->Add(*combo, 1, wxEXPAND);
assert((*combo)->edit_btn);
@ -8902,7 +8905,7 @@ Camera& Plater::get_camera()
void Plater::init_environment_texture()
{
if (p->environment_texture.get_id() == 0)
p->environment_texture.load_from_file(resources_dir() + "/icons/Pmetal_001.png", false, GLTexture::SingleThreaded, false);
p->environment_texture.load_from_file((icons_path() / "Pmetal_001.png").string(), false, GLTexture::SingleThreaded, false);
}
unsigned int Plater::get_environment_texture_id() const

View file

@ -291,6 +291,9 @@ std::shared_ptr<ConfigOptionsGroup> PreferencesDialog::create_options_group(cons
assert(opt_key_idx.idx < 0);
Field *field = optgroup->get_field(opt_key_idx);
// very special cases
if (opt_key_idx.key == "notify_release") {
get_app_config()->set("version_online_seen", "");
}
if (opt_key_idx.key == "use_custom_toolbar_size") {
m_icon_size_sizer->ShowItems(boost::any_cast<bool>(value));
refresh_og(m_optkey_to_optgroup["use_custom_toolbar_size"]);
@ -1849,13 +1852,13 @@ void PreferencesDialog::create_settings_font_widget(wxWindow* tab, std::shared_p
auto revert_btn = new ScalableButton(parent, wxID_ANY, "undo");
revert_btn->SetToolTip(_L("Revert font to default"));
revert_btn->Bind(wxEVT_BUTTON, [size_sc, apply_font](wxEvent& event) {
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont font = wxGetApp().normal_font();
const int val = font.GetPointSize();
size_sc->SetValue(val);
apply_font(val, font);
});
parent->Bind(wxEVT_UPDATE_UI, [size_sc](wxUpdateUIEvent& evt) {
const int def_size = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize();
const int def_size = wxGetApp().normal_font().GetPointSize();
evt.Enable(def_size != size_sc->GetValue());
}, revert_btn->GetId());

View file

@ -2273,13 +2273,13 @@ void Selection::render_bounding_box(const BoundingBoxf3& box, const Transform3d&
glsafe(::glEnable(GL_DEPTH_TEST));
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
if (OpenGLManager::get_gl_info().get_max_line_width() > 1) {
glsafe(::glLineWidth(2.0f * m_scale_factor));
}
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#else
glsafe(::glLineWidth(2.0f * m_scale_factor));
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
if (shader == nullptr)

View file

@ -609,7 +609,7 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
wxString html = GUI::format_wxstr(
"<html><body bgcolor=%1%><font color=%2%>"
"<table><tr><td>"
"<img src = \"" + resources_dir() + "/icons/" SLIC3R_APP_KEY "_192px.png\" />"
"<img src = \"" + (boost::filesystem::path(icons_dir()) / (wxGetApp().dark_icon_name()).generic_string() + ".png\" />"
"</td><td align=\"left\">"
+ text0 + "<br / ><br / >"
+ text1 + "<br /><br />"

View file

@ -112,20 +112,21 @@ SysInfoDialog::SysInfoDialog()
//m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
m_logo = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 192));
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
hsizer->Add(vsizer, 1, wxEXPAND|wxLEFT, 20);
// title is in the logo
// title
{
wxStaticText* title = new wxStaticText(this, wxID_ANY, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME, wxDefaultPosition, wxDefaultSize);
wxFont title_font = wxGetApp().bold_font();
title_font.SetFamily(wxFONTFAMILY_ROMAN);
title_font.SetPointSize(int(2.5 * title_font.GetPointSize()));//title_font.SetPointSize(22);
title->SetFont(title_font);
vsizer->Add(title, 0, wxEXPAND | wxALIGN_LEFT | wxTOP, wxGetApp().em_unit()/*50*/);
}
//{
// wxStaticText* title = new wxStaticText(this, wxID_ANY, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME, wxDefaultPosition, wxDefaultSize);
// wxFont title_font = wxGetApp().bold_font();
// title_font.SetFamily(wxFONTFAMILY_ROMAN);
// title_font.SetPointSize(int(2.5 * title_font.GetPointSize()));//title_font.SetPointSize(22);
// title->SetFont(title_font);
// vsizer->Add(title, 0, wxEXPAND | wxALIGN_LEFT | wxTOP, wxGetApp().em_unit()/*50*/);
//}
// main_info_text
wxFont font = GetFont();// get_default_font(this);

View file

@ -39,9 +39,17 @@ namespace Slic3r {
namespace GUI {
static const char* URL_CHANGELOG = "https://github.com/" SLIC3R_GITHUB "/releases";
static const char* URL_DOWNLOAD = "https://github.com/" SLIC3R_GITHUB "/releases";
static const char* URL_DEV = "https://github.com/" SLIC3R_GITHUB "/releases/tag/%1%";
constexpr bool starts_with_http(const char* str) {
return str[0] == 'h' && str[1] == 't' && str[2] == 't' && str[3] == 'p';
}
static const char *URL_CHANGELOG = starts_with_http(SLIC3R_GITHUB) ? SLIC3R_GITHUB "/releases" :
"https://github.com/" SLIC3R_GITHUB "/releases";
static const char *URL_DOWNLOAD = starts_with_http(SLIC3R_GITHUB) ? SLIC3R_GITHUB "/releases" :
"https://github.com/" SLIC3R_GITHUB "/releases";
static const char *URL_DEV = starts_with_http(SLIC3R_GITHUB) ? SLIC3R_GITHUB "/releases/tag/%1%" :
"https://github.com/" SLIC3R_GITHUB
"/releases/tag/%1%";
static const std::string CONFIG_UPDATE_WIKI_URL("https://github.com/prusa3d/PrusaSlicer/wiki/Slic3r-PE-1.40-configuration-update");
@ -124,12 +132,12 @@ AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, co
AUAD_size = content_sizer->GetSize();
add_button(wxID_NO);
add_button(wxID_CANCEL);
if (auto* btn_ok = get_button(wxID_OK); btn_ok != NULL) {
btn_ok->SetLabel(_L("Next"));
}
SetButtonLabel(wxID_OK, _L("Next"));
SetButtonLabel(wxID_NO, _L("Skip"));
finalize();
}
@ -607,7 +615,7 @@ void UpdateConfigDialog::add_vendor_in_list(wxWindow *parent, VendorSync &vendor
bt_version_msg = _L("Not installed");
}
wxButton *bt_version = new wxButton(parent, wxID_ANY, bt_version_msg);
if ((!vendor.is_installed && vendor.available_profiles.size() <= 1) || vendor.available_profiles.size() < 1 || vendor.profile.config_update_rest.empty()) {
if ((!vendor.is_installed && vendor.available_profiles.size() <= 1) || vendor.available_profiles.size() < 1) {
bt_version->Enable(false);
} else {
bt_version->Bind(wxEVT_BUTTON, ([this, vendor_id](wxCommandEvent &e) {
@ -644,6 +652,29 @@ void UpdateConfigDialog::add_vendor_in_list(wxWindow *parent, VendorSync &vendor
this->request_rebuild_ui();
});
}));
} else if (vendor.can_upgrade) {
assert(vendor.best->config_version > vendor.profile.config_version);
wxString config_version_str = vendor.best->config_version.to_string();
wxString msg = vendor.is_installed ? format(_L("Upgrade to %1%"), config_version_str) :
format(_L("Install %1%"), config_version_str);
wxButton *bt_upgrade = new wxButton(parent, wxID_ANY, msg);
if (vendor.is_installed) {
bts_green_color.push_back(bt_upgrade);
}
bt_upgrade->SetToolTip(_L("Click this button to create a snapshot and upgrade this vendor bundle to the "
"latest compatible version."));
versions_sizer->Add(bt_upgrade, wxGBPosition(line_num, 3), wxGBSpan(1, 1), wxEXPAND, 2);
bt_upgrade->Bind(wxEVT_BUTTON, ([this, vendor_id, best_version](wxCommandEvent &e) {
this->wait_dialog.reset(new wxBusyInfo(_L("Upgrading the preset, please wait")));
this->m_data.install_vendor(vendor_id, best_version,
[this](const std::string &error_msg) {
// end of waiting dialog (yes, it has to be called
// without any exception)
this->wait_dialog.reset();
this->request_show_error_msg(error_msg);
this->request_rebuild_ui();
});
}));
} else {
msg_synch = new wxStaticText(parent, wxID_ANY, _L("Local bundle"));
msg_synch->SetToolTip(
@ -682,11 +713,29 @@ void UpdateConfigDialog::add_vendor_in_list(wxWindow *parent, VendorSync &vendor
} else if (vendor.synch_in_progress) {
msg_synch = new wxStaticText(parent, wxID_ANY, _L("Synch with github ..."));
} else if (vendor.synch_failed) {
if (vendor.available_profiles.size() > 1) {
if (vendor.available_profiles.size() > 0 && !vendor.is_installed) {
wxString config_version_str = vendor.best->config_version.to_string();
wxString msg = format(_L("Install %1% from cache"), config_version_str);
wxButton *bt_upgrade = new wxButton(parent, wxID_ANY, msg);
bt_upgrade->SetToolTip(_L("Download failed") + ": "+_L("The slicer failed to access the GitHub repository."));
if (vendor.is_installed) {
bts_green_color.push_back(bt_upgrade);
}
bt_upgrade->SetToolTip(_L("Click this button to create a snapshot and install this vendor bundle available in the local repository."));
versions_sizer->Add(bt_upgrade, wxGBPosition(line_num, 3), wxGBSpan(1, 1), wxEXPAND, 2);
bt_upgrade->Bind(wxEVT_BUTTON, ([this, vendor_id, best_version](wxCommandEvent &e) {
this->wait_dialog.reset(new wxBusyInfo(_L("Installing the preset, please wait")));
this->m_data.install_vendor(vendor_id, best_version, [this](const std::string &error_msg) {
// end of waiting dialog (yes, it has to be called without any exception)
this->wait_dialog.reset();
this->request_show_error_msg(error_msg);
this->request_rebuild_ui();
});
}));
} else{
msg_synch = new wxStaticText(parent, wxID_ANY, _L("Download failed"));
msg_synch->SetToolTip(_L("Download failed") + ": "+_L("The slicer failed to access the GitHub repository."));
}
msg_synch = new wxStaticText(parent, wxID_ANY, _L("Download failed"));
msg_synch->SetToolTip(_L("The slicer failed to access the GitHub repository."));
} else {
msg_synch = new wxStaticText(parent, wxID_ANY, _L("Unchecked"));
msg_synch->SetToolTip(_L("This printer vendor bundle may have a new preset available online. Click the "
@ -830,9 +879,9 @@ void UpdateConfigDialog::build_ui() {
boost::filesystem::path path(into_path(dlg.GetPath()));
try {
// copy into cache
boost::filesystem::copy(path, into_path(data_dir()) / "cache" / "vendor" / path.filename());
boost::filesystem::copy(path, data_path() / "cache" / "vendor" / path.filename());
//copy icons if found nearby
boost::filesystem::path cache_icon_dir = into_path(data_dir()) / "cache" / "vendor" / path.stem();
boost::filesystem::path cache_icon_dir = data_path() / "cache" / "vendor" / path.stem();
boost::filesystem::path local_icon_dir = path.parent_path() / path.stem();
if (boost::filesystem::exists(local_icon_dir)) {
// remove all old

View file

@ -294,7 +294,7 @@ void WifiConfigDialog::on_ok(wxCommandEvent& e)
m_used_path = boost::nowide::widen(file_path.string());
FILE* file;
file = fopen(file_path.string().c_str(), "w");
file = boost::nowide::fopen(file_path.string().c_str(), "w");
if (file == NULL) {
BOOST_LOG_TRIVIAL(error) << "Failed to write to file " << file_path;
// TODO show error

View file

@ -480,30 +480,35 @@ wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int width/* = 16*
wxBitmapBundle *get_bmp_bundle(const std::string &bmp_name_in, int width, int height, Slic3r::ColorReplaces &new_colors_rgb)
{
#ifdef __WXGTK2__
width *= scale();
if (width > 0)
width *= scale();
if (height > 0)
height *= scale();
#endif // __WXGTK2__
assert(width >= 0);
if (width < 0) {
width = std::max(0, height);
}
if (height < 0) {
height = width;
}
assert(height >= 0);
static Slic3r::GUI::BitmapCache cache;
std::string bmp_name = bmp_name_in;
boost::replace_last(bmp_name, ".png", "");
if (height < 0)
height = width;
if (Slic3r::GUI::wxGetApp().dark_mode()) {
new_colors_rgb.add("#808080", "#FFFFFF");
new_colors_rgb.add("#000000", "#A0A0A0");
}
//wxBitmap *bmp = cache.load_svg(bmp_name, width, height, grayscale, dark_mode, color);
wxBitmapBundle* bmp = cache.from_svg(bmp_name, width, height, new_colors_rgb);
wxBitmapBundle* bmp = cache.from_svg(bmp_name, unsigned(width), unsigned(height), new_colors_rgb);
if (bmp == nullptr) {
bmp = cache.from_png(bmp_name, width, height, new_colors_rgb);
bmp = cache.from_png(bmp_name, unsigned(width), unsigned(height), new_colors_rgb);
if (!bmp)
// Neither SVG nor PNG has been found, raise error
throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);

View file

@ -69,8 +69,11 @@ void update_Slic3r_string(wxString& tooltip);
void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<int>& btn_ids, double height_koef = 1.);
int em_unit(wxWindow* win);
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int width = 16, int height = -1, const std::string& new_color_rgb = std::string());
// if width or height == 0, then their value will be computed from the "bmp" ratio (from the file).
// if height == -1, then it will us ehte same value as width.
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int width, int height, Slic3r::ColorReplaces& color_changes);
// shortcut for get_bmp_bundle when you only want to add one ColorReplace from the accent color (ed6b21/2172eb)
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int width = 16, int height = -1, const std::string& new_color_rgb = std::string());
wxBitmapBundle* get_empty_bmp_bundle(int width, int height);
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color);

View file

@ -165,7 +165,7 @@ AppUpdater::priv::priv() :
#ifdef __linux__
, m_default_dest_folder (boost::filesystem::path("/tmp"))
#else
, m_default_dest_folder (boost::filesystem::path(data_dir()) / "cache")
, m_default_dest_folder (Slic3r::data_path() / "cache")
#endif //_WIN32
{
boost::filesystem::path downloads_path = boost::filesystem::path(get_downloads_path());
@ -233,7 +233,7 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
tmp_path += format(".%1%%2%", std::to_string(GUI::GLCanvas3D::timestamp_now()), ".download");
FILE* file;
wxString temp_path_wstring(tmp_path.wstring());
file = fopen(temp_path_wstring.c_str(), "wb");
file = boost::nowide::fopen(temp_path_wstring.c_str(), "wb");
assert(file != NULL);
if (file == NULL) {
std::string line1 = GUI::format(_u8L("Download from %1% couldn't start:"), data.url);
@ -397,14 +397,14 @@ void AppUpdater::priv::parse_version_string(const std::string &constbody) {
std::regex matcher("[0-9]+\\.[0-9]+(\\.[0-9]+)*(-[A-Za-z0-9]+)?(\\+[A-Za-z0-9]+)?");
Semver current_version(SLIC3R_VERSION_FULL);
Semver best_pre(1, 0, 0, 0);
Semver best_release(1, 0, 0, 0);
Semver best_pre(0, 0, 0, 0);
Semver best_release(0, 0, 0, 0);
std::string best_pre_url;
std::string best_pre_assets_url;
std::string best_release_url;
std::string best_release_assets_url;
const std::regex reg_num("([0-9]+)");
bool not_found = true;
bool not_found = true; // not found -> nightly
for (auto json_version : root) {
std::string tag = json_version.second.get<std::string>("tag_name");
for (std::regex_iterator it = std::sregex_iterator(tag.begin(), tag.end(), reg_num);
@ -430,13 +430,17 @@ void AppUpdater::priv::parse_version_string(const std::string &constbody) {
}
// for testing:
//best_release = Semver { 3, 0, 0, 0 };
std::string opt = GUI::wxGetApp().app_config->get("notify_release");
// if release is more recent than beta, use release anyway
if (best_pre < best_release) {
best_pre = best_release;
best_pre_url = best_release_url;
} else if (not_found && best_pre > best_release) {
} else if ( (not_found || current_version.prerelease()) && best_pre > best_release) {
// I am not found, so I should be an experimental / nightly build.
i_am_pre = true;
} else if (opt == "all") {
// use prelease if more recent
i_am_pre = best_pre > best_release;
}
// if we're the most recent, don't do anything
if ((i_am_pre ? best_pre : best_release) <= current_version)
@ -455,9 +459,9 @@ void AppUpdater::priv::parse_version_string(const std::string &constbody) {
set_app_data(new_data);
// send
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME,
new_data.version->to_string());
new_data.version.to_string());
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
evt->SetString(new_data.version->to_string());
evt->SetString(new_data.version.to_string());
GUI::wxGetApp().QueueEvent(evt);
}
#endif
@ -533,7 +537,7 @@ void AppUpdater::priv::parse_version_string(const std::string& body)
BOOST_LOG_TRIVIAL(error) << format("Received invalid contents from version file: Not a correct semver: `%1%`", version);
return;
}
new_data.version = release_version;
new_data.version = release_version ? *release_version : Semver();
// Send after all data is read
/*
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, version);
@ -555,7 +559,7 @@ void AppUpdater::priv::parse_version_string(const std::string& body)
std::string version_string;
for (const std::string& ver_string : prerelease_versions) {
std::optional<Semver> ver = Semver::parse(ver_string);
if (ver && *new_data.version < *ver && ((recent_version && *recent_version < *ver) || !recent_version)) {
if (ver && new_data.version < *ver && ((recent_version && *recent_version < *ver) || !recent_version)) {
recent_version = ver;
version_string = ver_string;
}
@ -739,14 +743,14 @@ bool replace_me(DownloadAppData input_data, const boost::filesystem::path &archi
mz_zip_archive_file_stat file_stat;
std::string archive_name = archive_path.stem().string();
boost::filesystem::path archive_name = archive_path.stem();
// we first loop the entries to read from the archive the .model file only, in order to extract the version from it
bool found_model = false;
for (mz_uint i = 0; i < num_entries; ++i) {
if (mz_zip_reader_file_stat(&zip.archive, i, &file_stat)) {
boost::filesystem::path name(file_stat.m_filename);
boost::filesystem::path out = name.lexically_relative(archive_path.stem());
boost::filesystem::path out = name.lexically_relative(archive_name);
if (file_stat.m_is_directory) {
boost::filesystem::create_directories(out);
} else {
@ -787,6 +791,7 @@ bool replace_me(DownloadAppData input_data, const boost::filesystem::path &archi
}
void fix_replace_me() {
#ifdef _WIN32
//get our directory
boost::filesystem::path my_dir = binary_file().parent_path();
boost::filesystem::path temp_dir = my_dir / SLIC3R_VERSION_FULL ".old";
@ -799,11 +804,18 @@ void fix_replace_me() {
}
}
if (boost::filesystem::exists(temp_dir / "resources")) {
if (boost::filesystem::exists(my_dir / "resources")) {
boost::filesystem::remove_all(my_dir / "resources");
}
boost::filesystem::rename(temp_dir / "resources", my_dir / "resources");
}
#else
assert(false);
#endif
}
AppUpdater::AppUpdater()
:p(new priv())
{
@ -818,6 +830,21 @@ AppUpdater::~AppUpdater()
}
}
//clean "old" after a in-place upgrade
void AppUpdater::clean() {
#ifdef _WIN32
//get our directory
boost::filesystem::path my_dir = binary_file().parent_path();
// rename back all dll & exe
for (const boost::filesystem::directory_entry& file_entry : boost::filesystem::directory_iterator(my_dir)) {
if (file_entry.status().type() == boost::filesystem::file_type::regular_file
&& file_entry.path().extension() == ".old") {
boost::filesystem::remove(file_entry.path());
}
}
#endif
}
void AppUpdater::sync_download()
{
assert(p);
@ -844,15 +871,21 @@ void AppUpdater::sync_download()
1024 * 1024
// on_progress
,
[](Http::Progress progress) { return true; }
[](Http::Progress progress) {
return true;
}
// on_complete
,
[&](std::string body, std::string &error_message) {
boost::trim(body);
bool ok = false;
boost::property_tree::ptree root;
std::stringstream json_stream(body);
boost::property_tree::read_json(json_stream, root);
if (input_data.version != Semver()) {
GUI::wxGetApp().app_config->set("version_online_seen", input_data.version.to_string());
}
for (auto json_asset : root) {
std::string name = json_asset.second.get<std::string>("name");
#ifdef _WIN32
@ -885,6 +918,7 @@ void AppUpdater::sync_download()
//download
ok = true;
p->m_thread = std::thread([this, input_data]() {
p->m_download_ongoing = true;
if (boost::filesystem::path dest_path = p->download_file(input_data);
@ -923,7 +957,11 @@ void AppUpdater::sync_download()
});
}
}
return true;
if (!ok) {
error_message = GUI::format(
_u8L("Can't find a suitable file to download. You have to download it manually at %1%"), input_data.url);
}
return ok;
},
error_message);
// lm:In case the internet is not available, it will report no updates if run by user.
@ -934,11 +972,9 @@ void AppUpdater::sync_download()
std::string message = GUI::format("Downloading %1% assets file has failed:\n%2%", SLIC3R_APP_NAME,
error_message);
BOOST_LOG_TRIVIAL(error) << message;
if (p->m_triggered_by_user) {
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
evt->SetString(message);
GUI::wxGetApp().QueueEvent(evt);
}
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
evt->SetString(message);
GUI::wxGetApp().QueueEvent(evt);
}
#endif

View file

@ -26,7 +26,7 @@ struct DownloadAppData
std::string asset_name;
bool start_after;
bool replace_current;
std::optional<Semver> version;
Semver version;
size_t size;
boost::filesystem::path target_path;
};
@ -48,6 +48,8 @@ public:
void cancel();
bool cancel_callback();
static void clean();
std::string get_default_dest_folder();
static std::string get_filename_from_url(const std::string& url);

View file

@ -55,6 +55,9 @@ wxDEFINE_EVENT(EVT_CONFIG_UPDATER_SHOW_DIALOG, wxCommandEvent);
#define ERROR_MSG_UNABLE_SNAPSHOT "Error: fail to take a snapshot"
#define ERROR_MSG_UNABLE_COPY_CONFIG "Unable to copy the vendor bundle into the configuration directory."
bool copy_file_and_icons(boost::filesystem::path dir_in, boost::filesystem::path dir_out, std::string vendor_id, bool copy = true);
PresetUpdater::PresetUpdater(wxEvtHandler* event_handler) : evt_handler(event_handler){
evt_handler->Bind(EVT_CONFIG_UPDATER_SHOW_DIALOG, [this](const wxCommandEvent& evt) {
@ -84,7 +87,7 @@ void PresetUpdater::set_installed_vendors(const PresetBundle *preset_bundle) {
is_synch = false;
}
} else {
bool has_cache = boost::filesystem::exists(GUI::into_path(data_dir()) / "cache" / "vendor" / installed_vendor.usable_id());
bool has_cache = boost::filesystem::exists(data_path() / "cache" / "vendor" / installed_vendor.usable_id());
it->second.reset(installed_vendor, true, has_cache);
}
}
@ -100,9 +103,9 @@ void PresetUpdater::load_unused_vendors(std::set<std::string> &vendors_id, const
if (file_path.extension() != ".ini") {
continue;
}
if (vendors_id.find(file_path.stem().string()) == vendors_id.end()) {
//if (vendors_id.find(file_path.stem().string()) == vendors_id.end()) {
vendors.push_back(file_path);
}
//}
}
}
}
@ -115,7 +118,8 @@ void PresetUpdater::load_unused_vendors(std::set<std::string> &vendors_id, const
if (!vp.config_update_rest.empty()) {
is_synch = false;
}
bool has_cache = boost::filesystem::exists(GUI::into_path(data_dir()) / "cache" / "vendor" / vp.usable_id());
// ensure it's copied into the cache
bool has_cache = boost::filesystem::exists(data_path() / "cache" / "vendor" / vp.usable_id());
this->all_vendors[vp.id] = VendorSync{vp, is_installed, has_cache};
assert(this->all_vendors[vp.id].is_installed == is_installed);
if (vp.config_version != Semver()) {
@ -128,8 +132,21 @@ void PresetUpdater::load_unused_vendors(std::set<std::string> &vendors_id, const
// now order by version
this->all_vendors[vp.id].sort_available();
} else {
bool has_cache = boost::filesystem::exists(GUI::into_path(data_dir()) / "cache" / "vendor" / vp.usable_id());
it->second.reset(vp, is_installed, has_cache);
// add new available version if not present
bool new_version = true;
for (const VendorAvailable &version : it->second.available_profiles) {
if (version.config_version == vp.config_version) {
new_version = false;
break;
}
}
if (new_version) {
it->second.available_profiles.emplace_back(
VendorAvailable{vp.config_version, vp.slicer_version, path.string(), "", "", "",
/*tag = */vp.config_version.to_string() + "=" + vp.slicer_version.to_string(), ""});
it->second.sort_available();
it->second.can_upgrade = !it->second.available_profiles.empty() && it->second.available_profiles.front().config_version > it->second.profile.config_version;
}
}
}
}
@ -138,8 +155,8 @@ void PresetUpdater::reload_all_vendors() {
//this->unused_vendors.clear();
std::set<std::string> vendors_id;
boost::filesystem::path configuration_path(Slic3r::data_dir());
boost::filesystem::path resources_path(Slic3r::resources_dir());
boost::filesystem::path configuration_path = Slic3r::data_path();
boost::filesystem::path resources_path = Slic3r::resources_path();
all_vendors.clear();
// read all vendor from configuration
@ -177,15 +194,56 @@ void PresetUpdater::reload_all_vendors() {
}
}
// read all vendor from cache (added but not installed)
for (const boost::filesystem::directory_entry &vendor_entry : boost::filesystem::directory_iterator(configuration_path / "cache" / "vendor")) {
for (const boost::filesystem::directory_entry &vendor_entry :
boost::filesystem::directory_iterator(configuration_path / "cache" / "vendor")) {
if (vendor_entry.status().type() == boost::filesystem::file_type::directory_file) {
load_unused_vendors(vendors_id, vendor_entry.path(), /*is_installed=*/false);
}
}
// get our vendors from resources;
assert(boost::filesystem::exists(resources_path / "profiles"));
load_unused_vendors(vendors_id, resources_path / "profiles", /*is_installed=*/ false);
assert(boost::filesystem::exists(resources_path));
if (!boost::filesystem::exists(resources_path / "profiles")) {
boost::filesystem::create_directories(resources_path / "profiles");
}
//load_unused_vendors(vendors_id, resources_path / "profiles", /*is_installed=*/ false);
for (const boost::filesystem::directory_entry &vendor_entry :
boost::filesystem::directory_iterator(resources_path / "profiles")) {
if (vendor_entry.path().extension() != ".ini") {
continue;
}
try {
VendorProfile vp = VendorProfile::from_ini(vendor_entry.path(), false);
//if (vp.config_update_rest.empty())
{
// copy to cache if not already in
boost::filesystem::path vendor_cache = GUI::into_path(data_dir()) / "cache" / "vendor" /
vp.usable_id();
std::string vendor_file_id = vendor_entry.path().stem().string();
std::string dir_cache_name = vendor_entry.path().stem().string() + "_" + vp.config_version.to_string();
if (!boost::filesystem::exists(vendor_cache / dir_cache_name)) {
boost::filesystem::create_directories(vendor_cache / dir_cache_name / "profiles");
copy_file_and_icons(resources_path / "profiles", vendor_cache / dir_cache_name / "profiles", vendor_file_id, true);
}
}
} catch (std::exception) {
}
}
// load all available profile copied into cache.
for (const boost::filesystem::directory_entry &vendor_entry :
boost::filesystem::directory_iterator(configuration_path / "cache" / "vendor")) {
if (vendor_entry.is_directory()) {
for (const boost::filesystem::directory_entry &config_entry :
boost::filesystem::directory_iterator(vendor_entry.path())) {
if (config_entry.is_directory() && boost::filesystem::exists(config_entry.path() / "profiles")) {
load_unused_vendors(vendors_id, config_entry.path() / "profiles", /*is_installed=*/false);
}
}
}
}
}
@ -205,7 +263,7 @@ void PresetUpdater::download_logs(const std::string &vendor_id, std::function<vo
// note: all_vendors shoudln't change since vendor was stored somewhere elese.
std::lock_guard<std::mutex> guard(this->callback_update_changelog_mutex);
changelog_synch = vendor.available_profiles.size();
boost::filesystem::path cache_path = GUI::into_path(data_dir()) / "cache" / "vendor" / vendor.profile.usable_id() / "logs";
boost::filesystem::path cache_path = data_path() / "cache" / "vendor" / vendor.profile.usable_id() / "logs";
boost::filesystem::create_directories(cache_path);
// for each tag
for (size_t available_idx = 0; available_idx < vendor.available_profiles.size(); available_idx++) {
@ -415,7 +473,7 @@ void PresetUpdater::sync_async(std::function<void(int)> callback_for_after_updat
void PresetUpdater::update_vendor(VendorSync &vendor, bool force) {
// reuse
boost::filesystem::path cache_path = GUI::into_path(data_dir()) / "cache" / "vendor" / vendor.profile.usable_id() / (vendor.profile.usable_id() + "_tags.json");
boost::filesystem::path cache_path = data_path() / "cache" / "vendor" / vendor.profile.usable_id() / (vendor.profile.usable_id() + "_tags.json");
if (boost::filesystem::exists(cache_path) && !force) {
std::time_t last_mod = boost::filesystem::last_write_time(cache_path);
std::time_t now = std::time(nullptr);
@ -439,7 +497,7 @@ void PresetUpdater::update_vendor(VendorSync &vendor, bool force) {
end_updating();
return;
}
boost::filesystem::path cache_dir = GUI::into_path(data_dir()) / "cache" / "vendor" / vendor.profile.usable_id();
boost::filesystem::path cache_dir = data_path() / "cache" / "vendor" / vendor.profile.usable_id();
boost::filesystem::create_directories(cache_dir);
// create url to get tags from github
std::string url(VendorProfile::get_http_url_rest(vendor.profile.config_update_rest) + "/tags?per_page=100;page=1");
@ -711,7 +769,7 @@ void PresetUpdater::install_vendor(const std::string &vendor_id,
// read it with models
if (vendor.profile.models.empty()) {
assert(vendor.is_installed);
vendor.profile = VendorProfile::from_ini(GUI::into_path(data_dir()) / "vendor" / (vendor.profile.id + ".ini"), true);
vendor.profile = VendorProfile::from_ini(data_path() / "vendor" / (vendor.profile.id + ".ini"), true);
assert(!vendor.profile.models.empty());
}
// update appconfig : remove unfindable printers
@ -764,7 +822,7 @@ void PresetUpdater::install_vendor(const std::string &vendor_id,
callback_result(result);
}
bool copy_file_and_icons(boost::filesystem::path dir_in, boost::filesystem::path dir_out, std::string vendor_id, bool copy = true) {
bool copy_file_and_icons(boost::filesystem::path dir_in, boost::filesystem::path dir_out, std::string vendor_id, bool copy) {
// copy the file & icons
assert(boost::filesystem::exists(dir_in));
@ -820,14 +878,14 @@ bool copy_file_and_icons(boost::filesystem::path dir_in, boost::filesystem::path
std::string VendorSync::install_vendor_config(const VendorAvailable &to_install, PresetUpdater& api_slot) {
// rename current venddor file (if any)
boost::filesystem::path vendor_file = GUI::into_path(data_dir()) / "vendor" / (this->profile.id + ".ini");
boost::filesystem::path vendor_file = data_path() / "vendor" / (this->profile.id + ".ini");
assert(!this->is_installed || boost::filesystem::exists(vendor_file));
// get new file
if (!to_install.local_file.empty() && boost::filesystem::exists(to_install.local_file)) {
// file in resource directory
boost::filesystem::path new_vendor_file(to_install.local_file);
assert(new_vendor_file.stem() == profile.id);
bool copy_okay = copy_file_and_icons(new_vendor_file.parent_path(), GUI::into_path(data_dir()) / "vendor", new_vendor_file.stem().string(), true);
bool copy_okay = copy_file_and_icons(new_vendor_file.parent_path(), data_path() / "vendor", new_vendor_file.stem().string(), true);
if (!copy_okay) {
return _u8L(ERROR_MSG_UNABLE_COPY_CONFIG);
}
@ -837,11 +895,11 @@ std::string VendorSync::install_vendor_config(const VendorAvailable &to_install,
std::string directory_name = profile.id+"-"+to_install.tag;
directory_name = std::regex_replace(directory_name, std::regex("[^0-9a-zA-Z_\\-.]"), "-");
// download zip
boost::filesystem::path temp_dir = GUI::into_path(data_dir()) / "cache" / "vendor" / this->profile.usable_id();
boost::filesystem::path temp_dir = data_path() / "cache" / "vendor" / this->profile.usable_id();
boost::filesystem::path root_dir = temp_dir / directory_name;
if (!boost::filesystem::exists(root_dir)) {
boost::filesystem::create_directories(temp_dir);
boost::filesystem::path download_zip_file(data_dir());
boost::filesystem::path download_zip_file = data_path();
download_zip_file = download_zip_file / "cache" / "vendor" / this->profile.usable_id() / (this->profile.usable_id() + ".zip");
if (boost::filesystem::exists(download_zip_file)) {
boost::filesystem::remove(download_zip_file);
@ -934,7 +992,7 @@ std::string VendorSync::install_vendor_config(const VendorAvailable &to_install,
if (!p) {
return _u8L("Unable to open the preset zip. Maybe the download is corrupted");
}
FILE *file_to_write = fopen(out_path.string().c_str(), "wb");
FILE *file_to_write = boost::nowide::fopen(out_path.string().c_str(), "wb");
if (file_to_write == nullptr) {
BOOST_LOG_TRIVIAL(error) << "Fail to unzip downloaded config zip.";
return _u8L("Unable to write into the hard disk drive.");
@ -952,7 +1010,7 @@ std::string VendorSync::install_vendor_config(const VendorAvailable &to_install,
}
// copy the file & icons
assert(boost::filesystem::exists(root_dir));
bool copy_okay = copy_file_and_icons(root_dir / "profiles", GUI::into_path(data_dir()) / "vendor",
bool copy_okay = copy_file_and_icons(root_dir / "profiles", data_path() / "vendor",
this->profile.id, true);
if (!copy_okay) {
return _u8L(ERROR_MSG_UNABLE_COPY_CONFIG);
@ -962,7 +1020,8 @@ std::string VendorSync::install_vendor_config(const VendorAvailable &to_install,
//already downloaded
// copy the file & icons
assert(boost::filesystem::exists(root_dir));
bool copy_okay = copy_file_and_icons(root_dir / "profiles", GUI::into_path(data_dir()) / "vendor",
assert(boost::filesystem::exists(root_dir / "profiles"));
bool copy_okay = copy_file_and_icons(root_dir / "profiles", data_path() / "vendor",
this->profile.id, true);
if (!copy_okay) {
return _u8L(ERROR_MSG_UNABLE_COPY_CONFIG);
@ -970,7 +1029,7 @@ std::string VendorSync::install_vendor_config(const VendorAvailable &to_install,
}
}
// refresh this
VendorProfile vp = VendorProfile::from_ini(GUI::into_path(data_dir()) / "vendor" / (this->profile.id + ".ini"), true);
VendorProfile vp = VendorProfile::from_ini(data_path() / "vendor" / (this->profile.id + ".ini"), true);
this->is_installed = true;
this->profile = vp;
this->can_upgrade = !available_profiles.empty() && available_profiles.front().config_version > profile.config_version;
@ -979,7 +1038,7 @@ std::string VendorSync::install_vendor_config(const VendorAvailable &to_install,
bool VendorSync::uninstall_vendor_config() {
// move from vendor to cache
bool move_okay = copy_file_and_icons(GUI::into_path(data_dir()) / "vendor", GUI::into_path(data_dir()) / "cache" / "vendor" / this->profile.usable_id(), this->profile.usable_id(), false);
bool move_okay = copy_file_and_icons(data_path() / "vendor", data_path() / "cache" / "vendor" / this->profile.usable_id(), this->profile.usable_id(), false);
if (!move_okay) {
return false;
}
@ -994,7 +1053,7 @@ bool VendorSync::uninstall_vendor_config() {
bool VendorSync::clear_cache() {
assert(has_cache);
// remove cache
size_t nbdel = boost::filesystem::remove_all(GUI::into_path(data_dir()) / "cache" / "vendor" / this->profile.usable_id());
size_t nbdel = boost::filesystem::remove_all(data_path() / "cache" / "vendor" / this->profile.usable_id());
return nbdel > 0;
}
@ -1107,8 +1166,8 @@ void PresetUpdater::download_new_repo(const std::string &rest_url, std::function
boost::property_tree::read_ini(body_stream, root);
VendorProfile vp = VendorProfile::from_ini(root, id, false);
// save it
boost::filesystem::create_directories(GUI::into_path(data_dir()) / "cache" / "vendor" / vp.usable_id());
boost::filesystem::path file_path = GUI::into_path(data_dir()) / "cache" / "vendor" / vp.usable_id() / (vp.usable_id() + ".ini");
boost::filesystem::create_directories(data_path() / "cache" / "vendor" / vp.usable_id());
boost::filesystem::path file_path = data_path() / "cache" / "vendor" / vp.usable_id() / (vp.usable_id() + ".ini");
bool no_error = true;
try {
std::ofstream file_out;
@ -1159,8 +1218,8 @@ void PresetUpdater::download_new_repo(const std::string &rest_url, std::function
vp = VendorProfile::from_ini(root, id, false);
}
// save it
boost::filesystem::create_directories(GUI::into_path(data_dir()) / "cache" / "vendor" / vp.usable_id());
boost::filesystem::path file_path = GUI::into_path(data_dir()) / "cache" / "vendor" / vp.usable_id() / (vp.usable_id() + ".ini");
boost::filesystem::create_directories(data_path() / "cache" / "vendor" / vp.usable_id());
boost::filesystem::path file_path = data_path() / "cache" / "vendor" / vp.usable_id() / (vp.usable_id() + ".ini");
try {
std::ofstream file_out;
file_out.open(file_path.string().c_str(), std::ofstream::out | std::ofstream::trunc);
@ -1302,7 +1361,7 @@ void PresetUpdater::upgrade_all_installed_vendors(std::function<void(const std::
// read it with models
if (vendor.profile.models.empty()) {
assert(vendor.is_installed);
vendor.profile = VendorProfile::from_ini(GUI::into_path(data_dir()) / "vendor" / (vendor.profile.id + ".ini"), true);
vendor.profile = VendorProfile::from_ini(data_path() / "vendor" / (vendor.profile.id + ".ini"), true);
assert(!vendor.profile.models.empty());
}
// update appconfig : remove unfindable printers