##// END OF EJS Templates
Merge branch 'feature/TimeVariableAtDisplay' into develop
perrinel -
r317:e774472e365b merge
parent child
Show More
@@ -28,6 +28,7 public:
28 virtual ~VisualizationGraphWidget();
28 virtual ~VisualizationGraphWidget();
29
29
30 void addVariable(std::shared_ptr<Variable> variable);
30 void addVariable(std::shared_ptr<Variable> variable);
31 void addVariableUsingGraph(std::shared_ptr<Variable> variable);
31 /// Removes a variable from the graph
32 /// Removes a variable from the graph
32 void removeVariable(std::shared_ptr<Variable> variable) noexcept;
33 void removeVariable(std::shared_ptr<Variable> variable) noexcept;
33
34
@@ -52,7 +53,7 private slots:
52 /// Slot called when right clicking on the graph (displays a menu)
53 /// Slot called when right clicking on the graph (displays a menu)
53 void onGraphMenuRequested(const QPoint &pos) noexcept;
54 void onGraphMenuRequested(const QPoint &pos) noexcept;
54
55
55 void onRangeChanged(const QCPRange &t1, const QCPRange &t2);
56 void onRangeChanged(const QCPRange &t1);
56
57
57 /// Slot called when a mouse wheel was made, to perform some processing before the zoom is done
58 /// Slot called when a mouse wheel was made, to perform some processing before the zoom is done
58 void onMouseWheel(QWheelEvent *event) noexcept;
59 void onMouseWheel(QWheelEvent *event) noexcept;
@@ -63,6 +63,11 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie
63 << xValue.count();
63 << xValue.count();
64
64
65 qcpGraph->setData(xValue, vValue);
65 qcpGraph->setData(xValue, vValue);
66
67 // Display all data
68 // component->parentPlot()->xAxis->setRange(dateTime.m_TStart, dateTime.m_TEnd);
69 component->rescaleAxes();
70 component->parentPlot()->replot();
66 }
71 }
67 else {
72 else {
68 /// @todo DEBUG
73 /// @todo DEBUG
@@ -97,7 +102,6 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC
97
102
98 // Display all data
103 // Display all data
99 component->rescaleAxes();
104 component->rescaleAxes();
100
101 plot.replot();
105 plot.replot();
102 }
106 }
103 else {
107 else {
@@ -49,9 +49,9 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget
49 ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
49 ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
50 ui->widget->axisRect()->setRangeDrag(Qt::Horizontal);
50 ui->widget->axisRect()->setRangeDrag(Qt::Horizontal);
51 connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel);
51 connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel);
52 connect(ui->widget->xAxis, static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>(
52 connect(ui->widget->xAxis,
53 &QCPAxis::rangeChanged),
53 static_cast<void (QCPAxis::*)(const QCPRange &)>(&QCPAxis::rangeChanged), this,
54 this, &VisualizationGraphWidget::onRangeChanged);
54 &VisualizationGraphWidget::onRangeChanged);
55
55
56 // Activates menu when right clicking on the graph
56 // Activates menu when right clicking on the graph
57 ui->widget->setContextMenuPolicy(Qt::CustomContextMenu);
57 ui->widget->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -80,6 +80,34 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
80 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
80 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
81 }
81 }
82
82
83 void VisualizationGraphWidget::addVariableUsingGraph(std::shared_ptr<Variable> variable)
84 {
85
86 // when adding a variable, we need to set its time range to the current graph range
87 auto grapheRange = ui->widget->xAxis->range();
88 auto dateTime = SqpDateTime{grapheRange.lower, grapheRange.upper};
89 variable->setDateTime(dateTime);
90
91 auto variableDateTimeWithTolerance = dateTime;
92
93 // add 10% tolerance for each side
94 auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart);
95 variableDateTimeWithTolerance.m_TStart -= tolerance;
96 variableDateTimeWithTolerance.m_TEnd += tolerance;
97
98 // Uses delegate to create the qcpplot components according to the variable
99 auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget);
100
101 for (auto createdPlottable : qAsConst(createdPlottables)) {
102 impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable});
103 }
104
105 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
106
107 // CHangement detected, we need to ask controller to request data loading
108 emit requestDataLoading(variable, variableDateTimeWithTolerance);
109 }
110
83 void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept
111 void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept
84 {
112 {
85 // Each component associated to the variable :
113 // Each component associated to the variable :
@@ -136,16 +164,15 void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept
136 }
164 }
137 }
165 }
138
166
139 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange &t2)
167 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
140 {
168 {
141
142 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged");
169 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged");
143
170
144 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
171 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
145 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
172 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
146
173
147 auto variable = it->first;
174 auto variable = it->first;
148 auto dateTime = SqpDateTime{t2.lower, t2.upper};
175 auto dateTime = SqpDateTime{t1.lower, t1.upper};
149
176
150 if (!variable->contains(dateTime)) {
177 if (!variable->contains(dateTime)) {
151
178
@@ -137,7 +137,7 void GenerateVariableMenuOperation::visit(VisualizationGraphWidget *graphWidget)
137 if (graphWidget) {
137 if (graphWidget) {
138 impl->visitLeaf(
138 impl->visitLeaf(
139 *graphWidget, QObject::tr("Open in %1").arg(graphWidget->name()),
139 *graphWidget, QObject::tr("Open in %1").arg(graphWidget->name()),
140 [ var = impl->m_Variable, graphWidget ]() { graphWidget->addVariable(var); });
140 [ var = impl->m_Variable, graphWidget ]() { graphWidget->addVariableUsingGraph(var); });
141 }
141 }
142 else {
142 else {
143 qCCritical(LOG_GenerateVariableMenuOperation(),
143 qCCritical(LOG_GenerateVariableMenuOperation(),
General Comments 0
You need to be logged in to leave comments. Login now