Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main Repositories
otb
Commits
24c932f8
Commit
24c932f8
authored
6 years ago
by
Victor Poughon
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Show trailing dot for GUI floats
parent
3debd708
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!621
Release 7.0 (master)
,
!123
New custom widgets for Float and Int parameters
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSpinBoxes.cxx
+13
-1
13 additions, 1 deletion
...les/Wrappers/QtWidget/src/otbWrapperQtWidgetSpinBoxes.cxx
with
13 additions
and
1 deletion
Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSpinBoxes.cxx
+
13
−
1
View file @
24c932f8
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include
<sstream>
#include
<sstream>
#include
<limits>
#include
<limits>
#include
<locale>
#include
<QAction>
#include
<QAction>
namespace
otb
namespace
otb
...
@@ -179,13 +180,24 @@ QString QtWidgetDoubleSpinBox::textFromValue(double value) const
...
@@ -179,13 +180,24 @@ QString QtWidgetDoubleSpinBox::textFromValue(double value) const
// which leads to ugly trailing zeros for small values (e.g 1.50000)
// which leads to ugly trailing zeros for small values (e.g 1.50000)
// We use std::ostringstream because QString::arg formatting support is too limited
// We use std::ostringstream because QString::arg formatting support is too limited
std
::
ostringstream
oss
;
std
::
ostringstream
oss
;
oss
.
imbue
(
std
::
locale
(
""
));
// use system's locale for formatting
// Set precision to the number of decimal digits that can be represented without change.
// Set precision to the number of decimal digits that can be represented without change.
// Use float precision because OTB parameter is float
// Use float precision because OTB parameter is float
// For IEEE float it's 6.
// For IEEE float it's 6.
oss
.
precision
(
std
::
numeric_limits
<
float
>::
digits10
);
oss
.
precision
(
std
::
numeric_limits
<
float
>::
digits10
);
oss
<<
value
;
oss
<<
value
;
// Add a trailing dot if the number is integer,
// so that int and float parameters are more visually different.
// For now this is done for all locales, even though not all locales use this
// convention for formatting decimals...
const
char
dot
=
std
::
use_facet
<
std
::
numpunct
<
char
>>
(
std
::
locale
(
""
)).
decimal_point
();
if
(
oss
.
str
().
find
(
dot
)
==
std
::
string
::
npos
)
{
oss
<<
dot
;
}
return
QString
::
fromStdString
(
oss
.
str
());
return
QString
::
fromStdString
(
oss
.
str
());
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment