##// END OF EJS Templates
Merge branch 'feature/PurgeDataSeries' into develop
Merge branch 'feature/PurgeDataSeries' into develop

File last commit:

r595:8e31780497af
r633:e899bacb01d9 merge
Show More
VisualizationZoneWidget.cpp
260 lines | 10.3 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationZoneWidget.cpp
mv visualization -> Visualization...
r93 #include "Visualization/VisualizationZoneWidget.h"
Add synchronization that keep delta
r410
Alexandre Leroux
Updates visitor interface...
r192 #include "Visualization/IVisualizationWidgetVisitor.h"
Add synchronization that keep delta
r410 #include "Visualization/VisualizationGraphWidget.h"
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 #include "ui_VisualizationZoneWidget.h"
Implementation of V5 acquisition
r510 #include <Data/SqpRange.h>
Initialisation of the graph range at creation in a new graphe, or inside...
r518 #include <Variable/Variable.h>
Implementation of V5 acquisition
r510 #include <Variable/VariableController.h>
Add the visualization gui classes
r111
Implementation of V5 acquisition
r510 #include <QUuid>
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r245 #include <SqpApplication.h>
Change cmath include order from clang format
r580 #include <cmath>
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r245
Alexandre Leroux
Adds logs for null visitors
r204 Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget")
Alexandre Leroux
Completes the method of creating a zone from a variable
r186 namespace {
Alexandre Leroux
Adds scrollbar to tabs
r284 /// 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
r186 /// 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
Implementation of V5 acquisition
r510 struct VisualizationZoneWidget::VisualizationZoneWidgetPrivate {
explicit VisualizationZoneWidgetPrivate() : m_SynchronisationGroupId{QUuid::createUuid()} {}
QUuid m_SynchronisationGroupId;
};
Alexandre Leroux
Adds a name for a zone...
r183 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent)
Implementation of V5 acquisition
r510 : QWidget{parent},
ui{new Ui::VisualizationZoneWidget},
impl{spimpl::make_unique_impl<VisualizationZoneWidgetPrivate>()}
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 {
ui->setupUi(this);
Alexandre Leroux
Adds a name for a zone...
r183
ui->zoneNameLabel->setText(name);
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r245
// '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));
Implementation of V5 acquisition
r510
// Synchronisation id
QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronizationGroupId",
Qt::QueuedConnection, Q_ARG(QUuid, impl->m_SynchronisationGroupId));
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 }
VisualizationZoneWidget::~VisualizationZoneWidget()
{
delete ui;
}
Add the visualization gui classes
r111
void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
{
ui->visualizationZoneFrame->layout()->addWidget(graphWidget);
}
Alexandre Leroux
Completes the method of creating a zone from a variable
r186 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable)
Add the visualization gui classes
r111 {
Alexandre Leroux
Completes the method of creating a zone from a variable
r186 auto graphWidget = new VisualizationGraphWidget{
defaultGraphName(*ui->visualizationZoneFrame->layout()), this};
Alexandre Leroux
Adds scrollbar to tabs
r284
Add synchronization that keep delta
r410
Alexandre Leroux
Adds scrollbar to tabs
r284 // Set graph properties
graphWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
graphWidget->setMinimumHeight(GRAPH_MINIMUM_HEIGHT);
Alexandre Leroux
Completes the method of creating a zone from a variable
r186
Add synchronization that keep delta
r410 // Lambda to synchronize zone widget
change grapheRange to graphRange
r516 auto synchronizeZoneWidget = [this, graphWidget](const SqpRange &graphRange,
Implementation of V5 acquisition
r510 const SqpRange &oldGraphRange) {
change grapheRange to graphRange
r516 auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange);
Add synchronization that keep delta
r410 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) {
Implementation of V5 acquisition
r510 case AcquisitionZoomType::ZoomIn: {
change grapheRange to graphRange
r516 auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart;
auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd;
Add synchronization that keep delta
r410 graphChildRange.m_TStart += deltaLeft;
graphChildRange.m_TEnd -= deltaRight;
Next range of a variable synchronized is now computed using:...
r586 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn");
qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
<< deltaLeft;
qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
<< deltaRight;
qCDebug(LOG_VisualizationZoneWidget())
change grapheRange to graphRange
r516 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
Implementation of the calibration for the synchronization...
r411
Add synchronization that keep delta
r410 break;
}
Implementation of V5 acquisition
r510 case AcquisitionZoomType::ZoomOut: {
Next range of a variable synchronized is now computed using:...
r586 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut");
change grapheRange to graphRange
r516 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
Next range of a variable synchronized is now computed using:...
r586 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
<< deltaLeft;
qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
<< deltaRight;
qCDebug(LOG_VisualizationZoneWidget())
change grapheRange to graphRange
r516 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
Add synchronization that keep delta
r410 graphChildRange.m_TStart -= deltaLeft;
graphChildRange.m_TEnd += deltaRight;
break;
}
Implementation of V5 acquisition
r510 case AcquisitionZoomType::PanRight: {
Next range of a variable synchronized is now computed using:...
r586 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight");
change grapheRange to graphRange
r516 auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
Add synchronization that keep delta
r410 graphChildRange.m_TStart += deltaRight;
graphChildRange.m_TEnd += deltaRight;
Next range of a variable synchronized is now computed using:...
r586 qCDebug(LOG_VisualizationZoneWidget())
change grapheRange to graphRange
r516 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
Add synchronization that keep delta
r410 break;
}
Implementation of V5 acquisition
r510 case AcquisitionZoomType::PanLeft: {
Next range of a variable synchronized is now computed using:...
r586 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft");
change grapheRange to graphRange
r516 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
Add synchronization that keep delta
r410 graphChildRange.m_TStart -= deltaLeft;
graphChildRange.m_TEnd -= deltaLeft;
break;
}
Implementation of V5 acquisition
r510 case AcquisitionZoomType::Unknown: {
Next range of a variable synchronized is now computed using:...
r586 qCDebug(LOG_VisualizationZoneWidget())
Add synchronization that keep delta
r410 << 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;
}
Implementation of V5 acquisition
r510 graphChild->enableAcquisition(false);
Next range of a variable synchronized is now computed using:...
r586 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ")
<< graphChild->graphRange();
qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ")
<< graphChildRange;
qCDebug(LOG_VisualizationZoneWidget())
Implementation of the calibration for the synchronization...
r411 << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart;
graphChild->setGraphRange(graphChildRange);
Implementation of V5 acquisition
r510 graphChild->enableAcquisition(true);
Add synchronization that keep delta
r410 }
}
};
// connection for synchronization
connect(graphWidget, &VisualizationGraphWidget::synchronize, synchronizeZoneWidget);
Add synchronization part of v5 acquisition
r511 connect(graphWidget, &VisualizationGraphWidget::variableAdded, this,
&VisualizationZoneWidget::onVariableAdded);
Initialisation of the graph range at creation in a new graphe, or inside...
r518 auto range = SqpRange{};
// Apply visitor to graph children
auto layout = ui->visualizationZoneFrame->layout();
if (layout->count() > 0) {
// Case of a new graph in a existant zone
if (auto visualizationGraphWidget
= dynamic_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) {
range = visualizationGraphWidget->graphRange();
}
}
else {
// Case of a new graph as the first of the zone
range = variable->range();
}
Add synchronization part of v5 acquisition
r511 this->addGraph(graphWidget);
Initialisation of the graph range at creation in a new graphe, or inside...
r518 graphWidget->addVariable(variable, range);
Alexandre Leroux
Uses variable range in graph
r576
// get y using variable range
if (auto dataSeries = variable->dataSeries()) {
Add thread protection for DataSeries...
r594 dataSeries->lockRead();
Add clang format from linux
r595 auto valuesBounds
= dataSeries->valuesBounds(variable->range().m_TStart, variable->range().m_TEnd);
Alexandre Leroux
Uses variable range in graph
r576 auto end = dataSeries->cend();
if (valuesBounds.first != end && valuesBounds.second != end) {
auto rangeValue = [](const auto &value) { return std::isnan(value) ? 0. : value; };
auto minValue = rangeValue(valuesBounds.first->minValue());
auto maxValue = rangeValue(valuesBounds.second->maxValue());
graphWidget->setYRange(SqpRange{minValue, maxValue});
}
Add thread protection for DataSeries...
r594 dataSeries->unlock();
Alexandre Leroux
Uses variable range in graph
r576 }
Add synchronization that keep delta
r410
Add the visualization gui classes
r111 return graphWidget;
}
Alexandre Leroux
Updates visitor interface...
r192 void VisualizationZoneWidget::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 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
r205 // Widgets different from graphs are not visited (no action)
Alexandre Leroux
Implements accept() method of visualization widgets
r193 if (auto visualizationGraphWidget
= dynamic_cast<VisualizationGraphWidget *>(item->widget())) {
visualizationGraphWidget->accept(visitor);
}
}
}
visitor->visitLeave(this);
}
Alexandre Leroux
Adds logs for null visitors
r204 else {
qCCritical(LOG_VisualizationZoneWidget()) << 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 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...
r301 bool VisualizationZoneWidget::contains(const Variable &variable) const
{
Q_UNUSED(variable);
return false;
}
Add const and override
r112 QString VisualizationZoneWidget::name() const
Add the visualization gui classes
r111 {
Alexandre Leroux
Adds a name for a zone...
r183 return ui->zoneNameLabel->text();
Add the visualization gui classes
r111 }
Add synchronization part of v5 acquisition
r511
void VisualizationZoneWidget::onVariableAdded(std::shared_ptr<Variable> variable)
{
QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronized",
Qt::QueuedConnection, Q_ARG(std::shared_ptr<Variable>, variable),
Q_ARG(QUuid, impl->m_SynchronisationGroupId));
}