28#include <com/sun/star/chart/TimeUnit.hpp>
29#include <com/sun/star/chart2/AxisType.hpp>
30#include <com/sun/star/drawing/Position3D.hpp>
32#include <rtl/math.hxx>
42 : m_bSwapXAndY( false )
43 , m_nXResolution( 1000 )
44 , m_nYResolution( 1000 )
45 , m_nZResolution( 1000 )
46 , m_bMaySkipPointsInRegressionCalculation( true )
48 , m_nTimeResolution( css::
chart::TimeUnit::
DAY )
49 , m_aNullDate(30,12,1899)
50 , m_fScaledCategoryWidth(1.0)
51 , m_bAllowShiftXAxisPos(false)
52 , m_bAllowShiftZAxisPos(false)
56 : m_aScales( rSource.m_aScales )
57 , m_aMatrixScreenToScene( rSource.m_aMatrixScreenToScene )
59 , m_bSwapXAndY( rSource.m_bSwapXAndY )
60 , m_nXResolution( rSource.m_nXResolution )
61 , m_nYResolution( rSource.m_nYResolution )
62 , m_nZResolution( rSource.m_nZResolution )
63 , m_bMaySkipPointsInRegressionCalculation( rSource.m_bMaySkipPointsInRegressionCalculation )
64 , m_bDateAxis( rSource.m_bDateAxis )
65 , m_nTimeResolution( rSource.m_nTimeResolution )
66 , m_aNullDate( rSource.m_aNullDate )
67 , m_fScaledCategoryWidth( rSource.m_fScaledCategoryWidth )
68 , m_bAllowShiftXAxisPos( rSource.m_bAllowShiftXAxisPos )
69 , m_bAllowShiftZAxisPos( rSource.m_bAllowShiftZAxisPos )
80 return std::make_unique<PlottingPositionHelper>(*
this);
86 pRet->m_aScales[1]=rSecondaryScale;
121 AxisOrientation nXAxisOrientation =
m_aScales[0].Orientation;
122 AxisOrientation nYAxisOrientation =
m_aScales[1].Orientation;
123 AxisOrientation nZAxisOrientation =
m_aScales[2].Orientation;
131 std::swap(MinX,MinY);
132 std::swap(MaxX,MaxY);
133 std::swap(nXAxisOrientation,nYAxisOrientation);
136 double fWidthX = MaxX - MinX;
137 double fWidthY = MaxY - MinY;
138 double fWidthZ = MaxZ - MinZ;
140 double fScaleDirectionX = nXAxisOrientation==AxisOrientation_MATHEMATICAL ? 1.0 : -1.0;
141 double fScaleDirectionY = nYAxisOrientation==AxisOrientation_MATHEMATICAL ? 1.0 : -1.0;
142 double fScaleDirectionZ = nZAxisOrientation==AxisOrientation_MATHEMATICAL ? -1.0 : 1.0;
148 aMatrix.
scale(fScaleX, fScaleY, fScaleZ);
150 if( nXAxisOrientation==AxisOrientation_MATHEMATICAL )
151 aMatrix.
translate(-MinX*fScaleX, 0.0, 0.0);
153 aMatrix.
translate(-MaxX*fScaleX, 0.0, 0.0);
154 if( nYAxisOrientation==AxisOrientation_MATHEMATICAL )
155 aMatrix.
translate(0.0, -MinY*fScaleY, 0.0);
157 aMatrix.
translate(0.0, -MaxY*fScaleY, 0.0);
158 if( nZAxisOrientation==AxisOrientation_MATHEMATICAL )
159 aMatrix.
translate(0.0, 0.0, -MaxZ*fScaleZ);
161 aMatrix.
translate(0.0, 0.0, -MinZ*fScaleZ);
171 double fX,
double fY,
double fZ,
bool bClip )
const
181 double fX,
double fY,
double fZ,
bool bClip )
const
186 drawing::Position3D aPos( fX, fY, fZ);
190 return pTransformation->
transform( aPos );
195 , sal_Int32 nDimensionCount )
198 awt::Point aScreenPoint(
static_cast<sal_Int32
>(rScenePosition3D.PositionX),
static_cast<sal_Int32
>(rScenePosition3D.PositionY) );
201 if(nDimensionCount==3)
206 , rScenePosition3D,drawing::Direction3D(1,1,1)
207 , 0,
nullptr, aDummyPropertyNameMap);
209 aScreenPoint = xShape3DAnchor->getPosition();
210 xSceneTarget->remove(xShape3DAnchor);
217 drawing::Position3D aScenePosition;
218 auto SequenceXRange = asNonConstRange(rPolygon.SequenceX);
219 auto SequenceYRange = asNonConstRange(rPolygon.SequenceY);
220 auto SequenceZRange = asNonConstRange(rPolygon.SequenceZ);
221 for( sal_Int32 nS = rPolygon.SequenceX.getLength(); nS--;)
223 auto xValuesRange = asNonConstRange(SequenceXRange[nS]);
224 auto yValuesRange = asNonConstRange(SequenceYRange[nS]);
225 auto zValuesRange = asNonConstRange(SequenceZRange[nS]);
226 for( sal_Int32 nP = SequenceXRange[nS].
getLength(); nP--; )
228 double& fX = xValuesRange[nP];
229 double& fY = yValuesRange[nP];
230 double& fZ = zValuesRange[nP];
232 fX = aScenePosition.PositionX;
233 fY = aScenePosition.PositionY;
234 fZ = aScenePosition.PositionZ;
241 drawing::Position3D aScenePosition;
242 for( sal_Int32 nS =
static_cast<sal_Int32
>(rPolygon.size()); nS--;)
244 auto valuesRange = rPolygon[nS].data();
245 for( sal_Int32 nP = rPolygon[nS].
size(); nP--; )
247 double& fX = valuesRange[nP].PositionX;
248 double& fY = valuesRange[nP].PositionY;
249 double& fZ = valuesRange[nP].PositionZ;
251 fX = aScenePosition.PositionX;
252 fY = aScenePosition.PositionY;
253 fZ = aScenePosition.PositionZ;
276 else if( *pX > MaxX )
283 else if( *pY > MaxY )
290 else if( *pZ > MaxZ )
315 drawing::Direction3D aRet;
327 aRet.DirectionX = MaxX - MinX;
328 aRet.DirectionY = MaxY - MinY;
329 aRet.DirectionZ = MaxZ - MinZ;
334 : m_fRadiusOffset(0.0)
335 , m_fAngleDegreeOffset(90.0)
342 , m_fRadiusOffset( rSource.m_fRadiusOffset )
343 , m_fAngleDegreeOffset( rSource.m_fAngleDegreeOffset )
344 , m_aUnitCartesianToScene( rSource.m_aUnitCartesianToScene )
354 return std::make_unique<PolarPlottingPositionHelper>(*
this);
375 double fTranslate =1.0;
378 double fTranslateLogicZ;
381 double fScaleDirectionZ =
m_aScales[2].Orientation==AxisOrientation_MATHEMATICAL ? 1.0 : -1.0;
386 double fWidthZ = MaxZ - MinZ;
389 fTranslateLogicZ=MinZ;
391 fTranslateLogicZ=MaxZ;
395 double fTranslateX = fTranslate;
396 double fTranslateY = fTranslate;
397 double fTranslateZ = fTranslateLogicZ;
399 double fScaleX = fScale;
400 double fScaleY = fScale;
401 double fScaleZ = fScaleLogicZ;
403 aRet.
translate(fTranslateX, fTranslateY, fTranslateZ);
404 aRet.
scale(fScaleX, fScaleY, fScaleZ);
406 aRet = rMatrixScreenToScene * aRet;
420 if( rAngleScale.
Orientation != AxisOrientation_MATHEMATICAL )
421 std::swap( fStartLogicValueOnAngleAxis, fEndLogicValueOnAngleAxis );
425 double fWidthAngleDegree = fEndAngleDegree - fStartAngleDegree;
427 if( ::rtl::math::approxEqual( fStartAngleDegree, fEndAngleDegree )
428 && !::rtl::math::approxEqual( fStartLogicValueOnAngleAxis, fEndLogicValueOnAngleAxis ) )
429 fWidthAngleDegree = 360.0;
432 while (fWidthAngleDegree < 0.0)
433 fWidthAngleDegree += 360.0;
434 while (fWidthAngleDegree > 360.0)
435 fWidthAngleDegree -= 360.0;
437 return fWidthAngleDegree;
448 double fAxisAngleScaleDirection = 1.0;
451 if(rScale.
Orientation != AxisOrientation_MATHEMATICAL)
452 fAxisAngleScaleDirection *= -1.0;
455 double MinAngleValue = 0.0;
456 double MaxAngleValue = 0.0;
472 double fScaledLogicAngleValue = 0.0;
483 fScaledLogicAngleValue = fLogicValueOnAngleAxis;
486 + fAxisAngleScaleDirection*(fScaledLogicAngleValue-MinAngleValue)*360.0
487 /fabs(MaxAngleValue-MinAngleValue);
567 double fNormalRadius = 0.0;
569 double fScaledLogicRadiusValue = 0.0;
577 bool bMinIsInnerRadius =
true;
579 if(rScale.
Orientation != AxisOrientation_MATHEMATICAL)
580 bMinIsInnerRadius =
false;
582 double fInnerScaledLogicRadius=0.0;
583 double fOuterScaledLogicRadius=0.0;
595 fInnerScaledLogicRadius = bMinIsInnerRadius ? fMin : fMax;
596 fOuterScaledLogicRadius = bMinIsInnerRadius ? fMax : fMin;
599 if( bMinIsInnerRadius )
603 fNormalRadius = (fScaledLogicRadiusValue-fInnerScaledLogicRadius)/(fOuterScaledLogicRadius-fInnerScaledLogicRadius);
605 return fNormalRadius;
613 double fLogicValueOnRadiusAxis =
m_bSwapXAndY ? fX : fY;
622 double fLogicValueOnRadiusAxis =
m_bSwapXAndY ? fX : fY;
626 ,
double fLogicZ )
const
630 double fX=fUnitRadius*std::cos(fAnglePi);
631 double fY=fUnitRadius*std::sin(fAnglePi);
651 if( rScale.
Orientation==AxisOrientation_MATHEMATICAL )
659 return m_aScales[1].AxisType==AxisType::PERCENT;
673 double fCategoryWidth = 1.0;
679 if( nTimeResolution == css::chart::TimeUnit::YEAR )
681 const double fMonthCount = 12.0;
682 fCategoryWidth = fMonthCount;
void translate(double fX, double fY, double fZ)
void scale(double fX, double fY, double fZ)
double getBaseValueY() const
double getLogicMaxX() const
bool m_bAllowShiftZAxisPos
virtual ::chart::XTransformation2 * getTransformationScaledLogicToScene() const
double getLogicMinZ() const
double getLogicMaxY() const
css::drawing::Direction3D getScaledLogicWidth() const
::basegfx::B3DHomMatrix m_aMatrixScreenToScene
double getLogicMinX() const
double getLogicMinY() const
virtual void setScales(std::vector< ExplicitScaleData > &&rScales, bool bSwapXAndYAxis)
virtual void setTransformationSceneToScreen(const css::drawing::HomogenMatrix &rMatrix)
bool m_bAllowShiftXAxisPos
static css::awt::Point transformSceneToScreenPosition(const css::drawing::Position3D &rScenePosition3D, const rtl::Reference< SvxShapeGroupAnyD > &xSceneTarget, sal_Int32 nDimensionCount)
void AllowShiftZAxisPos(bool bAllowShift)
void clipScaledLogicValues(double *pX, double *pY, double *pZ) const
std::vector< ExplicitScaleData > m_aScales
::basegfx::B2DRectangle getScaledLogicClipDoubleRect() const
tools::Long m_nTimeResolution
void AllowShiftXAxisPos(bool bAllowShift)
virtual std::unique_ptr< PlottingPositionHelper > clone() const
void doUnshiftedLogicScaling(double *pX, double *pY, double *pZ) const
bool m_bMaySkipPointsInRegressionCalculation
virtual css::drawing::Position3D transformLogicToScene(double fX, double fY, double fZ, bool bClip) const
virtual void setScaledCategoryWidth(double fScaledCategoryWidth)
void doLogicScaling(double *pX, double *pY, double *pZ) const
virtual css::drawing::Position3D transformScaledLogicToScene(double fX, double fY, double fZ, bool bClip) const
virtual ~PlottingPositionHelper()
std::unique_ptr< ::chart::XTransformation2 > m_xTransformationLogicToScene
void setTimeResolution(tools::Long nTimeResolution, const Date &rNullDate)
double getLogicMaxZ() const
void clipLogicValues(double *pX, double *pY, double *pZ) const
double m_fScaledCategoryWidth
std::unique_ptr< PlottingPositionHelper > createSecondaryPosHelper(const ExplicitScaleData &rSecondaryScale)
virtual ~PolarPlottingPositionHelper() override
double transformToAngleDegree(double fLogicValueOnAngleAxis, bool bDoScaling=true) const
Given a value in the angle axis scale range (e.g.
css::drawing::Position3D transformUnitCircleToScene(double fUnitAngleDegree, double fUnitRadius, double fLogicZ) const
It returns the scene coordinates of the passed point: this point is described through a normalized cy...
::basegfx::B3DHomMatrix m_aUnitCartesianToScene
::basegfx::B3DHomMatrix impl_calculateMatrixUnitCartesianToScene(const ::basegfx::B3DHomMatrix &rMatrixScreenToScene) const
virtual std::unique_ptr< PlottingPositionHelper > clone() const override
virtual ::chart::XTransformation2 * getTransformationScaledLogicToScene() const override
double m_fAngleDegreeOffset
Offset for angle axis in real degree.
PolarPlottingPositionHelper()
virtual void setTransformationSceneToScreen(const css::drawing::HomogenMatrix &rMatrix) override
css::drawing::Position3D transformAngleRadiusToScene(double fLogicValueOnAngleAxis, double fLogicValueOnRadiusAxis, double fLogicZ, bool bDoScaling=true) const
virtual void setScales(std::vector< ExplicitScaleData > &&rScales, bool bSwapXAndYAxis) override
virtual css::drawing::Position3D transformScaledLogicToScene(double fX, double fY, double fZ, bool bClip) const override
double getWidthAngleDegree(double &fStartLogicValueOnAngleAxis, double &fEndLogicValueOnAngleAxis) const
Given 2 values in the angle axis scale range (e.g.
double transformToRadius(double fLogicValueOnRadiusAxis, bool bDoScaling=true) const
Given a value in the radius axis scale range, it returns the normalized value.
double getOuterLogicRadius() const
double m_fRadiusOffset
m_bSwapXAndY (inherited): by default the X axis (scale[0]) represents the angle axis and the Y axis (...
virtual css::drawing::Position3D transformLogicToScene(double fX, double fY, double fZ, bool bClip) const override
static rtl::Reference< Svx3DExtrudeObject > createCube(const rtl::Reference< SvxShapeGroupAnyD > &xTarget, const css::drawing::Position3D &rPosition, const css::drawing::Direction3D &rSize, sal_Int32 nRotateZAngleHundredthDegree, const css::uno::Reference< css::beans::XPropertySet > &xSourceProp, const tPropertyNameMap &rPropertyNameMap, bool bRounded=false)
constexpr double FIXED_SIZE_FOR_3D_CHART_VOLUME
double getLength(const B2DPolygon &rCandidate)
constexpr double deg2rad(double v)
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D B3DPointToPosition3D(const ::basegfx::B3DPoint &rPoint)
B3DPoint -> Position3D.
std::unordered_map< OUString, OUString > tPropertyNameMap
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::HomogenMatrix B3DHomMatrixToHomogenMatrix(const ::basegfx::B3DHomMatrix &rM)
diverse methods for class conversions; e.g.
OOO_DLLPUBLIC_CHARTTOOLS::basegfx::B3DHomMatrix HomogenMatrixToB3DHomMatrix(const css::drawing::HomogenMatrix &rHM)
HomogenMatrix -> basegfx::B3DHomMatrix.
This structure contains the explicit values for a scale like Minimum and Maximum.
css::chart2::AxisOrientation Orientation