##// END OF EJS Templates
Merge branch 'feature/WidgetsNames' into develop
Alexandre Leroux -
r204:418c600ae7b7 merge
parent child
Show More
@@ -19,7 +19,7 class VisualizationGraphWidget : public QWidget, public IVisualizationWidget {
19 Q_OBJECT
19 Q_OBJECT
20
20
21 public:
21 public:
22 explicit VisualizationGraphWidget(QWidget *parent = 0);
22 explicit VisualizationGraphWidget(const QString name = {}, QWidget *parent = 0);
23 virtual ~VisualizationGraphWidget();
23 virtual ~VisualizationGraphWidget();
24
24
25 void addVariable(std::shared_ptr<Variable> variable);
25 void addVariable(std::shared_ptr<Variable> variable);
@@ -3,8 +3,11
3
3
4 #include "Visualization/IVisualizationWidget.h"
4 #include "Visualization/IVisualizationWidget.h"
5
5
6 #include <Common/spimpl.h>
7
6 #include <QWidget>
8 #include <QWidget>
7
9
10 class Variable;
8 class VisualizationZoneWidget;
11 class VisualizationZoneWidget;
9
12
10 namespace Ui {
13 namespace Ui {
@@ -15,14 +18,19 class VisualizationTabWidget : public QWidget, public IVisualizationWidget {
15 Q_OBJECT
18 Q_OBJECT
16
19
17 public:
20 public:
18 explicit VisualizationTabWidget(QWidget *parent = 0);
21 explicit VisualizationTabWidget(const QString &name = {}, QWidget *parent = 0);
19 virtual ~VisualizationTabWidget();
22 virtual ~VisualizationTabWidget();
20
23
21 /// Add a zone widget
24 /// Add a zone widget
22 void addZone(VisualizationZoneWidget *zoneWidget);
25 void addZone(VisualizationZoneWidget *zoneWidget);
23
26
24 /// Create a zone using a Variable
27 /**
25 VisualizationZoneWidget *createZone();
28 * Creates a zone using a variable. The variable will be displayed in a new graph of the new
29 * zone.
30 * @param variable the variable for which to create the zone
31 * @return the pointer to the created zone
32 */
33 VisualizationZoneWidget *createZone(std::shared_ptr<Variable> variable);
26
34
27 /// Remove a zone
35 /// Remove a zone
28 void removeZone(VisualizationZoneWidget *zone);
36 void removeZone(VisualizationZoneWidget *zone);
@@ -34,6 +42,9 public:
34
42
35 private:
43 private:
36 Ui::VisualizationTabWidget *ui;
44 Ui::VisualizationTabWidget *ui;
45
46 class VisualizationTabWidgetPrivate;
47 spimpl::unique_impl_ptr<VisualizationTabWidgetPrivate> impl;
37 };
48 };
38
49
39 #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H
50 #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H
@@ -3,26 +3,31
3
3
4 #include "Visualization/IVisualizationWidget.h"
4 #include "Visualization/IVisualizationWidget.h"
5
5
6 class VisualizationGraphWidget;
7
8 #include <QWidget>
6 #include <QWidget>
9
7
10 namespace Ui {
8 namespace Ui {
11 class VisualizationZoneWidget;
9 class VisualizationZoneWidget;
12 } // Ui
10 } // Ui
13
11
12 class Variable;
13 class VisualizationGraphWidget;
14
14 class VisualizationZoneWidget : public QWidget, public IVisualizationWidget {
15 class VisualizationZoneWidget : public QWidget, public IVisualizationWidget {
15 Q_OBJECT
16 Q_OBJECT
16
17
17 public:
18 public:
18 explicit VisualizationZoneWidget(QWidget *parent = 0);
19 explicit VisualizationZoneWidget(const QString &name = {}, QWidget *parent = 0);
19 virtual ~VisualizationZoneWidget();
20 virtual ~VisualizationZoneWidget();
20
21
21 /// Add a graph widget
22 /// Add a graph widget
22 void addGraph(VisualizationGraphWidget *graphWidget);
23 void addGraph(VisualizationGraphWidget *graphWidget);
23
24
24 /// Create a graph using a Variable
25 /**
25 VisualizationGraphWidget *createGraph();
26 * Creates a graph using a variable. The variable will be displayed in the new graph.
27 * @param variable the variable for which to create the graph
28 * @return the pointer to the created graph
29 */
30 VisualizationGraphWidget *createGraph(std::shared_ptr<Variable> variable);
26
31
27 /// Remove a graph
32 /// Remove a graph
28 void removeGraph(VisualizationGraphWidget *graph);
33 void removeGraph(VisualizationGraphWidget *graph);
@@ -22,13 +22,17 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
22 std::unordered_map<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMap;
22 std::unordered_map<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMap;
23 };
23 };
24
24
25 VisualizationGraphWidget::VisualizationGraphWidget(QWidget *parent)
25 VisualizationGraphWidget::VisualizationGraphWidget(const QString name, QWidget *parent)
26 : QWidget{parent},
26 : QWidget{parent},
27 ui{new Ui::VisualizationGraphWidget},
27 ui{new Ui::VisualizationGraphWidget},
28 impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()}
28 impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()}
29 {
29 {
30 ui->setupUi(this);
30 ui->setupUi(this);
31
31
32 // qcpplot title
33 ui->widget->plotLayout()->insertRow(0);
34 ui->widget->plotLayout()->addElement(0, 0, new QCPTextElement{ui->widget, name});
35
32 // Set qcpplot properties :
36 // Set qcpplot properties :
33 // - Drag (on x-axis) and zoom are enabled
37 // - Drag (on x-axis) and zoom are enabled
34 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
38 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
@@ -65,7 +69,12 void VisualizationGraphWidget::close()
65
69
66 QString VisualizationGraphWidget::name() const
70 QString VisualizationGraphWidget::name() const
67 {
71 {
68 return QStringLiteral("MainView");
72 if (auto title = dynamic_cast<QCPTextElement *>(ui->widget->plotLayout()->elementAt(0))) {
73 return title->text();
74 }
75 else {
76 return QString{};
77 }
69 }
78 }
70
79
71 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
80 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
@@ -3,9 +3,34
3
3
4 #include "Visualization/VisualizationZoneWidget.h"
4 #include "Visualization/VisualizationZoneWidget.h"
5
5
6 namespace {
6
7
7 VisualizationTabWidget::VisualizationTabWidget(QWidget *parent)
8 /// Generates a default name for a new zone, according to the number of zones already displayed in
8 : QWidget{parent}, ui{new Ui::VisualizationTabWidget}
9 /// the tab
10 QString defaultZoneName(const QLayout &layout)
11 {
12 auto count = 0;
13 for (auto i = 0; i < layout.count(); ++i) {
14 if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) {
15 count++;
16 }
17 }
18
19 return QObject::tr("Zone %1").arg(count + 1);
20 }
21
22 } // namespace
23
24 struct VisualizationTabWidget::VisualizationTabWidgetPrivate {
25 explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {}
26
27 QString m_Name;
28 };
29
30 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent)
31 : QWidget{parent},
32 ui{new Ui::VisualizationTabWidget},
33 impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)}
9 {
34 {
10 ui->setupUi(this);
35 ui->setupUi(this);
11 }
36 }
@@ -20,11 +45,14 void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget)
20 this->layout()->addWidget(zoneWidget);
45 this->layout()->addWidget(zoneWidget);
21 }
46 }
22
47
23 VisualizationZoneWidget *VisualizationTabWidget::createZone()
48 VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable)
24 {
49 {
25 auto zoneWidget = new VisualizationZoneWidget{this};
50 auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(*layout()), this};
26 this->addZone(zoneWidget);
51 this->addZone(zoneWidget);
27
52
53 // Creates a new graph into the zone
54 zoneWidget->createGraph(variable);
55
28 return zoneWidget;
56 return zoneWidget;
29 }
57 }
30
58
@@ -45,5 +73,5 void VisualizationTabWidget::close()
45
73
46 QString VisualizationTabWidget::name() const
74 QString VisualizationTabWidget::name() const
47 {
75 {
48 return QStringLiteral("MainView");
76 return impl->m_Name;
49 }
77 }
@@ -32,8 +32,9 VisualizationWidget::VisualizationWidget(QWidget *parent)
32 };
32 };
33
33
34 auto addTabView = [this, enableMinimumCornerWidgetSize]() {
34 auto addTabView = [this, enableMinimumCornerWidgetSize]() {
35 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
35 auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1),
36 QString("View %1").arg(ui->tabWidget->count() + 1));
36 ui->tabWidget};
37 auto index = ui->tabWidget->addTab(widget, widget->name());
37 if (ui->tabWidget->count() > 0) {
38 if (ui->tabWidget->count() > 0) {
38 enableMinimumCornerWidgetSize(false);
39 enableMinimumCornerWidgetSize(false);
39 }
40 }
@@ -54,6 +55,9 VisualizationWidget::VisualizationWidget(QWidget *parent)
54
55
55 connect(addTabViewButton, &QToolButton::clicked, addTabView);
56 connect(addTabViewButton, &QToolButton::clicked, addTabView);
56 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
57 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
58
59 // Adds default tab
60 addTabView();
57 }
61 }
58
62
59 VisualizationWidget::~VisualizationWidget()
63 VisualizationWidget::~VisualizationWidget()
@@ -96,16 +100,7 QString VisualizationWidget::name() const
96 void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept
100 void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept
97 {
101 {
98 if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) {
102 if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) {
99 if (auto newZone = currentTab->createZone()) {
103 if (!currentTab->createZone(variable)) {
100 if (auto newGraph = newZone->createGraph()) {
101 newGraph->addVariable(variable);
102 }
103 else {
104 qCCritical(LOG_VisualizationWidget())
105 << tr("Can't display the variable : can't create the graph");
106 }
107 }
108 else {
109 qCCritical(LOG_VisualizationWidget())
104 qCCritical(LOG_VisualizationWidget())
110 << tr("Can't display the variable : can't create a new zone in the current tab");
105 << tr("Can't display the variable : can't create a new zone in the current tab");
111 }
106 }
@@ -3,10 +3,30
3
3
4 #include "Visualization/VisualizationGraphWidget.h"
4 #include "Visualization/VisualizationGraphWidget.h"
5
5
6 VisualizationZoneWidget::VisualizationZoneWidget(QWidget *parent)
6 namespace {
7
8 /// Generates a default name for a new graph, according to the number of graphs already displayed in
9 /// the zone
10 QString defaultGraphName(const QLayout &layout)
11 {
12 auto count = 0;
13 for (auto i = 0; i < layout.count(); ++i) {
14 if (dynamic_cast<VisualizationGraphWidget *>(layout.itemAt(i)->widget())) {
15 count++;
16 }
17 }
18
19 return QObject::tr("Graph %1").arg(count + 1);
20 }
21
22 } // namespace
23
24 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent)
7 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
25 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
8 {
26 {
9 ui->setupUi(this);
27 ui->setupUi(this);
28
29 ui->zoneNameLabel->setText(name);
10 }
30 }
11
31
12 VisualizationZoneWidget::~VisualizationZoneWidget()
32 VisualizationZoneWidget::~VisualizationZoneWidget()
@@ -19,11 +39,14 void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
19 ui->visualizationZoneFrame->layout()->addWidget(graphWidget);
39 ui->visualizationZoneFrame->layout()->addWidget(graphWidget);
20 }
40 }
21
41
22 VisualizationGraphWidget *VisualizationZoneWidget::createGraph()
42 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable)
23 {
43 {
24 auto graphWidget = new VisualizationGraphWidget{this};
44 auto graphWidget = new VisualizationGraphWidget{
45 defaultGraphName(*ui->visualizationZoneFrame->layout()), this};
25 this->addGraph(graphWidget);
46 this->addGraph(graphWidget);
26
47
48 graphWidget->addVariable(variable);
49
27 return graphWidget;
50 return graphWidget;
28 }
51 }
29
52
@@ -44,5 +67,5 void VisualizationZoneWidget::close()
44
67
45 QString VisualizationZoneWidget::name() const
68 QString VisualizationZoneWidget::name() const
46 {
69 {
47 return QStringLiteral("MainView");
70 return ui->zoneNameLabel->text();
48 }
71 }
@@ -17,25 +17,12
17 <item>
17 <item>
18 <widget class="QTabWidget" name="tabWidget">
18 <widget class="QTabWidget" name="tabWidget">
19 <property name="currentIndex">
19 <property name="currentIndex">
20 <number>0</number>
20 <number>-1</number>
21 </property>
21 </property>
22 <widget class="VisualizationTabWidget" name="firstView">
23 <attribute name="title">
24 <string>View 1</string>
25 </attribute>
26 </widget>
27 </widget>
22 </widget>
28 </item>
23 </item>
29 </layout>
24 </layout>
30 </widget>
25 </widget>
31 <customwidgets>
32 <customwidget>
33 <class>VisualizationTabWidget</class>
34 <extends>QWidget</extends>
35 <header location="global">Visualization/VisualizationTabWidget.h</header>
36 <container>1</container>
37 </customwidget>
38 </customwidgets>
39 <resources/>
26 <resources/>
40 <connections/>
27 <connections/>
41 </ui>
28 </ui>
@@ -14,23 +14,49
14 <string>Form</string>
14 <string>Form</string>
15 </property>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout_2">
16 <layout class="QVBoxLayout" name="verticalLayout_2">
17 <property name="spacing">
17 <item>
18 <number>3</number>
18 <widget class="QWidget" name="infobar" native="true">
19 </property>
19 <property name="sizePolicy">
20 <property name="leftMargin">
20 <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
21 <number>0</number>
21 <horstretch>0</horstretch>
22 </property>
22 <verstretch>0</verstretch>
23 <property name="topMargin">
23 </sizepolicy>
24 <number>0</number>
24 </property>
25 </property>
25 <layout class="QHBoxLayout" name="horizontalLayout">
26 <property name="rightMargin">
26 <property name="leftMargin">
27 <number>0</number>
27 <number>0</number>
28 </property>
28 </property>
29 <property name="bottomMargin">
29 <property name="topMargin">
30 <number>0</number>
30 <number>0</number>
31 </property>
31 </property>
32 <property name="rightMargin">
33 <number>0</number>
34 </property>
35 <property name="bottomMargin">
36 <number>0</number>
37 </property>
38 <item>
39 <widget class="QLabel" name="zoneNameLabel">
40 <property name="styleSheet">
41 <string notr="true">color: rgb(127, 127, 127);
42 </string>
43 </property>
44 <property name="text">
45 <string>TextLabel</string>
46 </property>
47 </widget>
48 </item>
49 </layout>
50 </widget>
51 </item>
32 <item>
52 <item>
33 <widget class="QFrame" name="visualizationZoneFrame">
53 <widget class="QFrame" name="visualizationZoneFrame">
54 <property name="sizePolicy">
55 <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
56 <horstretch>0</horstretch>
57 <verstretch>0</verstretch>
58 </sizepolicy>
59 </property>
34 <property name="frameShape">
60 <property name="frameShape">
35 <enum>QFrame::Box</enum>
61 <enum>QFrame::Box</enum>
36 </property>
62 </property>
@@ -8,4 +8,6 SqpApplication\.h:\d+:.IPSIS_S04_VARIABLE.*found: sqpApp
8
8
9 # Ignore false positive relative to unnamed namespace
9 # Ignore false positive relative to unnamed namespace
10 DataSourceTreeWidgetItem\.cpp:\d+:.*IPSIS_F13.*
10 DataSourceTreeWidgetItem\.cpp:\d+:.*IPSIS_F13.*
11 VisualizationTabWidget\.cpp:\d+:.*IPSIS_F13.*
12 VisualizationZoneWidget\.cpp:\d+:.*IPSIS_F13.*
11
13
General Comments 0
You need to be logged in to leave comments. Login now