diff options
Diffstat (limited to 'chart2/source/view/axes/VCartesianGrid.cxx')
-rw-r--r-- | chart2/source/view/axes/VCartesianGrid.cxx | 123 |
1 files changed, 52 insertions, 71 deletions
diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx index eda61d9b8e6c..ef00c97f14b5 100644 --- a/chart2/source/view/axes/VCartesianGrid.cxx +++ b/chart2/source/view/axes/VCartesianGrid.cxx @@ -25,9 +25,9 @@ #include <CommonConverters.hxx> #include <AxisHelper.hxx> #include <VLineProperties.hxx> +#include <GridProperties.hxx> #include <com/sun/star/drawing/PointSequenceSequence.hpp> #include <com/sun/star/drawing/LineStyle.hpp> -#include <com/sun/star/chart2/XTransformation.hpp> #include <memory> #include <vector> @@ -62,10 +62,7 @@ GridLinePoints::GridLinePoints( const PlottingPositionHelper* pPosHelper, sal_In , CuboidPlanePosition eLeftWallPos , CuboidPlanePosition eBackWallPos , CuboidPlanePosition eBottomPos ) - : P0(3) - , P1(3) - , P2(3) - , m_nDimensionIndex(nDimensionIndex) + : m_nDimensionIndex(nDimensionIndex) { double MinX = pPosHelper->getLogicMinX(); double MinY = pPosHelper->getLogicMinY(); @@ -78,51 +75,40 @@ GridLinePoints::GridLinePoints( const PlottingPositionHelper* pPosHelper, sal_In pPosHelper->doLogicScaling( &MaxX,&MaxY,&MaxZ ); if(!pPosHelper->isMathematicalOrientationX()) - { - double fHelp = MinX; - MinX = MaxX; - MaxX = fHelp; - } + std::swap( MinX, MaxX ); if(!pPosHelper->isMathematicalOrientationY()) - { - double fHelp = MinY; - MinY = MaxY; - MaxY = fHelp; - } + std::swap( MinY, MaxY ); if(pPosHelper->isMathematicalOrientationZ())//z axis in draw is reverse to mathematical - { - double fHelp = MinZ; - MinZ = MaxZ; - MaxZ = fHelp; - } + std::swap( MinZ, MaxZ ); bool bSwapXY = pPosHelper->isSwapXAndY(); //P0: point on 'back' wall, not on 'left' wall //P1: point on both walls //P2: point on 'left' wall not on 'back' wall - P0[0]=P1[0]=P2[0]= (eLeftWallPos == CuboidPlanePosition_Left || bSwapXY) ? MinX : MaxX; - P0[1]=P1[1]=P2[1]= (eLeftWallPos == CuboidPlanePosition_Left || !bSwapXY) ? MinY : MaxY; - P0[2]=P1[2]=P2[2]= (eBackWallPos == CuboidPlanePosition_Back) ? MinZ : MaxZ; + const double v0 = (eLeftWallPos == CuboidPlanePosition_Left || bSwapXY) ? MinX : MaxX; + const double v1 = (eLeftWallPos == CuboidPlanePosition_Left || !bSwapXY) ? MinY : MaxY; + const double v2 = (eBackWallPos == CuboidPlanePosition_Back) ? MinZ : MaxZ; + P0 = P1 = P2 = { v0, v1, v2 }; if(m_nDimensionIndex==0) { - P0[1]= (eLeftWallPos == CuboidPlanePosition_Left || !bSwapXY) ? MaxY : MinY; - P2[2]= (eBackWallPos == CuboidPlanePosition_Back) ? MaxZ : MinZ; + P0.getArray()[1] = (eLeftWallPos == CuboidPlanePosition_Left || !bSwapXY) ? MaxY : MinY; + P2.getArray()[2]= (eBackWallPos == CuboidPlanePosition_Back) ? MaxZ : MinZ; if( eBottomPos != CuboidPlanePosition_Bottom && !bSwapXY ) P2=P1; } else if(m_nDimensionIndex==1) { - P0[0]= (eLeftWallPos == CuboidPlanePosition_Left || bSwapXY) ? MaxX : MinX; - P2[2]= (eBackWallPos == CuboidPlanePosition_Back) ? MaxZ : MinZ; + P0.getArray()[0]= (eLeftWallPos == CuboidPlanePosition_Left || bSwapXY) ? MaxX : MinX; + P2.getArray()[2]= (eBackWallPos == CuboidPlanePosition_Back) ? MaxZ : MinZ; if( eBottomPos != CuboidPlanePosition_Bottom && bSwapXY ) P2=P1; } else if(m_nDimensionIndex==2) { - P0[0]= (eLeftWallPos == CuboidPlanePosition_Left || bSwapXY) ? MaxX : MinX; - P2[1]= (eLeftWallPos == CuboidPlanePosition_Left || !bSwapXY) ? MaxY : MinY; + P0.getArray()[0]= (eLeftWallPos == CuboidPlanePosition_Left || bSwapXY) ? MaxX : MinX; + P2.getArray()[1]= (eLeftWallPos == CuboidPlanePosition_Left || !bSwapXY) ? MaxY : MinY; if( eBottomPos != CuboidPlanePosition_Bottom ) { if( !bSwapXY ) @@ -135,40 +121,38 @@ GridLinePoints::GridLinePoints( const PlottingPositionHelper* pPosHelper, sal_In void GridLinePoints::update( double fScaledTickValue ) { - P0[m_nDimensionIndex] = P1[m_nDimensionIndex] = P2[m_nDimensionIndex] = fScaledTickValue; + P0.getArray()[m_nDimensionIndex] = P1.getArray()[m_nDimensionIndex] = P2.getArray()[m_nDimensionIndex] = fScaledTickValue; } static void addLine2D( drawing::PointSequenceSequence& rPoints, sal_Int32 nIndex , const GridLinePoints& rScaledLogicPoints - , const Reference< XTransformation > & xTransformation + , const XTransformation2& rTransformation ) { - drawing::Position3D aPA = SequenceToPosition3D( xTransformation->transform( rScaledLogicPoints.P0 ) ); - drawing::Position3D aPB = SequenceToPosition3D( xTransformation->transform( rScaledLogicPoints.P1 ) ); - - rPoints[nIndex].realloc(2); - rPoints[nIndex][0].X = static_cast<sal_Int32>(aPA.PositionX); - rPoints[nIndex][0].Y = static_cast<sal_Int32>(aPA.PositionY); - rPoints[nIndex][1].X = static_cast<sal_Int32>(aPB.PositionX); - rPoints[nIndex][1].Y = static_cast<sal_Int32>(aPB.PositionY); + drawing::Position3D aPA = rTransformation.transform( SequenceToPosition3D(rScaledLogicPoints.P0) ); + drawing::Position3D aPB = rTransformation.transform( SequenceToPosition3D(rScaledLogicPoints.P1) ); + + rPoints.getArray()[nIndex] + = { { static_cast<sal_Int32>(aPA.PositionX), static_cast<sal_Int32>(aPA.PositionY) }, + { static_cast<sal_Int32>(aPB.PositionX), static_cast<sal_Int32>(aPB.PositionY) } }; } -static void addLine3D( drawing::PolyPolygonShape3D& rPoints, sal_Int32 nIndex +static void addLine3D( std::vector<std::vector<css::drawing::Position3D>>& rPoints, sal_Int32 nIndex , const GridLinePoints& rBasePoints - , const Reference< XTransformation > & xTransformation ) + , const XTransformation2 & rTransformation ) { - drawing::Position3D aPoint = SequenceToPosition3D( xTransformation->transform( rBasePoints.P0 ) ); + drawing::Position3D aPoint =rTransformation.transform( rBasePoints.P0 ); AddPointToPoly( rPoints, aPoint, nIndex ); - aPoint = SequenceToPosition3D( xTransformation->transform( rBasePoints.P1 ) ); + aPoint = rTransformation.transform( rBasePoints.P1 ); AddPointToPoly( rPoints, aPoint, nIndex ); - aPoint = SequenceToPosition3D( xTransformation->transform( rBasePoints.P2 ) ); + aPoint = rTransformation.transform( rBasePoints.P2 ); AddPointToPoly( rPoints, aPoint, nIndex ); } VCartesianGrid::VCartesianGrid( sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount - , const Sequence< Reference< beans::XPropertySet > > & rGridPropertiesList ) + , std::vector< rtl::Reference< ::chart::GridProperties > > aGridPropertiesList ) : VAxisOrGridBase( nDimensionIndex, nDimensionCount ) - , m_aGridPropertiesList( rGridPropertiesList ) + , m_aGridPropertiesList( std::move(aGridPropertiesList) ) { m_pPosHelper = new PlottingPositionHelper(); } @@ -180,10 +164,10 @@ VCartesianGrid::~VCartesianGrid() } void VCartesianGrid::fillLinePropertiesFromGridModel( std::vector<VLineProperties>& rLinePropertiesList - , const Sequence< Reference< beans::XPropertySet > > & rGridPropertiesList ) + , const std::vector< rtl::Reference< ::chart::GridProperties > > & rGridPropertiesList ) { rLinePropertiesList.clear(); - if( !rGridPropertiesList.hasElements() ) + if( rGridPropertiesList.empty() ) return; VLineProperties aLineProperties; @@ -199,12 +183,12 @@ void VCartesianGrid::fillLinePropertiesFromGridModel( std::vector<VLinePropertie void VCartesianGrid::createShapes() { - if(!m_aGridPropertiesList.hasElements()) + if(m_aGridPropertiesList.empty()) return; //somehow equal to axis tickmarks //create named group shape - Reference< drawing::XShapes > xGroupShape_Shapes( + rtl::Reference< SvxShapeGroupAnyD > xGroupShape_Shapes( createGroupShape( m_xLogicTarget, m_aCID ) ); if(!xGroupShape_Shapes.is()) @@ -235,14 +219,14 @@ void VCartesianGrid::createShapes() if( !aLinePropertiesList[nDepth].isLineVisible() ) continue; - Reference< drawing::XShapes > xTarget( xGroupShape_Shapes ); + rtl::Reference< SvxShapeGroupAnyD > xTarget( xGroupShape_Shapes ); if( nDepth > 0 ) { - xTarget.set( createGroupShape( m_xLogicTarget + xTarget = createGroupShape( m_xLogicTarget , ObjectIdentifier::addChildParticle( m_aCID, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_SUBGRID, nDepth-1 ) ) - ) ); + ); if(!xTarget.is()) - xTarget.set( xGroupShape_Shapes ); + xTarget = xGroupShape_Shapes; } if(m_nDimension==2) @@ -259,35 +243,34 @@ void VCartesianGrid::createShapes() if( !tick.bPaintIt ) continue; aGridLinePoints.update( tick.fScaledTickValue ); - addLine2D( aPoints, nRealPointCount, aGridLinePoints, m_pPosHelper->getTransformationScaledLogicToScene() ); + addLine2D( aPoints, nRealPointCount, aGridLinePoints, *m_pPosHelper->getTransformationScaledLogicToScene() ); nRealPointCount++; } aPoints.realloc(nRealPointCount); - m_pShapeFactory->createLine2D( xTarget, aPoints, &aLinePropertiesList[nDepth] ); + ShapeFactory::createLine2D( xTarget, aPoints, &aLinePropertiesList[nDepth] ); //prepare polygon for handle shape: drawing::PointSequenceSequence aHandlesPoints(1); - sal_Int32 nOldHandleCount = aHandlesPoints[0].getLength(); - aHandlesPoints[0].realloc(nOldHandleCount+nRealPointCount); + auto pHandlesPoints = aHandlesPoints.getArray(); + pHandlesPoints[0].realloc(nRealPointCount); + auto pHandlesPoints0 = pHandlesPoints[0].getArray(); for( sal_Int32 nN = 0; nN<nRealPointCount; nN++) - aHandlesPoints[0][nOldHandleCount+nN] = aPoints[nN][1]; + pHandlesPoints0[nN] = aPoints[nN][1]; //create handle shape: VLineProperties aHandleLineProperties; aHandleLineProperties.LineStyle <<= drawing::LineStyle_NONE; - Reference< drawing::XShape > xHandleShape = - m_pShapeFactory->createLine2D( xTarget, aHandlesPoints, &aHandleLineProperties ); - ::chart::ShapeFactory::setShapeName( xHandleShape, "HandlesOnly" ); + rtl::Reference<SvxShapePolyPolygon> xHandleShape = + ShapeFactory::createLine2D( xTarget, aHandlesPoints, &aHandleLineProperties ); + ::chart::ShapeFactory::setShapeName( xHandleShape, u"HandlesOnly"_ustr ); } else //if(2!=m_nDimension) { GridLinePoints aGridLinePoints( m_pPosHelper, m_nDimensionIndex, m_eLeftWallPos, m_eBackWallPos, m_eBottomPos ); sal_Int32 nPointCount = (*aDepthIter).size(); - drawing::PolyPolygonShape3D aPoints; - aPoints.SequenceX.realloc(nPointCount); - aPoints.SequenceY.realloc(nPointCount); - aPoints.SequenceZ.realloc(nPointCount); + std::vector<std::vector<css::drawing::Position3D>> aPoints; + aPoints.resize(nPointCount); sal_Int32 nRealPointCount = 0; sal_Int32 nPolyIndex = 0; @@ -300,14 +283,12 @@ void VCartesianGrid::createShapes() } aGridLinePoints.update( tick.fScaledTickValue ); - addLine3D( aPoints, nPolyIndex, aGridLinePoints, m_pPosHelper->getTransformationScaledLogicToScene() ); + addLine3D( aPoints, nPolyIndex, aGridLinePoints, *m_pPosHelper->getTransformationScaledLogicToScene() ); nRealPointCount+=3; ++nPolyIndex; } - aPoints.SequenceX.realloc(nRealPointCount); - aPoints.SequenceY.realloc(nRealPointCount); - aPoints.SequenceZ.realloc(nRealPointCount); - m_pShapeFactory->createLine3D( xTarget, aPoints, aLinePropertiesList[nDepth] ); + aPoints.resize(nRealPointCount); + ShapeFactory::createLine3D( xTarget, aPoints, aLinePropertiesList[nDepth] ); } } } |