45 sal_Int32 nDimension )
46 : m_nDimensionCount(nDimension)
47 , m_xDiagram(xDiagram)
48 , m_aPreferredAspectRatio(rPreferredAspectRatio)
52 , m_bRightAngledAxes(false)
54 if( m_nDimensionCount != 3)
57 xDiagram->getRotationAngle( m_fXAnglePi, m_fYAnglePi, m_fZAnglePi );
58 if( ChartTypeHelper::isSupportingRightAngledAxes(
59 m_xDiagram->getChartTypeByIndex( 0 ) ) )
62 xDiagram->getPropertyValue(
"RightAngledAxes") >>= m_bRightAngledAxes;
63 if( m_bRightAngledAxes )
65 ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fXAnglePi, m_fYAnglePi );
80void VDiagram::createShapes(
const awt::Point& rPos,
const awt::Size& rSize )
82 m_aAvailablePosIncludingAxes = rPos;
83 m_aAvailableSizeIncludingAxes = rSize;
85 if( m_nDimensionCount == 3 )
97 if( m_nDimensionCount == 3 )
102 return aNewInnerRect;
107 m_aCurrentPosWithoutAxes = rPos;
108 m_aCurrentSizeWithoutAxes = rAvailableSize;
109 if( m_aPreferredAspectRatio.DirectionX > 0 && m_aPreferredAspectRatio.DirectionY > 0)
114 m_aCurrentSizeWithoutAxes = ShapeFactory::calculateNewSizeRespectingAspectRatio(
115 rAvailableSize, aAspectRatio );
117 m_aCurrentPosWithoutAxes = ShapeFactory::calculateTopLeftPositionToCenterObject(
118 rPos, rAvailableSize, m_aCurrentSizeWithoutAxes );
124 m_xWall2D->setSize( m_aCurrentSizeWithoutAxes);
125 m_xWall2D->setPosition(m_aCurrentPosWithoutAxes);
131void VDiagram::createShapes_2d()
133 OSL_PRECOND(
m_xTarget.is(),
"is not proper initialized");
139 m_xOuterGroupShape = xOuterGroup_Shapes;
144 m_xCoordinateRegionShape = ShapeFactory::createGroup2D(xOuterGroup_Shapes,
"testonly;CooContainer=XXX_CID");
146 bool bAddFloorAndWall = m_xDiagram->isSupportingFloorAndWall();
150 m_xWall2D = ShapeFactory::createRectangle( xGroupForWall );
154 OSL_ENSURE( m_xDiagram.is(),
"Invalid Diagram model" );
155 if( m_xDiagram.is() )
159 PropertyMapper::setMappedProperties( *m_xWall2D, xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties() );
161 if( !bAddFloorAndWall )
165 ShapeFactory::makeShapeInvisible( m_xWall2D );
174 catch(
const uno::Exception& )
181 adjustPosAndSize_2d( m_aAvailablePosIncludingAxes, m_aAvailableSizeIncludingAxes );
248void lcl_ensureScaleValue(
double& rfScale )
250 OSL_ENSURE(rfScale>0,
"calculation error for automatic 3D height in chart");
253 else if( rfScale<0.2 )
255 else if( rfScale>5.0 )
261void VDiagram::adjustAspectRatio3d(
const awt::Size& rAvailableSize )
263 OSL_PRECOND(m_xAspectRatio3D.is(),
"created shape offers no XPropertySet");
264 if( !m_xAspectRatio3D.is())
269 double fScaleX = m_aPreferredAspectRatio.DirectionX;
270 double fScaleY = m_aPreferredAspectRatio.DirectionY;
271 double fScaleZ = m_aPreferredAspectRatio.DirectionZ;
275 double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ );
281 if( fScaleX<0 || fScaleY<0 || fScaleZ<0 )
284 double fW = rAvailableSize.Width;
285 double fH = rAvailableSize.Height;
287 double sx = fabs(sin(m_fXAnglePi));
288 double sy = fabs(sin(m_fYAnglePi));
289 double cz = fabs(cos(m_fZAnglePi));
290 double sz = fabs(sin(m_fZAnglePi));
292 if(m_bRightAngledAxes)
298 if( fScaleX>0 && fScaleZ>0 )
301 if( !::basegfx::fTools::equalZero(fW) )
303 fScaleY = (fH/fW)*(sy*fScaleZ+fScaleX)-(sx*fScaleZ);
304 lcl_ensureScaleValue( fScaleY );
309 else if( fScaleY>0 && fScaleZ>0 )
312 if( !::basegfx::fTools::equalZero(fH) )
314 fScaleX = (fW/fH)*(sx*fScaleZ+fScaleY)-(sy*fScaleZ);
315 lcl_ensureScaleValue(fScaleX);
323 OSL_FAIL(
"not implemented yet");
339 if( fScaleX>0 && fScaleZ>0 )
342 double fDivide = fH*sz-fW*cz;
343 if( !::basegfx::fTools::equalZero(fDivide) )
345 fScaleY = fScaleX*(fW*sz-fH*cz) / fDivide;
346 lcl_ensureScaleValue(fScaleY);
352 else if( fScaleY>0 && fScaleZ>0 )
355 double fDivide = fW*sz-fH*cz;
356 if( !::basegfx::fTools::equalZero(fDivide) )
358 fScaleX = fScaleY*(fH*sz-fW*cz) / fDivide;
359 lcl_ensureScaleValue(fScaleX);
367 OSL_FAIL(
"not implemented yet");
381 double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ );
392 aResult.
scale( fScaleX, fScaleY, fScaleZ );
405 catch(
const uno::Exception& )
413 adjustAspectRatio3d( rAvailableSize );
416 m_aCurrentSizeWithoutAxes = ShapeFactory::calculateNewSizeRespectingAspectRatio(
417 rAvailableSize, m_xOuterGroupShape->getSize() );
418 m_xOuterGroupShape->setSize( m_aCurrentSizeWithoutAxes );
421 m_aCurrentPosWithoutAxes= ShapeFactory::calculateTopLeftPositionToCenterObject(
422 rPos, rAvailableSize, m_aCurrentSizeWithoutAxes );
423 m_xOuterGroupShape->setPosition(m_aCurrentPosWithoutAxes);
428void VDiagram::createShapes_3d()
430 OSL_PRECOND(
m_xTarget.is(),
"is not proper initialized");
436 m_xOuterGroupShape = xShapes;
441 xOuterGroup_Shapes = ShapeFactory::createGroup3D( xOuterGroup_Shapes );
443 m_xAspectRatio3D = xOuterGroup_Shapes;
445 bool bAddFloorAndWall = m_xDiagram->isSupportingFloorAndWall();
447 const bool bDoubleSided =
false;
452 if( m_xDiagram.is() )
453 xWallProp.set( m_xDiagram->getWall() );
456 if( !bAddFloorAndWall )
460 CuboidPlanePosition eLeftWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( m_xDiagram ) );
461 CuboidPlanePosition eBackWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( m_xDiagram ) );
482 ShapeFactory::createStripe( xWallGroup_Shapes, aStripe
483 , xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), bDoubleSided, nRotatedTexture );
484 if( !bAddFloorAndWall )
488 ShapeFactory::makeShapeInvisible( xShape );
493 short nRotatedTexture = 0;
510 ShapeFactory::createStripe(xWallGroup_Shapes, aStripe
511 , xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), bDoubleSided, nRotatedTexture );
512 if( !bAddFloorAndWall )
516 ShapeFactory::makeShapeInvisible( xShape );
528 static_cast<sal_Int32
>(m_xDiagram->getCameraDistance())));
553 if(!m_bRightAngledAxes)
554 aEffectiveTransformation.
rotate(m_fXAnglePi,m_fYAnglePi,m_fZAnglePi);
556 aEffectiveTransformation.
shearXY(m_fYAnglePi,-m_fXAnglePi);
565 catch(
const uno::Exception & )
573 if( m_xDiagram.is() )
574 xFloorProp.set( m_xDiagram->getFloor() );
576 Stripe aStripe( drawing::Position3D(0,0,0)
582 ShapeFactory::createStripe(xOuterGroup_Shapes, aStripe
583 , xFloorProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), bDoubleSided );
585 CuboidPlanePosition eBottomPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBottom( m_xDiagram ) );
590 ShapeFactory::makeShapeInvisible( xShape );
595 ShapeFactory::setShapeName( xShape, aFloorCID );
602 m_xCoordinateRegionShape = xShapes2;
612 aM.
scale( fXScale, fYScale, fZScale );
618 catch(
const uno::Exception& )
624 m_aCurrentPosWithoutAxes = m_aAvailablePosIncludingAxes;
625 m_aCurrentSizeWithoutAxes = m_aAvailableSizeIncludingAxes;
626 adjustPosAndSize_3d( m_aAvailablePosIncludingAxes, m_aAvailableSizeIncludingAxes );
634void VDiagram::reduceToMinimumSize()
636 if( !m_xOuterGroupShape.is() )
639 awt::Size aMaxSize( m_aAvailableSizeIncludingAxes );
640 awt::Point aMaxPos( m_aAvailablePosIncludingAxes );
642 sal_Int32 nNewWidth = std::round(aMaxSize.Width/2.2);
643 sal_Int32 nNewHeight = std::round(aMaxSize.Height/2.2);
644 awt::Size aNewSize( nNewWidth, nNewHeight );
645 awt::Point aNewPos( aMaxPos );
646 aNewPos.X += nNewWidth;
647 aNewPos.Y += nNewHeight;
649 adjustPosAndSize( aNewPos, aNewSize );
654 awt::Point aNewPos = m_aCurrentPosWithoutAxes;
655 awt::Size aNewSize = m_aCurrentSizeWithoutAxes;
660 sal_Int32 nDeltaWidth = aAvailableOuterRect.
getWidth() - rConsumedOuterRect.getWidth();
661 sal_Int32 nDeltaHeight = aAvailableOuterRect.
getHeight() - rConsumedOuterRect.getHeight();
662 if( (aNewSize.Width + nDeltaWidth) < aAvailableOuterRect.
getWidth()/3 )
663 nDeltaWidth = aAvailableOuterRect.
getWidth()/3 - aNewSize.Width;
664 aNewSize.Width += nDeltaWidth;
666 if( (aNewSize.Height + nDeltaHeight) < aAvailableOuterRect.
getHeight()/3 )
667 nDeltaHeight = aAvailableOuterRect.
getHeight()/3 - aNewSize.Height;
668 aNewSize.Height += nDeltaHeight;
670 sal_Int32 nDiffLeft = rConsumedOuterRect.getMinX() - aAvailableOuterRect.
getMinX();
671 sal_Int32 nDiffRight = aAvailableOuterRect.
getMaxX() - rConsumedOuterRect.getMaxX();
673 aNewPos.X -= nDiffLeft;
674 else if( nDiffRight >= 0 )
676 if( nDiffRight > -nDiffLeft )
677 aNewPos.X +=
abs(nDiffLeft);
678 else if( nDiffRight >
abs(nDeltaWidth) )
679 aNewPos.X += nDiffRight;
681 aNewPos.X +=
abs(nDeltaWidth);
684 sal_Int32 nDiffUp = rConsumedOuterRect.getMinY() - aAvailableOuterRect.
getMinY();
685 sal_Int32 nDiffDown = aAvailableOuterRect.
getMaxY() - rConsumedOuterRect.getMaxY();
687 aNewPos.Y -= nDiffUp;
688 else if( nDiffDown >= 0 )
690 if( nDiffDown > -nDiffUp )
691 aNewPos.Y +=
abs(nDiffUp);
692 else if( nDiffDown >
abs(nDeltaHeight) )
693 aNewPos.Y += nDiffDown;
695 aNewPos.Y +=
abs(nDeltaHeight);
698 return adjustPosAndSize( aNewPos, aNewSize );
#define GRID_TO_WALL_DISTANCE
void shearXY(double fSx, double fSy)
void rotate(double fAngleX, double fAngleY, double fAngleZ)
void translate(double fX, double fY, double fZ)
void scale(double fX, double fY, double fZ)
void intersect(const Range2D &rRange)
A Stripe represents a 2 dimensional foursquare plane in a 3 dimensional room.
void InvertNormal(bool bInvertNormal)
VDiagram(const rtl::Reference<::chart::Diagram > &xDiagram, const css::drawing::Direction3D &rPreferredAspectRatio, sal_Int32 nDimension)
Reference< lang::XComponent > m_xTarget
constexpr double FIXED_SIZE_FOR_3D_CHART_VOLUME
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XInterface > xTarget
OOO_DLLPUBLIC_CHARTTOOLS css::awt::Point B2IRectangleToAWTPoint(const ::basegfx::B2IRectangle &rB2IRectangle)
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::HomogenMatrix B3DHomMatrixToHomogenMatrix(const ::basegfx::B3DHomMatrix &rB3DMatrix)
OOO_DLLPUBLIC_CHARTTOOLS::basegfx::B2IRectangle makeRectangle(const css::awt::Point &rPosition, const css::awt::Size &rSize)
OOO_DLLPUBLIC_CHARTTOOLS css::awt::Size B2IRectangleToAWTSize(const ::basegfx::B2IRectangle &rB2IRectangle)
static E3dScene * lcl_getE3dScene(const rtl::Reference< SvxShapeGroupAnyD > &xShape)
@ OBJECTTYPE_DIAGRAM_FLOOR
@ OBJECTTYPE_DIAGRAM_WALL
static void lcl_setLightSources(const uno::Reference< beans::XPropertySet > &xSource, const uno::Reference< beans::XPropertySet > &xDest)
@ CuboidPlanePosition_Right
@ CuboidPlanePosition_Front
@ CuboidPlanePosition_Bottom
SwNodeOffset abs(const SwNodeOffset &a)
SVXCORE_DLLPUBLIC E3dScene * DynCastE3dScene(SdrObject *)
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTON_7
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTDIRECTION_8
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTDIRECTION_5
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTCOLOR_8
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTDIRECTION_6
constexpr OUStringLiteral UNO_NAME_3D_SCENE_TWO_SIDED_LIGHTING
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTCOLOR_7
constexpr OUStringLiteral UNO_NAME_3D_SCENE_DISTANCE
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTON_6
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTON_3
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTON_8
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTDIRECTION_7
constexpr OUStringLiteral UNO_NAME_3D_SCENE_PERSPECTIVE
constexpr OUStringLiteral UNO_NAME_3D_TRANSFORM_MATRIX
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTON_5
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTCOLOR_5
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTDIRECTION_2
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTON_1
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTDIRECTION_3
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTDIRECTION_4
constexpr OUStringLiteral UNO_NAME_3D_SCENE_SHADE_MODE
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTCOLOR_1
constexpr OUStringLiteral UNO_NAME_3D_SCENE_AMBIENTCOLOR
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTON_4
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTDIRECTION_1
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTCOLOR_3
constexpr OUStringLiteral UNO_NAME_MISC_OBJ_NAME
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTCOLOR_2
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTCOLOR_6
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTON_2
constexpr OUStringLiteral UNO_NAME_3D_SCENE_LIGHTCOLOR_4