This commit is contained in:
maliakal_d 2019-07-15 15:46:38 +02:00
parent 0f2641f9fa
commit 4f5b8c17b2
7 changed files with 65 additions and 64 deletions

View File

@ -9,7 +9,7 @@ class qCloneWidget;
class QGridLayout;
class QGroupBox;
class QwtSymbol;
#include <QFutureWatcher>
class qDrawPlot : public QWidget {
@ -75,7 +75,6 @@ class qDrawPlot : public QWidget {
void SetupPlots();
int LockLastImageArray();
int UnlockLastImageArray();
void SetStyleandSymbol(SlsQtH1D *h);
void GetStatistics(double &min, double &max, double &sum);
void DetachHists();
static void GetProgressCallBack(double currentProgress, void *this_pointer);
@ -141,8 +140,6 @@ class qDrawPlot : public QWidget {
int currentPersistency{0};
bool isLines{true};
bool isMarkers{false};
QwtSymbol *marker{nullptr};
QwtSymbol *noMarker{nullptr};
bool isPedestal{false};
double *pedestalVals{nullptr};
double *tempPedestalVals{nullptr};

View File

@ -13,6 +13,11 @@
#ifndef SLSQT1DPLOT_H
#define SLSQT1DPLOT_H
typedef double double32_t;
typedef float float32_t;
typedef int int32_t;
#include "ansi.h"
@ -26,6 +31,7 @@
class QPen;
class SlsQt1DPlot;
class QwtSymbol;
class SlsQtH1D:public QwtPlotCurve{
@ -40,6 +46,8 @@ class SlsQtH1D:public QwtPlotCurve{
int SetLineColor(int c=-1);
int SetLineWidth(int w=1);
void SetLineStyle(int s=0);
void setStyleLinesorDots(bool isLines);
void setSymbolMarkers(bool isMarker);
void SetData(int n, double xmin, double xmax, double* d=0);
void SetData(int n, double* dx, double* dy);
@ -72,7 +80,6 @@ class SlsQtH1D:public QwtPlotCurve{
double *x,*y;
double ymin,ymax;
double firstXgt0,firstYgt0;
void Initailize();
int SetUpArrays(int n);
int CheckIndex(int bx);
@ -120,8 +127,8 @@ class SlsQt1DPlot:public QwtPlot{
/** This group of functions have been added by Dhanya on 19.06.2012 to be able to
use zooming functionality without mouse control*/
void DisableZoom(bool disable);
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);};
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);};
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);Update();};
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);Update();};
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);};
void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);};
double GetXMinimum(){return hist_list->Hist()->GetXMin();};

View File

@ -50,10 +50,9 @@ class SlsQt1DZoomer:public QwtPlotZoomer{
#if QWT_VERSION<0x060000
virtual QwtText trackerText(const QwtDoublePoint &pos) const{
#elif QWT_VERSION==0x060000
virtual QwtText trackerText(const QPointF &pos) const{
#else
virtual QwtText trackerTextF(const QPointF &pos) const{
using QwtPlotPicker::trackerText;
virtual QwtText trackerText(const QPoint &pos) const{
#endif
QColor bg(Qt::white);
@ -64,8 +63,7 @@ class SlsQt1DZoomer:public QwtPlotZoomer{
#if QWT_VERSION<0x060000
QwtText text = QwtPlotZoomer::trackerText(pos);
#else
QPoint p=pos.toPoint();
QwtText text = QwtPlotZoomer::trackerText(p);
QwtText text = QwtPlotPicker::trackerText(pos);
#endif
text.setBackgroundBrush( QBrush( bg ));
return text;

View File

@ -14,6 +14,7 @@
#include <qwt_scale_draw.h>
#include <qwt_scale_engine.h>
#include <qwt_scale_widget.h>
#include "qwt_symbol.h"
#include <stdlib.h>
#if QWT_VERSION >= 0x060100
@ -124,6 +125,23 @@ void SlsQtH1D::SetLineStyle(int s) {
setPen(*pen_ptr);
}
void SlsQtH1D::setStyleLinesorDots(bool isLines) {
setStyle(isLines ? QwtPlotCurve::Lines : QwtPlotCurve::Dots);
}
void SlsQtH1D::setSymbolMarkers(bool isMarker) {
QwtSymbol* marker = new QwtSymbol();
if (isMarker) {
marker->setStyle(QwtSymbol::Cross);
marker->setSize(5, 5);
}
#if QWT_VERSION < 0x060000
setSymbol(*marker);
#else
setSymbol(marker);
#endif
}
void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
n = SetUpArrays(n);

View File

@ -9,7 +9,6 @@
#include <QLabel>
#include <QFileDialog>
#include <QPainter>
#include "qwt_symbol.h"
#include <QtConcurrentRun>
@ -17,6 +16,7 @@
qDrawPlot::qDrawPlot(QWidget *parent, multiSlsDetector *detector)
: QWidget(parent), myDet(detector) {
SetupWidgetWindow();
FILE_LOG(logINFO) << "Plots ready";
}
qDrawPlot::~qDrawPlot() {
@ -60,10 +60,6 @@ qDrawPlot::~qDrawPlot() {
delete layout;
if (plotLayout)
delete plotLayout;
if (marker)
delete marker;
if (noMarker)
delete noMarker;
if (widgetStatistics)
delete widgetStatistics;
if (lblMinDisp)
@ -83,12 +79,6 @@ void qDrawPlot::SetupWidgetWindow() {
lblFrameIndexTitle1d = new QLabel("");
lblFrameIndexTitle1d->setFixedHeight(10);
// marker
marker = new QwtSymbol();
marker->setStyle(QwtSymbol::Cross);
marker->setSize(5, 5);
noMarker = new QwtSymbol();
// save
try {
std::string temp = myDet->getFilePath();
@ -180,39 +170,37 @@ void qDrawPlot::SetupPlots() {
boxPlot->setFlat(true);
boxPlot->setContentsMargins(0, 15, 0, 0);
// setup 1d plot
plot1d = new SlsQt1DPlot(boxPlot);
plot1d->setFont(QFont("Sans Serif", 9, QFont::Normal));
plot1d->SetXTitle(xTitle1d.toAscii().constData());
plot1d->SetYTitle(yTitle1d.toAscii().constData());
plot1d->hide();
// setup data
// setup 1d data
if (datax1d)
delete[] datax1d;
datax1d = new double[nPixelsX];
for (auto &it : datay1d) {
delete[] it;
}
if (datay1d.size()) {
for (auto &it : datay1d) {
delete[] it;
}
datay1d.clear();
}
datay1d.push_back(new double[nPixelsX]);
// default display data
for (unsigned int px = 0; px < nPixelsX; ++px) {
datax1d[px] = px;
datay1d[0][px] = px;
datay1d[0][px] = 0;
}
// add a hist
SlsQtH1D *h = new SlsQtH1D("", nPixelsX, datax1d, datay1d[0]);
h->SetLineColor(0);
SetStyleandSymbol(h);
h->setStyleLinesorDots(isLines);
h->setSymbolMarkers(isMarkers);
hists1d.append(h);
// setup 1d plot
plot1d = new SlsQt1DPlot(boxPlot);
plot1d->setFont(QFont("Sans Serif", 9, QFont::Normal));
plot1d->SetXTitle(xTitle1d.toAscii().constData());
plot1d->SetYTitle(yTitle1d.toAscii().constData());
plot1d->hide();
h->Attach(plot1d);
plot1d->DisableZoom(true);
// setup 2d plot
plot2d = new SlsQt2DPlotLayout(boxPlot);
// default display data
// setup 2d data
if (data2d)
delete [] data2d;
data2d = new double[nPixelsY * nPixelsX];
@ -223,17 +211,6 @@ void qDrawPlot::SetupPlots() {
pow(nPixelsX / 2, 2) / pow(1 + 1, 2) +
pow(double(py) - nPixelsY / 2, 2) / pow(nPixelsY / 2, 2)) /
sqrt(2);
plot2d->setFont(QFont("Sans Serif", 9, QFont::Normal));
plot2d->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
-0.5, nPixelsY - 0.5, data2d);
plot2d->setTitle("");
plot2d->SetXTitle(xTitle2d);
plot2d->SetYTitle(yTitle2d);
plot2d->SetZTitle(zTitle2d);
plot2d->setAlignment(Qt::AlignLeft);
// gainplot
gainplot2d = new SlsQt2DPlotLayout(boxPlot);
if (gainData)
delete [] gainData;
gainData = new double[nPixelsY * nPixelsX];
@ -244,6 +221,17 @@ void qDrawPlot::SetupPlots() {
pow(nPixelsX / 2, 2) / pow(1 + 1, 2) +
pow(double(py) - nPixelsY / 2, 2) / pow(nPixelsY / 2, 2)) /
sqrt(2);
// setup 2d plot
plot2d = new SlsQt2DPlotLayout(boxPlot);
plot2d->setFont(QFont("Sans Serif", 9, QFont::Normal));
plot2d->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
-0.5, nPixelsY - 0.5, data2d);
plot2d->setTitle("");
plot2d->SetXTitle(xTitle2d);
plot2d->SetYTitle(yTitle2d);
plot2d->SetZTitle(zTitle2d);
plot2d->setAlignment(Qt::AlignLeft);
gainplot2d = new SlsQt2DPlotLayout(boxPlot);
gainplot2d->setFont(QFont("Sans Serif", 9, QFont::Normal));
gainplot2d->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
-0.5, nPixelsY - 0.5, gainData);
@ -280,23 +268,23 @@ int64_t qDrawPlot::GetCurrentFrameIndex() {
void qDrawPlot::Select1dPlot(bool enable) {
if (enable) {
is1d = true;
// DetachHists(); it clears the last measurement
plot1d->SetXTitle(xTitle1d.toAscii().constData());
plot1d->SetYTitle(yTitle1d.toAscii().constData());
plot1d->show();
plot2d->hide();
boxPlot->setFlat(false);
is1d = true;
layout->addWidget(lblFrameIndexTitle1d, 0, 0);
plotLayout->setContentsMargins(10, 10, 10, 10);
} else {
is1d = false;
plot2d->SetXTitle(xTitle2d);
plot2d->SetYTitle(yTitle2d);
plot2d->SetZTitle(zTitle2d);
plot1d->hide();
plot2d->show();
boxPlot->setFlat(true);
is1d = false;
lblFrameIndexTitle1d->setText("");
layout->removeWidget(lblFrameIndexTitle1d);
plotLayout->setContentsMargins(0, 0, 0, 0);
@ -405,7 +393,7 @@ void qDrawPlot::SetLines(bool enable) {
isLines = enable;
for (unsigned int i = 0; i < nHists; ++i) {
SlsQtH1D* h = hists1d.at(i);
SetStyleandSymbol(h);
h->setStyleLinesorDots(isLines);
}
}
@ -415,7 +403,7 @@ void qDrawPlot::SetMarkers(bool enable) {
isMarkers = enable;
for (unsigned int i = 0; i < nHists; ++i) {
SlsQtH1D* h = hists1d.at(i);
SetStyleandSymbol(h);
h->setSymbolMarkers(isMarkers);
}
}
@ -575,14 +563,6 @@ void qDrawPlot::SavePlot() {
}
}
void qDrawPlot::SetStyleandSymbol(SlsQtH1D *h) {
h->setStyle(isLines ? QwtPlotCurve::Lines : QwtPlotCurve::Dots);
#if QWT_VERSION < 0x060000
h->setSymbol(isMarkers ? *marker : *noMarker);
#else
h->setSymbol(isMarkers ? marker : noMarker);
#endif
}
void qDrawPlot::GetStatistics(double &min, double &max, double &sum) {
FILE_LOG(logDEBUG) << "Calculating Statistics";
@ -796,7 +776,8 @@ void qDrawPlot::Get1dData(double* rawData) {
datay1d.push_back(new double [nPixelsX]);
SlsQtH1D* h = new SlsQtH1D("", nPixelsX, datax1d, datay1d[i]);
h->SetLineColor(i);
SetStyleandSymbol(h);
h->setStyleLinesorDots(isLines);
h->setSymbolMarkers(isMarkers);
hists1d.append(h);
}
// copy previous data

View File

@ -7,4 +7,4 @@
#define APICTB 0x190604
#define APIEIGER 0x190712
#define APIJUNGFRAU 0x190712
#define APIGOTTHARD 0x190712
#define APIGOTTHARD 0x190715