diff options
author | Oliver Bolte <obo@openoffice.org> | 2008-10-17 08:40:10 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2008-10-17 08:40:10 +0000 |
commit | a8ac4bc4145e7e558153b58c87b2def339aebe36 (patch) | |
tree | d1f5da0a1b702f12725b2b82117b7ff49872bb21 /svx/source/engine3d/obj3d.cxx | |
parent | ae562e931a98e708a75e8d140cf1ff24854acfc7 (diff) |
CWS-TOOLING: integrate CWS aw057
Diffstat (limited to 'svx/source/engine3d/obj3d.cxx')
-rw-r--r-- | svx/source/engine3d/obj3d.cxx | 2400 |
1 files changed, 349 insertions, 2051 deletions
diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx index 5da69712d532..743aa3c6aa56 100644 --- a/svx/source/engine3d/obj3d.cxx +++ b/svx/source/engine3d/obj3d.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: obj3d.cxx,v $ - * $Revision: 1.48 $ + * $Revision: 1.48.18.1 $ * * This file is part of OpenOffice.org. * @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" - #include "svdstr.hrc" #include "svdglob.hxx" #include <svx/svdview.hxx> @@ -52,8 +51,6 @@ #include <svx/xflclit.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> -#include <goodies/base3d.hxx> -#include <goodies/b3dtex.hxx> #include <svx/xlnclit.hxx> #include <svtools/metitem.hxx> #include <svx/xtable.hxx> @@ -87,9 +84,20 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b3dpolygontools.hxx> +#include <svx/helperhittest3d.hxx> +#include <svx/sdr/contact/viewcontactofe3d.hxx> +#include <drawinglayer/geometry/viewinformation3d.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <svx/sdr/contact/viewcontactofe3dscene.hxx> +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#include <svx/e3dsceneupdater.hxx> #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + /************************************************************************* |* |* Liste fuer 3D-Objekte @@ -131,34 +139,51 @@ void E3dObjList::NbcInsertObject(SdrObject* pObj, ULONG nPos, const SdrInsertRea } } +void E3dObjList::InsertObject(SdrObject* pObj, ULONG nPos, const SdrInsertReason* pReason) +{ + OSL_ENSURE(GetOwnerObj()->ISA(E3dObject), "Insert 3DObject in non-3D Parent"); + //E3DModifySceneSnapRectUpdater aUpdater(GetOwnerObj()); + + // call parent + SdrObjList::InsertObject(pObj, nPos, pReason); + + E3dScene* pScene = ((E3dObject*)GetOwnerObj())->GetScene(); + if(pScene) + { + pScene->Cleanup3DDepthMapper(); + } +} + SdrObject* E3dObjList::NbcRemoveObject(ULONG nObjNum) { - // Owner holen DBG_ASSERT(GetOwnerObj()->ISA(E3dObject), "AW: Entfernen 3DObject aus Parent != 3DObject"); - //E3dObject* pOwner = (E3dObject*)GetOwnerObj(); + //E3DModifySceneSnapRectUpdater aUpdater(GetOwnerObj()); // call parent SdrObject* pRetval = SdrObjList::NbcRemoveObject(nObjNum); - // FitSnapRectToBoundVol vorbereiten - if(GetOwnerObj() && GetOwnerObj()->ISA(E3dScene)) - ((E3dScene*)GetOwnerObj())->CorrectSceneDimensions(); + E3dScene* pScene = ((E3dObject*)GetOwnerObj())->GetScene(); + if(pScene) + { + pScene->Cleanup3DDepthMapper(); + } return pRetval; } SdrObject* E3dObjList::RemoveObject(ULONG nObjNum) { - // Owner holen - DBG_ASSERT(GetOwnerObj()->ISA(E3dObject), "AW: Entfernen 3DObject aus Parent != 3DObject"); - //E3dObject* pOwner = (E3dObject*)GetOwnerObj(); + OSL_ENSURE(GetOwnerObj()->ISA(E3dObject), "3DObject is removed from non-3D Parent"); + //E3DModifySceneSnapRectUpdater aUpdater(GetOwnerObj()); // call parent SdrObject* pRetval = SdrObjList::RemoveObject(nObjNum); - // FitSnapRectToBoundVol vorbereiten - if(GetOwnerObj() && GetOwnerObj()->ISA(E3dScene)) - ((E3dScene*)GetOwnerObj())->CorrectSceneDimensions(); + E3dScene* pScene = ((E3dObject*)GetOwnerObj())->GetScene(); + if(pScene) + { + pScene->Cleanup3DDepthMapper(); + } return pRetval; } @@ -180,16 +205,18 @@ sdr::properties::BaseProperties* E3dObject::CreateObjectSpecificProperties() TYPEINIT1(E3dObject, SdrAttrObj); -E3dObject::E3dObject() : - bTfHasChanged(TRUE), - bBoundVolValid(TRUE), - bIsSelected(FALSE) +E3dObject::E3dObject() +: maSubList(), + maLocalBoundVol(), + maTransformation(), + maFullTransform(), + mbTfHasChanged(true), + mbIsSelected(false) { - bIs3DObj = TRUE; - pSub = new E3dObjList(NULL, NULL); - pSub->SetOwnerObj(this); - pSub->SetListKind(SDROBJLIST_GROUPOBJ); - bClosedObj = TRUE; + bIs3DObj = true; + maSubList.SetOwnerObj(this); + maSubList.SetListKind(SDROBJLIST_GROUPOBJ); + bClosedObj = true; } /************************************************************************* @@ -200,8 +227,6 @@ E3dObject::E3dObject() : E3dObject::~E3dObject() { - delete pSub; - pSub = NULL; } /************************************************************************* @@ -210,16 +235,21 @@ E3dObject::~E3dObject() |* \************************************************************************/ -void E3dObject::SetSelected(BOOL bNew) +void E3dObject::SetSelected(bool bNew) { - // selbst setzen - bIsSelected = bNew; + if((bool)mbIsSelected != bNew) + { + mbIsSelected = bNew; + } - // bei SubObjekten setzen - for ( ULONG i = 0; i < pSub->GetObjCount(); i++ ) + for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++) { - if(pSub->GetObj(i) && pSub->GetObj(i)->ISA(E3dObject)) - ((E3dObject*)pSub->GetObj(i))->SetSelected(bNew); + E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a)); + + if(pCandidate) + { + pCandidate->SetSelected(bNew); + } } } @@ -250,14 +280,13 @@ void E3dObject::SetRectsDirty(sal_Bool bNotMyself) // call parent SdrAttrObj::SetRectsDirty(bNotMyself); - // Eigene SubListe AUCH behandeln - if(pSub && pSub->GetObjCount()) + for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++) { - for (ULONG i = 0; i < pSub->GetObjCount(); i++) + E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a)); + + if(pCandidate) { - SdrObject* pObj = pSub->GetObj(i); - DBG_ASSERT(pObj->ISA(E3dObject), "AW: In E3dObject sind nur 3D-Objekte erlaubt!"); - ((E3dObject*)pObj)->SetRectsDirty(bNotMyself); + pCandidate->SetRectsDirty(bNotMyself); } } } @@ -320,7 +349,6 @@ void E3dObject::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const // Problem. rInfo.bCanConvToPoly = FALSE; rInfo.bCanConvToContour = FALSE; - rInfo.bCanConvToPathLineToArea = FALSE; rInfo.bCanConvToPolyLineToArea = FALSE; } @@ -335,11 +363,15 @@ void E3dObject::NbcSetLayer(SdrLayerID nLayer) { SdrAttrObj::NbcSetLayer(nLayer); - E3dObjList* pOL = pSub; - ULONG nObjCnt = pOL->GetObjCount(); - ULONG i; - for ( i = 0; i < nObjCnt; i++ ) - pOL->GetObj(i)->NbcSetLayer(nLayer); + for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++) + { + E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a)); + + if(pCandidate) + { + pCandidate->NbcSetLayer(nLayer); + } + } } /************************************************************************* @@ -351,7 +383,7 @@ void E3dObject::NbcSetLayer(SdrLayerID nLayer) void E3dObject::SetObjList(SdrObjList* pNewObjList) { SdrObject::SetObjList(pNewObjList); - pSub->SetUpList(pNewObjList); + maSubList.SetUpList(pNewObjList); } /************************************************************************* @@ -363,7 +395,7 @@ void E3dObject::SetObjList(SdrObjList* pNewObjList) void E3dObject::SetPage(SdrPage* pNewPage) { SdrAttrObj::SetPage(pNewPage); - pSub->SetPage(pNewPage); + maSubList.SetPage(pNewPage); } /************************************************************************* @@ -375,7 +407,7 @@ void E3dObject::SetPage(SdrPage* pNewPage) void E3dObject::SetModel(SdrModel* pNewModel) { SdrAttrObj::SetModel(pNewModel); - pSub->SetModel(pNewModel); + maSubList.SetModel(pNewModel); } /************************************************************************* @@ -391,35 +423,45 @@ void E3dObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fracti if(pScene) { - // pos ermitteln - B3dTransformationSet& rTransSet = pScene->GetCameraSet(); - basegfx::B3DPoint aScaleCenter((double)rRef.X(), (double)rRef.Y(), 32768.0); - aScaleCenter = rTransSet.ViewToEyeCoor(aScaleCenter); + // transform pos from 2D world to 3D eye + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); + const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D()); + basegfx::B2DPoint aScaleCenter2D((double)rRef.X(), (double)rRef.Y()); + basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation()); + + aInverseSceneTransform.invert(); + aScaleCenter2D = aInverseSceneTransform * aScaleCenter2D; + + basegfx::B3DPoint aScaleCenter3D(aScaleCenter2D.getX(), aScaleCenter2D.getY(), 0.5); + basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection()); + + aInverseViewToEye.invert(); + aScaleCenter3D = aInverseViewToEye * aScaleCenter3D; // scale-faktoren holen double fScaleX(xFact); double fScaleY(yFact); // build transform + basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation()); + aInverseOrientation.invert(); basegfx::B3DHomMatrix mFullTransform(GetFullTransform()); basegfx::B3DHomMatrix mTrans(mFullTransform); - mTrans *= rTransSet.GetOrientation(); - mTrans.translate(-aScaleCenter.getX(), -aScaleCenter.getY(), -aScaleCenter.getZ()); + mTrans *= aViewInfo3D.getOrientation(); + mTrans.translate(-aScaleCenter3D.getX(), -aScaleCenter3D.getY(), -aScaleCenter3D.getZ()); mTrans.scale(fScaleX, fScaleY, 1.0); - mTrans.translate(aScaleCenter.getX(), aScaleCenter.getY(), aScaleCenter.getZ()); - mTrans *= rTransSet.GetInvOrientation(); + mTrans.translate(aScaleCenter3D.getX(), aScaleCenter3D.getY(), aScaleCenter3D.getZ()); + mTrans *= aInverseOrientation; mFullTransform.invert(); mTrans *= mFullTransform; // anwenden basegfx::B3DHomMatrix mObjTrans(GetTransform()); mObjTrans *= mTrans; - SetTransform(mObjTrans); - // force new camera and SnapRect on scene, geometry may have really - // changed - pScene->CorrectSceneDimensions(); + E3DModifySceneSnapRectUpdater aUpdater(this); + SetTransform(mObjTrans); } } @@ -446,31 +488,33 @@ void E3dObject::NbcMove(const Size& rSize) mInvDispTransform.invert(); } - // BoundVolume von Weltkoordinaten in Eye-Koordinaten - B3dTransformationSet& rTransSet = pScene->GetCameraSet(); - const Volume3D& rVol = pScene->GetBoundVolume(); - Volume3D aEyeVol = rVol.GetTransformVolume(rTransSet.GetOrientation()); + // BoundVolume from 3d world to 3d eye + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); + const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D()); + basegfx::B3DRange aEyeVol(pScene->GetBoundVolume()); + aEyeVol.transform(aViewInfo3D.getOrientation()); - // relativen Bewegungsvektor in Augkoordinaten bilden + // build relative movement vector in eye coordinates basegfx::B3DPoint aMove( (double)rSize.Width() * aEyeVol.getWidth() / (double)aRect.GetWidth(), (double)-rSize.Height() * aEyeVol.getHeight() / (double)aRect.GetHeight(), 0.0); + basegfx::B3DPoint aPos(0.0, 0.0, 0.0); + + // movement vektor to local coordinates of objects' parent + basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation()); + aInverseOrientation.invert(); + basegfx::B3DHomMatrix aCompleteTrans(mInvDispTransform * aInverseOrientation); - // Bewegungsvektor in lokale Koordinaten des Parents des Objektes - basegfx::B3DPoint aPos; - aMove = rTransSet.EyeToWorldCoor(aMove); - aMove *= mInvDispTransform; - aPos = rTransSet.EyeToWorldCoor(aPos); - aPos *= mInvDispTransform; - aMove = aMove - aPos; + aMove = aCompleteTrans * aMove; + aPos = aCompleteTrans * aPos; - // Transformieren - Translate(aMove); + // build transformation and apply + basegfx::B3DHomMatrix aTranslate; + aTranslate.translate(aMove.getX() - aPos.getX(), aMove.getY() - aPos.getY(), aMove.getZ() - aPos.getZ()); - // force new camera and SnapRect on scene, geometry may have really - // changed - pScene->CorrectSceneDimensions(); + E3DModifySceneSnapRectUpdater aUpdater(pScene); + SetTransform(aTranslate * GetTransform()); } } @@ -482,55 +526,7 @@ void E3dObject::NbcMove(const Size& rSize) SdrObjList* E3dObject::GetSubList() const { - return pSub; -} - -/************************************************************************* -|* -|* Anzahl der Handles zurueckgeben -|* -\************************************************************************/ - -sal_uInt32 E3dObject::GetHdlCount() const -{ - // 8 Eckpunkte + 1 E3dVolumeMarker (= Wireframe-Darstellung) - return 9L; -} - -/************************************************************************* -|* -|* Handle-Liste fuellen -|* -\************************************************************************/ - -void E3dObject::AddToHdlList(SdrHdlList& rHdlList) const -{ - const basegfx::B2DPolyPolygon aPolyPoly(ImpCreateWireframePoly()); - const sal_uInt32 nPolyCount(aPolyPoly.count()); - - for(sal_uInt32 a(0L); a < nPolyCount; a += 3L) - { - const basegfx::B2DPolygon aPoly(aPolyPoly.getB2DPolygon(a)); - const basegfx::B2DPoint aPointA(aPoly.getB2DPoint(0L)); - const basegfx::B2DPoint aPointB(aPoly.getB2DPoint(1L)); - rHdlList.AddHdl(new SdrHdl(Point(FRound(aPointA.getX()), FRound(aPointA.getY())), HDL_BWGT)); - rHdlList.AddHdl(new SdrHdl(Point(FRound(aPointB.getX()), FRound(aPointB.getY())), HDL_BWGT)); - } - - if(nPolyCount) - { - E3dVolumeMarker* pVolMarker = new E3dVolumeMarker(aPolyPoly); - rHdlList.AddHdl(pVolMarker); - } -} - -/************************************************************************* -|* -\************************************************************************/ - -FASTBOOL E3dObject::HasSpecialDrag() const -{ - return TRUE; + return &(const_cast< E3dObjList& >(maSubList)); } /************************************************************************* @@ -542,14 +538,14 @@ FASTBOOL E3dObject::HasSpecialDrag() const void E3dObject::RecalcSnapRect() { maSnapRect = Rectangle(); - if(pSub && pSub->GetObjCount()) + + for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++) { - for (ULONG i = 0; i < pSub->GetObjCount(); i++) + E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a)); + + if(pCandidate) { - SdrObject* pObj = pSub->GetObj(i); - DBG_ASSERT(pObj->ISA(E3dObject), "AW: In E3dObject sind nur 3D-Objekte erlaubt!"); - Rectangle aSubRect = ((E3dObject*)pObj)->GetSnapRect(); - maSnapRect.Union(aSubRect); + maSnapRect.Union(pCandidate->GetSnapRect()); } } } @@ -576,16 +572,12 @@ void E3dObject::NewObjectInserted(const E3dObject* p3DObj) |* \************************************************************************/ -void E3dObject::StructureChanged(const E3dObject* p3DObj) +void E3dObject::StructureChanged() { if ( GetParentObj() ) { - // Wenn sich im Child das BoundVolume geaendert hat, muessen - // auch die der Parents angepasst werden - if ( !p3DObj->bBoundVolValid ) - GetParentObj()->bBoundVolValid = FALSE; - - GetParentObj()->StructureChanged(p3DObj); + GetParentObj()->InvalidateBoundVolume(); + GetParentObj()->StructureChanged(); } } @@ -599,11 +591,11 @@ void E3dObject::Insert3DObj(E3dObject* p3DObj) { DBG_ASSERT(p3DObj, "Insert3DObj mit NULL-Zeiger!"); SdrPage* pPg = pPage; - pSub->InsertObject(p3DObj); + maSubList.InsertObject(p3DObj); pPage = pPg; - bBoundVolValid = FALSE; + InvalidateBoundVolume(); NewObjectInserted(p3DObj); - StructureChanged(this); + StructureChanged(); } void E3dObject::Remove3DObj(E3dObject* p3DObj) @@ -613,11 +605,11 @@ void E3dObject::Remove3DObj(E3dObject* p3DObj) if(p3DObj->GetParentObj() == this) { SdrPage* pPg = pPage; - pSub->RemoveObject(p3DObj->GetOrdNum()); + maSubList.RemoveObject(p3DObj->GetOrdNum()); pPage = pPg; - bBoundVolValid = FALSE; - StructureChanged(this); + InvalidateBoundVolume(); + StructureChanged(); } } @@ -657,53 +649,47 @@ E3dScene* E3dObject::GetScene() const |* \************************************************************************/ -void E3dObject::RecalcBoundVolume() +basegfx::B3DRange E3dObject::RecalcBoundVolume() const { - E3dObjList* pOL = pSub; - ULONG nObjCnt = pOL->GetObjCount(); + basegfx::B3DRange aRetval; + const sal_uInt32 nObjCnt(maSubList.GetObjCount()); if(nObjCnt) { - aBoundVol = Volume3D(); - - for (ULONG i = 0; i < nObjCnt; i++) + for(sal_uInt32 a(0); a < nObjCnt; a++) { - SdrObject* pObj = pOL->GetObj(i); - - DBG_ASSERT(pObj->ISA(E3dObject), "In E3dObject sind nur 3D-Objekte erlaubt!"); - // Bei den Kindobjekten auch die lokalen Transformationen - // beruecksichtigen - E3dObject* p3DObj = (E3dObject*) pObj; - const Volume3D& rVol = p3DObj->GetBoundVolume(); - const basegfx::B3DHomMatrix& rTf = p3DObj->GetTransform(); - aBoundVol.expand(rVol.GetTransformVolume(rTf)); - } + const E3dObject* p3DObject = dynamic_cast< const E3dObject* >(maSubList.GetObj(a)); - aLocalBoundVol = aBoundVol; + if(p3DObject) + { + basegfx::B3DRange aLocalRange(p3DObject->GetBoundVolume()); + aLocalRange.transform(p3DObject->GetTransform()); + aRetval.expand(aLocalRange); + } + } } else { - // use local value - aBoundVol = aLocalBoundVol; + // single 3D object + const sdr::contact::ViewContactOfE3d* pVCOfE3D = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&GetViewContact()); - // detect if lines are displayed - const SfxItemSet& rSet = GetMergedItemSet(); - XLineStyle aLineStyle = ((const XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue(); - - if(aLineStyle != XLINE_NONE) + if(pVCOfE3D) { - // expand BoundVolume with 1/2 line width - sal_Int32 nLineWidth = ((const XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue(); + // BoundVolume is without 3D object transformation, use correct sequence + const drawinglayer::primitive3d::Primitive3DSequence xLocalSequence(pVCOfE3D->getVIP3DSWithoutObjectTransform()); - if(nLineWidth) + if(xLocalSequence.hasElements()) { - double fExpand(nLineWidth / 2.0); - aBoundVol.grow(fExpand); + const uno::Sequence< beans::PropertyValue > aEmptyParameters; + const drawinglayer::geometry::ViewInformation3D aLocalViewInformation3D(aEmptyParameters); + + aRetval = drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence( + xLocalSequence, aLocalViewInformation3D); } } } - bBoundVolValid = TRUE; + return aRetval; } /************************************************************************* @@ -712,25 +698,19 @@ void E3dObject::RecalcBoundVolume() |* \************************************************************************/ -const Volume3D& E3dObject::GetBoundVolume() const +const basegfx::B3DRange& E3dObject::GetBoundVolume() const { - if ( !bBoundVolValid ) + if(maLocalBoundVol.isEmpty()) { - ((E3dObject*)this)->RecalcBoundVolume(); + const_cast< E3dObject* >(this)->maLocalBoundVol = RecalcBoundVolume(); } - return aBoundVol; + return maLocalBoundVol; } -/************************************************************************* -|* -|* Mittelpunkt liefern -|* -\************************************************************************/ - -basegfx::B3DPoint E3dObject::GetCenter() +void E3dObject::InvalidateBoundVolume() { - return GetBoundVolume().getCenter(); + maLocalBoundVol.reset(); } /************************************************************************* @@ -741,17 +721,16 @@ basegfx::B3DPoint E3dObject::GetCenter() void E3dObject::SetBoundVolInvalid() { - bBoundVolValid = FALSE; - - E3dObjList* pOL = pSub; - ULONG nObjCnt = pOL->GetObjCount(); + InvalidateBoundVolume(); - for (ULONG i = 0; i < nObjCnt; i++) + for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++) { - SdrObject* pObj = pOL->GetObj(i); - DBG_ASSERT(pObj->ISA(E3dObject), "In E3dObject sind nur 3D-Objekte erlaubt!"); + E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a)); - ((E3dObject*) pObj)->SetBoundVolInvalid(); + if(pCandidate) + { + pCandidate->SetBoundVolInvalid(); + } } } @@ -763,40 +742,43 @@ void E3dObject::SetBoundVolInvalid() void E3dObject::SetTransformChanged() { - bTfHasChanged = TRUE; - bBoundVolValid = FALSE; - - E3dObjList* pOL = pSub; - ULONG nObjCnt = pOL->GetObjCount(); + InvalidateBoundVolume(); + mbTfHasChanged = true; - for (ULONG i = 0; i < nObjCnt; i++) + for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++) { - SdrObject* pObj = pOL->GetObj(i); - DBG_ASSERT(pObj->ISA(E3dObject), "In E3dObject sind nur 3D-Objekte erlaubt!"); + E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a)); - ((E3dObject*) pObj)->SetTransformChanged(); + if(pCandidate) + { + pCandidate->SetTransformChanged(); + } } } /************************************************************************* |* |* hierarchische Transformation ueber alle Parents bestimmen, in -|* aFullTfMatrix ablegen und diese zurueckgeben +|* maFullTransform ablegen und diese zurueckgeben |* \************************************************************************/ const basegfx::B3DHomMatrix& E3dObject::GetFullTransform() const { - if(bTfHasChanged) + if(mbTfHasChanged) { - E3dObject* pThis = (E3dObject*)this; - pThis->aFullTfMatrix = aTfMatrix; + basegfx::B3DHomMatrix aNewFullTransformation(maTransformation); + if ( GetParentObj() ) - pThis->aFullTfMatrix *= GetParentObj()->GetFullTransform(); - pThis->bTfHasChanged = FALSE; + { + aNewFullTransformation = GetParentObj()->GetFullTransform() * aNewFullTransformation; + } + + const_cast< E3dObject* >(this)->maFullTransform = aNewFullTransformation; + const_cast< E3dObject* >(this)->mbTfHasChanged = false; } - return aFullTfMatrix; + return maFullTransform; } /************************************************************************* @@ -807,7 +789,7 @@ const basegfx::B3DHomMatrix& E3dObject::GetFullTransform() const const basegfx::B3DHomMatrix& E3dObject::GetTransform() const { - return aTfMatrix; + return maTransformation; } /************************************************************************* @@ -818,22 +800,12 @@ const basegfx::B3DHomMatrix& E3dObject::GetTransform() const void E3dObject::NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix) { - aTfMatrix = rMatrix; - SetTransformChanged(); - StructureChanged(this); -} - -/************************************************************************* -|* -|* Transformationsmatrix auf Einheitsmatrix zuruecksetzen -|* -\************************************************************************/ - -void E3dObject::NbcResetTransform() -{ - aTfMatrix.identity(); - SetTransformChanged(); - StructureChanged(this); + if(maTransformation != rMatrix) + { + maTransformation = rMatrix; + SetTransformChanged(); + StructureChanged(); + } } /************************************************************************* @@ -844,245 +816,27 @@ void E3dObject::NbcResetTransform() void E3dObject::SetTransform(const basegfx::B3DHomMatrix& rMatrix) { - // #110094#-14 SendRepaintBroadcast(); - NbcSetTransform(rMatrix); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************* -|* -|* Transformationsmatrix zuruecksetzen mit Repaint-Broadcast -|* -\************************************************************************/ - -void E3dObject::ResetTransform() -{ - // #110094#-14 SendRepaintBroadcast(); - NbcResetTransform(); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************* -|* -|* Translation -|* -\************************************************************************/ - -void E3dObject::NbcTranslate(const basegfx::B3DVector& rTrans) -{ - aTfMatrix.translate(rTrans.getX(), rTrans.getY(), rTrans.getZ()); - SetTransformChanged(); - StructureChanged(this); -} -/************************************************************************* -|* -|* Translation mit Repaint-Broadcast -|* -\************************************************************************/ - -void E3dObject::Translate(const basegfx::B3DVector& rTrans) -{ - // #110094#-14 SendRepaintBroadcast(); - NbcTranslate(rTrans); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************* -|* -|* Skalierungen -|* -\************************************************************************/ - -void E3dObject::NbcScaleX(double fSx) -{ - aTfMatrix.scale(fSx, 1.0, 1.0); - SetTransformChanged(); - StructureChanged(this); -} - -/************************************************************************/ - -void E3dObject::NbcScaleY(double fSy) -{ - aTfMatrix.scale(1.0, fSy, 1.0); - SetTransformChanged(); - StructureChanged(this); -} - -/************************************************************************/ - -void E3dObject::NbcScaleZ(double fSz) -{ - aTfMatrix.scale(1.0, 1.0, fSz); - SetTransformChanged(); - StructureChanged(this); -} - -/************************************************************************/ - -void E3dObject::NbcScale(double fSx, double fSy, double fSz) -{ - aTfMatrix.scale(fSx, fSy, fSz); - SetTransformChanged(); - StructureChanged(this); -} - -/************************************************************************* -|* -|* gleichmaessige Skalierung -|* -\************************************************************************/ - -void E3dObject::NbcScale(double fS) -{ - aTfMatrix.scale(fS, fS, fS); - SetTransformChanged(); - StructureChanged(this); -} - -/************************************************************************* -|* -|* Skalierungen mit mit Repaint-Broadcast -|* -\************************************************************************/ - -void E3dObject::ScaleX(double fSx) -{ - // #110094#-14 SendRepaintBroadcast(); - NbcScaleX(fSx); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************/ - -void E3dObject::ScaleY(double fSy) -{ - // #110094#-14 SendRepaintBroadcast(); - NbcScaleY(fSy); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************/ - -void E3dObject::ScaleZ(double fSz) -{ - // #110094#-14 SendRepaintBroadcast(); - NbcScaleZ(fSz); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************/ - -void E3dObject::Scale(double fSx, double fSy, double fSz) -{ - // #110094#-14 SendRepaintBroadcast(); - NbcScale(fSx, fSy, fSz); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************/ - -void E3dObject::Scale(double fS) -{ - // #110094#-14 SendRepaintBroadcast(); - NbcScale(fS); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************* -|* -|* Rotationen mit Winkel in Radiant -|* -\************************************************************************/ - -void E3dObject::NbcRotateX(double fAng) -{ - aTfMatrix.rotate(fAng, 0.0, 0.0); - SetTransformChanged(); - StructureChanged(this); -} - -/************************************************************************/ - -void E3dObject::NbcRotateY(double fAng) -{ - aTfMatrix.rotate(0.0, fAng, 0.0); - SetTransformChanged(); - StructureChanged(this); -} - -/************************************************************************/ - -void E3dObject::NbcRotateZ(double fAng) -{ - aTfMatrix.rotate(0.0, 0.0, fAng); - SetTransformChanged(); - StructureChanged(this); -} - -/************************************************************************* -|* -|* Rotationen mit Repaint-Broadcast -|* -\************************************************************************/ - -void E3dObject::RotateX(double fAng) -{ - // #110094#-14 SendRepaintBroadcast(); - NbcRotateX(fAng); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************/ - -void E3dObject::RotateY(double fAng) -{ - // #110094#-14 SendRepaintBroadcast(); - NbcRotateY(fAng); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); -} - -/************************************************************************/ - -void E3dObject::RotateZ(double fAng) -{ - // #110094#-14 SendRepaintBroadcast(); - NbcRotateZ(fAng); - SetChanged(); - BroadcastObjectChange(); - if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); + if(rMatrix != maTransformation) + { + // #110094#-14 SendRepaintBroadcast(); + NbcSetTransform(rMatrix); + SetChanged(); + BroadcastObjectChange(); + if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle()); + } } /************************************************************************* |* |* Linien fuer die Wireframe-Darstellung des Objekts dem uebergebenen -|* basegfx::B3DPolygon hinzufuegen. Als default wird das BoundVolume verwendet. +|* basegfx::B3DPolygon hinzufuegen |* \************************************************************************/ -void E3dObject::CreateWireframe(basegfx::B3DPolygon& rWirePoly, const basegfx::B3DHomMatrix* pTf) const +basegfx::B3DPolyPolygon E3dObject::CreateWireframe() const { - GetBoundVolume().CreateWireframe(rWirePoly, pTf); + const basegfx::B3DRange aBoundVolume(GetBoundVolume()); + return basegfx::tools::createCubePolyPolygonFromB3DRange(aBoundVolume); } /************************************************************************* @@ -1118,57 +872,6 @@ void E3dObject::TakeObjNamePlural(XubString& rName) const /************************************************************************* |* -|* Wireframe-PolyPolygon erzeugen -|* -\************************************************************************/ - -basegfx::B2DPolyPolygon E3dObject::ImpCreateWireframePoly() const -{ - basegfx::B2DPolyPolygon aRetval; - E3dScene* pScene = GetScene(); - - if(pScene) - { - basegfx::B3DPolygon aPoly3D; - CreateWireframe(aPoly3D, 0L); - const sal_uInt32 nPntCnt(aPoly3D.count()); - - if(nPntCnt) - { - const Volume3D aVolume(pScene->FitInSnapRect()); - pScene->GetCameraSet().SetDeviceVolume(aVolume, sal_False); - pScene->GetCameraSet().SetObjectTrans(GetFullTransform()); - - for(sal_uInt32 a(0L); a < nPntCnt;) - { - basegfx::B3DPoint aPointA(aPoly3D.getB3DPoint(a++)); - aPointA = pScene->GetCameraSet().ObjectToViewCoor(aPointA); - basegfx::B3DPoint aPointB(aPoly3D.getB3DPoint(a++)); - aPointB = pScene->GetCameraSet().ObjectToViewCoor(aPointB); - basegfx::B2DPolygon aTmpPoly; - aTmpPoly.append(basegfx::B2DPoint(aPointA.getX(), aPointA.getY())); - aTmpPoly.append(basegfx::B2DPoint(aPointB.getX(), aPointB.getY())); - aRetval.append(aTmpPoly); - } - } - } - - return aRetval; -} - -/************************************************************************* -|* -|* Drag-Polygon zurueckgeben -|* -\************************************************************************/ - -basegfx::B2DPolyPolygon E3dObject::TakeXorPoly(sal_Bool /*bDetail*/) const -{ - return ImpCreateWireframePoly(); -} - -/************************************************************************* -|* |* Zuweisungsoperator |* \************************************************************************/ @@ -1180,74 +883,19 @@ void E3dObject::operator=(const SdrObject& rObj) const E3dObject& r3DObj = (const E3dObject&) rObj; if (r3DObj.GetSubList()) { - // feststellen, ob alle SubObjekte selektiert oder - // deselektiert sind - BOOL bAllSelected = TRUE; - BOOL bNoneSelected = TRUE; - UINT32 nObjCnt = r3DObj.GetSubList()->GetObjCount(); - - ULONG i; - for (i = 0; i < nObjCnt; i++) - { - SdrObject* pObj = r3DObj.GetSubList()->GetObj(i); - if(pObj && pObj->ISA(E3dObject)) - { - E3dObject* p3DObj = (E3dObject*)pObj; - if(p3DObj->GetSelected()) - bNoneSelected = FALSE; - else - bAllSelected = FALSE; - } - } - - if(bAllSelected || bNoneSelected) - { - // Normales verhalten - pSub->CopyObjects(*r3DObj.GetSubList()); - } - else - { - // Spezielle SubListe aufstellen, kopieren - SdrObjList aOwnSubList(*r3DObj.GetSubList()); - - // Alle nicht selektierten Objekte rausschmeissen - for(i = 0;i < aOwnSubList.GetObjCount();i++) - { - SdrObject* pObj = aOwnSubList.GetObj(i); - if(pObj && pObj->ISA(E3dObject)) - { - E3dObject* p3DObj = (E3dObject*)pObj; - if(!p3DObj->GetSelected()) - { - aOwnSubList.NbcRemoveObject(pObj->GetOrdNum()); - i--; - SdrObject::Free( pObj ); - } - } - } - - // jetzt diese Liste kopieren - pSub->CopyObjects(aOwnSubList); - - // Hier noch ein FitSnapRect einleiten - if(ISA(E3dScene)) - ((E3dScene&)r3DObj).FitSnapRectToBoundVol(); - } + maSubList.CopyObjects(*r3DObj.GetSubList()); } // BoundVol kann uebernommen werden, da die Childs auch kopiert werden - bBoundVolValid = r3DObj.bBoundVolValid; - aBoundVol = r3DObj.aBoundVol; - aLocalBoundVol = r3DObj.aLocalBoundVol; - - aTfMatrix = r3DObj.aTfMatrix; + maLocalBoundVol = r3DObj.maLocalBoundVol; + maTransformation = r3DObj.maTransformation; // Da sich der Parent geaendert haben kann, Gesamttransformation beim // naechsten Mal auf jeden Fall neu bestimmen SetTransformChanged(); // Selektionsstatus kopieren - bIsSelected = r3DObj.bIsSelected; + mbIsSelected = r3DObj.mbIsSelected; } /************************************************************************* @@ -1273,8 +921,8 @@ void E3dObject::SaveGeoData(SdrObjGeoData& rGeo) const { SdrAttrObj::SaveGeoData (rGeo); - ((E3DObjGeoData &) rGeo).aLocalBoundVol = aLocalBoundVol; - ((E3DObjGeoData &) rGeo).aTfMatrix = aTfMatrix; + ((E3DObjGeoData &) rGeo).maLocalBoundVol = maLocalBoundVol; + ((E3DObjGeoData &) rGeo).maTransformation = maTransformation; } /************************************************************************* @@ -1285,11 +933,10 @@ void E3dObject::SaveGeoData(SdrObjGeoData& rGeo) const void E3dObject::RestGeoData(const SdrObjGeoData& rGeo) { - aLocalBoundVol = ((E3DObjGeoData &) rGeo).aLocalBoundVol; - NbcSetTransform (((E3DObjGeoData &) rGeo).aTfMatrix); - + maLocalBoundVol = ((E3DObjGeoData &) rGeo).maLocalBoundVol; + E3DModifySceneSnapRectUpdater aUpdater(this); + NbcSetTransform(((E3DObjGeoData &) rGeo).maTransformation); SdrAttrObj::RestGeoData (rGeo); - GetScene()->FitSnapRectToBoundVol(); } /************************************************************************* @@ -1304,14 +951,18 @@ void E3dObject::RestGeoData(const SdrObjGeoData& rGeo) void E3dObject::NbcRotate(const Point& rRef, long nWink, double sn, double cs) { - // Also derzeit sind die Klebepunkte relativ zum aOutRect der Szene definiert. Vor dem Drehen - // werden die Klebepunkte relativ zur Seite definiert. Sie nehmen an der Drehung der Szene noch nicht Teil - // dafuer gibt es den + // Also derzeit sind die Klebepunkte relativ zum aOutRect der Szene definiert. Vor dem Drehen + // werden die Klebepunkte relativ zur Seite definiert. Sie nehmen an der Drehung der Szene noch nicht Teil + // dafuer gibt es den SetGlueReallyAbsolute(TRUE); // SendRepaintBroadcast(); double fWinkelInRad = nWink/100 * F_PI180; - NbcRotateZ(fWinkelInRad); + + basegfx::B3DHomMatrix aRotateZ; + aRotateZ.rotate(0.0, 0.0, fWinkelInRad); + NbcSetTransform(aRotateZ * GetTransform()); + SetRectsDirty(); // Veranlasst eine Neuberechnung aller BoundRects NbcRotateGluePoints(rRef,nWink,sn,cs); // Rotiert die Klebepunkte (die haben noch Koordinaten relativ // zum Urpsung des Blattes @@ -1337,22 +988,25 @@ TYPEINIT1(E3dCompoundObject, E3dObject); |* \************************************************************************/ -E3dCompoundObject::E3dCompoundObject() : E3dObject() +E3dCompoundObject::E3dCompoundObject() +: E3dObject(), + aMaterialAmbientColor(), + bCreateNormals(false), + bCreateTexture(false) { // Defaults setzen E3dDefaultAttributes aDefault; SetDefaultAttributes(aDefault); - - bGeometryValid = FALSE; - bFullTfIsPositive = TRUE; } -E3dCompoundObject::E3dCompoundObject(E3dDefaultAttributes& rDefault) : E3dObject() +E3dCompoundObject::E3dCompoundObject(E3dDefaultAttributes& rDefault) +: E3dObject(), + aMaterialAmbientColor(), + bCreateNormals(false), + bCreateTexture(false) { // Defaults setzen SetDefaultAttributes(rDefault); - - bGeometryValid = FALSE; } void E3dCompoundObject::SetDefaultAttributes(E3dDefaultAttributes& rDefault) @@ -1360,10 +1014,8 @@ void E3dCompoundObject::SetDefaultAttributes(E3dDefaultAttributes& rDefault) // Defaults setzen aMaterialAmbientColor = rDefault.GetDefaultAmbientColor(); - aBackMaterial = rDefault.GetDefaultBackMaterial(); bCreateNormals = rDefault.GetDefaultCreateNormals(); bCreateTexture = rDefault.GetDefaultCreateTexture(); - bUseDifferentBackMaterial = rDefault.GetDefaultUseDifferentBackMaterial(); } /************************************************************************* @@ -1378,879 +1030,165 @@ E3dCompoundObject::~E3dCompoundObject () /************************************************************************* |* -|* Start der Geometrieerzeugung ankuendigen -|* -\************************************************************************/ - -void E3dCompoundObject::StartCreateGeometry() -{ - // Geometriestart mitteilen - aDisplayGeometry.StartDescription(); - - // Lokales Volumen reset - aLocalBoundVol = Volume3D(); - - // Geometrie ist ab jetzt gueltig, um ein rekursives weiteres - // Erzeugen zu verhindern - bGeometryValid = TRUE; -} - -/************************************************************************* -|* -|* Identifier zurueckgeben +|* Drag-Polygon zurueckgeben |* \************************************************************************/ -UINT16 E3dCompoundObject::GetObjIdentifier() const +basegfx::B2DPolyPolygon E3dCompoundObject::TakeXorPoly() const { - return E3D_COMPOUNDOBJ_ID; -} - -/************************************************************************* -|* -|* SnapRect berechnen -|* -\************************************************************************/ + basegfx::B2DPolyPolygon aRetval; + const uno::Sequence< beans::PropertyValue > aEmptyParameters; + drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters); + E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this); -void E3dCompoundObject::RecalcSnapRect() -{ - E3dScene* pScene = GetScene(); - if(pScene) + if(pRootScene) { - // Objekttransformation uebernehmen - const Volume3D& rBoundVol = GetBoundVolume(); - maSnapRect = Rectangle(); - - if(!rBoundVol.isEmpty()) - { - const basegfx::B3DHomMatrix& rTrans = GetFullTransform(); - Vol3DPointIterator aIter(rBoundVol, &rTrans); - basegfx::B3DPoint aTfVec; - while ( aIter.Next(aTfVec) ) - { - aTfVec = pScene->GetCameraSet().WorldToViewCoor(aTfVec); - Point aPoint((long)(aTfVec.getX() + 0.5), (long)(aTfVec.getY() + 0.5)); - maSnapRect.Union(Rectangle(aPoint, aPoint)); - } - } - bSnapRectDirty = FALSE; + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact()); + const basegfx::B3DPolyPolygon aCubePolyPolygon(CreateWireframe()); + aRetval = basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aCubePolyPolygon, + aViewInfo3D.getObjectToView() * GetTransform()); + aRetval.transform(rVCScene.getObjectTransformation()); } + + return aRetval; } /************************************************************************* |* -|* BoundVolume holen. Falls die Geometrie ungueltig ist, diese neu -|* erzeugen und das BoundVol neu berechnen +|* Anzahl der Handles zurueckgeben |* \************************************************************************/ -const Volume3D& E3dCompoundObject::GetBoundVolume() const +sal_uInt32 E3dCompoundObject::GetHdlCount() const { - // Geometrie aktuell? - if(!bGeometryValid) - { - // Neu erzeugen und eine Neubestimmung des BoundVol erzwingen - E3dCompoundObject* pThis = (E3dCompoundObject*)this; - pThis->ReCreateGeometry(); - pThis->bBoundVolValid = FALSE; - } - - // call parent - return E3dObject::GetBoundVolume(); + // 8 Eckpunkte + 1 E3dVolumeMarker (= Wireframe-Darstellung) + return 9L; } /************************************************************************* |* -|* Give out simple line geometry +|* Handle-Liste fuellen |* \************************************************************************/ -basegfx::B3DPolyPolygon E3dCompoundObject::Get3DLineGeometry() const +void E3dCompoundObject::AddToHdlList(SdrHdlList& rHdlList) const { - basegfx::B3DPolyPolygon aRetval; - const B3dEntityBucket& rEntityBucket = GetDisplayGeometry().GetEntityBucket(); - const GeometryIndexValueBucket& rIndexBucket = GetDisplayGeometry().GetIndexBucket(); - sal_uInt32 nPolyCounter(0L); - sal_uInt32 nEntityCounter(0L); + const uno::Sequence< beans::PropertyValue > aEmptyParameters; + drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters); + E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this); - while(nPolyCounter < rIndexBucket.Count()) + if(pRootScene) { - // next primitive - sal_uInt32 nUpperBound(rIndexBucket[nPolyCounter++].GetIndex()); - basegfx::B3DPoint aLastPoint; - sal_Bool bLastLineVisible(rEntityBucket[nUpperBound - 1].IsEdgeVisible()); - - if(bLastLineVisible) - { - aLastPoint = rEntityBucket[nUpperBound - 1].Point(); - } + const basegfx::B3DRange aBoundVolume(GetBoundVolume()); - while(nEntityCounter < nUpperBound) + if(!aBoundVolume.isEmpty()) { - basegfx::B3DPoint aNewPoint(rEntityBucket[nEntityCounter].Point()); + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact()); - if(bLastLineVisible) + for(sal_uInt32 a(0); a < 8; a++) { - if(aLastPoint != aNewPoint) + basegfx::B3DPoint aPos3D; + + switch(a) { - // fill polygon - basegfx::B3DPolygon aNewPoly; - aNewPoly.append(aLastPoint); - aNewPoly.append(aNewPoint); - - // create line geometry for polygon in eye coor to - // have it always orthogonal to camera plane - aRetval.append(aNewPoly); + case 0 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMinZ()); break; + case 1 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break; + case 2 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMinZ()); break; + case 3 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break; + case 4 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMinZ()); break; + case 5 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break; + case 6 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMinZ()); break; + case 7 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break; } - } - - bLastLineVisible = rEntityBucket[nEntityCounter++].IsEdgeVisible(); - aLastPoint = aNewPoint; - } - } - - return aRetval; -} -/************************************************************************* -|* -|* Geometrieerzeugung -|* -\************************************************************************/ - -void E3dCompoundObject::DestroyGeometry() -{ - // Alle Objekte in der Sub-Liste zerstoeren. Dies sind die - // zur Visualisierung des Objektes verwendeten Hilfsobjekte - pSub->Clear(); - delete pSub; - pSub = new E3dObjList(NULL, NULL); - pSub->SetOwnerObj(this); - pSub->SetListKind(SDROBJLIST_GROUPOBJ); + // to 3d view coor + aPos3D *= aViewInfo3D.getObjectToView() * GetTransform(); - // Neue Geometrie zerstoeren - aDisplayGeometry.Erase(); + // create 2d relative scene + basegfx::B2DPoint aPos2D(aPos3D.getX(), aPos3D.getY()); - // BoundVols resetten - aLocalBoundVol = Volume3D(); - bBoundVolValid = FALSE; - StructureChanged(this); + // to 2d world coor + aPos2D *= rVCScene.getObjectTransformation(); - // Geometrie ist ungueltig - bGeometryValid = FALSE; -} - -void E3dCompoundObject::CreateGeometry() -{ - // Geometrie ist gueltig, um rekursion zu verhindern - bGeometryValid = TRUE; - - // Eventuell entstandene Geometrie noch korrigieren - // und Default -Normalen oder -Texturkoordinaten erzeugen - if(bCreateNormals) - { - if(GetNormalsKind() > 1) - aDisplayGeometry.CreateDefaultNormalsSphere(); - if(GetNormalsInvert()) - aDisplayGeometry.InvertNormals(); + rHdlList.AddHdl(new SdrHdl(Point(basegfx::fround(aPos2D.getX()), basegfx::fround(aPos2D.getY())), HDL_BWGT)); + } + } } - if(bCreateTexture) + const basegfx::B2DPolyPolygon aPolyPolygon(TakeXorPoly()); + + if(aPolyPolygon.count()) { - aDisplayGeometry.CreateDefaultTexture( - ((GetTextureProjectionX() > 0) ? B3D_CREATE_DEFAULT_X : FALSE) - |((GetTextureProjectionY() > 0) ? B3D_CREATE_DEFAULT_Y : FALSE), - GetTextureProjectionX() > 1); + E3dVolumeMarker* pVolMarker = new E3dVolumeMarker(aPolyPolygon); + rHdlList.AddHdl(pVolMarker); } - - // Das Ende der Geometrieerzeugung anzeigen - aDisplayGeometry.EndDescription(); -} - -void E3dCompoundObject::ReCreateGeometry() -{ - // Geometrie zerstoeren - DestroyGeometry(); - - // ... und neu erzeugen - CreateGeometry(); } /************************************************************************* |* -|* Geometrieerzeugung -|* \************************************************************************/ -void E3dCompoundObject::AddGeometry( - const basegfx::B3DPolyPolygon& rPolyPolygon, - BOOL bHintIsComplex, BOOL bOutline) -{ - if(rPolyPolygon.count()) - { - // neue Geometrie erzeugen - for(sal_uInt32 a(0L); a < rPolyPolygon.count(); a++) - { - const basegfx::B3DPolygon aPoly3D(rPolyPolygon.getB3DPolygon(a)); - aDisplayGeometry.StartObject(bHintIsComplex, bOutline); - - for(sal_uInt32 b(0L); b < aPoly3D.count(); b++ ) - { - aDisplayGeometry.AddEdge(aPoly3D.getB3DPoint(b)); - } - } - aDisplayGeometry.EndObject(); - - // LocalBoundVolume pflegen - aLocalBoundVol.expand(basegfx::tools::getRange(rPolyPolygon)); - - // Eigenes BoundVol nicht mehr gueltig - SetBoundVolInvalid(); - SetRectsDirty(); - } -} - -void E3dCompoundObject::AddGeometry( - const basegfx::B3DPolyPolygon& rPolyPolygon, - const basegfx::B3DPolyPolygon& rPolyPolygonNormal, - BOOL bHintIsComplex, BOOL bOutline) -{ - if(rPolyPolygon.count()) - { - // neue Geometrie erzeugen - for(sal_uInt32 a(0L); a < rPolyPolygon.count(); a++ ) - { - const basegfx::B3DPolygon aPoly3D(rPolyPolygon.getB3DPolygon(a)); - const basegfx::B3DPolygon aNormal3D(rPolyPolygonNormal.getB3DPolygon(a)); - aDisplayGeometry.StartObject(bHintIsComplex, bOutline); - - for(sal_uInt32 b(0L); b < aPoly3D.count(); b++ ) - { - aDisplayGeometry.AddEdge(aPoly3D.getB3DPoint(b), aNormal3D.getB3DPoint(b)); - } - } - aDisplayGeometry.EndObject(); - - // LocalBoundVolume pflegen - aLocalBoundVol.expand(basegfx::tools::getRange(rPolyPolygon)); - - // Eigenes BoundVol nicht mehr gueltig - SetBoundVolInvalid(); - SetRectsDirty(); - } -} - -void E3dCompoundObject::AddGeometry( - const basegfx::B3DPolyPolygon& rPolyPolygon, - const basegfx::B3DPolyPolygon& rPolyPolygonNormal, - const basegfx::B2DPolyPolygon& rPolyPolygonTexture, - BOOL bHintIsComplex, BOOL bOutline) +FASTBOOL E3dCompoundObject::HasSpecialDrag() const { - if(rPolyPolygon.count()) - { - // neue Geometrie erzeugen - for(sal_uInt32 a(0L); a < rPolyPolygon.count(); a++ ) - { - const basegfx::B3DPolygon aPoly3D(rPolyPolygon.getB3DPolygon(a)); - const basegfx::B3DPolygon aNormal3D(rPolyPolygonNormal.getB3DPolygon(a)); - const basegfx::B2DPolygon aTexture2D(rPolyPolygonTexture.getB2DPolygon(a)); - aDisplayGeometry.StartObject(bHintIsComplex, bOutline); - - for(sal_uInt32 b(0L); b < aPoly3D.count(); b++ ) - { - aDisplayGeometry.AddEdge(aPoly3D.getB3DPoint(b), aNormal3D.getB3DPoint(b), aTexture2D.getB2DPoint(b)); - } - } - aDisplayGeometry.EndObject(); - - // LocalBoundVolume pflegen - aLocalBoundVol.expand(basegfx::tools::getRange(rPolyPolygon)); - - // Eigenes BoundVol nicht mehr gueltig - SetBoundVolInvalid(); - SetRectsDirty(); - } + return TRUE; } /************************************************************************* |* -|* Hilfsfunktionen zur Geometrieerzeugung +|* Identifier zurueckgeben |* \************************************************************************/ -basegfx::B3DPolyPolygon E3dCompoundObject::ImpGrowPoly( - const basegfx::B3DPolyPolygon& rPolyPolyGrow, - const basegfx::B3DPolyPolygon& rPolyPolyNormals, - double fFactor) -{ - basegfx::B3DPolyPolygon aRetval; - const sal_uInt32 nPolyCount(rPolyPolyGrow.count()); - const bool bClosed(rPolyPolyGrow.isClosed()); - - for(sal_uInt32 a(0L); a < nPolyCount; a++) - { - const basegfx::B3DPolygon aPolyGrow(rPolyPolyGrow.getB3DPolygon(a)); - const basegfx::B3DPolygon aPolyNormals(rPolyPolyNormals.getB3DPolygon(a)); - const sal_uInt32 nPointCount(aPolyGrow.count()); - basegfx::B3DPolygon aNewPolyGrow; - - for(sal_uInt32 b(0L); b < nPointCount; b++) - { - aNewPolyGrow.append(aPolyGrow.getB3DPoint(b) + (aPolyNormals.getB3DPoint(b) * fFactor)); - } - - aNewPolyGrow.setClosed(bClosed); - aRetval.append(aNewPolyGrow); - } - - return aRetval; -} - -basegfx::B2VectorOrientation E3dCompoundObject::ImpGetOrientationInPoint( - const basegfx::B3DPolygon& rPolygon, - sal_uInt32 nIndex) -{ - sal_uInt32 nPntCnt(rPolygon.count()); - basegfx::B2VectorOrientation eRetval(basegfx::ORIENTATION_NEUTRAL); - - if(nIndex < nPntCnt) - { - const basegfx::B3DPoint aMid(rPolygon.getB3DPoint(nIndex)); - const basegfx::B3DPoint aPre(rPolygon.getB3DPoint((nIndex == 0L) ? nPntCnt - 1L : nIndex - 1L)); - const basegfx::B3DPoint aPos(rPolygon.getB3DPoint((nIndex == nPntCnt - 1L) ? 0L : nIndex + 1L)); - const basegfx::B3DVector aVecA(aPre - aMid); - const basegfx::B3DVector aVecB(aPos - aMid); - const basegfx::B3DVector aNormal(aVecA.getPerpendicular(aVecB)); - - if(aNormal.getZ() > 0.0) - { - eRetval = basegfx::ORIENTATION_POSITIVE; - } - else if(aNormal.getZ() < 0.0) - { - eRetval = basegfx::ORIENTATION_NEGATIVE; - } - } - - return eRetval; -} - -basegfx::B3DPolyPolygon E3dCompoundObject::ImpCorrectGrownPoly( - const basegfx::B3DPolyPolygon& aToBeCorrected, - const basegfx::B3DPolyPolygon& aOriginal) -{ - const sal_uInt32 aOriginalCount(aOriginal.count()); - const sal_uInt32 aToBeCorrectedCount(aToBeCorrected.count()); - const bool bClosed(aToBeCorrected.isClosed()); - - if(aOriginalCount == aToBeCorrectedCount) - { - basegfx::B3DPolyPolygon aRetval; - - for(sal_uInt32 a(0L); a < aToBeCorrectedCount; a++) - { - const basegfx::B3DPolygon aCorr(aToBeCorrected.getB3DPolygon(a)); - const basegfx::B3DPolygon aOrig(aOriginal.getB3DPolygon(a)); - const sal_uInt32 aOrigCount(aOrig.count()); - const sal_uInt32 aCorrCount(aCorr.count()); - - if(aOrigCount == aCorrCount && aOrigCount > 2L) - { - sal_uInt32 nNumDiff(0L); - sal_uInt32 nDoneStart(0xffffffff); - - // Testen auf Anzahl Aenderungen - sal_uInt32 b; - - for(b = 0L; b < aOrigCount; b++) - { - const basegfx::B2VectorOrientation eOrig(ImpGetOrientationInPoint(aOrig, b)); - const basegfx::B2VectorOrientation eCorr(ImpGetOrientationInPoint(aCorr, b)); - - if(eOrig != eCorr) - { - nNumDiff++; - } - else - { - if(nDoneStart == 0xffffffff) - { - // eventuellen Startpunkt auf gleiche Orientierung legen - nDoneStart = b; - } - } - } - - if(nNumDiff == aOrigCount) - { - // Komplett umgedreht, alles auf einen Punkt - const basegfx::B3DRange aCorrRange = basegfx::tools::getRange(aCorr); - basegfx::B3DPolygon aNew; - - aNew.append(aCorrRange.getCenter(), aCorrCount); - aRetval.append(aNew); - } - else if(nNumDiff) - { - // es gibt welche, nDoneStart ist gesetzt. Erzeuge (und - // setze) nDoneEnd - sal_uInt32 nDoneEnd(nDoneStart); - sal_uInt32 nStartLoop(0L); - BOOL bInLoop(FALSE); - basegfx::B3DPolygon aNew(aCorr); - - // einen step mehr in der Schleife, um Loops abzuschliessen - BOOL bFirstStep(TRUE); - - while(nDoneEnd != nDoneStart || bFirstStep) - { - bFirstStep = FALSE; - - // nCandidate ist Kandidat fuer Test - const sal_uInt32 nCandidate((nDoneEnd == aOrigCount - 1L) ? 0L : nDoneEnd + 1L); - const basegfx::B2VectorOrientation eOrig(ImpGetOrientationInPoint(aOrig, nCandidate)); - const basegfx::B2VectorOrientation eCorr(ImpGetOrientationInPoint(aCorr, nCandidate)); - - if(eOrig == eCorr) - { - // Orientierung ist gleich - if(bInLoop) - { - // Punkte innerhalb bInLoop auf ihr Zentrum setzen - basegfx::B3DPoint aMiddle; - sal_uInt32 nCounter(0L); - sal_uInt32 nStart(nStartLoop); - - while(nStart != nCandidate) - { - aMiddle += aCorr.getB3DPoint(nStart); - nCounter++; - nStart = (nStart == aOrigCount - 1L) ? 0L : nStart + 1L; - } - - // Mittelwert bilden - aMiddle /= (double)nCounter; - - // Punkte umsetzen - nStart = nStartLoop; - while(nStart != nCandidate) - { - aNew.setB3DPoint(nStart, aMiddle); - nStart = (nStart == aOrigCount - 1L) ? 0L : nStart + 1L; - } - - // Loop beenden - bInLoop = FALSE; - } - } - else - { - // Orientierung unterschiedlich - if(!bInLoop) - { - // Start eines Loop mit geaenderter Orientierung - nStartLoop = nCandidate; - bInLoop = TRUE; - } - } - - // Weitergehen - nDoneEnd = nCandidate; - } - - aRetval.append(aNew); - } - else - { - // no change, append original - aRetval.append(aCorr); - } - } - else - { - // less than 2 -> no change, append original - aRetval.append(aCorr); - } - } - - aRetval.setClosed(bClosed); - return aRetval; - } - else - { - return aToBeCorrected; - } -} - -basegfx::B3DPolyPolygon E3dCompoundObject::ImpScalePoly( - const basegfx::B3DPolyPolygon& rPolyPolyScale, - double fFactor) -{ - basegfx::B3DPolyPolygon aRetval(rPolyPolyScale); - const basegfx::B3DRange aPolyPolyRange(basegfx::tools::getRange(rPolyPolyScale)); - const basegfx::B3DPoint aCenter(aPolyPolyRange.getCenter()); - basegfx::B3DHomMatrix aTransform; - - aTransform.translate(-aCenter.getX(), -aCenter.getY(), -aCenter.getZ()); - aTransform.scale(fFactor, fFactor, fFactor); - aTransform.translate(aCenter.getX(), aCenter.getY(), aCenter.getZ()); - aRetval.transform(aTransform); - - return aRetval; -} - -void E3dCompoundObject::ImpCreateFront( - const basegfx::B3DPolyPolygon& rPolyPoly3D, - const basegfx::B3DPolyPolygon& rFrontNormals, - BOOL bDoCreateNormals, - BOOL bDoCreateTexture) -{ - // Vorderseite - if(bDoCreateNormals) - { - if(bDoCreateTexture) - { - // create default texture polygon - const basegfx::B3DRange aRange(basegfx::tools::getRange(rPolyPoly3D)); - const double fScaleX(0.0 == aRange.getWidth() ? 1.0 : 1.0 / aRange.getWidth()); - const double fScaleY(0.0 == aRange.getHeight() ? 1.0 : 1.0 / aRange.getHeight()); - const double fScaleZ(0.0 == aRange.getDepth() ? 1.0 : 1.0 / aRange.getDepth()); - basegfx::B3DHomMatrix aTrans3DTo2D; - - aTrans3DTo2D.translate(-aRange.getMinX(), -aRange.getMinY(), -aRange.getMinZ()); - aTrans3DTo2D.scale(fScaleX, -fScaleY, fScaleZ); - aTrans3DTo2D.translate(0.0, 1.0, 0.0); - basegfx::B2DPolyPolygon aPolyTexture(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(rPolyPoly3D, aTrans3DTo2D)); - - AddGeometry(rPolyPoly3D, rFrontNormals, aPolyTexture, TRUE); - } - else - { - AddGeometry(rPolyPoly3D, rFrontNormals, TRUE); - } - } - else - { - AddGeometry(rPolyPoly3D, TRUE); - } -} - -void E3dCompoundObject::ImpCreateBack( - const basegfx::B3DPolyPolygon& rPolyPoly3D, - const basegfx::B3DPolyPolygon& rBackNormals, - BOOL bDoCreateNormals, - BOOL bDoCreateTexture) -{ - // flip polys - basegfx::B3DPolyPolygon aPolyPoly3D(rPolyPoly3D); - basegfx::B3DPolyPolygon aBackNormals(rBackNormals); - aPolyPoly3D.flip(); - aBackNormals.flip(); - - // use ImpCreateFront with flipped polys - ImpCreateFront(aPolyPoly3D, aBackNormals, bDoCreateNormals, bDoCreateTexture); -} - -basegfx::B3DPolyPolygon E3dCompoundObject::ImpCreateByPattern(const basegfx::B3DPolyPolygon& rPattern) -{ - basegfx::B3DPolyPolygon aRetval; - const sal_uInt32 nPolyCount(rPattern.count()); - const bool bClosed(rPattern.isClosed()); - - for(sal_uInt32 a(0L); a < nPolyCount; a++) - { - basegfx::B3DPolygon aNew; - aNew.append(basegfx::B3DPoint(), rPattern.getB3DPolygon(a).count()); - aNew.setClosed(bClosed); - aRetval.append(aNew); - } - - return aRetval; -} - -basegfx::B3DPolyPolygon E3dCompoundObject::ImpAddFrontNormals( - const basegfx::B3DPolyPolygon& rNormalsFront, - const basegfx::B3DPoint& rOffset) +UINT16 E3dCompoundObject::GetObjIdentifier() const { - basegfx::B3DPoint aBackOffset(-rOffset); - return ImpAddBackNormals(rNormalsFront, aBackOffset); + return E3D_COMPOUNDOBJ_ID; } -basegfx::B3DPolyPolygon E3dCompoundObject::ImpAddBackNormals( - const basegfx::B3DPolyPolygon& rNormalsBack, - const basegfx::B3DPoint& rOffset) -{ - basegfx::B3DPolyPolygon aRetval; - basegfx::B3DVector aOffset(rOffset); - aOffset.normalize(); - basegfx::B3DPoint aValue(aOffset); - const sal_uInt32 nPolyCount(rNormalsBack.count()); - const bool bClosed(rNormalsBack.isClosed()); - - for(sal_uInt32 a(0L); a < nPolyCount; a++) - { - const basegfx::B3DPolygon aPoly(rNormalsBack.getB3DPolygon(a)); - const sal_uInt32 nPointCount(aPoly.count()); - basegfx::B3DPolygon aNew; - - for(sal_uInt32 b(0L); b < nPointCount; b++) - { - aNew.append(aPoly.getB3DPoint(b) + aValue); - } - - aNew.setClosed(bClosed); - aRetval.append(aNew); - } - - return aRetval; -} +/************************************************************************* +|* +|* SnapRect berechnen +|* +\************************************************************************/ -basegfx::B3DPolyPolygon E3dCompoundObject::ImpAddInBetweenNormals( - const basegfx::B3DPolyPolygon& rPolyPolyFront, - const basegfx::B3DPolyPolygon& rPolyPolyBack, - const basegfx::B3DPolyPolygon& rPolyPolyNormals, - BOOL bSmoothed) +void E3dCompoundObject::RecalcSnapRect() { - basegfx::B3DPolyPolygon aRetval; - const sal_uInt32 nPolyCnt(rPolyPolyFront.count()); - const bool bClosed(rPolyPolyFront.isClosed()); - - // Verbindungsstuecke - for(sal_uInt32 a(0L); a < nPolyCnt; a++) - { - const basegfx::B3DPolygon aPoly3DFront(rPolyPolyFront.getB3DPolygon(a)); - const basegfx::B3DPolygon aPoly3DBack(rPolyPolyBack.getB3DPolygon(a)); - const basegfx::B3DPolygon aNormalPoly(rPolyPolyNormals.getB3DPolygon(a)); - const sal_uInt32 nPntCnt(aPoly3DFront.count()); - - if(aPoly3DBack.isClosed()) - { - const basegfx::B3DVector aVecA(aPoly3DBack.getB3DPoint(nPntCnt - 1L) - aPoly3DFront.getB3DPoint(nPntCnt - 1L)); - const basegfx::B3DVector aVecB(aPoly3DFront.getB3DPoint(0L) - aPoly3DFront.getB3DPoint(nPntCnt - 1L)); - basegfx::B3DVector aNormal(aVecA.getPerpendicular(aVecB)); - aNormal.normalize(); - basegfx::B3DPolygon aNewPoly; - - for(sal_uInt32 i(0L); i < nPntCnt; i++) - { - const basegfx::B3DVector aVecC(aPoly3DBack.getB3DPoint(i) - aPoly3DFront.getB3DPoint(i)); - const basegfx::B3DVector aVecD(aPoly3DFront.getB3DPoint((i + 1L == nPntCnt) ? 0L : i + 1L) - aPoly3DFront.getB3DPoint(i)); - basegfx::B3DVector aNextNormal(aVecC.getPerpendicular(aVecD)); - aNextNormal.normalize(); - basegfx::B3DVector aNew; - - if(bSmoothed) - { - basegfx::B3DVector aMidNormal(aNormal + aNextNormal); - aMidNormal.normalize(); - aNew = aNormalPoly.getB3DPoint(i) + aMidNormal; - } - else - { - aNew = aNormalPoly.getB3DPoint(i) + aNormal; - } - - aNew.normalize(); - aNewPoly.append(aNew); - aNormal = aNextNormal; - } - - aNewPoly.setClosed(bClosed); - aRetval.append(aNewPoly); - } - else - { - basegfx::B3DVector aNormal; - - if(aPoly3DBack.getB3DPoint(0L) == aPoly3DFront.getB3DPoint(0L)) - { - const basegfx::B3DVector aVecA(aPoly3DBack.getB3DPoint(1L) - aPoly3DFront.getB3DPoint(1L)); - const basegfx::B3DVector aVecB(aPoly3DFront.getB3DPoint(1L) - aPoly3DFront.getB3DPoint(0L)); - aNormal = aVecA.getPerpendicular(aVecB); - } - else - { - const basegfx::B3DVector aVecA(aPoly3DBack.getB3DPoint(0L) - aPoly3DFront.getB3DPoint(0L)); - const basegfx::B3DVector aVecB(aPoly3DFront.getB3DPoint(1L) - aPoly3DFront.getB3DPoint(0L)); - aNormal = aVecA.getPerpendicular(aVecB); - } - - aNormal.normalize(); - basegfx::B3DVector aNew(aNormalPoly.getB3DPoint(0L) + aNormal); - aNew.normalize(); - basegfx::B3DPolygon aNewPoly; - aNewPoly.append(aNew); - - for(sal_uInt32 i(1L); i < nPntCnt; i++) - { - basegfx::B3DVector aNextNormal; - - if(i + 1L == nPntCnt) - { - aNextNormal = aNormal; - } - else - { - const basegfx::B3DVector aVecA(aPoly3DBack.getB3DPoint(i) - aPoly3DFront.getB3DPoint(i)); - const basegfx::B3DVector aVecB(aPoly3DFront.getB3DPoint(i + 1L) - aPoly3DFront.getB3DPoint(i)); - aNextNormal = aVecA.getPerpendicular(aVecB); - } - - aNextNormal.normalize(); - - if(bSmoothed) - { - basegfx::B3DVector aMidNormal(aNormal + aNextNormal); - aMidNormal.normalize(); - aNew = aNormalPoly.getB3DPoint(i) + aMidNormal; - } - else - { - aNew = aNormalPoly.getB3DPoint(i) + aNormal; - } - - aNew.normalize(); - aNewPoly.append(aNew); - aNormal = aNextNormal; - } - - aNewPoly.setClosed(bClosed); - aRetval.append(aNewPoly); - } - } - - return aRetval; -} + const uno::Sequence< beans::PropertyValue > aEmptyParameters; + drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters); + E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this); + maSnapRect = Rectangle(); -void E3dCompoundObject::ImpCreateInBetween( - const basegfx::B3DPolyPolygon& rPolyPolyFront, - const basegfx::B3DPolyPolygon& rPolyPolyBack, - const basegfx::B3DPolyPolygon& rFrontNormals, - const basegfx::B3DPolyPolygon& rBackNormals, - BOOL bDoCreateNormals, - double fSurroundFactor, - double fTextureStart, - double fTextureDepth, - BOOL bRotateTexture90) -{ - const sal_uInt32 nPolyCnt(rPolyPolyFront.count()); - bool bDoCreateTexture(0.0 != fTextureDepth); - double fPolyLength(0.0), fPolyPos(0.0); - sal_uInt32 nLastIndex(0L); - - // Verbindungsstuecke - if(bDoCreateNormals) + if(pRootScene) { - for(sal_uInt32 a(0L); a < nPolyCnt; a++) - { - const basegfx::B3DPolygon aPoly3DFront(rPolyPolyFront.getB3DPolygon(a)); - const basegfx::B3DPolygon aPoly3DBack(rPolyPolyBack.getB3DPolygon(a)); - const basegfx::B3DPolygon aPolyNormalsFront(rFrontNormals.getB3DPolygon(a)); - const basegfx::B3DPolygon aPolyNormalsBack(rBackNormals.getB3DPolygon(a)); - const sal_uInt32 nPntCnt(aPoly3DFront.count()); - const sal_uInt32 nPrefillIndex(aPoly3DFront.isClosed() ? nPntCnt - 1L : 0L); - basegfx::B3DPolygon aRect3D; - basegfx::B3DPolygon aNormal3D; - basegfx::B2DPolygon aTexture2D; - - aRect3D.append(basegfx::B3DPoint(), 4L); - aNormal3D.append(basegfx::B3DPoint(), 4L); - aTexture2D.append(basegfx::B2DPoint(), 4L); - aRect3D.setB3DPoint(3L, aPoly3DFront.getB3DPoint(nPrefillIndex)); - aRect3D.setB3DPoint(2L, aPoly3DBack.getB3DPoint(nPrefillIndex)); - aNormal3D.setB3DPoint(3L, aPolyNormalsFront.getB3DPoint(nPrefillIndex)); - aNormal3D.setB3DPoint(2L, aPolyNormalsBack.getB3DPoint(nPrefillIndex)); - - if(bDoCreateTexture) - { - fPolyLength = basegfx::tools::getLength(aPoly3DFront); - fPolyPos = 0.0; - nLastIndex = aPoly3DFront.isClosed() ? nPntCnt - 1L : 0L; + // get VC of 3D candidate + const sdr::contact::ViewContactOfE3d* pVCOfE3D = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&GetViewContact()); - if(bRotateTexture90) - { - // X,Y vertauschen - aTexture2D.setB2DPoint(3L, basegfx::B2DPoint(fTextureStart, (1.0 - fPolyPos) * fSurroundFactor)); - aTexture2D.setB2DPoint(2L, basegfx::B2DPoint(fTextureStart + fTextureDepth, (1.0 - fPolyPos) * fSurroundFactor)); - } - else - { - aTexture2D.setB2DPoint(3L, basegfx::B2DPoint(fPolyPos * fSurroundFactor, fTextureStart)); - aTexture2D.setB2DPoint(2L, basegfx::B2DPoint(fPolyPos * fSurroundFactor, fTextureStart + fTextureDepth)); - } - } - - for(sal_uInt32 i(aPoly3DFront.isClosed() ? 0L : 1L); i < nPntCnt; i++) - { - aRect3D.setB3DPoint(0L, aRect3D.getB3DPoint(3L)); - aRect3D.setB3DPoint(1L, aRect3D.getB3DPoint(2L)); - - aRect3D.setB3DPoint(3L, aPoly3DFront.getB3DPoint(i)); - aRect3D.setB3DPoint(2L, aPoly3DBack.getB3DPoint(i)); - - aNormal3D.setB3DPoint(0L, aNormal3D.getB3DPoint(3L)); - aNormal3D.setB3DPoint(1L, aNormal3D.getB3DPoint(2L)); - - aNormal3D.setB3DPoint(3L, aPolyNormalsFront.getB3DPoint(i)); - aNormal3D.setB3DPoint(2L, aPolyNormalsBack.getB3DPoint(i)); - - if(bDoCreateTexture) - { - // Texturkoordinaten ermitteln - basegfx::B3DVector aPart(aPoly3DFront.getB3DPoint(i) - aPoly3DFront.getB3DPoint(nLastIndex)); - fPolyPos += aPart.getLength() / fPolyLength; - nLastIndex = i; - - // Der Abschnitt am Polygon entspricht dem Teil - // von fPolyPos bis fPolyPos+fPartLength - - aTexture2D.setB2DPoint(0L, aTexture2D.getB2DPoint(3L)); - aTexture2D.setB2DPoint(1L, aTexture2D.getB2DPoint(2L)); - - if(bRotateTexture90) - { - // X,Y vertauschen - aTexture2D.setB2DPoint(3L, basegfx::B2DPoint(fTextureStart, (1.0 - fPolyPos) * fSurroundFactor)); - aTexture2D.setB2DPoint(2L, basegfx::B2DPoint(fTextureStart + fTextureDepth, (1.0 - fPolyPos) * fSurroundFactor)); - } - else - { - aTexture2D.setB2DPoint(3L, basegfx::B2DPoint(fPolyPos * fSurroundFactor, fTextureStart)); - aTexture2D.setB2DPoint(2L, basegfx::B2DPoint(fPolyPos * fSurroundFactor, fTextureStart + fTextureDepth)); - } - - AddGeometry(basegfx::B3DPolyPolygon(aRect3D), basegfx::B3DPolyPolygon(aNormal3D), basegfx::B2DPolyPolygon(aTexture2D), FALSE); - } - else - { - AddGeometry(basegfx::B3DPolyPolygon(aRect3D), basegfx::B3DPolyPolygon(aNormal3D), FALSE); - } - } - } - } - else - { - for(sal_uInt32 a(0L); a < nPolyCnt; a++) + if(pVCOfE3D) { - const basegfx::B3DPolygon aPoly3DFront(rPolyPolyFront.getB3DPolygon(a)); - const basegfx::B3DPolygon aPoly3DBack(rPolyPolyBack.getB3DPolygon(a)); - basegfx::B3DPolygon aRect3D; - const sal_uInt32 nPntCnt(aPoly3DFront.count()); - const sal_uInt32 nPrefillIndex(aPoly3DFront.isClosed() ? nPntCnt - 1L : 0L); + // get 3D primitive sequence + const drawinglayer::primitive3d::Primitive3DSequence xLocalSequence(pVCOfE3D->getViewIndependentPrimitive3DSequence()); - aRect3D.append(basegfx::B3DPoint(), 4L); - aRect3D.setB3DPoint(3L, aPoly3DFront.getB3DPoint(nPrefillIndex)); - aRect3D.setB3DPoint(2L, aPoly3DBack.getB3DPoint(nPrefillIndex)); - - for(sal_uInt32 i(aPoly3DFront.isClosed() ? 0L : 1L); i < nPntCnt; i++) + if(xLocalSequence.hasElements()) { - aRect3D.setB3DPoint(0L, aRect3D.getB3DPoint(3L)); - aRect3D.setB3DPoint(1L, aRect3D.getB3DPoint(2L)); - - aRect3D.setB3DPoint(3L, aPoly3DFront.getB3DPoint(i)); - aRect3D.setB3DPoint(2L, aPoly3DBack.getB3DPoint(i)); - - AddGeometry(basegfx::B3DPolyPolygon(aRect3D), FALSE); + // get BoundVolume + basegfx::B3DRange aBoundVolume(drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence( + xLocalSequence, aViewInfo3D)); + + // transform bound volume to relative scene coordinates + aBoundVolume.transform(aViewInfo3D.getObjectToView()); + + // build 2d relative scene range + basegfx::B2DRange aSnapRange( + aBoundVolume.getMinX(), aBoundVolume.getMinY(), + aBoundVolume.getMaxX(), aBoundVolume.getMaxY()); + + // transform to 2D world coordiantes + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact()); + aSnapRange.transform(rVCScene.getObjectTransformation()); + + // snap to integer + maSnapRect = Rectangle( + sal_Int32(floor(aSnapRange.getMinX())), sal_Int32(floor(aSnapRange.getMinY())), + sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY()))); } } } @@ -2270,16 +1208,9 @@ void E3dCompoundObject::operator=(const SdrObject& rObj) // weitere Parameter kopieren const E3dCompoundObject& r3DObj = (const E3dCompoundObject&) rObj; - aDisplayGeometry = r3DObj.aDisplayGeometry; bCreateNormals = r3DObj.bCreateNormals; bCreateTexture = r3DObj.bCreateTexture; - bGeometryValid = r3DObj.bGeometryValid; - - // neu ab 383: aMaterialAmbientColor = r3DObj.aMaterialAmbientColor; - - aBackMaterial = r3DObj.aBackMaterial; - bUseDifferentBackMaterial = r3DObj.bUseDifferentBackMaterial; } /************************************************************************* @@ -2288,572 +1219,14 @@ void E3dCompoundObject::operator=(const SdrObject& rObj) |* \************************************************************************/ -// #110988# test if given hit candidate point is inside bound volume of object -sal_Bool E3dCompoundObject::ImpIsInsideBoundVolume(const basegfx::B3DPoint& rFront, const basegfx::B3DPoint& rBack, const Point& /*rPnt*/) const -{ - const Volume3D& rBoundVol = ((E3dCompoundObject*)this)->GetBoundVolume(); - - if(!rBoundVol.isEmpty()) - { - double fXMax = rFront.getX(); - double fXMin = rBack.getX(); - - if(fXMax < fXMin) - { - fXMax = rBack.getX(); - fXMin = rFront.getX(); - } - - if(rBoundVol.getMinX() <= fXMax && rBoundVol.getMaxX() >= fXMin) - { - double fYMax = rFront.getY(); - double fYMin = rBack.getY(); - - if(fYMax < fYMin) - { - fYMax = rBack.getY(); - fYMin = rFront.getY(); - } - - if(rBoundVol.getMinY() <= fYMax && rBoundVol.getMaxY() >= fYMin) - { - double fZMax = rFront.getZ(); - double fZMin = rBack.getZ(); - - if(fZMax < fZMin) - { - fZMax = rBack.getZ(); - fZMin = rFront.getZ(); - } - - if(rBoundVol.getMinZ() <= fZMax && rBoundVol.getMaxZ() >= fZMin) - { - return sal_True; - } - } - } - } - - return sal_False; -} - -SdrObject* E3dCompoundObject::CheckHit(const Point& rPnt, USHORT nTol, const SetOfByte* /*pVisiLayer*/) const -{ - E3dPolyScene* pScene = (E3dPolyScene*)GetScene(); - - if(pScene) - { - // get HitLine in ObjectKoordinates - // set ObjectTrans - basegfx::B3DHomMatrix mTransform = GetFullTransform(); - pScene->GetCameraSet().SetObjectTrans(mTransform); - - // create HitPoint Front und Back, transform to object coordinates - basegfx::B3DPoint aFront(rPnt.X(), rPnt.Y(), 0.0); - basegfx::B3DPoint aBack(rPnt.X(), rPnt.Y(), ZBUFFER_DEPTH_RANGE); - aFront = pScene->GetCameraSet().ViewToObjectCoor(aFront); - aBack = pScene->GetCameraSet().ViewToObjectCoor(aBack); - - if(ImpIsInsideBoundVolume(aFront, aBack, rPnt)) - { - // Geometrie herstellen - if(!bGeometryValid) - ((E3dCompoundObject*)this)->ReCreateGeometry(); - - // 3D Volumes schneiden sich, teste in der Geometrie - // auf Basis der Projektion weiter - if(((E3dCompoundObject*)this)->aDisplayGeometry.CheckHit(aFront, aBack, nTol)) - { - return ((E3dCompoundObject*)this); - } - } - } - - return 0L; -} - -/************************************************************************* -|* -|* Schattenattribute holen -|* -\************************************************************************/ - -Color E3dCompoundObject::GetShadowColor() const -{ - return ((SdrShadowColorItem&)(GetObjectItem(SDRATTR_SHADOWCOLOR))).GetColorValue(); -} - -BOOL E3dCompoundObject::DrawShadowAsOutline() const -{ - const SfxItemSet& rSet = GetObjectItemSet(); - XFillStyle eFillStyle = ((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue(); - XLineStyle eLineStyle = ((XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue(); - BOOL bFillAttrIsNone = eFillStyle == XFILL_NONE; - BOOL bLineAttrIsNone = eLineStyle == XLINE_NONE; - return (bFillAttrIsNone && !bLineAttrIsNone); -} - -INT32 E3dCompoundObject::GetShadowXDistance() const -{ - return (long)((SdrShadowXDistItem&)(GetObjectItem(SDRATTR_SHADOWXDIST))).GetValue(); -} - -INT32 E3dCompoundObject::GetShadowYDistance() const +SdrObject* E3dCompoundObject::CheckHit(const Point& rPnt, USHORT /*nTol*/, const SetOfByte* /*pVisiLayer*/) const { - return (long)((SdrShadowYDistItem&)(GetObjectItem(SDRATTR_SHADOWYDIST))).GetValue(); -} - -BOOL E3dCompoundObject::DoDrawShadow() -{ - const SfxItemSet& rSet = GetObjectItemSet(); - BOOL bRetval(FALSE); - BOOL bShadOn = ((SdrShadowItem&)(rSet.Get(SDRATTR_SHADOW))).GetValue(); - - if(bShadOn) + if(checkHitSingle3DObject(basegfx::B2DPoint(rPnt.X(), rPnt.Y()), *this)) { - bRetval = TRUE; - - if(((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue() == XFILL_NONE) - { - if(((XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue() == XLINE_NONE) - { - bRetval = FALSE; - } - } + return const_cast< E3dCompoundObject* >(this); } - return bRetval; -} - -/************************************************************************* -|* -|* Create vertical polygons for line polygon -|* -\************************************************************************/ - -// #i28528# -basegfx::B3DPolyPolygon E3dCompoundObject::ImpCompleteLinePolygon(const basegfx::B3DPolyPolygon& rLinePolyPoly, sal_uInt32 nPolysPerRun, sal_Bool bClosed) -{ - basegfx::B3DPolyPolygon aRetval; - const sal_uInt32 nLinePolyPolyCount(rLinePolyPoly.count()); - - if(nLinePolyPolyCount && nPolysPerRun) - { - // get number of layers - sal_uInt32 nLayers(nLinePolyPolyCount / nPolysPerRun); - - // add vertical Polygons if at least two horizontal ones exist - if(nLayers > 1L) - { - for(sal_uInt32 a(0L); a < nPolysPerRun; a++) - { - const sal_uInt32 nPntCnt(rLinePolyPoly.getB3DPolygon(a).count()); - - for(sal_uInt32 b(0L); b < nPntCnt; b++) - { - basegfx::B3DPolygon aNewVerPoly; - - for(sal_uInt32 c(0L); c < nLayers; c++) - { - aNewVerPoly.append(rLinePolyPoly.getB3DPolygon((c * nPolysPerRun) + a).getB3DPoint(b)); - } - - // evtl. set first point again to close polygon - aNewVerPoly.setClosed(bClosed); - - // insert - aRetval.append(aNewVerPoly); - } - } - } - } - - return aRetval; -} - -/************************************************************************* -|* -|* Ein Segment fuer Extrude oder Lathe erzeugen -|* -\************************************************************************/ - -void E3dCompoundObject::ImpCreateSegment( - const basegfx::B3DPolyPolygon& rFront, // vorderes Polygon - const basegfx::B3DPolyPolygon& rBack, // hinteres Polygon - const basegfx::B3DPolyPolygon* pPrev, // smooth uebergang zu Vorgaenger - const basegfx::B3DPolyPolygon* pNext, // smooth uebergang zu Nachfolger - BOOL bCreateFront, // vorderen Deckel erzeugen - BOOL bCreateBack, // hinteren Deckel erzeugen - double fPercentDiag, // Anteil des Deckels an der Tiefe - BOOL bSmoothLeft, // Glaetten der umlaufenden Normalen links - BOOL bSmoothRight, // Glaetten der umlaufenden Normalen rechts - BOOL bSmoothFrontBack, // Glaetten der Abschlussflaechen - double fSurroundFactor, // Wertebereich der Texturkoordinaten im Umlauf - double fTextureStart, // TexCoor ueber Extrude-Tiefe - double fTextureDepth, // TexCoor ueber Extrude-Tiefe - BOOL bDoCreateTexture, - BOOL bDoCreateNormals, - BOOL bCharacterExtrude, // FALSE=exakt, TRUE=ohne Ueberschneidungen - BOOL bRotateTexture90, // Textur der Seitenflaechen um 90 Grad kippen - // #i28528# - basegfx::B3DPolyPolygon* pLineGeometryFront, // For creation of line geometry front parts - basegfx::B3DPolyPolygon* pLineGeometryBack, // For creation of line geometry back parts - basegfx::B3DPolyPolygon* pLineGeometry // For creation of line geometry in-betweens - ) -{ - basegfx::B3DPolyPolygon aNormalsLeft(ImpCreateByPattern(rFront)); - basegfx::B3DPolyPolygon aNormalsRight(ImpCreateByPattern(rFront)); - aNormalsLeft = ImpAddInBetweenNormals(rFront, rBack, aNormalsLeft, bSmoothLeft); - aNormalsRight = ImpAddInBetweenNormals(rFront, rBack, aNormalsRight, bSmoothRight); - const basegfx::B3DRange aBackRange(basegfx::tools::getRange(rBack)); - const basegfx::B3DRange aFrontRange(basegfx::tools::getRange(rFront)); - basegfx::B3DPoint aOffset(aBackRange.getCenter() - aFrontRange.getCenter()); - - // #i28528# - sal_Bool bTakeCareOfLineGeometry(pLineGeometryFront != 0L || pLineGeometryBack != 0L || pLineGeometry != 0L); - - // Ausnahmen: Nicht geschlossen - if(!rFront.isClosed()) - { - bCreateFront = FALSE; - } - if(!rBack.isClosed()) - { - bCreateBack = FALSE; - } - - // Ausnahmen: Einfache Linie - if(rFront.getB3DPolygon(0L).count() < 3L || (!bCreateFront && !bCreateBack)) - { - fPercentDiag = 0.0; - } - - if(fPercentDiag == 0.0) - { - // Ohne Schraegen, Vorderseite - if(bCreateFront) - { - basegfx::B3DPolyPolygon aNormalsFront(ImpCreateByPattern(rFront)); - aNormalsFront = ImpAddFrontNormals(aNormalsFront, aOffset); - - if(!bSmoothFrontBack) - ImpCreateFront(rFront, aNormalsFront, bDoCreateNormals, bDoCreateTexture); - if(bSmoothLeft) - aNormalsLeft = ImpAddFrontNormals(aNormalsLeft, aOffset); - if(bSmoothFrontBack) - ImpCreateFront(rFront, aNormalsLeft, bDoCreateNormals, bDoCreateTexture); - } - else - { - if(pPrev) - aNormalsLeft = ImpAddInBetweenNormals(*pPrev, rFront, aNormalsLeft, bSmoothLeft); - } - - // Ohne Schraegen, Rueckseite - if(bCreateBack) - { - basegfx::B3DPolyPolygon aNormalsBack(ImpCreateByPattern(rBack)); - aNormalsBack = ImpAddBackNormals(aNormalsBack, aOffset); - - if(!bSmoothFrontBack) - ImpCreateBack(rBack, aNormalsBack, bDoCreateNormals, bDoCreateTexture); - if(bSmoothRight) - aNormalsRight = ImpAddBackNormals(aNormalsRight, aOffset); - if(bSmoothFrontBack) - ImpCreateBack(rBack, aNormalsRight, bDoCreateNormals, bDoCreateTexture); - } - else - { - if(pNext) - aNormalsRight = ImpAddInBetweenNormals(rBack, *pNext, aNormalsRight, bSmoothRight); - } - - // eigentliches Zwischenstueck - ImpCreateInBetween(rFront, rBack, - aNormalsLeft, aNormalsRight, - bDoCreateNormals, - fSurroundFactor, - fTextureStart, - fTextureDepth, - bRotateTexture90); - - // #78972# - if(bTakeCareOfLineGeometry) - { - if(bCreateFront) - { - if(pLineGeometryFront) pLineGeometryFront->append(rFront); - } - else - { - if(pLineGeometry) pLineGeometry->append(rFront); - } - - if(bCreateBack) - { - if(pLineGeometryBack) pLineGeometryBack->append(rBack); - } - } - } - else - { - // Mit Scraegen, Vorderseite - basegfx::B3DPolyPolygon aLocalFront = rFront; - basegfx::B3DPolyPolygon aLocalBack = rBack; - double fExtrudeDepth, fDiagLen(0.0); - double fTexMidStart = fTextureStart; - double fTexMidDepth = fTextureDepth; - - if(bCreateFront || bCreateBack) - { - fExtrudeDepth = basegfx::B3DVector(aOffset).getLength(); - fDiagLen = fPercentDiag * fExtrudeDepth; - } - - basegfx::B3DPolyPolygon aOuterFront; - basegfx::B3DPolyPolygon aOuterBack; - - if(bCreateFront) - { - basegfx::B3DPolyPolygon aNormalsOuterFront(ImpCreateByPattern(aLocalFront)); - aNormalsOuterFront = ImpAddFrontNormals(aNormalsOuterFront, aOffset); - - if(bCharacterExtrude) - { - // Polygon kopieren - aOuterFront = aLocalFront; - - // notwendige Normalen erzeugen - basegfx::B3DPolyPolygon aGrowDirection(ImpCreateByPattern(aLocalFront)); - aGrowDirection = ImpAddInBetweenNormals(aLocalFront, aLocalBack, aGrowDirection, bSmoothLeft); - - // Groesse inneres Polygon merken - Volume3D aOldSize(basegfx::tools::getRange(aLocalFront)); - - // Inneres Polygon vergroessern - aLocalFront = ImpGrowPoly(aLocalFront, aGrowDirection, fDiagLen); - - // Inneres Polygon nach innen verschieben - //GrowPoly(aLocalFront, aNormalsOuterFront, -fDiagLen); - - // Neue Groesse inneres Polygon feststellen - basegfx::B3DRange aNewSize(basegfx::tools::getRange(aLocalFront)); - - // Skalierung feststellen (nur X,Y) - basegfx::B3DPoint aScaleVec( - (aNewSize.getWidth() != 0.0) ? aOldSize.getWidth() / aNewSize.getWidth() : 1.0, - (aNewSize.getHeight() != 0.0) ? aOldSize.getHeight() / aNewSize.getHeight() : 1.0, - (aNewSize.getDepth() != 0.0) ? aOldSize.getDepth() / aNewSize.getDepth() : 1.0); - - // Transformation bilden - basegfx::B3DHomMatrix aTransMat; - aTransMat.scale(aScaleVec.getX(), aScaleVec.getY(), aScaleVec.getZ()); - - // aeusseres und inneres Polygon skalieren - aLocalFront.transform(aTransMat); - aOuterFront.transform(aTransMat); - - // Neue Groesse aktualisieren - aNewSize = basegfx::tools::getRange(aLocalFront); - - // Translation feststellen - basegfx::B3DPoint aTransVec(aOldSize.getCenter() - aNewSize.getCenter()); - // Transformation bilden - aTransMat.identity(); - aTransMat.translate(aTransVec.getX(), aTransVec.getY(), aTransVec.getZ()); - - // aeusseres und inneres Polygon skalieren - aLocalFront.transform(aTransMat); - aOuterFront.transform(aTransMat); - - // move aLocalFront again, scale and translate has moved it back - aLocalFront = ImpGrowPoly(aLocalFront, aNormalsOuterFront, -fDiagLen); - } - else - { - // Polygon kopieren - aOuterFront = aLocalFront; - - // notwendige Normalen erzeugen - basegfx::B3DPolyPolygon aGrowDirection(ImpCreateByPattern(aLocalFront)); - aGrowDirection = ImpAddInBetweenNormals(aLocalFront, aLocalBack, aGrowDirection, bSmoothLeft); - - // Aeusseres Polygon verkleinern - aOuterFront = ImpGrowPoly(aOuterFront, aGrowDirection, -fDiagLen); - aOuterFront = ImpCorrectGrownPoly(aOuterFront, aLocalFront); - - // Inneres Polygon nach innen verschieben - aLocalFront = ImpGrowPoly(aLocalFront, aNormalsOuterFront, -fDiagLen); - } - - // eventuell noch glaetten - if(bSmoothLeft) - { - if(bSmoothFrontBack) - aNormalsOuterFront = ImpAddInBetweenNormals(aOuterFront, aLocalFront, aNormalsOuterFront, bSmoothLeft); - aNormalsLeft = ImpAddInBetweenNormals(aOuterFront, aLocalFront, aNormalsLeft, bSmoothLeft); - } - - // vordere Zwischenstuecke erzeugen - ImpCreateInBetween(aOuterFront, aLocalFront, - aNormalsOuterFront, aNormalsLeft, - bDoCreateNormals, - fSurroundFactor, - fTextureStart, - fTextureDepth * fPercentDiag, - bRotateTexture90); - - // Vorderseite erzeugen - ImpCreateFront(aOuterFront, aNormalsOuterFront, bDoCreateNormals, bDoCreateTexture); - - // Weitere Texturwerte setzen - fTexMidStart += fTextureDepth * fPercentDiag; - fTexMidDepth -= fTextureDepth * fPercentDiag; - } - else - { - if(pPrev) - aNormalsLeft = ImpAddInBetweenNormals(*pPrev, rFront, aNormalsLeft, bSmoothLeft); - } - - // Mit Scraegen, Rueckseite - if(bCreateBack) - { - basegfx::B3DPolyPolygon aNormalsOuterBack(ImpCreateByPattern(aLocalBack)); - aNormalsOuterBack = ImpAddBackNormals(aNormalsOuterBack, aOffset); - - if(bCharacterExtrude) - { - // Polygon kopieren - aOuterBack = aLocalBack; - - // notwendige Normalen erzeugen - basegfx::B3DPolyPolygon aGrowDirection(ImpCreateByPattern(aLocalFront)); - aGrowDirection = ImpAddInBetweenNormals(aLocalFront, aLocalBack, aGrowDirection, bSmoothRight); - - // Groesse inneres Polygon merken - Volume3D aOldSize(basegfx::tools::getRange(aLocalBack)); - - // Inneres Polygon vergroessern - aLocalBack = ImpGrowPoly(aLocalBack, aGrowDirection, fDiagLen); - - // Inneres Polygon nach innen verschieben - //GrowPoly(aLocalBack, aNormalsOuterBack, -fDiagLen); - - // Neue Groesse inneres Polygon feststellen - basegfx::B3DRange aNewSize(basegfx::tools::getRange(aLocalBack)); - - // Skalierung feststellen (nur X,Y) - basegfx::B3DPoint aScaleVec( - (aNewSize.getWidth() != 0.0) ? aOldSize.getWidth() / aNewSize.getWidth() : 1.0, - (aNewSize.getHeight() != 0.0) ? aOldSize.getHeight() / aNewSize.getHeight() : 1.0, - (aNewSize.getDepth() != 0.0) ? aOldSize.getDepth() / aNewSize.getDepth() : 1.0); - - // Transformation bilden - basegfx::B3DHomMatrix aTransMat; - aTransMat.scale(aScaleVec.getX(), aScaleVec.getY(), aScaleVec.getZ()); - - // aeusseres und inneres Polygon skalieren - aLocalBack.transform(aTransMat); - aOuterBack.transform(aTransMat); - - // Neue Groesse aktualisieren - aNewSize = basegfx::tools::getRange(aLocalBack); - - // Translation feststellen - basegfx::B3DPoint aTransVec(aOldSize.getCenter() - aNewSize.getCenter()); - - // Transformation bilden - aTransMat.identity(); - aTransMat.translate(aTransVec.getX(), aTransVec.getY(), aTransVec.getZ()); - - // aeusseres und inneres Polygon skalieren - aLocalBack.transform(aTransMat); - aOuterBack.transform(aTransMat); - - // move aLocalBack again, scale and translate has moved it back - aLocalBack = ImpGrowPoly(aLocalBack, aNormalsOuterBack, -fDiagLen); - } - else - { - // Polygon kopieren - aOuterBack = aLocalBack; - - // notwendige Normalen erzeugen - basegfx::B3DPolyPolygon aGrowDirection(ImpCreateByPattern(aLocalFront)); - aGrowDirection = ImpAddInBetweenNormals(aLocalFront, aLocalBack, aGrowDirection, bSmoothRight); - - // Aeusseres Polygon verkleinern - aOuterBack = ImpGrowPoly(aOuterBack, aGrowDirection, -fDiagLen); - aOuterBack = ImpCorrectGrownPoly(aOuterBack, aLocalBack); - - // Inneres Polygon nach innen verschieben - aLocalBack = ImpGrowPoly(aLocalBack, aNormalsOuterBack, -fDiagLen); - } - - // eventuell noch glaetten - if(bSmoothRight) - { - if(bSmoothFrontBack) - aNormalsOuterBack = ImpAddInBetweenNormals(aLocalBack, aOuterBack, aNormalsOuterBack, bSmoothRight); - aNormalsRight = ImpAddInBetweenNormals(aLocalBack, aOuterBack, aNormalsRight, bSmoothRight); - } - - // vordere Zwischenstuecke erzeugen - // hintere Zwischenstuecke erzeugen - ImpCreateInBetween(aLocalBack, aOuterBack, - aNormalsRight, aNormalsOuterBack, - bDoCreateNormals, - fSurroundFactor, - fTextureStart + (fTextureDepth * (1.0 - fPercentDiag)), - fTextureDepth * fPercentDiag, - bRotateTexture90); - - // Rueckseite erzeugen - ImpCreateBack(aOuterBack, aNormalsOuterBack, bDoCreateNormals, bDoCreateTexture); - - // Weitere Texturwerte setzen - fTexMidDepth -= fTextureDepth * fPercentDiag; - } - else - { - if(pNext) - aNormalsRight = ImpAddInBetweenNormals(rBack, *pNext, aNormalsRight, bSmoothRight); - } - - // eigentliches Zwischenstueck - ImpCreateInBetween(aLocalFront, aLocalBack, - aNormalsLeft, aNormalsRight, - bDoCreateNormals, - fSurroundFactor, - fTexMidStart, - fTexMidDepth, - bRotateTexture90); - - // #78972# - if(bTakeCareOfLineGeometry) - { - if(bCreateFront) - { - if(pLineGeometryFront) pLineGeometryFront->append(aOuterFront); - } - - if(bCreateFront) - { - if(pLineGeometryFront) pLineGeometryFront->append(aLocalFront); - } - else - { - if(pLineGeometry) pLineGeometry->append(aLocalFront); - } - - if(bCreateBack && pLineGeometryBack) - { - pLineGeometryBack->append(aLocalBack); - pLineGeometryBack->append(aOuterBack); - } - } - } + return 0; } /************************************************************************* @@ -2867,7 +1240,7 @@ void E3dCompoundObject::SetCreateNormals(BOOL bNew) if(bCreateNormals != bNew) { bCreateNormals = bNew; - bGeometryValid = FALSE; + ActionChanged(); } } @@ -2876,29 +1249,12 @@ void E3dCompoundObject::SetCreateTexture(BOOL bNew) if(bCreateTexture != bNew) { bCreateTexture = bNew; - bGeometryValid = FALSE; + ActionChanged(); } } /************************************************************************* |* -|* DisplayGeometry rausruecken -|* -\************************************************************************/ - -const B3dGeometry& E3dCompoundObject::GetDisplayGeometry() const -{ - // Geometrie herstellen - if(!bGeometryValid) - { - ((E3dCompoundObject*)this)->ReCreateGeometry(); - } - - return aDisplayGeometry; -} - -/************************************************************************* -|* |* Material des Objektes |* \************************************************************************/ @@ -2911,22 +1267,6 @@ void E3dCompoundObject::SetMaterialAmbientColor(const Color& rColor) } } -void E3dCompoundObject::SetBackMaterial(const B3dMaterial& rNew) -{ - if(aBackMaterial != rNew) - { - aBackMaterial = rNew; - } -} - -void E3dCompoundObject::SetUseDifferentBackMaterial(BOOL bNew) -{ - if(bUseDifferentBackMaterial != bNew) - { - bUseDifferentBackMaterial = bNew; - } -} - /************************************************************************* |* |* convert given basegfx::B3DPolyPolygon to screen coor @@ -2935,65 +1275,22 @@ void E3dCompoundObject::SetUseDifferentBackMaterial(BOOL bNew) basegfx::B2DPolyPolygon E3dCompoundObject::TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate) { + const uno::Sequence< beans::PropertyValue > aEmptyParameters; + drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters); + E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this); basegfx::B2DPolyPolygon aRetval; - B3dTransformationSet& rTransSet = GetScene()->GetCameraSet(); - const basegfx::B3DHomMatrix mTransform(GetFullTransform() * rTransSet.GetMatFromWorldToView()); - for(sal_uInt32 a(0L); a < rCandidate.count(); a++) + if(pRootScene) { - const basegfx::B3DPolygon aCandidate(rCandidate.getB3DPolygon(a)); - const sal_uInt32 nCount(aCandidate.count()); - - if(nCount) - { - basegfx::B2DPolygon aTempPoly; - - for(sal_uInt32 b(0L); b < nCount; b++) - { - basegfx::B3DPoint aPoint(aCandidate.getB3DPoint(b)); - aPoint *= mTransform; - aTempPoly.append(basegfx::B2DPoint(aPoint.getX(), aPoint.getY())); - } - - aRetval.append(aTempPoly); - } + aRetval = basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(rCandidate, + aViewInfo3D.getObjectToView() * GetTransform()); + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact()); + aRetval.transform(rVCScene.getObjectTransformation()); } return aRetval; } -// #110988# -double E3dCompoundObject::GetMinimalDepthInViewCoor(E3dScene& rScene) const -{ - double fRetval(DBL_MAX); - B3dTransformationSet& rTransSet = rScene.GetCameraSet(); - basegfx::B3DHomMatrix mTransform = GetFullTransform(); - rTransSet.SetObjectTrans(mTransform); - const B3dEntityBucket& rEntityBucket = GetDisplayGeometry().GetEntityBucket(); - const GeometryIndexValueBucket& rIndexBucket = GetDisplayGeometry().GetIndexBucket(); - sal_uInt32 nPolyCounter(0L); - sal_uInt32 nEntityCounter(0L); - - while(nPolyCounter < rIndexBucket.Count()) - { - sal_uInt32 nUpperBound(rIndexBucket[nPolyCounter++].GetIndex()); - - while(nEntityCounter < nUpperBound) - { - basegfx::B3DPoint aNewPoint(rEntityBucket[nEntityCounter++].Point()); - aNewPoint = rTransSet.ObjectToViewCoor(aNewPoint); - - if(aNewPoint.getZ() < fRetval) - { - fRetval = aNewPoint.getZ(); - } - } - } - - return fRetval; -} - -// #110988# sal_Bool E3dCompoundObject::IsAOrdNumRemapCandidate(E3dScene*& prScene) const { if(GetObjList() @@ -3007,4 +1304,5 @@ sal_Bool E3dCompoundObject::IsAOrdNumRemapCandidate(E3dScene*& prScene) const return sal_False; } +////////////////////////////////////////////////////////////////////////////// // eof |