1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19*cde9e8dcSAndrew Rist *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir #include "VPolarGrid.hxx"
27cdf0e10cSrcweir #include "VCartesianGrid.hxx"
28cdf0e10cSrcweir #include "Tickmarks.hxx"
29cdf0e10cSrcweir #include "PlottingPositionHelper.hxx"
30cdf0e10cSrcweir #include "ShapeFactory.hxx"
31cdf0e10cSrcweir #include "ObjectIdentifier.hxx"
32cdf0e10cSrcweir #include "macros.hxx"
33cdf0e10cSrcweir #include "CommonConverters.hxx"
34cdf0e10cSrcweir #include "Tickmarks_Equidistant.hxx"
35cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <vector>
38cdf0e10cSrcweir #include <memory>
39cdf0e10cSrcweir
40cdf0e10cSrcweir //.............................................................................
41cdf0e10cSrcweir namespace chart
42cdf0e10cSrcweir {
43cdf0e10cSrcweir //.............................................................................
44cdf0e10cSrcweir using namespace ::com::sun::star;
45cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
46cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
47cdf0e10cSrcweir
VPolarGrid(sal_Int32 nDimensionIndex,sal_Int32 nDimensionCount,const uno::Sequence<Reference<beans::XPropertySet>> & rGridPropertiesList)48cdf0e10cSrcweir VPolarGrid::VPolarGrid( sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount
49cdf0e10cSrcweir , const uno::Sequence< Reference< beans::XPropertySet > > & rGridPropertiesList )
50cdf0e10cSrcweir : VAxisOrGridBase( nDimensionIndex, nDimensionCount )
51cdf0e10cSrcweir , m_aGridPropertiesList( rGridPropertiesList )
52cdf0e10cSrcweir , m_pPosHelper( new PolarPlottingPositionHelper() )
53cdf0e10cSrcweir , m_aIncrements()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir PlotterBase::m_pPosHelper = m_pPosHelper;
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
~VPolarGrid()58cdf0e10cSrcweir VPolarGrid::~VPolarGrid()
59cdf0e10cSrcweir {
60cdf0e10cSrcweir delete m_pPosHelper;
61cdf0e10cSrcweir m_pPosHelper = NULL;
62cdf0e10cSrcweir }
63cdf0e10cSrcweir
setIncrements(const std::vector<ExplicitIncrementData> & rIncrements)64cdf0e10cSrcweir void VPolarGrid::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir m_aIncrements = rIncrements;
67cdf0e10cSrcweir }
68cdf0e10cSrcweir
getAllTickInfos(sal_Int32 nDimensionIndex,::std::vector<::std::vector<TickInfo>> & rAllTickInfos) const69cdf0e10cSrcweir void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
70cdf0e10cSrcweir {
71cdf0e10cSrcweir TickFactory aTickFactory(
72cdf0e10cSrcweir m_pPosHelper->getScales()[nDimensionIndex], m_aIncrements[nDimensionIndex] );
73cdf0e10cSrcweir aTickFactory.getAllTicks( rAllTickInfos );
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
createLinePointSequence_ForAngleAxis(drawing::PointSequenceSequence & rPoints,::std::vector<::std::vector<TickInfo>> & rAllTickInfos,const ExplicitIncrementData & rIncrement,const ExplicitScaleData & rScale,PolarPlottingPositionHelper * pPosHelper,double fLogicRadius,double fLogicZ)76cdf0e10cSrcweir void VPolarGrid::createLinePointSequence_ForAngleAxis(
77cdf0e10cSrcweir drawing::PointSequenceSequence& rPoints
78cdf0e10cSrcweir , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos
79cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement
80cdf0e10cSrcweir , const ExplicitScaleData& rScale
81cdf0e10cSrcweir , PolarPlottingPositionHelper* pPosHelper
82cdf0e10cSrcweir , double fLogicRadius, double fLogicZ )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir Reference< XScaling > xInverseScaling( NULL );
85cdf0e10cSrcweir if( rScale.Scaling.is() )
86cdf0e10cSrcweir xInverseScaling = rScale.Scaling->getInverseScaling();
87cdf0e10cSrcweir
88cdf0e10cSrcweir sal_Int32 nTick = 0;
89cdf0e10cSrcweir EquidistantTickIter aIter( rAllTickInfos, rIncrement, 0, 0 );
90cdf0e10cSrcweir for( TickInfo* pTickInfo = aIter.firstInfo()
91cdf0e10cSrcweir ; pTickInfo
92cdf0e10cSrcweir ; pTickInfo = aIter.nextInfo(), nTick++ )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir if(nTick>=rPoints[0].getLength())
95cdf0e10cSrcweir rPoints[0].realloc(rPoints[0].getLength()+30);
96cdf0e10cSrcweir
97cdf0e10cSrcweir //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
98cdf0e10cSrcweir double fLogicAngle = pTickInfo->getUnscaledTickValue();
99cdf0e10cSrcweir
100cdf0e10cSrcweir drawing::Position3D aScenePosition3D( pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicRadius, fLogicZ ) );
101cdf0e10cSrcweir rPoints[0][nTick].X = static_cast<sal_Int32>(aScenePosition3D.PositionX);
102cdf0e10cSrcweir rPoints[0][nTick].Y = static_cast<sal_Int32>(aScenePosition3D.PositionY);
103cdf0e10cSrcweir }
104cdf0e10cSrcweir if(rPoints[0].getLength()>1)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir rPoints[0].realloc(nTick+1);
107cdf0e10cSrcweir rPoints[0][nTick].X = rPoints[0][0].X;
108cdf0e10cSrcweir rPoints[0][nTick].Y = rPoints[0][0].Y;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir else
111cdf0e10cSrcweir rPoints[0].realloc(0);
112cdf0e10cSrcweir }
113cdf0e10cSrcweir #ifdef NOTYET
create2DAngleGrid(const Reference<drawing::XShapes> & xLogicTarget,::std::vector<::std::vector<TickInfo>> &,::std::vector<::std::vector<TickInfo>> & rAngleTickInfos,const::std::vector<VLineProperties> & rLinePropertiesList)114cdf0e10cSrcweir void VPolarGrid::create2DAngleGrid( const Reference< drawing::XShapes >& xLogicTarget
115cdf0e10cSrcweir , ::std::vector< ::std::vector< TickInfo > >& /* rRadiusTickInfos */
116cdf0e10cSrcweir , ::std::vector< ::std::vector< TickInfo > >& rAngleTickInfos
117cdf0e10cSrcweir , const ::std::vector<VLineProperties>& rLinePropertiesList )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir Reference< drawing::XShapes > xMainTarget(
120cdf0e10cSrcweir this->createGroupShape( xLogicTarget, m_aCID ) );
121cdf0e10cSrcweir
122cdf0e10cSrcweir const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
123cdf0e10cSrcweir Reference< XScaling > xInverseScaling( NULL );
124cdf0e10cSrcweir if( rAngleScale.Scaling.is() )
125cdf0e10cSrcweir xInverseScaling = rAngleScale.Scaling->getInverseScaling();
126cdf0e10cSrcweir
127cdf0e10cSrcweir double fLogicInnerRadius = m_pPosHelper->getInnerLogicRadius();
128cdf0e10cSrcweir double fLogicOuterRadius = m_pPosHelper->getOuterLogicRadius();
129cdf0e10cSrcweir double fLogicZ = 1.0;//as defined
130cdf0e10cSrcweir
131cdf0e10cSrcweir sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
132cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAngleTickInfos.begin();
133cdf0e10cSrcweir sal_Int32 nDepth=0;
134cdf0e10cSrcweir /*
135cdf0e10cSrcweir //no subgrids so far for polar angle grid (need different radii)
136cdf0e10cSrcweir const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAngleTickInfos.end();
137cdf0e10cSrcweir for( ; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount
138cdf0e10cSrcweir ; aDepthIter++, nDepth++ )
139cdf0e10cSrcweir */
140cdf0e10cSrcweir if(nLinePropertiesCount)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir //create axis main lines
143cdf0e10cSrcweir drawing::PointSequenceSequence aAllPoints;
144cdf0e10cSrcweir ::std::vector< TickInfo >::iterator aTickIter = (*aDepthIter).begin();
145cdf0e10cSrcweir const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end();
146cdf0e10cSrcweir for( ; aTickIter != aTickEnd; aTickIter++ )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir TickInfo& rTickInfo = *aTickIter;
149cdf0e10cSrcweir if( !rTickInfo.bPaintIt )
150cdf0e10cSrcweir continue;
151cdf0e10cSrcweir
152cdf0e10cSrcweir //xxxxx rTickInfo.updateUnscaledValue( xInverseScaling );
153cdf0e10cSrcweir double fLogicAngle = rTickInfo.getUnscaledTickValue();
154cdf0e10cSrcweir
155cdf0e10cSrcweir drawing::PointSequenceSequence aPoints(1);
156cdf0e10cSrcweir aPoints[0].realloc(2);
157cdf0e10cSrcweir drawing::Position3D aScenePositionStart( m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicInnerRadius, fLogicZ ) );
158cdf0e10cSrcweir drawing::Position3D aScenePositionEnd( m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicOuterRadius, fLogicZ ) );
159cdf0e10cSrcweir aPoints[0][0].X = static_cast<sal_Int32>(aScenePositionStart.PositionX);
160cdf0e10cSrcweir aPoints[0][0].Y = static_cast<sal_Int32>(aScenePositionStart.PositionY);
161cdf0e10cSrcweir aPoints[0][1].X = static_cast<sal_Int32>(aScenePositionEnd.PositionX);
162cdf0e10cSrcweir aPoints[0][1].Y = static_cast<sal_Int32>(aScenePositionEnd.PositionY);
163cdf0e10cSrcweir appendPointSequence( aAllPoints, aPoints );
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
166cdf0e10cSrcweir Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
167cdf0e10cSrcweir xMainTarget, aAllPoints, &rLinePropertiesList[nDepth] );
168cdf0e10cSrcweir //because of this name this line will be used for marking
169cdf0e10cSrcweir m_pShapeFactory->setShapeName( xShape, C2U("MarkHandles") );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir #endif
173cdf0e10cSrcweir
create2DRadiusGrid(const Reference<drawing::XShapes> & xLogicTarget,::std::vector<::std::vector<TickInfo>> & rRadiusTickInfos,::std::vector<::std::vector<TickInfo>> & rAngleTickInfos,const::std::vector<VLineProperties> & rLinePropertiesList)174cdf0e10cSrcweir void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogicTarget
175cdf0e10cSrcweir , ::std::vector< ::std::vector< TickInfo > >& rRadiusTickInfos
176cdf0e10cSrcweir , ::std::vector< ::std::vector< TickInfo > >& rAngleTickInfos
177cdf0e10cSrcweir , const ::std::vector<VLineProperties>& rLinePropertiesList )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir Reference< drawing::XShapes > xMainTarget(
180cdf0e10cSrcweir this->createGroupShape( xLogicTarget, m_aCID ) );
181cdf0e10cSrcweir
182cdf0e10cSrcweir const ExplicitScaleData& rRadiusScale = m_pPosHelper->getScales()[1];
183cdf0e10cSrcweir const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
184cdf0e10cSrcweir const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
185cdf0e10cSrcweir Reference< XScaling > xInverseRadiusScaling( NULL );
186cdf0e10cSrcweir if( rRadiusScale.Scaling.is() )
187cdf0e10cSrcweir xInverseRadiusScaling = rRadiusScale.Scaling->getInverseScaling();
188cdf0e10cSrcweir
189cdf0e10cSrcweir sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
190cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rRadiusTickInfos.begin();
191cdf0e10cSrcweir const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rRadiusTickInfos.end();
192cdf0e10cSrcweir for( sal_Int32 nDepth=0
193cdf0e10cSrcweir ; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount
194cdf0e10cSrcweir ; aDepthIter++, nDepth++ )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir if( !rLinePropertiesList[nDepth].isLineVisible() )
197cdf0e10cSrcweir continue;
198cdf0e10cSrcweir
199cdf0e10cSrcweir Reference< drawing::XShapes > xTarget( xMainTarget );
200cdf0e10cSrcweir if( nDepth > 0 )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir xTarget.set( this->createGroupShape( xLogicTarget
203cdf0e10cSrcweir , ObjectIdentifier::addChildParticle( m_aCID, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_SUBGRID, nDepth-1 ) )
204cdf0e10cSrcweir ) );
205cdf0e10cSrcweir if(!xTarget.is())
206cdf0e10cSrcweir xTarget.set( xMainTarget );
207cdf0e10cSrcweir }
208cdf0e10cSrcweir
209cdf0e10cSrcweir //create axis main lines
210cdf0e10cSrcweir drawing::PointSequenceSequence aAllPoints;
211cdf0e10cSrcweir ::std::vector< TickInfo >::iterator aTickIter = (*aDepthIter).begin();
212cdf0e10cSrcweir const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end();
213cdf0e10cSrcweir for( ; aTickIter != aTickEnd; aTickIter++ )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir TickInfo& rTickInfo = *aTickIter;
216cdf0e10cSrcweir if( !rTickInfo.bPaintIt )
217cdf0e10cSrcweir continue;
218cdf0e10cSrcweir
219cdf0e10cSrcweir //xxxxx rTickInfo.updateUnscaledValue( xInverseRadiusScaling );
220cdf0e10cSrcweir double fLogicRadius = rTickInfo.getUnscaledTickValue();
221cdf0e10cSrcweir double fLogicZ = 1.0;//as defined
222cdf0e10cSrcweir
223cdf0e10cSrcweir drawing::PointSequenceSequence aPoints(1);
224cdf0e10cSrcweir VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAngleTickInfos
225cdf0e10cSrcweir , rAngleIncrement, rAngleScale, m_pPosHelper, fLogicRadius, fLogicZ );
226cdf0e10cSrcweir if(aPoints[0].getLength())
227cdf0e10cSrcweir appendPointSequence( aAllPoints, aPoints );
228cdf0e10cSrcweir }
229cdf0e10cSrcweir
230cdf0e10cSrcweir Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
231cdf0e10cSrcweir xTarget, aAllPoints, &rLinePropertiesList[nDepth] );
232cdf0e10cSrcweir //because of this name this line will be used for marking
233cdf0e10cSrcweir m_pShapeFactory->setShapeName( xShape, C2U("MarkHandles") );
234cdf0e10cSrcweir }
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
createShapes()237cdf0e10cSrcweir void VPolarGrid::createShapes()
238cdf0e10cSrcweir {
239cdf0e10cSrcweir DBG_ASSERT(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized");
240cdf0e10cSrcweir if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
241cdf0e10cSrcweir return;
242cdf0e10cSrcweir if(!m_aGridPropertiesList.getLength())
243cdf0e10cSrcweir return;
244cdf0e10cSrcweir
245cdf0e10cSrcweir //-----------------------------------------
246cdf0e10cSrcweir //create all scaled tickmark values
247cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos;
248cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > > aRadiusTickInfos;
249cdf0e10cSrcweir getAllTickInfos( 0, aAngleTickInfos );
250cdf0e10cSrcweir getAllTickInfos( 1, aRadiusTickInfos );
251cdf0e10cSrcweir
252cdf0e10cSrcweir //-----------------------------------------
253cdf0e10cSrcweir ::std::vector<VLineProperties> aLinePropertiesList;
254cdf0e10cSrcweir VCartesianGrid::fillLinePropertiesFromGridModel( aLinePropertiesList, m_aGridPropertiesList );
255cdf0e10cSrcweir
256cdf0e10cSrcweir //-----------------------------------------
257cdf0e10cSrcweir //create tick mark line shapes
258cdf0e10cSrcweir if(2==m_nDimension)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir if(m_nDimensionIndex==1)
261cdf0e10cSrcweir this->create2DRadiusGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
262cdf0e10cSrcweir //else //no Angle Grid so far as this equals exactly the y axis positions
263cdf0e10cSrcweir // this->create2DAngleGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
264cdf0e10cSrcweir }
265cdf0e10cSrcweir }
266cdf0e10cSrcweir
267cdf0e10cSrcweir //.............................................................................
268cdf0e10cSrcweir } //namespace chart
269cdf0e10cSrcweir //.............................................................................
270