[seiscomp, scanloc] Install, add .gitignore

This commit is contained in:
2025-10-09 15:07:02 +02:00
commit 20f5301bb1
2848 changed files with 1315858 additions and 0 deletions

View File

@ -0,0 +1,89 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_PLOT_ABSTRACTDATASET_H
#define SEISCOMP_GUI_PLOT_ABSTRACTDATASET_H
#include <seiscomp/gui/plot/range.h>
#include <QObject>
#include <QRectF>
class QPolygonF;
namespace Seiscomp {
namespace Gui {
class Axis;
class SC_GUI_API AbstractDataSet : public QObject {
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
//! C'tor
explicit AbstractDataSet(QObject *parent=0);
// ----------------------------------------------------------------------
// Query interface
// ----------------------------------------------------------------------
public:
bool isEmpty() const { return this->count() == 0; }
virtual int count() const = 0;
virtual Range getXRange() const = 0;
virtual Range getYRange() const = 0;
virtual void getBounds(Range &x, Range &y) const;
/**
* @brief Convenience function that returns a QRectF instead of two
* single ranges.
* @return The bounding rectangle of the graph data
*/
QRectF getBounds() const;
virtual void clear() = 0;
/**
* @brief Unprojects the data from axis space to pixel space
* @param poly The target polygon that holds the projected and possibly
* clipped data. Note that the number of points in the
* polygon does not necessarily match the number of points
* in the graph due to clipping.
* @param keyAxis The axis to project keys to
* @param valueAxis The axis to project values to
*/
virtual void unproject(QPolygonF &poly,
const Axis *keyAxis,
const Axis *valueAxis) const = 0;
};
}
}
#endif

View File

@ -0,0 +1,75 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_PLOT_ABSTRACTLEGEND_H
#define SEISCOMP_GUI_PLOT_ABSTRACTLEGEND_H
#include <seiscomp/gui/qt.h>
#include <QObject>
#include <QPainter>
#include <QList>
namespace Seiscomp {
namespace Gui {
class Graph;
class SC_GUI_API AbstractLegend : public QObject {
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
//! C'tor
explicit AbstractLegend(QObject *parent=0);
// ----------------------------------------------------------------------
// Setup
// ----------------------------------------------------------------------
public:
void setVisible(bool visible);
bool isVisible() const { return _visible; }
// ----------------------------------------------------------------------
// Render interface
// ----------------------------------------------------------------------
public:
virtual void draw(QPainter &p, const QRect &plotRect,
const QList<Graph*> &graphs) = 0;
// ----------------------------------------------------------------------
// Render interface
// ----------------------------------------------------------------------
protected:
bool _visible;
};
}
}
#endif

View File

@ -0,0 +1,336 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_PLOT_AXIS_H
#define SEISCOMP_GUI_PLOT_AXIS_H
#include <QObject>
#include <QPainter>
#include <QTransform>
#include <seiscomp/gui/plot/range.h>
namespace Seiscomp {
namespace Gui {
class SC_GUI_API Axis : public QObject {
// ----------------------------------------------------------------------
// Public types
// ----------------------------------------------------------------------
public:
enum AxisPosition {
Left,
Right,
Top,
Bottom
};
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
//! C'tor
Axis(QObject *parent=0);
// ----------------------------------------------------------------------
// Public interface
// ----------------------------------------------------------------------
public:
void setLabel(const QString &label);
QString label() const;
void setTickLength(int length);
int tickLength() const;
void setRange(const Range &range);
void extendRange(const Range &range);
const Range &range() const;
void setPosition(AxisPosition pos);
AxisPosition position() const;
void setLogScale(bool);
bool logScale() const;
void setLogBase(double);
double logBase() const;
void setVisible(bool visible);
bool isVisible() const;
void setGrid(bool grid);
bool hasGrid() const;
/**
* @brief Set the pen used to draw the axis, the ticks and the
* labels.
* @param pen The pen
*/
void setPen(const QPen &pen);
const QPen &pen() const;
/**
* @brief Set the pen used to draw the primary grid at ticks. The
* default is a solid pen with color (192,192,192) and line
* width 1.
* @param pen The pen
*/
void setGridPen(const QPen &pen);
const QPen &gridPen() const;
/**
* @brief Set the pen used to draw the grid at subticks. The default
* is a solid pen with color (224,224,224) and line width 1.
* @param pen The pen
*/
void setSubGridPen(const QPen &pen);
const QPen &subGridPen() const;
// ----------------------------------------------------------------------
// Render specific interface
// ----------------------------------------------------------------------
public:
struct Tick {
Tick() {}
Tick(double v, int rp, int ap) : value(v), relPos(rp), absPos(ap) {}
double value;
int relPos;
int absPos;
};
typedef QVector<Tick> Ticks;
/**
* @brief Returns the generated ticks. A call to updateLayout
* should precede this call to get reasonable values.
* This call was added with API 13.
*/
const Ticks &ticks() const;
/**
* @brief Returns the generated subticks. A call to updateLayout
* should precede this call to get reasonable values.
* This call was added with API 13.
*/
const Ticks &subTicks() const;
/**
* @brief Returns the width in pixels of the axis. This is independent
* of the direction (horizontal or vertical).
* @return The width or height in pixels
*/
int width() const;
//! Transforms a pixel value into axis space. A call to updateLayout
//! must precede this call.
double project(double pixelValue) const;
//! Transforms an axis value into pixel. A call to updateLayout must
//! precede this call.
double unproject(double axisValue) const;
/**
* @brief Update the layout and sizes based on the range and settings.
* This calls generates also the tick marks and the extend of
* the axis in the flexible direction.
* With API 13 this method has been declared virtual.
* @param fm The font metrics of the font used to render the axis.
* @param rect The target rect which will be changed according to the
* flexible dimension, e.g. width or height. The width/height
* of the rect is only changed if it is equal to 0.
*/
virtual void updateLayout(const QFontMetrics &fm, QRect &rect);
//! Convenience function
//! With API 13 this method has been declared virtual.
virtual void updateLayout(const QPainter &painter, QRect &rect);
/**
* @brief Returns the size hint for the flexible dimension, for vertical
* axes it is the width and for horizontal axes the height.
* With API 13 this method has been declared virtual.
* @param mf The font metrics of the font used to render the axis.
* @return The value in pixels or -1 if not determinable.
*/
virtual int sizeHint(const QFontMetrics &fm) const;
//! Convenience function
//! With API 13 this method has been declared virtual.
virtual int sizeHint(const QPainter &painter) const;
/**
* @brief Renders the axis into the given rect.
* With API 13 this method has been declared virtual.
* @param painter The painter instance to render with.
* @param rect The target rectangle. Depending on the position the rect
* is being updated according to the flexible direction if
* the rect dimension (either width or height) is not valid.
* A valid dimension forces the axis to render into the given
* rect.
* @param clipText Whether to check for tick label overlaps with the given
* rect or not. If enabled, then tick labels that intersect
* with the rect will be pushed into the rect if possible.
*/
virtual void draw(QPainter &painter, const QRect &rect,
bool clipText = false);
/**
* @brief Draws the grid lines at the (sub)ticks within a passed plot rect.
* With API 13 this method has been declared virtual.
* @param painter The painter instance to render with.
* @param rect The target rect for the plot.
* @param ticks Defines whether ticks should be considered or not
* @param subTicks Defines whether sub-ticks should be considered or not
*/
virtual void drawGrid(QPainter &painter, const QRect &rect, bool ticks, bool subTicks);
// ----------------------------------------------------------------------
// Members
// ----------------------------------------------------------------------
private:
// Setup
bool _visible;
bool _grid;
QString _label;
Range _range;
AxisPosition _position;
bool _logScale;
double _logBase;
int _tickLength;
int _spacing;
// Render configuration
QTransform _transform;
int _extent;
int _width;
double _axisStartValue;
double _axisEndValue;
double _axisPixelScale;
double _tickSpacing;
double _tickStart;
QVector<Tick> _ticks;
QVector<Tick> _subTicks;
QPen _penAxis;
QPen _penGridTicks;
QPen _penGridSubticks;
};
inline int Axis::width() const {
return _width;
}
inline void Axis::setVisible(bool visible) {
_visible = visible;
}
inline bool Axis::isVisible() const {
return _visible;
}
inline void Axis::setGrid(bool grid) {
_grid = grid;
}
inline bool Axis::hasGrid() const {
return _grid;
}
inline void Axis::setLabel(const QString &label) {
_label = label;
}
inline QString Axis::label() const {
return _label;
}
inline void Axis::setTickLength(int length) {
_tickLength = length;
}
inline int Axis::tickLength() const {
return _tickLength;
}
inline void Axis::setRange(const Range &range) {
_range = range;
}
inline const Range &Axis::range() const {
return _range;
}
inline void Axis::setPosition(AxisPosition pos) {
_position = pos;
}
inline Axis::AxisPosition Axis::position() const {
return _position;
}
inline void Axis::setLogScale(bool s) {
_logScale = s;
}
inline bool Axis::logScale() const {
return _logScale;
}
inline double Axis::logBase() const {
return _logBase;
}
inline const QPen &Axis::pen() const {
return _penAxis;
}
inline const QPen &Axis::gridPen() const {
return _penGridTicks;
}
inline const QPen &Axis::subGridPen() const {
return _penGridSubticks;
}
inline const Axis::Ticks &Axis::ticks() const {
return _ticks;
}
inline const Axis::Ticks &Axis::subTicks() const {
return _subTicks;
}
}
}
#endif

View File

@ -0,0 +1,87 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_PLOT_DATAXY_H
#define SEISCOMP_GUI_PLOT_DATAXY_H
#include <seiscomp/gui/plot/abstractdataset.h>
#include <QVector>
namespace Seiscomp {
namespace Gui {
class SC_GUI_API DataXY : public AbstractDataSet {
// ----------------------------------------------------------------------
// Public types
// ----------------------------------------------------------------------
public:
/**
* @brief DataPoint represents a single point in a graph with a key
* and a value.
*/
typedef QPointF DataPoint;
/**
* @brief DataPoints represents the graph data as list of data points.
*/
typedef QVector<DataPoint> DataPoints;
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
//! C'tor
DataXY(QObject *parent = 0);
// ----------------------------------------------------------------------
// AbstractGraph interface
// ----------------------------------------------------------------------
public:
virtual int count() const;
virtual Range getXRange() const;
virtual Range getYRange() const;
virtual void getBounds(Range &x, Range &y) const;
virtual void clear();
virtual void unproject(QPolygonF &poly,
const Axis *keyAxis,
const Axis *valueAxis) const;
// ----------------------------------------------------------------------
// Public members
// ----------------------------------------------------------------------
public:
DataPoints data;
};
}
}
#endif

View File

@ -0,0 +1,96 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_PLOT_DATAY_H
#define SEISCOMP_GUI_PLOT_DATAY_H
#include <seiscomp/gui/plot/abstractdataset.h>
#include <QVector>
namespace Seiscomp {
namespace Gui {
/**
* @brief The DataY class describes a data set with an array of values and
* a procedural key space which is linearily interpolated for each
* value between index 0 and N-1. By definition the lower key corresponds
* with value at index 0 and the upper key with value at index N-1.
* That means the distance between two subsequent keys is range.length / (N-1)
* which requires at least two values to render a valid key space.
*/
class SC_GUI_API DataY : public AbstractDataSet {
// ----------------------------------------------------------------------
// Public types
// ----------------------------------------------------------------------
public:
/**
* @brief DataPoint represents a single value in a graph. The key values
* will be generated.
*/
typedef double DataPoint;
/**
* @brief DataPoints represents the graph data as list of data points.
*/
typedef QVector<DataPoint> DataPoints;
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
//! C'tor
DataY(QObject *parent = 0);
// ----------------------------------------------------------------------
// AbstractGraph interface
// ----------------------------------------------------------------------
public:
virtual int count() const;
virtual Range getXRange() const;
virtual Range getYRange() const;
virtual void clear();
virtual void unproject(QPolygonF &poly,
const Axis *keyAxis,
const Axis *valueAxis) const;
// ----------------------------------------------------------------------
// Public members
// ----------------------------------------------------------------------
public:
//! The x range
Range x;
//! The y data points
DataPoints y;
};
}
}
#endif

View File

@ -0,0 +1,232 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_PLOT_ABSTRACTGRAPH_H
#define SEISCOMP_GUI_PLOT_ABSTRACTGRAPH_H
#include <seiscomp/gui/plot/axis.h>
#include <seiscomp/gui/plot/abstractdataset.h>
#include <QObject>
#include <QColor>
#include <QPolygonF>
namespace Seiscomp {
namespace Gui {
class AbstractDataSet;
class SC_GUI_API Graph : public QObject {
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
//! C'tor
explicit Graph(Axis *keyAxis, Axis *valueAxis, QObject *parent=0);
explicit Graph(const QString &name, Axis *keyAxis, Axis *valueAxis, QObject *parent=0);
// ----------------------------------------------------------------------
// Meta data
// ----------------------------------------------------------------------
public:
void setName(const QString &name);
const QString &name() const;
// ----------------------------------------------------------------------
// Setup
// ----------------------------------------------------------------------
public:
/**
* @brief Sets the pen used to draw the graph
* @param p The pen
*/
void setPen(const QPen &p);
const QPen &pen() const;
/**
* @brief Sets the primary (line) color of the graph.
* @param c The color
*/
void setColor(QColor c);
QColor color() const;
/**
* @brief Sets the line width of the graph.
* @param lw The line width in pixels
*/
void setLineWidth(int lw);
int lineWidth() const;
/**
* @brief Sets whether anti aliasing should be enabled or not.
* @param e Flag
*/
void setAntiAliasing(bool e);
bool antiAliasing() const;
/**
* @brief Sets whether to drop a show in the plot or not for this graph
* @param e Flag
*/
void setDropShadow(bool e);
bool dropShadow() const;
// ----------------------------------------------------------------------
// Query interface
// ----------------------------------------------------------------------
public:
Axis *keyAxis() const;
Axis *valueAxis() const;
void setData(AbstractDataSet *data);
AbstractDataSet *data() const;
bool isEmpty() const { return count() == 0; }
int count() const;
Range getXRange() const;
Range getYRange() const;
void getBounds(Range &x, Range &y) const;
/**
* @brief Convenience function that returns a QRectF instead of two
* single ranges.
* @return The bounding rectangle of the graph data
*/
QRectF getBounds() const;
// ----------------------------------------------------------------------
// Data interface
// ----------------------------------------------------------------------
public:
void setVisible(bool visible);
bool isVisible() const { return _visible; }
void clear();
/**
* @brief Unprojects the data from axis space to pixel space
* @param poly The target polygon that holds the projected and possibly
* clipped data. Note that the number of points in the
* polygon does not necessarily match the number of points
* in the graph due to clipping.
*/
virtual void unproject(QPolygonF &poly) const;
// ----------------------------------------------------------------------
// Render interface
// ----------------------------------------------------------------------
public:
/**
* @brief Draws the graph. The default implementation projects the
* associated dataset to screen coordinates and renders a
* polyline with the configured pen and style.
*
* Derived classes can reimplement this method to do custom drawing.
* Note that screen space projection must be inverted to accomodate
* for top-down coordinate system. The plot sets up the correct
* clipping and translation before calling this method.
*
* @param p The painter
*/
virtual void draw(QPainter &p);
/**
* @brief Draws a symbol to represent the graph. This is used by e.g.
* legends. The default implementation draws a horizontal line
* with the configured pen. The line is vertically centered in
* the target rectangle.
* @param p The painter
* @param r The target rect
*/
virtual void drawSymbol(QPainter &p, const QRect &r);
// ----------------------------------------------------------------------
// Protected members
// ----------------------------------------------------------------------
protected:
// Meta data
QString _name;
// Context
Axis *_keyAxis;
Axis *_valueAxis;
AbstractDataSet *_data;
// Setup
bool _visible;
QPen _pen;
bool _antiAliasing;
bool _dropShadow;
};
inline const QString &Graph::name() const {
return _name;
}
inline Axis *Graph::keyAxis() const {
return _keyAxis;
}
inline Axis *Graph::valueAxis() const {
return _valueAxis;
}
inline void Graph::setData(AbstractDataSet *data) {
_data = data;
}
inline AbstractDataSet *Graph::data() const {
return _data;
}
inline int Graph::count() const {
return _data != nullptr ? _data->count() : 0;
}
inline Range Graph::getXRange() const {
return _data != nullptr ? _data->getXRange() : Range();
}
inline Range Graph::getYRange() const {
return _data != nullptr ? _data->getYRange() : Range();
}
inline void Graph::clear() {
if ( _data != nullptr ) _data->clear();
}
}
}
#endif

View File

@ -0,0 +1,66 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_PLOT_LEGEND_H
#define SEISCOMP_GUI_PLOT_LEGEND_H
#include <seiscomp/gui/plot/abstractlegend.h>
namespace Seiscomp {
namespace Gui {
/**
* @brief The Legend class renders a default legend for all visible graphs
* where the name is not empty.
*/
class SC_GUI_API Legend : public AbstractLegend {
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
//! C'tor
explicit Legend(Qt::Alignment align = Qt::AlignTop | Qt::AlignRight,
QObject *parent=0);
// ----------------------------------------------------------------------
// Render interface
// ----------------------------------------------------------------------
public:
virtual void draw(QPainter &p, const QRect &plotRect,
const QList<Graph*> &graphs);
// ----------------------------------------------------------------------
// Private members
// ----------------------------------------------------------------------
private:
Qt::Alignment _alignment;
};
}
}
#endif

View File

@ -0,0 +1,156 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_PLOT_PLOT_H
#define SEISCOMP_GUI_PLOT_PLOT_H
#include <QObject>
#include <QPoint>
#include <seiscomp/gui/qt.h>
#include <seiscomp/gui/plot/axis.h>
class QRect;
class QPainter;
namespace Seiscomp {
namespace Gui {
class Graph;
class AbstractLegend;
class SC_GUI_API Plot : public QObject {
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
public:
//! C'tor
Plot(QObject *parent=0);
// ----------------------------------------------------------------------
// Public interface
// ----------------------------------------------------------------------
public:
/**
* @brief Adds a graph to the plot. The graph is managed by the plot.
* @param keyAxis The axis to use for keys. If nullptr is passed then
* the default xAxis is being used.
* @param valueAxis The axis to use for values. If nullptr is passed then
* the default yAxis is being used.
* @return The graph pointer or nullptr in case of error.
*/
Graph *addGraph(Axis *keyAxis = nullptr, Axis *valueAxis = nullptr);
/**
* @brief Adds a graph instance to the plot. This function was added
* with API version 11.0.0.
* @param graph The graph instance. The ownership is transferred to
* the plot.
*/
void addGraph(Graph *graph);
/**
* @brief Adds an additional plot axis. This method was added with
* API 12.
* @param position The position of the new axis
* @return The axis instance which is a child of this plot
*/
Axis *addAxis(Axis::AxisPosition position);
/**
* @brief Sets a legend instance for which the draw method is called
* at every plot update. This function was added with API
* version 11.0.0.
* @param legend The legend instance. The ownership goes to the plot.
*/
void setLegend(AbstractLegend *legend);
/**
* @brief Updates all axis ranges according to the bounds of the
* attached graphs.
*/
void updateRanges();
/**
* @brief Renders the plot into the given rect
* @param painter The painter used to draw the plot
* @param rect The target rectangle in screen coordinates
*/
void draw(QPainter &painter, const QRect &rect);
/**
* @brief Checks whether point is inside the plot area. This function
* was added with API version 11.0.0.
* @param p The point in pixels
* @return true if inside, false otherwise
*/
bool isInsidePlot(const QPoint &p) const;
/**
* @brief Returns the rectangle of the actual data plot without
* the axis rectangle. This function was added with API
* version 11.0.0.
* @return QRect
*/
const QRect &plotRect() const;
// ----------------------------------------------------------------------
// Public Members
// ----------------------------------------------------------------------
public:
Axis *xAxis; //!< bottom axis
Axis *yAxis; //!< left axis
Axis *xAxis2; //!< top axis
Axis *yAxis2; //!< right axis
protected:
typedef QList<Graph*> Graphs;
Graphs _graphs;
AbstractLegend *_legend;
QVector<Axis*> _extraXAxis1; //!< additional bottom x axes
QVector<Axis*> _extraXAxis2; //!< additional top x axes
QVector<Axis*> _extraYAxis1; //!< additional left y axes
QVector<Axis*> _extraYAxis2; //!< additional right y axes
QRect _plotRect; //!< The plot rectangle of the last draw
};
inline bool Plot::isInsidePlot(const QPoint &p) const {
return _plotRect.contains(p);
}
inline const QRect &Plot::plotRect() const {
return _plotRect;
}
}
}
#endif

View File

@ -0,0 +1,87 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_PLOT_RANGE_H
#define SEISCOMP_GUI_PLOT_RANGE_H
#include <seiscomp/gui/qt.h>
namespace Seiscomp {
namespace Gui {
struct SC_GUI_API Range {
// ----------------------------------------------------------------------
// X'truction
// ----------------------------------------------------------------------
//! Constructs an invalid range
Range();
//! Constructs a range with lower and upper bounds which will be normalized
Range(double lower, double upper);
// ----------------------------------------------------------------------
// Pulic interface
// ----------------------------------------------------------------------
double length() const;
double center() const;
bool contains(double value) const;
void normalize();
void extend(const Range &other);
void translate(double delta);
bool isValid() const;
// ----------------------------------------------------------------------
// Attributes
// ----------------------------------------------------------------------
double lower;
double upper;
};
inline Range::Range() : lower(1), upper(-1) {}
inline Range::Range(double lower, double upper) : lower(lower), upper(upper) {
normalize();
}
inline double Range::length() const { return upper - lower; }
inline double Range::center() const { return (lower+upper)*0.5; }
inline bool Range::contains(double value) const {
return (value >= lower) && (value <= upper);
}
inline bool Range::isValid() const { return lower <= upper; }
inline void Range::translate(double delta) { lower += delta; upper += delta; }
}
}
#endif