gui works, including clone plots

This commit is contained in:
2019-07-17 16:58:04 +02:00
parent d3879bb834
commit 8cdfe4194f
26 changed files with 1812 additions and 1555 deletions

View File

@ -395,18 +395,34 @@ void SlsQt1DPlot::Update() {
replot();
}
void SlsQt1DPlot::SetTitle(const char *title) {
void SlsQt1DPlot::SetTitle(QString title) {
setTitle(title);
}
void SlsQt1DPlot::SetXTitle(const char *title) {
QwtText t(title);
t.setFont(QFont("Sans Serif", 11, QFont::Normal));
void SlsQt1DPlot::SetXTitle(QString title) {
setAxisTitle(QwtPlot::xBottom, title);
}
void SlsQt1DPlot::SetYTitle(QString title) {
setAxisTitle(QwtPlot::yLeft, title);
}
void SlsQt1DPlot::SetTitleFont(const QFont& f) {
QwtText t("");
t.setFont(f);
t.setRenderFlags( Qt::AlignLeft | Qt::AlignVCenter);
setTitle(t);
}
void SlsQt1DPlot::SetXFont(const QFont& f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::xBottom, t);
}
void SlsQt1DPlot::SetYTitle(const char *title) {
QwtText t(title);
t.setFont(QFont("Sans Serif", 11, QFont::Normal));
void SlsQt1DPlot::SetYFont(const QFont& f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::yLeft, t);
}

View File

@ -1,8 +1,5 @@
#include "SlsQt2DPlot.h"
/**
* @author Ian Johnson
* @version 1.0
*/
#include "ansi.h"
#include <cmath>
#include <iostream>
@ -22,7 +19,7 @@
#include <qwt_scale_engine.h>
#include <qwt_scale_widget.h>
#include "SlsQt2DPlot.h"
#if QWT_VERSION >= 0x060100
#define QwtLog10ScaleEngine QwtLogScaleEngine
@ -54,6 +51,48 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
Update();
}
void SlsQt2DPlot::SetTitle(QString title) {
setTitle(title);
}
void SlsQt2DPlot::SetXTitle(QString title) {
setAxisTitle(QwtPlot::xBottom, title);
}
void SlsQt2DPlot::SetYTitle(QString title) {
setAxisTitle(QwtPlot::yLeft, title);
}
void SlsQt2DPlot::SetZTitle(QString title) {
setAxisTitle(QwtPlot::yRight, title);
}
void SlsQt2DPlot::SetTitleFont(const QFont& f) {
QwtText t("");
t.setFont(f);
t.setRenderFlags( Qt::AlignLeft | Qt::AlignVCenter);
setTitle(t);
}
void SlsQt2DPlot::SetXFont(const QFont& f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::xBottom, t);
}
void SlsQt2DPlot::SetYFont(const QFont& f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::yLeft, t);
}
void SlsQt2DPlot::SetZFont(const QFont& f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::yRight, t);
}
void SlsQt2DPlot::SetupColorMap() {
colorMapLinearScale = myColourMap(0);
@ -179,6 +218,45 @@ void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width, double y_wid
#endif
}
void SlsQt2DPlot::DisableZoom(bool disable) {
if (disableZoom != disable) {
disableZoom = disable;
#ifdef VERBOSE
if (disable)
std::cout << "Disabling zoom\n";
else
std::cout << "Enabling zoom\n";
#endif
if (disable) {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
}
if (panner)
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);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
}
if (panner)
panner->setMouseButton(Qt::MidButton);
}
}
}
void SlsQt2DPlot::SetZMinMax(double zmin, double zmax) {
hist->SetMinMax(zmin, zmax);
}
@ -250,22 +328,34 @@ void SlsQt2DPlot::Update() {
}
void SlsQt2DPlot::showContour(bool on) {
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, on);
void SlsQt2DPlot::SetInterpolate(bool enable) {
hist->Interpolate(enable);
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));
void SlsQt2DPlot::SetContour(bool enable) {
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, enable);
Update();
}
void SlsQt2DPlot::InterpolatedPlot(bool on) {
hist->Interpolate(on);
Update();
void SlsQt2DPlot::SetLogz(bool enable, bool isMin, bool isMax, double min, double max) {
LogZ(enable);
SetZRange(isMin, isMax, min, max);
}
void SlsQt2DPlot::SetZRange(bool isMin, bool isMax, double min, double max){
if(isLog) {
SetZMinimumToFirstGreaterThanZero();
}
// set zmin and zmax
if (isMin || isMax) {
double zmin = (isMin ? min : GetZMinimum());
double zmax = (isMax ? max : GetZMaximum());
SetZMinMax(zmin, zmax);
}
Update();
}
void SlsQt2DPlot::LogZ(bool on) {
@ -303,45 +393,15 @@ void SlsQt2DPlot::LogZ(bool on) {
Update();
}
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set
void SlsQt2DPlot::DisableZoom(bool disable) {
if (disableZoom != disable) {
disableZoom = disable;
#ifdef VERBOSE
if (disable)
std::cout << "Disabling zoom\n";
else
std::cout << "Enabling zoom\n";
#endif
if (disable) {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
}
if (panner)
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);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
}
if (panner)
panner->setMouseButton(Qt::MidButton);
}
}
void SlsQt2DPlot::showSpectrogram(bool on) {
// static int io=0;
// FillTestPlot(io++);
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on);
d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen));
Update();
}
/*
void SlsQt2DPlot::printPlot(){
QPrinter printer;

View File

@ -1,81 +0,0 @@
#include "SlsQt2DPlotLayout.h"
#include "logger.h"
#include <iostream>
#include "ansi.h"
#include <qtoolbutton.h>
#include <qgroupbox.h>
#include <qgridlayout.h>
#include <qlabel.h>
#include <QString>
SlsQt2DPlotLayout::SlsQt2DPlotLayout(QWidget *parent):QGroupBox(parent){
the_layout=0;
the_plot = new SlsQt2DPlot(this);
isLog = false;
Layout();
}
SlsQt2DPlotLayout::~SlsQt2DPlotLayout(){
if(the_layout) delete the_layout;
delete the_plot;
}
SlsQt2DPlot* SlsQt2DPlotLayout::GetPlot(){
return the_plot;
}
void SlsQt2DPlotLayout::SetXTitle(QString st){
QwtText title(st);
title.setFont(QFont("Sans Serif",11,QFont::Normal));
GetPlot()->axisWidget(QwtPlot::xBottom)->setTitle(title);
}
void SlsQt2DPlotLayout::SetYTitle(QString st){
QwtText title(st);
title.setFont(QFont("Sans Serif",11,QFont::Normal));
GetPlot()->axisWidget(QwtPlot::yLeft)->setTitle(title);
}
void SlsQt2DPlotLayout::SetZTitle(QString st){
QwtText title(st);
title.setFont(QFont("Sans Serif",11,QFont::Normal));
GetPlot()->axisWidget(QwtPlot::yRight)->setTitle(title);
}
void SlsQt2DPlotLayout::SetInterpolate(bool enable) {
the_plot->InterpolatedPlot(enable);
}
void SlsQt2DPlotLayout::SetContour(bool enable) {
the_plot->showContour(enable);
}
void SlsQt2DPlotLayout::SetLogz(bool enable, bool isMin, bool isMax, double min, double max) {
isLog = enable;
the_plot->LogZ(enable);
SetZRange(isMin, isMax, min, max);
}
void SlsQt2DPlotLayout::Layout(){
if(the_layout) delete the_layout;
the_layout = new QGridLayout(this);
the_layout->addWidget(the_plot,2,0,3,3);
}
void SlsQt2DPlotLayout::SetZRange(bool isMin, bool isMax, double min, double max){
if(isLog) {
the_plot->SetZMinimumToFirstGreaterThanZero();
}
// set zmin and zmax
if (isMin || isMax) {
double zmin = (isMin ? min : the_plot->GetZMinimum());
double zmax = (isMax ? max : the_plot->GetZMaximum());
the_plot->SetZMinMax(zmin, zmax);
}
the_plot->Update();
}