1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "VPolarRadiusAxis.hxx"
21 #include "VCartesianAxis.hxx"
22 #include <PlottingPositionHelper.hxx>
23 #include <CommonConverters.hxx>
24 #include "Tickmarks_Equidistant.hxx"
25 #include <rtl/math.hxx>
29 using namespace ::com::sun::star
;
30 using namespace ::com::sun::star::chart2
;
31 using namespace ::rtl::math
;
33 VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties
& rAxisProperties
34 , const uno::Reference
< util::XNumberFormatsSupplier
>& xNumberFormatsSupplier
35 , sal_Int32 nDimensionCount
)
36 : VPolarAxis( rAxisProperties
, xNumberFormatsSupplier
, 1/*nDimensionIndex*/, nDimensionCount
)
38 m_aAxisProperties
.maLabelAlignment
.mfLabelDirection
= 0.0;
39 m_aAxisProperties
.maLabelAlignment
.mfInnerTickDirection
= 0.0;
40 m_aAxisProperties
.maLabelAlignment
.meAlignment
= LABEL_ALIGN_RIGHT
;
41 m_aAxisProperties
.m_bIsMainAxis
=false;
42 m_aAxisProperties
.init();
44 m_apAxisWithLabels
.reset( new VCartesianAxis(
45 m_aAxisProperties
,xNumberFormatsSupplier
,1/*nDimensionIndex*/,nDimensionCount
46 ,new PolarPlottingPositionHelper() ) );
49 VPolarRadiusAxis::~VPolarRadiusAxis()
53 void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMatrix
& rMatrix
)
55 VPolarAxis::setTransformationSceneToScreen( rMatrix
);
56 m_apAxisWithLabels
->setTransformationSceneToScreen( rMatrix
);
59 void VPolarRadiusAxis::setExplicitScaleAndIncrement(
60 const ExplicitScaleData
& rScale
61 , const ExplicitIncrementData
& rIncrement
)
63 VPolarAxis::setExplicitScaleAndIncrement( rScale
, rIncrement
);
64 m_apAxisWithLabels
->setExplicitScaleAndIncrement( rScale
, rIncrement
);
67 void VPolarRadiusAxis::initPlotter( const uno::Reference
< drawing::XShapes
>& xLogicTarget
68 , const uno::Reference
< drawing::XShapes
>& xFinalTarget
69 , const uno::Reference
< lang::XMultiServiceFactory
>& xShapeFactory
70 , const OUString
& rCID
)
72 VPolarAxis::initPlotter( xLogicTarget
, xFinalTarget
, xShapeFactory
, rCID
);
73 m_apAxisWithLabels
->initPlotter( xLogicTarget
, xFinalTarget
, xShapeFactory
, rCID
);
76 void VPolarRadiusAxis::setScales( const std::vector
< ExplicitScaleData
>& rScales
, bool bSwapXAndYAxis
)
78 VPolarAxis::setScales( rScales
, bSwapXAndYAxis
);
79 m_apAxisWithLabels
->setScales( rScales
, bSwapXAndYAxis
);
82 void VPolarRadiusAxis::initAxisLabelProperties( const css::awt::Size
& rFontReferenceSize
83 , const css::awt::Rectangle
& rMaximumSpaceForLabels
)
85 VPolarAxis::initAxisLabelProperties( rFontReferenceSize
, rMaximumSpaceForLabels
);
86 m_apAxisWithLabels
->initAxisLabelProperties( rFontReferenceSize
, rMaximumSpaceForLabels
);
89 sal_Int32
VPolarRadiusAxis::estimateMaximumAutoMainIncrementCount()
94 bool VPolarRadiusAxis::prepareShapeCreation()
96 //returns true if all is ready for further shape creation and any shapes need to be created
97 if( !isAnythingToDraw() )
100 if( m_xGroupShape_Shapes
.is() )
106 void VPolarRadiusAxis::createMaximumLabels()
108 m_apAxisWithLabels
->createMaximumLabels();
111 void VPolarRadiusAxis::updatePositions()
113 m_apAxisWithLabels
->updatePositions();
116 void VPolarRadiusAxis::createLabels()
118 m_apAxisWithLabels
->createLabels();
121 void VPolarRadiusAxis::createShapes()
123 if( !prepareShapeCreation() )
126 const ExplicitScaleData
& rAngleScale
= m_pPosHelper
->getScales()[0];
127 const ExplicitIncrementData
& rAngleIncrement
= m_aIncrements
[0];
129 TickInfoArraysType aAngleTickInfos
;
130 TickFactory
aAngleTickFactory( rAngleScale
, rAngleIncrement
);
131 aAngleTickFactory
.getAllTicks( aAngleTickInfos
);
133 uno::Reference
< XScaling
> xInverseScaling( nullptr );
134 if( rAngleScale
.Scaling
.is() )
135 xInverseScaling
= rAngleScale
.Scaling
->getInverseScaling();
137 AxisProperties
aAxisProperties(m_aAxisProperties
);
140 EquidistantTickIter
aIter( aAngleTickInfos
, rAngleIncrement
, 0 );
141 for( TickInfo
* pTickInfo
= aIter
.firstInfo()
142 ; pTickInfo
; pTickInfo
= aIter
.nextInfo(), nTick
++ )
146 m_apAxisWithLabels
->createShapes();
150 //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
151 aAxisProperties
.m_pfMainLinePositionAtOtherAxis
.reset(pTickInfo
->getUnscaledTickValue());
152 aAxisProperties
.m_bDisplayLabels
=false;
154 VCartesianAxis
aAxis(aAxisProperties
,m_xNumberFormatsSupplier
155 ,1,2,new PolarPlottingPositionHelper());
156 aAxis
.setExplicitScaleAndIncrement( m_aScale
, m_aIncrement
);
157 aAxis
.initPlotter(m_xLogicTarget
,m_xFinalTarget
,m_xShapeFactory
, m_aCID
);
158 aAxis
.setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( m_aMatrixScreenToScene
) );
159 aAxis
.setScales( m_pPosHelper
->getScales(), false );
160 aAxis
.initAxisLabelProperties(m_aAxisLabelProperties
.m_aFontReferenceSize
,m_aAxisLabelProperties
.m_aMaximumSpaceForLabels
);
161 aAxis
.createShapes();
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */