1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SVX_SCENE3D_HXX
21 #define INCLUDED_SVX_SCENE3D_HXX
23 #include <svx/camera3d.hxx>
24 #include <tools/b3dtrans.hxx>
25 #include <svx/svdpage.hxx>
26 #include <svx/svxdllapi.h>
27 #include <svx/obj3d.hxx>
28 #include <svx/svx3ditems.hxx>
31 namespace sdr::properties
{
35 /*************************************************************************
37 |* GeoData relevant for undo actions
39 \************************************************************************/
41 class E3DSceneGeoData final
: public E3DObjGeoData
49 class Imp3DDepthRemapper
;
51 /*************************************************************************
53 |* base class for 3D scenes
55 \************************************************************************/
57 class SVXCORE_DLLPUBLIC E3dScene final
: public E3dObject
, public SdrObjList
59 virtual std::unique_ptr
<sdr::properties::BaseProperties
> CreateObjectSpecificProperties() override
;
60 virtual std::unique_ptr
<sdr::contact::ViewContact
> CreateObjectSpecificViewContact() override
;
63 B3dCamera m_aCameraSet
;
66 mutable std::unique_ptr
<Imp3DDepthRemapper
> mp3DDepthRemapper
;
68 // Flag to determine if only selected objects should be drawn
69 bool m_bDrawOnlySelected
: 1;
71 bool mbSkipSettingDirty
: 1;
75 virtual void Notify(SfxBroadcaster
&rBC
, const SfxHint
&rHint
) override
;
77 void SetDefaultAttributes();
78 void ImpCleanup3DDepthMapper();
81 E3dScene(SdrModel
& rSdrModel
);
82 E3dScene(SdrModel
& rSdrModel
, E3dScene
const &);
83 virtual ~E3dScene() override
;
85 virtual void StructureChanged() override
;
87 // derived from SdrObjList
88 virtual SdrPage
* getSdrPageFromSdrObjList() const override
;
89 virtual SdrObject
* getSdrObjectFromSdrObjList() const override
;
91 // derived from SdrObject
92 virtual SdrObjList
* getChildrenOfSdrObject() const override
;
94 virtual void SetBoundRectDirty() override
;
96 virtual basegfx::B2DPolyPolygon
TakeXorPoly() const override
;
98 sal_uInt32
RemapOrdNum(sal_uInt32 nOrdNum
) const;
100 // Perspective: enum ProjectionType { ProjectionType::Parallel, ProjectionType::Perspective }
101 ProjectionType
GetPerspective() const
102 { return static_cast<ProjectionType
>(GetObjectItemSet().Get(SDRATTR_3DSCENE_PERSPECTIVE
).GetValue()); }
105 double GetDistance() const
106 { return static_cast<double>(GetObjectItemSet().Get(SDRATTR_3DSCENE_DISTANCE
).GetValue()); }
108 // Focal length: before cm, now 1/10th mm (*100)
109 double GetFocalLength() const
110 { return GetObjectItemSet().Get(SDRATTR_3DSCENE_FOCAL_LENGTH
).GetValue(); }
112 // set flag to draw only selected
113 void SetDrawOnlySelected(bool bNew
) { m_bDrawOnlySelected
= bNew
; }
114 bool GetDrawOnlySelected() const { return m_bDrawOnlySelected
; }
115 virtual SdrObjKind
GetObjIdentifier() const override
;
117 virtual void NbcSetSnapRect(const tools::Rectangle
& rRect
) override
;
118 virtual void NbcMove(const Size
& rSize
) override
;
119 virtual void NbcResize(const Point
& rRef
, const Fraction
& rXFact
,
120 const Fraction
& rYFact
) override
;
121 virtual void RecalcSnapRect() override
;
123 virtual E3dScene
* getRootE3dSceneFromE3dObject() const override
;
124 void SetCamera(const Camera3D
& rNewCamera
);
125 const Camera3D
& GetCamera() const { return m_aCamera
; }
126 void removeAllNonSelectedObjects();
128 virtual rtl::Reference
<SdrObject
> CloneSdrObject(SdrModel
& rTargetModel
) const override
;
130 virtual std::unique_ptr
<SdrObjGeoData
> NewGeoData() const override
;
131 virtual void SaveGeoData(SdrObjGeoData
& rGeo
) const override
;
132 virtual void RestoreGeoData(const SdrObjGeoData
& rGeo
) override
;
134 virtual void NbcSetTransform(const basegfx::B3DHomMatrix
& rMatrix
) override
;
135 virtual void SetTransform(const basegfx::B3DHomMatrix
& rMatrix
) override
;
137 virtual void NbcRotate(const Point
& rRef
, Degree100 nAngle
, double sn
, double cs
) override
;
138 void RotateScene(const Point
& rRef
, double sn
, double cs
);
140 // TakeObjName...() is for the display in the UI, for example "3 frames selected".
141 virtual OUString
TakeObjNameSingul() const override
;
142 virtual OUString
TakeObjNamePlural() const override
;
144 // get transformations
145 B3dCamera
& GetCameraSet() { return m_aCameraSet
; }
146 const B3dCamera
& GetCameraSet() const { return m_aCameraSet
; }
149 virtual bool IsBreakObjPossible() override
;
151 // polygon which is built during creation
152 virtual basegfx::B2DPolyPolygon
TakeCreatePoly(const SdrDragStat
& rDrag
) const override
;
155 virtual bool BegCreate(SdrDragStat
& rStat
) override
;
156 virtual bool MovCreate(SdrDragStat
& rStat
) override
; // true=Xor must be repainted
157 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
158 virtual bool BckCreate(SdrDragStat
& rStat
) override
;
159 virtual void BrkCreate(SdrDragStat
& rStat
) override
;
161 void SuspendReportingDirtyRects();
162 void ResumeReportingDirtyRects();
163 void SetAllSceneRectsDirty();
165 // set selection from E3dObject (temporary flag for 3D actions)
166 virtual void SetSelected(bool bNew
) override
;
168 // derived from SdrObjList
169 virtual void NbcInsertObject(SdrObject
* pObj
, size_t nPos
=SAL_MAX_SIZE
) override
;
170 virtual void InsertObject(SdrObject
* pObj
, size_t nPos
=SAL_MAX_SIZE
) override
;
171 virtual rtl::Reference
<SdrObject
> NbcRemoveObject(size_t nObjNum
) override
;
172 virtual rtl::Reference
<SdrObject
> RemoveObject(size_t nObjNum
) override
;
174 // needed for group functionality
175 virtual void SetBoundAndSnapRectsDirty(bool bNotMyself
= false, bool bRecursive
= true) override
;
176 virtual void NbcSetLayer(SdrLayerID nLayer
) override
;
178 // react on model/page change
179 virtual void handlePageChange(SdrPage
* pOldPage
, SdrPage
* pNewPage
) override
;
181 virtual SdrObjList
* GetSubList() const override
;
182 virtual void SetTransformChanged() override
;
185 virtual basegfx::B3DRange
RecalcBoundVolume() const override
;
188 #endif // INCLUDED_SVX_SCENE3D_HXX
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */