##// END OF EJS Templates
Setups test (4)...
Setups test (4) Implements the test

File last commit:

r677:48ebbf123b7f
r716:c3e161f3c70a
Show More
VisualizationWidget.cpp
172 lines | 5.9 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationWidget.cpp
mv visualization -> Visualization...
r93 #include "Visualization/VisualizationWidget.h"
Alexandre Leroux
Updates visitor interface...
r192 #include "Visualization/IVisualizationWidgetVisitor.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"
Alexandre Leroux
Prohibits the plot of a variable in several graphs (2)...
r675 #include "Visualization/operations/FindVariableOperation.h"
Alexandre Leroux
Creates a method (slot) in VisualizationWidget to add the plot menu to a variable menu
r231 #include "Visualization/operations/GenerateVariableMenuOperation.h"
Alexandre Leroux
Variable deletion (5)...
r308 #include "Visualization/operations/RemoveVariableOperation.h"
Add connection logical for the rescale operation
r403 #include "Visualization/operations/RescaleAxeOperation.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]() {
Alexandre Leroux
Adds a name for a tab...
r184 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...
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 }
Alexandre Leroux
Updates tab widget so it can be deleted when closed
r247 // Removes widget from tab and closes it
auto widget = ui->tabWidget->widget(index);
Widget of the tab widget are now of type VisualizationTabWidget...
r87 ui->tabWidget->removeTab(index);
Alexandre Leroux
Updates tab widget so it can be deleted when closed
r247 if (widget) {
widget->close();
}
Widget of the tab widget are now of type VisualizationTabWidget...
r87 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);
Alexandre Leroux
Removes the default tab from .ui and adds it manually...
r185
// Adds default tab
addTabView();
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 }
VisualizationWidget::~VisualizationWidget()
{
delete ui;
}
Add the visualization gui classes
r111
Alexandre Leroux
Updates visitor interface...
r192 void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor)
Add the visualization gui classes
r111 {
Alexandre Leroux
Implements accept() method of visualization widgets
r193 if (visitor) {
visitor->visitEnter(this);
// Apply visitor for tab children
for (auto i = 0; i < ui->tabWidget->count(); ++i) {
Alexandre Leroux
Add comments
r205 // Widgets different from tabs are not visited (no action)
Alexandre Leroux
Implements accept() method of visualization widgets
r193 if (auto visualizationTabWidget
= dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) {
visualizationTabWidget->accept(visitor);
}
}
visitor->visitLeave(this);
}
Alexandre Leroux
Adds logs for null visitors
r204 else {
qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null");
}
Add the visualization gui classes
r111 }
Alexandre Leroux
Creates a interface that defines a variable container...
r194 bool VisualizationWidget::canDrop(const Variable &variable) const
{
// The main widget can never accomodate a variable
Q_UNUSED(variable);
return false;
}
Alexandre Leroux
Unplot menu (5): adds contains() method to an IVariableContainer...
r301 bool VisualizationWidget::contains(const Variable &variable) const
{
Q_UNUSED(variable);
return false;
}
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
Alexandre Leroux
Changes signal to pass a list of variables...
r266 void VisualizationWidget::attachVariableMenu(
QMenu *menu, const QVector<std::shared_ptr<Variable> > &variables) noexcept
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r162 {
Alexandre Leroux
Changes signal to pass a list of variables...
r266 // Menu is generated only if there is a single variable
if (variables.size() == 1) {
if (auto variable = variables.first()) {
Alexandre Leroux
Prohibits the plot of a variable in several graphs (2)...
r675 // Gets the containers of the variable
FindVariableOperation findVariableOperation{variable};
accept(&findVariableOperation);
auto variableContainers = findVariableOperation.result();
Alexandre Leroux
Changes signal to pass a list of variables...
r266 // Generates the actions that make it possible to visualize the variable
Alexandre Leroux
Prohibits the plot of a variable in several graphs (2)...
r675 GenerateVariableMenuOperation generateVariableMenuOperation{
menu, variable, std::move(variableContainers)};
Alexandre Leroux
Changes signal to pass a list of variables...
r266 accept(&generateVariableMenuOperation);
}
else {
qCCritical(LOG_VisualizationWidget()) << tr(
"Can't generate the menu relative to the visualization: the variable is null");
}
}
else {
qCDebug(LOG_VisualizationWidget())
<< tr("No generation of the menu related to the visualization: several variables are "
"selected");
}
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r162 }
Alexandre Leroux
Variable deletion (5)...
r308
void VisualizationWidget::onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept
{
// Calls the operation of removing all references to the variable in the visualization
auto removeVariableOperation = RemoveVariableOperation{variable};
accept(&removeVariableOperation);
}
Add connection logical for the rescale operation
r403
void VisualizationWidget::onRangeChanged(std::shared_ptr<Variable> variable,
Change SqpRange for SqpDateTime
r471 const SqpRange &range) noexcept
Add connection logical for the rescale operation
r403 {
Correction for MR
r413 // Calls the operation of rescaling all graph that contrains variable in the visualization
Add connection logical for the rescale operation
r403 auto rescaleVariableOperation = RescaleAxeOperation{variable, range};
accept(&rescaleVariableOperation);
}
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r677
void VisualizationWidget::closeEvent(QCloseEvent *event)
{
// Closes tabs in the widget
for (auto i = 0; i < ui->tabWidget->count(); ++i) {
if (auto visualizationTabWidget
= dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) {
visualizationTabWidget->close();
}
}
QWidget::closeEvent(event);
}