##// END OF EJS Templates
Creates helper that filters a tree widget according to a filter function
Creates helper that filters a tree widget according to a filter function

File last commit:

r445:a75bae0e8d4d
r476:becb718e8802
Show More
VisualizationZoneWidget.cpp
200 lines | 8.2 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationZoneWidget.cpp
mv visualization -> Visualization...
r95 #include "Visualization/VisualizationZoneWidget.h"
Add synchronization that keep delta
r444
#include "Data/SqpDateTime.h"
Alexandre Leroux
Updates visitor interface...
r207 #include "Visualization/IVisualizationWidgetVisitor.h"
Add synchronization that keep delta
r444 #include "Visualization/VisualizationGraphWidget.h"
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 #include "ui_VisualizationZoneWidget.h"
Add the visualization gui classes
r118
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r265 #include <SqpApplication.h>
Alexandre Leroux
Adds logs for null visitors
r219 Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget")
Alexandre Leroux
Completes the method of creating a zone from a variable
r200 namespace {
Alexandre Leroux
Adds scrollbar to tabs
r307 /// Minimum height for graph added in zones (in pixels)
const auto GRAPH_MINIMUM_HEIGHT = 300;
Alexandre Leroux
Completes the method of creating a zone from a variable
r200 /// Generates a default name for a new graph, according to the number of graphs already displayed in
/// the zone
QString defaultGraphName(const QLayout &layout)
{
auto count = 0;
for (auto i = 0; i < layout.count(); ++i) {
if (dynamic_cast<VisualizationGraphWidget *>(layout.itemAt(i)->widget())) {
count++;
}
}
return QObject::tr("Graph %1").arg(count + 1);
}
} // namespace
Alexandre Leroux
Adds a name for a zone...
r197 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent)
Modify construction of objects to use initializer list...
r91 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 {
ui->setupUi(this);
Alexandre Leroux
Adds a name for a zone...
r197
ui->zoneNameLabel->setText(name);
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r265
// 'Close' options : widget is deleted when closed
setAttribute(Qt::WA_DeleteOnClose);
connect(ui->closeButton, &QToolButton::clicked, this, &VisualizationZoneWidget::close);
ui->closeButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 }
VisualizationZoneWidget::~VisualizationZoneWidget()
{
delete ui;
}
Add the visualization gui classes
r118
void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
{
ui->visualizationZoneFrame->layout()->addWidget(graphWidget);
}
Alexandre Leroux
Completes the method of creating a zone from a variable
r200 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable)
Add the visualization gui classes
r118 {
Alexandre Leroux
Completes the method of creating a zone from a variable
r200 auto graphWidget = new VisualizationGraphWidget{
defaultGraphName(*ui->visualizationZoneFrame->layout()), this};
Alexandre Leroux
Adds scrollbar to tabs
r307
Add synchronization that keep delta
r444
Alexandre Leroux
Adds scrollbar to tabs
r307 // Set graph properties
graphWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
graphWidget->setMinimumHeight(GRAPH_MINIMUM_HEIGHT);
Add the visualization gui classes
r118 this->addGraph(graphWidget);
Alexandre Leroux
Completes the method of creating a zone from a variable
r200 graphWidget->addVariable(variable);
Add synchronization that keep delta
r444 // Lambda to synchronize zone widget
auto synchronizeZoneWidget = [this, graphWidget](const SqpDateTime &dateTime,
const SqpDateTime &oldDateTime,
VisualizationGraphWidgetZoomType zoomType) {
auto frameLayout = ui->visualizationZoneFrame->layout();
for (auto i = 0; i < frameLayout->count(); ++i) {
auto graphChild
= dynamic_cast<VisualizationGraphWidget *>(frameLayout->itemAt(i)->widget());
if (graphChild && (graphChild != graphWidget)) {
auto graphChildRange = graphChild->graphRange();
switch (zoomType) {
case VisualizationGraphWidgetZoomType::ZoomIn: {
auto deltaLeft = dateTime.m_TStart - oldDateTime.m_TStart;
auto deltaRight = oldDateTime.m_TEnd - dateTime.m_TEnd;
graphChildRange.m_TStart += deltaLeft;
graphChildRange.m_TEnd -= deltaRight;
Implementation of the calibration for the synchronization...
r445 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn");
qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
<< deltaLeft;
qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
<< deltaRight;
qCCritical(LOG_VisualizationZoneWidget())
<< tr("TORM: dt") << dateTime.m_TEnd - dateTime.m_TStart;
Add synchronization that keep delta
r444 break;
}
case VisualizationGraphWidgetZoomType::ZoomOut: {
Implementation of the calibration for the synchronization...
r445 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut");
Add synchronization that keep delta
r444 auto deltaLeft = oldDateTime.m_TStart - dateTime.m_TStart;
auto deltaRight = dateTime.m_TEnd - oldDateTime.m_TEnd;
Implementation of the calibration for the synchronization...
r445 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
<< deltaLeft;
qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
<< deltaRight;
qCCritical(LOG_VisualizationZoneWidget())
<< tr("TORM: dt") << dateTime.m_TEnd - dateTime.m_TStart;
Add synchronization that keep delta
r444 graphChildRange.m_TStart -= deltaLeft;
graphChildRange.m_TEnd += deltaRight;
break;
}
case VisualizationGraphWidgetZoomType::PanRight: {
Implementation of the calibration for the synchronization...
r445 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight");
Add synchronization that keep delta
r444 auto deltaRight = dateTime.m_TEnd - oldDateTime.m_TEnd;
graphChildRange.m_TStart += deltaRight;
graphChildRange.m_TEnd += deltaRight;
Implementation of the calibration for the synchronization...
r445 qCCritical(LOG_VisualizationZoneWidget())
<< tr("TORM: dt") << dateTime.m_TEnd - dateTime.m_TStart;
Add synchronization that keep delta
r444 break;
}
case VisualizationGraphWidgetZoomType::PanLeft: {
Implementation of the calibration for the synchronization...
r445 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft");
Add synchronization that keep delta
r444 auto deltaLeft = oldDateTime.m_TStart - dateTime.m_TStart;
graphChildRange.m_TStart -= deltaLeft;
graphChildRange.m_TEnd -= deltaLeft;
break;
}
case VisualizationGraphWidgetZoomType::Unknown: {
qCCritical(LOG_VisualizationZoneWidget())
<< tr("Impossible to synchronize: zoom type unknown");
break;
}
default:
qCCritical(LOG_VisualizationZoneWidget())
<< tr("Impossible to synchronize: zoom type not take into account");
// No action
break;
}
graphChild->enableSynchronize(false);
Implementation of the calibration for the synchronization...
r445 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ")
<< graphChild->graphRange();
qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ")
<< graphChildRange;
qCCritical(LOG_VisualizationZoneWidget())
<< tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart;
graphChild->setGraphRange(graphChildRange);
Add synchronization that keep delta
r444 graphChild->enableSynchronize(true);
}
}
};
// connection for synchronization
connect(graphWidget, &VisualizationGraphWidget::synchronize, synchronizeZoneWidget);
Add the visualization gui classes
r118 return graphWidget;
}
Alexandre Leroux
Updates visitor interface...
r207 void VisualizationZoneWidget::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 to graph children
auto layout = ui->visualizationZoneFrame->layout();
for (auto i = 0; i < layout->count(); ++i) {
if (auto item = layout->itemAt(i)) {
Alexandre Leroux
Add comments
r220 // Widgets different from graphs are not visited (no action)
Alexandre Leroux
Implements accept() method of visualization widgets
r208 if (auto visualizationGraphWidget
= dynamic_cast<VisualizationGraphWidget *>(item->widget())) {
visualizationGraphWidget->accept(visitor);
}
}
}
visitor->visitLeave(this);
}
Alexandre Leroux
Adds logs for null visitors
r219 else {
qCCritical(LOG_VisualizationZoneWidget()) << 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 VisualizationZoneWidget::canDrop(const Variable &variable) const
{
// A tab can always accomodate a variable
Q_UNUSED(variable);
return true;
}
Alexandre Leroux
Unplot menu (5): adds contains() method to an IVariableContainer...
r327 bool VisualizationZoneWidget::contains(const Variable &variable) const
{
Q_UNUSED(variable);
return false;
}
Add const and override
r119 QString VisualizationZoneWidget::name() const
Add the visualization gui classes
r118 {
Alexandre Leroux
Adds a name for a zone...
r197 return ui->zoneNameLabel->text();
Add the visualization gui classes
r118 }