Merge branch 'main' into feature/OrcaFilamentLibrary

This commit is contained in:
SoftFever
2025-01-22 21:42:13 +08:00
committed by GitHub
75 changed files with 6670 additions and 6405 deletions

View File

@@ -1064,16 +1064,7 @@ void SpinCtrl::BUILD() {
break;
}
const int min_val = m_opt.min == INT_MIN
#ifdef __WXOSX__
// We will forcibly set the input value for SpinControl, since the value
// inserted from the keyboard is not updated under OSX.
// So, we can't set min control value bigger then 0.
// Otherwise, it couldn't be possible to input from keyboard value
// less then min_val.
|| m_opt.min > 0
#endif
? 0 : m_opt.min;
const int min_val = m_opt.min == INT_MIN ? 0 : m_opt.min;
const int max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647;
static Builder<SpinInput> builder;
@@ -1170,14 +1161,6 @@ void SpinCtrl::propagate_value()
if (!m_value.empty()) // BBS: null value
on_kill_focus();
} else {
#ifdef __WXOSX__
// check input value for minimum
if (m_opt.min > 0 && tmp_value < m_opt.min) {
SpinInput* spin = static_cast<SpinInput*>(window);
spin->SetValue(m_opt.min);
// spin->GetText()->SetInsertionPointEnd(); // BBS
}
#endif
auto ctrl = dynamic_cast<SpinInput *>(window);
if (m_value.empty()
? !ctrl->GetTextCtrl()->GetLabel().IsEmpty()

View File

@@ -6767,7 +6767,7 @@ void GLCanvas3D::_picking_pass()
case SceneRaycaster::EType::Bed:
{
// BBS: add plate picking logic
int plate_hover_id = PartPlate::PLATE_BASE_ID - hit.raycaster_id;
int plate_hover_id = hit.raycaster_id;
if (plate_hover_id >= 0 && plate_hover_id < PartPlateList::MAX_PLATES_COUNT * PartPlate::GRABBER_COUNT) {
wxGetApp().plater()->get_partplate_list().set_hover_id(plate_hover_id);
m_hover_plate_idxs.emplace_back(plate_hover_id);

View File

@@ -3598,7 +3598,7 @@ GuiCfg create_gui_configuration()
float space = line_height_with_spacing - line_height;
const ImGuiStyle &style = ImGui::GetStyle();
cfg.max_style_name_width = ImGui::CalcTextSize("Maximal font name, extended").x;
cfg.max_style_name_width = ImGui::CalcTextSize("Maximal style name..").x;
cfg.icon_width = static_cast<unsigned int>(std::ceil(line_height));
// make size pair number
@@ -3692,11 +3692,11 @@ GuiCfg create_gui_configuration()
// "Text is to object" + radio buttons
cfg.height_of_volume_type_selector = separator_height + line_height_with_spacing + input_height;
int max_style_image_width = static_cast<int>(std::round(cfg.max_style_name_width/2 - 2 * style.FramePadding.x));
int max_style_image_width = static_cast<int>(std::round(cfg.max_style_name_width - 2 * style.FramePadding.x));
int max_style_image_height = static_cast<int>(std::round(input_height));
cfg.max_style_image_size = Vec2i32(max_style_image_width, line_height);
cfg.face_name_size = Vec2i32(cfg.input_width, line_height_with_spacing);
cfg.face_name_texture_offset_x = cfg.face_name_size.x() + space;
cfg.face_name_texture_offset_x = cfg.face_name_size.x() + style.WindowPadding.x + space;
cfg.max_tooltip_width = ImGui::GetFontSize() * 20.0f;

View File

@@ -375,6 +375,9 @@ void GLGizmosManager::update_data()
: CommonGizmosDataID(0));
if (m_current != Undefined) m_gizmos[m_current]->data_changed(m_serializing);
// Orca: hack: Fix issue that flatten gizmo faces not updated after reload from disk
if (m_current != Flatten && !m_gizmos.empty()) m_gizmos[Flatten]->data_changed(m_serializing);
//BBS: GUI refactor: add object manipulation in gizmo
m_object_manipulation.update_ui_from_settings();
m_object_manipulation.UpdateAndShow(true);

View File

@@ -775,7 +775,6 @@ arrangement::ArrangeParams init_arrange_params(Plater *p)
params.printable_height = print_config.printable_height.value;
params.allow_rotations = settings.enable_rotation;
params.nozzle_height = print_config.nozzle_height.value;
params.all_objects_are_short = print.is_all_objects_are_short();
params.align_center = print_config.best_object_pos.value;
params.allow_multi_materials_on_same_plate = settings.allow_multi_materials_on_same_plate;
params.avoid_extrusion_cali_region = settings.avoid_extrusion_cali_region;

View File

@@ -142,8 +142,9 @@ void CreateFontImageJob::finalize(bool canceled, std::exception_ptr &)
glsafe(::glBindTexture(target, m_input.texture_id));
GLsizei w = m_tex_size.x(), h = m_tex_size.y();
GLint xoffset = m_input.size.x() - m_tex_size.x(), // arrange right
yoffset = m_input.size.y() * m_input.index;
GLint xoffset = 0; // align to left
// GLint xoffset = m_input.size.x() - m_tex_size.x(); // align right
GLint yoffset = m_input.size.y() * m_input.index;
glsafe(::glTexSubImage2D(target, m_input.level, xoffset, yoffset, w, h,
m_input.format, m_input.type, m_result.data()));

View File

@@ -42,12 +42,12 @@ void CreateFontStyleImagesJob::process(Ctl &ctl)
// create image description
StyleManager::StyleImage &image = m_images[index];
BoundingBox &bounding_box = image.bounding_box;
for (ExPolygon &shape : shapes)
for (const ExPolygon &shape : shapes)
bounding_box.merge(BoundingBox(shape.contour.points));
for (ExPolygon &shape : shapes) shape.translate(-bounding_box.min);
// calculate conversion from FontPoint to screen pixels by size of font
double scale = get_text_shape_scale(item.prop, *item.font.font_file);
double scale = get_text_shape_scale(item.prop, *item.font.font_file) * m_input.ppm;
scales[index] = scale;
//double scale = font_prop.size_in_mm * SCALING_FACTOR;

View File

@@ -56,7 +56,6 @@ void FillBedJob::prepare()
ArrangePolygon ap = get_instance_arrange_poly(mo->instances[inst_idx], global_config);
BoundingBox ap_bb = ap.transformed_poly().contour.bounding_box();
ap.height = 1;
ap.name = mo->name;
if (selected)
@@ -173,7 +172,6 @@ void FillBedJob::prepare()
ArrangePolygon ap = template_ap;
ap.poly = m_selected.front().poly;
ap.bed_idx = PartPlateList::MAX_PLATES_COUNT;
ap.height = 1;
ap.itemid = -1;
ap.setter = [this, mi](const ArrangePolygon &p) {
ModelObject *mo = m_plater->model().objects[m_object_idx];

View File

@@ -66,6 +66,7 @@
#ifdef _WIN32
#include <dbt.h>
#include <shlobj.h>
#include <shellapi.h>
#endif // _WIN32
#include <slic3r/GUI/CreatePresetsDialog.hpp>
@@ -634,8 +635,64 @@ void MainFrame::bind_diff_dialog()
#ifdef __WIN32__
// Orca: Fix maximized window overlaps taskbar when taskbar auto hide is enabled (#8085)
// Adopted from https://gist.github.com/MortenChristiansen/6463580
static void AdjustWorkingAreaForAutoHide(const HWND hWnd, MINMAXINFO* mmi)
{
const auto taskbarHwnd = FindWindowA("Shell_TrayWnd", nullptr);
if (!taskbarHwnd) {
return;
}
const auto monitorContainingApplication = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
const auto monitorWithTaskbarOnIt = MonitorFromWindow(taskbarHwnd, MONITOR_DEFAULTTONULL);
if (monitorContainingApplication != monitorWithTaskbarOnIt) {
return;
}
APPBARDATA abd;
abd.cbSize = sizeof(APPBARDATA);
abd.hWnd = taskbarHwnd;
// Find if task bar has auto-hide enabled
const auto uState = (UINT) SHAppBarMessage(ABM_GETSTATE, &abd);
if ((uState & ABS_AUTOHIDE) != ABS_AUTOHIDE) {
return;
}
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION, FALSE, 0);
// Determine taskbar position
SHAppBarMessage(ABM_GETTASKBARPOS, &abd);
const auto& rc = abd.rc;
if (rc.top == rc.left && rc.bottom > rc.right) {
// Left
const auto offset = borderThickness.left + 2;
mmi->ptMaxPosition.x += offset;
mmi->ptMaxTrackSize.x -= offset;
mmi->ptMaxSize.x -= offset;
} else if (rc.top == rc.left && rc.bottom < rc.right) {
// Top
const auto offset = borderThickness.top + 2;
mmi->ptMaxPosition.y += offset;
mmi->ptMaxTrackSize.y -= offset;
mmi->ptMaxSize.y -= offset;
} else if (rc.top > rc.left) {
// Bottom
const auto offset = borderThickness.bottom + 2;
mmi->ptMaxSize.y -= offset;
mmi->ptMaxTrackSize.y -= offset;
} else {
// Right
const auto offset = borderThickness.right + 2;
mmi->ptMaxSize.x -= offset;
mmi->ptMaxTrackSize.x -= offset;
}
}
WXLRESULT MainFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
HWND hWnd = GetHandle();
/* When we have a custom titlebar in the window, we don't need the non-client area of a normal window
* to be painted. In order to achieve this, we handle the "WM_NCCALCSIZE" which is responsible for the
* size of non-client area of a window and set the return value to 0. Also we have to tell the
@@ -654,7 +711,6 @@ WXLRESULT MainFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam
its wParam value is TRUE and the return value is 0 */
case WM_NCCALCSIZE:
if (wParam) {
HWND hWnd = GetHandle();
/* Detect whether window is maximized or not. We don't need to change the resize border when win is
* maximized because all resize borders are gone automatically */
WINDOWPLACEMENT wPos;
@@ -677,6 +733,13 @@ WXLRESULT MainFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam
}
}
break;
case WM_GETMINMAXINFO: {
auto mmi = (MINMAXINFO*) lParam;
HandleGetMinMaxInfo(mmi);
AdjustWorkingAreaForAutoHide(hWnd, mmi);
return 0;
}
}
return wxFrame::MSWWindowProc(nMsg, wParam, lParam);
}

View File

@@ -1348,8 +1348,7 @@ void PartPlate::register_raycasters_for_picking(GLCanvas3D &canvas)
int PartPlate::picking_id_component(int idx) const
{
unsigned int id = PLATE_BASE_ID - this->m_plate_index * GRABBER_COUNT - idx;
return id;
return this->m_plate_index * GRABBER_COUNT + idx;
}
std::vector<int> PartPlate::get_extruders(bool conside_custom_gcode) const

View File

@@ -198,7 +198,6 @@ private:
int picking_id_component(int idx) const;
public:
static const unsigned int PLATE_BASE_ID = 255 * 255 * 253;
static const unsigned int PLATE_NAME_HOVER_ID = 6;
static const unsigned int GRABBER_COUNT = 8;

View File

@@ -4396,7 +4396,9 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
cur_plate->translate_all_instance(new_origin - cur_origin);
}
view3D->get_canvas3d()->remove_raycasters_for_picking(SceneRaycaster::EType::Bed);
partplate_list.reset_size(current_width, current_depth, current_height, true, true);
partplate_list.register_raycasters_for_picking(*view3D->get_canvas3d());
}
//BBS: add gcode loading logic in the end
@@ -5972,6 +5974,11 @@ void Plater::priv::reload_from_disk()
}
}
if (found) break;
// BBS: step model,object loaded as a volume. GUI_ObfectList.cpp load_modifier()
if (obj->name == old_volume->name) {
new_object_idx = (int) o;
break;
}
}
}
@@ -5980,22 +5987,30 @@ void Plater::priv::reload_from_disk()
continue;
}
ModelObject *new_model_object = new_model.objects[new_object_idx];
if (new_volume_idx < 0 || int(new_model_object->volumes.size()) <= new_volume_idx) {
if (int(new_model_object->volumes.size()) <= new_volume_idx) {
fail_list.push_back(from_u8(has_source ? old_volume->source.input_file : old_volume->name));
continue;
}
old_model_object->add_volume(*new_model_object->volumes[new_volume_idx]);
ModelVolume *new_volume = old_model_object->volumes.back();
ModelVolume *new_volume = nullptr;
// BBS: step model
if (new_volume_idx < 0 && new_object_idx >= 0) {
TriangleMesh mesh = new_model_object->mesh();
new_volume = old_model_object->add_volume(std::move(mesh));
new_volume->name = new_model_object->name;
new_volume->source.input_file = new_model_object->input_file;
}else {
new_volume = old_model_object->add_volume(*new_model_object->volumes[new_volume_idx]);
// new_volume = old_model_object->volumes.back();
}
new_volume->set_new_unique_id();
new_volume->config.apply(old_volume->config);
new_volume->set_type(old_volume->type());
new_volume->set_material_id(old_volume->material_id());
Transform3d transform = Transform3d::Identity();
transform.translate(new_volume->source.mesh_offset - old_volume->source.mesh_offset);
new_volume->set_transformation(old_volume->get_transformation().get_matrix() * old_volume->source.transform.get_matrix_no_offset() *
transform * new_volume->source.transform.get_matrix_no_offset().inverse());
new_volume->source.mesh_offset = old_volume->source.mesh_offset;
new_volume->set_transformation(old_volume->get_transformation());
new_volume->source.object_idx = old_volume->source.object_idx;
new_volume->source.volume_idx = old_volume->source.volume_idx;

View File

@@ -52,7 +52,7 @@ public:
enum class EIdBase
{
Bed = 0,
Volume = 1000,
Volume = 1000, // Must be smaller than PartPlateList::MAX_PLATES_COUNT * PartPlate::GRABBER_COUNT
Gizmo = 1000000,
FallbackGizmo = 2000000
};

View File

@@ -2636,14 +2636,14 @@ void TabPrintModel::update_model_config()
}
else {
replace(m_all_keys.begin(), m_all_keys.end(), std::string("first_layer_print_sequence"), std::string("first_layer_sequence_choice"));
m_config->set_key_value("first_layer_sequence_choice", new ConfigOptionEnum<LayerSeq>(flsCutomize));
m_config->set_key_value("first_layer_sequence_choice", new ConfigOptionEnum<LayerSeq>(flsCustomize));
}
if (!plate_config.has("other_layers_print_sequence")) {
m_config->set_key_value("other_layers_sequence_choice", new ConfigOptionEnum<LayerSeq>(flsAuto));
}
else {
replace(m_all_keys.begin(), m_all_keys.end(), std::string("other_layers_print_sequence"), std::string("other_layers_sequence_choice"));
m_config->set_key_value("other_layers_sequence_choice", new ConfigOptionEnum<LayerSeq>(flsCutomize));
m_config->set_key_value("other_layers_sequence_choice", new ConfigOptionEnum<LayerSeq>(flsCustomize));
}
notify_changed(plate_item.first);
}
@@ -2883,7 +2883,7 @@ void TabPrintPlate::on_value_change(const std::string& opt_key, const boost::any
if (first_layer_seq_choice == LayerSeq::flsAuto) {
plate->set_first_layer_print_sequence({});
}
else if (first_layer_seq_choice == LayerSeq::flsCutomize) {
else if (first_layer_seq_choice == LayerSeq::flsCustomize) {
const DynamicPrintConfig& plate_config = plate_item.second->get();
if (!plate_config.has("first_layer_print_sequence")) {
std::vector<int> initial_sequence;
@@ -2904,7 +2904,7 @@ void TabPrintPlate::on_value_change(const std::string& opt_key, const boost::any
if (other_layer_seq_choice == LayerSeq::flsAuto) {
plate->set_other_layers_print_sequence({});
}
else if (other_layer_seq_choice == LayerSeq::flsCutomize) {
else if (other_layer_seq_choice == LayerSeq::flsCustomize) {
const DynamicPrintConfig& plate_config = plate_item.second->get();
if (!plate_config.has("other_layers_print_sequence")) {
std::vector<int> initial_sequence;
@@ -5115,13 +5115,12 @@ bool Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
apply_config_from_cache();
// Orca: update presets for the selected printer
load_current_preset();
if (m_type == Preset::TYPE_PRINTER && wxGetApp().app_config->get_bool("remember_printer_config")) {
m_preset_bundle->update_selections(*wxGetApp().app_config);
wxGetApp().plater()->sidebar().on_filaments_change(m_preset_bundle->filament_presets.size());
}
load_current_preset();
if (delete_third_printer) {
wxGetApp().CallAfter([filament_presets, process_presets]() {