mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-11 19:09:02 +08:00
Merge branch 'fs_fix_slider_snapshots_SPE-2100' into master_27x
This commit is contained in:
commit
fb4e4710e7
@ -77,6 +77,14 @@ using namespace Slic3r::GUI;
|
||||
using namespace Slic3r::GUI::Emboss;
|
||||
|
||||
namespace {
|
||||
// TRN - Title in Undo/Redo stack after rotate with text around emboss axe
|
||||
const std::string rotation_snapshot_name = L("Text rotate");
|
||||
// NOTE: Translation is made in "m_parent.do_rotate()"
|
||||
|
||||
// TRN - Title in Undo/Redo stack after move with text along emboss axe - From surface
|
||||
const std::string move_snapshot_name = L("Text move");
|
||||
// NOTE: Translation is made in "m_parent.do_translate()"
|
||||
|
||||
template<typename T> struct Limit {
|
||||
// Limitation for view slider range in GUI
|
||||
MinMax<T> gui;
|
||||
@ -978,7 +986,7 @@ void GLGizmoEmboss::on_stop_dragging()
|
||||
m_rotate_gizmo.set_angle(PI/2);
|
||||
|
||||
// apply rotation
|
||||
m_parent.do_rotate(L("Text-Rotate"));
|
||||
m_parent.do_rotate(rotation_snapshot_name);
|
||||
m_rotate_start_angle.reset();
|
||||
volume_transformation_changed();
|
||||
}
|
||||
@ -2139,7 +2147,9 @@ void fix_transformation(const StyleManager::Style &from, const StyleManager::Sty
|
||||
// fix rotation
|
||||
float f_angle = f_angle_opt.value_or(.0f);
|
||||
float t_angle = t_angle_opt.value_or(.0f);
|
||||
do_local_z_rotate(canvas, t_angle - f_angle);
|
||||
do_local_z_rotate(canvas.get_selection(), t_angle - f_angle);
|
||||
std::string no_snapshot;
|
||||
canvas.do_rotate(no_snapshot);
|
||||
}
|
||||
|
||||
// fix distance (Z move) when exists difference in styles
|
||||
@ -2148,7 +2158,9 @@ void fix_transformation(const StyleManager::Style &from, const StyleManager::Sty
|
||||
if (!is_approx(f_move_opt, t_move_opt)) {
|
||||
float f_move = f_move_opt.value_or(.0f);
|
||||
float t_move = t_move_opt.value_or(.0f);
|
||||
do_local_z_move(canvas, t_move - f_move);
|
||||
do_local_z_move(canvas.get_selection(), t_move - f_move);
|
||||
std::string no_snapshot;
|
||||
canvas.do_move(no_snapshot);
|
||||
}
|
||||
}
|
||||
} // namesapce
|
||||
@ -2412,6 +2424,10 @@ bool GLGizmoEmboss::revertible(const std::string &name,
|
||||
ImGui::SameLine(undo_offset); // change cursor postion
|
||||
if (draw_button(m_icons, IconType::undo)) {
|
||||
value = *default_value;
|
||||
|
||||
// !! Fix to detect change of value after revert of float-slider
|
||||
m_imgui->get_last_slider_status().deactivated_after_edit = true;
|
||||
|
||||
return true;
|
||||
} else if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", undo_tooltip.c_str());
|
||||
@ -2841,9 +2857,14 @@ void GLGizmoEmboss::draw_advanced()
|
||||
if (font_prop.per_glyph){
|
||||
process();
|
||||
} else {
|
||||
do_local_z_move(m_parent, distance.value_or(.0f) - prev_distance);
|
||||
do_local_z_move(m_parent.get_selection(), distance.value_or(.0f) - prev_distance);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply move to model(backend)
|
||||
if (m_imgui->get_last_slider_status().deactivated_after_edit)
|
||||
m_parent.do_rotate(move_snapshot_name);
|
||||
|
||||
m_imgui->disabled_end(); // allowe_surface_distance
|
||||
|
||||
// slider for Clock-wise angle in degress
|
||||
@ -2865,7 +2886,7 @@ void GLGizmoEmboss::draw_advanced()
|
||||
Geometry::to_range_pi_pi(angle_rad);
|
||||
|
||||
double diff_angle = angle_rad - angle;
|
||||
do_local_z_rotate(m_parent, diff_angle);
|
||||
do_local_z_rotate(m_parent.get_selection(), diff_angle);
|
||||
|
||||
// calc angle after rotation
|
||||
const Selection &selection = m_parent.get_selection();
|
||||
@ -2882,6 +2903,9 @@ void GLGizmoEmboss::draw_advanced()
|
||||
if (use_surface || font_prop.per_glyph)
|
||||
process();
|
||||
}
|
||||
// Apply rotation on model (backend)
|
||||
if (m_imgui->get_last_slider_status().deactivated_after_edit)
|
||||
m_parent.do_rotate(rotation_snapshot_name);
|
||||
|
||||
// Keep up - lock button icon
|
||||
if (!m_volume->is_the_only_one_part()) {
|
||||
|
@ -51,6 +51,14 @@ GLGizmoSVG::GLGizmoSVG(GLCanvas3D &parent)
|
||||
// Private functions to create emboss volume
|
||||
namespace{
|
||||
|
||||
// TRN - Title in Undo/Redo stack after rotate with SVG around emboss axe
|
||||
const std::string rotation_snapshot_name = L("SVG rotate");
|
||||
// NOTE: Translation is made in "m_parent.do_rotate()"
|
||||
|
||||
// TRN - Title in Undo/Redo stack after move with SVG along emboss axe - From surface
|
||||
const std::string move_snapshot_name = L("SVG move");
|
||||
// NOTE: Translation is made in "m_parent.do_translate()"
|
||||
|
||||
// Variable keep limits for variables
|
||||
const struct Limits
|
||||
{
|
||||
@ -539,7 +547,7 @@ void GLGizmoSVG::on_stop_dragging()
|
||||
|
||||
// apply rotation
|
||||
// TRN This is an item label in the undo-redo stack.
|
||||
m_parent.do_rotate(L("SVG-Rotate"));
|
||||
m_parent.do_rotate(rotation_snapshot_name);
|
||||
m_rotate_start_angle.reset();
|
||||
volume_transformation_changed();
|
||||
|
||||
@ -1832,18 +1840,20 @@ void GLGizmoSVG::draw_distance()
|
||||
if (m_imgui->slider_optional_float("##distance", m_distance, min_distance, max_distance, "%.2f mm", 1.f, false, move_tooltip))
|
||||
is_moved = true;
|
||||
}
|
||||
|
||||
bool can_reset = m_distance.has_value();
|
||||
if (can_reset) {
|
||||
bool is_stop_sliding = m_imgui->get_last_slider_status().deactivated_after_edit;
|
||||
bool is_reseted = false;
|
||||
if (m_distance.has_value()) {
|
||||
if (reset_button(m_icons)) {
|
||||
m_distance.reset();
|
||||
is_moved = true;
|
||||
is_reseted = true;
|
||||
} else if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Reset distance").c_str());
|
||||
}
|
||||
|
||||
if (is_moved)
|
||||
do_local_z_move(m_parent, m_distance.value_or(.0f) - prev_distance);
|
||||
if (is_moved || is_reseted)
|
||||
do_local_z_move(m_parent.get_selection(), m_distance.value_or(.0f) - prev_distance);
|
||||
if (is_stop_sliding || is_reseted)
|
||||
m_parent.do_move(move_snapshot_name);
|
||||
}
|
||||
|
||||
void GLGizmoSVG::draw_rotation()
|
||||
@ -1865,7 +1875,7 @@ void GLGizmoSVG::draw_rotation()
|
||||
|
||||
double diff_angle = angle_rad - angle;
|
||||
|
||||
do_local_z_rotate(m_parent, diff_angle);
|
||||
do_local_z_rotate(m_parent.get_selection(), diff_angle);
|
||||
|
||||
// calc angle after rotation
|
||||
m_angle = calc_angle(m_parent.get_selection());
|
||||
@ -1874,20 +1884,28 @@ void GLGizmoSVG::draw_rotation()
|
||||
if (m_volume->emboss_shape->projection.use_surface)
|
||||
process();
|
||||
}
|
||||
bool is_stop_sliding = m_imgui->get_last_slider_status().deactivated_after_edit;
|
||||
|
||||
// Reset button
|
||||
bool is_reseted = false;
|
||||
if (m_angle.has_value()) {
|
||||
if (reset_button(m_icons)) {
|
||||
do_local_z_rotate(m_parent, -(*m_angle));
|
||||
do_local_z_rotate(m_parent.get_selection(), -(*m_angle));
|
||||
m_angle.reset();
|
||||
|
||||
// recalculate for surface cut
|
||||
if (m_volume->emboss_shape->projection.use_surface)
|
||||
process();
|
||||
|
||||
is_reseted = true;
|
||||
} else if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Reset rotation").c_str());
|
||||
}
|
||||
|
||||
// Apply rotation on model (backend)
|
||||
if (is_stop_sliding || is_reseted)
|
||||
m_parent.do_rotate(rotation_snapshot_name);
|
||||
|
||||
// Keep up - lock button icon
|
||||
if (!m_volume->is_the_only_one_part()) {
|
||||
ImGui::SameLine(m_gui_cfg->lock_offset);
|
||||
|
@ -322,11 +322,11 @@ bool face_selected_volume_to_camera(const Camera &camera, GLCanvas3D &canvas, co
|
||||
return false;
|
||||
ModelObject &object = *object_ptr;
|
||||
|
||||
ModelInstance *instance_ptr = get_model_instance(gl_volume, object);
|
||||
const ModelInstance *instance_ptr = get_model_instance(gl_volume, object);
|
||||
assert(instance_ptr != nullptr);
|
||||
if (instance_ptr == nullptr)
|
||||
return false;
|
||||
ModelInstance &instance = *instance_ptr;
|
||||
const ModelInstance &instance = *instance_ptr;
|
||||
|
||||
ModelVolume *volume_ptr = get_model_volume(gl_volume, object);
|
||||
assert(volume_ptr != nullptr);
|
||||
@ -385,10 +385,7 @@ bool face_selected_volume_to_camera(const Camera &camera, GLCanvas3D &canvas, co
|
||||
return true;
|
||||
}
|
||||
|
||||
void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle)
|
||||
{
|
||||
Selection &selection = canvas.get_selection();
|
||||
|
||||
void do_local_z_rotate(Selection &selection, double relative_angle) {
|
||||
assert(!selection.is_empty());
|
||||
if(selection.is_empty()) return;
|
||||
|
||||
@ -418,17 +415,9 @@ void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle)
|
||||
selection.rotate(Vec3d(0., 0., relative_angle), get_drag_transformation_type(selection));
|
||||
};
|
||||
selection_transform(selection, selection_rotate_fnc);
|
||||
|
||||
std::string snapshot_name; // empty meand no store undo / redo
|
||||
// NOTE: it use L instead of _L macro because prefix _ is appended
|
||||
// inside function do_move
|
||||
// snapshot_name = L("Set text rotation");
|
||||
canvas.do_rotate(snapshot_name);
|
||||
}
|
||||
|
||||
void do_local_z_move(GLCanvas3D &canvas, double relative_move) {
|
||||
|
||||
Selection &selection = canvas.get_selection();
|
||||
void do_local_z_move(Selection &selection, double relative_move) {
|
||||
assert(!selection.is_empty());
|
||||
if (selection.is_empty()) return;
|
||||
|
||||
@ -438,12 +427,6 @@ void do_local_z_move(GLCanvas3D &canvas, double relative_move) {
|
||||
selection.translate(translate, TransformationType::Local);
|
||||
};
|
||||
selection_transform(selection, selection_translate_fnc);
|
||||
|
||||
std::string snapshot_name; // empty mean no store undo / redo
|
||||
// NOTE: it use L instead of _L macro because prefix _ is appended inside
|
||||
// function do_move
|
||||
// snapshot_name = L("Set surface distance");
|
||||
canvas.do_move(snapshot_name);
|
||||
}
|
||||
|
||||
TransformationType get_drag_transformation_type(const Selection &selection)
|
||||
|
@ -136,16 +136,16 @@ bool face_selected_volume_to_camera(const Camera &camera, GLCanvas3D &canvas, co
|
||||
/// <summary>
|
||||
/// Rotation around z Axis(emboss direction)
|
||||
/// </summary>
|
||||
/// <param name="canvas">Selected volume for rotation</param>
|
||||
/// <param name="selection">Selected volume for rotation</param>
|
||||
/// <param name="relative_angle">Relative angle to rotate around emboss direction</param>
|
||||
void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle);
|
||||
void do_local_z_rotate(Selection &selection, double relative_angle);
|
||||
|
||||
/// <summary>
|
||||
/// Translation along local z Axis (emboss direction)
|
||||
/// </summary>
|
||||
/// <param name="canvas">Selected volume for translate</param>
|
||||
/// <param name="selection">Selected volume for translate</param>
|
||||
/// <param name="relative_move">Relative move along emboss direction</param>
|
||||
void do_local_z_move(GLCanvas3D &canvas, double relative_move);
|
||||
void do_local_z_move(Selection &selection, double relative_move);
|
||||
|
||||
/// <summary>
|
||||
/// Distiguish between object and volume
|
||||
|
Loading…
x
Reference in New Issue
Block a user