Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2018-06-25 14:32:28 +0300
committerYuSanka <yusanka@gmail.com>2018-06-25 14:32:28 +0300
commit515502e685e8eeafd1c7b45ca44d09abdecfb689 (patch)
treeb2de281af44f8574d0b792f483bab8737ddf2be5 /xs
parent318212f47594df0b2b081c90ac00a144c64639b6 (diff)
Fixed #994.
Print double-type values according to "full" value instead of 2 digits after point
Diffstat (limited to 'xs')
-rw-r--r--xs/src/slic3r/GUI/Field.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp
index 43c9e7db9..85247b41b 100644
--- a/xs/src/slic3r/GUI/Field.cpp
+++ b/xs/src/slic3r/GUI/Field.cpp
@@ -12,10 +12,20 @@ namespace Slic3r { namespace GUI {
wxString double_to_string(double const value)
{
- int precision = 10 * value - int(10 * value) == 0 ? 1 : 2;
- return value - int(value) == 0 ?
- wxString::Format(_T("%i"), int(value)) :
- wxNumberFormatter::ToString(value, precision, wxNumberFormatter::Style_None);
+ if (value - int(value) == 0)
+ return wxString::Format(_T("%i"), int(value));
+ else {
+ int precision = 4;
+ for (size_t p = 1; p < 4; p++)
+ {
+ double cur_val = pow(10, p)*value;
+ if (cur_val - int(cur_val) == 0) {
+ precision = p;
+ break;
+ }
+ }
+ return wxNumberFormatter::ToString(value, precision, wxNumberFormatter::Style_None);
+ }
}
void Field::PostInitialize(){