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 :
21 : #include "VPolarRadiusAxis.hxx"
22 : #include "VCartesianAxis.hxx"
23 : #include "PlottingPositionHelper.hxx"
24 : #include "CommonConverters.hxx"
25 : #include "Tickmarks_Equidistant.hxx"
26 : #include <rtl/math.hxx>
27 :
28 : //.............................................................................
29 : namespace chart
30 : {
31 : //.............................................................................
32 : using namespace ::com::sun::star;
33 : using namespace ::com::sun::star::chart2;
34 : using namespace ::rtl::math;
35 :
36 0 : VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties
37 : , const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier
38 : , sal_Int32 nDimensionCount )
39 0 : : VPolarAxis( rAxisProperties, xNumberFormatsSupplier, 1/*nDimensionIndex*/, nDimensionCount )
40 : {
41 0 : m_aAxisProperties.m_fLabelDirectionSign=0.0;
42 0 : m_aAxisProperties.m_fInnerDirectionSign=0.0;
43 0 : m_aAxisProperties.m_bIsMainAxis=false;
44 0 : m_aAxisProperties.m_aLabelAlignment=LABEL_ALIGN_RIGHT;
45 0 : m_aAxisProperties.init();
46 :
47 : m_apAxisWithLabels = std::auto_ptr<VCartesianAxis>( new VCartesianAxis(
48 : m_aAxisProperties,xNumberFormatsSupplier,1/*nDimensionIndex*/,nDimensionCount
49 0 : ,new PolarPlottingPositionHelper() ) );
50 0 : }
51 :
52 0 : VPolarRadiusAxis::~VPolarRadiusAxis()
53 : {
54 0 : delete m_pPosHelper;
55 0 : m_pPosHelper = NULL;
56 0 : }
57 :
58 0 : void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
59 : {
60 0 : VPolarAxis::setTransformationSceneToScreen( rMatrix );
61 0 : m_apAxisWithLabels->setTransformationSceneToScreen( rMatrix );
62 0 : }
63 :
64 0 : void VPolarRadiusAxis::setExplicitScaleAndIncrement(
65 : const ExplicitScaleData& rScale
66 : , const ExplicitIncrementData& rIncrement )
67 : throw (uno::RuntimeException)
68 : {
69 0 : VPolarAxis::setExplicitScaleAndIncrement( rScale, rIncrement );
70 0 : m_apAxisWithLabels->setExplicitScaleAndIncrement( rScale, rIncrement );
71 0 : }
72 :
73 0 : void VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget
74 : , const uno::Reference< drawing::XShapes >& xFinalTarget
75 : , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory
76 : , const rtl::OUString& rCID )
77 : throw (uno::RuntimeException)
78 : {
79 0 : VPolarAxis::initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID );
80 0 : m_apAxisWithLabels->initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID );
81 0 : }
82 :
83 0 : void VPolarRadiusAxis::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis )
84 : {
85 0 : VPolarAxis::setScales( rScales, bSwapXAndYAxis );
86 0 : m_apAxisWithLabels->setScales( rScales, bSwapXAndYAxis );
87 0 : }
88 :
89 0 : void VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize
90 : , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels )
91 : {
92 0 : VPolarAxis::initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels );
93 0 : m_apAxisWithLabels->initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels );
94 0 : }
95 :
96 0 : sal_Int32 VPolarRadiusAxis::estimateMaximumAutoMainIncrementCount()
97 : {
98 0 : return 2;
99 : }
100 :
101 0 : bool VPolarRadiusAxis::prepareShapeCreation()
102 : {
103 : //returns true if all is ready for further shape creation and any shapes need to be created
104 0 : if( !isAnythingToDraw() )
105 0 : return false;
106 :
107 0 : if( m_xGroupShape_Shapes.is() )
108 0 : return true;
109 :
110 0 : return true;
111 : }
112 :
113 0 : void VPolarRadiusAxis::createMaximumLabels()
114 : {
115 0 : m_apAxisWithLabels->createMaximumLabels();
116 0 : }
117 :
118 0 : void VPolarRadiusAxis::updatePositions()
119 : {
120 0 : m_apAxisWithLabels->updatePositions();
121 0 : }
122 :
123 0 : void VPolarRadiusAxis::createLabels()
124 : {
125 0 : m_apAxisWithLabels->createLabels();
126 0 : }
127 :
128 0 : void VPolarRadiusAxis::createShapes()
129 : {
130 0 : if( !prepareShapeCreation() )
131 0 : return;
132 :
133 0 : const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
134 0 : const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
135 :
136 0 : ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos;
137 0 : TickFactory aAngleTickFactory( rAngleScale, rAngleIncrement );
138 0 : aAngleTickFactory.getAllTicks( aAngleTickInfos );
139 :
140 0 : uno::Reference< XScaling > xInverseScaling( NULL );
141 0 : if( rAngleScale.Scaling.is() )
142 0 : xInverseScaling = rAngleScale.Scaling->getInverseScaling();
143 :
144 0 : AxisProperties aAxisProperties(m_aAxisProperties);
145 :
146 0 : sal_Int32 nTick = 0;
147 0 : EquidistantTickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 );
148 0 : for( TickInfo* pTickInfo = aIter.firstInfo()
149 : ; pTickInfo; pTickInfo = aIter.nextInfo(), nTick++ )
150 : {
151 0 : if( nTick == 0 )
152 : {
153 0 : m_apAxisWithLabels->createShapes();
154 0 : continue;
155 : }
156 :
157 : //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
158 0 : aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->getUnscaledTickValue() );
159 0 : aAxisProperties.m_bDisplayLabels=false;
160 :
161 : //-------------------
162 : VCartesianAxis aAxis(aAxisProperties,m_xNumberFormatsSupplier
163 0 : ,1,2,new PolarPlottingPositionHelper());
164 0 : aAxis.setExplicitScaleAndIncrement( m_aScale, m_aIncrement );
165 0 : aAxis.initPlotter(m_xLogicTarget,m_xFinalTarget,m_xShapeFactory, m_aCID );
166 0 : aAxis.setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( m_aMatrixScreenToScene ) );
167 0 : aAxis.setScales( m_pPosHelper->getScales(), false );
168 0 : aAxis.initAxisLabelProperties(m_aAxisLabelProperties.m_aFontReferenceSize,m_aAxisLabelProperties.m_aMaximumSpaceForLabels);
169 0 : aAxis.createShapes();
170 0 : }
171 : }
172 :
173 : //.............................................................................
174 : } //namespace chart
175 : //.............................................................................
176 :
177 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|