xref: /trunk/main/chart2/source/inc/ThreeDHelper.hxx (revision de7b3f82)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef CHART2_THREEDHELPER_HXX
25 #define CHART2_THREEDHELPER_HXX
26 
27 #include <com/sun/star/chart2/XDiagram.hpp>
28 #include <com/sun/star/drawing/CameraGeometry.hpp>
29 #include <com/sun/star/drawing/ShadeMode.hpp>
30 #include "charttoolsdllapi.hxx"
31 
32 //.............................................................................
33 namespace chart
34 {
35 //.............................................................................
36 
37 //-----------------------------------------------------------------------------
38 /**
39 */
40 
41 enum ThreeDLookScheme
42 {
43     ThreeDLookScheme_Simple,
44     ThreeDLookScheme_Realistic,
45     ThreeDLookScheme_Unknown
46 };
47 
48 enum CuboidPlanePosition
49 {
50     CuboidPlanePosition_Left,
51     CuboidPlanePosition_Right,
52     CuboidPlanePosition_Top,
53     CuboidPlanePosition_Bottom,
54     CuboidPlanePosition_Front,
55     CuboidPlanePosition_Back
56 };
57 
58 class OOO_DLLPUBLIC_CHARTTOOLS ThreeDHelper
59 {
60 public:
61 
62     /** Returns the default camera geometry that is set in the Diagram CTOR.
63         This is not the property default!
64 
65         @todo deprecate the hard set camera geometry and use the property
66               default
67      */
68     static ::com::sun::star::drawing::CameraGeometry getDefaultCameraGeometry( bool bPie=false );
69 
70     static void getRotationAngleFromDiagram(
71         const ::com::sun::star::uno::Reference<
72             ::com::sun::star::beans::XPropertySet >& xSceneProperties
73             , double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad );
74     static void setRotationAngleToDiagram(
75         const ::com::sun::star::uno::Reference<
76             ::com::sun::star::beans::XPropertySet >& xSceneProperties
77             , double fXAngleRad, double fYAngleRad, double fZAngleRad );
78 
79     static void getRotationFromDiagram(
80         const ::com::sun::star::uno::Reference<
81             ::com::sun::star::beans::XPropertySet >& xSceneProperties
82             , sal_Int32& rnHorizontalAngleDegree, sal_Int32& rnVerticalAngleDegree );
83     static void setRotationToDiagram(
84         const ::com::sun::star::uno::Reference<
85             ::com::sun::star::beans::XPropertySet >& xSceneProperties
86             , sal_Int32 nHorizontalAngleDegree, sal_Int32 nVerticalYAngleDegree );
87 
88     static void switchRightAngledAxes( const ::com::sun::star::uno::Reference<
89             ::com::sun::star::beans::XPropertySet >& xSceneProperties
90             , sal_Bool bRightAngledAxes, bool bRotateLights=true );
91 
92     static void adaptRadAnglesForRightAngledAxes( double& rfXAngleRad, double& rfYAngleRad );
93     static double getXDegreeAngleLimitForRightAngledAxes();
94     static double getYDegreeAngleLimitForRightAngledAxes();
95     static double getValueClippedToRange( double fValue, const double& fPositivLimit );
96 
97     static void convertElevationRotationDegToXYZAngleRad(
98         sal_Int32 nElevationDeg, sal_Int32 nRotationDeg
99         , double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad );
100 
101     SAL_DLLPRIVATE static void convertXYZAngleRadToElevationRotationDeg(
102         sal_Int32& rnElevationDeg, sal_Int32& rnRotationDeg
103         , double fXRad, double fYRad, double fZRad );
104 
105     static double getCameraDistance(
106         const ::com::sun::star::uno::Reference<
107             ::com::sun::star::beans::XPropertySet >& xSceneProperties );
108     static void setCameraDistance(
109         const ::com::sun::star::uno::Reference<
110             ::com::sun::star::beans::XPropertySet >& xSceneProperties
111             , double fCameraDistance );
112     SAL_DLLPRIVATE static void ensureCameraDistanceRange( double& rfCameraDistance );
113     SAL_DLLPRIVATE static void getCameraDistanceRange( double& rfMinimumDistance, double& rfMaximumDistance );
114 
115     static double CameraDistanceToPerspective( double fCameraDistance );
116     static double PerspectiveToCameraDistance( double fPerspective );
117 
118     static void set3DSettingsToDefault( const ::com::sun::star::uno::Reference<
119             ::com::sun::star::beans::XPropertySet >& xSceneProperties );
120     static void setDefaultRotation( const ::com::sun::star::uno::Reference<
121             ::com::sun::star::beans::XPropertySet >& xSceneProperties );
122     static void setDefaultIllumination( const ::com::sun::star::uno::Reference<
123             ::com::sun::star::beans::XPropertySet >& xSceneProperties );
124 
125     static void setDefaultRotation( const ::com::sun::star::uno::Reference<
126             ::com::sun::star::beans::XPropertySet >& xSceneProperties, bool bPieOrDonut );
127 
128     static CuboidPlanePosition getAutomaticCuboidPlanePositionForStandardLeftWall( const ::com::sun::star::uno::Reference<
129             ::com::sun::star::beans::XPropertySet >& xSceneProperties );
130     static CuboidPlanePosition getAutomaticCuboidPlanePositionForStandardBackWall(const ::com::sun::star::uno::Reference<
131             ::com::sun::star::beans::XPropertySet >& xSceneProperties );
132     static CuboidPlanePosition getAutomaticCuboidPlanePositionForStandardBottom(const ::com::sun::star::uno::Reference<
133             ::com::sun::star::beans::XPropertySet >& xSceneProperties );
134 
135     static ThreeDLookScheme detectScheme( const ::com::sun::star::uno::Reference<
136             ::com::sun::star::chart2::XDiagram >& xDiagram );
137     static void setScheme( const ::com::sun::star::uno::Reference<
138             ::com::sun::star::chart2::XDiagram >& xDiagram
139             , ThreeDLookScheme aScheme );
140 
141     //sal_Int32 nRoundedEdges:  <0 or >100 -> mixed state
142     //sal_Int32 nObjectLines:  0->no lines; 1->all lines on; other->mixed state
143 
144     static void getRoundedEdgesAndObjectLines( const ::com::sun::star::uno::Reference<
145             ::com::sun::star::chart2::XDiagram >& xDiagram
146             , sal_Int32& rnRoundedEdges, sal_Int32& rnObjectLines );
147     static void setRoundedEdgesAndObjectLines( const ::com::sun::star::uno::Reference<
148             ::com::sun::star::chart2::XDiagram >& xDiagram
149             , sal_Int32 nRoundedEdges, sal_Int32 nObjectLines );
150 };
151 
152 //.............................................................................
153 } //namespace chart
154 //.............................................................................
155 #endif
156