areachartitem_p.h
118 lines
| 3.3 KiB
| text/x-c
|
CLexer
|
r794 | /**************************************************************************** | ||
** | ||||
|
r2432 | ** Copyright (C) 2013 Digia Plc | ||
|
r794 | ** All rights reserved. | ||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
|
r2574 | ** This file is part of the Qt Enterprise Charts Add-on. | ||
|
r794 | ** | ||
** $QT_BEGIN_LICENSE$ | ||||
|
r2574 | ** Licensees holding valid Qt Enterprise licenses may use this file in | ||
** accordance with the Qt Enterprise License Agreement provided with the | ||||
|
r794 | ** Software or, alternatively, in accordance with the terms contained in | ||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
|
r1366 | // W A R N I N G | ||
// ------------- | ||||
// | ||||
|
r2574 | // This file is not part of the Qt Enterprise 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 | ||||
#include "qchartglobal.h" | ||||
#include "linechartitem_p.h" | ||||
|
r2483 | #include "qareaseries.h" | ||
|
r421 | #include <QPen> | ||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
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); | ||||
|
r571 | |||
|
r775 | Q_SIGNALS: | ||
|
r2264 | void clicked(const QPointF &point); | ||
void hovered(const QPointF &point, bool state); | ||||
|
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; | ||
|
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 | { | ||
|
r2452 | // Turn off points drawing from component line chart item, as that | ||
// messes up the fill for area series. | ||||
suppressPoints(); | ||||
|
r2483 | // 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()); | ||||
|
r1217 | LineChartItem::updateGeometry(); | ||
|
r421 | m_item->updatePath(); | ||
} | ||||
private: | ||||
|
r2104 | AreaChartItem *m_item; | ||
|
r421 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif | ||||