summaryrefslogtreecommitdiff
path: root/chart2/source/view/inc/PlottingPositionHelper.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/view/inc/PlottingPositionHelper.hxx')
-rw-r--r--chart2/source/view/inc/PlottingPositionHelper.hxx99
1 files changed, 70 insertions, 29 deletions
diff --git a/chart2/source/view/inc/PlottingPositionHelper.hxx b/chart2/source/view/inc/PlottingPositionHelper.hxx
index 198941330b12..cd6753daac96 100644
--- a/chart2/source/view/inc/PlottingPositionHelper.hxx
+++ b/chart2/source/view/inc/PlottingPositionHelper.hxx
@@ -16,28 +16,68 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_PLOTTINGPOSITIONHELPER_HXX
-#define INCLUDED_CHART2_SOURCE_VIEW_INC_PLOTTINGPOSITIONHELPER_HXX
+#pragma once
+
+#include <sal/config.h>
+
+#include <memory>
#include <chartview/ExplicitScaleValues.hxx>
#include <basegfx/range/b2drectangle.hxx>
-#include <rtl/math.hxx>
+#include <tools/long.hxx>
#include <com/sun/star/drawing/Direction3D.hpp>
#include <com/sun/star/drawing/Position3D.hpp>
#include <basegfx/matrix/b3dhommatrix.hxx>
#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ref.hxx>
+#include <svx/unoshape.hxx>
-namespace com::sun::star::chart2 { class XTransformation; }
-namespace com::sun::star::drawing { class XShapes; }
namespace com::sun::star::drawing { struct HomogenMatrix; }
namespace com::sun::star::drawing { struct PolyPolygonShape3D; }
namespace chart
{
-class ShapeFactory;
+/** allows the transformation of numeric values from one
+ coordinate-system into another. Values may be transformed using
+ any mapping.
+ This is a non-UNO variant of the css::chart2::XTransformation interface,
+ but using more efficient calling and returning types.
+ */
+class XTransformation2
+{
+public:
+ virtual ~XTransformation2();
+ /** transforms the given input data tuple, given in the source
+ coordinate system, according to the internal transformation
+ rules, into a tuple of transformed coordinates in the
+ destination coordinate system.
+
+ <p>Note that both coordinate systems may have different
+ dimensions, e.g., if a transformation does simply a projection
+ into a lower-dimensional space.</p>
+
+ @param aValues a source tuple of data that is to be
+ transformed. The length of this sequence must be
+ equivalent to the dimension of the source coordinate
+ system.
+
+ @return the transformed data tuple. The length of this
+ sequence is equal to the dimension of the output
+ coordinate system.
+
+ @throws ::com::sun::star::lang::IllegalArgumentException
+ if the dimension of the input vector is not equal to the
+ dimension given in getSourceDimension().
+ */
+ virtual css::drawing::Position3D transform(
+ const css::drawing::Position3D& rSourceValues ) const = 0;
+ virtual css::drawing::Position3D transform(
+ const css::uno::Sequence< double >& rSourceValues ) const = 0;
+};
+
class PlottingPositionHelper
{
@@ -51,7 +91,7 @@ public:
virtual void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix);
- virtual void setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis );
+ virtual void setScales( std::vector< ExplicitScaleData >&& rScales, bool bSwapXAndYAxis );
const std::vector< ExplicitScaleData >& getScales() const { return m_aScales;}
//better performance for big data
@@ -69,7 +109,7 @@ public:
inline void doLogicScaling( css::drawing::Position3D& rPos ) const;
- virtual css::uno::Reference< css::chart2::XTransformation >
+ virtual ::chart::XTransformation2*
getTransformationScaledLogicToScene() const;
virtual css::drawing::Position3D
@@ -79,11 +119,12 @@ public:
transformScaledLogicToScene( double fX, double fY, double fZ, bool bClip ) const;
void transformScaledLogicToScene( css::drawing::PolyPolygonShape3D& rPoly ) const;
+ void transformScaledLogicToScene( std::vector<std::vector<css::drawing::Position3D>>& rPoly ) const;
static css::awt::Point transformSceneToScreenPosition(
const css::drawing::Position3D& rScenePosition3D
- , const css::uno::Reference< css::drawing::XShapes >& xSceneTarget
- , ShapeFactory* pShapeFactory, sal_Int32 nDimensionCount );
+ , const rtl::Reference<SvxShapeGroupAnyD>& xSceneTarget
+ , sal_Int32 nDimensionCount );
inline double getLogicMinX() const;
inline double getLogicMinY() const;
@@ -107,7 +148,7 @@ public:
inline bool maySkipPointsInRegressionCalculation() const;
- void setTimeResolution( long nTimeResolution, const Date& rNullDate );
+ void setTimeResolution( tools::Long nTimeResolution, const Date& rNullDate );
virtual void setScaledCategoryWidth( double fScaledCategoryWidth );
void AllowShiftXAxisPos( bool bAllowShift );
void AllowShiftZAxisPos( bool bAllowShift );
@@ -117,7 +158,7 @@ protected: //member
::basegfx::B3DHomMatrix m_aMatrixScreenToScene;
//this is calculated based on m_aScales and m_aMatrixScreenToScene
- mutable css::uno::Reference< css::chart2::XTransformation > m_xTransformationLogicToScene;
+ mutable std::unique_ptr< ::chart::XTransformation2 > m_xTransformationLogicToScene;
bool m_bSwapXAndY;//e.g. true for bar chart and false for column chart
@@ -128,7 +169,7 @@ protected: //member
bool m_bMaySkipPointsInRegressionCalculation;
bool m_bDateAxis;
- long m_nTimeResolution;
+ tools::Long m_nTimeResolution;
Date m_aNullDate;
double m_fScaledCategoryWidth;
@@ -146,11 +187,11 @@ public:
virtual std::unique_ptr<PlottingPositionHelper> clone() const override;
virtual void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix) override;
- virtual void setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) override;
+ virtual void setScales( std::vector< ExplicitScaleData >&& rScales, bool bSwapXAndYAxis ) override;
const ::basegfx::B3DHomMatrix& getUnitCartesianToScene() const { return m_aUnitCartesianToScene;}
- virtual css::uno::Reference< css::chart2::XTransformation >
+ virtual ::chart::XTransformation2*
getTransformationScaledLogicToScene() const override;
//the resulting values provided by the following 3 methods should be used
@@ -181,12 +222,17 @@ public:
css::drawing::Position3D
transformAngleRadiusToScene( double fLogicValueOnAngleAxis, double fLogicValueOnRadiusAxis, double fLogicZ, bool bDoScaling=true ) const;
- /** It returns the scene coordinates of the passed point: this point is
- * described through a normalized cylindrical coordinate system.
- * (For a pie chart the origin of the coordinate system is the pie center).
+ /** Return the scene coordinates of the passed point: this point is
+ * described through a normalized cylindrical coordinate system, with an
+ * optional offset.
+ * (For a standard pie chart the origin of the coordinate system is the
+ * pie center; for an of-pie chart the components of the aOffset
+ * parameter are not all zero).
*/
css::drawing::Position3D
- transformUnitCircleToScene( double fUnitAngleDegree, double fUnitRadius, double fLogicZ ) const;
+ transformUnitCircleToScene( double fUnitAngleDegree
+ , double fUnitRadius, double fLogicZ
+ , const ::basegfx::B3DVector& aOffset = ::basegfx::B3DVector()) const;
using PlottingPositionHelper::transformScaledLogicToScene;
@@ -278,9 +324,9 @@ bool PlottingPositionHelper::isStrongLowerRequested( sal_Int32 nDimensionIndex )
if( m_aScales.empty() )
return false;
if( 0==nDimensionIndex )
- return m_bAllowShiftXAxisPos && m_aScales[nDimensionIndex].ShiftedCategoryPosition;
+ return m_bAllowShiftXAxisPos && m_aScales[nDimensionIndex].m_bShiftedCategoryPosition;
else if( 2==nDimensionIndex )
- return m_bAllowShiftZAxisPos && m_aScales[nDimensionIndex].ShiftedCategoryPosition;
+ return m_bAllowShiftZAxisPos && m_aScales[nDimensionIndex].m_bShiftedCategoryPosition;
return false;
}
@@ -298,7 +344,7 @@ void PlottingPositionHelper::doLogicScaling( double* pX, double* pY, double* pZ
{
if( m_aScales[0].Scaling.is())
*pX = m_aScales[0].Scaling->doScaling(*pX);
- if( m_bAllowShiftXAxisPos && m_aScales[0].ShiftedCategoryPosition )
+ if( m_bAllowShiftXAxisPos && m_aScales[0].m_bShiftedCategoryPosition )
(*pX) += m_fScaledCategoryWidth/2.0;
}
if(pY && m_aScales[1].Scaling.is())
@@ -307,7 +353,7 @@ void PlottingPositionHelper::doLogicScaling( double* pX, double* pY, double* pZ
{
if( m_aScales[2].Scaling.is())
*pZ = m_aScales[2].Scaling->doScaling(*pZ);
- if( m_bAllowShiftZAxisPos && m_aScales[2].ShiftedCategoryPosition)
+ if( m_bAllowShiftZAxisPos && m_aScales[2].m_bShiftedCategoryPosition)
(*pZ) += 0.5;
}
}
@@ -356,11 +402,7 @@ inline bool PlottingPositionHelper::clipYRange( double& rMin, double& rMax ) con
{
//returns true if something remains
if( rMin > rMax )
- {
- double fHelp = rMin;
- rMin = rMax;
- rMax = fHelp;
- }
+ std::swap( rMin, rMax );
if( rMin > getLogicMaxY() )
return false;
if( rMax < getLogicMinY() )
@@ -419,6 +461,5 @@ inline bool PlottingPositionHelper::maySkipPointsInRegressionCalculation() const
}
} //namespace chart
-#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */