Merge remote-tracking branch 'origin/enh-port-edit-gcode-dlg' into enh-port-edit-gcode-dlg

This commit is contained in:
Ocraftyone 2024-01-05 06:06:40 -05:00
commit 907b160007
No known key found for this signature in database
GPG key ID: 85836ED21AD4D125
36 changed files with 156 additions and 304 deletions

View file

@ -28,7 +28,7 @@
using namespace Slic3r;
#include "ExPolygonsIndex.hpp"
#include <boost/next_prior.hpp>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Exact_integer.h>
#include <CGAL/Surface_mesh.h>

View file

@ -31,7 +31,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/string_file.hpp>
#include <boost/nowide/fstream.hpp>
#include <boost/nowide/cstdio.hpp>
#include <boost/spirit/include/karma.hpp>
@ -1290,9 +1289,9 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
model.set_backup_path(m_backup_path);
try {
if (boost::filesystem::exists(model.get_backup_path() + "/origin.txt"))
boost::filesystem::load_string_file(model.get_backup_path() + "/origin.txt", m_origin_file);
load_string_file(model.get_backup_path() + "/origin.txt", m_origin_file);
} catch (...) {}
boost::filesystem::save_string_file(
save_string_file(
model.get_backup_path() + "/lock.txt",
boost::lexical_cast<std::string>(get_current_pid()));
}
@ -1305,7 +1304,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
file_version = *m_bambuslicer_generator_version;
// save for restore
if (result && m_load_aux && !m_load_restore) {
boost::filesystem::save_string_file(model.get_backup_path() + "/origin.txt", filename);
save_string_file(model.get_backup_path() + "/origin.txt", filename);
}
if (m_load_restore && !result) // not clear failed backup data for later analyze
model.set_backup_path("detach");
@ -5544,7 +5543,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
return false;
}
if (!(store_params.strategy & SaveStrategy::Silence))
boost::filesystem::save_string_file(store_params.model->get_backup_path() + "/origin.txt", filename);
save_string_file(store_params.model->get_backup_path() + "/origin.txt", filename);
}
return result;
}
@ -8287,7 +8286,7 @@ bool has_restore_data(std::string & path, std::string& origin)
}
if (boost::filesystem::exists(path + "/lock.txt")) {
std::string pid;
boost::filesystem::load_string_file(path + "/lock.txt", pid);
load_string_file(path + "/lock.txt", pid);
try {
if (get_process_name(boost::lexical_cast<int>(pid)) ==
get_process_name(0)) {
@ -8304,7 +8303,7 @@ bool has_restore_data(std::string & path, std::string& origin)
return false;
try {
if (boost::filesystem::exists(path + "/origin.txt"))
boost::filesystem::load_string_file(path + "/origin.txt", origin);
load_string_file(path + "/origin.txt", origin);
}
catch (...) {
}

View file

@ -5,6 +5,7 @@
#include "libslic3r/format.hpp"
#undef PI
#include <boost/next_prior.hpp>
// Include igl first. It defines "L" macro which then clashes with our localization
#include <igl/copyleft/cgal/mesh_boolean.h>
#undef L

View file

@ -38,7 +38,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/string_file.hpp>
#include <boost/log/trivial.hpp>
#include <boost/nowide/iostream.hpp>
@ -873,7 +872,7 @@ std::string Model::get_backup_path()
BOOST_LOG_TRIVIAL(info) << "create /Metadata in " << temp_path;
boost::filesystem::create_directories(backup_path + "/Metadata");
BOOST_LOG_TRIVIAL(info) << "create /lock.txt in " << temp_path;
boost::filesystem::save_string_file(backup_path + "/lock.txt",
save_string_file(backup_path + "/lock.txt",
boost::lexical_cast<std::string>(get_current_pid()));
}
} catch (std::exception &ex) {

View file

@ -4,6 +4,7 @@
///|/
#include "Triangulation.hpp"
#include "IntersectionPoints.hpp"
#include <boost/next_prior.hpp>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>

View file

@ -655,6 +655,9 @@ inline std::string filter_characters(const std::string& str, const std::string&
void copy_directory_recursively(const boost::filesystem::path &source, const boost::filesystem::path &target);
// Orca: Since 1.7.9 Boost deprecated save_string_file and load_string_file, copy and modified from boost 1.7.8
void save_string_file(const boost::filesystem::path& p, const std::string& str);
void load_string_file(const boost::filesystem::path& p, std::string& str);
} // namespace Slic3r

View file

@ -1539,4 +1539,22 @@ void copy_directory_recursively(const boost::filesystem::path &source, const boo
return;
}
void save_string_file(const boost::filesystem::path& p, const std::string& str)
{
boost::nowide::ofstream file;
file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
file.open(p.generic_string(), std::ios_base::binary);
file.write(str.c_str(), str.size());
}
void load_string_file(const boost::filesystem::path& p, std::string& str)
{
boost::nowide::ifstream file;
file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
file.open(p.generic_string(), std::ios_base::binary);
std::size_t sz = static_cast<std::size_t>(boost::filesystem::file_size(p));
str.resize(sz, '\0');
file.read(&str[0], sz);
}
}; // namespace Slic3r

View file

@ -3221,8 +3221,8 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
// }
// break;
//}
//case 'I':
//case 'i': { _update_camera_zoom(1.0); break; }
case 'I':
case 'i': { _update_camera_zoom(1.0); break; }
//case 'K':
//case 'k': { wxGetApp().plater()->get_camera().select_next_type(); m_dirty = true; break; }
//case 'L':
@ -3234,8 +3234,8 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
//}
//break;
//}
//case 'O':
//case 'o': { _update_camera_zoom(-1.0); break; }
case 'O':
case 'o': { _update_camera_zoom(-1.0); break; }
//case 'Z':
//case 'z': {
// if (!m_selection.is_empty())

View file

@ -2149,8 +2149,8 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
// First (any) GLVolume of the selected instance. They all share the same instance matrix.
const GLVolume* v = selection.get_first_volume();
// Transform the new modifier to be aligned with the print bed.
const BoundingBoxf3 mesh_bb = new_volume->mesh().bounding_box();
new_volume->set_transformation(Geometry::Transformation::volume_to_bed_transformation(v->get_instance_transformation(), mesh_bb));
new_volume->set_transformation(v->get_instance_transformation().get_matrix_no_offset().inverse());
const BoundingBoxf3 mesh_bb = new_volume->mesh().bounding_box();
// Set the modifier position.
auto offset = (type_name == "Slab") ?
// Slab: Lift to print bed

View file

@ -388,15 +388,24 @@ bool GLGizmosManager::is_running() const
bool GLGizmosManager::handle_shortcut(int key)
{
if (!m_enabled || m_parent.get_selection().is_empty())
if (!m_enabled)
return false;
auto it = std::find_if(m_gizmos.begin(), m_gizmos.end(),
[key](const std::unique_ptr<GLGizmoBase>& gizmo) {
int gizmo_key = gizmo->get_shortcut_key();
return gizmo->is_activable()
&& ((gizmo_key == key - 64) || (gizmo_key == key - 96));
});
auto is_key = [pressed_key = key](int gizmo_key) { return (gizmo_key == pressed_key - 64) || (gizmo_key == pressed_key - 96); };
// allowe open shortcut even when selection is empty
if (GLGizmoBase* gizmo_emboss = m_gizmos[Emboss].get();
is_key(gizmo_emboss->get_shortcut_key())) {
dynamic_cast<GLGizmoEmboss *>(gizmo_emboss)->on_shortcut_key();
return true;
}
if (m_parent.get_selection().is_empty())
return false;
auto is_gizmo = [is_key](const std::unique_ptr<GLGizmoBase> &gizmo) {
return gizmo->is_activable() && is_key(gizmo->get_shortcut_key());
};
auto it = std::find_if(m_gizmos.begin(), m_gizmos.end(), is_gizmo);
if (it == m_gizmos.end())
return false;

View file

@ -258,6 +258,9 @@ void KBShortcutsDialog::fill_shortcuts()
{ "F", L("Gizmo Place face on bed") },
{ "L", L("Gizmo SLA support points") },
{ "P", L("Gizmo FDM paint-on seam") },
{ "T", L("Gizmo Text emboss / engrave")},
{ "I", L("Zoom in")},
{ "O", L("Zoom out")},
{ "Tab", L("Switch between Prepare/Preview") },
};

View file

@ -8,7 +8,6 @@
#include "MsgDialog.hpp"
#include "DownloadProgressDialog.hpp"
#include <boost/filesystem/string_file.hpp>
#include <boost/nowide/utf8_codecvt.hpp>
#undef pid_t
#include <boost/process.hpp>
@ -596,7 +595,7 @@ bool MediaPlayCtrl::start_stream_service(bool *need_install)
file_url2 = wxURI(file_url2).BuildURI();
try {
std::string configs;
boost::filesystem::load_string_file(file_ff_cfg, configs);
load_string_file(file_ff_cfg, configs);
std::vector<std::string> configss;
boost::algorithm::split(configss, configs, boost::algorithm::is_any_of("\r\n"));
configss.erase(std::remove(configss.begin(), configss.end(), std::string()), configss.end());

View file

@ -9,7 +9,6 @@
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/string_file.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/log/trivial.hpp>
@ -819,9 +818,9 @@ void PresetUpdater::priv::sync_tooltip(std::string http_url, std::string languag
fs::path cache_root = fs::path(data_dir()) / "resources/tooltip";
try {
auto vf = cache_root / "common" / "version";
if (fs::exists(vf)) fs::load_string_file(vf, common_version);
if (fs::exists(vf)) load_string_file(vf, common_version);
vf = cache_root / language / "version";
if (fs::exists(vf)) fs::load_string_file(vf, language_version);
if (fs::exists(vf)) load_string_file(vf, language_version);
} catch (...) {}
std::map<std::string, Resource> resources
{
@ -997,11 +996,11 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url)
auto cache_folder = data_dir_path / "ota" / "printers";
try {
boost::filesystem::load_string_file(config_folder / "version.txt", curr_version);
load_string_file(config_folder / "version.txt", curr_version);
boost::algorithm::trim(curr_version);
} catch (...) {}
try {
boost::filesystem::load_string_file(cache_folder / "version.txt", cached_version);
load_string_file(cache_folder / "version.txt", cached_version);
boost::algorithm::trim(cached_version);
} catch (...) {}
if (!cached_version.empty()) {
@ -1035,7 +1034,7 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url)
bool result = false;
try {
boost::filesystem::load_string_file(cache_folder / "version.txt", cached_version);
load_string_file(cache_folder / "version.txt", cached_version);
boost::algorithm::trim(cached_version);
result = true;
} catch (...) {}
@ -1154,11 +1153,11 @@ Updates PresetUpdater::priv::get_printer_config_updates(bool update) const
std::string curr_version;
std::string resc_version;
try {
boost::filesystem::load_string_file(resc_folder / "version.txt", resc_version);
load_string_file(resc_folder / "version.txt", resc_version);
boost::algorithm::trim(resc_version);
} catch (...) {}
try {
boost::filesystem::load_string_file(config_folder / "version.txt", curr_version);
load_string_file(config_folder / "version.txt", curr_version);
boost::algorithm::trim(curr_version);
} catch (...) {}