fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / view / axes / VPolarGrid.cxx
blobff1541df3536c2ad8b6b55481554f06b1f21db70
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 "macros.hxx"
27 #include "CommonConverters.hxx"
28 #include "Tickmarks_Equidistant.hxx"
29 #include <com/sun/star/drawing/LineStyle.hpp>
31 #include <vector>
33 namespace chart
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::chart2;
37 using ::com::sun::star::uno::Reference;
39 VPolarGrid::VPolarGrid( sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount
40 , const uno::Sequence< Reference< beans::XPropertySet > > & rGridPropertiesList )
41 : VAxisOrGridBase( nDimensionIndex, nDimensionCount )
42 , m_aGridPropertiesList( rGridPropertiesList )
43 , m_pPosHelper( new PolarPlottingPositionHelper() )
44 , m_aIncrements()
46 PlotterBase::m_pPosHelper = m_pPosHelper;
49 VPolarGrid::~VPolarGrid()
51 delete m_pPosHelper;
52 m_pPosHelper = NULL;
55 void VPolarGrid::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements )
57 m_aIncrements = rIncrements;
60 void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, TickInfoArraysType& rAllTickInfos ) const
62 TickFactory aTickFactory(
63 m_pPosHelper->getScales()[nDimensionIndex], m_aIncrements[nDimensionIndex] );
64 aTickFactory.getAllTicks( rAllTickInfos );
67 void VPolarGrid::createLinePointSequence_ForAngleAxis(
68 drawing::PointSequenceSequence& rPoints
69 , TickInfoArraysType& rAllTickInfos
70 , const ExplicitIncrementData& rIncrement
71 , const ExplicitScaleData& rScale
72 , PolarPlottingPositionHelper* pPosHelper
73 , double fLogicRadius, double fLogicZ )
75 Reference< XScaling > xInverseScaling( NULL );
76 if( rScale.Scaling.is() )
77 xInverseScaling = rScale.Scaling->getInverseScaling();
79 sal_Int32 nTick = 0;
80 EquidistantTickIter aIter( rAllTickInfos, rIncrement, 0, 0 );
81 for( TickInfo* pTickInfo = aIter.firstInfo()
82 ; pTickInfo
83 ; pTickInfo = aIter.nextInfo(), nTick++ )
85 if(nTick>=rPoints[0].getLength())
86 rPoints[0].realloc(rPoints[0].getLength()+30);
88 //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
89 double fLogicAngle = pTickInfo->getUnscaledTickValue();
91 drawing::Position3D aScenePosition3D( pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicRadius, fLogicZ ) );
92 rPoints[0][nTick].X = static_cast<sal_Int32>(aScenePosition3D.PositionX);
93 rPoints[0][nTick].Y = static_cast<sal_Int32>(aScenePosition3D.PositionY);
95 if(rPoints[0].getLength()>1)
97 rPoints[0].realloc(nTick+1);
98 rPoints[0][nTick].X = rPoints[0][0].X;
99 rPoints[0][nTick].Y = rPoints[0][0].Y;
101 else
102 rPoints[0].realloc(0);
104 #ifdef NOTYET
105 void VPolarGrid::create2DAngleGrid( const Reference< drawing::XShapes >& xLogicTarget
106 , TickInfoArraysType& /* rRadiusTickInfos */
107 , TickInfoArraysType& rAngleTickInfos
108 , const ::std::vector<VLineProperties>& rLinePropertiesList )
110 Reference< drawing::XShapes > xMainTarget(
111 this->createGroupShape( xLogicTarget, m_aCID ) );
113 const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[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 TickInfoArraysType::iterator aDepthIter = rAngleTickInfos.begin();
123 if(nLinePropertiesCount)
125 double fLogicZ = 1.0;//as defined
126 sal_Int32 nDepth=0;
127 //create axis main lines
128 drawing::PointSequenceSequence aAllPoints;
129 TickInfoArrayType::iterator aTickIter = (*aDepthIter).begin();
130 const TickInfoArrayType::const_iterator aTickEnd = (*aDepthIter).end();
131 for( ; aTickIter != aTickEnd; ++aTickIter )
133 TickInfo& rTickInfo = *aTickIter;
134 if( !rTickInfo.bPaintIt )
135 continue;
137 //xxxxx rTickInfo.updateUnscaledValue( xInverseScaling );
138 double fLogicAngle = rTickInfo.getUnscaledTickValue();
140 drawing::PointSequenceSequence aPoints(1);
141 aPoints[0].realloc(2);
142 drawing::Position3D aScenePositionStart( m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicInnerRadius, fLogicZ ) );
143 drawing::Position3D aScenePositionEnd( m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicOuterRadius, fLogicZ ) );
144 aPoints[0][0].X = static_cast<sal_Int32>(aScenePositionStart.PositionX);
145 aPoints[0][0].Y = static_cast<sal_Int32>(aScenePositionStart.PositionY);
146 aPoints[0][1].X = static_cast<sal_Int32>(aScenePositionEnd.PositionX);
147 aPoints[0][1].Y = static_cast<sal_Int32>(aScenePositionEnd.PositionY);
148 appendPointSequence( aAllPoints, aPoints );
151 Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
152 xMainTarget, aAllPoints, &rLinePropertiesList[nDepth] );
153 //because of this name this line will be used for marking
154 m_pShapeFactory->setShapeName( xShape, "MarkHandles" );
157 #endif
159 void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogicTarget
160 , TickInfoArraysType& rRadiusTickInfos
161 , TickInfoArraysType& rAngleTickInfos
162 , const ::std::vector<VLineProperties>& rLinePropertiesList )
164 Reference< drawing::XShapes > xMainTarget(
165 this->createGroupShape( xLogicTarget, m_aCID ) );
167 const ExplicitScaleData& rRadiusScale = m_pPosHelper->getScales()[1];
168 const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
169 const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
170 Reference< XScaling > xInverseRadiusScaling( NULL );
171 if( rRadiusScale.Scaling.is() )
172 xInverseRadiusScaling = rRadiusScale.Scaling->getInverseScaling();
174 sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
175 TickInfoArraysType::iterator aDepthIter = rRadiusTickInfos.begin();
176 const TickInfoArraysType::const_iterator aDepthEnd = rRadiusTickInfos.end();
177 for( sal_Int32 nDepth=0
178 ; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount
179 ; ++aDepthIter, nDepth++ )
181 if( !rLinePropertiesList[nDepth].isLineVisible() )
182 continue;
184 Reference< drawing::XShapes > xTarget( xMainTarget );
185 if( nDepth > 0 )
187 xTarget.set( this->createGroupShape( xLogicTarget
188 , ObjectIdentifier::addChildParticle( m_aCID, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_SUBGRID, nDepth-1 ) )
189 ) );
190 if(!xTarget.is())
191 xTarget.set( xMainTarget );
194 //create axis main lines
195 drawing::PointSequenceSequence aAllPoints;
196 TickInfoArrayType::iterator aTickIter = (*aDepthIter).begin();
197 const TickInfoArrayType::const_iterator aTickEnd = (*aDepthIter).end();
198 for( ; aTickIter != aTickEnd; ++aTickIter )
200 TickInfo& rTickInfo = *aTickIter;
201 if( !rTickInfo.bPaintIt )
202 continue;
204 //xxxxx rTickInfo.updateUnscaledValue( xInverseRadiusScaling );
205 double fLogicRadius = rTickInfo.getUnscaledTickValue();
206 double fLogicZ = 1.0;//as defined
208 drawing::PointSequenceSequence aPoints(1);
209 VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAngleTickInfos
210 , rAngleIncrement, rAngleScale, m_pPosHelper, fLogicRadius, fLogicZ );
211 if(aPoints[0].getLength())
212 appendPointSequence( aAllPoints, aPoints );
215 Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
216 xTarget, aAllPoints, &rLinePropertiesList[nDepth] );
217 //because of this name this line will be used for marking
218 ::chart::AbstractShapeFactory::setShapeName( xShape, "MarkHandles" );
222 void VPolarGrid::createShapes()
224 OSL_PRECOND(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized");
225 if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
226 return;
227 if(!m_aGridPropertiesList.getLength())
228 return;
230 //create all scaled tickmark values
231 TickInfoArraysType aAngleTickInfos;
232 TickInfoArraysType aRadiusTickInfos;
233 getAllTickInfos( 0, aAngleTickInfos );
234 getAllTickInfos( 1, aRadiusTickInfos );
236 ::std::vector<VLineProperties> aLinePropertiesList;
237 VCartesianGrid::fillLinePropertiesFromGridModel( aLinePropertiesList, m_aGridPropertiesList );
239 //create tick mark line shapes
240 if(2==m_nDimension)
242 if(m_nDimensionIndex==1)
243 this->create2DRadiusGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
244 //else //no Angle Grid so far as this equals exactly the y axis positions
245 // this->create2DAngleGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
249 } //namespace chart
251 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */