nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / view / axes / VPolarGrid.cxx
blob46d176b6d91b69efe5a111758f72824baa8ea0bf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "VPolarGrid.hxx"
21 #include "VCartesianGrid.hxx"
22 #include "Tickmarks.hxx"
23 #include <PlottingPositionHelper.hxx>
24 #include <ShapeFactory.hxx>
25 #include <ObjectIdentifier.hxx>
26 #include <CommonConverters.hxx>
27 #include <VLineProperties.hxx>
28 #include "Tickmarks_Equidistant.hxx"
30 #include <osl/diagnose.h>
32 #include <vector>
34 namespace chart
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::chart2;
38 using ::com::sun::star::uno::Reference;
40 VPolarGrid::VPolarGrid( sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount
41 , const uno::Sequence< Reference< beans::XPropertySet > > & rGridPropertiesList )
42 : VAxisOrGridBase( nDimensionIndex, nDimensionCount )
43 , m_aGridPropertiesList( rGridPropertiesList )
44 , m_pPosHelper( new PolarPlottingPositionHelper() )
45 , m_aIncrements()
47 PlotterBase::m_pPosHelper = m_pPosHelper.get();
50 VPolarGrid::~VPolarGrid()
54 void VPolarGrid::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements )
56 m_aIncrements = rIncrements;
59 void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, TickInfoArraysType& rAllTickInfos ) const
61 const std::vector<ExplicitScaleData>& rScales = m_pPosHelper->getScales();
62 TickFactory aTickFactory(rScales[nDimensionIndex], m_aIncrements[nDimensionIndex]);
63 aTickFactory.getAllTicks( rAllTickInfos );
66 void VPolarGrid::createLinePointSequence_ForAngleAxis(
67 drawing::PointSequenceSequence& rPoints
68 , TickInfoArraysType& rAllTickInfos
69 , const ExplicitIncrementData& rIncrement
70 , const ExplicitScaleData& rScale
71 , PolarPlottingPositionHelper const * pPosHelper
72 , double fLogicRadius, double fLogicZ )
74 Reference< XScaling > xInverseScaling;
75 if( rScale.Scaling.is() )
76 xInverseScaling = rScale.Scaling->getInverseScaling();
78 sal_Int32 nTick = 0;
79 EquidistantTickIter aIter( rAllTickInfos, rIncrement, 0 );
80 for( TickInfo* pTickInfo = aIter.firstInfo()
81 ; pTickInfo
82 ; pTickInfo = aIter.nextInfo(), nTick++ )
84 if(nTick>=rPoints[0].getLength())
85 rPoints[0].realloc(rPoints[0].getLength()+30);
87 //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
88 double fLogicAngle = pTickInfo->getUnscaledTickValue();
90 drawing::Position3D aScenePosition3D( pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicRadius, fLogicZ ) );
91 rPoints[0][nTick].X = static_cast<sal_Int32>(aScenePosition3D.PositionX);
92 rPoints[0][nTick].Y = static_cast<sal_Int32>(aScenePosition3D.PositionY);
94 if(rPoints[0].getLength()>1)
96 rPoints[0].realloc(nTick+1);
97 rPoints[0][nTick].X = rPoints[0][0].X;
98 rPoints[0][nTick].Y = rPoints[0][0].Y;
100 else
101 rPoints[0].realloc(0);
103 #ifdef NOTYET
104 void VPolarGrid::create2DAngleGrid( const Reference< drawing::XShapes >& xLogicTarget
105 , TickInfoArraysType& /* rRadiusTickInfos */
106 , TickInfoArraysType& rAngleTickInfos
107 , const std::vector<VLineProperties>& rLinePropertiesList )
109 Reference< drawing::XShapes > xMainTarget(
110 createGroupShape( xLogicTarget, m_aCID ) );
112 const std::vector<ExplicitScaleData>& rScales = m_pPosHelper->getScales();
113 const ExplicitScaleData& rAngleScale = rScales[0];
114 Reference< XScaling > xInverseScaling( NULL );
115 if( rAngleScale.Scaling.is() )
116 xInverseScaling = rAngleScale.Scaling->getInverseScaling();
118 double fLogicInnerRadius = m_pPosHelper->getInnerLogicRadius();
119 double fLogicOuterRadius = m_pPosHelper->getOuterLogicRadius();
121 sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
122 if(nLinePropertiesCount)
124 double fLogicZ = 1.0;//as defined
125 sal_Int32 nDepth=0;
126 //create axis main lines
127 drawing::PointSequenceSequence aAllPoints;
128 for (auto const& tick : rAngleTickInfos[0])
130 if( !tick.bPaintIt )
131 continue;
133 //xxxxx rTickInfo.updateUnscaledValue( xInverseScaling );
134 double fLogicAngle = tick.getUnscaledTickValue();
136 drawing::PointSequenceSequence aPoints(1);
137 aPoints[0].realloc(2);
138 drawing::Position3D aScenePositionStart( m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicInnerRadius, fLogicZ ) );
139 drawing::Position3D aScenePositionEnd( m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicOuterRadius, fLogicZ ) );
140 aPoints[0][0].X = static_cast<sal_Int32>(aScenePositionStart.PositionX);
141 aPoints[0][0].Y = static_cast<sal_Int32>(aScenePositionStart.PositionY);
142 aPoints[0][1].X = static_cast<sal_Int32>(aScenePositionEnd.PositionX);
143 aPoints[0][1].Y = static_cast<sal_Int32>(aScenePositionEnd.PositionY);
144 appendPointSequence( aAllPoints, aPoints );
147 Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
148 xMainTarget, aAllPoints, &rLinePropertiesList[nDepth] );
149 //because of this name this line will be used for marking
150 m_pShapeFactory->setShapeName( xShape, "MarkHandles" );
153 #endif
155 void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogicTarget
156 , TickInfoArraysType& rRadiusTickInfos
157 , TickInfoArraysType& rAngleTickInfos
158 , const std::vector<VLineProperties>& rLinePropertiesList )
160 Reference< drawing::XShapes > xMainTarget(
161 createGroupShape( xLogicTarget, m_aCID ) );
163 const std::vector<ExplicitScaleData>& rScales = m_pPosHelper->getScales();
164 const ExplicitScaleData& rRadiusScale = rScales[1];
165 const ExplicitScaleData& rAngleScale = rScales[0];
166 const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
167 Reference< XScaling > xInverseRadiusScaling;
168 if( rRadiusScale.Scaling.is() )
169 xInverseRadiusScaling = rRadiusScale.Scaling->getInverseScaling();
171 sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
172 TickInfoArraysType::iterator aDepthIter = rRadiusTickInfos.begin();
173 const TickInfoArraysType::const_iterator aDepthEnd = rRadiusTickInfos.end();
174 for( sal_Int32 nDepth=0
175 ; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount
176 ; ++aDepthIter, nDepth++ )
178 if( !rLinePropertiesList[nDepth].isLineVisible() )
179 continue;
181 Reference< drawing::XShapes > xTarget( xMainTarget );
182 if( nDepth > 0 )
184 xTarget.set( createGroupShape( xLogicTarget
185 , ObjectIdentifier::addChildParticle( m_aCID, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_SUBGRID, nDepth-1 ) )
186 ) );
187 if(!xTarget.is())
188 xTarget.set( xMainTarget );
191 //create axis main lines
192 drawing::PointSequenceSequence aAllPoints;
193 for (auto const& tick : *aDepthIter)
195 if( !tick.bPaintIt )
196 continue;
198 //xxxxx rTickInfo.updateUnscaledValue( xInverseRadiusScaling );
199 double fLogicRadius = tick.getUnscaledTickValue();
200 double const fLogicZ = 1.0;//as defined
202 drawing::PointSequenceSequence aPoints(1);
203 VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAngleTickInfos
204 , rAngleIncrement, rAngleScale, m_pPosHelper.get(), fLogicRadius, fLogicZ );
205 if(aPoints[0].getLength())
206 appendPointSequence( aAllPoints, aPoints );
209 Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
210 xTarget, aAllPoints, &rLinePropertiesList[nDepth] );
211 //because of this name this line will be used for marking
212 ::chart::ShapeFactory::setShapeName( xShape, "MarkHandles" );
216 void VPolarGrid::createShapes()
218 OSL_PRECOND(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized");
219 if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
220 return;
221 if(!m_aGridPropertiesList.hasElements())
222 return;
224 //create all scaled tickmark values
225 TickInfoArraysType aAngleTickInfos;
226 TickInfoArraysType aRadiusTickInfos;
227 getAllTickInfos( 0, aAngleTickInfos );
228 getAllTickInfos( 1, aRadiusTickInfos );
230 std::vector<VLineProperties> aLinePropertiesList;
231 VCartesianGrid::fillLinePropertiesFromGridModel( aLinePropertiesList, m_aGridPropertiesList );
233 //create tick mark line shapes
234 if(m_nDimension==2)
236 if(m_nDimensionIndex==1)
237 create2DRadiusGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
238 //else //no Angle Grid so far as this equals exactly the y axis positions
239 // create2DAngleGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
243 } //namespace chart
245 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */