##// END OF EJS Templates
Switched to new TS impl but quite broken!...
Switched to new TS impl but quite broken! Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1420:3c3e24550401
r1420:3c3e24550401
Show More
VisualizationWidget.cpp
240 lines | 7.7 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"
New class to manage actions in the visualization
r1078 #include "Visualization/VisualizationActionManager.h"
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r176 #include "Visualization/VisualizationGraphWidget.h"
Add action to remove the selected zone with the "del" buttons
r1082 #include "Visualization/VisualizationSelectionZoneItem.h"
multi selection of zones
r1049 #include "Visualization/VisualizationSelectionZoneManager.h"
mv visualization -> Visualization...
r95 #include "Visualization/VisualizationTabWidget.h"
Alexandre Leroux
Implements VisualizationWidget::displayVariable() slot
r176 #include "Visualization/VisualizationZoneWidget.h"
Alexandre Leroux
Prohibits the plot of a variable in several graphs (2)...
r736 #include "Visualization/operations/FindVariableOperation.h"
Alexandre Leroux
Creates a method (slot) in VisualizationWidget to add the plot menu to a variable menu
r248 #include "Visualization/operations/GenerateVariableMenuOperation.h"
Alexandre Leroux
Variable deletion (5)...
r334 #include "Visualization/operations/RemoveVariableOperation.h"
Add connection logical for the rescale operation
r437 #include "Visualization/operations/RescaleAxeOperation.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
Rename "DragDropHelper" in "DragDropGuiController"
r1075 #include "DragAndDrop/DragDropGuiController.h"
New event filter class to manage the tab switching of a tabBar during a drag&drop
r886 #include "SqpApplication.h"
Widget of the tab widget are now of type VisualizationTabWidget...
r88 #include <QToolButton>
multi selection of zones
r1049 #include <memory>
Widget of the tab widget are now of type VisualizationTabWidget...
r88 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58
Switched to new TS impl but quite broken!...
r1420 struct VisualizationWidget::VisualizationWidgetPrivate
{
multi selection of zones
r1049 std::unique_ptr<VisualizationSelectionZoneManager> m_ZoneSelectionManager = nullptr;
New class to manage actions in the visualization
r1078 VisualizationActionManager m_ActionManager;
multi selection of zones
r1049
VisualizationWidgetPrivate()
: m_ZoneSelectionManager(std::make_unique<VisualizationSelectionZoneManager>())
{
}
};
Switched to new TS impl but quite broken!...
r1420 VisualizationWidget::VisualizationWidget(QWidget* parent)
: QWidget { parent }
, ui { new Ui::VisualizationWidget }
, impl { spimpl::make_unique_impl<VisualizationWidgetPrivate>() }
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 {
ui->setupUi(this);
Widget of the tab widget are now of type VisualizationTabWidget...
r88
Switched to new TS impl but quite broken!...
r1420 auto addTabViewButton = new QToolButton { ui->tabWidget };
Modify construction of objects to use initializer list...
r91 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]() {
Switched to new TS impl but quite broken!...
r1420 auto widget
= new VisualizationTabWidget { QString { "View %1" }.arg(ui->tabWidget->count() + 1),
ui->tabWidget };
Alexandre Leroux
Adds a name for a tab...
r198 auto index = ui->tabWidget->addTab(widget, widget->name());
Switched to new TS impl but quite broken!...
r1420 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) {
Switched to new TS impl but quite broken!...
r1420 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);
Switched to new TS impl but quite broken!...
r1420 if (widget)
{
Alexandre Leroux
Updates tab widget so it can be deleted when closed
r267 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);
};
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
Rename "DragDropHelper" in "DragDropGuiController"
r1075 sqpApp->dragDropGuiController().addDragDropTabBar(ui->tabWidget->tabBar());
New event filter class to manage the tab switching of a tabBar during a drag&drop
r886
Add action to remove the selected zone with the "del" buttons
r1082 // Actions
New class to manage actions in the visualization
r1078 impl->m_ActionManager.installSelectionZoneActions();
Add action to remove the selected zone with the "del" buttons
r1082 auto removeZoneAction = new QAction("Remove selected zone(s)");
removeZoneAction->setShortcut(QKeySequence::Delete);
connect(removeZoneAction, &QAction::triggered, [this]() {
auto selection = impl->m_ZoneSelectionManager->selectedItems();
Switched to new TS impl but quite broken!...
r1420 for (auto selectionZone : selection)
{
if (auto graph = selectionZone->parentGraphWidget())
{
Add action to remove the selected zone with the "del" buttons
r1082 graph->removeSelectionZone(selectionZone);
}
}
});
addAction(removeZoneAction);
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()
{
Rename "DragDropHelper" in "DragDropGuiController"
r1075 sqpApp->dragDropGuiController().removeDragDropTabBar(ui->tabWidget->tabBar());
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 delete ui;
}
Add the visualization gui classes
r118
Switched to new TS impl but quite broken!...
r1420 VisualizationSelectionZoneManager& VisualizationWidget::selectionZoneManager() const
multi selection of zones
r1049 {
return *impl->m_ZoneSelectionManager.get();
}
Switched to new TS impl but quite broken!...
r1420 VisualizationTabWidget* VisualizationWidget::currentTabWidget() const
Retrieves zone names from the visualization
r1136 {
Switched to new TS impl but quite broken!...
r1420 if (auto tab = qobject_cast<VisualizationTabWidget*>(ui->tabWidget->currentWidget()))
{
Retrieves zone names from the visualization
r1136 return tab;
}
return nullptr;
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationWidget::accept(IVisualizationWidgetVisitor* visitor)
Add the visualization gui classes
r118 {
Switched to new TS impl but quite broken!...
r1420 if (visitor)
{
Alexandre Leroux
Implements accept() method of visualization widgets
r208 visitor->visitEnter(this);
// Apply visitor for tab children
Switched to new TS impl but quite broken!...
r1420 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
Switched to new TS impl but quite broken!...
r1420 = dynamic_cast<VisualizationTabWidget*>(ui->tabWidget->widget(i)))
{
Alexandre Leroux
Implements accept() method of visualization widgets
r208 visualizationTabWidget->accept(visitor);
}
}
visitor->visitLeave(this);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Alexandre Leroux
Adds logs for null visitors
r219 qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null");
}
Add the visualization gui classes
r118 }
Switched to new TS impl but quite broken!...
r1420 bool VisualizationWidget::canDrop(Variable2& variable) const
Alexandre Leroux
Creates a interface that defines a variable container...
r209 {
// The main widget can never accomodate a variable
Q_UNUSED(variable);
return false;
}
Switched to new TS impl but quite broken!...
r1420 bool VisualizationWidget::contains(Variable2& variable) const
Alexandre Leroux
Unplot menu (5): adds contains() method to an IVariableContainer...
r327 {
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
Changes signal to pass a list of variables...
r288 void VisualizationWidget::attachVariableMenu(
Switched to new TS impl but quite broken!...
r1420 QMenu* menu, const QVector<std::shared_ptr<Variable2>>& variables) noexcept
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r175 {
Alexandre Leroux
Changes signal to pass a list of variables...
r288 // Menu is generated only if there is a single variable
Switched to new TS impl but quite broken!...
r1420 if (variables.size() == 1)
{
if (auto variable = variables.first())
{
Alexandre Leroux
Prohibits the plot of a variable in several graphs (2)...
r736 // Gets the containers of the variable
Switched to new TS impl but quite broken!...
r1420 FindVariableOperation findVariableOperation { variable };
Alexandre Leroux
Prohibits the plot of a variable in several graphs (2)...
r736 accept(&findVariableOperation);
auto variableContainers = findVariableOperation.result();
Alexandre Leroux
Changes signal to pass a list of variables...
r288 // Generates the actions that make it possible to visualize the variable
Switched to new TS impl but quite broken!...
r1420 GenerateVariableMenuOperation generateVariableMenuOperation { menu, variable,
std::move(variableContainers) };
Alexandre Leroux
Changes signal to pass a list of variables...
r288 accept(&generateVariableMenuOperation);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Alexandre Leroux
Changes signal to pass a list of variables...
r288 qCCritical(LOG_VisualizationWidget()) << tr(
"Can't generate the menu relative to the visualization: the variable is null");
}
}
Switched to new TS impl but quite broken!...
r1420 else
{
Alexandre Leroux
Changes signal to pass a list of variables...
r288 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...
r175 }
Alexandre Leroux
Variable deletion (5)...
r334
Switched to new TS impl but quite broken!...
r1420 void VisualizationWidget::onVariableAboutToBeDeleted(std::shared_ptr<Variable2> variable) noexcept
Alexandre Leroux
Variable deletion (5)...
r334 {
// Calls the operation of removing all references to the variable in the visualization
Switched to new TS impl but quite broken!...
r1420 auto removeVariableOperation = RemoveVariableOperation { variable };
Alexandre Leroux
Variable deletion (5)...
r334 accept(&removeVariableOperation);
}
Add connection logical for the rescale operation
r437
Switched to new TS impl but quite broken!...
r1420 void VisualizationWidget::onRangeChanged(
std::shared_ptr<Variable2> variable, const DateTimeRange& range) noexcept
Add connection logical for the rescale operation
r437 {
Correction for MR
r447 // Calls the operation of rescaling all graph that contrains variable in the visualization
Switched to new TS impl but quite broken!...
r1420 auto rescaleVariableOperation = RescaleAxeOperation { variable, range };
Add connection logical for the rescale operation
r437 accept(&rescaleVariableOperation);
}
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738
Switched to new TS impl but quite broken!...
r1420 void VisualizationWidget::closeEvent(QCloseEvent* event)
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 {
// Closes tabs in the widget
Switched to new TS impl but quite broken!...
r1420 for (auto i = 0; i < ui->tabWidget->count(); ++i)
{
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 if (auto visualizationTabWidget
Switched to new TS impl but quite broken!...
r1420 = dynamic_cast<VisualizationTabWidget*>(ui->tabWidget->widget(i)))
{
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 visualizationTabWidget->close();
}
}
QWidget::closeEvent(event);
}