##// END OF EJS Templates
Bump Core, ready to integrate new DataSources model class...
Bump Core, ready to integrate new DataSources model class Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1486:8539a975891c
r1494:8ad169c5af90
Show More
VisualizationGraphWidget.cpp
1578 lines | 52.0 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationGraphWidget.cpp
mv visualization -> Visualization...
r95 #include "Visualization/VisualizationGraphWidget.h"
Alexandre Leroux
Updates visitor interface...
r207 #include "Visualization/IVisualizationWidgetVisitor.h"
Implements cursor mode
r960 #include "Visualization/VisualizationCursorItem.h"
Alexandre Leroux
Handles QCustomPlot plottables for vectors (2)...
r582 #include "Visualization/VisualizationDefs.h"
Correction for pull request
r243 #include "Visualization/VisualizationGraphHelper.h"
Alexandre Leroux
Creates a delegate offering methods for rendering a graph
r480 #include "Visualization/VisualizationGraphRenderingDelegate.h"
Selection of stacked zone via a dialog box
r1085 #include "Visualization/VisualizationMultiZoneSelectionDialog.h"
Display of selection zones on a graph
r1044 #include "Visualization/VisualizationSelectionZoneItem.h"
multi selection of zones
r1049 #include "Visualization/VisualizationSelectionZoneManager.h"
#include "Visualization/VisualizationWidget.h"
Integrates the drag&drop classes into the existing visualization classes.
r839 #include "Visualization/VisualizationZoneWidget.h"
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 #include "ui_VisualizationGraphWidget.h"
Adds selection zone actions in the context menu
r1077 #include <Actions/ActionsGuiController.h>
LineEdit to filter the create catalogue menu
r1328 #include <Actions/FilteringAction.h>
Move Common MIME types constants in a Definition file in core module.
r848 #include <Common/MimeTypesDef.h>
Switched to cpp_utils package...
r1486 #include <cpp_utils_qt/cpp_utils_qt.hpp>
#include <containers/algorithms.hpp>
Switched to new TS impl but quite broken!...
r1420 #include <Data/DateTimeRangeHelper.h>
Rename "DragDropHelper" in "DragDropGuiController"
r1075 #include <DragAndDrop/DragDropGuiController.h>
Alexandre Leroux
Settings binding (5)...
r470 #include <Settings/SqpSettingsDefs.h>
The mock plugin can now create data with view operation
r235 #include <SqpApplication.h>
Drop of variable, graph and zones on the time widget
r878 #include <Time/TimeController.h>
Switched to new TS impl but quite broken!...
r1420 #include <Variable/Variable2.h>
(•̀ᴗ•́)و ̑̑ Some cleaning, remover previous implementation of VariableController...
r1349 #include <Variable/VariableController2.h>
The mock plugin can now create data with view operation
r235
Add the visualization gui classes
r118 #include <unordered_map>
Alexandre Leroux
Adds logs for null visitors
r219 Q_LOGGING_CATEGORY(LOG_VisualizationGraphWidget, "VisualizationGraphWidget")
Switched to new TS impl but quite broken!...
r1420 namespace
{
Alexandre Leroux
Handles key modifiers for zoom...
r179
drag of selection zones
r1047 /// Key pressed to enable drag&drop in all modes
const auto DRAG_DROP_MODIFIER = Qt::AltModifier;
Alexandre Leroux
Handles key modifiers for zoom...
r179 /// Key pressed to enable zoom on horizontal axis
Basic mouse wheel interactions + mode drag
r958 const auto HORIZONTAL_ZOOM_MODIFIER = Qt::ControlModifier;
Alexandre Leroux
Handles key modifiers for zoom...
r179
/// Key pressed to enable zoom on vertical axis
Basic mouse wheel interactions + mode drag
r958 const auto VERTICAL_ZOOM_MODIFIER = Qt::ShiftModifier;
/// Speed of a step of a wheel event for a pan, in percentage of the axis range
const auto PAN_SPEED = 5;
/// Key pressed to enable a calibration pan
const auto VERTICAL_PAN_MODIFIER = Qt::AltModifier;
Alexandre Leroux
Handles key modifiers for zoom...
r179
multi selection of zones
r1049 /// Key pressed to enable multi selection of selection zones
const auto MULTI_ZONE_SELECTION_MODIFIER = Qt::ControlModifier;
Implements zoom box interaction mode
r959 /// Minimum size for the zoom box, in percentage of the axis range
const auto ZOOM_BOX_MIN_SIZE = 0.8;
Implements cursor mode
r960 /// Format of the dates appearing in the label of a cursor
const auto CURSOR_LABELS_DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd\nhh:mm:ss:zzz");
Alexandre Leroux
Handles key modifiers for zoom...
r179
} // namespace
Switched to new TS impl but quite broken!...
r1420 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate
{
Add the visualization gui classes
r118
Switched to new TS impl but quite broken!...
r1420 explicit VisualizationGraphWidgetPrivate(const QString& name)
: m_Name { name }
, m_Flags { GraphFlag::EnableAll }
, m_IsCalibration { false }
, m_RenderingDelegate { nullptr }
Alexandre Leroux
Creates a delegate offering methods for rendering a graph
r480 {
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 m_plot = new QCustomPlot();
// Necessary for all platform since Qt::AA_EnableHighDpiScaling is enable.
m_plot->setPlottingHint(QCP::phFastPolylines, true);
Alexandre Leroux
Creates a delegate offering methods for rendering a graph
r480 }
Implementation of the calibration for the synchronization...
r445
Switched to new TS impl but quite broken!...
r1420 void updateData(
PlottablesMap& plottables, std::shared_ptr<Variable2> variable, const DateTimeRange& range)
Alexandre Leroux
Updates sqp color scale thresholds (2)...
r1020 {
Alexandre Leroux
Updates VisualizationGraphHelper to use variable's type instead of dataseries
r1280 VisualizationGraphHelper::updateData(plottables, variable, range);
Alexandre Leroux
Updates sqp color scale thresholds (2)...
r1020
// Prevents that data has changed to update rendering
m_RenderingDelegate->onPlotUpdated();
}
Alexandre Leroux
Removes title and close button from graph widget...
r724 QString m_Name;
Add the visualization gui classes
r118 // 1 variable -> n qcpplot
Switched to new TS impl but quite broken!...
r1420 std::map<std::shared_ptr<Variable2>, PlottablesMap> m_VariableToPlotMultiMap;
Alexandre Leroux
Corrects the problem of refreshing synchronized graphs from TimeWidget (1)...
r1271 GraphFlags m_Flags;
Implementation of the calibration for the synchronization...
r445 bool m_IsCalibration;
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 QCustomPlot* m_plot;
QPoint m_lastMousePos;
Added RAW graph sync implementation...
r1373 QCPRange m_lastXRange;
QCPRange m_lastYRange;
Alexandre Leroux
Creates a delegate offering methods for rendering a graph
r480 /// Delegate used to attach rendering features to the plot
std::unique_ptr<VisualizationGraphRenderingDelegate> m_RenderingDelegate;
Implements zoom box interaction mode
r959
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 QCPItemRect* m_DrawingZoomRect = nullptr;
Switched to new TS impl but quite broken!...
r1420 QStack<QPair<QCPRange, QCPRange>> m_ZoomStack;
Display of selection zones on a graph
r1044
Implements cursor mode
r960 std::unique_ptr<VisualizationCursorItem> m_HorizontalCursor = nullptr;
std::unique_ptr<VisualizationCursorItem> m_VerticalCursor = nullptr;
Implements zoom box interaction mode
r959
Switched to new TS impl but quite broken!...
r1420 VisualizationSelectionZoneItem* m_DrawingZone = nullptr;
VisualizationSelectionZoneItem* m_HoveredZone = nullptr;
QVector<VisualizationSelectionZoneItem*> m_SelectionZones;
Implements zoom box interaction mode
r959
Improves display of selected zones
r1051 bool m_HasMovedMouse = false; // Indicates if the mouse moved in a releaseMouse even
Resize and move of multiple zones together
r1050
refactoring + fix created graph range
r1292 bool m_VariableAutoRangeOnInit = true;
Added RAW graph sync implementation...
r1373 inline void enterPlotDrag(const QPoint& position)
Implements zoom box interaction mode
r959 {
Added RAW graph sync implementation...
r1373 m_lastMousePos = m_plot->mapFromParent(position);
m_lastXRange = m_plot->xAxis->range();
m_lastYRange = m_plot->yAxis->range();
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 }
Switched to new TS impl but quite broken!...
r1420 inline bool isDrawingZoomRect() { return m_DrawingZoomRect != nullptr; }
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 void updateZoomRect(const QPoint& newPos)
{
Switched to new TS impl but quite broken!...
r1420 QPointF pos { m_plot->xAxis->pixelToCoord(newPos.x()),
m_plot->yAxis->pixelToCoord(newPos.y()) };
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 m_DrawingZoomRect->bottomRight->setCoords(pos);
m_plot->replot(QCustomPlot::rpQueuedReplot);
}
void applyZoomRect()
{
auto axisX = m_plot->axisRect()->axis(QCPAxis::atBottom);
auto axisY = m_plot->axisRect()->axis(QCPAxis::atLeft);
Switched to new TS impl but quite broken!...
r1420 auto newAxisXRange = QCPRange { m_DrawingZoomRect->topLeft->coords().x(),
m_DrawingZoomRect->bottomRight->coords().x() };
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364
Switched to new TS impl but quite broken!...
r1420 auto newAxisYRange = QCPRange { m_DrawingZoomRect->topLeft->coords().y(),
m_DrawingZoomRect->bottomRight->coords().y() };
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364
removeDrawingRect();
if (newAxisXRange.size() > axisX->range().size() * (ZOOM_BOX_MIN_SIZE / 100.0)
Switched to new TS impl but quite broken!...
r1420 && newAxisYRange.size() > axisY->range().size() * (ZOOM_BOX_MIN_SIZE / 100.0))
{
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 m_ZoomStack.push(qMakePair(axisX->range(), axisY->range()));
axisX->setRange(newAxisXRange);
axisY->setRange(newAxisYRange);
m_plot->replot(QCustomPlot::rpQueuedReplot);
}
}
Switched to new TS impl but quite broken!...
r1420 inline bool isDrawingZoneRect() { return m_DrawingZone != nullptr; }
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 void updateZoneRect(const QPoint& newPos)
{
m_DrawingZone->setEnd(m_plot->xAxis->pixelToCoord(newPos.x()));
m_plot->replot(QCustomPlot::rpQueuedReplot);
}
Switched to new TS impl but quite broken!...
r1420 void startDrawingRect(const QPoint& pos)
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 {
removeDrawingRect();
Implements zoom box interaction mode
r959
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto axisPos = posToAxisPos(pos);
Implements zoom box interaction mode
r959
Switched to new TS impl but quite broken!...
r1420 m_DrawingZoomRect = new QCPItemRect { m_plot };
Display of selection zones on a graph
r1044 QPen p;
p.setWidth(2);
m_DrawingZoomRect->setPen(p);
Implements zoom box interaction mode
r959
Display of selection zones on a graph
r1044 m_DrawingZoomRect->topLeft->setCoords(axisPos);
m_DrawingZoomRect->bottomRight->setCoords(axisPos);
Implements zoom box interaction mode
r959 }
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 void removeDrawingRect()
Implements zoom box interaction mode
r959 {
Switched to new TS impl but quite broken!...
r1420 if (m_DrawingZoomRect)
{
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 m_plot->removeItem(m_DrawingZoomRect); // the item is deleted by QCustomPlot
Display of selection zones on a graph
r1044 m_DrawingZoomRect = nullptr;
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 m_plot->replot(QCustomPlot::rpQueuedReplot);
Implements zoom box interaction mode
r959 }
}
Switched to new TS impl but quite broken!...
r1420 void selectZone(const QPoint& pos)
Display of selection zones on a graph
r1044 {
Refac + clang-format...
r1365 auto zoneAtPos = selectionZoneAt(pos);
Switched to new TS impl but quite broken!...
r1420 setSelectionZonesEditionEnabled(
sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones);
Refac + clang-format...
r1365 }
Switched to new TS impl but quite broken!...
r1420 void startDrawingZone(const QPoint& pos)
Refac + clang-format...
r1365 {
endDrawingZone();
Display of selection zones on a graph
r1044
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto axisPos = posToAxisPos(pos);
Display of selection zones on a graph
r1044
Switched to new TS impl but quite broken!...
r1420 m_DrawingZone = new VisualizationSelectionZoneItem { m_plot };
Display of selection zones on a graph
r1044 m_DrawingZone->setRange(axisPos.x(), axisPos.x());
m_DrawingZone->setEditionEnabled(false);
}
Refac + clang-format...
r1365 void endDrawingZone()
Display of selection zones on a graph
r1044 {
Switched to new TS impl but quite broken!...
r1420 if (m_DrawingZone)
{
Display of selection zones on a graph
r1044 auto drawingZoneRange = m_DrawingZone->range();
Switched to new TS impl but quite broken!...
r1420 if (qAbs(drawingZoneRange.m_TEnd - drawingZoneRange.m_TStart) > 0)
{
Display of selection zones on a graph
r1044 m_DrawingZone->setEditionEnabled(true);
multi selection of zones
r1049 addSelectionZone(m_DrawingZone);
Display of selection zones on a graph
r1044 }
Switched to new TS impl but quite broken!...
r1420 else
{
Refac + clang-format...
r1365 m_plot->removeItem(m_DrawingZone);
Display of selection zones on a graph
r1044 }
Refac + clang-format...
r1365 m_plot->replot(QCustomPlot::rpQueuedReplot);
Display of selection zones on a graph
r1044 m_DrawingZone = nullptr;
}
}
Refac + clang-format...
r1365 void moveSelectionZone(const QPoint& destination)
{
/*
* I give up on this for now
PySide2 bindings + some GUI clean...
r1478 * TODO implement this, the difficulty is that selection zones have their own
Refac + clang-format...
r1365 * event handling code which seems to rely on QCP GUI event handling propagation
* which was a realy bad design choice.
Switched to new TS impl but quite broken!...
r1420 */
Refac + clang-format...
r1365 }
Display of selection zones on a graph
r1044 void setSelectionZonesEditionEnabled(bool value)
{
Switched to new TS impl but quite broken!...
r1420 for (auto s : m_SelectionZones)
{
Display of selection zones on a graph
r1044 s->setEditionEnabled(value);
}
}
Switched to new TS impl but quite broken!...
r1420 void addSelectionZone(VisualizationSelectionZoneItem* zone) { m_SelectionZones << zone; }
multi selection of zones
r1049
Switched to new TS impl but quite broken!...
r1420 VisualizationSelectionZoneItem* selectionZoneAt(const QPoint& pos) const
drag of selection zones
r1047 {
Switched to new TS impl but quite broken!...
r1420 VisualizationSelectionZoneItem* selectionZoneItemUnderCursor = nullptr;
drag of selection zones
r1047 auto minDistanceToZone = -1;
Switched to new TS impl but quite broken!...
r1420 for (auto zone : m_SelectionZones)
{
drag of selection zones
r1047 auto distanceToZone = zone->selectTest(pos, false);
if ((minDistanceToZone < 0 || distanceToZone <= minDistanceToZone)
Switched to new TS impl but quite broken!...
r1420 && distanceToZone >= 0 && distanceToZone < m_plot->selectionTolerance())
{
drag of selection zones
r1047 selectionZoneItemUnderCursor = zone;
}
}
return selectionZoneItemUnderCursor;
}
Switched to new TS impl but quite broken!...
r1420 QVector<VisualizationSelectionZoneItem*> selectionZonesAt(
const QPoint& pos, const QCustomPlot& plot) const
Selection of stacked zone via a dialog box
r1085 {
Switched to new TS impl but quite broken!...
r1420 QVector<VisualizationSelectionZoneItem*> zones;
for (auto zone : m_SelectionZones)
{
Selection of stacked zone via a dialog box
r1085 auto distanceToZone = zone->selectTest(pos, false);
Switched to new TS impl but quite broken!...
r1420 if (distanceToZone >= 0 && distanceToZone < plot.selectionTolerance())
{
Selection of stacked zone via a dialog box
r1085 zones << zone;
}
}
return zones;
}
Switched to new TS impl but quite broken!...
r1420 void moveSelectionZoneOnTop(VisualizationSelectionZoneItem* zone, QCustomPlot& plot)
Selection of stacked zone via a dialog box
r1085 {
Switched to new TS impl but quite broken!...
r1420 if (!m_SelectionZones.isEmpty() && m_SelectionZones.last() != zone)
{
Selection of stacked zone via a dialog box
r1085 zone->moveToTop();
m_SelectionZones.removeAll(zone);
m_SelectionZones.append(zone);
}
}
Switched to new TS impl but quite broken!...
r1420 QPointF posToAxisPos(const QPoint& pos) const
Implements zoom box interaction mode
r959 {
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto axisX = m_plot->axisRect()->axis(QCPAxis::atBottom);
auto axisY = m_plot->axisRect()->axis(QCPAxis::atLeft);
Switched to new TS impl but quite broken!...
r1420 return QPointF { axisX->pixelToCoord(pos.x()), axisY->pixelToCoord(pos.y()) };
Implements zoom box interaction mode
r959 }
Implements cursor mode
r960
Switched to new TS impl but quite broken!...
r1420 bool pointIsInAxisRect(const QPointF& axisPoint, QCustomPlot& plot) const
Implements cursor mode
r960 {
auto axisX = plot.axisRect()->axis(QCPAxis::atBottom);
auto axisY = plot.axisRect()->axis(QCPAxis::atLeft);
return axisX->range().contains(axisPoint.x()) && axisY->range().contains(axisPoint.y());
}
More refactoring and added back plot tooltip...
r1363
Switched to new TS impl but quite broken!...
r1420 inline QCPRange _pixDistanceToRange(double pos1, double pos2, QCPAxis* axis)
More refactoring and added back plot tooltip...
r1363 {
if (axis->scaleType() == QCPAxis::stLinear)
{
auto diff = axis->pixelToCoord(pos1) - axis->pixelToCoord(pos2);
Switched to new TS impl but quite broken!...
r1420 return QCPRange { axis->range().lower + diff, axis->range().upper + diff };
More refactoring and added back plot tooltip...
r1363 }
else
{
auto diff = axis->pixelToCoord(pos1) / axis->pixelToCoord(pos2);
Switched to new TS impl but quite broken!...
r1420 return QCPRange { axis->range().lower * diff, axis->range().upper * diff };
More refactoring and added back plot tooltip...
r1363 }
}
Switched to new TS impl but quite broken!...
r1420 void setRange(const DateTimeRange& newRange, bool updateVar = true)
More refactoring and added back plot tooltip...
r1363 {
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 this->m_plot->xAxis->setRange(newRange.m_TStart, newRange.m_TEnd);
Switched to new TS impl but quite broken!...
r1420 if (updateVar)
More refactoring and added back plot tooltip...
r1363 {
Switched to new TS impl but quite broken!...
r1420 for (auto it = m_VariableToPlotMultiMap.begin(), end = m_VariableToPlotMultiMap.end();
More refactoring and added back plot tooltip...
r1363 it != end; it = m_VariableToPlotMultiMap.upper_bound(it->first))
{
Added RAW graph sync implementation...
r1373 sqpApp->variableController().asyncChangeRange(it->first, newRange);
More refactoring and added back plot tooltip...
r1363 }
}
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 m_plot->replot(QCustomPlot::rpQueuedReplot);
More refactoring and added back plot tooltip...
r1363 }
Switched to new TS impl but quite broken!...
r1420 void setRange(const QCPRange& newRange)
Added RAW graph sync implementation...
r1373 {
Switched to new TS impl but quite broken!...
r1420 auto graphRange = DateTimeRange { newRange.lower, newRange.upper };
Added RAW graph sync implementation...
r1373 setRange(graphRange);
}
Switched to new TS impl but quite broken!...
r1420 void rescaleY() { m_plot->yAxis->rescale(true); }
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377
Switched to new TS impl but quite broken!...
r1420 std::tuple<double, double> moveGraph(const QPoint& destination)
More refactoring and added back plot tooltip...
r1363 {
Added RAW graph sync implementation...
r1373 auto currentPos = m_plot->mapFromParent(destination);
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto xAxis = m_plot->axisRect()->rangeDragAxis(Qt::Horizontal);
auto yAxis = m_plot->axisRect()->rangeDragAxis(Qt::Vertical);
Added RAW graph sync implementation...
r1373 auto oldXRange = xAxis->range();
auto oldYRange = yAxis->range();
double dx = xAxis->pixelToCoord(m_lastMousePos.x()) - xAxis->pixelToCoord(currentPos.x());
Switched to new TS impl but quite broken!...
r1420 xAxis->setRange(m_lastXRange.lower + dx, m_lastXRange.upper + dx);
if (yAxis->scaleType() == QCPAxis::stLinear)
Added RAW graph sync implementation...
r1373 {
Switched to new TS impl but quite broken!...
r1420 double dy
= yAxis->pixelToCoord(m_lastMousePos.y()) - yAxis->pixelToCoord(currentPos.y());
yAxis->setRange(m_lastYRange.lower + dy, m_lastYRange.upper + dy);
Added RAW graph sync implementation...
r1373 }
else
{
Switched to new TS impl but quite broken!...
r1420 double dy
= yAxis->pixelToCoord(m_lastMousePos.y()) / yAxis->pixelToCoord(currentPos.y());
yAxis->setRange(m_lastYRange.lower * dy, m_lastYRange.upper * dy);
Added RAW graph sync implementation...
r1373 }
auto newXRange = xAxis->range();
auto newYRange = yAxis->range();
More refactoring and added back plot tooltip...
r1363 setRange(xAxis->range());
Switched to new TS impl but quite broken!...
r1420 // m_lastMousePos = currentPos;
return { newXRange.lower - oldXRange.lower, newYRange.lower - oldYRange.lower };
Added RAW graph sync implementation...
r1373 }
void zoom(double factor, int center, Qt::Orientation orientation)
{
Switched to new TS impl but quite broken!...
r1420 QCPAxis* axis = m_plot->axisRect()->rangeZoomAxis(orientation);
Added RAW graph sync implementation...
r1373 axis->scaleRange(factor, axis->pixelToCoord(center));
if (orientation == Qt::Horizontal)
setRange(axis->range());
m_plot->replot(QCustomPlot::rpQueuedReplot);
}
Switched to new TS impl but quite broken!...
r1420 void transform(const DateTimeRangeTransformation& tranformation)
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 {
auto graphRange = m_plot->xAxis->range();
Switched to new TS impl but quite broken!...
r1420 DateTimeRange range { graphRange.lower, graphRange.upper };
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 range = range.transform(tranformation);
setRange(range);
m_plot->replot(QCustomPlot::rpQueuedReplot);
}
Added RAW graph sync implementation...
r1373 void move(double dx, double dy)
{
auto xAxis = m_plot->axisRect()->rangeDragAxis(Qt::Horizontal);
auto yAxis = m_plot->axisRect()->rangeDragAxis(Qt::Vertical);
Switched to new TS impl but quite broken!...
r1420 xAxis->setRange(QCPRange(xAxis->range().lower + dx, xAxis->range().upper + dx));
yAxis->setRange(QCPRange(yAxis->range().lower + dy, yAxis->range().upper + dy));
Added RAW graph sync implementation...
r1373 setRange(xAxis->range());
m_plot->replot(QCustomPlot::rpQueuedReplot);
}
void move(double factor, Qt::Orientation orientation)
{
auto oldRange = m_plot->xAxis->range();
Switched to new TS impl but quite broken!...
r1420 QCPAxis* axis = m_plot->axisRect()->rangeDragAxis(orientation);
if (m_plot->xAxis->scaleType() == QCPAxis::stLinear)
{
Added RAW graph sync implementation...
r1373 double rg = (axis->range().upper - axis->range().lower) * (factor / 10);
axis->setRange(axis->range().lower + (rg), axis->range().upper + (rg));
}
Switched to new TS impl but quite broken!...
r1420 else if (m_plot->xAxis->scaleType() == QCPAxis::stLogarithmic)
{
Added RAW graph sync implementation...
r1373 int start = 0, stop = 0;
double diff = 0.;
Switched to new TS impl but quite broken!...
r1420 if (factor > 0.0)
{
Added RAW graph sync implementation...
r1373 stop = m_plot->width() * factor / 10;
start = 2 * m_plot->width() * factor / 10;
}
Switched to new TS impl but quite broken!...
r1420 if (factor < 0.0)
{
Added RAW graph sync implementation...
r1373 factor *= -1.0;
start = m_plot->width() * factor / 10;
stop = 2 * m_plot->width() * factor / 10;
}
diff = axis->pixelToCoord(start) / axis->pixelToCoord(stop);
axis->setRange(m_plot->axisRect()->rangeDragAxis(orientation)->range().lower * diff,
Switched to new TS impl but quite broken!...
r1420 m_plot->axisRect()->rangeDragAxis(orientation)->range().upper * diff);
Added RAW graph sync implementation...
r1373 }
if (orientation == Qt::Horizontal)
setRange(axis->range());
m_plot->replot(QCustomPlot::rpQueuedReplot);
More refactoring and added back plot tooltip...
r1363 }
Add the visualization gui classes
r118 };
Switched to new TS impl but quite broken!...
r1420 VisualizationGraphWidget::VisualizationGraphWidget(const QString& name, QWidget* parent)
: VisualizationDragWidget { parent }
, ui { new Ui::VisualizationGraphWidget }
, impl { spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>(name) }
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 {
ui->setupUi(this);
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 this->layout()->addWidget(impl->m_plot);
Alexandre Leroux
Adds a close button to a graph widget + calls close() method when clicked...
r266 // 'Close' options : widget is deleted when closed
setAttribute(Qt::WA_DeleteOnClose);
Alexandre Leroux
Adds name to a graph...
r196
Alexandre Leroux
Removes title and close button from graph widget...
r724 // The delegate must be initialized after the ui as it uses the plot
impl->m_RenderingDelegate = std::make_unique<VisualizationGraphRenderingDelegate>(*this);
Implements cursor mode
r960 // Init the cursors
impl->m_HorizontalCursor = std::make_unique<VisualizationCursorItem>(&plot());
impl->m_HorizontalCursor->setOrientation(Qt::Horizontal);
impl->m_VerticalCursor = std::make_unique<VisualizationCursorItem>(&plot());
impl->m_VerticalCursor->setOrientation(Qt::Vertical);
Partly reimplemented Graph event handling + bugfix...
r1362 this->setFocusPolicy(Qt::WheelFocus);
More refactoring and added back plot tooltip...
r1363 this->setMouseTracking(true);
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->m_plot->setAttribute(Qt::WA_TransparentForMouseEvents);
impl->m_plot->setContextMenuPolicy(Qt::CustomContextMenu);
impl->m_plot->setParent(this);
Fixed ugly bug, removing a variable didn't remove it from plot \_(ツ)_/¯...
r1381
Switched to new TS impl but quite broken!...
r1420 connect(&sqpApp->variableController(), &VariableController2::variableDeleted, this,
&VisualizationGraphWidget::variableDeleted);
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 }
Alexandre Leroux
QCustomPlot notify the graph widget when the xRange changed
r227
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 VisualizationGraphWidget::~VisualizationGraphWidget()
{
delete ui;
}
Add the visualization gui classes
r118
Switched to new TS impl but quite broken!...
r1420 VisualizationZoneWidget* VisualizationGraphWidget::parentZoneWidget() const noexcept
Integrates the drag&drop classes into the existing visualization classes.
r839 {
auto parent = parentWidget();
Switched to new TS impl but quite broken!...
r1420 while (parent != nullptr && !qobject_cast<VisualizationZoneWidget*>(parent))
{
Integrates the drag&drop classes into the existing visualization classes.
r839 parent = parent->parentWidget();
Fixes for review
r846 }
Integrates the drag&drop classes into the existing visualization classes.
r839
Switched to new TS impl but quite broken!...
r1420 return qobject_cast<VisualizationZoneWidget*>(parent);
Integrates the drag&drop classes into the existing visualization classes.
r839 }
Switched to new TS impl but quite broken!...
r1420 VisualizationWidget* VisualizationGraphWidget::parentVisualizationWidget() const
multi selection of zones
r1049 {
auto parent = parentWidget();
Switched to new TS impl but quite broken!...
r1420 while (parent != nullptr && !qobject_cast<VisualizationWidget*>(parent))
{
multi selection of zones
r1049 parent = parent->parentWidget();
}
Switched to new TS impl but quite broken!...
r1420 return qobject_cast<VisualizationWidget*>(parent);
multi selection of zones
r1049 }
Alexandre Leroux
Corrects the problem of refreshing synchronized graphs from TimeWidget (1)...
r1271 void VisualizationGraphWidget::setFlags(GraphFlags flags)
Add synchronization that keep delta
r444 {
Alexandre Leroux
Corrects the problem of refreshing synchronized graphs from TimeWidget (1)...
r1271 impl->m_Flags = std::move(flags);
Add synchronization that keep delta
r444 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable2> variable, DateTimeRange range)
Add the visualization gui classes
r118 {
Alexandre Leroux
Calls the update of the graph's units and range data of a variable have been loaded...
r1284 // Uses delegate to create the qcpplot components according to the variable
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto createdPlottables = VisualizationGraphHelper::create(variable, *impl->m_plot);
Alexandre Leroux
Calls the update of the graph's units and range data of a variable have been loaded...
r1284
// Sets graph properties
impl->m_RenderingDelegate->setGraphProperties(*variable, createdPlottables);
variable time is now set to range graphe displayed when it is displayed...
r314
Switched to new TS impl but quite broken!...
r1420 impl->m_VariableToPlotMultiMap.insert({ variable, std::move(createdPlottables) });
Alexandre Leroux
Calls the update of the graph's units and range data of a variable have been loaded...
r1284
Quite fixed D&D from tree......
r1378 setGraphRange(range);
Alexandre Leroux
Calls the update of the graph's units and range data of a variable have been loaded...
r1284 // If the variable already has its data loaded, load its units and its range in the graph
Switched to new TS impl but quite broken!...
r1420 if (variable->data() != nullptr)
{
Removed old IDataProvider IF, some small steps toward new VC integration...
r1351 impl->m_RenderingDelegate->setAxesUnits(*variable);
Quite fixed D&D from tree......
r1378 }
else
{
Switched to new TS impl but quite broken!...
r1420 auto context = new QObject { this };
connect(
variable.get(), &Variable2::updated, context, [this, variable, context, range](QUuid) {
this->impl->m_RenderingDelegate->setAxesUnits(*variable);
this->impl->m_plot->replot(QCustomPlot::rpQueuedReplot);
delete context;
});
Alexandre Leroux
Calls the update of the graph's units and range data of a variable have been loaded...
r1284 }
PySide2 bindings + some GUI clean...
r1478 //TODO this is bad! when variable is moved to another graph it still fires
[WIP] new generic WS plugin and few other fixes...
r1352 // even if this has been deleted
Switched to new TS impl but quite broken!...
r1420 connect(variable.get(), &Variable2::updated, this, &VisualizationGraphWidget::variableUpdated);
Partly reimplemented Graph event handling + bugfix...
r1362 this->onUpdateVarDisplaying(variable, range); // My bullshit
Initialisation of the graph range at creation in a new graphe, or inside...
r548 emit variableAdded(variable);
variable time is now set to range graphe displayed when it is displayed...
r314 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable2> variable) noexcept
Alexandre Leroux
Remove variable from graph (2)...
r270 {
Alexandre Leroux
Remove variable from graph (3)...
r271 // Each component associated to the variable :
// - is removed from qcpplot (which deletes it)
// - is no longer referenced in the map
Alexandre Leroux
Handles QCustomPlot plottables for vectors (2)...
r582 auto variableIt = impl->m_VariableToPlotMultiMap.find(variable);
Switched to new TS impl but quite broken!...
r1420 if (variableIt != impl->m_VariableToPlotMultiMap.cend())
{
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (1)...
r737 emit variableAboutToBeRemoved(variable);
Switched to new TS impl but quite broken!...
r1420 auto& plottablesMap = variableIt->second;
Alexandre Leroux
Handles QCustomPlot plottables for vectors (2)...
r582
for (auto plottableIt = plottablesMap.cbegin(), plottableEnd = plottablesMap.cend();
Switched to new TS impl but quite broken!...
r1420 plottableIt != plottableEnd;)
{
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->m_plot->removePlottable(plottableIt->second);
Alexandre Leroux
Handles QCustomPlot plottables for vectors (2)...
r582 plottableIt = plottablesMap.erase(plottableIt);
}
impl->m_VariableToPlotMultiMap.erase(variableIt);
Alexandre Leroux
Remove variable from graph (3)...
r271 }
// Updates graph
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->m_plot->replot(QCustomPlot::rpQueuedReplot);
Alexandre Leroux
Remove variable from graph (2)...
r270 }
Switched to new TS impl but quite broken!...
r1420 std::vector<std::shared_ptr<Variable2>> VisualizationGraphWidget::variables() const
Integrates the drag&drop classes into the existing visualization classes.
r839 {
Switched to new TS impl but quite broken!...
r1420 auto variables = std::vector<std::shared_ptr<Variable2>> {};
Format changes
r844 for (auto it = std::cbegin(impl->m_VariableToPlotMultiMap);
Switched to new TS impl but quite broken!...
r1420 it != std::cend(impl->m_VariableToPlotMultiMap); ++it)
{
Partly reimplemented Graph event handling + bugfix...
r1362 variables.push_back(it->first);
Integrates the drag&drop classes into the existing visualization classes.
r839 }
return variables;
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::setYRange(std::shared_ptr<Variable2> variable)
Initialisation of the graph range at creation in a new graphe, or inside...
r548 {
Switched to new TS impl but quite broken!...
r1420 if (!variable)
{
Alexandre Leroux
Refactors VisualizationGraphWidget::setYRange()...
r900 qCCritical(LOG_VisualizationGraphWidget()) << "Can't set y-axis range: variable is null";
return;
}
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 VisualizationGraphHelper::setYAxisRange(variable, *impl->m_plot);
Initialisation of the graph range at creation in a new graphe, or inside...
r548 }
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange VisualizationGraphWidget::graphRange() const noexcept
Add synchronization that keep delta
r444 {
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto graphRange = impl->m_plot->xAxis->range();
Switched to new TS impl but quite broken!...
r1420 return DateTimeRange { graphRange.lower, graphRange.upper };
Add synchronization that keep delta
r444 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::setGraphRange(
const DateTimeRange& range, bool updateVar, bool forward)
Add synchronization that keep delta
r444 {
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 impl->setRange(range, updateVar);
Switched to new TS impl but quite broken!...
r1420 if (forward)
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 {
Force range for each transformation among synchronized graphs, ignore missing X unit in data files since it's always time...
r1384 emit this->setrange_sig(this->graphRange(), true, false);
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 }
Add implementation for the range rescale. Variable is ignored here...
r438 }
refactoring + fix created graph range
r1292 void VisualizationGraphWidget::setAutoRangeOnVariableInitialization(bool value)
{
impl->m_VariableAutoRangeOnInit = value;
}
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 QVector<DateTimeRange> VisualizationGraphWidget::selectionZoneRanges() const
Keep the selection zones when a graph is dropped in another synchro zone
r1048 {
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 QVector<DateTimeRange> ranges;
Switched to new TS impl but quite broken!...
r1420 for (auto zone : impl->m_SelectionZones)
{
Keep the selection zones when a graph is dropped in another synchro zone
r1048 ranges << zone->range();
}
return ranges;
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::addSelectionZones(const QVector<DateTimeRange>& ranges)
Keep the selection zones when a graph is dropped in another synchro zone
r1048 {
Switched to new TS impl but quite broken!...
r1420 for (const auto& range : ranges)
{
multi selection of zones
r1049 // note: ownership is transfered to QCustomPlot
Keep the selection zones when a graph is dropped in another synchro zone
r1048 auto zone = new VisualizationSelectionZoneItem(&plot());
zone->setRange(range.m_TStart, range.m_TEnd);
multi selection of zones
r1049 impl->addSelectionZone(zone);
Keep the selection zones when a graph is dropped in another synchro zone
r1048 }
plot().replot(QCustomPlot::rpQueuedReplot);
}
Switched to new TS impl but quite broken!...
r1420 VisualizationSelectionZoneItem* VisualizationGraphWidget::addSelectionZone(
const QString& name, const DateTimeRange& range)
Link between selection zone item and event
r1293 {
// note: ownership is transfered to QCustomPlot
auto zone = new VisualizationSelectionZoneItem(&plot());
zone->setName(name);
zone->setRange(range.m_TStart, range.m_TEnd);
impl->addSelectionZone(zone);
plot().replot(QCustomPlot::rpQueuedReplot);
return zone;
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::removeSelectionZone(VisualizationSelectionZoneItem* selectionZone)
Action "Remove Selected Zones"
r1079 {
Add action to remove the selected zone with the "del" buttons
r1082 parentVisualizationWidget()->selectionZoneManager().setSelected(selectionZone, false);
Switched to new TS impl but quite broken!...
r1420 if (impl->m_HoveredZone == selectionZone)
{
Add action to remove the selected zone with the "del" buttons
r1082 impl->m_HoveredZone = nullptr;
setCursor(Qt::ArrowCursor);
}
Action "Remove Selected Zones"
r1079 impl->m_SelectionZones.removeAll(selectionZone);
plot().removeItem(selectionZone);
plot().replot(QCustomPlot::rpQueuedReplot);
}
Undo zoom box action
r1046 void VisualizationGraphWidget::undoZoom()
{
auto zoom = impl->m_ZoomStack.pop();
auto axisX = plot().axisRect()->axis(QCPAxis::atBottom);
auto axisY = plot().axisRect()->axis(QCPAxis::atLeft);
axisX->setRange(zoom.first);
axisY->setRange(zoom.second);
plot().replot(QCustomPlot::rpQueuedReplot);
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::zoom(
double factor, int center, Qt::Orientation orientation, bool forward)
Added RAW graph sync implementation...
r1373 {
impl->zoom(factor, center, orientation);
Switched to new TS impl but quite broken!...
r1420 if (forward && orientation == Qt::Horizontal)
Force range for each transformation among synchronized graphs, ignore missing X unit in data files since it's always time...
r1384 emit this->setrange_sig(this->graphRange(), true, false);
Added RAW graph sync implementation...
r1373 }
Partly reimplemented Graph event handling + bugfix...
r1362
Added RAW graph sync implementation...
r1373 void VisualizationGraphWidget::move(double factor, Qt::Orientation orientation, bool forward)
Partly reimplemented Graph event handling + bugfix...
r1362 {
Added RAW graph sync implementation...
r1373 impl->move(factor, orientation);
Switched to new TS impl but quite broken!...
r1420 if (forward)
Force range for each transformation among synchronized graphs, ignore missing X unit in data files since it's always time...
r1384 emit this->setrange_sig(this->graphRange(), true, false);
Partly reimplemented Graph event handling + bugfix...
r1362 }
Added RAW graph sync implementation...
r1373 void VisualizationGraphWidget::move(double dx, double dy, bool forward)
Partly reimplemented Graph event handling + bugfix...
r1362 {
Added RAW graph sync implementation...
r1373 impl->move(dx, dy);
Switched to new TS impl but quite broken!...
r1420 if (forward)
Force range for each transformation among synchronized graphs, ignore missing X unit in data files since it's always time...
r1384 emit this->setrange_sig(this->graphRange(), true, false);
Partly reimplemented Graph event handling + bugfix...
r1362 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::transform(
const DateTimeRangeTransformation& tranformation, bool forward)
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 {
impl->transform(tranformation);
Switched to new TS impl but quite broken!...
r1420 if (forward)
Force range for each transformation among synchronized graphs, ignore missing X unit in data files since it's always time...
r1384 emit this->setrange_sig(this->graphRange(), true, false);
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::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->visit(this);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Alexandre Leroux
Adds logs for null visitors
r219 qCCritical(LOG_VisualizationGraphWidget())
<< 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 VisualizationGraphWidget::canDrop(Variable2& variable) const
Alexandre Leroux
Creates a interface that defines a variable container...
r209 {
Switched to new TS impl but quite broken!...
r1420 auto isSpectrogram
= [](auto& variable) { return variable.type() == DataSeriesType::SPECTROGRAM; };
Alexandre Leroux
Prohibits the display of a spectrogram in an existing graph and the display of data on a graph already containing a spectrogram
r1022
// - A spectrogram series can't be dropped on graph with existing plottables
// - No data series can be dropped on graph with existing spectrogram series
return isSpectrogram(variable)
Switched to new TS impl but quite broken!...
r1420 ? impl->m_VariableToPlotMultiMap.empty()
: std::none_of(impl->m_VariableToPlotMultiMap.cbegin(),
impl->m_VariableToPlotMultiMap.cend(),
[isSpectrogram](const auto& entry) { return isSpectrogram(*entry.first); });
Alexandre Leroux
Creates a interface that defines a variable container...
r209 }
Switched to new TS impl but quite broken!...
r1420 bool VisualizationGraphWidget::contains(Variable2& variable) const
Alexandre Leroux
Unplot menu (5): adds contains() method to an IVariableContainer...
r327 {
// Finds the variable among the keys of the map
auto variablePtr = &variable;
auto findVariable
Switched to new TS impl but quite broken!...
r1420 = [variablePtr](const auto& entry) { return variablePtr == entry.first.get(); };
Alexandre Leroux
Unplot menu (5): adds contains() method to an IVariableContainer...
r327
auto end = impl->m_VariableToPlotMultiMap.cend();
auto it = std::find_if(impl->m_VariableToPlotMultiMap.cbegin(), end, findVariable);
return it != end;
}
Add const and override
r119 QString VisualizationGraphWidget::name() const
Add the visualization gui classes
r118 {
Alexandre Leroux
Removes title and close button from graph widget...
r724 return impl->m_Name;
Add the visualization gui classes
r118 }
Switched to new TS impl but quite broken!...
r1420 QMimeData* VisualizationGraphWidget::mimeData(const QPoint& position) const
Integrates the drag&drop classes into the existing visualization classes.
r839 {
Fixes for review
r846 auto mimeData = new QMimeData;
Integrates the drag&drop classes into the existing visualization classes.
r839
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto selectionZoneItemUnderCursor = impl->selectionZoneAt(position);
drag of selection zones
r1047 if (sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones
Switched to new TS impl but quite broken!...
r1420 && selectionZoneItemUnderCursor)
{
mimeData->setData(MIME_TYPE_TIME_RANGE,
TimeController::mimeDataForTimeRange(selectionZoneItemUnderCursor->range()));
mimeData->setData(MIME_TYPE_SELECTION_ZONE,
TimeController::mimeDataForTimeRange(selectionZoneItemUnderCursor->range()));
drag of selection zones
r1047 }
Switched to new TS impl but quite broken!...
r1420 else
{
mimeData->setData(MIME_TYPE_GRAPH, QByteArray {});
drag of selection zones
r1047
auto timeRangeData = TimeController::mimeDataForTimeRange(graphRange());
mimeData->setData(MIME_TYPE_TIME_RANGE, timeRangeData);
}
Drop of variable, graph and zones on the time widget
r878
Format changes
r844 return mimeData;
Integrates the drag&drop classes into the existing visualization classes.
r839 }
Switched to new TS impl but quite broken!...
r1420 QPixmap VisualizationGraphWidget::customDragPixmap(const QPoint& dragPosition)
drag of selection zones
r1047 {
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto selectionZoneItemUnderCursor = impl->selectionZoneAt(dragPosition);
drag of selection zones
r1047 if (sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones
Switched to new TS impl but quite broken!...
r1420 && selectionZoneItemUnderCursor)
{
drag of selection zones
r1047
auto zoneTopLeft = selectionZoneItemUnderCursor->topLeft->pixelPosition();
auto zoneBottomRight = selectionZoneItemUnderCursor->bottomRight->pixelPosition();
Switched to new TS impl but quite broken!...
r1420 auto zoneSize = QSizeF { qAbs(zoneBottomRight.x() - zoneTopLeft.x()),
qAbs(zoneBottomRight.y() - zoneTopLeft.y()) }
drag of selection zones
r1047 .toSize();
auto pixmap = QPixmap(zoneSize);
Switched to new TS impl but quite broken!...
r1420 render(&pixmap, QPoint(), QRegion { QRect { zoneTopLeft.toPoint(), zoneSize } });
drag of selection zones
r1047
return pixmap;
}
return QPixmap();
}
Integrates the drag&drop classes into the existing visualization classes.
r839 bool VisualizationGraphWidget::isDragAllowed() const
{
return true;
}
Improves visual effect of dropping a variable in a graph
r873 void VisualizationGraphWidget::highlightForMerge(bool highlighted)
{
Switched to new TS impl but quite broken!...
r1420 if (highlighted)
{
Improves visual effect of dropping a variable in a graph
r873 plot().setBackground(QBrush(QColor("#BBD5EE")));
}
Switched to new TS impl but quite broken!...
r1420 else
{
Improves visual effect of dropping a variable in a graph
r873 plot().setBackground(QBrush(Qt::white));
}
plot().update();
}
Implements cursor mode
r960 void VisualizationGraphWidget::addVerticalCursor(double time)
{
impl->m_VerticalCursor->setPosition(time);
impl->m_VerticalCursor->setVisible(true);
auto text
= DateUtils::dateTime(time).toString(CURSOR_LABELS_DATETIME_FORMAT).replace(' ', '\n');
impl->m_VerticalCursor->setLabelText(text);
}
void VisualizationGraphWidget::addVerticalCursorAtViewportPosition(double position)
{
impl->m_VerticalCursor->setAbsolutePosition(position);
impl->m_VerticalCursor->setVisible(true);
auto axis = plot().axisRect()->axis(QCPAxis::atBottom);
auto text
= DateUtils::dateTime(axis->pixelToCoord(position)).toString(CURSOR_LABELS_DATETIME_FORMAT);
impl->m_VerticalCursor->setLabelText(text);
}
void VisualizationGraphWidget::removeVerticalCursor()
{
impl->m_VerticalCursor->setVisible(false);
plot().replot(QCustomPlot::rpQueuedReplot);
}
void VisualizationGraphWidget::addHorizontalCursor(double value)
{
impl->m_HorizontalCursor->setPosition(value);
impl->m_HorizontalCursor->setVisible(true);
impl->m_HorizontalCursor->setLabelText(QString::number(value));
}
void VisualizationGraphWidget::addHorizontalCursorAtViewportPosition(double position)
{
impl->m_HorizontalCursor->setAbsolutePosition(position);
impl->m_HorizontalCursor->setVisible(true);
auto axis = plot().axisRect()->axis(QCPAxis::atLeft);
impl->m_HorizontalCursor->setLabelText(QString::number(axis->pixelToCoord(position)));
}
void VisualizationGraphWidget::removeHorizontalCursor()
{
impl->m_HorizontalCursor->setVisible(false);
plot().replot(QCustomPlot::rpQueuedReplot);
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::closeEvent(QCloseEvent* event)
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 {
Q_UNUSED(event);
Switched to new TS impl but quite broken!...
r1420 for (auto i : impl->m_SelectionZones)
{
Fix a bug with event edition from visu after a graph is closed
r1324 parentVisualizationWidget()->selectionZoneManager().setSelected(i, false);
}
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 // Prevents that all variables will be removed from graph when it will be closed
Switched to new TS impl but quite broken!...
r1420 for (auto& variableEntry : impl->m_VariableToPlotMultiMap)
{
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 emit variableAboutToBeRemoved(variableEntry.first);
}
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::enterEvent(QEvent* event)
Alexandre Leroux
Shows/hides plot overlay when entering/leaving graph
r728 {
Q_UNUSED(event);
impl->m_RenderingDelegate->showGraphOverlay(true);
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::leaveEvent(QEvent* event)
Alexandre Leroux
Shows/hides plot overlay when entering/leaving graph
r728 {
Q_UNUSED(event);
impl->m_RenderingDelegate->showGraphOverlay(false);
Implements cursor mode
r960
Switched to new TS impl but quite broken!...
r1420 if (auto parentZone = parentZoneWidget())
{
Implements cursor mode
r960 parentZone->notifyMouseLeaveGraph(this);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Implements cursor mode
r960 qCWarning(LOG_VisualizationGraphWidget()) << "leaveEvent: No parent zone widget";
}
Display of selection zones on a graph
r1044
Switched to new TS impl but quite broken!...
r1420 if (impl->m_HoveredZone)
{
Display of selection zones on a graph
r1044 impl->m_HoveredZone->setHovered(false);
impl->m_HoveredZone = nullptr;
}
Alexandre Leroux
Shows/hides plot overlay when entering/leaving graph
r728 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::wheelEvent(QWheelEvent* event)
Partly reimplemented Graph event handling + bugfix...
r1362 {
double factor;
double wheelSteps = event->delta() / 120.0; // a single step delta is +/-120 usually
Switched to new TS impl but quite broken!...
r1420 if (event->modifiers() == Qt::ControlModifier)
{
Partly reimplemented Graph event handling + bugfix...
r1362 if (event->orientation() == Qt::Vertical) // mRangeZoom.testFlag(Qt::Vertical))
{
setCursor(Qt::SizeVerCursor);
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 factor = pow(impl->m_plot->axisRect()->rangeZoomFactor(Qt::Vertical), wheelSteps);
Partly reimplemented Graph event handling + bugfix...
r1362 zoom(factor, event->pos().y(), Qt::Vertical);
}
}
Switched to new TS impl but quite broken!...
r1420 else if (event->modifiers() == Qt::ShiftModifier)
{
Partly reimplemented Graph event handling + bugfix...
r1362 if (event->orientation() == Qt::Vertical) // mRangeZoom.testFlag(Qt::Vertical))
{
setCursor(Qt::SizeHorCursor);
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 factor = pow(impl->m_plot->axisRect()->rangeZoomFactor(Qt::Horizontal), wheelSteps);
Partly reimplemented Graph event handling + bugfix...
r1362 zoom(factor, event->pos().x(), Qt::Horizontal);
}
}
Switched to new TS impl but quite broken!...
r1420 else
{
Partly reimplemented Graph event handling + bugfix...
r1362 move(wheelSteps, Qt::Horizontal);
}
Corrected stupid scroll bug, scrolling a graph did also trigger vertical scroll...
r1374 event->accept();
Partly reimplemented Graph event handling + bugfix...
r1362 }
More refactoring and added back plot tooltip...
r1363
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::mouseMoveEvent(QMouseEvent* event)
Partly reimplemented Graph event handling + bugfix...
r1362 {
Switched to new TS impl but quite broken!...
r1420 if (impl->isDrawingZoomRect())
Partly reimplemented Graph event handling + bugfix...
r1362 {
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->updateZoomRect(event->pos());
Partly reimplemented Graph event handling + bugfix...
r1362 }
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 else if (impl->isDrawingZoneRect())
Partly reimplemented Graph event handling + bugfix...
r1362 {
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->updateZoneRect(event->pos());
Partly reimplemented Graph event handling + bugfix...
r1362 }
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 else if (event->buttons() == Qt::LeftButton)
More refactoring and added back plot tooltip...
r1363 {
Switched to new TS impl but quite broken!...
r1420 if (sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::None)
Refac + clang-format...
r1365 {
Switched to new TS impl but quite broken!...
r1420 auto [dx, dy] = impl->moveGraph(event->pos());
Force range for each transformation among synchronized graphs, ignore missing X unit in data files since it's always time...
r1384 emit this->setrange_sig(this->graphRange(), true, false);
Added RAW graph sync implementation...
r1373 }
Switched to new TS impl but quite broken!...
r1420 else if (sqpApp->plotsInteractionMode()
== SqpApplication::PlotsInteractionMode::SelectionZones)
Added RAW graph sync implementation...
r1373 {
sync...
r1388 auto posInPlot = this->impl->m_plot->mapFromParent(event->pos());
Switched to new TS impl but quite broken!...
r1420 if (auto item = impl->m_plot->itemAt(posInPlot))
Restored Zones edition, now we can move and resize zones again...
r1387 {
Switched to new TS impl but quite broken!...
r1420 if (qobject_cast<VisualizationSelectionZoneItem*>(item))
Restored Zones edition, now we can move and resize zones again...
r1387 {
Switched to new TS impl but quite broken!...
r1420 QMouseEvent e { QEvent::MouseMove, posInPlot, event->button(), event->buttons(),
event->modifiers() };
Restored Zones edition, now we can move and resize zones again...
r1387 sqpApp->sendEvent(this->impl->m_plot, &e);
sync...
r1388 this->impl->m_plot->replot(QCustomPlot::rpImmediateRefresh);
Restored Zones edition, now we can move and resize zones again...
r1387 }
}
Refac + clang-format...
r1365 }
Partly reimplemented Graph event handling + bugfix...
r1362 }
More refactoring and added back plot tooltip...
r1363 else
{
impl->m_RenderingDelegate->updateTooltip(event);
}
Switched to new TS impl but quite broken!...
r1420 // event->accept();
Restored graph D&D and added full screen mode (F11)...
r1376 QWidget::mouseMoveEvent(event);
Partly reimplemented Graph event handling + bugfix...
r1362 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::mouseReleaseEvent(QMouseEvent* event)
Partly reimplemented Graph event handling + bugfix...
r1362 {
Switched to new TS impl but quite broken!...
r1420 if (impl->isDrawingZoomRect())
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 {
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 auto oldRange = this->graphRange();
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->applyZoomRect();
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 auto newRange = this->graphRange();
Switched to new TS impl but quite broken!...
r1420 if (auto tf = DateTimeRangeHelper::computeTransformation(oldRange, newRange))
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 emit this->transform_sig(tf.value(), false);
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 }
Switched to new TS impl but quite broken!...
r1420 else if (impl->isDrawingZoneRect())
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 {
Refac + clang-format...
r1365 impl->endDrawingZone();
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 }
else
{
setCursor(Qt::ArrowCursor);
}
Restored Zones edition, now we can move and resize zones again...
r1387 auto posInPlot = this->impl->m_plot->mapFromParent(event->pos());
Switched to new TS impl but quite broken!...
r1420 if (auto item = impl->m_plot->itemAt(posInPlot))
Restored Zones edition, now we can move and resize zones again...
r1387 {
Switched to new TS impl but quite broken!...
r1420 if (qobject_cast<VisualizationSelectionZoneItem*>(item))
Restored Zones edition, now we can move and resize zones again...
r1387 {
Switched to new TS impl but quite broken!...
r1420 QMouseEvent e { QEvent::MouseButtonRelease, posInPlot, event->button(),
event->buttons(), event->modifiers() };
Restored Zones edition, now we can move and resize zones again...
r1387 sqpApp->sendEvent(this->impl->m_plot, &e);
}
}
Corrected stupid scroll bug, scrolling a graph did also trigger vertical scroll...
r1374 event->accept();
Partly reimplemented Graph event handling + bugfix...
r1362 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::mousePressEvent(QMouseEvent* event)
Partly reimplemented Graph event handling + bugfix...
r1362 {
Switched to new TS impl but quite broken!...
r1420 if (event->button() == Qt::RightButton)
Refac + clang-format...
r1365 {
onGraphMenuRequested(event->pos());
}
else
{
auto selectedZone = impl->selectionZoneAt(event->pos());
switch (sqpApp->plotsInteractionMode())
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 {
Switched to new TS impl but quite broken!...
r1420 case SqpApplication::PlotsInteractionMode::DragAndDrop:
break;
case SqpApplication::PlotsInteractionMode::SelectionZones:
impl->setSelectionZonesEditionEnabled(true);
if ((event->modifiers() == Qt::ControlModifier) && (selectedZone != nullptr))
{
auto alreadySelectedZones
= parentVisualizationWidget()->selectionZoneManager().selectedItems();
Restored multi "Zone" selection...
r1386 selectedZone->setAssociatedEditedZones(alreadySelectedZones);
Switched to cpp_utils package...
r1486 if (cpp_utils::containers::contains(alreadySelectedZones, selectedZone))
Restored multi "Zone" selection...
r1386 {
alreadySelectedZones.removeOne(selectedZone);
}
else
{
alreadySelectedZones.append(selectedZone);
}
Switched to new TS impl but quite broken!...
r1420 parentVisualizationWidget()->selectionZoneManager().select(
alreadySelectedZones);
Refac + clang-format...
r1365 }
else
{
Switched to new TS impl but quite broken!...
r1420 if (!selectedZone)
{
parentVisualizationWidget()->selectionZoneManager().clearSelection();
impl->startDrawingZone(event->pos());
}
else
{
parentVisualizationWidget()->selectionZoneManager().select(
{ selectedZone });
}
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 }
Restored Zones edition, now we can move and resize zones again...
r1387 {
Switched to new TS impl but quite broken!...
r1420 auto posInPlot = this->impl->m_plot->mapFromParent(event->pos());
if (auto item = impl->m_plot->itemAt(posInPlot))
Restored Zones edition, now we can move and resize zones again...
r1387 {
Switched to new TS impl but quite broken!...
r1420 if (qobject_cast<VisualizationSelectionZoneItem*>(item))
{
QMouseEvent e { QEvent::MouseButtonPress, posInPlot, event->button(),
event->buttons(), event->modifiers() };
sqpApp->sendEvent(this->impl->m_plot, &e);
}
Restored Zones edition, now we can move and resize zones again...
r1387 }
}
Switched to new TS impl but quite broken!...
r1420 break;
case SqpApplication::PlotsInteractionMode::ZoomBox:
impl->startDrawingRect(event->pos());
break;
default:
if (auto item = impl->m_plot->itemAt(event->pos()))
{
emit impl->m_plot->itemClick(item, event);
if (qobject_cast<VisualizationSelectionZoneItem*>(item))
{
setCursor(Qt::ClosedHandCursor);
impl->enterPlotDrag(event->pos());
}
}
else
allow pan when click on zone...
r1383 {
setCursor(Qt::ClosedHandCursor);
impl->enterPlotDrag(event->pos());
}
Partly reimplemented Graph event handling + bugfix...
r1362 }
}
Switched to new TS impl but quite broken!...
r1420 // event->accept();
Restored graph D&D and added full screen mode (F11)...
r1376 QWidget::mousePressEvent(event);
Partly reimplemented Graph event handling + bugfix...
r1362 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::mouseDoubleClickEvent(QMouseEvent* event)
More refactoring and added back plot tooltip...
r1363 {
impl->m_RenderingDelegate->onMouseDoubleClick(event);
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::keyReleaseEvent(QKeyEvent* event)
Partly reimplemented Graph event handling + bugfix...
r1362 {
Switched to new TS impl but quite broken!...
r1420 switch (event->key())
{
Partly reimplemented Graph event handling + bugfix...
r1362 case Qt::Key_Control:
event->accept();
break;
case Qt::Key_Shift:
event->accept();
break;
default:
QWidget::keyReleaseEvent(event);
break;
}
setCursor(Qt::ArrowCursor);
Switched to new TS impl but quite broken!...
r1420 // event->accept();
Partly reimplemented Graph event handling + bugfix...
r1362 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::keyPressEvent(QKeyEvent* event)
Partly reimplemented Graph event handling + bugfix...
r1362 {
Switched to new TS impl but quite broken!...
r1420 switch (event->key())
{
Partly reimplemented Graph event handling + bugfix...
r1362 case Qt::Key_Control:
setCursor(Qt::CrossCursor);
break;
case Qt::Key_Shift:
break;
case Qt::Key_M:
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 impl->rescaleY();
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->m_plot->replot(QCustomPlot::rpQueuedReplot);
Partly reimplemented Graph event handling + bugfix...
r1362 break;
case Qt::Key_Left:
Switched to new TS impl but quite broken!...
r1420 if (event->modifiers() != Qt::ControlModifier)
{
Partly reimplemented Graph event handling + bugfix...
r1362 move(-0.1, Qt::Horizontal);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Partly reimplemented Graph event handling + bugfix...
r1362 zoom(2, this->width() / 2, Qt::Horizontal);
}
break;
case Qt::Key_Right:
Switched to new TS impl but quite broken!...
r1420 if (event->modifiers() != Qt::ControlModifier)
{
Partly reimplemented Graph event handling + bugfix...
r1362 move(0.1, Qt::Horizontal);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Partly reimplemented Graph event handling + bugfix...
r1362 zoom(0.5, this->width() / 2, Qt::Horizontal);
}
break;
case Qt::Key_Up:
Switched to new TS impl but quite broken!...
r1420 if (event->modifiers() != Qt::ControlModifier)
{
Partly reimplemented Graph event handling + bugfix...
r1362 move(0.1, Qt::Vertical);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Partly reimplemented Graph event handling + bugfix...
r1362 zoom(0.5, this->height() / 2, Qt::Vertical);
}
break;
case Qt::Key_Down:
Switched to new TS impl but quite broken!...
r1420 if (event->modifiers() != Qt::ControlModifier)
{
Partly reimplemented Graph event handling + bugfix...
r1362 move(-0.1, Qt::Vertical);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Partly reimplemented Graph event handling + bugfix...
r1362 zoom(2, this->height() / 2, Qt::Vertical);
}
break;
default:
QWidget::keyPressEvent(event);
break;
}
}
Switched to new TS impl but quite broken!...
r1420 QCustomPlot& VisualizationGraphWidget::plot() const noexcept
Alexandre Leroux
Passes directly GraphWidget in delegate...
r725 {
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 return *impl->m_plot;
Alexandre Leroux
Passes directly GraphWidget in delegate...
r725 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::onGraphMenuRequested(const QPoint& pos) noexcept
Add the visualization gui classes
r118 {
Switched to new TS impl but quite broken!...
r1420 QMenu graphMenu {};
Alexandre Leroux
Remove variable from graph (1)...
r269
Alexandre Leroux
Remove variable from graph (2)...
r270 // Iterates on variables (unique keys)
for (auto it = impl->m_VariableToPlotMultiMap.cbegin(),
Switched to new TS impl but quite broken!...
r1420 end = impl->m_VariableToPlotMultiMap.cend();
it != end; it = impl->m_VariableToPlotMultiMap.upper_bound(it->first))
{
Alexandre Leroux
Remove variable from graph (2)...
r270 // 'Remove variable' action
graphMenu.addAction(tr("Remove variable %1").arg(it->first->name()),
Switched to new TS impl but quite broken!...
r1420 [this, var = it->first]() { removeVariable(var); });
Alexandre Leroux
Adds name to a graph...
r196 }
Alexandre Leroux
Remove variable from graph (1)...
r269
Switched to new TS impl but quite broken!...
r1420 if (!impl->m_ZoomStack.isEmpty())
{
if (!graphMenu.isEmpty())
{
Undo zoom box action
r1046 graphMenu.addSeparator();
}
graphMenu.addAction(tr("Undo Zoom"), [this]() { undoZoom(); });
}
Put the align actions in sub menus
r1083 // Selection Zone Actions
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto selectionZoneItem = impl->selectionZoneAt(pos);
Switched to new TS impl but quite broken!...
r1420 if (selectionZoneItem)
{
Adds selection zone actions in the context menu
r1077 auto selectedItems = parentVisualizationWidget()->selectionZoneManager().selectedItems();
Alignment actions for zone selections
r1081 selectedItems.removeAll(selectionZoneItem);
selectedItems.prepend(selectionZoneItem); // Put the current selection zone first
Adds selection zone actions in the context menu
r1077 auto zoneActions = sqpApp->actionsGuiController().selectionZoneActions();
Switched to new TS impl but quite broken!...
r1420 if (!zoneActions.isEmpty() && !graphMenu.isEmpty())
{
Adds selection zone actions in the context menu
r1077 graphMenu.addSeparator();
}
Switched to new TS impl but quite broken!...
r1420 QHash<QString, QMenu*> subMenus;
Put the align actions in sub menus
r1083 QHash<QString, bool> subMenusEnabled;
Switched to new TS impl but quite broken!...
r1420 QHash<QString, FilteringAction*> filteredMenu;
Put the align actions in sub menus
r1083
Switched to new TS impl but quite broken!...
r1420 for (auto zoneAction : zoneActions)
{
Put the align actions in sub menus
r1083
auto isEnabled = zoneAction->isEnabled(selectedItems);
auto menu = &graphMenu;
LineEdit to filter the create catalogue menu
r1328 QString menuPath;
Switched to new TS impl but quite broken!...
r1420 for (auto subMenuName : zoneAction->subMenuList())
{
LineEdit to filter the create catalogue menu
r1328 menuPath += '/';
menuPath += subMenuName;
Switched to new TS impl but quite broken!...
r1420 if (!subMenus.contains(menuPath))
{
Put the align actions in sub menus
r1083 menu = menu->addMenu(subMenuName);
LineEdit to filter the create catalogue menu
r1328 subMenus[menuPath] = menu;
subMenusEnabled[menuPath] = isEnabled;
Put the align actions in sub menus
r1083 }
Switched to new TS impl but quite broken!...
r1420 else
{
LineEdit to filter the create catalogue menu
r1328 menu = subMenus.value(menuPath);
Switched to new TS impl but quite broken!...
r1420 if (isEnabled)
{
Put the align actions in sub menus
r1083 // The sub menu is enabled if at least one of its actions is enabled
LineEdit to filter the create catalogue menu
r1328 subMenusEnabled[menuPath] = true;
Put the align actions in sub menus
r1083 }
}
}
Switched to new TS impl but quite broken!...
r1420 FilteringAction* filterAction = nullptr;
if (sqpApp->actionsGuiController().isMenuFiltered(zoneAction->subMenuList()))
{
LineEdit to filter the create catalogue menu
r1328 filterAction = filteredMenu.value(menuPath);
Switched to new TS impl but quite broken!...
r1420 if (!filterAction)
{
filterAction = new FilteringAction { this };
LineEdit to filter the create catalogue menu
r1328 filteredMenu[menuPath] = filterAction;
menu->addAction(filterAction);
}
}
Put the align actions in sub menus
r1083 auto action = menu->addAction(zoneAction->name());
action->setEnabled(isEnabled);
Add action to remove the selected zone with the "del" buttons
r1082 action->setShortcut(zoneAction->displayedShortcut());
Alignment actions for zone selections
r1081 QObject::connect(action, &QAction::triggered,
Switched to new TS impl but quite broken!...
r1420 [zoneAction, selectedItems]() { zoneAction->execute(selectedItems); });
LineEdit to filter the create catalogue menu
r1328
Switched to new TS impl but quite broken!...
r1420 if (filterAction && zoneAction->isFilteringAllowed())
{
LineEdit to filter the create catalogue menu
r1328 filterAction->addActionToFilter(action);
}
Adds selection zone actions in the context menu
r1077 }
Put the align actions in sub menus
r1083
Switched to new TS impl but quite broken!...
r1420 for (auto it = subMenus.cbegin(); it != subMenus.cend(); ++it)
{
Put the align actions in sub menus
r1083 it.value()->setEnabled(subMenusEnabled[it.key()]);
}
Adds selection zone actions in the context menu
r1077 }
Switched to new TS impl but quite broken!...
r1420 if (!graphMenu.isEmpty())
{
Alexandre Leroux
Fixed menus position
r655 graphMenu.exec(QCursor::pos());
Alexandre Leroux
Adds name to a graph...
r196 }
Add the visualization gui classes
r118 }
Alexandre Leroux
Handles key modifiers for zoom...
r179
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::onMouseDoubleClick(QMouseEvent* event) noexcept
Alexandre Leroux
Handles double click on color scale...
r1002 {
impl->m_RenderingDelegate->onMouseDoubleClick(event);
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::onMouseMove(QMouseEvent* event) noexcept
Alexandre Leroux
Creates method that will display a tooltip and a tracer with data point information after a while
r481 {
// Handles plot rendering when mouse is moving
More refactoring and added back plot tooltip...
r1363 impl->m_RenderingDelegate->updateTooltip(event);
Integrates the drag&drop classes into the existing visualization classes.
r839
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto axisPos = impl->posToAxisPos(event->pos());
Implements cursor mode
r960
Display of selection zones on a graph
r1044 // Zoom box and zone drawing
Switched to new TS impl but quite broken!...
r1420 if (impl->m_DrawingZoomRect)
{
Display of selection zones on a graph
r1044 impl->m_DrawingZoomRect->bottomRight->setCoords(axisPos);
}
Switched to new TS impl but quite broken!...
r1420 else if (impl->m_DrawingZone)
{
Display of selection zones on a graph
r1044 impl->m_DrawingZone->setEnd(axisPos.x());
Implements zoom box interaction mode
r959 }
Display of selection zones on a graph
r1044 // Cursor
Switched to new TS impl but quite broken!...
r1420 if (auto parentZone = parentZoneWidget())
{
if (impl->pointIsInAxisRect(axisPos, plot()))
{
Implements cursor mode
r960 parentZone->notifyMouseMoveInGraph(event->pos(), axisPos, this);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Implements cursor mode
r960 parentZone->notifyMouseLeaveGraph(this);
}
}
Display of selection zones on a graph
r1044 // Search for the selection zone under the mouse
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto selectionZoneItemUnderCursor = impl->selectionZoneAt(event->pos());
Display of selection zones on a graph
r1044 if (selectionZoneItemUnderCursor && !impl->m_DrawingZone
Switched to new TS impl but quite broken!...
r1420 && sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones)
{
Display of selection zones on a graph
r1044
// Sets the appropriate cursor shape
auto cursorShape = selectionZoneItemUnderCursor->curshorShapeForPosition(event->pos());
setCursor(cursorShape);
// Manages the hovered zone
Switched to new TS impl but quite broken!...
r1420 if (selectionZoneItemUnderCursor != impl->m_HoveredZone)
{
if (impl->m_HoveredZone)
{
Display of selection zones on a graph
r1044 impl->m_HoveredZone->setHovered(false);
}
selectionZoneItemUnderCursor->setHovered(true);
impl->m_HoveredZone = selectionZoneItemUnderCursor;
plot().replot(QCustomPlot::rpQueuedReplot);
}
}
Switched to new TS impl but quite broken!...
r1420 else
{
Display of selection zones on a graph
r1044 // There is no zone under the mouse or the interaction mode is not "selection zones"
Switched to new TS impl but quite broken!...
r1420 if (impl->m_HoveredZone)
{
Display of selection zones on a graph
r1044 impl->m_HoveredZone->setHovered(false);
impl->m_HoveredZone = nullptr;
}
setCursor(Qt::ArrowCursor);
}
Resize and move of multiple zones together
r1050 impl->m_HasMovedMouse = true;
Integrates the drag&drop classes into the existing visualization classes.
r839 VisualizationDragWidget::mouseMoveEvent(event);
Alexandre Leroux
Creates method that will display a tooltip and a tracer with data point information after a while
r481 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::onMouseWheel(QWheelEvent* event) noexcept
Alexandre Leroux
Handles key modifiers for zoom...
r179 {
Alexandre Leroux
Fix the problem of calling the zoom at wheel event on the color scale
r1330 // Processes event only if the wheel occurs on axis rect
Switched to new TS impl but quite broken!...
r1420 if (!dynamic_cast<QCPAxisRect*>(impl->m_plot->layoutElementAt(event->posF())))
{
Alexandre Leroux
Fix the problem of calling the zoom at wheel event on the color scale
r1330 return;
}
Basic mouse wheel interactions + mode drag
r958 auto value = event->angleDelta().x() + event->angleDelta().y();
Switched to new TS impl but quite broken!...
r1420 if (value != 0)
{
Basic mouse wheel interactions + mode drag
r958
auto direction = value > 0 ? 1.0 : -1.0;
auto isZoomX = event->modifiers().testFlag(HORIZONTAL_ZOOM_MODIFIER);
auto isZoomY = event->modifiers().testFlag(VERTICAL_ZOOM_MODIFIER);
impl->m_IsCalibration = event->modifiers().testFlag(VERTICAL_PAN_MODIFIER);
Switched to new TS impl but quite broken!...
r1420 auto zoomOrientations = QFlags<Qt::Orientation> {};
Basic mouse wheel interactions + mode drag
r958 zoomOrientations.setFlag(Qt::Horizontal, isZoomX);
zoomOrientations.setFlag(Qt::Vertical, isZoomY);
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->m_plot->axisRect()->setRangeZoom(zoomOrientations);
Alexandre Leroux
Handles key modifiers for zoom...
r179
Switched to new TS impl but quite broken!...
r1420 if (!isZoomX && !isZoomY)
{
Basic mouse wheel interactions + mode drag
r958 auto axis = plot().axisRect()->axis(QCPAxis::atBottom);
auto diff = direction * (axis->range().size() * (PAN_SPEED / 100.0));
Alexandre Leroux
Handles key modifiers for zoom...
r179
Basic mouse wheel interactions + mode drag
r958 axis->setRange(axis->range() + diff);
Switched to new TS impl but quite broken!...
r1420 if (plot().noAntialiasingOnDrag())
{
Basic mouse wheel interactions + mode drag
r958 plot().setNotAntialiasedElements(QCP::aeAll);
}
Partly reimplemented Graph event handling + bugfix...
r1362 // plot().replot(QCustomPlot::rpQueuedReplot);
Basic mouse wheel interactions + mode drag
r958 }
}
Alexandre Leroux
Handles key modifiers for zoom...
r179 }
The mock plugin can now create data with view operation
r235
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::onMousePress(QMouseEvent* event) noexcept
Implementation of the calibration for the synchronization...
r445 {
Thibaud Rabillard
Fix interractions for mac
r1052 auto isDragDropClick = event->modifiers().testFlag(DRAG_DROP_MODIFIER);
multi selection of zones
r1049 auto isSelectionZoneMode
= sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones;
Thibaud Rabillard
Fix interractions for mac
r1052 auto isLeftClick = event->buttons().testFlag(Qt::LeftButton);
drag of selection zones
r1047
Switched to new TS impl but quite broken!...
r1420 if (!isDragDropClick && isLeftClick)
{
if (sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::ZoomBox)
{
drag of selection zones
r1047 // Starts a zoom box
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->startDrawingRect(event->pos());
drag of selection zones
r1047 }
Switched to new TS impl but quite broken!...
r1420 else if (isSelectionZoneMode && impl->m_DrawingZone == nullptr)
{
drag of selection zones
r1047 // Starts a new selection zone
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto zoneAtPos = impl->selectionZoneAt(event->pos());
Switched to new TS impl but quite broken!...
r1420 if (!zoneAtPos)
{
Refac + clang-format...
r1365 impl->startDrawingZone(event->pos());
drag of selection zones
r1047 }
Display of selection zones on a graph
r1044 }
}
multi selection of zones
r1049 // Allows zone edition only in selection zone mode without drag&drop
impl->setSelectionZonesEditionEnabled(isSelectionZoneMode && !isDragDropClick);
Improves display of selected zones
r1051 // Selection / Deselection
Switched to new TS impl but quite broken!...
r1420 if (isSelectionZoneMode)
{
multi selection of zones
r1049 auto isMultiSelectionClick = event->modifiers().testFlag(MULTI_ZONE_SELECTION_MODIFIER);
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto selectionZoneItemUnderCursor = impl->selectionZoneAt(event->pos());
Multi selection improvements
r1084
if (selectionZoneItemUnderCursor && !selectionZoneItemUnderCursor->selected()
Switched to new TS impl but quite broken!...
r1420 && !isMultiSelectionClick)
{
Multi selection improvements
r1084 parentVisualizationWidget()->selectionZoneManager().select(
Switched to new TS impl but quite broken!...
r1420 { selectionZoneItemUnderCursor });
multi selection of zones
r1049 }
Switched to new TS impl but quite broken!...
r1420 else if (!selectionZoneItemUnderCursor && !isMultiSelectionClick && isLeftClick)
{
multi selection of zones
r1049 parentVisualizationWidget()->selectionZoneManager().clearSelection();
}
Switched to new TS impl but quite broken!...
r1420 else
{
multi selection of zones
r1049 // No selection change
}
Multi selection improvements
r1084
Switched to new TS impl but quite broken!...
r1420 if (selectionZoneItemUnderCursor && isLeftClick)
{
Multi selection improvements
r1084 selectionZoneItemUnderCursor->setAssociatedEditedZones(
parentVisualizationWidget()->selectionZoneManager().selectedItems());
}
multi selection of zones
r1049 }
Integrates the drag&drop classes into the existing visualization classes.
r839
Resize and move of multiple zones together
r1050
impl->m_HasMovedMouse = false;
Integrates the drag&drop classes into the existing visualization classes.
r839 VisualizationDragWidget::mousePressEvent(event);
Implementation of the calibration for the synchronization...
r445 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::onMouseRelease(QMouseEvent* event) noexcept
Implementation of the calibration for the synchronization...
r445 {
Switched to new TS impl but quite broken!...
r1420 if (impl->m_DrawingZoomRect)
{
Implements zoom box interaction mode
r959
auto axisX = plot().axisRect()->axis(QCPAxis::atBottom);
auto axisY = plot().axisRect()->axis(QCPAxis::atLeft);
Switched to new TS impl but quite broken!...
r1420 auto newAxisXRange = QCPRange { impl->m_DrawingZoomRect->topLeft->coords().x(),
impl->m_DrawingZoomRect->bottomRight->coords().x() };
Implements zoom box interaction mode
r959
Switched to new TS impl but quite broken!...
r1420 auto newAxisYRange = QCPRange { impl->m_DrawingZoomRect->topLeft->coords().y(),
impl->m_DrawingZoomRect->bottomRight->coords().y() };
Implements zoom box interaction mode
r959
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 impl->removeDrawingRect();
Implements zoom box interaction mode
r959
if (newAxisXRange.size() > axisX->range().size() * (ZOOM_BOX_MIN_SIZE / 100.0)
Switched to new TS impl but quite broken!...
r1420 && newAxisYRange.size() > axisY->range().size() * (ZOOM_BOX_MIN_SIZE / 100.0))
{
Undo zoom box action
r1046 impl->m_ZoomStack.push(qMakePair(axisX->range(), axisY->range()));
Implements zoom box interaction mode
r959 axisX->setRange(newAxisXRange);
axisY->setRange(newAxisYRange);
plot().replot(QCustomPlot::rpQueuedReplot);
}
}
Refac + clang-format...
r1365 impl->endDrawingZone();
Display of selection zones on a graph
r1044
Resize and move of multiple zones together
r1050 // Selection / Deselection
auto isSelectionZoneMode
= sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones;
Switched to new TS impl but quite broken!...
r1420 if (isSelectionZoneMode)
{
Resize and move of multiple zones together
r1050 auto isMultiSelectionClick = event->modifiers().testFlag(MULTI_ZONE_SELECTION_MODIFIER);
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto selectionZoneItemUnderCursor = impl->selectionZoneAt(event->pos());
Selection of stacked zone via a dialog box
r1085 if (selectionZoneItemUnderCursor && event->button() == Qt::LeftButton
Switched to new TS impl but quite broken!...
r1420 && !impl->m_HasMovedMouse)
{
Selection of stacked zone via a dialog box
r1085
auto zonesUnderCursor = impl->selectionZonesAt(event->pos(), plot());
Switched to new TS impl but quite broken!...
r1420 if (zonesUnderCursor.count() > 1)
{
Selection of stacked zone via a dialog box
r1085 // There are multiple zones under the mouse.
// Performs the selection with a selection dialog.
Switched to new TS impl but quite broken!...
r1420 VisualizationMultiZoneSelectionDialog dialog { this };
Selection of stacked zone via a dialog box
r1085 dialog.setZones(zonesUnderCursor);
dialog.move(mapToGlobal(event->pos() - QPoint(dialog.width() / 2, 20)));
dialog.activateWindow();
dialog.raise();
Switched to new TS impl but quite broken!...
r1420 if (dialog.exec() == QDialog::Accepted)
{
Selection of stacked zone via a dialog box
r1085 auto selection = dialog.selectedZones();
Switched to new TS impl but quite broken!...
r1420 if (!isMultiSelectionClick)
{
Selection of stacked zone via a dialog box
r1085 parentVisualizationWidget()->selectionZoneManager().clearSelection();
}
Switched to new TS impl but quite broken!...
r1420 for (auto it = selection.cbegin(); it != selection.cend(); ++it)
{
Selection of stacked zone via a dialog box
r1085 auto zone = it.key();
auto isSelected = it.value();
Switched to new TS impl but quite broken!...
r1420 parentVisualizationWidget()->selectionZoneManager().setSelected(
zone, isSelected);
Selection of stacked zone via a dialog box
r1085
Switched to new TS impl but quite broken!...
r1420 if (isSelected)
{
Selection of stacked zone via a dialog box
r1085 // Puts the zone on top of the stack so it can be moved or resized
impl->moveSelectionZoneOnTop(zone, plot());
}
}
}
Resize and move of multiple zones together
r1050 }
Switched to new TS impl but quite broken!...
r1420 else
{
if (!isMultiSelectionClick)
{
Selection of stacked zone via a dialog box
r1085 parentVisualizationWidget()->selectionZoneManager().select(
Switched to new TS impl but quite broken!...
r1420 { selectionZoneItemUnderCursor });
Selection of stacked zone via a dialog box
r1085 impl->moveSelectionZoneOnTop(selectionZoneItemUnderCursor, plot());
}
Switched to new TS impl but quite broken!...
r1420 else
{
Selection of stacked zone via a dialog box
r1085 parentVisualizationWidget()->selectionZoneManager().setSelected(
Switched to new TS impl but quite broken!...
r1420 selectionZoneItemUnderCursor,
!selectionZoneItemUnderCursor->selected()
|| event->button() == Qt::RightButton);
Selection of stacked zone via a dialog box
r1085 }
Resize and move of multiple zones together
r1050 }
}
Switched to new TS impl but quite broken!...
r1420 else
{
Resize and move of multiple zones together
r1050 // No selection change
}
}
Implementation of the calibration for the synchronization...
r445 }
The mock plugin can now create data with view operation
r235 void VisualizationGraphWidget::onDataCacheVariableUpdated()
{
[VisualizationGraphWidget] Restored box zoom and zones plus refac...
r1364 auto graphRange = impl->m_plot->xAxis->range();
Switched to new TS impl but quite broken!...
r1420 auto dateTime = DateTimeRange { graphRange.lower, graphRange.upper };
Implementation of the cache feature : download before display needs
r433
Switched to new TS impl but quite broken!...
r1420 for (auto& variableEntry : impl->m_VariableToPlotMultiMap)
{
Alexandre Leroux
Handles QCustomPlot plottables for vectors (2)...
r582 auto variable = variableEntry.first;
Downgrade dev log from info to debug
r441 qCDebug(LOG_VisualizationGraphWidget())
Implementation of V5 acquisition
r539 << "TORM: VisualizationGraphWidget::onDataCacheVariableUpdated S" << variable->range();
Downgrade dev log from info to debug
r441 qCDebug(LOG_VisualizationGraphWidget())
Implementation of the cache feature : download before display needs
r433 << "TORM: VisualizationGraphWidget::onDataCacheVariableUpdated E" << dateTime;
Switched to new TS impl but quite broken!...
r1420 if (dateTime.contains(variable->range()) || dateTime.intersect(variable->range()))
{
Alexandre Leroux
Updates VisualizationGraphHelper to use variable's type instead of dataseries
r1280 impl->updateData(variableEntry.second, variable, variable->range());
Implementation of the cache feature : download before display needs
r433 }
The mock plugin can now create data with view operation
r235 }
}
add Skeleton for displaying data which are already in cache
r571
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::onUpdateVarDisplaying(
std::shared_ptr<Variable2> variable, const DateTimeRange& range)
add Skeleton for displaying data which are already in cache
r571 {
Alexandre Leroux
Handles QCustomPlot plottables for vectors (2)...
r582 auto it = impl->m_VariableToPlotMultiMap.find(variable);
Switched to new TS impl but quite broken!...
r1420 if (it != impl->m_VariableToPlotMultiMap.end())
{
Alexandre Leroux
Updates VisualizationGraphHelper to use variable's type instead of dataseries
r1280 impl->updateData(it->second, variable, range);
add Skeleton for displaying data which are already in cache
r571 }
}
[WIP] new generic WS plugin and few other fixes...
r1352
void VisualizationGraphWidget::variableUpdated(QUuid id)
{
Switched to new TS impl but quite broken!...
r1420 for (auto& [var, plotables] : impl->m_VariableToPlotMultiMap)
{
if (var->ID() == id)
{
Partly reimplemented Graph event handling + bugfix...
r1362 impl->updateData(plotables, var, this->graphRange());
[WIP] new generic WS plugin and few other fixes...
r1352 }
}
}
Fixed ugly bug, removing a variable didn't remove it from plot \_(ツ)_/¯...
r1381
Switched to new TS impl but quite broken!...
r1420 void VisualizationGraphWidget::variableDeleted(const std::shared_ptr<Variable2>& variable)
Fixed ugly bug, removing a variable didn't remove it from plot \_(ツ)_/¯...
r1381 {
this->removeVariable(variable);
}