Line data Source code
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 "AreaChart.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 "Splines.hxx"
28 : #include "ChartTypeHelper.hxx"
29 : #include "LabelPositionHelper.hxx"
30 : #include "Clipping.hxx"
31 : #include "Stripe.hxx"
32 : #include "DateHelper.hxx"
33 : #include <unonames.hxx>
34 :
35 : #include <com/sun/star/chart2/Symbol.hpp>
36 : #include <com/sun/star/chart/DataLabelPlacement.hpp>
37 : #include <com/sun/star/chart/MissingValueTreatment.hpp>
38 :
39 : #include <editeng/unoprnms.hxx>
40 : #include <rtl/math.hxx>
41 :
42 : #include <com/sun/star/drawing/DoubleSequence.hpp>
43 : #include <com/sun/star/drawing/NormalsKind.hpp>
44 : #include <com/sun/star/lang/XServiceName.hpp>
45 :
46 : namespace chart
47 : {
48 : using namespace ::com::sun::star;
49 : using namespace ::rtl::math;
50 : using namespace ::com::sun::star::chart2;
51 :
52 125 : AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel
53 : , sal_Int32 nDimensionCount
54 : , bool bCategoryXAxis
55 : , bool bNoArea
56 : )
57 : : VSeriesPlotter( xChartTypeModel, nDimensionCount, bCategoryXAxis )
58 0 : , m_pMainPosHelper(new PlottingPositionHelper())
59 125 : , m_bArea(!bNoArea)
60 : , m_bLine(bNoArea)
61 125 : , m_bSymbol( ChartTypeHelper::isSupportingSymbolProperties(xChartTypeModel,nDimensionCount) )
62 : , m_eCurveStyle(CurveStyle_LINES)
63 : , m_nCurveResolution(20)
64 : , m_nSplineOrder(3)
65 : , m_xSeriesTarget(0)
66 : , m_xErrorBarTarget(0)
67 : , m_xTextTarget(0)
68 375 : , m_xRegressionCurveEquationTarget(0)
69 : {
70 125 : m_pMainPosHelper->AllowShiftXAxisPos(true);
71 125 : m_pMainPosHelper->AllowShiftZAxisPos(true);
72 :
73 125 : PlotterBase::m_pPosHelper = m_pMainPosHelper;
74 125 : VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper;
75 :
76 : try
77 : {
78 125 : if( m_xChartTypeModelProps.is() )
79 : {
80 125 : m_xChartTypeModelProps->getPropertyValue(CHART_UNONAME_CURVE_STYLE) >>= m_eCurveStyle;
81 125 : m_xChartTypeModelProps->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) >>= m_nCurveResolution;
82 125 : m_xChartTypeModelProps->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) >>= m_nSplineOrder;
83 : }
84 : }
85 0 : catch( uno::Exception& e )
86 : {
87 : //the above properties are not supported by all charttypes supported by this class (e.g. area or net chart)
88 : //in that cases this exception is ok
89 0 : e.Context.is();//to have debug information without compilation warnings
90 : }
91 125 : }
92 :
93 375 : AreaChart::~AreaChart()
94 : {
95 125 : delete m_pMainPosHelper;
96 250 : }
97 :
98 278 : double AreaChart::getMaximumX()
99 : {
100 278 : double fMax = VSeriesPlotter::getMaximumX();
101 278 : return fMax;
102 : }
103 :
104 574 : bool AreaChart::isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex )
105 : {
106 574 : return VSeriesPlotter::isExpandIfValuesCloseToBorder( nDimensionIndex );
107 : }
108 :
109 1028 : bool AreaChart::isSeparateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex*/ )
110 : {
111 : // no separate stacking in all types of line/area charts
112 1028 : return false;
113 : }
114 :
115 150 : LegendSymbolStyle AreaChart::getLegendSymbolStyle()
116 : {
117 150 : if( m_bArea || m_nDimension == 3 )
118 0 : return LegendSymbolStyle_BOX;
119 150 : return LegendSymbolStyle_LINE;
120 : }
121 :
122 86 : uno::Any AreaChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex )
123 : {
124 86 : uno::Any aRet;
125 :
126 86 : Symbol* pSymbolProperties = rSeries.getSymbolProperties( nPointIndex );
127 86 : if( pSymbolProperties )
128 : {
129 86 : aRet = uno::makeAny(*pSymbolProperties);
130 : }
131 :
132 86 : return aRet;
133 : }
134 :
135 125 : drawing::Direction3D AreaChart::getPreferredDiagramAspectRatio() const
136 : {
137 125 : drawing::Direction3D aRet(1,-1,1);
138 125 : if( m_nDimension == 2 )
139 108 : aRet = drawing::Direction3D(-1,-1,-1);
140 17 : else if (m_pPosHelper)
141 : {
142 17 : drawing::Direction3D aScale( m_pPosHelper->getScaledLogicWidth() );
143 17 : aRet.DirectionZ = aScale.DirectionZ*0.2;
144 17 : if(aRet.DirectionZ>1.0)
145 0 : aRet.DirectionZ=1.0;
146 17 : if(aRet.DirectionZ>10)
147 0 : aRet.DirectionZ=10;
148 : }
149 125 : return aRet;
150 : }
151 :
152 0 : bool AreaChart::keepAspectRatio() const
153 : {
154 0 : if( m_nDimension == 2 )
155 : {
156 0 : if( !m_bSymbol )
157 0 : return false;
158 : }
159 0 : return true;
160 : }
161 :
162 321 : void AreaChart::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot )
163 : {
164 321 : if( m_bArea && pSeries )
165 : {
166 0 : sal_Int32 nMissingValueTreatment = pSeries->getMissingValueTreatment();
167 0 : if( nMissingValueTreatment == ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP )
168 0 : pSeries->setMissingValueTreatment( ::com::sun::star::chart::MissingValueTreatment::USE_ZERO );
169 : }
170 321 : if( m_nDimension == 3 && !m_bCategoryXAxis )
171 : {
172 : //3D xy always deep
173 : OSL_ENSURE( zSlot==-1,"3D xy charts should be deep stacked in model also" );
174 0 : zSlot=-1;
175 0 : xSlot=0;
176 0 : ySlot=0;
177 : }
178 321 : VSeriesPlotter::addSeries( pSeries, zSlot, xSlot, ySlot );
179 321 : }
180 :
181 0 : void lcl_removeDuplicatePoints( drawing::PolyPolygonShape3D& rPolyPoly, PlottingPositionHelper& rPosHelper )
182 : {
183 0 : sal_Int32 nPolyCount = rPolyPoly.SequenceX.getLength();
184 0 : if(!nPolyCount)
185 0 : return;
186 :
187 0 : drawing::PolyPolygonShape3D aTmp;
188 0 : aTmp.SequenceX.realloc(nPolyCount);
189 0 : aTmp.SequenceY.realloc(nPolyCount);
190 0 : aTmp.SequenceZ.realloc(nPolyCount);
191 :
192 0 : for( sal_Int32 nPolygonIndex = 0; nPolygonIndex<nPolyCount; nPolygonIndex++ )
193 : {
194 0 : drawing::DoubleSequence* pOuterSourceX = &rPolyPoly.SequenceX.getArray()[nPolygonIndex];
195 0 : drawing::DoubleSequence* pOuterSourceY = &rPolyPoly.SequenceY.getArray()[nPolygonIndex];
196 0 : drawing::DoubleSequence* pOuterSourceZ = &rPolyPoly.SequenceZ.getArray()[nPolygonIndex];
197 :
198 0 : drawing::DoubleSequence* pOuterTargetX = &aTmp.SequenceX.getArray()[nPolygonIndex];
199 0 : drawing::DoubleSequence* pOuterTargetY = &aTmp.SequenceY.getArray()[nPolygonIndex];
200 0 : drawing::DoubleSequence* pOuterTargetZ = &aTmp.SequenceZ.getArray()[nPolygonIndex];
201 :
202 0 : sal_Int32 nPointCount = pOuterSourceX->getLength();
203 0 : if( !nPointCount )
204 0 : continue;
205 :
206 0 : pOuterTargetX->realloc(nPointCount);
207 0 : pOuterTargetY->realloc(nPointCount);
208 0 : pOuterTargetZ->realloc(nPointCount);
209 :
210 0 : double* pSourceX = pOuterSourceX->getArray();
211 0 : double* pSourceY = pOuterSourceY->getArray();
212 0 : double* pSourceZ = pOuterSourceZ->getArray();
213 :
214 0 : double* pTargetX = pOuterTargetX->getArray();
215 0 : double* pTargetY = pOuterTargetY->getArray();
216 0 : double* pTargetZ = pOuterTargetZ->getArray();
217 :
218 : //copy first point
219 0 : *pTargetX=*pSourceX++;
220 0 : *pTargetY=*pSourceY++;
221 0 : *pTargetZ=*pSourceZ++;
222 0 : sal_Int32 nTargetPointCount=1;
223 :
224 0 : for( sal_Int32 nSource=1; nSource<nPointCount; nSource++ )
225 : {
226 0 : if( !rPosHelper.isSameForGivenResolution( *pTargetX, *pTargetY, *pTargetZ
227 0 : , *pSourceX, *pSourceY, *pSourceZ ) )
228 : {
229 0 : pTargetX++; pTargetY++; pTargetZ++;
230 0 : *pTargetX=*pSourceX;
231 0 : *pTargetY=*pSourceY;
232 0 : *pTargetZ=*pSourceZ;
233 0 : nTargetPointCount++;
234 : }
235 0 : pSourceX++; pSourceY++; pSourceZ++;
236 : }
237 :
238 : //free unused space
239 0 : if( nTargetPointCount<nPointCount )
240 : {
241 0 : pOuterTargetX->realloc(nTargetPointCount);
242 0 : pOuterTargetY->realloc(nTargetPointCount);
243 0 : pOuterTargetZ->realloc(nTargetPointCount);
244 : }
245 :
246 0 : pOuterSourceX->realloc(0);
247 0 : pOuterSourceY->realloc(0);
248 0 : pOuterSourceZ->realloc(0);
249 : }
250 :
251 : //free space
252 0 : rPolyPoly.SequenceX.realloc(nPolyCount);
253 0 : rPolyPoly.SequenceY.realloc(nPolyCount);
254 0 : rPolyPoly.SequenceZ.realloc(nPolyCount);
255 :
256 0 : rPolyPoly=aTmp;
257 : }
258 :
259 0 : bool AreaChart::create_stepped_line( drawing::PolyPolygonShape3D aStartPoly, chart2::CurveStyle eCurveStyle, PlottingPositionHelper* pPosHelper, drawing::PolyPolygonShape3D &aPoly )
260 : {
261 0 : drawing::PolyPolygonShape3D aSteppedPoly;
262 :
263 0 : aSteppedPoly.SequenceX.realloc(0);
264 0 : aSteppedPoly.SequenceY.realloc(0);
265 0 : aSteppedPoly.SequenceZ.realloc(0);
266 :
267 0 : sal_uInt32 nOuterCount = aStartPoly.SequenceX.getLength();
268 0 : if ( !nOuterCount )
269 0 : return false;
270 :
271 0 : aSteppedPoly.SequenceX.realloc(nOuterCount);
272 0 : aSteppedPoly.SequenceY.realloc(nOuterCount);
273 0 : aSteppedPoly.SequenceZ.realloc(nOuterCount);
274 0 : for( sal_uInt32 nOuter = 0; nOuter < nOuterCount; ++nOuter )
275 : {
276 0 : if( aStartPoly.SequenceX[nOuter].getLength() <= 1 )
277 0 : continue; //we need at least two points
278 :
279 0 : sal_uInt32 nMaxIndexPoints = aStartPoly.SequenceX[nOuter].getLength()-1; // is >1
280 0 : sal_uInt32 nNewIndexPoints = 0;
281 0 : if ( CurveStyle_STEP_START==eCurveStyle || CurveStyle_STEP_END==eCurveStyle)
282 0 : nNewIndexPoints = nMaxIndexPoints * 2 + 1;
283 : else
284 0 : nNewIndexPoints = nMaxIndexPoints * 3 + 1;
285 :
286 0 : const double* pOldX = aStartPoly.SequenceX[nOuter].getConstArray();
287 0 : const double* pOldY = aStartPoly.SequenceY[nOuter].getConstArray();
288 0 : const double* pOldZ = aStartPoly.SequenceZ[nOuter].getConstArray();
289 :
290 0 : aSteppedPoly.SequenceX[nOuter].realloc( nNewIndexPoints );
291 0 : aSteppedPoly.SequenceY[nOuter].realloc( nNewIndexPoints );
292 0 : aSteppedPoly.SequenceZ[nOuter].realloc( nNewIndexPoints );
293 :
294 0 : double* pNewX = aSteppedPoly.SequenceX[nOuter].getArray();
295 0 : double* pNewY = aSteppedPoly.SequenceY[nOuter].getArray();
296 0 : double* pNewZ = aSteppedPoly.SequenceZ[nOuter].getArray();
297 :
298 0 : pNewX[0] = pOldX[0];
299 0 : pNewY[0] = pOldY[0];
300 0 : pNewZ[0] = pOldZ[0];
301 0 : for( sal_uInt32 oi = 0; oi < nMaxIndexPoints; oi++ )
302 : {
303 0 : switch ( eCurveStyle )
304 : {
305 : case CurveStyle_STEP_START:
306 : /** O
307 : |
308 : |
309 : |
310 : O-----+
311 : */
312 : // create the intermediate point
313 0 : pNewX[1+oi*2] = pOldX[oi+1];
314 0 : pNewY[1+oi*2] = pOldY[oi];
315 0 : pNewZ[1+oi*2] = pOldZ[oi];
316 : // and now the normal one
317 0 : pNewX[1+oi*2+1] = pOldX[oi+1];
318 0 : pNewY[1+oi*2+1] = pOldY[oi+1];
319 0 : pNewZ[1+oi*2+1] = pOldZ[oi+1];
320 0 : break;
321 : case CurveStyle_STEP_END:
322 : /** +------O
323 : |
324 : |
325 : |
326 : O
327 : */
328 : // create the intermediate point
329 0 : pNewX[1+oi*2] = pOldX[oi];
330 0 : pNewY[1+oi*2] = pOldY[oi+1];
331 0 : pNewZ[1+oi*2] = pOldZ[oi];
332 : // and now the normal one
333 0 : pNewX[1+oi*2+1] = pOldX[oi+1];
334 0 : pNewY[1+oi*2+1] = pOldY[oi+1];
335 0 : pNewZ[1+oi*2+1] = pOldZ[oi+1];
336 0 : break;
337 : case CurveStyle_STEP_CENTER_X:
338 : /** +--O
339 : |
340 : |
341 : |
342 : O--+
343 : */
344 : // create the first intermediate point
345 0 : pNewX[1+oi*3] = (pOldX[oi]+pOldX[oi+1])/2;
346 0 : pNewY[1+oi*3] = pOldY[oi];
347 0 : pNewZ[1+oi*3] = pOldZ[oi];
348 : // create the second intermediate point
349 0 : pNewX[1+oi*3+1] = (pOldX[oi]+pOldX[oi+1])/2;
350 0 : pNewY[1+oi*3+1] = pOldY[oi+1];
351 0 : pNewZ[1+oi*3+1] = pOldZ[oi];
352 : // and now the normal one
353 0 : pNewX[1+oi*3+2] = pOldX[oi+1];
354 0 : pNewY[1+oi*3+2] = pOldY[oi+1];
355 0 : pNewZ[1+oi*3+2] = pOldZ[oi+1];
356 0 : break;
357 : case CurveStyle_STEP_CENTER_Y:
358 : /** O
359 : |
360 : +-----+
361 : |
362 : O
363 : */
364 : // create the first intermediate point
365 0 : pNewX[1+oi*3] = pOldX[oi];
366 0 : pNewY[1+oi*3] = (pOldY[oi]+pOldY[oi+1])/2;
367 0 : pNewZ[1+oi*3] = pOldZ[oi];
368 : // create the second intermediate point
369 0 : pNewX[1+oi*3+1] = pOldX[oi+1];
370 0 : pNewY[1+oi*3+1] = (pOldY[oi]+pOldY[oi+1])/2;
371 0 : pNewZ[1+oi*3+1] = pOldZ[oi];
372 : // and now the normal one
373 0 : pNewX[1+oi*3+2] = pOldX[oi+1];
374 0 : pNewY[1+oi*3+2] = pOldY[oi+1];
375 0 : pNewZ[1+oi*3+2] = pOldZ[oi+1];
376 0 : break;
377 : default:
378 : // this should never be executed
379 : OSL_FAIL("Unknown curvestyle in AreaChart::create_stepped_line");
380 : }
381 : }
382 : }
383 0 : Clipping::clipPolygonAtRectangle( aSteppedPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
384 :
385 0 : return true;
386 : }
387 :
388 321 : bool AreaChart::impl_createLine( VDataSeries* pSeries
389 : , drawing::PolyPolygonShape3D* pSeriesPoly
390 : , PlottingPositionHelper* pPosHelper )
391 : {
392 : //return true if a line was created successfully
393 321 : uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
394 :
395 642 : drawing::PolyPolygonShape3D aPoly;
396 321 : if(CurveStyle_CUBIC_SPLINES==m_eCurveStyle)
397 : {
398 0 : drawing::PolyPolygonShape3D aSplinePoly;
399 0 : SplineCalculater::CalculateCubicSplines( *pSeriesPoly, aSplinePoly, m_nCurveResolution );
400 0 : lcl_removeDuplicatePoints( aSplinePoly, *pPosHelper );
401 0 : Clipping::clipPolygonAtRectangle( aSplinePoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
402 : }
403 321 : else if(CurveStyle_B_SPLINES==m_eCurveStyle)
404 : {
405 0 : drawing::PolyPolygonShape3D aSplinePoly;
406 0 : SplineCalculater::CalculateBSplines( *pSeriesPoly, aSplinePoly, m_nCurveResolution, m_nSplineOrder );
407 0 : lcl_removeDuplicatePoints( aSplinePoly, *pPosHelper );
408 0 : Clipping::clipPolygonAtRectangle( aSplinePoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
409 : }
410 642 : else if (CurveStyle_STEP_START==m_eCurveStyle ||
411 642 : CurveStyle_STEP_END==m_eCurveStyle ||
412 642 : CurveStyle_STEP_CENTER_Y==m_eCurveStyle ||
413 321 : CurveStyle_STEP_CENTER_X==m_eCurveStyle
414 : )
415 : {
416 0 : if (!create_stepped_line(*pSeriesPoly, m_eCurveStyle, pPosHelper, aPoly))
417 : {
418 0 : return false;
419 : }
420 : }
421 : else
422 : { // default to creating a straight line
423 : SAL_WARN_IF(CurveStyle_LINES != m_eCurveStyle, "chart2.areachart", "Unknown curve style");
424 321 : Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
425 : }
426 :
427 321 : if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly))
428 0 : return false;
429 :
430 : //transformation 3) -> 4)
431 321 : pPosHelper->transformScaledLogicToScene( aPoly );
432 :
433 : //create line:
434 642 : uno::Reference< drawing::XShape > xShape(NULL);
435 321 : if(m_nDimension==3)
436 : {
437 51 : double fDepth = this->getTransformedDepth();
438 51 : sal_Int32 nPolyCount = aPoly.SequenceX.getLength();
439 102 : for(sal_Int32 nPoly=0;nPoly<nPolyCount;nPoly++)
440 : {
441 51 : sal_Int32 nPointCount = aPoly.SequenceX[nPoly].getLength();
442 663 : for(sal_Int32 nPoint=0;nPoint<nPointCount-1;nPoint++)
443 : {
444 612 : drawing::Position3D aPoint1, aPoint2;
445 612 : aPoint1.PositionX = aPoly.SequenceX[nPoly][nPoint+1];
446 612 : aPoint1.PositionY = aPoly.SequenceY[nPoly][nPoint+1];
447 612 : aPoint1.PositionZ = aPoly.SequenceZ[nPoly][nPoint+1];
448 :
449 612 : aPoint2.PositionX = aPoly.SequenceX[nPoly][nPoint];
450 612 : aPoint2.PositionY = aPoly.SequenceY[nPoly][nPoint];
451 612 : aPoint2.PositionZ = aPoly.SequenceZ[nPoly][nPoint];
452 :
453 612 : Stripe aStripe( aPoint1, aPoint2, fDepth );
454 :
455 : m_pShapeFactory->createStripe(xSeriesGroupShape_Shapes
456 : , Stripe( aPoint1, aPoint2, fDepth )
457 612 : , pSeries->getPropertiesOfSeries(), PropertyMapper::getPropertyNameMapForFilledSeriesProperties(), true, 1 );
458 : }
459 : }
460 : }
461 : else //m_nDimension!=3
462 : {
463 810 : xShape = m_pShapeFactory->createLine2D( xSeriesGroupShape_Shapes
464 540 : , PolyToPointSequence( aPoly ) );
465 : this->setMappedProperties( xShape
466 : , pSeries->getPropertiesOfSeries()
467 270 : , PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
468 : //because of this name this line will be used for marking
469 270 : ::chart::AbstractShapeFactory::setShapeName(xShape, "MarkHandles");
470 : }
471 642 : return true;
472 : }
473 :
474 0 : bool AreaChart::impl_createArea( VDataSeries* pSeries
475 : , drawing::PolyPolygonShape3D* pSeriesPoly
476 : , drawing::PolyPolygonShape3D* pPreviousSeriesPoly
477 : , PlottingPositionHelper* pPosHelper )
478 : {
479 : //return true if an area was created successfully
480 :
481 0 : uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
482 0 : double zValue = pSeries->m_fLogicZPos;
483 :
484 0 : drawing::PolyPolygonShape3D aPoly( *pSeriesPoly );
485 : //add second part to the polygon (grounding points or previous series points)
486 0 : if(!pPreviousSeriesPoly)
487 : {
488 0 : double fMinX = pSeries->m_fLogicMinX;
489 0 : double fMaxX = pSeries->m_fLogicMaxX;
490 0 : double fY = pPosHelper->getBaseValueY();//logic grounding
491 0 : if( m_nDimension==3 )
492 0 : fY = pPosHelper->getLogicMinY();
493 :
494 : //clip to scale
495 0 : if(fMaxX<pPosHelper->getLogicMinX() || fMinX>pPosHelper->getLogicMaxX())
496 0 : return false;//no visible shape needed
497 0 : pPosHelper->clipLogicValues( &fMinX, &fY, 0 );
498 0 : pPosHelper->clipLogicValues( &fMaxX, 0, 0 );
499 :
500 : //apply scaling
501 : {
502 0 : pPosHelper->doLogicScaling( &fMinX, &fY, &zValue );
503 0 : pPosHelper->doLogicScaling( &fMaxX, 0, 0 );
504 : }
505 :
506 0 : AddPointToPoly( aPoly, drawing::Position3D( fMaxX,fY,zValue) );
507 0 : AddPointToPoly( aPoly, drawing::Position3D( fMinX,fY,zValue) );
508 : }
509 : else
510 : {
511 0 : appendPoly( aPoly, *pPreviousSeriesPoly );
512 : }
513 0 : AbstractShapeFactory::closePolygon(aPoly);
514 :
515 : //apply clipping
516 : {
517 0 : drawing::PolyPolygonShape3D aClippedPoly;
518 0 : Clipping::clipPolygonAtRectangle( aPoly, pPosHelper->getScaledLogicClipDoubleRect(), aClippedPoly, false );
519 0 : AbstractShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping
520 0 : aPoly = aClippedPoly;
521 : }
522 :
523 0 : if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly))
524 0 : return false;
525 :
526 : //transformation 3) -> 4)
527 0 : pPosHelper->transformScaledLogicToScene( aPoly );
528 :
529 : //create area:
530 0 : uno::Reference< drawing::XShape > xShape(NULL);
531 0 : if(m_nDimension==3)
532 : {
533 0 : xShape = m_pShapeFactory->createArea3D( xSeriesGroupShape_Shapes
534 0 : , aPoly, this->getTransformedDepth() );
535 : }
536 : else //m_nDimension!=3
537 : {
538 0 : xShape = m_pShapeFactory->createArea2D( xSeriesGroupShape_Shapes
539 0 : , aPoly );
540 : }
541 : this->setMappedProperties( xShape
542 : , pSeries->getPropertiesOfSeries()
543 0 : , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
544 : //because of this name this line will be used for marking
545 0 : ::chart::AbstractShapeFactory::setShapeName(xShape, "MarkHandles");
546 0 : return true;
547 : }
548 :
549 125 : void AreaChart::impl_createSeriesShapes()
550 : {
551 : //the polygon shapes for each series need to be created before
552 :
553 : //iterate through all series again to create the series shapes
554 125 : ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin();
555 125 : const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end();
556 328 : for( sal_Int32 nZ=1; aZSlotIter != aZSlotEnd; ++aZSlotIter, ++nZ )
557 : {
558 203 : ::std::vector< VDataSeriesGroup >::iterator aXSlotIter = aZSlotIter->begin();
559 203 : const ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end();
560 :
561 586 : for( ; aXSlotIter != aXSlotEnd; ++aXSlotIter )
562 : {
563 383 : ::std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector);
564 :
565 383 : ::std::vector< VDataSeries* >::const_iterator aSeriesIter = pSeriesList->begin();
566 383 : const ::std::vector< VDataSeries* >::const_iterator aSeriesEnd = pSeriesList->end();
567 :
568 383 : std::map< sal_Int32, drawing::PolyPolygonShape3D* > aPreviousSeriesPolyMap;//a PreviousSeriesPoly for each different nAttachedAxisIndex
569 383 : drawing::PolyPolygonShape3D* pSeriesPoly = NULL;
570 :
571 : //iterate through all series
572 704 : for( ; aSeriesIter != aSeriesEnd; ++aSeriesIter )
573 : {
574 321 : sal_Int32 nAttachedAxisIndex = (*aSeriesIter)->getAttachedAxisIndex();
575 321 : PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
576 321 : if(!pPosHelper)
577 0 : pPosHelper = m_pMainPosHelper;
578 321 : PlotterBase::m_pPosHelper = pPosHelper;
579 :
580 321 : createRegressionCurvesShapes( **aSeriesIter, m_xErrorBarTarget, m_xRegressionCurveEquationTarget,
581 642 : m_pPosHelper->maySkipPointsInRegressionCalculation());
582 :
583 321 : pSeriesPoly = &(*aSeriesIter)->m_aPolyPolygonShape3D;
584 321 : if( m_bArea )
585 : {
586 0 : if( !impl_createArea( *aSeriesIter, pSeriesPoly, aPreviousSeriesPolyMap[nAttachedAxisIndex], pPosHelper ) )
587 0 : continue;
588 : }
589 321 : if( m_bLine )
590 : {
591 321 : if( !impl_createLine( *aSeriesIter, pSeriesPoly, pPosHelper ) )
592 0 : continue;
593 : }
594 321 : aPreviousSeriesPolyMap[nAttachedAxisIndex] = pSeriesPoly;
595 : }//next series in x slot (next y slot)
596 383 : }//next x slot
597 : }//next z slot
598 125 : }
599 :
600 : namespace
601 : {
602 :
603 50 : void lcl_reorderSeries( ::std::vector< ::std::vector< VDataSeriesGroup > >& rZSlots )
604 : {
605 50 : ::std::vector< ::std::vector< VDataSeriesGroup > > aRet( rZSlots.size() );
606 :
607 50 : ::std::vector< ::std::vector< VDataSeriesGroup > >::reverse_iterator aZIt( rZSlots.rbegin() );
608 50 : ::std::vector< ::std::vector< VDataSeriesGroup > >::reverse_iterator aZEnd( rZSlots.rend() );
609 100 : for( ; aZIt != aZEnd; ++aZIt )
610 : {
611 50 : ::std::vector< VDataSeriesGroup > aXSlot( aZIt->size() );
612 :
613 50 : ::std::vector< VDataSeriesGroup >::reverse_iterator aXIt( aZIt->rbegin() );
614 50 : ::std::vector< VDataSeriesGroup >::reverse_iterator aXEnd( aZIt->rend() );
615 128 : for( ; aXIt != aXEnd; ++aXIt )
616 78 : aXSlot.push_back(*aXIt);
617 :
618 50 : aRet.push_back(aXSlot);
619 50 : }
620 :
621 50 : rZSlots.clear();
622 50 : rZSlots = aRet;
623 50 : }
624 :
625 : }//anonymous namespace
626 :
627 : //better performance for big data
628 : struct FormerPoint
629 : {
630 2615 : FormerPoint( double fX, double fY, double fZ )
631 2615 : : m_fX(fX), m_fY(fY), m_fZ(fZ)
632 2615 : {}
633 321 : FormerPoint()
634 : {
635 321 : ::rtl::math::setNan( &m_fX );
636 321 : ::rtl::math::setNan( &m_fY );
637 321 : ::rtl::math::setNan( &m_fZ );
638 321 : }
639 :
640 : double m_fX;
641 : double m_fY;
642 : double m_fZ;
643 : };
644 :
645 125 : void AreaChart::createShapes()
646 : {
647 125 : if( m_aZSlots.begin() == m_aZSlots.end() ) //no series
648 0 : return;
649 :
650 125 : if( m_nDimension == 2 && ( m_bArea || !m_bCategoryXAxis ) )
651 50 : lcl_reorderSeries( m_aZSlots );
652 :
653 : OSL_ENSURE(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"AreaChart is not proper initialized");
654 125 : if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
655 0 : return;
656 :
657 : //the text labels should be always on top of the other series shapes
658 : //for area chart the error bars should be always on top of the other series shapes
659 :
660 : //therefore create an own group for the texts and the error bars to move them to front
661 : //(because the text group is created after the series group the texts are displayed on top)
662 125 : m_xSeriesTarget = createGroupShape( m_xLogicTarget,OUString() );
663 125 : if( m_bArea )
664 0 : m_xErrorBarTarget = createGroupShape( m_xLogicTarget,OUString() );
665 : else
666 125 : m_xErrorBarTarget = m_xSeriesTarget;
667 125 : m_xTextTarget = m_pShapeFactory->createGroup2D( m_xFinalTarget,OUString() );
668 125 : m_xRegressionCurveEquationTarget = m_pShapeFactory->createGroup2D( m_xFinalTarget,OUString() );
669 :
670 : //check necessary here that different Y axis can not be stacked in the same group? ... hm?
671 :
672 : //update/create information for current group
673 125 : double fLogicZ = 1.0;//as defined
674 :
675 125 : sal_Int32 nStartIndex = 0; // inclusive ;..todo get somehow from x scale
676 125 : sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
677 125 : if(nEndIndex<=0)
678 0 : nEndIndex=1;
679 :
680 : //better performance for big data
681 125 : std::map< VDataSeries*, FormerPoint > aSeriesFormerPointMap;
682 125 : m_bPointsWereSkipped = false;
683 125 : sal_Int32 nSkippedPoints = 0;
684 125 : sal_Int32 nCreatedPoints = 0;
685 :
686 125 : bool bDateCategory = (m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis());
687 :
688 125 : ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin();
689 125 : const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end();
690 :
691 250 : std::vector<std::map< sal_Int32, double > > aLogicYSumMapByX(nEndIndex);//one for each different nAttachedAxisIndex
692 328 : for( ; aZSlotIter != aZSlotEnd; ++aZSlotIter )
693 : {
694 203 : ::std::vector< VDataSeriesGroup >::iterator aXSlotIter = aZSlotIter->begin();
695 203 : const ::std::vector< VDataSeriesGroup >::iterator aXSlotEnd = aZSlotIter->end();
696 :
697 : //iterate through all x slots in this category to get 100percent sum
698 586 : for( ; aXSlotIter != aXSlotEnd; ++aXSlotIter )
699 : {
700 383 : std::vector<VDataSeries*>& rSeriesList = aXSlotIter->m_aSeriesVector;
701 383 : std::vector<VDataSeries*>::iterator aSeriesIter = rSeriesList.begin();
702 383 : std::vector<VDataSeries*>::iterator aSeriesEnd = rSeriesList.end();
703 :
704 704 : for( ; aSeriesIter != aSeriesEnd; ++aSeriesIter )
705 : {
706 321 : VDataSeries* pSeries( *aSeriesIter );
707 321 : if(!pSeries)
708 0 : continue;
709 :
710 321 : if (bDateCategory)
711 0 : pSeries->doSortByXValues();
712 :
713 2938 : for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
714 : {
715 2617 : std::map< sal_Int32, double >& rLogicYSumMap = aLogicYSumMapByX[nIndex];
716 2617 : sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
717 2617 : if( rLogicYSumMap.find(nAttachedAxisIndex)==rLogicYSumMap.end() )
718 995 : rLogicYSumMap[nAttachedAxisIndex]=0.0;
719 :
720 2617 : PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
721 2617 : if(!pPosHelper)
722 0 : pPosHelper = m_pMainPosHelper;
723 2617 : PlotterBase::m_pPosHelper = pPosHelper;
724 :
725 2617 : double fAdd = pSeries->getYValue( nIndex );
726 2617 : if( !::rtl::math::isNan(fAdd) && !::rtl::math::isInf(fAdd) )
727 2615 : rLogicYSumMap[nAttachedAxisIndex] += fabs( fAdd );
728 : }
729 : }
730 : }
731 : }
732 :
733 125 : aZSlotIter = m_aZSlots.begin();
734 328 : for( sal_Int32 nZ=1; aZSlotIter != aZSlotEnd; ++aZSlotIter, ++nZ )
735 : {
736 203 : ::std::vector< VDataSeriesGroup >::const_iterator aXSlotIter = aZSlotIter->begin();
737 203 : ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end();
738 :
739 : //for the area chart there should be at most one x slot (no side by side stacking available)
740 : //attention different: xSlots are always interpreted as independent areas one behind the other: @todo this doesn't work why not???
741 586 : for( sal_Int32 nX=0; aXSlotIter != aXSlotEnd; ++aXSlotIter, ++nX )
742 : {
743 383 : const std::vector<VDataSeries*>& rSeriesList = aXSlotIter->m_aSeriesVector;
744 383 : std::vector<VDataSeries*>::const_iterator aSeriesIter = rSeriesList.begin();
745 383 : const std::vector<VDataSeries*>::const_iterator aSeriesEnd = rSeriesList.end();
746 :
747 383 : std::vector<std::map< sal_Int32, double > > aLogicYForNextSeriesMapByX(nEndIndex); //one for each different nAttachedAxisIndex
748 : //iterate through all series
749 704 : for( sal_Int32 nSeriesIndex = 0; aSeriesIter != aSeriesEnd; ++aSeriesIter, ++nSeriesIndex )
750 : {
751 321 : VDataSeries* pSeries( *aSeriesIter );
752 321 : if(!pSeries)
753 0 : continue;
754 :
755 321 : uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(*aSeriesIter, m_xSeriesTarget);
756 :
757 321 : sal_Int32 nAttachedAxisIndex = (*aSeriesIter)->getAttachedAxisIndex();
758 321 : PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
759 321 : if(!pPosHelper)
760 0 : pPosHelper = m_pMainPosHelper;
761 321 : PlotterBase::m_pPosHelper = pPosHelper;
762 :
763 321 : if(m_nDimension==3)
764 51 : fLogicZ = nZ+0.5;
765 321 : (*aSeriesIter)->m_fLogicZPos = fLogicZ;
766 :
767 2938 : for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
768 : {
769 :
770 : /* #i70133# ignore points outside of series length in standard area
771 : charts. Stacked area charts will use missing points as zeros. In
772 : standard charts, pSeriesList contains only one series. */
773 2617 : if( m_bArea && (rSeriesList.size() == 1) && (nIndex >= (*aSeriesIter)->getTotalPointCount()) )
774 318 : continue;
775 :
776 : //collect data point information (logic coordinates, style ):
777 2617 : double fLogicX = (*aSeriesIter)->getXValue(nIndex);
778 2617 : if (bDateCategory)
779 0 : fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
780 2617 : double fLogicY = (*aSeriesIter)->getYValue(nIndex);
781 :
782 2617 : if( m_nDimension==3 && m_bArea && rSeriesList.size()!=1 )
783 0 : fLogicY = fabs( fLogicY );
784 :
785 2617 : std::map< sal_Int32, double >& rLogicYSumMap = aLogicYSumMapByX[nIndex];
786 2617 : if( pPosHelper->isPercentY() && !::rtl::math::approxEqual( rLogicYSumMap[nAttachedAxisIndex], 0.0 ) )
787 : {
788 156 : fLogicY = fabs( fLogicY )/rLogicYSumMap[nAttachedAxisIndex];
789 : }
790 :
791 7849 : if( ::rtl::math::isNan(fLogicX) || ::rtl::math::isInf(fLogicX)
792 2615 : || ::rtl::math::isNan(fLogicY) || ::rtl::math::isInf(fLogicY)
793 5232 : || ::rtl::math::isNan(fLogicZ) || ::rtl::math::isInf(fLogicZ) )
794 : {
795 2 : if( (*aSeriesIter)->getMissingValueTreatment() == ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP )
796 : {
797 2 : drawing::PolyPolygonShape3D& rPolygon = (*aSeriesIter)->m_aPolyPolygonShape3D;
798 2 : sal_Int32& rIndex = (*aSeriesIter)->m_nPolygonIndex;
799 2 : if( 0<= rIndex && rIndex < rPolygon.SequenceX.getLength() )
800 : {
801 2 : if( rPolygon.SequenceX[ rIndex ].getLength() )
802 2 : rIndex++; //start a new polygon for the next point if the current poly is not empty
803 : }
804 : }
805 2 : continue;
806 : }
807 :
808 2615 : std::map< sal_Int32, double >& rLogicYForNextSeriesMap = aLogicYForNextSeriesMapByX[nIndex];
809 2615 : if( rLogicYForNextSeriesMap.find(nAttachedAxisIndex) == rLogicYForNextSeriesMap.end() )
810 2407 : rLogicYForNextSeriesMap[nAttachedAxisIndex] = 0.0;
811 :
812 2615 : double fLogicValueForLabeDisplay = fLogicY;
813 :
814 2615 : fLogicY += rLogicYForNextSeriesMap[nAttachedAxisIndex];
815 2615 : rLogicYForNextSeriesMap[nAttachedAxisIndex] = fLogicY;
816 :
817 2615 : bool bIsVisible = pPosHelper->isLogicVisible( fLogicX, fLogicY, fLogicZ );
818 :
819 : //remind minimal and maximal x values for area 'grounding' points
820 : //only for filled area
821 : {
822 2615 : double& rfMinX = (*aSeriesIter)->m_fLogicMinX;
823 2615 : if(!nIndex||fLogicX<rfMinX)
824 321 : rfMinX=fLogicX;
825 2615 : double& rfMaxX = (*aSeriesIter)->m_fLogicMaxX;
826 2615 : if(!nIndex||fLogicX>rfMaxX)
827 2615 : rfMaxX=fLogicX;
828 : }
829 :
830 2615 : drawing::Position3D aUnscaledLogicPosition( fLogicX, fLogicY, fLogicZ );
831 2615 : drawing::Position3D aScaledLogicPosition(aUnscaledLogicPosition);
832 2615 : pPosHelper->doLogicScaling( aScaledLogicPosition );
833 :
834 : //transformation 3) -> 4)
835 2615 : drawing::Position3D aScenePosition( pPosHelper->transformLogicToScene( fLogicX,fLogicY,fLogicZ, false ) );
836 :
837 : //better performance for big data
838 2615 : FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries] );
839 2615 : pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution );
840 5230 : if( !pSeries->isAttributedDataPoint(nIndex)
841 5230 : &&
842 : pPosHelper->isSameForGivenResolution( aFormerPoint.m_fX, aFormerPoint.m_fY, aFormerPoint.m_fZ
843 2615 : , aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ ) )
844 : {
845 0 : ++nSkippedPoints;
846 0 : m_bPointsWereSkipped = true;
847 0 : continue;
848 : }
849 2615 : aSeriesFormerPointMap[pSeries] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ);
850 :
851 : //store point information for series polygon
852 : //for area and/or line (symbols only do not need this)
853 2615 : if( isValidPosition(aScaledLogicPosition) )
854 : {
855 2615 : AddPointToPoly( (*aSeriesIter)->m_aPolyPolygonShape3D, aScaledLogicPosition, (*aSeriesIter)->m_nPolygonIndex );
856 : }
857 :
858 : //create a single datapoint if point is visible
859 : //apply clipping:
860 2615 : if( !bIsVisible )
861 0 : continue;
862 :
863 2615 : bool bCreateYErrorBar = false, bCreateXErrorBar = false;
864 : {
865 2615 : uno::Reference< beans::XPropertySet > xErrorBarProp(pSeries->getYErrorBarProperties(nIndex));
866 2615 : if( xErrorBarProp.is() )
867 : {
868 758 : bool bShowPositive = false;
869 758 : bool bShowNegative = false;
870 758 : xErrorBarProp->getPropertyValue("ShowPositiveError") >>= bShowPositive;
871 758 : xErrorBarProp->getPropertyValue("ShowNegativeError") >>= bShowNegative;
872 758 : bCreateYErrorBar = bShowPositive || bShowNegative;
873 : }
874 :
875 2615 : xErrorBarProp = pSeries->getXErrorBarProperties(nIndex);
876 2615 : if ( xErrorBarProp.is() )
877 : {
878 0 : bool bShowPositive = false;
879 0 : bool bShowNegative = false;
880 0 : xErrorBarProp->getPropertyValue("ShowPositiveError") >>= bShowPositive;
881 0 : xErrorBarProp->getPropertyValue("ShowNegativeError") >>= bShowNegative;
882 0 : bCreateXErrorBar = bShowPositive || bShowNegative;
883 2615 : }
884 : }
885 :
886 2615 : Symbol* pSymbolProperties = m_bSymbol ? (*aSeriesIter)->getSymbolProperties( nIndex ) : 0;
887 2615 : bool bCreateSymbol = pSymbolProperties && (pSymbolProperties->Style != SymbolStyle_NONE);
888 :
889 9304 : if( !bCreateSymbol && !bCreateYErrorBar &&
890 6289 : !bCreateXErrorBar && !pSeries->getDataPointLabelIfLabel(nIndex) )
891 316 : continue;
892 :
893 : //create a group shape for this point and add to the series shape:
894 : OUString aPointCID = ObjectIdentifier::createPointCID(
895 2299 : (*aSeriesIter)->getPointCID_Stub(), nIndex );
896 : uno::Reference< drawing::XShapes > xPointGroupShape_Shapes(
897 4598 : createGroupShape(xSeriesGroupShape_Shapes,aPointCID) );
898 : uno::Reference<drawing::XShape> xPointGroupShape_Shape =
899 4598 : uno::Reference<drawing::XShape>( xPointGroupShape_Shapes, uno::UNO_QUERY );
900 :
901 : {
902 2299 : nCreatedPoints++;
903 :
904 : //create data point
905 2299 : drawing::Direction3D aSymbolSize(0,0,0);
906 2299 : if( bCreateSymbol )
907 : {
908 378 : if(m_nDimension!=3)
909 : {
910 378 : if( pSymbolProperties )
911 : {
912 378 : if( pSymbolProperties->Style != SymbolStyle_NONE )
913 : {
914 378 : aSymbolSize.DirectionX = pSymbolProperties->Size.Width;
915 378 : aSymbolSize.DirectionY = pSymbolProperties->Size.Height;
916 : }
917 :
918 378 : if( pSymbolProperties->Style == SymbolStyle_STANDARD )
919 : {
920 378 : sal_Int32 nSymbol = pSymbolProperties->StandardSymbol;
921 : m_pShapeFactory->createSymbol2D( xPointGroupShape_Shapes
922 : , aScenePosition, aSymbolSize
923 : , nSymbol
924 : , pSymbolProperties->BorderColor
925 378 : , pSymbolProperties->FillColor );
926 : }
927 0 : else if( pSymbolProperties->Style == SymbolStyle_GRAPHIC )
928 : {
929 : m_pShapeFactory->createGraphic2D( xPointGroupShape_Shapes
930 : , aScenePosition , aSymbolSize
931 0 : , pSymbolProperties->Graphic );
932 : }
933 : //@todo other symbol styles
934 : }
935 : }
936 : }
937 : //create error bars
938 2299 : if (bCreateXErrorBar)
939 0 : createErrorBar_X( aUnscaledLogicPosition, **aSeriesIter, nIndex, m_xErrorBarTarget );
940 :
941 2299 : if (bCreateYErrorBar)
942 446 : createErrorBar_Y( aUnscaledLogicPosition, **aSeriesIter, nIndex, m_xErrorBarTarget );
943 :
944 : //create data point label
945 2299 : if( (**aSeriesIter).getDataPointLabelIfLabel(nIndex) )
946 : {
947 1911 : LabelAlignment eAlignment = LABEL_ALIGN_TOP;
948 : drawing::Position3D aScenePosition3D( aScenePosition.PositionX
949 : , aScenePosition.PositionY
950 1911 : , aScenePosition.PositionZ+this->getTransformedDepth() );
951 :
952 1911 : sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() );
953 :
954 1911 : switch(nLabelPlacement)
955 : {
956 : case ::com::sun::star::chart::DataLabelPlacement::TOP:
957 1911 : aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
958 1911 : eAlignment = LABEL_ALIGN_TOP;
959 1911 : break;
960 : case ::com::sun::star::chart::DataLabelPlacement::BOTTOM:
961 0 : aScenePosition3D.PositionY += (aSymbolSize.DirectionY/2+1);
962 0 : eAlignment = LABEL_ALIGN_BOTTOM;
963 0 : break;
964 : case ::com::sun::star::chart::DataLabelPlacement::LEFT:
965 0 : aScenePosition3D.PositionX -= (aSymbolSize.DirectionX/2+1);
966 0 : eAlignment = LABEL_ALIGN_LEFT;
967 0 : break;
968 : case ::com::sun::star::chart::DataLabelPlacement::RIGHT:
969 0 : aScenePosition3D.PositionX += (aSymbolSize.DirectionX/2+1);
970 0 : eAlignment = LABEL_ALIGN_RIGHT;
971 0 : break;
972 : case ::com::sun::star::chart::DataLabelPlacement::CENTER:
973 0 : eAlignment = LABEL_ALIGN_CENTER;
974 : //todo implement this different for area charts
975 0 : break;
976 : default:
977 : OSL_FAIL("this label alignment is not implemented yet");
978 0 : aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
979 0 : eAlignment = LABEL_ALIGN_TOP;
980 0 : break;
981 : }
982 :
983 1911 : awt::Point aScreenPosition2D;//get the screen position for the labels
984 1911 : sal_Int32 nOffset = 100; //todo maybe calculate this font height dependent
985 : {
986 1911 : if(LABEL_ALIGN_CENTER==eAlignment || m_nDimension == 3 )
987 663 : nOffset = 0;
988 : aScreenPosition2D = awt::Point( LabelPositionHelper(pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory)
989 1911 : .transformSceneToScreenPosition( aScenePosition3D ) );
990 : }
991 :
992 1911 : createDataLabel( m_xTextTarget, **aSeriesIter, nIndex
993 : , fLogicValueForLabeDisplay
994 3822 : , rLogicYSumMap[nAttachedAxisIndex], aScreenPosition2D, eAlignment, nOffset );
995 : }
996 : }
997 :
998 : //remove PointGroupShape if empty
999 2299 : if(!xPointGroupShape_Shapes->getCount())
1000 1921 : xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shape);
1001 2299 : }
1002 :
1003 321 : }//next series in x slot (next y slot)
1004 383 : }//next x slot
1005 : }//next z slot
1006 :
1007 125 : impl_createSeriesShapes();
1008 :
1009 : /* @todo remove series shapes if empty
1010 : //remove and delete point-group-shape if empty
1011 : if(!xSeriesGroupShape_Shapes->getCount())
1012 : {
1013 : (*aSeriesIter)->m_xShape.set(NULL);
1014 : m_xLogicTarget->remove(xSeriesGroupShape_Shape);
1015 : }
1016 : */
1017 :
1018 : //remove and delete series-group-shape if empty
1019 :
1020 : //... todo
1021 :
1022 125 : OSL_TRACE( "\nPPPPPPPPP<<<<<<<<<<<< area chart :: createShapes():: skipped points: %d created points: %d", nSkippedPoints, nCreatedPoints );
1023 : }
1024 :
1025 108 : } //namespace chart
1026 :
1027 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|