VisualizationGraphWidget.h
158 lines
| 6.1 KiB
| text/x-c
|
CLexer
r58 | #ifndef SCIQLOP_VISUALIZATIONGRAPHWIDGET_H | |||
#define SCIQLOP_VISUALIZATIONGRAPHWIDGET_H | ||||
r118 | #include "Visualization/IVisualizationWidget.h" | |||
r842 | #include "Visualization/VisualizationDragWidget.h" | |||
r118 | ||||
Alexandre Leroux
|
r219 | #include <QLoggingCategory> | ||
r58 | #include <QWidget> | |||
r118 | #include <memory> | |||
#include <Common/spimpl.h> | ||||
Alexandre Leroux
|
r219 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationGraphWidget) | ||
Alexandre Leroux
|
r227 | class QCPRange; | ||
Alexandre Leroux
|
r725 | class QCustomPlot; | ||
r512 | class SqpRange; | |||
r118 | class Variable; | |||
r1089 | class VisualizationWidget; | |||
r842 | class VisualizationZoneWidget; | |||
r1114 | class VisualizationSelectionZoneItem; | |||
r118 | ||||
r58 | namespace Ui { | |||
class VisualizationGraphWidget; | ||||
} // namespace Ui | ||||
Alexandre Leroux
|
r1325 | /// Defines options that can be associated with the graph | ||
enum GraphFlag { | ||||
DisableAll = 0x0, ///< Disables acquisition and synchronization | ||||
EnableAcquisition = 0x1, ///< When this flag is set, the change of the graph's range leads to | ||||
/// the acquisition of data | ||||
EnableSynchronization = 0x2, ///< When this flag is set, the change of the graph's range causes | ||||
/// the call to the synchronization of the graphs contained in the | ||||
/// same zone of this graph | ||||
EnableAll = ~DisableAll ///< Enables acquisition and synchronization | ||||
}; | ||||
Q_DECLARE_FLAGS(GraphFlags, GraphFlag) | ||||
Q_DECLARE_OPERATORS_FOR_FLAGS(GraphFlags) | ||||
r842 | class VisualizationGraphWidget : public VisualizationDragWidget, public IVisualizationWidget { | |||
r58 | Q_OBJECT | |||
Alexandre Leroux
|
r730 | friend class QCustomPlotSynchronizer; | ||
Alexandre Leroux
|
r725 | friend class VisualizationGraphRenderingDelegate; | ||
r58 | public: | |||
Alexandre Leroux
|
r205 | explicit VisualizationGraphWidget(const QString &name = {}, QWidget *parent = 0); | ||
r58 | virtual ~VisualizationGraphWidget(); | |||
r1089 | /// Returns the VisualizationZoneWidget which contains the graph or nullptr | |||
r847 | VisualizationZoneWidget *parentZoneWidget() const noexcept; | |||
r842 | ||||
r1089 | /// Returns the main VisualizationWidget which contains the graph or nullptr | |||
VisualizationWidget *parentVisualizationWidget() const; | ||||
Alexandre Leroux
|
r1325 | /// Sets graph options | ||
void setFlags(GraphFlags flags); | ||||
r444 | ||||
r548 | void addVariable(std::shared_ptr<Variable> variable, SqpRange range); | |||
Alexandre Leroux
|
r270 | /// Removes a variable from the graph | ||
void removeVariable(std::shared_ptr<Variable> variable) noexcept; | ||||
r118 | ||||
r842 | /// Returns the list of all variables used in the graph | |||
r847 | QList<std::shared_ptr<Variable> > variables() const; | |||
r842 | ||||
Alexandre Leroux
|
r903 | /// Sets the y-axis range based on the data of a variable | ||
void setYRange(std::shared_ptr<Variable> variable); | ||||
r512 | SqpRange graphRange() const noexcept; | |||
r1345 | void setGraphRange(const SqpRange &range, bool calibration = false); | |||
r1346 | void setAutoRangeOnVariableInitialization(bool value); | |||
r437 | ||||
r1114 | // Zones | |||
r1088 | /// Returns the ranges of all the selection zones on the graph | |||
QVector<SqpRange> selectionZoneRanges() const; | ||||
/// Adds new selection zones in the graph | ||||
void addSelectionZones(const QVector<SqpRange> &ranges); | ||||
r1347 | /// Adds a new selection zone in the graph | |||
VisualizationSelectionZoneItem *addSelectionZone(const QString &name, const SqpRange &range); | ||||
r1114 | /// Removes the specified selection zone | |||
void removeSelectionZone(VisualizationSelectionZoneItem *selectionZone); | ||||
r1088 | ||||
r1086 | /// Undo the last zoom done with a zoom box | |||
void undoZoom(); | ||||
r118 | // IVisualizationWidget interface | |||
Alexandre Leroux
|
r207 | void accept(IVisualizationWidgetVisitor *visitor) override; | ||
Alexandre Leroux
|
r209 | bool canDrop(const Variable &variable) const override; | ||
Alexandre Leroux
|
r327 | bool contains(const Variable &variable) const override; | ||
Alexandre Leroux
|
r218 | QString name() const override; | ||
r118 | ||||
r842 | // VisualisationDragWidget | |||
r1087 | QMimeData *mimeData(const QPoint &position) const override; | |||
QPixmap customDragPixmap(const QPoint &dragPosition) override; | ||||
r842 | bool isDragAllowed() const override; | |||
r879 | void highlightForMerge(bool highlighted) override; | |||
r444 | ||||
r1003 | // Cursors | |||
/// Adds or moves the vertical cursor at the specified value on the x-axis | ||||
void addVerticalCursor(double time); | ||||
/// Adds or moves the vertical cursor at the specified value on the x-axis | ||||
void addVerticalCursorAtViewportPosition(double position); | ||||
void removeVerticalCursor(); | ||||
/// Adds or moves the vertical cursor at the specified value on the y-axis | ||||
void addHorizontalCursor(double value); | ||||
/// Adds or moves the vertical cursor at the specified value on the y-axis | ||||
void addHorizontalCursorAtViewportPosition(double position); | ||||
void removeHorizontalCursor(); | ||||
r298 | signals: | |||
r539 | void synchronize(const SqpRange &range, const SqpRange &oldRange); | |||
void requestDataLoading(QVector<std::shared_ptr<Variable> > variable, const SqpRange &range, | ||||
r816 | bool synchronise); | |||
r298 | ||||
Alexandre Leroux
|
r737 | /// Signal emitted when the variable is about to be removed from the graph | ||
void variableAboutToBeRemoved(std::shared_ptr<Variable> var); | ||||
/// Signal emitted when the variable has been added to the graph | ||||
r540 | void variableAdded(std::shared_ptr<Variable> var); | |||
Alexandre Leroux
|
r728 | protected: | ||
Alexandre Leroux
|
r738 | void closeEvent(QCloseEvent *event) override; | ||
Alexandre Leroux
|
r728 | void enterEvent(QEvent *event) override; | ||
void leaveEvent(QEvent *event) override; | ||||
r540 | ||||
r1087 | QCustomPlot &plot() const noexcept; | |||
Alexandre Leroux
|
r725 | |||
r58 | private: | |||
Ui::VisualizationGraphWidget *ui; | ||||
r118 | ||||
class VisualizationGraphWidgetPrivate; | ||||
spimpl::unique_impl_ptr<VisualizationGraphWidgetPrivate> impl; | ||||
Alexandre Leroux
|
r179 | |||
private slots: | ||||
Alexandre Leroux
|
r269 | /// Slot called when right clicking on the graph (displays a menu) | ||
void onGraphMenuRequested(const QPoint &pos) noexcept; | ||||
Alexandre Leroux
|
r227 | |||
r444 | /// Rescale the X axe to range parameter | |||
void onRangeChanged(const QCPRange &t1, const QCPRange &t2); | ||||
Alexandre Leroux
|
r227 | |||
Alexandre Leroux
|
r1043 | /// Slot called when a mouse double click was made | ||
void onMouseDoubleClick(QMouseEvent *event) noexcept; | ||||
Alexandre Leroux
|
r481 | /// Slot called when a mouse move was made | ||
void onMouseMove(QMouseEvent *event) noexcept; | ||||
Alexandre Leroux
|
r179 | /// Slot called when a mouse wheel was made, to perform some processing before the zoom is done | ||
void onMouseWheel(QWheelEvent *event) noexcept; | ||||
r445 | /// Slot called when a mouse press was made, to activate the calibration of a graph | |||
void onMousePress(QMouseEvent *event) noexcept; | ||||
/// Slot called when a mouse release was made, to deactivate the calibration of a graph | ||||
void onMouseRelease(QMouseEvent *event) noexcept; | ||||
r235 | ||||
void onDataCacheVariableUpdated(); | ||||
r571 | ||||
void onUpdateVarDisplaying(std::shared_ptr<Variable> variable, const SqpRange &range); | ||||
r58 | }; | |||
#endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H | ||||