Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_CHART2_SOURCE_VIEW_CHARTTYPES_PIECHART_HXX
21 : #define INCLUDED_CHART2_SOURCE_VIEW_CHARTTYPES_PIECHART_HXX
22 :
23 : #include "VSeriesPlotter.hxx"
24 : #include <basegfx/vector/b2dvector.hxx>
25 : #include <basegfx/range/b2irectangle.hxx>
26 :
27 : namespace chart
28 : {
29 : class PiePositionHelper;
30 :
31 : class PieChart : public VSeriesPlotter
32 : {
33 : // public methods
34 : public:
35 : PieChart( const ::com::sun::star::uno::Reference<
36 : ::com::sun::star::chart2::XChartType >& xChartTypeModel
37 : , sal_Int32 nDimensionCount, bool bExcludingPositioning );
38 : virtual ~PieChart();
39 :
40 : virtual void createShapes() SAL_OVERRIDE;
41 : virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size& rPageSize ) SAL_OVERRIDE;
42 :
43 : virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) SAL_OVERRIDE;
44 : virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ) SAL_OVERRIDE;
45 :
46 : virtual ::com::sun::star::drawing::Direction3D getPreferredDiagramAspectRatio() const SAL_OVERRIDE;
47 : virtual bool keepAspectRatio() const SAL_OVERRIDE;
48 : virtual bool shouldSnapRectToUsedArea() SAL_OVERRIDE;
49 :
50 : //MinimumAndMaximumSupplier
51 : virtual double getMinimumX() SAL_OVERRIDE;
52 : virtual double getMaximumX() SAL_OVERRIDE;
53 : virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) SAL_OVERRIDE;
54 : virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) SAL_OVERRIDE;
55 :
56 : virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex ) SAL_OVERRIDE;
57 : virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ) SAL_OVERRIDE;
58 : virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex ) SAL_OVERRIDE;
59 : virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ) SAL_OVERRIDE;
60 : virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex ) SAL_OVERRIDE;
61 :
62 : private: //methods
63 : //no default constructor
64 : PieChart();
65 :
66 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
67 : createDataPoint( const ::com::sun::star::uno::Reference<
68 : ::com::sun::star::drawing::XShapes >& xTarget
69 : , const ::com::sun::star::uno::Reference<
70 : ::com::sun::star::beans::XPropertySet >& xObjectProperties
71 : , double fUnitCircleStartAngleDegree, double fWidthAngleDegree
72 : , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
73 : , double fLogicZ, double fDepth, double fExplodePercentage
74 : , tPropertyNameValueMap* pOverWritePropertiesMap );
75 :
76 : double getMaxOffset();
77 : bool detectLabelOverlapsAndMove(const ::com::sun::star::awt::Size& rPageSize);//returns true when there might be more to do
78 : void resetLabelPositionsToPreviousState();
79 : struct PieLabelInfo;
80 : bool tryMoveLabels( PieLabelInfo* pFirstBorder, PieLabelInfo* pSecondBorder
81 : , PieLabelInfo* pCenter, bool bSingleCenter, bool& rbAlternativeMoveDirection
82 : , const ::com::sun::star::awt::Size& rPageSize );
83 :
84 : private: //member
85 : PiePositionHelper* m_pPosHelper;
86 : bool m_bUseRings;
87 : bool m_bSizeExcludesLabelsAndExplodedSegments;
88 :
89 0 : struct PieLabelInfo
90 : {
91 : PieLabelInfo();
92 : bool moveAwayFrom( const PieLabelInfo* pFix, const ::com::sun::star::awt::Size& rPageSize
93 : , bool bMoveHalfWay, bool bMoveClockwise, bool bAlternativeMoveDirection );
94 :
95 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xTextShape;
96 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xLabelGroupShape;
97 : ::basegfx::B2IVector aFirstPosition;
98 : ::basegfx::B2IVector aOrigin;
99 : double fValue;
100 : bool bMovementAllowed;
101 : bool bMoved;
102 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > xTextTarget;
103 : PieLabelInfo* pPrevious;
104 : PieLabelInfo* pNext;
105 : ::com::sun::star::awt::Point aPreviousPosition;
106 : };
107 :
108 : ::std::vector< PieLabelInfo > m_aLabelInfoList;
109 :
110 : double m_fMaxOffset; /// cached max offset value (init'ed to NaN)
111 : };
112 : } //namespace chart
113 : #endif
114 :
115 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|