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_OBJ3D_HXX
21 #define _E3D_OBJ3D_HXX
23 #include <svx/svdoattr.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/def3d.hxx>
26 #include <svx/svdpage.hxx>
27 #include <svx/deflt3d.hxx>
28 #include <vcl/bitmap.hxx>
29 #include <svx/svx3ditems.hxx>
30 #include <svx/xflclit.hxx>
31 #include <svl/itemset.hxx>
32 #include <basegfx/range/b3drange.hxx>
33 #include <basegfx/polygon/b3dpolypolygon.hxx>
34 #include <basegfx/point/b2dpoint.hxx>
35 #include <basegfx/polygon/b2dpolygon.hxx>
36 #include <basegfx/vector/b2enums.hxx>
37 #include "svx/svxdllapi.h"
39 //************************************************************
40 // Forward declaration
41 //************************************************************
48 namespace basegfx
{ class B3DPolyPolygon
; }
49 namespace sdr
{ namespace properties
{
52 class E3dCompoundProperties
;
53 class E3dExtrudeProperties
;
54 class E3dLatheProperties
;
55 class E3dSphereProperties
;
58 /*************************************************************************
60 |* GeoData relevant for undo actions
62 \************************************************************************/
64 class E3DObjGeoData
: public SdrObjGeoData
67 basegfx::B3DRange maLocalBoundVol
; // surrounding volume of the object
68 basegfx::B3DHomMatrix maTransformation
; // lokal transformations
73 /*************************************************************************
75 |* List for 3D objects
77 \************************************************************************/
79 class E3dObjList
: public SdrObjList
83 E3dObjList(SdrModel
* pNewModel
= 0, SdrPage
* pNewPage
= 0, E3dObjList
* pNewUpList
= 0);
84 SVX_DLLPUBLIC
E3dObjList(const E3dObjList
& rSrcList
);
85 SVX_DLLPUBLIC
virtual ~E3dObjList();
87 virtual void NbcInsertObject(SdrObject
* pObj
, sal_uIntPtr nPos
=CONTAINER_APPEND
, const SdrInsertReason
* pReason
=NULL
);
88 virtual void InsertObject(SdrObject
* pObj
, sal_uIntPtr nPos
=CONTAINER_APPEND
, const SdrInsertReason
* pReason
=NULL
);
89 virtual SdrObject
* NbcRemoveObject(sal_uIntPtr nObjNum
);
90 virtual SdrObject
* RemoveObject(sal_uIntPtr nObjNum
);
93 /*************************************************************************
95 |* Base class for 3D objects
97 \************************************************************************/
99 class SVX_DLLPUBLIC E3dObject
: public SdrAttrObj
102 // to allow sdr::properties::E3dProperties access to StructureChanged()
103 friend class sdr::properties::E3dProperties
;
105 // Allow everything for E3dObjList and E3dDragMethod
106 friend class E3dObjList
;
107 friend class E3dDragMethod
;
110 virtual sdr::properties::BaseProperties
* CreateObjectSpecificProperties();
112 E3dObjList maSubList
; // child objects
114 basegfx::B3DRange maLocalBoundVol
; // surrounding volume of the object (from the geometry generation)
115 basegfx::B3DHomMatrix maTransformation
; // local transformation
116 basegfx::B3DHomMatrix maFullTransform
; // global transformation (including. parents)
119 unsigned mbTfHasChanged
: 1;
120 unsigned mbIsSelected
: 1;
123 void SetBoundVolInvalid();
126 void SetTransformChanged();
127 virtual void NewObjectInserted(const E3dObject
* p3DObj
);
128 virtual void StructureChanged();
129 basegfx::B3DRange
RecalcBoundVolume() const;
132 // E3dObject is only a helper class (for E3DScene and E3DCompoundObject)
133 // and no instances should be created from anyone, so i move the constructors
136 E3dObject(sal_Bool bIsFromChart
);
140 virtual void RecalcSnapRect();
141 virtual void SetRectsDirty(sal_Bool bNotMyself
= sal_False
);
143 virtual ~E3dObject();
145 virtual sal_uInt32
GetObjInventor() const;
146 virtual sal_uInt16
GetObjIdentifier() const;
148 virtual void TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const;
150 virtual void NbcSetLayer(SdrLayerID nLayer
);
152 virtual void SetObjList(SdrObjList
* pNewObjList
);
153 virtual void SetPage(SdrPage
* pNewPage
);
154 virtual void SetModel(SdrModel
* pNewModel
);
155 virtual void NbcMove(const Size
& rSize
);
156 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
);
157 virtual SdrObjList
* GetSubList() const;
159 // Insert 3D object into the group; transfer to other owner!
160 virtual void Insert3DObj(E3dObject
* p3DObj
);
161 void Remove3DObj(E3dObject
* p3DObj
);
163 E3dObject
* GetParentObj() const;
164 virtual E3dScene
* GetScene() const;
166 const basegfx::B3DRange
& GetBoundVolume() const;
167 void InvalidateBoundVolume();
169 // calculate complete transformation including all parents
170 const basegfx::B3DHomMatrix
& GetFullTransform() const;
172 // get and (re)set transformation matrix
173 const basegfx::B3DHomMatrix
& GetTransform() const;
174 virtual void NbcSetTransform(const basegfx::B3DHomMatrix
& rMatrix
);
175 virtual void SetTransform(const basegfx::B3DHomMatrix
& rMatrix
);
177 // 2D rotations, are implemented as a rotation around the Z axis
178 // which is vertical to the screen, plus a shift of the scene.
179 // This means that also the scene (E3dScene) must define this
180 // routine as virtual in its class.
181 virtual void NbcRotate(const Point
& rRef
, long nWink
, double sn
, double cs
);
183 // get wireframe polygon for local object. No transform is applied.
184 basegfx::B3DPolyPolygon
CreateWireframe() const;
186 // TakeObjName...() is for the display in the UI, for example "3 frames selected".
187 virtual void TakeObjNameSingul(String
& rName
) const;
188 virtual void TakeObjNamePlural(String
& rName
) const;
189 sal_uInt16
GetLogicalGroup() { return 0; }
190 virtual E3dObject
* Clone() const;
191 E3dObject
& operator=( const E3dObject
& rObj
);
193 virtual SdrObjGeoData
*NewGeoData() const;
194 virtual void SaveGeoData(SdrObjGeoData
& rGeo
) const;
195 virtual void RestGeoData(const SdrObjGeoData
& rGeo
);
197 // get/set the selection
198 bool GetSelected() const { return mbIsSelected
; }
199 void SetSelected(bool bNew
);
202 virtual bool IsBreakObjPossible();
203 virtual SdrAttrObj
* GetBreakObj();
206 /*************************************************************************
208 |* Class for all compound objects (Cube, Lathe, Scene, Extrude)
209 |* This class saves some ISA queries and accelerates the behaviour
210 |* significantly, because all the attributes etc. are kept through this.
211 |* The polygons may only keep attributes if they are directly
212 |* subordinated to the scene.
214 \************************************************************************/
216 class SVX_DLLPUBLIC E3dCompoundObject
: public E3dObject
219 // to allow sdr::properties::E3dCompoundProperties access to SetGeometryValid()
220 friend class sdr::properties::E3dCompoundProperties
;
221 friend class sdr::properties::E3dExtrudeProperties
;
222 friend class sdr::properties::E3dLatheProperties
;
223 friend class sdr::properties::E3dSphereProperties
;
226 virtual sdr::properties::BaseProperties
* CreateObjectSpecificProperties();
228 // material of the object
229 Color aMaterialAmbientColor
;
231 // attributes for geometry creation
232 unsigned bCreateNormals
: 1;
233 unsigned bCreateTexture
: 1;
236 void SetDefaultAttributes(E3dDefaultAttributes
& rDefault
);
238 // convert given basegfx::B3DPolyPolygon to screen coor
239 basegfx::B2DPolyPolygon
TransformToScreenCoor(const basegfx::B3DPolyPolygon
& rCandidate
);
245 E3dCompoundObject(E3dDefaultAttributes
& rDefault
);
246 virtual ~E3dCompoundObject();
248 virtual basegfx::B2DPolyPolygon
TakeXorPoly() const;
249 virtual sal_uInt32
GetHdlCount() const;
250 virtual void AddToHdlList(SdrHdlList
& rHdlList
) const;
252 // DoubleSided: sal_True/FALSE
253 sal_Bool
GetDoubleSided() const
254 { return ((const Svx3DDoubleSidedItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_DOUBLE_SIDED
)).GetValue(); }
256 // NormalsKind: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE
257 sal_uInt16
GetNormalsKind() const
258 { return ((const Svx3DNormalsKindItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_NORMALS_KIND
)).GetValue(); }
260 // NormalsInvert: sal_True/FALSE
261 sal_Bool
GetNormalsInvert() const
262 { return ((const Svx3DNormalsInvertItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_NORMALS_INVERT
)).GetValue(); }
264 // TextureProjX: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE
265 sal_uInt16
GetTextureProjectionX() const
266 { return ((const Svx3DTextureProjectionXItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X
)).GetValue(); }
268 // TextureProjY: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE
269 sal_uInt16
GetTextureProjectionY() const
270 { return ((const Svx3DTextureProjectionYItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y
)).GetValue(); }
272 // Shadow3D: sal_True/FALSE
273 sal_Bool
GetShadow3D() const
274 { return ((const Svx3DShadow3DItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_SHADOW_3D
)).GetValue(); }
276 // MaterialColor: Color
277 Color
GetMaterialColor() const
278 { return ((const Svx3DMaterialColorItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_COLOR
)).GetValue(); }
280 // MaterialEmission: Color
281 Color
GetMaterialEmission() const
282 { return ((const Svx3DMaterialEmissionItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_EMISSION
)).GetValue(); }
284 // MaterialSpecular: Color
285 Color
GetMaterialSpecular() const
286 { return ((const Svx3DMaterialSpecularItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR
)).GetValue(); }
288 // MaterialSpecularIntensity:
289 sal_uInt16
GetMaterialSpecularIntensity() const
290 { return ((const Svx3DMaterialSpecularIntensityItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY
)).GetValue(); }
292 // TextureFilter: sal_True/FALSE
293 sal_Bool
GetTextureFilter() const
294 { return ((const Svx3DTextureFilterItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_FILTER
)).GetValue(); }
297 // Added extra Item (Bool) for chart2 to be able to show reduced line geometry
298 sal_Bool
GetReducedLineGeometry() const
299 { return ((const Svx3DReducedLineGeometryItem
&)GetObjectItemSet().Get(SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY
)).GetValue(); }
301 virtual sal_uInt16
GetObjIdentifier() const;
302 virtual void RecalcSnapRect();
304 // set/get parameters for geometry creation
305 sal_Bool
GetCreateNormals() const { return bCreateNormals
; }
307 sal_Bool
GetCreateTexture() const { return bCreateTexture
; }
309 virtual E3dCompoundObject
* Clone() const;
311 // material of the object
312 const Color
& GetMaterialAmbientColor() const { return aMaterialAmbientColor
; }
314 bool IsAOrdNumRemapCandidate(E3dScene
*& prScene
) const;
317 #endif // _E3D_OBJ3D_HXX
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */