1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: BarPositionHelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "BarPositionHelper.hxx"
35 #include "Linear3DTransformation.hxx"
36 #include "ViewDefines.hxx"
37 #include "CommonConverters.hxx"
39 //.............................................................................
42 //.............................................................................
43 using namespace ::com::sun::star
;
44 using namespace ::com::sun::star::chart2
;
46 BarPositionHelper::BarPositionHelper( bool /* bSwapXAndY */ )
47 : CategoryPositionHelper( 1 )
51 BarPositionHelper::BarPositionHelper( const BarPositionHelper
& rSource
)
52 : CategoryPositionHelper( rSource
)
53 , PlottingPositionHelper( rSource
)
57 BarPositionHelper::~BarPositionHelper()
61 PlottingPositionHelper
* BarPositionHelper::clone() const
63 BarPositionHelper
* pRet
= new BarPositionHelper(*this);
67 void BarPositionHelper::updateSeriesCount( double fSeriesCount
)
69 m_fSeriesCount
= fSeriesCount
;
72 uno::Reference
< XTransformation
> BarPositionHelper::getTransformationScaledLogicToScene() const
74 //transformation from 2) to 4) //@todo 2) and 4) need a link to a document
76 //we need to apply this transformation to each geometric object because of a bug/problem
77 //of the old drawing layer (the UNO_NAME_3D_EXTRUDE_DEPTH is an integer value instead of an double )
79 if( !m_xTransformationLogicToScene
.is() )
81 ::basegfx::B3DHomMatrix aMatrix
;
83 double MinX
= getLogicMinX();
84 double MinY
= getLogicMinY();
85 double MinZ
= getLogicMinZ();
86 double MaxX
= getLogicMaxX();
87 double MaxY
= getLogicMaxY();
88 double MaxZ
= getLogicMaxZ();
90 AxisOrientation nXAxisOrientation
= m_aScales
[0].Orientation
;
91 AxisOrientation nYAxisOrientation
= m_aScales
[1].Orientation
;
92 AxisOrientation nZAxisOrientation
= m_aScales
[2].Orientation
;
95 //scaling of x axis is refused/ignored
96 doLogicScaling( NULL
, &MinY
, &MinZ
);
97 doLogicScaling( NULL
, &MaxY
, &MaxZ
);
101 std::swap(MinX
,MinY
);
102 std::swap(MaxX
,MaxY
);
103 std::swap(nXAxisOrientation
,nYAxisOrientation
);
106 if( AxisOrientation_MATHEMATICAL
==nXAxisOrientation
)
107 aMatrix
.translate(-MinX
,0.0,0.0);
109 aMatrix
.translate(-MaxX
,0.0,0.0);
110 if( AxisOrientation_MATHEMATICAL
==nYAxisOrientation
)
111 aMatrix
.translate(0.0,-MinY
,0.0);
113 aMatrix
.translate(0.0,-MaxY
,0.0);
114 if( AxisOrientation_MATHEMATICAL
==nZAxisOrientation
)
115 aMatrix
.translate(0.0,0.0,-MaxZ
);//z direction in draw is reverse mathematical direction
117 aMatrix
.translate(0.0,0.0,-MinZ
);
119 double fWidthX
= MaxX
- MinX
;
120 double fWidthY
= MaxY
- MinY
;
121 double fWidthZ
= MaxZ
- MinZ
;
123 double fScaleDirectionX
= AxisOrientation_MATHEMATICAL
==nXAxisOrientation
? 1.0 : -1.0;
124 double fScaleDirectionY
= AxisOrientation_MATHEMATICAL
==nYAxisOrientation
? 1.0 : -1.0;
125 double fScaleDirectionZ
= AxisOrientation_MATHEMATICAL
==nZAxisOrientation
? -1.0 : 1.0;
127 aMatrix
.scale(fScaleDirectionX
*FIXED_SIZE_FOR_3D_CHART_VOLUME
/fWidthX
128 , fScaleDirectionY
*FIXED_SIZE_FOR_3D_CHART_VOLUME
/fWidthY
129 , fScaleDirectionZ
*FIXED_SIZE_FOR_3D_CHART_VOLUME
/fWidthZ
);
132 aMatrix
= m_aMatrixScreenToScene
*aMatrix
;
134 m_xTransformationLogicToScene
= new Linear3DTransformation(B3DHomMatrixToHomogenMatrix( aMatrix
),m_bSwapXAndY
);
136 return m_xTransformationLogicToScene
;
139 //.............................................................................
141 //.............................................................................