areachartitem_p.h
144 lines
| 4.4 KiB
| text/x-c
|
CLexer
|
r2854 | /**************************************************************************** | ||
|
r794 | ** | ||
|
r2854 | ** Copyright (C) 2016 The Qt Company Ltd. | ||
** Contact: https://www.qt.io/licensing/ | ||||
|
r794 | ** | ||
|
r2854 | ** This file is part of the Qt Charts module of the Qt Toolkit. | ||
|
r794 | ** | ||
|
r2854 | ** $QT_BEGIN_LICENSE:GPL$ | ||
|
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 | ||||
|
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. | ||||
|
r794 | ** | ||
|
r2845 | ** $QT_END_LICENSE$ | ||
** | ||||
|
r2854 | ****************************************************************************/ | ||
|
r794 | |||
|
r1366 | // W A R N I N G | ||
// ------------- | ||||
// | ||||
|
r2807 | // This file is not part of the Qt Chart API. It exists purely as an | ||
|
r1366 | // implementation detail. This header file may change from version to | ||
// version without notice, or even be removed. | ||||
// | ||||
// We mean it. | ||||
|
r421 | #ifndef AREACHARTITEM_H | ||
#define AREACHARTITEM_H | ||||
|
r2714 | #include <QtCharts/QChartGlobal> | ||
#include <private/linechartitem_p.h> | ||||
#include <QtCharts/QAreaSeries> | ||||
#include <QtGui/QPen> | ||||
|
r421 | |||
|
r2712 | QT_CHARTS_BEGIN_NAMESPACE | ||
|
r421 | |||
class AreaChartItem; | ||||
|
r689 | class AreaChartItem : public ChartItem | ||
|
r421 | { | ||
Q_OBJECT | ||||
public: | ||||
|
r2273 | AreaChartItem(QAreaSeries *areaSeries, QGraphicsItem* item = 0); | ||
|
r761 | ~AreaChartItem(); | ||
|
r421 | |||
//from QGraphicsItem | ||||
QRectF boundingRect() const; | ||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | ||||
QPainterPath shape() const; | ||||
|
r2104 | LineChartItem *upperLineItem() const { return m_upper; } | ||
LineChartItem *lowerLineItem() const { return m_lower; } | ||||
|
r560 | |||
|
r421 | void updatePath(); | ||
|
r571 | |||
|
r2273 | void setPresenter(ChartPresenter *presenter); | ||
|
r2483 | QAreaSeries *series() const { return m_series; } | ||
|
r571 | protected: | ||
|
r743 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | ||
|
r2264 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); | ||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); | ||||
|
r2739 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); | ||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); | ||||
|
r571 | |||
|
r775 | Q_SIGNALS: | ||
|
r2712 | void clicked(const QPointF &point); | ||
|
r2264 | void hovered(const QPointF &point, bool state); | ||
|
r2739 | void pressed(const QPointF &point); | ||
void released(const QPointF &point); | ||||
void doubleClicked(const QPointF &point); | ||||
|
r571 | |||
|
r775 | public Q_SLOTS: | ||
|
r421 | void handleUpdated(); | ||
|
r1698 | void handleDomainUpdated(); | ||
|
r421 | |||
private: | ||||
|
r2104 | QAreaSeries *m_series; | ||
LineChartItem *m_upper; | ||||
LineChartItem *m_lower; | ||||
|
r439 | QPainterPath m_path; | ||
|
r421 | QRectF m_rect; | ||
|
r563 | QPen m_linePen; | ||
QPen m_pointPen; | ||||
|
r421 | QBrush m_brush; | ||
|
r563 | bool m_pointsVisible; | ||
|
r2689 | bool m_pointLabelsVisible; | ||
QString m_pointLabelsFormat; | ||||
QFont m_pointLabelsFont; | ||||
QColor m_pointLabelsColor; | ||||
|
r2815 | bool m_pointLabelsClipping; | ||
|
r2689 | |||
|
r2739 | QPointF m_lastMousePos; | ||
bool m_mousePressed; | ||||
|
r421 | }; | ||
class AreaBoundItem : public LineChartItem | ||||
{ | ||||
public: | ||||
|
r2273 | AreaBoundItem(AreaChartItem *area, QLineSeries *lineSeries,QGraphicsItem* item = 0) | ||
: LineChartItem(lineSeries, item), m_item(area) | ||||
|
r2097 | { | ||
|
r2483 | // We do not actually want to draw anything from LineChartItem. | ||
// Drawing is done in AreaChartItem only. | ||||
setVisible(false); | ||||
|
r1241 | } | ||
|
r761 | ~AreaBoundItem() {} | ||
|
r421 | |||
|
r2273 | void updateGeometry() | ||
|
r2104 | { | ||
|
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(); | ||||
} | ||||
|
r421 | } | ||
private: | ||||
|
r2104 | AreaChartItem *m_item; | ||
|
r421 | }; | ||
|
r2712 | QT_CHARTS_END_NAMESPACE | ||
|
r421 | |||
#endif | ||||