Auto status change to "Under Review"
@@ -2,6 +2,7 | |||
|
2 | 2 | #define SCIQLOP_CATALOGUEEVENTSWIDGET_H |
|
3 | 3 | |
|
4 | 4 | #include <Common/spimpl.h> |
|
5 | #include <QLoggingCategory> | |
|
5 | 6 | #include <QWidget> |
|
6 | 7 | |
|
7 | 8 | class DBCatalogue; |
@@ -12,6 +13,8 namespace Ui { | |||
|
12 | 13 | class CatalogueEventsWidget; |
|
13 | 14 | } |
|
14 | 15 | |
|
16 | Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueEventsWidget) | |
|
17 | ||
|
15 | 18 | class CatalogueEventsWidget : public QWidget { |
|
16 | 19 | Q_OBJECT |
|
17 | 20 |
@@ -34,6 +34,10 public: | |||
|
34 | 34 | /// Returns the list of zone widget names in the order they are displayed |
|
35 | 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 | 42 | * Creates a zone using a variable. The variable will be displayed in a new graph of the new |
|
39 | 43 | * zone. The zone is added at the end. |
@@ -1,6 +1,7 | |||
|
1 | 1 | #ifndef SCIQLOP_VISUALIZATIONZONEWIDGET_H |
|
2 | 2 | #define SCIQLOP_VISUALIZATIONZONEWIDGET_H |
|
3 | 3 | |
|
4 | #include "Data/SqpRange.h" | |
|
4 | 5 | #include "Visualization/IVisualizationWidget.h" |
|
5 | 6 | #include "Visualization/VisualizationDragWidget.h" |
|
6 | 7 | |
@@ -27,6 +28,10 public: | |||
|
27 | 28 | explicit VisualizationZoneWidget(const QString &name = {}, QWidget *parent = 0); |
|
28 | 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 | 35 | /// Adds a graph widget |
|
31 | 36 | void addGraph(VisualizationGraphWidget *graphWidget); |
|
32 | 37 |
@@ -8,11 +8,13 | |||
|
8 | 8 | #include <SqpApplication.h> |
|
9 | 9 | #include <Visualization/VisualizationTabWidget.h> |
|
10 | 10 | #include <Visualization/VisualizationWidget.h> |
|
11 | #include <Visualization/VisualizationZoneWidget.h> | |
|
11 | 12 | |
|
12 | 13 | #include <QDialog> |
|
13 | 14 | #include <QDialogButtonBox> |
|
14 | 15 | #include <QListWidget> |
|
15 | 16 | |
|
17 | Q_LOGGING_CATEGORY(LOG_CatalogueEventsWidget, "CatalogueEventsWidget") | |
|
16 | 18 | |
|
17 | 19 | /// Format of the dates appearing in the label of a cursor |
|
18 | 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 | 22 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { |
|
21 | 23 | |
|
22 | 24 | CatalogueEventsTableModel *m_Model = nullptr; |
|
23 | QString m_ZoneForTimeMode; | |
|
25 | QStringList m_ZonesForTimeMode; | |
|
24 | 26 | QString m_ZoneForGraphMode; |
|
25 | 27 | |
|
26 | 28 | VisualizationWidget *m_VisualizationWidget = nullptr; |
@@ -128,6 +130,68 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |||
|
128 | 130 | |
|
129 | 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 | 197 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) |
@@ -147,10 +211,11 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |||
|
147 | 211 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { |
|
148 | 212 | if (checked) { |
|
149 | 213 | ui->btnChart->setChecked(false); |
|
150 | impl->m_ZoneForTimeMode | |
|
151 |
= impl->selectZone(this, |
|
|
152 | this->mapToGlobal(ui->btnTime->frameGeometry().center())) | |
|
153 | .value(0); | |
|
214 | impl->m_ZonesForTimeMode | |
|
215 | = impl->selectZone(this, impl->m_ZonesForTimeMode, true, | |
|
216 | this->mapToGlobal(ui->btnTime->frameGeometry().center())); | |
|
217 | ||
|
218 | impl->updateForTimeMode(ui->tableView); | |
|
154 | 219 | } |
|
155 | 220 | }); |
|
156 | 221 | |
@@ -161,6 +226,8 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |||
|
161 | 226 | = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false, |
|
162 | 227 | this->mapToGlobal(ui->btnChart->frameGeometry().center())) |
|
163 | 228 | .value(0); |
|
229 | ||
|
230 | impl->updateForGraphMode(ui->tableView); | |
|
164 | 231 | } |
|
165 | 232 | }); |
|
166 | 233 | |
@@ -180,6 +247,13 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |||
|
180 | 247 | auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1; |
|
181 | 248 | ui->btnChart->setEnabled(isNotMultiSelection); |
|
182 | 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 | 259 | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); |
@@ -131,6 +131,18 QStringList VisualizationTabWidget::availableZoneWidgets() const | |||
|
131 | 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 | 146 | VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable) |
|
135 | 147 | { |
|
136 | 148 | return createZone({variable}, -1); |
@@ -148,6 +148,17 VisualizationZoneWidget::~VisualizationZoneWidget() | |||
|
148 | 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 | 162 | void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget) |
|
152 | 163 | { |
|
153 | 164 | // Synchronize new graph with others in the zone |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now