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 _CHART2_PIECHART_HXX
21 : #define _CHART2_PIECHART_HXX
22 :
23 : #include "VSeriesPlotter.hxx"
24 : #include <basegfx/vector/b2dvector.hxx>
25 : #include <basegfx/range/b2irectangle.hxx>
26 :
27 : //.............................................................................
28 : namespace chart
29 : {
30 : //.............................................................................
31 : class PiePositionHelper;
32 :
33 : class PieChart : public VSeriesPlotter
34 : {
35 : //-------------------------------------------------------------------------
36 : // public methods
37 : //-------------------------------------------------------------------------
38 : public:
39 : PieChart( const ::com::sun::star::uno::Reference<
40 : ::com::sun::star::chart2::XChartType >& xChartTypeModel
41 : , sal_Int32 nDimensionCount, bool bExcludingPositioning );
42 : virtual ~PieChart();
43 :
44 : virtual void createShapes();
45 : virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size& rPageSize );
46 :
47 : virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis );
48 : virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 );
49 :
50 : //-------------------
51 : virtual ::com::sun::star::drawing::Direction3D getPreferredDiagramAspectRatio() const;
52 : virtual bool keepAspectRatio() const;
53 : virtual bool shouldSnapRectToUsedArea();
54 :
55 : //MinimumAndMaximumSupplier
56 : virtual double getMinimumX();
57 : virtual double getMaximumX();
58 : virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex );
59 : virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex );
60 :
61 : virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex );
62 : virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex );
63 : virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex );
64 : virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex );
65 : virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex );
66 :
67 : //-------------------------------------------------------------------------
68 : //-------------------------------------------------------------------------
69 : //-------------------------------------------------------------------------
70 : private: //methods
71 : //no default constructor
72 : PieChart();
73 :
74 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
75 : createDataPoint( const ::com::sun::star::uno::Reference<
76 : ::com::sun::star::drawing::XShapes >& xTarget
77 : , const ::com::sun::star::uno::Reference<
78 : ::com::sun::star::beans::XPropertySet >& xObjectProperties
79 : , double fUnitCircleStartAngleDegree, double fWidthAngleDegree
80 : , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
81 : , double fLogicZ, double fDepth, double fExplodePercentage
82 : , tPropertyNameValueMap* pOverWritePropertiesMap );
83 :
84 : double getMaxOffset();
85 : bool detectLabelOverlapsAndMove(const ::com::sun::star::awt::Size& rPageSize);//returns true when there might be more to do
86 : void resetLabelPositionsToPreviousState();
87 : struct PieLabelInfo;
88 : bool tryMoveLabels( PieLabelInfo* pFirstBorder, PieLabelInfo* pSecondBorder
89 : , PieLabelInfo* pCenter, bool bSingleCenter, bool& rbAlternativeMoveDirection
90 : , const ::com::sun::star::awt::Size& rPageSize );
91 :
92 : private: //member
93 : PiePositionHelper* m_pPosHelper;
94 : bool m_bUseRings;
95 : bool m_bSizeExcludesLabelsAndExplodedSegments;
96 :
97 0 : struct PieLabelInfo
98 : {
99 : PieLabelInfo();
100 : bool moveAwayFrom( const PieLabelInfo* pFix, const ::com::sun::star::awt::Size& rPageSize
101 : , bool bMoveHalfWay, bool bMoveClockwise, bool bAlternativeMoveDirection );
102 :
103 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xTextShape;
104 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xLabelGroupShape;
105 : ::basegfx::B2IVector aFirstPosition;
106 : ::basegfx::B2IVector aOrigin;
107 : double fValue;
108 : bool bMovementAllowed;
109 : bool bMoved;
110 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > xTextTarget;
111 : PieLabelInfo* pPrevious;
112 : PieLabelInfo* pNext;
113 : ::com::sun::star::awt::Point aPreviousPosition;
114 : };
115 :
116 : ::std::vector< PieLabelInfo > m_aLabelInfoList;
117 :
118 : double m_fMaxOffset; /// cached max offset value (init'ed to NaN)
119 : };
120 : //.............................................................................
121 : } //namespace chart
122 : //.............................................................................
123 : #endif
124 :
125 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|