From 4aa21a800326f7dc0c5869a667a4fab14b041f73 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Tue, 4 Nov 2003 12:18:21 +0000 Subject: [PATCH] added clipping for lines and stripes; removed problem with grids lying in front of series --- chart2/source/view/charttypes/AreaChart.cxx | 127 ++++++++++++++++++-- 1 file changed, 120 insertions(+), 7 deletions(-) diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index 5c5a772d976e..d46e3d9af2c6 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -8,6 +8,7 @@ #include "ViewDefines.hxx" #include "TransformationHelper.hxx" #include "chartview/ObjectIdentifier.hxx" +#include "Clipping.hxx" #ifndef _SV_GEN_HXX #include @@ -57,6 +58,7 @@ public: double getTransformedDepth() const; Rectangle getTransformedClipRect() const; + DoubleRectangle getTransformedClipDoubleRect() const; double getLogicGrounding() const; @@ -82,7 +84,7 @@ double AreaPositionHelper::getTransformedDepth() const return FIXED_SIZE_FOR_3D_CHART_VOLUME/(MaxZ-MinZ); } -Rectangle AreaPositionHelper::getTransformedClipRect() const +DoubleRectangle AreaPositionHelper::getTransformedClipDoubleRect() const { //get logic clip values: double MinX = getLogicMinX(); @@ -105,10 +107,21 @@ Rectangle AreaPositionHelper::getTransformedClipRect() const aMaximum = SequenceToPosition3D( getTransformationLogicToScene() ->transform( Position3DToSequence(aMaximum) ) ); - Rectangle aRet( static_cast(aMimimum.PositionX) - , static_cast(aMaximum.PositionY) - , static_cast(aMaximum.PositionX) - , static_cast(aMimimum.PositionY) ); + DoubleRectangle aRet( aMimimum.PositionX + , aMaximum.PositionY + , aMaximum.PositionX + , aMimimum.PositionY ); + return aRet; +} + +Rectangle AreaPositionHelper::getTransformedClipRect() const +{ + DoubleRectangle aDoubleRect( this->getTransformedClipDoubleRect() ); + + Rectangle aRet( static_cast(aDoubleRect.Left) + , static_cast(aDoubleRect.Top) + , static_cast(aDoubleRect.Right) + , static_cast(aDoubleRect.Bottom) ); return aRet; } @@ -240,6 +253,89 @@ drawing::PolyPolygonShape3D createBorderPolygon( return aRet; } +drawing::Position3D Vector3DToPosition3D( const Vector3D& rVector) +{ + return drawing::Position3D( + rVector.X() + , rVector.Y() + , rVector.Z() + ); +} + +/* +drawing::Position3D lcl_getPosition3DFromPoly( sal_Int32 nIndex, const drawing::PolyPolygonShape3D& rPoly ) +{ + drawing::Position3D aRet(0.0,0.0,0.0); + if(nIndex<0) + return aRet; + if( !rPoly.SequenceX.getLength() ) + return aRet; + if( rPoly.SequenceX[0].getLength() <= nIndex ) + return aRet; + + aRet.PositionX = rPoly.SequenceX[0][nIndex]; + aRet.PositionY = rPoly.SequenceY[0][nIndex]; + aRet.PositionZ = rPoly.SequenceZ[0][nIndex]; + return aRet; +} + +drawing::Position3D lcl_getNormal( const drawing::Position3D& rPos1 + , const drawing::Position3D& rPos2 ) +{ + drawing::Position3D rPos3(rPos2); + rPos3.PositionZ+=100;//arbitrary value not NULL + + Polygon3D aPolygon3D(3); + aPolygon3D[0] = Position3DToVector3D( rPos1 ); + aPolygon3D[1] = Position3DToVector3D( rPos2 ); + aPolygon3D[2] = Position3DToVector3D( rPos3 ); + Vector3D aNormal = aPolygon3D.GetNormal(); + return Vector3DToPosition3D(aNormal); +} + +drawing::PolyPolygonShape3D lcl_getNormalPolygon( const drawing::PolyPolygonShape3D& rPoly ) +{ + drawing::PolyPolygonShape3D aNormalPoly; + + sal_Int32 nPolyCount = rPoly.SequenceX.getLength(); + if(!nPolyCount) + return aNormalPoly; + + aNormalPoly.SequenceX.realloc(nPolyCount); + aNormalPoly.SequenceY.realloc(nPolyCount); + aNormalPoly.SequenceZ.realloc(nPolyCount); + + for(sal_Int32 nPoly=0;nPoly create3DLine( const uno::Reference< drawing::XShapes >& xTarget , uno::Reference< lang::XMultiServiceFactory > m_xShapeFactory @@ -267,6 +363,13 @@ uno::Reference< drawing::XShape > xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ) , uno::makeAny( rPoly ) ); + /* + //Normals Polygon + drawing::PolyPolygonShape3D aNormalPoly = lcl_getNormalPolygon( rPoly ); + xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALSPOLYGON3D ) + , uno::makeAny( aNormalPoly ) ); + */ + //NormalsKind xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALS_KIND ) , uno::makeAny( drawing::NormalsKind_FLAT ) ); @@ -289,13 +392,17 @@ bool AreaChart::impl_createLine( VDataSeries* pSeries //return true if a line was created successfully uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShape(pSeries, m_xLogicTarget); - drawing::PolyPolygonShape3D aPoly( *pSeriesPoly ); + m_pPosHelper->getTransformedClipRect(); + drawing::PolyPolygonShape3D aPoly; + Clipping::clipPolygonAtRectangle( *pSeriesPoly, m_pPosHelper->getTransformedClipDoubleRect(), aPoly ); + + /* double fMinZ = m_pPosHelper->getLogicMinZ(); m_pPosHelper->doLogicScaling( NULL, NULL, &fMinZ ); - Polygon aToolsPoly = PolyToToolsPoly( aPoly ); aToolsPoly.Clip( m_pPosHelper->getTransformedClipRect() ); aPoly = ToolsPolyToPoly( aToolsPoly, fMinZ ); + */ if(isPolygonEmptyOrSinglePoint(aPoly)) return false; @@ -503,6 +610,11 @@ void AreaChart::createShapes() DBG_ASSERT(xProp.is(), "created shape offers no XPropertySet"); if( xProp.is()) { + /* + //@todo + //this was a hack for placing symbols + //a wrong result was that gridlines got in front of the series + //when introducing the symbols there has to be found another way try { uno::Any aAZOrder = xProp->getPropertyValue( C2U( UNO_NAME_MISC_OBJ_ZORDER ) ); @@ -515,6 +627,7 @@ void AreaChart::createShapes() { e; } + */ } }