mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 13:25:56 +08:00
Fix for #8439 - Inches units and scaling not working.
It changes values if clicked into boxes multiple times!
This commit is contained in:
parent
f9e46ea871
commit
9839f75b3a
@ -590,7 +590,10 @@ void ObjectManipulation::update_ui_from_settings()
|
|||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
auto update = [this, i](/*ManipulationEditorKey*/int key_id, const Vec3d& new_value) {
|
auto update = [this, i](/*ManipulationEditorKey*/int key_id, const Vec3d& new_value) {
|
||||||
wxString new_text = double_to_string(m_imperial_units ? new_value(i) * mm_to_in : new_value(i), 2);
|
double value = new_value(i);
|
||||||
|
if (m_imperial_units)
|
||||||
|
value *= mm_to_in;
|
||||||
|
wxString new_text = double_to_string(value, m_imperial_units && key_id == 3/*meSize*/ ? 4 : 2);
|
||||||
const int id = key_id * 3 + i;
|
const int id = key_id * 3 + i;
|
||||||
if (id >= 0) m_editors[id]->set_value(new_text);
|
if (id >= 0) m_editors[id]->set_value(new_text);
|
||||||
};
|
};
|
||||||
@ -776,14 +779,22 @@ void ObjectManipulation::update_if_dirty()
|
|||||||
|
|
||||||
for (int i = 0; i < 3; ++ i) {
|
for (int i = 0; i < 3; ++ i) {
|
||||||
auto update = [this, i](Vec3d &cached, Vec3d &cached_rounded, ManipulationEditorKey key_id, const Vec3d &new_value) {
|
auto update = [this, i](Vec3d &cached, Vec3d &cached_rounded, ManipulationEditorKey key_id, const Vec3d &new_value) {
|
||||||
wxString new_text = double_to_string(new_value(i), 2);
|
wxString new_text = double_to_string(new_value(i), m_imperial_units && key_id == meSize ? 4 : 2);
|
||||||
double new_rounded;
|
double new_rounded;
|
||||||
new_text.ToDouble(&new_rounded);
|
new_text.ToDouble(&new_rounded);
|
||||||
if (std::abs(cached_rounded(i) - new_rounded) > EPSILON) {
|
if (std::abs(cached_rounded(i) - new_rounded) > EPSILON) {
|
||||||
cached_rounded(i) = new_rounded;
|
cached_rounded(i) = new_rounded;
|
||||||
const int id = key_id*3+i;
|
const int id = key_id*3+i;
|
||||||
if (m_imperial_units && (key_id == mePosition || key_id == meSize))
|
if (m_imperial_units) {
|
||||||
new_text = double_to_string(new_value(i)*mm_to_in, 2);
|
double inch_value = new_value(i) * mm_to_in;
|
||||||
|
if (key_id == mePosition)
|
||||||
|
new_text = double_to_string(inch_value, 2);
|
||||||
|
if (key_id == meSize) {
|
||||||
|
if(std::abs(m_cache.size_inches(i) - inch_value) > EPSILON)
|
||||||
|
m_cache.size_inches(i) = inch_value;
|
||||||
|
new_text = double_to_string(inch_value, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (id >= 0) m_editors[id]->set_value(new_text);
|
if (id >= 0) m_editors[id]->set_value(new_text);
|
||||||
}
|
}
|
||||||
cached(i) = new_value(i);
|
cached(i) = new_value(i);
|
||||||
@ -1137,6 +1148,13 @@ void ObjectManipulation::change_size_value(int axis, double value)
|
|||||||
if (value <= 0.0)
|
if (value <= 0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (m_imperial_units) {
|
||||||
|
if (std::abs(m_cache.size_inches(axis) - value) < EPSILON)
|
||||||
|
return;
|
||||||
|
m_cache.size_inches(axis) = value;
|
||||||
|
value *= in_to_mm;
|
||||||
|
}
|
||||||
|
|
||||||
if (std::abs(m_cache.size_rounded(axis) - value) < EPSILON)
|
if (std::abs(m_cache.size_rounded(axis) - value) < EPSILON)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1237,11 +1255,11 @@ void ObjectManipulation::on_change(const std::string& opt_key, int axis, double
|
|||||||
if (!m_cache.is_valid())
|
if (!m_cache.is_valid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_imperial_units && (opt_key == "position" || opt_key == "size"))
|
if (opt_key == "position") {
|
||||||
|
if (m_imperial_units)
|
||||||
new_value *= in_to_mm;
|
new_value *= in_to_mm;
|
||||||
|
|
||||||
if (opt_key == "position")
|
|
||||||
change_position_value(axis, new_value);
|
change_position_value(axis, new_value);
|
||||||
|
}
|
||||||
else if (opt_key == "rotation")
|
else if (opt_key == "rotation")
|
||||||
change_rotation_value(axis, new_value);
|
change_rotation_value(axis, new_value);
|
||||||
else if (opt_key == "scale") {
|
else if (opt_key == "scale") {
|
||||||
|
@ -85,6 +85,7 @@ private:
|
|||||||
Vec3d scale;
|
Vec3d scale;
|
||||||
Vec3d scale_rounded;
|
Vec3d scale_rounded;
|
||||||
Vec3d size;
|
Vec3d size;
|
||||||
|
Vec3d size_inches;
|
||||||
Vec3d size_rounded;
|
Vec3d size_rounded;
|
||||||
|
|
||||||
wxString move_label_string;
|
wxString move_label_string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user