Some problems with LogZ solved, but stil crashing when unsetting logZ

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@103 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
bergamaschi 2012-10-24 10:39:05 +00:00
parent 3e979fdece
commit 07ff5ce42d
3 changed files with 44 additions and 23 deletions

View File

@ -54,7 +54,7 @@ private:
QwtLinearColorMap* myColourMap(QVector<double> colourStops); QwtLinearColorMap* myColourMap(QVector<double> colourStops);
QwtLinearColorMap* myColourMap(int log=0); QwtLinearColorMap* myColourMap(int log=0);
int isLog;
public: public:

View File

@ -105,7 +105,12 @@ 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(){
@ -124,6 +129,12 @@ 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));
#endif
return z_min; return z_min;
} }

View File

@ -27,6 +27,7 @@
using namespace std; using namespace std;
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent):QwtPlot(parent){ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent):QwtPlot(parent){
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);
@ -67,7 +68,6 @@ void SlsQt2DPlot::SetupColorMap(){
d_spectrogram->setColorMap(colorMapLinearScale ); d_spectrogram->setColorMap(colorMapLinearScale );
#endif #endif
colorMapLogScale = myColourMap(1); colorMapLogScale = myColourMap(1);
#if QWT_VERSION<0x060000 #if QWT_VERSION<0x060000
contourLevelsLinear = new QwtValueList(); contourLevelsLinear = new QwtValueList();
@ -75,7 +75,7 @@ void SlsQt2DPlot::SetupColorMap(){
d_spectrogram->setContourLevels(*contourLevelsLinear); d_spectrogram->setContourLevels(*contourLevelsLinear);
#else #else
; ;
// contourLevelsLinear = new QList();
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;
d_spectrogram->setContourLevels(contourLevelsLinear); d_spectrogram->setContourLevels(contourLevelsLinear);
#endif #endif
@ -88,7 +88,7 @@ void SlsQt2DPlot::SetupColorMap(){
#else #else
; ;
// contourLevelsLog = new QList();
for(double level=0.5;level<10.0;level+=1.0 ) (contourLevelsLog) += (pow(10,2*level/10.0)-1)/99.0 * 10; for(double level=0.5;level<10.0;level+=1.0 ) (contourLevelsLog) += (pow(10,2*level/10.0)-1)/99.0 * 10;
#endif #endif
@ -235,14 +235,12 @@ 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
if (isLog)
hist->SetMinimumToFirstGreaterThanZero();
// const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis ); const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis );
const QwtInterval zInterval = hist->range();
QVector<double> colourStops =((QwtLinearColorMap*)d_spectrogram->colorMap())->colorStops(); rightAxis->setColorMap(zInterval,myColourMap(isLog));
QwtLinearColorMap* copyMap = myColourMap(colourStops);
rightAxis->setColorMap(zInterval,copyMap);
#endif #endif
@ -257,10 +255,14 @@ void SlsQt2DPlot::Update(){
setAxisScale(QwtPlot::yRight,zInterval.minValue(), zInterval.maxValue()); setAxisScale(QwtPlot::yRight,zInterval.minValue(), zInterval.maxValue());
cout << "axis scale set" << endl;
plotLayout()->setAlignCanvasToScales(true); plotLayout()->setAlignCanvasToScales(true);
cout << "layout" << endl;
#endif #endif
cout << "going to replot" << endl;
replot(); replot();
cout << "done" << endl;
} }
@ -286,11 +288,12 @@ void SlsQt2DPlot::InterpolatedPlot(bool on){
void SlsQt2DPlot::LogZ(bool on){ void SlsQt2DPlot::LogZ(bool on){
if(on){ if(on){
isLog=1;
//if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero(); //if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero();
#if QWT_VERSION<0x060000 #if QWT_VERSION<0x060000
d_spectrogram->setColorMap(*colorMapLogScale); d_spectrogram->setColorMap(*colorMapLogScale);
#else #else
d_spectrogram->setColorMap(colorMapLogScale); d_spectrogram->setColorMap(myColorMap(isLog));
#endif #endif
setAxisScaleEngine(QwtPlot::yRight,new QwtLog10ScaleEngine); setAxisScaleEngine(QwtPlot::yRight,new QwtLog10ScaleEngine);
#if QWT_VERSION<0x060000 #if QWT_VERSION<0x060000
@ -299,17 +302,24 @@ void SlsQt2DPlot::LogZ(bool on){
d_spectrogram->setContourLevels(contourLevelsLog); d_spectrogram->setContourLevels(contourLevelsLog);
#endif #endif
}else{ }else{
isLog=0;
#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(myColorMap(isLog));
#endif #endif
setAxisScaleEngine(QwtPlot::yRight,new QwtLinearScaleEngine); setAxisScaleEngine(QwtPlot::yRight,new QwtLinearScaleEngine);
#if QWT_VERSION<0x060000 #if QWT_VERSION<0x060000
d_spectrogram->setContourLevels(*contourLevelsLinear); d_spectrogram->setContourLevels(*contourLevelsLinear);
#else #else
d_spectrogram->setContourLevels(contourLevelsLinear); d_spectrogram->setContourLevels(contourLevelsLinear);
#endif #endif
} }
Update(); Update();