Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / svx / source / engine3d / scene3d.cxx
blob7a886fafc0362cc3c5c90048a833673c6106ae94
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <cstdlib>
24 #include <svx/strings.hrc>
25 #include <svx/dialmgr.hxx>
26 #include <svx/svditer.hxx>
28 #include <svx/svdobjkind.hxx>
29 #include <svx/svdpage.hxx>
30 #include <svx/scene3d.hxx>
31 #include <svx/svdtrans.hxx>
32 #include <sdr/properties/e3dsceneproperties.hxx>
33 #include <svx/sdr/contact/viewcontactofe3dscene.hxx>
34 #include <svx/svddrag.hxx>
35 #include "helperminimaldepth3d.hxx"
36 #include <algorithm>
37 #include <drawinglayer/geometry/viewinformation3d.hxx>
38 #include <basegfx/polygon/b2dpolypolygontools.hxx>
39 #include <svx/e3dsceneupdater.hxx>
40 #include <svx/svdmodel.hxx>
42 namespace {
44 class ImpRemap3DDepth
46 sal_uInt32 mnOrdNum;
47 double mfMinimalDepth;
49 // bit field
50 bool mbIsScene : 1;
52 public:
53 ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth);
54 explicit ImpRemap3DDepth(sal_uInt32 nOrdNum);
56 // for ::std::sort
57 bool operator<(const ImpRemap3DDepth& rComp) const;
59 sal_uInt32 GetOrdNum() const { return mnOrdNum; }
60 bool IsScene() const { return mbIsScene; }
65 ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth)
66 : mnOrdNum(nOrdNum),
67 mfMinimalDepth(fMinimalDepth),
68 mbIsScene(false)
72 ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum)
73 : mnOrdNum(nOrdNum),
74 mfMinimalDepth(0.0),
75 mbIsScene(true)
79 bool ImpRemap3DDepth::operator<(const ImpRemap3DDepth& rComp) const
81 if(IsScene())
83 return false;
85 else
87 if(rComp.IsScene())
89 return true;
91 else
93 return mfMinimalDepth < rComp.mfMinimalDepth;
98 class Imp3DDepthRemapper
100 std::vector< ImpRemap3DDepth > maVector;
102 public:
103 explicit Imp3DDepthRemapper(E3dScene const & rScene);
105 sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
108 Imp3DDepthRemapper::Imp3DDepthRemapper(E3dScene const & rScene)
110 // only called when rScene.GetSubList() and nObjCount > 1
111 SdrObjList* pList = rScene.GetSubList();
112 const size_t nObjCount(pList->GetObjCount());
114 for(size_t a = 0; a < nObjCount; ++a)
116 SdrObject* pCandidate = pList->GetObj(a);
118 if(pCandidate)
120 if(auto pCompoundObj = dynamic_cast< const E3dCompoundObject*>(pCandidate))
122 // single 3d object, calc depth
123 const double fMinimalDepth(getMinimalDepthInViewCoordinates(*pCompoundObj));
124 ImpRemap3DDepth aEntry(a, fMinimalDepth);
125 maVector.push_back(aEntry);
127 else
129 // scene, use standard entry for scene
130 ImpRemap3DDepth aEntry(a);
131 maVector.push_back(aEntry);
136 // now, we need to sort the maVector by its members minimal depth. The
137 // smaller, the nearer to the viewer.
138 ::std::sort(maVector.begin(), maVector.end());
141 sal_uInt32 Imp3DDepthRemapper::RemapOrdNum(sal_uInt32 nOrdNum) const
143 if(nOrdNum < maVector.size())
145 nOrdNum = maVector[(maVector.size() - 1) - nOrdNum].GetOrdNum();
148 return nOrdNum;
152 // BaseProperties section
154 std::unique_ptr<sdr::properties::BaseProperties> E3dScene::CreateObjectSpecificProperties()
156 return std::make_unique<sdr::properties::E3dSceneProperties>(*this);
160 // DrawContact section
162 std::unique_ptr<sdr::contact::ViewContact> E3dScene::CreateObjectSpecificViewContact()
164 return std::make_unique<sdr::contact::ViewContactOfE3dScene>(*this);
168 E3dScene::E3dScene(SdrModel& rSdrModel)
169 : E3dObject(rSdrModel),
170 aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
171 bDrawOnlySelected(false),
172 mbSkipSettingDirty(false)
174 // Set defaults
175 SetDefaultAttributes();
178 E3dScene::E3dScene(SdrModel& rSdrModel, E3dScene const & rSource)
179 : E3dObject(rSdrModel, rSource),
180 aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
181 bDrawOnlySelected(false),
182 mbSkipSettingDirty(false)
184 // Set defaults
185 SetDefaultAttributes();
187 // copy child SdrObjects
188 if (rSource.GetSubList())
190 CopyObjects(*rSource.GetSubList());
192 // tdf#116979: needed here, we need bSnapRectDirty to be true
193 // which it is after using SdrObject::operator= (see above),
194 // but set to false again using CopyObjects
195 SetBoundAndSnapRectsDirty();
198 // copy local data
199 aCamera = rSource.aCamera;
200 aCameraSet = rSource.aCameraSet;
201 static_cast<sdr::properties::E3dSceneProperties&>(GetProperties()).SetSceneItemsFromCamera();
202 InvalidateBoundVolume();
203 RebuildLists();
204 ImpCleanup3DDepthMapper();
205 GetViewContact().ActionChanged();
208 void E3dScene::SetDefaultAttributes()
210 // For WIN95/NT turn off the FP-Exceptions
211 #if defined(_WIN32)
212 _control87( _MCW_EM, _MCW_EM );
213 #endif
215 // Set defaults
216 aCamera.SetViewWindow(-2, -2, 4, 4);
217 aCameraSet.SetDeviceRectangle(-2, 2, -2, 2);
218 aCamera.SetDeviceWindow(tools::Rectangle(0, 0, 10, 10));
219 tools::Rectangle aRect(0, 0, 10, 10);
220 aCameraSet.SetViewportRectangle(aRect);
222 // set defaults for Camera from ItemPool
223 aCamera.SetProjection(GetPerspective());
224 basegfx::B3DPoint aActualPosition(aCamera.GetPosition());
225 double fNew = GetDistance();
227 if(fabs(fNew - aActualPosition.getZ()) > 1.0)
229 aCamera.SetPosition( basegfx::B3DPoint( aActualPosition.getX(), aActualPosition.getY(), fNew) );
232 fNew = GetFocalLength() / 100.0;
233 aCamera.SetFocalLength(fNew);
236 E3dScene::~E3dScene()
238 ImpCleanup3DDepthMapper();
241 SdrPage* E3dScene::getSdrPageFromSdrObjList() const
243 return getSdrPageFromSdrObject();
246 SdrObject* E3dScene::getSdrObjectFromSdrObjList() const
248 return const_cast< E3dScene* >(this);
251 SdrObjList* E3dScene::getChildrenOfSdrObject() const
253 return const_cast< E3dScene* >(this);
256 basegfx::B2DPolyPolygon E3dScene::TakeXorPoly() const
258 const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(GetViewContact());
259 const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D());
260 const basegfx::B3DPolyPolygon aCubePolyPolygon(CreateWireframe());
262 basegfx::B2DPolyPolygon aRetval(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aCubePolyPolygon,
263 aViewInfo3D.getObjectToView()));
264 aRetval.transform(rVCScene.getObjectTransformation());
266 return aRetval;
269 void E3dScene::ImpCleanup3DDepthMapper()
271 mp3DDepthRemapper.reset();
274 sal_uInt32 E3dScene::RemapOrdNum(sal_uInt32 nNewOrdNum) const
276 if(!mp3DDepthRemapper)
278 const size_t nObjCount(GetSubList() ? GetSubList()->GetObjCount() : 0);
280 if(nObjCount > 1)
282 mp3DDepthRemapper.reset(new Imp3DDepthRemapper(*this));
286 if(mp3DDepthRemapper)
288 return mp3DDepthRemapper->RemapOrdNum(nNewOrdNum);
291 return nNewOrdNum;
294 SdrObjKind E3dScene::GetObjIdentifier() const
296 return SdrObjKind::E3D_Scene;
299 void E3dScene::SetBoundRectDirty()
301 E3dScene* pScene(getRootE3dSceneFromE3dObject());
303 if(pScene == this)
305 // avoid resetting aOutRect which in case of a 3D scene used as 2d object
306 // is model data,not re-creatable view data
308 else
310 // if not the outmost scene it is used as group in 3d, call parent
311 E3dObject::SetBoundRectDirty();
315 void E3dScene::NbcSetSnapRect(const tools::Rectangle& rRect)
317 SetBoundAndSnapRectsDirty();
318 E3dObject::NbcSetSnapRect(rRect);
319 aCamera.SetDeviceWindow(rRect);
320 aCameraSet.SetViewportRectangle(rRect);
322 ImpCleanup3DDepthMapper();
325 void E3dScene::NbcMove(const Size& rSize)
327 tools::Rectangle aNewSnapRect = GetSnapRect();
328 aNewSnapRect.Move(rSize);
329 NbcSetSnapRect(aNewSnapRect);
332 void E3dScene::NbcResize(const Point& rRef, const Fraction& rXFact,
333 const Fraction& rYFact)
335 tools::Rectangle aNewSnapRect = GetSnapRect();
336 ResizeRect(aNewSnapRect, rRef, rXFact, rYFact);
337 NbcSetSnapRect(aNewSnapRect);
340 // Set new camera, and thus mark the scene and if possible the bound volume
341 // as changed
343 void E3dScene::SetCamera(const Camera3D& rNewCamera)
345 aCamera = rNewCamera;
346 static_cast<sdr::properties::E3dSceneProperties&>(GetProperties()).SetSceneItemsFromCamera();
348 SetBoundAndSnapRectsDirty();
350 // Turn off ratio
351 GetCameraSet().SetRatio(0.0);
353 // Set Imaging geometry
354 basegfx::B3DPoint aVRP(aCamera.GetViewPoint());
355 basegfx::B3DVector aVPN(aVRP - aCamera.GetVRP());
356 basegfx::B3DVector aVUV(aCamera.GetVUV());
358 // use SetViewportValues() to set VRP, VPN and VUV as vectors, too.
359 // Else these values would not be exported/imported correctly.
360 GetCameraSet().SetViewportValues(aVRP, aVPN, aVUV);
362 // Set perspective
363 GetCameraSet().SetPerspective(aCamera.GetProjection() == ProjectionType::Perspective);
364 GetCameraSet().SetViewportRectangle(aCamera.GetDeviceWindow());
366 ImpCleanup3DDepthMapper();
369 // Inform parent of changes of a child
371 void E3dScene::StructureChanged()
373 E3dObject::StructureChanged();
375 E3dScene* pScene(getRootE3dSceneFromE3dObject());
377 if(nullptr != pScene && !pScene->mbSkipSettingDirty)
379 SetBoundAndSnapRectsDirty();
382 ImpCleanup3DDepthMapper();
385 // Determine the overall scene object
387 E3dScene* E3dScene::getRootE3dSceneFromE3dObject() const
389 E3dScene* pParent(getParentE3dSceneFromE3dObject());
391 if(nullptr != pParent)
393 return pParent->getRootE3dSceneFromE3dObject();
396 return const_cast< E3dScene* >(this);
399 void E3dScene::removeAllNonSelectedObjects()
401 E3DModifySceneSnapRectUpdater aUpdater(this);
403 for(size_t a = 0; a < GetObjCount(); ++a)
405 SdrObject* pObj = GetObj(a);
407 if(pObj)
409 bool bRemoveObject(false);
411 if(E3dScene* pScene = DynCastE3dScene(pObj))
413 // iterate over this sub-scene
414 pScene->removeAllNonSelectedObjects();
416 // check object count. Empty scenes can be deleted
417 const size_t nObjCount(pScene->GetSubList() ? pScene->GetSubList()->GetObjCount() : 0);
419 if(!nObjCount)
421 // all objects removed, scene can be removed, too
422 bRemoveObject = true;
425 else if(auto pCompound = dynamic_cast<E3dCompoundObject*>(pObj))
427 if(!pCompound->GetSelected())
429 bRemoveObject = true;
433 if(bRemoveObject)
435 NbcRemoveObject(pObj->GetOrdNum());
436 a--;
442 rtl::Reference<SdrObject> E3dScene::CloneSdrObject(SdrModel& rTargetModel) const
444 return new E3dScene(rTargetModel, *this);
447 void E3dScene::SuspendReportingDirtyRects()
449 E3dScene* pScene(getRootE3dSceneFromE3dObject());
451 if(nullptr != pScene)
453 pScene->mbSkipSettingDirty = true;
457 void E3dScene::ResumeReportingDirtyRects()
459 E3dScene* pScene(getRootE3dSceneFromE3dObject());
461 if(nullptr != pScene)
463 pScene->mbSkipSettingDirty = false;
467 void E3dScene::SetAllSceneRectsDirty()
469 E3dScene* pScene(getRootE3dSceneFromE3dObject());
471 if(nullptr != pScene)
473 pScene->SetBoundAndSnapRectsDirty();
477 // Rebuild Light- and label- object lists rebuild (after loading, allocation)
479 void E3dScene::RebuildLists()
481 // first delete
482 const SdrLayerID nCurrLayerID(GetLayer());
483 SdrObjListIter a3DIterator(GetSubList(), SdrIterMode::Flat);
485 // then examine all the objects in the scene
486 while(a3DIterator.IsMore())
488 E3dObject* p3DObj(static_cast< E3dObject* >(a3DIterator.Next()));
489 p3DObj->NbcSetLayer(nCurrLayerID);
492 ImpCleanup3DDepthMapper();
495 std::unique_ptr<SdrObjGeoData> E3dScene::NewGeoData() const
497 return std::make_unique<E3DSceneGeoData>();
500 void E3dScene::SaveGeoData(SdrObjGeoData& rGeo) const
502 E3dObject::SaveGeoData (rGeo);
504 static_cast<E3DSceneGeoData &>(rGeo).aCamera = aCamera;
507 void E3dScene::RestoreGeoData(const SdrObjGeoData& rGeo)
509 // #i94832# removed E3DModifySceneSnapRectUpdater here.
510 // It should not be needed, is already part of E3dObject::RestoreGeoData
511 E3dObject::RestoreGeoData (rGeo);
512 SetCamera (static_cast<const E3DSceneGeoData &>(rGeo).aCamera);
515 // Something was changed in the style sheet, so change scene
517 void E3dScene::Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
519 SetBoundAndSnapRectsDirty();
520 E3dObject::Notify(rBC, rHint);
523 void E3dScene::RotateScene (const Point& rRef, double sn, double cs)
525 Point UpperLeft, LowerRight, Center, NewCenter;
527 UpperLeft = m_aOutRect.TopLeft();
528 LowerRight = m_aOutRect.BottomRight();
530 tools::Long dxOutRectHalf = std::abs(UpperLeft.X() - LowerRight.X());
531 dxOutRectHalf /= 2;
532 tools::Long dyOutRectHalf = std::abs(UpperLeft.Y() - LowerRight.Y());
533 dyOutRectHalf /= 2;
535 // Only the center is moved. The corners are moved by NbcMove. For the
536 // rotation a cartesian coordinate system is used in which the pivot
537 // point is the origin, and the y-axis increases upward, the X-axis to
538 // the right. This must be especially noted for the Y-values.
539 // (When considering a flat piece of paper the Y-axis pointing downwards
540 Center.setX( (UpperLeft.X() + dxOutRectHalf) - rRef.X() );
541 Center.setY( -((UpperLeft.Y() + dyOutRectHalf) - rRef.Y()) );
542 // A few special cases has to be dealt with first (n * 90 degrees n integer)
543 if (sn==1.0 && cs==0.0) { // 90deg
544 NewCenter.setX( -Center.Y() );
545 NewCenter.setY( -Center.X() );
546 } else if (sn==0.0 && cs==-1.0) { // 180deg
547 NewCenter.setX( -Center.X() );
548 NewCenter.setY( -Center.Y() );
549 } else if (sn==-1.0 && cs==0.0) { // 270deg
550 NewCenter.setX( Center.Y() );
551 NewCenter.setY( -Center.X() );
553 else // Here it is rotated to any angle in the mathematically
554 // positive direction!
555 { // xnew = x * cos(alpha) - y * sin(alpha)
556 // ynew = x * sin(alpha) + y * cos(alpha)
557 // Bottom Right is not rotated: the pages of aOutRect must
558 // remain parallel to the coordinate axes.
559 NewCenter.setX( static_cast<tools::Long>(Center.X() * cs - Center.Y() * sn) );
560 NewCenter.setY( static_cast<tools::Long>(Center.X() * sn + Center.Y() * cs) );
563 Size Differenz;
564 Point DiffPoint = NewCenter - Center;
565 Differenz.setWidth( DiffPoint.X() );
566 Differenz.setHeight( -DiffPoint.Y() ); // Note that the Y-axis is counted ad positive downward.
567 NbcMove (Differenz); // Actually executes the coordinate transformation.
570 OUString E3dScene::TakeObjNameSingul() const
572 OUString sName(SvxResId(STR_ObjNameSingulScene3d));
574 OUString aName(GetName());
575 if (!aName.isEmpty())
576 sName += " '" + aName + "'";
577 return sName;
580 OUString E3dScene::TakeObjNamePlural() const
582 return SvxResId(STR_ObjNamePluralScene3d);
585 // The NbcRotate routine overrides the one of the SdrObject. The idea is
586 // to be able to rotate the scene relative to the position of the scene
587 // and then the objects in the scene
589 void E3dScene::NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix)
591 if(maTransformation != rMatrix)
593 // call parent
594 E3dObject::NbcSetTransform(rMatrix);
598 void E3dScene::SetTransform(const basegfx::B3DHomMatrix& rMatrix)
600 if(rMatrix != maTransformation)
602 // call parent
603 E3dObject::SetTransform(rMatrix);
607 void E3dScene::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs)
609 // So currently the gluepoints are defined relative to the scene aOutRect.
610 // Before turning the gluepoints are defined relative to the page. They
611 // take no part in the rotation of the scene. To ensure this, there is the
612 // SetGlueReallyAbsolute(sal_True);
614 // So that was the scene, now the objects used in the scene
615 // 3D objects, if there is only one it can still have multiple surfaces but
616 // the surfaces do not have to be connected. This allows you to access child
617 // objects. So going through the entire list and rotate around the Z axis
618 // through the enter of aOutRect's (Steiner's theorem), so RotateZ
620 RotateScene (rRef, sn, cs); // Rotates the scene
621 double fAngleInRad = toRadians(nAngle);
623 basegfx::B3DHomMatrix aRotation;
624 aRotation.rotate(0.0, 0.0, fAngleInRad);
625 NbcSetTransform(aRotation * GetTransform());
627 SetBoundAndSnapRectsDirty(); // This forces a recalculation of all BoundRects
628 NbcRotateGluePoints(rRef,nAngle,sn,cs); // Rotate the gluepoints (who still
629 // have coordinates relative to the
630 // original page)
631 SetGlueReallyAbsolute(false); // from now they are again relative to BoundRect (that is defined as aOutRect)
632 SetBoundAndSnapRectsDirty();
635 void E3dScene::RecalcSnapRect()
637 E3dScene* pScene(getRootE3dSceneFromE3dObject());
639 if(pScene == this)
641 // The Scene is used as a 2D-Object, take the SnapRect from the
642 // 2D Display settings
643 maSnapRect = pScene->aCamera.GetDeviceWindow();
645 else
647 // The Scene itself is a member of another scene, get the SnapRect
648 // as a composite object
649 // call parent
650 E3dObject::RecalcSnapRect();
652 for(size_t a = 0; a < GetObjCount(); ++a)
654 E3dObject* pCandidate(DynCastE3dObject(GetObj(a)));
656 if(pCandidate)
658 maSnapRect.Union(pCandidate->GetSnapRect());
664 bool E3dScene::IsBreakObjPossible()
666 // Break scene, if all members are able to break
667 SdrObjListIter a3DIterator(GetSubList(), SdrIterMode::DeepWithGroups);
669 while ( a3DIterator.IsMore() )
671 E3dObject* pObj = static_cast<E3dObject*>(a3DIterator.Next());
672 if(!pObj->IsBreakObjPossible())
673 return false;
676 return true;
679 basegfx::B2DPolyPolygon E3dScene::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
681 return TakeXorPoly();
684 bool E3dScene::BegCreate(SdrDragStat& rStat)
686 rStat.SetOrtho4Possible();
687 tools::Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
688 aRect1.Normalize();
689 rStat.SetActionRect(aRect1);
690 NbcSetSnapRect(aRect1);
691 return true;
694 bool E3dScene::MovCreate(SdrDragStat& rStat)
696 tools::Rectangle aRect1;
697 rStat.TakeCreateRect(aRect1);
698 aRect1.Normalize();
699 rStat.SetActionRect(aRect1);
700 NbcSetSnapRect(aRect1);
701 SetBoundRectDirty();
702 m_bSnapRectDirty=true;
703 return true;
706 bool E3dScene::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
708 tools::Rectangle aRect1;
709 rStat.TakeCreateRect(aRect1);
710 aRect1.Normalize();
711 NbcSetSnapRect(aRect1);
712 SetBoundAndSnapRectsDirty();
713 return (eCmd==SdrCreateCmd::ForceEnd || rStat.GetPointCount()>=2);
716 bool E3dScene::BckCreate(SdrDragStat& /*rStat*/)
718 return false;
721 void E3dScene::BrkCreate(SdrDragStat& /*rStat*/)
725 void E3dScene::SetSelected(bool bNew)
727 // call parent
728 E3dObject::SetSelected(bNew);
730 for(size_t a(0); a < GetObjCount(); a++)
732 E3dObject* pCandidate(DynCastE3dObject(GetObj(a)));
734 if(pCandidate)
736 pCandidate->SetSelected(bNew);
741 void E3dScene::NbcInsertObject(SdrObject* pObj, size_t nPos)
743 // Is it even a 3D object?
744 if(DynCastE3dObject(pObj))
746 // Normal 3D object, insert means call parent
747 SdrObjList::NbcInsertObject(pObj, nPos);
749 // local needed stuff
750 InvalidateBoundVolume();
751 StructureChanged();
753 else
755 // No 3D object, inserted a page in place in a scene ...
756 getSdrObjectFromSdrObjList()->getSdrPageFromSdrObject()->InsertObject(pObj, nPos);
760 void E3dScene::InsertObject(SdrObject* pObj, size_t nPos)
762 // Is it even a 3D object?
763 if(DynCastE3dObject(pObj))
765 // call parent
766 SdrObjList::InsertObject(pObj, nPos);
768 // local needed stuff
769 InvalidateBoundVolume();
770 StructureChanged();
772 else
774 // No 3D object, inserted a page in place in a scene ...
775 getSdrObjectFromSdrObjList()->getSdrPageFromSdrObject()->InsertObject(pObj, nPos);
779 rtl::Reference<SdrObject> E3dScene::NbcRemoveObject(size_t nObjNum)
781 // call parent
782 rtl::Reference<SdrObject> pRetval = SdrObjList::NbcRemoveObject(nObjNum);
784 InvalidateBoundVolume();
785 StructureChanged();
787 return pRetval;
790 rtl::Reference<SdrObject> E3dScene::RemoveObject(size_t nObjNum)
792 // call parent
793 rtl::Reference<SdrObject> pRetval(SdrObjList::RemoveObject(nObjNum));
795 InvalidateBoundVolume();
796 StructureChanged();
798 return pRetval;
801 void E3dScene::SetBoundAndSnapRectsDirty(bool bNotMyself, bool bRecursive)
803 // call parent
804 E3dObject::SetBoundAndSnapRectsDirty(bNotMyself, bRecursive);
806 for(size_t a = 0; a < GetObjCount(); ++a)
808 E3dObject* pCandidate = DynCastE3dObject(GetObj(a));
810 if(pCandidate)
812 pCandidate->SetBoundAndSnapRectsDirty(bNotMyself, false);
817 void E3dScene::NbcSetLayer(SdrLayerID nLayer)
819 // call parent
820 E3dObject::NbcSetLayer(nLayer);
822 for(size_t a = 0; a < GetObjCount(); ++a)
824 E3dObject* pCandidate = DynCastE3dObject(GetObj(a));
826 if(pCandidate)
828 pCandidate->NbcSetLayer(nLayer);
833 void E3dScene::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage)
835 if(pOldPage == pNewPage)
836 return;
838 // call parent
839 E3dObject::handlePageChange(pOldPage, pNewPage);
841 for(size_t a(0); a < GetObjCount(); a++)
843 E3dObject* pCandidate = DynCastE3dObject(GetObj(a));
845 if(pCandidate)
847 pCandidate->handlePageChange(pOldPage, pNewPage);
849 else
851 OSL_ENSURE(false, "E3dScene::handlePageChange invalid object list (!)");
856 SdrObjList* E3dScene::GetSubList() const
858 return const_cast< E3dScene* >(this);
861 basegfx::B3DRange E3dScene::RecalcBoundVolume() const
863 basegfx::B3DRange aRetval;
864 const size_t nObjCnt(GetObjCount());
866 for(size_t a = 0; a < nObjCnt; ++a)
868 const E3dObject* p3DObject = DynCastE3dObject(GetObj(a));
870 if(p3DObject)
872 basegfx::B3DRange aLocalRange(p3DObject->GetBoundVolume());
873 aLocalRange.transform(p3DObject->GetTransform());
874 aRetval.expand(aLocalRange);
878 return aRetval;
881 void E3dScene::SetTransformChanged()
883 // call parent
884 E3dObject::SetTransformChanged();
886 for(size_t a = 0; a < GetObjCount(); ++a)
888 E3dObject* pCandidate = DynCastE3dObject(GetObj(a));
890 if(pCandidate)
892 pCandidate->SetTransformChanged();
897 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */