mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 09:05:59 +08:00
Merge branch 'master' into fs_emboss
# Conflicts: # src/libslic3r/Technologies.hpp # src/slic3r/GUI/GLCanvas3D.cpp
This commit is contained in:
commit
fce4f1f24e
@ -10,7 +10,6 @@ namespace Measure {
|
|||||||
|
|
||||||
|
|
||||||
constexpr double feature_hover_limit = 0.5; // how close to a feature the mouse must be to highlight it
|
constexpr double feature_hover_limit = 0.5; // how close to a feature the mouse must be to highlight it
|
||||||
constexpr double edge_endpoint_limit = 0.5; // how close to an edge endpoint the mouse ...
|
|
||||||
|
|
||||||
static std::pair<Vec3d, double> get_center_and_radius(const std::vector<Vec3d>& border, int start_idx, int end_idx, const Transform3d& trafo)
|
static std::pair<Vec3d, double> get_center_and_radius(const std::vector<Vec3d>& border, int start_idx, int end_idx, const Transform3d& trafo)
|
||||||
{
|
{
|
||||||
@ -467,6 +466,8 @@ std::optional<SurfaceFeature> MeasuringImpl::get_feature(size_t face_idx, const
|
|||||||
MeasurementResult res;
|
MeasurementResult res;
|
||||||
SurfaceFeature point_sf(point);
|
SurfaceFeature point_sf(point);
|
||||||
|
|
||||||
|
assert(plane.surface_features.empty() || plane.surface_features.back().get_type() == SurfaceFeatureType::Plane);
|
||||||
|
|
||||||
for (size_t i=0; i<plane.surface_features.size() - 1; ++i) {
|
for (size_t i=0; i<plane.surface_features.size() - 1; ++i) {
|
||||||
// The -1 is there to prevent measuring distance to the plane itself,
|
// The -1 is there to prevent measuring distance to the plane itself,
|
||||||
// which is needless and relatively expensive.
|
// which is needless and relatively expensive.
|
||||||
@ -484,9 +485,12 @@ std::optional<SurfaceFeature> MeasuringImpl::get_feature(size_t face_idx, const
|
|||||||
const SurfaceFeature& f = plane.surface_features[closest_feature_idx];
|
const SurfaceFeature& f = plane.surface_features[closest_feature_idx];
|
||||||
if (f.get_type() == SurfaceFeatureType::Edge) {
|
if (f.get_type() == SurfaceFeatureType::Edge) {
|
||||||
// If this is an edge, check if we are not close to the endpoint. If so,
|
// If this is an edge, check if we are not close to the endpoint. If so,
|
||||||
// we will include the endpoint as well.
|
// we will include the endpoint as well. Close = 10% of the lenghth of
|
||||||
constexpr double limit_sq = edge_endpoint_limit * edge_endpoint_limit;
|
// the edge, clamped between 0.025 and 0.5 mm.
|
||||||
const auto& [sp, ep] = f.get_edge();
|
const auto& [sp, ep] = f.get_edge();
|
||||||
|
double len_sq = (ep-sp).squaredNorm();
|
||||||
|
double limit_sq = std::max(0.025*0.025, std::min(0.5*0.5, 0.1 * 0.1 * len_sq));
|
||||||
|
|
||||||
if ((point-sp).squaredNorm() < limit_sq)
|
if ((point-sp).squaredNorm() < limit_sq)
|
||||||
return std::make_optional(SurfaceFeature(sp));
|
return std::make_optional(SurfaceFeature(sp));
|
||||||
if ((point-ep).squaredNorm() < limit_sq)
|
if ((point-ep).squaredNorm() < limit_sq)
|
||||||
|
@ -55,8 +55,6 @@
|
|||||||
#define ENABLE_RELOAD_FROM_DISK_REWORK (1 && ENABLE_2_5_0_ALPHA1)
|
#define ENABLE_RELOAD_FROM_DISK_REWORK (1 && ENABLE_2_5_0_ALPHA1)
|
||||||
// Enable editing volumes transformation in world coordinates and instances in local coordinates
|
// Enable editing volumes transformation in world coordinates and instances in local coordinates
|
||||||
#define ENABLE_WORLD_COORDINATE (1 && ENABLE_2_5_0_ALPHA1)
|
#define ENABLE_WORLD_COORDINATE (1 && ENABLE_2_5_0_ALPHA1)
|
||||||
// Enable modified camera control using mouse
|
|
||||||
#define ENABLE_NEW_CAMERA_MOVEMENTS (1 && ENABLE_2_5_0_ALPHA1)
|
|
||||||
// Enable alternative version of file_wildcards()
|
// Enable alternative version of file_wildcards()
|
||||||
#define ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR (1 && ENABLE_2_5_0_ALPHA1)
|
#define ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR (1 && ENABLE_2_5_0_ALPHA1)
|
||||||
// Enable processing of gcode G2 and G3 lines
|
// Enable processing of gcode G2 and G3 lines
|
||||||
|
@ -2997,7 +2997,6 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
|||||||
// set_cursor(Standard);
|
// set_cursor(Standard);
|
||||||
}
|
}
|
||||||
else if (keyCode == WXK_CONTROL) {
|
else if (keyCode == WXK_CONTROL) {
|
||||||
#if ENABLE_NEW_CAMERA_MOVEMENTS
|
|
||||||
#if ENABLE_RAYCAST_PICKING
|
#if ENABLE_RAYCAST_PICKING
|
||||||
if (m_mouse.dragging && !m_moving) {
|
if (m_mouse.dragging && !m_moving) {
|
||||||
#else
|
#else
|
||||||
@ -3008,7 +3007,6 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
|||||||
m_mouse.drag.move_volume_idx = -1;
|
m_mouse.drag.move_volume_idx = -1;
|
||||||
m_mouse.set_start_position_3D_as_invalid();
|
m_mouse.set_start_position_3D_as_invalid();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_NEW_CAMERA_MOVEMENTS
|
|
||||||
m_ctrl_kar_filter.reset_count();
|
m_ctrl_kar_filter.reset_count();
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
@ -3515,10 +3513,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
m_volumes.volumes[volume_idx]->hover = GLVolume::HS_None;
|
m_volumes.volumes[volume_idx]->hover = GLVolume::HS_None;
|
||||||
// The dragging operation is initiated.
|
// The dragging operation is initiated.
|
||||||
m_mouse.drag.move_volume_idx = volume_idx;
|
m_mouse.drag.move_volume_idx = volume_idx;
|
||||||
#if ENABLE_NEW_CAMERA_MOVEMENTS
|
|
||||||
m_selection.setup_cache();
|
m_selection.setup_cache();
|
||||||
if (!evt.CmdDown())
|
if (!evt.CmdDown())
|
||||||
#endif // ENABLE_NEW_CAMERA_MOVEMENTS
|
|
||||||
m_mouse.drag.start_position_3D = m_mouse.scene_position;
|
m_mouse.drag.start_position_3D = m_mouse.scene_position;
|
||||||
m_sequential_print_clearance_first_displacement = true;
|
m_sequential_print_clearance_first_displacement = true;
|
||||||
#if !ENABLE_RAYCAST_PICKING
|
#if !ENABLE_RAYCAST_PICKING
|
||||||
@ -3529,12 +3525,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_NEW_CAMERA_MOVEMENTS
|
|
||||||
else if (evt.Dragging() && evt.LeftIsDown() && !evt.CmdDown() && m_layers_editing.state == LayersEditing::Unknown &&
|
else if (evt.Dragging() && evt.LeftIsDown() && !evt.CmdDown() && m_layers_editing.state == LayersEditing::Unknown &&
|
||||||
m_mouse.drag.move_volume_idx != -1 && m_mouse.is_start_position_3D_defined()) {
|
m_mouse.drag.move_volume_idx != -1 && m_mouse.is_start_position_3D_defined()) {
|
||||||
#else
|
|
||||||
else if (evt.Dragging() && evt.LeftIsDown() && m_layers_editing.state == LayersEditing::Unknown && m_mouse.drag.move_volume_idx != -1) {
|
|
||||||
#endif // ENABLE_NEW_CAMERA_MOVEMENTS
|
|
||||||
if (!m_mouse.drag.move_requires_threshold) {
|
if (!m_mouse.drag.move_requires_threshold) {
|
||||||
m_mouse.dragging = true;
|
m_mouse.dragging = true;
|
||||||
Vec3d cur_pos = m_mouse.drag.start_position_3D;
|
Vec3d cur_pos = m_mouse.drag.start_position_3D;
|
||||||
@ -3602,18 +3594,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do not process the dragging if the left mouse was set down in another canvas
|
// do not process the dragging if the left mouse was set down in another canvas
|
||||||
#if ENABLE_NEW_CAMERA_MOVEMENTS
|
|
||||||
else if (evt.LeftIsDown()) {
|
else if (evt.LeftIsDown()) {
|
||||||
// if dragging over blank area with left button, rotate
|
// if dragging over blank area with left button, rotate
|
||||||
#if ENABLE_RAYCAST_PICKING
|
#if ENABLE_RAYCAST_PICKING
|
||||||
if (!m_moving) {
|
if (!m_moving) {
|
||||||
#endif // ENABLE_RAYCAST_PICKING
|
#endif // ENABLE_RAYCAST_PICKING
|
||||||
if ((any_gizmo_active || evt.CmdDown() || m_hover_volume_idxs.empty()) && m_mouse.is_start_position_3D_defined()) {
|
if ((any_gizmo_active || evt.CmdDown() || m_hover_volume_idxs.empty()) && m_mouse.is_start_position_3D_defined()) {
|
||||||
#else
|
|
||||||
// if dragging over blank area with left button, rotate
|
|
||||||
else if (evt.LeftIsDown()) {
|
|
||||||
if ((any_gizmo_active || m_hover_volume_idxs.empty()) && m_mouse.is_start_position_3D_defined()) {
|
|
||||||
#endif // ENABLE_NEW_CAMERA_MOVEMENTS
|
|
||||||
const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.0) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.0);
|
const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.0) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.0);
|
||||||
if (wxGetApp().app_config->get("use_free_camera") == "1")
|
if (wxGetApp().app_config->get("use_free_camera") == "1")
|
||||||
// Virtual track ball (similar to the 3DConnexion mouse).
|
// Virtual track ball (similar to the 3DConnexion mouse).
|
||||||
@ -6745,6 +6731,10 @@ void GLCanvas3D::_render_selection_sidebar_hints()
|
|||||||
|
|
||||||
void GLCanvas3D::_update_volumes_hover_state()
|
void GLCanvas3D::_update_volumes_hover_state()
|
||||||
{
|
{
|
||||||
|
// skip update if the Gizmo Measure is active
|
||||||
|
if (m_gizmos.get_current_type() == GLGizmosManager::Measure)
|
||||||
|
return;
|
||||||
|
|
||||||
for (GLVolume* v : m_volumes.volumes) {
|
for (GLVolume* v : m_volumes.volumes) {
|
||||||
v->hover = GLVolume::HS_None;
|
v->hover = GLVolume::HS_None;
|
||||||
}
|
}
|
||||||
@ -6752,9 +6742,9 @@ void GLCanvas3D::_update_volumes_hover_state()
|
|||||||
if (m_hover_volume_idxs.empty())
|
if (m_hover_volume_idxs.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool ctrl_pressed = wxGetKeyState(WXK_CONTROL); // additive select/deselect
|
const bool ctrl_pressed = wxGetKeyState(WXK_CONTROL);
|
||||||
bool shift_pressed = wxGetKeyState(WXK_SHIFT); // select by rectangle
|
const bool shift_pressed = wxGetKeyState(WXK_SHIFT);
|
||||||
bool alt_pressed = wxGetKeyState(WXK_ALT); // deselect by rectangle
|
const bool alt_pressed = wxGetKeyState(WXK_ALT);
|
||||||
|
|
||||||
if (alt_pressed && (shift_pressed || ctrl_pressed)) {
|
if (alt_pressed && (shift_pressed || ctrl_pressed)) {
|
||||||
// illegal combinations of keys
|
// illegal combinations of keys
|
||||||
@ -6789,22 +6779,22 @@ void GLCanvas3D::_update_volumes_hover_state()
|
|||||||
if (volume.hover != GLVolume::HS_None)
|
if (volume.hover != GLVolume::HS_None)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool deselect = volume.selected && ((shift_pressed && m_rectangle_selection.is_empty()) || (alt_pressed && !m_rectangle_selection.is_empty()));
|
const bool deselect = volume.selected && ((shift_pressed && m_rectangle_selection.is_empty()) || (alt_pressed && !m_rectangle_selection.is_empty()));
|
||||||
bool select = !volume.selected && (m_rectangle_selection.is_empty() || (shift_pressed && !m_rectangle_selection.is_empty()));
|
const bool select = !volume.selected && (m_rectangle_selection.is_empty() || (shift_pressed && !m_rectangle_selection.is_empty()));
|
||||||
|
|
||||||
if (select || deselect) {
|
if (select || deselect) {
|
||||||
bool as_volume =
|
const bool as_volume =
|
||||||
volume.is_modifier && hover_from_single_instance && !ctrl_pressed &&
|
volume.is_modifier && hover_from_single_instance && !ctrl_pressed &&
|
||||||
(
|
(
|
||||||
(!deselect) ||
|
!deselect ||
|
||||||
(deselect && !m_selection.is_single_full_instance() && (volume.object_idx() == m_selection.get_object_idx()) && (volume.instance_idx() == m_selection.get_instance_idx()))
|
(deselect && !m_selection.is_single_full_instance() && volume.object_idx() == m_selection.get_object_idx() && volume.instance_idx() == m_selection.get_instance_idx())
|
||||||
);
|
);
|
||||||
|
|
||||||
if (as_volume)
|
if (as_volume)
|
||||||
volume.hover = deselect ? GLVolume::HS_Deselect : GLVolume::HS_Select;
|
volume.hover = deselect ? GLVolume::HS_Deselect : GLVolume::HS_Select;
|
||||||
else {
|
else {
|
||||||
int object_idx = volume.object_idx();
|
const int object_idx = volume.object_idx();
|
||||||
int instance_idx = volume.instance_idx();
|
const int instance_idx = volume.instance_idx();
|
||||||
|
|
||||||
for (GLVolume* v : m_volumes.volumes) {
|
for (GLVolume* v : m_volumes.volumes) {
|
||||||
if (v->object_idx() == object_idx && v->instance_idx() == instance_idx)
|
if (v->object_idx() == object_idx && v->instance_idx() == instance_idx)
|
||||||
|
@ -310,6 +310,10 @@ bool GLGizmoMeasure::on_mouse(const wxMouseEvent &mouse_event)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
// if the mouse pointer is on any volume, filter out the event to prevent the user to move it
|
||||||
|
// equivalent tp: return (m_parent.get_first_hover_volume_idx() != -1);
|
||||||
|
return m_curr_feature.has_value();
|
||||||
|
|
||||||
// fix: prevent restart gizmo when reselect object
|
// fix: prevent restart gizmo when reselect object
|
||||||
// take responsibility for left up
|
// take responsibility for left up
|
||||||
@ -401,6 +405,7 @@ void GLGizmoMeasure::on_set_state()
|
|||||||
restore_scene_raycasters_state();
|
restore_scene_raycasters_state();
|
||||||
m_editing_distance = false;
|
m_editing_distance = false;
|
||||||
m_is_editing_distance_first_frame = true;
|
m_is_editing_distance_first_frame = true;
|
||||||
|
m_measuring.reset();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_mode = EMode::BasicSelection;
|
m_mode = EMode::BasicSelection;
|
||||||
|
@ -86,7 +86,7 @@ void read_used_binary(std::vector<std::string>& ids)
|
|||||||
BOOST_LOG_TRIVIAL(warning) << "Failed to load to hints.cereal. File does not exists. " << path.string();
|
BOOST_LOG_TRIVIAL(warning) << "Failed to load to hints.cereal. File does not exists. " << path.string();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boost::nowide::ifstream file(path.string());
|
boost::nowide::ifstream file(path.string(), std::ios::binary);
|
||||||
cereal::BinaryInputArchive archive(file);
|
cereal::BinaryInputArchive archive(file);
|
||||||
HintsCerealData cd;
|
HintsCerealData cd;
|
||||||
try
|
try
|
||||||
|
@ -228,35 +228,6 @@ int SceneRaycaster::base_id(EType type)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_RAYCAST_PICKING_DEBUG
|
|
||||||
size_t SceneRaycaster::active_beds_count() const
|
|
||||||
{
|
|
||||||
size_t count = 0;
|
|
||||||
for (const auto& item : m_bed) {
|
|
||||||
if (item->is_active()) ++count;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t SceneRaycaster::active_volumes_count() const
|
|
||||||
{
|
|
||||||
size_t count = 0;
|
|
||||||
for (const auto& item : m_volumes) {
|
|
||||||
if (item->is_active()) ++count;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t SceneRaycaster::active_gizmos_count() const
|
|
||||||
{
|
|
||||||
size_t count = 0;
|
|
||||||
for (const auto& item : m_gizmos) {
|
|
||||||
if (item->is_active()) ++count;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
#endif // ENABLE_RAYCAST_PICKING_DEBUG
|
|
||||||
|
|
||||||
int SceneRaycaster::encode_id(EType type, int id) { return base_id(type) + id; }
|
int SceneRaycaster::encode_id(EType type, int id) { return base_id(type) + id; }
|
||||||
int SceneRaycaster::decode_id(EType type, int id) { return id - base_id(type); }
|
int SceneRaycaster::decode_id(EType type, int id) { return id - base_id(type); }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user