##// END OF EJS Templates
Merge branch 'feature/CataloguesBasicGui' into develop
trabillard -
r1142:bc8467a5b117 merge
parent child
Show More
@@ -0,0 +1,31
1 #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H
2 #define SCIQLOP_CATALOGUEEVENTSWIDGET_H
3
4 #include <Common/spimpl.h>
5 #include <QWidget>
6
7 namespace Ui {
8 class CatalogueEventsWidget;
9 }
10
11 class CatalogueEventsWidget : public QWidget {
12 Q_OBJECT
13
14 signals:
15 void eventSelected(const QString &event);
16
17 public:
18 explicit CatalogueEventsWidget(QWidget *parent = 0);
19 virtual ~CatalogueEventsWidget();
20
21 public slots:
22 void populateWithCatalogue(const QString &catalogue);
23
24 private:
25 Ui::CatalogueEventsWidget *ui;
26
27 class CatalogueEventsWidgetPrivate;
28 spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl;
29 };
30
31 #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H
@@ -0,0 +1,21
1 #ifndef SCIQLOP_CATALOGUEEXPLORER_H
2 #define SCIQLOP_CATALOGUEEXPLORER_H
3
4 #include <QDialog>
5
6 namespace Ui {
7 class CatalogueExplorer;
8 }
9
10 class CatalogueExplorer : public QDialog {
11 Q_OBJECT
12
13 public:
14 explicit CatalogueExplorer(QWidget *parent = 0);
15 virtual ~CatalogueExplorer();
16
17 private:
18 Ui::CatalogueExplorer *ui;
19 };
20
21 #endif // SCIQLOP_CATALOGUEEXPLORER_H
@@ -0,0 +1,32
1 #ifndef SCIQLOP_CATALOGUEINSPECTORWIDGET_H
2 #define SCIQLOP_CATALOGUEINSPECTORWIDGET_H
3
4 #include <QWidget>
5
6 namespace Ui {
7 class CatalogueInspectorWidget;
8 }
9
10 class CatalogueInspectorWidget : public QWidget {
11 Q_OBJECT
12
13 public:
14 explicit CatalogueInspectorWidget(QWidget *parent = 0);
15 virtual ~CatalogueInspectorWidget();
16
17 /// Enum matching the pages inside the stacked widget
18 enum class Page { Empty, CatalogueProperties, EventProperties };
19
20 Page currentPage() const;
21
22 void setEvent(const QString &event);
23 void setCatalogue(const QString &catalogue);
24
25 public slots:
26 void showPage(Page page);
27
28 private:
29 Ui::CatalogueInspectorWidget *ui;
30 };
31
32 #endif // SCIQLOP_CATALOGUEINSPECTORWIDGET_H
@@ -0,0 +1,31
1 #ifndef SCIQLOP_CATALOGUESIDEBARWIDGET_H
2 #define SCIQLOP_CATALOGUESIDEBARWIDGET_H
3
4 #include <Common/spimpl.h>
5 #include <QTreeWidgetItem>
6 #include <QWidget>
7
8 namespace Ui {
9 class CatalogueSideBarWidget;
10 }
11
12 class CatalogueSideBarWidget : public QWidget {
13 Q_OBJECT
14
15 signals:
16 void catalogueSelected(const QString &catalogue);
17 void allEventsSelected();
18 void trashSelected();
19
20 public:
21 explicit CatalogueSideBarWidget(QWidget *parent = 0);
22 virtual ~CatalogueSideBarWidget();
23
24 private:
25 Ui::CatalogueSideBarWidget *ui;
26
27 class CatalogueSideBarWidgetPrivate;
28 spimpl::unique_impl_ptr<CatalogueSideBarWidgetPrivate> impl;
29 };
30
31 #endif // SCIQLOP_CATALOGUESIDEBARWIDGET_H
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,100
1 #include "Catalogue/CatalogueEventsWidget.h"
2 #include "ui_CatalogueEventsWidget.h"
3
4 #include <QtDebug>
5
6 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
7 void addEventItem(const QStringList &data, QTableWidget *tableWidget);
8
9 enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn };
10 QStringList columnNames() { return QStringList{"Event", "TStart", "TEnd", "Tags", "Product"}; }
11 };
12
13
14 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
15 : QWidget(parent),
16 ui(new Ui::CatalogueEventsWidget),
17 impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()}
18 {
19 ui->setupUi(this);
20
21 connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) {
22 if (checked) {
23 ui->btnChart->setChecked(false);
24 }
25 });
26
27 connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) {
28 if (checked) {
29 ui->btnTime->setChecked(false);
30 }
31 });
32
33 connect(ui->tableWidget, &QTableWidget::cellClicked, [this](auto row, auto column) {
34 auto event = ui->tableWidget->item(row, 0)->text();
35 emit this->eventSelected(event);
36 });
37
38 connect(ui->tableWidget, &QTableWidget::currentItemChanged,
39 [this](auto current, auto previous) {
40 if (current && current->row() >= 0) {
41 auto event = ui->tableWidget->item(current->row(), 0)->text();
42 emit this->eventSelected(event);
43 }
44 });
45
46 connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, [this]() {
47 auto selection = ui->tableWidget->selectedRanges();
48 auto isNotMultiSelection
49 = selection.isEmpty() || (selection.count() == 1 && selection.first().rowCount() == 1);
50 ui->btnChart->setEnabled(isNotMultiSelection);
51 ui->btnTime->setEnabled(isNotMultiSelection);
52 });
53
54 Q_ASSERT(impl->columnNames().count() == (int)CatalogueEventsWidgetPrivate::Column::NbColumn);
55 ui->tableWidget->setColumnCount((int)CatalogueEventsWidgetPrivate::Column::NbColumn);
56 ui->tableWidget->setHorizontalHeaderLabels(impl->columnNames());
57 ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
58 ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
59 ui->tableWidget->horizontalHeader()->setSortIndicatorShown(true);
60 }
61
62 CatalogueEventsWidget::~CatalogueEventsWidget()
63 {
64 delete ui;
65 }
66
67 void CatalogueEventsWidget::populateWithCatalogue(const QString &catalogue)
68 {
69 ui->tableWidget->clearContents();
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 }
86
87 void CatalogueEventsWidget::CatalogueEventsWidgetPrivate::addEventItem(const QStringList &data,
88 QTableWidget *tableWidget)
89 {
90 tableWidget->setSortingEnabled(false);
91 auto row = tableWidget->rowCount();
92 tableWidget->setRowCount(row + 1);
93
94 for (auto i = 0; i < (int)Column::NbColumn; ++i) {
95 auto item = new QTableWidgetItem(data.value(i));
96 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
97 tableWidget->setItem(row, i, item);
98 }
99 tableWidget->setSortingEnabled(true);
100 }
@@ -0,0 +1,22
1 #include "Catalogue/CatalogueExplorer.h"
2 #include "ui_CatalogueExplorer.h"
3
4 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
5 : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
6 ui(new Ui::CatalogueExplorer)
7 {
8 ui->setupUi(this);
9
10 connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto name) {
11 ui->inspector->setCatalogue(name);
12 ui->events->populateWithCatalogue(name);
13 });
14
15 connect(ui->events, &CatalogueEventsWidget::eventSelected,
16 [this](auto name) { ui->inspector->setEvent(name); });
17 }
18
19 CatalogueExplorer::~CatalogueExplorer()
20 {
21 delete ui;
22 }
@@ -0,0 +1,36
1 #include "Catalogue/CatalogueInspectorWidget.h"
2 #include "ui_CatalogueInspectorWidget.h"
3
4 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
5 : QWidget(parent), ui(new Ui::CatalogueInspectorWidget)
6 {
7 ui->setupUi(this);
8 showPage(Page::Empty);
9 }
10
11 CatalogueInspectorWidget::~CatalogueInspectorWidget()
12 {
13 delete ui;
14 }
15
16 void CatalogueInspectorWidget::showPage(CatalogueInspectorWidget::Page page)
17 {
18 ui->stackedWidget->setCurrentIndex(static_cast<int>(page));
19 }
20
21 CatalogueInspectorWidget::Page CatalogueInspectorWidget::currentPage() const
22 {
23 return static_cast<Page>(ui->stackedWidget->currentIndex());
24 }
25
26 void CatalogueInspectorWidget::setEvent(const QString &event)
27 {
28 showPage(Page::EventProperties);
29 ui->leEventName->setText(event);
30 }
31
32 void CatalogueInspectorWidget::setCatalogue(const QString &catalogue)
33 {
34 showPage(Page::CatalogueProperties);
35 ui->leCatalogueName->setText(catalogue);
36 }
@@ -0,0 +1,101
1 #include "Catalogue/CatalogueSideBarWidget.h"
2 #include "ui_CatalogueSideBarWidget.h"
3
4 constexpr auto ALL_EVENT_ITEM_TYPE = QTreeWidgetItem::UserType;
5 constexpr auto TRASH_ITEM_TYPE = QTreeWidgetItem::UserType + 1;
6 constexpr auto CATALOGUE_ITEM_TYPE = QTreeWidgetItem::UserType + 2;
7 constexpr auto DATABASE_ITEM_TYPE = QTreeWidgetItem::UserType + 3;
8
9
10 struct CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate {
11 void configureTreeWidget(QTreeWidget *treeWidget);
12 QTreeWidgetItem *addDatabaseItem(const QString &name, QTreeWidget *treeWidget);
13 void addCatalogueItem(const QString &name, QTreeWidgetItem *parentDatabaseItem);
14 };
15
16 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
17 : QWidget(parent),
18 ui(new Ui::CatalogueSideBarWidget),
19 impl{spimpl::make_unique_impl<CatalogueSideBarWidgetPrivate>()}
20 {
21 ui->setupUi(this);
22 impl->configureTreeWidget(ui->treeWidget);
23
24 auto emitSelection = [this](auto item) {
25 switch (item->type()) {
26 case CATALOGUE_ITEM_TYPE:
27 emit this->catalogueSelected(item->text(0));
28 break;
29 case ALL_EVENT_ITEM_TYPE:
30 emit this->allEventsSelected();
31 break;
32 case TRASH_ITEM_TYPE:
33 emit this->trashSelected();
34 break;
35 case DATABASE_ITEM_TYPE:
36 default:
37 break;
38 }
39 };
40
41 connect(ui->treeWidget, &QTreeWidget::itemClicked, emitSelection);
42 connect(ui->treeWidget, &QTreeWidget::currentItemChanged, emitSelection);
43 }
44
45 CatalogueSideBarWidget::~CatalogueSideBarWidget()
46 {
47 delete ui;
48 }
49
50 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::configureTreeWidget(
51 QTreeWidget *treeWidget)
52 {
53 auto allEventsItem = new QTreeWidgetItem({"All Events"}, ALL_EVENT_ITEM_TYPE);
54 allEventsItem->setIcon(0, QIcon(":/icones/allEvents.png"));
55 treeWidget->addTopLevelItem(allEventsItem);
56
57 auto trashItem = new QTreeWidgetItem({"Trash"}, TRASH_ITEM_TYPE);
58 trashItem->setIcon(0, QIcon(":/icones/trash.png"));
59 treeWidget->addTopLevelItem(trashItem);
60
61 auto separator = new QFrame(treeWidget);
62 separator->setFrameShape(QFrame::HLine);
63
64 auto separatorItem = new QTreeWidgetItem();
65 separatorItem->setFlags(Qt::NoItemFlags);
66 treeWidget->addTopLevelItem(separatorItem);
67 treeWidget->setItemWidget(separatorItem, 0, separator);
68
69 // Test
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
76 auto db2 = addDatabaseItem("Database 2", treeWidget);
77 addCatalogueItem("Catalogue A", db2);
78 addCatalogueItem("Catalogue B", db2);
79 addCatalogueItem("Catalogue C", db2);
80
81 treeWidget->expandAll();
82 }
83
84 QTreeWidgetItem *
85 CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addDatabaseItem(const QString &name,
86 QTreeWidget *treeWidget)
87 {
88 auto databaseItem = new QTreeWidgetItem({name}, DATABASE_ITEM_TYPE);
89 databaseItem->setIcon(0, QIcon(":/icones/database.png"));
90 treeWidget->addTopLevelItem(databaseItem);
91
92 return databaseItem;
93 }
94
95 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::addCatalogueItem(
96 const QString &name, QTreeWidgetItem *parentDatabaseItem)
97 {
98 auto catalogueItem = new QTreeWidgetItem({name}, CATALOGUE_ITEM_TYPE);
99 catalogueItem->setIcon(0, QIcon(":/icones/catalogue.png"));
100 parentDatabaseItem->addChild(catalogueItem);
101 }
@@ -0,0 +1,139
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>CatalogueEventsWidget</class>
4 <widget class="QWidget" name="CatalogueEventsWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>566</width>
10 <height>258</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <property name="leftMargin">
18 <number>0</number>
19 </property>
20 <property name="topMargin">
21 <number>0</number>
22 </property>
23 <property name="rightMargin">
24 <number>0</number>
25 </property>
26 <property name="bottomMargin">
27 <number>0</number>
28 </property>
29 <item>
30 <layout class="QHBoxLayout" name="horizontalLayout">
31 <item>
32 <widget class="QToolButton" name="btnAdd">
33 <property name="text">
34 <string>+</string>
35 </property>
36 <property name="icon">
37 <iconset>
38 <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset>
39 </property>
40 <property name="autoRaise">
41 <bool>true</bool>
42 </property>
43 </widget>
44 </item>
45 <item>
46 <widget class="QToolButton" name="btnRemove">
47 <property name="text">
48 <string> - </string>
49 </property>
50 <property name="icon">
51 <iconset>
52 <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset>
53 </property>
54 <property name="autoRaise">
55 <bool>true</bool>
56 </property>
57 </widget>
58 </item>
59 <item>
60 <widget class="Line" name="line">
61 <property name="orientation">
62 <enum>Qt::Vertical</enum>
63 </property>
64 </widget>
65 </item>
66 <item>
67 <widget class="QToolButton" name="btnTime">
68 <property name="text">
69 <string>T</string>
70 </property>
71 <property name="icon">
72 <iconset>
73 <normaloff>:/icones/time.png</normaloff>:/icones/time.png</iconset>
74 </property>
75 <property name="checkable">
76 <bool>true</bool>
77 </property>
78 <property name="autoRaise">
79 <bool>true</bool>
80 </property>
81 </widget>
82 </item>
83 <item>
84 <widget class="QToolButton" name="btnChart">
85 <property name="text">
86 <string>G</string>
87 </property>
88 <property name="icon">
89 <iconset>
90 <normaloff>:/icones/chart.png</normaloff>:/icones/chart.png</iconset>
91 </property>
92 <property name="checkable">
93 <bool>true</bool>
94 </property>
95 <property name="autoRaise">
96 <bool>true</bool>
97 </property>
98 </widget>
99 </item>
100 <item>
101 <widget class="Line" name="line_2">
102 <property name="orientation">
103 <enum>Qt::Vertical</enum>
104 </property>
105 </widget>
106 </item>
107 <item>
108 <widget class="QLineEdit" name="lineEdit">
109 <property name="enabled">
110 <bool>false</bool>
111 </property>
112 </widget>
113 </item>
114 </layout>
115 </item>
116 <item>
117 <widget class="QTableWidget" name="tableWidget">
118 <property name="alternatingRowColors">
119 <bool>true</bool>
120 </property>
121 <property name="selectionBehavior">
122 <enum>QAbstractItemView::SelectRows</enum>
123 </property>
124 <attribute name="horizontalHeaderHighlightSections">
125 <bool>false</bool>
126 </attribute>
127 <attribute name="verticalHeaderVisible">
128 <bool>false</bool>
129 </attribute>
130 <attribute name="verticalHeaderDefaultSectionSize">
131 <number>25</number>
132 </attribute>
133 </widget>
134 </item>
135 </layout>
136 </widget>
137 <resources/>
138 <connections/>
139 </ui>
@@ -0,0 +1,83
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>CatalogueExplorer</class>
4 <widget class="QDialog" name="CatalogueExplorer">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>755</width>
10 <height>481</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Catalogue Explorer</string>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
18 <widget class="QSplitter" name="horizontalSplitter">
19 <property name="orientation">
20 <enum>Qt::Horizontal</enum>
21 </property>
22 <widget class="CatalogueSideBarWidget" name="catalogues" native="true">
23 <property name="sizePolicy">
24 <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
25 <horstretch>1</horstretch>
26 <verstretch>0</verstretch>
27 </sizepolicy>
28 </property>
29 </widget>
30 <widget class="QSplitter" name="verticalSplitter">
31 <property name="sizePolicy">
32 <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
33 <horstretch>3</horstretch>
34 <verstretch>0</verstretch>
35 </sizepolicy>
36 </property>
37 <property name="orientation">
38 <enum>Qt::Vertical</enum>
39 </property>
40 <widget class="CatalogueEventsWidget" name="events" native="true">
41 <property name="sizePolicy">
42 <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
43 <horstretch>0</horstretch>
44 <verstretch>5</verstretch>
45 </sizepolicy>
46 </property>
47 </widget>
48 <widget class="CatalogueInspectorWidget" name="inspector" native="true">
49 <property name="sizePolicy">
50 <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
51 <horstretch>0</horstretch>
52 <verstretch>2</verstretch>
53 </sizepolicy>
54 </property>
55 </widget>
56 </widget>
57 </widget>
58 </item>
59 </layout>
60 </widget>
61 <customwidgets>
62 <customwidget>
63 <class>CatalogueSideBarWidget</class>
64 <extends>QWidget</extends>
65 <header>Catalogue/CatalogueSideBarWidget.h</header>
66 <container>1</container>
67 </customwidget>
68 <customwidget>
69 <class>CatalogueEventsWidget</class>
70 <extends>QWidget</extends>
71 <header>Catalogue/CatalogueEventsWidget.h</header>
72 <container>1</container>
73 </customwidget>
74 <customwidget>
75 <class>CatalogueInspectorWidget</class>
76 <extends>QWidget</extends>
77 <header>Catalogue/CatalogueInspectorWidget.h</header>
78 <container>1</container>
79 </customwidget>
80 </customwidgets>
81 <resources/>
82 <connections/>
83 </ui>
@@ -0,0 +1,214
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>CatalogueInspectorWidget</class>
4 <widget class="QWidget" name="CatalogueInspectorWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>400</width>
10 <height>300</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout_2">
17 <property name="leftMargin">
18 <number>0</number>
19 </property>
20 <property name="topMargin">
21 <number>0</number>
22 </property>
23 <property name="rightMargin">
24 <number>0</number>
25 </property>
26 <property name="bottomMargin">
27 <number>0</number>
28 </property>
29 <item>
30 <widget class="QFrame" name="frame">
31 <property name="frameShape">
32 <enum>QFrame::Box</enum>
33 </property>
34 <property name="frameShadow">
35 <enum>QFrame::Sunken</enum>
36 </property>
37 <property name="lineWidth">
38 <number>1</number>
39 </property>
40 <layout class="QVBoxLayout" name="verticalLayout">
41 <property name="leftMargin">
42 <number>0</number>
43 </property>
44 <property name="topMargin">
45 <number>0</number>
46 </property>
47 <property name="rightMargin">
48 <number>0</number>
49 </property>
50 <property name="bottomMargin">
51 <number>0</number>
52 </property>
53 <item>
54 <widget class="QStackedWidget" name="stackedWidget">
55 <property name="currentIndex">
56 <number>1</number>
57 </property>
58 <widget class="QWidget" name="emptyPage"/>
59 <widget class="QWidget" name="catalogueInspectorPage">
60 <layout class="QGridLayout" name="gridLayout_2">
61 <item row="1" column="0">
62 <widget class="QLabel" name="label_7">
63 <property name="text">
64 <string>Name</string>
65 </property>
66 </widget>
67 </item>
68 <item row="1" column="1">
69 <widget class="QLineEdit" name="leCatalogueName"/>
70 </item>
71 <item row="2" column="0">
72 <widget class="QLabel" name="label_8">
73 <property name="text">
74 <string>Author</string>
75 </property>
76 </widget>
77 </item>
78 <item row="2" column="1">
79 <widget class="QLineEdit" name="leCatalogueAuthor">
80 <property name="text">
81 <string/>
82 </property>
83 </widget>
84 </item>
85 <item row="3" column="1">
86 <spacer name="verticalSpacer_2">
87 <property name="orientation">
88 <enum>Qt::Vertical</enum>
89 </property>
90 <property name="sizeHint" stdset="0">
91 <size>
92 <width>20</width>
93 <height>40</height>
94 </size>
95 </property>
96 </spacer>
97 </item>
98 <item row="0" column="0" colspan="2">
99 <widget class="QLabel" name="label_9">
100 <property name="font">
101 <font>
102 <pointsize>10</pointsize>
103 <weight>75</weight>
104 <bold>true</bold>
105 </font>
106 </property>
107 <property name="text">
108 <string>Catalogue Properties</string>
109 </property>
110 </widget>
111 </item>
112 </layout>
113 </widget>
114 <widget class="QWidget" name="eventInspectorPage">
115 <layout class="QGridLayout" name="gridLayout">
116 <item row="5" column="1">
117 <widget class="QDateTimeEdit" name="dateTimeEventTEnd"/>
118 </item>
119 <item row="4" column="0">
120 <widget class="QLabel" name="label_4">
121 <property name="text">
122 <string>TStart</string>
123 </property>
124 </widget>
125 </item>
126 <item row="6" column="0">
127 <widget class="QLabel" name="label_6">
128 <property name="text">
129 <string>Tags</string>
130 </property>
131 </widget>
132 </item>
133 <item row="3" column="0">
134 <widget class="QLabel" name="label_3">
135 <property name="text">
136 <string>Product</string>
137 </property>
138 </widget>
139 </item>
140 <item row="3" column="1">
141 <widget class="QLineEdit" name="leEventProduct"/>
142 </item>
143 <item row="5" column="0">
144 <widget class="QLabel" name="label_5">
145 <property name="text">
146 <string>Tend</string>
147 </property>
148 </widget>
149 </item>
150 <item row="4" column="1">
151 <widget class="QDateTimeEdit" name="dateTimeEventTStart"/>
152 </item>
153 <item row="2" column="0">
154 <widget class="QLabel" name="label_2">
155 <property name="text">
156 <string>Mission</string>
157 </property>
158 </widget>
159 </item>
160 <item row="1" column="1">
161 <widget class="QLineEdit" name="leEventName"/>
162 </item>
163 <item row="1" column="0">
164 <widget class="QLabel" name="label">
165 <property name="text">
166 <string>Name</string>
167 </property>
168 </widget>
169 </item>
170 <item row="2" column="1">
171 <widget class="QLineEdit" name="leEventMission"/>
172 </item>
173 <item row="6" column="1">
174 <widget class="QLineEdit" name="leEventTags"/>
175 </item>
176 <item row="7" column="1">
177 <spacer name="verticalSpacer">
178 <property name="orientation">
179 <enum>Qt::Vertical</enum>
180 </property>
181 <property name="sizeHint" stdset="0">
182 <size>
183 <width>20</width>
184 <height>40</height>
185 </size>
186 </property>
187 </spacer>
188 </item>
189 <item row="0" column="0" colspan="2">
190 <widget class="QLabel" name="label_10">
191 <property name="font">
192 <font>
193 <pointsize>10</pointsize>
194 <weight>75</weight>
195 <bold>true</bold>
196 </font>
197 </property>
198 <property name="text">
199 <string>Event Properties</string>
200 </property>
201 </widget>
202 </item>
203 </layout>
204 </widget>
205 </widget>
206 </item>
207 </layout>
208 </widget>
209 </item>
210 </layout>
211 </widget>
212 <resources/>
213 <connections/>
214 </ui>
@@ -0,0 +1,90
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>CatalogueSideBarWidget</class>
4 <widget class="QWidget" name="CatalogueSideBarWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>330</width>
10 <height>523</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <property name="leftMargin">
18 <number>0</number>
19 </property>
20 <property name="topMargin">
21 <number>0</number>
22 </property>
23 <property name="rightMargin">
24 <number>0</number>
25 </property>
26 <property name="bottomMargin">
27 <number>0</number>
28 </property>
29 <item>
30 <layout class="QHBoxLayout" name="horizontalLayout">
31 <item>
32 <widget class="QToolButton" name="btnAdd">
33 <property name="text">
34 <string>+</string>
35 </property>
36 <property name="icon">
37 <iconset>
38 <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset>
39 </property>
40 <property name="autoRaise">
41 <bool>true</bool>
42 </property>
43 </widget>
44 </item>
45 <item>
46 <widget class="QToolButton" name="btnRemove">
47 <property name="text">
48 <string> - </string>
49 </property>
50 <property name="icon">
51 <iconset>
52 <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset>
53 </property>
54 <property name="autoRaise">
55 <bool>true</bool>
56 </property>
57 </widget>
58 </item>
59 <item>
60 <spacer name="horizontalSpacer">
61 <property name="orientation">
62 <enum>Qt::Horizontal</enum>
63 </property>
64 <property name="sizeHint" stdset="0">
65 <size>
66 <width>40</width>
67 <height>20</height>
68 </size>
69 </property>
70 </spacer>
71 </item>
72 </layout>
73 </item>
74 <item>
75 <widget class="QTreeWidget" name="treeWidget">
76 <attribute name="headerVisible">
77 <bool>false</bool>
78 </attribute>
79 <column>
80 <property name="text">
81 <string notr="true">1</string>
82 </property>
83 </column>
84 </widget>
85 </item>
86 </layout>
87 </widget>
88 <resources/>
89 <connections/>
90 </ui>
@@ -1,353 +1,364
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SciQLop Software
3 3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "MainWindow.h"
23 23 #include "ui_MainWindow.h"
24 24
25 #include <Catalogue/CatalogueExplorer.h>
25 26 #include <DataSource/DataSourceController.h>
26 27 #include <DataSource/DataSourceWidget.h>
27 28 #include <Settings/SqpSettingsDialog.h>
28 29 #include <Settings/SqpSettingsGeneralWidget.h>
29 30 #include <SidePane/SqpSidePane.h>
30 31 #include <SqpApplication.h>
31 32 #include <Time/TimeController.h>
32 33 #include <TimeWidget/TimeWidget.h>
33 34 #include <Variable/Variable.h>
34 35 #include <Variable/VariableController.h>
35 36 #include <Visualization/VisualizationController.h>
36 37
37 38 #include <QAction>
38 39 #include <QDate>
39 40 #include <QDir>
40 41 #include <QFileDialog>
41 42 #include <QToolBar>
42 43 #include <QToolButton>
43 44 #include <memory.h>
44 45
45 46 #include "iostream"
46 47
47 48 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
48 49
49 50 namespace {
50 51 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
51 52 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
52 53 const auto VIEWPLITTERINDEX = 2;
53 54 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
54 55 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
55 56 }
56 57
57 58 class MainWindow::MainWindowPrivate {
58 59 public:
59 60 explicit MainWindowPrivate(MainWindow *mainWindow)
60 61 : m_LastOpenLeftInspectorSize{},
61 62 m_LastOpenRightInspectorSize{},
62 63 m_GeneralSettingsWidget{new SqpSettingsGeneralWidget{mainWindow}},
63 m_SettingsDialog{new SqpSettingsDialog{mainWindow}}
64 m_SettingsDialog{new SqpSettingsDialog{mainWindow}},
65 m_CatalogExplorer{new CatalogueExplorer{mainWindow}}
64 66 {
65 67 }
66 68
67 69 QSize m_LastOpenLeftInspectorSize;
68 70 QSize m_LastOpenRightInspectorSize;
69 71 /// General settings widget. MainWindow has the ownership
70 72 SqpSettingsGeneralWidget *m_GeneralSettingsWidget;
71 73 /// Settings dialog. MainWindow has the ownership
72 74 SqpSettingsDialog *m_SettingsDialog;
75 /// Catalogue dialog. MainWindow has the ownership
76 CatalogueExplorer *m_CatalogExplorer;
73 77 };
74 78
75 79 MainWindow::MainWindow(QWidget *parent)
76 80 : QMainWindow{parent},
77 81 m_Ui{new Ui::MainWindow},
78 82 impl{spimpl::make_unique_impl<MainWindowPrivate>(this)}
79 83 {
80 84 m_Ui->setupUi(this);
81 85
82 86 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
83 87 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
84 88
85 89
86 90 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
87 91 auto openLeftInspectorAction = new QAction{QIcon{
88 92 ":/icones/previous.png",
89 93 },
90 94 tr("Show/hide the left inspector"), this};
91 95
92 96
93 97 auto spacerLeftTop = new QWidget{};
94 98 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
95 99
96 100 auto spacerLeftBottom = new QWidget{};
97 101 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
98 102
99 103 leftSidePane->addWidget(spacerLeftTop);
100 104 leftSidePane->addAction(openLeftInspectorAction);
101 105 leftSidePane->addWidget(spacerLeftBottom);
102 106
103 107
104 108 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
105 109 auto openRightInspectorAction = new QAction{QIcon{
106 110 ":/icones/next.png",
107 111 },
108 112 tr("Show/hide the right inspector"), this};
109 113
110 114 auto spacerRightTop = new QWidget{};
111 115 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
112 116
113 117 auto spacerRightBottom = new QWidget{};
114 118 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
115 119
116 120 rightSidePane->addWidget(spacerRightTop);
117 121 rightSidePane->addAction(openRightInspectorAction);
118 122 rightSidePane->addWidget(spacerRightBottom);
119 123
120 124 openLeftInspectorAction->setCheckable(true);
121 125 openRightInspectorAction->setCheckable(true);
122 126
123 127 auto openInspector = [this](bool checked, bool right, auto action) {
124 128
125 129 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
126 130
127 131 auto &lastInspectorSize
128 132 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
129 133
130 134 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
131 135 : m_Ui->leftMainInspectorWidget->size();
132 136
133 137 // Update of the last opened geometry
134 138 if (checked) {
135 139 lastInspectorSize = nextInspectorSize;
136 140 }
137 141
138 142 auto startSize = lastInspectorSize;
139 143 auto endSize = startSize;
140 144 endSize.setWidth(0);
141 145
142 146 auto splitterInspectorIndex
143 147 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
144 148
145 149 auto currentSizes = m_Ui->splitter->sizes();
146 150 if (checked) {
147 151 // adjust sizes individually here, e.g.
148 152 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
149 153 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
150 154 m_Ui->splitter->setSizes(currentSizes);
151 155 }
152 156 else {
153 157 // adjust sizes individually here, e.g.
154 158 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
155 159 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
156 160 m_Ui->splitter->setSizes(currentSizes);
157 161 }
158 162
159 163 };
160 164
161 165
162 166 connect(openLeftInspectorAction, &QAction::triggered,
163 167 [openInspector, openLeftInspectorAction](bool checked) {
164 168 openInspector(checked, false, openLeftInspectorAction);
165 169 });
166 170 connect(openRightInspectorAction, &QAction::triggered,
167 171 [openInspector, openRightInspectorAction](bool checked) {
168 172 openInspector(checked, true, openRightInspectorAction);
169 173 });
170 174
171 175 // //////////////// //
172 176 // Menu and Toolbar //
173 177 // //////////////// //
174 178 this->menuBar()->addAction(tr("File"));
175 179 auto toolsMenu = this->menuBar()->addMenu(tr("Tools"));
176 180 toolsMenu->addAction(tr("Settings..."), [this]() {
177 181 // Loads settings
178 182 impl->m_SettingsDialog->loadSettings();
179 183
180 184 // Open settings dialog and save settings if the dialog is accepted
181 185 if (impl->m_SettingsDialog->exec() == QDialog::Accepted) {
182 186 impl->m_SettingsDialog->saveSettings();
183 187 }
184 188
185 189 });
186 190
187 191 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
188 192
189 193 auto timeWidget = new TimeWidget{};
190 194 mainToolBar->addWidget(timeWidget);
191 195
196 // Interaction modes
192 197 auto actionPointerMode = new QAction{QIcon(":/icones/pointer.png"), "Move", this};
193 198 actionPointerMode->setCheckable(true);
194 199 actionPointerMode->setChecked(sqpApp->plotsInteractionMode()
195 200 == SqpApplication::PlotsInteractionMode::None);
196 201 connect(actionPointerMode, &QAction::triggered,
197 202 []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::None); });
198 203
199 204 auto actionZoomMode = new QAction{QIcon(":/icones/zoom.png"), "Zoom", this};
200 205 actionZoomMode->setCheckable(true);
201 206 actionZoomMode->setChecked(sqpApp->plotsInteractionMode()
202 207 == SqpApplication::PlotsInteractionMode::ZoomBox);
203 208 connect(actionZoomMode, &QAction::triggered, []() {
204 209 sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::ZoomBox);
205 210 });
206 211
207 212 auto actionOrganisationMode = new QAction{QIcon(":/icones/drag.png"), "Organize", this};
208 213 actionOrganisationMode->setCheckable(true);
209 214 actionOrganisationMode->setChecked(sqpApp->plotsInteractionMode()
210 215 == SqpApplication::PlotsInteractionMode::DragAndDrop);
211 216 connect(actionOrganisationMode, &QAction::triggered, []() {
212 217 sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::DragAndDrop);
213 218 });
214 219
215 220 auto actionZonesMode = new QAction{QIcon(":/icones/rectangle.png"), "Zones", this};
216 221 actionZonesMode->setCheckable(true);
217 222 actionZonesMode->setChecked(sqpApp->plotsInteractionMode()
218 223 == SqpApplication::PlotsInteractionMode::SelectionZones);
219 224 connect(actionZonesMode, &QAction::triggered, []() {
220 225 sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::SelectionZones);
221 226 });
222 227
223 228 auto modeActionGroup = new QActionGroup{this};
224 229 modeActionGroup->addAction(actionZoomMode);
225 230 modeActionGroup->addAction(actionZonesMode);
226 231 modeActionGroup->addAction(actionOrganisationMode);
227 232 modeActionGroup->addAction(actionPointerMode);
228 233 modeActionGroup->setExclusive(true);
229 234
230 235 mainToolBar->addSeparator();
231 236 mainToolBar->addAction(actionPointerMode);
232 237 mainToolBar->addAction(actionZoomMode);
233 238 mainToolBar->addAction(actionOrganisationMode);
234 239 mainToolBar->addAction(actionZonesMode);
235 240 mainToolBar->addSeparator();
236 241
242 // Cursors
237 243 auto btnCursor = new QToolButton{this};
238 244 btnCursor->setIcon(QIcon(":/icones/cursor.png"));
239 245 btnCursor->setText("Cursor");
240 246 btnCursor->setToolTip("Cursor");
241 247 btnCursor->setPopupMode(QToolButton::InstantPopup);
242 248 auto cursorMenu = new QMenu("CursorMenu", this);
243 249 btnCursor->setMenu(cursorMenu);
244 250
245 251 auto noCursorAction = cursorMenu->addAction("No Cursor");
246 252 noCursorAction->setCheckable(true);
247 253 noCursorAction->setChecked(sqpApp->plotsCursorMode()
248 254 == SqpApplication::PlotsCursorMode::NoCursor);
249 255 connect(noCursorAction, &QAction::triggered,
250 256 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::NoCursor); });
251 257
252 258 cursorMenu->addSeparator();
253 259 auto verticalCursorAction = cursorMenu->addAction("Vertical Cursor");
254 260 verticalCursorAction->setCheckable(true);
255 261 verticalCursorAction->setChecked(sqpApp->plotsCursorMode()
256 262 == SqpApplication::PlotsCursorMode::Vertical);
257 263 connect(verticalCursorAction, &QAction::triggered,
258 264 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Vertical); });
259 265
260 266 auto temporalCursorAction = cursorMenu->addAction("Temporal Cursor");
261 267 temporalCursorAction->setCheckable(true);
262 268 temporalCursorAction->setChecked(sqpApp->plotsCursorMode()
263 269 == SqpApplication::PlotsCursorMode::Temporal);
264 270 connect(temporalCursorAction, &QAction::triggered,
265 271 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Temporal); });
266 272
267 273 auto horizontalCursorAction = cursorMenu->addAction("Horizontal Cursor");
268 274 horizontalCursorAction->setCheckable(true);
269 275 horizontalCursorAction->setChecked(sqpApp->plotsCursorMode()
270 276 == SqpApplication::PlotsCursorMode::Horizontal);
271 277 connect(horizontalCursorAction, &QAction::triggered,
272 278 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Horizontal); });
273 279
274 280 auto crossCursorAction = cursorMenu->addAction("Cross Cursor");
275 281 crossCursorAction->setCheckable(true);
276 282 crossCursorAction->setChecked(sqpApp->plotsCursorMode()
277 283 == SqpApplication::PlotsCursorMode::Cross);
278 284 connect(crossCursorAction, &QAction::triggered,
279 285 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Cross); });
280 286
281 287 mainToolBar->addWidget(btnCursor);
282 288
283 289 auto cursorModeActionGroup = new QActionGroup{this};
284 290 cursorModeActionGroup->setExclusive(true);
285 291 cursorModeActionGroup->addAction(noCursorAction);
286 292 cursorModeActionGroup->addAction(verticalCursorAction);
287 293 cursorModeActionGroup->addAction(temporalCursorAction);
288 294 cursorModeActionGroup->addAction(horizontalCursorAction);
289 295 cursorModeActionGroup->addAction(crossCursorAction);
290 296
297 // Catalog
298 mainToolBar->addSeparator();
299 mainToolBar->addAction(QIcon(":/icones/catalogue.png"), "Catalogues",
300 [this]() { impl->m_CatalogExplorer->show(); });
301
291 302 // //////// //
292 303 // Settings //
293 304 // //////// //
294 305
295 306 // Registers "general settings" widget to the settings dialog
296 307 impl->m_SettingsDialog->registerWidget(QStringLiteral("General"),
297 308 impl->m_GeneralSettingsWidget);
298 309
299 310 // /////////// //
300 311 // Connections //
301 312 // /////////// //
302 313
303 314 // Controllers / controllers connections
304 315 connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpRange)), &sqpApp->variableController(),
305 316 SLOT(onDateTimeOnSelection(SqpRange)));
306 317
307 318 // Widgets / controllers connections
308 319
309 320 // DataSource
310 321 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
311 322 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
312 323
313 324 // Time
314 325 connect(timeWidget, SIGNAL(timeUpdated(SqpRange)), &sqpApp->timeController(),
315 326 SLOT(onTimeToUpdate(SqpRange)));
316 327
317 328 // Visualization
318 329 connect(&sqpApp->visualizationController(),
319 330 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view,
320 331 SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>)));
321 332
322 333 connect(&sqpApp->visualizationController(),
323 334 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), m_Ui->view,
324 335 SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpRange &)));
325 336
326 337 // Widgets / widgets connections
327 338
328 339 // For the following connections, we use DirectConnection to allow each widget that can
329 340 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
330 341 // The order of connections is also important, since it determines the order in which each
331 342 // widget will attach its menu
332 343 connect(
333 344 m_Ui->variableInspectorWidget,
334 345 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
335 346 m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
336 347 Qt::DirectConnection);
337 348 }
338 349
339 350 MainWindow::~MainWindow()
340 351 {
341 352 }
342 353
343 354 void MainWindow::changeEvent(QEvent *e)
344 355 {
345 356 QMainWindow::changeEvent(e);
346 357 switch (e->type()) {
347 358 case QEvent::LanguageChange:
348 359 m_Ui->retranslateUi(this);
349 360 break;
350 361 default:
351 362 break;
352 363 }
353 364 }
@@ -1,170 +1,170
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <ui version="4.0">
3 3 <class>MainWindow</class>
4 4 <widget class="QMainWindow" name="MainWindow">
5 5 <property name="geometry">
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 9 <width>800</width>
10 10 <height>600</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14 14 <string>SciQlop v0.0.1</string>
15 15 </property>
16 16 <property name="dockNestingEnabled">
17 17 <bool>true</bool>
18 18 </property>
19 19 <widget class="QWidget" name="centralWidget">
20 20 <property name="enabled">
21 21 <bool>true</bool>
22 22 </property>
23 23 <property name="sizePolicy">
24 24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
25 25 <horstretch>0</horstretch>
26 26 <verstretch>0</verstretch>
27 27 </sizepolicy>
28 28 </property>
29 29 <property name="maximumSize">
30 30 <size>
31 31 <width>16777215</width>
32 32 <height>16777215</height>
33 33 </size>
34 34 </property>
35 35 <layout class="QHBoxLayout" name="horizontalLayout">
36 36 <property name="spacing">
37 37 <number>0</number>
38 38 </property>
39 39 <property name="leftMargin">
40 40 <number>0</number>
41 41 </property>
42 42 <property name="topMargin">
43 43 <number>0</number>
44 44 </property>
45 45 <property name="rightMargin">
46 46 <number>0</number>
47 47 </property>
48 48 <property name="bottomMargin">
49 49 <number>0</number>
50 50 </property>
51 51 <item>
52 52 <widget class="QSplitter" name="splitter">
53 53 <property name="orientation">
54 54 <enum>Qt::Horizontal</enum>
55 55 </property>
56 56 <widget class="QWidget" name="leftMainInspectorWidget" native="true">
57 57 <layout class="QVBoxLayout" name="verticalLayout">
58 58 <property name="spacing">
59 59 <number>0</number>
60 60 </property>
61 61 <property name="leftMargin">
62 62 <number>0</number>
63 63 </property>
64 64 <property name="topMargin">
65 65 <number>0</number>
66 66 </property>
67 67 <property name="rightMargin">
68 68 <number>0</number>
69 69 </property>
70 70 <property name="bottomMargin">
71 71 <number>0</number>
72 72 </property>
73 73 <item>
74 74 <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/>
75 75 </item>
76 76 <item>
77 77 <widget class="QWidget" name="dateTimeWidget" native="true"/>
78 78 </item>
79 79 <item>
80 80 <widget class="VariableInspectorWidget" name="variableInspectorWidget" native="true"/>
81 81 </item>
82 82 </layout>
83 83 </widget>
84 84 <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"/>
85 85 <widget class="VisualizationWidget" name="view" native="true">
86 86 <property name="sizePolicy">
87 87 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
88 88 <horstretch>0</horstretch>
89 89 <verstretch>0</verstretch>
90 90 </sizepolicy>
91 91 </property>
92 92 </widget>
93 93 <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/>
94 94 <widget class="QWidget" name="rightMainInspectorWidget" native="true">
95 95 <layout class="QVBoxLayout" name="verticalLayout_3">
96 96 <property name="spacing">
97 97 <number>0</number>
98 98 </property>
99 99 <property name="leftMargin">
100 100 <number>0</number>
101 101 </property>
102 102 <property name="topMargin">
103 103 <number>0</number>
104 104 </property>
105 105 <property name="rightMargin">
106 106 <number>0</number>
107 107 </property>
108 108 <property name="bottomMargin">
109 109 <number>0</number>
110 110 </property>
111 111 <item>
112 112 <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/>
113 113 </item>
114 114 <item>
115 115 <widget class="QTreeWidget" name="catalogWidget">
116 116 <column>
117 117 <property name="text">
118 118 <string notr="true">Name</string>
119 119 </property>
120 120 </column>
121 121 </widget>
122 122 </item>
123 123 </layout>
124 124 </widget>
125 125 </widget>
126 126 </item>
127 127 </layout>
128 128 </widget>
129 129 <widget class="QMenuBar" name="menuBar">
130 130 <property name="geometry">
131 131 <rect>
132 132 <x>0</x>
133 133 <y>0</y>
134 134 <width>800</width>
135 <height>28</height>
135 <height>21</height>
136 136 </rect>
137 137 </property>
138 138 </widget>
139 139 <widget class="QStatusBar" name="statusBar"/>
140 140 </widget>
141 141 <layoutdefault spacing="6" margin="11"/>
142 142 <customwidgets>
143 143 <customwidget>
144 144 <class>VisualizationWidget</class>
145 145 <extends>QWidget</extends>
146 146 <header location="global">Visualization/VisualizationWidget.h</header>
147 147 <container>1</container>
148 148 </customwidget>
149 149 <customwidget>
150 150 <class>SqpSidePane</class>
151 151 <extends>QWidget</extends>
152 152 <header location="global">SidePane/SqpSidePane.h</header>
153 153 <container>1</container>
154 154 </customwidget>
155 155 <customwidget>
156 156 <class>DataSourceWidget</class>
157 157 <extends>QWidget</extends>
158 158 <header location="global">DataSource/DataSourceWidget.h</header>
159 159 <container>1</container>
160 160 </customwidget>
161 161 <customwidget>
162 162 <class>VariableInspectorWidget</class>
163 163 <extends>QWidget</extends>
164 164 <header location="global">Variable/VariableInspectorWidget.h</header>
165 165 <container>1</container>
166 166 </customwidget>
167 167 </customwidgets>
168 168 <resources/>
169 169 <connections/>
170 170 </ui>
@@ -1,110 +1,122
1 1
2 2 gui_moc_headers = [
3 3 'include/DataSource/DataSourceWidget.h',
4 4 'include/Settings/SqpSettingsDialog.h',
5 5 'include/Settings/SqpSettingsGeneralWidget.h',
6 6 'include/SidePane/SqpSidePane.h',
7 7 'include/SqpApplication.h',
8 8 'include/DragAndDrop/DragDropScroller.h',
9 9 'include/DragAndDrop/DragDropTabSwitcher.h',
10 10 'include/TimeWidget/TimeWidget.h',
11 11 'include/Variable/VariableInspectorWidget.h',
12 12 'include/Variable/RenameVariableDialog.h',
13 13 'include/Visualization/qcustomplot.h',
14 14 'include/Visualization/VisualizationGraphWidget.h',
15 15 'include/Visualization/VisualizationTabWidget.h',
16 16 'include/Visualization/VisualizationWidget.h',
17 17 'include/Visualization/VisualizationZoneWidget.h',
18 18 'include/Visualization/VisualizationDragDropContainer.h',
19 19 'include/Visualization/VisualizationDragWidget.h',
20 20 'include/Visualization/ColorScaleEditor.h',
21 21 'include/Actions/SelectionZoneAction.h',
22 'include/Visualization/VisualizationMultiZoneSelectionDialog.h'
22 'include/Visualization/VisualizationMultiZoneSelectionDialog.h',
23 'include/Catalogue/CatalogueExplorer.h',
24 'include/Catalogue/CatalogueEventsWidget.h',
25 'include/Catalogue/CatalogueSideBarWidget.h',
26 'include/Catalogue/CatalogueInspectorWidget.h'
23 27 ]
24 28
25 29 gui_ui_files = [
26 30 'ui/DataSource/DataSourceWidget.ui',
27 31 'ui/Settings/SqpSettingsDialog.ui',
28 32 'ui/Settings/SqpSettingsGeneralWidget.ui',
29 33 'ui/SidePane/SqpSidePane.ui',
30 34 'ui/TimeWidget/TimeWidget.ui',
31 35 'ui/Variable/VariableInspectorWidget.ui',
32 36 'ui/Variable/RenameVariableDialog.ui',
33 37 'ui/Variable/VariableMenuHeaderWidget.ui',
34 38 'ui/Visualization/VisualizationGraphWidget.ui',
35 39 'ui/Visualization/VisualizationTabWidget.ui',
36 40 'ui/Visualization/VisualizationWidget.ui',
37 41 'ui/Visualization/VisualizationZoneWidget.ui',
38 42 'ui/Visualization/ColorScaleEditor.ui',
39 'ui/Visualization/VisualizationMultiZoneSelectionDialog.ui'
43 'ui/Visualization/VisualizationMultiZoneSelectionDialog.ui',
44 'ui/Catalogue/CatalogueExplorer.ui',
45 'ui/Catalogue/CatalogueEventsWidget.ui',
46 'ui/Catalogue/CatalogueSideBarWidget.ui',
47 'ui/Catalogue/CatalogueInspectorWidget.ui'
40 48 ]
41 49
42 50 gui_qresources = ['resources/sqpguiresources.qrc']
43 51
44 52 gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers,
45 53 ui_files : gui_ui_files,
46 54 qresources : gui_qresources)
47 55
48 56 gui_sources = [
49 57 'src/SqpApplication.cpp',
50 58 'src/DragAndDrop/DragDropGuiController.cpp',
51 59 'src/DragAndDrop/DragDropScroller.cpp',
52 60 'src/DragAndDrop/DragDropTabSwitcher.cpp',
53 61 'src/Common/ColorUtils.cpp',
54 62 'src/Common/VisualizationDef.cpp',
55 63 'src/DataSource/DataSourceTreeWidgetItem.cpp',
56 64 'src/DataSource/DataSourceTreeWidgetHelper.cpp',
57 65 'src/DataSource/DataSourceWidget.cpp',
58 66 'src/DataSource/DataSourceTreeWidget.cpp',
59 67 'src/Settings/SqpSettingsDialog.cpp',
60 68 'src/Settings/SqpSettingsGeneralWidget.cpp',
61 69 'src/SidePane/SqpSidePane.cpp',
62 70 'src/TimeWidget/TimeWidget.cpp',
63 71 'src/Variable/VariableInspectorWidget.cpp',
64 72 'src/Variable/VariableInspectorTableView.cpp',
65 73 'src/Variable/VariableMenuHeaderWidget.cpp',
66 74 'src/Variable/RenameVariableDialog.cpp',
67 75 'src/Visualization/VisualizationGraphHelper.cpp',
68 76 'src/Visualization/VisualizationGraphRenderingDelegate.cpp',
69 77 'src/Visualization/VisualizationGraphWidget.cpp',
70 78 'src/Visualization/VisualizationTabWidget.cpp',
71 79 'src/Visualization/VisualizationWidget.cpp',
72 80 'src/Visualization/VisualizationZoneWidget.cpp',
73 81 'src/Visualization/qcustomplot.cpp',
74 82 'src/Visualization/QCustomPlotSynchronizer.cpp',
75 83 'src/Visualization/operations/FindVariableOperation.cpp',
76 84 'src/Visualization/operations/GenerateVariableMenuOperation.cpp',
77 85 'src/Visualization/operations/MenuBuilder.cpp',
78 86 'src/Visualization/operations/RemoveVariableOperation.cpp',
79 87 'src/Visualization/operations/RescaleAxeOperation.cpp',
80 88 'src/Visualization/VisualizationDragDropContainer.cpp',
81 89 'src/Visualization/VisualizationDragWidget.cpp',
82 90 'src/Visualization/AxisRenderingUtils.cpp',
83 91 'src/Visualization/PlottablesRenderingUtils.cpp',
84 92 'src/Visualization/MacScrollBarStyle.cpp',
85 93 'src/Visualization/VisualizationCursorItem.cpp',
86 94 'src/Visualization/ColorScaleEditor.cpp',
87 95 'src/Visualization/SqpColorScale.cpp',
88 96 'src/Visualization/QCPColorMapIterator.cpp',
89 97 'src/Visualization/VisualizationSelectionZoneItem.cpp',
90 98 'src/Visualization/VisualizationSelectionZoneManager.cpp',
91 99 'src/Actions/SelectionZoneAction.cpp',
92 100 'src/Actions/ActionsGuiController.cpp',
93 101 'src/Visualization/VisualizationActionManager.cpp',
94 'src/Visualization/VisualizationMultiZoneSelectionDialog.cpp'
102 'src/Visualization/VisualizationMultiZoneSelectionDialog.cpp',
103 'src/Catalogue/CatalogueExplorer.cpp',
104 'src/Catalogue/CatalogueEventsWidget.cpp',
105 'src/Catalogue/CatalogueSideBarWidget.cpp',
106 'src/Catalogue/CatalogueInspectorWidget.cpp'
95 107 ]
96 108
97 109 gui_inc = include_directories(['include'])
98 110
99 111 sciqlop_gui_lib = library('sciqlopgui',
100 112 gui_sources,
101 113 gui_moc_files,
102 114 include_directories : [gui_inc],
103 115 dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core],
104 116 install : true
105 117 )
106 118
107 119 sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib,
108 120 include_directories : gui_inc,
109 121 dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core])
110 122
@@ -1,22 +1,29
1 1 <RCC>
2 2 <qresource prefix="/">
3 3 <file>icones/dataSourceComponent.png</file>
4 4 <file>icones/dataSourceNode.png</file>
5 5 <file>icones/dataSourceProduct.png</file>
6 6 <file>icones/dataSourceRoot.png</file>
7 7 <file>icones/delete.png</file>
8 8 <file>icones/down.png</file>
9 9 <file>icones/openInspector.png</file>
10 10 <file>icones/next.png</file>
11 11 <file>icones/plot.png</file>
12 12 <file>icones/previous.png</file>
13 13 <file>icones/unplot.png</file>
14 14 <file>icones/up.png</file>
15 15 <file>icones/time.png</file>
16 16 <file>icones/zoom.png</file>
17 17 <file>icones/rectangle.png</file>
18 18 <file>icones/drag.png</file>
19 19 <file>icones/cursor.png</file>
20 20 <file>icones/pointer.png</file>
21 <file>icones/catalogue.png</file>
22 <file>icones/add.png</file>
23 <file>icones/remove.png</file>
24 <file>icones/chart.png</file>
25 <file>icones/allEvents.png</file>
26 <file>icones/trash.png</file>
27 <file>icones/database.png</file>
21 28 </qresource>
22 29 </RCC>
@@ -1,440 +1,438
1 1 #include "Visualization/VisualizationSelectionZoneItem.h"
2 2 #include "Visualization/VisualizationGraphWidget.h"
3 3 #include "Visualization/VisualizationSelectionZoneManager.h"
4 4 #include "Visualization/VisualizationWidget.h"
5 5
6 6 const QString &DEFAULT_COLOR = QStringLiteral("#E79D41");
7 7
8 8 struct VisualizationSelectionZoneItem::VisualizationSelectionZoneItemPrivate {
9 9
10 10 QCustomPlot *m_Plot;
11 11 double m_T1 = 0;
12 12 double m_T2 = 0;
13 13 QColor m_Color;
14 14
15 15 bool m_IsEditionEnabled = true;
16 16 double m_MovedOrinalT1 = 0;
17 17 double m_MovedOrinalT2 = 0;
18 18
19 19 QCPItemStraightLine *m_LeftLine;
20 20 QCPItemStraightLine *m_RightLine;
21 21 QCPItemText *m_NameLabelItem = nullptr;
22 22
23 23 enum class EditionMode { NoEdition, ResizeLeft, ResizeRight, Move };
24 24 EditionMode m_CurrentEditionMode;
25 25
26 26 QVector<VisualizationSelectionZoneItem *> m_AssociatedEditedZones;
27 27
28 28 VisualizationSelectionZoneItemPrivate(QCustomPlot *plot)
29 29 : m_Plot(plot), m_Color(Qt::blue), m_CurrentEditionMode(EditionMode::NoEdition)
30 30 {
31 31 }
32 32
33 33 void updatePosition(VisualizationSelectionZoneItem *item)
34 34 {
35 35 item->topLeft->setCoords(m_T1, 0);
36 36 item->bottomRight->setCoords(m_T2, 1);
37 37 }
38 38
39 39 EditionMode getEditionMode(const QPoint &pos, const VisualizationSelectionZoneItem *zoneItem)
40 40 {
41 41 auto distanceLeft = m_LeftLine->selectTest(pos, false);
42 42 auto distanceRight = m_RightLine->selectTest(pos, false);
43 43 auto distance = zoneItem->selectTest(pos, false);
44 44
45 45 if (distanceRight <= distance) {
46 46 return VisualizationSelectionZoneItemPrivate::EditionMode::ResizeRight;
47 47 }
48 48 else if (distanceLeft <= distance) {
49 49 return VisualizationSelectionZoneItemPrivate::EditionMode::ResizeLeft;
50 50 }
51 51
52 52 return VisualizationSelectionZoneItemPrivate::EditionMode::Move;
53 53 }
54 54
55 55 double pixelSizeToAxisXSize(double pixels)
56 56 {
57 57 auto axis = m_Plot->axisRect()->axis(QCPAxis::atBottom);
58 58 return axis->pixelToCoord(pixels) - axis->pixelToCoord(0);
59 59 }
60 60
61 61 bool alignZones(VisualizationSelectionZoneItem *referenceZone,
62 62 const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool alignOnLeft,
63 63 bool allowResize, bool vertically)
64 64 {
65 65 auto result = false;
66 66
67 67 auto referenceTime
68 68 = alignOnLeft ? referenceZone->range().m_TStart : referenceZone->range().m_TEnd;
69 69
70 70 auto referenceBottomAxis = m_Plot->axisRect()->axis(QCPAxis::atBottom);
71 71 auto referenceVerticalPosition = referenceBottomAxis->coordToPixel(referenceTime);
72 72
73 73 for (auto otherZone : zonesToAlign) {
74 74
75 75 auto otherZoneRange = otherZone->range();
76 76 auto newZoneStart = otherZoneRange.m_TStart;
77 77 auto newZoneEnd = otherZoneRange.m_TEnd;
78 78
79 79 auto alignedTime = referenceTime;
80 80 if (vertically) {
81 81 auto otherZoneAxis = otherZone->parentPlot()->axisRect()->axis(QCPAxis::atBottom);
82 82 alignedTime = otherZoneAxis->pixelToCoord(referenceVerticalPosition);
83 83 }
84 84
85 85 if (alignOnLeft) {
86 86 newZoneStart = alignedTime;
87 87 if (!allowResize) {
88 88 newZoneEnd = alignedTime + (otherZoneRange.m_TEnd - otherZoneRange.m_TStart);
89 89 }
90 90 }
91 91 else { // align on right
92 92 newZoneEnd = alignedTime;
93 93 if (!allowResize) {
94 94 newZoneStart = alignedTime - (otherZoneRange.m_TEnd - otherZoneRange.m_TStart);
95 95 }
96 96 }
97 97
98 98 if (newZoneStart < newZoneEnd) {
99 99 result = true;
100 100 otherZone->setRange(newZoneStart, newZoneEnd);
101 101 otherZone->parentPlot()->replot();
102 102 }
103 103 }
104 104
105 105 return result;
106 106 }
107 107 };
108 108
109 109 VisualizationSelectionZoneItem::VisualizationSelectionZoneItem(QCustomPlot *plot)
110 110 : QCPItemRect(plot),
111 111 impl{spimpl::make_unique_impl<VisualizationSelectionZoneItemPrivate>(plot)}
112 112 {
113 113 topLeft->setTypeX(QCPItemPosition::ptPlotCoords);
114 114 topLeft->setTypeY(QCPItemPosition::ptAxisRectRatio);
115 115 bottomRight->setTypeX(QCPItemPosition::ptPlotCoords);
116 116 bottomRight->setTypeY(QCPItemPosition::ptAxisRectRatio);
117 117 setSelectable(false);
118 118
119 119 impl->m_RightLine = new QCPItemStraightLine(plot);
120 120 impl->m_RightLine->point1->setParentAnchor(topRight);
121 121 impl->m_RightLine->point2->setParentAnchor(bottomRight);
122 122 impl->m_RightLine->point1->setTypeX(QCPItemPosition::ptAbsolute);
123 123 impl->m_RightLine->point1->setTypeY(QCPItemPosition::ptAbsolute);
124 124 impl->m_RightLine->point2->setTypeX(QCPItemPosition::ptAbsolute);
125 125 impl->m_RightLine->point2->setTypeY(QCPItemPosition::ptAbsolute);
126 126 impl->m_RightLine->setSelectable(false);
127 127
128 128 impl->m_LeftLine = new QCPItemStraightLine(plot);
129 129 impl->m_LeftLine->point1->setParentAnchor(topLeft);
130 130 impl->m_LeftLine->point2->setParentAnchor(bottomLeft);
131 131 impl->m_LeftLine->point1->setTypeX(QCPItemPosition::ptAbsolute);
132 132 impl->m_LeftLine->point1->setTypeY(QCPItemPosition::ptAbsolute);
133 133 impl->m_LeftLine->point2->setTypeX(QCPItemPosition::ptAbsolute);
134 134 impl->m_LeftLine->point2->setTypeY(QCPItemPosition::ptAbsolute);
135 135 impl->m_LeftLine->setSelectable(false);
136 136
137 137 connect(this, &VisualizationSelectionZoneItem::selectionChanged, impl->m_RightLine,
138 138 &QCPItemStraightLine::setSelected);
139 139 connect(this, &VisualizationSelectionZoneItem::selectionChanged, impl->m_LeftLine,
140 140 &QCPItemStraightLine::setSelected);
141 141
142 142 setColor(QColor(DEFAULT_COLOR));
143 143 }
144 144
145 VisualizationSelectionZoneItem::~VisualizationSelectionZoneItem()
146 {
147 }
145 VisualizationSelectionZoneItem::~VisualizationSelectionZoneItem() {}
148 146
149 147 VisualizationGraphWidget *VisualizationSelectionZoneItem::parentGraphWidget() const noexcept
150 148 {
151 149 auto parent = impl->m_Plot->parentWidget();
152 150 while (parent != nullptr && !qobject_cast<VisualizationGraphWidget *>(parent)) {
153 151 parent = parent->parentWidget();
154 152 }
155 153
156 154 return qobject_cast<VisualizationGraphWidget *>(parent);
157 155 }
158 156
159 157 void VisualizationSelectionZoneItem::setName(const QString &name)
160 158 {
161 159 if (name.isEmpty() && impl->m_NameLabelItem) {
162 160 impl->m_Plot->removeItem(impl->m_NameLabelItem);
163 161 impl->m_NameLabelItem = nullptr;
164 162 }
165 163 else if (!impl->m_NameLabelItem) {
166 164 impl->m_NameLabelItem = new QCPItemText(impl->m_Plot);
167 165 impl->m_NameLabelItem->setText(name);
168 166 impl->m_NameLabelItem->setPositionAlignment(Qt::AlignHCenter | Qt::AlignTop);
169 167 impl->m_NameLabelItem->setColor(impl->m_Color);
170 168 impl->m_NameLabelItem->position->setParentAnchor(top);
171 169 }
172 170 }
173 171
174 172 QString VisualizationSelectionZoneItem::name() const
175 173 {
176 174 if (!impl->m_NameLabelItem) {
177 175 return QString();
178 176 }
179 177
180 178 return impl->m_NameLabelItem->text();
181 179 }
182 180
183 181 SqpRange VisualizationSelectionZoneItem::range() const
184 182 {
185 183 SqpRange range;
186 184 range.m_TStart = impl->m_T1 <= impl->m_T2 ? impl->m_T1 : impl->m_T2;
187 185 range.m_TEnd = impl->m_T1 > impl->m_T2 ? impl->m_T1 : impl->m_T2;
188 186 return range;
189 187 }
190 188
191 189 void VisualizationSelectionZoneItem::setRange(double tstart, double tend)
192 190 {
193 191 impl->m_T1 = tstart;
194 192 impl->m_T2 = tend;
195 193 impl->updatePosition(this);
196 194 }
197 195
198 196 void VisualizationSelectionZoneItem::setStart(double tstart)
199 197 {
200 198 impl->m_T1 = tstart;
201 199 impl->updatePosition(this);
202 200 }
203 201
204 202 void VisualizationSelectionZoneItem::setEnd(double tend)
205 203 {
206 204 impl->m_T2 = tend;
207 205 impl->updatePosition(this);
208 206 }
209 207
210 208 void VisualizationSelectionZoneItem::setColor(const QColor &color)
211 209 {
212 210 impl->m_Color = color;
213 211
214 212 auto brushColor = color;
215 213 brushColor.setAlpha(80);
216 214 setBrush(QBrush(brushColor));
217 215 setPen(QPen(Qt::NoPen));
218 216
219 217 auto selectedBrushColor = brushColor;
220 218 selectedBrushColor.setAlpha(150);
221 219 setSelectedBrush(QBrush(selectedBrushColor));
222 220 setSelectedPen(QPen(Qt::NoPen));
223 221
224 222 auto linePen = QPen(color);
225 223 linePen.setStyle(Qt::SolidLine);
226 224 linePen.setWidth(4);
227 225
228 226 auto selectedLinePen = linePen;
229 227 selectedLinePen.setColor(color.darker(120));
230 228 selectedLinePen.setWidth(4);
231 229
232 230 impl->m_LeftLine->setPen(linePen);
233 231 impl->m_RightLine->setPen(linePen);
234 232
235 233 impl->m_LeftLine->setSelectedPen(selectedLinePen);
236 234 impl->m_RightLine->setSelectedPen(selectedLinePen);
237 235 }
238 236
239 237 void VisualizationSelectionZoneItem::setEditionEnabled(bool value)
240 238 {
241 239 impl->m_IsEditionEnabled = value;
242 240 setSelectable(value);
243 241 if (!value) {
244 242 setSelected(false);
245 243 impl->m_CurrentEditionMode = VisualizationSelectionZoneItemPrivate::EditionMode::NoEdition;
246 244 }
247 245 }
248 246
249 247 bool VisualizationSelectionZoneItem::isEditionEnabled() const
250 248 {
251 249 return impl->m_IsEditionEnabled;
252 250 }
253 251
254 252 void VisualizationSelectionZoneItem::moveToTop()
255 253 {
256 254 moveToLayer(layer(), false);
257 255 }
258 256
259 257 Qt::CursorShape
260 258 VisualizationSelectionZoneItem::curshorShapeForPosition(const QPoint &position) const
261 259 {
262 260 auto mode = impl->m_CurrentEditionMode
263 261 == VisualizationSelectionZoneItemPrivate::EditionMode::NoEdition
264 262 ? impl->getEditionMode(position, this)
265 263 : impl->m_CurrentEditionMode;
266 264 switch (mode) {
267 265 case VisualizationSelectionZoneItemPrivate::EditionMode::Move:
268 266 return Qt::SizeAllCursor;
269 267 case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeLeft:
270 268 case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeRight: // fallthrough
271 269 return Qt::SizeHorCursor;
272 270 default:
273 271 return Qt::ArrowCursor;
274 272 }
275 273 }
276 274
277 275 void VisualizationSelectionZoneItem::setHovered(bool value)
278 276 {
279 277 if (value) {
280 278 auto linePen = impl->m_LeftLine->pen();
281 279 linePen.setStyle(Qt::DotLine);
282 280 linePen.setWidth(3);
283 281
284 282 auto selectedLinePen = impl->m_LeftLine->selectedPen();
285 283 ;
286 284 selectedLinePen.setStyle(Qt::DotLine);
287 285 selectedLinePen.setWidth(3);
288 286
289 287 impl->m_LeftLine->setPen(linePen);
290 288 impl->m_RightLine->setPen(linePen);
291 289
292 290 impl->m_LeftLine->setSelectedPen(selectedLinePen);
293 291 impl->m_RightLine->setSelectedPen(selectedLinePen);
294 292 }
295 293 else {
296 294 setColor(impl->m_Color);
297 295 }
298 296 }
299 297
300 298 void VisualizationSelectionZoneItem::setAssociatedEditedZones(
301 299 const QVector<VisualizationSelectionZoneItem *> &associatedZones)
302 300 {
303 301 impl->m_AssociatedEditedZones = associatedZones;
304 302 impl->m_AssociatedEditedZones.removeAll(this);
305 303 }
306 304
307 305 bool VisualizationSelectionZoneItem::alignZonesVerticallyOnLeft(
308 306 const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool allowResize)
309 307 {
310 308 return impl->alignZones(this, zonesToAlign, true, allowResize, true);
311 309 }
312 310
313 311 bool VisualizationSelectionZoneItem::alignZonesVerticallyOnRight(
314 312 const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool allowResize)
315 313 {
316 314 return impl->alignZones(this, zonesToAlign, false, allowResize, true);
317 315 }
318 316
319 317 bool VisualizationSelectionZoneItem::alignZonesTemporallyOnLeft(
320 318 const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool allowResize)
321 319 {
322 320 return impl->alignZones(this, zonesToAlign, true, allowResize, false);
323 321 }
324 322
325 323 bool VisualizationSelectionZoneItem::alignZonesTemporallyOnRight(
326 324 const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool allowResize)
327 325 {
328 326 return impl->alignZones(this, zonesToAlign, false, allowResize, false);
329 327 }
330 328
331 329 void VisualizationSelectionZoneItem::mousePressEvent(QMouseEvent *event, const QVariant &details)
332 330 {
333 331 Q_UNUSED(details);
334 332
335 333 if (isEditionEnabled() && event->button() == Qt::LeftButton) {
336 334 impl->m_CurrentEditionMode = impl->getEditionMode(event->pos(), this);
337 335
338 336 impl->m_MovedOrinalT1 = impl->m_T1;
339 337 impl->m_MovedOrinalT2 = impl->m_T2;
340 338 for (auto associatedZone : impl->m_AssociatedEditedZones) {
341 339 associatedZone->impl->m_MovedOrinalT1 = associatedZone->impl->m_T1;
342 340 associatedZone->impl->m_MovedOrinalT2 = associatedZone->impl->m_T2;
343 341 }
344 342 }
345 343 else {
346 344 impl->m_CurrentEditionMode = VisualizationSelectionZoneItemPrivate::EditionMode::NoEdition;
347 345 event->ignore();
348 346 }
349 347 }
350 348
351 349 void VisualizationSelectionZoneItem::mouseMoveEvent(QMouseEvent *event, const QPointF &startPos)
352 350 {
353 351 if (isEditionEnabled()) {
354 352 if (!selected()) {
355 353 // Force the item to be selected during the edition
356 354 parentGraphWidget()->parentVisualizationWidget()->selectionZoneManager().setSelected(
357 355 this, true);
358 356 }
359 357
360 358 auto axis = impl->m_Plot->axisRect()->axis(QCPAxis::atBottom);
361 359 auto pixelDiff = event->pos().x() - startPos.x();
362 360 auto diff = impl->pixelSizeToAxisXSize(pixelDiff);
363 361
364 362 switch (impl->m_CurrentEditionMode) {
365 363 case VisualizationSelectionZoneItemPrivate::EditionMode::Move:
366 364 setRange(impl->m_MovedOrinalT1 + diff, impl->m_MovedOrinalT2 + diff);
367 365 for (auto associatedZone : impl->m_AssociatedEditedZones) {
368 366 associatedZone->move(pixelDiff);
369 367 }
370 368 break;
371 369 case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeLeft:
372 370 setStart(impl->m_MovedOrinalT1 + diff);
373 371 for (auto associatedZone : impl->m_AssociatedEditedZones) {
374 372 impl->m_MovedOrinalT1 < impl->m_MovedOrinalT2
375 373 ? associatedZone->resizeLeft(pixelDiff)
376 374 : associatedZone->resizeRight(pixelDiff);
377 375 }
378 376 break;
379 377 case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeRight:
380 378 setEnd(impl->m_MovedOrinalT2 + diff);
381 379 for (auto associatedZone : impl->m_AssociatedEditedZones) {
382 380 impl->m_MovedOrinalT1 < impl->m_MovedOrinalT2
383 381 ? associatedZone->resizeRight(pixelDiff)
384 382 : associatedZone->resizeLeft(pixelDiff);
385 383 }
386 384 break;
387 385 default:
388 386 break;
389 387 }
390 388
391 389 for (auto associatedZone : impl->m_AssociatedEditedZones) {
392 390 associatedZone->parentPlot()->replot();
393 391 }
394 392 }
395 393 else {
396 394 event->ignore();
397 395 }
398 396 }
399 397
400 398 void VisualizationSelectionZoneItem::mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos)
401 399 {
402 400 Q_UNUSED(startPos);
403 401
404 402 if (isEditionEnabled()) {
405 403 impl->m_CurrentEditionMode = VisualizationSelectionZoneItemPrivate::EditionMode::NoEdition;
406 404 }
407 405 else {
408 406 event->ignore();
409 407 }
410 408
411 409 impl->m_AssociatedEditedZones.clear();
412 410 }
413 411
414 412 void VisualizationSelectionZoneItem::resizeLeft(double pixelDiff)
415 413 {
416 414 auto diff = impl->pixelSizeToAxisXSize(pixelDiff);
417 415 if (impl->m_MovedOrinalT1 <= impl->m_MovedOrinalT2) {
418 416 setStart(impl->m_MovedOrinalT1 + diff);
419 417 }
420 418 else {
421 419 setEnd(impl->m_MovedOrinalT2 + diff);
422 420 }
423 421 }
424 422
425 423 void VisualizationSelectionZoneItem::resizeRight(double pixelDiff)
426 424 {
427 425 auto diff = impl->pixelSizeToAxisXSize(pixelDiff);
428 426 if (impl->m_MovedOrinalT1 > impl->m_MovedOrinalT2) {
429 427 setStart(impl->m_MovedOrinalT1 + diff);
430 428 }
431 429 else {
432 430 setEnd(impl->m_MovedOrinalT2 + diff);
433 431 }
434 432 }
435 433
436 434 void VisualizationSelectionZoneItem::move(double pixelDiff)
437 435 {
438 436 auto diff = impl->pixelSizeToAxisXSize(pixelDiff);
439 437 setRange(impl->m_MovedOrinalT1 + diff, impl->m_MovedOrinalT2 + diff);
440 438 }
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

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