Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
mantidproject
mantid
Commits
da22c5c0
Commit
da22c5c0
authored
9 years ago
by
Harry Jeffery
Browse files
Options
Downloads
Patches
Plain Diff
Refs #11704 Handle min/max betrer in QwtWorkspaceBinData
parent
612027b6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Mantid/MantidQt/API/inc/MantidQtAPI/QwtWorkspaceBinData.h
+8
-2
8 additions, 2 deletions
...Mantid/MantidQt/API/inc/MantidQtAPI/QwtWorkspaceBinData.h
Code/Mantid/MantidQt/API/src/QwtWorkspaceBinData.cpp
+47
-36
47 additions, 36 deletions
Code/Mantid/MantidQt/API/src/QwtWorkspaceBinData.cpp
with
55 additions
and
38 deletions
Code/Mantid/MantidQt/API/inc/MantidQtAPI/QwtWorkspaceBinData.h
+
8
−
2
View file @
da22c5c0
...
@@ -65,7 +65,6 @@ protected:
...
@@ -65,7 +65,6 @@ protected:
QwtWorkspaceBinData
&
operator
=
(
const
QwtWorkspaceBinData
&
);
// required by QwtData base class
QwtWorkspaceBinData
&
operator
=
(
const
QwtWorkspaceBinData
&
);
// required by QwtData base class
private
:
private
:
/// Initialize the object
/// Initialize the object
void
init
(
const
Mantid
::
API
::
MatrixWorkspace
&
workspace
);
void
init
(
const
Mantid
::
API
::
MatrixWorkspace
&
workspace
);
...
@@ -85,7 +84,14 @@ private:
...
@@ -85,7 +84,14 @@ private:
/// Indicates that the data is plotted on a log y scale
/// Indicates that the data is plotted on a log y scale
bool
m_logScale
;
bool
m_logScale
;
/// lowest y value
double
m_minY
;
/// lowest positive y value
/// lowest positive y value
mutable
double
m_minPositive
;
double
m_minPositive
;
/// highest y value
double
m_maxY
;
};
};
#endif
#endif
This diff is collapsed.
Click to expand it.
Code/Mantid/MantidQt/API/src/QwtWorkspaceBinData.cpp
+
47
−
36
View file @
da22c5c0
...
@@ -7,8 +7,7 @@
...
@@ -7,8 +7,7 @@
/// Constructor
/// Constructor
QwtWorkspaceBinData
::
QwtWorkspaceBinData
(
const
Mantid
::
API
::
MatrixWorkspace
&
workspace
,
int
binIndex
,
const
bool
logScale
)
QwtWorkspaceBinData
::
QwtWorkspaceBinData
(
const
Mantid
::
API
::
MatrixWorkspace
&
workspace
,
int
binIndex
,
const
bool
logScale
)
:
m_binIndex
(
binIndex
),
m_X
(),
m_Y
(),
m_E
(),
m_xTitle
(),
m_yTitle
(),
:
m_binIndex
(
binIndex
),
m_X
(),
m_Y
(),
m_E
(),
m_xTitle
(),
m_yTitle
(),
m_logScale
(
logScale
),
m_logScale
(
logScale
)
m_minPositive
(
0
)
{
{
init
(
workspace
);
init
(
workspace
);
}
}
...
@@ -53,12 +52,11 @@ Return the y value of data point i
...
@@ -53,12 +52,11 @@ Return the y value of data point i
*/
*/
double
QwtWorkspaceBinData
::
y
(
size_t
i
)
const
double
QwtWorkspaceBinData
::
y
(
size_t
i
)
const
{
{
double
tmp
=
m_Y
[
i
];
Mantid
::
signal_t
val
=
m_Y
[
i
];
if
(
m_logScale
&&
tmp
<=
0.
)
if
(
m_logScale
&&
val
<=
0.
)
{
return
m_minPositive
;
tmp
=
m_minPositive
;
else
}
return
val
;
return
tmp
;
}
}
double
QwtWorkspaceBinData
::
ex
(
size_t
i
)
const
double
QwtWorkspaceBinData
::
ex
(
size_t
i
)
const
...
@@ -90,20 +88,10 @@ size_t QwtWorkspaceBinData::esize() const
...
@@ -90,20 +88,10 @@ size_t QwtWorkspaceBinData::esize() const
*/
*/
double
QwtWorkspaceBinData
::
getYMin
()
const
double
QwtWorkspaceBinData
::
getYMin
()
const
{
{
double
temp
=
m_Y
[
0
];
if
(
m_logScale
)
for
(
size_t
i
=
1
;
i
<
m_Y
.
size
();
++
i
)
return
m_minPositive
;
{
else
if
((
boost
::
math
::
isnan
)(
temp
)
||
(
boost
::
math
::
isinf
)(
temp
))
return
m_minY
;
temp
=
m_Y
[
i
];
else
if
(
m_Y
[
i
]
<
temp
&&
!
(
boost
::
math
::
isnan
)(
m_Y
[
i
])
&&
!
(
boost
::
math
::
isinf
)(
m_Y
[
i
]))
temp
=
m_Y
[
i
];
}
if
(
m_logScale
&&
temp
<=
0.
)
{
temp
=
m_minPositive
;
}
return
temp
;
}
}
/**
/**
...
@@ -112,20 +100,10 @@ double QwtWorkspaceBinData::getYMin() const
...
@@ -112,20 +100,10 @@ double QwtWorkspaceBinData::getYMin() const
*/
*/
double
QwtWorkspaceBinData
::
getYMax
()
const
double
QwtWorkspaceBinData
::
getYMax
()
const
{
{
double
temp
=
m_Y
[
0
];
if
(
m_logScale
&&
m_maxY
<=
0
)
for
(
size_t
i
=
1
;
i
<
m_Y
.
size
();
++
i
)
return
m_minPositive
;
{
else
if
((
boost
::
math
::
isnan
)(
temp
)
||
(
boost
::
math
::
isinf
)(
temp
))
return
m_maxY
;
temp
=
m_Y
[
i
];
else
if
(
m_Y
[
i
]
>
temp
&&
!
(
boost
::
math
::
isnan
)(
m_Y
[
i
])
&&
!
(
boost
::
math
::
isinf
)(
m_Y
[
i
]))
temp
=
m_Y
[
i
];
}
if
(
m_logScale
&&
temp
<=
0.
)
{
temp
=
m_minPositive
;
}
return
temp
;
}
}
/**
/**
...
@@ -215,4 +193,37 @@ void QwtWorkspaceBinData::init(const Mantid::API::MatrixWorkspace &workspace)
...
@@ -215,4 +193,37 @@ void QwtWorkspaceBinData::init(const Mantid::API::MatrixWorkspace &workspace)
// meta data
// meta data
m_xTitle
=
MantidQt
::
API
::
PlotAxis
(
workspace
,
1
).
title
();
m_xTitle
=
MantidQt
::
API
::
PlotAxis
(
workspace
,
1
).
title
();
m_yTitle
=
MantidQt
::
API
::
PlotAxis
(
false
,
workspace
).
title
();
m_yTitle
=
MantidQt
::
API
::
PlotAxis
(
false
,
workspace
).
title
();
// Calculate the min and max values
double
curMin
=
m_Y
[
0
];
double
curMinPos
=
m_Y
[
0
];
double
curMax
=
m_Y
[
0
];
for
(
size_t
i
=
1
;
i
<
m_Y
.
size
();
++
i
)
{
// skip NaNs
if
((
boost
::
math
::
isnan
)(
m_Y
[
i
])
||
(
boost
::
math
::
isinf
)(
m_Y
[
i
]))
continue
;
// Try and get rid any starting NaNs as soon as possible
if
((
boost
::
math
::
isnan
)(
curMin
)
||
(
boost
::
math
::
isinf
)(
curMin
))
curMin
=
m_Y
[
i
];
if
((
boost
::
math
::
isnan
)(
curMinPos
)
||
(
boost
::
math
::
isinf
)(
curMinPos
))
curMinPos
=
m_Y
[
i
];
if
((
boost
::
math
::
isnan
)(
curMax
)
||
(
boost
::
math
::
isinf
)(
curMax
))
curMax
=
m_Y
[
i
];
// Update our values as appropriate
if
(
m_Y
[
i
]
<
curMin
)
curMin
=
m_Y
[
i
];
if
(
m_Y
[
i
]
<
curMinPos
&&
m_Y
[
i
]
>
0
)
curMinPos
=
m_Y
[
i
];
if
(
m_Y
[
i
]
>
curMax
)
curMax
=
m_Y
[
i
];
}
// Save the results
m_minY
=
curMin
;
m_minPositive
=
curMinPos
;
m_maxY
=
curMax
;
}
}
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