12 #include "ui_WolmanCustomPlot.h"
15 const Eigen::Array3d& dq_final,
16 const Eigen::Array3d& edq)
18 setProperty(
"TypeOfCustomPlot",
"WolmanCustomPlot");
22 setWindowTitle(
"Wolman");
29 int nSamples = d_sample.size();
30 QVector<double> x_data(nSamples);
31 for (
int k = 0; k < nSamples; k++) {
32 x_data[k] = d_sample(k);
34 while (x_data.contains(0.)) {
35 int index = x_data.indexOf(0.);
36 std::cout <<
"[WolmanCustomPlot::WolmanCustomPlot] remove null "
38 << QString::number(index).toStdString() <<
std::endl;
41 std::sort(x_data.begin(), x_data.end());
44 int nValidSamples = x_data.size();
45 QVector<double> y_data(nValidSamples);
46 for (
int k = 0; k < nValidSamples; k++) {
48 (
static_cast<double>(k)) /
static_cast<double>(nValidSamples);
51 m_graph->setData(x_data, y_data);
54 this->xAxis->setScaleType(QCPAxis::stLogarithmic);
55 this->xAxis->setLabel(
"Diameter [mm]");
56 this->yAxis->setLabel(
"CDF");
59 QCPGraph* errorBarsGraph = this->addGraph();
60 errorBarsGraph->setData(
61 QVector<double>({dq_final[0], dq_final[1], dq_final[2]}),
62 QVector<double>({0.1, 0.5, 0.9}));
63 errorBarsGraph->setLineStyle(QCPGraph::lsNone);
64 errorBarsGraph->setScatterStyle(
65 QCPScatterStyle(QCPScatterStyle::ssCircle, 4));
66 QCPErrorBars* errorBars =
new QCPErrorBars(xAxis, yAxis);
67 errorBars->removeFromLegend();
68 errorBars->setAntialiased(
false);
69 errorBars->setDataPlottable(errorBarsGraph);
70 errorBars->setErrorType(QCPErrorBars::etKeyError);
72 errorBars->setPen(pen);
73 errorBars->setData(QVector<double>({edq[0], edq[1], edq[2]}));
74 errorBars->setPen(QPen(QColor(
Qt::red)));
75 errorBars->rescaleAxes(
true);
77 setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
89 if (
event->button() == Qt::LeftButton) {
92 QCustomPlot::mouseDoubleClickEvent(
event);
96 if (
event->button() == Qt::RightButton) {
97 QMenu* menu =
new QMenu(
this);
98 QAction* action =
new QAction(
"Close tab");
99 menu->addAction(action);
100 connect(action, &QAction::triggered,
this,
102 menu->popup(
event->globalPos());
104 QCustomPlot::mousePressEvent(
event);
void mouseDoubleClickEvent(QMouseEvent *event) override
void mousePressEvent(QMouseEvent *event) override
WolmanCustomPlot(const Eigen::ArrayXf &d_sample, const Eigen::Array3d &dq_final, const Eigen::Array3d &edq)
QTextStream & endl(QTextStream &stream)
constexpr Rgb red(MAX, 0, 0)