From 6897882500e5e2bde69c1d3a701c5a9bbafde66c 2017-12-13 11:17:01 From: Thibaud Rabillard Date: 2017-12-13 11:17:01 Subject: [PATCH] Retrieves zone names from the visualization --- diff --git a/app/src/MainWindow.cpp b/app/src/MainWindow.cpp index c96666f..eda17cd 100644 --- a/app/src/MainWindow.cpp +++ b/app/src/MainWindow.cpp @@ -86,6 +86,8 @@ MainWindow::MainWindow(QWidget *parent) m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); + impl->m_CatalogExplorer->setVisualizationWidget(m_Ui->view); + auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); auto openLeftInspectorAction = new QAction{QIcon{ diff --git a/gui/include/Catalogue/CatalogueEventsWidget.h b/gui/include/Catalogue/CatalogueEventsWidget.h index 5793d23..6a1025f 100644 --- a/gui/include/Catalogue/CatalogueEventsWidget.h +++ b/gui/include/Catalogue/CatalogueEventsWidget.h @@ -6,6 +6,7 @@ class DBCatalogue; class DBEvent; +class VisualizationWidget; namespace Ui { class CatalogueEventsWidget; @@ -21,6 +22,8 @@ public: explicit CatalogueEventsWidget(QWidget *parent = 0); virtual ~CatalogueEventsWidget(); + void setVisualizationWidget(VisualizationWidget *visualization); + public slots: void populateWithCatalogues(const QVector &catalogues); diff --git a/gui/include/Catalogue/CatalogueExplorer.h b/gui/include/Catalogue/CatalogueExplorer.h index 0e433f2..9baa58f 100644 --- a/gui/include/Catalogue/CatalogueExplorer.h +++ b/gui/include/Catalogue/CatalogueExplorer.h @@ -1,12 +1,15 @@ #ifndef SCIQLOP_CATALOGUEEXPLORER_H #define SCIQLOP_CATALOGUEEXPLORER_H +#include #include namespace Ui { class CatalogueExplorer; } +class VisualizationWidget; + class CatalogueExplorer : public QDialog { Q_OBJECT @@ -14,8 +17,13 @@ public: explicit CatalogueExplorer(QWidget *parent = 0); virtual ~CatalogueExplorer(); + void setVisualizationWidget(VisualizationWidget *visualization); + private: Ui::CatalogueExplorer *ui; + + class CatalogueExplorerPrivate; + spimpl::unique_impl_ptr impl; }; #endif // SCIQLOP_CATALOGUEEXPLORER_H diff --git a/gui/include/Visualization/VisualizationTabWidget.h b/gui/include/Visualization/VisualizationTabWidget.h index 4df7113..0155bda 100644 --- a/gui/include/Visualization/VisualizationTabWidget.h +++ b/gui/include/Visualization/VisualizationTabWidget.h @@ -25,11 +25,15 @@ public: explicit VisualizationTabWidget(const QString &name = {}, QWidget *parent = 0); virtual ~VisualizationTabWidget(); - /// Add a zone widget + /// Adds a zone widget void addZone(VisualizationZoneWidget *zoneWidget); + /// Inserts a zone widget at the specified position void insertZone(int index, VisualizationZoneWidget *zoneWidget); + /// Returns the list of zone widget names in the order they are displayed + QStringList availableZoneWidgets() const; + /** * Creates a zone using a variable. The variable will be displayed in a new graph of the new * zone. The zone is added at the end. diff --git a/gui/include/Visualization/VisualizationWidget.h b/gui/include/Visualization/VisualizationWidget.h index fedb137..adcfe8a 100644 --- a/gui/include/Visualization/VisualizationWidget.h +++ b/gui/include/Visualization/VisualizationWidget.h @@ -30,6 +30,8 @@ public: /// Returns the class which manage the selection of selection zone across the visualization VisualizationSelectionZoneManager &selectionZoneManager() const; + VisualizationTabWidget *currentTabWidget() const; + // IVisualizationWidget interface void accept(IVisualizationWidgetVisitor *visitor) override; bool canDrop(const Variable &variable) const override; diff --git a/gui/src/Catalogue/CatalogueEventsWidget.cpp b/gui/src/Catalogue/CatalogueEventsWidget.cpp index 1ea37af..5bd5e5d 100644 --- a/gui/src/Catalogue/CatalogueEventsWidget.cpp +++ b/gui/src/Catalogue/CatalogueEventsWidget.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include @@ -21,6 +23,8 @@ struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { QString m_ZoneForTimeMode; QString m_ZoneForGraphMode; + VisualizationWidget *m_VisualizationWidget = nullptr; + void setEvents(const QVector &events, QTableView *tableView) { tableView->setSortingEnabled(false); @@ -42,10 +46,25 @@ struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { tableView->setSortingEnabled(true); } - QStringList selectZone(QWidget *parent, const QStringList &availableZones, - const QStringList &selectedZones, bool allowMultiSelection, - const QPoint &location) + QStringList getAvailableVisualizationZoneList() const + { + if (m_VisualizationWidget) { + if (auto tab = m_VisualizationWidget->currentTabWidget()) { + return tab->availableZoneWidgets(); + } + } + + return QStringList{}; + } + + QStringList selectZone(QWidget *parent, const QStringList &selectedZones, + bool allowMultiSelection, const QPoint &location) { + auto availableZones = getAvailableVisualizationZoneList(); + if (availableZones.isEmpty()) { + return QStringList{}; + } + QDialog d(parent, Qt::Tool); d.setWindowTitle("Choose a zone"); auto layout = new QVBoxLayout{&d}; @@ -103,6 +122,9 @@ struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { result += item->text(); } } + else { + result = selectedZones; + } return result; } @@ -126,8 +148,7 @@ CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) if (checked) { ui->btnChart->setChecked(false); impl->m_ZoneForTimeMode - = impl->selectZone(this, {"Zone 1", "Zone 2", "Zone 3", "Zone 4"}, - {impl->m_ZoneForTimeMode}, false, + = impl->selectZone(this, {impl->m_ZoneForTimeMode}, false, this->mapToGlobal(ui->btnTime->frameGeometry().center())) .value(0); } @@ -137,8 +158,7 @@ CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) if (checked) { ui->btnTime->setChecked(false); impl->m_ZoneForGraphMode - = impl->selectZone(this, {"Zone 1", "Zone 2", "Zone 3", "Zone 4"}, - {impl->m_ZoneForGraphMode}, false, + = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false, this->mapToGlobal(ui->btnChart->frameGeometry().center())) .value(0); } @@ -172,6 +192,11 @@ CatalogueEventsWidget::~CatalogueEventsWidget() delete ui; } +void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualization) +{ + impl->m_VisualizationWidget = visualization; +} + void CatalogueEventsWidget::populateWithCatalogues(const QVector &catalogues) { auto &dao = sqpApp->catalogueController().getDao(); diff --git a/gui/src/Catalogue/CatalogueExplorer.cpp b/gui/src/Catalogue/CatalogueExplorer.cpp index 877b0e6..43c1b1c 100644 --- a/gui/src/Catalogue/CatalogueExplorer.cpp +++ b/gui/src/Catalogue/CatalogueExplorer.cpp @@ -1,12 +1,18 @@ #include "Catalogue/CatalogueExplorer.h" #include "ui_CatalogueExplorer.h" +#include + #include #include +struct CatalogueExplorer::CatalogueExplorerPrivate { +}; + CatalogueExplorer::CatalogueExplorer(QWidget *parent) : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), - ui(new Ui::CatalogueExplorer) + ui(new Ui::CatalogueExplorer), + impl{spimpl::make_unique_impl()} { ui->setupUi(this); @@ -48,3 +54,8 @@ CatalogueExplorer::~CatalogueExplorer() { delete ui; } + +void CatalogueExplorer::setVisualizationWidget(VisualizationWidget *visualization) +{ + ui->events->setVisualizationWidget(visualization); +} diff --git a/gui/src/Visualization/VisualizationTabWidget.cpp b/gui/src/Visualization/VisualizationTabWidget.cpp index ff81937..0ae5135 100644 --- a/gui/src/Visualization/VisualizationTabWidget.cpp +++ b/gui/src/Visualization/VisualizationTabWidget.cpp @@ -118,6 +118,15 @@ void VisualizationTabWidget::insertZone(int index, VisualizationZoneWidget *zone ui->dragDropContainer->insertDragWidget(index, zoneWidget); } +QStringList VisualizationTabWidget::availableZoneWidgets() const +{ + QStringList zones; + processZones(tabLayout(), + [&zones](VisualizationZoneWidget &zoneWidget) { zones << zoneWidget.name(); }); + + return zones; +} + VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr variable) { return createZone({variable}, -1); diff --git a/gui/src/Visualization/VisualizationWidget.cpp b/gui/src/Visualization/VisualizationWidget.cpp index f406a0e..0dfa151 100644 --- a/gui/src/Visualization/VisualizationWidget.cpp +++ b/gui/src/Visualization/VisualizationWidget.cpp @@ -119,6 +119,15 @@ VisualizationSelectionZoneManager &VisualizationWidget::selectionZoneManager() c return *impl->m_ZoneSelectionManager.get(); } +VisualizationTabWidget *VisualizationWidget::currentTabWidget() const +{ + if (auto tab = qobject_cast(ui->tabWidget->currentWidget())) { + return tab; + } + + return nullptr; +} + void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor) { if (visitor) {