15#include <ui/qt/widgets/qcustomplot.h>
16#include "ui/qt/marker_dialog.h"
52 QString
currentValue()
const {
return QString::number(tracer()->position->value(),
'g', 4); }
123 QVector<Marker*>
markers()
const {
return markers_; }
196 void markerMoved(
const int idx,
const double newPos,
const bool visible);
203 QList<const Marker*> orderedMarkers(QList<const Marker*> list)
const;
215 QCPItemTracer* tracer()
const {
return findChild<QCPItemTracer*>(); }
220 void resetSelectedMarker() { selected_marker_idx_ = -1; }
226 void deleteMarkerDataPoint(
const int marker_idx);
234 QCPItemText* markerTitle(
const int idx,
const bool create =
false);
242 QCPItemText* markerDataPoint(
const QString& idx,
const bool create =
false);
251 QCPItemStraightLine* markerLine(
const int mIdx,
const int rectIdx,
const bool create =
false);
260 void updateQCPItemText(QCPItemText* item,
const QString& txt,
const QPointF pos, QCPAxis* y_axis = Q_NULLPTR);
269 void updateDataPointMarker(QCPItemText* item,
const double x, QCPGraph* graph,
bool visible);
276 QString dataPointMarker(
const double x)
const;
284 inline QString itemIndex(
int markerIdx,
int graphIdx)
const {
return QString(
"%1_%2").arg(markerIdx).arg(graphIdx); }
294 void addDataPointsMarker(QCPGraph* graph,
int graph_idx,
const int marker_idx,
const double x,
bool visible);
302 bool canAddDataPoint(
const QCPGraph* graph,
const double x)
const;
319 template <
typename T>
320 typename std::enable_if<std::is_base_of<QCPAbstractItem, T>::value, T*>::type
321 getOrAddQCPItem(QCustomPlot* plot,
const QString& objName,
const bool create);
324 int selected_marker_idx_;
327 bool data_point_visible_;
330 bool marker_diff_visible_;
336 QVector<Marker*> markers_;
348typename std::enable_if<std::is_base_of<QCPAbstractItem, T>::value, T*>::type
349inline CustomPlot::getOrAddQCPItem(QCustomPlot* plot,
const QString& objName,
const bool create)
351 T* item = plot->findChild<T*>(objName);
352 if (create && item ==
nullptr) {
354 item->setObjectName(objName);
An extended QCustomPlot widget supporting markers, data points, and their interactions.
Definition customplot.h:23
Marker * posMarker()
Retrieves the special position marker linked to the tracer.
Definition customplot.cpp:316
void clearMarkerDifferences()
Clears any displayed marker differences.
Definition customplot.cpp:60
void axisRemoved(QCPAxis *axis) override
Handles cleanup when an axis is removed from the plot.
Definition customplot.cpp:362
void mouseReleased()
Handles mouse release logic specific to the plot markers and interactions.
Definition customplot.cpp:423
void markerVisibilityChanged(const Marker *m)
Handles a visibility change for a specific marker.
Definition customplot.cpp:404
QVector< Marker * > markers() const
Retrieves all markers currently in the plot.
Definition customplot.h:123
void mouseMoveEvent(QMouseEvent *event) override
Handles mouse movement events for tracking and dragging.
Definition customplot.cpp:349
void markerMoved(const Marker *m)
Updates plot visuals when a marker has been moved.
Definition customplot.cpp:331
~CustomPlot()
Destroys the CustomPlot.
Definition customplot.cpp:30
void deleteMarkersElements()
Deletes visual elements for all markers.
Definition customplot.cpp:231
bool mousePressed(QPoint pos)
Handles mouse press logic, returning whether interaction was captured.
Definition customplot.cpp:431
int selectedMarker() const
Retrieves the index of the currently selected marker.
Definition customplot.h:75
QString currentValue() const
Retrieves the current value traced by the plot.
Definition customplot.h:52
void deleteMarkerElements(const int index)
Deletes visual elements for a specific marker.
Definition customplot.cpp:215
Marker * marker(const QString &name)
Retrieves a marker by its name/identifier.
Definition customplot.cpp:306
void addDataPointsMarker(QCPGraph *graph)
Adds data point markers along a specific graph.
Definition customplot.cpp:260
void showMarkersDifference(bool show)
Toggles the visibility of the difference between markers.
Definition customplot.h:87
void deleteMarker(Marker *m)
Deletes a specific marker.
Definition customplot.cpp:276
QList< const Marker * > visibleMarkers() const
Retrieves a list of all currently visible markers.
Definition customplot.cpp:338
void deleteAllMarkers()
Deletes all markers from the plot.
Definition customplot.cpp:288
void showMarkerDifferences()
Shows the calculated differences between visible markers.
Definition customplot.cpp:70
Marker * addMarker(double x, bool isPosMarker)
Adds a new marker at the specified X coordinate.
Definition customplot.cpp:294
void addMarkerElements(const Marker *marker)
Adds plot elements (lines, labels) associated with a marker.
Definition customplot.cpp:172
void setDataPointVisibility(const bool visible)
Sets the visibility of data points on the plot.
Definition customplot.cpp:35
A widget representing a marker on a graph or timeline.
Definition marker_dialog.h:21