##// END OF EJS Templates
Time Zone Mode + prepare graph mode
trabillard -
r1171:f7fe3621eadc
parent child
Show More
@@ -2,6 +2,7
2 #define SCIQLOP_CATALOGUEEVENTSWIDGET_H
2 #define SCIQLOP_CATALOGUEEVENTSWIDGET_H
3
3
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5 #include <QLoggingCategory>
5 #include <QWidget>
6 #include <QWidget>
6
7
7 class DBCatalogue;
8 class DBCatalogue;
@@ -12,6 +13,8 namespace Ui {
12 class CatalogueEventsWidget;
13 class CatalogueEventsWidget;
13 }
14 }
14
15
16 Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueEventsWidget)
17
15 class CatalogueEventsWidget : public QWidget {
18 class CatalogueEventsWidget : public QWidget {
16 Q_OBJECT
19 Q_OBJECT
17
20
@@ -34,6 +34,10 public:
34 /// Returns the list of zone widget names in the order they are displayed
34 /// Returns the list of zone widget names in the order they are displayed
35 QStringList availableZoneWidgets() const;
35 QStringList availableZoneWidgets() const;
36
36
37 /// Returns the zone with the specified name.
38 /// If multiple zone with the same name exist, the first one is returned.
39 VisualizationZoneWidget *getZoneWithName(const QString &zoneName);
40
37 /**
41 /**
38 * Creates a zone using a variable. The variable will be displayed in a new graph of the new
42 * Creates a zone using a variable. The variable will be displayed in a new graph of the new
39 * zone. The zone is added at the end.
43 * zone. The zone is added at the end.
@@ -1,6 +1,7
1 #ifndef SCIQLOP_VISUALIZATIONZONEWIDGET_H
1 #ifndef SCIQLOP_VISUALIZATIONZONEWIDGET_H
2 #define SCIQLOP_VISUALIZATIONZONEWIDGET_H
2 #define SCIQLOP_VISUALIZATIONZONEWIDGET_H
3
3
4 #include "Data/SqpRange.h"
4 #include "Visualization/IVisualizationWidget.h"
5 #include "Visualization/IVisualizationWidget.h"
5 #include "Visualization/VisualizationDragWidget.h"
6 #include "Visualization/VisualizationDragWidget.h"
6
7
@@ -27,6 +28,10 public:
27 explicit VisualizationZoneWidget(const QString &name = {}, QWidget *parent = 0);
28 explicit VisualizationZoneWidget(const QString &name = {}, QWidget *parent = 0);
28 virtual ~VisualizationZoneWidget();
29 virtual ~VisualizationZoneWidget();
29
30
31 /// Sets the range of the zone, only works if there is at least one graph in the zone
32 /// Note: calibrations between graphs are lost.
33 void setZoneRange(const SqpRange &range);
34
30 /// Adds a graph widget
35 /// Adds a graph widget
31 void addGraph(VisualizationGraphWidget *graphWidget);
36 void addGraph(VisualizationGraphWidget *graphWidget);
32
37
@@ -8,11 +8,13
8 #include <SqpApplication.h>
8 #include <SqpApplication.h>
9 #include <Visualization/VisualizationTabWidget.h>
9 #include <Visualization/VisualizationTabWidget.h>
10 #include <Visualization/VisualizationWidget.h>
10 #include <Visualization/VisualizationWidget.h>
11 #include <Visualization/VisualizationZoneWidget.h>
11
12
12 #include <QDialog>
13 #include <QDialog>
13 #include <QDialogButtonBox>
14 #include <QDialogButtonBox>
14 #include <QListWidget>
15 #include <QListWidget>
15
16
17 Q_LOGGING_CATEGORY(LOG_CatalogueEventsWidget, "CatalogueEventsWidget")
16
18
17 /// Format of the dates appearing in the label of a cursor
19 /// Format of the dates appearing in the label of a cursor
18 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss");
20 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss");
@@ -20,7 +22,7 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss");
20 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
22 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
21
23
22 CatalogueEventsTableModel *m_Model = nullptr;
24 CatalogueEventsTableModel *m_Model = nullptr;
23 QString m_ZoneForTimeMode;
25 QStringList m_ZonesForTimeMode;
24 QString m_ZoneForGraphMode;
26 QString m_ZoneForGraphMode;
25
27
26 VisualizationWidget *m_VisualizationWidget = nullptr;
28 VisualizationWidget *m_VisualizationWidget = nullptr;
@@ -128,6 +130,68 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
128
130
129 return result;
131 return result;
130 }
132 }
133
134 void updateForTimeMode(QTableView *tableView)
135 {
136 auto selectedRows = tableView->selectionModel()->selectedRows();
137
138 if (selectedRows.count() == 1) {
139 auto event = m_Model->getEvent(selectedRows.first().row());
140 if (m_VisualizationWidget) {
141 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
142
143 for (auto zoneName : m_ZonesForTimeMode) {
144 if (auto zone = tab->getZoneWithName(zoneName)) {
145 SqpRange eventRange;
146 eventRange.m_TStart = event.getTStart();
147 eventRange.m_TEnd = event.getTEnd();
148 zone->setZoneRange(eventRange);
149 }
150 }
151 }
152 else {
153 qCWarning(LOG_CatalogueEventsWidget())
154 << "updateTimeZone: no tab found in the visualization";
155 }
156 }
157 else {
158 qCWarning(LOG_CatalogueEventsWidget())
159 << "updateTimeZone: visualization widget not found";
160 }
161 }
162 else {
163 qCWarning(LOG_CatalogueEventsWidget())
164 << "updateTimeZone: not compatible with multiple events selected";
165 }
166 }
167
168 void updateForGraphMode(QTableView *tableView)
169 {
170 auto selectedRows = tableView->selectionModel()->selectedRows();
171
172 if (selectedRows.count() == 1) {
173 auto event = m_Model->getEvent(selectedRows.first().row());
174 if (m_VisualizationWidget) {
175 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
176 if (auto zone = tab->getZoneWithName(m_ZoneForGraphMode)) {
177 // TODO
178 }
179 }
180 else {
181 qCWarning(LOG_CatalogueEventsWidget())
182 << "updateGraphMode: no tab found in the visualization";
183 }
184 }
185 else {
186 qCWarning(LOG_CatalogueEventsWidget())
187 << "updateGraphMode: visualization widget not found";
188 }
189 }
190 else {
191 qCWarning(LOG_CatalogueEventsWidget())
192 << "updateGraphMode: not compatible with multiple events selected";
193 }
194 }
131 };
195 };
132
196
133 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
197 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
@@ -147,10 +211,11 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
147 connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) {
211 connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) {
148 if (checked) {
212 if (checked) {
149 ui->btnChart->setChecked(false);
213 ui->btnChart->setChecked(false);
150 impl->m_ZoneForTimeMode
214 impl->m_ZonesForTimeMode
151 = impl->selectZone(this, {impl->m_ZoneForTimeMode}, false,
215 = impl->selectZone(this, impl->m_ZonesForTimeMode, true,
152 this->mapToGlobal(ui->btnTime->frameGeometry().center()))
216 this->mapToGlobal(ui->btnTime->frameGeometry().center()));
153 .value(0);
217
218 impl->updateForTimeMode(ui->tableView);
154 }
219 }
155 });
220 });
156
221
@@ -161,6 +226,8 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
161 = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false,
226 = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false,
162 this->mapToGlobal(ui->btnChart->frameGeometry().center()))
227 this->mapToGlobal(ui->btnChart->frameGeometry().center()))
163 .value(0);
228 .value(0);
229
230 impl->updateForGraphMode(ui->tableView);
164 }
231 }
165 });
232 });
166
233
@@ -180,6 +247,13 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
180 auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1;
247 auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1;
181 ui->btnChart->setEnabled(isNotMultiSelection);
248 ui->btnChart->setEnabled(isNotMultiSelection);
182 ui->btnTime->setEnabled(isNotMultiSelection);
249 ui->btnTime->setEnabled(isNotMultiSelection);
250
251 if (isNotMultiSelection && ui->btnTime->isChecked()) {
252 impl->updateForTimeMode(ui->tableView);
253 }
254 else if (isNotMultiSelection && ui->btnChart->isChecked()) {
255 impl->updateForGraphMode(ui->tableView);
256 }
183 });
257 });
184
258
185 ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
259 ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
@@ -131,6 +131,18 QStringList VisualizationTabWidget::availableZoneWidgets() const
131 return zones;
131 return zones;
132 }
132 }
133
133
134 VisualizationZoneWidget *VisualizationTabWidget::getZoneWithName(const QString &zoneName)
135 {
136 VisualizationZoneWidget *result = nullptr;
137 processZones(tabLayout(), [&zoneName, &result](VisualizationZoneWidget &zoneWidget) {
138 if (!result && zoneWidget.name() == zoneName) {
139 result = &zoneWidget;
140 }
141 });
142
143 return result;
144 }
145
134 VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable)
146 VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable)
135 {
147 {
136 return createZone({variable}, -1);
148 return createZone({variable}, -1);
@@ -148,6 +148,17 VisualizationZoneWidget::~VisualizationZoneWidget()
148 delete ui;
148 delete ui;
149 }
149 }
150
150
151 void VisualizationZoneWidget::setZoneRange(const SqpRange &range)
152 {
153 if (auto graph = firstGraph()) {
154 graph->setGraphRange(range);
155 }
156 else {
157 qCWarning(LOG_VisualizationZoneWidget())
158 << tr("setZoneRange:Cannot set the range of an empty zone.");
159 }
160 }
161
151 void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
162 void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
152 {
163 {
153 // Synchronize new graph with others in the zone
164 // Synchronize new graph with others in the zone
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

You need to be logged in to leave comments. Login now