1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "NetChart.hxx"
#include <PlottingPositionHelper.hxx>
#include <ShapeFactory.hxx>
#include <ExplicitCategoriesProvider.hxx>
#include <CommonConverters.hxx>
#include <ObjectIdentifier.hxx>
#include <LabelPositionHelper.hxx>
#include <Clipping.hxx>
#include <PolarLabelPositionHelper.hxx>
#include <DateHelper.hxx>
#include <ChartType.hxx>
#include <com/sun/star/chart2/Symbol.hpp>
#include <com/sun/star/chart/DataLabelPlacement.hpp>
#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <officecfg/Office/Compatibility.hxx>
#include <limits>
namespace chart
{
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
NetChart::NetChart( const rtl::Reference<ChartType>& xChartTypeModel
, sal_Int32 nDimensionCount
, bool bNoArea
, std::unique_ptr<PlottingPositionHelper> pPlottingPositionHelper
)
: VSeriesPlotter( xChartTypeModel, nDimensionCount, true )
, m_pMainPosHelper(std::move(pPlottingPositionHelper))
, m_bArea(!bNoArea)
, m_bLine(bNoArea)
{
// we only support 2D Net charts
assert(nDimensionCount == 2);
m_pMainPosHelper->AllowShiftXAxisPos(true);
m_pMainPosHelper->AllowShiftZAxisPos(true);
PlotterBase::m_pPosHelper = m_pMainPosHelper.get();
VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get();
}
NetChart::~NetChart()
{
}
double NetChart::getMaximumX()
{
double fMax = VSeriesPlotter::getMaximumX() + 1.0;
return fMax;
}
bool NetChart::isExpandIfValuesCloseToBorder( sal_Int32 )
{
return false;
}
bool NetChart::isSeparateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex*/ )
{
// no separate stacking in all types of line/area charts
return false;
}
LegendSymbolStyle NetChart::getLegendSymbolStyle()
{
if( m_bArea )
return LegendSymbolStyle::Box;
return LegendSymbolStyle::Line;
}
uno::Any NetChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex )
{
uno::Any aRet;
Symbol* pSymbolProperties = rSeries.getSymbolProperties( nPointIndex );
if( pSymbolProperties )
{
aRet <<= *pSymbolProperties;
}
return aRet;
}
drawing::Direction3D NetChart::getPreferredDiagramAspectRatio() const
{
return drawing::Direction3D(1,1,1);
}
bool NetChart::impl_createLine( VDataSeries* pSeries
, const std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly
, PlottingPositionHelper const * pPosHelper )
{
//return true if a line was created successfully
rtl::Reference<SvxShapeGroupAnyD> xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
std::vector<std::vector<css::drawing::Position3D>> aPoly;
{
bool bIsClipped = false;
if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
{
// do NOT connect last and first point, if one is NAN, and NAN handling is NAN_AS_GAP
double fFirstY = pSeries->getYValue( 0 );
double fLastY = pSeries->getYValue( VSeriesPlotter::getPointCount() - 1 );
if( (pSeries->getMissingValueTreatment() != css::chart::MissingValueTreatment::LEAVE_GAP)
|| (std::isfinite( fFirstY ) && std::isfinite( fLastY )) )
{
// connect last point in last polygon with first point in first polygon
::basegfx::B2DRectangle aScaledLogicClipDoubleRect( pPosHelper->getScaledLogicClipDoubleRect() );
std::vector<std::vector<css::drawing::Position3D>> aTmpPoly(*pSeriesPoly);
drawing::Position3D aLast(aScaledLogicClipDoubleRect.getMaxX(),aTmpPoly[0][0].PositionY,aTmpPoly[0][0].PositionZ);
// add connector line to last polygon
AddPointToPoly( aTmpPoly, aLast, pSeriesPoly->size() - 1 );
Clipping::clipPolygonAtRectangle( aTmpPoly, aScaledLogicClipDoubleRect, aPoly );
bIsClipped = true;
}
}
if( !bIsClipped )
Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
}
if(!ShapeFactory::hasPolygonAnyLines(aPoly))
return false;
//transformation 3) -> 4)
pPosHelper->transformScaledLogicToScene( aPoly );
//create line:
rtl::Reference<SvxShapePolyPolygon> xShape;
{
xShape = ShapeFactory::createLine2D( xSeriesGroupShape_Shapes, aPoly );
PropertyMapper::setMappedProperties( *xShape
, pSeries->getPropertiesOfSeries()
, PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
//because of this name this line will be used for marking
::chart::ShapeFactory::setShapeName(xShape, u"MarkHandles"_ustr);
}
return true;
}
bool NetChart::impl_createArea( VDataSeries* pSeries
, const std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly
, std::vector<std::vector<css::drawing::Position3D>> const * pPreviousSeriesPoly
, PlottingPositionHelper const * pPosHelper )
{
//return true if an area was created successfully
rtl::Reference<SvxShapeGroupAnyD> xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
double zValue = pSeries->m_fLogicZPos;
std::vector<std::vector<css::drawing::Position3D>> aPoly( *pSeriesPoly );
//add second part to the polygon (grounding points or previous series points)
if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
{
if( pPreviousSeriesPoly )
addPolygon( aPoly, *pPreviousSeriesPoly );
}
else if(!pPreviousSeriesPoly)
{
double fMinX = pSeries->m_fLogicMinX;
double fMaxX = pSeries->m_fLogicMaxX;
double fY = pPosHelper->getBaseValueY();//logic grounding
//clip to scale
if(fMaxX<pPosHelper->getLogicMinX() || fMinX>pPosHelper->getLogicMaxX())
return false;//no visible shape needed
pPosHelper->clipLogicValues( &fMinX, &fY, nullptr );
pPosHelper->clipLogicValues( &fMaxX, nullptr, nullptr );
//apply scaling
{
pPosHelper->doLogicScaling( &fMinX, &fY, &zValue );
pPosHelper->doLogicScaling( &fMaxX, nullptr, nullptr );
}
AddPointToPoly( aPoly, drawing::Position3D( fMaxX,fY,zValue) );
AddPointToPoly( aPoly, drawing::Position3D( fMinX,fY,zValue) );
}
else
{
appendPoly( aPoly, *pPreviousSeriesPoly );
}
ShapeFactory::closePolygon(aPoly);
//apply clipping
{
std::vector<std::vector<css::drawing::Position3D>> aClippedPoly;
Clipping::clipPolygonAtRectangle( aPoly, pPosHelper->getScaledLogicClipDoubleRect(), aClippedPoly, false );
ShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping
aPoly = std::move(aClippedPoly);
}
if(!ShapeFactory::hasPolygonAnyLines(aPoly))
return false;
//transformation 3) -> 4)
pPosHelper->transformScaledLogicToScene( aPoly );
//create area:
rtl::Reference<SvxShapePolyPolygon>
xShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
, aPoly );
PropertyMapper::setMappedProperties( *xShape
, pSeries->getPropertiesOfSeries()
, PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
//because of this name this line will be used for marking
::chart::ShapeFactory::setShapeName(xShape, u"MarkHandles"_ustr);
return true;
}
void NetChart::impl_createSeriesShapes()
{
//the polygon shapes for each series need to be created before
//iterate through all series again to create the series shapes
for( auto const& rZSlot : m_aZSlots )
{
for( auto const& rXSlot : rZSlot )
{
std::map< sal_Int32, std::vector<std::vector<css::drawing::Position3D>>* > aPreviousSeriesPolyMap;//a PreviousSeriesPoly for each different nAttachedAxisIndex
std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly = nullptr;
//iterate through all series
for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
{
sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
pSeriesPoly = &pSeries->m_aPolyPolygonShape3D;
if( m_bArea )
{
if (!impl_createArea(pSeries.get(), pSeriesPoly,
aPreviousSeriesPolyMap[nAttachedAxisIndex], m_pPosHelper))
continue;
}
if( m_bLine )
{
if (!impl_createLine(pSeries.get(), pSeriesPoly, m_pPosHelper))
continue;
}
aPreviousSeriesPolyMap[nAttachedAxisIndex] = pSeriesPoly;
}//next series in x slot (next y slot)
}//next x slot
}//next z slot
}
namespace
{
void lcl_reorderSeries( std::vector< std::vector< VDataSeriesGroup > >& rZSlots )
{
std::vector< std::vector< VDataSeriesGroup > > aRet;
aRet.reserve( rZSlots.size() );
std::vector< std::vector< VDataSeriesGroup > >::reverse_iterator aZIt( rZSlots.rbegin() );
std::vector< std::vector< VDataSeriesGroup > >::reverse_iterator aZEnd( rZSlots.rend() );
for( ; aZIt != aZEnd; ++aZIt )
{
std::vector< VDataSeriesGroup > aXSlot;
std::vector< VDataSeriesGroup >::reverse_iterator aXIt( aZIt->rbegin() );
std::vector< VDataSeriesGroup >::reverse_iterator aXEnd( aZIt->rend() );
for( ; aXIt != aXEnd; ++aXIt )
aXSlot.push_back(std::move(*aXIt));
aRet.push_back(std::move(aXSlot));
}
rZSlots = std::move(aRet);
}
//better performance for big data
struct FormerPoint
{
FormerPoint( double fX, double fY, double fZ )
: m_fX(fX), m_fY(fY), m_fZ(fZ)
{}
FormerPoint()
: m_fX(std::numeric_limits<double>::quiet_NaN())
, m_fY(std::numeric_limits<double>::quiet_NaN())
, m_fZ(std::numeric_limits<double>::quiet_NaN())
{
}
double m_fX;
double m_fY;
double m_fZ;
};
}//anonymous namespace
void NetChart::createShapes()
{
if( m_aZSlots.empty() ) //no series
return;
//tdf#127813 Don't reverse the series in OOXML-heavy environments
if (officecfg::Office::Compatibility::View::ReverseSeriesOrderAreaAndNetChart::get() && m_bArea)
lcl_reorderSeries( m_aZSlots );
OSL_ENSURE(m_xLogicTarget.is()&&m_xFinalTarget.is(),"NetChart is not proper initialized");
if(!(m_xLogicTarget.is()&&m_xFinalTarget.is()))
return;
//the text labels should be always on top of the other series shapes
//for area chart the error bars should be always on top of the other series shapes
//therefore create an own group for the texts and the error bars to move them to front
//(because the text group is created after the series group the texts are displayed on top)
m_xSeriesTarget = createGroupShape( m_xLogicTarget );
m_xTextTarget = ShapeFactory::createGroup2D( m_xFinalTarget );
//check necessary here that different Y axis can not be stacked in the same group? ... hm?
//update/create information for current group
double fLogicZ = 1.0;//as defined
sal_Int32 const nStartIndex = 0; // inclusive ;..todo get somehow from x scale
sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
if(nEndIndex<=0)
nEndIndex=1;
//better performance for big data
std::map< VDataSeries*, FormerPoint > aSeriesFormerPointMap;
m_bPointsWereSkipped = false;
bool bDateCategory = (m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis());
//iterate through all x values per indices
for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
{
std::map< sal_Int32, double > aLogicYSumMap;//one for each different nAttachedAxisIndex
for( auto const& rZSlot : m_aZSlots )
{
//iterate through all x slots in this category to get 100percent sum
for( auto const& rXSlot : rZSlot )
{
for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
{
if(!pSeries)
continue;
if (bDateCategory)
pSeries->doSortByXValues();
sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
aLogicYSumMap.insert({nAttachedAxisIndex, 0.0});
m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
double fAdd = pSeries->getYValue( nIndex );
if( !std::isnan(fAdd) && !std::isinf(fAdd) )
aLogicYSumMap[nAttachedAxisIndex] += fabs( fAdd );
}
}
}
for( auto const& rZSlot : m_aZSlots )
{
//for the area chart there should be at most one x slot (no side by side stacking available)
//attention different: xSlots are always interpreted as independent areas one behind the other: @todo this doesn't work why not???
for( auto const& rXSlot : rZSlot )
{
std::map< sal_Int32, double > aLogicYForNextSeriesMap;//one for each different nAttachedAxisIndex
//iterate through all series
for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
{
if(!pSeries)
continue;
/* #i70133# ignore points outside of series length in standard area
charts. Stacked area charts will use missing points as zeros. In
standard charts, pSeriesList contains only one series. */
if( m_bArea && (rXSlot.m_aSeriesVector.size() == 1) && (nIndex >= pSeries->getTotalPointCount()) )
continue;
rtl::Reference<SvxShapeGroupAnyD> xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(pSeries.get(), m_xSeriesTarget);
sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
pSeries->m_fLogicZPos = fLogicZ;
//collect data point information (logic coordinates, style ):
double fLogicX = pSeries->getXValue(nIndex);
if (bDateCategory)
fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
double fLogicY = pSeries->getYValue(nIndex);
if( m_bArea && ( std::isnan(fLogicY) || std::isinf(fLogicY) ) )
{
if( pSeries->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP )
{
if( rXSlot.m_aSeriesVector.size() == 1 || pSeries == rXSlot.m_aSeriesVector.front() )
{
fLogicY = m_pPosHelper->getLogicMinY();
if (!m_pPosHelper->isMathematicalOrientationY())
fLogicY = m_pPosHelper->getLogicMaxY();
}
else
fLogicY = 0.0;
}
}
if (m_pPosHelper->isPercentY() && aLogicYSumMap[nAttachedAxisIndex] != 0.0)
{
fLogicY = fabs( fLogicY )/aLogicYSumMap[nAttachedAxisIndex];
}
if( std::isnan(fLogicX) || std::isinf(fLogicX)
|| std::isnan(fLogicY) || std::isinf(fLogicY)
|| std::isnan(fLogicZ) || std::isinf(fLogicZ) )
{
if( pSeries->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP )
{
std::vector<std::vector<css::drawing::Position3D>>& rPolygon = pSeries->m_aPolyPolygonShape3D;
sal_Int32& rIndex = pSeries->m_nPolygonIndex;
if( 0<= rIndex && o3tl::make_unsigned(rIndex) < rPolygon.size() )
{
if( !rPolygon[ rIndex ].empty() )
rIndex++; //start a new polygon for the next point if the current poly is not empty
}
}
continue;
}
aLogicYForNextSeriesMap.try_emplace(nAttachedAxisIndex, 0.0);
double fLogicValueForLabeDisplay = fLogicY;
fLogicY += aLogicYForNextSeriesMap[nAttachedAxisIndex];
aLogicYForNextSeriesMap[nAttachedAxisIndex] = fLogicY;
bool bIsVisible = m_pPosHelper->isLogicVisible(fLogicX, fLogicY, fLogicZ);
//remind minimal and maximal x values for area 'grounding' points
//only for filled area
{
double& rfMinX = pSeries->m_fLogicMinX;
if(!nIndex||fLogicX<rfMinX)
rfMinX=fLogicX;
double& rfMaxX = pSeries->m_fLogicMaxX;
if(!nIndex||fLogicX>rfMaxX)
rfMaxX=fLogicX;
}
drawing::Position3D aUnscaledLogicPosition( fLogicX, fLogicY, fLogicZ );
drawing::Position3D aScaledLogicPosition(aUnscaledLogicPosition);
m_pPosHelper->doLogicScaling(aScaledLogicPosition);
//transformation 3) -> 4)
drawing::Position3D aScenePosition(
m_pPosHelper->transformLogicToScene(fLogicX, fLogicY, fLogicZ, false));
//better performance for big data
FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries.get()] );
m_pPosHelper->setCoordinateSystemResolution(m_aCoordinateSystemResolution);
if( !pSeries->isAttributedDataPoint(nIndex)
&& m_pPosHelper->isSameForGivenResolution(
aFormerPoint.m_fX, aFormerPoint.m_fY, aFormerPoint.m_fZ
, aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ ) )
{
m_bPointsWereSkipped = true;
continue;
}
aSeriesFormerPointMap[pSeries.get()] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ);
//store point information for series polygon
//for area and/or line (symbols only do not need this)
if( isValidPosition(aScaledLogicPosition) )
{
AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aScaledLogicPosition, pSeries->m_nPolygonIndex );
//prepare clipping for filled net charts
if( !bIsVisible && m_bArea )
{
drawing::Position3D aClippedPos(aScaledLogicPosition);
m_pPosHelper->clipScaledLogicValues(nullptr, &aClippedPos.PositionY,
nullptr);
if (m_pPosHelper->isLogicVisible(aClippedPos.PositionX,
aClippedPos.PositionY,
aClippedPos.PositionZ))
{
AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aClippedPos, pSeries->m_nPolygonIndex );
AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aScaledLogicPosition, pSeries->m_nPolygonIndex );
}
}
}
//create a single datapoint if point is visible
//apply clipping:
if( !bIsVisible )
continue;
Symbol* pSymbolProperties = pSeries->getSymbolProperties( nIndex );
bool bCreateSymbol = pSymbolProperties && (pSymbolProperties->Style != SymbolStyle_NONE);
if( !bCreateSymbol && !pSeries->getDataPointLabelIfLabel(nIndex) )
continue;
//create a group shape for this point and add to the series shape:
OUString aPointCID = ObjectIdentifier::createPointCID(
pSeries->getPointCID_Stub(), nIndex );
rtl::Reference<SvxShapeGroupAnyD> xPointGroupShape_Shapes(
createGroupShape(xSeriesGroupShape_Shapes,aPointCID) );
{
//create data point
drawing::Direction3D aSymbolSize(0,0,0);
if (bCreateSymbol) // implies pSymbolProperties
{
if (pSymbolProperties->Style != SymbolStyle_NONE)
{
aSymbolSize.DirectionX = pSymbolProperties->Size.Width;
aSymbolSize.DirectionY = pSymbolProperties->Size.Height;
}
if (pSymbolProperties->Style == SymbolStyle_STANDARD)
{
sal_Int32 nSymbol = pSymbolProperties->StandardSymbol;
ShapeFactory::createSymbol2D(
xPointGroupShape_Shapes, aScenePosition, aSymbolSize, nSymbol,
pSymbolProperties->BorderColor, pSymbolProperties->FillColor);
}
else if (pSymbolProperties->Style == SymbolStyle_GRAPHIC)
{
ShapeFactory::createGraphic2D(xPointGroupShape_Shapes,
aScenePosition, aSymbolSize,
pSymbolProperties->Graphic);
}
//@todo other symbol styles
}
//create data point label
if( pSeries->getDataPointLabelIfLabel(nIndex) )
{
LabelAlignment eAlignment = LABEL_ALIGN_TOP;
drawing::Position3D aScenePosition3D( aScenePosition.PositionX
, aScenePosition.PositionY
, aScenePosition.PositionZ+getTransformedDepth() );
sal_Int32 nLabelPlacement = pSeries->getLabelPlacement(
nIndex, m_xChartTypeModel, m_pPosHelper->isSwapXAndY());
switch(nLabelPlacement)
{
case css::chart::DataLabelPlacement::TOP:
aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
eAlignment = LABEL_ALIGN_TOP;
break;
case css::chart::DataLabelPlacement::BOTTOM:
aScenePosition3D.PositionY += (aSymbolSize.DirectionY/2+1);
eAlignment = LABEL_ALIGN_BOTTOM;
break;
case css::chart::DataLabelPlacement::LEFT:
aScenePosition3D.PositionX -= (aSymbolSize.DirectionX/2+1);
eAlignment = LABEL_ALIGN_LEFT;
break;
case css::chart::DataLabelPlacement::RIGHT:
aScenePosition3D.PositionX += (aSymbolSize.DirectionX/2+1);
eAlignment = LABEL_ALIGN_RIGHT;
break;
case css::chart::DataLabelPlacement::CENTER:
eAlignment = LABEL_ALIGN_CENTER;
//todo implement this different for area charts
break;
default:
OSL_FAIL("this label alignment is not implemented yet");
aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
eAlignment = LABEL_ALIGN_TOP;
break;
}
awt::Point aScreenPosition2D;//get the screen position for the labels
sal_Int32 nOffset = 100; //todo maybe calculate this font height dependent
if( nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE )
{
PolarPlottingPositionHelper* pPolarPosHelper
= dynamic_cast<PolarPlottingPositionHelper*>(m_pPosHelper);
if( pPolarPosHelper )
{
PolarLabelPositionHelper aPolarLabelPositionHelper(pPolarPosHelper,m_nDimension,m_xLogicTarget);
aScreenPosition2D = aPolarLabelPositionHelper.getLabelScreenPositionAndAlignmentForLogicValues(
eAlignment, fLogicX, fLogicY, fLogicZ, nOffset );
}
}
else
{
if(eAlignment==LABEL_ALIGN_CENTER )
nOffset = 0;
aScreenPosition2D = LabelPositionHelper(m_nDimension,m_xLogicTarget)
.transformSceneToScreenPosition( aScenePosition3D );
}
createDataLabel( m_xTextTarget, *pSeries, nIndex
, fLogicValueForLabeDisplay
, aLogicYSumMap[nAttachedAxisIndex], aScreenPosition2D, eAlignment, nOffset );
}
}
//remove PointGroupShape if empty
if(!xPointGroupShape_Shapes->getCount())
xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shapes);
}//next series in x slot (next y slot)
}//next x slot
}//next z slot
}//next category
impl_createSeriesShapes();
}
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|