fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / view / charttypes / NetChart.cxx
blob5bd26237adb4cabffbdd1a2fdee16d89dd5ba5d7
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 "NetChart.hxx"
21 #include "PlottingPositionHelper.hxx"
22 #include "AbstractShapeFactory.hxx"
23 #include "CommonConverters.hxx"
24 #include "macros.hxx"
25 #include "ViewDefines.hxx"
26 #include "ObjectIdentifier.hxx"
27 #include "ChartTypeHelper.hxx"
28 #include "LabelPositionHelper.hxx"
29 #include "Clipping.hxx"
30 #include "Stripe.hxx"
31 #include "PolarLabelPositionHelper.hxx"
32 #include "DateHelper.hxx"
34 #include <com/sun/star/chart2/Symbol.hpp>
35 #include <com/sun/star/chart/DataLabelPlacement.hpp>
36 #include <com/sun/star/chart/MissingValueTreatment.hpp>
38 #include <editeng/unoprnms.hxx>
39 #include <rtl/math.hxx>
41 #include <com/sun/star/drawing/DoubleSequence.hpp>
42 #include <com/sun/star/drawing/NormalsKind.hpp>
43 #include <com/sun/star/lang/XServiceName.hpp>
45 namespace chart
47 using namespace ::com::sun::star;
48 using namespace ::rtl::math;
49 using namespace ::com::sun::star::chart2;
51 NetChart::NetChart( const uno::Reference<XChartType>& xChartTypeModel
52 , sal_Int32 nDimensionCount
53 , bool bNoArea
54 , PlottingPositionHelper* pPlottingPositionHelper
56 : VSeriesPlotter( xChartTypeModel, nDimensionCount, true )
57 , m_pMainPosHelper(pPlottingPositionHelper)
58 , m_bArea(!bNoArea)
59 , m_bLine(bNoArea)
60 , m_xSeriesTarget(0)
61 , m_xTextTarget(0)
63 // we only support 2D Net charts
64 assert(nDimensionCount == 2);
66 m_pMainPosHelper->AllowShiftXAxisPos(true);
67 m_pMainPosHelper->AllowShiftZAxisPos(true);
69 PlotterBase::m_pPosHelper = m_pMainPosHelper.get();
70 VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get();
73 NetChart::~NetChart()
77 double NetChart::getMaximumX()
79 double fMax = VSeriesPlotter::getMaximumX() + 1.0;
80 return fMax;
83 bool NetChart::isExpandIfValuesCloseToBorder( sal_Int32 )
85 return false;
88 bool NetChart::isSeparateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex*/ )
90 // no separate stacking in all types of line/area charts
91 return false;
94 LegendSymbolStyle NetChart::getLegendSymbolStyle()
96 if( m_bArea )
97 return LegendSymbolStyle_BOX;
98 return LegendSymbolStyle_LINE;
101 uno::Any NetChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex )
103 uno::Any aRet;
105 Symbol* pSymbolProperties = rSeries.getSymbolProperties( nPointIndex );
106 if( pSymbolProperties )
108 aRet = uno::makeAny(*pSymbolProperties);
111 return aRet;
114 drawing::Direction3D NetChart::getPreferredDiagramAspectRatio() const
116 return drawing::Direction3D(1,1,1);
119 bool NetChart::keepAspectRatio() const
121 return true;
124 void NetChart::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot )
126 VSeriesPlotter::addSeries( pSeries, zSlot, xSlot, ySlot );
129 bool NetChart::impl_createLine( VDataSeries* pSeries
130 , drawing::PolyPolygonShape3D* pSeriesPoly
131 , PlottingPositionHelper* pPosHelper )
133 //return true if a line was created successfully
134 uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
136 drawing::PolyPolygonShape3D aPoly;
138 bool bIsClipped = false;
139 if( !AbstractShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
141 // do NOT connect last and first point, if one is NAN, and NAN handling is NAN_AS_GAP
142 double fFirstY = pSeries->getYValue( 0 );
143 double fLastY = pSeries->getYValue( VSeriesPlotter::getPointCount() - 1 );
144 if( (pSeries->getMissingValueTreatment() != ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
145 || (::rtl::math::isFinite( fFirstY ) && ::rtl::math::isFinite( fLastY )) )
147 // connect last point in last polygon with first point in first polygon
148 ::basegfx::B2DRectangle aScaledLogicClipDoubleRect( pPosHelper->getScaledLogicClipDoubleRect() );
149 drawing::PolyPolygonShape3D aTmpPoly(*pSeriesPoly);
150 drawing::Position3D aLast(aScaledLogicClipDoubleRect.getMaxX(),aTmpPoly.SequenceY[0][0],aTmpPoly.SequenceZ[0][0]);
151 // add connector line to last polygon
152 AddPointToPoly( aTmpPoly, aLast, pSeriesPoly->SequenceX.getLength() - 1 );
153 Clipping::clipPolygonAtRectangle( aTmpPoly, aScaledLogicClipDoubleRect, aPoly );
154 bIsClipped = true;
158 if( !bIsClipped )
159 Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
162 if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly))
163 return false;
165 //transformation 3) -> 4)
166 pPosHelper->transformScaledLogicToScene( aPoly );
168 //create line:
169 uno::Reference< drawing::XShape > xShape(NULL);
171 xShape = m_pShapeFactory->createLine2D( xSeriesGroupShape_Shapes
172 , PolyToPointSequence( aPoly ) );
173 setMappedProperties( xShape
174 , pSeries->getPropertiesOfSeries()
175 , PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
176 //because of this name this line will be used for marking
177 ::chart::AbstractShapeFactory::setShapeName(xShape, "MarkHandles");
179 return true;
182 bool NetChart::impl_createArea( VDataSeries* pSeries
183 , drawing::PolyPolygonShape3D* pSeriesPoly
184 , drawing::PolyPolygonShape3D* pPreviousSeriesPoly
185 , PlottingPositionHelper* pPosHelper )
187 //return true if an area was created successfully
189 uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
190 double zValue = pSeries->m_fLogicZPos;
192 drawing::PolyPolygonShape3D aPoly( *pSeriesPoly );
193 //add second part to the polygon (grounding points or previous series points)
194 if( !AbstractShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
196 if( pPreviousSeriesPoly )
197 addPolygon( aPoly, *pPreviousSeriesPoly );
199 else if(!pPreviousSeriesPoly)
201 double fMinX = pSeries->m_fLogicMinX;
202 double fMaxX = pSeries->m_fLogicMaxX;
203 double fY = pPosHelper->getBaseValueY();//logic grounding
205 //clip to scale
206 if(fMaxX<pPosHelper->getLogicMinX() || fMinX>pPosHelper->getLogicMaxX())
207 return false;//no visible shape needed
208 pPosHelper->clipLogicValues( &fMinX, &fY, 0 );
209 pPosHelper->clipLogicValues( &fMaxX, 0, 0 );
211 //apply scaling
213 pPosHelper->doLogicScaling( &fMinX, &fY, &zValue );
214 pPosHelper->doLogicScaling( &fMaxX, 0, 0 );
217 AddPointToPoly( aPoly, drawing::Position3D( fMaxX,fY,zValue) );
218 AddPointToPoly( aPoly, drawing::Position3D( fMinX,fY,zValue) );
220 else
222 appendPoly( aPoly, *pPreviousSeriesPoly );
224 AbstractShapeFactory::closePolygon(aPoly);
226 //apply clipping
228 drawing::PolyPolygonShape3D aClippedPoly;
229 Clipping::clipPolygonAtRectangle( aPoly, pPosHelper->getScaledLogicClipDoubleRect(), aClippedPoly, false );
230 AbstractShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping
231 aPoly = aClippedPoly;
234 if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly))
235 return false;
237 //transformation 3) -> 4)
238 pPosHelper->transformScaledLogicToScene( aPoly );
240 //create area:
241 uno::Reference< drawing::XShape >
242 xShape = m_pShapeFactory->createArea2D( xSeriesGroupShape_Shapes
243 , aPoly );
244 setMappedProperties( xShape
245 , pSeries->getPropertiesOfSeries()
246 , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
247 //because of this name this line will be used for marking
248 ::chart::AbstractShapeFactory::setShapeName(xShape, "MarkHandles");
249 return true;
252 void NetChart::impl_createSeriesShapes()
254 //the polygon shapes for each series need to be created before
256 //iterate through all series again to create the series shapes
257 ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin();
258 const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end();
259 for( sal_Int32 nZ=1; aZSlotIter != aZSlotEnd; ++aZSlotIter, ++nZ )
261 ::std::vector< VDataSeriesGroup >::iterator aXSlotIter = aZSlotIter->begin();
262 const ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end();
264 for( ; aXSlotIter != aXSlotEnd; ++aXSlotIter )
266 ::std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector);
268 ::std::vector< VDataSeries* >::const_iterator aSeriesIter = pSeriesList->begin();
269 const ::std::vector< VDataSeries* >::const_iterator aSeriesEnd = pSeriesList->end();
271 std::map< sal_Int32, drawing::PolyPolygonShape3D* > aPreviousSeriesPolyMap;//a PreviousSeriesPoly for each different nAttachedAxisIndex
272 drawing::PolyPolygonShape3D* pSeriesPoly = NULL;
274 //iterate through all series
275 for( ; aSeriesIter != aSeriesEnd; ++aSeriesIter )
277 sal_Int32 nAttachedAxisIndex = (*aSeriesIter)->getAttachedAxisIndex();
278 PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
279 if(!pPosHelper)
280 pPosHelper = m_pMainPosHelper.get();
281 PlotterBase::m_pPosHelper = pPosHelper;
283 pSeriesPoly = &(*aSeriesIter)->m_aPolyPolygonShape3D;
284 if( m_bArea )
286 if( !impl_createArea( *aSeriesIter, pSeriesPoly, aPreviousSeriesPolyMap[nAttachedAxisIndex], pPosHelper ) )
287 continue;
289 if( m_bLine )
291 if( !impl_createLine( *aSeriesIter, pSeriesPoly, pPosHelper ) )
292 continue;
294 aPreviousSeriesPolyMap[nAttachedAxisIndex] = pSeriesPoly;
295 }//next series in x slot (next y slot)
296 }//next x slot
297 }//next z slot
300 namespace
303 void lcl_reorderSeries( ::std::vector< ::std::vector< VDataSeriesGroup > >& rZSlots )
305 ::std::vector< ::std::vector< VDataSeriesGroup > > aRet( rZSlots.size() );
307 ::std::vector< ::std::vector< VDataSeriesGroup > >::reverse_iterator aZIt( rZSlots.rbegin() );
308 ::std::vector< ::std::vector< VDataSeriesGroup > >::reverse_iterator aZEnd( rZSlots.rend() );
309 for( ; aZIt != aZEnd; ++aZIt )
311 ::std::vector< VDataSeriesGroup > aXSlot( aZIt->size() );
313 ::std::vector< VDataSeriesGroup >::reverse_iterator aXIt( aZIt->rbegin() );
314 ::std::vector< VDataSeriesGroup >::reverse_iterator aXEnd( aZIt->rend() );
315 for( ; aXIt != aXEnd; ++aXIt )
316 aXSlot.push_back(*aXIt);
318 aRet.push_back(aXSlot);
321 rZSlots.clear();
322 rZSlots = aRet;
325 }//anonymous namespace
327 //better performance for big data
328 struct FormerPoint
330 FormerPoint( double fX, double fY, double fZ )
331 : m_fX(fX), m_fY(fY), m_fZ(fZ)
333 FormerPoint()
335 ::rtl::math::setNan( &m_fX );
336 ::rtl::math::setNan( &m_fY );
337 ::rtl::math::setNan( &m_fZ );
340 double m_fX;
341 double m_fY;
342 double m_fZ;
345 void NetChart::createShapes()
347 if( m_aZSlots.begin() == m_aZSlots.end() ) //no series
348 return;
350 if( m_bArea )
351 lcl_reorderSeries( m_aZSlots );
353 OSL_ENSURE(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"NetChart is not proper initialized");
354 if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
355 return;
357 //the text labels should be always on top of the other series shapes
358 //for area chart the error bars should be always on top of the other series shapes
360 //therefore create an own group for the texts and the error bars to move them to front
361 //(because the text group is created after the series group the texts are displayed on top)
362 m_xSeriesTarget = createGroupShape( m_xLogicTarget,OUString() );
363 m_xTextTarget = m_pShapeFactory->createGroup2D( m_xFinalTarget,OUString() );
365 //check necessary here that different Y axis can not be stacked in the same group? ... hm?
367 //update/create information for current group
368 double fLogicZ = 1.0;//as defined
370 sal_Int32 nStartIndex = 0; // inclusive ;..todo get somehow from x scale
371 sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
372 if(nEndIndex<=0)
373 nEndIndex=1;
375 //better performance for big data
376 std::map< VDataSeries*, FormerPoint > aSeriesFormerPointMap;
377 m_bPointsWereSkipped = false;
378 sal_Int32 nSkippedPoints = 0;
379 sal_Int32 nCreatedPoints = 0;
381 bool bDateCategory = (m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis());
383 //iterate through all x values per indices
384 for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
386 ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin();
387 const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end();
389 std::map< sal_Int32, double > aLogicYSumMap;//one for each different nAttachedAxisIndex
390 for( ; aZSlotIter != aZSlotEnd; ++aZSlotIter )
392 ::std::vector< VDataSeriesGroup >::iterator aXSlotIter = aZSlotIter->begin();
393 const ::std::vector< VDataSeriesGroup >::iterator aXSlotEnd = aZSlotIter->end();
395 //iterate through all x slots in this category to get 100percent sum
396 for( ; aXSlotIter != aXSlotEnd; ++aXSlotIter )
398 std::vector<VDataSeries*>& rSeriesList = aXSlotIter->m_aSeriesVector;
399 std::vector<VDataSeries*>::iterator aSeriesIter = rSeriesList.begin();
400 std::vector<VDataSeries*>::iterator aSeriesEnd = rSeriesList.end();
402 for( ; aSeriesIter != aSeriesEnd; ++aSeriesIter )
404 VDataSeries* pSeries( *aSeriesIter );
405 if(!pSeries)
406 continue;
408 if (bDateCategory)
409 pSeries->doSortByXValues();
411 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
412 if( aLogicYSumMap.find(nAttachedAxisIndex)==aLogicYSumMap.end() )
413 aLogicYSumMap[nAttachedAxisIndex]=0.0;
415 PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
416 if(!pPosHelper)
417 pPosHelper = m_pMainPosHelper.get();
418 PlotterBase::m_pPosHelper = pPosHelper;
420 double fAdd = pSeries->getYValue( nIndex );
421 if( !::rtl::math::isNan(fAdd) && !::rtl::math::isInf(fAdd) )
422 aLogicYSumMap[nAttachedAxisIndex] += fabs( fAdd );
427 aZSlotIter = m_aZSlots.begin();
428 for( sal_Int32 nZ=1; aZSlotIter != aZSlotEnd; ++aZSlotIter, ++nZ )
430 ::std::vector< VDataSeriesGroup >::const_iterator aXSlotIter = aZSlotIter->begin();
431 ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end();
433 //for the area chart there should be at most one x slot (no side by side stacking available)
434 //attention different: xSlots are always interpreted as independent areas one behind the other: @todo this doesn't work why not???
435 for( sal_Int32 nX=0; aXSlotIter != aXSlotEnd; ++aXSlotIter, ++nX )
437 const std::vector<VDataSeries*>& rSeriesList = aXSlotIter->m_aSeriesVector;
438 std::vector<VDataSeries*>::const_iterator aSeriesIter = rSeriesList.begin();
439 const std::vector<VDataSeries*>::const_iterator aSeriesEnd = rSeriesList.end();
441 std::map< sal_Int32, double > aLogicYForNextSeriesMap;//one for each different nAttachedAxisIndex
442 //iterate through all series
443 for( sal_Int32 nSeriesIndex = 0; aSeriesIter != aSeriesEnd; ++aSeriesIter, ++nSeriesIndex )
445 VDataSeries* pSeries( *aSeriesIter );
446 if(!pSeries)
447 continue;
449 /* #i70133# ignore points outside of series length in standard area
450 charts. Stacked area charts will use missing points as zeros. In
451 standard charts, pSeriesList contains only one series. */
452 if( m_bArea && (rSeriesList.size() == 1) && (nIndex >= (*aSeriesIter)->getTotalPointCount()) )
453 continue;
455 uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(*aSeriesIter, m_xSeriesTarget);
457 sal_Int32 nAttachedAxisIndex = (*aSeriesIter)->getAttachedAxisIndex();
458 PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
459 if(!pPosHelper)
460 pPosHelper = m_pMainPosHelper.get();
461 PlotterBase::m_pPosHelper = pPosHelper;
463 (*aSeriesIter)->m_fLogicZPos = fLogicZ;
465 //collect data point information (logic coordinates, style ):
466 double fLogicX = (*aSeriesIter)->getXValue(nIndex);
467 if (bDateCategory)
468 fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
469 double fLogicY = (*aSeriesIter)->getYValue(nIndex);
471 if( m_bArea && ( ::rtl::math::isNan(fLogicY) || ::rtl::math::isInf(fLogicY) ) )
473 if( (*aSeriesIter)->getMissingValueTreatment() == ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP )
475 if( rSeriesList.size() == 1 || nSeriesIndex == 0 )
477 fLogicY = pPosHelper->getLogicMinY();
478 if( !pPosHelper->isMathematicalOrientationY() )
479 fLogicY = pPosHelper->getLogicMaxY();
481 else
482 fLogicY = 0.0;
486 if( pPosHelper->isPercentY() && !::rtl::math::approxEqual( aLogicYSumMap[nAttachedAxisIndex], 0.0 ) )
488 fLogicY = fabs( fLogicY )/aLogicYSumMap[nAttachedAxisIndex];
491 if( ::rtl::math::isNan(fLogicX) || ::rtl::math::isInf(fLogicX)
492 || ::rtl::math::isNan(fLogicY) || ::rtl::math::isInf(fLogicY)
493 || ::rtl::math::isNan(fLogicZ) || ::rtl::math::isInf(fLogicZ) )
495 if( (*aSeriesIter)->getMissingValueTreatment() == ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP )
497 drawing::PolyPolygonShape3D& rPolygon = (*aSeriesIter)->m_aPolyPolygonShape3D;
498 sal_Int32& rIndex = (*aSeriesIter)->m_nPolygonIndex;
499 if( 0<= rIndex && rIndex < rPolygon.SequenceX.getLength() )
501 if( rPolygon.SequenceX[ rIndex ].getLength() )
502 rIndex++; //start a new polygon for the next point if the current poly is not empty
505 continue;
508 if( aLogicYForNextSeriesMap.find(nAttachedAxisIndex) == aLogicYForNextSeriesMap.end() )
509 aLogicYForNextSeriesMap[nAttachedAxisIndex] = 0.0;
511 double fLogicValueForLabeDisplay = fLogicY;
513 fLogicY += aLogicYForNextSeriesMap[nAttachedAxisIndex];
514 aLogicYForNextSeriesMap[nAttachedAxisIndex] = fLogicY;
516 bool bIsVisible = pPosHelper->isLogicVisible( fLogicX, fLogicY, fLogicZ );
518 //remind minimal and maximal x values for area 'grounding' points
519 //only for filled area
521 double& rfMinX = (*aSeriesIter)->m_fLogicMinX;
522 if(!nIndex||fLogicX<rfMinX)
523 rfMinX=fLogicX;
524 double& rfMaxX = (*aSeriesIter)->m_fLogicMaxX;
525 if(!nIndex||fLogicX>rfMaxX)
526 rfMaxX=fLogicX;
529 drawing::Position3D aUnscaledLogicPosition( fLogicX, fLogicY, fLogicZ );
530 drawing::Position3D aScaledLogicPosition(aUnscaledLogicPosition);
531 pPosHelper->doLogicScaling( aScaledLogicPosition );
533 //transformation 3) -> 4)
534 drawing::Position3D aScenePosition( pPosHelper->transformLogicToScene( fLogicX,fLogicY,fLogicZ, false ) );
536 //better performance for big data
537 FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries] );
538 pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution );
539 if( !pSeries->isAttributedDataPoint(nIndex)
541 pPosHelper->isSameForGivenResolution( aFormerPoint.m_fX, aFormerPoint.m_fY, aFormerPoint.m_fZ
542 , aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ ) )
544 ++nSkippedPoints;
545 m_bPointsWereSkipped = true;
546 continue;
548 aSeriesFormerPointMap[pSeries] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ);
550 //store point information for series polygon
551 //for area and/or line (symbols only do not need this)
552 if( isValidPosition(aScaledLogicPosition) )
554 AddPointToPoly( (*aSeriesIter)->m_aPolyPolygonShape3D, aScaledLogicPosition, (*aSeriesIter)->m_nPolygonIndex );
556 //prepare clipping for filled net charts
557 if( !bIsVisible && m_bArea )
559 drawing::Position3D aClippedPos(aScaledLogicPosition);
560 pPosHelper->clipScaledLogicValues( 0, &aClippedPos.PositionY, 0 );
561 if( pPosHelper->isLogicVisible( aClippedPos.PositionX, aClippedPos.PositionY, aClippedPos.PositionZ ) )
563 AddPointToPoly( (*aSeriesIter)->m_aPolyPolygonShape3D, aClippedPos, (*aSeriesIter)->m_nPolygonIndex );
564 AddPointToPoly( (*aSeriesIter)->m_aPolyPolygonShape3D, aScaledLogicPosition, (*aSeriesIter)->m_nPolygonIndex );
569 //create a single datapoint if point is visible
570 //apply clipping:
571 if( !bIsVisible )
572 continue;
574 Symbol* pSymbolProperties = (*aSeriesIter)->getSymbolProperties( nIndex );
575 bool bCreateSymbol = pSymbolProperties && (pSymbolProperties->Style != SymbolStyle_NONE);
577 if( !bCreateSymbol && !pSeries->getDataPointLabelIfLabel(nIndex) )
578 continue;
580 //create a group shape for this point and add to the series shape:
581 OUString aPointCID = ObjectIdentifier::createPointCID(
582 (*aSeriesIter)->getPointCID_Stub(), nIndex );
583 uno::Reference< drawing::XShapes > xPointGroupShape_Shapes(
584 createGroupShape(xSeriesGroupShape_Shapes,aPointCID) );
585 uno::Reference<drawing::XShape> xPointGroupShape_Shape =
586 uno::Reference<drawing::XShape>( xPointGroupShape_Shapes, uno::UNO_QUERY );
589 nCreatedPoints++;
591 //create data point
592 drawing::Direction3D aSymbolSize(0,0,0);
593 if( bCreateSymbol )
595 if( pSymbolProperties )
597 if( pSymbolProperties->Style != SymbolStyle_NONE )
599 aSymbolSize.DirectionX = pSymbolProperties->Size.Width;
600 aSymbolSize.DirectionY = pSymbolProperties->Size.Height;
603 if( pSymbolProperties->Style == SymbolStyle_STANDARD )
605 sal_Int32 nSymbol = pSymbolProperties->StandardSymbol;
606 m_pShapeFactory->createSymbol2D( xPointGroupShape_Shapes
607 , aScenePosition, aSymbolSize
608 , nSymbol
609 , pSymbolProperties->BorderColor
610 , pSymbolProperties->FillColor );
612 else if( pSymbolProperties->Style == SymbolStyle_GRAPHIC )
614 m_pShapeFactory->createGraphic2D( xPointGroupShape_Shapes
615 , aScenePosition , aSymbolSize
616 , pSymbolProperties->Graphic );
618 //@todo other symbol styles
622 //create data point label
623 if( (**aSeriesIter).getDataPointLabelIfLabel(nIndex) )
625 LabelAlignment eAlignment = LABEL_ALIGN_TOP;
626 drawing::Position3D aScenePosition3D( aScenePosition.PositionX
627 , aScenePosition.PositionY
628 , aScenePosition.PositionZ+this->getTransformedDepth() );
630 sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() );
632 switch(nLabelPlacement)
634 case ::com::sun::star::chart::DataLabelPlacement::TOP:
635 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
636 eAlignment = LABEL_ALIGN_TOP;
637 break;
638 case ::com::sun::star::chart::DataLabelPlacement::BOTTOM:
639 aScenePosition3D.PositionY += (aSymbolSize.DirectionY/2+1);
640 eAlignment = LABEL_ALIGN_BOTTOM;
641 break;
642 case ::com::sun::star::chart::DataLabelPlacement::LEFT:
643 aScenePosition3D.PositionX -= (aSymbolSize.DirectionX/2+1);
644 eAlignment = LABEL_ALIGN_LEFT;
645 break;
646 case ::com::sun::star::chart::DataLabelPlacement::RIGHT:
647 aScenePosition3D.PositionX += (aSymbolSize.DirectionX/2+1);
648 eAlignment = LABEL_ALIGN_RIGHT;
649 break;
650 case ::com::sun::star::chart::DataLabelPlacement::CENTER:
651 eAlignment = LABEL_ALIGN_CENTER;
652 //todo implement this different for area charts
653 break;
654 default:
655 OSL_FAIL("this label alignment is not implemented yet");
656 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
657 eAlignment = LABEL_ALIGN_TOP;
658 break;
661 awt::Point aScreenPosition2D;//get the screen position for the labels
662 sal_Int32 nOffset = 100; //todo maybe calculate this font height dependent
663 if( nLabelPlacement == ::com::sun::star::chart::DataLabelPlacement::OUTSIDE )
665 PolarPlottingPositionHelper* pPolarPosHelper = dynamic_cast<PolarPlottingPositionHelper*>(pPosHelper);
666 if( pPolarPosHelper )
668 PolarLabelPositionHelper aPolarLabelPositionHelper(pPolarPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory);
669 aScreenPosition2D = awt::Point( aPolarLabelPositionHelper.getLabelScreenPositionAndAlignmentForLogicValues(
670 eAlignment, fLogicX, fLogicY, fLogicZ, nOffset ));
673 else
675 if(LABEL_ALIGN_CENTER==eAlignment )
676 nOffset = 0;
677 aScreenPosition2D = awt::Point( LabelPositionHelper(pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory)
678 .transformSceneToScreenPosition( aScenePosition3D ) );
681 createDataLabel( m_xTextTarget, **aSeriesIter, nIndex
682 , fLogicValueForLabeDisplay
683 , aLogicYSumMap[nAttachedAxisIndex], aScreenPosition2D, eAlignment, nOffset );
687 //remove PointGroupShape if empty
688 if(!xPointGroupShape_Shapes->getCount())
689 xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shape);
691 }//next series in x slot (next y slot)
692 }//next x slot
693 }//next z slot
694 }//next category
696 impl_createSeriesShapes();
700 } //namespace chart
702 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */