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