mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
merging refactor (replacing)
This commit is contained in:
5
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h
Normal file → Executable file
5
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h
Normal file → Executable file
@ -13,9 +13,6 @@
|
||||
#ifndef SLSQT1DPLOT_H
|
||||
#define SLSQT1DPLOT_H
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
#include "ansi.h"
|
||||
|
||||
|
||||
@ -25,7 +22,7 @@ typedef int int32_t;
|
||||
#include <qwt_scale_div.h>
|
||||
#include "SlsQt1DZoomer.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
class QPen;
|
||||
class SlsQt1DPlot;
|
||||
|
7
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h
Normal file → Executable file
7
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h
Normal file → Executable file
@ -7,13 +7,6 @@
|
||||
#ifndef SLSQT1DZOOMER_H
|
||||
#define SLSQT1DZOOMER_H
|
||||
|
||||
#ifndef IAN
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
|
||||
|
||||
#include <qwt_plot_zoomer.h>
|
||||
#include <qwt_plot_panner.h>
|
||||
#include <qwt_global.h>
|
||||
|
8
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h
Normal file → Executable file
8
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h
Normal file → Executable file
@ -9,14 +9,6 @@
|
||||
#define SLSQT2DHIST_H
|
||||
|
||||
|
||||
#ifndef IAN
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if QT_VERSION >= 0x040000
|
||||
#include <qprintdialog.h>
|
||||
#endif
|
||||
|
5
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h
Normal file → Executable file
5
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h
Normal file → Executable file
@ -14,11 +14,6 @@
|
||||
#ifndef SLSQT2DPLOT_H
|
||||
#define SLSQT2DPLOT_H
|
||||
|
||||
#ifndef IAN
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
5
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h
Normal file → Executable file
5
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h
Normal file → Executable file
@ -12,11 +12,6 @@
|
||||
#ifndef SLSQT2DPLOTLAYOUT_H
|
||||
#define SLSQT2DPLOTLAYOUT_H
|
||||
|
||||
#ifndef IAN
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
|
||||
|
||||
#include <qwidget.h>
|
||||
|
5
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h
Normal file → Executable file
5
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h
Normal file → Executable file
@ -9,11 +9,6 @@
|
||||
#ifndef SLSQT2DZOOMER_H
|
||||
#define SLSQT2DZOOMER_H
|
||||
|
||||
#ifndef IAN
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
|
||||
|
||||
/**included by Dhanya on 05.12.2012 to avoid compile time errors with the latest gcc*/
|
||||
|
5
slsDetectorGui/slsDetectorPlotting/include/SlsQtNumberEntry.h
Normal file → Executable file
5
slsDetectorGui/slsDetectorPlotting/include/SlsQtNumberEntry.h
Normal file → Executable file
@ -7,11 +7,6 @@
|
||||
#ifndef SLSQTNUMBERENTRY_H
|
||||
#define SLSQTNUMBERENTRY_H
|
||||
|
||||
#ifndef IAN
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
|
||||
|
||||
#include <qwidget.h>
|
||||
|
6
slsDetectorGui/slsDetectorPlotting/include/SlsQtValidators.h
Normal file → Executable file
6
slsDetectorGui/slsDetectorPlotting/include/SlsQtValidators.h
Normal file → Executable file
@ -7,12 +7,6 @@
|
||||
#ifndef SLSQTVALIDATORS_H
|
||||
#define SLSQTVALIDATORS_H
|
||||
|
||||
#ifndef IAN
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
|
||||
|
751
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx
Normal file → Executable file
751
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx
Normal file → Executable file
@ -4,514 +4,567 @@
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <qwt_legend.h>
|
||||
#include <qwt_math.h>
|
||||
#include <qwt_painter.h>
|
||||
#include <qwt_plot_canvas.h>
|
||||
#include <qwt_plot_curve.h>
|
||||
#include <qwt_scale_widget.h>
|
||||
#include <qwt_legend.h>
|
||||
#include <qwt_scale_draw.h>
|
||||
#include <qwt_scale_engine.h>
|
||||
#include <qwt_math.h>
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include <qwt_scale_widget.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if QWT_VERSION >= 0x060100
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
SlsQtH1D::SlsQtH1D(QString title,int n, double min, double max, double* data):QwtPlotCurve(title){
|
||||
Initailize();
|
||||
SetData(n,min,max,data);
|
||||
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title) {
|
||||
Initailize();
|
||||
SetData(n, min, max, data);
|
||||
}
|
||||
|
||||
SlsQtH1D::SlsQtH1D(QString title,int n, double* data_x, double* data_y):QwtPlotCurve(title){
|
||||
Initailize();
|
||||
SetData(n,data_x,data_y);
|
||||
SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y) : QwtPlotCurve(title) {
|
||||
Initailize();
|
||||
SetData(n, data_x, data_y);
|
||||
}
|
||||
|
||||
void SlsQtH1D::Initailize(){
|
||||
ndata=n_array=0;
|
||||
x=y=0;
|
||||
pen_ptr = new QPen();
|
||||
SetLineColor();
|
||||
void SlsQtH1D::Initailize() {
|
||||
ndata = n_array = 0;
|
||||
x = y = 0;
|
||||
pen_ptr = new QPen();
|
||||
SetLineColor();
|
||||
}
|
||||
|
||||
SlsQtH1D::~SlsQtH1D(){delete x;delete y;delete pen_ptr;}
|
||||
|
||||
void SlsQtH1D::Attach(SlsQt1DPlot* p){
|
||||
attach((QwtPlot*) p);
|
||||
p->NewHistogramAttached(this);
|
||||
SlsQtH1D::~SlsQtH1D() {
|
||||
delete x;
|
||||
delete y;
|
||||
delete pen_ptr;
|
||||
}
|
||||
|
||||
void SlsQtH1D::Detach(SlsQt1DPlot* p){
|
||||
detach();
|
||||
p->HistogramDetached(this);
|
||||
void SlsQtH1D::Attach(SlsQt1DPlot *p) {
|
||||
attach((QwtPlot *)p);
|
||||
p->NewHistogramAttached(this);
|
||||
}
|
||||
|
||||
void SlsQtH1D::Detach(SlsQt1DPlot *p) {
|
||||
detach();
|
||||
p->HistogramDetached(this);
|
||||
}
|
||||
|
||||
int SlsQtH1D::SetLineColor(int c){
|
||||
static int last_color = 1;
|
||||
if(c<0) c=(last_color+1)%3;
|
||||
|
||||
switch(c){
|
||||
case 0: pen_ptr->setColor(Qt::black); break;
|
||||
case 1: pen_ptr->setColor(Qt::red); break;
|
||||
case 2: pen_ptr->setColor(Qt::blue); break;
|
||||
case 3: pen_ptr->setColor(Qt::green); break;
|
||||
case 4: pen_ptr->setColor(Qt::magenta); break;
|
||||
case 5: pen_ptr->setColor(Qt::cyan); break;
|
||||
case 6: pen_ptr->setColor(Qt::darkYellow); break;
|
||||
case 7: pen_ptr->setColor(Qt::gray); break;
|
||||
case 8: pen_ptr->setColor(Qt::darkBlue); break;
|
||||
case 9: pen_ptr->setColor(Qt::darkGreen); break;
|
||||
case 10: pen_ptr->setColor(Qt::darkMagenta); break;
|
||||
}
|
||||
/* if(c==0) pen_ptr->setColor(Qt::black);
|
||||
int SlsQtH1D::SetLineColor(int c) {
|
||||
static int last_color = 1;
|
||||
if (c < 0)
|
||||
c = (last_color + 1) % 3;
|
||||
|
||||
switch (c) {
|
||||
case 0:
|
||||
pen_ptr->setColor(Qt::black);
|
||||
break;
|
||||
case 1:
|
||||
pen_ptr->setColor(Qt::red);
|
||||
break;
|
||||
case 2:
|
||||
pen_ptr->setColor(Qt::blue);
|
||||
break;
|
||||
case 3:
|
||||
pen_ptr->setColor(Qt::green);
|
||||
break;
|
||||
case 4:
|
||||
pen_ptr->setColor(Qt::magenta);
|
||||
break;
|
||||
case 5:
|
||||
pen_ptr->setColor(Qt::cyan);
|
||||
break;
|
||||
case 6:
|
||||
pen_ptr->setColor(Qt::darkYellow);
|
||||
break;
|
||||
case 7:
|
||||
pen_ptr->setColor(Qt::gray);
|
||||
break;
|
||||
case 8:
|
||||
pen_ptr->setColor(Qt::darkBlue);
|
||||
break;
|
||||
case 9:
|
||||
pen_ptr->setColor(Qt::darkGreen);
|
||||
break;
|
||||
case 10:
|
||||
pen_ptr->setColor(Qt::darkMagenta);
|
||||
break;
|
||||
}
|
||||
/* if(c==0) pen_ptr->setColor(Qt::black);
|
||||
else if(c==1) pen_ptr->setColor(Qt::red);
|
||||
else pen_ptr->setColor(Qt::blue);*/
|
||||
|
||||
setPen(*pen_ptr);
|
||||
setPen(*pen_ptr);
|
||||
|
||||
return last_color=c;
|
||||
return last_color = c;
|
||||
}
|
||||
|
||||
int SlsQtH1D::SetLineWidth(int w){
|
||||
pen_ptr->setWidth(w);
|
||||
setPen(*pen_ptr);
|
||||
return w;
|
||||
int SlsQtH1D::SetLineWidth(int w) {
|
||||
pen_ptr->setWidth(w);
|
||||
setPen(*pen_ptr);
|
||||
return w;
|
||||
}
|
||||
|
||||
void SlsQtH1D::SetLineStyle(int s){
|
||||
if(s==1) pen_ptr->setStyle(Qt::DashLine);
|
||||
else if(s==2) pen_ptr->setStyle(Qt::DotLine);
|
||||
else if(s==3) pen_ptr->setStyle(Qt::DashDotLine);
|
||||
else if(s==4) pen_ptr->setStyle(Qt::DashDotDotLine);
|
||||
else if(s==5) pen_ptr->setStyle(Qt::CustomDashLine);
|
||||
else pen_ptr->setStyle(Qt::SolidLine);
|
||||
setPen(*pen_ptr);
|
||||
void SlsQtH1D::SetLineStyle(int s) {
|
||||
if (s == 1)
|
||||
pen_ptr->setStyle(Qt::DashLine);
|
||||
else if (s == 2)
|
||||
pen_ptr->setStyle(Qt::DotLine);
|
||||
else if (s == 3)
|
||||
pen_ptr->setStyle(Qt::DashDotLine);
|
||||
else if (s == 4)
|
||||
pen_ptr->setStyle(Qt::DashDotDotLine);
|
||||
else if (s == 5)
|
||||
pen_ptr->setStyle(Qt::CustomDashLine);
|
||||
else
|
||||
pen_ptr->setStyle(Qt::SolidLine);
|
||||
setPen(*pen_ptr);
|
||||
}
|
||||
|
||||
void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
|
||||
n = SetUpArrays(n);
|
||||
|
||||
void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data){
|
||||
n = SetUpArrays(n);
|
||||
|
||||
ndata=n;
|
||||
if(xmin>xmax){
|
||||
double t=xmin;
|
||||
xmin=xmax;
|
||||
xmax=t;
|
||||
}
|
||||
ndata = n;
|
||||
if (xmin > xmax) {
|
||||
double t = xmin;
|
||||
xmin = xmax;
|
||||
xmax = t;
|
||||
}
|
||||
|
||||
dx = (xmax-xmin)/n;
|
||||
ymin=ymax= data ? data[0]:0;
|
||||
firstXgt0=-1;
|
||||
firstYgt0=-1;
|
||||
dx = (xmax - xmin) / n;
|
||||
ymin = ymax = data ? data[0] : 0;
|
||||
firstXgt0 = -1;
|
||||
firstYgt0 = -1;
|
||||
|
||||
for(int i=0;i<ndata;i++){
|
||||
x[i] = i ? x[i-1]+dx:xmin;
|
||||
y[i] = data ? data[i]:0;
|
||||
if(data&&ymin>y[i]) ymin = y[i];
|
||||
if(data&&ymax<y[i]) ymax = y[i];
|
||||
if(x[i]>0&&(firstXgt0<0||firstXgt0>x[i])) firstXgt0=x[i];
|
||||
if(y[i]>0&&(firstYgt0<0||firstYgt0>y[i])) firstYgt0=y[i];
|
||||
}
|
||||
for (int i = 0; i < ndata; i++) {
|
||||
x[i] = i ? x[i - 1] + dx : xmin;
|
||||
y[i] = data ? data[i] : 0;
|
||||
if (data && ymin > y[i])
|
||||
ymin = y[i];
|
||||
if (data && ymax < y[i])
|
||||
ymax = y[i];
|
||||
if (x[i] > 0 && (firstXgt0 < 0 || firstXgt0 > x[i]))
|
||||
firstXgt0 = x[i];
|
||||
if (y[i] > 0 && (firstYgt0 < 0 || firstYgt0 > y[i]))
|
||||
firstYgt0 = y[i];
|
||||
}
|
||||
|
||||
// cout<<endl<<endl<<"one can think about correcting negative values in the data and recalling the setRawData function in setRawData when plotting on log scales"<<endl;
|
||||
|
||||
// if(firstXgt0<0)firstXgt0=0.001;
|
||||
// if(firstYgt0<0)firstYgt0=0.001;
|
||||
#if QWT_VERSION<0x060000
|
||||
setRawData(x,y,ndata);
|
||||
#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) {
|
||||
|
||||
int reverse = (data_x&&n>0&&data_x[0]>data_x[n-1]) ? 1:0;
|
||||
n = SetUpArrays(n);
|
||||
int reverse = (data_x && n > 0 && data_x[0] > data_x[n - 1]) ? 1 : 0;
|
||||
n = SetUpArrays(n);
|
||||
|
||||
ndata=n;
|
||||
dx=-1; //signifies not regular intervals
|
||||
ndata = n;
|
||||
dx = -1; //signifies not regular intervals
|
||||
|
||||
ymin=ymax= data_y ? data_y[0]:0;
|
||||
ymin = ymax = data_y ? data_y[0] : 0;
|
||||
|
||||
firstXgt0=-1;
|
||||
firstYgt0=-1;
|
||||
firstXgt0 = -1;
|
||||
firstYgt0 = -1;
|
||||
|
||||
for(int i=0;i<ndata;i++){
|
||||
int b = reverse ? n-i-1:i;
|
||||
x[b] = data_x ? data_x[i]:0;
|
||||
y[b] = data_y ? data_y[i]:0;
|
||||
if(data_y&&ymin>y[b]) ymin = y[b];
|
||||
if(data_y&&ymax<y[b]) ymax = y[b];
|
||||
if(x[b]>0&&(firstXgt0<0||firstXgt0>x[b])) firstXgt0=x[b];
|
||||
if(y[b]>0&&(firstYgt0<0||firstYgt0>y[b])) firstYgt0=y[b];
|
||||
}
|
||||
for (int i = 0; i < ndata; i++) {
|
||||
int b = reverse ? n - i - 1 : i;
|
||||
x[b] = data_x ? data_x[i] : 0;
|
||||
y[b] = data_y ? data_y[i] : 0;
|
||||
if (data_y && ymin > y[b])
|
||||
ymin = y[b];
|
||||
if (data_y && ymax < y[b])
|
||||
ymax = y[b];
|
||||
if (x[b] > 0 && (firstXgt0 < 0 || firstXgt0 > x[b]))
|
||||
firstXgt0 = x[b];
|
||||
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
|
||||
// #if QWT_VERSION<0x060000
|
||||
// setRawData(x,y,ndata);
|
||||
// #else
|
||||
setRawSamples(x, y, ndata);
|
||||
// #endif
|
||||
}
|
||||
|
||||
int SlsQtH1D::SetUpArrays(int n){
|
||||
n = n<1 ? 1 : n; //overflow bin
|
||||
|
||||
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];
|
||||
}
|
||||
int SlsQtH1D::SetUpArrays(int n) {
|
||||
n = n < 1 ? 1 : n; //overflow bin
|
||||
|
||||
return 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];
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
double SlsQtH1D::FillBin(int bx, double v) {
|
||||
bx = CheckIndex(bx);
|
||||
return SetBinContent(bx,y[bx]+v);
|
||||
double SlsQtH1D::FillBin(int bx, double v) {
|
||||
bx = CheckIndex(bx);
|
||||
return SetBinContent(bx, y[bx] + v);
|
||||
}
|
||||
double SlsQtH1D::Fill(double x, double v){return FillBin(FindBinIndex(x),v);}
|
||||
double SlsQtH1D::Fill(double x, double v) { return FillBin(FindBinIndex(x), v); }
|
||||
|
||||
double SlsQtH1D::SetBinContent(int bx,double v){
|
||||
bx = CheckIndex(bx);
|
||||
y[bx]=v;
|
||||
if(bx<ndata){
|
||||
if(y[bx]<ymin) ymin = y[bx];
|
||||
if(y[bx]>0&&(firstYgt0<=0||y[bx]<firstYgt0)) firstYgt0 = y[bx];
|
||||
if(y[bx]>ymax) ymax = y[bx];
|
||||
}
|
||||
return y[bx];
|
||||
double SlsQtH1D::SetBinContent(int bx, double v) {
|
||||
bx = CheckIndex(bx);
|
||||
y[bx] = v;
|
||||
if (bx < ndata) {
|
||||
if (y[bx] < ymin)
|
||||
ymin = y[bx];
|
||||
if (y[bx] > 0 && (firstYgt0 <= 0 || y[bx] < firstYgt0))
|
||||
firstYgt0 = y[bx];
|
||||
if (y[bx] > ymax)
|
||||
ymax = y[bx];
|
||||
}
|
||||
return y[bx];
|
||||
}
|
||||
|
||||
double SlsQtH1D::SetContent(double x,double v) {return SetBinContent(FindBinIndex(x),v); }
|
||||
double SlsQtH1D::SetContent(double x, double v) { return SetBinContent(FindBinIndex(x), v); }
|
||||
|
||||
int SlsQtH1D::FindBinIndex(double px){
|
||||
if(dx>0) CheckIndex(int((px-x[0])/dx));
|
||||
|
||||
//find closest bin
|
||||
int b=0; for(;b<ndata;b++) if(x[b]>px) break;
|
||||
int SlsQtH1D::FindBinIndex(double px) {
|
||||
if (dx > 0)
|
||||
CheckIndex(int((px - x[0]) / dx));
|
||||
|
||||
if(b==0) return 0;
|
||||
else if(fabs(px-x[b-1])<fabs(px-x[b])) return b-1;
|
||||
//find closest bin
|
||||
int b = 0;
|
||||
for (; b < ndata; b++)
|
||||
if (x[b] > px)
|
||||
break;
|
||||
|
||||
return b;
|
||||
if (b == 0)
|
||||
return 0;
|
||||
else if (fabs(px - x[b - 1]) < fabs(px - x[b]))
|
||||
return b - 1;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
int SlsQtH1D::CheckIndex(int bx){return (bx<0||bx>ndata) ? ndata : bx;}//ndata is the overflow bin
|
||||
|
||||
SlsQtH1D* SlsQtH1D::Add(double v){ for(int bx=0;bx<ndata;bx++) FillBin(bx,v); return this;}
|
||||
int SlsQtH1D::CheckIndex(int bx) { return (bx < 0 || bx > ndata) ? ndata : bx; } //ndata is the overflow bin
|
||||
|
||||
SlsQtH1D *SlsQtH1D::Add(double v) {
|
||||
for (int bx = 0; bx < ndata; bx++)
|
||||
FillBin(bx, v);
|
||||
return this;
|
||||
}
|
||||
|
||||
//1d hist list stuff
|
||||
SlsQtH1DList::SlsQtH1DList(SlsQtH1D* hist){
|
||||
the_hist = hist;
|
||||
the_next = 0;
|
||||
SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) {
|
||||
the_hist = hist;
|
||||
the_next = 0;
|
||||
}
|
||||
|
||||
SlsQtH1DList::~SlsQtH1DList(){
|
||||
if(the_next) delete the_next;
|
||||
SlsQtH1DList::~SlsQtH1DList() {
|
||||
if (the_next)
|
||||
delete the_next;
|
||||
}
|
||||
|
||||
SlsQtH1D* SlsQtH1DList::Add(SlsQtH1D* hist){
|
||||
// cout<<"Adding: "<<hist<<endl;
|
||||
SlsQtH1DList* hl=this;
|
||||
SlsQtH1D *SlsQtH1DList::Add(SlsQtH1D *hist) {
|
||||
SlsQtH1DList *hl = this;
|
||||
|
||||
while(hl){
|
||||
if(hist==hl->the_hist) return hist; //already added
|
||||
if(!hl->the_next) break;
|
||||
hl=hl->the_next;
|
||||
}
|
||||
if(hl->the_hist) hl->the_next = new SlsQtH1DList(hist);
|
||||
else hl->the_hist = hist;
|
||||
|
||||
// Print();
|
||||
|
||||
return hist;
|
||||
}
|
||||
|
||||
void SlsQtH1DList::Print(){
|
||||
// cout<<"Printing List"<<endl;
|
||||
SlsQtH1DList* hl=this;
|
||||
int i=0;
|
||||
while(hl){
|
||||
cout<<" "<<i++<<") "<<hl<<" "<<hl->the_hist<<" "<<hl->the_next<<endl;
|
||||
hl=hl->the_next;
|
||||
if(i>10) break;
|
||||
}
|
||||
}
|
||||
|
||||
void SlsQtH1DList::Remove(SlsQtH1D* hist){
|
||||
// cout<<"Removing: "<<hist<<endl;
|
||||
SlsQtH1DList* hl=this;
|
||||
while(hl){ //every match will be removed
|
||||
if(hl->the_hist!=hist) hl = hl->the_next;
|
||||
else{ //match
|
||||
if(!hl->the_next) hl->the_hist=0; // first the_hist is zero when there's no next
|
||||
else{
|
||||
SlsQtH1DList* t = hl->the_next;
|
||||
hl->the_hist = t->the_hist;
|
||||
hl->the_next = t->the_next;
|
||||
t->the_next = 0;
|
||||
delete t;
|
||||
}
|
||||
while (hl) {
|
||||
if (hist == hl->the_hist)
|
||||
return hist; //already added
|
||||
if (!hl->the_next)
|
||||
break;
|
||||
hl = hl->the_next;
|
||||
}
|
||||
}
|
||||
// Print();
|
||||
if (hl->the_hist)
|
||||
hl->the_next = new SlsQtH1DList(hist);
|
||||
else
|
||||
hl->the_hist = hist;
|
||||
|
||||
// Print();
|
||||
|
||||
return hist;
|
||||
}
|
||||
|
||||
void SlsQtH1DList::Print() {
|
||||
SlsQtH1DList *hl = this;
|
||||
int i = 0;
|
||||
while (hl) {
|
||||
std::cout << " " << i++ << ") " << hl << " " << hl->the_hist << " " << hl->the_next << '\n';
|
||||
hl = hl->the_next;
|
||||
if (i > 10)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SlsQtH1DList::Remove(SlsQtH1D *hist) {
|
||||
SlsQtH1DList *hl = this;
|
||||
while (hl) { //every match will be removed
|
||||
if (hl->the_hist != hist)
|
||||
hl = hl->the_next;
|
||||
else { //match
|
||||
if (!hl->the_next)
|
||||
hl->the_hist = 0; // first the_hist is zero when there's no next
|
||||
else {
|
||||
SlsQtH1DList *t = hl->the_next;
|
||||
hl->the_hist = t->the_hist;
|
||||
hl->the_next = t->the_next;
|
||||
t->the_next = 0;
|
||||
delete t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//1d plot stuff
|
||||
SlsQt1DPlot::SlsQt1DPlot(QWidget *parent):QwtPlot(parent){
|
||||
// n_histograms_attached=0;
|
||||
hline=vline=0;
|
||||
hist_list = new SlsQtH1DList();
|
||||
SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||
// n_histograms_attached=0;
|
||||
hline = vline = 0;
|
||||
hist_list = new SlsQtH1DList();
|
||||
|
||||
UnknownStuff();
|
||||
alignScales();
|
||||
SetupZoom();
|
||||
UnknownStuff();
|
||||
alignScales();
|
||||
SetupZoom();
|
||||
|
||||
// Assign a title
|
||||
// Assign a title
|
||||
#ifndef IAN
|
||||
insertLegend(new QwtLegend(), QwtPlot::BottomLegend);
|
||||
insertLegend(new QwtLegend(), QwtPlot::BottomLegend);
|
||||
#else
|
||||
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
|
||||
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
|
||||
#endif
|
||||
|
||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
|
||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
|
||||
}
|
||||
|
||||
SlsQt1DPlot::~SlsQt1DPlot(){
|
||||
delete hist_list;
|
||||
SlsQt1DPlot::~SlsQt1DPlot() {
|
||||
delete hist_list;
|
||||
|
||||
if(hline) delete hline;
|
||||
if(vline) delete vline;
|
||||
if (hline)
|
||||
delete hline;
|
||||
if (vline)
|
||||
delete vline;
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::CalculateNResetZoomBase(){
|
||||
if(hist_list->Hist()) zoomer->SetZoomBase(hist_list->Hist());
|
||||
SlsQtH1DList* hl = hist_list->Next();
|
||||
while(hl){
|
||||
if(hl->Hist()) zoomer->ExtendZoomBase(hl->Hist());
|
||||
hl=hl->Next();
|
||||
}
|
||||
void SlsQt1DPlot::CalculateNResetZoomBase() {
|
||||
if (hist_list->Hist())
|
||||
zoomer->SetZoomBase(hist_list->Hist());
|
||||
SlsQtH1DList *hl = hist_list->Next();
|
||||
while (hl) {
|
||||
if (hl->Hist())
|
||||
zoomer->ExtendZoomBase(hl->Hist());
|
||||
hl = hl->Next();
|
||||
}
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::NewHistogramAttached(SlsQtH1D* h){
|
||||
hist_list->Add(h);
|
||||
CalculateNResetZoomBase();
|
||||
//commented out by dhanya to take off zooming every hist in 1d plots
|
||||
//if(!hist_list->Next()) UnZoom();
|
||||
Update();
|
||||
void SlsQt1DPlot::NewHistogramAttached(SlsQtH1D *h) {
|
||||
hist_list->Add(h);
|
||||
CalculateNResetZoomBase();
|
||||
//commented out by dhanya to take off zooming every hist in 1d plots
|
||||
//if(!hist_list->Next()) UnZoom();
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::HistogramDetached(SlsQtH1D* h){
|
||||
hist_list->Remove(h);
|
||||
CalculateNResetZoomBase();
|
||||
Update();
|
||||
void SlsQt1DPlot::HistogramDetached(SlsQtH1D *h) {
|
||||
hist_list->Remove(h);
|
||||
CalculateNResetZoomBase();
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::Update(){
|
||||
void SlsQt1DPlot::Update() {
|
||||
replot();
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::SetTitle(const char* title){
|
||||
setTitle(title);
|
||||
|
||||
void SlsQt1DPlot::SetTitle(const char *title) {
|
||||
setTitle(title);
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::SetXTitle(const char* title){
|
||||
QwtText t(title);
|
||||
t.setFont(QFont("Sans Serif",11,QFont::Normal));
|
||||
setAxisTitle(QwtPlot::xBottom,t);
|
||||
void SlsQt1DPlot::SetXTitle(const char *title) {
|
||||
QwtText t(title);
|
||||
t.setFont(QFont("Sans Serif", 11, QFont::Normal));
|
||||
setAxisTitle(QwtPlot::xBottom, t);
|
||||
}
|
||||
void SlsQt1DPlot::SetYTitle(const char* title){
|
||||
QwtText t(title);
|
||||
t.setFont(QFont("Sans Serif",11,QFont::Normal));
|
||||
setAxisTitle(QwtPlot::yLeft,t);
|
||||
void SlsQt1DPlot::SetYTitle(const char *title) {
|
||||
QwtText t(title);
|
||||
t.setFont(QFont("Sans Serif", 11, QFont::Normal));
|
||||
setAxisTitle(QwtPlot::yLeft, t);
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::SetLogX(bool yes){ SetLog(QwtPlot::xBottom,yes);}
|
||||
void SlsQt1DPlot::SetLogY(bool yes){ SetLog(QwtPlot::yLeft,yes);}
|
||||
void SlsQt1DPlot::SetLog(int axisId, bool yes){
|
||||
if(axisId==QwtPlot::xBottom) zoomer->SetLogX(yes);
|
||||
if(axisId==QwtPlot::yLeft) zoomer->SetLogY(yes);
|
||||
void SlsQt1DPlot::SetLogX(bool yes) { SetLog(QwtPlot::xBottom, yes); }
|
||||
void SlsQt1DPlot::SetLogY(bool yes) { SetLog(QwtPlot::yLeft, yes); }
|
||||
void SlsQt1DPlot::SetLog(int axisId, bool yes) {
|
||||
if (axisId == QwtPlot::xBottom)
|
||||
zoomer->SetLogX(yes);
|
||||
if (axisId == QwtPlot::yLeft)
|
||||
zoomer->SetLogY(yes);
|
||||
|
||||
zoomer->ResetZoomBase(); //needs to be done before setting Engine
|
||||
zoomer->ResetZoomBase(); //needs to be done before setting Engine
|
||||
|
||||
//the old ones are deleted by in the setAxisScaleFunction() function see: 128 of file qwt_plot_axis.cpp
|
||||
if(yes) setAxisScaleEngine(axisId,new QwtLog10ScaleEngine());
|
||||
else setAxisScaleEngine(axisId,new QwtLinearScaleEngine());
|
||||
//the old ones are deleted by in the setAxisScaleFunction() function see: 128 of file qwt_plot_axis.cpp
|
||||
if (yes)
|
||||
setAxisScaleEngine(axisId, new QwtLog10ScaleEngine());
|
||||
else
|
||||
setAxisScaleEngine(axisId, new QwtLinearScaleEngine());
|
||||
|
||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
|
||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
|
||||
|
||||
Update();
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::UnZoom(){
|
||||
setAxisScale(QwtPlot::xBottom,zoomer->x(),zoomer->x()+zoomer->w());
|
||||
setAxisScale(QwtPlot::yLeft,zoomer->y(),zoomer->y()+zoomer->h());
|
||||
void SlsQt1DPlot::UnZoom() {
|
||||
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
|
||||
setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h());
|
||||
|
||||
zoomer->setZoomBase();//Call replot for the attached plot before initializing the zoomer with its scales.
|
||||
Update();
|
||||
zoomer->setZoomBase(); //Call replot for the attached plot before initializing the zoomer with its scales.
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::SetZoom(double xmin,double ymin,double x_width,double y_width){
|
||||
setAxisScale(QwtPlot::xBottom,xmin,xmin+x_width);
|
||||
setAxisScale(QwtPlot::yLeft ,ymin,ymin+y_width);
|
||||
Update();
|
||||
void SlsQt1DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) {
|
||||
setAxisScale(QwtPlot::xBottom, xmin, xmin + x_width);
|
||||
setAxisScale(QwtPlot::yLeft, ymin, ymin + y_width);
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::RemoveHLine(){
|
||||
if(hline) hline->detach();
|
||||
delete hline;
|
||||
hline=0;
|
||||
void SlsQt1DPlot::RemoveHLine() {
|
||||
if (hline)
|
||||
hline->detach();
|
||||
delete hline;
|
||||
hline = 0;
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::InsertHLine(double y){
|
||||
if(!hline){
|
||||
hline = new QwtPlotMarker();
|
||||
hline->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
|
||||
hline->setLineStyle(QwtPlotMarker::HLine);
|
||||
hline->attach(this);
|
||||
}
|
||||
hline->setYValue(y);
|
||||
void SlsQt1DPlot::InsertHLine(double y) {
|
||||
if (!hline) {
|
||||
hline = new QwtPlotMarker();
|
||||
hline->setLabelAlignment(Qt::AlignRight | Qt::AlignTop);
|
||||
hline->setLineStyle(QwtPlotMarker::HLine);
|
||||
hline->attach(this);
|
||||
}
|
||||
hline->setYValue(y);
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::RemoveVLine(){
|
||||
if(vline) vline->detach();
|
||||
delete vline;
|
||||
vline=0;
|
||||
void SlsQt1DPlot::RemoveVLine() {
|
||||
if (vline)
|
||||
vline->detach();
|
||||
delete vline;
|
||||
vline = 0;
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::InsertVLine(double x){
|
||||
if(!vline){
|
||||
vline = new QwtPlotMarker();
|
||||
vline->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
|
||||
vline->setLineStyle(QwtPlotMarker::VLine);
|
||||
vline->attach(this);
|
||||
}
|
||||
vline->setXValue(x);
|
||||
void SlsQt1DPlot::InsertVLine(double x) {
|
||||
if (!vline) {
|
||||
vline = new QwtPlotMarker();
|
||||
vline->setLabelAlignment(Qt::AlignRight | Qt::AlignTop);
|
||||
vline->setLineStyle(QwtPlotMarker::VLine);
|
||||
vline->attach(this);
|
||||
}
|
||||
vline->setXValue(x);
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::SetupZoom() {
|
||||
// LeftButton for the zooming
|
||||
// MidButton for the panning
|
||||
// RightButton: zoom out by 1
|
||||
// Ctrl+RighButton: zoom out to full size
|
||||
|
||||
|
||||
zoomer = new SlsQt1DZoomer(canvas());
|
||||
|
||||
void SlsQt1DPlot::SetupZoom(){
|
||||
// LeftButton for the zooming
|
||||
// MidButton for the panning
|
||||
// RightButton: zoom out by 1
|
||||
// Ctrl+RighButton: zoom out to full size
|
||||
|
||||
zoomer = new SlsQt1DZoomer(canvas());
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton);
|
||||
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);
|
||||
|
||||
panner = new QwtPlotPanner((QwtPlotCanvas*)canvas());
|
||||
panner = new QwtPlotPanner((QwtPlotCanvas *)canvas());
|
||||
panner->setAxisEnabled(QwtPlot::yRight, false);
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
|
||||
// Avoid jumping when labels with more/less digits
|
||||
// appear/disappear when scrolling vertically
|
||||
// Avoid jumping when labels with more/less digits
|
||||
// appear/disappear when scrolling vertically
|
||||
|
||||
const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
|
||||
QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
|
||||
sd->setMinimumExtent( fm.width("100.00") );
|
||||
const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
|
||||
QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
|
||||
sd->setMinimumExtent(fm.width("100.00"));
|
||||
|
||||
const QColor c(Qt::darkBlue);
|
||||
zoomer->setRubberBandPen(c);
|
||||
zoomer->setTrackerPen(c);
|
||||
}
|
||||
|
||||
|
||||
// Set a plain canvas frame and align the scales to it
|
||||
void SlsQt1DPlot::alignScales(){
|
||||
void SlsQt1DPlot::alignScales() {
|
||||
// The code below shows how to align the scales to
|
||||
// the canvas frame, but is also a good example demonstrating
|
||||
// why the spreaded API needs polishing.
|
||||
|
||||
((QwtPlotCanvas*)canvas())->setFrameStyle(QFrame::Box | QFrame::Plain );
|
||||
((QwtPlotCanvas*)canvas())->setLineWidth(1);
|
||||
((QwtPlotCanvas *)canvas())->setFrameStyle(QFrame::Box | QFrame::Plain);
|
||||
((QwtPlotCanvas *)canvas())->setLineWidth(1);
|
||||
|
||||
for(int i = 0; i < QwtPlot::axisCnt; i++ ){
|
||||
QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i);
|
||||
if(scaleWidget) scaleWidget->setMargin(0);
|
||||
QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i);
|
||||
if(scaleDraw) scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false);
|
||||
for (int i = 0; i < QwtPlot::axisCnt; i++) {
|
||||
QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i);
|
||||
if (scaleWidget)
|
||||
scaleWidget->setMargin(0);
|
||||
QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i);
|
||||
if (scaleDraw)
|
||||
scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
// 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);
|
||||
// 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 disableZoom){
|
||||
void SlsQt1DPlot::DisableZoom(bool disableZoom) {
|
||||
#ifdef VERBOSE
|
||||
if(disableZoom) cout<<"Disabling zoom"<<endl;
|
||||
else cout<<"Enabling zoom"<<endl;
|
||||
if (disableZoom)
|
||||
std::cout << "Disabling zoom\n";
|
||||
else
|
||||
std::cout << "Enabling zoom\n";
|
||||
#endif
|
||||
if(disableZoom){
|
||||
if(zoomer){
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,Qt::NoButton);
|
||||
if (disableZoom) {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlButton);
|
||||
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);
|
||||
}
|
||||
if(panner) panner->setMouseButton(Qt::NoButton);
|
||||
}else {
|
||||
if(zoomer){
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,Qt::LeftButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::NoButton);
|
||||
} else {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton);
|
||||
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);
|
||||
}
|
||||
if(panner) panner->setMouseButton(Qt::MidButton);
|
||||
}
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
3
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx
Normal file → Executable file
3
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx
Normal file → Executable file
@ -13,7 +13,6 @@
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include "SlsQt1DZoomer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void SlsQt1DZoomer::ResetZoomBase(){
|
||||
SetZoomBase(x0,y0,x1-x0,y1-y0); //for going between log and nonlog plots
|
||||
@ -100,8 +99,6 @@ void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D* h){
|
||||
if(h->GetFirstXgtZero()<firstXgt0) firstXgt0 = h->GetFirstXgtZero();
|
||||
if(h->GetFirstYgtZero()<firstYgt0) firstYgt0 = h->GetFirstYgtZero();
|
||||
|
||||
// cout<<"extend "<<h_x0<<" "<<h_y0<<" "<<h_x1<<" "<<h_y1<<endl;
|
||||
// cout<<"extend "<<x0<<" "<<y0<<" "<<x1-x0<<" "<<y1-y0<<endl;
|
||||
ResetZoomBase();
|
||||
}
|
||||
|
||||
|
0
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cxx
Normal file → Executable file
0
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cxx
Normal file → Executable file
450
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx
Normal file → Executable file
450
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx
Normal file → Executable file
@ -4,153 +4,148 @@
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <cmath>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <qlist.h>
|
||||
#include <qprinter.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <qlist.h>
|
||||
|
||||
#if QT_VERSION >= 0x040000
|
||||
#include <qprintdialog.h>
|
||||
#endif
|
||||
#include <qwt_color_map.h>
|
||||
#include <qwt_plot_spectrogram.h>
|
||||
#include <qwt_scale_widget.h>
|
||||
#include <qwt_scale_draw.h>
|
||||
#include <qwt_plot_zoomer.h>
|
||||
#include <qwt_plot_panner.h>
|
||||
#include <qwt_plot_layout.h>
|
||||
#include <qwt_plot_panner.h>
|
||||
#include <qwt_plot_spectrogram.h>
|
||||
#include <qwt_plot_zoomer.h>
|
||||
#include <qwt_scale_draw.h>
|
||||
#include <qwt_scale_engine.h>
|
||||
#include <qwt_scale_widget.h>
|
||||
|
||||
#include "SlsQt2DPlot.h"
|
||||
|
||||
#if QWT_VERSION >= 0x060100
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
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);
|
||||
#if QWT_VERSION >= 0x060100
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
||||
#endif
|
||||
|
||||
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||
isLog = 0;
|
||||
|
||||
d_spectrogram->attach(this);
|
||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
|
||||
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
d_spectrogram = new QwtPlotSpectrogram();
|
||||
|
||||
FillTestPlot();
|
||||
Update();
|
||||
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();
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetupColorMap() {
|
||||
|
||||
void SlsQt2DPlot::SetupColorMap(){
|
||||
|
||||
|
||||
|
||||
|
||||
colorMapLinearScale = myColourMap(0);
|
||||
#if QWT_VERSION<0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLinearScale );
|
||||
colorMapLinearScale = myColourMap(0);
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
||||
#else
|
||||
d_spectrogram->setColorMap(colorMapLinearScale );
|
||||
d_spectrogram->setColorMap(colorMapLinearScale);
|
||||
#endif
|
||||
|
||||
colorMapLogScale = myColourMap(1);
|
||||
#if QWT_VERSION<0x060000
|
||||
colorMapLogScale = myColourMap(1);
|
||||
#if QWT_VERSION < 0x060000
|
||||
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;
|
||||
d_spectrogram->setContourLevels(*contourLevelsLinear);
|
||||
#else
|
||||
;
|
||||
|
||||
for(double level=0.5;level<10.0;level+=1.0 ) (contourLevelsLinear) += level;
|
||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
||||
|
||||
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||
(contourLevelsLinear) += level;
|
||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
#if QWT_VERSION<0x060000
|
||||
//
|
||||
#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;
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
// A color bar on the right axis
|
||||
rightAxis = axisWidget(QwtPlot::yRight);
|
||||
|
||||
rightAxis->setTitle("Intensity");
|
||||
|
||||
rightAxis->setTitle("Intensity");
|
||||
rightAxis->setColorBarEnabled(true);
|
||||
enableAxis(QwtPlot::yRight);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::FillTestPlot(int mode){
|
||||
static int nx = 50;
|
||||
static int ny = 50;
|
||||
static double *the_data=0;
|
||||
if(the_data==0) the_data = new double [nx*ny];
|
||||
void SlsQt2DPlot::FillTestPlot(int mode) {
|
||||
static int nx = 50;
|
||||
static int ny = 50;
|
||||
static double *the_data = 0;
|
||||
if (the_data == 0)
|
||||
the_data = new double[nx * ny];
|
||||
|
||||
double dmax = sqrt(pow(nx/2.0-0.5,2) + pow(ny/2.0-0.5,2));
|
||||
for(int i=0;i<nx;i++){
|
||||
for(int j=0;j<ny;j++){
|
||||
double d = sqrt(pow(nx/2.0-(i+0.5),2) + pow(ny/2.0-(j+0.5),2));
|
||||
double dmax = sqrt(pow(nx / 2.0 - 0.5, 2) + pow(ny / 2.0 - 0.5, 2));
|
||||
for (int i = 0; i < nx; i++) {
|
||||
for (int j = 0; j < ny; j++) {
|
||||
double d = sqrt(pow(nx / 2.0 - (i + 0.5), 2) + pow(ny / 2.0 - (j + 0.5), 2));
|
||||
|
||||
if(mode%3) the_data[i+j*nx] = 10*d/dmax;
|
||||
else the_data[i+j*nx] = 10*(1-d/dmax);
|
||||
if (mode % 3)
|
||||
the_data[i + j * nx] = 10 * d / dmax;
|
||||
else
|
||||
the_data[i + j * nx] = 10 * (1 - d / dmax);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hist->SetData(nx,200,822,ny,-0.5,ny-0.5,the_data);
|
||||
hist->SetData(nx, 200, 822, ny, -0.5, ny - 0.5, the_data);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetupZoom(){
|
||||
// LeftButton for the zooming
|
||||
// MidButton for the panning
|
||||
// RightButton: zoom out by 1
|
||||
// Ctrl+RighButton: zoom out to full size
|
||||
void SlsQt2DPlot::SetupZoom() {
|
||||
// LeftButton for the zooming
|
||||
// MidButton for the panning
|
||||
// RightButton: zoom out by 1
|
||||
// Ctrl+RighButton: zoom out to full size
|
||||
|
||||
zoomer = new SlsQt2DZoomer(canvas());
|
||||
zoomer = new SlsQt2DZoomer(canvas());
|
||||
zoomer->SetHist(hist);
|
||||
|
||||
#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);
|
||||
|
||||
panner = new QwtPlotPanner(canvas());
|
||||
#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);
|
||||
|
||||
panner = new QwtPlotPanner(canvas());
|
||||
panner->setAxisEnabled(QwtPlot::yRight, false);
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
|
||||
// Avoid jumping when labels with more/less digits
|
||||
// appear/disappear when scrolling vertically
|
||||
// Avoid jumping when labels with more/less digits
|
||||
// appear/disappear when scrolling vertically
|
||||
|
||||
const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
|
||||
QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
|
||||
sd->setMinimumExtent( fm.width("100.00") );
|
||||
const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
|
||||
QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
|
||||
sd->setMinimumExtent(fm.width("100.00"));
|
||||
|
||||
const QColor c(Qt::darkBlue);
|
||||
zoomer->setRubberBandPen(c);
|
||||
@ -164,211 +159,200 @@ void SlsQt2DPlot::SetupZoom(){
|
||||
//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()));
|
||||
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);
|
||||
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){
|
||||
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));
|
||||
#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::SetZMinMax(double zmin,double zmax){
|
||||
hist->SetMinMax(zmin,zmax);
|
||||
void SlsQt2DPlot::SetZMinMax(double zmin, double zmax) {
|
||||
hist->SetMinMax(zmin, zmax);
|
||||
}
|
||||
|
||||
QwtLinearColorMap *SlsQt2DPlot::myColourMap(QVector<double> colourStops) {
|
||||
|
||||
QwtLinearColorMap* SlsQt2DPlot::myColourMap(QVector<double> colourStops) {
|
||||
|
||||
int ns=5;
|
||||
|
||||
double r[]={0.00, 0.00, 0.87, 1.00, 0.51};
|
||||
double g[]={0.00, 0.81, 1.00, 0.20, 0.00};
|
||||
double b[] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
|
||||
int ns = 5;
|
||||
|
||||
QColor c1,c2,c;
|
||||
c1.setRgbF(r[0],g[0],b[0],0);
|
||||
c2.setRgbF(r[ns-1],g[ns-1],b[ns-1]);
|
||||
QwtLinearColorMap* copyMap = new QwtLinearColorMap(Qt::lightGray, c2);
|
||||
double r[] = {0.00, 0.00, 0.87, 1.00, 0.51};
|
||||
double g[] = {0.00, 0.81, 1.00, 0.20, 0.00};
|
||||
double b[] = {0.51, 1.00, 0.12, 0.00, 0.00};
|
||||
|
||||
for (int is=0; is<ns-1; is++) {
|
||||
c.setRgbF(r[is],g[is],b[is]);
|
||||
copyMap->addColorStop(colourStops.value(is),c );
|
||||
}
|
||||
QColor c1, c2, c;
|
||||
c1.setRgbF(r[0], g[0], b[0], 0);
|
||||
c2.setRgbF(r[ns - 1], g[ns - 1], b[ns - 1]);
|
||||
QwtLinearColorMap *copyMap = new QwtLinearColorMap(Qt::lightGray, c2);
|
||||
|
||||
return copyMap;
|
||||
for (int is = 0; is < ns - 1; is++) {
|
||||
c.setRgbF(r[is], g[is], b[is]);
|
||||
copyMap->addColorStop(colourStops.value(is), c);
|
||||
}
|
||||
|
||||
|
||||
return copyMap;
|
||||
}
|
||||
QwtLinearColorMap* SlsQt2DPlot::myColourMap(int log) {
|
||||
|
||||
int ns=5;
|
||||
|
||||
|
||||
QVector<double> cs1(0);
|
||||
QVector<double> lcs1(0);
|
||||
|
||||
|
||||
cs1.append(0.);
|
||||
cs1.append(0.34);
|
||||
cs1.append(0.61);
|
||||
cs1.append(0.84);
|
||||
cs1.append(1.);
|
||||
if (log) {
|
||||
for (int is=0; is<ns; is++) {
|
||||
lcs1.append((pow(10,2*cs1.value(is))-1)/99.0);
|
||||
}
|
||||
return myColourMap(lcs1);
|
||||
}
|
||||
|
||||
return myColourMap(cs1);
|
||||
QwtLinearColorMap *SlsQt2DPlot::myColourMap(int log) {
|
||||
|
||||
int ns = 5;
|
||||
|
||||
QVector<double> cs1(0);
|
||||
QVector<double> lcs1(0);
|
||||
|
||||
cs1.append(0.);
|
||||
cs1.append(0.34);
|
||||
cs1.append(0.61);
|
||||
cs1.append(0.84);
|
||||
cs1.append(1.);
|
||||
if (log) {
|
||||
for (int is = 0; is < ns; is++) {
|
||||
lcs1.append((pow(10, 2 * cs1.value(is)) - 1) / 99.0);
|
||||
}
|
||||
return myColourMap(lcs1);
|
||||
}
|
||||
|
||||
return myColourMap(cs1);
|
||||
}
|
||||
|
||||
|
||||
void SlsQt2DPlot::Update(){
|
||||
#if QWT_VERSION<0x060000
|
||||
rightAxis->setColorMap(d_spectrogram->data().range(),d_spectrogram->colorMap());
|
||||
void SlsQt2DPlot::Update() {
|
||||
#if QWT_VERSION < 0x060000
|
||||
rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap());
|
||||
#else
|
||||
if (isLog)
|
||||
hist->SetMinimumToFirstGreaterThanZero();
|
||||
if (isLog)
|
||||
hist->SetMinimumToFirstGreaterThanZero();
|
||||
|
||||
const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis );
|
||||
|
||||
rightAxis->setColorMap(zInterval,myColourMap(isLog));
|
||||
const QwtInterval zInterval = d_spectrogram->data()->interval(Qt::ZAxis);
|
||||
|
||||
rightAxis->setColorMap(zInterval, myColourMap(isLog));
|
||||
|
||||
#endif
|
||||
|
||||
if(!zoomer->zoomRectIndex()) UnZoom();
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
if (!zoomer->zoomRectIndex())
|
||||
UnZoom();
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
|
||||
setAxisScale(QwtPlot::yRight,d_spectrogram->data().range().minValue(),
|
||||
d_spectrogram->data().range().maxValue());
|
||||
#else
|
||||
setAxisScale(QwtPlot::yRight, d_spectrogram->data().range().minValue(),
|
||||
d_spectrogram->data().range().maxValue());
|
||||
#else
|
||||
|
||||
|
||||
setAxisScale(QwtPlot::yRight,zInterval.minValue(), zInterval.maxValue());
|
||||
setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue());
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "axis scale set" << endl;
|
||||
std::cout << "axis scale set\n";
|
||||
#endif
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "layout" << endl;
|
||||
std::cout << "layout\n";
|
||||
#endif
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "going to replot" << endl;
|
||||
std::cout << "going to replot\n";
|
||||
#endif
|
||||
replot();
|
||||
replot();
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "done" << endl;
|
||||
std::cout << "done\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SlsQt2DPlot::showContour(bool on){
|
||||
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode,on);
|
||||
Update();
|
||||
void SlsQt2DPlot::showContour(bool on) {
|
||||
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, on);
|
||||
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::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::InterpolatedPlot(bool on){
|
||||
hist->Interpolate(on);
|
||||
Update();
|
||||
void SlsQt2DPlot::InterpolatedPlot(bool on) {
|
||||
hist->Interpolate(on);
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void SlsQt2DPlot::LogZ(bool on){
|
||||
if(on){
|
||||
isLog=1;
|
||||
//if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero();
|
||||
#if QWT_VERSION<0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLogScale);
|
||||
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));
|
||||
d_spectrogram->setColorMap(myColourMap(isLog));
|
||||
#endif
|
||||
setAxisScaleEngine(QwtPlot::yRight,new QwtLog10ScaleEngine);
|
||||
#if QWT_VERSION<0x060000
|
||||
d_spectrogram->setContourLevels(*contourLevelsLog);
|
||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLog10ScaleEngine);
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setContourLevels(*contourLevelsLog);
|
||||
#else
|
||||
d_spectrogram->setContourLevels(contourLevelsLog);
|
||||
d_spectrogram->setContourLevels(contourLevelsLog);
|
||||
#endif
|
||||
}else{
|
||||
isLog=0;
|
||||
} else {
|
||||
isLog = 0;
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
||||
#else
|
||||
d_spectrogram->setColorMap(myColourMap(isLog));
|
||||
#endif
|
||||
|
||||
|
||||
d_spectrogram->setColorMap(myColourMap(isLog));
|
||||
#endif
|
||||
|
||||
setAxisScaleEngine(QwtPlot::yRight,new QwtLinearScaleEngine);
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
d_spectrogram->setContourLevels(*contourLevelsLinear);
|
||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine);
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setContourLevels(*contourLevelsLinear);
|
||||
#else
|
||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
||||
#endif
|
||||
|
||||
}
|
||||
Update();
|
||||
|
||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
||||
#endif
|
||||
}
|
||||
Update();
|
||||
}
|
||||
|
||||
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set
|
||||
void SlsQt2DPlot::DisableZoom(bool disableZoom){
|
||||
void SlsQt2DPlot::DisableZoom(bool disableZoom) {
|
||||
#ifdef VERBOSE
|
||||
if(disableZoom) cout<<"Disabling zoom"<<endl;
|
||||
else cout<<"Enabling zoom"<<endl;
|
||||
if (disableZoom)
|
||||
std::cout << "Disabling zoom\n";
|
||||
else
|
||||
std::cout << "Enabling zoom\n";
|
||||
#endif
|
||||
if(disableZoom){
|
||||
if(zoomer){
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,Qt::NoButton);
|
||||
if (disableZoom) {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlButton);
|
||||
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);
|
||||
}
|
||||
if(panner) panner->setMouseButton(Qt::NoButton);
|
||||
}else {
|
||||
if(zoomer){
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,Qt::LeftButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::NoButton);
|
||||
} else {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton);
|
||||
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);
|
||||
}
|
||||
if(panner) panner->setMouseButton(Qt::MidButton);
|
||||
}
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void SlsQt2DPlot::printPlot(){
|
||||
QPrinter printer;
|
||||
|
2
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx
Normal file → Executable file
2
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx
Normal file → Executable file
@ -14,7 +14,7 @@
|
||||
|
||||
#include "SlsQt2DPlotLayout.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
SlsQt2DPlotLayout::SlsQt2DPlotLayout(QWidget *parent):QGroupBox(parent){
|
||||
the_layout=0;
|
||||
|
1
slsDetectorGui/slsDetectorPlotting/src/SlsQtNumberEntry.cxx
Normal file → Executable file
1
slsDetectorGui/slsDetectorPlotting/src/SlsQtNumberEntry.cxx
Normal file → Executable file
@ -27,7 +27,6 @@
|
||||
|
||||
#include "SlsQtNumberEntry.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SlsQtNumberEntry::SlsQtNumberEntry(QWidget *parent, int with_checkbox, char *start_string, int num_type, char* middle_string, int num2_type, int n_units, char** units, double* unit_factors,char* end_string):QWidget(parent){
|
||||
SetupNumberEntry(with_checkbox,start_string,num_type,middle_string,num2_type,n_units,units,unit_factors,end_string);
|
||||
|
Reference in New Issue
Block a user