Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / scene3d.hxx
blob83ecca16b1f5f5985b0115bcd95027a4bb4568a9
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/svxdllapi.h>
26 #include <svx/obj3d.hxx>
28 namespace sdr { namespace properties {
29 class BaseProperties;
30 class E3dSceneProperties;
33 namespace drawinglayer { namespace geometry {
34 class ViewInformation3D;
37 /*************************************************************************
39 |* GeoData relevant for undo actions
41 \************************************************************************/
43 class E3DSceneGeoData : public E3DObjGeoData
45 public:
46 Camera3D aCamera;
48 E3DSceneGeoData() {}
51 class Imp3DDepthRemapper;
53 /*************************************************************************
55 |* base class for 3D scenes
57 \************************************************************************/
59 class SVX_DLLPUBLIC E3dScene : public E3dObject
61 private:
62 // to allow sdr::properties::E3dSceneProperties access to StructureChanged()
63 friend class sdr::properties::E3dSceneProperties;
65 protected:
66 virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override;
67 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
69 // transformations
70 B3dCamera aCameraSet;
71 Camera3D aCamera;
73 Imp3DDepthRemapper* mp3DDepthRemapper;
75 // Flag to determine if only selected objects should be drawn
76 bool bDrawOnlySelected : 1;
78 virtual void NewObjectInserted(const E3dObject* p3DObj) override;
79 virtual void StructureChanged() override;
81 void RebuildLists();
83 virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override;
85 protected:
86 void SetDefaultAttributes();
88 void ImpCleanup3DDepthMapper();
90 public:
91 E3dScene();
92 virtual ~E3dScene() override;
94 virtual void SetBoundRectDirty() override;
96 // access to cleanup of depth mapper
97 void Cleanup3DDepthMapper() { ImpCleanup3DDepthMapper(); }
99 virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
101 sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
103 // Perspective: enum ProjectionType { ProjectionType::Parallel, ProjectionType::Perspective }
104 ProjectionType GetPerspective() const
105 { return (ProjectionType) static_cast<const Svx3DPerspectiveItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_PERSPECTIVE)).GetValue(); }
107 // Distance:
108 double GetDistance() const
109 { return (double)static_cast<const SfxUInt32Item&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_DISTANCE)).GetValue(); }
111 // Focal length: before cm, now 1/10th mm (*100)
112 double GetFocalLength() const
113 { return static_cast<const SfxUInt32Item&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue(); }
115 // set flag to draw only selected
116 void SetDrawOnlySelected(bool bNew) { bDrawOnlySelected = bNew; }
117 bool GetDrawOnlySelected() const { return bDrawOnlySelected; }
118 virtual sal_uInt16 GetObjIdentifier() const override;
120 virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
121 virtual void NbcMove(const Size& rSize) override;
122 virtual void NbcResize(const Point& rRef, const Fraction& rXFact,
123 const Fraction& rYFact) override;
124 virtual void RecalcSnapRect() override;
126 virtual E3dScene* GetScene() const override;
127 void SetCamera(const Camera3D& rNewCamera);
128 const Camera3D& GetCamera() const { return aCamera; }
129 void removeAllNonSelectedObjects();
131 virtual E3dScene* Clone() const override;
132 E3dScene& operator=(const E3dScene&);
134 virtual SdrObjGeoData *NewGeoData() const override;
135 virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
136 virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
138 virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix) override;
139 virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix) override;
141 virtual void NbcRotate(const Point& rRef, long nAngle, double sn, double cs) override;
142 void RotateScene(const Point& rRef, double sn, double cs);
144 // TakeObjName...() is for the display in the UI, for example "3 frames selected".
145 virtual OUString TakeObjNameSingul() const override;
146 virtual OUString TakeObjNamePlural() const override;
148 // get transformations
149 B3dCamera& GetCameraSet() { return aCameraSet; }
150 const B3dCamera& GetCameraSet() const { return aCameraSet; }
152 // break up
153 virtual bool IsBreakObjPossible() override;
155 // polygon which is built during creation
156 virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
158 // create moves
159 virtual bool BegCreate(SdrDragStat& rStat) override;
160 virtual bool MovCreate(SdrDragStat& rStat) override; // true=Xor must be repainted
161 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
162 virtual bool BckCreate(SdrDragStat& rStat) override;
163 virtual void BrkCreate(SdrDragStat& rStat) override;
166 #endif // INCLUDED_SVX_SCENE3D_HXX
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */