File indexing completed on 2025-01-26 03:34:13
0001 /* 0002 File : Plot.h 0003 Project : LabPlot 0004 Description : Base class for all plots like scatter plot, box plot, etc. 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2020-2023 Alexander Semke <alexander.semke@web.de> 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #ifndef PLOT_H 0011 #define PLOT_H 0012 0013 #include "backend/lib/macros.h" 0014 #include "backend/worksheet/WorksheetElement.h" 0015 #include "backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h" 0016 0017 class AbstractColumn; 0018 class Column; 0019 class PlotPrivate; 0020 class QPointF; 0021 0022 class Plot : public WorksheetElement { 0023 Q_OBJECT 0024 0025 public: 0026 virtual ~Plot(); 0027 0028 BASIC_D_ACCESSOR_DECL(bool, legendVisible, LegendVisible) 0029 virtual bool minMax(const CartesianCoordinateSystem::Dimension dim, const Range<int>& indexRange, Range<double>& r, bool includeErrorBars = true) const; 0030 virtual double minimum(CartesianCoordinateSystem::Dimension dim) const = 0; 0031 virtual double maximum(CartesianCoordinateSystem::Dimension dim) const = 0; 0032 virtual bool hasData() const = 0; 0033 bool activatePlot(QPointF mouseScenePos, double maxDist = -1); 0034 virtual QColor color() const = 0; // Color of the plot. If the plot consists multiple colors, return the main Color (This is used in the cursor dock as 0035 // background color for example) 0036 0037 /*! 0038 * returns \c true if the column is used internally in the plot for the visualisation, returns \c false otherwise. 0039 */ 0040 virtual bool usingColumn(const Column*) const = 0; 0041 0042 /*! 0043 * This function is called when a column in the project was renamed or a new column was added 0044 * with the name/path that was potentially used earlier in the plot. 0045 * The implementation in the derived classes should handle these two cases and update the visualisation accordingly: 0046 * 1. the column is the same and was just renamed -> update the column path internally 0047 * 2. another column was added or renamed and fits to the path that was used before -> set and connect to the new column and update the visualisation 0048 */ 0049 virtual void updateColumnDependencies(const AbstractColumn*) = 0; 0050 0051 typedef PlotPrivate Private; 0052 0053 private: 0054 Q_DECLARE_PRIVATE(Plot) 0055 0056 protected: 0057 Plot(const QString&, PlotPrivate* dd, AspectType); 0058 PlotPrivate* const d_ptr; 0059 0060 Q_SIGNALS: 0061 void dataChanged(); // emitted when the data to be plotted was changed to re-adjust the parent plot area 0062 void appearanceChanged(); 0063 void legendVisibleChanged(bool); 0064 }; 0065 0066 #endif