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 _E3D_SCENE3D_HXX
21 #define _E3D_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
{
30 class E3dSceneProperties
;
33 namespace drawinglayer
{ namespace geometry
{
34 class ViewInformation3D
;
37 /*************************************************************************
39 |* GeoData relevant for undo actions
41 \************************************************************************/
43 class E3DSceneGeoData
: public E3DObjGeoData
51 class Imp3DDepthRemapper
;
53 /*************************************************************************
55 |* base class for 3D scenes
57 \************************************************************************/
59 class SVX_DLLPUBLIC E3dScene
: public E3dObject
62 // to allow sdr::properties::E3dSceneProperties access to StructureChanged()
63 friend class sdr::properties::E3dSceneProperties
;
66 virtual sdr::properties::BaseProperties
* CreateObjectSpecificProperties();
67 virtual sdr::contact::ViewContact
* CreateObjectSpecificViewContact();
73 Imp3DDepthRemapper
* mp3DDepthRemapper
;
75 // Flag to determine if only selected objects should be drawn
76 unsigned bDrawOnlySelected
: 1;
78 virtual void NewObjectInserted(const E3dObject
* p3DObj
);
79 virtual void StructureChanged();
83 virtual void Notify(SfxBroadcaster
&rBC
, const SfxHint
&rHint
);
86 void SetDefaultAttributes(E3dDefaultAttributes
& rDefault
);
88 void ImpCleanup3DDepthMapper();
93 E3dScene(E3dDefaultAttributes
& rDefault
);
96 virtual void SetBoundRectDirty();
98 // access to cleanup of depth mapper
99 void Cleanup3DDepthMapper() { ImpCleanup3DDepthMapper(); }
101 virtual basegfx::B2DPolyPolygon
TakeXorPoly() const;
103 sal_uInt32
RemapOrdNum(sal_uInt32 nOrdNum
) const;
105 // Perspective: enum ProjectionType { PR_PARALLEL, PR_PERSPECTIVE }
106 ProjectionType
GetPerspective() const
107 { return (ProjectionType
)((const Svx3DPerspectiveItem
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_PERSPECTIVE
)).GetValue(); }
110 double GetDistance() const
111 { return (double)((const Svx3DDistanceItem
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_DISTANCE
)).GetValue(); }
113 // Focal length: before cm, now 1/10th mm (*100)
114 double GetFocalLength() const
115 { return ((const Svx3DFocalLengthItem
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_FOCAL_LENGTH
)).GetValue(); }
117 // Two sided lighting:
118 sal_Bool
GetTwoSidedLighting() const
119 { return ((const Svx3DTwoSidedLightingItem
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING
)).GetValue(); }
122 Color
GetLightColor1() const
123 { return ((const Svx3DLightcolor1Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_1
)).GetValue(); }
124 Color
GetLightColor2() const
125 { return ((const Svx3DLightcolor2Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_2
)).GetValue(); }
126 Color
GetLightColor3() const
127 { return ((const Svx3DLightcolor3Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_3
)).GetValue(); }
128 Color
GetLightColor4() const
129 { return ((const Svx3DLightcolor4Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_4
)).GetValue(); }
130 Color
GetLightColor5() const
131 { return ((const Svx3DLightcolor5Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_5
)).GetValue(); }
132 Color
GetLightColor6() const
133 { return ((const Svx3DLightcolor6Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_6
)).GetValue(); }
134 Color
GetLightColor7() const
135 { return ((const Svx3DLightcolor7Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_7
)).GetValue(); }
136 Color
GetLightColor8() const
137 { return ((const Svx3DLightcolor8Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_8
)).GetValue(); }
140 Color
GetGlobalAmbientColor() const
141 { return ((const Svx3DAmbientcolorItem
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_AMBIENTCOLOR
)).GetValue(); }
144 sal_Bool
GetLightOnOff1() const
145 { return ((const Svx3DLightOnOff1Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_1
)).GetValue(); }
146 sal_Bool
GetLightOnOff2() const
147 { return ((const Svx3DLightOnOff2Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_2
)).GetValue(); }
148 sal_Bool
GetLightOnOff3() const
149 { return ((const Svx3DLightOnOff3Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_3
)).GetValue(); }
150 sal_Bool
GetLightOnOff4() const
151 { return ((const Svx3DLightOnOff4Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_4
)).GetValue(); }
152 sal_Bool
GetLightOnOff5() const
153 { return ((const Svx3DLightOnOff5Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_5
)).GetValue(); }
154 sal_Bool
GetLightOnOff6() const
155 { return ((const Svx3DLightOnOff6Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_6
)).GetValue(); }
156 sal_Bool
GetLightOnOff7() const
157 { return ((const Svx3DLightOnOff7Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_7
)).GetValue(); }
158 sal_Bool
GetLightOnOff8() const
159 { return ((const Svx3DLightOnOff8Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_8
)).GetValue(); }
162 basegfx::B3DVector
GetLightDirection1() const
163 { return ((const Svx3DLightDirection1Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1
)).GetValue(); }
164 basegfx::B3DVector
GetLightDirection2() const
165 { return ((const Svx3DLightDirection2Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2
)).GetValue(); }
166 basegfx::B3DVector
GetLightDirection3() const
167 { return ((const Svx3DLightDirection3Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3
)).GetValue(); }
168 basegfx::B3DVector
GetLightDirection4() const
169 { return ((const Svx3DLightDirection4Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4
)).GetValue(); }
170 basegfx::B3DVector
GetLightDirection5() const
171 { return ((const Svx3DLightDirection5Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5
)).GetValue(); }
172 basegfx::B3DVector
GetLightDirection6() const
173 { return ((const Svx3DLightDirection6Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6
)).GetValue(); }
174 basegfx::B3DVector
GetLightDirection7() const
175 { return ((const Svx3DLightDirection7Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7
)).GetValue(); }
176 basegfx::B3DVector
GetLightDirection8() const
177 { return ((const Svx3DLightDirection8Item
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8
)).GetValue(); }
180 sal_uInt16
GetShadowSlant() const
181 { return ((const Svx3DShadowSlantItem
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_SHADOW_SLANT
)).GetValue(); }
183 // ShadeMode: 0 == FLAT, 1 == PHONG, 2 == SMOOTH, 3 == ForceDraft
184 sal_uInt16
GetShadeMode() const
185 { return ((const Svx3DShadeModeItem
&)GetObjectItemSet().Get(SDRATTR_3DSCENE_SHADE_MODE
)).GetValue(); }
187 // set flag to draw only selected
188 void SetDrawOnlySelected(sal_Bool bNew
) { bDrawOnlySelected
= bNew
; }
189 bool GetDrawOnlySelected() const { return bDrawOnlySelected
; }
190 virtual sal_uInt16
GetObjIdentifier() const;
192 virtual void NbcSetSnapRect(const Rectangle
& rRect
);
193 virtual void NbcMove(const Size
& rSize
);
194 virtual void NbcResize(const Point
& rRef
, const Fraction
& rXFact
,
195 const Fraction
& rYFact
);
196 virtual void RecalcSnapRect();
198 virtual E3dScene
* GetScene() const;
199 void SetCamera(const Camera3D
& rNewCamera
);
200 const Camera3D
& GetCamera() const { return aCamera
; }
201 void removeAllNonSelectedObjects();
203 virtual E3dScene
* Clone() const;
204 E3dScene
& operator=(const E3dScene
&);
206 virtual SdrObjGeoData
*NewGeoData() const;
207 virtual void SaveGeoData(SdrObjGeoData
& rGeo
) const;
208 virtual void RestGeoData(const SdrObjGeoData
& rGeo
);
210 virtual void NbcSetTransform(const basegfx::B3DHomMatrix
& rMatrix
);
211 virtual void SetTransform(const basegfx::B3DHomMatrix
& rMatrix
);
213 virtual void NbcRotate(const Point
& rRef
, long nWink
, double sn
, double cs
);
214 void RotateScene(const Point
& rRef
, long nWink
, double sn
, double cs
);
216 // TakeObjName...() is for the display in the UI, for example "3 frames selected".
217 virtual void TakeObjNameSingul(String
& rName
) const;
218 virtual void TakeObjNamePlural(String
& rName
) const;
220 // get transformations
221 B3dCamera
& GetCameraSet() { return aCameraSet
; }
224 virtual bool IsBreakObjPossible();
226 // polygon which is built during creation
227 virtual basegfx::B2DPolyPolygon
TakeCreatePoly(const SdrDragStat
& rDrag
) const;
230 virtual bool BegCreate(SdrDragStat
& rStat
);
231 virtual bool MovCreate(SdrDragStat
& rStat
); // true=Xor muss repainted werden
232 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
);
233 virtual bool BckCreate(SdrDragStat
& rStat
);
234 virtual void BrkCreate(SdrDragStat
& rStat
);
237 #endif // _E3D_SCENE3D_HXX
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */