areachartitem_p.h
144 lines
| 4.4 KiB
| text/x-c
|
CLexer
Miikka Heikkinen
|
r2854 | /**************************************************************************** | ||
Jani Honkonen
|
r794 | ** | ||
Miikka Heikkinen
|
r2854 | ** Copyright (C) 2016 The Qt Company Ltd. | ||
** Contact: https://www.qt.io/licensing/ | ||||
Jani Honkonen
|
r794 | ** | ||
Miikka Heikkinen
|
r2854 | ** This file is part of the Qt Charts module of the Qt Toolkit. | ||
Jani Honkonen
|
r794 | ** | ||
Miikka Heikkinen
|
r2854 | ** $QT_BEGIN_LICENSE:GPL$ | ||
Titta Heikkala
|
r2845 | ** Commercial License Usage | ||
** Licensees holding valid commercial Qt licenses may use this file in | ||||
** accordance with the commercial license agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and The Qt Company. For licensing terms | ||||
Miikka Heikkinen
|
r2854 | ** and conditions see https://www.qt.io/terms-conditions. For further | ||
** information use the contact form at https://www.qt.io/contact-us. | ||||
** | ||||
** GNU General Public License Usage | ||||
** Alternatively, this file may be used under the terms of the GNU | ||||
** General Public License version 3 or (at your option) any later version | ||||
** approved by the KDE Free Qt Foundation. The licenses are as published by | ||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3 | ||||
** included in the packaging of this file. Please review the following | ||||
** information to ensure the GNU General Public License requirements will | ||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html. | ||||
Jani Honkonen
|
r794 | ** | ||
Titta Heikkala
|
r2845 | ** $QT_END_LICENSE$ | ||
** | ||||
Miikka Heikkinen
|
r2854 | ****************************************************************************/ | ||
Jani Honkonen
|
r794 | |||
unknown
|
r1366 | // W A R N I N G | ||
// ------------- | ||||
// | ||||
Titta Heikkala
|
r2807 | // This file is not part of the Qt Chart API. It exists purely as an | ||
unknown
|
r1366 | // implementation detail. This header file may change from version to | ||
// version without notice, or even be removed. | ||||
// | ||||
// We mean it. | ||||
Michal Klocek
|
r421 | #ifndef AREACHARTITEM_H | ||
#define AREACHARTITEM_H | ||||
Titta Heikkala
|
r2714 | #include <QtCharts/QChartGlobal> | ||
#include <private/linechartitem_p.h> | ||||
#include <QtCharts/QAreaSeries> | ||||
#include <QtGui/QPen> | ||||
Michal Klocek
|
r421 | |||
Titta Heikkala
|
r2712 | QT_CHARTS_BEGIN_NAMESPACE | ||
Michal Klocek
|
r421 | |||
class AreaChartItem; | ||||
Michal Klocek
|
r689 | class AreaChartItem : public ChartItem | ||
Michal Klocek
|
r421 | { | ||
Q_OBJECT | ||||
public: | ||||
Michal Klocek
|
r2273 | AreaChartItem(QAreaSeries *areaSeries, QGraphicsItem* item = 0); | ||
Tero Ahola
|
r761 | ~AreaChartItem(); | ||
Michal Klocek
|
r421 | |||
//from QGraphicsItem | ||||
QRectF boundingRect() const; | ||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | ||||
QPainterPath shape() const; | ||||
Jani Honkonen
|
r2104 | LineChartItem *upperLineItem() const { return m_upper; } | ||
LineChartItem *lowerLineItem() const { return m_lower; } | ||||
Michal Klocek
|
r560 | |||
Michal Klocek
|
r421 | void updatePath(); | ||
Michal Klocek
|
r571 | |||
Michal Klocek
|
r2273 | void setPresenter(ChartPresenter *presenter); | ||
Miikka Heikkinen
|
r2483 | QAreaSeries *series() const { return m_series; } | ||
Michal Klocek
|
r571 | protected: | ||
sauimone
|
r743 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | ||
Marek Rosa
|
r2264 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); | ||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); | ||||
Titta Heikkala
|
r2739 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); | ||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); | ||||
Michal Klocek
|
r571 | |||
sauimone
|
r775 | Q_SIGNALS: | ||
Titta Heikkala
|
r2712 | void clicked(const QPointF &point); | ||
Marek Rosa
|
r2264 | void hovered(const QPointF &point, bool state); | ||
Titta Heikkala
|
r2739 | void pressed(const QPointF &point); | ||
void released(const QPointF &point); | ||||
void doubleClicked(const QPointF &point); | ||||
Michal Klocek
|
r571 | |||
sauimone
|
r775 | public Q_SLOTS: | ||
Michal Klocek
|
r421 | void handleUpdated(); | ||
Michal Klocek
|
r1698 | void handleDomainUpdated(); | ||
Michal Klocek
|
r421 | |||
private: | ||||
Jani Honkonen
|
r2104 | QAreaSeries *m_series; | ||
LineChartItem *m_upper; | ||||
LineChartItem *m_lower; | ||||
Michal Klocek
|
r439 | QPainterPath m_path; | ||
Michal Klocek
|
r421 | QRectF m_rect; | ||
Michal Klocek
|
r563 | QPen m_linePen; | ||
QPen m_pointPen; | ||||
Michal Klocek
|
r421 | QBrush m_brush; | ||
Michal Klocek
|
r563 | bool m_pointsVisible; | ||
Titta Heikkala
|
r2689 | bool m_pointLabelsVisible; | ||
QString m_pointLabelsFormat; | ||||
QFont m_pointLabelsFont; | ||||
QColor m_pointLabelsColor; | ||||
Titta Heikkala
|
r2815 | bool m_pointLabelsClipping; | ||
Titta Heikkala
|
r2689 | |||
Titta Heikkala
|
r2739 | QPointF m_lastMousePos; | ||
bool m_mousePressed; | ||||
Michal Klocek
|
r421 | }; | ||
class AreaBoundItem : public LineChartItem | ||||
{ | ||||
public: | ||||
Michal Klocek
|
r2273 | AreaBoundItem(AreaChartItem *area, QLineSeries *lineSeries,QGraphicsItem* item = 0) | ||
: LineChartItem(lineSeries, item), m_item(area) | ||||
Jani Honkonen
|
r2097 | { | ||
Miikka Heikkinen
|
r2483 | // We do not actually want to draw anything from LineChartItem. | ||
// Drawing is done in AreaChartItem only. | ||||
setVisible(false); | ||||
Michal Klocek
|
r1241 | } | ||
Tero Ahola
|
r761 | ~AreaBoundItem() {} | ||
Michal Klocek
|
r421 | |||
Michal Klocek
|
r2273 | void updateGeometry() | ||
Jani Honkonen
|
r2104 | { | ||
Miikka Heikkinen
|
r2800 | // Make sure the series is in a chart before trying to update | ||
if (m_item->series()->chart()) { | ||||
// Turn off points drawing from component line chart item, as that | ||||
// messes up the fill for area series. | ||||
suppressPoints(); | ||||
// Component lineseries are not necessarily themselves on the chart, | ||||
// so get the chart type for them from area chart. | ||||
forceChartType(m_item->series()->chart()->chartType()); | ||||
LineChartItem::updateGeometry(); | ||||
m_item->updatePath(); | ||||
} | ||||
Michal Klocek
|
r421 | } | ||
private: | ||||
Jani Honkonen
|
r2104 | AreaChartItem *m_item; | ||
Michal Klocek
|
r421 | }; | ||
Titta Heikkala
|
r2712 | QT_CHARTS_END_NAMESPACE | ||
Michal Klocek
|
r421 | |||
#endif | ||||