1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26
27 #include "VPolarRadiusAxis.hxx"
28 #include "VCartesianAxis.hxx"
29 #include "PlottingPositionHelper.hxx"
30 #include "CommonConverters.hxx"
31 #include "Tickmarks_Equidistant.hxx"
32 #include <rtl/math.hxx>
33
34 //.............................................................................
35 namespace chart
36 {
37 //.............................................................................
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::chart2;
40 using namespace ::rtl::math;
41
VPolarRadiusAxis(const AxisProperties & rAxisProperties,const uno::Reference<util::XNumberFormatsSupplier> & xNumberFormatsSupplier,sal_Int32 nDimensionCount)42 VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties
43 , const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier
44 , sal_Int32 nDimensionCount )
45 : VPolarAxis( rAxisProperties, xNumberFormatsSupplier, 1/*nDimensionIndex*/, nDimensionCount )
46 {
47 m_aAxisProperties.m_fLabelDirectionSign=0.0;
48 m_aAxisProperties.m_fInnerDirectionSign=0.0;
49 m_aAxisProperties.m_bIsMainAxis=false;
50 m_aAxisProperties.m_aLabelAlignment=LABEL_ALIGN_RIGHT;
51 m_aAxisProperties.init();
52
53 m_apAxisWithLabels = std::auto_ptr<VCartesianAxis>( new VCartesianAxis(
54 m_aAxisProperties,xNumberFormatsSupplier,1/*nDimensionIndex*/,nDimensionCount
55 ,new PolarPlottingPositionHelper() ) );
56 }
57
~VPolarRadiusAxis()58 VPolarRadiusAxis::~VPolarRadiusAxis()
59 {
60 delete m_pPosHelper;
61 m_pPosHelper = NULL;
62 }
63
setTransformationSceneToScreen(const drawing::HomogenMatrix & rMatrix)64 void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
65 {
66 VPolarAxis::setTransformationSceneToScreen( rMatrix );
67 m_apAxisWithLabels->setTransformationSceneToScreen( rMatrix );
68 }
69
setExplicitScaleAndIncrement(const ExplicitScaleData & rScale,const ExplicitIncrementData & rIncrement)70 void VPolarRadiusAxis::setExplicitScaleAndIncrement(
71 const ExplicitScaleData& rScale
72 , const ExplicitIncrementData& rIncrement )
73 throw (uno::RuntimeException)
74 {
75 VPolarAxis::setExplicitScaleAndIncrement( rScale, rIncrement );
76 m_apAxisWithLabels->setExplicitScaleAndIncrement( rScale, rIncrement );
77 }
78
initPlotter(const uno::Reference<drawing::XShapes> & xLogicTarget,const uno::Reference<drawing::XShapes> & xFinalTarget,const uno::Reference<lang::XMultiServiceFactory> & xShapeFactory,const rtl::OUString & rCID)79 void VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget
80 , const uno::Reference< drawing::XShapes >& xFinalTarget
81 , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory
82 , const rtl::OUString& rCID )
83 throw (uno::RuntimeException)
84 {
85 VPolarAxis::initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID );
86 m_apAxisWithLabels->initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID );
87 }
88
setScales(const std::vector<ExplicitScaleData> & rScales,bool bSwapXAndYAxis)89 void VPolarRadiusAxis::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis )
90 {
91 VPolarAxis::setScales( rScales, bSwapXAndYAxis );
92 m_apAxisWithLabels->setScales( rScales, bSwapXAndYAxis );
93 }
94
initAxisLabelProperties(const::com::sun::star::awt::Size & rFontReferenceSize,const::com::sun::star::awt::Rectangle & rMaximumSpaceForLabels)95 void VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize
96 , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels )
97 {
98 VPolarAxis::initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels );
99 m_apAxisWithLabels->initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels );
100 }
101
estimateMaximumAutoMainIncrementCount()102 sal_Int32 VPolarRadiusAxis::estimateMaximumAutoMainIncrementCount()
103 {
104 return 2;
105 }
106
prepareShapeCreation()107 bool VPolarRadiusAxis::prepareShapeCreation()
108 {
109 //returns true if all is ready for further shape creation and any shapes need to be created
110 if( !isAnythingToDraw() )
111 return false;
112
113 if( m_xGroupShape_Shapes.is() )
114 return true;
115
116 return true;
117 }
118
createMaximumLabels()119 void VPolarRadiusAxis::createMaximumLabels()
120 {
121 m_apAxisWithLabels->createMaximumLabels();
122 }
123
updatePositions()124 void VPolarRadiusAxis::updatePositions()
125 {
126 m_apAxisWithLabels->updatePositions();
127 }
128
createLabels()129 void VPolarRadiusAxis::createLabels()
130 {
131 m_apAxisWithLabels->createLabels();
132 }
133
createShapes()134 void VPolarRadiusAxis::createShapes()
135 {
136 if( !prepareShapeCreation() )
137 return;
138
139 const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
140 const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
141
142 ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos;
143 TickFactory aAngleTickFactory( rAngleScale, rAngleIncrement );
144 aAngleTickFactory.getAllTicks( aAngleTickInfos );
145
146 uno::Reference< XScaling > xInverseScaling( NULL );
147 if( rAngleScale.Scaling.is() )
148 xInverseScaling = rAngleScale.Scaling->getInverseScaling();
149
150 AxisProperties aAxisProperties(m_aAxisProperties);
151
152 sal_Int32 nTick = 0;
153 EquidistantTickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 );
154 for( TickInfo* pTickInfo = aIter.firstInfo()
155 ; pTickInfo; pTickInfo = aIter.nextInfo(), nTick++ )
156 {
157 if( nTick == 0 )
158 {
159 m_apAxisWithLabels->createShapes();
160 continue;
161 }
162
163 //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
164 aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->getUnscaledTickValue() );
165 aAxisProperties.m_bDisplayLabels=false;
166
167 //-------------------
168 VCartesianAxis aAxis(aAxisProperties,m_xNumberFormatsSupplier
169 ,1,2,new PolarPlottingPositionHelper());
170 aAxis.setExplicitScaleAndIncrement( m_aScale, m_aIncrement );
171 aAxis.initPlotter(m_xLogicTarget,m_xFinalTarget,m_xShapeFactory, m_aCID );
172 aAxis.setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( m_aMatrixScreenToScene ) );
173 aAxis.setScales( m_pPosHelper->getScales(), false );
174 aAxis.initAxisLabelProperties(m_aAxisLabelProperties.m_aFontReferenceSize,m_aAxisLabelProperties.m_aMaximumSpaceForLabels);
175 aAxis.createShapes();
176 }
177 }
178
179 //.............................................................................
180 } //namespace chart
181 //.............................................................................
182