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