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