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>
24 #include <CommonConverters.hxx>
25 #include "Tickmarks_Equidistant.hxx"
29 using namespace ::com::sun::star
;
30 using namespace ::com::sun::star::chart2
;
32 VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties
& rAxisProperties
33 , const uno::Reference
< util::XNumberFormatsSupplier
>& xNumberFormatsSupplier
34 , sal_Int32 nDimensionCount
)
35 : VPolarAxis( rAxisProperties
, xNumberFormatsSupplier
, 1/*nDimensionIndex*/, nDimensionCount
)
37 m_aAxisProperties
.maLabelAlignment
.mfLabelDirection
= 0.0;
38 m_aAxisProperties
.maLabelAlignment
.mfInnerTickDirection
= 0.0;
39 m_aAxisProperties
.maLabelAlignment
.meAlignment
= LABEL_ALIGN_RIGHT
;
40 m_aAxisProperties
.m_bIsMainAxis
=false;
41 m_aAxisProperties
.init();
43 m_apAxisWithLabels
.reset( new VCartesianAxis(
44 m_aAxisProperties
,xNumberFormatsSupplier
,1/*nDimensionIndex*/,nDimensionCount
45 ,new PolarPlottingPositionHelper() ) );
48 VPolarRadiusAxis::~VPolarRadiusAxis()
52 void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMatrix
& rMatrix
)
54 VPolarAxis::setTransformationSceneToScreen( rMatrix
);
55 m_apAxisWithLabels
->setTransformationSceneToScreen( rMatrix
);
58 void VPolarRadiusAxis::setExplicitScaleAndIncrement(
59 const ExplicitScaleData
& rScale
60 , const ExplicitIncrementData
& rIncrement
)
62 VPolarAxis::setExplicitScaleAndIncrement( rScale
, rIncrement
);
63 m_apAxisWithLabels
->setExplicitScaleAndIncrement( rScale
, rIncrement
);
66 void VPolarRadiusAxis::initPlotter( const rtl::Reference
<SvxShapeGroupAnyD
>& xLogicTarget
67 , const rtl::Reference
<SvxShapeGroupAnyD
>& xFinalTarget
68 , const OUString
& rCID
)
70 VPolarAxis::initPlotter( xLogicTarget
, xFinalTarget
, rCID
);
71 m_apAxisWithLabels
->initPlotter( xLogicTarget
, xFinalTarget
, rCID
);
74 void VPolarRadiusAxis::setScales( std::vector
< ExplicitScaleData
>&& rScales
, bool bSwapXAndYAxis
)
76 VPolarAxis::setScales( std::vector(rScales
), bSwapXAndYAxis
);
77 m_apAxisWithLabels
->setScales( std::move(rScales
), bSwapXAndYAxis
);
80 void VPolarRadiusAxis::initAxisLabelProperties( const css::awt::Size
& rFontReferenceSize
81 , const css::awt::Rectangle
& rMaximumSpaceForLabels
)
83 VPolarAxis::initAxisLabelProperties( rFontReferenceSize
, rMaximumSpaceForLabels
);
84 m_apAxisWithLabels
->initAxisLabelProperties( rFontReferenceSize
, rMaximumSpaceForLabels
);
87 sal_Int32
VPolarRadiusAxis::estimateMaximumAutoMainIncrementCount()
92 bool VPolarRadiusAxis::prepareShapeCreation()
94 //returns true if all is ready for further shape creation and any shapes need to be created
95 if( !isAnythingToDraw() )
98 if( m_xGroupShape_Shapes
.is() )
104 void VPolarRadiusAxis::createMaximumLabels()
106 m_apAxisWithLabels
->createMaximumLabels();
109 void VPolarRadiusAxis::updatePositions()
111 m_apAxisWithLabels
->updatePositions();
114 void VPolarRadiusAxis::createLabels()
116 m_apAxisWithLabels
->createLabels();
119 void VPolarRadiusAxis::createShapes()
121 if( !prepareShapeCreation() )
124 const ExplicitScaleData
& rAngleScale
= m_pPosHelper
->getScales()[0];
125 const ExplicitIncrementData
& rAngleIncrement
= m_aIncrements
[0];
127 TickInfoArraysType aAngleTickInfos
;
128 TickFactory
aAngleTickFactory( rAngleScale
, rAngleIncrement
);
129 aAngleTickFactory
.getAllTicks( aAngleTickInfos
);
131 uno::Reference
< XScaling
> xInverseScaling
;
132 if( rAngleScale
.Scaling
.is() )
133 xInverseScaling
= rAngleScale
.Scaling
->getInverseScaling();
135 AxisProperties
aAxisProperties(m_aAxisProperties
);
138 EquidistantTickIter
aIter( aAngleTickInfos
, rAngleIncrement
, 0 );
139 for( TickInfo
* pTickInfo
= aIter
.firstInfo()
140 ; pTickInfo
; pTickInfo
= aIter
.nextInfo(), nTick
++ )
144 m_apAxisWithLabels
->createShapes();
148 //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
149 aAxisProperties
.m_pfMainLinePositionAtOtherAxis
= pTickInfo
->getUnscaledTickValue();
150 aAxisProperties
.m_bDisplayLabels
=false;
152 VCartesianAxis
aAxis(aAxisProperties
,m_xNumberFormatsSupplier
153 ,1,2,new PolarPlottingPositionHelper());
154 aAxis
.setExplicitScaleAndIncrement( m_aScale
, m_aIncrement
);
155 aAxis
.initPlotter(m_xLogicTarget
,m_xFinalTarget
, m_aCID
);
156 aAxis
.setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( m_aMatrixScreenToScene
) );
157 aAxis
.setScales( std::vector(m_pPosHelper
->getScales()), false );
158 aAxis
.initAxisLabelProperties(m_aAxisLabelProperties
.m_aFontReferenceSize
,m_aAxisLabelProperties
.m_aMaximumSpaceForLabels
);
159 aAxis
.createShapes();
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */