summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2007-07-03 12:45:24 +0000
committerRüdiger Timm <rt@openoffice.org>2007-07-03 12:45:24 +0000
commit9109a315897bdc6d690658cc3bcce61c1c4e1708 (patch)
treee316867f07775a09a987060f19c03d12540ea374 /chart2
parent495197f51106c2c91f60fb730d149a643747c0fe (diff)
INTEGRATION: CWS chart06 (1.13.8); FILE MERGED
2007/06/22 12:45:07 iha 1.13.8.5: RESYNC: (1.13-1.14); FILE MERGED 2007/06/15 12:45:40 iha 1.13.8.4: #i67754# for right-angled-axes restrict angles to meaningful values 2007/06/14 09:15:09 iha 1.13.8.3: #i67754#,#i76430# better default illumination also depending on right angled axes 2007/06/11 11:57:27 iha 1.13.8.2: #i67754# right-angled-axes, not supported for pie and donut 2007/06/11 09:07:40 iha 1.13.8.1: #i67754# right-angled-axes option for 3D charts
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/diagram/VDiagram.cxx180
1 files changed, 118 insertions, 62 deletions
diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx
index 2af203fc17e1..46a201d133bb 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: VDiagram.cxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: obo $ $Date: 2007-06-11 15:03:18 $
+ * last change: $Author: rt $ $Date: 2007-07-03 13:45:24 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -45,6 +45,8 @@
#include "DiagramHelper.hxx"
#include "BaseGFXHelper.hxx"
#include "CommonConverters.hxx"
+#include "ChartTypeHelper.hxx"
+#include "ThreeDHelper.hxx"
#ifndef _SVX_UNOPRNMS_HXX
#include <svx/unoprnms.hxx>
@@ -115,11 +117,23 @@ VDiagram::VDiagram(
, m_fXAnglePi(0)
, m_fYAnglePi(0)
, m_fZAnglePi(0)
+ , m_bRightAngledAxes(sal_False)
{
if( m_nDimensionCount == 3)
{
uno::Reference< beans::XPropertySet > xSourceProp( m_xDiagram, uno::UNO_QUERY );
- DiagramHelper::getRotationAngleFromDiagram( xSourceProp, m_fXAnglePi, m_fYAnglePi, m_fZAnglePi );
+ ThreeDHelper::getRotationAngleFromDiagram( xSourceProp, m_fXAnglePi, m_fYAnglePi, m_fZAnglePi );
+ if( ChartTypeHelper::isSupportingRightAngledAxes(
+ DiagramHelper::getChartTypeByIndex( m_xDiagram, 0 ) ) )
+ {
+ if(xSourceProp.is())
+ xSourceProp->getPropertyValue(C2U( "RightAngledAxes" )) >>= m_bRightAngledAxes;
+ if( m_bRightAngledAxes )
+ {
+ ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fXAnglePi, m_fYAnglePi );
+ m_fZAnglePi=0.0;
+ }
+ }
}
}
@@ -331,6 +345,22 @@ void lcl_setLightSources(
xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_8 )));
}
+namespace
+{
+
+void lcl_ensureScaleValue( double& rfScale )
+{
+ DBG_ASSERT(rfScale>0, "calculation error for automatic 3D height in chart");
+ if( rfScale<0 )
+ rfScale = 1.0;
+ else if( rfScale<0.2 )
+ rfScale = 0.2;
+ else if( rfScale>5.0 )
+ rfScale = 5.0;
+}
+
+}
+
void VDiagram::adjustAspectRatio3d( const awt::Size& rAvailableSize )
{
DBG_ASSERT(m_xAspectRatio3D.is(), "created shape offers no XPropertySet");
@@ -363,82 +393,104 @@ void VDiagram::adjustAspectRatio3d( const awt::Size& rAvailableSize )
double cz = fabs(cos(m_fZAnglePi));
double sz = fabs(sin(m_fZAnglePi));
- if( fScaleX>0 && fScaleZ>0 )
+ if(m_bRightAngledAxes)
{
- //calculate fScaleY:
//base equations:
- //fH*zoomfactor == cz*fScaleY + sz*fScaleX;
- //fW*zoomfactor == cz*fScaleX + sz*fScaleY;
- //==> fScaleY*(fH*sz-fW*cz) == fScaleX*(fW*sz-fH*cz);
- double fDivide = fH*sz-fW*cz;
- if( !::basegfx::fTools::equalZero(fDivide) )
+ //fH*zoomfactor == sx*fScaleZ + fScaleY;
+ //fW*zoomfactor == sy*fScaleZ + fScaleX;
+
+ if( fScaleX>0 && fScaleZ>0 )
{
- fScaleY = fScaleX*(fW*sz-fH*cz) / fDivide;
- DBG_ASSERT(fScaleY>0, "calculation error for automatic 3D height in chart");
- if( fScaleY<0 )
- fScaleY = 1.0;
- if( fScaleY<0.2 )
- fScaleY = 0.2;
- if( fScaleY>5.0 )
- fScaleY = 5.0;
+ //calculate fScaleY:
+ if( !::basegfx::fTools::equalZero(fW) )
+ {
+ fScaleY = (fH/fW)*(sy*fScaleZ+fScaleX)-(sx*fScaleZ);
+ lcl_ensureScaleValue( fScaleY );
+ }
+ else
+ fScaleY = 1.0;//looking from top or bottom the height is irrelevant
+ }
+ else if( fScaleY>0 && fScaleZ>0 )
+ {
+ //calculate fScaleX:
+ if( !::basegfx::fTools::equalZero(fH) )
+ {
+ fScaleX = (fW/fH)*(sx*fScaleZ+fScaleY)-(sy*fScaleZ);
+ lcl_ensureScaleValue(fScaleX);
+ }
+ else
+ fScaleX = 1.0;//looking from top or bottom hieght is irrelevant
}
else
- fScaleY = 1.0;//looking from top or bottom hieght is irrelevant
-
- /*
- //fW*zoomfactor == fScaleX*cy*cz + fScaleY*sz*cy + fScaleZ*sy*cx;
- //fH*zoomfactor == fScaleY*cx*cz + fScaleX*sz*cy + fScaleZ*sx*cz;
- //==> fScaleY*(sz*cy*fH -cx*cz*fW) = fScaleX*(sz*cy*fW - cy*cz*fH) + fScaleZ*(sx*cz*fW - sy*cx*fH);
- double fDivide = sz*cy*fH -cx*cz*fW;
- if( !::basegfx::fTools::equalZero(fDivide) )
{
- fScaleY = ( fScaleX*(sz*cy*fW - cy*cz*fH)
- + fScaleZ*(sx*cz*fW - sy*cx*fH) ) / fDivide;
- DBG_ASSERT(fScaleY>0, "calculation error for automatic 3D height in chart");
+ //todo
+ DBG_ASSERT(false, "not implemented yet");
+
+ if( fScaleX<0 )
+ fScaleX = 1.0;
if( fScaleY<0 )
fScaleY = 1.0;
- if( fScaleY<0.2 )
- fScaleY = 0.2;
- if( fScaleY>5.0 )
- fScaleY = 5.0;
+ if( fScaleZ<0 )
+ fScaleZ = 1.0;
}
- else
- fScaleY = 1.0;//looking from top or bottom hieght is irrelevant
- */
}
- else if( fScaleY>0 && fScaleZ>0 )
+ else
{
- //calculate fScaleY:
//base equations:
//fH*zoomfactor == cz*fScaleY + sz*fScaleX;
//fW*zoomfactor == cz*fScaleX + sz*fScaleY;
//==> fScaleY*(fH*sz-fW*cz) == fScaleX*(fW*sz-fH*cz);
- double fDivide = fW*sz-fH*cz;
- if( !::basegfx::fTools::equalZero(fDivide) )
+ if( fScaleX>0 && fScaleZ>0 )
+ {
+ //calculate fScaleY:
+ double fDivide = fH*sz-fW*cz;
+ if( !::basegfx::fTools::equalZero(fDivide) )
+ {
+ fScaleY = fScaleX*(fW*sz-fH*cz) / fDivide;
+ lcl_ensureScaleValue(fScaleY);
+ }
+ else
+ fScaleY = 1.0;//looking from top or bottom the height is irrelevant
+
+ /*
+ //fW*zoomfactor == fScaleX*cy*cz + fScaleY*sz*cy + fScaleZ*sy*cx;
+ //fH*zoomfactor == fScaleY*cx*cz + fScaleX*sz*cy + fScaleZ*sx*cz;
+ //==> fScaleY*(sz*cy*fH -cx*cz*fW) = fScaleX*(sz*cy*fW - cy*cz*fH) + fScaleZ*(sx*cz*fW - sy*cx*fH);
+ double fDivide = sz*cy*fH -cx*cz*fW;
+ if( !::basegfx::fTools::equalZero(fDivide) )
+ {
+ fScaleY = ( fScaleX*(sz*cy*fW - cy*cz*fH)
+ + fScaleZ*(sx*cz*fW - sy*cx*fH) ) / fDivide;
+ lcl_ensureScaleValue(fScaleY);
+ }
+ else
+ fScaleY = 1.0;//looking from top or bottom hieght is irrelevant
+ */
+ }
+ else if( fScaleY>0 && fScaleZ>0 )
+ {
+ //calculate fScaleX:
+ double fDivide = fW*sz-fH*cz;
+ if( !::basegfx::fTools::equalZero(fDivide) )
+ {
+ fScaleX = fScaleY*(fH*sz-fW*cz) / fDivide;
+ lcl_ensureScaleValue(fScaleX);
+ }
+ else
+ fScaleX = 1.0;//looking from top or bottom hieght is irrelevant
+ }
+ else
{
- fScaleX = fScaleY*(fH*sz-fW*cz) / fDivide;
- DBG_ASSERT(fScaleX>0, "calculation error for automatic 3D height in chart");
+ //todo
+ DBG_ASSERT(false, "not implemented yet");
+
if( fScaleX<0 )
fScaleX = 1.0;
- if( fScaleX<0.2 )
- fScaleX = 0.2;
- if( fScaleX>5.0 )
- fScaleX = 5.0;
+ if( fScaleY<0 )
+ fScaleY = 1.0;
+ if( fScaleZ<0 )
+ fScaleZ = 1.0;
}
- else
- fScaleX = 1.0;//looking from top or bottom hieght is irrelevant
- }
- else
- {
- //todo
- DBG_ASSERT(false, "not implemented yet");
-
- if( fScaleX<0 )
- fScaleX = 1.0;
- if( fScaleY<0 )
- fScaleY = 1.0;
- if( fScaleZ<0 )
- fScaleZ = 1.0;
}
}
@@ -513,7 +565,7 @@ void VDiagram::createShapes_3d()
//ignore distance and focal length from file format and model comcpletely
//use vrp only to indicate the distance of the camera and thus influence the perspecitve
xDestProp->setPropertyValue( C2U( UNO_NAME_3D_SCENE_DISTANCE ), uno::makeAny(
- static_cast<sal_Int32>(DiagramHelper::getCameraDistance( xSourceProp ))));
+ static_cast<sal_Int32>(ThreeDHelper::getCameraDistance( xSourceProp ))));
xDestProp->setPropertyValue( C2U( UNO_NAME_3D_SCENE_PERSPECTIVE ),
xSourceProp->getPropertyValue( C2U( UNO_NAME_3D_SCENE_PERSPECTIVE )));
}
@@ -537,7 +589,11 @@ void VDiagram::createShapes_3d()
::basegfx::B3DHomMatrix aEffectiveTranformation;
aEffectiveTranformation.translate(-FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0);
- aEffectiveTranformation.rotate(m_fXAnglePi,m_fYAnglePi,m_fZAnglePi);
+
+ if(!m_bRightAngledAxes)
+ aEffectiveTranformation.rotate(m_fXAnglePi,m_fYAnglePi,m_fZAnglePi);
+ else
+ aEffectiveTranformation.shearXY(m_fYAnglePi,-m_fXAnglePi);
xDestProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX ),
uno::makeAny( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aEffectiveTranformation ) ) );