##// END OF EJS Templates
Implements VisualizationWidget::displayVariable() slot
Implements VisualizationWidget::displayVariable() slot

File last commit:

r176:a33df991d7dc
r176:a33df991d7dc
Show More
VisualizationWidget.cpp
105 lines | 3.4 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationWidget.cpp
mv visualization -> Visualization...
r95 #include "Visualization/VisualizationWidget.h"
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r176 #include "Visualization/VisualizationGraphWidget.h"
mv visualization -> Visualization...
r95 #include "Visualization/VisualizationTabWidget.h"
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r176 #include "Visualization/VisualizationZoneWidget.h"
Add the visualization gui classes
r118 #include "Visualization/qcustomplot.h"
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 #include "ui_VisualizationWidget.h"
Widget of the tab widget are now of type VisualizationTabWidget...
r88
#include <QToolButton>
Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58
VisualizationWidget::VisualizationWidget(QWidget *parent)
Modify construction of objects to use initializer list...
r91 : QWidget{parent}, ui{new Ui::VisualizationWidget}
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 {
ui->setupUi(this);
Widget of the tab widget are now of type VisualizationTabWidget...
r88
Modify construction of objects to use initializer list...
r91 auto addTabViewButton = new QToolButton{ui->tabWidget};
addTabViewButton->setText(tr("Add View"));
Widget of the tab widget are now of type VisualizationTabWidget...
r88 addTabViewButton->setCursor(Qt::ArrowCursor);
addTabViewButton->setAutoRaise(true);
ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
Add code to ensure the corner widget to be always visible
r156 auto width = ui->tabWidget->cornerWidget()->width();
auto height = ui->tabWidget->cornerWidget()->height();
addTabViewButton->setMinimumHeight(height);
addTabViewButton->setMinimumWidth(width);
ui->tabWidget->setMinimumHeight(height);
ui->tabWidget->setMinimumWidth(width);
Widget of the tab widget are now of type VisualizationTabWidget...
r88
Add button on the SidePane widgets to open left or right inspectors
r101 auto addTabView = [&]() {
Widget of the tab widget are now of type VisualizationTabWidget...
r88 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
QString("View %1").arg(ui->tabWidget->count() + 1));
qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
};
auto removeTabView = [&](int index) {
ui->tabWidget->removeTab(index);
qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
};
ui->tabWidget->setTabsClosable(true);
connect(addTabViewButton, &QToolButton::clicked, addTabView);
connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 }
VisualizationWidget::~VisualizationWidget()
{
delete ui;
}
Add the visualization gui classes
r118
void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget)
{
// NOTE: check is this method has to be deleted because of its dupplicated version visible as
// lambda function (in the constructor)
}
VisualizationTabWidget *VisualizationWidget::createTab()
{
}
void VisualizationWidget::removeTab(VisualizationTabWidget *tab)
{
// NOTE: check is this method has to be deleted because of its dupplicated version visible as
// lambda function (in the constructor)
}
void VisualizationWidget::accept(IVisualizationWidget *visitor)
{
// TODO: manage the visitor
}
void VisualizationWidget::close()
{
// The main view cannot be directly closed.
return;
}
Add const and override
r119 QString VisualizationWidget::name() const
Add the visualization gui classes
r118 {
return QStringLiteral("MainView");
}
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r175
void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept
{
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r176 if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) {
if (auto newZone = currentTab->createZone()) {
if (auto newGraph = newZone->createGraph()) {
newGraph->addVariable(variable);
}
else {
qCDebug(LOG_VisualizationWidget())
<< tr("Can't display the variable : can't create the graph");
}
}
else {
qCDebug(LOG_VisualizationWidget())
<< tr("Can't display the variable : can't create a new zone in the current tab");
}
}
else {
qCDebug(LOG_VisualizationWidget())
<< tr("Can't display the variable : there is no current tab");
}
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r175 }