Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / scene3d.hxx
blobaa24245a19488d0b624623768f2dd3c77e17de73
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() SAL_OVERRIDE;
67 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() SAL_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) SAL_OVERRIDE;
79 virtual void StructureChanged() SAL_OVERRIDE;
81 void RebuildLists();
83 virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) SAL_OVERRIDE;
85 protected:
86 void SetDefaultAttributes(E3dDefaultAttributes& rDefault);
88 void ImpCleanup3DDepthMapper();
90 public:
91 TYPEINFO_OVERRIDE();
92 E3dScene();
93 E3dScene(E3dDefaultAttributes& rDefault);
94 virtual ~E3dScene();
96 virtual void SetBoundRectDirty() SAL_OVERRIDE;
98 // access to cleanup of depth mapper
99 void Cleanup3DDepthMapper() { ImpCleanup3DDepthMapper(); }
101 virtual basegfx::B2DPolyPolygon TakeXorPoly() const SAL_OVERRIDE;
103 sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
105 // Perspective: enum ProjectionType { PR_PARALLEL, PR_PERSPECTIVE }
106 ProjectionType GetPerspective() const
107 { return (ProjectionType) static_cast<const Svx3DPerspectiveItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_PERSPECTIVE)).GetValue(); }
109 // Distance:
110 double GetDistance() const
111 { return (double)static_cast<const SfxUInt32Item&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_DISTANCE)).GetValue(); }
113 // Focal length: before cm, now 1/10th mm (*100)
114 double GetFocalLength() const
115 { return static_cast<const SfxUInt32Item&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue(); }
117 // Two sided lighting:
118 bool GetTwoSidedLighting() const
119 { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING)).GetValue(); }
121 // Lightcolor:
122 Color GetLightColor1() const
123 { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue(); }
124 Color GetLightColor2() const
125 { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue(); }
126 Color GetLightColor3() const
127 { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue(); }
128 Color GetLightColor4() const
129 { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue(); }
130 Color GetLightColor5() const
131 { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue(); }
132 Color GetLightColor6() const
133 { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue(); }
134 Color GetLightColor7() const
135 { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue(); }
136 Color GetLightColor8() const
137 { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue(); }
139 // Ambient color:
140 Color GetGlobalAmbientColor() const
141 { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_AMBIENTCOLOR)).GetValue(); }
143 // Light on/off:
144 bool GetLightOnOff1() const
145 { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue(); }
146 bool GetLightOnOff2() const
147 { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue(); }
148 bool GetLightOnOff3() const
149 { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue(); }
150 bool GetLightOnOff4() const
151 { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue(); }
152 bool GetLightOnOff5() const
153 { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue(); }
154 bool GetLightOnOff6() const
155 { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue(); }
156 bool GetLightOnOff7() const
157 { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue(); }
158 bool GetLightOnOff8() const
159 { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue(); }
161 // Light direction:
162 basegfx::B3DVector GetLightDirection1() const
163 { return static_cast<const SvxB3DVectorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue(); }
164 basegfx::B3DVector GetLightDirection2() const
165 { return static_cast<const SvxB3DVectorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue(); }
166 basegfx::B3DVector GetLightDirection3() const
167 { return static_cast<const SvxB3DVectorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue(); }
168 basegfx::B3DVector GetLightDirection4() const
169 { return static_cast<const SvxB3DVectorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue(); }
170 basegfx::B3DVector GetLightDirection5() const
171 { return static_cast<const SvxB3DVectorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue(); }
172 basegfx::B3DVector GetLightDirection6() const
173 { return static_cast<const SvxB3DVectorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue(); }
174 basegfx::B3DVector GetLightDirection7() const
175 { return static_cast<const SvxB3DVectorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue(); }
176 basegfx::B3DVector GetLightDirection8() const
177 { return static_cast<const SvxB3DVectorItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue(); }
179 // ShadowSlant:
180 sal_uInt16 GetShadowSlant() const
181 { return static_cast<const SfxUInt16Item&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_SHADOW_SLANT)).GetValue(); }
183 // ShadeMode: 0 == FLAT, 1 == PHONG, 2 == SMOOTH, 3 == ForceDraft
184 sal_uInt16 GetShadeMode() const
185 { return static_cast<const Svx3DShadeModeItem&>(GetObjectItemSet().Get(SDRATTR_3DSCENE_SHADE_MODE)).GetValue(); }
187 // set flag to draw only selected
188 void SetDrawOnlySelected(bool bNew) { bDrawOnlySelected = bNew; }
189 bool GetDrawOnlySelected() const { return bDrawOnlySelected; }
190 virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
192 virtual void NbcSetSnapRect(const Rectangle& rRect) SAL_OVERRIDE;
193 virtual void NbcMove(const Size& rSize) SAL_OVERRIDE;
194 virtual void NbcResize(const Point& rRef, const Fraction& rXFact,
195 const Fraction& rYFact) SAL_OVERRIDE;
196 virtual void RecalcSnapRect() SAL_OVERRIDE;
198 virtual E3dScene* GetScene() const SAL_OVERRIDE;
199 void SetCamera(const Camera3D& rNewCamera);
200 const Camera3D& GetCamera() const { return aCamera; }
201 void removeAllNonSelectedObjects();
203 virtual E3dScene* Clone() const SAL_OVERRIDE;
204 E3dScene& operator=(const E3dScene&);
206 virtual SdrObjGeoData *NewGeoData() const SAL_OVERRIDE;
207 virtual void SaveGeoData(SdrObjGeoData& rGeo) const SAL_OVERRIDE;
208 virtual void RestGeoData(const SdrObjGeoData& rGeo) SAL_OVERRIDE;
210 virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix) SAL_OVERRIDE;
211 virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix) SAL_OVERRIDE;
213 virtual void NbcRotate(const Point& rRef, long nAngle, double sn, double cs) SAL_OVERRIDE;
214 void RotateScene(const Point& rRef, long nAngle, double sn, double cs);
216 // TakeObjName...() is for the display in the UI, for example "3 frames selected".
217 virtual OUString TakeObjNameSingul() const SAL_OVERRIDE;
218 virtual OUString TakeObjNamePlural() const SAL_OVERRIDE;
220 // get transformations
221 B3dCamera& GetCameraSet() { return aCameraSet; }
222 const B3dCamera& GetCameraSet() const { return aCameraSet; }
224 // break up
225 virtual bool IsBreakObjPossible() SAL_OVERRIDE;
227 // polygon which is built during creation
228 virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const SAL_OVERRIDE;
230 // create moves
231 virtual bool BegCreate(SdrDragStat& rStat) SAL_OVERRIDE;
232 virtual bool MovCreate(SdrDragStat& rStat) SAL_OVERRIDE; // true=Xor muss repainted werden
233 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
234 virtual bool BckCreate(SdrDragStat& rStat) SAL_OVERRIDE;
235 virtual void BrkCreate(SdrDragStat& rStat) SAL_OVERRIDE;
238 #endif // INCLUDED_SVX_SCENE3D_HXX
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */