LibreOffice Module svx (master) 1
scene3d.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SVX_SCENE3D_HXX
21#define INCLUDED_SVX_SCENE3D_HXX
22
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>
30
31namespace sdr::properties {
32 class BaseProperties;
33}
34
35/*************************************************************************
36|*
37|* GeoData relevant for undo actions
38|*
39\************************************************************************/
40
41class E3DSceneGeoData final : public E3DObjGeoData
42{
43public:
45
47};
48
50
51/*************************************************************************
52|*
53|* base class for 3D scenes
54|*
55\************************************************************************/
56
57class SVXCORE_DLLPUBLIC E3dScene final : public E3dObject, public SdrObjList
58{
59 virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
60 virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
61
62 // transformations
65
66 mutable std::unique_ptr<Imp3DDepthRemapper> mp3DDepthRemapper;
67
68 // Flag to determine if only selected objects should be drawn
70
72
73 void RebuildLists();
74
75 virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override;
76
77 void SetDefaultAttributes();
78 void ImpCleanup3DDepthMapper();
79
80public:
81 E3dScene(SdrModel& rSdrModel);
82 E3dScene(SdrModel& rSdrModel, E3dScene const &);
83 virtual ~E3dScene() override;
84
85 virtual void StructureChanged() override;
86
87 // derived from SdrObjList
88 virtual SdrPage* getSdrPageFromSdrObjList() const override;
89 virtual SdrObject* getSdrObjectFromSdrObjList() const override;
90
91 // derived from SdrObject
92 virtual SdrObjList* getChildrenOfSdrObject() const override;
93
94 virtual void SetBoundRectDirty() override;
95
96 virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
97
98 sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
99
100 // Perspective: enum ProjectionType { ProjectionType::Parallel, ProjectionType::Perspective }
102 { return static_cast<ProjectionType>(GetObjectItemSet().Get(SDRATTR_3DSCENE_PERSPECTIVE).GetValue()); }
103
104 // Distance:
105 double GetDistance() const
106 { return static_cast<double>(GetObjectItemSet().Get(SDRATTR_3DSCENE_DISTANCE).GetValue()); }
107
108 // Focal length: before cm, now 1/10th mm (*100)
109 double GetFocalLength() const
110 { return GetObjectItemSet().Get(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue(); }
111
112 // set flag to draw only selected
113 void SetDrawOnlySelected(bool bNew) { bDrawOnlySelected = bNew; }
114 bool GetDrawOnlySelected() const { return bDrawOnlySelected; }
115 virtual SdrObjKind GetObjIdentifier() const override;
116
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;
122
123 virtual E3dScene* getRootE3dSceneFromE3dObject() const override;
124 void SetCamera(const Camera3D& rNewCamera);
125 const Camera3D& GetCamera() const { return aCamera; }
126 void removeAllNonSelectedObjects();
127
128 virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
129
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;
133
134 virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix) override;
135 virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix) override;
136
137 virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override;
138 void RotateScene(const Point& rRef, double sn, double cs);
139
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;
143
144 // get transformations
145 B3dCamera& GetCameraSet() { return aCameraSet; }
146 const B3dCamera& GetCameraSet() const { return aCameraSet; }
147
148 // break up
149 virtual bool IsBreakObjPossible() override;
150
151 // polygon which is built during creation
152 virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
153
154 // create moves
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;
160
161 void SuspendReportingDirtyRects();
162 void ResumeReportingDirtyRects();
163 void SetAllSceneRectsDirty();
164
165 // set selection from E3dObject (temporary flag for 3D actions)
166 virtual void SetSelected(bool bNew) override;
167
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;
173
174 // needed for group functionality
175 virtual void SetBoundAndSnapRectsDirty(bool bNotMyself = false, bool bRecursive = true) override;
176 virtual void NbcSetLayer(SdrLayerID nLayer) override;
177
178 // react on model/page change
179 virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
180
181 virtual SdrObjList* GetSubList() const override;
182 virtual void SetTransformChanged() override;
183
184private:
185 virtual basegfx::B3DRange RecalcBoundVolume() const override;
186};
187
188#endif // INCLUDED_SVX_SCENE3D_HXX
189
190/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Camera3D aCamera
Definition: scene3d.hxx:44
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs) override
Definition: obj3d.cxx:430
virtual void StructureChanged()
Definition: obj3d.cxx:254
virtual void SetTransformChanged()
Definition: obj3d.cxx:326
virtual void SetTransform(const basegfx::B3DHomMatrix &rMatrix)
Definition: obj3d.cxx:364
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const override
Definition: obj3d.cxx:400
virtual basegfx::B3DRange RecalcBoundVolume() const
Definition: obj3d.cxx:284
virtual void NbcMove(const Size &rSize) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: obj3d.cxx:194
virtual void NbcSetTransform(const basegfx::B3DHomMatrix &rMatrix)
Definition: obj3d.cxx:353
virtual E3dScene * getRootE3dSceneFromE3dObject() const
Definition: obj3d.cxx:271
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: obj3d.cxx:142
virtual void SetSelected(bool bNew)
Definition: obj3d.cxx:84
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: obj3d.cxx:410
virtual void RestoreGeoData(const SdrObjGeoData &rGeo) override
Definition: obj3d.cxx:418
virtual OUString TakeObjNamePlural() const override
Definition: obj3d.cxx:395
virtual SdrObjKind GetObjIdentifier() const override
Definition: obj3d.cxx:108
virtual OUString TakeObjNameSingul() const override
Definition: obj3d.cxx:382
virtual std::unique_ptr< SdrObjGeoData > NewGeoData() const override
A derived class must override these 3 methods if it has own geometric data that must be saved for Und...
Definition: obj3d.cxx:405
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: obj3d.cxx:46
virtual void RecalcSnapRect() override
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: obj3d.cxx:247
virtual bool IsBreakObjPossible()
Definition: obj3d.cxx:93
const B3dCamera & GetCameraSet() const
Definition: scene3d.hxx:146
Camera3D aCamera
Definition: scene3d.hxx:64
bool bDrawOnlySelected
Definition: scene3d.hxx:69
B3dCamera & GetCameraSet()
Definition: scene3d.hxx:145
bool GetDrawOnlySelected() const
Definition: scene3d.hxx:114
bool mbSkipSettingDirty
Definition: scene3d.hxx:71
B3dCamera aCameraSet
Definition: scene3d.hxx:63
double GetFocalLength() const
Definition: scene3d.hxx:109
ProjectionType GetPerspective() const
Definition: scene3d.hxx:101
double GetDistance() const
Definition: scene3d.hxx:105
std::unique_ptr< Imp3DDepthRemapper > mp3DDepthRemapper
Definition: scene3d.hxx:66
void SetDrawOnlySelected(bool bNew)
Definition: scene3d.hxx:113
const Camera3D & GetCamera() const
Definition: scene3d.hxx:125
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Detects when a stylesheet is changed.
Definition: svdoattr.cxx:61
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:174
virtual SdrPage * getSdrPageFromSdrObjList() const
Definition: svdpage.cxx:122
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:295
virtual void NbcInsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:244
virtual rtl::Reference< SdrObject > NbcRemoveObject(size_t nObjNum)
remove from list without delete
Definition: svdpage.cxx:334
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum)
Definition: svdpage.cxx:373
virtual SdrObject * getSdrObjectFromSdrObjList() const
Definition: svdpage.cxx:128
Abstract DrawObject.
Definition: svdobj.hxx:260
virtual bool BckCreate(SdrDragStat &rStat)
Definition: svdobj.cxx:1417
virtual void NbcSetLayer(SdrLayerID nLayer)
Definition: svdobj.cxx:664
virtual bool BegCreate(SdrDragStat &rStat)
Every object must be able to create itself interactively.
Definition: svdobj.cxx:1383
virtual basegfx::B2DPolyPolygon TakeXorPoly() const
The Xor-Polygon is required by the View to drag the object.
Definition: svdobj.cxx:1131
virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat &rDrag) const
Polygon dragged by the user when creating the object.
Definition: svdobj.cxx:1422
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:717
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage)
Definition: svdobj.cxx:523
virtual bool MovCreate(SdrDragStat &rStat)
Definition: svdobj.cxx:1393
virtual void NbcSetSnapRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1667
virtual SdrObjList * getChildrenOfSdrObject() const
Definition: svdobj.cxx:323
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact()
Definition: svdobj.cxx:256
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd)
Definition: svdobj.cxx:1403
virtual void BrkCreate(SdrDragStat &rStat)
Definition: svdobj.cxx:1413
virtual void SetBoundRectDirty()
Definition: svdobj.cxx:329
virtual void SetBoundAndSnapRectsDirty(bool bNotMyself=false, bool bRecursive=true)
Definition: svdobj.cxx:509
const SfxItemSet & GetObjectItemSet() const
Definition: svdobj.cxx:1969
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:379
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr TypedWhichId< Svx3DPerspectiveItem > SDRATTR_3DSCENE_PERSPECTIVE(SDRATTR_3DSCENE_FIRST+0)
constexpr TypedWhichId< SfxUInt32Item > SDRATTR_3DSCENE_FOCAL_LENGTH(SDRATTR_3DSCENE_FIRST+2)
constexpr TypedWhichId< SfxUInt32Item > SDRATTR_3DSCENE_DISTANCE(SDRATTR_3DSCENE_FIRST+1)
SdrObjKind
Definition: svdobjkind.hxx:25
SdrCreateCmd
Definition: svdtypes.hxx:27
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
ProjectionType
Definition: viewpt3d.hxx:38