improve kfactor support

add per camera gain
add the ability to save plot to vector pdf
add the ability to plot uint8_t mat types
This commit is contained in:
uvos 2021-07-20 23:17:31 +02:00
parent 1b6c3672b6
commit 24646e82ed
12 changed files with 185 additions and 110 deletions

View file

@ -12,7 +12,8 @@ Plot::Plot(QWidget* parent):
actionAdd_Regression("Add regression", nullptr),
actionDelete_Regression("Delete regression", nullptr),
actionExport_Selection("Export selection", nullptr),
actionSetValueString("Set Y Axis Label", nullptr)
actionSetValueString("Set Y Axis Label", nullptr),
savePdfAction("Save to pdf", nullptr)
{
xAxis->setLabel("Coordinate");
yAxis->setLabel("Counts");
@ -50,12 +51,14 @@ Plot::Plot(QWidget* parent):
connect(&actionDelete_Regression, &QAction::triggered, this, &Plot::deleteRegression);
connect(&actionExport_Selection, &QAction::triggered, this, &Plot::saveCsvDiag);
connect(&actionSetValueString, &QAction::triggered, this, &Plot::askForValueString);
connect(&savePdfAction, &QAction::triggered, this, &Plot::savePdf);
graphContextMenu.addAction(&actionStatistics);
graphContextMenu.addAction(&actionAdd_Regression);
graphContextMenu.addAction(&actionDelete_Regression);
graphContextMenu.addAction(&actionExport_Selection);
graphContextMenu.addAction(&actionSetValueString);
graphContextMenu.addAction(&savePdfAction);
}
Plot::~Plot()
@ -63,6 +66,14 @@ Plot::~Plot()
}
void Plot::savePdf()
{
QString fileName = QFileDialog::getSaveFileName(this, "Save graph as PDF", "./", "*.pdf" );
if(!fileName.isEmpty())
QCustomPlot::savePdf(fileName);
}
bool Plot::event(QEvent *event)
{
if(event->type()==QEvent::Gesture) graphContextMenu.show();
@ -78,9 +89,11 @@ void Plot::addMainGraph()
{
addGraph();
graph(graphCount()-1)->setSelectable(QCP::stDataRange);
graph(graphCount()-1)->setPen(QPen(QBrush(QColor(0,0,255,255)),2,Qt::SolidLine));
QPen selectionPen = graph(graphCount()-1)->pen();
selectionPen.setColor(QColor(255,0,0));
graph(graphCount()-1)->selectionDecorator()->setPen(selectionPen);
}
void Plot::clear()
@ -197,7 +210,7 @@ void Plot::deleteRegression()
void Plot::showStatistics()
{
if(graphCount() > 0 && !graph(0)->selection().dataRanges().at(0).isEmpty())
if(graphCount() > 0 && !graph(0)->selection().dataRanges().isEmpty() && !graph(0)->selection().dataRanges().at(0).isEmpty())
{
QCPDataRange dataRange = graph(0)->selection().dataRanges().at(0);
QCPGraphDataContainer::const_iterator begin = graph(0)->data()->at(dataRange.begin());
@ -210,10 +223,10 @@ void Plot::showStatistics()
statDiag.show();
statDiag.exec();
}
else if(graphCount() > 0 && selectedGraphs().size() > 1 && selectedGraphs().at(1) != graph(0))
else if(graphCount() > 0 && selectedGraphs().size() > 0 && selectedGraphs().at(0) != graph(0))
{
unsigned i = 0;
while(selectedGraphs().at(1) != graph(i)) i++;
while(selectedGraphs().at(0) != graph(i)) i++;
RegressionDiag regDiag(regressions.at(i-1), this);
regDiag.show();
regDiag.exec();