##// END OF EJS Templates
Adds name to a graph...
Adds name to a graph - The name is passed as a parameter in the ctor - It is used as a title of the graph and will also be used to be displayed in menus related to a variable

File last commit:

r175:a02da6065266
r182:8ddc77b998a0
Show More
VisualizationWidget.cpp
117 lines | 3.8 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationWidget.cpp
mv visualization -> Visualization...
r93 #include "Visualization/VisualizationWidget.h"
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r163 #include "Visualization/VisualizationGraphWidget.h"
mv visualization -> Visualization...
r93 #include "Visualization/VisualizationTabWidget.h"
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r163 #include "Visualization/VisualizationZoneWidget.h"
Add the visualization gui classes
r111 #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...
r87
#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...
r89 : 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...
r87
Modify construction of objects to use initializer list...
r89 auto addTabViewButton = new QToolButton{ui->tabWidget};
addTabViewButton->setText(tr("Add View"));
Widget of the tab widget are now of type VisualizationTabWidget...
r87 addTabViewButton->setCursor(Qt::ArrowCursor);
ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r173
Alexandre Leroux
Fixes after review
r175 auto enableMinimumCornerWidgetSize = [this](bool enable) {
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r173
auto tabViewCornerWidget = ui->tabWidget->cornerWidget();
auto width = enable ? tabViewCornerWidget->width() : 0;
auto height = enable ? tabViewCornerWidget->height() : 0;
tabViewCornerWidget->setMinimumHeight(height);
tabViewCornerWidget->setMinimumWidth(width);
ui->tabWidget->setMinimumHeight(height);
ui->tabWidget->setMinimumWidth(width);
};
Alexandre Leroux
Fixes after review
r175 auto addTabView = [this, enableMinimumCornerWidgetSize]() {
Widget of the tab widget are now of type VisualizationTabWidget...
r87 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
QString("View %1").arg(ui->tabWidget->count() + 1));
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r173 if (ui->tabWidget->count() > 0) {
Alexandre Leroux
Fixes after review
r175 enableMinimumCornerWidgetSize(false);
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r173 }
Widget of the tab widget are now of type VisualizationTabWidget...
r87 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
};
Alexandre Leroux
Fixes after review
r175 auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) {
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r173 if (ui->tabWidget->count() == 1) {
Alexandre Leroux
Fixes after review
r175 enableMinimumCornerWidgetSize(true);
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r173 }
Widget of the tab widget are now of type VisualizationTabWidget...
r87 ui->tabWidget->removeTab(index);
qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r173
Widget of the tab widget are now of type VisualizationTabWidget...
r87 };
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
r111
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
r112 QString VisualizationWidget::name() const
Add the visualization gui classes
r111 {
return QStringLiteral("MainView");
}
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r162
void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept
{
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r163 if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) {
if (auto newZone = currentTab->createZone()) {
if (auto newGraph = newZone->createGraph()) {
newGraph->addVariable(variable);
}
else {
Alexandre Leroux
Fixes after review
r175 qCCritical(LOG_VisualizationWidget())
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r163 << tr("Can't display the variable : can't create the graph");
}
}
else {
Alexandre Leroux
Fixes after review
r175 qCCritical(LOG_VisualizationWidget())
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r163 << tr("Can't display the variable : can't create a new zone in the current tab");
}
}
else {
Alexandre Leroux
Fixes after review
r175 qCCritical(LOG_VisualizationWidget())
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r163 << 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...
r162 }