/usr/include/KChart/KChartPieDiagram.h is in libkchart-dev 2.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | /**
* Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
*
* This file is part of the KD Chart library.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KCHARTPIEDIAGRAM_H
#define KCHARTPIEDIAGRAM_H
#include "KChartAbstractPieDiagram.h"
namespace KChart {
class LabelPaintCache;
/**
* @brief PieDiagram defines a common pie diagram
*/
class KCHART_EXPORT PieDiagram : public AbstractPieDiagram
{
Q_OBJECT
Q_DISABLE_COPY( PieDiagram )
KCHART_DECLARE_DERIVED_DIAGRAM( PieDiagram, PolarCoordinatePlane )
public:
explicit PieDiagram(
QWidget* parent = 0, PolarCoordinatePlane* plane = 0 );
virtual ~PieDiagram();
protected:
// Implement AbstractDiagram
/** \reimpl */
virtual void paint( PaintContext* paintContext );
public:
/**
* Describes which decorations are painted around data labels.
*/
enum LabelDecoration {
NoDecoration = 0, ///< No decoration
FrameDecoration = 1, ///< A rectangular frame is painted around the label text
LineFromSliceDecoration = 2 ///< A line is drawn from the pie slice to its label
};
Q_DECLARE_FLAGS( LabelDecorations, LabelDecoration )
/// Set the decorations to be painted around data labels according to @p decorations.
void setLabelDecorations( LabelDecorations decorations );
/// Return the decorations to be painted around data labels.
LabelDecorations labelDecorations() const;
/// If @p enabled is set to true, labels that would overlap will be shuffled to avoid overlap.
/// \note Collision avoidance may allow labels to be closer than AbstractDiagram with
/// allowOverlappingDataValueTexts() == false, so you should usually also call
/// setAllowOverlappingDataValueTexts( true ) if you enable this feature.
void setLabelCollisionAvoidanceEnabled( bool enabled );
/// Return whether overlapping labels will be moved to until they don't overlap anymore.
bool isLabelCollisionAvoidanceEnabled() const;
/** \reimpl */
virtual void resize ( const QSizeF& area );
// Implement AbstractPolarDiagram
/** \reimpl */
virtual qreal valueTotals () const;
/** \reimpl */
virtual qreal numberOfValuesPerDataset() const;
/** \reimpl */
virtual qreal numberOfGridRings() const;
virtual PieDiagram * clone() const;
protected:
/** \reimpl */
virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const;
void paintEvent( QPaintEvent* );
void resizeEvent( QResizeEvent* );
private:
// ### move to private class?
void placeLabels( PaintContext* paintContext );
// Solve problems with label overlap by changing label positions inside d->labelPaintCache.
void shuffleLabels( QRectF* textBoundingRect );
void paintInternal( PaintContext* paintContext );
void drawSlice( QPainter* painter, const QRectF& drawPosition, uint slice );
void drawSliceSurface( QPainter* painter, const QRectF& drawPosition, uint slice );
void addSliceLabel( LabelPaintCache* lpc, const QRectF& drawPosition, uint slice );
void draw3DEffect( QPainter* painter, const QRectF& drawPosition, uint slice );
void draw3dCutSurface( QPainter* painter,
const QRectF& rect,
qreal threeDHeight,
qreal angle );
void draw3dOuterRim( QPainter* painter,
const QRectF& rect,
qreal threeDHeight,
qreal startAngle,
qreal endAngle );
void calcSliceAngles();
void calcPieSize( const QRectF &contentsRect );
QRectF twoDPieRect( const QRectF &contentsRect, const ThreeDPieAttributes& threeDAttrs ) const;
QRectF explodedDrawPosition( const QRectF& drawPosition, uint slice ) const;
uint findSliceAt( qreal angle, int columnCount );
uint findLeftSlice( uint slice, int columnCount );
uint findRightSlice( uint slice, int columnCount );
QPointF pointOnEllipse( const QRectF& boundingBox, qreal angle );
}; // End of class KChartPieDiagram
Q_DECLARE_OPERATORS_FOR_FLAGS( PieDiagram::LabelDecorations )
}
#endif // KCHARTPIEDIAGRAM_H
|