Auto status change to "Under Review"
@@ -0,0 +1,38 | |||||
|
1 | #ifndef SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H | |||
|
2 | #define SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H | |||
|
3 | ||||
|
4 | #include <Common/spimpl.h> | |||
|
5 | #include <QAbstractTableModel> | |||
|
6 | ||||
|
7 | class DBEvent; | |||
|
8 | ||||
|
9 | class CatalogueEventsTableModel : public QAbstractTableModel { | |||
|
10 | public: | |||
|
11 | CatalogueEventsTableModel(QObject *parent = nullptr); | |||
|
12 | ||||
|
13 | void setEvents(const QVector<std::shared_ptr<DBEvent> > &events); | |||
|
14 | std::shared_ptr<DBEvent> getEvent(int row) const; | |||
|
15 | ||||
|
16 | void addEvent(const std::shared_ptr<DBEvent> &events); | |||
|
17 | void removeEvent(const std::shared_ptr<DBEvent> &events); | |||
|
18 | ||||
|
19 | // Model | |||
|
20 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | |||
|
21 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; | |||
|
22 | Qt::ItemFlags flags(const QModelIndex &index) const override; | |||
|
23 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | |||
|
24 | QVariant headerData(int section, Qt::Orientation orientation, | |||
|
25 | int role = Qt::DisplayRole) const override; | |||
|
26 | void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; | |||
|
27 | ||||
|
28 | Qt::DropActions supportedDragActions() const override; | |||
|
29 | QStringList mimeTypes() const override; | |||
|
30 | QMimeData *mimeData(const QModelIndexList &indexes) const override; | |||
|
31 | ||||
|
32 | ||||
|
33 | private: | |||
|
34 | class CatalogueEventsTableModelPrivate; | |||
|
35 | spimpl::unique_impl_ptr<CatalogueEventsTableModelPrivate> impl; | |||
|
36 | }; | |||
|
37 | ||||
|
38 | #endif // SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H |
@@ -0,0 +1,28 | |||||
|
1 | #ifndef SCIQLOP_CATALOGUETREEWIDGETITEM_H | |||
|
2 | #define SCIQLOP_CATALOGUETREEWIDGETITEM_H | |||
|
3 | ||||
|
4 | #include <Common/spimpl.h> | |||
|
5 | #include <QTreeWidgetItem> | |||
|
6 | ||||
|
7 | class DBCatalogue; | |||
|
8 | ||||
|
9 | ||||
|
10 | class CatalogueTreeWidgetItem : public QTreeWidgetItem { | |||
|
11 | public: | |||
|
12 | CatalogueTreeWidgetItem(std::shared_ptr<DBCatalogue> catalogue, | |||
|
13 | int type = QTreeWidgetItem::Type); | |||
|
14 | ||||
|
15 | QVariant data(int column, int role) const override; | |||
|
16 | void setData(int column, int role, const QVariant &value) override; | |||
|
17 | ||||
|
18 | /// Returns the catalogue represented by the item | |||
|
19 | std::shared_ptr<DBCatalogue> catalogue() const; | |||
|
20 | ||||
|
21 | void setHasChanges(bool value); | |||
|
22 | ||||
|
23 | private: | |||
|
24 | class CatalogueTreeWidgetItemPrivate; | |||
|
25 | spimpl::unique_impl_ptr<CatalogueTreeWidgetItemPrivate> impl; | |||
|
26 | }; | |||
|
27 | ||||
|
28 | #endif // SCIQLOP_CATALOGUETREEWIDGETITEM_H |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,185 | |||||
|
1 | #include "Catalogue/CatalogueEventsTableModel.h" | |||
|
2 | ||||
|
3 | #include <Common/DateUtils.h> | |||
|
4 | #include <Common/MimeTypesDef.h> | |||
|
5 | #include <DBEvent.h> | |||
|
6 | #include <DBTag.h> | |||
|
7 | #include <Data/SqpRange.h> | |||
|
8 | #include <QMimeData> | |||
|
9 | #include <SqpApplication.h> | |||
|
10 | #include <Time/TimeController.h> | |||
|
11 | ||||
|
12 | struct CatalogueEventsTableModel::CatalogueEventsTableModelPrivate { | |||
|
13 | QVector<std::shared_ptr<DBEvent> > m_Events; | |||
|
14 | ||||
|
15 | enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn }; | |||
|
16 | QStringList columnNames() | |||
|
17 | { | |||
|
18 | return QStringList{tr("Event"), tr("TStart"), tr("TEnd"), tr("Tags"), tr("Product")}; | |||
|
19 | } | |||
|
20 | ||||
|
21 | QVariant eventData(int col, const std::shared_ptr<DBEvent> &event) const | |||
|
22 | { | |||
|
23 | switch (static_cast<Column>(col)) { | |||
|
24 | case Column::Event: | |||
|
25 | return event->getName(); | |||
|
26 | case Column::TStart: | |||
|
27 | return DateUtils::dateTime(event->getTStart()); | |||
|
28 | case Column::TEnd: | |||
|
29 | return DateUtils::dateTime(event->getTEnd()); | |||
|
30 | case Column::Product: | |||
|
31 | return event->getProduct(); | |||
|
32 | case Column::Tags: { | |||
|
33 | QString tagList; | |||
|
34 | auto tags = event->getTags(); | |||
|
35 | for (auto tag : tags) { | |||
|
36 | tagList += tag.getName(); | |||
|
37 | tagList += ' '; | |||
|
38 | } | |||
|
39 | ||||
|
40 | return tagList; | |||
|
41 | } | |||
|
42 | default: | |||
|
43 | break; | |||
|
44 | } | |||
|
45 | ||||
|
46 | Q_ASSERT(false); | |||
|
47 | return QStringLiteral("Unknown Data"); | |||
|
48 | } | |||
|
49 | }; | |||
|
50 | ||||
|
51 | CatalogueEventsTableModel::CatalogueEventsTableModel(QObject *parent) | |||
|
52 | : QAbstractTableModel(parent), | |||
|
53 | impl{spimpl::make_unique_impl<CatalogueEventsTableModelPrivate>()} | |||
|
54 | { | |||
|
55 | } | |||
|
56 | ||||
|
57 | void CatalogueEventsTableModel::setEvents(const QVector<std::shared_ptr<DBEvent> > &events) | |||
|
58 | { | |||
|
59 | beginResetModel(); | |||
|
60 | impl->m_Events = events; | |||
|
61 | endResetModel(); | |||
|
62 | } | |||
|
63 | ||||
|
64 | std::shared_ptr<DBEvent> CatalogueEventsTableModel::getEvent(int row) const | |||
|
65 | { | |||
|
66 | return impl->m_Events.value(row); | |||
|
67 | } | |||
|
68 | ||||
|
69 | void CatalogueEventsTableModel::addEvent(const std::shared_ptr<DBEvent> &events) | |||
|
70 | { | |||
|
71 | beginInsertRows(QModelIndex(), impl->m_Events.count() - 1, impl->m_Events.count() - 1); | |||
|
72 | // impl->m_Events.append(event); TODO | |||
|
73 | endInsertRows(); | |||
|
74 | } | |||
|
75 | ||||
|
76 | void CatalogueEventsTableModel::removeEvent(const std::shared_ptr<DBEvent> &events) | |||
|
77 | { | |||
|
78 | // TODO | |||
|
79 | auto index = -1; // impl->m_Events.indexOf(event); | |||
|
80 | if (index >= 0) { | |||
|
81 | beginRemoveRows(QModelIndex(), index, index); | |||
|
82 | impl->m_Events.removeAt(index); | |||
|
83 | endRemoveRows(); | |||
|
84 | } | |||
|
85 | } | |||
|
86 | ||||
|
87 | int CatalogueEventsTableModel::rowCount(const QModelIndex &parent) const | |||
|
88 | { | |||
|
89 | int r = impl->m_Events.count(); | |||
|
90 | return r; | |||
|
91 | } | |||
|
92 | ||||
|
93 | int CatalogueEventsTableModel::columnCount(const QModelIndex &parent) const | |||
|
94 | { | |||
|
95 | int c = static_cast<int>(CatalogueEventsTableModelPrivate::Column::NbColumn); | |||
|
96 | return c; | |||
|
97 | } | |||
|
98 | ||||
|
99 | Qt::ItemFlags CatalogueEventsTableModel::flags(const QModelIndex &index) const | |||
|
100 | { | |||
|
101 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QVariant CatalogueEventsTableModel::data(const QModelIndex &index, int role) const | |||
|
105 | { | |||
|
106 | if (index.isValid()) { | |||
|
107 | auto event = getEvent(index.row()); | |||
|
108 | ||||
|
109 | switch (role) { | |||
|
110 | case Qt::DisplayRole: | |||
|
111 | return impl->eventData(index.column(), event); | |||
|
112 | break; | |||
|
113 | } | |||
|
114 | } | |||
|
115 | ||||
|
116 | return QVariant{}; | |||
|
117 | } | |||
|
118 | ||||
|
119 | QVariant CatalogueEventsTableModel::headerData(int section, Qt::Orientation orientation, | |||
|
120 | int role) const | |||
|
121 | { | |||
|
122 | if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | |||
|
123 | return impl->columnNames().value(section); | |||
|
124 | } | |||
|
125 | ||||
|
126 | return QVariant(); | |||
|
127 | } | |||
|
128 | ||||
|
129 | void CatalogueEventsTableModel::sort(int column, Qt::SortOrder order) | |||
|
130 | { | |||
|
131 | std::sort(impl->m_Events.begin(), impl->m_Events.end(), | |||
|
132 | [this, column, order](auto e1, auto e2) { | |||
|
133 | auto data1 = impl->eventData(column, e1); | |||
|
134 | auto data2 = impl->eventData(column, e2); | |||
|
135 | ||||
|
136 | auto result = data1.toString() < data2.toString(); | |||
|
137 | ||||
|
138 | return order == Qt::AscendingOrder ? result : !result; | |||
|
139 | }); | |||
|
140 | ||||
|
141 | emit dataChanged(QModelIndex(), QModelIndex()); | |||
|
142 | } | |||
|
143 | ||||
|
144 | Qt::DropActions CatalogueEventsTableModel::supportedDragActions() const | |||
|
145 | { | |||
|
146 | return Qt::CopyAction | Qt::MoveAction; | |||
|
147 | } | |||
|
148 | ||||
|
149 | QStringList CatalogueEventsTableModel::mimeTypes() const | |||
|
150 | { | |||
|
151 | return {MIME_TYPE_EVENT_LIST, MIME_TYPE_TIME_RANGE}; | |||
|
152 | } | |||
|
153 | ||||
|
154 | QMimeData *CatalogueEventsTableModel::mimeData(const QModelIndexList &indexes) const | |||
|
155 | { | |||
|
156 | auto mimeData = new QMimeData; | |||
|
157 | ||||
|
158 | QVector<std::shared_ptr<DBEvent> > eventList; | |||
|
159 | ||||
|
160 | SqpRange firstTimeRange; | |||
|
161 | for (const auto &index : indexes) { | |||
|
162 | if (index.column() == 0) { // only the first column | |||
|
163 | auto event = getEvent(index.row()); | |||
|
164 | if (eventList.isEmpty()) { | |||
|
165 | // Gets the range of the first variable | |||
|
166 | firstTimeRange.m_TStart = event->getTStart(); | |||
|
167 | firstTimeRange.m_TEnd = event->getTEnd(); | |||
|
168 | } | |||
|
169 | ||||
|
170 | eventList << event; | |||
|
171 | } | |||
|
172 | } | |||
|
173 | ||||
|
174 | auto eventsEncodedData | |||
|
175 | = QByteArray{}; // sqpApp->catalogueController().->mimeDataForEvents(eventList); //TODO | |||
|
176 | mimeData->setData(MIME_TYPE_EVENT_LIST, eventsEncodedData); | |||
|
177 | ||||
|
178 | if (eventList.count() == 1) { | |||
|
179 | // No time range MIME data if multiple events are dragged | |||
|
180 | auto timeEncodedData = TimeController::mimeDataForTimeRange(firstTimeRange); | |||
|
181 | mimeData->setData(MIME_TYPE_TIME_RANGE, timeEncodedData); | |||
|
182 | } | |||
|
183 | ||||
|
184 | return mimeData; | |||
|
185 | } |
@@ -0,0 +1,93 | |||||
|
1 | #include "Catalogue/CatalogueTreeWidgetItem.h" | |||
|
2 | ||||
|
3 | #include <memory> | |||
|
4 | ||||
|
5 | #include <DBCatalogue.h> | |||
|
6 | #include <QBoxLayout> | |||
|
7 | #include <QToolButton> | |||
|
8 | ||||
|
9 | const auto VALIDATION_BUTTON_ICON_SIZE = 12; | |||
|
10 | ||||
|
11 | struct CatalogueTreeWidgetItem::CatalogueTreeWidgetItemPrivate { | |||
|
12 | ||||
|
13 | std::shared_ptr<DBCatalogue> m_Catalogue; | |||
|
14 | ||||
|
15 | CatalogueTreeWidgetItemPrivate(std::shared_ptr<DBCatalogue> catalogue) : m_Catalogue(catalogue) | |||
|
16 | { | |||
|
17 | } | |||
|
18 | }; | |||
|
19 | ||||
|
20 | ||||
|
21 | CatalogueTreeWidgetItem::CatalogueTreeWidgetItem(std::shared_ptr<DBCatalogue> catalogue, int type) | |||
|
22 | : QTreeWidgetItem(type), | |||
|
23 | impl{spimpl::make_unique_impl<CatalogueTreeWidgetItemPrivate>(catalogue)} | |||
|
24 | { | |||
|
25 | setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable); | |||
|
26 | } | |||
|
27 | ||||
|
28 | QVariant CatalogueTreeWidgetItem::data(int column, int role) const | |||
|
29 | { | |||
|
30 | if (column == 0) { | |||
|
31 | switch (role) { | |||
|
32 | case Qt::EditRole: // fallthrough | |||
|
33 | case Qt::DisplayRole: | |||
|
34 | return impl->m_Catalogue->getName(); | |||
|
35 | default: | |||
|
36 | break; | |||
|
37 | } | |||
|
38 | } | |||
|
39 | ||||
|
40 | return QTreeWidgetItem::data(column, role); | |||
|
41 | } | |||
|
42 | ||||
|
43 | void CatalogueTreeWidgetItem::setData(int column, int role, const QVariant &value) | |||
|
44 | { | |||
|
45 | if (role == Qt::EditRole && column == 0) { | |||
|
46 | auto newName = value.toString(); | |||
|
47 | if (newName != impl->m_Catalogue->getName()) { | |||
|
48 | setText(0, newName); | |||
|
49 | impl->m_Catalogue->setName(newName); | |||
|
50 | setHasChanges(true); | |||
|
51 | } | |||
|
52 | } | |||
|
53 | else { | |||
|
54 | QTreeWidgetItem::setData(column, role, value); | |||
|
55 | } | |||
|
56 | } | |||
|
57 | ||||
|
58 | std::shared_ptr<DBCatalogue> CatalogueTreeWidgetItem::catalogue() const | |||
|
59 | { | |||
|
60 | return impl->m_Catalogue; | |||
|
61 | } | |||
|
62 | ||||
|
63 | void CatalogueTreeWidgetItem::setHasChanges(bool value) | |||
|
64 | { | |||
|
65 | if (value) { | |||
|
66 | auto widet = new QWidget{treeWidget()}; | |||
|
67 | ||||
|
68 | auto layout = new QHBoxLayout{widet}; | |||
|
69 | layout->setContentsMargins(0, 0, 0, 0); | |||
|
70 | layout->setSpacing(0); | |||
|
71 | ||||
|
72 | auto btnValid = new QToolButton{widet}; | |||
|
73 | btnValid->setIcon(QIcon{":/icones/save"}); | |||
|
74 | btnValid->setIconSize(QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE}); | |||
|
75 | btnValid->setAutoRaise(true); | |||
|
76 | QObject::connect(btnValid, &QToolButton::clicked, [this]() { setHasChanges(false); }); | |||
|
77 | layout->addWidget(btnValid); | |||
|
78 | ||||
|
79 | auto btnDiscard = new QToolButton{widet}; | |||
|
80 | btnDiscard->setIcon(QIcon{":/icones/discard"}); | |||
|
81 | btnDiscard->setIconSize(QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE}); | |||
|
82 | btnDiscard->setAutoRaise(true); | |||
|
83 | QObject::connect(btnDiscard, &QToolButton::clicked, [this]() { setHasChanges(false); }); | |||
|
84 | layout->addWidget(btnDiscard); | |||
|
85 | ||||
|
86 | treeWidget()->setItemWidget(this, 1, {widet}); | |||
|
87 | treeWidget()->resizeColumnToContents(1); | |||
|
88 | } | |||
|
89 | else { | |||
|
90 | // Note: the widget is destroyed | |||
|
91 | treeWidget()->setItemWidget(this, 1, nullptr); | |||
|
92 | } | |||
|
93 | } |
@@ -1,364 +1,366 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SciQLop Software |
|
2 | -- This file is a part of the SciQLop Software | |
3 | -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "MainWindow.h" |
|
22 | #include "MainWindow.h" | |
23 | #include "ui_MainWindow.h" |
|
23 | #include "ui_MainWindow.h" | |
24 |
|
24 | |||
25 | #include <Catalogue/CatalogueExplorer.h> |
|
25 | #include <Catalogue/CatalogueExplorer.h> | |
26 | #include <DataSource/DataSourceController.h> |
|
26 | #include <DataSource/DataSourceController.h> | |
27 | #include <DataSource/DataSourceWidget.h> |
|
27 | #include <DataSource/DataSourceWidget.h> | |
28 | #include <Settings/SqpSettingsDialog.h> |
|
28 | #include <Settings/SqpSettingsDialog.h> | |
29 | #include <Settings/SqpSettingsGeneralWidget.h> |
|
29 | #include <Settings/SqpSettingsGeneralWidget.h> | |
30 | #include <SidePane/SqpSidePane.h> |
|
30 | #include <SidePane/SqpSidePane.h> | |
31 | #include <SqpApplication.h> |
|
31 | #include <SqpApplication.h> | |
32 | #include <Time/TimeController.h> |
|
32 | #include <Time/TimeController.h> | |
33 | #include <TimeWidget/TimeWidget.h> |
|
33 | #include <TimeWidget/TimeWidget.h> | |
34 | #include <Variable/Variable.h> |
|
34 | #include <Variable/Variable.h> | |
35 | #include <Variable/VariableController.h> |
|
35 | #include <Variable/VariableController.h> | |
36 | #include <Visualization/VisualizationController.h> |
|
36 | #include <Visualization/VisualizationController.h> | |
37 |
|
37 | |||
38 | #include <QAction> |
|
38 | #include <QAction> | |
39 | #include <QDate> |
|
39 | #include <QDate> | |
40 | #include <QDir> |
|
40 | #include <QDir> | |
41 | #include <QFileDialog> |
|
41 | #include <QFileDialog> | |
42 | #include <QToolBar> |
|
42 | #include <QToolBar> | |
43 | #include <QToolButton> |
|
43 | #include <QToolButton> | |
44 | #include <memory.h> |
|
44 | #include <memory.h> | |
45 |
|
45 | |||
46 | #include "iostream" |
|
46 | #include "iostream" | |
47 |
|
47 | |||
48 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") |
|
48 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") | |
49 |
|
49 | |||
50 | namespace { |
|
50 | namespace { | |
51 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; |
|
51 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; | |
52 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; |
|
52 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; | |
53 | const auto VIEWPLITTERINDEX = 2; |
|
53 | const auto VIEWPLITTERINDEX = 2; | |
54 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; |
|
54 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; | |
55 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; |
|
55 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | class MainWindow::MainWindowPrivate { |
|
58 | class MainWindow::MainWindowPrivate { | |
59 | public: |
|
59 | public: | |
60 | explicit MainWindowPrivate(MainWindow *mainWindow) |
|
60 | explicit MainWindowPrivate(MainWindow *mainWindow) | |
61 | : m_LastOpenLeftInspectorSize{}, |
|
61 | : m_LastOpenLeftInspectorSize{}, | |
62 | m_LastOpenRightInspectorSize{}, |
|
62 | m_LastOpenRightInspectorSize{}, | |
63 | m_GeneralSettingsWidget{new SqpSettingsGeneralWidget{mainWindow}}, |
|
63 | m_GeneralSettingsWidget{new SqpSettingsGeneralWidget{mainWindow}}, | |
64 | m_SettingsDialog{new SqpSettingsDialog{mainWindow}}, |
|
64 | m_SettingsDialog{new SqpSettingsDialog{mainWindow}}, | |
65 | m_CatalogExplorer{new CatalogueExplorer{mainWindow}} |
|
65 | m_CatalogExplorer{new CatalogueExplorer{mainWindow}} | |
66 | { |
|
66 | { | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | QSize m_LastOpenLeftInspectorSize; |
|
69 | QSize m_LastOpenLeftInspectorSize; | |
70 | QSize m_LastOpenRightInspectorSize; |
|
70 | QSize m_LastOpenRightInspectorSize; | |
71 | /// General settings widget. MainWindow has the ownership |
|
71 | /// General settings widget. MainWindow has the ownership | |
72 | SqpSettingsGeneralWidget *m_GeneralSettingsWidget; |
|
72 | SqpSettingsGeneralWidget *m_GeneralSettingsWidget; | |
73 | /// Settings dialog. MainWindow has the ownership |
|
73 | /// Settings dialog. MainWindow has the ownership | |
74 | SqpSettingsDialog *m_SettingsDialog; |
|
74 | SqpSettingsDialog *m_SettingsDialog; | |
75 | /// Catalogue dialog. MainWindow has the ownership |
|
75 | /// Catalogue dialog. MainWindow has the ownership | |
76 | CatalogueExplorer *m_CatalogExplorer; |
|
76 | CatalogueExplorer *m_CatalogExplorer; | |
77 | }; |
|
77 | }; | |
78 |
|
78 | |||
79 | MainWindow::MainWindow(QWidget *parent) |
|
79 | MainWindow::MainWindow(QWidget *parent) | |
80 | : QMainWindow{parent}, |
|
80 | : QMainWindow{parent}, | |
81 | m_Ui{new Ui::MainWindow}, |
|
81 | m_Ui{new Ui::MainWindow}, | |
82 | impl{spimpl::make_unique_impl<MainWindowPrivate>(this)} |
|
82 | impl{spimpl::make_unique_impl<MainWindowPrivate>(this)} | |
83 | { |
|
83 | { | |
84 | m_Ui->setupUi(this); |
|
84 | m_Ui->setupUi(this); | |
85 |
|
85 | |||
86 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
86 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); | |
87 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
87 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); | |
88 |
|
88 | |||
|
89 | impl->m_CatalogExplorer->setVisualizationWidget(m_Ui->view); | |||
|
90 | ||||
89 |
|
91 | |||
90 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); |
|
92 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); | |
91 | auto openLeftInspectorAction = new QAction{QIcon{ |
|
93 | auto openLeftInspectorAction = new QAction{QIcon{ | |
92 | ":/icones/previous.png", |
|
94 | ":/icones/previous.png", | |
93 | }, |
|
95 | }, | |
94 | tr("Show/hide the left inspector"), this}; |
|
96 | tr("Show/hide the left inspector"), this}; | |
95 |
|
97 | |||
96 |
|
98 | |||
97 | auto spacerLeftTop = new QWidget{}; |
|
99 | auto spacerLeftTop = new QWidget{}; | |
98 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
100 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
99 |
|
101 | |||
100 | auto spacerLeftBottom = new QWidget{}; |
|
102 | auto spacerLeftBottom = new QWidget{}; | |
101 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
103 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
102 |
|
104 | |||
103 | leftSidePane->addWidget(spacerLeftTop); |
|
105 | leftSidePane->addWidget(spacerLeftTop); | |
104 | leftSidePane->addAction(openLeftInspectorAction); |
|
106 | leftSidePane->addAction(openLeftInspectorAction); | |
105 | leftSidePane->addWidget(spacerLeftBottom); |
|
107 | leftSidePane->addWidget(spacerLeftBottom); | |
106 |
|
108 | |||
107 |
|
109 | |||
108 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); |
|
110 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); | |
109 | auto openRightInspectorAction = new QAction{QIcon{ |
|
111 | auto openRightInspectorAction = new QAction{QIcon{ | |
110 | ":/icones/next.png", |
|
112 | ":/icones/next.png", | |
111 | }, |
|
113 | }, | |
112 | tr("Show/hide the right inspector"), this}; |
|
114 | tr("Show/hide the right inspector"), this}; | |
113 |
|
115 | |||
114 | auto spacerRightTop = new QWidget{}; |
|
116 | auto spacerRightTop = new QWidget{}; | |
115 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
117 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
116 |
|
118 | |||
117 | auto spacerRightBottom = new QWidget{}; |
|
119 | auto spacerRightBottom = new QWidget{}; | |
118 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
120 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
119 |
|
121 | |||
120 | rightSidePane->addWidget(spacerRightTop); |
|
122 | rightSidePane->addWidget(spacerRightTop); | |
121 | rightSidePane->addAction(openRightInspectorAction); |
|
123 | rightSidePane->addAction(openRightInspectorAction); | |
122 | rightSidePane->addWidget(spacerRightBottom); |
|
124 | rightSidePane->addWidget(spacerRightBottom); | |
123 |
|
125 | |||
124 | openLeftInspectorAction->setCheckable(true); |
|
126 | openLeftInspectorAction->setCheckable(true); | |
125 | openRightInspectorAction->setCheckable(true); |
|
127 | openRightInspectorAction->setCheckable(true); | |
126 |
|
128 | |||
127 | auto openInspector = [this](bool checked, bool right, auto action) { |
|
129 | auto openInspector = [this](bool checked, bool right, auto action) { | |
128 |
|
130 | |||
129 | action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"}); |
|
131 | action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"}); | |
130 |
|
132 | |||
131 | auto &lastInspectorSize |
|
133 | auto &lastInspectorSize | |
132 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; |
|
134 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; | |
133 |
|
135 | |||
134 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() |
|
136 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() | |
135 | : m_Ui->leftMainInspectorWidget->size(); |
|
137 | : m_Ui->leftMainInspectorWidget->size(); | |
136 |
|
138 | |||
137 | // Update of the last opened geometry |
|
139 | // Update of the last opened geometry | |
138 | if (checked) { |
|
140 | if (checked) { | |
139 | lastInspectorSize = nextInspectorSize; |
|
141 | lastInspectorSize = nextInspectorSize; | |
140 | } |
|
142 | } | |
141 |
|
143 | |||
142 | auto startSize = lastInspectorSize; |
|
144 | auto startSize = lastInspectorSize; | |
143 | auto endSize = startSize; |
|
145 | auto endSize = startSize; | |
144 | endSize.setWidth(0); |
|
146 | endSize.setWidth(0); | |
145 |
|
147 | |||
146 | auto splitterInspectorIndex |
|
148 | auto splitterInspectorIndex | |
147 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; |
|
149 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; | |
148 |
|
150 | |||
149 | auto currentSizes = m_Ui->splitter->sizes(); |
|
151 | auto currentSizes = m_Ui->splitter->sizes(); | |
150 | if (checked) { |
|
152 | if (checked) { | |
151 | // adjust sizes individually here, e.g. |
|
153 | // adjust sizes individually here, e.g. | |
152 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); |
|
154 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); | |
153 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); |
|
155 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); | |
154 | m_Ui->splitter->setSizes(currentSizes); |
|
156 | m_Ui->splitter->setSizes(currentSizes); | |
155 | } |
|
157 | } | |
156 | else { |
|
158 | else { | |
157 | // adjust sizes individually here, e.g. |
|
159 | // adjust sizes individually here, e.g. | |
158 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); |
|
160 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); | |
159 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); |
|
161 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); | |
160 | m_Ui->splitter->setSizes(currentSizes); |
|
162 | m_Ui->splitter->setSizes(currentSizes); | |
161 | } |
|
163 | } | |
162 |
|
164 | |||
163 | }; |
|
165 | }; | |
164 |
|
166 | |||
165 |
|
167 | |||
166 | connect(openLeftInspectorAction, &QAction::triggered, |
|
168 | connect(openLeftInspectorAction, &QAction::triggered, | |
167 | [openInspector, openLeftInspectorAction](bool checked) { |
|
169 | [openInspector, openLeftInspectorAction](bool checked) { | |
168 | openInspector(checked, false, openLeftInspectorAction); |
|
170 | openInspector(checked, false, openLeftInspectorAction); | |
169 | }); |
|
171 | }); | |
170 | connect(openRightInspectorAction, &QAction::triggered, |
|
172 | connect(openRightInspectorAction, &QAction::triggered, | |
171 | [openInspector, openRightInspectorAction](bool checked) { |
|
173 | [openInspector, openRightInspectorAction](bool checked) { | |
172 | openInspector(checked, true, openRightInspectorAction); |
|
174 | openInspector(checked, true, openRightInspectorAction); | |
173 | }); |
|
175 | }); | |
174 |
|
176 | |||
175 | // //////////////// // |
|
177 | // //////////////// // | |
176 | // Menu and Toolbar // |
|
178 | // Menu and Toolbar // | |
177 | // //////////////// // |
|
179 | // //////////////// // | |
178 | this->menuBar()->addAction(tr("File")); |
|
180 | this->menuBar()->addAction(tr("File")); | |
179 | auto toolsMenu = this->menuBar()->addMenu(tr("Tools")); |
|
181 | auto toolsMenu = this->menuBar()->addMenu(tr("Tools")); | |
180 | toolsMenu->addAction(tr("Settings..."), [this]() { |
|
182 | toolsMenu->addAction(tr("Settings..."), [this]() { | |
181 | // Loads settings |
|
183 | // Loads settings | |
182 | impl->m_SettingsDialog->loadSettings(); |
|
184 | impl->m_SettingsDialog->loadSettings(); | |
183 |
|
185 | |||
184 | // Open settings dialog and save settings if the dialog is accepted |
|
186 | // Open settings dialog and save settings if the dialog is accepted | |
185 | if (impl->m_SettingsDialog->exec() == QDialog::Accepted) { |
|
187 | if (impl->m_SettingsDialog->exec() == QDialog::Accepted) { | |
186 | impl->m_SettingsDialog->saveSettings(); |
|
188 | impl->m_SettingsDialog->saveSettings(); | |
187 | } |
|
189 | } | |
188 |
|
190 | |||
189 | }); |
|
191 | }); | |
190 |
|
192 | |||
191 | auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); |
|
193 | auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); | |
192 |
|
194 | |||
193 | auto timeWidget = new TimeWidget{}; |
|
195 | auto timeWidget = new TimeWidget{}; | |
194 | mainToolBar->addWidget(timeWidget); |
|
196 | mainToolBar->addWidget(timeWidget); | |
195 |
|
197 | |||
196 | // Interaction modes |
|
198 | // Interaction modes | |
197 | auto actionPointerMode = new QAction{QIcon(":/icones/pointer.png"), "Move", this}; |
|
199 | auto actionPointerMode = new QAction{QIcon(":/icones/pointer.png"), "Move", this}; | |
198 | actionPointerMode->setCheckable(true); |
|
200 | actionPointerMode->setCheckable(true); | |
199 | actionPointerMode->setChecked(sqpApp->plotsInteractionMode() |
|
201 | actionPointerMode->setChecked(sqpApp->plotsInteractionMode() | |
200 | == SqpApplication::PlotsInteractionMode::None); |
|
202 | == SqpApplication::PlotsInteractionMode::None); | |
201 | connect(actionPointerMode, &QAction::triggered, |
|
203 | connect(actionPointerMode, &QAction::triggered, | |
202 | []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::None); }); |
|
204 | []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::None); }); | |
203 |
|
205 | |||
204 | auto actionZoomMode = new QAction{QIcon(":/icones/zoom.png"), "Zoom", this}; |
|
206 | auto actionZoomMode = new QAction{QIcon(":/icones/zoom.png"), "Zoom", this}; | |
205 | actionZoomMode->setCheckable(true); |
|
207 | actionZoomMode->setCheckable(true); | |
206 | actionZoomMode->setChecked(sqpApp->plotsInteractionMode() |
|
208 | actionZoomMode->setChecked(sqpApp->plotsInteractionMode() | |
207 | == SqpApplication::PlotsInteractionMode::ZoomBox); |
|
209 | == SqpApplication::PlotsInteractionMode::ZoomBox); | |
208 | connect(actionZoomMode, &QAction::triggered, []() { |
|
210 | connect(actionZoomMode, &QAction::triggered, []() { | |
209 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::ZoomBox); |
|
211 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::ZoomBox); | |
210 | }); |
|
212 | }); | |
211 |
|
213 | |||
212 | auto actionOrganisationMode = new QAction{QIcon(":/icones/drag.png"), "Organize", this}; |
|
214 | auto actionOrganisationMode = new QAction{QIcon(":/icones/drag.png"), "Organize", this}; | |
213 | actionOrganisationMode->setCheckable(true); |
|
215 | actionOrganisationMode->setCheckable(true); | |
214 | actionOrganisationMode->setChecked(sqpApp->plotsInteractionMode() |
|
216 | actionOrganisationMode->setChecked(sqpApp->plotsInteractionMode() | |
215 | == SqpApplication::PlotsInteractionMode::DragAndDrop); |
|
217 | == SqpApplication::PlotsInteractionMode::DragAndDrop); | |
216 | connect(actionOrganisationMode, &QAction::triggered, []() { |
|
218 | connect(actionOrganisationMode, &QAction::triggered, []() { | |
217 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::DragAndDrop); |
|
219 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::DragAndDrop); | |
218 | }); |
|
220 | }); | |
219 |
|
221 | |||
220 | auto actionZonesMode = new QAction{QIcon(":/icones/rectangle.png"), "Zones", this}; |
|
222 | auto actionZonesMode = new QAction{QIcon(":/icones/rectangle.png"), "Zones", this}; | |
221 | actionZonesMode->setCheckable(true); |
|
223 | actionZonesMode->setCheckable(true); | |
222 | actionZonesMode->setChecked(sqpApp->plotsInteractionMode() |
|
224 | actionZonesMode->setChecked(sqpApp->plotsInteractionMode() | |
223 | == SqpApplication::PlotsInteractionMode::SelectionZones); |
|
225 | == SqpApplication::PlotsInteractionMode::SelectionZones); | |
224 | connect(actionZonesMode, &QAction::triggered, []() { |
|
226 | connect(actionZonesMode, &QAction::triggered, []() { | |
225 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::SelectionZones); |
|
227 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::SelectionZones); | |
226 | }); |
|
228 | }); | |
227 |
|
229 | |||
228 | auto modeActionGroup = new QActionGroup{this}; |
|
230 | auto modeActionGroup = new QActionGroup{this}; | |
229 | modeActionGroup->addAction(actionZoomMode); |
|
231 | modeActionGroup->addAction(actionZoomMode); | |
230 | modeActionGroup->addAction(actionZonesMode); |
|
232 | modeActionGroup->addAction(actionZonesMode); | |
231 | modeActionGroup->addAction(actionOrganisationMode); |
|
233 | modeActionGroup->addAction(actionOrganisationMode); | |
232 | modeActionGroup->addAction(actionPointerMode); |
|
234 | modeActionGroup->addAction(actionPointerMode); | |
233 | modeActionGroup->setExclusive(true); |
|
235 | modeActionGroup->setExclusive(true); | |
234 |
|
236 | |||
235 | mainToolBar->addSeparator(); |
|
237 | mainToolBar->addSeparator(); | |
236 | mainToolBar->addAction(actionPointerMode); |
|
238 | mainToolBar->addAction(actionPointerMode); | |
237 | mainToolBar->addAction(actionZoomMode); |
|
239 | mainToolBar->addAction(actionZoomMode); | |
238 | mainToolBar->addAction(actionOrganisationMode); |
|
240 | mainToolBar->addAction(actionOrganisationMode); | |
239 | mainToolBar->addAction(actionZonesMode); |
|
241 | mainToolBar->addAction(actionZonesMode); | |
240 | mainToolBar->addSeparator(); |
|
242 | mainToolBar->addSeparator(); | |
241 |
|
243 | |||
242 | // Cursors |
|
244 | // Cursors | |
243 | auto btnCursor = new QToolButton{this}; |
|
245 | auto btnCursor = new QToolButton{this}; | |
244 | btnCursor->setIcon(QIcon(":/icones/cursor.png")); |
|
246 | btnCursor->setIcon(QIcon(":/icones/cursor.png")); | |
245 | btnCursor->setText("Cursor"); |
|
247 | btnCursor->setText("Cursor"); | |
246 | btnCursor->setToolTip("Cursor"); |
|
248 | btnCursor->setToolTip("Cursor"); | |
247 | btnCursor->setPopupMode(QToolButton::InstantPopup); |
|
249 | btnCursor->setPopupMode(QToolButton::InstantPopup); | |
248 | auto cursorMenu = new QMenu("CursorMenu", this); |
|
250 | auto cursorMenu = new QMenu("CursorMenu", this); | |
249 | btnCursor->setMenu(cursorMenu); |
|
251 | btnCursor->setMenu(cursorMenu); | |
250 |
|
252 | |||
251 | auto noCursorAction = cursorMenu->addAction("No Cursor"); |
|
253 | auto noCursorAction = cursorMenu->addAction("No Cursor"); | |
252 | noCursorAction->setCheckable(true); |
|
254 | noCursorAction->setCheckable(true); | |
253 | noCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
255 | noCursorAction->setChecked(sqpApp->plotsCursorMode() | |
254 | == SqpApplication::PlotsCursorMode::NoCursor); |
|
256 | == SqpApplication::PlotsCursorMode::NoCursor); | |
255 | connect(noCursorAction, &QAction::triggered, |
|
257 | connect(noCursorAction, &QAction::triggered, | |
256 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::NoCursor); }); |
|
258 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::NoCursor); }); | |
257 |
|
259 | |||
258 | cursorMenu->addSeparator(); |
|
260 | cursorMenu->addSeparator(); | |
259 | auto verticalCursorAction = cursorMenu->addAction("Vertical Cursor"); |
|
261 | auto verticalCursorAction = cursorMenu->addAction("Vertical Cursor"); | |
260 | verticalCursorAction->setCheckable(true); |
|
262 | verticalCursorAction->setCheckable(true); | |
261 | verticalCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
263 | verticalCursorAction->setChecked(sqpApp->plotsCursorMode() | |
262 | == SqpApplication::PlotsCursorMode::Vertical); |
|
264 | == SqpApplication::PlotsCursorMode::Vertical); | |
263 | connect(verticalCursorAction, &QAction::triggered, |
|
265 | connect(verticalCursorAction, &QAction::triggered, | |
264 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Vertical); }); |
|
266 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Vertical); }); | |
265 |
|
267 | |||
266 | auto temporalCursorAction = cursorMenu->addAction("Temporal Cursor"); |
|
268 | auto temporalCursorAction = cursorMenu->addAction("Temporal Cursor"); | |
267 | temporalCursorAction->setCheckable(true); |
|
269 | temporalCursorAction->setCheckable(true); | |
268 | temporalCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
270 | temporalCursorAction->setChecked(sqpApp->plotsCursorMode() | |
269 | == SqpApplication::PlotsCursorMode::Temporal); |
|
271 | == SqpApplication::PlotsCursorMode::Temporal); | |
270 | connect(temporalCursorAction, &QAction::triggered, |
|
272 | connect(temporalCursorAction, &QAction::triggered, | |
271 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Temporal); }); |
|
273 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Temporal); }); | |
272 |
|
274 | |||
273 | auto horizontalCursorAction = cursorMenu->addAction("Horizontal Cursor"); |
|
275 | auto horizontalCursorAction = cursorMenu->addAction("Horizontal Cursor"); | |
274 | horizontalCursorAction->setCheckable(true); |
|
276 | horizontalCursorAction->setCheckable(true); | |
275 | horizontalCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
277 | horizontalCursorAction->setChecked(sqpApp->plotsCursorMode() | |
276 | == SqpApplication::PlotsCursorMode::Horizontal); |
|
278 | == SqpApplication::PlotsCursorMode::Horizontal); | |
277 | connect(horizontalCursorAction, &QAction::triggered, |
|
279 | connect(horizontalCursorAction, &QAction::triggered, | |
278 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Horizontal); }); |
|
280 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Horizontal); }); | |
279 |
|
281 | |||
280 | auto crossCursorAction = cursorMenu->addAction("Cross Cursor"); |
|
282 | auto crossCursorAction = cursorMenu->addAction("Cross Cursor"); | |
281 | crossCursorAction->setCheckable(true); |
|
283 | crossCursorAction->setCheckable(true); | |
282 | crossCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
284 | crossCursorAction->setChecked(sqpApp->plotsCursorMode() | |
283 | == SqpApplication::PlotsCursorMode::Cross); |
|
285 | == SqpApplication::PlotsCursorMode::Cross); | |
284 | connect(crossCursorAction, &QAction::triggered, |
|
286 | connect(crossCursorAction, &QAction::triggered, | |
285 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Cross); }); |
|
287 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Cross); }); | |
286 |
|
288 | |||
287 | mainToolBar->addWidget(btnCursor); |
|
289 | mainToolBar->addWidget(btnCursor); | |
288 |
|
290 | |||
289 | auto cursorModeActionGroup = new QActionGroup{this}; |
|
291 | auto cursorModeActionGroup = new QActionGroup{this}; | |
290 | cursorModeActionGroup->setExclusive(true); |
|
292 | cursorModeActionGroup->setExclusive(true); | |
291 | cursorModeActionGroup->addAction(noCursorAction); |
|
293 | cursorModeActionGroup->addAction(noCursorAction); | |
292 | cursorModeActionGroup->addAction(verticalCursorAction); |
|
294 | cursorModeActionGroup->addAction(verticalCursorAction); | |
293 | cursorModeActionGroup->addAction(temporalCursorAction); |
|
295 | cursorModeActionGroup->addAction(temporalCursorAction); | |
294 | cursorModeActionGroup->addAction(horizontalCursorAction); |
|
296 | cursorModeActionGroup->addAction(horizontalCursorAction); | |
295 | cursorModeActionGroup->addAction(crossCursorAction); |
|
297 | cursorModeActionGroup->addAction(crossCursorAction); | |
296 |
|
298 | |||
297 | // Catalog |
|
299 | // Catalog | |
298 | mainToolBar->addSeparator(); |
|
300 | mainToolBar->addSeparator(); | |
299 | mainToolBar->addAction(QIcon(":/icones/catalogue.png"), "Catalogues", |
|
301 | mainToolBar->addAction(QIcon(":/icones/catalogue.png"), "Catalogues", | |
300 | [this]() { impl->m_CatalogExplorer->show(); }); |
|
302 | [this]() { impl->m_CatalogExplorer->show(); }); | |
301 |
|
303 | |||
302 | // //////// // |
|
304 | // //////// // | |
303 | // Settings // |
|
305 | // Settings // | |
304 | // //////// // |
|
306 | // //////// // | |
305 |
|
307 | |||
306 | // Registers "general settings" widget to the settings dialog |
|
308 | // Registers "general settings" widget to the settings dialog | |
307 | impl->m_SettingsDialog->registerWidget(QStringLiteral("General"), |
|
309 | impl->m_SettingsDialog->registerWidget(QStringLiteral("General"), | |
308 | impl->m_GeneralSettingsWidget); |
|
310 | impl->m_GeneralSettingsWidget); | |
309 |
|
311 | |||
310 | // /////////// // |
|
312 | // /////////// // | |
311 | // Connections // |
|
313 | // Connections // | |
312 | // /////////// // |
|
314 | // /////////// // | |
313 |
|
315 | |||
314 | // Controllers / controllers connections |
|
316 | // Controllers / controllers connections | |
315 | connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpRange)), &sqpApp->variableController(), |
|
317 | connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpRange)), &sqpApp->variableController(), | |
316 | SLOT(onDateTimeOnSelection(SqpRange))); |
|
318 | SLOT(onDateTimeOnSelection(SqpRange))); | |
317 |
|
319 | |||
318 | // Widgets / controllers connections |
|
320 | // Widgets / controllers connections | |
319 |
|
321 | |||
320 | // DataSource |
|
322 | // DataSource | |
321 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), |
|
323 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), | |
322 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); |
|
324 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); | |
323 |
|
325 | |||
324 | // Time |
|
326 | // Time | |
325 | connect(timeWidget, SIGNAL(timeUpdated(SqpRange)), &sqpApp->timeController(), |
|
327 | connect(timeWidget, SIGNAL(timeUpdated(SqpRange)), &sqpApp->timeController(), | |
326 | SLOT(onTimeToUpdate(SqpRange))); |
|
328 | SLOT(onTimeToUpdate(SqpRange))); | |
327 |
|
329 | |||
328 | // Visualization |
|
330 | // Visualization | |
329 | connect(&sqpApp->visualizationController(), |
|
331 | connect(&sqpApp->visualizationController(), | |
330 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view, |
|
332 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view, | |
331 | SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>))); |
|
333 | SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>))); | |
332 |
|
334 | |||
333 | connect(&sqpApp->visualizationController(), |
|
335 | connect(&sqpApp->visualizationController(), | |
334 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), m_Ui->view, |
|
336 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), m_Ui->view, | |
335 | SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpRange &))); |
|
337 | SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpRange &))); | |
336 |
|
338 | |||
337 | // Widgets / widgets connections |
|
339 | // Widgets / widgets connections | |
338 |
|
340 | |||
339 | // For the following connections, we use DirectConnection to allow each widget that can |
|
341 | // For the following connections, we use DirectConnection to allow each widget that can | |
340 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. |
|
342 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. | |
341 | // The order of connections is also important, since it determines the order in which each |
|
343 | // The order of connections is also important, since it determines the order in which each | |
342 | // widget will attach its menu |
|
344 | // widget will attach its menu | |
343 | connect( |
|
345 | connect( | |
344 | m_Ui->variableInspectorWidget, |
|
346 | m_Ui->variableInspectorWidget, | |
345 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)), |
|
347 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)), | |
346 | m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)), |
|
348 | m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)), | |
347 | Qt::DirectConnection); |
|
349 | Qt::DirectConnection); | |
348 | } |
|
350 | } | |
349 |
|
351 | |||
350 | MainWindow::~MainWindow() |
|
352 | MainWindow::~MainWindow() | |
351 | { |
|
353 | { | |
352 | } |
|
354 | } | |
353 |
|
355 | |||
354 | void MainWindow::changeEvent(QEvent *e) |
|
356 | void MainWindow::changeEvent(QEvent *e) | |
355 | { |
|
357 | { | |
356 | QMainWindow::changeEvent(e); |
|
358 | QMainWindow::changeEvent(e); | |
357 | switch (e->type()) { |
|
359 | switch (e->type()) { | |
358 | case QEvent::LanguageChange: |
|
360 | case QEvent::LanguageChange: | |
359 | m_Ui->retranslateUi(this); |
|
361 | m_Ui->retranslateUi(this); | |
360 | break; |
|
362 | break; | |
361 | default: |
|
363 | default: | |
362 | break; |
|
364 | break; | |
363 | } |
|
365 | } | |
364 | } |
|
366 | } |
@@ -1,70 +1,69 | |||||
1 | #ifndef SCIQLOP_CATALOGUECONTROLLER_H |
|
1 | #ifndef SCIQLOP_CATALOGUECONTROLLER_H | |
2 | #define SCIQLOP_CATALOGUECONTROLLER_H |
|
2 | #define SCIQLOP_CATALOGUECONTROLLER_H | |
3 |
|
3 | |||
4 | #include "CoreGlobal.h" |
|
4 | #include "CoreGlobal.h" | |
5 |
|
5 | |||
6 | #include <Data/SqpRange.h> |
|
6 | #include <Data/SqpRange.h> | |
7 |
|
7 | |||
8 | #include <QLoggingCategory> |
|
8 | #include <QLoggingCategory> | |
9 | #include <QObject> |
|
9 | #include <QObject> | |
10 | #include <QUuid> |
|
10 | #include <QUuid> | |
11 |
|
11 | |||
12 | #include <Common/spimpl.h> |
|
12 | #include <Common/spimpl.h> | |
13 |
|
13 | |||
14 | #include <memory> |
|
14 | #include <memory> | |
15 |
|
15 | |||
16 | class DBCatalogue; |
|
16 | class DBCatalogue; | |
17 | class DBEvent; |
|
17 | class DBEvent; | |
18 |
|
18 | |||
19 | Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueController) |
|
19 | Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueController) | |
20 |
|
20 | |||
21 | class DataSourceItem; |
|
21 | class DataSourceItem; | |
22 | class Variable; |
|
22 | class Variable; | |
23 |
|
23 | |||
24 | /** |
|
24 | /** | |
25 | * @brief The CatalogueController class aims to handle catalogues and event using the CatalogueAPI |
|
25 | * @brief The CatalogueController class aims to handle catalogues and event using the CatalogueAPI | |
26 | * library. |
|
26 | * library. | |
27 | */ |
|
27 | */ | |
28 | class SCIQLOP_CORE_EXPORT CatalogueController : public QObject { |
|
28 | class SCIQLOP_CORE_EXPORT CatalogueController : public QObject { | |
29 | Q_OBJECT |
|
29 | Q_OBJECT | |
30 | public: |
|
30 | public: | |
31 | explicit CatalogueController(QObject *parent = 0); |
|
31 | explicit CatalogueController(QObject *parent = 0); | |
32 | virtual ~CatalogueController(); |
|
32 | virtual ~CatalogueController(); | |
33 |
|
33 | |||
34 | // DB |
|
34 | // DB | |
35 | // QStringList getRepositories() const; |
|
35 | // QStringList getRepositories() const; | |
36 | void addDB(const QString &dbPath); |
|
36 | void addDB(const QString &dbPath); | |
37 | void saveDB(const QString &destinationPath, const QString &repository); |
|
37 | void saveDB(const QString &destinationPath, const QString &repository); | |
38 |
|
38 | |||
39 | // Event |
|
39 | // Event | |
40 | // bool createEvent(const QString &name); |
|
40 | // bool createEvent(const QString &name); | |
41 | std::list<std::shared_ptr<DBEvent> > retrieveEvents(const QString &repository) const; |
|
41 | std::list<std::shared_ptr<DBEvent> > retrieveEvents(const QString &repository) const; | |
42 | std::list<std::shared_ptr<DBEvent> > retrieveAllEvents() const; |
|
42 | std::list<std::shared_ptr<DBEvent> > retrieveAllEvents() const; | |
43 | std::list<std::shared_ptr<DBEvent> > |
|
43 | std::list<std::shared_ptr<DBEvent> > | |
44 | retrieveEventsFromCatalogue(const QString &repository, |
|
44 | retrieveEventsFromCatalogue(std::shared_ptr<DBCatalogue> catalogue) const; | |
45 | std::shared_ptr<DBCatalogue> catalogue) const; |
|
|||
46 | // void updateEvent(std::shared_ptr<DBEvent> event); |
|
45 | // void updateEvent(std::shared_ptr<DBEvent> event); | |
47 | // void trashEvent(std::shared_ptr<DBEvent> event); |
|
46 | // void trashEvent(std::shared_ptr<DBEvent> event); | |
48 | // void removeEvent(std::shared_ptr<DBEvent> event); |
|
47 | // void removeEvent(std::shared_ptr<DBEvent> event); | |
49 | // void restore(QUuid eventId); |
|
48 | // void restore(QUuid eventId); | |
50 | // void saveEvent(std::shared_ptr<DBEvent> event); |
|
49 | // void saveEvent(std::shared_ptr<DBEvent> event); | |
51 |
|
50 | |||
52 | // Catalogue |
|
51 | // Catalogue | |
53 | // bool createCatalogue(const QString &name, QVector<QUuid> eventList); |
|
52 | // bool createCatalogue(const QString &name, QVector<QUuid> eventList); | |
54 | std::list<std::shared_ptr<DBCatalogue> > getCatalogues(const QString &repository) const; |
|
53 | std::list<std::shared_ptr<DBCatalogue> > getCatalogues(const QString &repository) const; | |
55 | // void removeEvent(QUuid catalogueId, const QString &repository); |
|
54 | // void removeEvent(QUuid catalogueId, const QString &repository); | |
56 | // void saveCatalogue(std::shared_ptr<DBEvent> event); |
|
55 | // void saveCatalogue(std::shared_ptr<DBEvent> event); | |
57 |
|
56 | |||
58 | public slots: |
|
57 | public slots: | |
59 | /// Manage init/end of the controller |
|
58 | /// Manage init/end of the controller | |
60 | void initialize(); |
|
59 | void initialize(); | |
61 | void finalize(); |
|
60 | void finalize(); | |
62 |
|
61 | |||
63 | private: |
|
62 | private: | |
64 | void waitForFinish(); |
|
63 | void waitForFinish(); | |
65 |
|
64 | |||
66 | class CatalogueControllerPrivate; |
|
65 | class CatalogueControllerPrivate; | |
67 | spimpl::unique_impl_ptr<CatalogueControllerPrivate> impl; |
|
66 | spimpl::unique_impl_ptr<CatalogueControllerPrivate> impl; | |
68 | }; |
|
67 | }; | |
69 |
|
68 | |||
70 | #endif // SCIQLOP_CATALOGUECONTROLLER_H |
|
69 | #endif // SCIQLOP_CATALOGUECONTROLLER_H |
@@ -1,20 +1,21 | |||||
1 | #ifndef SCIQLOP_MIMETYPESDEF_H |
|
1 | #ifndef SCIQLOP_MIMETYPESDEF_H | |
2 | #define SCIQLOP_MIMETYPESDEF_H |
|
2 | #define SCIQLOP_MIMETYPESDEF_H | |
3 |
|
3 | |||
4 | #include "CoreGlobal.h" |
|
4 | #include "CoreGlobal.h" | |
5 |
|
5 | |||
6 | #include <QString> |
|
6 | #include <QString> | |
7 |
|
7 | |||
8 | // ////////////////// // |
|
8 | // ////////////////// // | |
9 | // SciQlop Mime Types // |
|
9 | // SciQlop Mime Types // | |
10 | // ////////////////// // |
|
10 | // ////////////////// // | |
11 |
|
11 | |||
12 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_GRAPH; |
|
12 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_GRAPH; | |
13 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_ZONE; |
|
13 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_ZONE; | |
14 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_VARIABLE_LIST; |
|
14 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_VARIABLE_LIST; | |
15 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_PRODUCT_LIST; |
|
15 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_PRODUCT_LIST; | |
16 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_TIME_RANGE; |
|
16 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_TIME_RANGE; | |
17 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_SELECTION_ZONE; |
|
17 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_SELECTION_ZONE; | |
|
18 | extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_EVENT_LIST; | |||
18 |
|
19 | |||
19 |
|
20 | |||
20 | #endif // SCIQLOP_MIMETYPESDEF_H |
|
21 | #endif // SCIQLOP_MIMETYPESDEF_H |
@@ -1,162 +1,161 | |||||
1 | #include <Catalogue/CatalogueController.h> |
|
1 | #include <Catalogue/CatalogueController.h> | |
2 |
|
2 | |||
3 | #include <Variable/Variable.h> |
|
3 | #include <Variable/Variable.h> | |
4 |
|
4 | |||
5 | #include <CatalogueDao.h> |
|
5 | #include <CatalogueDao.h> | |
6 |
|
6 | |||
7 | #include <ComparaisonPredicate.h> |
|
7 | #include <ComparaisonPredicate.h> | |
8 | #include <CompoundPredicate.h> |
|
8 | #include <CompoundPredicate.h> | |
9 | #include <DBCatalogue.h> |
|
9 | #include <DBCatalogue.h> | |
10 | #include <DBEvent.h> |
|
10 | #include <DBEvent.h> | |
11 | #include <DBTag.h> |
|
11 | #include <DBTag.h> | |
12 | #include <IRequestPredicate.h> |
|
12 | #include <IRequestPredicate.h> | |
13 |
|
13 | |||
14 | #include <QMutex> |
|
14 | #include <QMutex> | |
15 | #include <QThread> |
|
15 | #include <QThread> | |
16 |
|
16 | |||
17 | #include <QDir> |
|
17 | #include <QDir> | |
18 | #include <QStandardPaths> |
|
18 | #include <QStandardPaths> | |
19 |
|
19 | |||
20 | Q_LOGGING_CATEGORY(LOG_CatalogueController, "CatalogueController") |
|
20 | Q_LOGGING_CATEGORY(LOG_CatalogueController, "CatalogueController") | |
21 |
|
21 | |||
22 | namespace { |
|
22 | namespace { | |
23 |
|
23 | |||
24 | static QString REPOSITORY_WORK_SUFFIX = QString{"Work"}; |
|
24 | static QString REPOSITORY_WORK_SUFFIX = QString{"Work"}; | |
25 |
|
25 | |||
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | class CatalogueController::CatalogueControllerPrivate { |
|
28 | class CatalogueController::CatalogueControllerPrivate { | |
29 | public: |
|
29 | public: | |
30 | QMutex m_WorkingMutex; |
|
30 | QMutex m_WorkingMutex; | |
31 | CatalogueDao m_CatalogueDao; |
|
31 | CatalogueDao m_CatalogueDao; | |
32 |
|
32 | |||
33 | std::list<QString> m_RepositoryList; |
|
33 | std::list<QString> m_RepositoryList; | |
34 | }; |
|
34 | }; | |
35 |
|
35 | |||
36 | CatalogueController::CatalogueController(QObject *parent) |
|
36 | CatalogueController::CatalogueController(QObject *parent) | |
37 | : impl{spimpl::make_unique_impl<CatalogueControllerPrivate>()} |
|
37 | : impl{spimpl::make_unique_impl<CatalogueControllerPrivate>()} | |
38 | { |
|
38 | { | |
39 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController construction") |
|
39 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController construction") | |
40 | << QThread::currentThread(); |
|
40 | << QThread::currentThread(); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | CatalogueController::~CatalogueController() |
|
43 | CatalogueController::~CatalogueController() | |
44 | { |
|
44 | { | |
45 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController destruction") |
|
45 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController destruction") | |
46 | << QThread::currentThread(); |
|
46 | << QThread::currentThread(); | |
47 | this->waitForFinish(); |
|
47 | this->waitForFinish(); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | void CatalogueController::addDB(const QString &dbPath) |
|
50 | void CatalogueController::addDB(const QString &dbPath) | |
51 | { |
|
51 | { | |
52 | QDir dbDir(dbPath); |
|
52 | QDir dbDir(dbPath); | |
53 | if (dbDir.exists()) { |
|
53 | if (dbDir.exists()) { | |
54 | auto dirName = dbDir.dirName(); |
|
54 | auto dirName = dbDir.dirName(); | |
55 |
|
55 | |||
56 | if (std::find(impl->m_RepositoryList.cbegin(), impl->m_RepositoryList.cend(), dirName) |
|
56 | if (std::find(impl->m_RepositoryList.cbegin(), impl->m_RepositoryList.cend(), dirName) | |
57 | != impl->m_RepositoryList.cend()) { |
|
57 | != impl->m_RepositoryList.cend()) { | |
58 | qCCritical(LOG_CatalogueController()) |
|
58 | qCCritical(LOG_CatalogueController()) | |
59 | << tr("Impossible to addDB that is already loaded"); |
|
59 | << tr("Impossible to addDB that is already loaded"); | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | if (!impl->m_CatalogueDao.addDB(dbPath, dirName)) { |
|
62 | if (!impl->m_CatalogueDao.addDB(dbPath, dirName)) { | |
63 | qCCritical(LOG_CatalogueController()) |
|
63 | qCCritical(LOG_CatalogueController()) | |
64 | << tr("Impossible to addDB %1 from %2 ").arg(dirName, dbPath); |
|
64 | << tr("Impossible to addDB %1 from %2 ").arg(dirName, dbPath); | |
65 | } |
|
65 | } | |
66 | else { |
|
66 | else { | |
67 | impl->m_RepositoryList.push_back(dirName); |
|
67 | impl->m_RepositoryList.push_back(dirName); | |
68 | } |
|
68 | } | |
69 | } |
|
69 | } | |
70 | else { |
|
70 | else { | |
71 | qCCritical(LOG_CatalogueController()) << tr("Impossible to addDB that not exists: ") |
|
71 | qCCritical(LOG_CatalogueController()) << tr("Impossible to addDB that not exists: ") | |
72 | << dbPath; |
|
72 | << dbPath; | |
73 | } |
|
73 | } | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | void CatalogueController::saveDB(const QString &destinationPath, const QString &repository) |
|
76 | void CatalogueController::saveDB(const QString &destinationPath, const QString &repository) | |
77 | { |
|
77 | { | |
78 | if (!impl->m_CatalogueDao.saveDB(destinationPath, repository)) { |
|
78 | if (!impl->m_CatalogueDao.saveDB(destinationPath, repository)) { | |
79 | qCCritical(LOG_CatalogueController()) |
|
79 | qCCritical(LOG_CatalogueController()) | |
80 | << tr("Impossible to saveDB %1 from %2 ").arg(repository, destinationPath); |
|
80 | << tr("Impossible to saveDB %1 from %2 ").arg(repository, destinationPath); | |
81 | } |
|
81 | } | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | std::list<std::shared_ptr<DBEvent> > |
|
84 | std::list<std::shared_ptr<DBEvent> > | |
85 | CatalogueController::retrieveEvents(const QString &repository) const |
|
85 | CatalogueController::retrieveEvents(const QString &repository) const | |
86 | { |
|
86 | { | |
87 | auto eventsShared = std::list<std::shared_ptr<DBEvent> >{}; |
|
87 | auto eventsShared = std::list<std::shared_ptr<DBEvent> >{}; | |
88 | auto events = impl->m_CatalogueDao.getEvents(repository); |
|
88 | auto events = impl->m_CatalogueDao.getEvents(repository); | |
89 | for (auto event : events) { |
|
89 | for (auto event : events) { | |
90 | eventsShared.push_back(std::make_shared<DBEvent>(event)); |
|
90 | eventsShared.push_back(std::make_shared<DBEvent>(event)); | |
91 | } |
|
91 | } | |
92 | return eventsShared; |
|
92 | return eventsShared; | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | std::list<std::shared_ptr<DBEvent> > CatalogueController::retrieveAllEvents() const |
|
95 | std::list<std::shared_ptr<DBEvent> > CatalogueController::retrieveAllEvents() const | |
96 | { |
|
96 | { | |
97 | auto eventsShared = std::list<std::shared_ptr<DBEvent> >{}; |
|
97 | auto eventsShared = std::list<std::shared_ptr<DBEvent> >{}; | |
98 | for (auto repository : impl->m_RepositoryList) { |
|
98 | for (auto repository : impl->m_RepositoryList) { | |
99 | eventsShared.splice(eventsShared.end(), retrieveEvents(repository)); |
|
99 | eventsShared.splice(eventsShared.end(), retrieveEvents(repository)); | |
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | return eventsShared; |
|
102 | return eventsShared; | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | std::list<std::shared_ptr<DBEvent> > |
|
105 | std::list<std::shared_ptr<DBEvent> > | |
106 |
CatalogueController::retrieveEventsFromCatalogue(const |
|
106 | CatalogueController::retrieveEventsFromCatalogue(std::shared_ptr<DBCatalogue> catalogue) const | |
107 | std::shared_ptr<DBCatalogue> catalogue) const |
|
|||
108 | { |
|
107 | { | |
109 | auto eventsShared = std::list<std::shared_ptr<DBEvent> >{}; |
|
108 | auto eventsShared = std::list<std::shared_ptr<DBEvent> >{}; | |
110 | auto events = impl->m_CatalogueDao.getCatalogueEvents(*catalogue); |
|
109 | auto events = impl->m_CatalogueDao.getCatalogueEvents(*catalogue); | |
111 | for (auto event : events) { |
|
110 | for (auto event : events) { | |
112 | eventsShared.push_back(std::make_shared<DBEvent>(event)); |
|
111 | eventsShared.push_back(std::make_shared<DBEvent>(event)); | |
113 | } |
|
112 | } | |
114 | return eventsShared; |
|
113 | return eventsShared; | |
115 | } |
|
114 | } | |
116 |
|
115 | |||
117 | std::list<std::shared_ptr<DBCatalogue> > |
|
116 | std::list<std::shared_ptr<DBCatalogue> > | |
118 | CatalogueController::getCatalogues(const QString &repository) const |
|
117 | CatalogueController::getCatalogues(const QString &repository) const | |
119 | { |
|
118 | { | |
120 | auto cataloguesShared = std::list<std::shared_ptr<DBCatalogue> >{}; |
|
119 | auto cataloguesShared = std::list<std::shared_ptr<DBCatalogue> >{}; | |
121 | auto catalogues = impl->m_CatalogueDao.getCatalogues(repository); |
|
120 | auto catalogues = impl->m_CatalogueDao.getCatalogues(repository); | |
122 | for (auto catalogue : catalogues) { |
|
121 | for (auto catalogue : catalogues) { | |
123 | cataloguesShared.push_back(std::make_shared<DBCatalogue>(catalogue)); |
|
122 | cataloguesShared.push_back(std::make_shared<DBCatalogue>(catalogue)); | |
124 | } |
|
123 | } | |
125 | return cataloguesShared; |
|
124 | return cataloguesShared; | |
126 | } |
|
125 | } | |
127 |
|
126 | |||
128 | void CatalogueController::initialize() |
|
127 | void CatalogueController::initialize() | |
129 | { |
|
128 | { | |
130 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController init") |
|
129 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController init") | |
131 | << QThread::currentThread(); |
|
130 | << QThread::currentThread(); | |
132 | impl->m_WorkingMutex.lock(); |
|
131 | impl->m_WorkingMutex.lock(); | |
133 | impl->m_CatalogueDao.initialize(); |
|
132 | impl->m_CatalogueDao.initialize(); | |
134 | auto defaultRepositoryLocation |
|
133 | auto defaultRepositoryLocation | |
135 | = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); |
|
134 | = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); | |
136 |
|
135 | |||
137 | QDir defaultRepositoryLocationDir; |
|
136 | QDir defaultRepositoryLocationDir; | |
138 | if (defaultRepositoryLocationDir.mkpath(defaultRepositoryLocation)) { |
|
137 | if (defaultRepositoryLocationDir.mkpath(defaultRepositoryLocation)) { | |
139 | defaultRepositoryLocationDir.cd(defaultRepositoryLocation); |
|
138 | defaultRepositoryLocationDir.cd(defaultRepositoryLocation); | |
140 | auto defaultRepository = defaultRepositoryLocationDir.absoluteFilePath(REPOSITORY_DEFAULT); |
|
139 | auto defaultRepository = defaultRepositoryLocationDir.absoluteFilePath(REPOSITORY_DEFAULT); | |
141 | qCInfo(LOG_CatalogueController()) |
|
140 | qCInfo(LOG_CatalogueController()) | |
142 | << tr("Persistant data loading from: ") << defaultRepository; |
|
141 | << tr("Persistant data loading from: ") << defaultRepository; | |
143 | this->addDB(defaultRepository); |
|
142 | this->addDB(defaultRepository); | |
144 | } |
|
143 | } | |
145 | else { |
|
144 | else { | |
146 | qCWarning(LOG_CatalogueController()) |
|
145 | qCWarning(LOG_CatalogueController()) | |
147 | << tr("Cannot load the persistent default repository from ") |
|
146 | << tr("Cannot load the persistent default repository from ") | |
148 | << defaultRepositoryLocation; |
|
147 | << defaultRepositoryLocation; | |
149 | } |
|
148 | } | |
150 |
|
149 | |||
151 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END"); |
|
150 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END"); | |
152 | } |
|
151 | } | |
153 |
|
152 | |||
154 | void CatalogueController::finalize() |
|
153 | void CatalogueController::finalize() | |
155 | { |
|
154 | { | |
156 | impl->m_WorkingMutex.unlock(); |
|
155 | impl->m_WorkingMutex.unlock(); | |
157 | } |
|
156 | } | |
158 |
|
157 | |||
159 | void CatalogueController::waitForFinish() |
|
158 | void CatalogueController::waitForFinish() | |
160 | { |
|
159 | { | |
161 | QMutexLocker locker{&impl->m_WorkingMutex}; |
|
160 | QMutexLocker locker{&impl->m_WorkingMutex}; | |
162 | } |
|
161 | } |
@@ -1,8 +1,9 | |||||
1 | #include "Common/MimeTypesDef.h" |
|
1 | #include "Common/MimeTypesDef.h" | |
2 |
|
2 | |||
3 | const QString MIME_TYPE_GRAPH = QStringLiteral("sciqlop/graph"); |
|
3 | const QString MIME_TYPE_GRAPH = QStringLiteral("sciqlop/graph"); | |
4 | const QString MIME_TYPE_ZONE = QStringLiteral("sciqlop/zone"); |
|
4 | const QString MIME_TYPE_ZONE = QStringLiteral("sciqlop/zone"); | |
5 | const QString MIME_TYPE_VARIABLE_LIST = QStringLiteral("sciqlop/var-list"); |
|
5 | const QString MIME_TYPE_VARIABLE_LIST = QStringLiteral("sciqlop/var-list"); | |
6 | const QString MIME_TYPE_PRODUCT_LIST = QStringLiteral("sciqlop/product-list"); |
|
6 | const QString MIME_TYPE_PRODUCT_LIST = QStringLiteral("sciqlop/product-list"); | |
7 | const QString MIME_TYPE_TIME_RANGE = QStringLiteral("sciqlop/time-range"); |
|
7 | const QString MIME_TYPE_TIME_RANGE = QStringLiteral("sciqlop/time-range"); | |
8 | const QString MIME_TYPE_SELECTION_ZONE = QStringLiteral("sciqlop/selection-zone"); |
|
8 | const QString MIME_TYPE_SELECTION_ZONE = QStringLiteral("sciqlop/selection-zone"); | |
|
9 | const QString MIME_TYPE_EVENT_LIST = QStringLiteral("sciqlop/event-list"); |
@@ -1,1063 +1,1063 | |||||
1 | #include <Variable/Variable.h> |
|
1 | #include <Variable/Variable.h> | |
2 | #include <Variable/VariableAcquisitionWorker.h> |
|
2 | #include <Variable/VariableAcquisitionWorker.h> | |
3 | #include <Variable/VariableCacheStrategy.h> |
|
3 | #include <Variable/VariableCacheStrategy.h> | |
4 | #include <Variable/VariableCacheStrategyFactory.h> |
|
4 | #include <Variable/VariableCacheStrategyFactory.h> | |
5 | #include <Variable/VariableController.h> |
|
5 | #include <Variable/VariableController.h> | |
6 | #include <Variable/VariableModel.h> |
|
6 | #include <Variable/VariableModel.h> | |
7 | #include <Variable/VariableSynchronizationGroup.h> |
|
7 | #include <Variable/VariableSynchronizationGroup.h> | |
8 |
|
8 | |||
9 | #include <Data/DataProviderParameters.h> |
|
9 | #include <Data/DataProviderParameters.h> | |
10 | #include <Data/IDataProvider.h> |
|
10 | #include <Data/IDataProvider.h> | |
11 | #include <Data/IDataSeries.h> |
|
11 | #include <Data/IDataSeries.h> | |
12 | #include <Data/VariableRequest.h> |
|
12 | #include <Data/VariableRequest.h> | |
13 | #include <Time/TimeController.h> |
|
13 | #include <Time/TimeController.h> | |
14 |
|
14 | |||
15 | #include <QDataStream> |
|
15 | #include <QDataStream> | |
16 | #include <QMutex> |
|
16 | #include <QMutex> | |
17 | #include <QThread> |
|
17 | #include <QThread> | |
18 | #include <QUuid> |
|
18 | #include <QUuid> | |
19 | #include <QtCore/QItemSelectionModel> |
|
19 | #include <QtCore/QItemSelectionModel> | |
20 |
|
20 | |||
21 | #include <deque> |
|
21 | #include <deque> | |
22 | #include <set> |
|
22 | #include <set> | |
23 | #include <unordered_map> |
|
23 | #include <unordered_map> | |
24 |
|
24 | |||
25 | Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") |
|
25 | Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") | |
26 |
|
26 | |||
27 | namespace { |
|
27 | namespace { | |
28 |
|
28 | |||
29 | SqpRange computeSynchroRangeRequested(const SqpRange &varRange, const SqpRange &graphRange, |
|
29 | SqpRange computeSynchroRangeRequested(const SqpRange &varRange, const SqpRange &graphRange, | |
30 | const SqpRange &oldGraphRange) |
|
30 | const SqpRange &oldGraphRange) | |
31 | { |
|
31 | { | |
32 | auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange); |
|
32 | auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange); | |
33 |
|
33 | |||
34 | auto varRangeRequested = varRange; |
|
34 | auto varRangeRequested = varRange; | |
35 | switch (zoomType) { |
|
35 | switch (zoomType) { | |
36 | case AcquisitionZoomType::ZoomIn: { |
|
36 | case AcquisitionZoomType::ZoomIn: { | |
37 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; |
|
37 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; | |
38 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; |
|
38 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; | |
39 | varRangeRequested.m_TStart += deltaLeft; |
|
39 | varRangeRequested.m_TStart += deltaLeft; | |
40 | varRangeRequested.m_TEnd -= deltaRight; |
|
40 | varRangeRequested.m_TEnd -= deltaRight; | |
41 | break; |
|
41 | break; | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | case AcquisitionZoomType::ZoomOut: { |
|
44 | case AcquisitionZoomType::ZoomOut: { | |
45 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; |
|
45 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; | |
46 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; |
|
46 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; | |
47 | varRangeRequested.m_TStart -= deltaLeft; |
|
47 | varRangeRequested.m_TStart -= deltaLeft; | |
48 | varRangeRequested.m_TEnd += deltaRight; |
|
48 | varRangeRequested.m_TEnd += deltaRight; | |
49 | break; |
|
49 | break; | |
50 | } |
|
50 | } | |
51 | case AcquisitionZoomType::PanRight: { |
|
51 | case AcquisitionZoomType::PanRight: { | |
52 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; |
|
52 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; | |
53 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; |
|
53 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; | |
54 | varRangeRequested.m_TStart += deltaLeft; |
|
54 | varRangeRequested.m_TStart += deltaLeft; | |
55 | varRangeRequested.m_TEnd += deltaRight; |
|
55 | varRangeRequested.m_TEnd += deltaRight; | |
56 | break; |
|
56 | break; | |
57 | } |
|
57 | } | |
58 | case AcquisitionZoomType::PanLeft: { |
|
58 | case AcquisitionZoomType::PanLeft: { | |
59 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; |
|
59 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; | |
60 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; |
|
60 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; | |
61 | varRangeRequested.m_TStart -= deltaLeft; |
|
61 | varRangeRequested.m_TStart -= deltaLeft; | |
62 | varRangeRequested.m_TEnd -= deltaRight; |
|
62 | varRangeRequested.m_TEnd -= deltaRight; | |
63 | break; |
|
63 | break; | |
64 | } |
|
64 | } | |
65 | case AcquisitionZoomType::Unknown: { |
|
65 | case AcquisitionZoomType::Unknown: { | |
66 | qCCritical(LOG_VariableController()) |
|
66 | qCCritical(LOG_VariableController()) | |
67 | << VariableController::tr("Impossible to synchronize: zoom type unknown"); |
|
67 | << VariableController::tr("Impossible to synchronize: zoom type unknown"); | |
68 | break; |
|
68 | break; | |
69 | } |
|
69 | } | |
70 | default: |
|
70 | default: | |
71 | qCCritical(LOG_VariableController()) << VariableController::tr( |
|
71 | qCCritical(LOG_VariableController()) << VariableController::tr( | |
72 | "Impossible to synchronize: zoom type not take into account"); |
|
72 | "Impossible to synchronize: zoom type not take into account"); | |
73 | // No action |
|
73 | // No action | |
74 | break; |
|
74 | break; | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | return varRangeRequested; |
|
77 | return varRangeRequested; | |
78 | } |
|
78 | } | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | enum class VariableRequestHandlerState { OFF, RUNNING, PENDING }; |
|
81 | enum class VariableRequestHandlerState { OFF, RUNNING, PENDING }; | |
82 |
|
82 | |||
83 | struct VariableRequestHandler { |
|
83 | struct VariableRequestHandler { | |
84 |
|
84 | |||
85 | VariableRequestHandler() |
|
85 | VariableRequestHandler() | |
86 | { |
|
86 | { | |
87 | m_CanUpdate = false; |
|
87 | m_CanUpdate = false; | |
88 | m_State = VariableRequestHandlerState::OFF; |
|
88 | m_State = VariableRequestHandlerState::OFF; | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | QUuid m_VarId; |
|
91 | QUuid m_VarId; | |
92 | VariableRequest m_RunningVarRequest; |
|
92 | VariableRequest m_RunningVarRequest; | |
93 | VariableRequest m_PendingVarRequest; |
|
93 | VariableRequest m_PendingVarRequest; | |
94 | VariableRequestHandlerState m_State; |
|
94 | VariableRequestHandlerState m_State; | |
95 | bool m_CanUpdate; |
|
95 | bool m_CanUpdate; | |
96 | }; |
|
96 | }; | |
97 |
|
97 | |||
98 | struct VariableController::VariableControllerPrivate { |
|
98 | struct VariableController::VariableControllerPrivate { | |
99 | explicit VariableControllerPrivate(VariableController *parent) |
|
99 | explicit VariableControllerPrivate(VariableController *parent) | |
100 | : m_WorkingMutex{}, |
|
100 | : m_WorkingMutex{}, | |
101 | m_VariableModel{new VariableModel{parent}}, |
|
101 | m_VariableModel{new VariableModel{parent}}, | |
102 | m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, |
|
102 | m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, | |
103 | // m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()}, |
|
103 | // m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()}, | |
104 | m_VariableCacheStrategy{VariableCacheStrategyFactory::createCacheStrategy( |
|
104 | m_VariableCacheStrategy{VariableCacheStrategyFactory::createCacheStrategy( | |
105 | CacheStrategy::SingleThreshold)}, |
|
105 | CacheStrategy::SingleThreshold)}, | |
106 | m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()}, |
|
106 | m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()}, | |
107 | q{parent} |
|
107 | q{parent} | |
108 | { |
|
108 | { | |
109 |
|
109 | |||
110 | m_VariableAcquisitionWorker->moveToThread(&m_VariableAcquisitionWorkerThread); |
|
110 | m_VariableAcquisitionWorker->moveToThread(&m_VariableAcquisitionWorkerThread); | |
111 | m_VariableAcquisitionWorkerThread.setObjectName("VariableAcquisitionWorkerThread"); |
|
111 | m_VariableAcquisitionWorkerThread.setObjectName("VariableAcquisitionWorkerThread"); | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | virtual ~VariableControllerPrivate() |
|
115 | virtual ~VariableControllerPrivate() | |
116 | { |
|
116 | { | |
117 | qCDebug(LOG_VariableController()) << tr("VariableControllerPrivate destruction"); |
|
117 | qCDebug(LOG_VariableController()) << tr("VariableControllerPrivate destruction"); | |
118 | m_VariableAcquisitionWorkerThread.quit(); |
|
118 | m_VariableAcquisitionWorkerThread.quit(); | |
119 | m_VariableAcquisitionWorkerThread.wait(); |
|
119 | m_VariableAcquisitionWorkerThread.wait(); | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 |
|
122 | |||
123 | void processRequest(std::shared_ptr<Variable> var, const SqpRange &rangeRequested, |
|
123 | void processRequest(std::shared_ptr<Variable> var, const SqpRange &rangeRequested, | |
124 | QUuid varRequestId); |
|
124 | QUuid varRequestId); | |
125 |
|
125 | |||
126 | std::shared_ptr<Variable> findVariable(QUuid vIdentifier); |
|
126 | std::shared_ptr<Variable> findVariable(QUuid vIdentifier); | |
127 | std::shared_ptr<IDataSeries> |
|
127 | std::shared_ptr<IDataSeries> | |
128 | retrieveDataSeries(const QVector<AcquisitionDataPacket> acqDataPacketVector); |
|
128 | retrieveDataSeries(const QVector<AcquisitionDataPacket> acqDataPacketVector); | |
129 |
|
129 | |||
130 | void registerProvider(std::shared_ptr<IDataProvider> provider); |
|
130 | void registerProvider(std::shared_ptr<IDataProvider> provider); | |
131 |
|
131 | |||
132 | void storeVariableRequest(QUuid varId, QUuid varRequestId, const VariableRequest &varRequest); |
|
132 | void storeVariableRequest(QUuid varId, QUuid varRequestId, const VariableRequest &varRequest); | |
133 | QUuid acceptVariableRequest(QUuid varId, std::shared_ptr<IDataSeries> dataSeries); |
|
133 | QUuid acceptVariableRequest(QUuid varId, std::shared_ptr<IDataSeries> dataSeries); | |
134 | void updateVariables(QUuid varRequestId); |
|
134 | void updateVariables(QUuid varRequestId); | |
135 | void updateVariableRequest(QUuid varRequestId); |
|
135 | void updateVariableRequest(QUuid varRequestId); | |
136 | void cancelVariableRequest(QUuid varRequestId); |
|
136 | void cancelVariableRequest(QUuid varRequestId); | |
137 | void executeVarRequest(std::shared_ptr<Variable> var, VariableRequest &varRequest); |
|
137 | void executeVarRequest(std::shared_ptr<Variable> var, VariableRequest &varRequest); | |
138 |
|
138 | |||
139 | QMutex m_WorkingMutex; |
|
139 | QMutex m_WorkingMutex; | |
140 | /// Variable model. The VariableController has the ownership |
|
140 | /// Variable model. The VariableController has the ownership | |
141 | VariableModel *m_VariableModel; |
|
141 | VariableModel *m_VariableModel; | |
142 | QItemSelectionModel *m_VariableSelectionModel; |
|
142 | QItemSelectionModel *m_VariableSelectionModel; | |
143 |
|
143 | |||
144 |
|
144 | |||
145 | TimeController *m_TimeController{nullptr}; |
|
145 | TimeController *m_TimeController{nullptr}; | |
146 | std::unique_ptr<VariableCacheStrategy> m_VariableCacheStrategy; |
|
146 | std::unique_ptr<VariableCacheStrategy> m_VariableCacheStrategy; | |
147 | std::unique_ptr<VariableAcquisitionWorker> m_VariableAcquisitionWorker; |
|
147 | std::unique_ptr<VariableAcquisitionWorker> m_VariableAcquisitionWorker; | |
148 | QThread m_VariableAcquisitionWorkerThread; |
|
148 | QThread m_VariableAcquisitionWorkerThread; | |
149 |
|
149 | |||
150 | std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> > |
|
150 | std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> > | |
151 | m_VariableToProviderMap; |
|
151 | m_VariableToProviderMap; | |
152 | std::unordered_map<std::shared_ptr<Variable>, QUuid> m_VariableToIdentifierMap; |
|
152 | std::unordered_map<std::shared_ptr<Variable>, QUuid> m_VariableToIdentifierMap; | |
153 | std::map<QUuid, std::shared_ptr<VariableSynchronizationGroup> > |
|
153 | std::map<QUuid, std::shared_ptr<VariableSynchronizationGroup> > | |
154 | m_GroupIdToVariableSynchronizationGroupMap; |
|
154 | m_GroupIdToVariableSynchronizationGroupMap; | |
155 | std::map<QUuid, QUuid> m_VariableIdGroupIdMap; |
|
155 | std::map<QUuid, QUuid> m_VariableIdGroupIdMap; | |
156 | std::set<std::shared_ptr<IDataProvider> > m_ProviderSet; |
|
156 | std::set<std::shared_ptr<IDataProvider> > m_ProviderSet; | |
157 |
|
157 | |||
158 | std::map<QUuid, std::list<QUuid> > m_VarGroupIdToVarIds; |
|
158 | std::map<QUuid, std::list<QUuid> > m_VarGroupIdToVarIds; | |
159 | std::map<QUuid, std::unique_ptr<VariableRequestHandler> > m_VarIdToVarRequestHandler; |
|
159 | std::map<QUuid, std::unique_ptr<VariableRequestHandler> > m_VarIdToVarRequestHandler; | |
160 |
|
160 | |||
161 | VariableController *q; |
|
161 | VariableController *q; | |
162 | }; |
|
162 | }; | |
163 |
|
163 | |||
164 |
|
164 | |||
165 | VariableController::VariableController(QObject *parent) |
|
165 | VariableController::VariableController(QObject *parent) | |
166 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)} |
|
166 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)} | |
167 | { |
|
167 | { | |
168 | qCDebug(LOG_VariableController()) << tr("VariableController construction") |
|
168 | qCDebug(LOG_VariableController()) << tr("VariableController construction") | |
169 | << QThread::currentThread(); |
|
169 | << QThread::currentThread(); | |
170 |
|
170 | |||
171 | connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this, |
|
171 | connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this, | |
172 | &VariableController::onAbortProgressRequested); |
|
172 | &VariableController::onAbortProgressRequested); | |
173 |
|
173 | |||
174 | connect(impl->m_VariableAcquisitionWorker.get(), |
|
174 | connect(impl->m_VariableAcquisitionWorker.get(), | |
175 | &VariableAcquisitionWorker::variableCanceledRequested, this, |
|
175 | &VariableAcquisitionWorker::variableCanceledRequested, this, | |
176 | &VariableController::onAbortAcquisitionRequested); |
|
176 | &VariableController::onAbortAcquisitionRequested); | |
177 |
|
177 | |||
178 | connect(impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::dataProvided, this, |
|
178 | connect(impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::dataProvided, this, | |
179 | &VariableController::onDataProvided); |
|
179 | &VariableController::onDataProvided); | |
180 | connect(impl->m_VariableAcquisitionWorker.get(), |
|
180 | connect(impl->m_VariableAcquisitionWorker.get(), | |
181 | &VariableAcquisitionWorker::variableRequestInProgress, this, |
|
181 | &VariableAcquisitionWorker::variableRequestInProgress, this, | |
182 | &VariableController::onVariableRetrieveDataInProgress); |
|
182 | &VariableController::onVariableRetrieveDataInProgress); | |
183 |
|
183 | |||
184 |
|
184 | |||
185 | connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::started, |
|
185 | connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::started, | |
186 | impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::initialize); |
|
186 | impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::initialize); | |
187 | connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished, |
|
187 | connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished, | |
188 | impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::finalize); |
|
188 | impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::finalize); | |
189 |
|
189 | |||
190 | connect(impl->m_VariableModel, &VariableModel::requestVariableRangeUpdate, this, |
|
190 | connect(impl->m_VariableModel, &VariableModel::requestVariableRangeUpdate, this, | |
191 | &VariableController::onUpdateDateTime); |
|
191 | &VariableController::onUpdateDateTime); | |
192 |
|
192 | |||
193 | impl->m_VariableAcquisitionWorkerThread.start(); |
|
193 | impl->m_VariableAcquisitionWorkerThread.start(); | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | VariableController::~VariableController() |
|
196 | VariableController::~VariableController() | |
197 | { |
|
197 | { | |
198 | qCDebug(LOG_VariableController()) << tr("VariableController destruction") |
|
198 | qCDebug(LOG_VariableController()) << tr("VariableController destruction") | |
199 | << QThread::currentThread(); |
|
199 | << QThread::currentThread(); | |
200 | this->waitForFinish(); |
|
200 | this->waitForFinish(); | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | VariableModel *VariableController::variableModel() noexcept |
|
203 | VariableModel *VariableController::variableModel() noexcept | |
204 | { |
|
204 | { | |
205 | return impl->m_VariableModel; |
|
205 | return impl->m_VariableModel; | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | QItemSelectionModel *VariableController::variableSelectionModel() noexcept |
|
208 | QItemSelectionModel *VariableController::variableSelectionModel() noexcept | |
209 | { |
|
209 | { | |
210 | return impl->m_VariableSelectionModel; |
|
210 | return impl->m_VariableSelectionModel; | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | void VariableController::setTimeController(TimeController *timeController) noexcept |
|
213 | void VariableController::setTimeController(TimeController *timeController) noexcept | |
214 | { |
|
214 | { | |
215 | impl->m_TimeController = timeController; |
|
215 | impl->m_TimeController = timeController; | |
216 | } |
|
216 | } | |
217 |
|
217 | |||
218 | std::shared_ptr<Variable> |
|
218 | std::shared_ptr<Variable> | |
219 | VariableController::cloneVariable(std::shared_ptr<Variable> variable) noexcept |
|
219 | VariableController::cloneVariable(std::shared_ptr<Variable> variable) noexcept | |
220 | { |
|
220 | { | |
221 | if (impl->m_VariableModel->containsVariable(variable)) { |
|
221 | if (impl->m_VariableModel->containsVariable(variable)) { | |
222 | // Clones variable |
|
222 | // Clones variable | |
223 | auto duplicate = variable->clone(); |
|
223 | auto duplicate = variable->clone(); | |
224 |
|
224 | |||
225 | // Adds clone to model |
|
225 | // Adds clone to model | |
226 | impl->m_VariableModel->addVariable(duplicate); |
|
226 | impl->m_VariableModel->addVariable(duplicate); | |
227 |
|
227 | |||
228 | // Generates clone identifier |
|
228 | // Generates clone identifier | |
229 | impl->m_VariableToIdentifierMap[duplicate] = QUuid::createUuid(); |
|
229 | impl->m_VariableToIdentifierMap[duplicate] = QUuid::createUuid(); | |
230 |
|
230 | |||
231 | // Registers provider |
|
231 | // Registers provider | |
232 | auto variableProvider = impl->m_VariableToProviderMap.at(variable); |
|
232 | auto variableProvider = impl->m_VariableToProviderMap.at(variable); | |
233 | auto duplicateProvider = variableProvider != nullptr ? variableProvider->clone() : nullptr; |
|
233 | auto duplicateProvider = variableProvider != nullptr ? variableProvider->clone() : nullptr; | |
234 |
|
234 | |||
235 | impl->m_VariableToProviderMap[duplicate] = duplicateProvider; |
|
235 | impl->m_VariableToProviderMap[duplicate] = duplicateProvider; | |
236 | if (duplicateProvider) { |
|
236 | if (duplicateProvider) { | |
237 | impl->registerProvider(duplicateProvider); |
|
237 | impl->registerProvider(duplicateProvider); | |
238 | } |
|
238 | } | |
239 |
|
239 | |||
240 | return duplicate; |
|
240 | return duplicate; | |
241 | } |
|
241 | } | |
242 | else { |
|
242 | else { | |
243 | qCCritical(LOG_VariableController()) |
|
243 | qCCritical(LOG_VariableController()) | |
244 | << tr("Can't create duplicate of variable %1: variable not registered in the model") |
|
244 | << tr("Can't create duplicate of variable %1: variable not registered in the model") | |
245 | .arg(variable->name()); |
|
245 | .arg(variable->name()); | |
246 | return nullptr; |
|
246 | return nullptr; | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noexcept |
|
250 | void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noexcept | |
251 | { |
|
251 | { | |
252 | if (!variable) { |
|
252 | if (!variable) { | |
253 | qCCritical(LOG_VariableController()) << "Can't delete variable: variable is null"; |
|
253 | qCCritical(LOG_VariableController()) << "Can't delete variable: variable is null"; | |
254 | return; |
|
254 | return; | |
255 | } |
|
255 | } | |
256 |
|
256 | |||
257 | // Spreads in SciQlop that the variable will be deleted, so that potential receivers can |
|
257 | // Spreads in SciQlop that the variable will be deleted, so that potential receivers can | |
258 | // make some treatments before the deletion |
|
258 | // make some treatments before the deletion | |
259 | emit variableAboutToBeDeleted(variable); |
|
259 | emit variableAboutToBeDeleted(variable); | |
260 |
|
260 | |||
261 | // Deletes identifier |
|
261 | // Deletes identifier | |
262 | impl->m_VariableToIdentifierMap.erase(variable); |
|
262 | impl->m_VariableToIdentifierMap.erase(variable); | |
263 |
|
263 | |||
264 | // Deletes provider |
|
264 | // Deletes provider | |
265 | auto nbProvidersDeleted = impl->m_VariableToProviderMap.erase(variable); |
|
265 | auto nbProvidersDeleted = impl->m_VariableToProviderMap.erase(variable); | |
266 | qCDebug(LOG_VariableController()) |
|
266 | qCDebug(LOG_VariableController()) | |
267 | << tr("Number of providers deleted for variable %1: %2") |
|
267 | << tr("Number of providers deleted for variable %1: %2") | |
268 | .arg(variable->name(), QString::number(nbProvidersDeleted)); |
|
268 | .arg(variable->name(), QString::number(nbProvidersDeleted)); | |
269 |
|
269 | |||
270 |
|
270 | |||
271 | // Deletes from model |
|
271 | // Deletes from model | |
272 | impl->m_VariableModel->deleteVariable(variable); |
|
272 | impl->m_VariableModel->deleteVariable(variable); | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | void VariableController::deleteVariables( |
|
275 | void VariableController::deleteVariables( | |
276 | const QVector<std::shared_ptr<Variable> > &variables) noexcept |
|
276 | const QVector<std::shared_ptr<Variable> > &variables) noexcept | |
277 | { |
|
277 | { | |
278 | for (auto variable : qAsConst(variables)) { |
|
278 | for (auto variable : qAsConst(variables)) { | |
279 | deleteVariable(variable); |
|
279 | deleteVariable(variable); | |
280 | } |
|
280 | } | |
281 | } |
|
281 | } | |
282 |
|
282 | |||
283 | QByteArray |
|
283 | QByteArray | |
284 | VariableController::mimeDataForVariables(const QList<std::shared_ptr<Variable> > &variables) const |
|
284 | VariableController::mimeDataForVariables(const QList<std::shared_ptr<Variable> > &variables) const | |
285 | { |
|
285 | { | |
286 | auto encodedData = QByteArray{}; |
|
286 | auto encodedData = QByteArray{}; | |
287 |
|
287 | |||
288 | QVariantList ids; |
|
288 | QVariantList ids; | |
289 | for (auto &var : variables) { |
|
289 | for (auto &var : variables) { | |
290 | auto itVar = impl->m_VariableToIdentifierMap.find(var); |
|
290 | auto itVar = impl->m_VariableToIdentifierMap.find(var); | |
291 | if (itVar == impl->m_VariableToIdentifierMap.cend()) { |
|
291 | if (itVar == impl->m_VariableToIdentifierMap.cend()) { | |
292 | qCCritical(LOG_VariableController()) |
|
292 | qCCritical(LOG_VariableController()) | |
293 | << tr("Impossible to find the data for an unknown variable."); |
|
293 | << tr("Impossible to find the data for an unknown variable."); | |
294 | } |
|
294 | } | |
295 |
|
295 | |||
296 | ids << itVar->second.toByteArray(); |
|
296 | ids << itVar->second.toByteArray(); | |
297 | } |
|
297 | } | |
298 |
|
298 | |||
299 | QDataStream stream{&encodedData, QIODevice::WriteOnly}; |
|
299 | QDataStream stream{&encodedData, QIODevice::WriteOnly}; | |
300 | stream << ids; |
|
300 | stream << ids; | |
301 |
|
301 | |||
302 | return encodedData; |
|
302 | return encodedData; | |
303 | } |
|
303 | } | |
304 |
|
304 | |||
305 | QList<std::shared_ptr<Variable> > |
|
305 | QList<std::shared_ptr<Variable> > | |
306 | VariableController::variablesForMimeData(const QByteArray &mimeData) const |
|
306 | VariableController::variablesForMimeData(const QByteArray &mimeData) const | |
307 | { |
|
307 | { | |
308 | auto variables = QList<std::shared_ptr<Variable> >{}; |
|
308 | auto variables = QList<std::shared_ptr<Variable> >{}; | |
309 | QDataStream stream{mimeData}; |
|
309 | QDataStream stream{mimeData}; | |
310 |
|
310 | |||
311 | QVariantList ids; |
|
311 | QVariantList ids; | |
312 | stream >> ids; |
|
312 | stream >> ids; | |
313 |
|
313 | |||
314 | for (auto id : ids) { |
|
314 | for (auto id : ids) { | |
315 | auto uuid = QUuid{id.toByteArray()}; |
|
315 | auto uuid = QUuid{id.toByteArray()}; | |
316 | auto var = impl->findVariable(uuid); |
|
316 | auto var = impl->findVariable(uuid); | |
317 | variables << var; |
|
317 | variables << var; | |
318 | } |
|
318 | } | |
319 |
|
319 | |||
320 | return variables; |
|
320 | return variables; | |
321 | } |
|
321 | } | |
322 |
|
322 | |||
323 | std::shared_ptr<Variable> |
|
323 | std::shared_ptr<Variable> | |
324 | VariableController::createVariable(const QString &name, const QVariantHash &metadata, |
|
324 | VariableController::createVariable(const QString &name, const QVariantHash &metadata, | |
325 | std::shared_ptr<IDataProvider> provider) noexcept |
|
325 | std::shared_ptr<IDataProvider> provider) noexcept | |
326 | { |
|
326 | { | |
327 | if (!impl->m_TimeController) { |
|
327 | if (!impl->m_TimeController) { | |
328 | qCCritical(LOG_VariableController()) |
|
328 | qCCritical(LOG_VariableController()) | |
329 | << tr("Impossible to create variable: The time controller is null"); |
|
329 | << tr("Impossible to create variable: The time controller is null"); | |
330 | return nullptr; |
|
330 | return nullptr; | |
331 | } |
|
331 | } | |
332 |
|
332 | |||
333 | auto range = impl->m_TimeController->dateTime(); |
|
333 | auto range = impl->m_TimeController->dateTime(); | |
334 |
|
334 | |||
335 | if (auto newVariable = impl->m_VariableModel->createVariable(name, metadata)) { |
|
335 | if (auto newVariable = impl->m_VariableModel->createVariable(name, metadata)) { | |
336 | auto varId = QUuid::createUuid(); |
|
336 | auto varId = QUuid::createUuid(); | |
337 |
|
337 | |||
338 | // Create the handler |
|
338 | // Create the handler | |
339 | auto varRequestHandler = std::make_unique<VariableRequestHandler>(); |
|
339 | auto varRequestHandler = std::make_unique<VariableRequestHandler>(); | |
340 | varRequestHandler->m_VarId = varId; |
|
340 | varRequestHandler->m_VarId = varId; | |
341 |
|
341 | |||
342 | impl->m_VarIdToVarRequestHandler.insert( |
|
342 | impl->m_VarIdToVarRequestHandler.insert( | |
343 | std::make_pair(varId, std::move(varRequestHandler))); |
|
343 | std::make_pair(varId, std::move(varRequestHandler))); | |
344 |
|
344 | |||
345 | // store the provider |
|
345 | // store the provider | |
346 | impl->registerProvider(provider); |
|
346 | impl->registerProvider(provider); | |
347 |
|
347 | |||
348 | // Associate the provider |
|
348 | // Associate the provider | |
349 | impl->m_VariableToProviderMap[newVariable] = provider; |
|
349 | impl->m_VariableToProviderMap[newVariable] = provider; | |
350 | impl->m_VariableToIdentifierMap[newVariable] = varId; |
|
350 | impl->m_VariableToIdentifierMap[newVariable] = varId; | |
351 |
|
351 | |||
352 | this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{newVariable}, range, false); |
|
352 | this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{newVariable}, range, false); | |
353 |
|
353 | |||
354 | // auto varRequestId = QUuid::createUuid(); |
|
354 | // auto varRequestId = QUuid::createUuid(); | |
355 | // qCInfo(LOG_VariableController()) << "createVariable: " << varId << varRequestId; |
|
355 | // qCInfo(LOG_VariableController()) << "createVariable: " << varId << varRequestId; | |
356 | // impl->processRequest(newVariable, range, varRequestId); |
|
356 | // impl->processRequest(newVariable, range, varRequestId); | |
357 | // impl->updateVariableRequest(varRequestId); |
|
357 | // impl->updateVariableRequest(varRequestId); | |
358 |
|
358 | |||
359 | return newVariable; |
|
359 | return newVariable; | |
360 | } |
|
360 | } | |
361 |
|
361 | |||
362 | qCCritical(LOG_VariableController()) << tr("Impossible to create variable"); |
|
362 | qCCritical(LOG_VariableController()) << tr("Impossible to create variable"); | |
363 | return nullptr; |
|
363 | return nullptr; | |
364 | } |
|
364 | } | |
365 |
|
365 | |||
366 | void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) |
|
366 | void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) | |
367 | { |
|
367 | { | |
368 | // NOTE: Even if acquisition request is aborting, the graphe range will be changed |
|
368 | // NOTE: Even if acquisition request is aborting, the graphe range will be changed | |
369 | qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection" |
|
369 | qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection" | |
370 | << QThread::currentThread()->objectName(); |
|
370 | << QThread::currentThread()->objectName(); | |
371 | auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); |
|
371 | auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); | |
372 |
|
372 | |||
373 | // NOTE we only permit the time modification for one variable |
|
373 | // NOTE we only permit the time modification for one variable | |
374 | // DEPRECATED |
|
374 | // DEPRECATED | |
375 | // auto variables = QVector<std::shared_ptr<Variable> >{}; |
|
375 | // auto variables = QVector<std::shared_ptr<Variable> >{}; | |
376 | // for (const auto &selectedRow : qAsConst(selectedRows)) { |
|
376 | // for (const auto &selectedRow : qAsConst(selectedRows)) { | |
377 | // if (auto selectedVariable = |
|
377 | // if (auto selectedVariable = | |
378 | // impl->m_VariableModel->variable(selectedRow.row())) { |
|
378 | // impl->m_VariableModel->variable(selectedRow.row())) { | |
379 | // variables << selectedVariable; |
|
379 | // variables << selectedVariable; | |
380 |
|
380 | |||
381 | // // notify that rescale operation has to be done |
|
381 | // // notify that rescale operation has to be done | |
382 | // emit rangeChanged(selectedVariable, dateTime); |
|
382 | // emit rangeChanged(selectedVariable, dateTime); | |
383 | // } |
|
383 | // } | |
384 | // } |
|
384 | // } | |
385 | // if (!variables.isEmpty()) { |
|
385 | // if (!variables.isEmpty()) { | |
386 | // this->onRequestDataLoading(variables, dateTime, synchro); |
|
386 | // this->onRequestDataLoading(variables, dateTime, synchro); | |
387 | // } |
|
387 | // } | |
388 | if (selectedRows.size() == 1) { |
|
388 | if (selectedRows.size() == 1) { | |
389 |
|
389 | |||
390 | if (auto selectedVariable |
|
390 | if (auto selectedVariable | |
391 | = impl->m_VariableModel->variable(qAsConst(selectedRows).first().row())) { |
|
391 | = impl->m_VariableModel->variable(qAsConst(selectedRows).first().row())) { | |
392 |
|
392 | |||
393 | onUpdateDateTime(selectedVariable, dateTime); |
|
393 | onUpdateDateTime(selectedVariable, dateTime); | |
394 | } |
|
394 | } | |
395 | } |
|
395 | } | |
396 | else if (selectedRows.size() > 1) { |
|
396 | else if (selectedRows.size() > 1) { | |
397 | qCCritical(LOG_VariableController()) |
|
397 | qCCritical(LOG_VariableController()) | |
398 | << tr("Impossible to set time for more than 1 variable in the same time"); |
|
398 | << tr("Impossible to set time for more than 1 variable in the same time"); | |
399 | } |
|
399 | } | |
400 | else { |
|
400 | else { | |
401 | qCWarning(LOG_VariableController()) |
|
401 | qCWarning(LOG_VariableController()) | |
402 | << tr("There is no variable selected to set the time one"); |
|
402 | << tr("There is no variable selected to set the time one"); | |
403 | } |
|
403 | } | |
404 | } |
|
404 | } | |
405 |
|
405 | |||
406 | void VariableController::onUpdateDateTime(std::shared_ptr<Variable> variable, |
|
406 | void VariableController::onUpdateDateTime(std::shared_ptr<Variable> variable, | |
407 | const SqpRange &dateTime) |
|
407 | const SqpRange &dateTime) | |
408 | { |
|
408 | { | |
409 | auto itVar = impl->m_VariableToIdentifierMap.find(variable); |
|
409 | auto itVar = impl->m_VariableToIdentifierMap.find(variable); | |
410 | if (itVar == impl->m_VariableToIdentifierMap.cend()) { |
|
410 | if (itVar == impl->m_VariableToIdentifierMap.cend()) { | |
411 | qCCritical(LOG_VariableController()) |
|
411 | qCCritical(LOG_VariableController()) | |
412 | << tr("Impossible to onDateTimeOnSelection request for unknown variable"); |
|
412 | << tr("Impossible to onDateTimeOnSelection request for unknown variable"); | |
413 | return; |
|
413 | return; | |
414 | } |
|
414 | } | |
415 |
|
415 | |||
416 | // notify that rescale operation has to be done |
|
416 | // notify that rescale operation has to be done | |
417 | emit rangeChanged(variable, dateTime); |
|
417 | emit rangeChanged(variable, dateTime); | |
418 |
|
418 | |||
419 | auto synchro |
|
419 | auto synchro | |
420 | = impl->m_VariableIdGroupIdMap.find(itVar->second) != impl->m_VariableIdGroupIdMap.cend(); |
|
420 | = impl->m_VariableIdGroupIdMap.find(itVar->second) != impl->m_VariableIdGroupIdMap.cend(); | |
421 |
|
421 | |||
422 | this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{variable}, dateTime, synchro); |
|
422 | this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{variable}, dateTime, synchro); | |
423 | } |
|
423 | } | |
424 |
|
424 | |||
425 | void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, |
|
425 | void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, | |
426 | const SqpRange &cacheRangeRequested, |
|
426 | const SqpRange &cacheRangeRequested, | |
427 | QVector<AcquisitionDataPacket> dataAcquired) |
|
427 | QVector<AcquisitionDataPacket> dataAcquired) | |
428 | { |
|
428 | { | |
429 | qCDebug(LOG_VariableController()) << tr("onDataProvided") << QThread::currentThread(); |
|
429 | qCDebug(LOG_VariableController()) << tr("onDataProvided") << QThread::currentThread(); | |
430 | auto retrievedDataSeries = impl->retrieveDataSeries(dataAcquired); |
|
430 | auto retrievedDataSeries = impl->retrieveDataSeries(dataAcquired); | |
431 | auto varRequestId = impl->acceptVariableRequest(vIdentifier, retrievedDataSeries); |
|
431 | auto varRequestId = impl->acceptVariableRequest(vIdentifier, retrievedDataSeries); | |
432 | if (!varRequestId.isNull()) { |
|
432 | if (!varRequestId.isNull()) { | |
433 | impl->updateVariables(varRequestId); |
|
433 | impl->updateVariables(varRequestId); | |
434 | } |
|
434 | } | |
435 | } |
|
435 | } | |
436 |
|
436 | |||
437 | void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, double progress) |
|
437 | void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, double progress) | |
438 | { |
|
438 | { | |
439 | qCDebug(LOG_VariableController()) |
|
439 | qCDebug(LOG_VariableController()) | |
440 | << "TORM: variableController::onVariableRetrieveDataInProgress" |
|
440 | << "TORM: variableController::onVariableRetrieveDataInProgress" | |
441 | << QThread::currentThread()->objectName() << progress; |
|
441 | << QThread::currentThread()->objectName() << progress; | |
442 | if (auto var = impl->findVariable(identifier)) { |
|
442 | if (auto var = impl->findVariable(identifier)) { | |
443 | impl->m_VariableModel->setDataProgress(var, progress); |
|
443 | impl->m_VariableModel->setDataProgress(var, progress); | |
444 | } |
|
444 | } | |
445 | else { |
|
445 | else { | |
446 | qCCritical(LOG_VariableController()) |
|
446 | qCCritical(LOG_VariableController()) | |
447 | << tr("Impossible to notify progression of a null variable"); |
|
447 | << tr("Impossible to notify progression of a null variable"); | |
448 | } |
|
448 | } | |
449 | } |
|
449 | } | |
450 |
|
450 | |||
451 | void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> variable) |
|
451 | void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> variable) | |
452 | { |
|
452 | { | |
453 | qCDebug(LOG_VariableController()) << "TORM: variableController::onAbortProgressRequested" |
|
453 | qCDebug(LOG_VariableController()) << "TORM: variableController::onAbortProgressRequested" | |
454 | << QThread::currentThread()->objectName() << variable->name(); |
|
454 | << QThread::currentThread()->objectName() << variable->name(); | |
455 |
|
455 | |||
456 | auto itVar = impl->m_VariableToIdentifierMap.find(variable); |
|
456 | auto itVar = impl->m_VariableToIdentifierMap.find(variable); | |
457 | if (itVar == impl->m_VariableToIdentifierMap.cend()) { |
|
457 | if (itVar == impl->m_VariableToIdentifierMap.cend()) { | |
458 | qCCritical(LOG_VariableController()) |
|
458 | qCCritical(LOG_VariableController()) | |
459 | << tr("Impossible to onAbortProgressRequested request for unknown variable"); |
|
459 | << tr("Impossible to onAbortProgressRequested request for unknown variable"); | |
460 | return; |
|
460 | return; | |
461 | } |
|
461 | } | |
462 |
|
462 | |||
463 | auto varId = itVar->second; |
|
463 | auto varId = itVar->second; | |
464 |
|
464 | |||
465 | auto itVarHandler = impl->m_VarIdToVarRequestHandler.find(varId); |
|
465 | auto itVarHandler = impl->m_VarIdToVarRequestHandler.find(varId); | |
466 | if (itVarHandler == impl->m_VarIdToVarRequestHandler.cend()) { |
|
466 | if (itVarHandler == impl->m_VarIdToVarRequestHandler.cend()) { | |
467 | qCCritical(LOG_VariableController()) |
|
467 | qCCritical(LOG_VariableController()) | |
468 | << tr("Impossible to onAbortProgressRequested for variable with unknown handler"); |
|
468 | << tr("Impossible to onAbortProgressRequested for variable with unknown handler"); | |
469 | return; |
|
469 | return; | |
470 | } |
|
470 | } | |
471 |
|
471 | |||
472 | auto varHandler = itVarHandler->second.get(); |
|
472 | auto varHandler = itVarHandler->second.get(); | |
473 |
|
473 | |||
474 | // case where a variable has a running request |
|
474 | // case where a variable has a running request | |
475 | if (varHandler->m_State != VariableRequestHandlerState::OFF) { |
|
475 | if (varHandler->m_State != VariableRequestHandlerState::OFF) { | |
476 | impl->cancelVariableRequest(varHandler->m_RunningVarRequest.m_VariableGroupId); |
|
476 | impl->cancelVariableRequest(varHandler->m_RunningVarRequest.m_VariableGroupId); | |
477 | } |
|
477 | } | |
478 | } |
|
478 | } | |
479 |
|
479 | |||
480 | void VariableController::onAbortAcquisitionRequested(QUuid vIdentifier) |
|
480 | void VariableController::onAbortAcquisitionRequested(QUuid vIdentifier) | |
481 | { |
|
481 | { | |
482 | qCDebug(LOG_VariableController()) << "TORM: variableController::onAbortAcquisitionRequested" |
|
482 | qCDebug(LOG_VariableController()) << "TORM: variableController::onAbortAcquisitionRequested" | |
483 | << QThread::currentThread()->objectName() << vIdentifier; |
|
483 | << QThread::currentThread()->objectName() << vIdentifier; | |
484 |
|
484 | |||
485 | if (auto var = impl->findVariable(vIdentifier)) { |
|
485 | if (auto var = impl->findVariable(vIdentifier)) { | |
486 | this->onAbortProgressRequested(var); |
|
486 | this->onAbortProgressRequested(var); | |
487 | } |
|
487 | } | |
488 | else { |
|
488 | else { | |
489 | qCCritical(LOG_VariableController()) |
|
489 | qCCritical(LOG_VariableController()) | |
490 | << tr("Impossible to abort Acquisition Requestof a null variable"); |
|
490 | << tr("Impossible to abort Acquisition Requestof a null variable"); | |
491 | } |
|
491 | } | |
492 | } |
|
492 | } | |
493 |
|
493 | |||
494 | void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId) |
|
494 | void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId) | |
495 | { |
|
495 | { | |
496 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId" |
|
496 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId" | |
497 | << QThread::currentThread()->objectName() |
|
497 | << QThread::currentThread()->objectName() | |
498 | << synchronizationGroupId; |
|
498 | << synchronizationGroupId; | |
499 | auto vSynchroGroup = std::make_shared<VariableSynchronizationGroup>(); |
|
499 | auto vSynchroGroup = std::make_shared<VariableSynchronizationGroup>(); | |
500 | impl->m_GroupIdToVariableSynchronizationGroupMap.insert( |
|
500 | impl->m_GroupIdToVariableSynchronizationGroupMap.insert( | |
501 | std::make_pair(synchronizationGroupId, vSynchroGroup)); |
|
501 | std::make_pair(synchronizationGroupId, vSynchroGroup)); | |
502 | } |
|
502 | } | |
503 |
|
503 | |||
504 | void VariableController::onRemoveSynchronizationGroupId(QUuid synchronizationGroupId) |
|
504 | void VariableController::onRemoveSynchronizationGroupId(QUuid synchronizationGroupId) | |
505 | { |
|
505 | { | |
506 | impl->m_GroupIdToVariableSynchronizationGroupMap.erase(synchronizationGroupId); |
|
506 | impl->m_GroupIdToVariableSynchronizationGroupMap.erase(synchronizationGroupId); | |
507 | } |
|
507 | } | |
508 |
|
508 | |||
509 | void VariableController::onAddSynchronized(std::shared_ptr<Variable> variable, |
|
509 | void VariableController::onAddSynchronized(std::shared_ptr<Variable> variable, | |
510 | QUuid synchronizationGroupId) |
|
510 | QUuid synchronizationGroupId) | |
511 |
|
511 | |||
512 | { |
|
512 | { | |
513 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronized" |
|
513 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronized" | |
514 | << synchronizationGroupId; |
|
514 | << synchronizationGroupId; | |
515 | auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(variable); |
|
515 | auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(variable); | |
516 | if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { |
|
516 | if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { | |
517 | auto groupIdToVSGIt |
|
517 | auto groupIdToVSGIt | |
518 | = impl->m_GroupIdToVariableSynchronizationGroupMap.find(synchronizationGroupId); |
|
518 | = impl->m_GroupIdToVariableSynchronizationGroupMap.find(synchronizationGroupId); | |
519 | if (groupIdToVSGIt != impl->m_GroupIdToVariableSynchronizationGroupMap.cend()) { |
|
519 | if (groupIdToVSGIt != impl->m_GroupIdToVariableSynchronizationGroupMap.cend()) { | |
520 | impl->m_VariableIdGroupIdMap.insert( |
|
520 | impl->m_VariableIdGroupIdMap.insert( | |
521 | std::make_pair(varToVarIdIt->second, synchronizationGroupId)); |
|
521 | std::make_pair(varToVarIdIt->second, synchronizationGroupId)); | |
522 | groupIdToVSGIt->second->addVariableId(varToVarIdIt->second); |
|
522 | groupIdToVSGIt->second->addVariableId(varToVarIdIt->second); | |
523 | } |
|
523 | } | |
524 | else { |
|
524 | else { | |
525 | qCCritical(LOG_VariableController()) |
|
525 | qCCritical(LOG_VariableController()) | |
526 | << tr("Impossible to synchronize a variable with an unknown sycnhronization group") |
|
526 | << tr("Impossible to synchronize a variable with an unknown sycnhronization group") | |
527 | << variable->name(); |
|
527 | << variable->name(); | |
528 | } |
|
528 | } | |
529 | } |
|
529 | } | |
530 | else { |
|
530 | else { | |
531 | qCCritical(LOG_VariableController()) |
|
531 | qCCritical(LOG_VariableController()) | |
532 | << tr("Impossible to synchronize a variable with no identifier") << variable->name(); |
|
532 | << tr("Impossible to synchronize a variable with no identifier") << variable->name(); | |
533 | } |
|
533 | } | |
534 | } |
|
534 | } | |
535 |
|
535 | |||
536 | void VariableController::desynchronize(std::shared_ptr<Variable> variable, |
|
536 | void VariableController::desynchronize(std::shared_ptr<Variable> variable, | |
537 | QUuid synchronizationGroupId) |
|
537 | QUuid synchronizationGroupId) | |
538 | { |
|
538 | { | |
539 | // Gets variable id |
|
539 | // Gets variable id | |
540 | auto variableIt = impl->m_VariableToIdentifierMap.find(variable); |
|
540 | auto variableIt = impl->m_VariableToIdentifierMap.find(variable); | |
541 | if (variableIt == impl->m_VariableToIdentifierMap.cend()) { |
|
541 | if (variableIt == impl->m_VariableToIdentifierMap.cend()) { | |
542 | qCCritical(LOG_VariableController()) |
|
542 | qCCritical(LOG_VariableController()) | |
543 | << tr("Can't desynchronize variable %1: variable identifier not found") |
|
543 | << tr("Can't desynchronize variable %1: variable identifier not found") | |
544 | .arg(variable->name()); |
|
544 | .arg(variable->name()); | |
545 | return; |
|
545 | return; | |
546 | } |
|
546 | } | |
547 |
|
547 | |||
548 | // Gets synchronization group |
|
548 | // Gets synchronization group | |
549 | auto groupIt = impl->m_GroupIdToVariableSynchronizationGroupMap.find(synchronizationGroupId); |
|
549 | auto groupIt = impl->m_GroupIdToVariableSynchronizationGroupMap.find(synchronizationGroupId); | |
550 | if (groupIt == impl->m_GroupIdToVariableSynchronizationGroupMap.cend()) { |
|
550 | if (groupIt == impl->m_GroupIdToVariableSynchronizationGroupMap.cend()) { | |
551 | qCCritical(LOG_VariableController()) |
|
551 | qCCritical(LOG_VariableController()) | |
552 | << tr("Can't desynchronize variable %1: unknown synchronization group") |
|
552 | << tr("Can't desynchronize variable %1: unknown synchronization group") | |
553 | .arg(variable->name()); |
|
553 | .arg(variable->name()); | |
554 | return; |
|
554 | return; | |
555 | } |
|
555 | } | |
556 |
|
556 | |||
557 | auto variableId = variableIt->second; |
|
557 | auto variableId = variableIt->second; | |
558 |
|
558 | |||
559 | // Removes variable from synchronization group |
|
559 | // Removes variable from synchronization group | |
560 | auto synchronizationGroup = groupIt->second; |
|
560 | auto synchronizationGroup = groupIt->second; | |
561 | synchronizationGroup->removeVariableId(variableId); |
|
561 | synchronizationGroup->removeVariableId(variableId); | |
562 |
|
562 | |||
563 | // Removes link between variable and synchronization group |
|
563 | // Removes link between variable and synchronization group | |
564 | impl->m_VariableIdGroupIdMap.erase(variableId); |
|
564 | impl->m_VariableIdGroupIdMap.erase(variableId); | |
565 | } |
|
565 | } | |
566 |
|
566 | |||
567 | void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, |
|
567 | void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, | |
568 | const SqpRange &range, bool synchronise) |
|
568 | const SqpRange &range, bool synchronise) | |
569 | { |
|
569 | { | |
570 | // variables is assumed synchronized |
|
570 | // variables is assumed synchronized | |
571 | // TODO: Asser variables synchronization |
|
571 | // TODO: Asser variables synchronization | |
572 | // we want to load data of the variable for the dateTime. |
|
572 | // we want to load data of the variable for the dateTime. | |
573 | if (variables.isEmpty()) { |
|
573 | if (variables.isEmpty()) { | |
574 | return; |
|
574 | return; | |
575 | } |
|
575 | } | |
576 |
|
576 | |||
577 | auto varRequestId = QUuid::createUuid(); |
|
577 | auto varRequestId = QUuid::createUuid(); | |
578 | qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading" |
|
578 | qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading" | |
579 | << QThread::currentThread()->objectName() << varRequestId |
|
579 | << QThread::currentThread()->objectName() << varRequestId | |
580 | << range << synchronise; |
|
580 | << range << synchronise; | |
581 |
|
581 | |||
582 | if (!synchronise) { |
|
582 | if (!synchronise) { | |
583 | auto varIds = std::list<QUuid>{}; |
|
583 | auto varIds = std::list<QUuid>{}; | |
584 | for (const auto &var : variables) { |
|
584 | for (const auto &var : variables) { | |
585 | auto vId = impl->m_VariableToIdentifierMap.at(var); |
|
585 | auto vId = impl->m_VariableToIdentifierMap.at(var); | |
586 | varIds.push_back(vId); |
|
586 | varIds.push_back(vId); | |
587 | } |
|
587 | } | |
588 | impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); |
|
588 | impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); | |
589 | for (const auto &var : variables) { |
|
589 | for (const auto &var : variables) { | |
590 | qCDebug(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId |
|
590 | qCDebug(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId | |
591 | << varIds.size(); |
|
591 | << varIds.size(); | |
592 | impl->processRequest(var, range, varRequestId); |
|
592 | impl->processRequest(var, range, varRequestId); | |
593 | } |
|
593 | } | |
594 | } |
|
594 | } | |
595 | else { |
|
595 | else { | |
596 | auto vId = impl->m_VariableToIdentifierMap.at(variables.first()); |
|
596 | auto vId = impl->m_VariableToIdentifierMap.at(variables.first()); | |
597 | auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId); |
|
597 | auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId); | |
598 | if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) { |
|
598 | if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) { | |
599 | auto groupId = varIdToGroupIdIt->second; |
|
599 | auto groupId = varIdToGroupIdIt->second; | |
600 |
|
600 | |||
601 | auto vSynchronizationGroup |
|
601 | auto vSynchronizationGroup | |
602 | = impl->m_GroupIdToVariableSynchronizationGroupMap.at(groupId); |
|
602 | = impl->m_GroupIdToVariableSynchronizationGroupMap.at(groupId); | |
603 | auto vSyncIds = vSynchronizationGroup->getIds(); |
|
603 | auto vSyncIds = vSynchronizationGroup->getIds(); | |
604 |
|
604 | |||
605 | auto varIds = std::list<QUuid>{}; |
|
605 | auto varIds = std::list<QUuid>{}; | |
606 | for (auto vId : vSyncIds) { |
|
606 | for (auto vId : vSyncIds) { | |
607 | varIds.push_back(vId); |
|
607 | varIds.push_back(vId); | |
608 | } |
|
608 | } | |
609 | impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); |
|
609 | impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); | |
610 |
|
610 | |||
611 | for (auto vId : vSyncIds) { |
|
611 | for (auto vId : vSyncIds) { | |
612 | auto var = impl->findVariable(vId); |
|
612 | auto var = impl->findVariable(vId); | |
613 |
|
613 | |||
614 | // Don't process already processed var |
|
614 | // Don't process already processed var | |
615 | if (var != nullptr) { |
|
615 | if (var != nullptr) { | |
616 | qCDebug(LOG_VariableController()) << "processRequest synchro for" << var->name() |
|
616 | qCDebug(LOG_VariableController()) << "processRequest synchro for" << var->name() | |
617 | << varRequestId; |
|
617 | << varRequestId; | |
618 | auto vSyncRangeRequested |
|
618 | auto vSyncRangeRequested | |
619 | = variables.contains(var) |
|
619 | = variables.contains(var) | |
620 | ? range |
|
620 | ? range | |
621 | : computeSynchroRangeRequested(var->range(), range, |
|
621 | : computeSynchroRangeRequested(var->range(), range, | |
622 | variables.first()->range()); |
|
622 | variables.first()->range()); | |
623 | qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested; |
|
623 | qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested; | |
624 | impl->processRequest(var, vSyncRangeRequested, varRequestId); |
|
624 | impl->processRequest(var, vSyncRangeRequested, varRequestId); | |
625 | } |
|
625 | } | |
626 | else { |
|
626 | else { | |
627 | qCCritical(LOG_VariableController()) |
|
627 | qCCritical(LOG_VariableController()) | |
628 |
|
628 | |||
629 | << tr("Impossible to synchronize a null variable"); |
|
629 | << tr("Impossible to synchronize a null variable"); | |
630 | } |
|
630 | } | |
631 | } |
|
631 | } | |
632 | } |
|
632 | } | |
633 | } |
|
633 | } | |
634 |
|
634 | |||
635 | impl->updateVariables(varRequestId); |
|
635 | impl->updateVariables(varRequestId); | |
636 | } |
|
636 | } | |
637 |
|
637 | |||
638 |
|
638 | |||
639 | void VariableController::initialize() |
|
639 | void VariableController::initialize() | |
640 | { |
|
640 | { | |
641 | qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread(); |
|
641 | qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread(); | |
642 | impl->m_WorkingMutex.lock(); |
|
642 | impl->m_WorkingMutex.lock(); | |
643 | qCDebug(LOG_VariableController()) << tr("VariableController init END"); |
|
643 | qCDebug(LOG_VariableController()) << tr("VariableController init END"); | |
644 | } |
|
644 | } | |
645 |
|
645 | |||
646 | void VariableController::finalize() |
|
646 | void VariableController::finalize() | |
647 | { |
|
647 | { | |
648 | impl->m_WorkingMutex.unlock(); |
|
648 | impl->m_WorkingMutex.unlock(); | |
649 | } |
|
649 | } | |
650 |
|
650 | |||
651 | void VariableController::waitForFinish() |
|
651 | void VariableController::waitForFinish() | |
652 | { |
|
652 | { | |
653 | QMutexLocker locker{&impl->m_WorkingMutex}; |
|
653 | QMutexLocker locker{&impl->m_WorkingMutex}; | |
654 | } |
|
654 | } | |
655 |
|
655 | |||
656 | AcquisitionZoomType VariableController::getZoomType(const SqpRange &range, const SqpRange &oldRange) |
|
656 | AcquisitionZoomType VariableController::getZoomType(const SqpRange &range, const SqpRange &oldRange) | |
657 | { |
|
657 | { | |
658 | // t1.m_TStart <= t2.m_TStart && t2.m_TEnd <= t1.m_TEnd |
|
658 | // t1.m_TStart <= t2.m_TStart && t2.m_TEnd <= t1.m_TEnd | |
659 | auto zoomType = AcquisitionZoomType::Unknown; |
|
659 | auto zoomType = AcquisitionZoomType::Unknown; | |
660 | if (range.m_TStart <= oldRange.m_TStart && oldRange.m_TEnd <= range.m_TEnd) { |
|
660 | if (range.m_TStart <= oldRange.m_TStart && oldRange.m_TEnd <= range.m_TEnd) { | |
661 | qCDebug(LOG_VariableController()) << "zoomtype: ZoomOut"; |
|
661 | qCDebug(LOG_VariableController()) << "zoomtype: ZoomOut"; | |
662 | zoomType = AcquisitionZoomType::ZoomOut; |
|
662 | zoomType = AcquisitionZoomType::ZoomOut; | |
663 | } |
|
663 | } | |
664 | else if (range.m_TStart > oldRange.m_TStart && range.m_TEnd > oldRange.m_TEnd) { |
|
664 | else if (range.m_TStart > oldRange.m_TStart && range.m_TEnd > oldRange.m_TEnd) { | |
665 | qCDebug(LOG_VariableController()) << "zoomtype: PanRight"; |
|
665 | qCDebug(LOG_VariableController()) << "zoomtype: PanRight"; | |
666 | zoomType = AcquisitionZoomType::PanRight; |
|
666 | zoomType = AcquisitionZoomType::PanRight; | |
667 | } |
|
667 | } | |
668 | else if (range.m_TStart < oldRange.m_TStart && range.m_TEnd < oldRange.m_TEnd) { |
|
668 | else if (range.m_TStart < oldRange.m_TStart && range.m_TEnd < oldRange.m_TEnd) { | |
669 | qCDebug(LOG_VariableController()) << "zoomtype: PanLeft"; |
|
669 | qCDebug(LOG_VariableController()) << "zoomtype: PanLeft"; | |
670 | zoomType = AcquisitionZoomType::PanLeft; |
|
670 | zoomType = AcquisitionZoomType::PanLeft; | |
671 | } |
|
671 | } | |
672 | else if (range.m_TStart > oldRange.m_TStart && oldRange.m_TEnd > range.m_TEnd) { |
|
672 | else if (range.m_TStart >= oldRange.m_TStart && oldRange.m_TEnd >= range.m_TEnd) { | |
673 | qCDebug(LOG_VariableController()) << "zoomtype: ZoomIn"; |
|
673 | qCDebug(LOG_VariableController()) << "zoomtype: ZoomIn"; | |
674 | zoomType = AcquisitionZoomType::ZoomIn; |
|
674 | zoomType = AcquisitionZoomType::ZoomIn; | |
675 | } |
|
675 | } | |
676 | else { |
|
676 | else { | |
677 | qCDebug(LOG_VariableController()) << "getZoomType: Unknown type detected"; |
|
677 | qCDebug(LOG_VariableController()) << "getZoomType: Unknown type detected"; | |
678 | } |
|
678 | } | |
679 | return zoomType; |
|
679 | return zoomType; | |
680 | } |
|
680 | } | |
681 |
|
681 | |||
682 | void VariableController::VariableControllerPrivate::processRequest(std::shared_ptr<Variable> var, |
|
682 | void VariableController::VariableControllerPrivate::processRequest(std::shared_ptr<Variable> var, | |
683 | const SqpRange &rangeRequested, |
|
683 | const SqpRange &rangeRequested, | |
684 | QUuid varRequestId) |
|
684 | QUuid varRequestId) | |
685 | { |
|
685 | { | |
686 | auto itVar = m_VariableToIdentifierMap.find(var); |
|
686 | auto itVar = m_VariableToIdentifierMap.find(var); | |
687 | if (itVar == m_VariableToIdentifierMap.cend()) { |
|
687 | if (itVar == m_VariableToIdentifierMap.cend()) { | |
688 | qCCritical(LOG_VariableController()) |
|
688 | qCCritical(LOG_VariableController()) | |
689 | << tr("Impossible to process request for unknown variable"); |
|
689 | << tr("Impossible to process request for unknown variable"); | |
690 | return; |
|
690 | return; | |
691 | } |
|
691 | } | |
692 |
|
692 | |||
693 | auto varId = itVar->second; |
|
693 | auto varId = itVar->second; | |
694 |
|
694 | |||
695 | auto itVarHandler = m_VarIdToVarRequestHandler.find(varId); |
|
695 | auto itVarHandler = m_VarIdToVarRequestHandler.find(varId); | |
696 | if (itVarHandler == m_VarIdToVarRequestHandler.cend()) { |
|
696 | if (itVarHandler == m_VarIdToVarRequestHandler.cend()) { | |
697 | qCCritical(LOG_VariableController()) |
|
697 | qCCritical(LOG_VariableController()) | |
698 | << tr("Impossible to process request for variable with unknown handler"); |
|
698 | << tr("Impossible to process request for variable with unknown handler"); | |
699 | return; |
|
699 | return; | |
700 | } |
|
700 | } | |
701 |
|
701 | |||
702 | auto oldRange = var->range(); |
|
702 | auto oldRange = var->range(); | |
703 |
|
703 | |||
704 | auto varHandler = itVarHandler->second.get(); |
|
704 | auto varHandler = itVarHandler->second.get(); | |
705 |
|
705 | |||
706 | if (varHandler->m_State != VariableRequestHandlerState::OFF) { |
|
706 | if (varHandler->m_State != VariableRequestHandlerState::OFF) { | |
707 | oldRange = varHandler->m_RunningVarRequest.m_RangeRequested; |
|
707 | oldRange = varHandler->m_RunningVarRequest.m_RangeRequested; | |
708 | } |
|
708 | } | |
709 |
|
709 | |||
710 | auto varRequest = VariableRequest{}; |
|
710 | auto varRequest = VariableRequest{}; | |
711 | varRequest.m_VariableGroupId = varRequestId; |
|
711 | varRequest.m_VariableGroupId = varRequestId; | |
712 | auto varStrategyRangesRequested |
|
712 | auto varStrategyRangesRequested | |
713 | = m_VariableCacheStrategy->computeRange(oldRange, rangeRequested); |
|
713 | = m_VariableCacheStrategy->computeRange(oldRange, rangeRequested); | |
714 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; |
|
714 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; | |
715 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; |
|
715 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; | |
716 |
|
716 | |||
717 | switch (varHandler->m_State) { |
|
717 | switch (varHandler->m_State) { | |
718 | case VariableRequestHandlerState::OFF: { |
|
718 | case VariableRequestHandlerState::OFF: { | |
719 | qCDebug(LOG_VariableController()) << tr("Process Request OFF") |
|
719 | qCDebug(LOG_VariableController()) << tr("Process Request OFF") | |
720 | << varRequest.m_RangeRequested |
|
720 | << varRequest.m_RangeRequested | |
721 | << varRequest.m_CacheRangeRequested; |
|
721 | << varRequest.m_CacheRangeRequested; | |
722 | varHandler->m_RunningVarRequest = varRequest; |
|
722 | varHandler->m_RunningVarRequest = varRequest; | |
723 | varHandler->m_State = VariableRequestHandlerState::RUNNING; |
|
723 | varHandler->m_State = VariableRequestHandlerState::RUNNING; | |
724 | executeVarRequest(var, varRequest); |
|
724 | executeVarRequest(var, varRequest); | |
725 | break; |
|
725 | break; | |
726 | } |
|
726 | } | |
727 | case VariableRequestHandlerState::RUNNING: { |
|
727 | case VariableRequestHandlerState::RUNNING: { | |
728 | qCDebug(LOG_VariableController()) << tr("Process Request RUNNING") |
|
728 | qCDebug(LOG_VariableController()) << tr("Process Request RUNNING") | |
729 | << varRequest.m_RangeRequested |
|
729 | << varRequest.m_RangeRequested | |
730 | << varRequest.m_CacheRangeRequested; |
|
730 | << varRequest.m_CacheRangeRequested; | |
731 | varHandler->m_State = VariableRequestHandlerState::PENDING; |
|
731 | varHandler->m_State = VariableRequestHandlerState::PENDING; | |
732 | varHandler->m_PendingVarRequest = varRequest; |
|
732 | varHandler->m_PendingVarRequest = varRequest; | |
733 | break; |
|
733 | break; | |
734 | } |
|
734 | } | |
735 | case VariableRequestHandlerState::PENDING: { |
|
735 | case VariableRequestHandlerState::PENDING: { | |
736 | qCDebug(LOG_VariableController()) << tr("Process Request PENDING") |
|
736 | qCDebug(LOG_VariableController()) << tr("Process Request PENDING") | |
737 | << varRequest.m_RangeRequested |
|
737 | << varRequest.m_RangeRequested | |
738 | << varRequest.m_CacheRangeRequested; |
|
738 | << varRequest.m_CacheRangeRequested; | |
739 | auto variableGroupIdToCancel = varHandler->m_PendingVarRequest.m_VariableGroupId; |
|
739 | auto variableGroupIdToCancel = varHandler->m_PendingVarRequest.m_VariableGroupId; | |
740 | cancelVariableRequest(variableGroupIdToCancel); |
|
740 | cancelVariableRequest(variableGroupIdToCancel); | |
741 | // Cancel variable can make state downgrade |
|
741 | // Cancel variable can make state downgrade | |
742 | varHandler->m_State = VariableRequestHandlerState::PENDING; |
|
742 | varHandler->m_State = VariableRequestHandlerState::PENDING; | |
743 | varHandler->m_PendingVarRequest = varRequest; |
|
743 | varHandler->m_PendingVarRequest = varRequest; | |
744 |
|
744 | |||
745 | break; |
|
745 | break; | |
746 | } |
|
746 | } | |
747 | default: |
|
747 | default: | |
748 | qCCritical(LOG_VariableController()) |
|
748 | qCCritical(LOG_VariableController()) | |
749 | << QObject::tr("Unknown VariableRequestHandlerState"); |
|
749 | << QObject::tr("Unknown VariableRequestHandlerState"); | |
750 | } |
|
750 | } | |
751 | } |
|
751 | } | |
752 |
|
752 | |||
753 | std::shared_ptr<Variable> |
|
753 | std::shared_ptr<Variable> | |
754 | VariableController::VariableControllerPrivate::findVariable(QUuid vIdentifier) |
|
754 | VariableController::VariableControllerPrivate::findVariable(QUuid vIdentifier) | |
755 | { |
|
755 | { | |
756 | std::shared_ptr<Variable> var; |
|
756 | std::shared_ptr<Variable> var; | |
757 | auto findReply = [vIdentifier](const auto &entry) { return vIdentifier == entry.second; }; |
|
757 | auto findReply = [vIdentifier](const auto &entry) { return vIdentifier == entry.second; }; | |
758 |
|
758 | |||
759 | auto end = m_VariableToIdentifierMap.cend(); |
|
759 | auto end = m_VariableToIdentifierMap.cend(); | |
760 | auto it = std::find_if(m_VariableToIdentifierMap.cbegin(), end, findReply); |
|
760 | auto it = std::find_if(m_VariableToIdentifierMap.cbegin(), end, findReply); | |
761 | if (it != end) { |
|
761 | if (it != end) { | |
762 | var = it->first; |
|
762 | var = it->first; | |
763 | } |
|
763 | } | |
764 | else { |
|
764 | else { | |
765 | qCCritical(LOG_VariableController()) |
|
765 | qCCritical(LOG_VariableController()) | |
766 | << tr("Impossible to find the variable with the identifier: ") << vIdentifier; |
|
766 | << tr("Impossible to find the variable with the identifier: ") << vIdentifier; | |
767 | } |
|
767 | } | |
768 |
|
768 | |||
769 | return var; |
|
769 | return var; | |
770 | } |
|
770 | } | |
771 |
|
771 | |||
772 | std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retrieveDataSeries( |
|
772 | std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retrieveDataSeries( | |
773 | const QVector<AcquisitionDataPacket> acqDataPacketVector) |
|
773 | const QVector<AcquisitionDataPacket> acqDataPacketVector) | |
774 | { |
|
774 | { | |
775 | qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size") |
|
775 | qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size") | |
776 | << acqDataPacketVector.size(); |
|
776 | << acqDataPacketVector.size(); | |
777 | std::shared_ptr<IDataSeries> dataSeries; |
|
777 | std::shared_ptr<IDataSeries> dataSeries; | |
778 | if (!acqDataPacketVector.isEmpty()) { |
|
778 | if (!acqDataPacketVector.isEmpty()) { | |
779 | dataSeries = acqDataPacketVector[0].m_DateSeries; |
|
779 | dataSeries = acqDataPacketVector[0].m_DateSeries; | |
780 | for (int i = 1; i < acqDataPacketVector.size(); ++i) { |
|
780 | for (int i = 1; i < acqDataPacketVector.size(); ++i) { | |
781 | dataSeries->merge(acqDataPacketVector[i].m_DateSeries.get()); |
|
781 | dataSeries->merge(acqDataPacketVector[i].m_DateSeries.get()); | |
782 | } |
|
782 | } | |
783 | } |
|
783 | } | |
784 | qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size END") |
|
784 | qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size END") | |
785 | << acqDataPacketVector.size(); |
|
785 | << acqDataPacketVector.size(); | |
786 | return dataSeries; |
|
786 | return dataSeries; | |
787 | } |
|
787 | } | |
788 |
|
788 | |||
789 | void VariableController::VariableControllerPrivate::registerProvider( |
|
789 | void VariableController::VariableControllerPrivate::registerProvider( | |
790 | std::shared_ptr<IDataProvider> provider) |
|
790 | std::shared_ptr<IDataProvider> provider) | |
791 | { |
|
791 | { | |
792 | if (m_ProviderSet.find(provider) == m_ProviderSet.end()) { |
|
792 | if (m_ProviderSet.find(provider) == m_ProviderSet.end()) { | |
793 | qCDebug(LOG_VariableController()) << tr("Registering of a new provider") |
|
793 | qCDebug(LOG_VariableController()) << tr("Registering of a new provider") | |
794 | << provider->objectName(); |
|
794 | << provider->objectName(); | |
795 | m_ProviderSet.insert(provider); |
|
795 | m_ProviderSet.insert(provider); | |
796 | connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(), |
|
796 | connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(), | |
797 | &VariableAcquisitionWorker::onVariableDataAcquired); |
|
797 | &VariableAcquisitionWorker::onVariableDataAcquired); | |
798 | connect(provider.get(), &IDataProvider::dataProvidedProgress, |
|
798 | connect(provider.get(), &IDataProvider::dataProvidedProgress, | |
799 | m_VariableAcquisitionWorker.get(), |
|
799 | m_VariableAcquisitionWorker.get(), | |
800 | &VariableAcquisitionWorker::onVariableRetrieveDataInProgress); |
|
800 | &VariableAcquisitionWorker::onVariableRetrieveDataInProgress); | |
801 | connect(provider.get(), &IDataProvider::dataProvidedFailed, |
|
801 | connect(provider.get(), &IDataProvider::dataProvidedFailed, | |
802 | m_VariableAcquisitionWorker.get(), |
|
802 | m_VariableAcquisitionWorker.get(), | |
803 | &VariableAcquisitionWorker::onVariableAcquisitionFailed); |
|
803 | &VariableAcquisitionWorker::onVariableAcquisitionFailed); | |
804 | } |
|
804 | } | |
805 | else { |
|
805 | else { | |
806 | qCDebug(LOG_VariableController()) << tr("Cannot register provider, it already exists "); |
|
806 | qCDebug(LOG_VariableController()) << tr("Cannot register provider, it already exists "); | |
807 | } |
|
807 | } | |
808 | } |
|
808 | } | |
809 |
|
809 | |||
810 | QUuid VariableController::VariableControllerPrivate::acceptVariableRequest( |
|
810 | QUuid VariableController::VariableControllerPrivate::acceptVariableRequest( | |
811 | QUuid varId, std::shared_ptr<IDataSeries> dataSeries) |
|
811 | QUuid varId, std::shared_ptr<IDataSeries> dataSeries) | |
812 | { |
|
812 | { | |
813 | auto itVarHandler = m_VarIdToVarRequestHandler.find(varId); |
|
813 | auto itVarHandler = m_VarIdToVarRequestHandler.find(varId); | |
814 | if (itVarHandler == m_VarIdToVarRequestHandler.cend()) { |
|
814 | if (itVarHandler == m_VarIdToVarRequestHandler.cend()) { | |
815 | return QUuid(); |
|
815 | return QUuid(); | |
816 | } |
|
816 | } | |
817 |
|
817 | |||
818 | auto varHandler = itVarHandler->second.get(); |
|
818 | auto varHandler = itVarHandler->second.get(); | |
819 | if (varHandler->m_State == VariableRequestHandlerState::OFF) { |
|
819 | if (varHandler->m_State == VariableRequestHandlerState::OFF) { | |
820 | qCCritical(LOG_VariableController()) |
|
820 | qCCritical(LOG_VariableController()) | |
821 | << tr("acceptVariableRequest impossible on a variable with OFF state"); |
|
821 | << tr("acceptVariableRequest impossible on a variable with OFF state"); | |
822 | } |
|
822 | } | |
823 |
|
823 | |||
824 | varHandler->m_RunningVarRequest.m_DataSeries = dataSeries; |
|
824 | varHandler->m_RunningVarRequest.m_DataSeries = dataSeries; | |
825 | varHandler->m_CanUpdate = true; |
|
825 | varHandler->m_CanUpdate = true; | |
826 |
|
826 | |||
827 | // Element traité, on a déjà toutes les données necessaires |
|
827 | // Element traité, on a déjà toutes les données necessaires | |
828 | auto varGroupId = varHandler->m_RunningVarRequest.m_VariableGroupId; |
|
828 | auto varGroupId = varHandler->m_RunningVarRequest.m_VariableGroupId; | |
829 | qCDebug(LOG_VariableController()) << "Variable::acceptVariableRequest" << varGroupId |
|
829 | qCDebug(LOG_VariableController()) << "Variable::acceptVariableRequest" << varGroupId | |
830 | << m_VarGroupIdToVarIds.size(); |
|
830 | << m_VarGroupIdToVarIds.size(); | |
831 |
|
831 | |||
832 | return varHandler->m_RunningVarRequest.m_VariableGroupId; |
|
832 | return varHandler->m_RunningVarRequest.m_VariableGroupId; | |
833 | } |
|
833 | } | |
834 |
|
834 | |||
835 | void VariableController::VariableControllerPrivate::updateVariables(QUuid varRequestId) |
|
835 | void VariableController::VariableControllerPrivate::updateVariables(QUuid varRequestId) | |
836 | { |
|
836 | { | |
837 | qCDebug(LOG_VariableController()) << "VariableControllerPrivate::updateVariables" |
|
837 | qCDebug(LOG_VariableController()) << "VariableControllerPrivate::updateVariables" | |
838 | << QThread::currentThread()->objectName() << varRequestId; |
|
838 | << QThread::currentThread()->objectName() << varRequestId; | |
839 |
|
839 | |||
840 | auto varGroupIdToVarIdsIt = m_VarGroupIdToVarIds.find(varRequestId); |
|
840 | auto varGroupIdToVarIdsIt = m_VarGroupIdToVarIds.find(varRequestId); | |
841 | if (varGroupIdToVarIdsIt == m_VarGroupIdToVarIds.end()) { |
|
841 | if (varGroupIdToVarIdsIt == m_VarGroupIdToVarIds.end()) { | |
842 | qCWarning(LOG_VariableController()) |
|
842 | qCWarning(LOG_VariableController()) | |
843 | << tr("Impossible to updateVariables of unknown variables") << varRequestId; |
|
843 | << tr("Impossible to updateVariables of unknown variables") << varRequestId; | |
844 | return; |
|
844 | return; | |
845 | } |
|
845 | } | |
846 |
|
846 | |||
847 | auto &varIds = varGroupIdToVarIdsIt->second; |
|
847 | auto &varIds = varGroupIdToVarIdsIt->second; | |
848 | auto varIdsEnd = varIds.end(); |
|
848 | auto varIdsEnd = varIds.end(); | |
849 | bool processVariableUpdate = true; |
|
849 | bool processVariableUpdate = true; | |
850 | qCDebug(LOG_VariableController()) << "VariableControllerPrivate::updateVariables" |
|
850 | qCDebug(LOG_VariableController()) << "VariableControllerPrivate::updateVariables" | |
851 | << varRequestId << varIds.size(); |
|
851 | << varRequestId << varIds.size(); | |
852 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd) && processVariableUpdate; |
|
852 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd) && processVariableUpdate; | |
853 | ++varIdsIt) { |
|
853 | ++varIdsIt) { | |
854 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); |
|
854 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
855 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { |
|
855 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { | |
856 | processVariableUpdate &= itVarHandler->second->m_CanUpdate; |
|
856 | processVariableUpdate &= itVarHandler->second->m_CanUpdate; | |
857 | } |
|
857 | } | |
858 | } |
|
858 | } | |
859 |
|
859 | |||
860 | if (processVariableUpdate) { |
|
860 | if (processVariableUpdate) { | |
861 | qCDebug(LOG_VariableController()) << "Final update OK for the var request" << varIds.size(); |
|
861 | qCDebug(LOG_VariableController()) << "Final update OK for the var request" << varIds.size(); | |
862 | for (auto varIdsIt = varIds.begin(); varIdsIt != varIdsEnd; ++varIdsIt) { |
|
862 | for (auto varIdsIt = varIds.begin(); varIdsIt != varIdsEnd; ++varIdsIt) { | |
863 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); |
|
863 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
864 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { |
|
864 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { | |
865 | if (auto var = findVariable(*varIdsIt)) { |
|
865 | if (auto var = findVariable(*varIdsIt)) { | |
866 | auto &varRequest = itVarHandler->second->m_RunningVarRequest; |
|
866 | auto &varRequest = itVarHandler->second->m_RunningVarRequest; | |
867 | var->setRange(varRequest.m_RangeRequested); |
|
867 | var->setRange(varRequest.m_RangeRequested); | |
868 | var->setCacheRange(varRequest.m_CacheRangeRequested); |
|
868 | var->setCacheRange(varRequest.m_CacheRangeRequested); | |
869 | qCDebug(LOG_VariableController()) << tr("1: onDataProvided") |
|
869 | qCDebug(LOG_VariableController()) << tr("1: onDataProvided") | |
870 | << varRequest.m_RangeRequested |
|
870 | << varRequest.m_RangeRequested | |
871 | << varRequest.m_CacheRangeRequested; |
|
871 | << varRequest.m_CacheRangeRequested; | |
872 | qCDebug(LOG_VariableController()) << tr("2: onDataProvided var points before") |
|
872 | qCDebug(LOG_VariableController()) << tr("2: onDataProvided var points before") | |
873 | << var->nbPoints() |
|
873 | << var->nbPoints() | |
874 | << varRequest.m_DataSeries->nbPoints(); |
|
874 | << varRequest.m_DataSeries->nbPoints(); | |
875 | var->mergeDataSeries(varRequest.m_DataSeries); |
|
875 | var->mergeDataSeries(varRequest.m_DataSeries); | |
876 | qCDebug(LOG_VariableController()) << tr("3: onDataProvided var points after") |
|
876 | qCDebug(LOG_VariableController()) << tr("3: onDataProvided var points after") | |
877 | << var->nbPoints(); |
|
877 | << var->nbPoints(); | |
878 |
|
878 | |||
879 | emit var->updated(); |
|
879 | emit var->updated(); | |
880 | qCDebug(LOG_VariableController()) << tr("Update OK"); |
|
880 | qCDebug(LOG_VariableController()) << tr("Update OK"); | |
881 | } |
|
881 | } | |
882 | else { |
|
882 | else { | |
883 | qCCritical(LOG_VariableController()) |
|
883 | qCCritical(LOG_VariableController()) | |
884 | << tr("Impossible to update data to a null variable"); |
|
884 | << tr("Impossible to update data to a null variable"); | |
885 | } |
|
885 | } | |
886 | } |
|
886 | } | |
887 | } |
|
887 | } | |
888 | updateVariableRequest(varRequestId); |
|
888 | updateVariableRequest(varRequestId); | |
889 |
|
889 | |||
890 | // cleaning varRequestId |
|
890 | // cleaning varRequestId | |
891 | qCDebug(LOG_VariableController()) << tr("m_VarGroupIdToVarIds erase") << varRequestId; |
|
891 | qCDebug(LOG_VariableController()) << tr("m_VarGroupIdToVarIds erase") << varRequestId; | |
892 | m_VarGroupIdToVarIds.erase(varRequestId); |
|
892 | m_VarGroupIdToVarIds.erase(varRequestId); | |
893 | } |
|
893 | } | |
894 | } |
|
894 | } | |
895 |
|
895 | |||
896 |
|
896 | |||
897 | void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid varRequestId) |
|
897 | void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid varRequestId) | |
898 | { |
|
898 | { | |
899 | auto varGroupIdToVarIdsIt = m_VarGroupIdToVarIds.find(varRequestId); |
|
899 | auto varGroupIdToVarIdsIt = m_VarGroupIdToVarIds.find(varRequestId); | |
900 | if (varGroupIdToVarIdsIt == m_VarGroupIdToVarIds.end()) { |
|
900 | if (varGroupIdToVarIdsIt == m_VarGroupIdToVarIds.end()) { | |
901 | qCCritical(LOG_VariableController()) << QObject::tr( |
|
901 | qCCritical(LOG_VariableController()) << QObject::tr( | |
902 | "Impossible to updateVariableRequest since varGroupdId isn't here anymore"); |
|
902 | "Impossible to updateVariableRequest since varGroupdId isn't here anymore"); | |
903 |
|
903 | |||
904 | return; |
|
904 | return; | |
905 | } |
|
905 | } | |
906 |
|
906 | |||
907 | auto &varIds = varGroupIdToVarIdsIt->second; |
|
907 | auto &varIds = varGroupIdToVarIdsIt->second; | |
908 | auto varIdsEnd = varIds.end(); |
|
908 | auto varIdsEnd = varIds.end(); | |
909 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { |
|
909 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { | |
910 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); |
|
910 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
911 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { |
|
911 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { | |
912 |
|
912 | |||
913 | auto varHandler = itVarHandler->second.get(); |
|
913 | auto varHandler = itVarHandler->second.get(); | |
914 | varHandler->m_CanUpdate = false; |
|
914 | varHandler->m_CanUpdate = false; | |
915 |
|
915 | |||
916 |
|
916 | |||
917 | switch (varHandler->m_State) { |
|
917 | switch (varHandler->m_State) { | |
918 | case VariableRequestHandlerState::OFF: { |
|
918 | case VariableRequestHandlerState::OFF: { | |
919 | qCCritical(LOG_VariableController()) |
|
919 | qCCritical(LOG_VariableController()) | |
920 | << QObject::tr("Impossible to update a variable with handler in OFF state"); |
|
920 | << QObject::tr("Impossible to update a variable with handler in OFF state"); | |
921 | } break; |
|
921 | } break; | |
922 | case VariableRequestHandlerState::RUNNING: { |
|
922 | case VariableRequestHandlerState::RUNNING: { | |
923 | varHandler->m_State = VariableRequestHandlerState::OFF; |
|
923 | varHandler->m_State = VariableRequestHandlerState::OFF; | |
924 | varHandler->m_RunningVarRequest = VariableRequest{}; |
|
924 | varHandler->m_RunningVarRequest = VariableRequest{}; | |
925 | break; |
|
925 | break; | |
926 | } |
|
926 | } | |
927 | case VariableRequestHandlerState::PENDING: { |
|
927 | case VariableRequestHandlerState::PENDING: { | |
928 | varHandler->m_State = VariableRequestHandlerState::RUNNING; |
|
928 | varHandler->m_State = VariableRequestHandlerState::RUNNING; | |
929 | varHandler->m_RunningVarRequest = varHandler->m_PendingVarRequest; |
|
929 | varHandler->m_RunningVarRequest = varHandler->m_PendingVarRequest; | |
930 | varHandler->m_PendingVarRequest = VariableRequest{}; |
|
930 | varHandler->m_PendingVarRequest = VariableRequest{}; | |
931 | auto var = findVariable(itVarHandler->first); |
|
931 | auto var = findVariable(itVarHandler->first); | |
932 | executeVarRequest(var, varHandler->m_RunningVarRequest); |
|
932 | executeVarRequest(var, varHandler->m_RunningVarRequest); | |
933 | break; |
|
933 | break; | |
934 | } |
|
934 | } | |
935 | default: |
|
935 | default: | |
936 | qCCritical(LOG_VariableController()) |
|
936 | qCCritical(LOG_VariableController()) | |
937 | << QObject::tr("Unknown VariableRequestHandlerState"); |
|
937 | << QObject::tr("Unknown VariableRequestHandlerState"); | |
938 | } |
|
938 | } | |
939 | } |
|
939 | } | |
940 | } |
|
940 | } | |
941 | } |
|
941 | } | |
942 |
|
942 | |||
943 |
|
943 | |||
944 | void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid varRequestId) |
|
944 | void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid varRequestId) | |
945 | { |
|
945 | { | |
946 | qCDebug(LOG_VariableController()) << tr("cancelVariableRequest") << varRequestId; |
|
946 | qCDebug(LOG_VariableController()) << tr("cancelVariableRequest") << varRequestId; | |
947 |
|
947 | |||
948 | auto varGroupIdToVarIdsIt = m_VarGroupIdToVarIds.find(varRequestId); |
|
948 | auto varGroupIdToVarIdsIt = m_VarGroupIdToVarIds.find(varRequestId); | |
949 | if (varGroupIdToVarIdsIt == m_VarGroupIdToVarIds.end()) { |
|
949 | if (varGroupIdToVarIdsIt == m_VarGroupIdToVarIds.end()) { | |
950 | qCCritical(LOG_VariableController()) |
|
950 | qCCritical(LOG_VariableController()) | |
951 | << tr("Impossible to cancelVariableRequest for unknown varGroupdId") << varRequestId; |
|
951 | << tr("Impossible to cancelVariableRequest for unknown varGroupdId") << varRequestId; | |
952 | return; |
|
952 | return; | |
953 | } |
|
953 | } | |
954 |
|
954 | |||
955 | auto &varIds = varGroupIdToVarIdsIt->second; |
|
955 | auto &varIds = varGroupIdToVarIdsIt->second; | |
956 | auto varIdsEnd = varIds.end(); |
|
956 | auto varIdsEnd = varIds.end(); | |
957 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { |
|
957 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { | |
958 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); |
|
958 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
959 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { |
|
959 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { | |
960 |
|
960 | |||
961 | auto varHandler = itVarHandler->second.get(); |
|
961 | auto varHandler = itVarHandler->second.get(); | |
962 | varHandler->m_VarId = QUuid{}; |
|
962 | varHandler->m_VarId = QUuid{}; | |
963 | switch (varHandler->m_State) { |
|
963 | switch (varHandler->m_State) { | |
964 | case VariableRequestHandlerState::OFF: { |
|
964 | case VariableRequestHandlerState::OFF: { | |
965 | qCWarning(LOG_VariableController()) |
|
965 | qCWarning(LOG_VariableController()) | |
966 | << QObject::tr("Impossible to cancel a variable with no running request"); |
|
966 | << QObject::tr("Impossible to cancel a variable with no running request"); | |
967 | break; |
|
967 | break; | |
968 | } |
|
968 | } | |
969 | case VariableRequestHandlerState::RUNNING: { |
|
969 | case VariableRequestHandlerState::RUNNING: { | |
970 |
|
970 | |||
971 | if (varHandler->m_RunningVarRequest.m_VariableGroupId == varRequestId) { |
|
971 | if (varHandler->m_RunningVarRequest.m_VariableGroupId == varRequestId) { | |
972 | auto var = findVariable(itVarHandler->first); |
|
972 | auto var = findVariable(itVarHandler->first); | |
973 | auto varProvider = m_VariableToProviderMap.at(var); |
|
973 | auto varProvider = m_VariableToProviderMap.at(var); | |
974 | if (varProvider != nullptr) { |
|
974 | if (varProvider != nullptr) { | |
975 | m_VariableAcquisitionWorker->abortProgressRequested( |
|
975 | m_VariableAcquisitionWorker->abortProgressRequested( | |
976 | itVarHandler->first); |
|
976 | itVarHandler->first); | |
977 | } |
|
977 | } | |
978 | m_VariableModel->setDataProgress(var, 0.0); |
|
978 | m_VariableModel->setDataProgress(var, 0.0); | |
979 | varHandler->m_CanUpdate = false; |
|
979 | varHandler->m_CanUpdate = false; | |
980 | varHandler->m_State = VariableRequestHandlerState::OFF; |
|
980 | varHandler->m_State = VariableRequestHandlerState::OFF; | |
981 | varHandler->m_RunningVarRequest = VariableRequest{}; |
|
981 | varHandler->m_RunningVarRequest = VariableRequest{}; | |
982 | } |
|
982 | } | |
983 | else { |
|
983 | else { | |
984 | // TODO: log Impossible to cancel the running variable request beacause its |
|
984 | // TODO: log Impossible to cancel the running variable request beacause its | |
985 | // varRequestId isn't not the canceled one |
|
985 | // varRequestId isn't not the canceled one | |
986 | } |
|
986 | } | |
987 | break; |
|
987 | break; | |
988 | } |
|
988 | } | |
989 | case VariableRequestHandlerState::PENDING: { |
|
989 | case VariableRequestHandlerState::PENDING: { | |
990 | if (varHandler->m_RunningVarRequest.m_VariableGroupId == varRequestId) { |
|
990 | if (varHandler->m_RunningVarRequest.m_VariableGroupId == varRequestId) { | |
991 | auto var = findVariable(itVarHandler->first); |
|
991 | auto var = findVariable(itVarHandler->first); | |
992 | auto varProvider = m_VariableToProviderMap.at(var); |
|
992 | auto varProvider = m_VariableToProviderMap.at(var); | |
993 | if (varProvider != nullptr) { |
|
993 | if (varProvider != nullptr) { | |
994 | m_VariableAcquisitionWorker->abortProgressRequested( |
|
994 | m_VariableAcquisitionWorker->abortProgressRequested( | |
995 | itVarHandler->first); |
|
995 | itVarHandler->first); | |
996 | } |
|
996 | } | |
997 | m_VariableModel->setDataProgress(var, 0.0); |
|
997 | m_VariableModel->setDataProgress(var, 0.0); | |
998 | varHandler->m_CanUpdate = false; |
|
998 | varHandler->m_CanUpdate = false; | |
999 | varHandler->m_State = VariableRequestHandlerState::RUNNING; |
|
999 | varHandler->m_State = VariableRequestHandlerState::RUNNING; | |
1000 | varHandler->m_RunningVarRequest = varHandler->m_PendingVarRequest; |
|
1000 | varHandler->m_RunningVarRequest = varHandler->m_PendingVarRequest; | |
1001 | varHandler->m_PendingVarRequest = VariableRequest{}; |
|
1001 | varHandler->m_PendingVarRequest = VariableRequest{}; | |
1002 | executeVarRequest(var, varHandler->m_RunningVarRequest); |
|
1002 | executeVarRequest(var, varHandler->m_RunningVarRequest); | |
1003 | } |
|
1003 | } | |
1004 | else if (varHandler->m_PendingVarRequest.m_VariableGroupId == varRequestId) { |
|
1004 | else if (varHandler->m_PendingVarRequest.m_VariableGroupId == varRequestId) { | |
1005 | varHandler->m_State = VariableRequestHandlerState::RUNNING; |
|
1005 | varHandler->m_State = VariableRequestHandlerState::RUNNING; | |
1006 | varHandler->m_PendingVarRequest = VariableRequest{}; |
|
1006 | varHandler->m_PendingVarRequest = VariableRequest{}; | |
1007 | } |
|
1007 | } | |
1008 | else { |
|
1008 | else { | |
1009 | // TODO: log Impossible to cancel the variable request beacause its |
|
1009 | // TODO: log Impossible to cancel the variable request beacause its | |
1010 | // varRequestId isn't not the canceled one |
|
1010 | // varRequestId isn't not the canceled one | |
1011 | } |
|
1011 | } | |
1012 | break; |
|
1012 | break; | |
1013 | } |
|
1013 | } | |
1014 | default: |
|
1014 | default: | |
1015 | qCCritical(LOG_VariableController()) |
|
1015 | qCCritical(LOG_VariableController()) | |
1016 | << QObject::tr("Unknown VariableRequestHandlerState"); |
|
1016 | << QObject::tr("Unknown VariableRequestHandlerState"); | |
1017 | } |
|
1017 | } | |
1018 | } |
|
1018 | } | |
1019 | } |
|
1019 | } | |
1020 | qCDebug(LOG_VariableController()) << tr("cancelVariableRequest: erase") << varRequestId; |
|
1020 | qCDebug(LOG_VariableController()) << tr("cancelVariableRequest: erase") << varRequestId; | |
1021 | m_VarGroupIdToVarIds.erase(varRequestId); |
|
1021 | m_VarGroupIdToVarIds.erase(varRequestId); | |
1022 | } |
|
1022 | } | |
1023 |
|
1023 | |||
1024 | void VariableController::VariableControllerPrivate::executeVarRequest(std::shared_ptr<Variable> var, |
|
1024 | void VariableController::VariableControllerPrivate::executeVarRequest(std::shared_ptr<Variable> var, | |
1025 | VariableRequest &varRequest) |
|
1025 | VariableRequest &varRequest) | |
1026 | { |
|
1026 | { | |
1027 | qCDebug(LOG_VariableController()) << tr("TORM: executeVarRequest"); |
|
1027 | qCDebug(LOG_VariableController()) << tr("TORM: executeVarRequest"); | |
1028 |
|
1028 | |||
1029 | auto varId = m_VariableToIdentifierMap.at(var); |
|
1029 | auto varId = m_VariableToIdentifierMap.at(var); | |
1030 |
|
1030 | |||
1031 | auto varCacheRange = var->cacheRange(); |
|
1031 | auto varCacheRange = var->cacheRange(); | |
1032 | auto varCacheRangeRequested = varRequest.m_CacheRangeRequested; |
|
1032 | auto varCacheRangeRequested = varRequest.m_CacheRangeRequested; | |
1033 | auto notInCacheRangeList |
|
1033 | auto notInCacheRangeList | |
1034 | = Variable::provideNotInCacheRangeList(varCacheRange, varCacheRangeRequested); |
|
1034 | = Variable::provideNotInCacheRangeList(varCacheRange, varCacheRangeRequested); | |
1035 | auto inCacheRangeList |
|
1035 | auto inCacheRangeList | |
1036 | = Variable::provideInCacheRangeList(varCacheRange, varCacheRangeRequested); |
|
1036 | = Variable::provideInCacheRangeList(varCacheRange, varCacheRangeRequested); | |
1037 |
|
1037 | |||
1038 | if (!notInCacheRangeList.empty()) { |
|
1038 | if (!notInCacheRangeList.empty()) { | |
1039 |
|
1039 | |||
1040 | auto varProvider = m_VariableToProviderMap.at(var); |
|
1040 | auto varProvider = m_VariableToProviderMap.at(var); | |
1041 | if (varProvider != nullptr) { |
|
1041 | if (varProvider != nullptr) { | |
1042 | qCDebug(LOG_VariableController()) << "executeVarRequest " << varRequest.m_RangeRequested |
|
1042 | qCDebug(LOG_VariableController()) << "executeVarRequest " << varRequest.m_RangeRequested | |
1043 | << varRequest.m_CacheRangeRequested; |
|
1043 | << varRequest.m_CacheRangeRequested; | |
1044 | m_VariableAcquisitionWorker->pushVariableRequest( |
|
1044 | m_VariableAcquisitionWorker->pushVariableRequest( | |
1045 | varRequest.m_VariableGroupId, varId, varRequest.m_RangeRequested, |
|
1045 | varRequest.m_VariableGroupId, varId, varRequest.m_RangeRequested, | |
1046 | varRequest.m_CacheRangeRequested, |
|
1046 | varRequest.m_CacheRangeRequested, | |
1047 | DataProviderParameters{std::move(notInCacheRangeList), var->metadata()}, |
|
1047 | DataProviderParameters{std::move(notInCacheRangeList), var->metadata()}, | |
1048 | varProvider); |
|
1048 | varProvider); | |
1049 | } |
|
1049 | } | |
1050 | else { |
|
1050 | else { | |
1051 | qCCritical(LOG_VariableController()) |
|
1051 | qCCritical(LOG_VariableController()) | |
1052 | << "Impossible to provide data with a null provider"; |
|
1052 | << "Impossible to provide data with a null provider"; | |
1053 | } |
|
1053 | } | |
1054 |
|
1054 | |||
1055 | if (!inCacheRangeList.empty()) { |
|
1055 | if (!inCacheRangeList.empty()) { | |
1056 | emit q->updateVarDisplaying(var, inCacheRangeList.first()); |
|
1056 | emit q->updateVarDisplaying(var, inCacheRangeList.first()); | |
1057 | } |
|
1057 | } | |
1058 | } |
|
1058 | } | |
1059 | else { |
|
1059 | else { | |
1060 | acceptVariableRequest(varId, |
|
1060 | acceptVariableRequest(varId, | |
1061 | var->dataSeries()->subDataSeries(varRequest.m_CacheRangeRequested)); |
|
1061 | var->dataSeries()->subDataSeries(varRequest.m_CacheRangeRequested)); | |
1062 | } |
|
1062 | } | |
1063 | } |
|
1063 | } |
@@ -1,73 +1,73 | |||||
1 | # - Clone and build CatalogueAPI Module |
|
1 | # - Clone and build CatalogueAPI Module | |
2 | include(ExternalProject) |
|
2 | include(ExternalProject) | |
3 |
|
3 | |||
4 | find_package(Git REQUIRED) |
|
4 | find_package(Git REQUIRED) | |
5 |
|
5 | |||
6 | if(WIN32) |
|
6 | if(WIN32) | |
7 | find_program(MesonExec meson PATHS C:/Appli/Meson) |
|
7 | find_program(MesonExec meson PATHS C:/Appli/Meson) | |
8 | if(NOT MesonExec) |
|
8 | if(NOT MesonExec) | |
9 | Message("Error: Meson not found") |
|
9 | Message("Error: Meson not found") | |
10 | else() |
|
10 | else() | |
11 | message("Meson found: ${MesonExec}" ) |
|
11 | message("Meson found: ${MesonExec}" ) | |
12 | endif() |
|
12 | endif() | |
13 | find_program(NinjaExec ninja PATHS C:/Appli/Meson) |
|
13 | find_program(NinjaExec ninja PATHS C:/Appli/Meson) | |
14 | if(NOT NinjaExec) |
|
14 | if(NOT NinjaExec) | |
15 | Message("Error: Ninja not found") |
|
15 | Message("Error: Ninja not found") | |
16 | else() |
|
16 | else() | |
17 | message("Ninja found: ${NinjaExec}" ) |
|
17 | message("Ninja found: ${NinjaExec}" ) | |
18 | endif() |
|
18 | endif() | |
19 | endif() |
|
19 | endif() | |
20 | if(NOT MesonExec) |
|
20 | if(NOT MesonExec) | |
21 | set (MesonExec meson) |
|
21 | set (MesonExec meson) | |
22 | endif() |
|
22 | endif() | |
23 | if(NOT NinjaExec) |
|
23 | if(NOT NinjaExec) | |
24 | set (NinjaExec ninja) |
|
24 | set (NinjaExec ninja) | |
25 | endif() |
|
25 | endif() | |
26 |
|
26 | |||
27 | SET(CATALOGUEAPI_SOURCES_PATH ${CMAKE_SOURCE_DIR}/3rdparty/CatalogueAPI) |
|
27 | SET(CATALOGUEAPI_SOURCES_PATH ${CMAKE_SOURCE_DIR}/3rdparty/CatalogueAPI) | |
28 | SET(CATALOGUEAPI_BUILD_PATH ${CATALOGUEAPI_SOURCES_PATH}/build) |
|
28 | SET(CATALOGUEAPI_BUILD_PATH ${CATALOGUEAPI_SOURCES_PATH}/build) | |
29 | SET(CATALOGUEAPI_QXORM_LIB_PATH ${CATALOGUEAPI_BUILD_PATH}/subprojects/QxOrm) |
|
29 | SET(CATALOGUEAPI_QXORM_LIB_PATH ${CATALOGUEAPI_BUILD_PATH}/subprojects/QxOrm) | |
30 | SET(CatalogueAPI_build_type plain) |
|
30 | SET(CatalogueAPI_build_type plain) | |
31 |
|
31 | |||
32 | if(CMAKE_BUILD_TYPE STREQUAL "") |
|
32 | if(CMAKE_BUILD_TYPE STREQUAL "") | |
33 | set(CMAKE_BUILD_TYPE Release) |
|
33 | set(CMAKE_BUILD_TYPE Release) | |
34 | endif() |
|
34 | endif() | |
35 | string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) |
|
35 | string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) | |
36 |
|
36 | |||
37 | ExternalProject_Add( |
|
37 | ExternalProject_Add( | |
38 | CatalogueAPI |
|
38 | CatalogueAPI | |
39 |
|
39 | |||
40 | GIT_REPOSITORY https://perrinel@hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/CatalogueAPI |
|
40 | GIT_REPOSITORY https://perrinel@hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/CatalogueAPI | |
41 | GIT_TAG develop |
|
41 | GIT_TAG develop | |
42 |
|
42 | |||
43 | UPDATE_COMMAND ${GIT_EXECUTABLE} pull |
|
43 | UPDATE_COMMAND ${GIT_EXECUTABLE} pull origin develop | |
44 | PATCH_COMMAND "" |
|
44 | PATCH_COMMAND "" | |
45 |
|
45 | |||
46 | SOURCE_DIR "${CATALOGUEAPI_SOURCES_PATH}" |
|
46 | SOURCE_DIR "${CATALOGUEAPI_SOURCES_PATH}" | |
47 | CONFIGURE_COMMAND ${MesonExec} --prefix=${CATALOGUEAPI_SOURCES_PATH} --buildtype=${CMAKE_BUILD_TYPE_TOLOWER} "${CATALOGUEAPI_SOURCES_PATH}" "${CATALOGUEAPI_BUILD_PATH}" |
|
47 | CONFIGURE_COMMAND ${MesonExec} --prefix=${CATALOGUEAPI_SOURCES_PATH} --buildtype=${CMAKE_BUILD_TYPE_TOLOWER} "${CATALOGUEAPI_SOURCES_PATH}" "${CATALOGUEAPI_BUILD_PATH}" | |
48 |
|
48 | |||
49 | BUILD_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" |
|
49 | BUILD_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" | |
50 | INSTALL_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" install |
|
50 | INSTALL_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" install | |
51 | LOG_DOWNLOAD 1 |
|
51 | LOG_DOWNLOAD 1 | |
52 | LOG_UPDATE 1 |
|
52 | LOG_UPDATE 1 | |
53 | ) |
|
53 | ) | |
54 |
|
54 | |||
55 | set(CATALOG_LIB_PATH lib) |
|
55 | set(CATALOG_LIB_PATH lib) | |
56 | if(WIN32) |
|
56 | if(WIN32) | |
57 | set(CATALOG_LIB_PATH bin) |
|
57 | set(CATALOG_LIB_PATH bin) | |
58 | endif() |
|
58 | endif() | |
59 |
|
59 | |||
60 | ExternalProject_Add_Step( |
|
60 | ExternalProject_Add_Step( | |
61 | CatalogueAPI CopyToBin |
|
61 | CatalogueAPI CopyToBin | |
62 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_SOURCES_PATH}/lib64 ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} |
|
62 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_SOURCES_PATH}/lib64 ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} | |
63 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_QXORM_LIB_PATH} ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} |
|
63 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_QXORM_LIB_PATH} ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} | |
64 | DEPENDEES install |
|
64 | DEPENDEES install | |
65 | ) |
|
65 | ) | |
66 |
|
66 | |||
67 |
|
67 | |||
68 | set(CATALOGUEAPI_INCLUDE ${CATALOGUEAPI_SOURCES_PATH}/src) |
|
68 | set(CATALOGUEAPI_INCLUDE ${CATALOGUEAPI_SOURCES_PATH}/src) | |
69 | set(CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}CatalogueAPI${CMAKE_SHARED_LIBRARY_SUFFIX}) |
|
69 | set(CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}CatalogueAPI${CMAKE_SHARED_LIBRARY_SUFFIX}) | |
70 | list(APPEND CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}QxOrm${CMAKE_SHARED_LIBRARY_SUFFIX}) |
|
70 | list(APPEND CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}QxOrm${CMAKE_SHARED_LIBRARY_SUFFIX}) | |
71 |
|
71 | |||
72 | mark_as_advanced(CATALOGUEAPI_INCLUDE) |
|
72 | mark_as_advanced(CATALOGUEAPI_INCLUDE) | |
73 | mark_as_advanced(CATALOGUEAPI_LIBRARIES) |
|
73 | mark_as_advanced(CATALOGUEAPI_LIBRARIES) |
@@ -1,169 +1,179 | |||||
1 |
|
1 | |||
2 | ## gui - CMakeLists.txt |
|
2 | ## gui - CMakeLists.txt | |
3 | STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) |
|
3 | STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) | |
4 | SET(SQPGUI_LIBRARY_NAME "${LIBRARY_PREFFIX}_gui${DEBUG_SUFFIX}") |
|
4 | SET(SQPGUI_LIBRARY_NAME "${LIBRARY_PREFFIX}_gui${DEBUG_SUFFIX}") | |
5 | SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
5 | SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") | |
6 | SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") |
|
6 | SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") | |
7 | SET(UI_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/ui") |
|
7 | SET(UI_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/ui") | |
8 | SET(RES_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/resources") |
|
8 | SET(RES_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/resources") | |
9 |
|
9 | |||
10 | # Include gui directory |
|
10 | # Include gui directory | |
11 | include_directories("${INCLUDES_DIR}") |
|
11 | include_directories("${INCLUDES_DIR}") | |
12 | include_directories("${CMAKE_CURRENT_BINARY_DIR}") |
|
12 | include_directories("${CMAKE_CURRENT_BINARY_DIR}") | |
13 |
|
13 | |||
14 | # Set a variable to display a warning in the version files. |
|
14 | # Set a variable to display a warning in the version files. | |
15 | SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.") |
|
15 | SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.") | |
16 |
|
16 | |||
17 | # |
|
17 | # | |
18 | # Find Qt modules |
|
18 | # Find Qt modules | |
19 | # |
|
19 | # | |
20 | SCIQLOP_FIND_QT(Core Widgets PrintSupport) |
|
20 | SCIQLOP_FIND_QT(Core Widgets PrintSupport) | |
21 |
|
21 | |||
22 | # |
|
22 | # | |
23 | # Find dependent libraries |
|
23 | # Find dependent libraries | |
24 | # ======================== |
|
24 | # ======================== | |
25 | find_package(sciqlop-core) |
|
25 | find_package(sciqlop-core) | |
26 |
|
26 | |||
27 | SET(LIBRARIES ${SCIQLOP-CORE_LIBRARIES}) |
|
27 | SET(LIBRARIES ${SCIQLOP-CORE_LIBRARIES}) | |
28 |
|
28 | |||
29 | INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR}) |
|
29 | INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR}) | |
30 |
|
30 | |||
31 | # Add sqpcore to the list of libraries to use |
|
31 | # Add sqpcore to the list of libraries to use | |
32 | list(APPEND LIBRARIES ${SQPCORE_LIBRARY_NAME}) |
|
32 | list(APPEND LIBRARIES ${SQPCORE_LIBRARY_NAME}) | |
33 |
|
33 | |||
34 | # Add dependent shared libraries |
|
34 | # Add dependent shared libraries | |
35 | list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES}) |
|
35 | list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES}) | |
36 |
|
36 | |||
37 |
|
37 | |||
38 | # Ui files |
|
38 | # Ui files | |
39 | FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui) |
|
39 | FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui) | |
40 |
|
40 | |||
41 | # Resources files |
|
41 | # Resources files | |
42 | FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc) |
|
42 | FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc) | |
43 |
|
43 | |||
44 | # |
|
44 | # | |
45 | # Compile the library library |
|
45 | # Compile the library library | |
46 | # |
|
46 | # | |
47 | FILE (GLOB_RECURSE MODULE_SOURCES |
|
47 | FILE (GLOB_RECURSE MODULE_SOURCES | |
48 | ${INCLUDES_DIR}/*.h |
|
48 | ${INCLUDES_DIR}/*.h | |
49 | ${SOURCES_DIR}/*.c |
|
49 | ${SOURCES_DIR}/*.c | |
50 | ${SOURCES_DIR}/*.cpp |
|
50 | ${SOURCES_DIR}/*.cpp | |
51 | ${SOURCES_DIR}/*.h |
|
51 | ${SOURCES_DIR}/*.h | |
52 | ${PROJECT_FORMS}) |
|
52 | ${PROJECT_FORMS}) | |
53 |
|
53 | |||
54 | QT5_ADD_RESOURCES(RCC_HDRS |
|
54 | QT5_ADD_RESOURCES(RCC_HDRS | |
55 | ${PROJECT_RESOURCES} |
|
55 | ${PROJECT_RESOURCES} | |
56 | ) |
|
56 | ) | |
57 |
|
57 | |||
58 | QT5_WRAP_UI(UIS_HDRS |
|
58 | QT5_WRAP_UI(UIS_HDRS | |
59 | ${PROJECT_FORMS} |
|
59 | ${PROJECT_FORMS} | |
60 | ) |
|
60 | ) | |
61 |
|
61 | |||
62 |
|
62 | |||
63 | ADD_LIBRARY(${SQPGUI_LIBRARY_NAME} ${MODULE_SOURCES} ${UIS_HDRS} ${RCC_HDRS}) |
|
63 | ADD_LIBRARY(${SQPGUI_LIBRARY_NAME} ${MODULE_SOURCES} ${UIS_HDRS} ${RCC_HDRS}) | |
64 | set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD 14) |
|
64 | set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD 14) | |
65 | set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
65 | set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) | |
66 |
|
66 | |||
67 | TARGET_LINK_LIBRARIES(${SQPGUI_LIBRARY_NAME} ${LIBRARIES}) |
|
67 | TARGET_LINK_LIBRARIES(${SQPGUI_LIBRARY_NAME} ${LIBRARIES}) | |
68 | qt5_use_modules(${SQPGUI_LIBRARY_NAME} Core Widgets PrintSupport) |
|
68 | qt5_use_modules(${SQPGUI_LIBRARY_NAME} Core Widgets PrintSupport) | |
69 |
|
69 | |||
70 |
|
70 | |||
71 | INSTALL(TARGETS ${SQPGUI_LIBRARY_NAME} |
|
71 | INSTALL(TARGETS ${SQPGUI_LIBRARY_NAME} | |
72 | RUNTIME DESTINATION ${INSTALL_BINARY_DIR} |
|
72 | RUNTIME DESTINATION ${INSTALL_BINARY_DIR} | |
73 | LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} |
|
73 | LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} | |
74 | ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR} |
|
74 | ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR} | |
75 | ) |
|
75 | ) | |
76 | add_dependencies(${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME}) |
|
76 | add_dependencies(${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME}) | |
77 |
|
77 | |||
|
78 | # Find CATALOGUE_API | |||
|
79 | include_directories("${CATALOGUEAPI_INCLUDE}") | |||
|
80 | TARGET_LINK_LIBRARIES(${SQPGUI_LIBRARY_NAME} ${CATALOGUEAPI_LIBRARIES}) | |||
|
81 | INSTALL(TARGETS ${SQPGUI_LIBRARY_NAME} | |||
|
82 | RUNTIME DESTINATION ${INSTALL_BINARY_DIR} | |||
|
83 | LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} | |||
|
84 | ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR} | |||
|
85 | ) | |||
|
86 | ||||
|
87 | add_dependencies(${SQPGUI_LIBRARY_NAME} CatalogueAPI) | |||
78 |
|
88 | |||
79 | # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html |
|
89 | # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html | |
80 | # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. |
|
90 | # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. | |
81 | # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets |
|
91 | # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets | |
82 | IF(BUILD_SHARED_LIBS) |
|
92 | IF(BUILD_SHARED_LIBS) | |
83 | SET_TARGET_PROPERTIES(${SQPGUI_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") |
|
93 | SET_TARGET_PROPERTIES(${SQPGUI_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") | |
84 | ELSE() |
|
94 | ELSE() | |
85 | TARGET_COMPILE_DEFINITIONS(${SQPGUI_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") |
|
95 | TARGET_COMPILE_DEFINITIONS(${SQPGUI_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") | |
86 | ENDIF() |
|
96 | ENDIF() | |
87 |
|
97 | |||
88 | # Set the variable to parent scope so that the other projects can copy the |
|
98 | # Set the variable to parent scope so that the other projects can copy the | |
89 | # dependent shared libraries |
|
99 | # dependent shared libraries | |
90 | SCIQLOP_SET_TO_PARENT_SCOPE(SQPGUI_LIBRARY_NAME) |
|
100 | SCIQLOP_SET_TO_PARENT_SCOPE(SQPGUI_LIBRARY_NAME) | |
91 |
|
101 | |||
92 | # Copy extern shared libraries to the lib folder |
|
102 | # Copy extern shared libraries to the lib folder | |
93 | SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPGUI_LIBRARY_NAME}) |
|
103 | SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPGUI_LIBRARY_NAME}) | |
94 |
|
104 | |||
95 | # Add the files to the list of files to be analyzed |
|
105 | # Add the files to the list of files to be analyzed | |
96 | LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) |
|
106 | LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) | |
97 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) |
|
107 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) | |
98 | # Vera++ exclusion files |
|
108 | # Vera++ exclusion files | |
99 | LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt) |
|
109 | LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt) | |
100 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) |
|
110 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) | |
101 |
|
111 | |||
102 | # |
|
112 | # | |
103 | # Compile the tests |
|
113 | # Compile the tests | |
104 | # |
|
114 | # | |
105 | IF(BUILD_TESTS) |
|
115 | IF(BUILD_TESTS) | |
106 | INCLUDE_DIRECTORIES(${SOURCES_DIR}) |
|
116 | INCLUDE_DIRECTORIES(${SOURCES_DIR}) | |
107 | FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) |
|
117 | FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) | |
108 | FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) |
|
118 | FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) | |
109 | SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME}) |
|
119 | SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME}) | |
110 |
|
120 | |||
111 | FOREACH( testFile ${TESTS_SOURCES} ) |
|
121 | FOREACH( testFile ${TESTS_SOURCES} ) | |
112 | GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) |
|
122 | GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) | |
113 | GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) |
|
123 | GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) | |
114 |
|
124 | |||
115 | # Add to the list of sources files all the sources in the same |
|
125 | # Add to the list of sources files all the sources in the same | |
116 | # directory that aren't another test |
|
126 | # directory that aren't another test | |
117 | FILE (GLOB currentTestSources |
|
127 | FILE (GLOB currentTestSources | |
118 | ${testDirectory}/*.c |
|
128 | ${testDirectory}/*.c | |
119 | ${testDirectory}/*.cpp |
|
129 | ${testDirectory}/*.cpp | |
120 | ${testDirectory}/*.h) |
|
130 | ${testDirectory}/*.h) | |
121 | LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) |
|
131 | LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) | |
122 | # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) |
|
132 | # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) | |
123 |
|
133 | |||
124 | ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) |
|
134 | ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) | |
125 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14) |
|
135 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14) | |
126 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
136 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON) | |
127 | TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) |
|
137 | TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) | |
128 | qt5_use_modules(${testName} Test) |
|
138 | qt5_use_modules(${testName} Test) | |
129 |
|
139 | |||
130 | ADD_TEST( NAME ${testName} COMMAND ${testName} ) |
|
140 | ADD_TEST( NAME ${testName} COMMAND ${testName} ) | |
131 |
|
141 | |||
132 | SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) |
|
142 | SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) | |
133 | ENDFOREACH( testFile ) |
|
143 | ENDFOREACH( testFile ) | |
134 |
|
144 | |||
135 | LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) |
|
145 | LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) | |
136 | LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) |
|
146 | LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) | |
137 | LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) |
|
147 | LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) | |
138 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
148 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) | |
139 | ENDIF(BUILD_TESTS) |
|
149 | ENDIF(BUILD_TESTS) | |
140 |
|
150 | |||
141 | # |
|
151 | # | |
142 | # Set the files that must be formatted by clang-format. |
|
152 | # Set the files that must be formatted by clang-format. | |
143 | # |
|
153 | # | |
144 | LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) |
|
154 | LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) | |
145 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
155 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) | |
146 |
|
156 | |||
147 | # |
|
157 | # | |
148 | # Set the directories that doxygen must browse to generate the |
|
158 | # Set the directories that doxygen must browse to generate the | |
149 | # documentation. |
|
159 | # documentation. | |
150 | # |
|
160 | # | |
151 | # Source directories: |
|
161 | # Source directories: | |
152 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") |
|
162 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") | |
153 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
163 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") | |
154 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) |
|
164 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) | |
155 | # Source directories to exclude from the documentation generation |
|
165 | # Source directories to exclude from the documentation generation | |
156 | #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") |
|
166 | #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") | |
157 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) |
|
167 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) | |
158 |
|
168 | |||
159 | # |
|
169 | # | |
160 | # Set the directories with the sources to analyze and propagate the |
|
170 | # Set the directories with the sources to analyze and propagate the | |
161 | # modification to the parent scope |
|
171 | # modification to the parent scope | |
162 | # |
|
172 | # | |
163 | # Source directories to analyze: |
|
173 | # Source directories to analyze: | |
164 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
174 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") | |
165 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") |
|
175 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") | |
166 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) |
|
176 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) | |
167 | # Source directories to exclude from the analysis |
|
177 | # Source directories to exclude from the analysis | |
168 | #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") |
|
178 | #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") | |
169 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) |
|
179 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) |
@@ -1,31 +1,40 | |||||
1 | #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H |
|
1 | #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H | |
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 | |||
|
8 | class DBCatalogue; | |||
|
9 | class DBEvent; | |||
|
10 | class VisualizationWidget; | |||
|
11 | ||||
7 | namespace Ui { |
|
12 | namespace Ui { | |
8 | class CatalogueEventsWidget; |
|
13 | class CatalogueEventsWidget; | |
9 | } |
|
14 | } | |
10 |
|
15 | |||
|
16 | Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueEventsWidget) | |||
|
17 | ||||
11 | class CatalogueEventsWidget : public QWidget { |
|
18 | class CatalogueEventsWidget : public QWidget { | |
12 | Q_OBJECT |
|
19 | Q_OBJECT | |
13 |
|
20 | |||
14 | signals: |
|
21 | signals: | |
15 |
void eventSelected(const Q |
|
22 | void eventsSelected(const QVector<std::shared_ptr<DBEvent> > &event); | |
16 |
|
23 | |||
17 | public: |
|
24 | public: | |
18 | explicit CatalogueEventsWidget(QWidget *parent = 0); |
|
25 | explicit CatalogueEventsWidget(QWidget *parent = 0); | |
19 | virtual ~CatalogueEventsWidget(); |
|
26 | virtual ~CatalogueEventsWidget(); | |
20 |
|
27 | |||
|
28 | void setVisualizationWidget(VisualizationWidget *visualization); | |||
|
29 | ||||
21 | public slots: |
|
30 | public slots: | |
22 |
void populateWithCatalogue(const Q |
|
31 | void populateWithCatalogues(const QVector<std::shared_ptr<DBCatalogue> > &catalogues); | |
23 |
|
32 | |||
24 | private: |
|
33 | private: | |
25 | Ui::CatalogueEventsWidget *ui; |
|
34 | Ui::CatalogueEventsWidget *ui; | |
26 |
|
35 | |||
27 | class CatalogueEventsWidgetPrivate; |
|
36 | class CatalogueEventsWidgetPrivate; | |
28 | spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl; |
|
37 | spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl; | |
29 | }; |
|
38 | }; | |
30 |
|
39 | |||
31 | #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H |
|
40 | #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H |
@@ -1,21 +1,29 | |||||
1 | #ifndef SCIQLOP_CATALOGUEEXPLORER_H |
|
1 | #ifndef SCIQLOP_CATALOGUEEXPLORER_H | |
2 | #define SCIQLOP_CATALOGUEEXPLORER_H |
|
2 | #define SCIQLOP_CATALOGUEEXPLORER_H | |
3 |
|
3 | |||
|
4 | #include <Common/spimpl.h> | |||
4 | #include <QDialog> |
|
5 | #include <QDialog> | |
5 |
|
6 | |||
6 | namespace Ui { |
|
7 | namespace Ui { | |
7 | class CatalogueExplorer; |
|
8 | class CatalogueExplorer; | |
8 | } |
|
9 | } | |
9 |
|
10 | |||
|
11 | class VisualizationWidget; | |||
|
12 | ||||
10 | class CatalogueExplorer : public QDialog { |
|
13 | class CatalogueExplorer : public QDialog { | |
11 | Q_OBJECT |
|
14 | Q_OBJECT | |
12 |
|
15 | |||
13 | public: |
|
16 | public: | |
14 | explicit CatalogueExplorer(QWidget *parent = 0); |
|
17 | explicit CatalogueExplorer(QWidget *parent = 0); | |
15 | virtual ~CatalogueExplorer(); |
|
18 | virtual ~CatalogueExplorer(); | |
16 |
|
19 | |||
|
20 | void setVisualizationWidget(VisualizationWidget *visualization); | |||
|
21 | ||||
17 | private: |
|
22 | private: | |
18 | Ui::CatalogueExplorer *ui; |
|
23 | Ui::CatalogueExplorer *ui; | |
|
24 | ||||
|
25 | class CatalogueExplorerPrivate; | |||
|
26 | spimpl::unique_impl_ptr<CatalogueExplorerPrivate> impl; | |||
19 | }; |
|
27 | }; | |
20 |
|
28 | |||
21 | #endif // SCIQLOP_CATALOGUEEXPLORER_H |
|
29 | #endif // SCIQLOP_CATALOGUEEXPLORER_H |
@@ -1,32 +1,36 | |||||
1 | #ifndef SCIQLOP_CATALOGUEINSPECTORWIDGET_H |
|
1 | #ifndef SCIQLOP_CATALOGUEINSPECTORWIDGET_H | |
2 | #define SCIQLOP_CATALOGUEINSPECTORWIDGET_H |
|
2 | #define SCIQLOP_CATALOGUEINSPECTORWIDGET_H | |
3 |
|
3 | |||
4 | #include <QWidget> |
|
4 | #include <QWidget> | |
|
5 | #include <memory> | |||
5 |
|
6 | |||
6 | namespace Ui { |
|
7 | namespace Ui { | |
7 | class CatalogueInspectorWidget; |
|
8 | class CatalogueInspectorWidget; | |
8 | } |
|
9 | } | |
9 |
|
10 | |||
|
11 | class DBCatalogue; | |||
|
12 | class DBEvent; | |||
|
13 | ||||
10 | class CatalogueInspectorWidget : public QWidget { |
|
14 | class CatalogueInspectorWidget : public QWidget { | |
11 | Q_OBJECT |
|
15 | Q_OBJECT | |
12 |
|
16 | |||
13 | public: |
|
17 | public: | |
14 | explicit CatalogueInspectorWidget(QWidget *parent = 0); |
|
18 | explicit CatalogueInspectorWidget(QWidget *parent = 0); | |
15 | virtual ~CatalogueInspectorWidget(); |
|
19 | virtual ~CatalogueInspectorWidget(); | |
16 |
|
20 | |||
17 | /// Enum matching the pages inside the stacked widget |
|
21 | /// Enum matching the pages inside the stacked widget | |
18 | enum class Page { Empty, CatalogueProperties, EventProperties }; |
|
22 | enum class Page { Empty, CatalogueProperties, EventProperties }; | |
19 |
|
23 | |||
20 | Page currentPage() const; |
|
24 | Page currentPage() const; | |
21 |
|
25 | |||
22 |
void setEvent(const |
|
26 | void setEvent(const std::shared_ptr<DBEvent> &event); | |
23 |
void setCatalogue(const |
|
27 | void setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue); | |
24 |
|
28 | |||
25 | public slots: |
|
29 | public slots: | |
26 | void showPage(Page page); |
|
30 | void showPage(Page page); | |
27 |
|
31 | |||
28 | private: |
|
32 | private: | |
29 | Ui::CatalogueInspectorWidget *ui; |
|
33 | Ui::CatalogueInspectorWidget *ui; | |
30 | }; |
|
34 | }; | |
31 |
|
35 | |||
32 | #endif // SCIQLOP_CATALOGUEINSPECTORWIDGET_H |
|
36 | #endif // SCIQLOP_CATALOGUEINSPECTORWIDGET_H |
@@ -1,31 +1,38 | |||||
1 | #ifndef SCIQLOP_CATALOGUESIDEBARWIDGET_H |
|
1 | #ifndef SCIQLOP_CATALOGUESIDEBARWIDGET_H | |
2 | #define SCIQLOP_CATALOGUESIDEBARWIDGET_H |
|
2 | #define SCIQLOP_CATALOGUESIDEBARWIDGET_H | |
3 |
|
3 | |||
4 | #include <Common/spimpl.h> |
|
4 | #include <Common/spimpl.h> | |
5 | #include <QTreeWidgetItem> |
|
5 | #include <QTreeWidgetItem> | |
6 | #include <QWidget> |
|
6 | #include <QWidget> | |
7 |
|
7 | |||
|
8 | class DBCatalogue; | |||
|
9 | ||||
8 | namespace Ui { |
|
10 | namespace Ui { | |
9 | class CatalogueSideBarWidget; |
|
11 | class CatalogueSideBarWidget; | |
10 | } |
|
12 | } | |
11 |
|
13 | |||
12 | class CatalogueSideBarWidget : public QWidget { |
|
14 | class CatalogueSideBarWidget : public QWidget { | |
13 | Q_OBJECT |
|
15 | Q_OBJECT | |
14 |
|
16 | |||
15 | signals: |
|
17 | signals: | |
16 |
void catalogueSelected(const Q |
|
18 | void catalogueSelected(const QVector<std::shared_ptr<DBCatalogue> > &catalogues); | |
|
19 | void databaseSelected(const QStringList &databases); | |||
17 | void allEventsSelected(); |
|
20 | void allEventsSelected(); | |
18 | void trashSelected(); |
|
21 | void trashSelected(); | |
|
22 | void selectionCleared(); | |||
19 |
|
23 | |||
20 | public: |
|
24 | public: | |
21 | explicit CatalogueSideBarWidget(QWidget *parent = 0); |
|
25 | explicit CatalogueSideBarWidget(QWidget *parent = 0); | |
22 | virtual ~CatalogueSideBarWidget(); |
|
26 | virtual ~CatalogueSideBarWidget(); | |
23 |
|
27 | |||
24 | private: |
|
28 | private: | |
25 | Ui::CatalogueSideBarWidget *ui; |
|
29 | Ui::CatalogueSideBarWidget *ui; | |
26 |
|
30 | |||
27 | class CatalogueSideBarWidgetPrivate; |
|
31 | class CatalogueSideBarWidgetPrivate; | |
28 | spimpl::unique_impl_ptr<CatalogueSideBarWidgetPrivate> impl; |
|
32 | spimpl::unique_impl_ptr<CatalogueSideBarWidgetPrivate> impl; | |
|
33 | ||||
|
34 | private slots: | |||
|
35 | void onContextMenuRequested(const QPoint &pos); | |||
29 | }; |
|
36 | }; | |
30 |
|
37 | |||
31 | #endif // SCIQLOP_CATALOGUESIDEBARWIDGET_H |
|
38 | #endif // SCIQLOP_CATALOGUESIDEBARWIDGET_H |
@@ -1,69 +1,71 | |||||
1 | #ifndef SCIQLOP_SQPAPPLICATION_H |
|
1 | #ifndef SCIQLOP_SQPAPPLICATION_H | |
2 | #define SCIQLOP_SQPAPPLICATION_H |
|
2 | #define SCIQLOP_SQPAPPLICATION_H | |
3 |
|
3 | |||
4 | #include "SqpApplication.h" |
|
4 | #include "SqpApplication.h" | |
5 |
|
5 | |||
6 | #include <QApplication> |
|
6 | #include <QApplication> | |
7 | #include <QLoggingCategory> |
|
7 | #include <QLoggingCategory> | |
8 |
|
8 | |||
9 | #include <Common/spimpl.h> |
|
9 | #include <Common/spimpl.h> | |
10 |
|
10 | |||
11 | Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) |
|
11 | Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) | |
12 |
|
12 | |||
13 | #if defined(sqpApp) |
|
13 | #if defined(sqpApp) | |
14 | #undef sqpApp |
|
14 | #undef sqpApp | |
15 | #endif |
|
15 | #endif | |
16 | #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance())) |
|
16 | #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance())) | |
17 |
|
17 | |||
18 | class DataSourceController; |
|
18 | class DataSourceController; | |
19 | class NetworkController; |
|
19 | class NetworkController; | |
20 | class TimeController; |
|
20 | class TimeController; | |
21 | class VariableController; |
|
21 | class VariableController; | |
22 | class VisualizationController; |
|
22 | class VisualizationController; | |
23 | class DragDropGuiController; |
|
23 | class DragDropGuiController; | |
24 | class ActionsGuiController; |
|
24 | class ActionsGuiController; | |
|
25 | class CatalogueController; | |||
25 |
|
26 | |||
26 | /** |
|
27 | /** | |
27 | * @brief The SqpApplication class aims to make the link between SciQlop |
|
28 | * @brief The SqpApplication class aims to make the link between SciQlop | |
28 | * and its plugins. This is the intermediate class that SciQlop has to use |
|
29 | * and its plugins. This is the intermediate class that SciQlop has to use | |
29 | * in the way to connect a data source. Please first use load method to initialize |
|
30 | * in the way to connect a data source. Please first use load method to initialize | |
30 | * a plugin specified by its metadata name (JSON plugin source) then others specifics |
|
31 | * a plugin specified by its metadata name (JSON plugin source) then others specifics | |
31 | * method will be able to access it. |
|
32 | * method will be able to access it. | |
32 | * You can load a data source driver plugin then create a data source. |
|
33 | * You can load a data source driver plugin then create a data source. | |
33 | */ |
|
34 | */ | |
34 |
|
35 | |||
35 | class SqpApplication : public QApplication { |
|
36 | class SqpApplication : public QApplication { | |
36 | Q_OBJECT |
|
37 | Q_OBJECT | |
37 | public: |
|
38 | public: | |
38 | explicit SqpApplication(int &argc, char **argv); |
|
39 | explicit SqpApplication(int &argc, char **argv); | |
39 | virtual ~SqpApplication(); |
|
40 | virtual ~SqpApplication(); | |
40 | void initialize(); |
|
41 | void initialize(); | |
41 |
|
42 | |||
42 | /// Accessors for the differents sciqlop controllers |
|
43 | /// Accessors for the differents sciqlop controllers | |
43 | DataSourceController &dataSourceController() noexcept; |
|
44 | DataSourceController &dataSourceController() noexcept; | |
44 | NetworkController &networkController() noexcept; |
|
45 | NetworkController &networkController() noexcept; | |
45 | TimeController &timeController() noexcept; |
|
46 | TimeController &timeController() noexcept; | |
46 | VariableController &variableController() noexcept; |
|
47 | VariableController &variableController() noexcept; | |
47 | VisualizationController &visualizationController() noexcept; |
|
48 | VisualizationController &visualizationController() noexcept; | |
|
49 | CatalogueController &catalogueController() noexcept; | |||
48 |
|
50 | |||
49 | /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but |
|
51 | /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but | |
50 | /// doesn't live in a thread and access gui |
|
52 | /// doesn't live in a thread and access gui | |
51 | DragDropGuiController &dragDropGuiController() noexcept; |
|
53 | DragDropGuiController &dragDropGuiController() noexcept; | |
52 | ActionsGuiController &actionsGuiController() noexcept; |
|
54 | ActionsGuiController &actionsGuiController() noexcept; | |
53 |
|
55 | |||
54 | enum class PlotsInteractionMode { None, ZoomBox, DragAndDrop, SelectionZones }; |
|
56 | enum class PlotsInteractionMode { None, ZoomBox, DragAndDrop, SelectionZones }; | |
55 |
|
57 | |||
56 | enum class PlotsCursorMode { NoCursor, Vertical, Temporal, Horizontal, Cross }; |
|
58 | enum class PlotsCursorMode { NoCursor, Vertical, Temporal, Horizontal, Cross }; | |
57 |
|
59 | |||
58 | PlotsInteractionMode plotsInteractionMode() const; |
|
60 | PlotsInteractionMode plotsInteractionMode() const; | |
59 | void setPlotsInteractionMode(PlotsInteractionMode mode); |
|
61 | void setPlotsInteractionMode(PlotsInteractionMode mode); | |
60 |
|
62 | |||
61 | PlotsCursorMode plotsCursorMode() const; |
|
63 | PlotsCursorMode plotsCursorMode() const; | |
62 | void setPlotsCursorMode(PlotsCursorMode mode); |
|
64 | void setPlotsCursorMode(PlotsCursorMode mode); | |
63 |
|
65 | |||
64 | private: |
|
66 | private: | |
65 | class SqpApplicationPrivate; |
|
67 | class SqpApplicationPrivate; | |
66 | spimpl::unique_impl_ptr<SqpApplicationPrivate> impl; |
|
68 | spimpl::unique_impl_ptr<SqpApplicationPrivate> impl; | |
67 | }; |
|
69 | }; | |
68 |
|
70 | |||
69 | #endif // SCIQLOP_SQPAPPLICATION_H |
|
71 | #endif // SCIQLOP_SQPAPPLICATION_H |
@@ -1,80 +1,88 | |||||
1 | #ifndef SCIQLOP_VISUALIZATIONTABWIDGET_H |
|
1 | #ifndef SCIQLOP_VISUALIZATIONTABWIDGET_H | |
2 | #define SCIQLOP_VISUALIZATIONTABWIDGET_H |
|
2 | #define SCIQLOP_VISUALIZATIONTABWIDGET_H | |
3 |
|
3 | |||
4 | #include "Visualization/IVisualizationWidget.h" |
|
4 | #include "Visualization/IVisualizationWidget.h" | |
5 |
|
5 | |||
6 | #include <Common/spimpl.h> |
|
6 | #include <Common/spimpl.h> | |
7 |
|
7 | |||
8 | #include <QLoggingCategory> |
|
8 | #include <QLoggingCategory> | |
9 | #include <QMimeData> |
|
9 | #include <QMimeData> | |
10 | #include <QWidget> |
|
10 | #include <QWidget> | |
11 |
|
11 | |||
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationTabWidget) |
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationTabWidget) | |
13 |
|
13 | |||
14 | class Variable; |
|
14 | class Variable; | |
15 | class VisualizationZoneWidget; |
|
15 | class VisualizationZoneWidget; | |
16 |
|
16 | |||
17 | namespace Ui { |
|
17 | namespace Ui { | |
18 | class VisualizationTabWidget; |
|
18 | class VisualizationTabWidget; | |
19 | } // namespace Ui |
|
19 | } // namespace Ui | |
20 |
|
20 | |||
21 | class VisualizationTabWidget : public QWidget, public IVisualizationWidget { |
|
21 | class VisualizationTabWidget : public QWidget, public IVisualizationWidget { | |
22 | Q_OBJECT |
|
22 | Q_OBJECT | |
23 |
|
23 | |||
24 | public: |
|
24 | public: | |
25 | explicit VisualizationTabWidget(const QString &name = {}, QWidget *parent = 0); |
|
25 | explicit VisualizationTabWidget(const QString &name = {}, QWidget *parent = 0); | |
26 | virtual ~VisualizationTabWidget(); |
|
26 | virtual ~VisualizationTabWidget(); | |
27 |
|
27 | |||
28 | /// Add a zone widget |
|
28 | /// Adds a zone widget | |
29 | void addZone(VisualizationZoneWidget *zoneWidget); |
|
29 | void addZone(VisualizationZoneWidget *zoneWidget); | |
30 |
|
30 | |||
|
31 | /// Inserts a zone widget at the specified position | |||
31 | void insertZone(int index, VisualizationZoneWidget *zoneWidget); |
|
32 | void insertZone(int index, VisualizationZoneWidget *zoneWidget); | |
32 |
|
33 | |||
|
34 | /// Returns the list of zone widget names in the order they are displayed | |||
|
35 | QStringList availableZoneWidgets() const; | |||
|
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 | ||||
33 | /** |
|
41 | /** | |
34 | * 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 | |
35 | * zone. The zone is added at the end. |
|
43 | * zone. The zone is added at the end. | |
36 | * @param variable the variable for which to create the zone |
|
44 | * @param variable the variable for which to create the zone | |
37 | * @return the pointer to the created zone |
|
45 | * @return the pointer to the created zone | |
38 | */ |
|
46 | */ | |
39 | VisualizationZoneWidget *createZone(std::shared_ptr<Variable> variable); |
|
47 | VisualizationZoneWidget *createZone(std::shared_ptr<Variable> variable); | |
40 |
|
48 | |||
41 | /** |
|
49 | /** | |
42 | * Creates a zone using a list of variables. The variables will be displayed in a new graph of |
|
50 | * Creates a zone using a list of variables. The variables will be displayed in a new graph of | |
43 | * the new zone. The zone is inserted at the specified index. |
|
51 | * the new zone. The zone is inserted at the specified index. | |
44 | * @param variables the variables for which to create the zone |
|
52 | * @param variables the variables for which to create the zone | |
45 | * @param index The index where the zone should be inserted in the layout |
|
53 | * @param index The index where the zone should be inserted in the layout | |
46 | * @return the pointer to the created zone |
|
54 | * @return the pointer to the created zone | |
47 | */ |
|
55 | */ | |
48 | VisualizationZoneWidget *createZone(const QList<std::shared_ptr<Variable> > &variables, |
|
56 | VisualizationZoneWidget *createZone(const QList<std::shared_ptr<Variable> > &variables, | |
49 | int index); |
|
57 | int index); | |
50 |
|
58 | |||
51 | /** |
|
59 | /** | |
52 | * Creates a zone which is empty (no variables). The zone is inserted at the specified index. |
|
60 | * Creates a zone which is empty (no variables). The zone is inserted at the specified index. | |
53 | * @param index The index where the zone should be inserted in the layout |
|
61 | * @param index The index where the zone should be inserted in the layout | |
54 | * @return the pointer to the created zone |
|
62 | * @return the pointer to the created zone | |
55 | */ |
|
63 | */ | |
56 | VisualizationZoneWidget *createEmptyZone(int index); |
|
64 | VisualizationZoneWidget *createEmptyZone(int index); | |
57 |
|
65 | |||
58 | // IVisualizationWidget interface |
|
66 | // IVisualizationWidget interface | |
59 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
67 | void accept(IVisualizationWidgetVisitor *visitor) override; | |
60 | bool canDrop(const Variable &variable) const override; |
|
68 | bool canDrop(const Variable &variable) const override; | |
61 | bool contains(const Variable &variable) const override; |
|
69 | bool contains(const Variable &variable) const override; | |
62 | QString name() const override; |
|
70 | QString name() const override; | |
63 |
|
71 | |||
64 | protected: |
|
72 | protected: | |
65 | void closeEvent(QCloseEvent *event) override; |
|
73 | void closeEvent(QCloseEvent *event) override; | |
66 |
|
74 | |||
67 | private: |
|
75 | private: | |
68 | /// @return the layout of tab in which zones are added |
|
76 | /// @return the layout of tab in which zones are added | |
69 | QLayout &tabLayout() const noexcept; |
|
77 | QLayout &tabLayout() const noexcept; | |
70 |
|
78 | |||
71 | Ui::VisualizationTabWidget *ui; |
|
79 | Ui::VisualizationTabWidget *ui; | |
72 |
|
80 | |||
73 | class VisualizationTabWidgetPrivate; |
|
81 | class VisualizationTabWidgetPrivate; | |
74 | spimpl::unique_impl_ptr<VisualizationTabWidgetPrivate> impl; |
|
82 | spimpl::unique_impl_ptr<VisualizationTabWidgetPrivate> impl; | |
75 |
|
83 | |||
76 | private slots: |
|
84 | private slots: | |
77 | void dropMimeData(int index, const QMimeData *mimeData); |
|
85 | void dropMimeData(int index, const QMimeData *mimeData); | |
78 | }; |
|
86 | }; | |
79 |
|
87 | |||
80 | #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H |
|
88 | #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H |
@@ -1,63 +1,65 | |||||
1 | #ifndef SCIQLOP_VISUALIZATIONWIDGET_H |
|
1 | #ifndef SCIQLOP_VISUALIZATIONWIDGET_H | |
2 | #define SCIQLOP_VISUALIZATIONWIDGET_H |
|
2 | #define SCIQLOP_VISUALIZATIONWIDGET_H | |
3 |
|
3 | |||
4 | #include "Visualization/IVisualizationWidget.h" |
|
4 | #include "Visualization/IVisualizationWidget.h" | |
5 | #include <Data/SqpRange.h> |
|
5 | #include <Data/SqpRange.h> | |
6 |
|
6 | |||
7 | #include <QLoggingCategory> |
|
7 | #include <QLoggingCategory> | |
8 | #include <QWidget> |
|
8 | #include <QWidget> | |
9 |
|
9 | |||
10 | #include <Common/spimpl.h> |
|
10 | #include <Common/spimpl.h> | |
11 |
|
11 | |||
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) |
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) | |
13 |
|
13 | |||
14 | class QMenu; |
|
14 | class QMenu; | |
15 | class Variable; |
|
15 | class Variable; | |
16 | class VisualizationTabWidget; |
|
16 | class VisualizationTabWidget; | |
17 | class VisualizationSelectionZoneManager; |
|
17 | class VisualizationSelectionZoneManager; | |
18 |
|
18 | |||
19 | namespace Ui { |
|
19 | namespace Ui { | |
20 | class VisualizationWidget; |
|
20 | class VisualizationWidget; | |
21 | } // namespace Ui |
|
21 | } // namespace Ui | |
22 |
|
22 | |||
23 | class VisualizationWidget : public QWidget, public IVisualizationWidget { |
|
23 | class VisualizationWidget : public QWidget, public IVisualizationWidget { | |
24 | Q_OBJECT |
|
24 | Q_OBJECT | |
25 |
|
25 | |||
26 | public: |
|
26 | public: | |
27 | explicit VisualizationWidget(QWidget *parent = 0); |
|
27 | explicit VisualizationWidget(QWidget *parent = 0); | |
28 | virtual ~VisualizationWidget(); |
|
28 | virtual ~VisualizationWidget(); | |
29 |
|
29 | |||
30 | /// Returns the class which manage the selection of selection zone across the visualization |
|
30 | /// Returns the class which manage the selection of selection zone across the visualization | |
31 | VisualizationSelectionZoneManager &selectionZoneManager() const; |
|
31 | VisualizationSelectionZoneManager &selectionZoneManager() const; | |
32 |
|
32 | |||
|
33 | VisualizationTabWidget *currentTabWidget() const; | |||
|
34 | ||||
33 | // IVisualizationWidget interface |
|
35 | // IVisualizationWidget interface | |
34 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
36 | void accept(IVisualizationWidgetVisitor *visitor) override; | |
35 | bool canDrop(const Variable &variable) const override; |
|
37 | bool canDrop(const Variable &variable) const override; | |
36 | bool contains(const Variable &variable) const override; |
|
38 | bool contains(const Variable &variable) const override; | |
37 | QString name() const override; |
|
39 | QString name() const override; | |
38 |
|
40 | |||
39 | public slots: |
|
41 | public slots: | |
40 | /** |
|
42 | /** | |
41 | * Attaches to a menu the menu relative to the visualization of variables |
|
43 | * Attaches to a menu the menu relative to the visualization of variables | |
42 | * @param menu the parent menu of the generated menu |
|
44 | * @param menu the parent menu of the generated menu | |
43 | * @param variables the variables for which to generate the menu |
|
45 | * @param variables the variables for which to generate the menu | |
44 | */ |
|
46 | */ | |
45 | void attachVariableMenu(QMenu *menu, |
|
47 | void attachVariableMenu(QMenu *menu, | |
46 | const QVector<std::shared_ptr<Variable> > &variables) noexcept; |
|
48 | const QVector<std::shared_ptr<Variable> > &variables) noexcept; | |
47 |
|
49 | |||
48 | /// Slot called when a variable is about to be deleted from SciQlop |
|
50 | /// Slot called when a variable is about to be deleted from SciQlop | |
49 | void onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept; |
|
51 | void onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept; | |
50 |
|
52 | |||
51 | void onRangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range) noexcept; |
|
53 | void onRangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range) noexcept; | |
52 |
|
54 | |||
53 | protected: |
|
55 | protected: | |
54 | void closeEvent(QCloseEvent *event) override; |
|
56 | void closeEvent(QCloseEvent *event) override; | |
55 |
|
57 | |||
56 | private: |
|
58 | private: | |
57 | Ui::VisualizationWidget *ui; |
|
59 | Ui::VisualizationWidget *ui; | |
58 |
|
60 | |||
59 | class VisualizationWidgetPrivate; |
|
61 | class VisualizationWidgetPrivate; | |
60 | spimpl::unique_impl_ptr<VisualizationWidgetPrivate> impl; |
|
62 | spimpl::unique_impl_ptr<VisualizationWidgetPrivate> impl; | |
61 | }; |
|
63 | }; | |
62 |
|
64 | |||
63 | #endif // VISUALIZATIONWIDGET_H |
|
65 | #endif // VISUALIZATIONWIDGET_H |
@@ -1,98 +1,103 | |||||
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 | |||
7 | #include <QLoggingCategory> |
|
8 | #include <QLoggingCategory> | |
8 | #include <QWidget> |
|
9 | #include <QWidget> | |
9 |
|
10 | |||
10 | #include <memory> |
|
11 | #include <memory> | |
11 |
|
12 | |||
12 | #include <Common/spimpl.h> |
|
13 | #include <Common/spimpl.h> | |
13 |
|
14 | |||
14 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationZoneWidget) |
|
15 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationZoneWidget) | |
15 |
|
16 | |||
16 | namespace Ui { |
|
17 | namespace Ui { | |
17 | class VisualizationZoneWidget; |
|
18 | class VisualizationZoneWidget; | |
18 | } // namespace Ui |
|
19 | } // namespace Ui | |
19 |
|
20 | |||
20 | class Variable; |
|
21 | class Variable; | |
21 | class VisualizationGraphWidget; |
|
22 | class VisualizationGraphWidget; | |
22 |
|
23 | |||
23 | class VisualizationZoneWidget : public VisualizationDragWidget, public IVisualizationWidget { |
|
24 | class VisualizationZoneWidget : public VisualizationDragWidget, public IVisualizationWidget { | |
24 | Q_OBJECT |
|
25 | Q_OBJECT | |
25 |
|
26 | |||
26 | public: |
|
27 | 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 | |||
33 | /// Inserts a graph widget |
|
38 | /// Inserts a graph widget | |
34 | void insertGraph(int index, VisualizationGraphWidget *graphWidget); |
|
39 | void insertGraph(int index, VisualizationGraphWidget *graphWidget); | |
35 |
|
40 | |||
36 | /** |
|
41 | /** | |
37 | * Creates a graph using a variable. The variable will be displayed in the new graph. |
|
42 | * Creates a graph using a variable. The variable will be displayed in the new graph. | |
38 | * The graph is added at the end. |
|
43 | * The graph is added at the end. | |
39 | * @param variable the variable for which to create the graph |
|
44 | * @param variable the variable for which to create the graph | |
40 | * @return the pointer to the created graph |
|
45 | * @return the pointer to the created graph | |
41 | */ |
|
46 | */ | |
42 | VisualizationGraphWidget *createGraph(std::shared_ptr<Variable> variable); |
|
47 | VisualizationGraphWidget *createGraph(std::shared_ptr<Variable> variable); | |
43 |
|
48 | |||
44 | /** |
|
49 | /** | |
45 | * Creates a graph using a variable. The variable will be displayed in the new graph. |
|
50 | * Creates a graph using a variable. The variable will be displayed in the new graph. | |
46 | * The graph is inserted at the specified index. |
|
51 | * The graph is inserted at the specified index. | |
47 | * @param variable the variable for which to create the graph |
|
52 | * @param variable the variable for which to create the graph | |
48 | * @param index The index where the graph should be inserted in the layout |
|
53 | * @param index The index where the graph should be inserted in the layout | |
49 | * @return the pointer to the created graph |
|
54 | * @return the pointer to the created graph | |
50 | */ |
|
55 | */ | |
51 | VisualizationGraphWidget *createGraph(std::shared_ptr<Variable> variable, int index); |
|
56 | VisualizationGraphWidget *createGraph(std::shared_ptr<Variable> variable, int index); | |
52 |
|
57 | |||
53 | /** |
|
58 | /** | |
54 | * Creates a graph using a list of variables. The variables will be displayed in the new graph. |
|
59 | * Creates a graph using a list of variables. The variables will be displayed in the new graph. | |
55 | * The graph is inserted at the specified index. |
|
60 | * The graph is inserted at the specified index. | |
56 | * @param variables List of variables to be added to the graph |
|
61 | * @param variables List of variables to be added to the graph | |
57 | * @param index The index where the graph should be inserted in the layout |
|
62 | * @param index The index where the graph should be inserted in the layout | |
58 | * @return the pointer to the created graph |
|
63 | * @return the pointer to the created graph | |
59 | */ |
|
64 | */ | |
60 | VisualizationGraphWidget *createGraph(const QList<std::shared_ptr<Variable> > variables, |
|
65 | VisualizationGraphWidget *createGraph(const QList<std::shared_ptr<Variable> > variables, | |
61 | int index); |
|
66 | int index); | |
62 |
|
67 | |||
63 | /// Returns the first graph in the zone or nullptr if there is no graph inside |
|
68 | /// Returns the first graph in the zone or nullptr if there is no graph inside | |
64 | VisualizationGraphWidget *firstGraph() const; |
|
69 | VisualizationGraphWidget *firstGraph() const; | |
65 |
|
70 | |||
66 | // IVisualizationWidget interface |
|
71 | // IVisualizationWidget interface | |
67 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
72 | void accept(IVisualizationWidgetVisitor *visitor) override; | |
68 | bool canDrop(const Variable &variable) const override; |
|
73 | bool canDrop(const Variable &variable) const override; | |
69 | bool contains(const Variable &variable) const override; |
|
74 | bool contains(const Variable &variable) const override; | |
70 | QString name() const override; |
|
75 | QString name() const override; | |
71 |
|
76 | |||
72 | // VisualisationDragWidget |
|
77 | // VisualisationDragWidget | |
73 | QMimeData *mimeData(const QPoint &position) const override; |
|
78 | QMimeData *mimeData(const QPoint &position) const override; | |
74 | bool isDragAllowed() const override; |
|
79 | bool isDragAllowed() const override; | |
75 |
|
80 | |||
76 | void notifyMouseMoveInGraph(const QPointF &graphPosition, const QPointF &plotPosition, |
|
81 | void notifyMouseMoveInGraph(const QPointF &graphPosition, const QPointF &plotPosition, | |
77 | VisualizationGraphWidget *graphWidget); |
|
82 | VisualizationGraphWidget *graphWidget); | |
78 | void notifyMouseLeaveGraph(VisualizationGraphWidget *graphWidget); |
|
83 | void notifyMouseLeaveGraph(VisualizationGraphWidget *graphWidget); | |
79 |
|
84 | |||
80 | protected: |
|
85 | protected: | |
81 | void closeEvent(QCloseEvent *event) override; |
|
86 | void closeEvent(QCloseEvent *event) override; | |
82 |
|
87 | |||
83 | private: |
|
88 | private: | |
84 | Ui::VisualizationZoneWidget *ui; |
|
89 | Ui::VisualizationZoneWidget *ui; | |
85 |
|
90 | |||
86 | class VisualizationZoneWidgetPrivate; |
|
91 | class VisualizationZoneWidgetPrivate; | |
87 | spimpl::unique_impl_ptr<VisualizationZoneWidgetPrivate> impl; |
|
92 | spimpl::unique_impl_ptr<VisualizationZoneWidgetPrivate> impl; | |
88 |
|
93 | |||
89 | private slots: |
|
94 | private slots: | |
90 | void onVariableAdded(std::shared_ptr<Variable> variable); |
|
95 | void onVariableAdded(std::shared_ptr<Variable> variable); | |
91 | /// Slot called when a variable is about to be removed from a graph contained in the zone |
|
96 | /// Slot called when a variable is about to be removed from a graph contained in the zone | |
92 | void onVariableAboutToBeRemoved(std::shared_ptr<Variable> variable); |
|
97 | void onVariableAboutToBeRemoved(std::shared_ptr<Variable> variable); | |
93 |
|
98 | |||
94 | void dropMimeData(int index, const QMimeData *mimeData); |
|
99 | void dropMimeData(int index, const QMimeData *mimeData); | |
95 | void dropMimeDataOnGraph(VisualizationDragWidget *dragWidget, const QMimeData *mimeData); |
|
100 | void dropMimeDataOnGraph(VisualizationDragWidget *dragWidget, const QMimeData *mimeData); | |
96 | }; |
|
101 | }; | |
97 |
|
102 | |||
98 | #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H |
|
103 | #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H |
@@ -1,122 +1,127 | |||||
1 |
|
1 | |||
|
2 | qxorm_dep = dependency('QxOrm', required : true, fallback:['QxOrm','qxorm_dep']) | |||
|
3 | catalogueapi_dep = dependency('CatalogueAPI', required : true, fallback:['CatalogueAPI','CatalogueAPI_dep']) | |||
|
4 | ||||
2 | gui_moc_headers = [ |
|
5 | gui_moc_headers = [ | |
3 | 'include/DataSource/DataSourceWidget.h', |
|
6 | 'include/DataSource/DataSourceWidget.h', | |
4 | 'include/Settings/SqpSettingsDialog.h', |
|
7 | 'include/Settings/SqpSettingsDialog.h', | |
5 | 'include/Settings/SqpSettingsGeneralWidget.h', |
|
8 | 'include/Settings/SqpSettingsGeneralWidget.h', | |
6 | 'include/SidePane/SqpSidePane.h', |
|
9 | 'include/SidePane/SqpSidePane.h', | |
7 | 'include/SqpApplication.h', |
|
10 | 'include/SqpApplication.h', | |
8 | 'include/DragAndDrop/DragDropScroller.h', |
|
11 | 'include/DragAndDrop/DragDropScroller.h', | |
9 | 'include/DragAndDrop/DragDropTabSwitcher.h', |
|
12 | 'include/DragAndDrop/DragDropTabSwitcher.h', | |
10 | 'include/TimeWidget/TimeWidget.h', |
|
13 | 'include/TimeWidget/TimeWidget.h', | |
11 | 'include/Variable/VariableInspectorWidget.h', |
|
14 | 'include/Variable/VariableInspectorWidget.h', | |
12 | 'include/Variable/RenameVariableDialog.h', |
|
15 | 'include/Variable/RenameVariableDialog.h', | |
13 | 'include/Visualization/qcustomplot.h', |
|
16 | 'include/Visualization/qcustomplot.h', | |
14 | 'include/Visualization/VisualizationGraphWidget.h', |
|
17 | 'include/Visualization/VisualizationGraphWidget.h', | |
15 | 'include/Visualization/VisualizationTabWidget.h', |
|
18 | 'include/Visualization/VisualizationTabWidget.h', | |
16 | 'include/Visualization/VisualizationWidget.h', |
|
19 | 'include/Visualization/VisualizationWidget.h', | |
17 | 'include/Visualization/VisualizationZoneWidget.h', |
|
20 | 'include/Visualization/VisualizationZoneWidget.h', | |
18 | 'include/Visualization/VisualizationDragDropContainer.h', |
|
21 | 'include/Visualization/VisualizationDragDropContainer.h', | |
19 | 'include/Visualization/VisualizationDragWidget.h', |
|
22 | 'include/Visualization/VisualizationDragWidget.h', | |
20 | 'include/Visualization/ColorScaleEditor.h', |
|
23 | 'include/Visualization/ColorScaleEditor.h', | |
21 | 'include/Actions/SelectionZoneAction.h', |
|
24 | 'include/Actions/SelectionZoneAction.h', | |
22 | 'include/Visualization/VisualizationMultiZoneSelectionDialog.h', |
|
25 | 'include/Visualization/VisualizationMultiZoneSelectionDialog.h', | |
23 | 'include/Catalogue/CatalogueExplorer.h', |
|
26 | 'include/Catalogue/CatalogueExplorer.h', | |
24 | 'include/Catalogue/CatalogueEventsWidget.h', |
|
27 | 'include/Catalogue/CatalogueEventsWidget.h', | |
25 | 'include/Catalogue/CatalogueSideBarWidget.h', |
|
28 | 'include/Catalogue/CatalogueSideBarWidget.h', | |
26 | 'include/Catalogue/CatalogueInspectorWidget.h' |
|
29 | 'include/Catalogue/CatalogueInspectorWidget.h' | |
27 | ] |
|
30 | ] | |
28 |
|
31 | |||
29 | gui_ui_files = [ |
|
32 | gui_ui_files = [ | |
30 | 'ui/DataSource/DataSourceWidget.ui', |
|
33 | 'ui/DataSource/DataSourceWidget.ui', | |
31 | 'ui/Settings/SqpSettingsDialog.ui', |
|
34 | 'ui/Settings/SqpSettingsDialog.ui', | |
32 | 'ui/Settings/SqpSettingsGeneralWidget.ui', |
|
35 | 'ui/Settings/SqpSettingsGeneralWidget.ui', | |
33 | 'ui/SidePane/SqpSidePane.ui', |
|
36 | 'ui/SidePane/SqpSidePane.ui', | |
34 | 'ui/TimeWidget/TimeWidget.ui', |
|
37 | 'ui/TimeWidget/TimeWidget.ui', | |
35 | 'ui/Variable/VariableInspectorWidget.ui', |
|
38 | 'ui/Variable/VariableInspectorWidget.ui', | |
36 | 'ui/Variable/RenameVariableDialog.ui', |
|
39 | 'ui/Variable/RenameVariableDialog.ui', | |
37 | 'ui/Variable/VariableMenuHeaderWidget.ui', |
|
40 | 'ui/Variable/VariableMenuHeaderWidget.ui', | |
38 | 'ui/Visualization/VisualizationGraphWidget.ui', |
|
41 | 'ui/Visualization/VisualizationGraphWidget.ui', | |
39 | 'ui/Visualization/VisualizationTabWidget.ui', |
|
42 | 'ui/Visualization/VisualizationTabWidget.ui', | |
40 | 'ui/Visualization/VisualizationWidget.ui', |
|
43 | 'ui/Visualization/VisualizationWidget.ui', | |
41 | 'ui/Visualization/VisualizationZoneWidget.ui', |
|
44 | 'ui/Visualization/VisualizationZoneWidget.ui', | |
42 | 'ui/Visualization/ColorScaleEditor.ui', |
|
45 | 'ui/Visualization/ColorScaleEditor.ui', | |
43 | 'ui/Visualization/VisualizationMultiZoneSelectionDialog.ui', |
|
46 | 'ui/Visualization/VisualizationMultiZoneSelectionDialog.ui', | |
44 | 'ui/Catalogue/CatalogueExplorer.ui', |
|
47 | 'ui/Catalogue/CatalogueExplorer.ui', | |
45 | 'ui/Catalogue/CatalogueEventsWidget.ui', |
|
48 | 'ui/Catalogue/CatalogueEventsWidget.ui', | |
46 | 'ui/Catalogue/CatalogueSideBarWidget.ui', |
|
49 | 'ui/Catalogue/CatalogueSideBarWidget.ui', | |
47 | 'ui/Catalogue/CatalogueInspectorWidget.ui' |
|
50 | 'ui/Catalogue/CatalogueInspectorWidget.ui' | |
48 | ] |
|
51 | ] | |
49 |
|
52 | |||
50 | gui_qresources = ['resources/sqpguiresources.qrc'] |
|
53 | gui_qresources = ['resources/sqpguiresources.qrc'] | |
51 |
|
54 | |||
52 | gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers, |
|
55 | gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers, | |
53 | ui_files : gui_ui_files, |
|
56 | ui_files : gui_ui_files, | |
54 | qresources : gui_qresources) |
|
57 | qresources : gui_qresources) | |
55 |
|
58 | |||
56 | gui_sources = [ |
|
59 | gui_sources = [ | |
57 | 'src/SqpApplication.cpp', |
|
60 | 'src/SqpApplication.cpp', | |
58 | 'src/DragAndDrop/DragDropGuiController.cpp', |
|
61 | 'src/DragAndDrop/DragDropGuiController.cpp', | |
59 | 'src/DragAndDrop/DragDropScroller.cpp', |
|
62 | 'src/DragAndDrop/DragDropScroller.cpp', | |
60 | 'src/DragAndDrop/DragDropTabSwitcher.cpp', |
|
63 | 'src/DragAndDrop/DragDropTabSwitcher.cpp', | |
61 | 'src/Common/ColorUtils.cpp', |
|
64 | 'src/Common/ColorUtils.cpp', | |
62 | 'src/Common/VisualizationDef.cpp', |
|
65 | 'src/Common/VisualizationDef.cpp', | |
63 | 'src/DataSource/DataSourceTreeWidgetItem.cpp', |
|
66 | 'src/DataSource/DataSourceTreeWidgetItem.cpp', | |
64 | 'src/DataSource/DataSourceTreeWidgetHelper.cpp', |
|
67 | 'src/DataSource/DataSourceTreeWidgetHelper.cpp', | |
65 | 'src/DataSource/DataSourceWidget.cpp', |
|
68 | 'src/DataSource/DataSourceWidget.cpp', | |
66 | 'src/DataSource/DataSourceTreeWidget.cpp', |
|
69 | 'src/DataSource/DataSourceTreeWidget.cpp', | |
67 | 'src/Settings/SqpSettingsDialog.cpp', |
|
70 | 'src/Settings/SqpSettingsDialog.cpp', | |
68 | 'src/Settings/SqpSettingsGeneralWidget.cpp', |
|
71 | 'src/Settings/SqpSettingsGeneralWidget.cpp', | |
69 | 'src/SidePane/SqpSidePane.cpp', |
|
72 | 'src/SidePane/SqpSidePane.cpp', | |
70 | 'src/TimeWidget/TimeWidget.cpp', |
|
73 | 'src/TimeWidget/TimeWidget.cpp', | |
71 | 'src/Variable/VariableInspectorWidget.cpp', |
|
74 | 'src/Variable/VariableInspectorWidget.cpp', | |
72 | 'src/Variable/VariableInspectorTableView.cpp', |
|
75 | 'src/Variable/VariableInspectorTableView.cpp', | |
73 | 'src/Variable/VariableMenuHeaderWidget.cpp', |
|
76 | 'src/Variable/VariableMenuHeaderWidget.cpp', | |
74 | 'src/Variable/RenameVariableDialog.cpp', |
|
77 | 'src/Variable/RenameVariableDialog.cpp', | |
75 | 'src/Visualization/VisualizationGraphHelper.cpp', |
|
78 | 'src/Visualization/VisualizationGraphHelper.cpp', | |
76 | 'src/Visualization/VisualizationGraphRenderingDelegate.cpp', |
|
79 | 'src/Visualization/VisualizationGraphRenderingDelegate.cpp', | |
77 | 'src/Visualization/VisualizationGraphWidget.cpp', |
|
80 | 'src/Visualization/VisualizationGraphWidget.cpp', | |
78 | 'src/Visualization/VisualizationTabWidget.cpp', |
|
81 | 'src/Visualization/VisualizationTabWidget.cpp', | |
79 | 'src/Visualization/VisualizationWidget.cpp', |
|
82 | 'src/Visualization/VisualizationWidget.cpp', | |
80 | 'src/Visualization/VisualizationZoneWidget.cpp', |
|
83 | 'src/Visualization/VisualizationZoneWidget.cpp', | |
81 | 'src/Visualization/qcustomplot.cpp', |
|
84 | 'src/Visualization/qcustomplot.cpp', | |
82 | 'src/Visualization/QCustomPlotSynchronizer.cpp', |
|
85 | 'src/Visualization/QCustomPlotSynchronizer.cpp', | |
83 | 'src/Visualization/operations/FindVariableOperation.cpp', |
|
86 | 'src/Visualization/operations/FindVariableOperation.cpp', | |
84 | 'src/Visualization/operations/GenerateVariableMenuOperation.cpp', |
|
87 | 'src/Visualization/operations/GenerateVariableMenuOperation.cpp', | |
85 | 'src/Visualization/operations/MenuBuilder.cpp', |
|
88 | 'src/Visualization/operations/MenuBuilder.cpp', | |
86 | 'src/Visualization/operations/RemoveVariableOperation.cpp', |
|
89 | 'src/Visualization/operations/RemoveVariableOperation.cpp', | |
87 | 'src/Visualization/operations/RescaleAxeOperation.cpp', |
|
90 | 'src/Visualization/operations/RescaleAxeOperation.cpp', | |
88 | 'src/Visualization/VisualizationDragDropContainer.cpp', |
|
91 | 'src/Visualization/VisualizationDragDropContainer.cpp', | |
89 | 'src/Visualization/VisualizationDragWidget.cpp', |
|
92 | 'src/Visualization/VisualizationDragWidget.cpp', | |
90 | 'src/Visualization/AxisRenderingUtils.cpp', |
|
93 | 'src/Visualization/AxisRenderingUtils.cpp', | |
91 | 'src/Visualization/PlottablesRenderingUtils.cpp', |
|
94 | 'src/Visualization/PlottablesRenderingUtils.cpp', | |
92 | 'src/Visualization/MacScrollBarStyle.cpp', |
|
95 | 'src/Visualization/MacScrollBarStyle.cpp', | |
93 | 'src/Visualization/VisualizationCursorItem.cpp', |
|
96 | 'src/Visualization/VisualizationCursorItem.cpp', | |
94 | 'src/Visualization/ColorScaleEditor.cpp', |
|
97 | 'src/Visualization/ColorScaleEditor.cpp', | |
95 | 'src/Visualization/SqpColorScale.cpp', |
|
98 | 'src/Visualization/SqpColorScale.cpp', | |
96 | 'src/Visualization/QCPColorMapIterator.cpp', |
|
99 | 'src/Visualization/QCPColorMapIterator.cpp', | |
97 | 'src/Visualization/VisualizationSelectionZoneItem.cpp', |
|
100 | 'src/Visualization/VisualizationSelectionZoneItem.cpp', | |
98 | 'src/Visualization/VisualizationSelectionZoneManager.cpp', |
|
101 | 'src/Visualization/VisualizationSelectionZoneManager.cpp', | |
99 | 'src/Actions/SelectionZoneAction.cpp', |
|
102 | 'src/Actions/SelectionZoneAction.cpp', | |
100 | 'src/Actions/ActionsGuiController.cpp', |
|
103 | 'src/Actions/ActionsGuiController.cpp', | |
101 | 'src/Visualization/VisualizationActionManager.cpp', |
|
104 | 'src/Visualization/VisualizationActionManager.cpp', | |
102 | 'src/Visualization/VisualizationMultiZoneSelectionDialog.cpp', |
|
105 | 'src/Visualization/VisualizationMultiZoneSelectionDialog.cpp', | |
103 | 'src/Catalogue/CatalogueExplorer.cpp', |
|
106 | 'src/Catalogue/CatalogueExplorer.cpp', | |
104 | 'src/Catalogue/CatalogueEventsWidget.cpp', |
|
107 | 'src/Catalogue/CatalogueEventsWidget.cpp', | |
105 | 'src/Catalogue/CatalogueSideBarWidget.cpp', |
|
108 | 'src/Catalogue/CatalogueSideBarWidget.cpp', | |
106 | 'src/Catalogue/CatalogueInspectorWidget.cpp' |
|
109 | 'src/Catalogue/CatalogueInspectorWidget.cpp', | |
|
110 | 'src/Catalogue/CatalogueTreeWidgetItem.cpp', | |||
|
111 | 'src/Catalogue/CatalogueEventsTableModel.cpp' | |||
107 | ] |
|
112 | ] | |
108 |
|
113 | |||
109 | gui_inc = include_directories(['include']) |
|
114 | gui_inc = include_directories(['include']) | |
110 |
|
115 | |||
111 | sciqlop_gui_lib = library('sciqlopgui', |
|
116 | sciqlop_gui_lib = library('sciqlopgui', | |
112 | gui_sources, |
|
117 | gui_sources, | |
113 | gui_moc_files, |
|
118 | gui_moc_files, | |
114 | include_directories : [gui_inc], |
|
119 | include_directories : [gui_inc], | |
115 | dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core], |
|
120 | dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep], | |
116 | install : true |
|
121 | install : true | |
117 | ) |
|
122 | ) | |
118 |
|
123 | |||
119 | sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib, |
|
124 | sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib, | |
120 | include_directories : gui_inc, |
|
125 | include_directories : gui_inc, | |
121 | dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core]) |
|
126 | dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep]) | |
122 |
|
127 |
@@ -1,29 +1,31 | |||||
1 | <RCC> |
|
1 | <RCC> | |
2 | <qresource prefix="/"> |
|
2 | <qresource prefix="/"> | |
3 | <file>icones/dataSourceComponent.png</file> |
|
3 | <file>icones/dataSourceComponent.png</file> | |
4 | <file>icones/dataSourceNode.png</file> |
|
4 | <file>icones/dataSourceNode.png</file> | |
5 | <file>icones/dataSourceProduct.png</file> |
|
5 | <file>icones/dataSourceProduct.png</file> | |
6 | <file>icones/dataSourceRoot.png</file> |
|
6 | <file>icones/dataSourceRoot.png</file> | |
7 | <file>icones/delete.png</file> |
|
7 | <file>icones/delete.png</file> | |
8 | <file>icones/down.png</file> |
|
8 | <file>icones/down.png</file> | |
9 | <file>icones/openInspector.png</file> |
|
9 | <file>icones/openInspector.png</file> | |
10 | <file>icones/next.png</file> |
|
10 | <file>icones/next.png</file> | |
11 | <file>icones/plot.png</file> |
|
11 | <file>icones/plot.png</file> | |
12 | <file>icones/previous.png</file> |
|
12 | <file>icones/previous.png</file> | |
13 | <file>icones/unplot.png</file> |
|
13 | <file>icones/unplot.png</file> | |
14 | <file>icones/up.png</file> |
|
14 | <file>icones/up.png</file> | |
15 | <file>icones/time.png</file> |
|
15 | <file>icones/time.png</file> | |
16 | <file>icones/zoom.png</file> |
|
16 | <file>icones/zoom.png</file> | |
17 | <file>icones/rectangle.png</file> |
|
17 | <file>icones/rectangle.png</file> | |
18 | <file>icones/drag.png</file> |
|
18 | <file>icones/drag.png</file> | |
19 | <file>icones/cursor.png</file> |
|
19 | <file>icones/cursor.png</file> | |
20 | <file>icones/pointer.png</file> |
|
20 | <file>icones/pointer.png</file> | |
21 | <file>icones/catalogue.png</file> |
|
21 | <file>icones/catalogue.png</file> | |
22 | <file>icones/add.png</file> |
|
22 | <file>icones/add.png</file> | |
23 | <file>icones/remove.png</file> |
|
23 | <file>icones/remove.png</file> | |
24 | <file>icones/chart.png</file> |
|
24 | <file>icones/chart.png</file> | |
25 | <file>icones/allEvents.png</file> |
|
25 | <file>icones/allEvents.png</file> | |
26 | <file>icones/trash.png</file> |
|
26 | <file>icones/trash.png</file> | |
27 | <file>icones/database.png</file> |
|
27 | <file>icones/database.png</file> | |
|
28 | <file>icones/save.png</file> | |||
|
29 | <file>icones/discard.png</file> | |||
28 | </qresource> |
|
30 | </qresource> | |
29 | </RCC> |
|
31 | </RCC> |
@@ -1,100 +1,291 | |||||
1 | #include "Catalogue/CatalogueEventsWidget.h" |
|
1 | #include "Catalogue/CatalogueEventsWidget.h" | |
2 | #include "ui_CatalogueEventsWidget.h" |
|
2 | #include "ui_CatalogueEventsWidget.h" | |
3 |
|
3 | |||
4 | #include <QtDebug> |
|
4 | #include <Catalogue/CatalogueController.h> | |
|
5 | #include <Catalogue/CatalogueEventsTableModel.h> | |||
|
6 | #include <CatalogueDao.h> | |||
|
7 | #include <DBCatalogue.h> | |||
|
8 | #include <SqpApplication.h> | |||
|
9 | #include <Visualization/VisualizationTabWidget.h> | |||
|
10 | #include <Visualization/VisualizationWidget.h> | |||
|
11 | #include <Visualization/VisualizationZoneWidget.h> | |||
|
12 | ||||
|
13 | #include <QDialog> | |||
|
14 | #include <QDialogButtonBox> | |||
|
15 | #include <QListWidget> | |||
|
16 | ||||
|
17 | Q_LOGGING_CATEGORY(LOG_CatalogueEventsWidget, "CatalogueEventsWidget") | |||
|
18 | ||||
|
19 | /// Format of the dates appearing in the label of a cursor | |||
|
20 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss"); | |||
5 |
|
21 | |||
6 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { |
|
22 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |
7 | void addEventItem(const QStringList &data, QTableWidget *tableWidget); |
|
|||
8 |
|
23 | |||
9 | enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn }; |
|
24 | CatalogueEventsTableModel *m_Model = nullptr; | |
10 | QStringList columnNames() { return QStringList{"Event", "TStart", "TEnd", "Tags", "Product"}; } |
|
25 | QStringList m_ZonesForTimeMode; | |
11 | }; |
|
26 | QString m_ZoneForGraphMode; | |
|
27 | ||||
|
28 | VisualizationWidget *m_VisualizationWidget = nullptr; | |||
|
29 | ||||
|
30 | void setEvents(const QVector<std::shared_ptr<DBEvent> > &events, QTableView *tableView) | |||
|
31 | { | |||
|
32 | tableView->setSortingEnabled(false); | |||
|
33 | m_Model->setEvents(events); | |||
|
34 | tableView->setSortingEnabled(true); | |||
|
35 | } | |||
|
36 | ||||
|
37 | void addEvent(const std::shared_ptr<DBEvent> &event, QTableView *tableView) | |||
|
38 | { | |||
|
39 | tableView->setSortingEnabled(false); | |||
|
40 | m_Model->addEvent(event); | |||
|
41 | tableView->setSortingEnabled(true); | |||
|
42 | } | |||
|
43 | ||||
|
44 | void removeEvent(const std::shared_ptr<DBEvent> &event, QTableView *tableView) | |||
|
45 | { | |||
|
46 | tableView->setSortingEnabled(false); | |||
|
47 | m_Model->removeEvent(event); | |||
|
48 | tableView->setSortingEnabled(true); | |||
|
49 | } | |||
|
50 | ||||
|
51 | QStringList getAvailableVisualizationZoneList() const | |||
|
52 | { | |||
|
53 | if (m_VisualizationWidget) { | |||
|
54 | if (auto tab = m_VisualizationWidget->currentTabWidget()) { | |||
|
55 | return tab->availableZoneWidgets(); | |||
|
56 | } | |||
|
57 | } | |||
|
58 | ||||
|
59 | return QStringList{}; | |||
|
60 | } | |||
|
61 | ||||
|
62 | QStringList selectZone(QWidget *parent, const QStringList &selectedZones, | |||
|
63 | bool allowMultiSelection, const QPoint &location) | |||
|
64 | { | |||
|
65 | auto availableZones = getAvailableVisualizationZoneList(); | |||
|
66 | if (availableZones.isEmpty()) { | |||
|
67 | return QStringList{}; | |||
|
68 | } | |||
|
69 | ||||
|
70 | QDialog d(parent, Qt::Tool); | |||
|
71 | d.setWindowTitle("Choose a zone"); | |||
|
72 | auto layout = new QVBoxLayout{&d}; | |||
|
73 | layout->setContentsMargins(0, 0, 0, 0); | |||
|
74 | auto listWidget = new QListWidget{&d}; | |||
|
75 | layout->addWidget(listWidget); | |||
|
76 | ||||
|
77 | QSet<QListWidgetItem *> checkedItems; | |||
|
78 | for (auto zone : availableZones) { | |||
|
79 | auto item = new QListWidgetItem{zone}; | |||
|
80 | item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); | |||
|
81 | if (selectedZones.contains(zone)) { | |||
|
82 | item->setCheckState(Qt::Checked); | |||
|
83 | checkedItems << item; | |||
|
84 | } | |||
|
85 | else { | |||
|
86 | item->setCheckState(Qt::Unchecked); | |||
|
87 | } | |||
|
88 | ||||
|
89 | listWidget->addItem(item); | |||
|
90 | } | |||
|
91 | ||||
|
92 | auto buttonBox = new QDialogButtonBox{QDialogButtonBox::Ok, &d}; | |||
|
93 | layout->addWidget(buttonBox); | |||
|
94 | ||||
|
95 | QObject::connect(buttonBox, &QDialogButtonBox::accepted, &d, &QDialog::accept); | |||
|
96 | QObject::connect(buttonBox, &QDialogButtonBox::rejected, &d, &QDialog::reject); | |||
|
97 | ||||
|
98 | QObject::connect(listWidget, &QListWidget::itemChanged, | |||
|
99 | [&checkedItems, allowMultiSelection, listWidget](auto item) { | |||
|
100 | if (item->checkState() == Qt::Checked) { | |||
|
101 | if (!allowMultiSelection) { | |||
|
102 | for (auto checkedItem : checkedItems) { | |||
|
103 | listWidget->blockSignals(true); | |||
|
104 | checkedItem->setCheckState(Qt::Unchecked); | |||
|
105 | listWidget->blockSignals(false); | |||
|
106 | } | |||
|
107 | ||||
|
108 | checkedItems.clear(); | |||
|
109 | } | |||
|
110 | checkedItems << item; | |||
|
111 | } | |||
|
112 | else { | |||
|
113 | checkedItems.remove(item); | |||
|
114 | } | |||
|
115 | }); | |||
|
116 | ||||
|
117 | QStringList result; | |||
|
118 | ||||
|
119 | d.setMinimumWidth(120); | |||
|
120 | d.resize(d.minimumSizeHint()); | |||
|
121 | d.move(location); | |||
|
122 | if (d.exec() == QDialog::Accepted) { | |||
|
123 | for (auto item : checkedItems) { | |||
|
124 | result += item->text(); | |||
|
125 | } | |||
|
126 | } | |||
|
127 | else { | |||
|
128 | result = selectedZones; | |||
|
129 | } | |||
|
130 | ||||
|
131 | return result; | |||
|
132 | } | |||
|
133 | ||||
|
134 | void updateForTimeMode(QTableView *tableView) | |||
|
135 | { | |||
|
136 | auto selectedRows = tableView->selectionModel()->selectedRows(); | |||
12 |
|
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 | } | |||
|
195 | }; | |||
13 |
|
196 | |||
14 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) |
|
197 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |
15 | : QWidget(parent), |
|
198 | : QWidget(parent), | |
16 | ui(new Ui::CatalogueEventsWidget), |
|
199 | ui(new Ui::CatalogueEventsWidget), | |
17 | impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()} |
|
200 | impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()} | |
18 | { |
|
201 | { | |
19 | ui->setupUi(this); |
|
202 | ui->setupUi(this); | |
20 |
|
203 | |||
|
204 | impl->m_Model = new CatalogueEventsTableModel{this}; | |||
|
205 | ui->tableView->setModel(impl->m_Model); | |||
|
206 | ||||
|
207 | ui->tableView->setSortingEnabled(true); | |||
|
208 | ui->tableView->setDragDropMode(QAbstractItemView::DragDrop); | |||
|
209 | ui->tableView->setDragEnabled(true); | |||
|
210 | ||||
21 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { |
|
211 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { | |
22 | if (checked) { |
|
212 | if (checked) { | |
23 | ui->btnChart->setChecked(false); |
|
213 | ui->btnChart->setChecked(false); | |
|
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); | |||
24 | } |
|
219 | } | |
25 | }); |
|
220 | }); | |
26 |
|
221 | |||
27 | connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) { |
|
222 | connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) { | |
28 | if (checked) { |
|
223 | if (checked) { | |
29 | ui->btnTime->setChecked(false); |
|
224 | ui->btnTime->setChecked(false); | |
|
225 | impl->m_ZoneForGraphMode | |||
|
226 | = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false, | |||
|
227 | this->mapToGlobal(ui->btnChart->frameGeometry().center())) | |||
|
228 | .value(0); | |||
|
229 | ||||
|
230 | impl->updateForGraphMode(ui->tableView); | |||
30 | } |
|
231 | } | |
31 | }); |
|
232 | }); | |
32 |
|
233 | |||
33 | connect(ui->tableWidget, &QTableWidget::cellClicked, [this](auto row, auto column) { |
|
234 | auto emitSelection = [this]() { | |
34 | auto event = ui->tableWidget->item(row, 0)->text(); |
|
235 | QVector<std::shared_ptr<DBEvent> > events; | |
35 | emit this->eventSelected(event); |
|
236 | for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) { | |
36 | }); |
|
237 | events << impl->m_Model->getEvent(rowIndex.row()); | |
|
238 | } | |||
37 |
|
239 | |||
38 | connect(ui->tableWidget, &QTableWidget::currentItemChanged, |
|
240 | emit this->eventsSelected(events); | |
39 | [this](auto current, auto previous) { |
|
241 | }; | |
40 | if (current && current->row() >= 0) { |
|
|||
41 | auto event = ui->tableWidget->item(current->row(), 0)->text(); |
|
|||
42 | emit this->eventSelected(event); |
|
|||
43 | } |
|
|||
44 | }); |
|
|||
45 |
|
242 | |||
46 |
connect(ui->table |
|
243 | connect(ui->tableView, &QTableView::clicked, emitSelection); | |
47 | auto selection = ui->tableWidget->selectedRanges(); |
|
244 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, emitSelection); | |
48 | auto isNotMultiSelection |
|
245 | ||
49 | = selection.isEmpty() || (selection.count() == 1 && selection.first().rowCount() == 1); |
|
246 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { | |
|
247 | auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1; | |||
50 | ui->btnChart->setEnabled(isNotMultiSelection); |
|
248 | ui->btnChart->setEnabled(isNotMultiSelection); | |
51 | 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 | } | |||
52 | }); |
|
257 | }); | |
53 |
|
258 | |||
54 | Q_ASSERT(impl->columnNames().count() == (int)CatalogueEventsWidgetPrivate::Column::NbColumn); |
|
259 | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); | |
55 | ui->tableWidget->setColumnCount((int)CatalogueEventsWidgetPrivate::Column::NbColumn); |
|
260 | ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); | |
56 |
ui->table |
|
261 | ui->tableView->horizontalHeader()->setSortIndicatorShown(true); | |
57 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); |
|
|||
58 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); |
|
|||
59 | ui->tableWidget->horizontalHeader()->setSortIndicatorShown(true); |
|
|||
60 | } |
|
262 | } | |
61 |
|
263 | |||
62 | CatalogueEventsWidget::~CatalogueEventsWidget() |
|
264 | CatalogueEventsWidget::~CatalogueEventsWidget() | |
63 | { |
|
265 | { | |
64 | delete ui; |
|
266 | delete ui; | |
65 | } |
|
267 | } | |
66 |
|
268 | |||
67 | void CatalogueEventsWidget::populateWithCatalogue(const QString &catalogue) |
|
269 | void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualization) | |
68 | { |
|
270 | { | |
69 | ui->tableWidget->clearContents(); |
|
271 | impl->m_VisualizationWidget = visualization; | |
70 | ui->tableWidget->setRowCount(0); |
|
|||
71 |
|
||||
72 | // TODO |
|
|||
73 | impl->addEventItem( |
|
|||
74 | {catalogue + " - Event 1", "12/12/2012 12:12", "12/12/2042 12:52", "cloud", "mfi/b_gse42"}, |
|
|||
75 | ui->tableWidget); |
|
|||
76 | impl->addEventItem( |
|
|||
77 | {catalogue + " - Event 2", "12/12/2012 12:10", "12/12/2042 12:42", "Acloud", "mfi/b_gse1"}, |
|
|||
78 | ui->tableWidget); |
|
|||
79 | impl->addEventItem( |
|
|||
80 | {catalogue + " - Event 3", "12/12/2012 12:22", "12/12/2042 12:12", "Gcloud", "mfi/b_gse2"}, |
|
|||
81 | ui->tableWidget); |
|
|||
82 | impl->addEventItem( |
|
|||
83 | {catalogue + " - Event 4", "12/12/2012 12:00", "12/12/2042 12:62", "Bcloud", "mfi/b_gse3"}, |
|
|||
84 | ui->tableWidget); |
|
|||
85 | } |
|
272 | } | |
86 |
|
273 | |||
87 | void CatalogueEventsWidget::CatalogueEventsWidgetPrivate::addEventItem(const QStringList &data, |
|
274 | void CatalogueEventsWidget::populateWithCatalogues( | |
88 | QTableWidget *tableWidget) |
|
275 | const QVector<std::shared_ptr<DBCatalogue> > &catalogues) | |
89 | { |
|
276 | { | |
90 | tableWidget->setSortingEnabled(false); |
|
277 | QSet<QUuid> eventIds; | |
91 | auto row = tableWidget->rowCount(); |
|
278 | QVector<std::shared_ptr<DBEvent> > events; | |
92 | tableWidget->setRowCount(row + 1); |
|
279 | ||
93 |
|
280 | for (auto catalogue : catalogues) { | ||
94 | for (auto i = 0; i < (int)Column::NbColumn; ++i) { |
|
281 | auto catalogueEvents = sqpApp->catalogueController().retrieveEventsFromCatalogue(catalogue); | |
95 | auto item = new QTableWidgetItem(data.value(i)); |
|
282 | for (auto event : catalogueEvents) { | |
96 | item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
283 | if (!eventIds.contains(event->getUniqId())) { | |
97 | tableWidget->setItem(row, i, item); |
|
284 | events << event; | |
|
285 | eventIds.insert(event->getUniqId()); | |||
|
286 | } | |||
|
287 | } | |||
98 | } |
|
288 | } | |
99 | tableWidget->setSortingEnabled(true); |
|
289 | ||
|
290 | impl->setEvents(events, ui->tableView); | |||
100 | } |
|
291 | } |
@@ -1,22 +1,61 | |||||
1 | #include "Catalogue/CatalogueExplorer.h" |
|
1 | #include "Catalogue/CatalogueExplorer.h" | |
2 | #include "ui_CatalogueExplorer.h" |
|
2 | #include "ui_CatalogueExplorer.h" | |
3 |
|
3 | |||
|
4 | #include <Visualization/VisualizationWidget.h> | |||
|
5 | ||||
|
6 | #include <DBCatalogue.h> | |||
|
7 | #include <DBEvent.h> | |||
|
8 | ||||
|
9 | struct CatalogueExplorer::CatalogueExplorerPrivate { | |||
|
10 | }; | |||
|
11 | ||||
4 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) |
|
12 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) | |
5 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), |
|
13 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), | |
6 | ui(new Ui::CatalogueExplorer) |
|
14 | ui(new Ui::CatalogueExplorer), | |
|
15 | impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>()} | |||
7 | { |
|
16 | { | |
8 | ui->setupUi(this); |
|
17 | ui->setupUi(this); | |
9 |
|
18 | |||
10 |
connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto |
|
19 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogues) { | |
11 | ui->inspector->setCatalogue(name); |
|
20 | if (catalogues.count() == 1) { | |
12 | ui->events->populateWithCatalogue(name); |
|
21 | ui->inspector->setCatalogue(catalogues.first()); | |
|
22 | } | |||
|
23 | else { | |||
|
24 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |||
|
25 | } | |||
|
26 | ||||
|
27 | ui->events->populateWithCatalogues(catalogues); | |||
13 | }); |
|
28 | }); | |
14 |
|
29 | |||
15 |
connect(ui-> |
|
30 | connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databases) { | |
16 | [this](auto name) { ui->inspector->setEvent(name); }); |
|
31 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |
|
32 | }); | |||
|
33 | ||||
|
34 | connect(ui->catalogues, &CatalogueSideBarWidget::trashSelected, | |||
|
35 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |||
|
36 | ||||
|
37 | connect(ui->catalogues, &CatalogueSideBarWidget::allEventsSelected, | |||
|
38 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |||
|
39 | ||||
|
40 | connect(ui->catalogues, &CatalogueSideBarWidget::selectionCleared, | |||
|
41 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |||
|
42 | ||||
|
43 | connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) { | |||
|
44 | if (events.count() == 1) { | |||
|
45 | ui->inspector->setEvent(events.first()); | |||
|
46 | } | |||
|
47 | else { | |||
|
48 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |||
|
49 | } | |||
|
50 | }); | |||
17 | } |
|
51 | } | |
18 |
|
52 | |||
19 | CatalogueExplorer::~CatalogueExplorer() |
|
53 | CatalogueExplorer::~CatalogueExplorer() | |
20 | { |
|
54 | { | |
21 | delete ui; |
|
55 | delete ui; | |
22 | } |
|
56 | } | |
|
57 | ||||
|
58 | void CatalogueExplorer::setVisualizationWidget(VisualizationWidget *visualization) | |||
|
59 | { | |||
|
60 | ui->events->setVisualizationWidget(visualization); | |||
|
61 | } |
@@ -1,36 +1,56 | |||||
1 | #include "Catalogue/CatalogueInspectorWidget.h" |
|
1 | #include "Catalogue/CatalogueInspectorWidget.h" | |
2 | #include "ui_CatalogueInspectorWidget.h" |
|
2 | #include "ui_CatalogueInspectorWidget.h" | |
3 |
|
3 | |||
|
4 | #include <Common/DateUtils.h> | |||
|
5 | #include <DBCatalogue.h> | |||
|
6 | #include <DBEvent.h> | |||
|
7 | #include <DBTag.h> | |||
|
8 | ||||
4 | CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent) |
|
9 | CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent) | |
5 | : QWidget(parent), ui(new Ui::CatalogueInspectorWidget) |
|
10 | : QWidget(parent), ui(new Ui::CatalogueInspectorWidget) | |
6 | { |
|
11 | { | |
7 | ui->setupUi(this); |
|
12 | ui->setupUi(this); | |
8 | showPage(Page::Empty); |
|
13 | showPage(Page::Empty); | |
9 | } |
|
14 | } | |
10 |
|
15 | |||
11 | CatalogueInspectorWidget::~CatalogueInspectorWidget() |
|
16 | CatalogueInspectorWidget::~CatalogueInspectorWidget() | |
12 | { |
|
17 | { | |
13 | delete ui; |
|
18 | delete ui; | |
14 | } |
|
19 | } | |
15 |
|
20 | |||
16 | void CatalogueInspectorWidget::showPage(CatalogueInspectorWidget::Page page) |
|
21 | void CatalogueInspectorWidget::showPage(CatalogueInspectorWidget::Page page) | |
17 | { |
|
22 | { | |
18 | ui->stackedWidget->setCurrentIndex(static_cast<int>(page)); |
|
23 | ui->stackedWidget->setCurrentIndex(static_cast<int>(page)); | |
19 | } |
|
24 | } | |
20 |
|
25 | |||
21 | CatalogueInspectorWidget::Page CatalogueInspectorWidget::currentPage() const |
|
26 | CatalogueInspectorWidget::Page CatalogueInspectorWidget::currentPage() const | |
22 | { |
|
27 | { | |
23 | return static_cast<Page>(ui->stackedWidget->currentIndex()); |
|
28 | return static_cast<Page>(ui->stackedWidget->currentIndex()); | |
24 | } |
|
29 | } | |
25 |
|
30 | |||
26 |
void CatalogueInspectorWidget::setEvent(const |
|
31 | void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event) | |
27 | { |
|
32 | { | |
28 | showPage(Page::EventProperties); |
|
33 | showPage(Page::EventProperties); | |
29 | ui->leEventName->setText(event); |
|
34 | ui->leEventName->setText(event->getName()); | |
|
35 | ui->leEventMission->setText(event->getMission()); | |||
|
36 | ui->leEventProduct->setText(event->getProduct()); | |||
|
37 | ||||
|
38 | QString tagList; | |||
|
39 | auto tags = event->getTags(); | |||
|
40 | for (auto tag : tags) { | |||
|
41 | tagList += tag.getName(); | |||
|
42 | tagList += ' '; | |||
|
43 | } | |||
|
44 | ||||
|
45 | ui->leEventTags->setText(tagList); | |||
|
46 | ||||
|
47 | ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event->getTStart())); | |||
|
48 | ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event->getTEnd())); | |||
30 | } |
|
49 | } | |
31 |
|
50 | |||
32 |
void CatalogueInspectorWidget::setCatalogue(const |
|
51 | void CatalogueInspectorWidget::setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue) | |
33 | { |
|
52 | { | |
34 | showPage(Page::CatalogueProperties); |
|
53 | showPage(Page::CatalogueProperties); | |
35 | ui->leCatalogueName->setText(catalogue); |
|
54 | ui->leCatalogueName->setText(catalogue->getName()); | |
|
55 | ui->leCatalogueAuthor->setText(catalogue->getAuthor()); | |||
36 | } |
|
56 | } |
@@ -1,101 +1,198 | |||||
1 | #include "Catalogue/CatalogueSideBarWidget.h" |
|
1 | #include "Catalogue/CatalogueSideBarWidget.h" | |
2 | #include "ui_CatalogueSideBarWidget.h" |
|
2 | #include "ui_CatalogueSideBarWidget.h" | |
|
3 | #include <SqpApplication.h> | |||
|
4 | ||||
|
5 | #include <Catalogue/CatalogueController.h> | |||
|
6 | #include <Catalogue/CatalogueTreeWidgetItem.h> | |||
|
7 | #include <CatalogueDao.h> | |||
|
8 | #include <ComparaisonPredicate.h> | |||
|
9 | #include <DBCatalogue.h> | |||
|
10 | ||||
|
11 | #include <QMenu> | |||
|
12 | ||||
3 |
|
13 | |||
4 | constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType; |
|
14 | constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType; | |
5 | constexpr auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1; |
|
15 | constexpr auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1; | |
6 | constexpr auto CATALOGUE_ITEM_TYPE = QTreeWidgetItem::UserType + 2; |
|
16 | constexpr auto CATALOGUE_ITEM_TYPE = QTreeWidgetItem::UserType + 2; | |
7 | constexpr auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3; |
|
17 | constexpr auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3; | |
8 |
|
18 | |||
9 |
|
19 | |||
10 | struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate { |
|
20 | struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate { | |
|
21 | ||||
11 | void configureTreeWidget(QTreeWidget *treeWidget); |
|
22 | void configureTreeWidget(QTreeWidget *treeWidget); | |
12 | QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget); |
|
23 | QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget); | |
13 |
|
|
24 | QTreeWidgetItem *getDatabaseItem(const QString &name, QTreeWidget *treeWidget); | |
|
25 | void addCatalogueItem(const std::shared_ptr<DBCatalogue> &catalogue, | |||
|
26 | QTreeWidgetItem *parentDatabaseItem); | |||
14 | }; |
|
27 | }; | |
15 |
|
28 | |||
16 | CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) |
|
29 | CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent) | |
17 | : QWidget(parent), |
|
30 | : QWidget(parent), | |
18 | ui(new Ui::CatalogueSideBarWidget), |
|
31 | ui(new Ui::CatalogueSideBarWidget), | |
19 | impl{spimpl::make_unique_impl<CatalogueSideBarWidgetPrivate>()} |
|
32 | impl{spimpl::make_unique_impl<CatalogueSideBarWidgetPrivate>()} | |
20 | { |
|
33 | { | |
21 | ui->setupUi(this); |
|
34 | ui->setupUi(this); | |
22 | impl->configureTreeWidget(ui->treeWidget); |
|
35 | impl->configureTreeWidget(ui->treeWidget); | |
23 |
|
36 | |||
24 | auto emitSelection = [this](auto item) { |
|
37 | ui->treeWidget->setColumnCount(2); | |
25 | switch (item->type()) { |
|
38 | ui->treeWidget->header()->setStretchLastSection(false); | |
26 | case CATALOGUE_ITEM_TYPE: |
|
39 | ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); | |
27 | emit this->catalogueSelected(item->text(0)); |
|
40 | ui->treeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch); | |
28 | break; |
|
41 | ||
29 | case ALL_EVENT_ITEM_TYPE: |
|
42 | auto emitSelection = [this]() { | |
30 | emit this->allEventsSelected(); |
|
43 | ||
31 | break; |
|
44 | auto selectedItems = ui->treeWidget->selectedItems(); | |
32 | case TRASH_ITEM_TYPE: |
|
45 | if (selectedItems.isEmpty()) { | |
33 |
|
|
46 | emit this->selectionCleared(); | |
34 | break; |
|
|||
35 | case DATABASE_ITEM_TYPE: |
|
|||
36 | default: |
|
|||
37 | break; |
|
|||
38 | } |
|
47 | } | |
|
48 | else { | |||
|
49 | QVector<std::shared_ptr<DBCatalogue> > catalogues; | |||
|
50 | QStringList databases; | |||
|
51 | int selectionType = selectedItems.first()->type(); | |||
|
52 | ||||
|
53 | for (auto item : ui->treeWidget->selectedItems()) { | |||
|
54 | if (item->type() == selectionType) { | |||
|
55 | switch (selectionType) { | |||
|
56 | case CATALOGUE_ITEM_TYPE: | |||
|
57 | catalogues.append( | |||
|
58 | static_cast<CatalogueTreeWidgetItem *>(item)->catalogue()); | |||
|
59 | break; | |||
|
60 | case DATABASE_ITEM_TYPE: | |||
|
61 | selectionType = DATABASE_ITEM_TYPE; | |||
|
62 | databases.append(item->text(0)); | |||
|
63 | case ALL_EVENT_ITEM_TYPE: // fallthrough | |||
|
64 | case TRASH_ITEM_TYPE: // fallthrough | |||
|
65 | default: | |||
|
66 | break; | |||
|
67 | } | |||
|
68 | } | |||
|
69 | else { | |||
|
70 | // Incoherent multi selection | |||
|
71 | selectionType = -1; | |||
|
72 | break; | |||
|
73 | } | |||
|
74 | } | |||
|
75 | ||||
|
76 | switch (selectionType) { | |||
|
77 | case CATALOGUE_ITEM_TYPE: | |||
|
78 | emit this->catalogueSelected(catalogues); | |||
|
79 | break; | |||
|
80 | case DATABASE_ITEM_TYPE: | |||
|
81 | emit this->databaseSelected(databases); | |||
|
82 | break; | |||
|
83 | case ALL_EVENT_ITEM_TYPE: | |||
|
84 | emit this->allEventsSelected(); | |||
|
85 | break; | |||
|
86 | case TRASH_ITEM_TYPE: | |||
|
87 | emit this->trashSelected(); | |||
|
88 | break; | |||
|
89 | default: | |||
|
90 | emit this->selectionCleared(); | |||
|
91 | break; | |||
|
92 | } | |||
|
93 | } | |||
|
94 | ||||
|
95 | ||||
39 | }; |
|
96 | }; | |
40 |
|
97 | |||
41 | connect(ui->treeWidget, &QTreeWidget::itemClicked, emitSelection); |
|
98 | connect(ui->treeWidget, &QTreeWidget::itemClicked, emitSelection); | |
42 | connect(ui->treeWidget, &QTreeWidget::currentItemChanged, emitSelection); |
|
99 | connect(ui->treeWidget, &QTreeWidget::currentItemChanged, emitSelection); | |
|
100 | ||||
|
101 | ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); | |||
|
102 | connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this, | |||
|
103 | &CatalogueSideBarWidget::onContextMenuRequested); | |||
43 | } |
|
104 | } | |
44 |
|
105 | |||
45 | CatalogueSideBarWidget::~CatalogueSideBarWidget() |
|
106 | CatalogueSideBarWidget::~CatalogueSideBarWidget() | |
46 | { |
|
107 | { | |
47 | delete ui; |
|
108 | delete ui; | |
48 | } |
|
109 | } | |
49 |
|
110 | |||
|
111 | void CatalogueSideBarWidget::onContextMenuRequested(const QPoint &pos) | |||
|
112 | { | |||
|
113 | QMenu menu{this}; | |||
|
114 | ||||
|
115 | auto currentItem = ui->treeWidget->currentItem(); | |||
|
116 | switch (currentItem->type()) { | |||
|
117 | case CATALOGUE_ITEM_TYPE: | |||
|
118 | menu.addAction("Rename", | |||
|
119 | [this, currentItem]() { ui->treeWidget->editItem(currentItem); }); | |||
|
120 | break; | |||
|
121 | case DATABASE_ITEM_TYPE: | |||
|
122 | break; | |||
|
123 | case ALL_EVENT_ITEM_TYPE: | |||
|
124 | break; | |||
|
125 | case TRASH_ITEM_TYPE: | |||
|
126 | menu.addAction("Empty Trash", []() { | |||
|
127 | // TODO | |||
|
128 | }); | |||
|
129 | break; | |||
|
130 | default: | |||
|
131 | break; | |||
|
132 | } | |||
|
133 | ||||
|
134 | if (!menu.isEmpty()) { | |||
|
135 | menu.exec(ui->treeWidget->mapToGlobal(pos)); | |||
|
136 | } | |||
|
137 | } | |||
|
138 | ||||
50 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget( |
|
139 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget( | |
51 | QTreeWidget *treeWidget) |
|
140 | QTreeWidget *treeWidget) | |
52 | { |
|
141 | { | |
53 |
auto allEventsItem = new QTreeWidgetItem |
|
142 | auto allEventsItem = new QTreeWidgetItem{{"All Events"}, ALL_EVENT_ITEM_TYPE}; | |
54 | allEventsItem->setIcon(0, QIcon(":/icones/allEvents.png")); |
|
143 | allEventsItem->setIcon(0, QIcon(":/icones/allEvents.png")); | |
55 | treeWidget->addTopLevelItem(allEventsItem); |
|
144 | treeWidget->addTopLevelItem(allEventsItem); | |
56 |
|
145 | |||
57 |
auto trashItem = new QTreeWidgetItem |
|
146 | auto trashItem = new QTreeWidgetItem{{"Trash"}, TRASH_ITEM_TYPE}; | |
58 | trashItem->setIcon(0, QIcon(":/icones/trash.png")); |
|
147 | trashItem->setIcon(0, QIcon(":/icones/trash.png")); | |
59 | treeWidget->addTopLevelItem(trashItem); |
|
148 | treeWidget->addTopLevelItem(trashItem); | |
60 |
|
149 | |||
61 |
auto separator = new QFrame |
|
150 | auto separator = new QFrame{treeWidget}; | |
62 | separator->setFrameShape(QFrame::HLine); |
|
151 | separator->setFrameShape(QFrame::HLine); | |
63 |
|
152 | auto separatorItem = new QTreeWidgetItem{}; | ||
64 | auto separatorItem = new QTreeWidgetItem(); |
|
|||
65 | separatorItem->setFlags(Qt::NoItemFlags); |
|
153 | separatorItem->setFlags(Qt::NoItemFlags); | |
66 | treeWidget->addTopLevelItem(separatorItem); |
|
154 | treeWidget->addTopLevelItem(separatorItem); | |
67 | treeWidget->setItemWidget(separatorItem, 0, separator); |
|
155 | treeWidget->setItemWidget(separatorItem, 0, separator); | |
68 |
|
156 | |||
69 | // Test |
|
157 | auto db = addDatabaseItem("Default", treeWidget); | |
70 | auto db = addDatabaseItem("Database 1", treeWidget); |
|
|||
71 | addCatalogueItem("Catalogue 1", db); |
|
|||
72 | addCatalogueItem("Catalogue 2", db); |
|
|||
73 | addCatalogueItem("Catalogue 3", db); |
|
|||
74 | addCatalogueItem("Catalogue 4", db); |
|
|||
75 |
|
158 | |||
76 | auto db2 = addDatabaseItem("Database 2", treeWidget); |
|
159 | auto catalogues = sqpApp->catalogueController().getCatalogues("Default"); | |
77 | addCatalogueItem("Catalogue A", db2); |
|
160 | for (auto catalogue : catalogues) { | |
78 |
addCatalogueItem( |
|
161 | addCatalogueItem(catalogue, db); | |
79 | addCatalogueItem("Catalogue C", db2); |
|
162 | } | |
80 |
|
163 | |||
81 | treeWidget->expandAll(); |
|
164 | treeWidget->expandAll(); | |
82 | } |
|
165 | } | |
83 |
|
166 | |||
84 | QTreeWidgetItem * |
|
167 | QTreeWidgetItem * | |
85 | CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addDatabaseItem(const QString &name, |
|
168 | CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addDatabaseItem(const QString &name, | |
86 | QTreeWidget *treeWidget) |
|
169 | QTreeWidget *treeWidget) | |
87 | { |
|
170 | { | |
88 |
auto databaseItem = new QTreeWidgetItem |
|
171 | auto databaseItem = new QTreeWidgetItem{{name}, DATABASE_ITEM_TYPE}; | |
89 |
databaseItem->setIcon(0, QIcon |
|
172 | databaseItem->setIcon(0, QIcon{":/icones/database.png"}); | |
90 | treeWidget->addTopLevelItem(databaseItem); |
|
173 | treeWidget->addTopLevelItem(databaseItem); | |
91 |
|
174 | |||
92 | return databaseItem; |
|
175 | return databaseItem; | |
93 | } |
|
176 | } | |
94 |
|
177 | |||
|
178 | QTreeWidgetItem * | |||
|
179 | CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::getDatabaseItem(const QString &name, | |||
|
180 | QTreeWidget *treeWidget) | |||
|
181 | { | |||
|
182 | for (auto i = 0; i < treeWidget->topLevelItemCount(); ++i) { | |||
|
183 | auto item = treeWidget->topLevelItem(i); | |||
|
184 | if (item->type() == DATABASE_ITEM_TYPE && item->text(0) == name) { | |||
|
185 | return item; | |||
|
186 | } | |||
|
187 | } | |||
|
188 | ||||
|
189 | return nullptr; | |||
|
190 | } | |||
|
191 | ||||
95 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem( |
|
192 | void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem( | |
96 |
const |
|
193 | const std::shared_ptr<DBCatalogue> &catalogue, QTreeWidgetItem *parentDatabaseItem) | |
97 | { |
|
194 | { | |
98 |
auto catalogueItem = new |
|
195 | auto catalogueItem = new CatalogueTreeWidgetItem{catalogue, CATALOGUE_ITEM_TYPE}; | |
99 |
catalogueItem->setIcon(0, QIcon |
|
196 | catalogueItem->setIcon(0, QIcon{":/icones/catalogue.png"}); | |
100 | parentDatabaseItem->addChild(catalogueItem); |
|
197 | parentDatabaseItem->addChild(catalogueItem); | |
101 | } |
|
198 | } |
@@ -1,212 +1,217 | |||||
1 | #include "SqpApplication.h" |
|
1 | #include "SqpApplication.h" | |
2 |
|
2 | |||
3 | #include <Actions/ActionsGuiController.h> |
|
3 | #include <Actions/ActionsGuiController.h> | |
4 | #include <Catalogue/CatalogueController.h> |
|
4 | #include <Catalogue/CatalogueController.h> | |
5 | #include <Data/IDataProvider.h> |
|
5 | #include <Data/IDataProvider.h> | |
6 | #include <DataSource/DataSourceController.h> |
|
6 | #include <DataSource/DataSourceController.h> | |
7 | #include <DragAndDrop/DragDropGuiController.h> |
|
7 | #include <DragAndDrop/DragDropGuiController.h> | |
8 | #include <Network/NetworkController.h> |
|
8 | #include <Network/NetworkController.h> | |
9 | #include <QThread> |
|
9 | #include <QThread> | |
10 | #include <Time/TimeController.h> |
|
10 | #include <Time/TimeController.h> | |
11 | #include <Variable/Variable.h> |
|
11 | #include <Variable/Variable.h> | |
12 | #include <Variable/VariableController.h> |
|
12 | #include <Variable/VariableController.h> | |
13 | #include <Variable/VariableModel.h> |
|
13 | #include <Variable/VariableModel.h> | |
14 | #include <Visualization/VisualizationController.h> |
|
14 | #include <Visualization/VisualizationController.h> | |
15 |
|
15 | |||
16 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
|
16 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | |
17 |
|
17 | |||
18 | class SqpApplication::SqpApplicationPrivate { |
|
18 | class SqpApplication::SqpApplicationPrivate { | |
19 | public: |
|
19 | public: | |
20 | SqpApplicationPrivate() |
|
20 | SqpApplicationPrivate() | |
21 | : m_DataSourceController{std::make_unique<DataSourceController>()}, |
|
21 | : m_DataSourceController{std::make_unique<DataSourceController>()}, | |
22 | m_VariableController{std::make_unique<VariableController>()}, |
|
22 | m_VariableController{std::make_unique<VariableController>()}, | |
23 | m_TimeController{std::make_unique<TimeController>()}, |
|
23 | m_TimeController{std::make_unique<TimeController>()}, | |
24 | m_NetworkController{std::make_unique<NetworkController>()}, |
|
24 | m_NetworkController{std::make_unique<NetworkController>()}, | |
25 | m_VisualizationController{std::make_unique<VisualizationController>()}, |
|
25 | m_VisualizationController{std::make_unique<VisualizationController>()}, | |
26 | m_DragDropGuiController{std::make_unique<DragDropGuiController>()}, |
|
26 | m_DragDropGuiController{std::make_unique<DragDropGuiController>()}, | |
27 | m_CatalogueController{std::make_unique<CatalogueController>()}, |
|
27 | m_CatalogueController{std::make_unique<CatalogueController>()}, | |
28 | m_ActionsGuiController{std::make_unique<ActionsGuiController>()}, |
|
28 | m_ActionsGuiController{std::make_unique<ActionsGuiController>()}, | |
29 | m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None), |
|
29 | m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None), | |
30 | m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor) |
|
30 | m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor) | |
31 | { |
|
31 | { | |
32 | // /////////////////////////////// // |
|
32 | // /////////////////////////////// // | |
33 | // Connections between controllers // |
|
33 | // Connections between controllers // | |
34 | // /////////////////////////////// // |
|
34 | // /////////////////////////////// // | |
35 |
|
35 | |||
36 | // VariableController <-> DataSourceController |
|
36 | // VariableController <-> DataSourceController | |
37 | connect(m_DataSourceController.get(), |
|
37 | connect(m_DataSourceController.get(), | |
38 | SIGNAL(variableCreationRequested(const QString &, const QVariantHash &, |
|
38 | SIGNAL(variableCreationRequested(const QString &, const QVariantHash &, | |
39 | std::shared_ptr<IDataProvider>)), |
|
39 | std::shared_ptr<IDataProvider>)), | |
40 | m_VariableController.get(), |
|
40 | m_VariableController.get(), | |
41 | SLOT(createVariable(const QString &, const QVariantHash &, |
|
41 | SLOT(createVariable(const QString &, const QVariantHash &, | |
42 | std::shared_ptr<IDataProvider>))); |
|
42 | std::shared_ptr<IDataProvider>))); | |
43 |
|
43 | |||
44 | connect(m_VariableController->variableModel(), &VariableModel::requestVariable, |
|
44 | connect(m_VariableController->variableModel(), &VariableModel::requestVariable, | |
45 | m_DataSourceController.get(), &DataSourceController::requestVariable); |
|
45 | m_DataSourceController.get(), &DataSourceController::requestVariable); | |
46 |
|
46 | |||
47 | // VariableController <-> VisualizationController |
|
47 | // VariableController <-> VisualizationController | |
48 | connect(m_VariableController.get(), |
|
48 | connect(m_VariableController.get(), | |
49 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), |
|
49 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | |
50 | m_VisualizationController.get(), |
|
50 | m_VisualizationController.get(), | |
51 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); |
|
51 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); | |
52 |
|
52 | |||
53 | connect(m_VariableController.get(), |
|
53 | connect(m_VariableController.get(), | |
54 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), |
|
54 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), | |
55 | m_VisualizationController.get(), |
|
55 | m_VisualizationController.get(), | |
56 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &))); |
|
56 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &))); | |
57 |
|
57 | |||
58 |
|
58 | |||
59 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
59 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | |
60 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); |
|
60 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); | |
61 | m_NetworkController->moveToThread(&m_NetworkControllerThread); |
|
61 | m_NetworkController->moveToThread(&m_NetworkControllerThread); | |
62 | m_NetworkControllerThread.setObjectName("NetworkControllerThread"); |
|
62 | m_NetworkControllerThread.setObjectName("NetworkControllerThread"); | |
63 | m_VariableController->moveToThread(&m_VariableControllerThread); |
|
63 | m_VariableController->moveToThread(&m_VariableControllerThread); | |
64 | m_VariableControllerThread.setObjectName("VariableControllerThread"); |
|
64 | m_VariableControllerThread.setObjectName("VariableControllerThread"); | |
65 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); |
|
65 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |
66 | m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); |
|
66 | m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); | |
67 | m_CatalogueController->moveToThread(&m_CatalogueControllerThread); |
|
67 | m_CatalogueController->moveToThread(&m_CatalogueControllerThread); | |
68 | m_CatalogueControllerThread.setObjectName("CatalogueControllerThread"); |
|
68 | m_CatalogueControllerThread.setObjectName("CatalogueControllerThread"); | |
69 |
|
69 | |||
70 |
|
70 | |||
71 | // Additionnal init |
|
71 | // Additionnal init | |
72 | m_VariableController->setTimeController(m_TimeController.get()); |
|
72 | m_VariableController->setTimeController(m_TimeController.get()); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | virtual ~SqpApplicationPrivate() |
|
75 | virtual ~SqpApplicationPrivate() | |
76 | { |
|
76 | { | |
77 | m_DataSourceControllerThread.quit(); |
|
77 | m_DataSourceControllerThread.quit(); | |
78 | m_DataSourceControllerThread.wait(); |
|
78 | m_DataSourceControllerThread.wait(); | |
79 |
|
79 | |||
80 | m_NetworkControllerThread.quit(); |
|
80 | m_NetworkControllerThread.quit(); | |
81 | m_NetworkControllerThread.wait(); |
|
81 | m_NetworkControllerThread.wait(); | |
82 |
|
82 | |||
83 | m_VariableControllerThread.quit(); |
|
83 | m_VariableControllerThread.quit(); | |
84 | m_VariableControllerThread.wait(); |
|
84 | m_VariableControllerThread.wait(); | |
85 |
|
85 | |||
86 | m_VisualizationControllerThread.quit(); |
|
86 | m_VisualizationControllerThread.quit(); | |
87 | m_VisualizationControllerThread.wait(); |
|
87 | m_VisualizationControllerThread.wait(); | |
88 |
|
88 | |||
89 | m_CatalogueControllerThread.quit(); |
|
89 | m_CatalogueControllerThread.quit(); | |
90 | m_CatalogueControllerThread.wait(); |
|
90 | m_CatalogueControllerThread.wait(); | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
93 | std::unique_ptr<DataSourceController> m_DataSourceController; | |
94 | std::unique_ptr<VariableController> m_VariableController; |
|
94 | std::unique_ptr<VariableController> m_VariableController; | |
95 | std::unique_ptr<TimeController> m_TimeController; |
|
95 | std::unique_ptr<TimeController> m_TimeController; | |
96 | std::unique_ptr<NetworkController> m_NetworkController; |
|
96 | std::unique_ptr<NetworkController> m_NetworkController; | |
97 | std::unique_ptr<VisualizationController> m_VisualizationController; |
|
97 | std::unique_ptr<VisualizationController> m_VisualizationController; | |
98 | std::unique_ptr<CatalogueController> m_CatalogueController; |
|
98 | std::unique_ptr<CatalogueController> m_CatalogueController; | |
99 |
|
99 | |||
100 | QThread m_DataSourceControllerThread; |
|
100 | QThread m_DataSourceControllerThread; | |
101 | QThread m_NetworkControllerThread; |
|
101 | QThread m_NetworkControllerThread; | |
102 | QThread m_VariableControllerThread; |
|
102 | QThread m_VariableControllerThread; | |
103 | QThread m_VisualizationControllerThread; |
|
103 | QThread m_VisualizationControllerThread; | |
104 | QThread m_CatalogueControllerThread; |
|
104 | QThread m_CatalogueControllerThread; | |
105 |
|
105 | |||
106 | std::unique_ptr<DragDropGuiController> m_DragDropGuiController; |
|
106 | std::unique_ptr<DragDropGuiController> m_DragDropGuiController; | |
107 | std::unique_ptr<ActionsGuiController> m_ActionsGuiController; |
|
107 | std::unique_ptr<ActionsGuiController> m_ActionsGuiController; | |
108 |
|
108 | |||
109 | SqpApplication::PlotsInteractionMode m_PlotInterractionMode; |
|
109 | SqpApplication::PlotsInteractionMode m_PlotInterractionMode; | |
110 | SqpApplication::PlotsCursorMode m_PlotCursorMode; |
|
110 | SqpApplication::PlotsCursorMode m_PlotCursorMode; | |
111 | }; |
|
111 | }; | |
112 |
|
112 | |||
113 |
|
113 | |||
114 | SqpApplication::SqpApplication(int &argc, char **argv) |
|
114 | SqpApplication::SqpApplication(int &argc, char **argv) | |
115 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} |
|
115 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} | |
116 | { |
|
116 | { | |
117 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); |
|
117 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); | |
118 |
|
118 | |||
119 | connect(&impl->m_DataSourceControllerThread, &QThread::started, |
|
119 | connect(&impl->m_DataSourceControllerThread, &QThread::started, | |
120 | impl->m_DataSourceController.get(), &DataSourceController::initialize); |
|
120 | impl->m_DataSourceController.get(), &DataSourceController::initialize); | |
121 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, |
|
121 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, | |
122 | impl->m_DataSourceController.get(), &DataSourceController::finalize); |
|
122 | impl->m_DataSourceController.get(), &DataSourceController::finalize); | |
123 |
|
123 | |||
124 | connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(), |
|
124 | connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(), | |
125 | &NetworkController::initialize); |
|
125 | &NetworkController::initialize); | |
126 | connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(), |
|
126 | connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(), | |
127 | &NetworkController::finalize); |
|
127 | &NetworkController::finalize); | |
128 |
|
128 | |||
129 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), |
|
129 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), | |
130 | &VariableController::initialize); |
|
130 | &VariableController::initialize); | |
131 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), |
|
131 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), | |
132 | &VariableController::finalize); |
|
132 | &VariableController::finalize); | |
133 |
|
133 | |||
134 | connect(&impl->m_VisualizationControllerThread, &QThread::started, |
|
134 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |
135 | impl->m_VisualizationController.get(), &VisualizationController::initialize); |
|
135 | impl->m_VisualizationController.get(), &VisualizationController::initialize); | |
136 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, |
|
136 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, | |
137 | impl->m_VisualizationController.get(), &VisualizationController::finalize); |
|
137 | impl->m_VisualizationController.get(), &VisualizationController::finalize); | |
138 |
|
138 | |||
139 | connect(&impl->m_CatalogueControllerThread, &QThread::started, |
|
139 | connect(&impl->m_CatalogueControllerThread, &QThread::started, | |
140 | impl->m_CatalogueController.get(), &CatalogueController::initialize); |
|
140 | impl->m_CatalogueController.get(), &CatalogueController::initialize); | |
141 | connect(&impl->m_CatalogueControllerThread, &QThread::finished, |
|
141 | connect(&impl->m_CatalogueControllerThread, &QThread::finished, | |
142 | impl->m_CatalogueController.get(), &CatalogueController::finalize); |
|
142 | impl->m_CatalogueController.get(), &CatalogueController::finalize); | |
143 |
|
143 | |||
144 | impl->m_DataSourceControllerThread.start(); |
|
144 | impl->m_DataSourceControllerThread.start(); | |
145 | impl->m_NetworkControllerThread.start(); |
|
145 | impl->m_NetworkControllerThread.start(); | |
146 | impl->m_VariableControllerThread.start(); |
|
146 | impl->m_VariableControllerThread.start(); | |
147 | impl->m_VisualizationControllerThread.start(); |
|
147 | impl->m_VisualizationControllerThread.start(); | |
148 | impl->m_CatalogueControllerThread.start(); |
|
148 | impl->m_CatalogueControllerThread.start(); | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | SqpApplication::~SqpApplication() |
|
151 | SqpApplication::~SqpApplication() | |
152 | { |
|
152 | { | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | void SqpApplication::initialize() |
|
155 | void SqpApplication::initialize() | |
156 | { |
|
156 | { | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | DataSourceController &SqpApplication::dataSourceController() noexcept |
|
159 | DataSourceController &SqpApplication::dataSourceController() noexcept | |
160 | { |
|
160 | { | |
161 | return *impl->m_DataSourceController; |
|
161 | return *impl->m_DataSourceController; | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | NetworkController &SqpApplication::networkController() noexcept |
|
164 | NetworkController &SqpApplication::networkController() noexcept | |
165 | { |
|
165 | { | |
166 | return *impl->m_NetworkController; |
|
166 | return *impl->m_NetworkController; | |
167 | } |
|
167 | } | |
168 |
|
168 | |||
169 | TimeController &SqpApplication::timeController() noexcept |
|
169 | TimeController &SqpApplication::timeController() noexcept | |
170 | { |
|
170 | { | |
171 | return *impl->m_TimeController; |
|
171 | return *impl->m_TimeController; | |
172 | } |
|
172 | } | |
173 |
|
173 | |||
174 | VariableController &SqpApplication::variableController() noexcept |
|
174 | VariableController &SqpApplication::variableController() noexcept | |
175 | { |
|
175 | { | |
176 | return *impl->m_VariableController; |
|
176 | return *impl->m_VariableController; | |
177 | } |
|
177 | } | |
178 |
|
178 | |||
179 | VisualizationController &SqpApplication::visualizationController() noexcept |
|
179 | VisualizationController &SqpApplication::visualizationController() noexcept | |
180 | { |
|
180 | { | |
181 | return *impl->m_VisualizationController; |
|
181 | return *impl->m_VisualizationController; | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
|
184 | CatalogueController &SqpApplication::catalogueController() noexcept | |||
|
185 | { | |||
|
186 | return *impl->m_CatalogueController; | |||
|
187 | } | |||
|
188 | ||||
184 | DragDropGuiController &SqpApplication::dragDropGuiController() noexcept |
|
189 | DragDropGuiController &SqpApplication::dragDropGuiController() noexcept | |
185 | { |
|
190 | { | |
186 | return *impl->m_DragDropGuiController; |
|
191 | return *impl->m_DragDropGuiController; | |
187 | } |
|
192 | } | |
188 |
|
193 | |||
189 | ActionsGuiController &SqpApplication::actionsGuiController() noexcept |
|
194 | ActionsGuiController &SqpApplication::actionsGuiController() noexcept | |
190 | { |
|
195 | { | |
191 | return *impl->m_ActionsGuiController; |
|
196 | return *impl->m_ActionsGuiController; | |
192 | } |
|
197 | } | |
193 |
|
198 | |||
194 | SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const |
|
199 | SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const | |
195 | { |
|
200 | { | |
196 | return impl->m_PlotInterractionMode; |
|
201 | return impl->m_PlotInterractionMode; | |
197 | } |
|
202 | } | |
198 |
|
203 | |||
199 | void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode) |
|
204 | void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode) | |
200 | { |
|
205 | { | |
201 | impl->m_PlotInterractionMode = mode; |
|
206 | impl->m_PlotInterractionMode = mode; | |
202 | } |
|
207 | } | |
203 |
|
208 | |||
204 | SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const |
|
209 | SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const | |
205 | { |
|
210 | { | |
206 | return impl->m_PlotCursorMode; |
|
211 | return impl->m_PlotCursorMode; | |
207 | } |
|
212 | } | |
208 |
|
213 | |||
209 | void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode) |
|
214 | void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode) | |
210 | { |
|
215 | { | |
211 | impl->m_PlotCursorMode = mode; |
|
216 | impl->m_PlotCursorMode = mode; | |
212 | } |
|
217 | } |
@@ -1,329 +1,354 | |||||
1 | #include "Visualization/VisualizationTabWidget.h" |
|
1 | #include "Visualization/VisualizationTabWidget.h" | |
2 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
2 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
3 | #include "ui_VisualizationTabWidget.h" |
|
3 | #include "ui_VisualizationTabWidget.h" | |
4 |
|
4 | |||
5 | #include "Visualization/VisualizationGraphWidget.h" |
|
5 | #include "Visualization/VisualizationGraphWidget.h" | |
6 | #include "Visualization/VisualizationZoneWidget.h" |
|
6 | #include "Visualization/VisualizationZoneWidget.h" | |
7 |
|
7 | |||
8 | #include "Visualization/MacScrollBarStyle.h" |
|
8 | #include "Visualization/MacScrollBarStyle.h" | |
9 |
|
9 | |||
10 | #include "Variable/VariableController.h" |
|
10 | #include "Variable/VariableController.h" | |
11 |
|
11 | |||
12 | #include "Common/MimeTypesDef.h" |
|
12 | #include "Common/MimeTypesDef.h" | |
13 |
|
13 | |||
14 | #include "DragAndDrop/DragDropGuiController.h" |
|
14 | #include "DragAndDrop/DragDropGuiController.h" | |
15 | #include "SqpApplication.h" |
|
15 | #include "SqpApplication.h" | |
16 |
|
16 | |||
17 | Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget") |
|
17 | Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget") | |
18 |
|
18 | |||
19 | namespace { |
|
19 | namespace { | |
20 |
|
20 | |||
21 | /// Generates a default name for a new zone, according to the number of zones already displayed in |
|
|||
22 | /// the tab |
|
|||
23 | QString defaultZoneName(const QLayout &layout) |
|
|||
24 | { |
|
|||
25 | auto count = 0; |
|
|||
26 | for (auto i = 0; i < layout.count(); ++i) { |
|
|||
27 | if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) { |
|
|||
28 | count++; |
|
|||
29 | } |
|
|||
30 | } |
|
|||
31 |
|
||||
32 | return QObject::tr("Zone %1").arg(count + 1); |
|
|||
33 | } |
|
|||
34 |
|
||||
35 | /** |
|
21 | /** | |
36 | * Applies a function to all zones of the tab represented by its layout |
|
22 | * Applies a function to all zones of the tab represented by its layout | |
37 | * @param layout the layout that contains zones |
|
23 | * @param layout the layout that contains zones | |
38 | * @param fun the function to apply to each zone |
|
24 | * @param fun the function to apply to each zone | |
39 | */ |
|
25 | */ | |
40 | template <typename Fun> |
|
26 | template <typename Fun> | |
41 | void processZones(QLayout &layout, Fun fun) |
|
27 | void processZones(QLayout &layout, Fun fun) | |
42 | { |
|
28 | { | |
43 | for (auto i = 0; i < layout.count(); ++i) { |
|
29 | for (auto i = 0; i < layout.count(); ++i) { | |
44 | if (auto item = layout.itemAt(i)) { |
|
30 | if (auto item = layout.itemAt(i)) { | |
45 | if (auto visualizationZoneWidget |
|
31 | if (auto visualizationZoneWidget | |
46 |
= |
|
32 | = qobject_cast<VisualizationZoneWidget *>(item->widget())) { | |
47 | fun(*visualizationZoneWidget); |
|
33 | fun(*visualizationZoneWidget); | |
48 | } |
|
34 | } | |
49 | } |
|
35 | } | |
50 | } |
|
36 | } | |
51 | } |
|
37 | } | |
52 |
|
38 | |||
|
39 | /// Generates a default name for a new zone, according to the number of zones already displayed in | |||
|
40 | /// the tab | |||
|
41 | QString defaultZoneName(QLayout &layout) | |||
|
42 | { | |||
|
43 | QSet<QString> existingNames; | |||
|
44 | processZones(layout, | |||
|
45 | [&existingNames](auto &zoneWidget) { existingNames.insert(zoneWidget.name()); }); | |||
|
46 | ||||
|
47 | int zoneNum = 1; | |||
|
48 | QString name; | |||
|
49 | do { | |||
|
50 | name = QObject::tr("Zone ").append(QString::number(zoneNum)); | |||
|
51 | ++zoneNum; | |||
|
52 | } while (existingNames.contains(name)); | |||
|
53 | ||||
|
54 | return name; | |||
|
55 | } | |||
|
56 | ||||
53 | } // namespace |
|
57 | } // namespace | |
54 |
|
58 | |||
55 | struct VisualizationTabWidget::VisualizationTabWidgetPrivate { |
|
59 | struct VisualizationTabWidget::VisualizationTabWidgetPrivate { | |
56 | explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {} |
|
60 | explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {} | |
57 |
|
61 | |||
58 | QString m_Name; |
|
62 | QString m_Name; | |
59 |
|
63 | |||
60 | #ifdef Q_OS_MAC |
|
64 | #ifdef Q_OS_MAC | |
61 | std::unique_ptr<MacScrollBarStyle> m_MacScrollBarStyle = std::make_unique<MacScrollBarStyle>(); |
|
65 | std::unique_ptr<MacScrollBarStyle> m_MacScrollBarStyle = std::make_unique<MacScrollBarStyle>(); | |
62 | #endif |
|
66 | #endif | |
63 |
|
67 | |||
64 | void dropGraph(int index, VisualizationTabWidget *tabWidget); |
|
68 | void dropGraph(int index, VisualizationTabWidget *tabWidget); | |
65 | void dropZone(int index, VisualizationTabWidget *tabWidget); |
|
69 | void dropZone(int index, VisualizationTabWidget *tabWidget); | |
66 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, |
|
70 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, | |
67 | VisualizationTabWidget *tabWidget); |
|
71 | VisualizationTabWidget *tabWidget); | |
68 | }; |
|
72 | }; | |
69 |
|
73 | |||
70 | VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent) |
|
74 | VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent) | |
71 | : QWidget{parent}, |
|
75 | : QWidget{parent}, | |
72 | ui{new Ui::VisualizationTabWidget}, |
|
76 | ui{new Ui::VisualizationTabWidget}, | |
73 | impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)} |
|
77 | impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)} | |
74 | { |
|
78 | { | |
75 | ui->setupUi(this); |
|
79 | ui->setupUi(this); | |
76 |
|
80 | |||
77 | #ifdef Q_OS_MAC |
|
81 | #ifdef Q_OS_MAC | |
78 | impl->m_MacScrollBarStyle->selfInstallOn(ui->scrollArea, true); |
|
82 | impl->m_MacScrollBarStyle->selfInstallOn(ui->scrollArea, true); | |
79 | #endif |
|
83 | #endif | |
80 |
|
84 | |||
81 | ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Zone, "Zone"); |
|
85 | ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Zone, "Zone"); | |
82 | ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12); |
|
86 | ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12); | |
83 | ui->dragDropContainer->layout()->setSpacing(0); |
|
87 | ui->dragDropContainer->layout()->setSpacing(0); | |
84 | ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH, |
|
88 | ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH, | |
85 | VisualizationDragDropContainer::DropBehavior::Inserted); |
|
89 | VisualizationDragDropContainer::DropBehavior::Inserted); | |
86 | ui->dragDropContainer->setMimeType(MIME_TYPE_ZONE, |
|
90 | ui->dragDropContainer->setMimeType(MIME_TYPE_ZONE, | |
87 | VisualizationDragDropContainer::DropBehavior::Inserted); |
|
91 | VisualizationDragDropContainer::DropBehavior::Inserted); | |
88 | ui->dragDropContainer->setMimeType(MIME_TYPE_VARIABLE_LIST, |
|
92 | ui->dragDropContainer->setMimeType(MIME_TYPE_VARIABLE_LIST, | |
89 | VisualizationDragDropContainer::DropBehavior::Inserted); |
|
93 | VisualizationDragDropContainer::DropBehavior::Inserted); | |
90 |
|
94 | |||
91 | ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) { |
|
95 | ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) { | |
92 | return sqpApp->dragDropGuiController().checkMimeDataForVisualization(mimeData, |
|
96 | return sqpApp->dragDropGuiController().checkMimeDataForVisualization(mimeData, | |
93 | ui->dragDropContainer); |
|
97 | ui->dragDropContainer); | |
94 | }); |
|
98 | }); | |
95 |
|
99 | |||
96 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this, |
|
100 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this, | |
97 | &VisualizationTabWidget::dropMimeData); |
|
101 | &VisualizationTabWidget::dropMimeData); | |
98 |
|
102 | |||
99 | sqpApp->dragDropGuiController().addDragDropScrollArea(ui->scrollArea); |
|
103 | sqpApp->dragDropGuiController().addDragDropScrollArea(ui->scrollArea); | |
100 |
|
104 | |||
101 | // Widget is deleted when closed |
|
105 | // Widget is deleted when closed | |
102 | setAttribute(Qt::WA_DeleteOnClose); |
|
106 | setAttribute(Qt::WA_DeleteOnClose); | |
103 | } |
|
107 | } | |
104 |
|
108 | |||
105 | VisualizationTabWidget::~VisualizationTabWidget() |
|
109 | VisualizationTabWidget::~VisualizationTabWidget() | |
106 | { |
|
110 | { | |
107 | sqpApp->dragDropGuiController().removeDragDropScrollArea(ui->scrollArea); |
|
111 | sqpApp->dragDropGuiController().removeDragDropScrollArea(ui->scrollArea); | |
108 | delete ui; |
|
112 | delete ui; | |
109 | } |
|
113 | } | |
110 |
|
114 | |||
111 | void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget) |
|
115 | void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget) | |
112 | { |
|
116 | { | |
113 | ui->dragDropContainer->addDragWidget(zoneWidget); |
|
117 | ui->dragDropContainer->addDragWidget(zoneWidget); | |
114 | } |
|
118 | } | |
115 |
|
119 | |||
116 | void VisualizationTabWidget::insertZone(int index, VisualizationZoneWidget *zoneWidget) |
|
120 | void VisualizationTabWidget::insertZone(int index, VisualizationZoneWidget *zoneWidget) | |
117 | { |
|
121 | { | |
118 | ui->dragDropContainer->insertDragWidget(index, zoneWidget); |
|
122 | ui->dragDropContainer->insertDragWidget(index, zoneWidget); | |
119 | } |
|
123 | } | |
120 |
|
124 | |||
|
125 | QStringList VisualizationTabWidget::availableZoneWidgets() const | |||
|
126 | { | |||
|
127 | QStringList zones; | |||
|
128 | processZones(tabLayout(), | |||
|
129 | [&zones](VisualizationZoneWidget &zoneWidget) { zones << zoneWidget.name(); }); | |||
|
130 | ||||
|
131 | return zones; | |||
|
132 | } | |||
|
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 | ||||
121 | VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable) |
|
146 | VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable) | |
122 | { |
|
147 | { | |
123 | return createZone({variable}, -1); |
|
148 | return createZone({variable}, -1); | |
124 | } |
|
149 | } | |
125 |
|
150 | |||
126 | VisualizationZoneWidget * |
|
151 | VisualizationZoneWidget * | |
127 | VisualizationTabWidget::createZone(const QList<std::shared_ptr<Variable> > &variables, int index) |
|
152 | VisualizationTabWidget::createZone(const QList<std::shared_ptr<Variable> > &variables, int index) | |
128 | { |
|
153 | { | |
129 | auto zoneWidget = createEmptyZone(index); |
|
154 | auto zoneWidget = createEmptyZone(index); | |
130 |
|
155 | |||
131 | // Creates a new graph into the zone |
|
156 | // Creates a new graph into the zone | |
132 | zoneWidget->createGraph(variables, index); |
|
157 | zoneWidget->createGraph(variables, index); | |
133 |
|
158 | |||
134 | return zoneWidget; |
|
159 | return zoneWidget; | |
135 | } |
|
160 | } | |
136 |
|
161 | |||
137 | VisualizationZoneWidget *VisualizationTabWidget::createEmptyZone(int index) |
|
162 | VisualizationZoneWidget *VisualizationTabWidget::createEmptyZone(int index) | |
138 | { |
|
163 | { | |
139 | auto zoneWidget |
|
164 | auto zoneWidget | |
140 | = new VisualizationZoneWidget{defaultZoneName(*ui->dragDropContainer->layout()), this}; |
|
165 | = new VisualizationZoneWidget{defaultZoneName(*ui->dragDropContainer->layout()), this}; | |
141 | this->insertZone(index, zoneWidget); |
|
166 | this->insertZone(index, zoneWidget); | |
142 |
|
167 | |||
143 | return zoneWidget; |
|
168 | return zoneWidget; | |
144 | } |
|
169 | } | |
145 |
|
170 | |||
146 | void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
171 | void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor) | |
147 | { |
|
172 | { | |
148 | if (visitor) { |
|
173 | if (visitor) { | |
149 | visitor->visitEnter(this); |
|
174 | visitor->visitEnter(this); | |
150 |
|
175 | |||
151 | // Apply visitor to zone children: widgets different from zones are not visited (no action) |
|
176 | // Apply visitor to zone children: widgets different from zones are not visited (no action) | |
152 | processZones(tabLayout(), [visitor](VisualizationZoneWidget &zoneWidget) { |
|
177 | processZones(tabLayout(), [visitor](VisualizationZoneWidget &zoneWidget) { | |
153 | zoneWidget.accept(visitor); |
|
178 | zoneWidget.accept(visitor); | |
154 | }); |
|
179 | }); | |
155 |
|
180 | |||
156 | visitor->visitLeave(this); |
|
181 | visitor->visitLeave(this); | |
157 | } |
|
182 | } | |
158 | else { |
|
183 | else { | |
159 | qCCritical(LOG_VisualizationTabWidget()) << tr("Can't visit widget : the visitor is null"); |
|
184 | qCCritical(LOG_VisualizationTabWidget()) << tr("Can't visit widget : the visitor is null"); | |
160 | } |
|
185 | } | |
161 | } |
|
186 | } | |
162 |
|
187 | |||
163 | bool VisualizationTabWidget::canDrop(const Variable &variable) const |
|
188 | bool VisualizationTabWidget::canDrop(const Variable &variable) const | |
164 | { |
|
189 | { | |
165 | // A tab can always accomodate a variable |
|
190 | // A tab can always accomodate a variable | |
166 | Q_UNUSED(variable); |
|
191 | Q_UNUSED(variable); | |
167 | return true; |
|
192 | return true; | |
168 | } |
|
193 | } | |
169 |
|
194 | |||
170 | bool VisualizationTabWidget::contains(const Variable &variable) const |
|
195 | bool VisualizationTabWidget::contains(const Variable &variable) const | |
171 | { |
|
196 | { | |
172 | Q_UNUSED(variable); |
|
197 | Q_UNUSED(variable); | |
173 | return false; |
|
198 | return false; | |
174 | } |
|
199 | } | |
175 |
|
200 | |||
176 | QString VisualizationTabWidget::name() const |
|
201 | QString VisualizationTabWidget::name() const | |
177 | { |
|
202 | { | |
178 | return impl->m_Name; |
|
203 | return impl->m_Name; | |
179 | } |
|
204 | } | |
180 |
|
205 | |||
181 | void VisualizationTabWidget::closeEvent(QCloseEvent *event) |
|
206 | void VisualizationTabWidget::closeEvent(QCloseEvent *event) | |
182 | { |
|
207 | { | |
183 | // Closes zones in the tab |
|
208 | // Closes zones in the tab | |
184 | processZones(tabLayout(), [](VisualizationZoneWidget &zoneWidget) { zoneWidget.close(); }); |
|
209 | processZones(tabLayout(), [](VisualizationZoneWidget &zoneWidget) { zoneWidget.close(); }); | |
185 |
|
210 | |||
186 | QWidget::closeEvent(event); |
|
211 | QWidget::closeEvent(event); | |
187 | } |
|
212 | } | |
188 |
|
213 | |||
189 | QLayout &VisualizationTabWidget::tabLayout() const noexcept |
|
214 | QLayout &VisualizationTabWidget::tabLayout() const noexcept | |
190 | { |
|
215 | { | |
191 | return *ui->dragDropContainer->layout(); |
|
216 | return *ui->dragDropContainer->layout(); | |
192 | } |
|
217 | } | |
193 |
|
218 | |||
194 | void VisualizationTabWidget::dropMimeData(int index, const QMimeData *mimeData) |
|
219 | void VisualizationTabWidget::dropMimeData(int index, const QMimeData *mimeData) | |
195 | { |
|
220 | { | |
196 | if (mimeData->hasFormat(MIME_TYPE_GRAPH)) { |
|
221 | if (mimeData->hasFormat(MIME_TYPE_GRAPH)) { | |
197 | impl->dropGraph(index, this); |
|
222 | impl->dropGraph(index, this); | |
198 | } |
|
223 | } | |
199 | else if (mimeData->hasFormat(MIME_TYPE_ZONE)) { |
|
224 | else if (mimeData->hasFormat(MIME_TYPE_ZONE)) { | |
200 | impl->dropZone(index, this); |
|
225 | impl->dropZone(index, this); | |
201 | } |
|
226 | } | |
202 | else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { |
|
227 | else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { | |
203 | auto variables = sqpApp->variableController().variablesForMimeData( |
|
228 | auto variables = sqpApp->variableController().variablesForMimeData( | |
204 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); |
|
229 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); | |
205 | impl->dropVariables(variables, index, this); |
|
230 | impl->dropVariables(variables, index, this); | |
206 | } |
|
231 | } | |
207 | else { |
|
232 | else { | |
208 | qCWarning(LOG_VisualizationZoneWidget()) |
|
233 | qCWarning(LOG_VisualizationZoneWidget()) | |
209 | << tr("VisualizationTabWidget::dropMimeData, unknown MIME data received."); |
|
234 | << tr("VisualizationTabWidget::dropMimeData, unknown MIME data received."); | |
210 | } |
|
235 | } | |
211 | } |
|
236 | } | |
212 |
|
237 | |||
213 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph( |
|
238 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph( | |
214 | int index, VisualizationTabWidget *tabWidget) |
|
239 | int index, VisualizationTabWidget *tabWidget) | |
215 | { |
|
240 | { | |
216 | auto &helper = sqpApp->dragDropGuiController(); |
|
241 | auto &helper = sqpApp->dragDropGuiController(); | |
217 |
|
242 | |||
218 | auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget()); |
|
243 | auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget()); | |
219 | if (!graphWidget) { |
|
244 | if (!graphWidget) { | |
220 | qCWarning(LOG_VisualizationZoneWidget()) |
|
245 | qCWarning(LOG_VisualizationZoneWidget()) | |
221 | << tr("VisualizationTabWidget::dropGraph, drop aborted, the dropped graph is not " |
|
246 | << tr("VisualizationTabWidget::dropGraph, drop aborted, the dropped graph is not " | |
222 | "found or invalid."); |
|
247 | "found or invalid."); | |
223 | Q_ASSERT(false); |
|
248 | Q_ASSERT(false); | |
224 | return; |
|
249 | return; | |
225 | } |
|
250 | } | |
226 |
|
251 | |||
227 | auto parentDragDropContainer |
|
252 | auto parentDragDropContainer | |
228 | = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget()); |
|
253 | = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget()); | |
229 | if (!parentDragDropContainer) { |
|
254 | if (!parentDragDropContainer) { | |
230 | qCWarning(LOG_VisualizationZoneWidget()) |
|
255 | qCWarning(LOG_VisualizationZoneWidget()) | |
231 | << tr("VisualizationTabWidget::dropGraph, drop aborted, the parent container of " |
|
256 | << tr("VisualizationTabWidget::dropGraph, drop aborted, the parent container of " | |
232 | "the dropped graph is not found."); |
|
257 | "the dropped graph is not found."); | |
233 | Q_ASSERT(false); |
|
258 | Q_ASSERT(false); | |
234 | return; |
|
259 | return; | |
235 | } |
|
260 | } | |
236 |
|
261 | |||
237 | auto nbGraph = parentDragDropContainer->countDragWidget(); |
|
262 | auto nbGraph = parentDragDropContainer->countDragWidget(); | |
238 |
|
263 | |||
239 | const auto &variables = graphWidget->variables(); |
|
264 | const auto &variables = graphWidget->variables(); | |
240 |
|
265 | |||
241 | if (!variables.isEmpty()) { |
|
266 | if (!variables.isEmpty()) { | |
242 | // Abort the requests for the variables (if any) |
|
267 | // Abort the requests for the variables (if any) | |
243 | // Commented, because it's not sure if it's needed or not |
|
268 | // Commented, because it's not sure if it's needed or not | |
244 | // for (const auto& var : variables) |
|
269 | // for (const auto& var : variables) | |
245 | //{ |
|
270 | //{ | |
246 | // sqpApp->variableController().onAbortProgressRequested(var); |
|
271 | // sqpApp->variableController().onAbortProgressRequested(var); | |
247 | //} |
|
272 | //} | |
248 |
|
273 | |||
249 | if (nbGraph == 1) { |
|
274 | if (nbGraph == 1) { | |
250 | // This is the only graph in the previous zone, close the zone |
|
275 | // This is the only graph in the previous zone, close the zone | |
251 | helper.delayedCloseWidget(graphWidget->parentZoneWidget()); |
|
276 | helper.delayedCloseWidget(graphWidget->parentZoneWidget()); | |
252 | } |
|
277 | } | |
253 | else { |
|
278 | else { | |
254 | // Close the graph |
|
279 | // Close the graph | |
255 | helper.delayedCloseWidget(graphWidget); |
|
280 | helper.delayedCloseWidget(graphWidget); | |
256 | } |
|
281 | } | |
257 |
|
282 | |||
258 | auto zoneWidget = tabWidget->createZone(variables, index); |
|
283 | auto zoneWidget = tabWidget->createZone(variables, index); | |
259 | auto firstGraph = zoneWidget->firstGraph(); |
|
284 | auto firstGraph = zoneWidget->firstGraph(); | |
260 | if (firstGraph) { |
|
285 | if (firstGraph) { | |
261 | firstGraph->addSelectionZones(graphWidget->selectionZoneRanges()); |
|
286 | firstGraph->addSelectionZones(graphWidget->selectionZoneRanges()); | |
262 | } |
|
287 | } | |
263 | else { |
|
288 | else { | |
264 | qCWarning(LOG_VisualizationZoneWidget()) |
|
289 | qCWarning(LOG_VisualizationZoneWidget()) | |
265 | << tr("VisualizationTabWidget::dropGraph, no graph added in the widget."); |
|
290 | << tr("VisualizationTabWidget::dropGraph, no graph added in the widget."); | |
266 | Q_ASSERT(false); |
|
291 | Q_ASSERT(false); | |
267 | } |
|
292 | } | |
268 | } |
|
293 | } | |
269 | else { |
|
294 | else { | |
270 | // The graph is empty, create an empty zone and move the graph inside |
|
295 | // The graph is empty, create an empty zone and move the graph inside | |
271 |
|
296 | |||
272 | auto parentZoneWidget = graphWidget->parentZoneWidget(); |
|
297 | auto parentZoneWidget = graphWidget->parentZoneWidget(); | |
273 |
|
298 | |||
274 | parentDragDropContainer->layout()->removeWidget(graphWidget); |
|
299 | parentDragDropContainer->layout()->removeWidget(graphWidget); | |
275 |
|
300 | |||
276 | auto zoneWidget = tabWidget->createEmptyZone(index); |
|
301 | auto zoneWidget = tabWidget->createEmptyZone(index); | |
277 | zoneWidget->addGraph(graphWidget); |
|
302 | zoneWidget->addGraph(graphWidget); | |
278 |
|
303 | |||
279 | // Close the old zone if it was the only graph inside |
|
304 | // Close the old zone if it was the only graph inside | |
280 | if (nbGraph == 1) { |
|
305 | if (nbGraph == 1) { | |
281 | helper.delayedCloseWidget(parentZoneWidget); |
|
306 | helper.delayedCloseWidget(parentZoneWidget); | |
282 | } |
|
307 | } | |
283 | } |
|
308 | } | |
284 | } |
|
309 | } | |
285 |
|
310 | |||
286 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropZone( |
|
311 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropZone( | |
287 | int index, VisualizationTabWidget *tabWidget) |
|
312 | int index, VisualizationTabWidget *tabWidget) | |
288 | { |
|
313 | { | |
289 | auto &helper = sqpApp->dragDropGuiController(); |
|
314 | auto &helper = sqpApp->dragDropGuiController(); | |
290 |
|
315 | |||
291 | auto zoneWidget = qobject_cast<VisualizationZoneWidget *>(helper.getCurrentDragWidget()); |
|
316 | auto zoneWidget = qobject_cast<VisualizationZoneWidget *>(helper.getCurrentDragWidget()); | |
292 | if (!zoneWidget) { |
|
317 | if (!zoneWidget) { | |
293 | qCWarning(LOG_VisualizationZoneWidget()) |
|
318 | qCWarning(LOG_VisualizationZoneWidget()) | |
294 | << tr("VisualizationTabWidget::dropZone, drop aborted, the dropped zone is not " |
|
319 | << tr("VisualizationTabWidget::dropZone, drop aborted, the dropped zone is not " | |
295 | "found or invalid."); |
|
320 | "found or invalid."); | |
296 | Q_ASSERT(false); |
|
321 | Q_ASSERT(false); | |
297 | return; |
|
322 | return; | |
298 | } |
|
323 | } | |
299 |
|
324 | |||
300 | auto parentDragDropContainer |
|
325 | auto parentDragDropContainer | |
301 | = qobject_cast<VisualizationDragDropContainer *>(zoneWidget->parentWidget()); |
|
326 | = qobject_cast<VisualizationDragDropContainer *>(zoneWidget->parentWidget()); | |
302 | if (!parentDragDropContainer) { |
|
327 | if (!parentDragDropContainer) { | |
303 | qCWarning(LOG_VisualizationZoneWidget()) |
|
328 | qCWarning(LOG_VisualizationZoneWidget()) | |
304 | << tr("VisualizationTabWidget::dropZone, drop aborted, the parent container of " |
|
329 | << tr("VisualizationTabWidget::dropZone, drop aborted, the parent container of " | |
305 | "the dropped zone is not found."); |
|
330 | "the dropped zone is not found."); | |
306 | Q_ASSERT(false); |
|
331 | Q_ASSERT(false); | |
307 | return; |
|
332 | return; | |
308 | } |
|
333 | } | |
309 |
|
334 | |||
310 | // Simple move of the zone, no variable operation associated |
|
335 | // Simple move of the zone, no variable operation associated | |
311 | parentDragDropContainer->layout()->removeWidget(zoneWidget); |
|
336 | parentDragDropContainer->layout()->removeWidget(zoneWidget); | |
312 | tabWidget->ui->dragDropContainer->insertDragWidget(index, zoneWidget); |
|
337 | tabWidget->ui->dragDropContainer->insertDragWidget(index, zoneWidget); | |
313 | } |
|
338 | } | |
314 |
|
339 | |||
315 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropVariables( |
|
340 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropVariables( | |
316 | const QList<std::shared_ptr<Variable> > &variables, int index, |
|
341 | const QList<std::shared_ptr<Variable> > &variables, int index, | |
317 | VisualizationTabWidget *tabWidget) |
|
342 | VisualizationTabWidget *tabWidget) | |
318 | { |
|
343 | { | |
319 | // Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and |
|
344 | // Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and | |
320 | // compatible variable here |
|
345 | // compatible variable here | |
321 | if (variables.count() > 1) { |
|
346 | if (variables.count() > 1) { | |
322 | qCWarning(LOG_VisualizationZoneWidget()) |
|
347 | qCWarning(LOG_VisualizationZoneWidget()) | |
323 | << tr("VisualizationTabWidget::dropVariables, dropping multiple variables, operation " |
|
348 | << tr("VisualizationTabWidget::dropVariables, dropping multiple variables, operation " | |
324 | "aborted."); |
|
349 | "aborted."); | |
325 | return; |
|
350 | return; | |
326 | } |
|
351 | } | |
327 |
|
352 | |||
328 | tabWidget->createZone(variables, index); |
|
353 | tabWidget->createZone(variables, index); | |
329 | } |
|
354 | } |
@@ -1,215 +1,224 | |||||
1 | #include "Visualization/VisualizationWidget.h" |
|
1 | #include "Visualization/VisualizationWidget.h" | |
2 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
2 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
3 | #include "Visualization/VisualizationActionManager.h" |
|
3 | #include "Visualization/VisualizationActionManager.h" | |
4 | #include "Visualization/VisualizationGraphWidget.h" |
|
4 | #include "Visualization/VisualizationGraphWidget.h" | |
5 | #include "Visualization/VisualizationSelectionZoneItem.h" |
|
5 | #include "Visualization/VisualizationSelectionZoneItem.h" | |
6 | #include "Visualization/VisualizationSelectionZoneManager.h" |
|
6 | #include "Visualization/VisualizationSelectionZoneManager.h" | |
7 | #include "Visualization/VisualizationTabWidget.h" |
|
7 | #include "Visualization/VisualizationTabWidget.h" | |
8 | #include "Visualization/VisualizationZoneWidget.h" |
|
8 | #include "Visualization/VisualizationZoneWidget.h" | |
9 | #include "Visualization/operations/FindVariableOperation.h" |
|
9 | #include "Visualization/operations/FindVariableOperation.h" | |
10 | #include "Visualization/operations/GenerateVariableMenuOperation.h" |
|
10 | #include "Visualization/operations/GenerateVariableMenuOperation.h" | |
11 | #include "Visualization/operations/RemoveVariableOperation.h" |
|
11 | #include "Visualization/operations/RemoveVariableOperation.h" | |
12 | #include "Visualization/operations/RescaleAxeOperation.h" |
|
12 | #include "Visualization/operations/RescaleAxeOperation.h" | |
13 | #include "Visualization/qcustomplot.h" |
|
13 | #include "Visualization/qcustomplot.h" | |
14 |
|
14 | |||
15 | #include "ui_VisualizationWidget.h" |
|
15 | #include "ui_VisualizationWidget.h" | |
16 |
|
16 | |||
17 | #include "DragAndDrop/DragDropGuiController.h" |
|
17 | #include "DragAndDrop/DragDropGuiController.h" | |
18 | #include "SqpApplication.h" |
|
18 | #include "SqpApplication.h" | |
19 |
|
19 | |||
20 | #include <QToolButton> |
|
20 | #include <QToolButton> | |
21 |
|
21 | |||
22 | #include <memory> |
|
22 | #include <memory> | |
23 |
|
23 | |||
24 | Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") |
|
24 | Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") | |
25 |
|
25 | |||
26 | struct VisualizationWidget::VisualizationWidgetPrivate { |
|
26 | struct VisualizationWidget::VisualizationWidgetPrivate { | |
27 | std::unique_ptr<VisualizationSelectionZoneManager> m_ZoneSelectionManager = nullptr; |
|
27 | std::unique_ptr<VisualizationSelectionZoneManager> m_ZoneSelectionManager = nullptr; | |
28 | VisualizationActionManager m_ActionManager; |
|
28 | VisualizationActionManager m_ActionManager; | |
29 |
|
29 | |||
30 | VisualizationWidgetPrivate() |
|
30 | VisualizationWidgetPrivate() | |
31 | : m_ZoneSelectionManager(std::make_unique<VisualizationSelectionZoneManager>()) |
|
31 | : m_ZoneSelectionManager(std::make_unique<VisualizationSelectionZoneManager>()) | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 | }; |
|
34 | }; | |
35 |
|
35 | |||
36 | VisualizationWidget::VisualizationWidget(QWidget *parent) |
|
36 | VisualizationWidget::VisualizationWidget(QWidget *parent) | |
37 | : QWidget{parent}, |
|
37 | : QWidget{parent}, | |
38 | ui{new Ui::VisualizationWidget}, |
|
38 | ui{new Ui::VisualizationWidget}, | |
39 | impl{spimpl::make_unique_impl<VisualizationWidgetPrivate>()} |
|
39 | impl{spimpl::make_unique_impl<VisualizationWidgetPrivate>()} | |
40 | { |
|
40 | { | |
41 | ui->setupUi(this); |
|
41 | ui->setupUi(this); | |
42 |
|
42 | |||
43 | auto addTabViewButton = new QToolButton{ui->tabWidget}; |
|
43 | auto addTabViewButton = new QToolButton{ui->tabWidget}; | |
44 | addTabViewButton->setText(tr("Add View")); |
|
44 | addTabViewButton->setText(tr("Add View")); | |
45 | addTabViewButton->setCursor(Qt::ArrowCursor); |
|
45 | addTabViewButton->setCursor(Qt::ArrowCursor); | |
46 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); |
|
46 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); | |
47 |
|
47 | |||
48 | auto enableMinimumCornerWidgetSize = [this](bool enable) { |
|
48 | auto enableMinimumCornerWidgetSize = [this](bool enable) { | |
49 |
|
49 | |||
50 | auto tabViewCornerWidget = ui->tabWidget->cornerWidget(); |
|
50 | auto tabViewCornerWidget = ui->tabWidget->cornerWidget(); | |
51 | auto width = enable ? tabViewCornerWidget->width() : 0; |
|
51 | auto width = enable ? tabViewCornerWidget->width() : 0; | |
52 | auto height = enable ? tabViewCornerWidget->height() : 0; |
|
52 | auto height = enable ? tabViewCornerWidget->height() : 0; | |
53 | tabViewCornerWidget->setMinimumHeight(height); |
|
53 | tabViewCornerWidget->setMinimumHeight(height); | |
54 | tabViewCornerWidget->setMinimumWidth(width); |
|
54 | tabViewCornerWidget->setMinimumWidth(width); | |
55 | ui->tabWidget->setMinimumHeight(height); |
|
55 | ui->tabWidget->setMinimumHeight(height); | |
56 | ui->tabWidget->setMinimumWidth(width); |
|
56 | ui->tabWidget->setMinimumWidth(width); | |
57 | }; |
|
57 | }; | |
58 |
|
58 | |||
59 | auto addTabView = [this, enableMinimumCornerWidgetSize]() { |
|
59 | auto addTabView = [this, enableMinimumCornerWidgetSize]() { | |
60 | auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1), |
|
60 | auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1), | |
61 | ui->tabWidget}; |
|
61 | ui->tabWidget}; | |
62 | auto index = ui->tabWidget->addTab(widget, widget->name()); |
|
62 | auto index = ui->tabWidget->addTab(widget, widget->name()); | |
63 | if (ui->tabWidget->count() > 0) { |
|
63 | if (ui->tabWidget->count() > 0) { | |
64 | enableMinimumCornerWidgetSize(false); |
|
64 | enableMinimumCornerWidgetSize(false); | |
65 | } |
|
65 | } | |
66 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); |
|
66 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); | |
67 | }; |
|
67 | }; | |
68 |
|
68 | |||
69 | auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) { |
|
69 | auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) { | |
70 | if (ui->tabWidget->count() == 1) { |
|
70 | if (ui->tabWidget->count() == 1) { | |
71 | enableMinimumCornerWidgetSize(true); |
|
71 | enableMinimumCornerWidgetSize(true); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | // Removes widget from tab and closes it |
|
74 | // Removes widget from tab and closes it | |
75 | auto widget = ui->tabWidget->widget(index); |
|
75 | auto widget = ui->tabWidget->widget(index); | |
76 | ui->tabWidget->removeTab(index); |
|
76 | ui->tabWidget->removeTab(index); | |
77 | if (widget) { |
|
77 | if (widget) { | |
78 | widget->close(); |
|
78 | widget->close(); | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); |
|
81 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); | |
82 |
|
82 | |||
83 | }; |
|
83 | }; | |
84 |
|
84 | |||
85 | ui->tabWidget->setTabsClosable(true); |
|
85 | ui->tabWidget->setTabsClosable(true); | |
86 |
|
86 | |||
87 | connect(addTabViewButton, &QToolButton::clicked, addTabView); |
|
87 | connect(addTabViewButton, &QToolButton::clicked, addTabView); | |
88 | connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); |
|
88 | connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); | |
89 |
|
89 | |||
90 | sqpApp->dragDropGuiController().addDragDropTabBar(ui->tabWidget->tabBar()); |
|
90 | sqpApp->dragDropGuiController().addDragDropTabBar(ui->tabWidget->tabBar()); | |
91 |
|
91 | |||
92 | // Actions |
|
92 | // Actions | |
93 | impl->m_ActionManager.installSelectionZoneActions(); |
|
93 | impl->m_ActionManager.installSelectionZoneActions(); | |
94 |
|
94 | |||
95 | auto removeZoneAction = new QAction("Remove selected zone(s)"); |
|
95 | auto removeZoneAction = new QAction("Remove selected zone(s)"); | |
96 | removeZoneAction->setShortcut(QKeySequence::Delete); |
|
96 | removeZoneAction->setShortcut(QKeySequence::Delete); | |
97 | connect(removeZoneAction, &QAction::triggered, [this]() { |
|
97 | connect(removeZoneAction, &QAction::triggered, [this]() { | |
98 | auto selection = impl->m_ZoneSelectionManager->selectedItems(); |
|
98 | auto selection = impl->m_ZoneSelectionManager->selectedItems(); | |
99 | for (auto selectionZone : selection) { |
|
99 | for (auto selectionZone : selection) { | |
100 | if (auto graph = selectionZone->parentGraphWidget()) { |
|
100 | if (auto graph = selectionZone->parentGraphWidget()) { | |
101 | graph->removeSelectionZone(selectionZone); |
|
101 | graph->removeSelectionZone(selectionZone); | |
102 | } |
|
102 | } | |
103 | } |
|
103 | } | |
104 | }); |
|
104 | }); | |
105 | addAction(removeZoneAction); |
|
105 | addAction(removeZoneAction); | |
106 |
|
106 | |||
107 | // Adds default tab |
|
107 | // Adds default tab | |
108 | addTabView(); |
|
108 | addTabView(); | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 | VisualizationWidget::~VisualizationWidget() |
|
111 | VisualizationWidget::~VisualizationWidget() | |
112 | { |
|
112 | { | |
113 | sqpApp->dragDropGuiController().removeDragDropTabBar(ui->tabWidget->tabBar()); |
|
113 | sqpApp->dragDropGuiController().removeDragDropTabBar(ui->tabWidget->tabBar()); | |
114 | delete ui; |
|
114 | delete ui; | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | VisualizationSelectionZoneManager &VisualizationWidget::selectionZoneManager() const |
|
117 | VisualizationSelectionZoneManager &VisualizationWidget::selectionZoneManager() const | |
118 | { |
|
118 | { | |
119 | return *impl->m_ZoneSelectionManager.get(); |
|
119 | return *impl->m_ZoneSelectionManager.get(); | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
|
122 | VisualizationTabWidget *VisualizationWidget::currentTabWidget() const | |||
|
123 | { | |||
|
124 | if (auto tab = qobject_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) { | |||
|
125 | return tab; | |||
|
126 | } | |||
|
127 | ||||
|
128 | return nullptr; | |||
|
129 | } | |||
|
130 | ||||
122 | void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
131 | void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor) | |
123 | { |
|
132 | { | |
124 | if (visitor) { |
|
133 | if (visitor) { | |
125 | visitor->visitEnter(this); |
|
134 | visitor->visitEnter(this); | |
126 |
|
135 | |||
127 | // Apply visitor for tab children |
|
136 | // Apply visitor for tab children | |
128 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { |
|
137 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { | |
129 | // Widgets different from tabs are not visited (no action) |
|
138 | // Widgets different from tabs are not visited (no action) | |
130 | if (auto visualizationTabWidget |
|
139 | if (auto visualizationTabWidget | |
131 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { |
|
140 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { | |
132 | visualizationTabWidget->accept(visitor); |
|
141 | visualizationTabWidget->accept(visitor); | |
133 | } |
|
142 | } | |
134 | } |
|
143 | } | |
135 |
|
144 | |||
136 | visitor->visitLeave(this); |
|
145 | visitor->visitLeave(this); | |
137 | } |
|
146 | } | |
138 | else { |
|
147 | else { | |
139 | qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null"); |
|
148 | qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null"); | |
140 | } |
|
149 | } | |
141 | } |
|
150 | } | |
142 |
|
151 | |||
143 | bool VisualizationWidget::canDrop(const Variable &variable) const |
|
152 | bool VisualizationWidget::canDrop(const Variable &variable) const | |
144 | { |
|
153 | { | |
145 | // The main widget can never accomodate a variable |
|
154 | // The main widget can never accomodate a variable | |
146 | Q_UNUSED(variable); |
|
155 | Q_UNUSED(variable); | |
147 | return false; |
|
156 | return false; | |
148 | } |
|
157 | } | |
149 |
|
158 | |||
150 | bool VisualizationWidget::contains(const Variable &variable) const |
|
159 | bool VisualizationWidget::contains(const Variable &variable) const | |
151 | { |
|
160 | { | |
152 | Q_UNUSED(variable); |
|
161 | Q_UNUSED(variable); | |
153 | return false; |
|
162 | return false; | |
154 | } |
|
163 | } | |
155 |
|
164 | |||
156 | QString VisualizationWidget::name() const |
|
165 | QString VisualizationWidget::name() const | |
157 | { |
|
166 | { | |
158 | return QStringLiteral("MainView"); |
|
167 | return QStringLiteral("MainView"); | |
159 | } |
|
168 | } | |
160 |
|
169 | |||
161 | void VisualizationWidget::attachVariableMenu( |
|
170 | void VisualizationWidget::attachVariableMenu( | |
162 | QMenu *menu, const QVector<std::shared_ptr<Variable> > &variables) noexcept |
|
171 | QMenu *menu, const QVector<std::shared_ptr<Variable> > &variables) noexcept | |
163 | { |
|
172 | { | |
164 | // Menu is generated only if there is a single variable |
|
173 | // Menu is generated only if there is a single variable | |
165 | if (variables.size() == 1) { |
|
174 | if (variables.size() == 1) { | |
166 | if (auto variable = variables.first()) { |
|
175 | if (auto variable = variables.first()) { | |
167 | // Gets the containers of the variable |
|
176 | // Gets the containers of the variable | |
168 | FindVariableOperation findVariableOperation{variable}; |
|
177 | FindVariableOperation findVariableOperation{variable}; | |
169 | accept(&findVariableOperation); |
|
178 | accept(&findVariableOperation); | |
170 | auto variableContainers = findVariableOperation.result(); |
|
179 | auto variableContainers = findVariableOperation.result(); | |
171 |
|
180 | |||
172 | // Generates the actions that make it possible to visualize the variable |
|
181 | // Generates the actions that make it possible to visualize the variable | |
173 | GenerateVariableMenuOperation generateVariableMenuOperation{ |
|
182 | GenerateVariableMenuOperation generateVariableMenuOperation{ | |
174 | menu, variable, std::move(variableContainers)}; |
|
183 | menu, variable, std::move(variableContainers)}; | |
175 | accept(&generateVariableMenuOperation); |
|
184 | accept(&generateVariableMenuOperation); | |
176 | } |
|
185 | } | |
177 | else { |
|
186 | else { | |
178 | qCCritical(LOG_VisualizationWidget()) << tr( |
|
187 | qCCritical(LOG_VisualizationWidget()) << tr( | |
179 | "Can't generate the menu relative to the visualization: the variable is null"); |
|
188 | "Can't generate the menu relative to the visualization: the variable is null"); | |
180 | } |
|
189 | } | |
181 | } |
|
190 | } | |
182 | else { |
|
191 | else { | |
183 | qCDebug(LOG_VisualizationWidget()) |
|
192 | qCDebug(LOG_VisualizationWidget()) | |
184 | << tr("No generation of the menu related to the visualization: several variables are " |
|
193 | << tr("No generation of the menu related to the visualization: several variables are " | |
185 | "selected"); |
|
194 | "selected"); | |
186 | } |
|
195 | } | |
187 | } |
|
196 | } | |
188 |
|
197 | |||
189 | void VisualizationWidget::onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept |
|
198 | void VisualizationWidget::onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept | |
190 | { |
|
199 | { | |
191 | // Calls the operation of removing all references to the variable in the visualization |
|
200 | // Calls the operation of removing all references to the variable in the visualization | |
192 | auto removeVariableOperation = RemoveVariableOperation{variable}; |
|
201 | auto removeVariableOperation = RemoveVariableOperation{variable}; | |
193 | accept(&removeVariableOperation); |
|
202 | accept(&removeVariableOperation); | |
194 | } |
|
203 | } | |
195 |
|
204 | |||
196 | void VisualizationWidget::onRangeChanged(std::shared_ptr<Variable> variable, |
|
205 | void VisualizationWidget::onRangeChanged(std::shared_ptr<Variable> variable, | |
197 | const SqpRange &range) noexcept |
|
206 | const SqpRange &range) noexcept | |
198 | { |
|
207 | { | |
199 | // Calls the operation of rescaling all graph that contrains variable in the visualization |
|
208 | // Calls the operation of rescaling all graph that contrains variable in the visualization | |
200 | auto rescaleVariableOperation = RescaleAxeOperation{variable, range}; |
|
209 | auto rescaleVariableOperation = RescaleAxeOperation{variable, range}; | |
201 | accept(&rescaleVariableOperation); |
|
210 | accept(&rescaleVariableOperation); | |
202 | } |
|
211 | } | |
203 |
|
212 | |||
204 | void VisualizationWidget::closeEvent(QCloseEvent *event) |
|
213 | void VisualizationWidget::closeEvent(QCloseEvent *event) | |
205 | { |
|
214 | { | |
206 | // Closes tabs in the widget |
|
215 | // Closes tabs in the widget | |
207 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { |
|
216 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { | |
208 | if (auto visualizationTabWidget |
|
217 | if (auto visualizationTabWidget | |
209 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { |
|
218 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { | |
210 | visualizationTabWidget->close(); |
|
219 | visualizationTabWidget->close(); | |
211 | } |
|
220 | } | |
212 | } |
|
221 | } | |
213 |
|
222 | |||
214 | QWidget::closeEvent(event); |
|
223 | QWidget::closeEvent(event); | |
215 | } |
|
224 | } |
@@ -1,587 +1,601 | |||||
1 | #include "Visualization/VisualizationZoneWidget.h" |
|
1 | #include "Visualization/VisualizationZoneWidget.h" | |
2 |
|
2 | |||
3 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
3 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
4 | #include "Visualization/QCustomPlotSynchronizer.h" |
|
4 | #include "Visualization/QCustomPlotSynchronizer.h" | |
5 | #include "Visualization/VisualizationGraphWidget.h" |
|
5 | #include "Visualization/VisualizationGraphWidget.h" | |
6 | #include "Visualization/VisualizationWidget.h" |
|
6 | #include "Visualization/VisualizationWidget.h" | |
7 | #include "ui_VisualizationZoneWidget.h" |
|
7 | #include "ui_VisualizationZoneWidget.h" | |
8 |
|
8 | |||
9 | #include "Common/MimeTypesDef.h" |
|
9 | #include "Common/MimeTypesDef.h" | |
10 | #include "Common/VisualizationDef.h" |
|
10 | #include "Common/VisualizationDef.h" | |
11 |
|
11 | |||
12 | #include <Data/SqpRange.h> |
|
12 | #include <Data/SqpRange.h> | |
13 | #include <Time/TimeController.h> |
|
13 | #include <Time/TimeController.h> | |
14 | #include <Variable/Variable.h> |
|
14 | #include <Variable/Variable.h> | |
15 | #include <Variable/VariableController.h> |
|
15 | #include <Variable/VariableController.h> | |
16 |
|
16 | |||
17 | #include <Visualization/operations/FindVariableOperation.h> |
|
17 | #include <Visualization/operations/FindVariableOperation.h> | |
18 |
|
18 | |||
19 | #include <DragAndDrop/DragDropGuiController.h> |
|
19 | #include <DragAndDrop/DragDropGuiController.h> | |
20 | #include <QUuid> |
|
20 | #include <QUuid> | |
21 | #include <SqpApplication.h> |
|
21 | #include <SqpApplication.h> | |
22 | #include <cmath> |
|
22 | #include <cmath> | |
23 |
|
23 | |||
24 | #include <QLayout> |
|
24 | #include <QLayout> | |
25 |
|
25 | |||
26 | Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget") |
|
26 | Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget") | |
27 |
|
27 | |||
28 | namespace { |
|
28 | namespace { | |
29 |
|
29 | |||
30 |
|
||||
31 | /// Generates a default name for a new graph, according to the number of graphs already displayed in |
|
|||
32 | /// the zone |
|
|||
33 | QString defaultGraphName(const QLayout &layout) |
|
|||
34 | { |
|
|||
35 | auto count = 0; |
|
|||
36 | for (auto i = 0; i < layout.count(); ++i) { |
|
|||
37 | if (dynamic_cast<VisualizationGraphWidget *>(layout.itemAt(i)->widget())) { |
|
|||
38 | count++; |
|
|||
39 | } |
|
|||
40 | } |
|
|||
41 |
|
||||
42 | return QObject::tr("Graph %1").arg(count + 1); |
|
|||
43 | } |
|
|||
44 |
|
||||
45 | /** |
|
30 | /** | |
46 | * Applies a function to all graphs of the zone represented by its layout |
|
31 | * Applies a function to all graphs of the zone represented by its layout | |
47 | * @param layout the layout that contains graphs |
|
32 | * @param layout the layout that contains graphs | |
48 | * @param fun the function to apply to each graph |
|
33 | * @param fun the function to apply to each graph | |
49 | */ |
|
34 | */ | |
50 | template <typename Fun> |
|
35 | template <typename Fun> | |
51 | void processGraphs(QLayout &layout, Fun fun) |
|
36 | void processGraphs(QLayout &layout, Fun fun) | |
52 | { |
|
37 | { | |
53 | for (auto i = 0; i < layout.count(); ++i) { |
|
38 | for (auto i = 0; i < layout.count(); ++i) { | |
54 | if (auto item = layout.itemAt(i)) { |
|
39 | if (auto item = layout.itemAt(i)) { | |
55 | if (auto visualizationGraphWidget |
|
40 | if (auto visualizationGraphWidget | |
56 | = qobject_cast<VisualizationGraphWidget *>(item->widget())) { |
|
41 | = qobject_cast<VisualizationGraphWidget *>(item->widget())) { | |
57 | fun(*visualizationGraphWidget); |
|
42 | fun(*visualizationGraphWidget); | |
58 | } |
|
43 | } | |
59 | } |
|
44 | } | |
60 | } |
|
45 | } | |
61 | } |
|
46 | } | |
62 |
|
47 | |||
|
48 | /// Generates a default name for a new graph, according to the number of graphs already displayed in | |||
|
49 | /// the zone | |||
|
50 | QString defaultGraphName(QLayout &layout) | |||
|
51 | { | |||
|
52 | QSet<QString> existingNames; | |||
|
53 | processGraphs( | |||
|
54 | layout, [&existingNames](auto &graphWidget) { existingNames.insert(graphWidget.name()); }); | |||
|
55 | ||||
|
56 | int zoneNum = 1; | |||
|
57 | QString name; | |||
|
58 | do { | |||
|
59 | name = QObject::tr("Graph ").append(QString::number(zoneNum)); | |||
|
60 | ++zoneNum; | |||
|
61 | } while (existingNames.contains(name)); | |||
|
62 | ||||
|
63 | return name; | |||
|
64 | } | |||
|
65 | ||||
63 | } // namespace |
|
66 | } // namespace | |
64 |
|
67 | |||
65 | struct VisualizationZoneWidget::VisualizationZoneWidgetPrivate { |
|
68 | struct VisualizationZoneWidget::VisualizationZoneWidgetPrivate { | |
66 |
|
69 | |||
67 | explicit VisualizationZoneWidgetPrivate() |
|
70 | explicit VisualizationZoneWidgetPrivate() | |
68 | : m_SynchronisationGroupId{QUuid::createUuid()}, |
|
71 | : m_SynchronisationGroupId{QUuid::createUuid()}, | |
69 | m_Synchronizer{std::make_unique<QCustomPlotSynchronizer>()} |
|
72 | m_Synchronizer{std::make_unique<QCustomPlotSynchronizer>()} | |
70 | { |
|
73 | { | |
71 | } |
|
74 | } | |
72 | QUuid m_SynchronisationGroupId; |
|
75 | QUuid m_SynchronisationGroupId; | |
73 | std::unique_ptr<IGraphSynchronizer> m_Synchronizer; |
|
76 | std::unique_ptr<IGraphSynchronizer> m_Synchronizer; | |
74 |
|
77 | |||
75 | void dropGraph(int index, VisualizationZoneWidget *zoneWidget); |
|
78 | void dropGraph(int index, VisualizationZoneWidget *zoneWidget); | |
76 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, |
|
79 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, | |
77 | VisualizationZoneWidget *zoneWidget); |
|
80 | VisualizationZoneWidget *zoneWidget); | |
78 | }; |
|
81 | }; | |
79 |
|
82 | |||
80 | VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent) |
|
83 | VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent) | |
81 | : VisualizationDragWidget{parent}, |
|
84 | : VisualizationDragWidget{parent}, | |
82 | ui{new Ui::VisualizationZoneWidget}, |
|
85 | ui{new Ui::VisualizationZoneWidget}, | |
83 | impl{spimpl::make_unique_impl<VisualizationZoneWidgetPrivate>()} |
|
86 | impl{spimpl::make_unique_impl<VisualizationZoneWidgetPrivate>()} | |
84 | { |
|
87 | { | |
85 | ui->setupUi(this); |
|
88 | ui->setupUi(this); | |
86 |
|
89 | |||
87 | ui->zoneNameLabel->setText(name); |
|
90 | ui->zoneNameLabel->setText(name); | |
88 |
|
91 | |||
89 | ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Graph); |
|
92 | ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Graph); | |
90 | ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH, |
|
93 | ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH, | |
91 | VisualizationDragDropContainer::DropBehavior::Inserted); |
|
94 | VisualizationDragDropContainer::DropBehavior::Inserted); | |
92 | ui->dragDropContainer->setMimeType( |
|
95 | ui->dragDropContainer->setMimeType( | |
93 | MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged); |
|
96 | MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged); | |
94 | ui->dragDropContainer->setMimeType(MIME_TYPE_TIME_RANGE, |
|
97 | ui->dragDropContainer->setMimeType(MIME_TYPE_TIME_RANGE, | |
95 | VisualizationDragDropContainer::DropBehavior::Merged); |
|
98 | VisualizationDragDropContainer::DropBehavior::Merged); | |
96 | ui->dragDropContainer->setMimeType(MIME_TYPE_ZONE, |
|
99 | ui->dragDropContainer->setMimeType(MIME_TYPE_ZONE, | |
97 | VisualizationDragDropContainer::DropBehavior::Forbidden); |
|
100 | VisualizationDragDropContainer::DropBehavior::Forbidden); | |
98 | ui->dragDropContainer->setMimeType(MIME_TYPE_SELECTION_ZONE, |
|
101 | ui->dragDropContainer->setMimeType(MIME_TYPE_SELECTION_ZONE, | |
99 | VisualizationDragDropContainer::DropBehavior::Forbidden); |
|
102 | VisualizationDragDropContainer::DropBehavior::Forbidden); | |
100 | ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) { |
|
103 | ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) { | |
101 | return sqpApp->dragDropGuiController().checkMimeDataForVisualization(mimeData, |
|
104 | return sqpApp->dragDropGuiController().checkMimeDataForVisualization(mimeData, | |
102 | ui->dragDropContainer); |
|
105 | ui->dragDropContainer); | |
103 | }); |
|
106 | }); | |
104 |
|
107 | |||
105 | auto acceptDragWidgetFun = [](auto dragWidget, auto mimeData) { |
|
108 | auto acceptDragWidgetFun = [](auto dragWidget, auto mimeData) { | |
106 | if (!mimeData) { |
|
109 | if (!mimeData) { | |
107 | return false; |
|
110 | return false; | |
108 | } |
|
111 | } | |
109 |
|
112 | |||
110 | if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { |
|
113 | if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { | |
111 | auto variables = sqpApp->variableController().variablesForMimeData( |
|
114 | auto variables = sqpApp->variableController().variablesForMimeData( | |
112 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); |
|
115 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); | |
113 |
|
116 | |||
114 | if (variables.count() != 1) { |
|
117 | if (variables.count() != 1) { | |
115 | return false; |
|
118 | return false; | |
116 | } |
|
119 | } | |
117 | auto variable = variables.first(); |
|
120 | auto variable = variables.first(); | |
118 |
|
121 | |||
119 | if (auto graphWidget = dynamic_cast<const VisualizationGraphWidget *>(dragWidget)) { |
|
122 | if (auto graphWidget = dynamic_cast<const VisualizationGraphWidget *>(dragWidget)) { | |
120 | return graphWidget->canDrop(*variable); |
|
123 | return graphWidget->canDrop(*variable); | |
121 | } |
|
124 | } | |
122 | } |
|
125 | } | |
123 |
|
126 | |||
124 | return true; |
|
127 | return true; | |
125 | }; |
|
128 | }; | |
126 | ui->dragDropContainer->setAcceptDragWidgetFunction(acceptDragWidgetFun); |
|
129 | ui->dragDropContainer->setAcceptDragWidgetFunction(acceptDragWidgetFun); | |
127 |
|
130 | |||
128 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this, |
|
131 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this, | |
129 | &VisualizationZoneWidget::dropMimeData); |
|
132 | &VisualizationZoneWidget::dropMimeData); | |
130 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredOnWidget, this, |
|
133 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredOnWidget, this, | |
131 | &VisualizationZoneWidget::dropMimeDataOnGraph); |
|
134 | &VisualizationZoneWidget::dropMimeDataOnGraph); | |
132 |
|
135 | |||
133 | // 'Close' options : widget is deleted when closed |
|
136 | // 'Close' options : widget is deleted when closed | |
134 | setAttribute(Qt::WA_DeleteOnClose); |
|
137 | setAttribute(Qt::WA_DeleteOnClose); | |
135 | connect(ui->closeButton, &QToolButton::clicked, this, &VisualizationZoneWidget::close); |
|
138 | connect(ui->closeButton, &QToolButton::clicked, this, &VisualizationZoneWidget::close); | |
136 | ui->closeButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton)); |
|
139 | ui->closeButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton)); | |
137 |
|
140 | |||
138 | // Synchronisation id |
|
141 | // Synchronisation id | |
139 | QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronizationGroupId", |
|
142 | QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronizationGroupId", | |
140 | Qt::QueuedConnection, Q_ARG(QUuid, impl->m_SynchronisationGroupId)); |
|
143 | Qt::QueuedConnection, Q_ARG(QUuid, impl->m_SynchronisationGroupId)); | |
141 | } |
|
144 | } | |
142 |
|
145 | |||
143 | VisualizationZoneWidget::~VisualizationZoneWidget() |
|
146 | VisualizationZoneWidget::~VisualizationZoneWidget() | |
144 | { |
|
147 | { | |
145 | delete ui; |
|
148 | delete ui; | |
146 | } |
|
149 | } | |
147 |
|
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 | ||||
148 | void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget) |
|
162 | void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget) | |
149 | { |
|
163 | { | |
150 | // Synchronize new graph with others in the zone |
|
164 | // Synchronize new graph with others in the zone | |
151 | impl->m_Synchronizer->addGraph(*graphWidget); |
|
165 | impl->m_Synchronizer->addGraph(*graphWidget); | |
152 |
|
166 | |||
153 | ui->dragDropContainer->addDragWidget(graphWidget); |
|
167 | ui->dragDropContainer->addDragWidget(graphWidget); | |
154 | } |
|
168 | } | |
155 |
|
169 | |||
156 | void VisualizationZoneWidget::insertGraph(int index, VisualizationGraphWidget *graphWidget) |
|
170 | void VisualizationZoneWidget::insertGraph(int index, VisualizationGraphWidget *graphWidget) | |
157 | { |
|
171 | { | |
158 | // Synchronize new graph with others in the zone |
|
172 | // Synchronize new graph with others in the zone | |
159 | impl->m_Synchronizer->addGraph(*graphWidget); |
|
173 | impl->m_Synchronizer->addGraph(*graphWidget); | |
160 |
|
174 | |||
161 | ui->dragDropContainer->insertDragWidget(index, graphWidget); |
|
175 | ui->dragDropContainer->insertDragWidget(index, graphWidget); | |
162 | } |
|
176 | } | |
163 |
|
177 | |||
164 | VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable) |
|
178 | VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable) | |
165 | { |
|
179 | { | |
166 | return createGraph(variable, -1); |
|
180 | return createGraph(variable, -1); | |
167 | } |
|
181 | } | |
168 |
|
182 | |||
169 | VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable, |
|
183 | VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable, | |
170 | int index) |
|
184 | int index) | |
171 | { |
|
185 | { | |
172 | auto graphWidget |
|
186 | auto graphWidget | |
173 | = new VisualizationGraphWidget{defaultGraphName(*ui->dragDropContainer->layout()), this}; |
|
187 | = new VisualizationGraphWidget{defaultGraphName(*ui->dragDropContainer->layout()), this}; | |
174 |
|
188 | |||
175 |
|
189 | |||
176 | // Set graph properties |
|
190 | // Set graph properties | |
177 | graphWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); |
|
191 | graphWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); | |
178 | graphWidget->setMinimumHeight(GRAPH_MINIMUM_HEIGHT); |
|
192 | graphWidget->setMinimumHeight(GRAPH_MINIMUM_HEIGHT); | |
179 |
|
193 | |||
180 |
|
194 | |||
181 | // Lambda to synchronize zone widget |
|
195 | // Lambda to synchronize zone widget | |
182 | auto synchronizeZoneWidget = [this, graphWidget](const SqpRange &graphRange, |
|
196 | auto synchronizeZoneWidget = [this, graphWidget](const SqpRange &graphRange, | |
183 | const SqpRange &oldGraphRange) { |
|
197 | const SqpRange &oldGraphRange) { | |
184 |
|
198 | |||
185 | auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange); |
|
199 | auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange); | |
186 | auto frameLayout = ui->dragDropContainer->layout(); |
|
200 | auto frameLayout = ui->dragDropContainer->layout(); | |
187 | for (auto i = 0; i < frameLayout->count(); ++i) { |
|
201 | for (auto i = 0; i < frameLayout->count(); ++i) { | |
188 | auto graphChild |
|
202 | auto graphChild | |
189 | = dynamic_cast<VisualizationGraphWidget *>(frameLayout->itemAt(i)->widget()); |
|
203 | = dynamic_cast<VisualizationGraphWidget *>(frameLayout->itemAt(i)->widget()); | |
190 | if (graphChild && (graphChild != graphWidget)) { |
|
204 | if (graphChild && (graphChild != graphWidget)) { | |
191 |
|
205 | |||
192 | auto graphChildRange = graphChild->graphRange(); |
|
206 | auto graphChildRange = graphChild->graphRange(); | |
193 | switch (zoomType) { |
|
207 | switch (zoomType) { | |
194 | case AcquisitionZoomType::ZoomIn: { |
|
208 | case AcquisitionZoomType::ZoomIn: { | |
195 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; |
|
209 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; | |
196 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; |
|
210 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; | |
197 | graphChildRange.m_TStart += deltaLeft; |
|
211 | graphChildRange.m_TStart += deltaLeft; | |
198 | graphChildRange.m_TEnd -= deltaRight; |
|
212 | graphChildRange.m_TEnd -= deltaRight; | |
199 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn"); |
|
213 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn"); | |
200 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft") |
|
214 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft") | |
201 | << deltaLeft; |
|
215 | << deltaLeft; | |
202 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight") |
|
216 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight") | |
203 | << deltaRight; |
|
217 | << deltaRight; | |
204 | qCDebug(LOG_VisualizationZoneWidget()) |
|
218 | qCDebug(LOG_VisualizationZoneWidget()) | |
205 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; |
|
219 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; | |
206 |
|
220 | |||
207 | break; |
|
221 | break; | |
208 | } |
|
222 | } | |
209 |
|
223 | |||
210 | case AcquisitionZoomType::ZoomOut: { |
|
224 | case AcquisitionZoomType::ZoomOut: { | |
211 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut"); |
|
225 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut"); | |
212 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; |
|
226 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; | |
213 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; |
|
227 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; | |
214 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft") |
|
228 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft") | |
215 | << deltaLeft; |
|
229 | << deltaLeft; | |
216 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight") |
|
230 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight") | |
217 | << deltaRight; |
|
231 | << deltaRight; | |
218 | qCDebug(LOG_VisualizationZoneWidget()) |
|
232 | qCDebug(LOG_VisualizationZoneWidget()) | |
219 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; |
|
233 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; | |
220 | graphChildRange.m_TStart -= deltaLeft; |
|
234 | graphChildRange.m_TStart -= deltaLeft; | |
221 | graphChildRange.m_TEnd += deltaRight; |
|
235 | graphChildRange.m_TEnd += deltaRight; | |
222 | break; |
|
236 | break; | |
223 | } |
|
237 | } | |
224 | case AcquisitionZoomType::PanRight: { |
|
238 | case AcquisitionZoomType::PanRight: { | |
225 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight"); |
|
239 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight"); | |
226 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; |
|
240 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; | |
227 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; |
|
241 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; | |
228 | graphChildRange.m_TStart += deltaLeft; |
|
242 | graphChildRange.m_TStart += deltaLeft; | |
229 | graphChildRange.m_TEnd += deltaRight; |
|
243 | graphChildRange.m_TEnd += deltaRight; | |
230 | qCDebug(LOG_VisualizationZoneWidget()) |
|
244 | qCDebug(LOG_VisualizationZoneWidget()) | |
231 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; |
|
245 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; | |
232 | break; |
|
246 | break; | |
233 | } |
|
247 | } | |
234 | case AcquisitionZoomType::PanLeft: { |
|
248 | case AcquisitionZoomType::PanLeft: { | |
235 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft"); |
|
249 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft"); | |
236 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; |
|
250 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; | |
237 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; |
|
251 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; | |
238 | graphChildRange.m_TStart -= deltaLeft; |
|
252 | graphChildRange.m_TStart -= deltaLeft; | |
239 | graphChildRange.m_TEnd -= deltaRight; |
|
253 | graphChildRange.m_TEnd -= deltaRight; | |
240 | break; |
|
254 | break; | |
241 | } |
|
255 | } | |
242 | case AcquisitionZoomType::Unknown: { |
|
256 | case AcquisitionZoomType::Unknown: { | |
243 | qCDebug(LOG_VisualizationZoneWidget()) |
|
257 | qCDebug(LOG_VisualizationZoneWidget()) | |
244 | << tr("Impossible to synchronize: zoom type unknown"); |
|
258 | << tr("Impossible to synchronize: zoom type unknown"); | |
245 | break; |
|
259 | break; | |
246 | } |
|
260 | } | |
247 | default: |
|
261 | default: | |
248 | qCCritical(LOG_VisualizationZoneWidget()) |
|
262 | qCCritical(LOG_VisualizationZoneWidget()) | |
249 | << tr("Impossible to synchronize: zoom type not take into account"); |
|
263 | << tr("Impossible to synchronize: zoom type not take into account"); | |
250 | // No action |
|
264 | // No action | |
251 | break; |
|
265 | break; | |
252 | } |
|
266 | } | |
253 | graphChild->enableAcquisition(false); |
|
267 | graphChild->enableAcquisition(false); | |
254 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ") |
|
268 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ") | |
255 | << graphChild->graphRange(); |
|
269 | << graphChild->graphRange(); | |
256 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ") |
|
270 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ") | |
257 | << graphChildRange; |
|
271 | << graphChildRange; | |
258 | qCDebug(LOG_VisualizationZoneWidget()) |
|
272 | qCDebug(LOG_VisualizationZoneWidget()) | |
259 | << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart; |
|
273 | << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart; | |
260 | graphChild->setGraphRange(graphChildRange); |
|
274 | graphChild->setGraphRange(graphChildRange); | |
261 | graphChild->enableAcquisition(true); |
|
275 | graphChild->enableAcquisition(true); | |
262 | } |
|
276 | } | |
263 | } |
|
277 | } | |
264 | }; |
|
278 | }; | |
265 |
|
279 | |||
266 | // connection for synchronization |
|
280 | // connection for synchronization | |
267 | connect(graphWidget, &VisualizationGraphWidget::synchronize, synchronizeZoneWidget); |
|
281 | connect(graphWidget, &VisualizationGraphWidget::synchronize, synchronizeZoneWidget); | |
268 | connect(graphWidget, &VisualizationGraphWidget::variableAdded, this, |
|
282 | connect(graphWidget, &VisualizationGraphWidget::variableAdded, this, | |
269 | &VisualizationZoneWidget::onVariableAdded); |
|
283 | &VisualizationZoneWidget::onVariableAdded); | |
270 | connect(graphWidget, &VisualizationGraphWidget::variableAboutToBeRemoved, this, |
|
284 | connect(graphWidget, &VisualizationGraphWidget::variableAboutToBeRemoved, this, | |
271 | &VisualizationZoneWidget::onVariableAboutToBeRemoved); |
|
285 | &VisualizationZoneWidget::onVariableAboutToBeRemoved); | |
272 |
|
286 | |||
273 | auto range = SqpRange{}; |
|
287 | auto range = SqpRange{}; | |
274 | if (auto firstGraph = this->firstGraph()) { |
|
288 | if (auto firstGraph = this->firstGraph()) { | |
275 | // Case of a new graph in a existant zone |
|
289 | // Case of a new graph in a existant zone | |
276 | range = firstGraph->graphRange(); |
|
290 | range = firstGraph->graphRange(); | |
277 | } |
|
291 | } | |
278 | else { |
|
292 | else { | |
279 | // Case of a new graph as the first of the zone |
|
293 | // Case of a new graph as the first of the zone | |
280 | range = variable->range(); |
|
294 | range = variable->range(); | |
281 | } |
|
295 | } | |
282 |
|
296 | |||
283 | this->insertGraph(index, graphWidget); |
|
297 | this->insertGraph(index, graphWidget); | |
284 |
|
298 | |||
285 | graphWidget->addVariable(variable, range); |
|
299 | graphWidget->addVariable(variable, range); | |
286 | graphWidget->setYRange(variable); |
|
300 | graphWidget->setYRange(variable); | |
287 |
|
301 | |||
288 | return graphWidget; |
|
302 | return graphWidget; | |
289 | } |
|
303 | } | |
290 |
|
304 | |||
291 | VisualizationGraphWidget * |
|
305 | VisualizationGraphWidget * | |
292 | VisualizationZoneWidget::createGraph(const QList<std::shared_ptr<Variable> > variables, int index) |
|
306 | VisualizationZoneWidget::createGraph(const QList<std::shared_ptr<Variable> > variables, int index) | |
293 | { |
|
307 | { | |
294 | if (variables.isEmpty()) { |
|
308 | if (variables.isEmpty()) { | |
295 | return nullptr; |
|
309 | return nullptr; | |
296 | } |
|
310 | } | |
297 |
|
311 | |||
298 | auto graphWidget = createGraph(variables.first(), index); |
|
312 | auto graphWidget = createGraph(variables.first(), index); | |
299 | for (auto variableIt = variables.cbegin() + 1; variableIt != variables.cend(); ++variableIt) { |
|
313 | for (auto variableIt = variables.cbegin() + 1; variableIt != variables.cend(); ++variableIt) { | |
300 | graphWidget->addVariable(*variableIt, graphWidget->graphRange()); |
|
314 | graphWidget->addVariable(*variableIt, graphWidget->graphRange()); | |
301 | } |
|
315 | } | |
302 |
|
316 | |||
303 | return graphWidget; |
|
317 | return graphWidget; | |
304 | } |
|
318 | } | |
305 |
|
319 | |||
306 | VisualizationGraphWidget *VisualizationZoneWidget::firstGraph() const |
|
320 | VisualizationGraphWidget *VisualizationZoneWidget::firstGraph() const | |
307 | { |
|
321 | { | |
308 | VisualizationGraphWidget *firstGraph = nullptr; |
|
322 | VisualizationGraphWidget *firstGraph = nullptr; | |
309 | auto layout = ui->dragDropContainer->layout(); |
|
323 | auto layout = ui->dragDropContainer->layout(); | |
310 | if (layout->count() > 0) { |
|
324 | if (layout->count() > 0) { | |
311 | if (auto visualizationGraphWidget |
|
325 | if (auto visualizationGraphWidget | |
312 | = qobject_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) { |
|
326 | = qobject_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) { | |
313 | firstGraph = visualizationGraphWidget; |
|
327 | firstGraph = visualizationGraphWidget; | |
314 | } |
|
328 | } | |
315 | } |
|
329 | } | |
316 |
|
330 | |||
317 | return firstGraph; |
|
331 | return firstGraph; | |
318 | } |
|
332 | } | |
319 |
|
333 | |||
320 | void VisualizationZoneWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
334 | void VisualizationZoneWidget::accept(IVisualizationWidgetVisitor *visitor) | |
321 | { |
|
335 | { | |
322 | if (visitor) { |
|
336 | if (visitor) { | |
323 | visitor->visitEnter(this); |
|
337 | visitor->visitEnter(this); | |
324 |
|
338 | |||
325 | // Apply visitor to graph children: widgets different from graphs are not visited (no |
|
339 | // Apply visitor to graph children: widgets different from graphs are not visited (no | |
326 | // action) |
|
340 | // action) | |
327 | processGraphs( |
|
341 | processGraphs( | |
328 | *ui->dragDropContainer->layout(), |
|
342 | *ui->dragDropContainer->layout(), | |
329 | [visitor](VisualizationGraphWidget &graphWidget) { graphWidget.accept(visitor); }); |
|
343 | [visitor](VisualizationGraphWidget &graphWidget) { graphWidget.accept(visitor); }); | |
330 |
|
344 | |||
331 | visitor->visitLeave(this); |
|
345 | visitor->visitLeave(this); | |
332 | } |
|
346 | } | |
333 | else { |
|
347 | else { | |
334 | qCCritical(LOG_VisualizationZoneWidget()) << tr("Can't visit widget : the visitor is null"); |
|
348 | qCCritical(LOG_VisualizationZoneWidget()) << tr("Can't visit widget : the visitor is null"); | |
335 | } |
|
349 | } | |
336 | } |
|
350 | } | |
337 |
|
351 | |||
338 | bool VisualizationZoneWidget::canDrop(const Variable &variable) const |
|
352 | bool VisualizationZoneWidget::canDrop(const Variable &variable) const | |
339 | { |
|
353 | { | |
340 | // A tab can always accomodate a variable |
|
354 | // A tab can always accomodate a variable | |
341 | Q_UNUSED(variable); |
|
355 | Q_UNUSED(variable); | |
342 | return true; |
|
356 | return true; | |
343 | } |
|
357 | } | |
344 |
|
358 | |||
345 | bool VisualizationZoneWidget::contains(const Variable &variable) const |
|
359 | bool VisualizationZoneWidget::contains(const Variable &variable) const | |
346 | { |
|
360 | { | |
347 | Q_UNUSED(variable); |
|
361 | Q_UNUSED(variable); | |
348 | return false; |
|
362 | return false; | |
349 | } |
|
363 | } | |
350 |
|
364 | |||
351 | QString VisualizationZoneWidget::name() const |
|
365 | QString VisualizationZoneWidget::name() const | |
352 | { |
|
366 | { | |
353 | return ui->zoneNameLabel->text(); |
|
367 | return ui->zoneNameLabel->text(); | |
354 | } |
|
368 | } | |
355 |
|
369 | |||
356 | QMimeData *VisualizationZoneWidget::mimeData(const QPoint &position) const |
|
370 | QMimeData *VisualizationZoneWidget::mimeData(const QPoint &position) const | |
357 | { |
|
371 | { | |
358 | Q_UNUSED(position); |
|
372 | Q_UNUSED(position); | |
359 |
|
373 | |||
360 | auto mimeData = new QMimeData; |
|
374 | auto mimeData = new QMimeData; | |
361 | mimeData->setData(MIME_TYPE_ZONE, QByteArray{}); |
|
375 | mimeData->setData(MIME_TYPE_ZONE, QByteArray{}); | |
362 |
|
376 | |||
363 | if (auto firstGraph = this->firstGraph()) { |
|
377 | if (auto firstGraph = this->firstGraph()) { | |
364 | auto timeRangeData = TimeController::mimeDataForTimeRange(firstGraph->graphRange()); |
|
378 | auto timeRangeData = TimeController::mimeDataForTimeRange(firstGraph->graphRange()); | |
365 | mimeData->setData(MIME_TYPE_TIME_RANGE, timeRangeData); |
|
379 | mimeData->setData(MIME_TYPE_TIME_RANGE, timeRangeData); | |
366 | } |
|
380 | } | |
367 |
|
381 | |||
368 | return mimeData; |
|
382 | return mimeData; | |
369 | } |
|
383 | } | |
370 |
|
384 | |||
371 | bool VisualizationZoneWidget::isDragAllowed() const |
|
385 | bool VisualizationZoneWidget::isDragAllowed() const | |
372 | { |
|
386 | { | |
373 | return true; |
|
387 | return true; | |
374 | } |
|
388 | } | |
375 |
|
389 | |||
376 | void VisualizationZoneWidget::notifyMouseMoveInGraph(const QPointF &graphPosition, |
|
390 | void VisualizationZoneWidget::notifyMouseMoveInGraph(const QPointF &graphPosition, | |
377 | const QPointF &plotPosition, |
|
391 | const QPointF &plotPosition, | |
378 | VisualizationGraphWidget *graphWidget) |
|
392 | VisualizationGraphWidget *graphWidget) | |
379 | { |
|
393 | { | |
380 | processGraphs(*ui->dragDropContainer->layout(), [&graphPosition, &plotPosition, &graphWidget]( |
|
394 | processGraphs(*ui->dragDropContainer->layout(), [&graphPosition, &plotPosition, &graphWidget]( | |
381 | VisualizationGraphWidget &processedGraph) { |
|
395 | VisualizationGraphWidget &processedGraph) { | |
382 |
|
396 | |||
383 | switch (sqpApp->plotsCursorMode()) { |
|
397 | switch (sqpApp->plotsCursorMode()) { | |
384 | case SqpApplication::PlotsCursorMode::Vertical: |
|
398 | case SqpApplication::PlotsCursorMode::Vertical: | |
385 | processedGraph.removeHorizontalCursor(); |
|
399 | processedGraph.removeHorizontalCursor(); | |
386 | processedGraph.addVerticalCursorAtViewportPosition(graphPosition.x()); |
|
400 | processedGraph.addVerticalCursorAtViewportPosition(graphPosition.x()); | |
387 | break; |
|
401 | break; | |
388 | case SqpApplication::PlotsCursorMode::Temporal: |
|
402 | case SqpApplication::PlotsCursorMode::Temporal: | |
389 | processedGraph.addVerticalCursor(plotPosition.x()); |
|
403 | processedGraph.addVerticalCursor(plotPosition.x()); | |
390 | processedGraph.removeHorizontalCursor(); |
|
404 | processedGraph.removeHorizontalCursor(); | |
391 | break; |
|
405 | break; | |
392 | case SqpApplication::PlotsCursorMode::Horizontal: |
|
406 | case SqpApplication::PlotsCursorMode::Horizontal: | |
393 | processedGraph.removeVerticalCursor(); |
|
407 | processedGraph.removeVerticalCursor(); | |
394 | if (&processedGraph == graphWidget) { |
|
408 | if (&processedGraph == graphWidget) { | |
395 | processedGraph.addHorizontalCursorAtViewportPosition(graphPosition.y()); |
|
409 | processedGraph.addHorizontalCursorAtViewportPosition(graphPosition.y()); | |
396 | } |
|
410 | } | |
397 | else { |
|
411 | else { | |
398 | processedGraph.removeHorizontalCursor(); |
|
412 | processedGraph.removeHorizontalCursor(); | |
399 | } |
|
413 | } | |
400 | break; |
|
414 | break; | |
401 | case SqpApplication::PlotsCursorMode::Cross: |
|
415 | case SqpApplication::PlotsCursorMode::Cross: | |
402 | if (&processedGraph == graphWidget) { |
|
416 | if (&processedGraph == graphWidget) { | |
403 | processedGraph.addVerticalCursorAtViewportPosition(graphPosition.x()); |
|
417 | processedGraph.addVerticalCursorAtViewportPosition(graphPosition.x()); | |
404 | processedGraph.addHorizontalCursorAtViewportPosition(graphPosition.y()); |
|
418 | processedGraph.addHorizontalCursorAtViewportPosition(graphPosition.y()); | |
405 | } |
|
419 | } | |
406 | else { |
|
420 | else { | |
407 | processedGraph.removeHorizontalCursor(); |
|
421 | processedGraph.removeHorizontalCursor(); | |
408 | processedGraph.removeVerticalCursor(); |
|
422 | processedGraph.removeVerticalCursor(); | |
409 | } |
|
423 | } | |
410 | break; |
|
424 | break; | |
411 | case SqpApplication::PlotsCursorMode::NoCursor: |
|
425 | case SqpApplication::PlotsCursorMode::NoCursor: | |
412 | processedGraph.removeHorizontalCursor(); |
|
426 | processedGraph.removeHorizontalCursor(); | |
413 | processedGraph.removeVerticalCursor(); |
|
427 | processedGraph.removeVerticalCursor(); | |
414 | break; |
|
428 | break; | |
415 | } |
|
429 | } | |
416 |
|
430 | |||
417 |
|
431 | |||
418 | }); |
|
432 | }); | |
419 | } |
|
433 | } | |
420 |
|
434 | |||
421 | void VisualizationZoneWidget::notifyMouseLeaveGraph(VisualizationGraphWidget *graphWidget) |
|
435 | void VisualizationZoneWidget::notifyMouseLeaveGraph(VisualizationGraphWidget *graphWidget) | |
422 | { |
|
436 | { | |
423 | processGraphs(*ui->dragDropContainer->layout(), [](VisualizationGraphWidget &processedGraph) { |
|
437 | processGraphs(*ui->dragDropContainer->layout(), [](VisualizationGraphWidget &processedGraph) { | |
424 | processedGraph.removeHorizontalCursor(); |
|
438 | processedGraph.removeHorizontalCursor(); | |
425 | processedGraph.removeVerticalCursor(); |
|
439 | processedGraph.removeVerticalCursor(); | |
426 | }); |
|
440 | }); | |
427 | } |
|
441 | } | |
428 |
|
442 | |||
429 | void VisualizationZoneWidget::closeEvent(QCloseEvent *event) |
|
443 | void VisualizationZoneWidget::closeEvent(QCloseEvent *event) | |
430 | { |
|
444 | { | |
431 | // Closes graphs in the zone |
|
445 | // Closes graphs in the zone | |
432 | processGraphs(*ui->dragDropContainer->layout(), |
|
446 | processGraphs(*ui->dragDropContainer->layout(), | |
433 | [](VisualizationGraphWidget &graphWidget) { graphWidget.close(); }); |
|
447 | [](VisualizationGraphWidget &graphWidget) { graphWidget.close(); }); | |
434 |
|
448 | |||
435 | // Delete synchronization group from variable controller |
|
449 | // Delete synchronization group from variable controller | |
436 | QMetaObject::invokeMethod(&sqpApp->variableController(), "onRemoveSynchronizationGroupId", |
|
450 | QMetaObject::invokeMethod(&sqpApp->variableController(), "onRemoveSynchronizationGroupId", | |
437 | Qt::QueuedConnection, Q_ARG(QUuid, impl->m_SynchronisationGroupId)); |
|
451 | Qt::QueuedConnection, Q_ARG(QUuid, impl->m_SynchronisationGroupId)); | |
438 |
|
452 | |||
439 | QWidget::closeEvent(event); |
|
453 | QWidget::closeEvent(event); | |
440 | } |
|
454 | } | |
441 |
|
455 | |||
442 | void VisualizationZoneWidget::onVariableAdded(std::shared_ptr<Variable> variable) |
|
456 | void VisualizationZoneWidget::onVariableAdded(std::shared_ptr<Variable> variable) | |
443 | { |
|
457 | { | |
444 | QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronized", |
|
458 | QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronized", | |
445 | Qt::QueuedConnection, Q_ARG(std::shared_ptr<Variable>, variable), |
|
459 | Qt::QueuedConnection, Q_ARG(std::shared_ptr<Variable>, variable), | |
446 | Q_ARG(QUuid, impl->m_SynchronisationGroupId)); |
|
460 | Q_ARG(QUuid, impl->m_SynchronisationGroupId)); | |
447 | } |
|
461 | } | |
448 |
|
462 | |||
449 | void VisualizationZoneWidget::onVariableAboutToBeRemoved(std::shared_ptr<Variable> variable) |
|
463 | void VisualizationZoneWidget::onVariableAboutToBeRemoved(std::shared_ptr<Variable> variable) | |
450 | { |
|
464 | { | |
451 | QMetaObject::invokeMethod(&sqpApp->variableController(), "desynchronize", Qt::QueuedConnection, |
|
465 | QMetaObject::invokeMethod(&sqpApp->variableController(), "desynchronize", Qt::QueuedConnection, | |
452 | Q_ARG(std::shared_ptr<Variable>, variable), |
|
466 | Q_ARG(std::shared_ptr<Variable>, variable), | |
453 | Q_ARG(QUuid, impl->m_SynchronisationGroupId)); |
|
467 | Q_ARG(QUuid, impl->m_SynchronisationGroupId)); | |
454 | } |
|
468 | } | |
455 |
|
469 | |||
456 | void VisualizationZoneWidget::dropMimeData(int index, const QMimeData *mimeData) |
|
470 | void VisualizationZoneWidget::dropMimeData(int index, const QMimeData *mimeData) | |
457 | { |
|
471 | { | |
458 | if (mimeData->hasFormat(MIME_TYPE_GRAPH)) { |
|
472 | if (mimeData->hasFormat(MIME_TYPE_GRAPH)) { | |
459 | impl->dropGraph(index, this); |
|
473 | impl->dropGraph(index, this); | |
460 | } |
|
474 | } | |
461 | else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { |
|
475 | else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { | |
462 | auto variables = sqpApp->variableController().variablesForMimeData( |
|
476 | auto variables = sqpApp->variableController().variablesForMimeData( | |
463 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); |
|
477 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); | |
464 | impl->dropVariables(variables, index, this); |
|
478 | impl->dropVariables(variables, index, this); | |
465 | } |
|
479 | } | |
466 | else { |
|
480 | else { | |
467 | qCWarning(LOG_VisualizationZoneWidget()) |
|
481 | qCWarning(LOG_VisualizationZoneWidget()) | |
468 | << tr("VisualizationZoneWidget::dropMimeData, unknown MIME data received."); |
|
482 | << tr("VisualizationZoneWidget::dropMimeData, unknown MIME data received."); | |
469 | } |
|
483 | } | |
470 | } |
|
484 | } | |
471 |
|
485 | |||
472 | void VisualizationZoneWidget::dropMimeDataOnGraph(VisualizationDragWidget *dragWidget, |
|
486 | void VisualizationZoneWidget::dropMimeDataOnGraph(VisualizationDragWidget *dragWidget, | |
473 | const QMimeData *mimeData) |
|
487 | const QMimeData *mimeData) | |
474 | { |
|
488 | { | |
475 | auto graphWidget = qobject_cast<VisualizationGraphWidget *>(dragWidget); |
|
489 | auto graphWidget = qobject_cast<VisualizationGraphWidget *>(dragWidget); | |
476 | if (!graphWidget) { |
|
490 | if (!graphWidget) { | |
477 | qCWarning(LOG_VisualizationZoneWidget()) |
|
491 | qCWarning(LOG_VisualizationZoneWidget()) | |
478 | << tr("VisualizationZoneWidget::dropMimeDataOnGraph, dropping in an unknown widget, " |
|
492 | << tr("VisualizationZoneWidget::dropMimeDataOnGraph, dropping in an unknown widget, " | |
479 | "drop aborted"); |
|
493 | "drop aborted"); | |
480 | Q_ASSERT(false); |
|
494 | Q_ASSERT(false); | |
481 | return; |
|
495 | return; | |
482 | } |
|
496 | } | |
483 |
|
497 | |||
484 | if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { |
|
498 | if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { | |
485 | auto variables = sqpApp->variableController().variablesForMimeData( |
|
499 | auto variables = sqpApp->variableController().variablesForMimeData( | |
486 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); |
|
500 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); | |
487 | for (const auto &var : variables) { |
|
501 | for (const auto &var : variables) { | |
488 | graphWidget->addVariable(var, graphWidget->graphRange()); |
|
502 | graphWidget->addVariable(var, graphWidget->graphRange()); | |
489 | } |
|
503 | } | |
490 | } |
|
504 | } | |
491 | else if (mimeData->hasFormat(MIME_TYPE_TIME_RANGE)) { |
|
505 | else if (mimeData->hasFormat(MIME_TYPE_TIME_RANGE)) { | |
492 | auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME_TYPE_TIME_RANGE)); |
|
506 | auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME_TYPE_TIME_RANGE)); | |
493 | graphWidget->setGraphRange(range); |
|
507 | graphWidget->setGraphRange(range); | |
494 | } |
|
508 | } | |
495 | else { |
|
509 | else { | |
496 | qCWarning(LOG_VisualizationZoneWidget()) |
|
510 | qCWarning(LOG_VisualizationZoneWidget()) | |
497 | << tr("VisualizationZoneWidget::dropMimeDataOnGraph, unknown MIME data received."); |
|
511 | << tr("VisualizationZoneWidget::dropMimeDataOnGraph, unknown MIME data received."); | |
498 | } |
|
512 | } | |
499 | } |
|
513 | } | |
500 |
|
514 | |||
501 | void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph( |
|
515 | void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph( | |
502 | int index, VisualizationZoneWidget *zoneWidget) |
|
516 | int index, VisualizationZoneWidget *zoneWidget) | |
503 | { |
|
517 | { | |
504 | auto &helper = sqpApp->dragDropGuiController(); |
|
518 | auto &helper = sqpApp->dragDropGuiController(); | |
505 |
|
519 | |||
506 | auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget()); |
|
520 | auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget()); | |
507 | if (!graphWidget) { |
|
521 | if (!graphWidget) { | |
508 | qCWarning(LOG_VisualizationZoneWidget()) |
|
522 | qCWarning(LOG_VisualizationZoneWidget()) | |
509 | << tr("VisualizationZoneWidget::dropGraph, drop aborted, the dropped graph is not " |
|
523 | << tr("VisualizationZoneWidget::dropGraph, drop aborted, the dropped graph is not " | |
510 | "found or invalid."); |
|
524 | "found or invalid."); | |
511 | Q_ASSERT(false); |
|
525 | Q_ASSERT(false); | |
512 | return; |
|
526 | return; | |
513 | } |
|
527 | } | |
514 |
|
528 | |||
515 | auto parentDragDropContainer |
|
529 | auto parentDragDropContainer | |
516 | = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget()); |
|
530 | = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget()); | |
517 | if (!parentDragDropContainer) { |
|
531 | if (!parentDragDropContainer) { | |
518 | qCWarning(LOG_VisualizationZoneWidget()) |
|
532 | qCWarning(LOG_VisualizationZoneWidget()) | |
519 | << tr("VisualizationZoneWidget::dropGraph, drop aborted, the parent container of " |
|
533 | << tr("VisualizationZoneWidget::dropGraph, drop aborted, the parent container of " | |
520 | "the dropped graph is not found."); |
|
534 | "the dropped graph is not found."); | |
521 | Q_ASSERT(false); |
|
535 | Q_ASSERT(false); | |
522 | return; |
|
536 | return; | |
523 | } |
|
537 | } | |
524 |
|
538 | |||
525 | const auto &variables = graphWidget->variables(); |
|
539 | const auto &variables = graphWidget->variables(); | |
526 |
|
540 | |||
527 | if (parentDragDropContainer != zoneWidget->ui->dragDropContainer && !variables.isEmpty()) { |
|
541 | if (parentDragDropContainer != zoneWidget->ui->dragDropContainer && !variables.isEmpty()) { | |
528 | // The drop didn't occur in the same zone |
|
542 | // The drop didn't occur in the same zone | |
529 |
|
543 | |||
530 | // Abort the requests for the variables (if any) |
|
544 | // Abort the requests for the variables (if any) | |
531 | // Commented, because it's not sure if it's needed or not |
|
545 | // Commented, because it's not sure if it's needed or not | |
532 | // for (const auto& var : variables) |
|
546 | // for (const auto& var : variables) | |
533 | //{ |
|
547 | //{ | |
534 | // sqpApp->variableController().onAbortProgressRequested(var); |
|
548 | // sqpApp->variableController().onAbortProgressRequested(var); | |
535 | //} |
|
549 | //} | |
536 |
|
550 | |||
537 | auto previousParentZoneWidget = graphWidget->parentZoneWidget(); |
|
551 | auto previousParentZoneWidget = graphWidget->parentZoneWidget(); | |
538 | auto nbGraph = parentDragDropContainer->countDragWidget(); |
|
552 | auto nbGraph = parentDragDropContainer->countDragWidget(); | |
539 | if (nbGraph == 1) { |
|
553 | if (nbGraph == 1) { | |
540 | // This is the only graph in the previous zone, close the zone |
|
554 | // This is the only graph in the previous zone, close the zone | |
541 | helper.delayedCloseWidget(previousParentZoneWidget); |
|
555 | helper.delayedCloseWidget(previousParentZoneWidget); | |
542 | } |
|
556 | } | |
543 | else { |
|
557 | else { | |
544 | // Close the graph |
|
558 | // Close the graph | |
545 | helper.delayedCloseWidget(graphWidget); |
|
559 | helper.delayedCloseWidget(graphWidget); | |
546 | } |
|
560 | } | |
547 |
|
561 | |||
548 | // Creates the new graph in the zone |
|
562 | // Creates the new graph in the zone | |
549 | auto newGraphWidget = zoneWidget->createGraph(variables, index); |
|
563 | auto newGraphWidget = zoneWidget->createGraph(variables, index); | |
550 | newGraphWidget->addSelectionZones(graphWidget->selectionZoneRanges()); |
|
564 | newGraphWidget->addSelectionZones(graphWidget->selectionZoneRanges()); | |
551 | } |
|
565 | } | |
552 | else { |
|
566 | else { | |
553 | // The drop occurred in the same zone or the graph is empty |
|
567 | // The drop occurred in the same zone or the graph is empty | |
554 | // Simple move of the graph, no variable operation associated |
|
568 | // Simple move of the graph, no variable operation associated | |
555 | parentDragDropContainer->layout()->removeWidget(graphWidget); |
|
569 | parentDragDropContainer->layout()->removeWidget(graphWidget); | |
556 |
|
570 | |||
557 | if (variables.isEmpty() && parentDragDropContainer != zoneWidget->ui->dragDropContainer) { |
|
571 | if (variables.isEmpty() && parentDragDropContainer != zoneWidget->ui->dragDropContainer) { | |
558 | // The graph is empty and dropped in a different zone. |
|
572 | // The graph is empty and dropped in a different zone. | |
559 | // Take the range of the first graph in the zone (if existing). |
|
573 | // Take the range of the first graph in the zone (if existing). | |
560 | auto layout = zoneWidget->ui->dragDropContainer->layout(); |
|
574 | auto layout = zoneWidget->ui->dragDropContainer->layout(); | |
561 | if (layout->count() > 0) { |
|
575 | if (layout->count() > 0) { | |
562 | if (auto visualizationGraphWidget |
|
576 | if (auto visualizationGraphWidget | |
563 | = qobject_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) { |
|
577 | = qobject_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) { | |
564 | graphWidget->setGraphRange(visualizationGraphWidget->graphRange()); |
|
578 | graphWidget->setGraphRange(visualizationGraphWidget->graphRange()); | |
565 | } |
|
579 | } | |
566 | } |
|
580 | } | |
567 | } |
|
581 | } | |
568 |
|
582 | |||
569 | zoneWidget->ui->dragDropContainer->insertDragWidget(index, graphWidget); |
|
583 | zoneWidget->ui->dragDropContainer->insertDragWidget(index, graphWidget); | |
570 | } |
|
584 | } | |
571 | } |
|
585 | } | |
572 |
|
586 | |||
573 | void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropVariables( |
|
587 | void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropVariables( | |
574 | const QList<std::shared_ptr<Variable> > &variables, int index, |
|
588 | const QList<std::shared_ptr<Variable> > &variables, int index, | |
575 | VisualizationZoneWidget *zoneWidget) |
|
589 | VisualizationZoneWidget *zoneWidget) | |
576 | { |
|
590 | { | |
577 | // Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and |
|
591 | // Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and | |
578 | // compatible variable here |
|
592 | // compatible variable here | |
579 | if (variables.count() > 1) { |
|
593 | if (variables.count() > 1) { | |
580 | qCWarning(LOG_VisualizationZoneWidget()) |
|
594 | qCWarning(LOG_VisualizationZoneWidget()) | |
581 | << tr("VisualizationZoneWidget::dropVariables, dropping multiple variables, operation " |
|
595 | << tr("VisualizationZoneWidget::dropVariables, dropping multiple variables, operation " | |
582 | "aborted."); |
|
596 | "aborted."); | |
583 | return; |
|
597 | return; | |
584 | } |
|
598 | } | |
585 |
|
599 | |||
586 | zoneWidget->createGraph(variables, index); |
|
600 | zoneWidget->createGraph(variables, index); | |
587 | } |
|
601 | } |
@@ -1,139 +1,154 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>CatalogueEventsWidget</class> |
|
3 | <class>CatalogueEventsWidget</class> | |
4 | <widget class="QWidget" name="CatalogueEventsWidget"> |
|
4 | <widget class="QWidget" name="CatalogueEventsWidget"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>566</width> |
|
9 | <width>566</width> | |
10 | <height>258</height> |
|
10 | <height>258</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Form</string> |
|
14 | <string>Form</string> | |
15 | </property> |
|
15 | </property> | |
16 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
16 | <layout class="QVBoxLayout" name="verticalLayout"> | |
17 | <property name="leftMargin"> |
|
17 | <property name="leftMargin"> | |
18 | <number>0</number> |
|
18 | <number>0</number> | |
19 | </property> |
|
19 | </property> | |
20 | <property name="topMargin"> |
|
20 | <property name="topMargin"> | |
21 | <number>0</number> |
|
21 | <number>0</number> | |
22 | </property> |
|
22 | </property> | |
23 | <property name="rightMargin"> |
|
23 | <property name="rightMargin"> | |
24 | <number>0</number> |
|
24 | <number>0</number> | |
25 | </property> |
|
25 | </property> | |
26 | <property name="bottomMargin"> |
|
26 | <property name="bottomMargin"> | |
27 | <number>0</number> |
|
27 | <number>0</number> | |
28 | </property> |
|
28 | </property> | |
29 | <item> |
|
29 | <item> | |
30 | <layout class="QHBoxLayout" name="horizontalLayout"> |
|
30 | <layout class="QHBoxLayout" name="horizontalLayout"> | |
31 | <item> |
|
31 | <item> | |
32 | <widget class="QToolButton" name="btnAdd"> |
|
32 | <widget class="QToolButton" name="btnAdd"> | |
33 | <property name="text"> |
|
33 | <property name="text"> | |
34 | <string>+</string> |
|
34 | <string>+</string> | |
35 | </property> |
|
35 | </property> | |
36 | <property name="icon"> |
|
36 | <property name="icon"> | |
37 | <iconset> |
|
37 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
38 | <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset> |
|
38 | <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset> | |
39 | </property> |
|
39 | </property> | |
40 | <property name="autoRaise"> |
|
40 | <property name="autoRaise"> | |
41 | <bool>true</bool> |
|
41 | <bool>true</bool> | |
42 | </property> |
|
42 | </property> | |
43 | </widget> |
|
43 | </widget> | |
44 | </item> |
|
44 | </item> | |
45 | <item> |
|
45 | <item> | |
46 | <widget class="QToolButton" name="btnRemove"> |
|
46 | <widget class="QToolButton" name="btnRemove"> | |
47 | <property name="text"> |
|
47 | <property name="text"> | |
48 | <string> - </string> |
|
48 | <string> - </string> | |
49 | </property> |
|
49 | </property> | |
50 | <property name="icon"> |
|
50 | <property name="icon"> | |
51 | <iconset> |
|
51 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
52 | <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset> |
|
52 | <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset> | |
53 | </property> |
|
53 | </property> | |
54 | <property name="autoRaise"> |
|
54 | <property name="autoRaise"> | |
55 | <bool>true</bool> |
|
55 | <bool>true</bool> | |
56 | </property> |
|
56 | </property> | |
57 | </widget> |
|
57 | </widget> | |
58 | </item> |
|
58 | </item> | |
59 | <item> |
|
59 | <item> | |
60 | <widget class="Line" name="line"> |
|
60 | <widget class="Line" name="line"> | |
61 | <property name="orientation"> |
|
61 | <property name="orientation"> | |
62 | <enum>Qt::Vertical</enum> |
|
62 | <enum>Qt::Vertical</enum> | |
63 | </property> |
|
63 | </property> | |
64 | </widget> |
|
64 | </widget> | |
65 | </item> |
|
65 | </item> | |
66 | <item> |
|
66 | <item> | |
67 | <widget class="QToolButton" name="btnTime"> |
|
67 | <widget class="QToolButton" name="btnTime"> | |
68 | <property name="text"> |
|
68 | <property name="text"> | |
69 | <string>T</string> |
|
69 | <string>T</string> | |
70 | </property> |
|
70 | </property> | |
71 | <property name="icon"> |
|
71 | <property name="icon"> | |
72 | <iconset> |
|
72 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
73 | <normaloff>:/icones/time.png</normaloff>:/icones/time.png</iconset> |
|
73 | <normaloff>:/icones/time.png</normaloff>:/icones/time.png</iconset> | |
74 | </property> |
|
74 | </property> | |
75 | <property name="checkable"> |
|
75 | <property name="checkable"> | |
76 | <bool>true</bool> |
|
76 | <bool>true</bool> | |
77 | </property> |
|
77 | </property> | |
78 | <property name="autoRaise"> |
|
78 | <property name="autoRaise"> | |
79 | <bool>true</bool> |
|
79 | <bool>true</bool> | |
80 | </property> |
|
80 | </property> | |
81 | </widget> |
|
81 | </widget> | |
82 | </item> |
|
82 | </item> | |
83 | <item> |
|
83 | <item> | |
84 | <widget class="QToolButton" name="btnChart"> |
|
84 | <widget class="QToolButton" name="btnChart"> | |
85 | <property name="text"> |
|
85 | <property name="text"> | |
86 | <string>G</string> |
|
86 | <string>G</string> | |
87 | </property> |
|
87 | </property> | |
88 | <property name="icon"> |
|
88 | <property name="icon"> | |
89 | <iconset> |
|
89 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
90 | <normaloff>:/icones/chart.png</normaloff>:/icones/chart.png</iconset> |
|
90 | <normaloff>:/icones/chart.png</normaloff>:/icones/chart.png</iconset> | |
91 | </property> |
|
91 | </property> | |
92 | <property name="checkable"> |
|
92 | <property name="checkable"> | |
93 | <bool>true</bool> |
|
93 | <bool>true</bool> | |
94 | </property> |
|
94 | </property> | |
95 | <property name="autoRaise"> |
|
95 | <property name="autoRaise"> | |
96 | <bool>true</bool> |
|
96 | <bool>true</bool> | |
97 | </property> |
|
97 | </property> | |
98 | </widget> |
|
98 | </widget> | |
99 | </item> |
|
99 | </item> | |
100 | <item> |
|
100 | <item> | |
101 | <widget class="Line" name="line_2"> |
|
101 | <widget class="Line" name="line_2"> | |
102 | <property name="orientation"> |
|
102 | <property name="orientation"> | |
103 | <enum>Qt::Vertical</enum> |
|
103 | <enum>Qt::Vertical</enum> | |
104 | </property> |
|
104 | </property> | |
105 | </widget> |
|
105 | </widget> | |
106 | </item> |
|
106 | </item> | |
107 | <item> |
|
107 | <item> | |
108 | <widget class="QLineEdit" name="lineEdit"> |
|
108 | <widget class="QLineEdit" name="lineEdit"> | |
109 | <property name="enabled"> |
|
109 | <property name="enabled"> | |
110 | <bool>false</bool> |
|
110 | <bool>false</bool> | |
111 | </property> |
|
111 | </property> | |
112 | </widget> |
|
112 | </widget> | |
113 | </item> |
|
113 | </item> | |
114 | </layout> |
|
114 | </layout> | |
115 | </item> |
|
115 | </item> | |
116 | <item> |
|
116 | <item> | |
117 |
<widget class="QTable |
|
117 | <widget class="QTableView" name="tableView"> | |
118 |
<property name=" |
|
118 | <property name="dragEnabled"> | |
119 | <bool>true</bool> |
|
119 | <bool>true</bool> | |
120 | </property> |
|
120 | </property> | |
|
121 | <property name="dragDropMode"> | |||
|
122 | <enum>QAbstractItemView::DragDrop</enum> | |||
|
123 | </property> | |||
121 | <property name="selectionBehavior"> |
|
124 | <property name="selectionBehavior"> | |
122 | <enum>QAbstractItemView::SelectRows</enum> |
|
125 | <enum>QAbstractItemView::SelectRows</enum> | |
123 | </property> |
|
126 | </property> | |
|
127 | <attribute name="horizontalHeaderVisible"> | |||
|
128 | <bool>true</bool> | |||
|
129 | </attribute> | |||
124 | <attribute name="horizontalHeaderHighlightSections"> |
|
130 | <attribute name="horizontalHeaderHighlightSections"> | |
125 | <bool>false</bool> |
|
131 | <bool>false</bool> | |
126 | </attribute> |
|
132 | </attribute> | |
|
133 | <attribute name="horizontalHeaderShowSortIndicator" stdset="0"> | |||
|
134 | <bool>true</bool> | |||
|
135 | </attribute> | |||
127 | <attribute name="verticalHeaderVisible"> |
|
136 | <attribute name="verticalHeaderVisible"> | |
128 | <bool>false</bool> |
|
137 | <bool>false</bool> | |
129 | </attribute> |
|
138 | </attribute> | |
130 | <attribute name="verticalHeaderDefaultSectionSize"> |
|
139 | <attribute name="verticalHeaderDefaultSectionSize"> | |
131 | <number>25</number> |
|
140 | <number>25</number> | |
132 | </attribute> |
|
141 | </attribute> | |
|
142 | <attribute name="verticalHeaderHighlightSections"> | |||
|
143 | <bool>false</bool> | |||
|
144 | </attribute> | |||
133 | </widget> |
|
145 | </widget> | |
134 | </item> |
|
146 | </item> | |
135 | </layout> |
|
147 | </layout> | |
136 | </widget> |
|
148 | </widget> | |
137 |
<resources |
|
149 | <resources> | |
|
150 | <include location="../../resources/sqpguiresources.qrc"/> | |||
|
151 | <include location="../../resources/sqpguiresources.qrc"/> | |||
|
152 | </resources> | |||
138 | <connections/> |
|
153 | <connections/> | |
139 | </ui> |
|
154 | </ui> |
@@ -1,90 +1,96 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>CatalogueSideBarWidget</class> |
|
3 | <class>CatalogueSideBarWidget</class> | |
4 | <widget class="QWidget" name="CatalogueSideBarWidget"> |
|
4 | <widget class="QWidget" name="CatalogueSideBarWidget"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>330</width> |
|
9 | <width>330</width> | |
10 | <height>523</height> |
|
10 | <height>523</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Form</string> |
|
14 | <string>Form</string> | |
15 | </property> |
|
15 | </property> | |
16 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
16 | <layout class="QVBoxLayout" name="verticalLayout"> | |
17 | <property name="leftMargin"> |
|
17 | <property name="leftMargin"> | |
18 | <number>0</number> |
|
18 | <number>0</number> | |
19 | </property> |
|
19 | </property> | |
20 | <property name="topMargin"> |
|
20 | <property name="topMargin"> | |
21 | <number>0</number> |
|
21 | <number>0</number> | |
22 | </property> |
|
22 | </property> | |
23 | <property name="rightMargin"> |
|
23 | <property name="rightMargin"> | |
24 | <number>0</number> |
|
24 | <number>0</number> | |
25 | </property> |
|
25 | </property> | |
26 | <property name="bottomMargin"> |
|
26 | <property name="bottomMargin"> | |
27 | <number>0</number> |
|
27 | <number>0</number> | |
28 | </property> |
|
28 | </property> | |
29 | <item> |
|
29 | <item> | |
30 | <layout class="QHBoxLayout" name="horizontalLayout"> |
|
30 | <layout class="QHBoxLayout" name="horizontalLayout"> | |
31 | <item> |
|
31 | <item> | |
32 | <widget class="QToolButton" name="btnAdd"> |
|
32 | <widget class="QToolButton" name="btnAdd"> | |
33 | <property name="text"> |
|
33 | <property name="text"> | |
34 | <string>+</string> |
|
34 | <string>+</string> | |
35 | </property> |
|
35 | </property> | |
36 | <property name="icon"> |
|
36 | <property name="icon"> | |
37 | <iconset> |
|
37 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
38 | <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset> |
|
38 | <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset> | |
39 | </property> |
|
39 | </property> | |
40 | <property name="autoRaise"> |
|
40 | <property name="autoRaise"> | |
41 | <bool>true</bool> |
|
41 | <bool>true</bool> | |
42 | </property> |
|
42 | </property> | |
43 | </widget> |
|
43 | </widget> | |
44 | </item> |
|
44 | </item> | |
45 | <item> |
|
45 | <item> | |
46 | <widget class="QToolButton" name="btnRemove"> |
|
46 | <widget class="QToolButton" name="btnRemove"> | |
47 | <property name="text"> |
|
47 | <property name="text"> | |
48 | <string> - </string> |
|
48 | <string> - </string> | |
49 | </property> |
|
49 | </property> | |
50 | <property name="icon"> |
|
50 | <property name="icon"> | |
51 | <iconset> |
|
51 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
52 | <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset> |
|
52 | <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset> | |
53 | </property> |
|
53 | </property> | |
54 | <property name="autoRaise"> |
|
54 | <property name="autoRaise"> | |
55 | <bool>true</bool> |
|
55 | <bool>true</bool> | |
56 | </property> |
|
56 | </property> | |
57 | </widget> |
|
57 | </widget> | |
58 | </item> |
|
58 | </item> | |
59 | <item> |
|
59 | <item> | |
60 | <spacer name="horizontalSpacer"> |
|
60 | <spacer name="horizontalSpacer"> | |
61 | <property name="orientation"> |
|
61 | <property name="orientation"> | |
62 | <enum>Qt::Horizontal</enum> |
|
62 | <enum>Qt::Horizontal</enum> | |
63 | </property> |
|
63 | </property> | |
64 | <property name="sizeHint" stdset="0"> |
|
64 | <property name="sizeHint" stdset="0"> | |
65 | <size> |
|
65 | <size> | |
66 | <width>40</width> |
|
66 | <width>40</width> | |
67 | <height>20</height> |
|
67 | <height>20</height> | |
68 | </size> |
|
68 | </size> | |
69 | </property> |
|
69 | </property> | |
70 | </spacer> |
|
70 | </spacer> | |
71 | </item> |
|
71 | </item> | |
72 | </layout> |
|
72 | </layout> | |
73 | </item> |
|
73 | </item> | |
74 | <item> |
|
74 | <item> | |
75 | <widget class="QTreeWidget" name="treeWidget"> |
|
75 | <widget class="QTreeWidget" name="treeWidget"> | |
|
76 | <property name="selectionMode"> | |||
|
77 | <enum>QAbstractItemView::ExtendedSelection</enum> | |||
|
78 | </property> | |||
76 | <attribute name="headerVisible"> |
|
79 | <attribute name="headerVisible"> | |
77 | <bool>false</bool> |
|
80 | <bool>false</bool> | |
78 | </attribute> |
|
81 | </attribute> | |
79 | <column> |
|
82 | <column> | |
80 | <property name="text"> |
|
83 | <property name="text"> | |
81 | <string notr="true">1</string> |
|
84 | <string notr="true">1</string> | |
82 | </property> |
|
85 | </property> | |
83 | </column> |
|
86 | </column> | |
84 | </widget> |
|
87 | </widget> | |
85 | </item> |
|
88 | </item> | |
86 | </layout> |
|
89 | </layout> | |
87 | </widget> |
|
90 | </widget> | |
88 |
<resources |
|
91 | <resources> | |
|
92 | <include location="../../resources/sqpguiresources.qrc"/> | |||
|
93 | <include location="../../resources/sqpguiresources.qrc"/> | |||
|
94 | </resources> | |||
89 | <connections/> |
|
95 | <connections/> | |
90 | </ui> |
|
96 | </ui> |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now