##// END OF EJS Templates
Adds width and height properties
Adds width and height properties

File last commit:

r268:8c02c648f602
r276:7011b0fc9fba
Show More
VisualizationWidget.cpp
115 lines | 3.8 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationWidget.cpp
mv visualization -> Visualization...
r95 #include "Visualization/VisualizationWidget.h"
Alexandre Leroux
Updates visitor interface...
r207 #include "Visualization/IVisualizationWidgetVisitor.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"
Alexandre Leroux
Creates a method (slot) in VisualizationWidget to add the plot menu to a variable menu
r248 #include "Visualization/operations/GenerateVariableMenuOperation.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);
ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r186
Alexandre Leroux
Fixes after review
r188 auto enableMinimumCornerWidgetSize = [this](bool enable) {
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r186
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
r188 auto addTabView = [this, enableMinimumCornerWidgetSize]() {
Alexandre Leroux
Adds a name for a tab...
r198 auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1),
ui->tabWidget};
auto index = ui->tabWidget->addTab(widget, widget->name());
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r186 if (ui->tabWidget->count() > 0) {
Alexandre Leroux
Fixes after review
r188 enableMinimumCornerWidgetSize(false);
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r186 }
Widget of the tab widget are now of type VisualizationTabWidget...
r88 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
};
Alexandre Leroux
Fixes after review
r188 auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) {
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r186 if (ui->tabWidget->count() == 1) {
Alexandre Leroux
Fixes after review
r188 enableMinimumCornerWidgetSize(true);
Add lambda in VIsualizationWidget to fix the bug of the corner widget button size...
r186 }
Alexandre Leroux
Updates tab widget so it can be deleted when closed
r267 // Removes widget from tab and closes it
auto widget = ui->tabWidget->widget(index);
Widget of the tab widget are now of type VisualizationTabWidget...
r88 ui->tabWidget->removeTab(index);
Alexandre Leroux
Updates tab widget so it can be deleted when closed
r267 if (widget) {
widget->close();
}
Widget of the tab widget are now of type VisualizationTabWidget...
r88 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...
r186
Widget of the tab widget are now of type VisualizationTabWidget...
r88 };
ui->tabWidget->setTabsClosable(true);
connect(addTabViewButton, &QToolButton::clicked, addTabView);
connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
Alexandre Leroux
Removes the default tab from .ui and adds it manually...
r199
// Adds default tab
addTabView();
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 }
VisualizationWidget::~VisualizationWidget()
{
delete ui;
}
Add the visualization gui classes
r118
Alexandre Leroux
Updates visitor interface...
r207 void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor)
Add the visualization gui classes
r118 {
Alexandre Leroux
Implements accept() method of visualization widgets
r208 if (visitor) {
visitor->visitEnter(this);
// Apply visitor for tab children
for (auto i = 0; i < ui->tabWidget->count(); ++i) {
Alexandre Leroux
Add comments
r220 // Widgets different from tabs are not visited (no action)
Alexandre Leroux
Implements accept() method of visualization widgets
r208 if (auto visualizationTabWidget
= dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) {
visualizationTabWidget->accept(visitor);
}
}
visitor->visitLeave(this);
}
Alexandre Leroux
Adds logs for null visitors
r219 else {
qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null");
}
Add the visualization gui classes
r118 }
Alexandre Leroux
Creates a interface that defines a variable container...
r209 bool VisualizationWidget::canDrop(const Variable &variable) const
{
// The main widget can never accomodate a variable
Q_UNUSED(variable);
return false;
}
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
Alexandre Leroux
Creates a method (slot) in VisualizationWidget to add the plot menu to a variable menu
r248 void VisualizationWidget::attachVariableMenu(QMenu *menu,
std::shared_ptr<Variable> variable) noexcept
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r175 {
Alexandre Leroux
Creates a method (slot) in VisualizationWidget to add the plot menu to a variable menu
r248 // Generates the actions that make it possible to visualize the variable
auto generateVariableMenuOperation = GenerateVariableMenuOperation{menu, variable};
accept(&generateVariableMenuOperation);
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r175 }