VisualizationWidget.cpp
85 lines
| 2.6 KiB
| text/x-c
|
CppLexer
r95 | #include "Visualization/VisualizationWidget.h" | |||
#include "Visualization/VisualizationTabWidget.h" | ||||
r118 | #include "Visualization/qcustomplot.h" | |||
r58 | #include "ui_VisualizationWidget.h" | |||
r88 | ||||
#include <QToolButton> | ||||
Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") | ||||
r58 | ||||
VisualizationWidget::VisualizationWidget(QWidget *parent) | ||||
r91 | : QWidget{parent}, ui{new Ui::VisualizationWidget} | |||
r58 | { | |||
ui->setupUi(this); | ||||
r88 | ||||
r91 | auto addTabViewButton = new QToolButton{ui->tabWidget}; | |||
addTabViewButton->setText(tr("Add View")); | ||||
r88 | addTabViewButton->setCursor(Qt::ArrowCursor); | |||
addTabViewButton->setAutoRaise(true); | ||||
ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); | ||||
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); | ||||
r88 | ||||
r101 | auto addTabView = [&]() { | |||
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); | ||||
r58 | } | |||
VisualizationWidget::~VisualizationWidget() | ||||
{ | ||||
delete ui; | ||||
} | ||||
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; | ||||
} | ||||
r119 | QString VisualizationWidget::name() const | |||
r118 | { | |||
return QStringLiteral("MainView"); | ||||
} | ||||
Alexandre Leroux
|
r175 | |||
void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept | ||||
{ | ||||
/// @todo ALX : add variable in a new graph | ||||
} | ||||