mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
Merge pull request #85 from slsdetectorgroup/qwtifdef
Version defs and checking pointer before delete
This commit is contained in:
commit
013836bea5
@ -167,7 +167,7 @@ endif (SLS_USE_RECEIVER)
|
||||
|
||||
if (SLS_USE_GUI)
|
||||
find_package(Qt4 REQUIRED)
|
||||
find_package(Qwt 6 REQUIRED)
|
||||
find_package(Qwt 6.1 REQUIRED)
|
||||
if (QT4_FOUND AND QWT_FOUND)
|
||||
add_subdirectory(slsDetectorGui)
|
||||
endif()
|
||||
|
@ -20,11 +20,7 @@ class SlsQt1DZoomer:public QwtPlotZoomer{
|
||||
bool xIsLog,yIsLog;
|
||||
|
||||
public:
|
||||
#if QWT_VERSION < 0x060100
|
||||
SlsQt1DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
|
||||
#else
|
||||
SlsQt1DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
||||
#endif
|
||||
SlsQt1DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
||||
setTrackerMode(AlwaysOn);
|
||||
xIsLog=yIsLog=0;
|
||||
}
|
||||
@ -48,25 +44,15 @@ class SlsQt1DZoomer:public QwtPlotZoomer{
|
||||
bool SetLogY(bool yes) { return yIsLog=yes;}
|
||||
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
virtual QwtText trackerText(const QwtDoublePoint &pos) const{
|
||||
#else
|
||||
using QwtPlotPicker::trackerText;
|
||||
|
||||
using QwtPlotPicker::trackerText;
|
||||
virtual QwtText trackerText(const QPoint &pos) const{
|
||||
#endif
|
||||
QColor bg(Qt::white);
|
||||
|
||||
#if QT_VERSION >= 0x040300
|
||||
bg.setAlpha(200);
|
||||
#endif
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
QwtText text = QwtPlotZoomer::trackerText(pos);
|
||||
#else
|
||||
QwtText text = QwtPlotPicker::trackerText(pos);
|
||||
#endif
|
||||
text.setBackgroundBrush( QBrush( bg ));
|
||||
return text;
|
||||
QColor bg(Qt::white);
|
||||
bg.setAlpha(200);
|
||||
QwtText text = QwtPlotPicker::trackerText(pos);
|
||||
text.setBackgroundBrush( QBrush( bg ));
|
||||
return text;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -77,9 +77,7 @@ class SlsQt2DHist: public QwtRasterData{
|
||||
return (QwtRasterData*) this;
|
||||
}
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
virtual QwtDoubleInterval range() const{ return QwtDoubleInterval(z_min,z_max);}
|
||||
#else
|
||||
|
||||
virtual QwtInterval range() const{ return QwtInterval(z_min,z_max);}
|
||||
virtual QwtInterval interval(Qt::Axis axis) const {
|
||||
switch (axis){
|
||||
@ -93,7 +91,7 @@ class SlsQt2DHist: public QwtRasterData{
|
||||
return QwtInterval(z_min,z_max);
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -85,13 +85,8 @@ private:
|
||||
|
||||
QwtLinearColorMap* colorMapLinearScale{nullptr};
|
||||
QwtLinearColorMap* colorMapLogScale{nullptr};
|
||||
#if QWT_VERSION<0x060000
|
||||
QwtValueList* contourLevelsLinear{nullptr};
|
||||
QwtValueList* contourLevelsLog{nullptr};
|
||||
#else
|
||||
QList<double> contourLevelsLinear;
|
||||
QList<double> contourLevelsLog;
|
||||
#endif
|
||||
bool disableZoom{false};
|
||||
int isLog;
|
||||
};
|
||||
|
@ -25,11 +25,8 @@ class SlsQt2DZoomer:public QwtPlotZoomer{
|
||||
SlsQt2DHist* hist;
|
||||
|
||||
public:
|
||||
#if QWT_VERSION < 0x060100
|
||||
SlsQt2DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
|
||||
#else
|
||||
|
||||
SlsQt2DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
||||
#endif
|
||||
setTrackerMode(AlwaysOn);
|
||||
}
|
||||
|
||||
@ -38,15 +35,11 @@ class SlsQt2DZoomer:public QwtPlotZoomer{
|
||||
}
|
||||
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
virtual QwtText trackerText(const QwtDoublePoint &pos) const{
|
||||
#else
|
||||
|
||||
virtual QwtText trackerTextF(const QPointF &pos) const{
|
||||
#endif
|
||||
QColor bg(Qt::white);
|
||||
#if QT_VERSION >= 0x040300
|
||||
bg.setAlpha(200);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//QwtText text = QwtPlotZoomer::trackerText(pos);
|
||||
@ -57,12 +50,10 @@ class SlsQt2DZoomer:public QwtPlotZoomer{
|
||||
sprintf(t,"%3.2f, %3.2f, %3.2f",pos.x(),pos.y(),hist->value(pos.x(),pos.y()));
|
||||
text.setText(t);
|
||||
}else {
|
||||
#if QWT_VERSION<0x060000
|
||||
QwtText text = QwtPlotZoomer::trackerText(pos);
|
||||
#else
|
||||
|
||||
QPoint p=pos.toPoint();
|
||||
QwtText text = QwtPlotZoomer::trackerText(p);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
text.setBackgroundBrush( QBrush( bg ));
|
||||
|
@ -17,9 +17,9 @@
|
||||
#include "qwt_symbol.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#if QWT_VERSION >= 0x060100
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
||||
#endif
|
||||
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine //hmm
|
||||
|
||||
|
||||
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
|
||||
Initailize();
|
||||
@ -39,11 +39,11 @@ void SlsQtH1D::Initailize() {
|
||||
}
|
||||
|
||||
SlsQtH1D::~SlsQtH1D() {
|
||||
if (x)
|
||||
|
||||
delete [] x;
|
||||
if (y)
|
||||
|
||||
delete [] y;
|
||||
if (pen_ptr)
|
||||
|
||||
delete pen_ptr;
|
||||
}
|
||||
|
||||
@ -138,11 +138,8 @@ void SlsQtH1D::setSymbolMarkers(bool 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) {
|
||||
@ -173,11 +170,9 @@ void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
|
||||
firstYgt0 = y[i];
|
||||
}
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
setRawData(x, y, ndata);
|
||||
#else
|
||||
|
||||
setRawSamples(x, y, ndata);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
|
||||
@ -206,12 +201,8 @@ void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
|
||||
if (y[b] > 0 && (firstYgt0 < 0 || firstYgt0 > y[b]))
|
||||
firstYgt0 = y[b];
|
||||
}
|
||||
|
||||
// #if QWT_VERSION<0x060000
|
||||
// setRawData(x,y,ndata);
|
||||
// #else
|
||||
setRawSamples(x, y, ndata);
|
||||
// #endif
|
||||
|
||||
}
|
||||
|
||||
int SlsQtH1D::SetUpArrays(int n) {
|
||||
@ -219,9 +210,9 @@ int SlsQtH1D::SetUpArrays(int n) {
|
||||
|
||||
if (n + 1 > n_array) {
|
||||
n_array = n + 1;
|
||||
if (x)
|
||||
|
||||
delete x;
|
||||
if (y)
|
||||
|
||||
delete y;
|
||||
x = new double[n_array];
|
||||
y = new double[n_array];
|
||||
@ -285,7 +276,7 @@ SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) {
|
||||
}
|
||||
|
||||
SlsQtH1DList::~SlsQtH1DList() {
|
||||
if (the_next)
|
||||
|
||||
delete the_next;
|
||||
}
|
||||
|
||||
@ -361,15 +352,15 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||
}
|
||||
|
||||
SlsQt1DPlot::~SlsQt1DPlot() {
|
||||
if (hist_list)
|
||||
|
||||
delete hist_list;
|
||||
if (hline)
|
||||
|
||||
delete hline;
|
||||
if (vline)
|
||||
|
||||
delete vline;
|
||||
if (zoomer)
|
||||
|
||||
delete zoomer;
|
||||
if (panner)
|
||||
|
||||
delete panner;
|
||||
}
|
||||
|
||||
@ -554,45 +545,24 @@ void SlsQt1DPlot::alignScales() {
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::UnknownStuff() {
|
||||
#if QWT_VERSION < 0x060000
|
||||
// Disable polygon clipping
|
||||
//not supported for version 6
|
||||
QwtPainter::setDeviceClipping(false);
|
||||
canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
|
||||
canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
|
||||
#else
|
||||
// We don't need the cache here
|
||||
((QwtPlotCanvas *)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
|
||||
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x040000
|
||||
#ifdef Q_WS_X11
|
||||
// Qt::WA_PaintOnScreen is only supported for X11, but leads
|
||||
// to substantial bugs with Qt 4.2.x/Windows
|
||||
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set
|
||||
void SlsQt1DPlot::DisableZoom(bool disable) {
|
||||
if (disableZoom != disable) {
|
||||
disableZoom = disable;
|
||||
#ifdef VERBOSE
|
||||
if (disable)
|
||||
std::cout << "Disabling zoom\n";
|
||||
else
|
||||
std::cout << "Enabling zoom\n";
|
||||
#endif
|
||||
if (disable) {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||
}
|
||||
if (panner)
|
||||
@ -600,11 +570,7 @@ void SlsQt1DPlot::DisableZoom(bool disable) {
|
||||
} else {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
}
|
||||
if (panner)
|
||||
|
@ -34,43 +34,27 @@ void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y
|
||||
|
||||
if(plot()){
|
||||
if(xIsLog){
|
||||
#if QWT_VERSION < 0x50200
|
||||
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lBound();
|
||||
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->hBound();
|
||||
#elif QWT_VERSION < 0x060100
|
||||
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lowerBound();
|
||||
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->upperBound();
|
||||
#else
|
||||
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound();
|
||||
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom).upperBound();
|
||||
#endif
|
||||
if(xmin_curr<xmin) xmin_curr=xmin;
|
||||
if(xmax_curr>xmin+x_width) xmax_curr=xmin+x_width;
|
||||
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound();
|
||||
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom).upperBound();
|
||||
if(xmin_curr<xmin)
|
||||
xmin_curr=xmin;
|
||||
if(xmax_curr>xmin+x_width)
|
||||
xmax_curr=xmin+x_width;
|
||||
plot()->setAxisScale(QwtPlot::xBottom,xmin_curr,xmax_curr);
|
||||
}
|
||||
if(yIsLog){
|
||||
#if QWT_VERSION < 0x50200
|
||||
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lBound();
|
||||
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->hBound();
|
||||
#elif QWT_VERSION < 0x060100
|
||||
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lowerBound();
|
||||
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->upperBound();
|
||||
#else
|
||||
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
|
||||
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
|
||||
#endif
|
||||
if(ymin_curr<ymin) ymin_curr=ymin;
|
||||
if(ymax_curr>ymin+y_width) ymax_curr=ymin+y_width;
|
||||
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
|
||||
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
|
||||
if(ymin_curr<ymin)
|
||||
ymin_curr=ymin;
|
||||
if(ymax_curr>ymin+y_width)
|
||||
ymax_curr=ymin+y_width;
|
||||
plot()->setAxisScale(QwtPlot::yLeft,ymin_curr,ymax_curr);
|
||||
}
|
||||
plot()->replot();
|
||||
}
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
setZoomBase(QwtDoubleRect(xmin,ymin,x_width,y_width));
|
||||
#else
|
||||
setZoomBase(QRectF(xmin,ymin,x_width,y_width));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void SlsQt1DZoomer::SetZoomBase(SlsQtH1D* h){
|
||||
|
@ -20,7 +20,7 @@ SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, doubl
|
||||
}
|
||||
|
||||
|
||||
SlsQt2DHist::~SlsQt2DHist(){if(data) delete [] data;}
|
||||
SlsQt2DHist::~SlsQt2DHist(){ delete [] data;}
|
||||
|
||||
int SlsQt2DHist::GetBinIndex(int bx, int by){
|
||||
int b = bx*ny+by;
|
||||
@ -55,16 +55,8 @@ void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,doubl
|
||||
if(x_min!=xmin||x_max!=xmax||y_min!=ymin||y_max!=ymax){
|
||||
x_min=xmin;x_max=xmax;
|
||||
y_min=ymin;y_max=ymax;
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
setBoundingRect(QRectF(xmin,ymin,x_max-x_min,y_max-y_min));
|
||||
#else
|
||||
setInterval( Qt::XAxis,QwtInterval(xmin,xmax));
|
||||
setInterval( Qt::YAxis,QwtInterval(ymin,ymax));
|
||||
// setInterval( Qt::ZAxis,QwtInterval(zmin,zmax));
|
||||
//setInterval( Qt::ZAxis,QwtInterval(0.,1.));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if(nbinsx*nbinsy<1){
|
||||
@ -73,7 +65,7 @@ void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,doubl
|
||||
}
|
||||
|
||||
if(nbinsx*nbinsy>nx_array*ny_array){
|
||||
if(data) delete [] data;
|
||||
delete [] data;
|
||||
data = new double [nbinsx*nbinsy+1]; //one for under/overflow bin
|
||||
nx_array = nbinsx;
|
||||
ny_array = nbinsy;
|
||||
@ -107,12 +99,7 @@ void SlsQt2DHist::SetMinMax(double zmin,double zmax){
|
||||
if(z_min>0) z_min/=1.02; else z_min*=1.02;
|
||||
if(z_max>0) z_max*=1.02; else z_max/=1.02;
|
||||
}
|
||||
#if QWT_VERSION<0x060000
|
||||
;
|
||||
#else
|
||||
setInterval( Qt::ZAxis,QwtInterval(z_min,z_max));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
double SlsQt2DHist::GetMean(){
|
||||
@ -131,11 +118,8 @@ double SlsQt2DHist::SetMinimumToFirstGreaterThanZero(){
|
||||
for(int i=0;i<nb;i++){
|
||||
if(data[i]>0 && data[i]<z_min) z_min=data[i];
|
||||
}
|
||||
#if QWT_VERSION<0x060000
|
||||
;
|
||||
#else
|
||||
setInterval( Qt::ZAxis,QwtInterval(z_min,z_max));
|
||||
#endif
|
||||
|
||||
|
||||
return z_min;
|
||||
}
|
||||
|
@ -21,32 +21,21 @@
|
||||
|
||||
|
||||
|
||||
#if QWT_VERSION >= 0x060100
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
||||
#endif
|
||||
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine //hmm remove?
|
||||
|
||||
|
||||
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||
isLog = 0;
|
||||
|
||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
|
||||
|
||||
d_spectrogram = new QwtPlotSpectrogram();
|
||||
|
||||
hist = new SlsQt2DHist();
|
||||
SetupZoom();
|
||||
SetupColorMap();
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setData(*hist);
|
||||
#else
|
||||
d_spectrogram->setData(hist);
|
||||
#endif
|
||||
|
||||
d_spectrogram->attach(this);
|
||||
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
|
||||
FillTestPlot();
|
||||
Update();
|
||||
}
|
||||
@ -57,25 +46,11 @@ SlsQt2DPlot::~SlsQt2DPlot() {
|
||||
d_spectrogram->detach();
|
||||
//delete d_spectrogram;
|
||||
}
|
||||
if (hist) {
|
||||
delete hist;
|
||||
}
|
||||
if (colorMapLinearScale)
|
||||
delete colorMapLinearScale;
|
||||
if (colorMapLogScale)
|
||||
delete colorMapLogScale;
|
||||
|
||||
|
||||
if (zoomer)
|
||||
delete zoomer;
|
||||
if (panner)
|
||||
delete panner;
|
||||
#if QWT_VERSION<0x060000
|
||||
if (contourLevelsLinear)
|
||||
delete contourLevelsLinear;
|
||||
if (contourLevelsLog)
|
||||
delete contourLevelsLog;
|
||||
#endif
|
||||
delete hist;
|
||||
delete colorMapLinearScale;
|
||||
delete colorMapLogScale;
|
||||
delete zoomer;
|
||||
delete panner;
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetTitle(QString title) {
|
||||
@ -120,40 +95,16 @@ void SlsQt2DPlot::SetZFont(const QFont& f) {
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetupColorMap() {
|
||||
|
||||
colorMapLinearScale = myColourMap(0);
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
||||
#else
|
||||
d_spectrogram->setColorMap(colorMapLinearScale);
|
||||
#endif
|
||||
|
||||
colorMapLogScale = myColourMap(1);
|
||||
#if QWT_VERSION < 0x060000
|
||||
contourLevelsLinear = new QwtValueList();
|
||||
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||
(*contourLevelsLinear) += level;
|
||||
d_spectrogram->setContourLevels(*contourLevelsLinear);
|
||||
#else
|
||||
;
|
||||
|
||||
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||
(contourLevelsLinear) += level;
|
||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
||||
#endif
|
||||
|
||||
//
|
||||
#if QWT_VERSION < 0x060000
|
||||
contourLevelsLog = new QwtValueList();
|
||||
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||
(*contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
|
||||
|
||||
#else
|
||||
;
|
||||
|
||||
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||
(contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
|
||||
#endif
|
||||
|
||||
|
||||
// A color bar on the right axis
|
||||
rightAxis = axisWidget(QwtPlot::yRight);
|
||||
@ -225,23 +176,14 @@ void SlsQt2DPlot::SetupZoom() {
|
||||
}*/
|
||||
|
||||
void SlsQt2DPlot::UnZoom(bool replot) {
|
||||
#if QWT_VERSION < 0x060000
|
||||
zoomer->setZoomBase(QwtDoubleRect(hist->GetXMin(), hist->GetYMin(), hist->GetXMax() - hist->GetXMin(), hist->GetYMax() - hist->GetYMin()));
|
||||
#else
|
||||
|
||||
zoomer->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(), hist->GetXMax() - hist->GetXMin(), hist->GetYMax() - hist->GetYMin()));
|
||||
#endif
|
||||
zoomer->setZoomBase(replot); //Call replot for the attached plot before initializing the zoomer with its scales.
|
||||
// zoomer->zoom(0);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) {
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
zoomer->setZoomBase(QwtDoubleRect(xmin, ymin, x_width, y_width));
|
||||
|
||||
#else
|
||||
zoomer->setZoomBase(QRectF(xmin, ymin, x_width, y_width));
|
||||
#endif
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::DisableZoom(bool disable) {
|
||||
@ -330,28 +272,16 @@ QwtLinearColorMap *SlsQt2DPlot::myColourMap(int log) {
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::Update() {
|
||||
#if QWT_VERSION < 0x060000
|
||||
rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap());
|
||||
#else
|
||||
if (isLog)
|
||||
hist->SetMinimumToFirstGreaterThanZero();
|
||||
|
||||
const QwtInterval zInterval = d_spectrogram->data()->interval(Qt::ZAxis);
|
||||
|
||||
rightAxis->setColorMap(zInterval, myColourMap(isLog));
|
||||
#endif
|
||||
|
||||
if (!zoomer->zoomRectIndex())
|
||||
UnZoom();
|
||||
#if QWT_VERSION < 0x060000
|
||||
setAxisScale(QwtPlot::yRight, d_spectrogram->data().range().minValue(),
|
||||
d_spectrogram->data().range().maxValue());
|
||||
#else
|
||||
//cprintf(MAGENTA, "zmin:%f zmax:%f\n", zInterval.minValue(), zInterval.maxValue());
|
||||
setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue());
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
#endif
|
||||
replot();
|
||||
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetInterpolate(bool enable) {
|
||||
@ -387,63 +317,20 @@ void SlsQt2DPlot::SetZRange(bool isMin, bool isMax, double min, double max){
|
||||
void SlsQt2DPlot::LogZ(bool on) {
|
||||
if (on) {
|
||||
isLog = 1;
|
||||
//if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero();
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLogScale);
|
||||
#else
|
||||
d_spectrogram->setColorMap(myColourMap(isLog));
|
||||
#endif
|
||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLog10ScaleEngine);
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setContourLevels(*contourLevelsLog);
|
||||
#else
|
||||
d_spectrogram->setContourLevels(contourLevelsLog);
|
||||
#endif
|
||||
} else {
|
||||
isLog = 0;
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
||||
#else
|
||||
d_spectrogram->setColorMap(myColourMap(isLog));
|
||||
#endif
|
||||
|
||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine);
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setContourLevels(*contourLevelsLinear);
|
||||
#else
|
||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
||||
#endif
|
||||
}
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::showSpectrogram(bool on) {
|
||||
// static int io=0;
|
||||
// FillTestPlot(io++);
|
||||
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on);
|
||||
d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen));
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void SlsQt2DPlot::printPlot(){
|
||||
QPrinter printer;
|
||||
printer.setOrientation(QPrinter::Landscape);
|
||||
#if QT_VERSION < 0x040000
|
||||
printer.setColorMode(QPrinter::Color);
|
||||
printer.setOutputFileName("spectrogram.ps");
|
||||
if (printer.setup())
|
||||
#else
|
||||
printer.setOutputFileName("spectrogram.pdf");
|
||||
QPrintDialog dialog(&printer);
|
||||
if ( dialog.exec() )
|
||||
#endif
|
||||
{
|
||||
print(printer);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
@ -22,13 +22,13 @@ qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot* p1, SlsQt2DPlot* p2, Sl
|
||||
}
|
||||
|
||||
qCloneWidget::~qCloneWidget() {
|
||||
if (plot1d)
|
||||
|
||||
delete plot1d;
|
||||
if (plot2d)
|
||||
|
||||
delete plot2d;
|
||||
if (gainplot1d)
|
||||
|
||||
delete gainplot1d;
|
||||
if (gainplot2d)
|
||||
|
||||
delete gainplot2d;
|
||||
}
|
||||
|
||||
|
@ -20,39 +20,27 @@ qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector) : QWidget(parent)
|
||||
}
|
||||
|
||||
qDrawPlot::~qDrawPlot() {
|
||||
|
||||
DetachHists();
|
||||
for (QVector<SlsQtH1D *>::iterator h = hists1d.begin();
|
||||
h != hists1d.end(); ++h)
|
||||
delete *h;
|
||||
hists1d.clear();
|
||||
h != hists1d.end(); ++h){
|
||||
delete *h;
|
||||
}
|
||||
|
||||
if (datax1d)
|
||||
delete [] datax1d;
|
||||
hists1d.clear();
|
||||
delete [] datax1d;
|
||||
for (auto &it : datay1d)
|
||||
delete [] it;
|
||||
if (gainDatay1d)
|
||||
delete [] gainDatay1d;
|
||||
if (data2d)
|
||||
delete [] data2d;
|
||||
if (gainData)
|
||||
delete [] gainData;
|
||||
|
||||
if (plot1d)
|
||||
delete plot1d;
|
||||
if (gainhist1d)
|
||||
delete gainhist1d;
|
||||
if (gainplot1d)
|
||||
delete gainplot1d;
|
||||
if (plot2d)
|
||||
delete plot2d;
|
||||
if (gainplot2d)
|
||||
delete gainplot2d;
|
||||
|
||||
if (pedestalVals)
|
||||
delete [] pedestalVals;
|
||||
if (tempPedestalVals)
|
||||
delete [] tempPedestalVals;
|
||||
delete [] gainDatay1d;
|
||||
delete [] data2d;
|
||||
delete [] gainData;
|
||||
delete plot1d;
|
||||
delete gainhist1d;
|
||||
delete gainplot1d;
|
||||
delete plot2d;
|
||||
delete gainplot2d;
|
||||
delete [] pedestalVals;
|
||||
delete [] tempPedestalVals;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetupWidgetWindow() {
|
||||
@ -127,7 +115,7 @@ void qDrawPlot::SetupPlots() {
|
||||
widgetStatistics->hide();
|
||||
|
||||
// setup 1d data
|
||||
if (datax1d)
|
||||
|
||||
delete[] datax1d;
|
||||
datax1d = new double[nPixelsX];
|
||||
if (datay1d.size()) {
|
||||
@ -160,7 +148,7 @@ void qDrawPlot::SetupPlots() {
|
||||
h->Attach(plot1d);
|
||||
plot1d->hide();
|
||||
|
||||
if (gainDatay1d)
|
||||
|
||||
delete[] gainDatay1d;
|
||||
gainDatay1d = new double[nPixelsX];
|
||||
// default display data
|
||||
@ -189,7 +177,7 @@ void qDrawPlot::SetupPlots() {
|
||||
gainplot1d->hide();
|
||||
|
||||
// setup 2d data
|
||||
if (data2d)
|
||||
|
||||
delete [] data2d;
|
||||
data2d = new double[nPixelsY * nPixelsX];
|
||||
for (unsigned int px = 0; px < nPixelsX; ++px)
|
||||
@ -199,7 +187,7 @@ void qDrawPlot::SetupPlots() {
|
||||
pow(nPixelsX / 2, 2) / pow(1 + 1, 2) +
|
||||
pow(double(py) - nPixelsY / 2, 2) / pow(nPixelsY / 2, 2)) /
|
||||
sqrt(2);
|
||||
if (gainData)
|
||||
|
||||
delete [] gainData;
|
||||
gainData = new double[nPixelsY * nPixelsX];
|
||||
for (unsigned int px = 0; px < nPixelsX; ++px)
|
||||
@ -714,7 +702,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
|
||||
nPixelsX = data->nx;
|
||||
nPixelsY = data->ny;
|
||||
FILE_LOG(logINFO) << "Change in Detector Shape:\n\tnPixelsX:" << nPixelsX << " nPixelsY:" << nPixelsY;
|
||||
if (data2d)
|
||||
|
||||
delete [] data2d;
|
||||
data2d = new double[nPixelsY * nPixelsX];
|
||||
std::fill(data2d, data2d + nPixelsX * nPixelsY, 0);
|
||||
@ -742,11 +730,11 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
|
||||
// reset pedestal
|
||||
if (resetPedestal) {
|
||||
pedestalCount = 0;
|
||||
if (pedestalVals != nullptr)
|
||||
|
||||
delete [] pedestalVals;
|
||||
pedestalVals = new double[nPixels];
|
||||
std::fill(pedestalVals, pedestalVals + nPixels, 0);
|
||||
if (tempPedestalVals != nullptr)
|
||||
|
||||
delete [] tempPedestalVals;
|
||||
tempPedestalVals = new double[nPixels];
|
||||
std::fill(tempPedestalVals, tempPedestalVals + nPixels, 0);
|
||||
|
@ -17,7 +17,6 @@ qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector) : QWidg
|
||||
}
|
||||
|
||||
qTabDataOutput::~qTabDataOutput() {
|
||||
if (btnGroupRate)
|
||||
delete btnGroupRate;
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,9 @@ qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector) :
|
||||
}
|
||||
|
||||
qTabDebugging::~qTabDebugging() {
|
||||
if (treeDet)
|
||||
delete treeDet;
|
||||
if (lblDetectorHostname)
|
||||
delete lblDetectorHostname;
|
||||
if (lblDetectorFirmware)
|
||||
delete lblDetectorFirmware;
|
||||
if (lblDetectorSoftware)
|
||||
delete lblDetectorSoftware;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ qTabMeasurement::qTabMeasurement(QWidget *parent, sls::Detector *detector, qDraw
|
||||
}
|
||||
|
||||
qTabMeasurement::~qTabMeasurement() {
|
||||
if (progressTimer)
|
||||
delete progressTimer;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,7 @@ qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) {
|
||||
|
||||
qTabMessages::~qTabMessages() {
|
||||
process->close();
|
||||
if (process)
|
||||
delete process;
|
||||
delete process;
|
||||
}
|
||||
|
||||
void qTabMessages::SetupWidgetWindow() {
|
||||
|
@ -27,8 +27,7 @@ qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p) :
|
||||
}
|
||||
|
||||
qTabPlot::~qTabPlot() {
|
||||
if (btnGroupPlotType)
|
||||
delete btnGroupPlotType;
|
||||
delete btnGroupPlotType;
|
||||
}
|
||||
|
||||
void qTabPlot::SetupWidgetWindow() {
|
||||
|
@ -40,12 +40,9 @@ void qTabSettings::SetupWidgetWindow() {
|
||||
SetupDetectorSettings();
|
||||
}
|
||||
spinThreshold->setValue(-1);
|
||||
|
||||
Initialization();
|
||||
|
||||
// default for the disabled
|
||||
GetDynamicRange();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user