Kaydet (Commit) 9408a1d0 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Draw MeanValue in chart bounds, smarter define no. of curve points.

Change-Id: Ida8006af7f2771ee5f2c425d5c72df4cdba827b5
üst 95314b1f
...@@ -966,22 +966,26 @@ void VSeriesPlotter::createErrorBar_Y( const drawing::Position3D& rUnscaledLogic ...@@ -966,22 +966,26 @@ void VSeriesPlotter::createErrorBar_Y( const drawing::Position3D& rUnscaledLogic
void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries, void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries,
const uno::Reference< drawing::XShapes >& xTarget, const uno::Reference< drawing::XShapes >& xTarget,
const uno::Reference< drawing::XShapes >& xEquationTarget, const uno::Reference< drawing::XShapes >& xEquationTarget,
bool bMaySkipPointsInRegressionCalculation ) bool bMaySkipPoints )
{ {
if(m_nDimension!=2) if(m_nDimension!=2)
return; return;
uno::Reference< XRegressionCurveContainer > xRegressionContainer( uno::Reference< XRegressionCurveContainer > xContainer( rVDataSeries.getModel(), uno::UNO_QUERY );
rVDataSeries.getModel(), uno::UNO_QUERY ); if(!xContainer.is())
if(!xRegressionContainer.is())
return; return;
uno::Sequence< uno::Reference< XRegressionCurve > > aCurveList = uno::Sequence< uno::Reference< XRegressionCurve > > aCurveList = xContainer->getRegressionCurves();
xRegressionContainer->getRegressionCurves();
for(sal_Int32 nN=0; nN<aCurveList.getLength(); nN++) for(sal_Int32 nN=0; nN<aCurveList.getLength(); nN++)
{ {
uno::Reference< XRegressionCurveCalculator > xCalculator( aCurveList[nN]->getCalculator() );
if( !xCalculator.is())
continue;
uno::Reference< beans::XPropertySet > xProperties( aCurveList[nN], uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xProperties( aCurveList[nN], uno::UNO_QUERY );
bool bAverageLine = RegressionCurveHelper::isMeanValueLine( aCurveList[nN] );
sal_Int32 aDegree = 2; sal_Int32 aDegree = 2;
sal_Int32 aPeriod = 2; sal_Int32 aPeriod = 2;
double aExtrapolateForward = 0.0; double aExtrapolateForward = 0.0;
...@@ -989,7 +993,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries, ...@@ -989,7 +993,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries,
sal_Bool aForceIntercept = false; sal_Bool aForceIntercept = false;
double aInterceptValue = 0.0; double aInterceptValue = 0.0;
if ( xProperties.is() ) if ( xProperties.is() && !bAverageLine )
{ {
xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree; xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree;
xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod; xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod;
...@@ -1000,29 +1004,40 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries, ...@@ -1000,29 +1004,40 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries,
xProperties->getPropertyValue( "InterceptValue") >>= aInterceptValue; xProperties->getPropertyValue( "InterceptValue") >>= aInterceptValue;
} }
uno::Reference< XRegressionCurveCalculator > xRegressionCurveCalculator( aCurveList[nN]->getCalculator() );
if( ! xRegressionCurveCalculator.is())
continue;
double fMinX; double fMinX;
double fMaxX; double fMaxX;
rVDataSeries.getMinMaxXValue(fMinX, fMaxX); double fChartMinX = m_pPosHelper->getLogicMinX();
fMaxX += aExtrapolateForward; double fChartMaxX = m_pPosHelper->getLogicMaxX();
fMinX -= aExtrapolateBackward;
xRegressionCurveCalculator->setRegressionProperties(aDegree, aForceIntercept, aInterceptValue, aPeriod); double fPointScale = 1.0;
xRegressionCurveCalculator->recalculateRegression( rVDataSeries.getAllX(), rVDataSeries.getAllY() );
if( bAverageLine )
{
fMinX = fChartMinX;
fMaxX = fChartMaxX;
}
else
{
rVDataSeries.getMinMaxXValue(fMinX, fMaxX);
fMaxX += aExtrapolateForward;
fMinX -= aExtrapolateBackward;
fPointScale = (fMaxX - fMinX) / (fChartMaxX - fChartMinX);
}
xCalculator->setRegressionProperties(aDegree, aForceIntercept, aInterceptValue, aPeriod);
xCalculator->recalculateRegression( rVDataSeries.getAllX(), rVDataSeries.getAllY() );
sal_Int32 nPointCount = 100 * fPointScale;
sal_Int32 nRegressionPointCount = 100; //@todo find a more optimal solution if more complicated curve types are introduced
drawing::PolyPolygonShape3D aRegressionPoly; drawing::PolyPolygonShape3D aRegressionPoly;
aRegressionPoly.SequenceX.realloc(1); aRegressionPoly.SequenceX.realloc(1);
aRegressionPoly.SequenceY.realloc(1); aRegressionPoly.SequenceY.realloc(1);
aRegressionPoly.SequenceZ.realloc(1); aRegressionPoly.SequenceZ.realloc(1);
aRegressionPoly.SequenceX[0].realloc(nRegressionPointCount); aRegressionPoly.SequenceX[0].realloc(nPointCount);
aRegressionPoly.SequenceY[0].realloc(nRegressionPointCount); aRegressionPoly.SequenceY[0].realloc(nPointCount);
aRegressionPoly.SequenceZ[0].realloc(nRegressionPointCount); aRegressionPoly.SequenceZ[0].realloc(nPointCount);
sal_Int32 nRealPointCount=0; sal_Int32 nRealPointCount=0;
std::vector< ExplicitScaleData > aScales( m_pPosHelper->getScales()); std::vector< ExplicitScaleData > aScales( m_pPosHelper->getScales());
...@@ -1035,16 +1050,15 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries, ...@@ -1035,16 +1050,15 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries,
} }
uno::Sequence< geometry::RealPoint2D > aCalculatedPoints( uno::Sequence< geometry::RealPoint2D > aCalculatedPoints(
xRegressionCurveCalculator->getCurveValues( xCalculator->getCurveValues(
fMinX, fMaxX, nRegressionPointCount, xScalingX, xScalingY, bMaySkipPointsInRegressionCalculation )); fMinX, fMaxX, nPointCount,
nRegressionPointCount = aCalculatedPoints.getLength(); xScalingX, xScalingY, bMaySkipPoints ));
bool bAverageLine = RegressionCurveHelper::isMeanValueLine( aCurveList[nN] );
for(sal_Int32 nP=0; nP<nRegressionPointCount; nP++) for(sal_Int32 nP=0; nP<aCalculatedPoints.getLength(); nP++)
{ {
double fLogicX = aCalculatedPoints[nP].X; double fLogicX = aCalculatedPoints[nP].X;
double fLogicY = aCalculatedPoints[nP].Y; double fLogicY = aCalculatedPoints[nP].Y;
double fLogicZ = 0.0;//dummy double fLogicZ = 0.0; //dummy
// fdo#51656: don't scale mean value lines // fdo#51656: don't scale mean value lines
if(!bAverageLine) if(!bAverageLine)
...@@ -1089,7 +1103,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries, ...@@ -1089,7 +1103,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries,
{ {
createRegressionCurveEquationShapes( createRegressionCurveEquationShapes(
rVDataSeries.getDataCurveEquationCID( nN ), rVDataSeries.getDataCurveEquationCID( nN ),
xEquationProperties, xEquationTarget, xRegressionCurveCalculator, xEquationProperties, xEquationTarget, xCalculator,
aDefaultPos ); aDefaultPos );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment