mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
works with qwt5, but qwt6 except for 2D plots
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@101 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
parent
8715a416a0
commit
1d03067bd5
@ -40,7 +40,6 @@ private:
|
|||||||
|
|
||||||
QwtLinearColorMap* colorMapLinearScale;
|
QwtLinearColorMap* colorMapLinearScale;
|
||||||
QwtLinearColorMap* colorMapLogScale;
|
QwtLinearColorMap* colorMapLogScale;
|
||||||
QwtLinearColorMap* currentColorMap;
|
|
||||||
#if QWT_VERSION<0x060000
|
#if QWT_VERSION<0x060000
|
||||||
QwtValueList* contourLevelsLinear;
|
QwtValueList* contourLevelsLinear;
|
||||||
QwtValueList* contourLevelsLog;
|
QwtValueList* contourLevelsLog;
|
||||||
@ -52,6 +51,11 @@ private:
|
|||||||
void SetupZoom();
|
void SetupZoom();
|
||||||
void SetupColorMap();
|
void SetupColorMap();
|
||||||
|
|
||||||
|
QwtLinearColorMap* myColourMap(QVector<double> colourStops);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SlsQt2DPlot(QWidget * = NULL);
|
SlsQt2DPlot(QWidget * = NULL);
|
||||||
|
|
||||||
@ -80,12 +84,20 @@ public:
|
|||||||
|
|
||||||
void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1){
|
void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1){
|
||||||
hist->SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax);
|
hist->SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax);
|
||||||
|
|
||||||
|
#if QWT_VERSION<0x060000
|
||||||
|
;
|
||||||
|
#else
|
||||||
|
d_spectrogram->setData(hist);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double* GetDataPtr() {return hist->GetDataPtr();}
|
double* GetDataPtr() {return hist->GetDataPtr();}
|
||||||
int GetBinIndex(int bx,int by) {return hist->GetBinIndex(bx,by);}
|
int GetBinIndex(int bx,int by) {return hist->GetBinIndex(bx,by);}
|
||||||
int FindBinIndex(double x,double y) {return hist->FindBinIndex(x,y);}
|
int FindBinIndex(double x,double y) {return hist->FindBinIndex(x,y);}
|
||||||
void SetBinValue(int bx,int by,double v) {hist->SetBinValue(bx,by,v);}
|
void SetBinValue(int bx,int by,double v) { hist->SetBinValue(bx,by,v);}
|
||||||
double GetBinValue(int bx,int by) {return hist->GetBinValue(bx,by);}
|
double GetBinValue(int bx,int by) {return hist->GetBinValue(bx,by);}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent):QwtPlot(parent){
|
|||||||
d_spectrogram = new QwtPlotSpectrogram();
|
d_spectrogram = new QwtPlotSpectrogram();
|
||||||
|
|
||||||
hist = new SlsQt2DHist();
|
hist = new SlsQt2DHist();
|
||||||
currentColorMap=NULL;
|
|
||||||
SetupZoom();
|
SetupZoom();
|
||||||
SetupColorMap();
|
SetupColorMap();
|
||||||
|
|
||||||
@ -57,27 +56,33 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent):QwtPlot(parent){
|
|||||||
|
|
||||||
|
|
||||||
void SlsQt2DPlot::SetupColorMap(){
|
void SlsQt2DPlot::SetupColorMap(){
|
||||||
|
QVector<double> cs(0);
|
||||||
|
|
||||||
colorMapLinearScale = new QwtLinearColorMap(Qt::darkCyan, Qt::red);
|
|
||||||
colorMapLinearScale->addColorStop(0.1, Qt::cyan);
|
cs.append(0);
|
||||||
colorMapLinearScale->addColorStop(0.4, Qt::blue);
|
cs.append(0.1);
|
||||||
colorMapLinearScale->addColorStop(0.6, Qt::green);
|
cs.append(0.4);
|
||||||
colorMapLinearScale->addColorStop(0.95, Qt::yellow);
|
cs.append(0.6);
|
||||||
|
cs.append(0.95);
|
||||||
|
cs.append(1.);
|
||||||
|
|
||||||
|
colorMapLinearScale = myColourMap(cs);
|
||||||
#if QWT_VERSION<0x060000
|
#if QWT_VERSION<0x060000
|
||||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
d_spectrogram->setColorMap(*colorMapLinearScale);
|
||||||
#else
|
#else
|
||||||
d_spectrogram->setColorMap(colorMapLinearScale);
|
d_spectrogram->setColorMap(colorMapLinearScale);
|
||||||
currentColorMap=colorMapLinearScale;
|
|
||||||
cout << "current color map is linear" << endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
QVector<double> cs1(0);
|
||||||
|
|
||||||
|
|
||||||
colorMapLogScale = new QwtLinearColorMap(Qt::darkCyan, Qt::red);
|
cs.append(0);
|
||||||
colorMapLogScale->addColorStop((pow(10,2*0.10)-1)/99.0, Qt::cyan); //linear scale goes from 0 to 2 and log scale goes from 1 to 100
|
cs.append((pow(10,2*0.10)-1)/99.0);
|
||||||
colorMapLogScale->addColorStop((pow(10,2*0.40)-1)/99.0,Qt::blue);
|
cs.append((pow(10,2*0.40)-1)/99.0);
|
||||||
colorMapLogScale->addColorStop((pow(10,2*0.60)-1)/99.0,Qt::green);
|
cs.append((pow(10,2*0.60)-1)/99.0);
|
||||||
colorMapLogScale->addColorStop((pow(10,2*0.95)-1)/99.0,Qt::yellow);
|
cs.append((pow(10,2*0.95)-1)/99.0);
|
||||||
|
cs.append(1.);
|
||||||
|
|
||||||
|
colorMapLogScale = myColourMap(cs1);
|
||||||
#if QWT_VERSION<0x060000
|
#if QWT_VERSION<0x060000
|
||||||
contourLevelsLinear = new QwtValueList();
|
contourLevelsLinear = new QwtValueList();
|
||||||
for(double level=0.5;level<10.0;level+=1.0 ) (*contourLevelsLinear) += level;
|
for(double level=0.5;level<10.0;level+=1.0 ) (*contourLevelsLinear) += level;
|
||||||
@ -104,6 +109,7 @@ void SlsQt2DPlot::SetupColorMap(){
|
|||||||
|
|
||||||
// A color bar on the right axis
|
// A color bar on the right axis
|
||||||
rightAxis = axisWidget(QwtPlot::yRight);
|
rightAxis = axisWidget(QwtPlot::yRight);
|
||||||
|
|
||||||
rightAxis->setTitle("Intensity");
|
rightAxis->setTitle("Intensity");
|
||||||
rightAxis->setColorBarEnabled(true);
|
rightAxis->setColorBarEnabled(true);
|
||||||
enableAxis(QwtPlot::yRight);
|
enableAxis(QwtPlot::yRight);
|
||||||
@ -192,17 +198,33 @@ void SlsQt2DPlot::SetZMinMax(double zmin,double zmax){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QwtLinearColorMap* SlsQt2DPlot::myColourMap(QVector<double> colourStops) {
|
||||||
|
QwtLinearColorMap* copyMap = new QwtLinearColorMap();
|
||||||
|
|
||||||
|
|
||||||
|
copyMap->addColorStop(colourStops.value(0), Qt::white);
|
||||||
|
// copyMap->addColorStop(colourStops.value(0), Qt::darkCyan);
|
||||||
|
copyMap->addColorStop(colourStops.value(1), Qt::cyan);
|
||||||
|
copyMap->addColorStop(colourStops.value(2), Qt::blue);
|
||||||
|
copyMap->addColorStop(colourStops.value(3), Qt::green);
|
||||||
|
copyMap->addColorStop(colourStops.value(4), Qt::yellow);
|
||||||
|
copyMap->addColorStop(colourStops.value(5), Qt::red);
|
||||||
|
|
||||||
|
return copyMap;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SlsQt2DPlot::Update(){
|
void SlsQt2DPlot::Update(){
|
||||||
#if QWT_VERSION<0x060000
|
#if QWT_VERSION<0x060000
|
||||||
rightAxis->setColorMap(d_spectrogram->data().range(),d_spectrogram->colorMap());
|
rightAxis->setColorMap(d_spectrogram->data().range(),d_spectrogram->colorMap());
|
||||||
#else
|
#else
|
||||||
;
|
|
||||||
rightAxis->setColorMap(d_spectrogram->data()->interval(Qt::ZAxis),currentColorMap);
|
|
||||||
|
|
||||||
|
QVector<double> colourStops =((QwtLinearColorMap*)d_spectrogram->colorMap())->colorStops();
|
||||||
|
QwtLinearColorMap* copyMap = myColourMap(colourStops);
|
||||||
|
|
||||||
cout << "Should reset the color map? " << currentColorMap << endl;
|
// rightAxis->setColorMap(d_spectrogram->data()->interval(Qt::ZAxis),copyMap);
|
||||||
// QwtColorMap *c=d_spectrogram->colorMap();
|
rightAxis->setColorMap(hist->range(),copyMap);
|
||||||
// rightAxis->setColorMap(d_spectrogram->data()->interval(Qt::ZAxis),c);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -212,11 +234,11 @@ void SlsQt2DPlot::Update(){
|
|||||||
setAxisScale(QwtPlot::yRight,d_spectrogram->data().range().minValue(),
|
setAxisScale(QwtPlot::yRight,d_spectrogram->data().range().minValue(),
|
||||||
d_spectrogram->data().range().maxValue());
|
d_spectrogram->data().range().maxValue());
|
||||||
#else
|
#else
|
||||||
setAxisScale(QwtPlot::yRight,d_spectrogram->data()->interval(Qt::ZAxis).minValue(),
|
// setAxisScale(QwtPlot::yRight,d_spectrogram->data()->interval(Qt::ZAxis).minValue(), d_spectrogram->data()->interval(Qt::ZAxis).maxValue());
|
||||||
d_spectrogram->data()->interval(Qt::ZAxis).maxValue());
|
setAxisScale(QwtPlot::yRight,hist->range().minValue(), hist->range().maxValue());
|
||||||
|
|
||||||
cout << "min is " << d_spectrogram->data()->interval(Qt::YAxis).minValue() << endl;
|
cout << "min is " << d_spectrogram->data()->interval(Qt::ZAxis).minValue() << " " << hist->range().minValue() << endl;
|
||||||
cout << "max is " << d_spectrogram->data()->interval(Qt::YAxis).maxValue() << endl;
|
cout << "max is " << d_spectrogram->data()->interval(Qt::ZAxis).maxValue() << " " << hist->range().maxValue() << endl;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
replot();
|
replot();
|
||||||
@ -250,7 +272,6 @@ void SlsQt2DPlot::LogZ(bool on){
|
|||||||
d_spectrogram->setColorMap(*colorMapLogScale);
|
d_spectrogram->setColorMap(*colorMapLogScale);
|
||||||
#else
|
#else
|
||||||
d_spectrogram->setColorMap(colorMapLogScale);
|
d_spectrogram->setColorMap(colorMapLogScale);
|
||||||
currentColorMap=colorMapLogScale;
|
|
||||||
#endif
|
#endif
|
||||||
setAxisScaleEngine(QwtPlot::yRight,new QwtLog10ScaleEngine);
|
setAxisScaleEngine(QwtPlot::yRight,new QwtLog10ScaleEngine);
|
||||||
#if QWT_VERSION<0x060000
|
#if QWT_VERSION<0x060000
|
||||||
@ -263,7 +284,6 @@ void SlsQt2DPlot::LogZ(bool on){
|
|||||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
d_spectrogram->setColorMap(*colorMapLinearScale);
|
||||||
#else
|
#else
|
||||||
d_spectrogram->setColorMap(colorMapLinearScale);
|
d_spectrogram->setColorMap(colorMapLinearScale);
|
||||||
currentColorMap=colorMapLinearScale;
|
|
||||||
#endif
|
#endif
|
||||||
setAxisScaleEngine(QwtPlot::yRight,new QwtLinearScaleEngine);
|
setAxisScaleEngine(QwtPlot::yRight,new QwtLinearScaleEngine);
|
||||||
#if QWT_VERSION<0x060000
|
#if QWT_VERSION<0x060000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user