Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
Ploty2
Commits
60086230
Commit
60086230
authored
Jun 24, 2019
by
Locatelli
Browse files
Take care of image reduction for big size
parent
c7b1805e
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/manager/PlotManager.cpp
View file @
60086230
...
...
@@ -20,6 +20,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include "protobuf/generated/DataPlotMessages.pb.h"
#include "Trace.h"
...
...
src/plot/Plot2D.cpp
View file @
60086230
...
...
@@ -105,7 +105,7 @@ void Plot2D::display() throw (Error) {
//// Create plots
////
try
{
m_MplPlot2D
.
plot
((
int32
)
m_datax
.
size
(),
(
int32
)
m_datay
.
size
(),
m_dataz
,
m_dataprojx
,
m_dataprojy
);
m_MplPlot2D
.
plot
((
int32
)
m_datax
.
size
(),
(
int32
)
m_datay
.
size
(),
m_dataz
,
m_datax
,
m_datay
,
m_dataprojx
,
m_dataprojy
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"Plot2D"
,
"display"
,
"Failed to do plot"
);
}
...
...
@@ -169,6 +169,11 @@ void Plot2D::display() throw (Error) {
Warning
(
"Plot2D"
,
"display"
,
"Could not set color map"
);
}
}
///////////////////////////////////////////////////////////////////////////////////////
//// reset limits
////
resetLimits
();
}
/*
...
...
@@ -197,17 +202,23 @@ void Plot2D::computeProjections() {
* resetLimits
*/
void
Plot2D
::
resetLimits
()
throw
(
Error
)
{
float64
xmin
=
*
std
::
min_element
(
m_datax
.
begin
(),
m_datax
.
end
());
float64
xmax
=
*
std
::
max_element
(
m_datax
.
begin
(),
m_datax
.
end
());
float64
ymin
=
*
std
::
min_element
(
m_datay
.
begin
(),
m_datay
.
end
());
float64
ymax
=
*
std
::
max_element
(
m_datay
.
begin
(),
m_datay
.
end
());
m_MplPlot2D
.
set_imagelim
(
xmin
,
xmax
,
ymin
,
ymax
);
// Reset X limits
if
(
m_dataprojx
.
empty
()
==
false
)
{
float64
proj
x
min
=
*
std
::
min_element
(
m_dataprojx
.
begin
(),
m_dataprojx
.
end
());
float64
proj
x
max
=
*
std
::
max_element
(
m_dataprojx
.
begin
(),
m_dataprojx
.
end
());
m_MplPlot2D
.
set_projxlim
(
proj
x
min
,
proj
x
max
);
float64
proj
y
min
=
*
std
::
min_element
(
m_dataprojx
.
begin
(),
m_dataprojx
.
end
());
float64
proj
y
max
=
*
std
::
max_element
(
m_dataprojx
.
begin
(),
m_dataprojx
.
end
());
m_MplPlot2D
.
set_projxlim
(
xmin
,
xmax
,
proj
y
min
,
proj
y
max
);
}
// Reset Y limits
if
(
m_dataprojy
.
empty
()
==
false
)
{
float64
proj
y
min
=
*
std
::
min_element
(
m_dataprojy
.
begin
(),
m_dataprojy
.
end
());
float64
proj
y
max
=
*
std
::
max_element
(
m_dataprojy
.
begin
(),
m_dataprojy
.
end
());
m_MplPlot2D
.
set_projylim
(
proj
y
min
,
projymax
);
float64
proj
x
min
=
*
std
::
min_element
(
m_dataprojy
.
begin
(),
m_dataprojy
.
end
());
float64
proj
x
max
=
*
std
::
max_element
(
m_dataprojy
.
begin
(),
m_dataprojy
.
end
());
m_MplPlot2D
.
set_projylim
(
proj
x
min
,
proj
xmax
,
ymin
,
ymax
);
}
}
...
...
src/plot/property/PropertyPlot2D.cpp
View file @
60086230
...
...
@@ -270,24 +270,12 @@ void PropertyPlot2D::update(int32 id) {
try
{
getData
(
m_DataCont
->
dataZPropertyTypes
[
m_DataCont
->
dataZIds
[
0
]],
m_DataCont
->
dataZIds
[
0
],
m_dataz
);
computeProjections
();
uint32
projxminbox
=
0
;
uint32
projxmaxbox
=
m_dataprojx
.
size
()
-
1
;
uint32
projyminbox
=
0
;
uint32
projymaxbox
=
m_dataprojy
.
size
()
-
1
;
// if (m_PlotWindow->getPlotToolBar().isZooming() == true) {
// }
if
(
m_dataprojx
.
empty
()
==
false
)
{
float64
projxmin
=
*
std
::
min_element
(
m_dataprojx
.
begin
()
+
projxminbox
,
m_dataprojx
.
begin
()
+
projxmaxbox
);
float64
projxmax
=
*
std
::
max_element
(
m_dataprojx
.
begin
()
+
projxminbox
,
m_dataprojx
.
begin
()
+
projxmaxbox
);
m_MplPlot2D
.
set_projxlim
(
projxmin
,
projxmax
);
}
if
(
m_dataprojy
.
empty
()
==
false
)
{
float64
projymin
=
*
std
::
min_element
(
m_dataprojy
.
begin
()
+
projyminbox
,
m_dataprojy
.
begin
()
+
projymaxbox
);
float64
projymax
=
*
std
::
max_element
(
m_dataprojy
.
begin
()
+
projyminbox
,
m_dataprojy
.
begin
()
+
projymaxbox
);
m_MplPlot2D
.
set_projylim
(
projymin
,
projymax
);
}
colorLimits
(
m_MinColorLim
,
m_MaxColorLim
);
m_MplPlot2D
.
updateplot
((
int32
)
m_datax
.
size
(),
(
int32
)
m_datay
.
size
(),
m_dataz
,
m_dataprojx
,
m_dataprojy
);
m_MplPlot2D
.
updateplot
((
int32
)
m_datax
.
size
(),
(
int32
)
m_datay
.
size
(),
m_dataz
,
m_datax
,
m_datay
,
m_dataprojx
,
m_dataprojy
);
///////////////////////////////////////////////////////////////////////////////////////
//// reset limits
////
resetLimits
();
m_PlotWindow
->
repaint
();
}
catch
(
Error
&
e
)
{
Error
(
"PropertyPlot2D"
,
"update"
,
"Failed to update z data "
,
m_DataCont
->
dataZIds
[
0
]);
...
...
src/view/mpl/MplPlot2D.cpp
View file @
60086230
...
...
@@ -145,7 +145,8 @@ void MplPlot2D::ylabel(const std::string& name) throw (Error) {
/*
* plot
*/
void
MplPlot2D
::
plot
(
int32
xsize
,
int32
ysize
,
const
std
::
vector
<
float64
>&
data
,
const
std
::
vector
<
float64
>&
dataprojx
,
void
MplPlot2D
::
plot
(
int32
xsize
,
int32
ysize
,
const
std
::
vector
<
float64
>&
data
,
const
std
::
vector
<
float64
>&
datax
,
const
std
::
vector
<
float64
>&
datay
,
const
std
::
vector
<
float64
>&
dataprojx
,
const
std
::
vector
<
float64
>&
dataprojy
)
throw
(
Error
)
{
MplLock
lock
;
...
...
@@ -209,7 +210,7 @@ void MplPlot2D::plot(int32 xsize, int32 ysize, const std::vector<float64>& data,
bp
::
dict
keywords
;
keywords
[
"linewidth"
]
=
0.5
;
try
{
m_XProjectionLine
=
plotproj
(
m_XProjectionAxis
,
dataprojx
,
keywords
);
m_XProjectionLine
=
plotproj
(
m_XProjectionAxis
,
datax
,
dataprojx
,
keywords
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot2D"
,
"plot"
,
"Could not created x projection"
);
}
...
...
@@ -269,20 +270,11 @@ void MplPlot2D::plot(int32 xsize, int32 ysize, const std::vector<float64>& data,
throw
Error
(
"MplPlot2D"
,
"plot"
,
"Could not tick_params on x projection"
);
}
// Set x limits for displaying the full main image
try
{
m_Mpl
->
set_xlim
(
m_XProjectionAxis
,
(
size_t
)
0
,
dataprojx
.
size
()
-
1
,
0
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot2D"
,
"plot"
,
"Error when executing the set_xlim method"
);
}
///////////////////////////////////////////////////////////////////////////////////////
//// Create y projection plot
////
vector
<
float64
>
range
(
dataprojy
.
size
());
iota
(
range
.
begin
(),
range
.
end
(),
0.0
);
try
{
m_YProjectionLine
=
plotproj
(
m_YProjectionAxis
,
dataprojy
,
range
,
keywords
);
m_YProjectionLine
=
plotproj
(
m_YProjectionAxis
,
dataprojy
,
datay
,
keywords
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot2D"
,
"plot"
,
"Could not created y projection"
);
}
...
...
@@ -341,19 +333,13 @@ void MplPlot2D::plot(int32 xsize, int32 ysize, const std::vector<float64>& data,
throw
Error
(
"MplPlot2D"
,
"plot"
,
"Could not tick_top on y projection"
);
}
// Set y limits for displaying the full main image
try
{
m_Mpl
->
set_ylim
(
m_YProjectionAxis
,
(
size_t
)
0
,
dataprojy
.
size
()
-
1
,
0
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot2D"
,
"plot"
,
"Error when executing the set_ylim method"
);
}
}
/*
* updateplot
*/
void
MplPlot2D
::
updateplot
(
int32
xsize
,
int32
ysize
,
const
std
::
vector
<
float64
>&
data
,
const
std
::
vector
<
float64
>&
dataprojx
,
void
MplPlot2D
::
updateplot
(
int32
xsize
,
int32
ysize
,
const
std
::
vector
<
float64
>&
data
,
const
std
::
vector
<
float64
>&
datax
,
const
std
::
vector
<
float64
>&
datay
,
const
std
::
vector
<
float64
>&
dataprojx
,
const
std
::
vector
<
float64
>&
dataprojy
)
throw
(
Error
)
{
///////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -361,6 +347,11 @@ void MplPlot2D::updateplot(int32 xsize, int32 ysize, const std::vector<float64>&
////
try
{
m_Mpl
->
set_ydata
(
m_XProjectionLine
,
dataprojx
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot2D"
,
"updateplot"
,
"Could not set_ydata"
);
}
try
{
m_Mpl
->
set_xdata
(
m_XProjectionLine
,
datax
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot2D"
,
"updateplot"
,
"Could not set_xdata"
);
}
...
...
@@ -370,6 +361,11 @@ void MplPlot2D::updateplot(int32 xsize, int32 ysize, const std::vector<float64>&
////
try
{
m_Mpl
->
set_xdata
(
m_YProjectionLine
,
dataprojy
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot2D"
,
"updateplot"
,
"Could not set_xdata"
);
}
try
{
m_Mpl
->
set_ydata
(
m_YProjectionLine
,
datay
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot2D"
,
"updateplot"
,
"Could not set_ydata"
);
}
...
...
src/view/mpl/MplPlot2D.h
View file @
60086230
...
...
@@ -64,24 +64,30 @@ public:
* \param[in] xsize The 2d data x size
* \param[in] ysize The 2d data y size
* \param[in] data The 2d data
* \param[in] datax The data x indice
* \param[in] datay The data y indice
* \param[in] dataprojx The x projection data
* \param[in] dataprojy The y projection data
* \throws Error
*/
void
plot
(
int32
xsize
,
int32
ysize
,
const
std
::
vector
<
float64
>&
data
,
const
std
::
vector
<
float64
>&
dataprojx
,
const
std
::
vector
<
float64
>&
dataprojy
)
throw
(
Error
);
void
plot
(
int32
xsize
,
int32
ysize
,
const
std
::
vector
<
float64
>&
data
,
const
std
::
vector
<
float64
>&
datax
,
const
std
::
vector
<
float64
>&
datay
,
const
std
::
vector
<
float64
>&
dataprojx
,
const
std
::
vector
<
float64
>&
dataprojy
)
throw
(
Error
);
/*!
* \brief update the 2d plot, projections and colorbar
* \param[in] xsize The 2d data x size
* \param[in] ysize The 2d data y size
* \param[in] data The 2d data
* \param[in] datax The data x indice
* \param[in] datay The data y indice
* \param[in] dataprojx The x projection data
* \param[in] dataprojy The y projection data
* \throws Error
*/
void
updateplot
(
int32
xsize
,
int32
ysize
,
const
std
::
vector
<
float64
>&
data
,
const
std
::
vector
<
float64
>&
dataprojx
,
const
std
::
vector
<
float64
>&
dataprojy
)
throw
(
Error
);
void
updateplot
(
int32
xsize
,
int32
ysize
,
const
std
::
vector
<
float64
>&
data
,
const
std
::
vector
<
float64
>&
datax
,
const
std
::
vector
<
float64
>&
datay
,
const
std
::
vector
<
float64
>&
dataprojx
,
const
std
::
vector
<
float64
>&
dataprojy
)
throw
(
Error
);
/*!
* \brief set title of the plot
...
...
@@ -162,20 +168,34 @@ public:
float64
hspace
,
float64
wspace
)
throw
(
Error
);
/*!
* \brief refresh x limit of the plot
* \param[in] min the minimum value
* \param[in] max the maximum value
* \brief refresh x and y limits of the image plot
* \param[in] xmin the minimum of x value
* \param[in] xmax the maximum of x value
* \param[in] ymin the minimum of y value
* \param[in] ymax the maximum of y value
* \throws Error
*/
template
<
typename
Numeric
>
void
set_
projx
lim
(
Numeric
min
,
Numeric
max
)
throw
(
Error
);
template
<
typename
Numeric
>
void
set_
image
lim
(
Numeric
x
min
,
Numeric
,
Numeric
ymin
,
Numeric
y
max
)
throw
(
Error
);
/*!
* \brief refresh y limit of the plot
* \param[in] min the minimum value
* \param[in] max the maximum value
* \brief refresh x and y limits of the projection x plot
* \param[in] xmin the minimum of x value
* \param[in] xmax the maximum of x value
* \param[in] ymin the minimum of y value
* \param[in] ymax the maximum of y value
* \throws Error
*/
template
<
typename
Numeric
>
void
set_projylim
(
Numeric
min
,
Numeric
max
)
throw
(
Error
);
template
<
typename
Numeric
>
void
set_projxlim
(
Numeric
xmin
,
Numeric
,
Numeric
ymin
,
Numeric
ymax
)
throw
(
Error
);
/*!
* \brief refresh x and y limits of the projection y plot
* \param[in] xmin the minimum of x value
* \param[in] xmax the maximum of x value
* \param[in] ymin the minimum of y value
* \param[in] ymax the maximum of y value
* \throws Error
*/
template
<
typename
Numeric
>
void
set_projylim
(
Numeric
xmin
,
Numeric
,
Numeric
ymin
,
Numeric
ymax
)
throw
(
Error
);
/*!
* \brief Select currect axis plot which is over the mouse
...
...
@@ -219,7 +239,7 @@ private:
* \param[in] keywords plot options
* \throws Error
*/
template
<
typename
Numeric
>
bp
::
object
plotproj
(
bp
::
object
axis
,
const
std
::
vector
<
Numeric
>
&
x
,
const
std
::
vector
<
Numeric
>
&
y
,
template
<
typename
Numeric
>
bp
::
object
plotproj
(
const
bp
::
object
&
axis
,
const
std
::
vector
<
Numeric
>
&
x
,
const
std
::
vector
<
Numeric
>
&
y
,
bp
::
dict
&
keywords
)
throw
(
Error
);
Mpl
*
m_Mpl
;
//! Mpl object (main class which managed the matplotib api)
...
...
@@ -269,7 +289,7 @@ bp::object MplPlot2D::plotproj(const bp::object& axis, const std::vector<Numeric
* plotproj
*/
template
<
typename
Numeric
>
bp
::
object
MplPlot2D
::
plotproj
(
bp
::
object
axis
,
const
std
::
vector
<
Numeric
>
&
x
,
const
std
::
vector
<
Numeric
>
&
y
,
bp
::
object
MplPlot2D
::
plotproj
(
const
bp
::
object
&
axis
,
const
std
::
vector
<
Numeric
>
&
x
,
const
std
::
vector
<
Numeric
>
&
y
,
bp
::
dict
&
keywords
)
throw
(
Error
)
{
MplLock
lock
;
...
...
@@ -300,21 +320,49 @@ bp::object MplPlot2D::plotproj(bp::object axis, const std::vector<Numeric> &x, c
* set_projxlim
*/
template
<
typename
Numeric
>
void
MplPlot2D
::
set_projxlim
(
Numeric
min
,
Numeric
max
)
throw
(
Error
)
{
void
MplPlot2D
::
set_imagelim
(
Numeric
xmin
,
Numeric
xmax
,
Numeric
ymin
,
Numeric
ymax
)
throw
(
Error
)
{
bp
::
list
lims
;
lims
.
append
(
xmin
);
lims
.
append
(
xmax
);
lims
.
append
(
ymin
);
lims
.
append
(
ymax
);
auto
args
=
bp
::
make_tuple
(
lims
);
try
{
m_AxisImage
.
attr
(
"set_extent"
)(
*
args
);
}
catch
(...)
{
throw
Error
(
"MplPlot2D"
,
"set_imagelim"
,
"Could not update image set_extent"
);
}
}
/*
* set_projxlim
*/
template
<
typename
Numeric
>
void
MplPlot2D
::
set_projxlim
(
Numeric
xmin
,
Numeric
xmax
,
Numeric
ymin
,
Numeric
ymax
)
throw
(
Error
)
{
try
{
m_Mpl
->
set_
y
lim
(
m_XProjectionAxis
,
min
,
max
,
0.0
);
m_Mpl
->
set_
x
lim
(
m_XProjectionAxis
,
x
min
,
x
max
,
0.0
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot1D"
,
"set_xlim"
,
"Error when executing the set_xlim method"
);
}
try
{
m_Mpl
->
set_ylim
(
m_XProjectionAxis
,
ymin
,
ymax
,
0.0
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot1D"
,
"set_xlim"
,
"Error when executing the set_ylim method"
);
}
}
/*
* set_projylim
*/
template
<
typename
Numeric
>
void
MplPlot2D
::
set_projylim
(
Numeric
min
,
Numeric
max
)
throw
(
Error
)
{
void
MplPlot2D
::
set_projylim
(
Numeric
xmin
,
Numeric
xmax
,
Numeric
ymin
,
Numeric
ymax
)
throw
(
Error
)
{
try
{
m_Mpl
->
set_xlim
(
m_YProjectionAxis
,
xmin
,
xmax
,
0.0
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot1D"
,
"set_ylim"
,
"Error when executing the set_ylim method"
);
}
try
{
m_Mpl
->
set_
x
lim
(
m_YProjectionAxis
,
min
,
max
,
0.0
);
m_Mpl
->
set_
y
lim
(
m_YProjectionAxis
,
y
min
,
y
max
,
0.0
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"MplPlot1D"
,
"set_ylim"
,
"Error when executing the set_ylim method"
);
}
...
...
src/view/qt/QtWindow.cpp
View file @
60086230
...
...
@@ -240,7 +240,9 @@ void QtWindow::readSettings() {
void
QtWindow
::
treatMouseMoveEvent
(
const
QPoint
&
point
)
{
try
{
vector
<
float64
>
coords
=
m_PlotWindow
->
toDataCoord
(
point
.
x
(),
point
.
y
(),
devicePixelRatio
());
m_StatusWidget
->
refreshStatusValues
(
coords
[
0
],
coords
[
1
],
coords
[
2
]);
if
(
coords
.
empty
()
==
false
)
{
m_StatusWidget
->
refreshStatusValues
(
coords
[
0
],
coords
[
1
],
coords
[
2
]);
}
}
catch
(...)
{
throw
Error
(
"QtWindow"
,
"treatMouseMoveEvent"
,
"Failled to treat mouse coordinates event"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment