Qt5 built in qwt (#570)

- qt4->qt5
- in built qt5 6.1.5 because rhel7 is not upto date with qt5, removed findqwt.cmake
- made a fix in qwt lib (qwt_plot_layout.h) to work with 5.15 and lower versions for qrect constr.
- qt5 forms fixed, qt4 many hard coding forms switched to forms including qtabwidget, scrolls etc, fonts moved to forms
 - docking option enabled by default, removed option to disable docking feature from "Mode"
- added qVersionResolve utility functions to handle compatibility before and after qt5.12
- qtplots (ian's code) takes in gain mode enable to set some settings within the class, with proper gain plot ticks
- ensure gain plots have no zooming of z axis in 2d and y axis in 1d
- removed placeholder text in qpalette in main window form as its not supportd until 5.12 (so using qt5.9 designer insted of qt5.15 to cope)
- tab order
Servers:
- fixed some error messages that were empty for fail in funcs (mostly minor as if this error, major issues)
This commit is contained in:
Dhanya Thattil
2022-11-11 15:15:10 +01:00
committed by GitHub
parent 05f657c106
commit 38cd10d4e6
1697 changed files with 255572 additions and 4708 deletions

View File

@ -3,7 +3,10 @@
/* TODO! short description */
#include "SlsQt1DPlot.h"
#include "qDefs.h"
#include "qVersionResolve.h"
#include "sls/logger.h"
#include <iostream>
#include <qwt_legend.h>
#include <qwt_math.h>
@ -333,7 +336,8 @@ void SlsQtH1DList::Remove(SlsQtH1D *hist) {
}
// 1d plot stuff
SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
SlsQt1DPlot::SlsQt1DPlot(QWidget *parent, bool gain)
: QwtPlot(parent), gainPlot(gain) {
// n_histograms_attached=0;
hline = vline = nullptr;
hist_list = new SlsQtH1DList();
@ -351,6 +355,19 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
setFont(qDefs::GetDefaultFont());
SetTitleFont(qDefs::GetDefaultFont());
SetXFont(qDefs::GetDefaultFont());
SetYFont(qDefs::GetDefaultFont());
if (gainPlot) {
SetTitle("");
SetYTitle("Gain");
DisableZoom(true);
// set only major ticks from 0 to 3
auto div = axisScaleEngine(QwtPlot::yLeft)->divideScale(0, 3, 3, 0, 1);
setAxisScaleDiv(QwtPlot::yLeft, div);
}
}
SlsQt1DPlot::~SlsQt1DPlot() {
@ -543,7 +560,7 @@ void SlsQt1DPlot::InsertVLine(double x) {
void SlsQt1DPlot::SetupZoom() {
// LeftButton for the zooming
// MidButton for the panning
// MiddleButton for the panning
// RightButton: zoom out by 1
// Ctrl+RighButton: zoom out to full size
@ -555,15 +572,14 @@ void SlsQt1DPlot::SetupZoom() {
panner = new QwtPlotPanner((QwtPlotCanvas *)canvas());
panner->setAxisEnabled(QwtPlot::yRight, false);
panner->setMouseButton(Qt::MidButton);
panner->setMouseButton(Qt::MiddleButton);
// 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"));
sd->setMinimumExtent(qResolve_GetQFontWidth(fm, "100.00"));
const QColor c(Qt::darkBlue);
zoomer->setRubberBandPen(c);
zoomer->setTrackerPen(c);
@ -630,7 +646,7 @@ void SlsQt1DPlot::DisableZoom(bool disable) {
Qt::RightButton);
}
if (panner)
panner->setMouseButton(Qt::MidButton);
panner->setMouseButton(Qt::MiddleButton);
}
}
}

View File

@ -1,10 +1,11 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "SlsQt2DPlot.h"
#include "qDefs.h"
#include "qVersionResolve.h"
#include "sls/logger.h"
#include <qlist.h>
#include <qprinter.h>
#include <qtoolbutton.h>
#include <qwt_color_map.h>
#include <qwt_plot_layout.h>
@ -20,7 +21,8 @@
namespace sls {
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent, bool gain)
: QwtPlot(parent), gainPlot(gain) {
isLog = 0;
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
@ -32,7 +34,23 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
d_spectrogram->attach(this);
plotLayout()->setAlignCanvasToScales(true);
FillTestPlot();
setFont(qDefs::GetDefaultFont());
SetTitleFont(qDefs::GetDefaultFont());
SetXFont(qDefs::GetDefaultFont());
SetYFont(qDefs::GetDefaultFont());
SetZFont(qDefs::GetDefaultFont());
Update();
if (gainPlot) {
setTitle("Gain");
SetZTitle("");
enableAxis(QwtPlot::yLeft, false);
enableAxis(QwtPlot::xBottom, false);
DisableZoom(true);
// set only major ticks from 0 to 3
auto div = axisScaleEngine(QwtPlot::yRight)->divideScale(0, 3, 3, 0, 1);
setAxisScaleDiv(QwtPlot::yRight, div);
}
}
SlsQt2DPlot::~SlsQt2DPlot() = default;
@ -118,7 +136,7 @@ void SlsQt2DPlot::FillTestPlot(int mode) {
void SlsQt2DPlot::SetupZoom() {
// LeftButton for the zooming
// MidButton for the panning
// MiddleButton for the panning
// RightButton: zoom out by 1
// Ctrl+RighButton: zoom out to full size
@ -129,15 +147,14 @@ void SlsQt2DPlot::SetupZoom() {
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
panner = new QwtPlotPanner(canvas());
panner->setAxisEnabled(QwtPlot::yRight, false);
panner->setMouseButton(Qt::MidButton);
panner->setMouseButton(Qt::MiddleButton);
// 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"));
sd->setMinimumExtent(qResolve_GetQFontWidth(fm, "100.00"));
const QColor c(Qt::darkBlue);
zoomer->setRubberBandPen(c);
zoomer->setTrackerPen(c);
@ -221,7 +238,7 @@ void SlsQt2DPlot::DisableZoom(bool disable) {
Qt::RightButton);
}
if (panner)
panner->setMouseButton(Qt::MidButton);
panner->setMouseButton(Qt::MiddleButton);
}
}
}
@ -265,10 +282,12 @@ void SlsQt2DPlot::Update() {
hist->SetMinimumToFirstGreaterThanZero();
const QwtInterval zInterval = d_spectrogram->data()->interval(Qt::ZAxis);
rightAxis->setColorMap(zInterval, myColourMap(isLog));
if (!zoomer->zoomRectIndex())
UnZoom();
setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue());
if (!gainPlot) {
setAxisScale(QwtPlot::yRight, zInterval.minValue(),
zInterval.maxValue());
}
plotLayout()->setAlignCanvasToScales(true);
replot();
}