[Libreoffice-commits] core.git: Branch 'private/moggi/abstract-chart-rendering' - 7 commits - chart2/Library_chartcore.mk chart2/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Wed Oct 9 19:58:34 PDT 2013
chart2/Library_chartcore.mk | 1
chart2/source/view/charttypes/AreaChart.cxx | 96 --
chart2/source/view/charttypes/AreaChart.hxx | 9
chart2/source/view/charttypes/BarChart.cxx | 2
chart2/source/view/charttypes/BubbleChart.cxx | 23
chart2/source/view/charttypes/NetChart.cxx | 786 +++++++++++++++++++++++
chart2/source/view/charttypes/NetChart.hxx | 85 ++
chart2/source/view/charttypes/VSeriesPlotter.cxx | 12
chart2/source/view/inc/VDataSeries.hxx | 3
chart2/source/view/main/ChartView.cxx | 2
chart2/source/view/main/VDataSeries.cxx | 24
11 files changed, 901 insertions(+), 142 deletions(-)
New commits:
commit ff28e4489cc89cdd98e4256a2efbae206f142a84
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 10 05:47:04 2013 +0200
remove a few more unnecessary lines
Change-Id: I44eafb69bf32cb8dbf7d07278a010ca4d812a832
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 195b706..3dee4f4 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -29,7 +29,6 @@
#include "LabelPositionHelper.hxx"
#include "Clipping.hxx"
#include "Stripe.hxx"
-#include "PolarLabelPositionHelper.hxx"
#include "DateHelper.hxx"
#include <com/sun/star/chart2/Symbol.hpp>
diff --git a/chart2/source/view/charttypes/NetChart.cxx b/chart2/source/view/charttypes/NetChart.cxx
index 297de74..76672e1 100644
--- a/chart2/source/view/charttypes/NetChart.cxx
+++ b/chart2/source/view/charttypes/NetChart.cxx
@@ -24,7 +24,6 @@
#include "macros.hxx"
#include "ViewDefines.hxx"
#include "ObjectIdentifier.hxx"
-#include "Splines.hxx"
#include "ChartTypeHelper.hxx"
#include "LabelPositionHelper.hxx"
#include "Clipping.hxx"
@@ -58,7 +57,6 @@ NetChart::NetChart( const uno::Reference<XChartType>& xChartTypeModel
, m_pMainPosHelper(pPlottingPositionHelper)
, m_bArea(!bNoArea)
, m_bLine(bNoArea)
- , m_bSymbol( ChartTypeHelper::isSupportingSymbolProperties(xChartTypeModel,nDimensionCount) )
, m_xSeriesTarget(0)
, m_xTextTarget(0)
{
@@ -657,7 +655,7 @@ void NetChart::createShapes()
if( !bIsVisible )
continue;
- Symbol* pSymbolProperties = m_bSymbol ? (*aSeriesIter)->getSymbolProperties( nIndex ) : 0;
+ Symbol* pSymbolProperties = (*aSeriesIter)->getSymbolProperties( nIndex );
bool bCreateSymbol = pSymbolProperties && (pSymbolProperties->Style != SymbolStyle_NONE);
if( !bCreateSymbol && !pSeries->getDataPointLabelIfLabel(nIndex) )
diff --git a/chart2/source/view/charttypes/NetChart.hxx b/chart2/source/view/charttypes/NetChart.hxx
index 3452241..6b3a73f 100644
--- a/chart2/source/view/charttypes/NetChart.hxx
+++ b/chart2/source/view/charttypes/NetChart.hxx
@@ -69,7 +69,6 @@ private: //member
bool m_bArea;//false -> line or symbol only
bool m_bLine;
- bool m_bSymbol;
::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShapes > m_xSeriesTarget;
commit 11e1b6823dda41bf00be0e10f39000f7d7f1b811
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 10 05:41:34 2013 +0200
simplify AreaChart now that it does not deal with net charts
Change-Id: I4ff556a43b65d54954b3d057b86dbb1fe7e66ac6
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index d3af561..195b706 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -53,20 +53,12 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel
, sal_Int32 nDimensionCount
, bool bCategoryXAxis
, bool bNoArea
- , PlottingPositionHelper* pPlottingPositionHelper
- , bool bConnectLastToFirstPoint
- , bool bExpandIfValuesCloseToBorder
- , sal_Int32 nKeepAspectRatio
)
: VSeriesPlotter( xChartTypeModel, nDimensionCount, bCategoryXAxis )
- , m_pMainPosHelper(pPlottingPositionHelper)
+ , m_pMainPosHelper(new PlottingPositionHelper())
, m_bArea(!bNoArea)
, m_bLine(bNoArea)
, m_bSymbol( ChartTypeHelper::isSupportingSymbolProperties(xChartTypeModel,nDimensionCount) )
- , m_bIsPolarCooSys( bConnectLastToFirstPoint )
- , m_bConnectLastToFirstPoint( bConnectLastToFirstPoint )
- , m_bExpandIfValuesCloseToBorder( bExpandIfValuesCloseToBorder )
- , m_nKeepAspectRatio(nKeepAspectRatio)
, m_eCurveStyle(CurveStyle_LINES)
, m_nCurveResolution(20)
, m_nSplineOrder(3)
@@ -75,9 +67,6 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel
, m_xTextTarget(0)
, m_xRegressionCurveEquationTarget(0)
{
- if( !m_pMainPosHelper )
- m_pMainPosHelper = new PlottingPositionHelper();
-
m_pMainPosHelper->AllowShiftXAxisPos(true);
m_pMainPosHelper->AllowShiftZAxisPos(true);
@@ -109,15 +98,12 @@ AreaChart::~AreaChart()
double AreaChart::getMaximumX()
{
double fMax = VSeriesPlotter::getMaximumX();
- if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling
- fMax += 1.0;
return fMax;
}
bool AreaChart::isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex )
{
- return m_bExpandIfValuesCloseToBorder &&
- VSeriesPlotter::isExpandIfValuesCloseToBorder( nDimensionIndex );
+ return VSeriesPlotter::isExpandIfValuesCloseToBorder( nDimensionIndex );
}
bool AreaChart::isSeparateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex*/ )
@@ -148,8 +134,6 @@ uno::Any AreaChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPo
drawing::Direction3D AreaChart::getPreferredDiagramAspectRatio() const
{
- if( m_nKeepAspectRatio == 1 )
- return drawing::Direction3D(1,1,1);
drawing::Direction3D aRet(1,-1,1);
if( m_nDimension == 2 )
aRet = drawing::Direction3D(-1,-1,-1);
@@ -167,10 +151,6 @@ drawing::Direction3D AreaChart::getPreferredDiagramAspectRatio() const
bool AreaChart::keepAspectRatio() const
{
- if( m_nKeepAspectRatio == 0 )
- return false;
- if( m_nKeepAspectRatio == 1 )
- return true;
if( m_nDimension == 2 )
{
if( !m_bSymbol )
@@ -181,7 +161,7 @@ bool AreaChart::keepAspectRatio() const
void AreaChart::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot )
{
- if( m_bArea && !m_bIsPolarCooSys && pSeries )
+ if( m_bArea && pSeries )
{
sal_Int32 nMissingValueTreatment = pSeries->getMissingValueTreatment();
if( nMissingValueTreatment == ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP )
@@ -441,28 +421,7 @@ bool AreaChart::impl_createLine( VDataSeries* pSeries
else
{ // default to creating a straight line
SAL_WARN_IF(CurveStyle_LINES != m_eCurveStyle, "chart2.areachart", "Unknown curve style");
- bool bIsClipped = false;
- if( m_bConnectLastToFirstPoint && !AbstractShapeFactory::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() != ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
- || (::rtl::math::isFinite( fFirstY ) && ::rtl::math::isFinite( fLastY )) )
- {
- // connect last point in last polygon with first point in first polygon
- ::basegfx::B2DRectangle aScaledLogicClipDoubleRect( pPosHelper->getScaledLogicClipDoubleRect() );
- drawing::PolyPolygonShape3D aTmpPoly(*pSeriesPoly);
- drawing::Position3D aLast(aScaledLogicClipDoubleRect.getMaxX(),aTmpPoly.SequenceY[0][0],aTmpPoly.SequenceZ[0][0]);
- // add connector line to last polygon
- AddPointToPoly( aTmpPoly, aLast, pSeriesPoly->SequenceX.getLength() - 1 );
- Clipping::clipPolygonAtRectangle( aTmpPoly, aScaledLogicClipDoubleRect, aPoly );
- bIsClipped = true;
- }
- }
-
- if( !bIsClipped )
- Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
+ Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
}
if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly))
@@ -524,12 +483,7 @@ bool AreaChart::impl_createArea( VDataSeries* pSeries
drawing::PolyPolygonShape3D aPoly( *pSeriesPoly );
//add second part to the polygon (grounding points or previous series points)
- if( m_bConnectLastToFirstPoint && !AbstractShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
- {
- if( pPreviousSeriesPoly )
- addPolygon( aPoly, *pPreviousSeriesPoly );
- }
- else if(!pPreviousSeriesPoly)
+ if(!pPreviousSeriesPoly)
{
double fMinX = pSeries->m_fLogicMinX;
double fMaxX = pSeries->m_fLogicMaxX;
@@ -822,22 +776,6 @@ void AreaChart::createShapes()
fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
double fLogicY = (*aSeriesIter)->getYValue(nIndex);
- if( m_bIsPolarCooSys && m_bArea &&
- ( ::rtl::math::isNan(fLogicY) || ::rtl::math::isInf(fLogicY) ) )
- {
- if( (*aSeriesIter)->getMissingValueTreatment() == ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP )
- {
- if( rSeriesList.size() == 1 || nSeriesIndex == 0 )
- {
- fLogicY = pPosHelper->getLogicMinY();
- if( !pPosHelper->isMathematicalOrientationY() )
- fLogicY = pPosHelper->getLogicMaxY();
- }
- else
- fLogicY = 0.0;
- }
- }
-
if( m_nDimension==3 && m_bArea && rSeriesList.size()!=1 )
fLogicY = fabs( fLogicY );
@@ -911,18 +849,6 @@ void AreaChart::createShapes()
if( isValidPosition(aScaledLogicPosition) )
{
AddPointToPoly( (*aSeriesIter)->m_aPolyPolygonShape3D, aScaledLogicPosition, (*aSeriesIter)->m_nPolygonIndex );
-
- //prepare clipping for filled net charts
- if( !bIsVisible && m_bIsPolarCooSys && m_bArea )
- {
- drawing::Position3D aClippedPos(aScaledLogicPosition);
- pPosHelper->clipScaledLogicValues( 0, &aClippedPos.PositionY, 0 );
- if( pPosHelper->isLogicVisible( aClippedPos.PositionX, aClippedPos.PositionY, aClippedPos.PositionZ ) )
- {
- AddPointToPoly( (*aSeriesIter)->m_aPolyPolygonShape3D, aClippedPos, (*aSeriesIter)->m_nPolygonIndex );
- AddPointToPoly( (*aSeriesIter)->m_aPolyPolygonShape3D, aScaledLogicPosition, (*aSeriesIter)->m_nPolygonIndex );
- }
- }
}
//create a single datapoint if point is visible
@@ -1052,17 +978,6 @@ void AreaChart::createShapes()
awt::Point aScreenPosition2D;//get the screen position for the labels
sal_Int32 nOffset = 100; //todo maybe calculate this font height dependent
- if( m_bIsPolarCooSys && nLabelPlacement == ::com::sun::star::chart::DataLabelPlacement::OUTSIDE )
- {
- PolarPlottingPositionHelper* pPolarPosHelper = dynamic_cast<PolarPlottingPositionHelper*>(pPosHelper);
- if( pPolarPosHelper )
- {
- PolarLabelPositionHelper aPolarLabelPositionHelper(pPolarPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory);
- aScreenPosition2D = awt::Point( aPolarLabelPositionHelper.getLabelScreenPositionAndAlignmentForLogicValues(
- eAlignment, fLogicX, fLogicY, fLogicZ, nOffset ));
- }
- }
- else
{
if(LABEL_ALIGN_CENTER==eAlignment || m_nDimension == 3 )
nOffset = 0;
diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx
index d8ff6b2..029aa77 100644
--- a/chart2/source/view/charttypes/AreaChart.hxx
+++ b/chart2/source/view/charttypes/AreaChart.hxx
@@ -34,10 +34,6 @@ public:
::com::sun::star::chart2::XChartType >& xChartTypeModel
, sal_Int32 nDimensionCount
, bool bCategoryXAxis, bool bNoArea=false
- , PlottingPositionHelper* pPlottingPositionHelper=NULL //takes owner ship
- , bool bConnectLastToFirstPoint=false
- , bool bExpandIfValuesCloseToBorder=true
- , sal_Int32 nKeepAspectRatio=-1 //0->no 1->yes other value->automatic
);
virtual ~AreaChart();
@@ -78,11 +74,6 @@ private: //member
bool m_bArea;//false -> line or symbol only
bool m_bLine;
bool m_bSymbol;
- bool m_bIsPolarCooSys;//used e.g. for net chart (the data labels need to be placed different)
- bool m_bConnectLastToFirstPoint;//used e.g. for net chart
- bool m_bExpandIfValuesCloseToBorder; // e.g. false for net charts
-
- sal_Int32 m_nKeepAspectRatio; //0->no 1->yes other value->automatic
//Properties for splines:
::com::sun::star::chart2::CurveStyle m_eCurveStyle;
commit 60069ef60f53128b2ad539e1da722f7bf380955c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 10 05:33:16 2013 +0200
extract code for net charts from AreaChart
Now AreaChart only contains code for 11 different chart types. NetChart
was the only one needing a PolarPlottingPositionHelper
Change-Id: Ibbe45f9afdf91fea1ef542020d8a3388a6e8c27b
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 8e6d796..601821c 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -82,6 +82,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/view/charttypes/BubbleChart \
chart2/source/view/charttypes/CandleStickChart \
chart2/source/view/charttypes/CategoryPositionHelper \
+ chart2/source/view/charttypes/NetChart \
chart2/source/view/charttypes/PieChart \
chart2/source/view/charttypes/Splines \
chart2/source/view/charttypes/VSeriesPlotter \
diff --git a/chart2/source/view/charttypes/NetChart.cxx b/chart2/source/view/charttypes/NetChart.cxx
new file mode 100644
index 0000000..297de74
--- /dev/null
+++ b/chart2/source/view/charttypes/NetChart.cxx
@@ -0,0 +1,788 @@
+/* -*- 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 "AbstractShapeFactory.hxx"
+#include "CommonConverters.hxx"
+#include "macros.hxx"
+#include "ViewDefines.hxx"
+#include "ObjectIdentifier.hxx"
+#include "Splines.hxx"
+#include "ChartTypeHelper.hxx"
+#include "LabelPositionHelper.hxx"
+#include "Clipping.hxx"
+#include "Stripe.hxx"
+#include "PolarLabelPositionHelper.hxx"
+#include "DateHelper.hxx"
+
+#include <com/sun/star/chart2/Symbol.hpp>
+#include <com/sun/star/chart/DataLabelPlacement.hpp>
+#include <com/sun/star/chart/MissingValueTreatment.hpp>
+
+#include <editeng/unoprnms.hxx>
+#include <rtl/math.hxx>
+
+#include <com/sun/star/drawing/DoubleSequence.hpp>
+#include <com/sun/star/drawing/NormalsKind.hpp>
+#include <com/sun/star/lang/XServiceName.hpp>
+
+namespace chart
+{
+using namespace ::com::sun::star;
+using namespace ::rtl::math;
+using namespace ::com::sun::star::chart2;
+
+NetChart::NetChart( const uno::Reference<XChartType>& xChartTypeModel
+ , sal_Int32 nDimensionCount
+ , bool bNoArea
+ , PlottingPositionHelper* pPlottingPositionHelper
+ )
+ : VSeriesPlotter( xChartTypeModel, nDimensionCount, true )
+ , m_pMainPosHelper(pPlottingPositionHelper)
+ , m_bArea(!bNoArea)
+ , m_bLine(bNoArea)
+ , m_bSymbol( ChartTypeHelper::isSupportingSymbolProperties(xChartTypeModel,nDimensionCount) )
+ , m_xSeriesTarget(0)
+ , m_xTextTarget(0)
+{
+ // 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 = uno::makeAny(*pSymbolProperties);
+ }
+
+ return aRet;
+}
+
+drawing::Direction3D NetChart::getPreferredDiagramAspectRatio() const
+{
+ return drawing::Direction3D(1,1,1);
+}
+
+bool NetChart::keepAspectRatio() const
+{
+ return true;
+}
+
+void NetChart::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot )
+{
+ VSeriesPlotter::addSeries( pSeries, zSlot, xSlot, ySlot );
+}
+
+namespace {
+
+void lcl_removeDuplicatePoints( drawing::PolyPolygonShape3D& rPolyPoly, PlottingPositionHelper& rPosHelper )
+{
+ sal_Int32 nPolyCount = rPolyPoly.SequenceX.getLength();
+ if(!nPolyCount)
+ return;
+
+ drawing::PolyPolygonShape3D aTmp;
+ aTmp.SequenceX.realloc(nPolyCount);
+ aTmp.SequenceY.realloc(nPolyCount);
+ aTmp.SequenceZ.realloc(nPolyCount);
+
+ for( sal_Int32 nPolygonIndex = 0; nPolygonIndex<nPolyCount; nPolygonIndex++ )
+ {
+ drawing::DoubleSequence* pOuterSourceX = &rPolyPoly.SequenceX.getArray()[nPolygonIndex];
+ drawing::DoubleSequence* pOuterSourceY = &rPolyPoly.SequenceY.getArray()[nPolygonIndex];
+ drawing::DoubleSequence* pOuterSourceZ = &rPolyPoly.SequenceZ.getArray()[nPolygonIndex];
+
+ drawing::DoubleSequence* pOuterTargetX = &aTmp.SequenceX.getArray()[nPolygonIndex];
+ drawing::DoubleSequence* pOuterTargetY = &aTmp.SequenceY.getArray()[nPolygonIndex];
+ drawing::DoubleSequence* pOuterTargetZ = &aTmp.SequenceZ.getArray()[nPolygonIndex];
+
+ sal_Int32 nPointCount = pOuterSourceX->getLength();
+ if( !nPointCount )
+ continue;
+
+ pOuterTargetX->realloc(nPointCount);
+ pOuterTargetY->realloc(nPointCount);
+ pOuterTargetZ->realloc(nPointCount);
+
+ double* pSourceX = pOuterSourceX->getArray();
+ double* pSourceY = pOuterSourceY->getArray();
+ double* pSourceZ = pOuterSourceZ->getArray();
+
+ double* pTargetX = pOuterTargetX->getArray();
+ double* pTargetY = pOuterTargetY->getArray();
+ double* pTargetZ = pOuterTargetZ->getArray();
+
+ //copy first point
+ *pTargetX=*pSourceX++;
+ *pTargetY=*pSourceY++;
+ *pTargetZ=*pSourceZ++;
+ sal_Int32 nTargetPointCount=1;
+
+ for( sal_Int32 nSource=1; nSource<nPointCount; nSource++ )
+ {
+ if( !rPosHelper.isSameForGivenResolution( *pTargetX, *pTargetY, *pTargetZ
+ , *pSourceX, *pSourceY, *pSourceZ ) )
+ {
+ pTargetX++; pTargetY++; pTargetZ++;
+ *pTargetX=*pSourceX;
+ *pTargetY=*pSourceY;
+ *pTargetZ=*pSourceZ;
+ nTargetPointCount++;
+ }
+ pSourceX++; pSourceY++; pSourceZ++;
+ }
+
+ //free unused space
+ if( nTargetPointCount<nPointCount )
+ {
+ pOuterTargetX->realloc(nTargetPointCount);
+ pOuterTargetY->realloc(nTargetPointCount);
+ pOuterTargetZ->realloc(nTargetPointCount);
+ }
+
+ pOuterSourceX->realloc(0);
+ pOuterSourceY->realloc(0);
+ pOuterSourceZ->realloc(0);
+ }
+
+ //free space
+ rPolyPoly.SequenceX.realloc(nPolyCount);
+ rPolyPoly.SequenceY.realloc(nPolyCount);
+ rPolyPoly.SequenceZ.realloc(nPolyCount);
+
+ rPolyPoly=aTmp;
+}
+
+}
+
+bool NetChart::impl_createLine( VDataSeries* pSeries
+ , drawing::PolyPolygonShape3D* pSeriesPoly
+ , PlottingPositionHelper* pPosHelper )
+{
+ //return true if a line was created successfully
+ uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
+
+ drawing::PolyPolygonShape3D aPoly;
+ {
+ bool bIsClipped = false;
+ if( !AbstractShapeFactory::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() != ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
+ || (::rtl::math::isFinite( fFirstY ) && ::rtl::math::isFinite( fLastY )) )
+ {
+ // connect last point in last polygon with first point in first polygon
+ ::basegfx::B2DRectangle aScaledLogicClipDoubleRect( pPosHelper->getScaledLogicClipDoubleRect() );
+ drawing::PolyPolygonShape3D aTmpPoly(*pSeriesPoly);
+ drawing::Position3D aLast(aScaledLogicClipDoubleRect.getMaxX(),aTmpPoly.SequenceY[0][0],aTmpPoly.SequenceZ[0][0]);
+ // add connector line to last polygon
+ AddPointToPoly( aTmpPoly, aLast, pSeriesPoly->SequenceX.getLength() - 1 );
+ Clipping::clipPolygonAtRectangle( aTmpPoly, aScaledLogicClipDoubleRect, aPoly );
+ bIsClipped = true;
+ }
+ }
+
+ if( !bIsClipped )
+ Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
+ }
+
+ if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly))
+ return false;
+
+ //transformation 3) -> 4)
+ pPosHelper->transformScaledLogicToScene( aPoly );
+
+ //create line:
+ uno::Reference< drawing::XShape > xShape(NULL);
+ {
+ xShape = m_pShapeFactory->createLine2D( xSeriesGroupShape_Shapes
+ , PolyToPointSequence( aPoly ) );
+ this->setMappedProperties( xShape
+ , pSeries->getPropertiesOfSeries()
+ , PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
+ //because of this name this line will be used for marking
+ m_pShapeFactory->setShapeName(xShape, "MarkHandles");
+ }
+ return true;
+}
+
+bool NetChart::impl_createArea( VDataSeries* pSeries
+ , drawing::PolyPolygonShape3D* pSeriesPoly
+ , drawing::PolyPolygonShape3D* pPreviousSeriesPoly
+ , PlottingPositionHelper* pPosHelper )
+{
+ //return true if an area was created successfully
+
+ uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
+ double zValue = pSeries->m_fLogicZPos;
+
+ drawing::PolyPolygonShape3D aPoly( *pSeriesPoly );
+ //add second part to the polygon (grounding points or previous series points)
+ if( !AbstractShapeFactory::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, 0 );
+ pPosHelper->clipLogicValues( &fMaxX, 0, 0 );
+
+ //apply scaling
+ {
+ pPosHelper->doLogicScaling( &fMinX, &fY, &zValue );
+ pPosHelper->doLogicScaling( &fMaxX, 0, 0 );
+ }
+
+ AddPointToPoly( aPoly, drawing::Position3D( fMaxX,fY,zValue) );
+ AddPointToPoly( aPoly, drawing::Position3D( fMinX,fY,zValue) );
+ }
+ else
+ {
+ appendPoly( aPoly, *pPreviousSeriesPoly );
+ }
+ AbstractShapeFactory::closePolygon(aPoly);
+
+ //apply clipping
+ {
+ drawing::PolyPolygonShape3D aClippedPoly;
+ Clipping::clipPolygonAtRectangle( aPoly, pPosHelper->getScaledLogicClipDoubleRect(), aClippedPoly, false );
+ AbstractShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping
+ aPoly = aClippedPoly;
+ }
+
+ if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly))
+ return false;
+
+ //transformation 3) -> 4)
+ pPosHelper->transformScaledLogicToScene( aPoly );
+
+ //create area:
+ uno::Reference< drawing::XShape >
+ xShape = m_pShapeFactory->createArea2D( xSeriesGroupShape_Shapes
+ , aPoly );
+ this->setMappedProperties( xShape
+ , pSeries->getPropertiesOfSeries()
+ , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
+ //because of this name this line will be used for marking
+ m_pShapeFactory->setShapeName(xShape, "MarkHandles");
+ 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
+ ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin();
+ const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end();
+ for( sal_Int32 nZ=1; aZSlotIter != aZSlotEnd; ++aZSlotIter, ++nZ )
+ {
+ ::std::vector< VDataSeriesGroup >::iterator aXSlotIter = aZSlotIter->begin();
+ const ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end();
+
+ for( ; aXSlotIter != aXSlotEnd; ++aXSlotIter )
+ {
+ ::std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector);
+
+ ::std::vector< VDataSeries* >::const_iterator aSeriesIter = pSeriesList->begin();
+ const ::std::vector< VDataSeries* >::const_iterator aSeriesEnd = pSeriesList->end();
+
+ std::map< sal_Int32, drawing::PolyPolygonShape3D* > aPreviousSeriesPolyMap;//a PreviousSeriesPoly for each different nAttachedAxisIndex
+ drawing::PolyPolygonShape3D* pSeriesPoly = NULL;
+
+ //iterate through all series
+ for( ; aSeriesIter != aSeriesEnd; ++aSeriesIter )
+ {
+ sal_Int32 nAttachedAxisIndex = (*aSeriesIter)->getAttachedAxisIndex();
+ PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
+ if(!pPosHelper)
+ pPosHelper = m_pMainPosHelper.get();
+ PlotterBase::m_pPosHelper = pPosHelper;
+
+ pSeriesPoly = &(*aSeriesIter)->m_aPolyPolygonShape3D;
+ if( m_bArea )
+ {
+ if( !impl_createArea( *aSeriesIter, pSeriesPoly, aPreviousSeriesPolyMap[nAttachedAxisIndex], pPosHelper ) )
+ continue;
+ }
+ if( m_bLine )
+ {
+ if( !impl_createLine( *aSeriesIter, pSeriesPoly, 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( 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( aZIt->size() );
+
+ ::std::vector< VDataSeriesGroup >::reverse_iterator aXIt( aZIt->rbegin() );
+ ::std::vector< VDataSeriesGroup >::reverse_iterator aXEnd( aZIt->rend() );
+ for( ; aXIt != aXEnd; ++aXIt )
+ aXSlot.push_back(*aXIt);
+
+ aRet.push_back(aXSlot);
+ }
+
+ rZSlots.clear();
+ rZSlots = aRet;
+}
+
+}//anonymous namespace
+
+//better performance for big data
+struct FormerPoint
+{
+ FormerPoint( double fX, double fY, double fZ )
+ : m_fX(fX), m_fY(fY), m_fZ(fZ)
+ {}
+ FormerPoint()
+ {
+ ::rtl::math::setNan( &m_fX );
+ ::rtl::math::setNan( &m_fY );
+ ::rtl::math::setNan( &m_fZ );
+ }
+
+ double m_fX;
+ double m_fY;
+ double m_fZ;
+};
+
+void NetChart::createShapes()
+{
+ if( m_aZSlots.begin() == m_aZSlots.end() ) //no series
+ return;
+
+ if( m_bArea )
+ lcl_reorderSeries( m_aZSlots );
+
+ OSL_ENSURE(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"NetChart is not proper initialized");
+ if(!(m_pShapeFactory&&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,OUString() );
+ m_xTextTarget = m_pShapeFactory->createGroup2D( m_xFinalTarget,OUString() );
+
+ //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 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;
+ sal_Int32 nSkippedPoints = 0;
+ sal_Int32 nCreatedPoints = 0;
+ //
+
+ bool bDateCategory = (m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis());
+
+ //iterate through all x values per indices
+ for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
+ {
+ ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin();
+ const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end();
+
+ std::map< sal_Int32, double > aLogicYSumMap;//one for each different nAttachedAxisIndex
+ for( ; aZSlotIter != aZSlotEnd; ++aZSlotIter )
+ {
+ ::std::vector< VDataSeriesGroup >::iterator aXSlotIter = aZSlotIter->begin();
+ const ::std::vector< VDataSeriesGroup >::iterator aXSlotEnd = aZSlotIter->end();
+
+ //iterate through all x slots in this category to get 100percent sum
+ for( ; aXSlotIter != aXSlotEnd; ++aXSlotIter )
+ {
+ std::vector<VDataSeries*>& rSeriesList = aXSlotIter->m_aSeriesVector;
+ std::vector<VDataSeries*>::iterator aSeriesIter = rSeriesList.begin();
+ std::vector<VDataSeries*>::iterator aSeriesEnd = rSeriesList.end();
+
+ for( ; aSeriesIter != aSeriesEnd; ++aSeriesIter )
+ {
+ VDataSeries* pSeries( *aSeriesIter );
+ if(!pSeries)
+ continue;
+
+ if (bDateCategory)
+ pSeries->doSortByXValues();
+
+ sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
+ if( aLogicYSumMap.find(nAttachedAxisIndex)==aLogicYSumMap.end() )
+ aLogicYSumMap[nAttachedAxisIndex]=0.0;
+
+ PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
+ if(!pPosHelper)
+ pPosHelper = m_pMainPosHelper.get();
+ PlotterBase::m_pPosHelper = pPosHelper;
+
+ double fAdd = pSeries->getYValue( nIndex );
+ if( !::rtl::math::isNan(fAdd) && !::rtl::math::isInf(fAdd) )
+ aLogicYSumMap[nAttachedAxisIndex] += fabs( fAdd );
+ }
+ }
+ }
+
+ aZSlotIter = m_aZSlots.begin();
+ for( sal_Int32 nZ=1; aZSlotIter != aZSlotEnd; ++aZSlotIter, ++nZ )
+ {
+ ::std::vector< VDataSeriesGroup >::const_iterator aXSlotIter = aZSlotIter->begin();
+ ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end();
+
+ //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( sal_Int32 nX=0; aXSlotIter != aXSlotEnd; ++aXSlotIter, ++nX )
+ {
+ const std::vector<VDataSeries*>& rSeriesList = aXSlotIter->m_aSeriesVector;
+ std::vector<VDataSeries*>::const_iterator aSeriesIter = rSeriesList.begin();
+ const std::vector<VDataSeries*>::const_iterator aSeriesEnd = rSeriesList.end();
+
+ std::map< sal_Int32, double > aLogicYForNextSeriesMap;//one for each different nAttachedAxisIndex
+ //iterate through all series
+ for( sal_Int32 nSeriesIndex = 0; aSeriesIter != aSeriesEnd; ++aSeriesIter, ++nSeriesIndex )
+ {
+ VDataSeries* pSeries( *aSeriesIter );
+ 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 && (rSeriesList.size() == 1) && (nIndex >= (*aSeriesIter)->getTotalPointCount()) )
+ continue;
+
+ uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(*aSeriesIter, m_xSeriesTarget);
+
+ sal_Int32 nAttachedAxisIndex = (*aSeriesIter)->getAttachedAxisIndex();
+ PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
+ if(!pPosHelper)
+ pPosHelper = m_pMainPosHelper.get();
+ PlotterBase::m_pPosHelper = pPosHelper;
+
+ (*aSeriesIter)->m_fLogicZPos = fLogicZ;
+
+ //collect data point information (logic coordinates, style ):
+ double fLogicX = (*aSeriesIter)->getXValue(nIndex);
+ if (bDateCategory)
+ fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
+ double fLogicY = (*aSeriesIter)->getYValue(nIndex);
+
+ if( m_bArea && ( ::rtl::math::isNan(fLogicY) || ::rtl::math::isInf(fLogicY) ) )
+ {
+ if( (*aSeriesIter)->getMissingValueTreatment() == ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP )
+ {
+ if( rSeriesList.size() == 1 || nSeriesIndex == 0 )
+ {
+ fLogicY = pPosHelper->getLogicMinY();
+ if( !pPosHelper->isMathematicalOrientationY() )
+ fLogicY = pPosHelper->getLogicMaxY();
+ }
+ else
+ fLogicY = 0.0;
+ }
+ }
+
+ if( pPosHelper->isPercentY() && !::rtl::math::approxEqual( aLogicYSumMap[nAttachedAxisIndex], 0.0 ) )
+ {
+ fLogicY = fabs( fLogicY )/aLogicYSumMap[nAttachedAxisIndex];
+ }
+
+ if( ::rtl::math::isNan(fLogicX) || ::rtl::math::isInf(fLogicX)
+ || ::rtl::math::isNan(fLogicY) || ::rtl::math::isInf(fLogicY)
+ || ::rtl::math::isNan(fLogicZ) || ::rtl::math::isInf(fLogicZ) )
+ {
+ if( (*aSeriesIter)->getMissingValueTreatment() == ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP )
+ {
+ drawing::PolyPolygonShape3D& rPolygon = (*aSeriesIter)->m_aPolyPolygonShape3D;
+ sal_Int32& rIndex = (*aSeriesIter)->m_nPolygonIndex;
+ if( 0<= rIndex && rIndex < rPolygon.SequenceX.getLength() )
+ {
+ if( rPolygon.SequenceX[ rIndex ].getLength() )
+ rIndex++; //start a new polygon for the next point if the current poly is not empty
+ }
+ }
+ continue;
+ }
+
+ if( aLogicYForNextSeriesMap.find(nAttachedAxisIndex) == aLogicYForNextSeriesMap.end() )
+ aLogicYForNextSeriesMap[nAttachedAxisIndex] = 0.0;
+
+ double fLogicValueForLabeDisplay = fLogicY;
+
+ fLogicY += aLogicYForNextSeriesMap[nAttachedAxisIndex];
+ aLogicYForNextSeriesMap[nAttachedAxisIndex] = fLogicY;
+
+ bool bIsVisible = pPosHelper->isLogicVisible( fLogicX, fLogicY, fLogicZ );
+
+ //remind minimal and maximal x values for area 'grounding' points
+ //only for filled area
+ {
+ double& rfMinX = (*aSeriesIter)->m_fLogicMinX;
+ if(!nIndex||fLogicX<rfMinX)
+ rfMinX=fLogicX;
+ double& rfMaxX = (*aSeriesIter)->m_fLogicMaxX;
+ if(!nIndex||fLogicX>rfMaxX)
+ rfMaxX=fLogicX;
+ }
+
+ drawing::Position3D aUnscaledLogicPosition( fLogicX, fLogicY, fLogicZ );
+ drawing::Position3D aScaledLogicPosition(aUnscaledLogicPosition);
+ pPosHelper->doLogicScaling( aScaledLogicPosition );
+
+ //transformation 3) -> 4)
+ drawing::Position3D aScenePosition( pPosHelper->transformLogicToScene( fLogicX,fLogicY,fLogicZ, false ) );
+
+ //better performance for big data
+ FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries] );
+ pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution );
+ if( !pSeries->isAttributedDataPoint(nIndex)
+ &&
+ pPosHelper->isSameForGivenResolution( aFormerPoint.m_fX, aFormerPoint.m_fY, aFormerPoint.m_fZ
+ , aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ ) )
+ {
+ ++nSkippedPoints;
+ m_bPointsWereSkipped = true;
+ continue;
+ }
+ aSeriesFormerPointMap[pSeries] = 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( (*aSeriesIter)->m_aPolyPolygonShape3D, aScaledLogicPosition, (*aSeriesIter)->m_nPolygonIndex );
+
+ //prepare clipping for filled net charts
+ if( !bIsVisible && m_bArea )
+ {
+ drawing::Position3D aClippedPos(aScaledLogicPosition);
+ pPosHelper->clipScaledLogicValues( 0, &aClippedPos.PositionY, 0 );
+ if( pPosHelper->isLogicVisible( aClippedPos.PositionX, aClippedPos.PositionY, aClippedPos.PositionZ ) )
+ {
+ AddPointToPoly( (*aSeriesIter)->m_aPolyPolygonShape3D, aClippedPos, (*aSeriesIter)->m_nPolygonIndex );
+ AddPointToPoly( (*aSeriesIter)->m_aPolyPolygonShape3D, aScaledLogicPosition, (*aSeriesIter)->m_nPolygonIndex );
+ }
+ }
+ }
+
+ //create a single datapoint if point is visible
+ //apply clipping:
+ if( !bIsVisible )
+ continue;
+
+ Symbol* pSymbolProperties = m_bSymbol ? (*aSeriesIter)->getSymbolProperties( nIndex ) : 0;
+ 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(
+ (*aSeriesIter)->getPointCID_Stub(), nIndex );
+ uno::Reference< drawing::XShapes > xPointGroupShape_Shapes(
+ createGroupShape(xSeriesGroupShape_Shapes,aPointCID) );
+ uno::Reference<drawing::XShape> xPointGroupShape_Shape =
+ uno::Reference<drawing::XShape>( xPointGroupShape_Shapes, uno::UNO_QUERY );
+
+ {
+ nCreatedPoints++;
+
+ //create data point
+ drawing::Direction3D aSymbolSize(0,0,0);
+ if( bCreateSymbol )
+ {
+ if( 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;
+ m_pShapeFactory->createSymbol2D( xPointGroupShape_Shapes
+ , aScenePosition, aSymbolSize
+ , nSymbol
+ , pSymbolProperties->BorderColor
+ , pSymbolProperties->FillColor );
+ }
+ else if( pSymbolProperties->Style == SymbolStyle_GRAPHIC )
+ {
+ m_pShapeFactory->createGraphic2D( xPointGroupShape_Shapes
+ , aScenePosition , aSymbolSize
+ , pSymbolProperties->Graphic );
+ }
+ //@todo other symbol styles
+ }
+ }
+
+ //create data point label
+ if( (**aSeriesIter).getDataPointLabelIfLabel(nIndex) )
+ {
+ LabelAlignment eAlignment = LABEL_ALIGN_TOP;
+ drawing::Position3D aScenePosition3D( aScenePosition.PositionX
+ , aScenePosition.PositionY
+ , aScenePosition.PositionZ+this->getTransformedDepth() );
+
+ sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() );
+
+ switch(nLabelPlacement)
+ {
+ case ::com::sun::star::chart::DataLabelPlacement::TOP:
+ aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
+ eAlignment = LABEL_ALIGN_TOP;
+ break;
+ case ::com::sun::star::chart::DataLabelPlacement::BOTTOM:
+ aScenePosition3D.PositionY += (aSymbolSize.DirectionY/2+1);
+ eAlignment = LABEL_ALIGN_BOTTOM;
+ break;
+ case ::com::sun::star::chart::DataLabelPlacement::LEFT:
+ aScenePosition3D.PositionX -= (aSymbolSize.DirectionX/2+1);
+ eAlignment = LABEL_ALIGN_LEFT;
+ break;
+ case ::com::sun::star::chart::DataLabelPlacement::RIGHT:
+ aScenePosition3D.PositionX += (aSymbolSize.DirectionX/2+1);
+ eAlignment = LABEL_ALIGN_RIGHT;
+ break;
+ case ::com::sun::star::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 == ::com::sun::star::chart::DataLabelPlacement::OUTSIDE )
+ {
+ PolarPlottingPositionHelper* pPolarPosHelper = dynamic_cast<PolarPlottingPositionHelper*>(pPosHelper);
+ if( pPolarPosHelper )
+ {
+ PolarLabelPositionHelper aPolarLabelPositionHelper(pPolarPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory);
+ aScreenPosition2D = awt::Point( aPolarLabelPositionHelper.getLabelScreenPositionAndAlignmentForLogicValues(
+ eAlignment, fLogicX, fLogicY, fLogicZ, nOffset ));
+ }
+ }
+ else
+ {
+ if(LABEL_ALIGN_CENTER==eAlignment )
+ nOffset = 0;
+ aScreenPosition2D = awt::Point( LabelPositionHelper(pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory)
+ .transformSceneToScreenPosition( aScenePosition3D ) );
+ }
+
+ this->createDataLabel( m_xTextTarget, **aSeriesIter, nIndex
+ , fLogicValueForLabeDisplay
+ , aLogicYSumMap[nAttachedAxisIndex], aScreenPosition2D, eAlignment, nOffset );
+ }
+ }
+
+ //remove PointGroupShape if empty
+ if(!xPointGroupShape_Shapes->getCount())
+ xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shape);
+
+ }//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: */
diff --git a/chart2/source/view/charttypes/NetChart.hxx b/chart2/source/view/charttypes/NetChart.hxx
new file mode 100644
index 0000000..3452241
--- /dev/null
+++ b/chart2/source/view/charttypes/NetChart.hxx
@@ -0,0 +1,86 @@
+/* -*- 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 .
+ */
+
+#ifndef _CHART2_NETCHART_HXX
+#define _CHART2_NETCHART_HXX
+
+#include "VSeriesPlotter.hxx"
+
+namespace chart
+{
+
+class NetChart : public VSeriesPlotter
+{
+ // public methods
+public:
+ NetChart( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartType >& xChartTypeModel
+ , sal_Int32 nDimensionCount
+ , bool bNoArea
+ , PlottingPositionHelper* pPlottingPositionHelper //takes owner ship
+ );
+ virtual ~NetChart();
+
+ virtual void createShapes();
+ virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 );
+
+ virtual ::com::sun::star::drawing::Direction3D getPreferredDiagramAspectRatio() const;
+ virtual bool keepAspectRatio() const;
+
+ // MinimumAndMaximumSupplier
+ virtual double getMaximumX();
+ virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex );
+ virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex );
+
+ virtual LegendSymbolStyle getLegendSymbolStyle();
+ virtual ::com::sun::star::uno::Any getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex=-1/*-1 for series symbol*/ );
+
+private: //methods
+ //no default constructor
+ NetChart();
+
+ void impl_createSeriesShapes();
+ bool impl_createArea( VDataSeries* pSeries
+ , ::com::sun::star::drawing::PolyPolygonShape3D* pSeriesPoly
+ , ::com::sun::star::drawing::PolyPolygonShape3D* pPreviousSeriesPoly
+ , PlottingPositionHelper* pPosHelper );
+ bool impl_createLine( VDataSeries* pSeries
+ , ::com::sun::star::drawing::PolyPolygonShape3D* pSeriesPoly
+ , PlottingPositionHelper* pPosHelper );
+
+private: //member
+ boost::scoped_ptr<PlottingPositionHelper> m_pMainPosHelper;
+
+ bool m_bArea;//false -> line or symbol only
+ bool m_bLine;
+ bool m_bSymbol;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes > m_xSeriesTarget;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes > m_xErrorBarTarget;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes > m_xTextTarget;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes > m_xRegressionCurveEquationTarget;
+};
+} //namespace chart
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 444ee2e..44e4c58 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -50,6 +50,7 @@
#include "AreaChart.hxx"
#include "CandleStickChart.hxx"
#include "BubbleChart.hxx"
+#include "NetChart.hxx"
//
#include <com/sun/star/chart/ErrorBarStyle.hpp>
@@ -2434,9 +2435,9 @@ VSeriesPlotter* VSeriesPlotter::createSeriesPlotter(
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
pRet = new PieChart(xChartTypeModel,nDimensionCount, bExcludingPositioning );
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
- pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,true,new PolarPlottingPositionHelper(),true,false,1 );
+ pRet = new NetChart(xChartTypeModel,nDimensionCount,true,new PolarPlottingPositionHelper());
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
- pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,false,new PolarPlottingPositionHelper(),true,false,1 );
+ pRet = new NetChart(xChartTypeModel,nDimensionCount,false,new PolarPlottingPositionHelper());
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
pRet = new CandleStickChart(xChartTypeModel,nDimensionCount);
else
commit 5a32bd0b1ceb3fcbd8f0478d5b65ac6cdad9410a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 10 04:00:25 2013 +0200
make it a normal variable
Change-Id: I75e38a02d48db938df2216bc245f34f363838042
diff --git a/chart2/source/view/inc/VDataSeries.hxx b/chart2/source/view/inc/VDataSeries.hxx
index 224c54f..3148247 100644
--- a/chart2/source/view/inc/VDataSeries.hxx
+++ b/chart2/source/view/inc/VDataSeries.hxx
@@ -190,9 +190,6 @@ public: //member
private: //member
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries > m_xDataSeries;
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XLabeledDataSequence > > m_aDataSequences;
//all points given by the model data (here are not only the visible points meant)
sal_Int32 m_nPointCount;
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index def2f6e..72cefde 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -189,13 +189,15 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
uno::Reference<data::XDataSource> xDataSource =
uno::Reference<data::XDataSource>( xDataSeries, uno::UNO_QUERY );
- m_aDataSequences = xDataSource->getDataSequences();
+ uno::Sequence< uno::Reference<
+ chart2::data::XLabeledDataSequence > > aDataSequences =
+ xDataSource->getDataSequences();
- for(sal_Int32 nN = m_aDataSequences.getLength();nN--;)
+ for(sal_Int32 nN = aDataSequences.getLength();nN--;)
{
- if(!m_aDataSequences[nN].is())
+ if(!aDataSequences[nN].is())
continue;
- uno::Reference<data::XDataSequence> xDataSequence( m_aDataSequences[nN]->getValues());
+ uno::Reference<data::XDataSequence> xDataSequence( aDataSequences[nN]->getValues());
uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY );
if( xProp.is())
{
commit bf6898469dd8f68c1557a6e4f9a951698aa11f83
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 10 03:20:32 2013 +0200
leave default constructed objects out
Change-Id: I551574e33d1a3c08c0653f88f2d626beee3f2594
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index d7e1522..def2f6e 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -152,17 +152,8 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
, m_xFrontSubGroupShape(NULL)
, m_xBackSubGroupShape(NULL)
, m_xDataSeries(xDataSeries)
- , m_aDataSequences()
, m_nPointCount(0)
- , m_aValues_X()
- , m_aValues_Y()
- , m_aValues_Z()
- , m_aValues_Y_Min()
- , m_aValues_Y_Max()
- , m_aValues_Y_First()
- , m_aValues_Y_Last()
- , m_aValues_Bubble_Size()
, m_pValueSequenceForDataLabelNumberFormatDetection(&m_aValues_Y)
, m_fXMeanValue(1.0)
@@ -176,11 +167,6 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
, m_bGroupBarsPerAxis(sal_True)
, m_nStartingAngle(90)
- , m_aSeriesParticle()
- , m_aCID()
- , m_aPointCID_Stub()
- , m_aLabelCID_Stub()
-
, m_nGlobalSeriesIndex(0)
, m_apLabel_Series(NULL)
commit 5699b320fbf0fc2676c16ba9697d8297c0cd3b2d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 10 03:10:45 2013 +0200
small clean up in chart code
Change-Id: I42c1b4aa4e174917199d1635a044b8698d8ae851
diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx
index ef9e1a1..96386d8 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -117,8 +117,6 @@ drawing::Direction3D BarChart::getPreferredDiagramAspectRatio() const
bool BarChart::keepAspectRatio() const
{
- if( m_nDimension == 3 )
- return true;
return true;
}
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index be9af9f..444ee2e 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -110,7 +110,7 @@ VDataSeriesGroup::~VDataSeriesGroup()
void VDataSeriesGroup::deleteSeries()
{
//delete all data series help objects:
- ::std::vector< VDataSeries* >::const_iterator aIter = m_aSeriesVector.begin();
+ ::std::vector< VDataSeries* >::const_iterator aIter = m_aSeriesVector.begin();
const ::std::vector< VDataSeries* >::const_iterator aEnd = m_aSeriesVector.end();
for( ; aIter != aEnd; ++aIter )
{
@@ -168,8 +168,8 @@ VSeriesPlotter::~VSeriesPlotter()
while( aPosIt != m_aSecondaryPosHelperMap.end() )
{
PlottingPositionHelper* pPosHelper = aPosIt->second;
- if( pPosHelper )
- delete pPosHelper;
+ delete pPosHelper;
+
++aPosIt;
}
m_aSecondaryPosHelperMap.clear();
@@ -2418,7 +2418,6 @@ VSeriesPlotter* VSeriesPlotter::createSeriesPlotter(
{
OUString aChartType = xChartTypeModel->getChartType();
- //@todo: in future the plotter should be instanciated via service factory
VSeriesPlotter* pRet=NULL;
if( aChartType.equalsIgnoreAsciiCase( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ) )
pRet = new BarChart(xChartTypeModel,nDimensionCount);
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index ae309b4..ae48bbb 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -679,6 +679,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount, bExcludingPositioning );
if( !pPlotter )
continue;
+
m_aSeriesPlotterList.push_back( pPlotter );
pPlotter->setNumberFormatsSupplier( xNumberFormatsSupplier );
pPlotter->setColorScheme( xColorScheme );
@@ -693,6 +694,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
OSL_ASSERT( xDataSeriesContainer.is());
if( !xDataSeriesContainer.is() )
continue;
+
sal_Int32 zSlot=-1;
sal_Int32 xSlot=-1;
sal_Int32 ySlot=-1;
commit 69b134a5e34cb6783594bee7a39c0081bf539b78
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 10 02:55:47 2013 +0200
we only support 2D Bubble Charts anyway
Change-Id: I3e1ac100c3c217e194f2b58c2dadcec370560d51
diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx
index fd6306d..1db4d83 100644
--- a/chart2/source/view/charttypes/BubbleChart.cxx
+++ b/chart2/source/view/charttypes/BubbleChart.cxx
@@ -52,6 +52,9 @@ BubbleChart::BubbleChart( const uno::Reference<XChartType>& xChartTypeModel
, m_fMaxLogicBubbleSize( 0.0 )
, m_fBubbleSizeFactorToScreen( 1.0 )
{
+ // We only support 2 dimensional bubble charts
+ assert(nDimensionCount == 2);
+
if( !m_pMainPosHelper )
m_pMainPosHelper = new PlottingPositionHelper();
PlotterBase::m_pPosHelper = m_pMainPosHelper;
@@ -253,9 +256,6 @@ void BubbleChart::createShapes()
pPosHelper = m_pMainPosHelper;
PlotterBase::m_pPosHelper = pPosHelper;
- if(m_nDimension==3)
- fLogicZ = nZ+0.5;
-
//collect data point information (logic coordinates, style ):
double fLogicX = pSeries->getXValue(nIndex);
double fLogicY = pSeries->getYValue(nIndex);
@@ -311,18 +311,15 @@ void BubbleChart::createShapes()
//create data point
drawing::Direction3D aSymbolSize = transformToScreenBubbleSize( fBubbleSize );
- if(m_nDimension!=3)
- {
- uno::Reference<drawing::XShape> xShape;
- xShape = m_pShapeFactory->createCircle2D( xPointGroupShape_Shapes
- , aScenePosition, aSymbolSize );
+ uno::Reference<drawing::XShape> xShape;
+ xShape = m_pShapeFactory->createCircle2D( xPointGroupShape_Shapes
+ , aScenePosition, aSymbolSize );
- this->setMappedProperties( xShape
- , pSeries->getPropertiesOfPoint( nIndex )
- , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
+ this->setMappedProperties( xShape
+ , pSeries->getPropertiesOfPoint( nIndex )
+ , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
- m_pShapeFactory->setShapeName( xShape, "MarkHandles" );
- }
+ m_pShapeFactory->setShapeName( xShape, "MarkHandles" );
//create data point label
if( (**aSeriesIter).getDataPointLabelIfLabel(nIndex) )
More information about the Libreoffice-commits
mailing list