mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-03 12:04:05 -06:00
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_seams_as_batched_models
This commit is contained in:
commit
c12e5bb4ed
49 changed files with 780 additions and 668 deletions
|
@ -163,12 +163,16 @@ bool Bed3D::set_shape(const Pointfs& shape, const std::string& custom_texture, c
|
|||
}
|
||||
|
||||
std::string texture_filename = custom_texture.empty() ? texture : custom_texture;
|
||||
if (!check_texture(texture_filename))
|
||||
if (! texture_filename.empty() && ! check_texture(texture_filename)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Unable to load bed texture: " << texture_filename;
|
||||
texture_filename.clear();
|
||||
}
|
||||
|
||||
std::string model_filename = custom_model.empty() ? model : custom_model;
|
||||
if (!check_model(model_filename))
|
||||
if (! model_filename.empty() && ! check_model(model_filename)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Unable to load bed model: " << model_filename;
|
||||
model_filename.clear();
|
||||
}
|
||||
|
||||
if (m_shape == shape && m_type == type && m_texture_filename == texture_filename && m_model_filename == model_filename)
|
||||
// No change, no need to update the UI.
|
||||
|
|
|
@ -574,11 +574,8 @@ Print::ApplyStatus BackgroundSlicingProcess::apply(const Model &model, const Dyn
|
|||
// Some FFF status was invalidated, and the G-code was not exported yet.
|
||||
// Let the G-code preview UI know that the final G-code preview is not valid.
|
||||
// In addition, this early memory deallocation reduces memory footprint.
|
||||
if (m_gcode_result != nullptr) {
|
||||
//FIXME calling platter from here is not a staple of a good architecture.
|
||||
GUI::wxGetApp().plater()->stop_mapping_gcode_window();
|
||||
if (m_gcode_result != nullptr)
|
||||
m_gcode_result->reset();
|
||||
}
|
||||
}
|
||||
return invalidated;
|
||||
}
|
||||
|
|
|
@ -70,18 +70,9 @@ static std::vector<std::array<float, 4>> decode_colors(const std::vector<std::st
|
|||
return output;
|
||||
}
|
||||
|
||||
static float round_to_nearest(float value, unsigned int decimals)
|
||||
static float round_to_nearest_percent(float value)
|
||||
{
|
||||
float res = 0.0f;
|
||||
if (decimals == 0)
|
||||
res = std::round(value);
|
||||
else {
|
||||
char buf[64];
|
||||
// locales should not matter, both sprintf and stof are sensitive, so...
|
||||
sprintf(buf, "%.*g", decimals, value);
|
||||
res = std::stof(buf);
|
||||
}
|
||||
return res;
|
||||
return std::round(value * 100.f) * 0.01f;
|
||||
}
|
||||
|
||||
void GCodeViewer::VBuffer::reset()
|
||||
|
@ -146,7 +137,7 @@ bool GCodeViewer::Path::matches(const GCodeProcessor::MoveVertex& move) const
|
|||
// use rounding to reduce the number of generated paths
|
||||
return type == move.type && extruder_id == move.extruder_id && cp_color_id == move.cp_color_id && role == move.extrusion_role &&
|
||||
move.position.z() <= sub_paths.front().first.position.z() && feedrate == move.feedrate && fan_speed == move.fan_speed &&
|
||||
height == round_to_nearest(move.height, 2) && width == round_to_nearest(move.width, 2) &&
|
||||
height == round_to_nearest_percent(move.height) && width == round_to_nearest_percent(move.width) &&
|
||||
matches_percent(volumetric_rate, move.volumetric_rate(), 0.05f);
|
||||
}
|
||||
case EMoveType::Travel: {
|
||||
|
@ -183,7 +174,7 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessor::MoveVertex& move, unsi
|
|||
Path::Endpoint endpoint = { b_id, i_id, s_id, move.position };
|
||||
// use rounding to reduce the number of generated paths
|
||||
paths.push_back({ move.type, move.extrusion_role, move.delta_extruder,
|
||||
round_to_nearest(move.height, 2), round_to_nearest(move.width, 2),
|
||||
round_to_nearest_percent(move.height), round_to_nearest_percent(move.width),
|
||||
move.feedrate, move.fan_speed, move.temperature,
|
||||
move.volumetric_rate(), move.extruder_id, move.cp_color_id, { { endpoint, endpoint } } });
|
||||
}
|
||||
|
@ -293,45 +284,14 @@ void GCodeViewer::SequentialView::Marker::render() const
|
|||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
void GCodeViewer::SequentialView::GCodeWindow::load_gcode()
|
||||
void GCodeViewer::SequentialView::GCodeWindow::load_gcode(const std::string& filename, const std::vector<size_t> &lines_ends)
|
||||
{
|
||||
if (m_filename.empty())
|
||||
return;
|
||||
|
||||
assert(! m_file.is_open());
|
||||
if (m_file.is_open())
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// generate mapping for accessing data in file by line number
|
||||
boost::nowide::ifstream f(m_filename);
|
||||
|
||||
f.seekg(0, f.end);
|
||||
uint64_t file_length = static_cast<uint64_t>(f.tellg());
|
||||
f.seekg(0, f.beg);
|
||||
|
||||
std::string line;
|
||||
uint64_t offset = 0;
|
||||
while (std::getline(f, line)) {
|
||||
uint64_t line_length = static_cast<uint64_t>(line.length());
|
||||
m_lines_map.push_back({ offset, line_length });
|
||||
offset += static_cast<uint64_t>(line_length) + 1;
|
||||
}
|
||||
|
||||
if (offset != file_length) {
|
||||
// if the final offset does not match with file length, lines are terminated with CR+LF
|
||||
// so update all offsets accordingly
|
||||
for (size_t i = 0; i < m_lines_map.size(); ++i) {
|
||||
m_lines_map[i].first += static_cast<uint64_t>(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(error) << "Unable to load data from " << m_filename << ". Cannot show G-code window.";
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
m_filename = filename;
|
||||
m_lines_ends = std::move(lines_ends);
|
||||
|
||||
m_selected_line_id = 0;
|
||||
m_last_lines_size = 0;
|
||||
|
@ -354,7 +314,9 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, u
|
|||
ret.reserve(end_id - start_id + 1);
|
||||
for (uint64_t id = start_id; id <= end_id; ++id) {
|
||||
// read line from file
|
||||
std::string gline(m_file.data() + m_lines_map[id - 1].first, m_lines_map[id - 1].second);
|
||||
const size_t start = id == 1 ? 0 : m_lines_ends[id - 2];
|
||||
const size_t len = m_lines_ends[id - 1] - start;
|
||||
std::string gline(m_file.data() + start, len);
|
||||
|
||||
std::string command;
|
||||
std::string parameters;
|
||||
|
@ -388,7 +350,7 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, u
|
|||
static const ImVec4 PARAMETERS_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static const ImVec4 COMMENT_COLOR = { 0.7f, 0.7f, 0.7f, 1.0f };
|
||||
|
||||
if (!m_visible || m_filename.empty() || m_lines_map.empty() || curr_line_id == 0)
|
||||
if (!m_visible || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0)
|
||||
return;
|
||||
|
||||
// window height
|
||||
|
@ -406,8 +368,8 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, u
|
|||
const uint64_t half_lines_count = lines_count / 2;
|
||||
uint64_t start_id = (curr_line_id >= half_lines_count) ? curr_line_id - half_lines_count : 0;
|
||||
uint64_t end_id = start_id + lines_count - 1;
|
||||
if (end_id >= static_cast<uint64_t>(m_lines_map.size())) {
|
||||
end_id = static_cast<uint64_t>(m_lines_map.size()) - 1;
|
||||
if (end_id >= static_cast<uint64_t>(m_lines_ends.size())) {
|
||||
end_id = static_cast<uint64_t>(m_lines_ends.size()) - 1;
|
||||
start_id = end_id - lines_count + 1;
|
||||
}
|
||||
|
||||
|
@ -512,7 +474,7 @@ void GCodeViewer::SequentialView::render(float legend_height) const
|
|||
}
|
||||
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
|
||||
{ 0.75f, 0.75f, 0.75f, 1.0f }, // erNone
|
||||
{ 0.90f, 0.70f, 0.70f, 1.0f }, // erNone
|
||||
{ 1.00f, 0.90f, 0.30f, 1.0f }, // erPerimeter
|
||||
{ 1.00f, 0.49f, 0.22f, 1.0f }, // erExternalPerimeter
|
||||
{ 0.12f, 0.12f, 1.00f, 1.0f }, // erOverhangPerimeter
|
||||
|
@ -615,8 +577,7 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print&
|
|||
// release gpu memory, if used
|
||||
reset();
|
||||
|
||||
m_sequential_view.gcode_window.set_filename(gcode_result.filename);
|
||||
m_sequential_view.gcode_window.load_gcode();
|
||||
m_sequential_view.gcode_window.load_gcode(gcode_result.filename, gcode_result.lines_ends);
|
||||
|
||||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
if (wxGetApp().is_gcode_viewer())
|
||||
|
@ -704,8 +665,8 @@ void GCodeViewer::refresh(const GCodeProcessor::Result& gcode_result, const std:
|
|||
// update tool colors
|
||||
m_tool_colors = decode_colors(str_tool_colors);
|
||||
|
||||
// ensure at least one (default) color is defined
|
||||
if (m_tool_colors.empty())
|
||||
// ensure there are enough colors defined
|
||||
while (m_tool_colors.size() < std::max(size_t(1), gcode_result.extruders_count))
|
||||
m_tool_colors.push_back(decode_color("#FF8000"));
|
||||
|
||||
// update ranges for coloring / legend
|
||||
|
@ -721,11 +682,11 @@ void GCodeViewer::refresh(const GCodeProcessor::Result& gcode_result, const std:
|
|||
{
|
||||
case EMoveType::Extrude:
|
||||
{
|
||||
m_extrusions.ranges.height.update_from(round_to_nearest(curr.height, 2));
|
||||
m_extrusions.ranges.width.update_from(round_to_nearest(curr.width, 2));
|
||||
m_extrusions.ranges.height.update_from(round_to_nearest_percent(curr.height));
|
||||
m_extrusions.ranges.width.update_from(round_to_nearest_percent(curr.width));
|
||||
m_extrusions.ranges.fan_speed.update_from(curr.fan_speed);
|
||||
m_extrusions.ranges.temperature.update_from(curr.temperature);
|
||||
m_extrusions.ranges.volumetric_rate.update_from(round_to_nearest(curr.volumetric_rate(), 2));
|
||||
m_extrusions.ranges.volumetric_rate.update_from(round_to_nearest_percent(curr.volumetric_rate()));
|
||||
[[fallthrough]];
|
||||
}
|
||||
case EMoveType::Travel:
|
||||
|
@ -1175,16 +1136,6 @@ void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
|
|||
fclose(fp);
|
||||
}
|
||||
|
||||
void GCodeViewer::start_mapping_gcode_window()
|
||||
{
|
||||
m_sequential_view.gcode_window.load_gcode();
|
||||
}
|
||||
|
||||
void GCodeViewer::stop_mapping_gcode_window()
|
||||
{
|
||||
m_sequential_view.gcode_window.stop_mapping_file();
|
||||
}
|
||||
|
||||
void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
|
||||
{
|
||||
// max index buffer size, in bytes
|
||||
|
@ -2563,7 +2514,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
|||
|
||||
buffer.model.instances.render_ranges.reset();
|
||||
|
||||
if (!buffer.visible)
|
||||
if (!buffer.visible || buffer.model.instances.s_ids.empty())
|
||||
continue;
|
||||
|
||||
buffer.model.instances.render_ranges.ranges.push_back({ 0, 0, 0, buffer.model.color });
|
||||
|
|
|
@ -695,18 +695,17 @@ public:
|
|||
std::string m_filename;
|
||||
boost::iostreams::mapped_file_source m_file;
|
||||
// map for accessing data in file by line number
|
||||
std::vector<std::pair<uint64_t, uint64_t>> m_lines_map;
|
||||
std::vector<size_t> m_lines_ends;
|
||||
// current visible lines
|
||||
std::vector<Line> m_lines;
|
||||
|
||||
public:
|
||||
GCodeWindow() = default;
|
||||
~GCodeWindow() { stop_mapping_file(); }
|
||||
void set_filename(const std::string& filename) { m_filename = filename; }
|
||||
void load_gcode();
|
||||
void load_gcode(const std::string& filename, const std::vector<size_t> &lines_ends);
|
||||
void reset() {
|
||||
stop_mapping_file();
|
||||
m_lines_map.clear();
|
||||
m_lines_ends.clear();
|
||||
m_lines.clear();
|
||||
m_filename.clear();
|
||||
}
|
||||
|
@ -833,8 +832,6 @@ public:
|
|||
|
||||
void export_toolpaths_to_obj(const char* filename) const;
|
||||
|
||||
void start_mapping_gcode_window();
|
||||
void stop_mapping_gcode_window();
|
||||
void toggle_gcode_window_visibility() { m_sequential_view.gcode_window.toggle_visibility(); }
|
||||
|
||||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||
|
|
|
@ -1114,16 +1114,6 @@ int GLCanvas3D::check_volumes_outside_state() const
|
|||
return (int)state;
|
||||
}
|
||||
|
||||
void GLCanvas3D::start_mapping_gcode_window()
|
||||
{
|
||||
m_gcode_viewer.start_mapping_gcode_window();
|
||||
}
|
||||
|
||||
void GLCanvas3D::stop_mapping_gcode_window()
|
||||
{
|
||||
m_gcode_viewer.stop_mapping_gcode_window();
|
||||
}
|
||||
|
||||
void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo, int instance_idx)
|
||||
{
|
||||
m_render_sla_auxiliaries = visible;
|
||||
|
|
|
@ -621,9 +621,6 @@ public:
|
|||
const GCodeViewer::SequentialView& get_gcode_sequential_view() const { return m_gcode_viewer.get_sequential_view(); }
|
||||
void update_gcode_sequential_view_current(unsigned int first, unsigned int last) { m_gcode_viewer.update_sequential_view_current(first, last); }
|
||||
|
||||
void start_mapping_gcode_window();
|
||||
void stop_mapping_gcode_window();
|
||||
|
||||
void toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
||||
void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
||||
void update_instance_printable_state_for_object(size_t obj_idx);
|
||||
|
|
|
@ -1044,13 +1044,8 @@ void ObjectList::key_event(wxKeyEvent& event)
|
|||
{
|
||||
if (event.GetKeyCode() == WXK_TAB)
|
||||
Navigate(event.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward);
|
||||
else if (event.GetKeyCode() == WXK_DELETE
|
||||
#ifdef __WXOSX__
|
||||
|| event.GetKeyCode() == WXK_BACK
|
||||
#endif //__WXOSX__
|
||||
) {
|
||||
else if (event.GetKeyCode() == WXK_DELETE || event.GetKeyCode() == WXK_BACK )
|
||||
remove();
|
||||
}
|
||||
else if (event.GetKeyCode() == WXK_F5)
|
||||
wxGetApp().plater()->reload_all_from_disk();
|
||||
else if (wxGetKeyState(wxKeyCode('A')) && wxGetKeyState(WXK_CONTROL/*WXK_SHIFT*/))
|
||||
|
@ -4030,17 +4025,12 @@ void ObjectList::simplify()
|
|||
|
||||
// Do not simplify when a gizmo is open. There might be issues with updates
|
||||
// and what is worse, the snapshot time would refer to the internal stack.
|
||||
auto current_type = gizmos_mgr.get_current_type();
|
||||
if (current_type == GLGizmosManager::Simplify) {
|
||||
if (! gizmos_mgr.check_gizmos_closed_except(GLGizmosManager::EType::Simplify))
|
||||
return;
|
||||
|
||||
if (gizmos_mgr.get_current_type() == GLGizmosManager::Simplify) {
|
||||
// close first
|
||||
gizmos_mgr.open_gizmo(GLGizmosManager::EType::Simplify);
|
||||
}else if (current_type != GLGizmosManager::Undefined) {
|
||||
plater->get_notification_manager()->push_notification(
|
||||
NotificationType::CustomSupportsAndSeamRemovedAfterRepair,
|
||||
NotificationManager::NotificationLevel::RegularNotification,
|
||||
_u8L("ERROR: Please close all manipulators available from "
|
||||
"the left toolbar before start simplify the mesh."));
|
||||
return;
|
||||
}
|
||||
gizmos_mgr.open_gizmo(GLGizmosManager::EType::Simplify);
|
||||
}
|
||||
|
|
|
@ -232,6 +232,20 @@ void GLGizmoBase::render_input_window(float x, float y, float bottom_limit)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string GLGizmoBase::get_name(bool include_shortcut) const
|
||||
{
|
||||
int key = get_shortcut_key();
|
||||
assert( key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z);
|
||||
std::string out = on_get_name();
|
||||
if (include_shortcut)
|
||||
out += std::string(" [") + char(int('A') + key - int(WXK_CONTROL_A)) + "]";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
|
||||
// were not interpolated by alpha blending or multi sampling.
|
||||
unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue)
|
||||
|
|
|
@ -120,7 +120,7 @@ public:
|
|||
void load(cereal::BinaryInputArchive& ar) { m_state = On; on_load(ar); }
|
||||
void save(cereal::BinaryOutputArchive& ar) const { on_save(ar); }
|
||||
|
||||
std::string get_name() const { return on_get_name(); }
|
||||
std::string get_name(bool include_shortcut = true) const;
|
||||
|
||||
int get_group_id() const { return m_group_id; }
|
||||
void set_group_id(int id) { m_group_id = id; }
|
||||
|
@ -135,6 +135,7 @@ public:
|
|||
bool is_activable() const { return on_is_activable(); }
|
||||
bool is_selectable() const { return on_is_selectable(); }
|
||||
CommonGizmosDataID get_requirements() const { return on_get_requirements(); }
|
||||
virtual bool wants_enter_leave_snapshots() const { return false; }
|
||||
void set_common_data_pool(CommonGizmosDataPool* ptr) { m_c = ptr; }
|
||||
|
||||
unsigned int get_sprite_id() const { return m_sprite_id; }
|
||||
|
|
|
@ -49,7 +49,7 @@ bool GLGizmoCut::on_init()
|
|||
|
||||
std::string GLGizmoCut::on_get_name() const
|
||||
{
|
||||
return (_L("Cut") + " [C]").ToUTF8().data();
|
||||
return _u8L("Cut");
|
||||
}
|
||||
|
||||
void GLGizmoCut::on_set_state()
|
||||
|
|
|
@ -28,7 +28,7 @@ void GLGizmoFdmSupports::on_shutdown()
|
|||
|
||||
std::string GLGizmoFdmSupports::on_get_name() const
|
||||
{
|
||||
return (_L("Paint-on supports") + " [L]").ToUTF8().data();
|
||||
return _u8L("Paint-on supports");
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,7 +85,7 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
y = std::min(y, bottom_limit - approx_height);
|
||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||
|
||||
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
m_imgui->begin(get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
// First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that:
|
||||
const float clipping_slider_left = std::max(m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x,
|
||||
|
|
|
@ -37,7 +37,7 @@ CommonGizmosDataID GLGizmoFlatten::on_get_requirements() const
|
|||
|
||||
std::string GLGizmoFlatten::on_get_name() const
|
||||
{
|
||||
return (_L("Place on face") + " [F]").ToUTF8().data();
|
||||
return _u8L("Place on face");
|
||||
}
|
||||
|
||||
bool GLGizmoFlatten::on_is_activable() const
|
||||
|
|
|
@ -505,7 +505,7 @@ RENDER_AGAIN:
|
|||
y = std::min(y, bottom_limit - approx_height);
|
||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||
|
||||
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
m_imgui->begin(get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
// First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that:
|
||||
const float settings_sliders_left =
|
||||
|
@ -773,7 +773,7 @@ bool GLGizmoHollow::on_is_selectable() const
|
|||
|
||||
std::string GLGizmoHollow::on_get_name() const
|
||||
{
|
||||
return (_(L("Hollow and drill")) + " [H]").ToUTF8().data();
|
||||
return _u8L("Hollow and drill");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ void GLGizmoMmuSegmentation::on_shutdown()
|
|||
std::string GLGizmoMmuSegmentation::on_get_name() const
|
||||
{
|
||||
// FIXME Lukas H.: Discuss and change shortcut
|
||||
return (_L("Multimaterial painting") + " [N]").ToUTF8().data();
|
||||
return _u8L("Multimaterial painting");
|
||||
}
|
||||
|
||||
bool GLGizmoMmuSegmentation::on_is_selectable() const
|
||||
|
@ -239,7 +239,7 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
y = std::min(y, bottom_limit - approx_height);
|
||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||
|
||||
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
m_imgui->begin(get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
// First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that:
|
||||
const float clipping_slider_left = std::max(m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x,
|
||||
|
|
|
@ -52,7 +52,7 @@ bool GLGizmoMove3D::on_init()
|
|||
|
||||
std::string GLGizmoMove3D::on_get_name() const
|
||||
{
|
||||
return (_L("Move") + " [M]").ToUTF8().data();
|
||||
return _u8L("Move");
|
||||
}
|
||||
|
||||
bool GLGizmoMove3D::on_is_activable() const
|
||||
|
|
|
@ -463,7 +463,7 @@ bool GLGizmoRotate3D::on_init()
|
|||
|
||||
std::string GLGizmoRotate3D::on_get_name() const
|
||||
{
|
||||
return (_L("Rotate") + " [R]").ToUTF8().data();
|
||||
return _u8L("Rotate");
|
||||
}
|
||||
|
||||
bool GLGizmoRotate3D::on_is_activable() const
|
||||
|
|
|
@ -76,7 +76,7 @@ bool GLGizmoScale3D::on_init()
|
|||
|
||||
std::string GLGizmoScale3D::on_get_name() const
|
||||
{
|
||||
return (_L("Scale") + " [S]").ToUTF8().data();
|
||||
return _u8L("Scale");
|
||||
}
|
||||
|
||||
bool GLGizmoScale3D::on_is_activable() const
|
||||
|
|
|
@ -48,7 +48,7 @@ bool GLGizmoSeam::on_init()
|
|||
|
||||
std::string GLGizmoSeam::on_get_name() const
|
||||
{
|
||||
return (_L("Seam painting") + " [P]").ToUTF8().data();
|
||||
return _u8L("Seam painting");
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
|
|||
const float approx_height = m_imgui->scaled(14.0f);
|
||||
y = std::min(y, bottom_limit - approx_height);
|
||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
m_imgui->begin(get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
// First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that:
|
||||
const float clipping_slider_left = std::max(m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x,
|
||||
|
|
|
@ -44,7 +44,7 @@ bool GLGizmoSimplify::on_init()
|
|||
|
||||
std::string GLGizmoSimplify::on_get_name() const
|
||||
{
|
||||
return (_L("Simplify")).ToUTF8().data();
|
||||
return _u8L("Simplify");
|
||||
}
|
||||
|
||||
void GLGizmoSimplify::on_render() {}
|
||||
|
@ -97,7 +97,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||
|
||||
int flag = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoCollapse;
|
||||
m_imgui->begin(on_get_name(), flag);
|
||||
m_imgui->begin(get_name(), flag);
|
||||
|
||||
size_t triangle_count = m_volume->mesh().its.indices.size();
|
||||
// already reduced mesh
|
||||
|
|
|
@ -625,7 +625,7 @@ RENDER_AGAIN:
|
|||
//ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) ));
|
||||
//ImGui::SetNextWindowSize(ImVec2(window_size));
|
||||
|
||||
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
m_imgui->begin(get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
// adjust window position to avoid overlap the view toolbar
|
||||
float win_h = ImGui::GetWindowHeight();
|
||||
|
@ -863,7 +863,7 @@ bool GLGizmoSlaSupports::on_is_selectable() const
|
|||
|
||||
std::string GLGizmoSlaSupports::on_get_name() const
|
||||
{
|
||||
return (_L("SLA Support Points") + " [L]").ToUTF8().data();
|
||||
return _u8L("SLA Support Points");
|
||||
}
|
||||
|
||||
CommonGizmosDataID GLGizmoSlaSupports::on_get_requirements() const
|
||||
|
@ -901,15 +901,6 @@ void GLGizmoSlaSupports::on_set_state()
|
|||
return;
|
||||
|
||||
if (m_state == On && m_old_state != On) { // the gizmo was just turned on
|
||||
if (! m_parent.get_gizmos_manager().is_serializing()) {
|
||||
// Only take the snapshot when the USER opens the gizmo. Common gizmos
|
||||
// data are not yet available, the CallAfter will postpone taking the
|
||||
// snapshot until they are. No, it does not feel right.
|
||||
wxGetApp().CallAfter([]() {
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Entering SLA gizmo"));
|
||||
});
|
||||
}
|
||||
|
||||
// Set default head diameter from config.
|
||||
const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
|
||||
m_new_point_head_diameter = static_cast<const ConfigOptionFloat*>(cfg.option("support_head_front_diameter"))->value;
|
||||
|
@ -925,8 +916,6 @@ void GLGizmoSlaSupports::on_set_state()
|
|||
else {
|
||||
// we are actually shutting down
|
||||
disable_editing_mode(); // so it is not active next time the gizmo opens
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Leaving SLA gizmo"));
|
||||
m_normal_cache.clear();
|
||||
m_old_mo_id = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ public:
|
|||
bool has_backend_supports() const;
|
||||
void reslice_SLA_supports(bool postpone_error_messages = false) const;
|
||||
|
||||
bool wants_enter_leave_snapshots() const override { return true; }
|
||||
|
||||
private:
|
||||
bool on_init() override;
|
||||
void on_update(const UpdateData& data) override;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp"
|
||||
#include "slic3r/GUI/Gizmos/GLGizmoSimplify.hpp"
|
||||
|
||||
#include "libslic3r/format.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
|
@ -163,10 +164,8 @@ void GLGizmosManager::refresh_on_off_state()
|
|||
return;
|
||||
|
||||
if (m_current != Undefined
|
||||
&& ! m_gizmos[m_current]->is_activable()) {
|
||||
activate_gizmo(Undefined);
|
||||
&& ! m_gizmos[m_current]->is_activable() && activate_gizmo(Undefined))
|
||||
update_data();
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmosManager::reset_all_states()
|
||||
|
@ -181,14 +180,28 @@ void GLGizmosManager::reset_all_states()
|
|||
bool GLGizmosManager::open_gizmo(EType type)
|
||||
{
|
||||
int idx = int(type);
|
||||
if (m_gizmos[idx]->is_activable()) {
|
||||
activate_gizmo(m_current == idx ? Undefined : (EType)idx);
|
||||
if (m_gizmos[idx]->is_activable()
|
||||
&& activate_gizmo(m_current == idx ? Undefined : (EType)idx)) {
|
||||
update_data();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool GLGizmosManager::check_gizmos_closed_except(EType type) const
|
||||
{
|
||||
if (get_current_type() != type && get_current_type() != Undefined) {
|
||||
wxGetApp().plater()->get_notification_manager()->push_notification(
|
||||
NotificationType::CustomSupportsAndSeamRemovedAfterRepair,
|
||||
NotificationManager::NotificationLevel::RegularNotification,
|
||||
_u8L("ERROR: Please close all manipulators available from "
|
||||
"the left toolbar first"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLGizmosManager::set_hover_id(int id)
|
||||
{
|
||||
if (!m_enabled || m_current == Undefined)
|
||||
|
@ -1193,31 +1206,35 @@ std::string GLGizmosManager::update_hover_state(const Vec2d& mouse_pos)
|
|||
return name;
|
||||
}
|
||||
|
||||
void GLGizmosManager::activate_gizmo(EType type)
|
||||
bool GLGizmosManager::activate_gizmo(EType type)
|
||||
{
|
||||
if (m_gizmos.empty() || m_current == type)
|
||||
return;
|
||||
return true;
|
||||
|
||||
if (m_current != Undefined) {
|
||||
m_gizmos[m_current]->set_state(GLGizmoBase::Off);
|
||||
if (m_gizmos[m_current]->get_state() != GLGizmoBase::Off)
|
||||
return; // gizmo refused to be turned off, do nothing.
|
||||
GLGizmoBase* old_gizmo = m_current == Undefined ? nullptr : m_gizmos[m_current].get();
|
||||
GLGizmoBase* new_gizmo = type == Undefined ? nullptr : m_gizmos[type].get();
|
||||
|
||||
if (old_gizmo) {
|
||||
old_gizmo->set_state(GLGizmoBase::Off);
|
||||
if (old_gizmo->get_state() != GLGizmoBase::Off)
|
||||
return false; // gizmo refused to be turned off, do nothing.
|
||||
|
||||
if (! m_parent.get_gizmos_manager().is_serializing()
|
||||
&& old_gizmo->wants_enter_leave_snapshots())
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(),
|
||||
Slic3r::format(_utf8("Leaving %1%"), old_gizmo->get_name(false)));
|
||||
}
|
||||
|
||||
if (new_gizmo && ! m_parent.get_gizmos_manager().is_serializing()
|
||||
&& new_gizmo->wants_enter_leave_snapshots())
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(),
|
||||
Slic3r::format(_utf8("Entering %1%"), new_gizmo->get_name(false)));
|
||||
|
||||
m_current = type;
|
||||
|
||||
// Updating common data should be left to the update_data function, which
|
||||
// is always called after this one. activate_gizmo can be called by undo/redo,
|
||||
// when selection is not yet deserialized, so the common data would update
|
||||
// incorrectly (or crash if relying on unempty selection). Undo/redo stack
|
||||
// will also call update_data, after selection is restored.
|
||||
|
||||
//m_common_gizmos_data->update(get_current()
|
||||
// ? get_current()->get_requirements()
|
||||
// : CommonGizmosDataID(0));
|
||||
|
||||
if (type != Undefined)
|
||||
m_gizmos[type]->set_state(GLGizmoBase::On);
|
||||
if (new_gizmo)
|
||||
new_gizmo->set_state(GLGizmoBase::On);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ private:
|
|||
std::vector<size_t> get_selectable_idxs() const;
|
||||
size_t get_gizmo_idx_from_mouse(const Vec2d& mouse_pos) const;
|
||||
|
||||
void activate_gizmo(EType type);
|
||||
bool activate_gizmo(EType type);
|
||||
|
||||
struct MouseCapture
|
||||
{
|
||||
|
@ -176,6 +176,7 @@ public:
|
|||
void reset_all_states();
|
||||
bool is_serializing() const { return m_serializing; }
|
||||
bool open_gizmo(EType type);
|
||||
bool check_gizmos_closed_except(EType) const;
|
||||
|
||||
void set_hover_id(int id);
|
||||
void enable_grabber(EType type, unsigned int id, bool enable);
|
||||
|
|
|
@ -74,7 +74,12 @@ void write_used_binary(const std::vector<std::string>& ids)
|
|||
}
|
||||
void read_used_binary(std::vector<std::string>& ids)
|
||||
{
|
||||
boost::filesystem::ifstream file((boost::filesystem::path(data_dir()) / "cache" / "hints.cereal"));
|
||||
boost::filesystem::path path(boost::filesystem::path(data_dir()) / "cache" / "hints.cereal");
|
||||
if (!boost::filesystem::exists(path)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Failed to load to hints.cereal. File does not exists. " << path.string();
|
||||
return;
|
||||
}
|
||||
boost::filesystem::ifstream file(path);
|
||||
cereal::BinaryInputArchive archive(file);
|
||||
HintsCerealData cd;
|
||||
try
|
||||
|
|
|
@ -142,11 +142,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("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer");
|
||||
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer-mac_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer");
|
||||
break;
|
||||
case GUI_App::EAppMode::GCodeViewer:
|
||||
m_taskbar_icon = std::make_unique<GCodeViewerTaskBarIcon>(wxTBI_DOCK);
|
||||
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer-gcodeviewer_128px.png"), wxBITMAP_TYPE_PNG), "G-code Viewer");
|
||||
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer-gcodeviewer-mac_128px.png"), wxBITMAP_TYPE_PNG), "G-code Viewer");
|
||||
break;
|
||||
}
|
||||
#endif // __APPLE__
|
||||
|
|
|
@ -1361,7 +1361,8 @@ wxDataViewItem ObjectDataViewModel::ReorganizeChildren( const int current_volume
|
|||
if (!node_parent) // happens if item.IsOk()==false
|
||||
return ret_item;
|
||||
|
||||
const size_t shift = node_parent->GetChildren().Item(0)->m_type == itSettings ? 1 : 0;
|
||||
size_t shift;
|
||||
for (shift = 0; shift < node_parent->GetChildCount() && node_parent->GetNthChild(shift)->GetType() != itVolume; shift ++);
|
||||
|
||||
ObjectDataViewModelNode *deleted_node = node_parent->GetNthChild(current_volume_id+shift);
|
||||
node_parent->GetChildren().Remove(deleted_node);
|
||||
|
|
|
@ -3186,6 +3186,9 @@ void Plater::priv::update_sla_scene()
|
|||
|
||||
void Plater::priv::replace_with_stl()
|
||||
{
|
||||
if (! q->canvas3D()->get_gizmos_manager().check_gizmos_closed_except(GLGizmosManager::EType::Undefined))
|
||||
return;
|
||||
|
||||
const Selection& selection = get_selection();
|
||||
|
||||
if (selection.is_wipe_tower() || get_selection().get_volume_idxs().size() != 1)
|
||||
|
@ -3530,14 +3533,8 @@ void Plater::priv::fix_through_netfabb(const int obj_idx, const int vol_idx/* =
|
|||
|
||||
// Do not fix anything when a gizmo is open. There might be issues with updates
|
||||
// and what is worse, the snapshot time would refer to the internal stack.
|
||||
if (q->canvas3D()->get_gizmos_manager().get_current_type() != GLGizmosManager::Undefined) {
|
||||
notification_manager->push_notification(
|
||||
NotificationType::CustomSupportsAndSeamRemovedAfterRepair,
|
||||
NotificationManager::NotificationLevel::RegularNotification,
|
||||
_u8L("ERROR: Please close all manipulators available from "
|
||||
"the left toolbar before fixing the mesh."));
|
||||
if (! q->canvas3D()->get_gizmos_manager().check_gizmos_closed_except(GLGizmosManager::Undefined))
|
||||
return;
|
||||
}
|
||||
|
||||
// size_t snapshot_time = undo_redo_stack().active_snapshot_time();
|
||||
Plater::TakeSnapshot snapshot(q, _L("Fix through NetFabb"));
|
||||
|
@ -6146,16 +6143,6 @@ BoundingBoxf Plater::bed_shape_bb() const
|
|||
return p->bed_shape_bb();
|
||||
}
|
||||
|
||||
void Plater::start_mapping_gcode_window()
|
||||
{
|
||||
p->preview->get_canvas3d()->start_mapping_gcode_window();
|
||||
}
|
||||
|
||||
void Plater::stop_mapping_gcode_window()
|
||||
{
|
||||
p->preview->get_canvas3d()->stop_mapping_gcode_window();
|
||||
}
|
||||
|
||||
void Plater::arrange()
|
||||
{
|
||||
p->m_ui_jobs.arrange();
|
||||
|
|
|
@ -282,9 +282,6 @@ public:
|
|||
GLCanvas3D* get_current_canvas3D();
|
||||
BoundingBoxf bed_shape_bb() const;
|
||||
|
||||
void start_mapping_gcode_window();
|
||||
void stop_mapping_gcode_window();
|
||||
|
||||
void arrange();
|
||||
void find_new_position(const ModelInstancePtrs &instances);
|
||||
|
||||
|
|
|
@ -696,7 +696,12 @@ void DiffViewCtrl::context_menu(wxDataViewEvent& event)
|
|||
auto it = m_items_map.find(item);
|
||||
if (it == m_items_map.end() || !it->second.is_long)
|
||||
return;
|
||||
FullCompareDialog(it->second.opt_name, it->second.old_val, it->second.new_val).ShowModal();
|
||||
|
||||
size_t column_cnt = this->GetColumnCount();
|
||||
const wxString old_value_header = this->GetColumn(column_cnt - 2)->GetTitle();
|
||||
const wxString new_value_header = this->GetColumn(column_cnt - 1)->GetTitle();
|
||||
FullCompareDialog(it->second.opt_name, it->second.old_val, it->second.new_val,
|
||||
old_value_header, new_value_header).ShowModal();
|
||||
|
||||
#ifdef __WXOSX__
|
||||
wxWindow* parent = this->GetParent();
|
||||
|
@ -1281,7 +1286,8 @@ void UnsavedChangesDialog::on_sys_color_changed()
|
|||
// FullCompareDialog
|
||||
//------------------------------------------
|
||||
|
||||
FullCompareDialog::FullCompareDialog(const wxString& option_name, const wxString& old_value, const wxString& new_value)
|
||||
FullCompareDialog::FullCompareDialog(const wxString& option_name, const wxString& old_value, const wxString& new_value,
|
||||
const wxString& old_value_header, const wxString& new_value_header)
|
||||
: wxDialog(nullptr, wxID_ANY, option_name, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
|
@ -1302,8 +1308,8 @@ FullCompareDialog::FullCompareDialog(const wxString& option_name, const wxString
|
|||
grid_sizer->Add(text, 0, wxALL, border);
|
||||
};
|
||||
|
||||
add_header(_L("Old value"));
|
||||
add_header(_L("New value"));
|
||||
add_header(old_value_header);
|
||||
add_header(new_value_header);
|
||||
|
||||
auto get_set_from_val = [](wxString str) {
|
||||
if (str.Find("\n") == wxNOT_FOUND)
|
||||
|
@ -1327,7 +1333,7 @@ FullCompareDialog::FullCompareDialog(const wxString& option_name, const wxString
|
|||
std::set_difference(new_set.begin(), new_set.end(), old_set.begin(), old_set.end(), std::inserter(new_old_diff_set, new_old_diff_set.begin()));
|
||||
|
||||
auto add_value = [grid_sizer, border, this](wxString label, const std::set<wxString>& diff_set, bool is_colored = false) {
|
||||
wxTextCtrl* text = new wxTextCtrl(this, wxID_ANY, label, wxDefaultPosition, wxSize(400, 400), wxTE_MULTILINE | wxTE_READONLY | wxBORDER_SIMPLE | wxTE_RICH);
|
||||
wxTextCtrl* text = new wxTextCtrl(this, wxID_ANY, label, wxDefaultPosition, wxSize(400, 400), wxTE_MULTILINE | wxTE_READONLY | wxBORDER_DEFAULT | wxTE_RICH);
|
||||
wxGetApp().UpdateDarkUI(text);
|
||||
text->SetStyle(0, label.Len(), wxTextAttr(is_colored ? wxColour(orange) : wxNullColour, wxNullColour, this->GetFont()));
|
||||
|
||||
|
|
|
@ -299,7 +299,8 @@ protected:
|
|||
class FullCompareDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
FullCompareDialog(const wxString& option_name, const wxString& old_value, const wxString& new_value);
|
||||
FullCompareDialog(const wxString& option_name, const wxString& old_value, const wxString& new_value,
|
||||
const wxString& old_value_header, const wxString& new_value_header);
|
||||
~FullCompareDialog() {}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue