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
ad085027
Commit
ad085027
authored
Apr 09, 2020
by
Locatelli
Browse files
Improvements:
- Scan plots with repeater - Multiplots - Offscreen
parent
072ad007
Changes
27
Hide whitespace changes
Inline
Side-by-side
ToDo.txt
View file @
ad085027
...
...
@@ -4,15 +4,17 @@
* Use async method for filling data vectors for accelerating process
* Remove multiplot files at the start of server
* Multiplot
- Try create a plot with all plots (subplot)
- For PN do something for detecting channel problem (using CPU of mpda_dpp?) or in nomad?
* Bugs:
- Min and max colorlimits when update data from server during a count
* Does we limits x data for plot 1D (as doing in plot2d)?
* Does we limits x data for plot 1D (as doing in plot2d)? -> Yes , I did it, df fipps
* OpenGL:
See writing specific backend qt - opengl (mantid already did that or plan to?)
* Remove usr1_signal for brng in front a plot. Use a cameo message instead.
* Look for memoryleaks
- Check Remove python objects after a clear for example (MplPlot1d::clear) or object ...
* Unitary tests
\ No newline at end of file
src/mainoffscreenplot.cpp
View file @
ad085027
...
...
@@ -47,32 +47,38 @@ void crash_handler(int32 sig) {
*/
int32
main
(
int32
argc
,
char
*
argv
[])
{
// ofstream out("/users/cameo/off.log", std::ofstream::out | std::ofstream::app);
for
(
int32
i
=
0
;
i
<
argc
;
++
i
)
{
cout
<<
argv
[
i
]
<<
endl
;
}
if
(
argc
<
3
)
{
cerr
<<
"mainoffscreenplot Missing arguments, need 2 : got "
<<
argc
;
//
cerr << "mainoffscreenplot Missing arguments, need 2 : got " << argc;
return
EXIT_FAILURE
;
}
std
::
string
pbfilename
=
argv
[
1
];
std
::
string
path
=
argv
[
2
];
// Create and init the Matplolib module
// Create and init the Matplolib module
shared_ptr
<
view
::
mpl
::
Mpl
>
mpl
=
make_shared
<
view
::
mpl
::
Mpl
>
();
// Create the publisher.
std
::
shared_ptr
<
cameo
::
application
::
Publisher
>
spypublisher
=
application
::
Publisher
::
create
(
"spy_publisher"
);
cout
<<
"Created publisher "
<<
*
spypublisher
;
if
(
spypublisher
.
get
()
==
0
)
{
// TODO Error
cout
<<
"spypublisher error"
<<
endl
;
return
EXIT_FAILURE
;
}
// Ne marche pas pour une application non cameo-iser
// out << "try Created publisher " << endl;
//// Create the publisher.
// std::shared_ptr<cameo::application::Publisher> spypublisher = application::Publisher::create("spy_publisher");
// out << "Created publisher " << *spypublisher;
// if (spypublisher.get() == 0) {
// // TODO Error
// out << "spypublisher error" << endl;
// return EXIT_FAILURE;
// }
OffScreenPlotManager
::
getInstance
()
->
init
(
mpl
,
spypublisher
,
false
);
// out << "init off manager" << endl;
OffScreenPlotManager
::
getInstance
()
->
init
(
mpl
,
nullptr
,
false
);
// out << "run" << endl;
OffScreenPlotManager
::
getInstance
()
->
run
(
pbfilename
,
path
);
// out << "finished" << endl;
return
EXIT_SUCCESS
;
}
src/manager/OffScreenPlotManager.cpp
View file @
ad085027
...
...
@@ -24,6 +24,7 @@
#include <boost/filesystem/path.hpp>
#include <thread>
#include <boost/thread.hpp>
//#include <chrono>
#include "plot/offscreen/OffScreenEmptyPlot.h"
#include "plot/offscreen/OffScreenPlot1D.h"
...
...
@@ -105,10 +106,10 @@ void OffScreenPlotManager::loop(std::shared_ptr<cameo::application::Subscriber>
notification
::
ImageDataReady
messageImageReady
;
try
{
messageImageReady
.
ParseFromString
(
data2
);
//
run(messageImageReady.imagename(), messageImageReady.imagepath());
ThreadPoolManager
::
getInstance
()
->
addJob
(
bind
(
&
OffScreenPlotManager
::
run
,
m_Instance
,
messageImageReady
.
imagename
(),
messageImageReady
.
imagepath
()));
run
(
messageImageReady
.
imagename
(),
messageImageReady
.
imagepath
());
//
ThreadPoolManager::getInstance()->addJob(
//
bind(&OffScreenPlotManager::run, m_Instance, messageImageReady.imagename(),
//
messageImageReady.imagepath()));
// ostringstream com;
// com << "./offscreenplot " << messageImageReady.imagename() << " " << messageImageReady.imagepath();
// system(com.str().c_str());
...
...
@@ -151,6 +152,17 @@ void OffScreenPlotManager::loop(std::shared_ptr<cameo::application::Subscriber>
*/
void
OffScreenPlotManager
::
run
(
std
::
string
pbfilename
,
std
::
string
path
)
{
// size_t p1 = pbfilename.find("0.0#");
// size_t p2 = pbfilename.find(".png");
// uint32 num = 0;
// if (p1 != string::npos) {
// istringstream sbuf(pbfilename.substr(p1 + 4, p2 - p1 - 4));
// sbuf >> num;
// if (num == 0) {
//// DBGMSG(pbfilename);
// start = chrono::steady_clock::now();
// }
// }
try
{
unique_ptr
<
view
::
mpl
::
MplFigure
>
figure
(
new
view
::
mpl
::
MplFigure
(
*
m_Mpl
,
false
));
boost
::
filesystem
::
path
pbfile
=
path
;
...
...
@@ -167,12 +179,12 @@ void OffScreenPlotManager::run(std::string pbfilename, std::string path) {
buffer
::
Data
data
;
data
.
ParseFromArray
(
buffer
,
size
);
DBGMSG
(
"pbfilename = "
<<
path
<<
"/"
<<
pbfilename
);
//
DBGMSG("pbfilename = " << path << "/" << pbfilename);
// DBGMSG("buffer = " << size);
// DBGMSG("numor = " << data.numor());
//
DBGMSG("dataxArray = " << data.xdata_size());
//
DBGMSG("datayArray = " << data.ydata_size());
//
DBGMSG("datazArray = " << data.zdata_size());
//
DBGMSG("dataxArray = " << data.xdata_size());
//
DBGMSG("datayArray = " << data.ydata_size());
//
DBGMSG("datazArray = " << data.zdata_size());
inputMessage
.
close
();
ostringstream
plotkey
;
...
...
@@ -188,25 +200,21 @@ void OffScreenPlotManager::run(std::string pbfilename, std::string path) {
}
if
((
data
.
xdata_size
()
>
0
)
&&
(
data
.
ydata_size
()
>
0
)
&&
(
data
.
zdata_size
()
>
0
))
{
// 2D
for
(
int32
i
=
0
;
i
<
data
.
xdata_size
();
++
i
)
{
try
{
plot
::
offscreen
::
OffScreenPlot2D
plot
(
0
,
*
figure
,
plotkey
.
str
(),
*
m_Mpl
,
data
);
plot
.
display
();
plot
.
save
(
pbfile
.
parent_path
().
parent_path
().
string
(),
dpi
,
pad
);
}
catch
(
Error
&
e
)
{
Error
(
"OffScreenPlotManager"
,
"savePlot"
,
"Failed create 2d plot"
,
plotkey
.
str
());
}
try
{
plot
::
offscreen
::
OffScreenPlot2D
plot
(
0
,
*
figure
,
plotkey
.
str
(),
*
m_Mpl
,
data
);
plot
.
display
();
plot
.
save
(
pbfile
.
parent_path
().
parent_path
().
string
(),
dpi
,
pad
);
}
catch
(
Error
&
e
)
{
Error
(
"OffScreenPlotManager"
,
"savePlot"
,
"Failed create 2d plot"
,
plotkey
.
str
());
}
}
else
if
((
data
.
xdata_size
()
>
0
)
&&
(
data
.
ydata_size
()
>
0
))
{
// 1D
for
(
int32
i
=
0
;
i
<
data
.
xdata_size
();
++
i
)
{
try
{
plot
::
offscreen
::
OffScreenPlot1D
plot
(
0
,
*
figure
,
plotkey
.
str
(),
*
m_Mpl
,
data
);
plot
.
display
();
plot
.
save
(
pbfile
.
parent_path
().
parent_path
().
string
(),
dpi
,
pad
);
}
catch
(
Error
&
e
)
{
Error
(
"OffScreenPlotManager"
,
"savePlot"
,
"Failed create 1d plot"
,
plotkey
.
str
());
}
try
{
plot
::
offscreen
::
OffScreenPlot1D
plot
(
0
,
*
figure
,
plotkey
.
str
(),
*
m_Mpl
,
data
);
plot
.
display
();
plot
.
save
(
pbfile
.
parent_path
().
parent_path
().
string
(),
dpi
,
pad
);
}
catch
(
Error
&
e
)
{
Error
(
"OffScreenPlotManager"
,
"savePlot"
,
"Failed create 1d plot"
,
plotkey
.
str
());
}
}
else
{
try
{
...
...
@@ -230,7 +238,7 @@ void OffScreenPlotManager::run(std::string pbfilename, std::string path) {
json
::
LogSender
sender
(
&
data
);
sender
.
postMessage
();
// delete image file
//
boost::filesystem::remove(pngfile);
boost
::
filesystem
::
remove
(
pngfile
);
}
else
{
if
(
m_Remote
==
false
)
{
...
...
@@ -271,6 +279,12 @@ void OffScreenPlotManager::run(std::string pbfilename, std::string path) {
Error
(
"OffScreenPlotManager"
,
"savePlot"
,
"Failed to open temporary file which contains ploty::PlotPropertyDataMessage"
,
pbfilename
);
}
// if (num == 119) {
//// DBGMSG(pbfilename);
// end = chrono::steady_clock::now();
// DBGMSG("Elapse : " << chrono::duration_cast<chrono::milliseconds>(end - start).count() << " ms");
// }
}
}
src/manager/OffScreenPlotManager.h
View file @
ad085027
...
...
@@ -102,6 +102,8 @@ private:
std
::
mutex
m_SpyMutex
;
std
::
mutex
m_MultiplotMutex
;
// std::chrono::time_point<std::chrono::steady_clock> start;
// std::chrono::time_point<std::chrono::steady_clock> end;
// typedef std::unordered_map<uint32, std::thread> ThreadMap;
// ThreadMap m_ThreadMap;
// std::mutex m_ThreadMapMutex;
...
...
src/manager/ThreadPoolManager.cpp
View file @
ad085027
...
...
@@ -87,7 +87,6 @@ void ThreadPoolManager::infiniteLoopFunction() {
m_Job
=
m_Queue
.
front
();
m_Queue
.
pop
();
}
DBGMSG
(
"Execute JOB"
);
m_Job
();
// function<void()> type
}
}
...
...
src/plot/Plot1D.cpp
View file @
ad085027
...
...
@@ -39,6 +39,10 @@ namespace plot {
Plot1D
::
Plot1D
(
uint32
plotid
,
const
std
::
string
&
plotkey
,
view
::
mpl
::
Mpl
&
mpl
,
window
::
PlotWindow
*
plotwindow
,
view
::
mpl
::
MplFigure
&
figure
)
:
Plot
(
plotid
,
plotkey
,
mpl
,
plotwindow
,
figure
,
PlotType
::
PLOT_1D
),
m_MplPlot1D
(
mpl
,
figure
)
{
m_NbPlots
=
0
;
m_ShowTitle
=
true
;
m_ShowXLabel
=
true
;
m_ShowYLabel
=
true
;
m_ShowLegend
=
true
;
}
/*
...
...
@@ -55,7 +59,7 @@ void Plot1D::display() throw (Error) {
//// Creat subplot
////
try
{
m_MplPlot1D
.
subplots
();
m_MplPlot1D
.
subplots
(
m_PlotWindow
==
nullptr
);
}
catch
(
Error
&
e
)
{
throw
Error
(
"Plot1D"
,
"display"
,
"Failed to do subplot"
);
}
...
...
@@ -74,6 +78,7 @@ void Plot1D::display() throw (Error) {
getYData
(
i
);
}
// Check if all colors are the same
for
(
uint32
i
=
0
;
i
<
m_NbPlots
;
++
i
)
{
localplot
(
i
);
}
...
...
@@ -85,129 +90,140 @@ void Plot1D::display() throw (Error) {
*/
void
Plot1D
::
localplot
(
uint32
numplot
)
throw
(
Error
)
{
////
//// Set plot parameters
////
string
label
=
getLegendKey
(
numplot
);
string
color
=
string
(
"#"
)
+
getColor
(
numplot
);
////
//// Plot arrays
////
if
(
m_PlotXArrays
[
numplot
].
size
()
==
m_PlotYArrays
[
numplot
].
size
())
{
if
((
m_PlotXPropertyTypes
[
numplot
]
==
"int32array"
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"int32array"
))
{
try
{
plot
(
numplot
,
m_PlotXArrays
[
numplot
],
m_PlotYArrays
[
numplot
],
label
,
color
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot data"
,
"x = int32array , y = int32array"
);
if
((
m_PlotXArrays
[
numplot
].
size
()
!=
0
)
&&
(
m_PlotYArrays
[
numplot
].
size
()
!=
0
))
{
////
//// Set plot parameters
////
string
label
=
getLegendKey
(
numplot
);
string
color
=
string
(
"#"
)
+
getColor
(
numplot
);
////
//// Plot arrays
////
if
(
m_PlotXArrays
[
numplot
].
size
()
==
m_PlotYArrays
[
numplot
].
size
())
{
if
((
m_PlotXPropertyTypes
[
numplot
]
==
"int32array"
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"int32array"
))
{
try
{
plot
(
numplot
,
m_PlotXArrays
[
numplot
],
m_PlotYArrays
[
numplot
],
label
,
color
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot data"
,
"x = int32array , y = int32array"
);
}
}
else
if
((
m_PlotXPropertyTypes
[
numplot
]
==
"float64array"
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"float64array"
))
{
try
{
plot
(
numplot
,
m_PlotXArrays
[
numplot
],
m_PlotYArrays
[
numplot
],
label
,
color
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot data"
,
"x = float64array , y = float64array"
);
}
}
else
if
((
m_PlotXPropertyTypes
[
numplot
]
==
"int32array"
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"float64array"
))
{
try
{
plot
(
numplot
,
m_PlotXArrays
[
numplot
],
m_PlotYArrays
[
numplot
],
label
,
color
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot data"
,
"x = int32array , y = float64array"
);
}
}
else
if
((
m_PlotXPropertyTypes
[
numplot
]
==
"float64array"
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"int32array"
))
{
try
{
plot
(
numplot
,
m_PlotXArrays
[
numplot
],
m_PlotYArrays
[
numplot
],
label
,
color
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot data"
,
"x = float64array , y = int32array"
);
}
}
else
if
((
m_PlotXPropertyTypes
[
numplot
].
empty
()
==
true
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"float64array"
))
{
try
{
plot
(
numplot
,
m_PlotYArrays
[
numplot
],
label
,
color
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot data"
,
"y = float64array"
);
}
}
}
else
if
((
m_PlotXPropertyTypes
[
numplot
]
==
"float64array"
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"float64array"
))
{
}
///////////////////////////////////////////////////////////////////////////////////////
//// optimization Plot if there is
////
try
{
optimizationPlot
(
numplot
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot optimization y"
);
}
try
{
optimizationResult
(
numplot
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot optimization result"
);
}
///////////////////////////////////////////////////////////////////////////////////////
//// Set Title
////
if
(
m_ShowTitle
==
true
)
{
string
title
=
getPlotTitle
();
try
{
plot
(
numplot
,
m_PlotXArrays
[
numplot
],
m_PlotYArrays
[
numplot
],
label
,
color
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot
data"
,
"x = float64array , y = float64array"
);
m_MplPlot1D
.
title
(
title
);
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to
set
plot
title"
,
title
);
}
}
else
if
((
m_PlotXPropertyTypes
[
numplot
]
==
"int32array"
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"float64array"
))
{
if
(
m_PlotWindow
!=
nullptr
)
{
title
=
getWindowTitle
();
try
{
m_PlotWindow
->
setWindowTitle
(
title
);
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to set window title"
,
title
);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////
//// Set x label
////
if
(
m_ShowXLabel
==
true
)
{
string
xlabel
=
getXLabel
();
try
{
plot
(
numplot
,
m_PlotXArrays
[
numplot
],
m_PlotYArrays
[
numplot
],
label
,
color
);
m_MplPlot1D
.
xlabel
(
xlabel
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to
plot data"
,
"x = int32array , y = float64array"
);
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to
set x label"
,
xlabel
);
}
}
else
if
((
m_PlotXPropertyTypes
[
numplot
]
==
"float64array"
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"int32array"
))
{
}
///////////////////////////////////////////////////////////////////////////////////////
//// Set y label
////
if
(
m_ShowYLabel
==
true
)
{
string
ylabel
=
getYLabel
();
try
{
plot
(
numplot
,
m_PlotXArrays
[
numplot
],
m_PlotYArrays
[
numplot
],
label
,
color
);
m_MplPlot1D
.
ylabel
(
ylabel
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to
plot data"
,
"x = float64array , y = int32array"
);
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to
set y label"
,
ylabel
);
}
}
else
if
((
m_PlotXPropertyTypes
[
numplot
].
empty
()
==
true
)
&&
(
m_PlotYPropertyTypes
[
numplot
]
==
"float64array"
))
{
}
///////////////////////////////////////////////////////////////////////////////////////
//// set legend
////
if
(
m_ShowLegend
==
true
)
{
try
{
plot
(
numplot
,
m_PlotYArrays
[
numplot
],
label
,
colo
r
);
m_MplPlot1D
.
legend
(
"xx-small"
,
"upper right"
,
m_PlotWindow
==
nullpt
r
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to
plot data"
,
"y = float64array
"
);
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to
create plot legend
"
);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////
//// optimization Plot if there is
////
try
{
optimizationPlot
(
numplot
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot optimization y"
);
}
try
{
optimizationResult
(
numplot
);
}
catch
(
Error
&
e
)
{
Error
(
"Plot1D"
,
"localplot"
,
"Failed to plot optimization result"
);
}
///////////////////////////////////////////////////////////////////////////////////////
//// Set Title
////
string
title
=
getPlotTitle
();
try
{
m_MplPlot1D
.
title
(
title
);
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to set plot title"
,
title
);
}
if
(
m_PlotWindow
!=
nullptr
)
{
title
=
getWindowTitle
();
///////////////////////////////////////////////////////////////////////////////////////
//// check grid
////
try
{
m_PlotWindow
->
setWindowTitle
(
title
);
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to set window title"
,
title
);
}
}
///////////////////////////////////////////////////////////////////////////////////////
//// Set x label
////
string
xlabel
=
getXLabel
();
try
{
m_MplPlot1D
.
xlabel
(
xlabel
);
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to set x label"
,
xlabel
);
}
///////////////////////////////////////////////////////////////////////////////////////
//// Set y label
////
string
ylabel
=
getYLabel
();
try
{
m_MplPlot1D
.
ylabel
(
ylabel
);
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to set y label"
,
ylabel
);
}
///////////////////////////////////////////////////////////////////////////////////////
//// set legend
////
try
{
m_MplPlot1D
.
legend
(
"xx-small"
,
"upper right"
);
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to create plot legend"
);
}
///////////////////////////////////////////////////////////////////////////////////////
//// check grid
////
try
{
if
(
m_PlotWindow
!=
nullptr
)
{
grid
(
m_PlotWindow
->
gridActivated
());
if
(
m_PlotWindow
!=
nullptr
)
{
grid
(
m_PlotWindow
->
gridActivated
());
}
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to show plot grid"
);
}
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to show plot grid"
);
}
///////////////////////////////////////////////////////////////////////////////////////
//// check log
////
try
{
if
(
m_PlotWindow
!=
nullptr
)
{
log
(
m_PlotWindow
->
logActivated
());
///////////////////////////////////////////////////////////////////////////////////////
//// check log
////
try
{
if
(
m_PlotWindow
!=
nullptr
)
{
log
(
m_PlotWindow
->
logActivated
());
}
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to activate log"
);
}
}
catch
(
Error
&
e
)
{
Warning
(
"Plot1D"
,
"localplot"
,
"Failed to activate log"
);
}
}
...
...
@@ -379,7 +395,6 @@ vector<Stats> Plot1D::updateStats(const RectangleCoord& rect) throw (Error) {
*/
void
Plot1D
::
dismissStats
()
throw
(
Error
)
{
m_MplPlot1D
.
dismissFitPlots
();
m_PlotWindow
->
repaint
();
Plot
::
dismissStats
();
}
...
...
@@ -437,11 +452,14 @@ vector<FitGaussianStats> Plot1D::updateGaussianFitStats(const RectangleCoord& re
for
(
auto
val
:
fitData
.
fitydata
())
{
y
.
push_back
(
val
);
}
m_MplPlot1D
.
fitPlot
((
uint32
)
i
,
xfit
,
y
,
"Fit Gaussian"
,
string
(
"#0ef139"
),
0.5
);
ostringstream
fitname
;
fitname
<<
"Fit Gaussian "
<<
getLegendKey
((
uint32
)
i
);
vector
<
string
>
colors
=
{
"#0ef139"
,
"#1ef149"
,
"#2ef159"
,
"#3ef169"
,
"#4ef179"
,
"#5ef189"
,
"#6ef199"
,
"#7ef1A9"
};
m_MplPlot1D
.
fitPlot
((
uint32
)
i
,
xfit
,
y
,
fitname
.
str
(),
colors
[
i
],
0.5
);
buf
.
push_back
(
stats
);
}
else
{
m_MplPlot1D
.
dismissFitPlot
s
();
m_MplPlot1D
.
dismissFitPlot
(
(
uint32
)
i
);
m_PlotWindow
->
repaint
();
}
}
...
...
@@ -503,11 +521,14 @@ vector<FitGaussianStats> Plot1D::updateMultiGaussianFitStats(const RectangleCoor
for
(
auto
val
:
fitData
.
fitydata
())
{
y
.
push_back
(
val
);
}
m_MplPlot1D
.
fitPlot
((
uint32
)
i
,
xfit
,
y
,
"Fit Multi Gaussian"
,
string
(
"#0ef139"
),
0.5
);
ostringstream
fitname
;
fitname
<<
"Fit Multi Gaussian "
<<
getLegendKey
((
uint32
)
i
);
vector
<
string
>
colors
=
{
"#0ef139"
,
"#1ef149"
,
"#2ef159"
,
"#3ef169"
,
"#4ef179"
,
"#5ef189"
,
"#6ef199"
,
"#7ef1A9"
};
m_MplPlot1D
.
fitPlot
((
uint32
)
i
,
xfit
,
y
,
fitname
.
str
(),
colors
[
i
],
0.5
);
buf
.
push_back
(
stats
);
}
else
{
m_MplPlot1D
.
dismissFitPlot
s
();
m_MplPlot1D
.
dismissFitPlot
(
(
uint32
)
i
);
m_PlotWindow
->
repaint
();
}
}
...
...
@@ -568,11 +589,14 @@ vector<CenterOfMassStats> Plot1D::updateCenterOfMassStats(const RectangleCoord&
for
(
auto
val
:
fitData
.
fitydata
())
{
y
.
push_back
(
val
);
}
m_MplPlot1D
.
fitPlot
((
uint32
)
i
,
xfit
,
y
,
"Center Of Mass"
,
string
(
"#0ef139"
),
0.5
);
ostringstream
fitname
;
fitname
<<
"Center Of Mass "
<<
getLegendKey
((
uint32
)
i
);
vector
<
string
>
colors
=
{
"#0ef139"
,
"#1ef149"
,
"#2ef159"
,
"#3ef169"
,
"#4ef179"
,
"#5ef189"
,
"#6ef199"
,
"#7ef1A9"
};
m_MplPlot1D
.
fitPlot
((
uint32
)
i
,
xfit
,
y
,
fitname
.
str
(),
colors
[
i
],
0.5
);
buf
.
push_back
(
stats
);
}
else
{
m_MplPlot1D
.
dismissFitPlot
s
();
m_MplPlot1D
.
dismissFitPlot
(
(
uint32
)
i
);
m_PlotWindow
->
repaint
();
}
}
...
...
src/plot/Plot1D.h
View file @
ad085027
...
...
@@ -198,19 +198,19 @@ protected:
* \brief Get Data array this index
* \param[in] index The index in the data array of array
*/
virtual
void
getDataArray
(
int32
index
)
=
0
;
virtual
void
getDataArray
(
u
int32
index
)
=
0
;
/*!
* \brief Get X data
* \param[in] index The index in the x data array of array
*/
virtual
void
getXData
(
int32
index
)
=
0
;
virtual
void
getXData
(
u
int32
index
)
=
0
;
/*!
* \brief Get Y data
* \param[in] index The index in the y data array of array
*/
virtual
void
getYData
(
int32
index
)
=
0
;
virtual
void
getYData
(
u
int32
index
)
=
0
;
/*!
* \brief plot data with one dimension (y)
...
...
@@ -304,6 +304,11 @@ protected:
view
::
mpl
::
MplPlot1D
m_MplPlot1D
;
//! Mpl plot1d view object
bool
m_ShowTitle
;
//! Show Plot Title flag
bool
m_ShowXLabel
;
//! Show plot x label flag
bool
m_ShowYLabel
;
//! Show plot y label flag
bool
m_ShowLegend
;
//! Show plor legend flag
};
}
...
...
src/plot/Plot2D.cpp
View file @
ad085027
...
...
@@ -37,14 +37,18 @@ namespace plot {
/*
* constructor
*/
Plot2D
::
Plot2D
(
uint32
plotid
,
const
std
::
string
&
plotkey
,
view
::
mpl
::
Mpl
&
mpl
,
window
::
PlotWindow
*
plotwindow
,
view
::
mpl
::
MplFigure
&
figure
,
bool
doProjections
)
:
Plot
(
plotid
,
plotkey
,
mpl
,
plotwindow
,
figure
,
PlotType
::
PLOT_2D
),
m_MplPlot2D
(
mpl
,
figure
)
,
m_DoProjections
(
doProjections
)
{
Plot2D
::
Plot2D
(
uint32
plotid
,
const
std
::
string
&
plotkey
,
view
::
mpl
::
Mpl
&
mpl
,
window
::
PlotWindow
*
plotwindow
,
view
::
mpl
::
MplFigure
&
figure
)
:
Plot
(
plotid
,
plotkey
,
mpl
,
plotwindow
,
figure
,
PlotType
::
PLOT_2D
),
m_MplPlot2D
(
mpl
,
figure
)
{
m_MinColorLim
=
100.
;
m_MaxColorLim
=
100.
;
m_XPhysicalSize
=
1.
;
m_YPhysicalSize
=
1.
;
m_Space
=
0.1
;
m_Log
=
false
;
m_DoProjections
=
true
;
m_ShowTitle
=
true
;
m_ShowXLabel
=
true
;
m_ShowYLabel
=
true
;
}
/*
...
...
@@ -86,10 +90,10 @@ void Plot2D::display() throw (Error) {
////
try
{
if
(
m_DoProjections
==
true
)
{
m_MplPlot2D
.
subplots
(
m_PlotWindow
!
=
nullptr
,
1
,
4
,
0
,
2
);
m_MplPlot2D
.
subplots
(
m_PlotWindow
=
=
nullptr
,
1
,
4
,
0
,
2
);
}
else
{
m_MplPlot2D
.
subplots
(
m_PlotWindow
!
=
nullptr
,
0
);
m_MplPlot2D