Bump version to 6.4-15
[LibreOffice.git] / include / svx / scene3d.hxx
blobac41ca0821916c88349b9965f897f8ecaaf2e9f0
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 #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>
29 #include <memory>
31 namespace sdr { namespace properties {
32 class BaseProperties;
35 /*************************************************************************
37 |* GeoData relevant for undo actions
39 \************************************************************************/
41 class E3DSceneGeoData final : public E3DObjGeoData
43 public:
44 Camera3D aCamera;
46 E3DSceneGeoData() {}
49 class Imp3DDepthRemapper;
51 /*************************************************************************
53 |* base class for 3D scenes
55 \************************************************************************/
57 class SVX_DLLPUBLIC E3dScene : public E3dObject, public SdrObjList
59 protected:
60 virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
61 virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
63 // transformations
64 B3dCamera aCameraSet;
65 Camera3D aCamera;
67 mutable std::unique_ptr<Imp3DDepthRemapper> mp3DDepthRemapper;
69 // Flag to determine if only selected objects should be drawn
70 bool bDrawOnlySelected : 1;
72 bool mbSkipSettingDirty : 1;
74 void RebuildLists();
76 virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override;
78 void SetDefaultAttributes();
79 void ImpCleanup3DDepthMapper();
81 // protected destructor
82 virtual ~E3dScene() override;
84 public:
85 E3dScene(SdrModel& rSdrModel);
87 virtual void StructureChanged() override;
89 // derived from SdrObjList
90 virtual SdrPage* getSdrPageFromSdrObjList() const override;
91 virtual SdrObject* getSdrObjectFromSdrObjList() const override;
93 // derived from SdrObject
94 virtual SdrObjList* getChildrenOfSdrObject() const override;
96 virtual void SetBoundRectDirty() override;
98 virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
100 sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
102 // Perspective: enum ProjectionType { ProjectionType::Parallel, ProjectionType::Perspective }
103 ProjectionType GetPerspective() const
104 { return static_cast<ProjectionType>(GetObjectItemSet().Get(SDRATTR_3DSCENE_PERSPECTIVE).GetValue()); }
106 // Distance:
107 double GetDistance() const
108 { return static_cast<double>(GetObjectItemSet().Get(SDRATTR_3DSCENE_DISTANCE).GetValue()); }
110 // Focal length: before cm, now 1/10th mm (*100)
111 double GetFocalLength() const
112 { return GetObjectItemSet().Get(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue(); }
114 // set flag to draw only selected
115 void SetDrawOnlySelected(bool bNew) { bDrawOnlySelected = bNew; }
116 bool GetDrawOnlySelected() const { return bDrawOnlySelected; }
117 virtual sal_uInt16 GetObjIdentifier() const override;
119 virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
120 virtual void NbcMove(const Size& rSize) override;
121 virtual void NbcResize(const Point& rRef, const Fraction& rXFact,
122 const Fraction& rYFact) override;
123 virtual void RecalcSnapRect() override;
125 virtual E3dScene* getRootE3dSceneFromE3dObject() const override;
126 void SetCamera(const Camera3D& rNewCamera);
127 const Camera3D& GetCamera() const { return aCamera; }
128 void removeAllNonSelectedObjects();
130 virtual E3dScene* CloneSdrObject(SdrModel& rTargetModel) const override;
131 E3dScene& operator=(const E3dScene&);
133 virtual SdrObjGeoData *NewGeoData() const override;
134 virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
135 virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
137 virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix) override;
138 virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix) override;
140 virtual void NbcRotate(const Point& rRef, long nAngle, double sn, double cs) override;
141 void RotateScene(const Point& rRef, double sn, double cs);
143 // TakeObjName...() is for the display in the UI, for example "3 frames selected".
144 virtual OUString TakeObjNameSingul() const override;
145 virtual OUString TakeObjNamePlural() const override;
147 // get transformations
148 B3dCamera& GetCameraSet() { return aCameraSet; }
149 const B3dCamera& GetCameraSet() const { return aCameraSet; }
151 // break up
152 virtual bool IsBreakObjPossible() override;
154 // polygon which is built during creation
155 virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
157 // create moves
158 virtual bool BegCreate(SdrDragStat& rStat) override;
159 virtual bool MovCreate(SdrDragStat& rStat) override; // true=Xor must be repainted
160 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
161 virtual bool BckCreate(SdrDragStat& rStat) override;
162 virtual void BrkCreate(SdrDragStat& rStat) override;
164 void SuspendReportingDirtyRects();
165 void ResumeReportingDirtyRects();
166 void SetAllSceneRectsDirty();
168 // set selection from E3dObject (temporary flag for 3D actions)
169 virtual void SetSelected(bool bNew) override;
171 // derived from SdrObjList
172 virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override;
173 virtual void InsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override;
174 virtual SdrObject* NbcRemoveObject(size_t nObjNum) override;
175 virtual SdrObject* RemoveObject(size_t nObjNum) override;
177 // needed for group functionality
178 virtual void SetRectsDirty(bool bNotMyself = false, bool bRecursive = true) override;
179 virtual void NbcSetLayer(SdrLayerID nLayer) override;
181 // react on model/page change
182 virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
184 virtual SdrObjList* GetSubList() const override;
185 virtual void SetTransformChanged() override;
187 protected:
188 virtual basegfx::B3DRange RecalcBoundVolume() const override;
191 #endif // INCLUDED_SVX_SCENE3D_HXX
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */