Simplify using designated initializers
[LibreOffice.git] / svx / source / engine3d / scene3d.cxx
blobee9cad6365a8d7fc1e984535ee80a5ff3a8e1e2a
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>
41 #include <osl/diagnose.h>
43 namespace {
45 class ImpRemap3DDepth
47 sal_uInt32 mnOrdNum;
48 double mfMinimalDepth;
50 // bit field
51 bool mbIsScene : 1;
53 public:
54 ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth);
55 explicit ImpRemap3DDepth(sal_uInt32 nOrdNum);
57 // for ::std::sort
58 bool operator<(const ImpRemap3DDepth& rComp) const;
60 sal_uInt32 GetOrdNum() const { return mnOrdNum; }
61 bool IsScene() const { return mbIsScene; }
66 ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth)
67 : mnOrdNum(nOrdNum),
68 mfMinimalDepth(fMinimalDepth),
69 mbIsScene(false)
73 ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum)
74 : mnOrdNum(nOrdNum),
75 mfMinimalDepth(0.0),
76 mbIsScene(true)
80 bool ImpRemap3DDepth::operator<(const ImpRemap3DDepth& rComp) const
82 if(IsScene())
84 return false;
86 else
88 if(rComp.IsScene())
90 return true;
92 else
94 return mfMinimalDepth < rComp.mfMinimalDepth;
99 class Imp3DDepthRemapper
101 std::vector< ImpRemap3DDepth > maVector;
103 public:
104 explicit Imp3DDepthRemapper(E3dScene const & rScene);
106 sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
109 Imp3DDepthRemapper::Imp3DDepthRemapper(E3dScene const & rScene)
111 // only called when rScene.GetSubList() and nObjCount > 1
112 SdrObjList* pList = rScene.GetSubList();
113 const size_t nObjCount(pList->GetObjCount());
115 for(size_t a = 0; a < nObjCount; ++a)
117 SdrObject* pCandidate = pList->GetObj(a);
119 if(pCandidate)
121 if(auto pCompoundObj = dynamic_cast< const E3dCompoundObject*>(pCandidate))
123 // single 3d object, calc depth
124 const double fMinimalDepth(getMinimalDepthInViewCoordinates(*pCompoundObj));
125 ImpRemap3DDepth aEntry(a, fMinimalDepth);
126 maVector.push_back(aEntry);
128 else
130 // scene, use standard entry for scene
131 ImpRemap3DDepth aEntry(a);
132 maVector.push_back(aEntry);
137 // now, we need to sort the maVector by its members minimal depth. The
138 // smaller, the nearer to the viewer.
139 ::std::sort(maVector.begin(), maVector.end());
142 sal_uInt32 Imp3DDepthRemapper::RemapOrdNum(sal_uInt32 nOrdNum) const
144 if(nOrdNum < maVector.size())
146 nOrdNum = maVector[(maVector.size() - 1) - nOrdNum].GetOrdNum();
149 return nOrdNum;
153 // BaseProperties section
155 std::unique_ptr<sdr::properties::BaseProperties> E3dScene::CreateObjectSpecificProperties()
157 return std::make_unique<sdr::properties::E3dSceneProperties>(*this);
161 // DrawContact section
163 std::unique_ptr<sdr::contact::ViewContact> E3dScene::CreateObjectSpecificViewContact()
165 return std::make_unique<sdr::contact::ViewContactOfE3dScene>(*this);
169 E3dScene::E3dScene(SdrModel& rSdrModel)
170 : E3dObject(rSdrModel),
171 m_aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
172 m_bDrawOnlySelected(false),
173 mbSkipSettingDirty(false)
175 // Set defaults
176 SetDefaultAttributes();
179 E3dScene::E3dScene(SdrModel& rSdrModel, E3dScene const & rSource)
180 : E3dObject(rSdrModel, rSource),
181 m_aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
182 m_bDrawOnlySelected(false),
183 mbSkipSettingDirty(false)
185 // Set defaults
186 SetDefaultAttributes();
188 // copy child SdrObjects
189 if (rSource.GetSubList())
191 CopyObjects(*rSource.GetSubList());
193 // tdf#116979: needed here, we need bSnapRectDirty to be true
194 // which it is after using SdrObject::operator= (see above),
195 // but set to false again using CopyObjects
196 SetBoundAndSnapRectsDirty();
199 // copy local data
200 m_aCamera = rSource.m_aCamera;
201 m_aCameraSet = rSource.m_aCameraSet;
202 static_cast<sdr::properties::E3dSceneProperties&>(GetProperties()).SetSceneItemsFromCamera();
203 InvalidateBoundVolume();
204 RebuildLists();
205 ImpCleanup3DDepthMapper();
206 GetViewContact().ActionChanged();
209 void E3dScene::SetDefaultAttributes()
211 // For WIN95/NT turn off the FP-Exceptions
212 #if defined(_WIN32)
213 _control87( _MCW_EM, _MCW_EM );
214 #endif
216 // Set defaults
217 m_aCamera.SetViewWindow(-2, -2, 4, 4);
218 m_aCameraSet.SetDeviceRectangle(-2, 2, -2, 2);
219 m_aCamera.SetDeviceWindow(tools::Rectangle(0, 0, 10, 10));
220 tools::Rectangle aRect(0, 0, 10, 10);
221 m_aCameraSet.SetViewportRectangle(aRect);
223 // set defaults for Camera from ItemPool
224 m_aCamera.SetProjection(GetPerspective());
225 basegfx::B3DPoint aActualPosition(m_aCamera.GetPosition());
226 double fNew = GetDistance();
228 if(fabs(fNew - aActualPosition.getZ()) > 1.0)
230 m_aCamera.SetPosition( basegfx::B3DPoint( aActualPosition.getX(), aActualPosition.getY(), fNew) );
233 fNew = GetFocalLength() / 100.0;
234 m_aCamera.SetFocalLength(fNew);
237 E3dScene::~E3dScene()
239 ImpCleanup3DDepthMapper();
242 SdrPage* E3dScene::getSdrPageFromSdrObjList() const
244 return getSdrPageFromSdrObject();
247 SdrObject* E3dScene::getSdrObjectFromSdrObjList() const
249 return const_cast< E3dScene* >(this);
252 SdrObjList* E3dScene::getChildrenOfSdrObject() const
254 return const_cast< E3dScene* >(this);
257 basegfx::B2DPolyPolygon E3dScene::TakeXorPoly() const
259 const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(GetViewContact());
260 const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D());
261 const basegfx::B3DPolyPolygon aCubePolyPolygon(CreateWireframe());
263 basegfx::B2DPolyPolygon aRetval(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aCubePolyPolygon,
264 aViewInfo3D.getObjectToView()));
265 aRetval.transform(rVCScene.getObjectTransformation());
267 return aRetval;
270 void E3dScene::ImpCleanup3DDepthMapper()
272 mp3DDepthRemapper.reset();
275 sal_uInt32 E3dScene::RemapOrdNum(sal_uInt32 nNewOrdNum) const
277 if(!mp3DDepthRemapper)
279 const size_t nObjCount(GetSubList() ? GetSubList()->GetObjCount() : 0);
281 if(nObjCount > 1)
283 mp3DDepthRemapper.reset(new Imp3DDepthRemapper(*this));
287 if(mp3DDepthRemapper)
289 return mp3DDepthRemapper->RemapOrdNum(nNewOrdNum);
292 return nNewOrdNum;
295 SdrObjKind E3dScene::GetObjIdentifier() const
297 return SdrObjKind::E3D_Scene;
300 void E3dScene::SetBoundRectDirty()
302 E3dScene* pScene(getRootE3dSceneFromE3dObject());
304 if(pScene == this)
306 // avoid resetting aOutRect which in case of a 3D scene used as 2d object
307 // is model data,not re-creatable view data
309 else
311 // if not the outmost scene it is used as group in 3d, call parent
312 E3dObject::SetBoundRectDirty();
316 void E3dScene::NbcSetSnapRect(const tools::Rectangle& rRect)
318 SetBoundAndSnapRectsDirty();
319 E3dObject::NbcSetSnapRect(rRect);
320 m_aCamera.SetDeviceWindow(rRect);
321 m_aCameraSet.SetViewportRectangle(rRect);
323 ImpCleanup3DDepthMapper();
326 void E3dScene::NbcMove(const Size& rSize)
328 tools::Rectangle aNewSnapRect = GetSnapRect();
329 aNewSnapRect.Move(rSize);
330 NbcSetSnapRect(aNewSnapRect);
333 void E3dScene::NbcResize(const Point& rRef, const Fraction& rXFact,
334 const Fraction& rYFact)
336 tools::Rectangle aNewSnapRect = GetSnapRect();
337 ResizeRect(aNewSnapRect, rRef, rXFact, rYFact);
338 NbcSetSnapRect(aNewSnapRect);
341 // Set new camera, and thus mark the scene and if possible the bound volume
342 // as changed
344 void E3dScene::SetCamera(const Camera3D& rNewCamera)
346 m_aCamera = rNewCamera;
347 static_cast<sdr::properties::E3dSceneProperties&>(GetProperties()).SetSceneItemsFromCamera();
349 SetBoundAndSnapRectsDirty();
351 // Turn off ratio
352 GetCameraSet().SetRatio(0.0);
354 // Set Imaging geometry
355 basegfx::B3DPoint aVRP(m_aCamera.GetViewPoint());
356 basegfx::B3DVector aVPN(aVRP - m_aCamera.GetVRP());
357 basegfx::B3DVector aVUV(m_aCamera.GetVUV());
359 // use SetViewportValues() to set VRP, VPN and VUV as vectors, too.
360 // Else these values would not be exported/imported correctly.
361 GetCameraSet().SetViewportValues(aVRP, aVPN, aVUV);
363 // Set perspective
364 GetCameraSet().SetPerspective(m_aCamera.GetProjection() == ProjectionType::Perspective);
365 GetCameraSet().SetViewportRectangle(m_aCamera.GetDeviceWindow());
367 ImpCleanup3DDepthMapper();
370 // Inform parent of changes of a child
372 void E3dScene::StructureChanged()
374 E3dObject::StructureChanged();
376 E3dScene* pScene(getRootE3dSceneFromE3dObject());
378 if(nullptr != pScene && !pScene->mbSkipSettingDirty)
380 SetBoundAndSnapRectsDirty();
383 ImpCleanup3DDepthMapper();
386 // Determine the overall scene object
388 E3dScene* E3dScene::getRootE3dSceneFromE3dObject() const
390 E3dScene* pParent(getParentE3dSceneFromE3dObject());
392 if(nullptr != pParent)
394 return pParent->getRootE3dSceneFromE3dObject();
397 return const_cast< E3dScene* >(this);
400 void E3dScene::removeAllNonSelectedObjects()
402 E3DModifySceneSnapRectUpdater aUpdater(this);
404 size_t a = 0;
405 while (a < GetObjCount())
407 SdrObject* pObj = GetObj(a);
409 if(pObj)
411 bool bRemoveObject(false);
413 if(E3dScene* pScene = DynCastE3dScene(pObj))
415 // iterate over this sub-scene
416 pScene->removeAllNonSelectedObjects();
418 // check object count. Empty scenes can be deleted
419 const size_t nObjCount(pScene->GetSubList() ? pScene->GetSubList()->GetObjCount() : 0);
421 if(!nObjCount)
423 // all objects removed, scene can be removed, too
424 bRemoveObject = true;
427 else if(auto pCompound = dynamic_cast<E3dCompoundObject*>(pObj))
429 if(!pCompound->GetSelected())
431 bRemoveObject = true;
435 if(bRemoveObject)
437 NbcRemoveObject(pObj->GetOrdNum());
438 continue;
441 ++a;
445 rtl::Reference<SdrObject> E3dScene::CloneSdrObject(SdrModel& rTargetModel) const
447 return new E3dScene(rTargetModel, *this);
450 void E3dScene::SuspendReportingDirtyRects()
452 E3dScene* pScene(getRootE3dSceneFromE3dObject());
454 if(nullptr != pScene)
456 pScene->mbSkipSettingDirty = true;
460 void E3dScene::ResumeReportingDirtyRects()
462 E3dScene* pScene(getRootE3dSceneFromE3dObject());
464 if(nullptr != pScene)
466 pScene->mbSkipSettingDirty = false;
470 void E3dScene::SetAllSceneRectsDirty()
472 E3dScene* pScene(getRootE3dSceneFromE3dObject());
474 if(nullptr != pScene)
476 pScene->SetBoundAndSnapRectsDirty();
480 // Rebuild Light- and label- object lists rebuild (after loading, allocation)
482 void E3dScene::RebuildLists()
484 // first delete
485 const SdrLayerID nCurrLayerID(GetLayer());
486 SdrObjListIter a3DIterator(GetSubList(), SdrIterMode::Flat);
488 // then examine all the objects in the scene
489 while(a3DIterator.IsMore())
491 E3dObject* p3DObj(static_cast< E3dObject* >(a3DIterator.Next()));
492 p3DObj->NbcSetLayer(nCurrLayerID);
495 ImpCleanup3DDepthMapper();
498 std::unique_ptr<SdrObjGeoData> E3dScene::NewGeoData() const
500 return std::make_unique<E3DSceneGeoData>();
503 void E3dScene::SaveGeoData(SdrObjGeoData& rGeo) const
505 E3dObject::SaveGeoData (rGeo);
507 static_cast<E3DSceneGeoData &>(rGeo).aCamera = m_aCamera;
510 void E3dScene::RestoreGeoData(const SdrObjGeoData& rGeo)
512 // #i94832# removed E3DModifySceneSnapRectUpdater here.
513 // It should not be needed, is already part of E3dObject::RestoreGeoData
514 E3dObject::RestoreGeoData (rGeo);
515 SetCamera (static_cast<const E3DSceneGeoData &>(rGeo).aCamera);
518 // Something was changed in the style sheet, so change scene
520 void E3dScene::Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
522 SetBoundAndSnapRectsDirty();
523 E3dObject::Notify(rBC, rHint);
526 void E3dScene::RotateScene (const Point& rRef, double sn, double cs)
528 Point NewCenter;
530 auto const& rRectangle = getOutRectangle();
531 Point Center = rRectangle.Center();
533 // Only the center is moved. The corners are moved by NbcMove. For the
534 // rotation a cartesian coordinate system is used in which the pivot
535 // point is the origin, and the y-axis increases upward, the X-axis to
536 // the right. This must be especially noted for the Y-values.
537 // (When considering a flat piece of paper the Y-axis pointing downwards
538 Center.setX(Center.X() - rRef.X());
539 Center.setY(rRef.Y() - Center.Y());
540 // A few special cases has to be dealt with first (n * 90 degrees n integer)
541 if (sn==1.0 && cs==0.0) { // 90deg
542 NewCenter.setX( -Center.Y() );
543 NewCenter.setY( -Center.X() );
544 } else if (sn==0.0 && cs==-1.0) { // 180deg
545 NewCenter.setX( -Center.X() );
546 NewCenter.setY( -Center.Y() );
547 } else if (sn==-1.0 && cs==0.0) { // 270deg
548 NewCenter.setX( Center.Y() );
549 NewCenter.setY( -Center.X() );
551 else // Here it is rotated to any angle in the mathematically
552 // positive direction!
553 { // xnew = x * cos(alpha) - y * sin(alpha)
554 // ynew = x * sin(alpha) + y * cos(alpha)
555 // Bottom Right is not rotated: the pages of aOutRect must
556 // remain parallel to the coordinate axes.
557 NewCenter.setX( static_cast<tools::Long>(Center.X() * cs - Center.Y() * sn) );
558 NewCenter.setY( static_cast<tools::Long>(Center.X() * sn + Center.Y() * cs) );
561 Size Differenz;
562 Point DiffPoint = NewCenter - Center;
563 Differenz.setWidth( DiffPoint.X() );
564 Differenz.setHeight( -DiffPoint.Y() ); // Note that the Y-axis is counted ad positive downward.
565 NbcMove (Differenz); // Actually executes the coordinate transformation.
568 OUString E3dScene::TakeObjNameSingul() const
570 OUString sName(SvxResId(STR_ObjNameSingulScene3d));
572 OUString aName(GetName());
573 if (!aName.isEmpty())
574 sName += " '" + aName + "'";
575 return sName;
578 OUString E3dScene::TakeObjNamePlural() const
580 return SvxResId(STR_ObjNamePluralScene3d);
583 // The NbcRotate routine overrides the one of the SdrObject. The idea is
584 // to be able to rotate the scene relative to the position of the scene
585 // and then the objects in the scene
587 void E3dScene::NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix)
589 if(maTransformation != rMatrix)
591 // call parent
592 E3dObject::NbcSetTransform(rMatrix);
596 void E3dScene::SetTransform(const basegfx::B3DHomMatrix& rMatrix)
598 if(rMatrix != maTransformation)
600 // call parent
601 E3dObject::SetTransform(rMatrix);
605 void E3dScene::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs)
607 // So currently the gluepoints are defined relative to the scene aOutRect.
608 // Before turning the gluepoints are defined relative to the page. They
609 // take no part in the rotation of the scene. To ensure this, there is the
610 // SetGlueReallyAbsolute(sal_True);
612 // So that was the scene, now the objects used in the scene
613 // 3D objects, if there is only one it can still have multiple surfaces but
614 // the surfaces do not have to be connected. This allows you to access child
615 // objects. So going through the entire list and rotate around the Z axis
616 // through the enter of aOutRect's (Steiner's theorem), so RotateZ
618 RotateScene (rRef, sn, cs); // Rotates the scene
619 double fAngleInRad = toRadians(nAngle);
621 basegfx::B3DHomMatrix aRotation;
622 aRotation.rotate(0.0, 0.0, fAngleInRad);
623 NbcSetTransform(aRotation * GetTransform());
625 SetBoundAndSnapRectsDirty(); // This forces a recalculation of all BoundRects
626 NbcRotateGluePoints(rRef,nAngle,sn,cs); // Rotate the gluepoints (who still
627 // have coordinates relative to the
628 // original page)
629 SetGlueReallyAbsolute(false); // from now they are again relative to BoundRect (that is defined as aOutRect)
630 SetBoundAndSnapRectsDirty();
633 void E3dScene::RecalcSnapRect()
635 E3dScene* pScene(getRootE3dSceneFromE3dObject());
637 if(pScene == this)
639 // The Scene is used as a 2D-Object, take the SnapRect from the
640 // 2D Display settings
641 maSnapRect = pScene->m_aCamera.GetDeviceWindow();
643 else
645 // The Scene itself is a member of another scene, get the SnapRect
646 // as a composite object
647 // call parent
648 E3dObject::RecalcSnapRect();
650 for (const rtl::Reference<SdrObject>& pObj : *this)
652 E3dObject* pCandidate(DynCastE3dObject(pObj.get()));
654 if(pCandidate)
656 maSnapRect.Union(pCandidate->GetSnapRect());
662 bool E3dScene::IsBreakObjPossible()
664 // Break scene, if all members are able to break
665 SdrObjListIter a3DIterator(GetSubList(), SdrIterMode::DeepWithGroups);
667 while ( a3DIterator.IsMore() )
669 E3dObject* pObj = static_cast<E3dObject*>(a3DIterator.Next());
670 if(!pObj->IsBreakObjPossible())
671 return false;
674 return true;
677 basegfx::B2DPolyPolygon E3dScene::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
679 return TakeXorPoly();
682 bool E3dScene::BegCreate(SdrDragStat& rStat)
684 rStat.SetOrtho4Possible();
685 tools::Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
686 aRect1.Normalize();
687 rStat.SetActionRect(aRect1);
688 NbcSetSnapRect(aRect1);
689 return true;
692 bool E3dScene::MovCreate(SdrDragStat& rStat)
694 tools::Rectangle aRect1;
695 rStat.TakeCreateRect(aRect1);
696 aRect1.Normalize();
697 rStat.SetActionRect(aRect1);
698 NbcSetSnapRect(aRect1);
699 SetBoundRectDirty();
700 m_bSnapRectDirty=true;
701 return true;
704 bool E3dScene::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
706 tools::Rectangle aRect1;
707 rStat.TakeCreateRect(aRect1);
708 aRect1.Normalize();
709 NbcSetSnapRect(aRect1);
710 SetBoundAndSnapRectsDirty();
711 return (eCmd==SdrCreateCmd::ForceEnd || rStat.GetPointCount()>=2);
714 bool E3dScene::BckCreate(SdrDragStat& /*rStat*/)
716 return false;
719 void E3dScene::BrkCreate(SdrDragStat& /*rStat*/)
723 void E3dScene::SetSelected(bool bNew)
725 // call parent
726 E3dObject::SetSelected(bNew);
728 for (const rtl::Reference<SdrObject>& pObj : *this)
730 E3dObject* pCandidate(DynCastE3dObject(pObj.get()));
732 if(pCandidate)
734 pCandidate->SetSelected(bNew);
739 void E3dScene::NbcInsertObject(SdrObject* pObj, size_t nPos)
741 // Is it even a 3D object?
742 if(DynCastE3dObject(pObj))
744 // Normal 3D object, insert means call parent
745 SdrObjList::NbcInsertObject(pObj, nPos);
747 // local needed stuff
748 InvalidateBoundVolume();
749 StructureChanged();
751 else
753 // No 3D object, inserted a page in place in a scene ...
754 getSdrObjectFromSdrObjList()->getSdrPageFromSdrObject()->InsertObject(pObj, nPos);
758 void E3dScene::InsertObject(SdrObject* pObj, size_t nPos)
760 // Is it even a 3D object?
761 if(DynCastE3dObject(pObj))
763 // call parent
764 SdrObjList::InsertObject(pObj, nPos);
766 // local needed stuff
767 InvalidateBoundVolume();
768 StructureChanged();
770 else
772 // No 3D object, inserted a page in place in a scene ...
773 getSdrObjectFromSdrObjList()->getSdrPageFromSdrObject()->InsertObject(pObj, nPos);
777 rtl::Reference<SdrObject> E3dScene::NbcRemoveObject(size_t nObjNum)
779 // call parent
780 rtl::Reference<SdrObject> pRetval = SdrObjList::NbcRemoveObject(nObjNum);
782 InvalidateBoundVolume();
783 StructureChanged();
785 return pRetval;
788 rtl::Reference<SdrObject> E3dScene::RemoveObject(size_t nObjNum)
790 // call parent
791 rtl::Reference<SdrObject> pRetval(SdrObjList::RemoveObject(nObjNum));
793 InvalidateBoundVolume();
794 StructureChanged();
796 return pRetval;
799 void E3dScene::SetBoundAndSnapRectsDirty(bool bNotMyself, bool bRecursive)
801 // call parent
802 E3dObject::SetBoundAndSnapRectsDirty(bNotMyself, bRecursive);
804 for (const rtl::Reference<SdrObject>& pObj : *this)
806 E3dObject* pCandidate = DynCastE3dObject(pObj.get());
808 if(pCandidate)
810 pCandidate->SetBoundAndSnapRectsDirty(bNotMyself, false);
815 void E3dScene::NbcSetLayer(SdrLayerID nLayer)
817 // call parent
818 E3dObject::NbcSetLayer(nLayer);
820 for (const rtl::Reference<SdrObject>& pObj : *this)
822 E3dObject* pCandidate = DynCastE3dObject(pObj.get());
824 if(pCandidate)
826 pCandidate->NbcSetLayer(nLayer);
831 void E3dScene::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage)
833 if(pOldPage == pNewPage)
834 return;
836 // call parent
837 E3dObject::handlePageChange(pOldPage, pNewPage);
839 for (const rtl::Reference<SdrObject>& pObj : *this)
841 E3dObject* pCandidate = DynCastE3dObject(pObj.get());
843 if(pCandidate)
845 pCandidate->handlePageChange(pOldPage, pNewPage);
847 else
849 OSL_ENSURE(false, "E3dScene::handlePageChange invalid object list (!)");
854 SdrObjList* E3dScene::GetSubList() const
856 return const_cast< E3dScene* >(this);
859 basegfx::B3DRange E3dScene::RecalcBoundVolume() const
861 basegfx::B3DRange aRetval;
863 for (const rtl::Reference<SdrObject>& pObj : *this)
865 const E3dObject* p3DObject = DynCastE3dObject(pObj.get());
867 if(p3DObject)
869 basegfx::B3DRange aLocalRange(p3DObject->GetBoundVolume());
870 aLocalRange.transform(p3DObject->GetTransform());
871 aRetval.expand(aLocalRange);
875 return aRetval;
878 void E3dScene::SetTransformChanged()
880 // call parent
881 E3dObject::SetTransformChanged();
883 for (const rtl::Reference<SdrObject>& pObj : *this)
885 E3dObject* pCandidate = DynCastE3dObject(pObj.get());
887 if(pCandidate)
889 pCandidate->SetTransformChanged();
894 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */