xref: /AOO41X/main/chart2/source/view/inc/PlottingPositionHelper.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _CHART2_PLOTTINGPOSITIONHELPER_HXX
28*cdf0e10cSrcweir #define _CHART2_PLOTTINGPOSITIONHELPER_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "LabelAlignment.hxx"
31*cdf0e10cSrcweir #include "chartview/ExplicitScaleValues.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx>
34*cdf0e10cSrcweir #include <rtl/math.hxx>
35*cdf0e10cSrcweir #include <com/sun/star/chart2/XTransformation.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/drawing/Direction3D.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/drawing/HomogenMatrix.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/drawing/Position3D.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
41*cdf0e10cSrcweir #include <basegfx/matrix/b3dhommatrix.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir /*
44*cdf0e10cSrcweir //for WeakImplHelper1
45*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
46*cdf0e10cSrcweir */
47*cdf0e10cSrcweir //.............................................................................
48*cdf0e10cSrcweir namespace chart
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir //.............................................................................
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir class ShapeFactory;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir //-----------------------------------------------------------------------------
55*cdf0e10cSrcweir /**
56*cdf0e10cSrcweir */
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir class PlottingPositionHelper
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir public:
61*cdf0e10cSrcweir     PlottingPositionHelper();
62*cdf0e10cSrcweir     PlottingPositionHelper( const PlottingPositionHelper& rSource );
63*cdf0e10cSrcweir     virtual ~PlottingPositionHelper();
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     virtual PlottingPositionHelper* clone() const;
66*cdf0e10cSrcweir     virtual PlottingPositionHelper* createSecondaryPosHelper( const ExplicitScaleData& rSecondaryScale );
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix);
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis );
71*cdf0e10cSrcweir     const ::std::vector< ExplicitScaleData >& getScales() const;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     //better performance for big data
74*cdf0e10cSrcweir     inline void   setCoordinateSystemResolution( const ::com::sun::star::uno::Sequence< sal_Int32 >& rCoordinateSystemResolution );
75*cdf0e10cSrcweir     inline bool   isSameForGivenResolution( double fX, double fY, double fZ
76*cdf0e10cSrcweir                                 , double fX2, double fY2, double fZ2 );
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     inline bool   isStrongLowerRequested( sal_Int32 nDimensionIndex ) const;
79*cdf0e10cSrcweir     inline bool   isLogicVisible( double fX, double fY, double fZ ) const;
80*cdf0e10cSrcweir     inline void   doLogicScaling( double* pX, double* pY, double* pZ, bool bClip=false ) const;
81*cdf0e10cSrcweir     inline void   doUnshiftedLogicScaling( double* pX, double* pY, double* pZ, bool bClip=false ) const;
82*cdf0e10cSrcweir     inline void   clipLogicValues( double* pX, double* pY, double* pZ ) const;
83*cdf0e10cSrcweir            void   clipScaledLogicValues( double* pX, double* pY, double* pZ ) const;
84*cdf0e10cSrcweir     inline bool   clipYRange( double& rMin, double& rMax ) const;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir     inline void   doLogicScaling( ::com::sun::star::drawing::Position3D& rPos, bool bClip=false ) const;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >
89*cdf0e10cSrcweir                   getTransformationScaledLogicToScene() const;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     virtual ::com::sun::star::drawing::Position3D
92*cdf0e10cSrcweir             transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     virtual ::com::sun::star::drawing::Position3D
95*cdf0e10cSrcweir             transformScaledLogicToScene( double fX, double fY, double fZ, bool bClip ) const;
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     void    transformScaledLogicToScene( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly ) const;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     static com::sun::star::awt::Point transformSceneToScreenPosition(
100*cdf0e10cSrcweir                   const com::sun::star::drawing::Position3D& rScenePosition3D
101*cdf0e10cSrcweir                 , const com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& xSceneTarget
102*cdf0e10cSrcweir                 , ShapeFactory* pShapeFactory, sal_Int32 nDimensionCount );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     inline double getLogicMinX() const;
105*cdf0e10cSrcweir     inline double getLogicMinY() const;
106*cdf0e10cSrcweir     inline double getLogicMinZ() const;
107*cdf0e10cSrcweir     inline double getLogicMaxX() const;
108*cdf0e10cSrcweir     inline double getLogicMaxY() const;
109*cdf0e10cSrcweir     inline double getLogicMaxZ() const;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     inline bool isMathematicalOrientationX() const;
112*cdf0e10cSrcweir     inline bool isMathematicalOrientationY() const;
113*cdf0e10cSrcweir     inline bool isMathematicalOrientationZ() const;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     ::basegfx::B2DRectangle     getScaledLogicClipDoubleRect() const;
116*cdf0e10cSrcweir     ::com::sun::star::drawing::Direction3D getScaledLogicWidth() const;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     inline bool isSwapXAndY() const;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     bool isPercentY() const;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     double getBaseValueY() const;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     inline bool maySkipPointsInRegressionCalculation() const;
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     void setTimeResolution( long nTimeResolution, const Date& rNullDate );
127*cdf0e10cSrcweir     virtual void setScaledCategoryWidth( double fScaledCategoryWidth );
128*cdf0e10cSrcweir     void AllowShiftXAxisPos( bool bAllowShift );
129*cdf0e10cSrcweir     void AllowShiftZAxisPos( bool bAllowShift );
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir protected: //member
132*cdf0e10cSrcweir     ::std::vector< ExplicitScaleData >  m_aScales;
133*cdf0e10cSrcweir     ::basegfx::B3DHomMatrix             m_aMatrixScreenToScene;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     //this is calculated based on m_aScales and m_aMatrixScreenToScene
136*cdf0e10cSrcweir     mutable ::com::sun::star::uno::Reference<
137*cdf0e10cSrcweir         ::com::sun::star::chart2::XTransformation >     m_xTransformationLogicToScene;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     bool    m_bSwapXAndY;//e.g. true for bar chart and false for column chart
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     sal_Int32 m_nXResolution;
142*cdf0e10cSrcweir     sal_Int32 m_nYResolution;
143*cdf0e10cSrcweir     sal_Int32 m_nZResolution;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     bool m_bMaySkipPointsInRegressionCalculation;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     bool m_bDateAxis;
148*cdf0e10cSrcweir     long m_nTimeResolution;
149*cdf0e10cSrcweir     Date m_aNullDate;
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     double m_fScaledCategoryWidth;
152*cdf0e10cSrcweir     bool   m_bAllowShiftXAxisPos;
153*cdf0e10cSrcweir     bool   m_bAllowShiftZAxisPos;
154*cdf0e10cSrcweir };
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir //describes wich axis of the drawinglayer scene or sreen axis are the normal axis
157*cdf0e10cSrcweir enum NormalAxis
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir       NormalAxis_X
160*cdf0e10cSrcweir     , NormalAxis_Y
161*cdf0e10cSrcweir     , NormalAxis_Z
162*cdf0e10cSrcweir };
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir class PolarPlottingPositionHelper : public PlottingPositionHelper
165*cdf0e10cSrcweir     /*
166*cdf0e10cSrcweir                                   , public ::cppu::WeakImplHelper1<
167*cdf0e10cSrcweir                                 ::com::sun::star::chart2::XTransformation >
168*cdf0e10cSrcweir                                 */
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir public:
171*cdf0e10cSrcweir     PolarPlottingPositionHelper( NormalAxis eNormalAxis=NormalAxis_Z );
172*cdf0e10cSrcweir     PolarPlottingPositionHelper( const PolarPlottingPositionHelper& rSource );
173*cdf0e10cSrcweir     virtual ~PolarPlottingPositionHelper();
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     virtual PlottingPositionHelper* clone() const;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix);
178*cdf0e10cSrcweir     virtual void setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis );
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     ::basegfx::B3DHomMatrix getUnitCartesianToScene() const;
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >
183*cdf0e10cSrcweir                   getTransformationScaledLogicToScene() const;
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     //the resulting values should be used for input to the transformation
186*cdf0e10cSrcweir     //received with 'getTransformationScaledLogicToScene'
187*cdf0e10cSrcweir     double  transformToRadius( double fLogicValueOnRadiusAxis, bool bDoScaling=true ) const;
188*cdf0e10cSrcweir     double  transformToAngleDegree( double fLogicValueOnAngleAxis, bool bDoScaling=true ) const;
189*cdf0e10cSrcweir     double  getWidthAngleDegree( double& fStartLogicValueOnAngleAxis, double& fEndLogicValueOnAngleAxis ) const;
190*cdf0e10cSrcweir     //
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     virtual ::com::sun::star::drawing::Position3D
193*cdf0e10cSrcweir             transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const;
194*cdf0e10cSrcweir     virtual ::com::sun::star::drawing::Position3D
195*cdf0e10cSrcweir             transformScaledLogicToScene( double fX, double fY, double fZ, bool bClip ) const;
196*cdf0e10cSrcweir     ::com::sun::star::drawing::Position3D
197*cdf0e10cSrcweir             transformAngleRadiusToScene( double fLogicValueOnAngleAxis, double fLogicValueOnRadiusAxis, double fLogicZ, bool bDoScaling=true ) const;
198*cdf0e10cSrcweir     ::com::sun::star::drawing::Position3D
199*cdf0e10cSrcweir             transformUnitCircleToScene( double fUnitAngleDegree, double fUnitRadius, double fLogicZ, bool bDoScaling=true ) const;
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir     using PlottingPositionHelper::transformScaledLogicToScene;
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir #ifdef NOTYET
204*cdf0e10cSrcweir     double  getInnerLogicRadius() const;
205*cdf0e10cSrcweir #endif
206*cdf0e10cSrcweir     double  getOuterLogicRadius() const;
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir     inline bool isMathematicalOrientationAngle() const;
209*cdf0e10cSrcweir     inline bool isMathematicalOrientationRadius() const;
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     /*
212*cdf0e10cSrcweir     // ____ XTransformation ____
213*cdf0e10cSrcweir     /// @see ::com::sun::star::chart2::XTransformation
214*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< double > SAL_CALL transform(
215*cdf0e10cSrcweir         const ::com::sun::star::uno::Sequence< double >& rSourceValues )
216*cdf0e10cSrcweir         throw (::com::sun::star::lang::IllegalArgumentException,
217*cdf0e10cSrcweir                ::com::sun::star::uno::RuntimeException);
218*cdf0e10cSrcweir     /// @see ::com::sun::star::chart2::XTransformation
219*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getSourceDimension()
220*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
221*cdf0e10cSrcweir     /// @see ::com::sun::star::chart2::XTransformation
222*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getTargetDimension()
223*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
224*cdf0e10cSrcweir         */
225*cdf0e10cSrcweir public:
226*cdf0e10cSrcweir     //Offset for radius axis in absolute logic scaled values (1.0 == 1 category)
227*cdf0e10cSrcweir     double      m_fRadiusOffset;
228*cdf0e10cSrcweir     //Offset for angle axis in real degree
229*cdf0e10cSrcweir     double      m_fAngleDegreeOffset;
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir private:
232*cdf0e10cSrcweir     ::basegfx::B3DHomMatrix m_aUnitCartesianToScene;
233*cdf0e10cSrcweir     NormalAxis  m_eNormalAxis;
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     ::basegfx::B3DHomMatrix impl_calculateMatrixUnitCartesianToScene( const ::basegfx::B3DHomMatrix& rMatrixScreenToScene ) const;
236*cdf0e10cSrcweir };
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir bool PolarPlottingPositionHelper::isMathematicalOrientationAngle() const
239*cdf0e10cSrcweir {
240*cdf0e10cSrcweir     const ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[1] : m_aScales[2];
241*cdf0e10cSrcweir     if( ::com::sun::star::chart2::AxisOrientation_MATHEMATICAL==rScale.Orientation )
242*cdf0e10cSrcweir         return true;
243*cdf0e10cSrcweir     return false;
244*cdf0e10cSrcweir }
245*cdf0e10cSrcweir bool PolarPlottingPositionHelper::isMathematicalOrientationRadius() const
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir     const ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[0] : m_aScales[1];
248*cdf0e10cSrcweir     if( ::com::sun::star::chart2::AxisOrientation_MATHEMATICAL==rScale.Orientation )
249*cdf0e10cSrcweir         return true;
250*cdf0e10cSrcweir     return false;
251*cdf0e10cSrcweir }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir //better performance for big data
254*cdf0e10cSrcweir void PlottingPositionHelper::setCoordinateSystemResolution( const ::com::sun::star::uno::Sequence< sal_Int32 >& rCoordinateSystemResolution )
255*cdf0e10cSrcweir {
256*cdf0e10cSrcweir     m_nXResolution = 1000;
257*cdf0e10cSrcweir     m_nYResolution = 1000;
258*cdf0e10cSrcweir     m_nZResolution = 1000;
259*cdf0e10cSrcweir     if( rCoordinateSystemResolution.getLength() > 0 )
260*cdf0e10cSrcweir         m_nXResolution = rCoordinateSystemResolution[0];
261*cdf0e10cSrcweir     if( rCoordinateSystemResolution.getLength() > 1 )
262*cdf0e10cSrcweir         m_nYResolution = rCoordinateSystemResolution[1];
263*cdf0e10cSrcweir     if( rCoordinateSystemResolution.getLength() > 2 )
264*cdf0e10cSrcweir         m_nZResolution = rCoordinateSystemResolution[2];
265*cdf0e10cSrcweir }
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir bool PlottingPositionHelper::isSameForGivenResolution( double fX, double fY, double fZ
268*cdf0e10cSrcweir                                 , double fX2, double fY2, double fZ2 /*these values are all expected tp be scaled already*/ )
269*cdf0e10cSrcweir {
270*cdf0e10cSrcweir     if( !::rtl::math::isFinite(fX) || !::rtl::math::isFinite(fY) || !::rtl::math::isFinite(fZ)
271*cdf0e10cSrcweir         || !::rtl::math::isFinite(fX2) || !::rtl::math::isFinite(fY2) || !::rtl::math::isFinite(fZ2) )
272*cdf0e10cSrcweir         return false;
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir     double fScaledMinX = getLogicMinX();
275*cdf0e10cSrcweir     double fScaledMinY = getLogicMinY();
276*cdf0e10cSrcweir     double fScaledMinZ = getLogicMinZ();
277*cdf0e10cSrcweir     double fScaledMaxX = getLogicMaxX();
278*cdf0e10cSrcweir     double fScaledMaxY = getLogicMaxY();
279*cdf0e10cSrcweir     double fScaledMaxZ = getLogicMaxZ();
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir     doLogicScaling( &fScaledMinX, &fScaledMinY, &fScaledMinZ );
282*cdf0e10cSrcweir     doLogicScaling( &fScaledMaxX, &fScaledMaxY, &fScaledMaxZ);
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     bool bSameX = ( static_cast<sal_Int32>(m_nXResolution*(fX - fScaledMinX)/(fScaledMaxX-fScaledMinX))
285*cdf0e10cSrcweir                 == static_cast<sal_Int32>(m_nXResolution*(fX2 - fScaledMinX)/(fScaledMaxX-fScaledMinX)) );
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     bool bSameY = ( static_cast<sal_Int32>(m_nYResolution*(fY - fScaledMinY)/(fScaledMaxY-fScaledMinY))
288*cdf0e10cSrcweir                 == static_cast<sal_Int32>(m_nYResolution*(fY2 - fScaledMinY)/(fScaledMaxY-fScaledMinY)) );
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir     bool bSameZ = ( static_cast<sal_Int32>(m_nZResolution*(fZ - fScaledMinZ)/(fScaledMaxZ-fScaledMinZ))
291*cdf0e10cSrcweir                 == static_cast<sal_Int32>(m_nZResolution*(fZ2 - fScaledMinZ)/(fScaledMaxZ-fScaledMinZ)) );
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir     return (bSameX && bSameY && bSameZ);
294*cdf0e10cSrcweir }
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir bool PlottingPositionHelper::isStrongLowerRequested( sal_Int32 nDimensionIndex ) const
297*cdf0e10cSrcweir {
298*cdf0e10cSrcweir     if( m_aScales.empty() )
299*cdf0e10cSrcweir         return false;
300*cdf0e10cSrcweir     if( 0==nDimensionIndex )
301*cdf0e10cSrcweir         return m_bAllowShiftXAxisPos && m_aScales[nDimensionIndex].ShiftedCategoryPosition;
302*cdf0e10cSrcweir     else if( 2==nDimensionIndex )
303*cdf0e10cSrcweir         return m_bAllowShiftZAxisPos && m_aScales[nDimensionIndex].ShiftedCategoryPosition;
304*cdf0e10cSrcweir     return false;
305*cdf0e10cSrcweir }
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir bool PlottingPositionHelper::isLogicVisible(
308*cdf0e10cSrcweir     double fX, double fY, double fZ ) const
309*cdf0e10cSrcweir {
310*cdf0e10cSrcweir     return fX >= m_aScales[0].Minimum && ( isStrongLowerRequested(0) ? fX < m_aScales[0].Maximum : fX <= m_aScales[0].Maximum )
311*cdf0e10cSrcweir         && fY >= m_aScales[1].Minimum && fY <= m_aScales[1].Maximum
312*cdf0e10cSrcweir         && fZ >= m_aScales[2].Minimum && ( isStrongLowerRequested(2) ? fZ < m_aScales[2].Maximum : fZ <= m_aScales[2].Maximum );
313*cdf0e10cSrcweir }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir void PlottingPositionHelper::doLogicScaling( double* pX, double* pY, double* pZ, bool bClip ) const
316*cdf0e10cSrcweir {
317*cdf0e10cSrcweir     if(bClip)
318*cdf0e10cSrcweir         this->clipLogicValues( pX,pY,pZ );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     if(pX)
321*cdf0e10cSrcweir     {
322*cdf0e10cSrcweir         if( m_aScales[0].Scaling.is())
323*cdf0e10cSrcweir             *pX = m_aScales[0].Scaling->doScaling(*pX);
324*cdf0e10cSrcweir         if( m_bAllowShiftXAxisPos && m_aScales[0].ShiftedCategoryPosition )
325*cdf0e10cSrcweir             (*pX) += m_fScaledCategoryWidth/2.0;
326*cdf0e10cSrcweir     }
327*cdf0e10cSrcweir     if(pY && m_aScales[1].Scaling.is())
328*cdf0e10cSrcweir         *pY = m_aScales[1].Scaling->doScaling(*pY);
329*cdf0e10cSrcweir     if(pZ)
330*cdf0e10cSrcweir     {
331*cdf0e10cSrcweir         if( m_aScales[2].Scaling.is())
332*cdf0e10cSrcweir             *pZ = m_aScales[2].Scaling->doScaling(*pZ);
333*cdf0e10cSrcweir         if( m_bAllowShiftZAxisPos && m_aScales[2].ShiftedCategoryPosition)
334*cdf0e10cSrcweir             (*pZ) += 0.5;
335*cdf0e10cSrcweir     }
336*cdf0e10cSrcweir }
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir void PlottingPositionHelper::doUnshiftedLogicScaling( double* pX, double* pY, double* pZ, bool bClip ) const
339*cdf0e10cSrcweir {
340*cdf0e10cSrcweir     if(bClip)
341*cdf0e10cSrcweir         this->clipLogicValues( pX,pY,pZ );
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir     if(pX && m_aScales[0].Scaling.is())
344*cdf0e10cSrcweir         *pX = m_aScales[0].Scaling->doScaling(*pX);
345*cdf0e10cSrcweir     if(pY && m_aScales[1].Scaling.is())
346*cdf0e10cSrcweir         *pY = m_aScales[1].Scaling->doScaling(*pY);
347*cdf0e10cSrcweir     if(pZ && m_aScales[2].Scaling.is())
348*cdf0e10cSrcweir         *pZ = m_aScales[2].Scaling->doScaling(*pZ);
349*cdf0e10cSrcweir }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir void PlottingPositionHelper::doLogicScaling( ::com::sun::star::drawing::Position3D& rPos, bool bClip ) const
352*cdf0e10cSrcweir {
353*cdf0e10cSrcweir     doLogicScaling( &rPos.PositionX, &rPos.PositionY, &rPos.PositionZ, bClip );
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir void PlottingPositionHelper::clipLogicValues( double* pX, double* pY, double* pZ ) const
357*cdf0e10cSrcweir {
358*cdf0e10cSrcweir     if(pX)
359*cdf0e10cSrcweir     {
360*cdf0e10cSrcweir         if( *pX < m_aScales[0].Minimum )
361*cdf0e10cSrcweir             *pX = m_aScales[0].Minimum;
362*cdf0e10cSrcweir         else if( *pX > m_aScales[0].Maximum )
363*cdf0e10cSrcweir             *pX = m_aScales[0].Maximum;
364*cdf0e10cSrcweir     }
365*cdf0e10cSrcweir     if(pY)
366*cdf0e10cSrcweir     {
367*cdf0e10cSrcweir         if( *pY < m_aScales[1].Minimum )
368*cdf0e10cSrcweir             *pY = m_aScales[1].Minimum;
369*cdf0e10cSrcweir         else if( *pY > m_aScales[1].Maximum )
370*cdf0e10cSrcweir             *pY = m_aScales[1].Maximum;
371*cdf0e10cSrcweir     }
372*cdf0e10cSrcweir     if(pZ)
373*cdf0e10cSrcweir     {
374*cdf0e10cSrcweir         if( *pZ < m_aScales[2].Minimum )
375*cdf0e10cSrcweir             *pZ = m_aScales[2].Minimum;
376*cdf0e10cSrcweir         else if( *pZ > m_aScales[2].Maximum )
377*cdf0e10cSrcweir             *pZ = m_aScales[2].Maximum;
378*cdf0e10cSrcweir     }
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir inline bool PlottingPositionHelper::clipYRange( double& rMin, double& rMax ) const
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir     //returns true if something remains
384*cdf0e10cSrcweir     if( rMin > rMax )
385*cdf0e10cSrcweir     {
386*cdf0e10cSrcweir         double fHelp = rMin;
387*cdf0e10cSrcweir         rMin = rMax;
388*cdf0e10cSrcweir         rMax = fHelp;
389*cdf0e10cSrcweir     }
390*cdf0e10cSrcweir     if( rMin > getLogicMaxY() )
391*cdf0e10cSrcweir         return false;
392*cdf0e10cSrcweir     if( rMax < getLogicMinY() )
393*cdf0e10cSrcweir         return false;
394*cdf0e10cSrcweir     if( rMin < getLogicMinY() )
395*cdf0e10cSrcweir         rMin = getLogicMinY();
396*cdf0e10cSrcweir     if( rMax > getLogicMaxY() )
397*cdf0e10cSrcweir         rMax = getLogicMaxY();
398*cdf0e10cSrcweir     return true;
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir inline double PlottingPositionHelper::getLogicMinX() const
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir     return m_aScales[0].Minimum;
404*cdf0e10cSrcweir }
405*cdf0e10cSrcweir inline double PlottingPositionHelper::getLogicMinY() const
406*cdf0e10cSrcweir {
407*cdf0e10cSrcweir     return m_aScales[1].Minimum;
408*cdf0e10cSrcweir }
409*cdf0e10cSrcweir inline double PlottingPositionHelper::getLogicMinZ() const
410*cdf0e10cSrcweir {
411*cdf0e10cSrcweir     return m_aScales[2].Minimum;
412*cdf0e10cSrcweir }
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir inline double PlottingPositionHelper::getLogicMaxX() const
415*cdf0e10cSrcweir {
416*cdf0e10cSrcweir     return m_aScales[0].Maximum;
417*cdf0e10cSrcweir }
418*cdf0e10cSrcweir inline double PlottingPositionHelper::getLogicMaxY() const
419*cdf0e10cSrcweir {
420*cdf0e10cSrcweir     return m_aScales[1].Maximum;
421*cdf0e10cSrcweir }
422*cdf0e10cSrcweir inline double PlottingPositionHelper::getLogicMaxZ() const
423*cdf0e10cSrcweir {
424*cdf0e10cSrcweir     return m_aScales[2].Maximum;
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir inline bool PlottingPositionHelper::isMathematicalOrientationX() const
427*cdf0e10cSrcweir {
428*cdf0e10cSrcweir     return ::com::sun::star::chart2::AxisOrientation_MATHEMATICAL == m_aScales[0].Orientation;
429*cdf0e10cSrcweir }
430*cdf0e10cSrcweir inline bool PlottingPositionHelper::isMathematicalOrientationY() const
431*cdf0e10cSrcweir {
432*cdf0e10cSrcweir     return ::com::sun::star::chart2::AxisOrientation_MATHEMATICAL == m_aScales[1].Orientation;
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir inline bool PlottingPositionHelper::isMathematicalOrientationZ() const
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir     return ::com::sun::star::chart2::AxisOrientation_MATHEMATICAL == m_aScales[2].Orientation;
437*cdf0e10cSrcweir }
438*cdf0e10cSrcweir inline bool PlottingPositionHelper::isSwapXAndY() const
439*cdf0e10cSrcweir {
440*cdf0e10cSrcweir     return m_bSwapXAndY;
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir inline bool PlottingPositionHelper::maySkipPointsInRegressionCalculation() const
443*cdf0e10cSrcweir {
444*cdf0e10cSrcweir     return m_bMaySkipPointsInRegressionCalculation;
445*cdf0e10cSrcweir }
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir //.............................................................................
448*cdf0e10cSrcweir } //namespace chart
449*cdf0e10cSrcweir //.............................................................................
450*cdf0e10cSrcweir #endif
451