mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
WIP
This commit is contained in:
parent
a4fa9ff480
commit
e4a86e544a
@ -20,11 +20,7 @@ class SlsQt1DZoomer:public QwtPlotZoomer{
|
|||||||
bool xIsLog,yIsLog;
|
bool xIsLog,yIsLog;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if QWT_VERSION < 0x060100
|
SlsQt1DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
||||||
SlsQt1DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
|
|
||||||
#else
|
|
||||||
SlsQt1DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
|
||||||
#endif
|
|
||||||
setTrackerMode(AlwaysOn);
|
setTrackerMode(AlwaysOn);
|
||||||
xIsLog=yIsLog=0;
|
xIsLog=yIsLog=0;
|
||||||
}
|
}
|
||||||
@ -48,25 +44,15 @@ class SlsQt1DZoomer:public QwtPlotZoomer{
|
|||||||
bool SetLogY(bool yes) { return yIsLog=yes;}
|
bool SetLogY(bool yes) { return yIsLog=yes;}
|
||||||
|
|
||||||
|
|
||||||
#if QWT_VERSION<0x060000
|
|
||||||
virtual QwtText trackerText(const QwtDoublePoint &pos) const{
|
using QwtPlotPicker::trackerText;
|
||||||
#else
|
|
||||||
using QwtPlotPicker::trackerText;
|
|
||||||
virtual QwtText trackerText(const QPoint &pos) const{
|
virtual QwtText trackerText(const QPoint &pos) const{
|
||||||
#endif
|
|
||||||
QColor bg(Qt::white);
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040300
|
QColor bg(Qt::white);
|
||||||
bg.setAlpha(200);
|
bg.setAlpha(200);
|
||||||
#endif
|
QwtText text = QwtPlotPicker::trackerText(pos);
|
||||||
|
text.setBackgroundBrush( QBrush( bg ));
|
||||||
#if QWT_VERSION<0x060000
|
return text;
|
||||||
QwtText text = QwtPlotZoomer::trackerText(pos);
|
|
||||||
#else
|
|
||||||
QwtText text = QwtPlotPicker::trackerText(pos);
|
|
||||||
#endif
|
|
||||||
text.setBackgroundBrush( QBrush( bg ));
|
|
||||||
return text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -77,9 +77,7 @@ class SlsQt2DHist: public QwtRasterData{
|
|||||||
return (QwtRasterData*) this;
|
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 range() const{ return QwtInterval(z_min,z_max);}
|
||||||
virtual QwtInterval interval(Qt::Axis axis) const {
|
virtual QwtInterval interval(Qt::Axis axis) const {
|
||||||
switch (axis){
|
switch (axis){
|
||||||
@ -93,7 +91,7 @@ class SlsQt2DHist: public QwtRasterData{
|
|||||||
return QwtInterval(z_min,z_max);
|
return QwtInterval(z_min,z_max);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,13 +85,8 @@ private:
|
|||||||
|
|
||||||
QwtLinearColorMap* colorMapLinearScale{nullptr};
|
QwtLinearColorMap* colorMapLinearScale{nullptr};
|
||||||
QwtLinearColorMap* colorMapLogScale{nullptr};
|
QwtLinearColorMap* colorMapLogScale{nullptr};
|
||||||
#if QWT_VERSION<0x060000
|
|
||||||
QwtValueList* contourLevelsLinear{nullptr};
|
|
||||||
QwtValueList* contourLevelsLog{nullptr};
|
|
||||||
#else
|
|
||||||
QList<double> contourLevelsLinear;
|
QList<double> contourLevelsLinear;
|
||||||
QList<double> contourLevelsLog;
|
QList<double> contourLevelsLog;
|
||||||
#endif
|
|
||||||
bool disableZoom{false};
|
bool disableZoom{false};
|
||||||
int isLog;
|
int isLog;
|
||||||
};
|
};
|
||||||
|
@ -25,11 +25,8 @@ class SlsQt2DZoomer:public QwtPlotZoomer{
|
|||||||
SlsQt2DHist* hist;
|
SlsQt2DHist* hist;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if QWT_VERSION < 0x060100
|
|
||||||
SlsQt2DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
|
|
||||||
#else
|
|
||||||
SlsQt2DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
SlsQt2DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
||||||
#endif
|
|
||||||
setTrackerMode(AlwaysOn);
|
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{
|
virtual QwtText trackerTextF(const QPointF &pos) const{
|
||||||
#endif
|
|
||||||
QColor bg(Qt::white);
|
QColor bg(Qt::white);
|
||||||
#if QT_VERSION >= 0x040300
|
|
||||||
bg.setAlpha(200);
|
bg.setAlpha(200);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//QwtText text = QwtPlotZoomer::trackerText(pos);
|
//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()));
|
sprintf(t,"%3.2f, %3.2f, %3.2f",pos.x(),pos.y(),hist->value(pos.x(),pos.y()));
|
||||||
text.setText(t);
|
text.setText(t);
|
||||||
}else {
|
}else {
|
||||||
#if QWT_VERSION<0x060000
|
|
||||||
QwtText text = QwtPlotZoomer::trackerText(pos);
|
|
||||||
#else
|
|
||||||
QPoint p=pos.toPoint();
|
QPoint p=pos.toPoint();
|
||||||
QwtText text = QwtPlotZoomer::trackerText(p);
|
QwtText text = QwtPlotZoomer::trackerText(p);
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
text.setBackgroundBrush( QBrush( bg ));
|
text.setBackgroundBrush( QBrush( bg ));
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
#include "qwt_symbol.h"
|
#include "qwt_symbol.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#if QWT_VERSION >= 0x060100
|
|
||||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
#define QwtLog10ScaleEngine QwtLogScaleEngine //hmm
|
||||||
#endif
|
|
||||||
|
|
||||||
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
|
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
|
||||||
Initailize();
|
Initailize();
|
||||||
@ -138,11 +138,8 @@ void SlsQtH1D::setSymbolMarkers(bool isMarker) {
|
|||||||
marker->setStyle(QwtSymbol::Cross);
|
marker->setStyle(QwtSymbol::Cross);
|
||||||
marker->setSize(5, 5);
|
marker->setSize(5, 5);
|
||||||
}
|
}
|
||||||
#if QWT_VERSION < 0x060000
|
|
||||||
setSymbol(*marker);
|
|
||||||
#else
|
|
||||||
setSymbol(marker);
|
setSymbol(marker);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
|
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];
|
firstYgt0 = y[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QWT_VERSION < 0x060000
|
|
||||||
setRawData(x, y, ndata);
|
|
||||||
#else
|
|
||||||
setRawSamples(x, y, ndata);
|
setRawSamples(x, y, ndata);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
|
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]))
|
if (y[b] > 0 && (firstYgt0 < 0 || firstYgt0 > y[b]))
|
||||||
firstYgt0 = y[b];
|
firstYgt0 = y[b];
|
||||||
}
|
}
|
||||||
|
|
||||||
// #if QWT_VERSION<0x060000
|
|
||||||
// setRawData(x,y,ndata);
|
|
||||||
// #else
|
|
||||||
setRawSamples(x, y, ndata);
|
setRawSamples(x, y, ndata);
|
||||||
// #endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SlsQtH1D::SetUpArrays(int n) {
|
int SlsQtH1D::SetUpArrays(int n) {
|
||||||
@ -554,45 +545,24 @@ void SlsQt1DPlot::alignScales() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt1DPlot::UnknownStuff() {
|
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
|
// We don't need the cache here
|
||||||
((QwtPlotCanvas *)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
|
((QwtPlotCanvas *)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040000
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
// Qt::WA_PaintOnScreen is only supported for X11, but leads
|
// Qt::WA_PaintOnScreen is only supported for X11, but leads
|
||||||
// to substantial bugs with Qt 4.2.x/Windows
|
// to substantial bugs with Qt 4.2.x/Windows
|
||||||
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
|
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set
|
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set
|
||||||
void SlsQt1DPlot::DisableZoom(bool disable) {
|
void SlsQt1DPlot::DisableZoom(bool disable) {
|
||||||
if (disableZoom != disable) {
|
if (disableZoom != disable) {
|
||||||
disableZoom = disable;
|
disableZoom = disable;
|
||||||
#ifdef VERBOSE
|
|
||||||
if (disable)
|
|
||||||
std::cout << "Disabling zoom\n";
|
|
||||||
else
|
|
||||||
std::cout << "Enabling zoom\n";
|
|
||||||
#endif
|
|
||||||
if (disable) {
|
if (disable) {
|
||||||
if (zoomer) {
|
if (zoomer) {
|
||||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
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);
|
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
|
||||||
#endif
|
|
||||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||||
}
|
}
|
||||||
if (panner)
|
if (panner)
|
||||||
@ -600,11 +570,7 @@ void SlsQt1DPlot::DisableZoom(bool disable) {
|
|||||||
} else {
|
} else {
|
||||||
if (zoomer) {
|
if (zoomer) {
|
||||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
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);
|
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||||
#endif
|
|
||||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||||
}
|
}
|
||||||
if (panner)
|
if (panner)
|
||||||
|
@ -34,43 +34,27 @@ void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y
|
|||||||
|
|
||||||
if(plot()){
|
if(plot()){
|
||||||
if(xIsLog){
|
if(xIsLog){
|
||||||
#if QWT_VERSION < 0x50200
|
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound();
|
||||||
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lBound();
|
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom).upperBound();
|
||||||
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->hBound();
|
if(xmin_curr<xmin)
|
||||||
#elif QWT_VERSION < 0x060100
|
xmin_curr=xmin;
|
||||||
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lowerBound();
|
if(xmax_curr>xmin+x_width)
|
||||||
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->upperBound();
|
xmax_curr=xmin+x_width;
|
||||||
#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;
|
|
||||||
plot()->setAxisScale(QwtPlot::xBottom,xmin_curr,xmax_curr);
|
plot()->setAxisScale(QwtPlot::xBottom,xmin_curr,xmax_curr);
|
||||||
}
|
}
|
||||||
if(yIsLog){
|
if(yIsLog){
|
||||||
#if QWT_VERSION < 0x50200
|
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
|
||||||
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lBound();
|
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
|
||||||
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->hBound();
|
if(ymin_curr<ymin)
|
||||||
#elif QWT_VERSION < 0x060100
|
ymin_curr=ymin;
|
||||||
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lowerBound();
|
if(ymax_curr>ymin+y_width)
|
||||||
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->upperBound();
|
ymax_curr=ymin+y_width;
|
||||||
#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;
|
|
||||||
plot()->setAxisScale(QwtPlot::yLeft,ymin_curr,ymax_curr);
|
plot()->setAxisScale(QwtPlot::yLeft,ymin_curr,ymax_curr);
|
||||||
}
|
}
|
||||||
plot()->replot();
|
plot()->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QWT_VERSION<0x060000
|
|
||||||
setZoomBase(QwtDoubleRect(xmin,ymin,x_width,y_width));
|
|
||||||
#else
|
|
||||||
setZoomBase(QRectF(xmin,ymin,x_width,y_width));
|
setZoomBase(QRectF(xmin,ymin,x_width,y_width));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt1DZoomer::SetZoomBase(SlsQtH1D* h){
|
void SlsQt1DZoomer::SetZoomBase(SlsQtH1D* h){
|
||||||
|
@ -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){
|
if(x_min!=xmin||x_max!=xmax||y_min!=ymin||y_max!=ymax){
|
||||||
x_min=xmin;x_max=xmax;
|
x_min=xmin;x_max=xmax;
|
||||||
y_min=ymin;y_max=ymax;
|
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::XAxis,QwtInterval(xmin,xmax));
|
||||||
setInterval( Qt::YAxis,QwtInterval(ymin,ymax));
|
setInterval( Qt::YAxis,QwtInterval(ymin,ymax));
|
||||||
// setInterval( Qt::ZAxis,QwtInterval(zmin,zmax));
|
|
||||||
//setInterval( Qt::ZAxis,QwtInterval(0.,1.));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nbinsx*nbinsy<1){
|
if(nbinsx*nbinsy<1){
|
||||||
@ -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_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(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));
|
setInterval( Qt::ZAxis,QwtInterval(z_min,z_max));
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double SlsQt2DHist::GetMean(){
|
double SlsQt2DHist::GetMean(){
|
||||||
@ -131,11 +118,8 @@ double SlsQt2DHist::SetMinimumToFirstGreaterThanZero(){
|
|||||||
for(int i=0;i<nb;i++){
|
for(int i=0;i<nb;i++){
|
||||||
if(data[i]>0 && data[i]<z_min) z_min=data[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));
|
setInterval( Qt::ZAxis,QwtInterval(z_min,z_max));
|
||||||
#endif
|
|
||||||
|
|
||||||
return z_min;
|
return z_min;
|
||||||
}
|
}
|
||||||
|
@ -21,32 +21,21 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if QWT_VERSION >= 0x060100
|
|
||||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
#define QwtLog10ScaleEngine QwtLogScaleEngine //hmm remove?
|
||||||
#endif
|
|
||||||
|
|
||||||
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
|
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||||
isLog = 0;
|
isLog = 0;
|
||||||
|
|
||||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
||||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
|
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
|
||||||
|
|
||||||
d_spectrogram = new QwtPlotSpectrogram();
|
d_spectrogram = new QwtPlotSpectrogram();
|
||||||
|
|
||||||
hist = new SlsQt2DHist();
|
hist = new SlsQt2DHist();
|
||||||
SetupZoom();
|
SetupZoom();
|
||||||
SetupColorMap();
|
SetupColorMap();
|
||||||
|
|
||||||
#if QWT_VERSION < 0x060000
|
|
||||||
d_spectrogram->setData(*hist);
|
|
||||||
#else
|
|
||||||
d_spectrogram->setData(hist);
|
d_spectrogram->setData(hist);
|
||||||
#endif
|
|
||||||
|
|
||||||
d_spectrogram->attach(this);
|
d_spectrogram->attach(this);
|
||||||
|
|
||||||
plotLayout()->setAlignCanvasToScales(true);
|
plotLayout()->setAlignCanvasToScales(true);
|
||||||
|
|
||||||
FillTestPlot();
|
FillTestPlot();
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
@ -57,25 +46,11 @@ SlsQt2DPlot::~SlsQt2DPlot() {
|
|||||||
d_spectrogram->detach();
|
d_spectrogram->detach();
|
||||||
//delete d_spectrogram;
|
//delete d_spectrogram;
|
||||||
}
|
}
|
||||||
if (hist) {
|
delete hist;
|
||||||
delete hist;
|
delete colorMapLinearScale;
|
||||||
}
|
delete colorMapLogScale;
|
||||||
if (colorMapLinearScale)
|
delete zoomer;
|
||||||
delete colorMapLinearScale;
|
delete panner;
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt2DPlot::SetTitle(QString title) {
|
void SlsQt2DPlot::SetTitle(QString title) {
|
||||||
@ -120,40 +95,16 @@ void SlsQt2DPlot::SetZFont(const QFont& f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt2DPlot::SetupColorMap() {
|
void SlsQt2DPlot::SetupColorMap() {
|
||||||
|
|
||||||
colorMapLinearScale = myColourMap(0);
|
colorMapLinearScale = myColourMap(0);
|
||||||
#if QWT_VERSION < 0x060000
|
|
||||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
|
||||||
#else
|
|
||||||
d_spectrogram->setColorMap(colorMapLinearScale);
|
d_spectrogram->setColorMap(colorMapLinearScale);
|
||||||
#endif
|
|
||||||
|
|
||||||
colorMapLogScale = myColourMap(1);
|
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)
|
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||||
(contourLevelsLinear) += level;
|
(contourLevelsLinear) += level;
|
||||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
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)
|
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||||
(contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
|
(contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
|
||||||
#endif
|
|
||||||
|
|
||||||
// A color bar on the right axis
|
// A color bar on the right axis
|
||||||
rightAxis = axisWidget(QwtPlot::yRight);
|
rightAxis = axisWidget(QwtPlot::yRight);
|
||||||
@ -225,23 +176,14 @@ void SlsQt2DPlot::SetupZoom() {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
void SlsQt2DPlot::UnZoom(bool replot) {
|
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()));
|
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->setZoomBase(replot); //Call replot for the attached plot before initializing the zoomer with its scales.
|
||||||
// zoomer->zoom(0);
|
// zoomer->zoom(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) {
|
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));
|
zoomer->setZoomBase(QRectF(xmin, ymin, x_width, y_width));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt2DPlot::DisableZoom(bool disable) {
|
void SlsQt2DPlot::DisableZoom(bool disable) {
|
||||||
@ -330,28 +272,16 @@ QwtLinearColorMap *SlsQt2DPlot::myColourMap(int log) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt2DPlot::Update() {
|
void SlsQt2DPlot::Update() {
|
||||||
#if QWT_VERSION < 0x060000
|
|
||||||
rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap());
|
|
||||||
#else
|
|
||||||
if (isLog)
|
if (isLog)
|
||||||
hist->SetMinimumToFirstGreaterThanZero();
|
hist->SetMinimumToFirstGreaterThanZero();
|
||||||
|
|
||||||
const QwtInterval zInterval = d_spectrogram->data()->interval(Qt::ZAxis);
|
const QwtInterval zInterval = d_spectrogram->data()->interval(Qt::ZAxis);
|
||||||
|
|
||||||
rightAxis->setColorMap(zInterval, myColourMap(isLog));
|
rightAxis->setColorMap(zInterval, myColourMap(isLog));
|
||||||
#endif
|
|
||||||
if (!zoomer->zoomRectIndex())
|
if (!zoomer->zoomRectIndex())
|
||||||
UnZoom();
|
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());
|
setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue());
|
||||||
plotLayout()->setAlignCanvasToScales(true);
|
plotLayout()->setAlignCanvasToScales(true);
|
||||||
#endif
|
|
||||||
replot();
|
replot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt2DPlot::SetInterpolate(bool enable) {
|
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) {
|
void SlsQt2DPlot::LogZ(bool on) {
|
||||||
if (on) {
|
if (on) {
|
||||||
isLog = 1;
|
isLog = 1;
|
||||||
//if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero();
|
|
||||||
#if QWT_VERSION < 0x060000
|
|
||||||
d_spectrogram->setColorMap(*colorMapLogScale);
|
|
||||||
#else
|
|
||||||
d_spectrogram->setColorMap(myColourMap(isLog));
|
d_spectrogram->setColorMap(myColourMap(isLog));
|
||||||
#endif
|
|
||||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLog10ScaleEngine);
|
setAxisScaleEngine(QwtPlot::yRight, new QwtLog10ScaleEngine);
|
||||||
#if QWT_VERSION < 0x060000
|
|
||||||
d_spectrogram->setContourLevels(*contourLevelsLog);
|
|
||||||
#else
|
|
||||||
d_spectrogram->setContourLevels(contourLevelsLog);
|
d_spectrogram->setContourLevels(contourLevelsLog);
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
isLog = 0;
|
isLog = 0;
|
||||||
|
|
||||||
#if QWT_VERSION < 0x060000
|
|
||||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
|
||||||
#else
|
|
||||||
d_spectrogram->setColorMap(myColourMap(isLog));
|
d_spectrogram->setColorMap(myColourMap(isLog));
|
||||||
#endif
|
|
||||||
|
|
||||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine);
|
setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine);
|
||||||
|
|
||||||
#if QWT_VERSION < 0x060000
|
|
||||||
d_spectrogram->setContourLevels(*contourLevelsLinear);
|
|
||||||
#else
|
|
||||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
d_spectrogram->setContourLevels(contourLevelsLinear);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt2DPlot::showSpectrogram(bool on) {
|
void SlsQt2DPlot::showSpectrogram(bool on) {
|
||||||
// static int io=0;
|
|
||||||
// FillTestPlot(io++);
|
|
||||||
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on);
|
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on);
|
||||||
d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen));
|
d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen));
|
||||||
Update();
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user