@@ -0,0 +1,18 | |||
|
1 | #ifndef SCIQLOP_MACSCROLLBARSTYLE_H | |
|
2 | #define SCIQLOP_MACSCROLLBARSTYLE_H | |
|
3 | ||
|
4 | #include <QProxyStyle> | |
|
5 | ||
|
6 | /** | |
|
7 | * @brief Special style to always display the scrollbars on MAC. | |
|
8 | */ | |
|
9 | class MacScrollBarStyle : public QProxyStyle { | |
|
10 | ||
|
11 | public: | |
|
12 | int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, | |
|
13 | QStyleHintReturn *returnData) const; | |
|
14 | ||
|
15 | void selfInstallOn(QWidget *widget, bool installOnSubWidgets); | |
|
16 | }; | |
|
17 | ||
|
18 | #endif // SCIQLOP_MACSCROLLBARSTYLE_H |
@@ -0,0 +1,40 | |||
|
1 | #include "Visualization/MacScrollBarStyle.h" | |
|
2 | ||
|
3 | #include <QWidget> | |
|
4 | ||
|
5 | int MacScrollBarStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *option, | |
|
6 | const QWidget *widget, QStyleHintReturn *returnData) const | |
|
7 | { | |
|
8 | switch (hint) { | |
|
9 | case SH_ScrollBar_Transient: | |
|
10 | return false; // Makes the scrollbar always visible | |
|
11 | case SH_ScrollView_FrameOnlyAroundContents: | |
|
12 | return true; // Avoid that the scrollbar is drawn on top of the widget | |
|
13 | default: | |
|
14 | break; | |
|
15 | } | |
|
16 | ||
|
17 | return QProxyStyle::styleHint(hint, option, widget, returnData); | |
|
18 | } | |
|
19 | ||
|
20 | void MacScrollBarStyle::selfInstallOn(QWidget *widget, bool installOnSubWidgets) | |
|
21 | { | |
|
22 | // Note: a style can be installed on a particular widget but it is not automatically applied its | |
|
23 | // children widgets. | |
|
24 | ||
|
25 | QList<QWidget *> widgetsToStyle{widget}; | |
|
26 | while (!widgetsToStyle.isEmpty()) { | |
|
27 | ||
|
28 | auto widget = widgetsToStyle.takeFirst(); | |
|
29 | widget->setStyle(this); | |
|
30 | ||
|
31 | if (installOnSubWidgets) { | |
|
32 | for (auto child : widget->children()) { | |
|
33 | auto childWidget = qobject_cast<QWidget *>(child); | |
|
34 | if (childWidget) { | |
|
35 | widgetsToStyle << childWidget; | |
|
36 | } | |
|
37 | } | |
|
38 | } | |
|
39 | } | |
|
40 | } |
@@ -3,8 +3,11 | |||
|
3 | 3 | |
|
4 | 4 | #include <memory> |
|
5 | 5 | |
|
6 | #include <QtCore/QLoggingCategory> | |
|
6 | 7 | #include <QtCore/QString> |
|
7 | 8 | |
|
9 | Q_DECLARE_LOGGING_CATEGORY(LOG_AxisRenderingUtils) | |
|
10 | ||
|
8 | 11 | class IDataSeries; |
|
9 | 12 | class QCPAxis; |
|
10 | 13 | class QCPColorScale; |
@@ -5,6 +5,10 | |||
|
5 | 5 | |
|
6 | 6 | #include <memory> |
|
7 | 7 | |
|
8 | #include <QtCore/QLoggingCategory> | |
|
9 | ||
|
10 | Q_DECLARE_LOGGING_CATEGORY(LOG_PlottablesRenderingUtils) | |
|
11 | ||
|
8 | 12 | class IDataSeries; |
|
9 | 13 | class QCPColorScale; |
|
10 | 14 | class QCustomPlot; |
@@ -76,9 +76,10 gui_sources = [ | |||
|
76 | 76 | 'src/Visualization/operations/RemoveVariableOperation.cpp', |
|
77 | 77 | 'src/Visualization/operations/RescaleAxeOperation.cpp', |
|
78 | 78 | 'src/Visualization/VisualizationDragDropContainer.cpp', |
|
79 | 'src/Visualization/VisualizationDragWidget.cpp' | |
|
79 | 'src/Visualization/VisualizationDragWidget.cpp', | |
|
80 | 80 | 'src/Visualization/AxisRenderingUtils.cpp', |
|
81 | 'src/Visualization/PlottablesRenderingUtils.cpp' | |
|
81 | 'src/Visualization/PlottablesRenderingUtils.cpp', | |
|
82 | 'src/Visualization/MacScrollBarStyle.cpp' | |
|
82 | 83 | ] |
|
83 | 84 | |
|
84 | 85 | gui_inc = include_directories(['include']) |
@@ -6,6 +6,8 | |||
|
6 | 6 | |
|
7 | 7 | #include <Visualization/qcustomplot.h> |
|
8 | 8 | |
|
9 | Q_LOGGING_CATEGORY(LOG_AxisRenderingUtils, "AxisRenderingUtils") | |
|
10 | ||
|
9 | 11 | namespace { |
|
10 | 12 | |
|
11 | 13 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss:zzz"); |
@@ -15,7 +17,7 const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss"); | |||
|
15 | 17 | |
|
16 | 18 | /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or |
|
17 | 19 | /// non-time data |
|
18 | QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis) | |
|
20 | QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis, QCPAxis::ScaleType scaleType) | |
|
19 | 21 | { |
|
20 | 22 | if (isTimeAxis) { |
|
21 | 23 | auto dateTicker = QSharedPointer<QCPAxisTickerDateTime>::create(); |
@@ -24,6 +26,9 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis) | |||
|
24 | 26 | |
|
25 | 27 | return dateTicker; |
|
26 | 28 | } |
|
29 | else if (scaleType == QCPAxis::stLogarithmic) { | |
|
30 | return QSharedPointer<QCPAxisTickerLog>::create(); | |
|
31 | } | |
|
27 | 32 | else { |
|
28 | 33 | // default ticker |
|
29 | 34 | return QSharedPointer<QCPAxisTicker>::create(); |
@@ -44,9 +49,14 void setAxisProperties(QCPAxis &axis, const Unit &unit, | |||
|
44 | 49 | |
|
45 | 50 | // scale type |
|
46 | 51 | axis.setScaleType(scaleType); |
|
52 | if (scaleType == QCPAxis::stLogarithmic) { | |
|
53 | // Scientific notation | |
|
54 | axis.setNumberPrecision(0); | |
|
55 | axis.setNumberFormat("eb"); | |
|
56 | } | |
|
47 | 57 | |
|
48 | 58 | // ticker (depending on the type of unit) |
|
49 | axis.setTicker(axisTicker(unit.m_TimeUnit)); | |
|
59 | axis.setTicker(axisTicker(unit.m_TimeUnit, scaleType)); | |
|
50 | 60 | } |
|
51 | 61 | |
|
52 | 62 | /** |
@@ -57,6 +67,7 struct AxisSetter { | |||
|
57 | 67 | static void setProperties(T &, QCustomPlot &, QCPColorScale &) |
|
58 | 68 | { |
|
59 | 69 | // Default implementation does nothing |
|
70 | qCCritical(LOG_AxisRenderingUtils()) << "Can't set axis properties: unmanaged type of data"; | |
|
60 | 71 | } |
|
61 | 72 | }; |
|
62 | 73 | |
@@ -96,7 +107,7 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<SpectrogramSeries | |||
|
96 | 107 | dataSeries.unlock(); |
|
97 | 108 | |
|
98 | 109 | setAxisProperties(*plot.xAxis, xAxisUnit); |
|
99 | setAxisProperties(*plot.yAxis, yAxisUnit); | |
|
110 | setAxisProperties(*plot.yAxis, yAxisUnit, QCPAxis::stLogarithmic); | |
|
100 | 111 | |
|
101 | 112 | // Displays color scale in plot |
|
102 | 113 | plot.plotLayout()->insertRow(0); |
@@ -111,8 +122,7 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<SpectrogramSeries | |||
|
111 | 122 | } |
|
112 | 123 | |
|
113 | 124 | // Set color scale properties |
|
114 | colorScale.setLabel(valuesUnit.m_Name); | |
|
115 | colorScale.setDataScaleType(QCPAxis::stLogarithmic); // Logarithmic scale | |
|
125 | setAxisProperties(*colorScale.axis(), valuesUnit, QCPAxis::stLogarithmic); | |
|
116 | 126 | } |
|
117 | 127 | }; |
|
118 | 128 |
@@ -8,6 +8,8 | |||
|
8 | 8 | |
|
9 | 9 | #include <Visualization/qcustomplot.h> |
|
10 | 10 | |
|
11 | Q_LOGGING_CATEGORY(LOG_PlottablesRenderingUtils, "PlottablesRenderingUtils") | |
|
12 | ||
|
11 | 13 | namespace { |
|
12 | 14 | |
|
13 | 15 | /// Default gradient used for colormap |
@@ -21,6 +23,8 struct PlottablesSetter { | |||
|
21 | 23 | static void setProperties(T &, PlottablesMap &) |
|
22 | 24 | { |
|
23 | 25 | // Default implementation does nothing |
|
26 | qCCritical(LOG_PlottablesRenderingUtils()) | |
|
27 | << "Can't set plottables properties: unmanaged type of data"; | |
|
24 | 28 | } |
|
25 | 29 | }; |
|
26 | 30 | |
@@ -81,6 +85,9 struct PlottablesSetter<T, | |||
|
81 | 85 | colormap->setGradient(DEFAULT_COLORMAP_GRADIENT); |
|
82 | 86 | colormap->rescaleDataRange(); |
|
83 | 87 | } |
|
88 | else { | |
|
89 | qCCritical(LOG_PlottablesRenderingUtils()) << "Can't get colormap of the spectrogram"; | |
|
90 | } | |
|
84 | 91 | } |
|
85 | 92 | }; |
|
86 | 93 |
@@ -5,6 +5,8 | |||
|
5 | 5 | #include "Visualization/VisualizationGraphWidget.h" |
|
6 | 6 | #include "Visualization/VisualizationZoneWidget.h" |
|
7 | 7 | |
|
8 | #include "Visualization/MacScrollBarStyle.h" | |
|
9 | ||
|
8 | 10 | #include "Variable/VariableController.h" |
|
9 | 11 | |
|
10 | 12 | #include "Common/MimeTypesDef.h" |
@@ -55,6 +57,10 struct VisualizationTabWidget::VisualizationTabWidgetPrivate { | |||
|
55 | 57 | |
|
56 | 58 | QString m_Name; |
|
57 | 59 | |
|
60 | #ifdef Q_OS_MAC | |
|
61 | std::unique_ptr<MacScrollBarStyle> m_MacScrollBarStyle = std::make_unique<MacScrollBarStyle>(); | |
|
62 | #endif | |
|
63 | ||
|
58 | 64 | void dropGraph(int index, VisualizationTabWidget *tabWidget); |
|
59 | 65 | void dropZone(int index, VisualizationTabWidget *tabWidget); |
|
60 | 66 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, |
@@ -68,6 +74,10 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *par | |||
|
68 | 74 | { |
|
69 | 75 | ui->setupUi(this); |
|
70 | 76 | |
|
77 | #ifdef Q_OS_MAC | |
|
78 | impl->m_MacScrollBarStyle->selfInstallOn(ui->scrollArea, true); | |
|
79 | #endif | |
|
80 | ||
|
71 | 81 | ui->dragDropContainer->setPlaceHolderType(DragDropHelper::PlaceHolderType::Zone, "Zone"); |
|
72 | 82 | ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 5); |
|
73 | 83 | ui->dragDropContainer->addAcceptedMimeType( |
General Comments 0
You need to be logged in to leave comments.
Login now