Line data Source code
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 _E3D_OBJ3D_HXX
21 : #define _E3D_OBJ3D_HXX
22 :
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"
38 :
39 : //************************************************************
40 : // Forward declaration
41 : //************************************************************
42 :
43 : class SfxPoolItem;
44 : class Viewport3D;
45 : class E3dScene;
46 : class E3dPolyScene;
47 :
48 : namespace basegfx { class B3DPolyPolygon; }
49 : namespace sdr { namespace properties {
50 : class BaseProperties;
51 : class E3dProperties;
52 : class E3dCompoundProperties;
53 : class E3dExtrudeProperties;
54 : class E3dLatheProperties;
55 : class E3dSphereProperties;
56 : }}
57 :
58 : /*************************************************************************
59 : |*
60 : |* GeoData relevant for undo actions
61 : |*
62 : \************************************************************************/
63 :
64 0 : class E3DObjGeoData : public SdrObjGeoData
65 : {
66 : public:
67 : basegfx::B3DRange maLocalBoundVol; // surrounding volume of the object
68 : basegfx::B3DHomMatrix maTransformation; // lokal transformations
69 :
70 0 : E3DObjGeoData() {}
71 : };
72 :
73 : /*************************************************************************
74 : |*
75 : |* List for 3D objects
76 : |*
77 : \************************************************************************/
78 :
79 : class E3dObjList : public SdrObjList
80 : {
81 : public:
82 : TYPEINFO();
83 : E3dObjList(SdrModel* pNewModel = 0, SdrPage* pNewPage = 0, E3dObjList* pNewUpList = 0);
84 : SVX_DLLPUBLIC E3dObjList(const E3dObjList& rSrcList);
85 : SVX_DLLPUBLIC virtual ~E3dObjList();
86 :
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);
91 : };
92 :
93 : /*************************************************************************
94 : |*
95 : |* Base class for 3D objects
96 : |*
97 : \************************************************************************/
98 :
99 : class SVX_DLLPUBLIC E3dObject : public SdrAttrObj
100 : {
101 : private:
102 : // to allow sdr::properties::E3dProperties access to StructureChanged()
103 : friend class sdr::properties::E3dProperties;
104 :
105 : // Allow everything for E3dObjList and E3dDragMethod
106 : friend class E3dObjList;
107 : friend class E3dDragMethod;
108 :
109 : protected:
110 : virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
111 :
112 : E3dObjList maSubList; // child objects
113 :
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)
117 :
118 : // Flags
119 : unsigned mbTfHasChanged : 1;
120 : unsigned mbIsSelected : 1;
121 :
122 : public:
123 : void SetBoundVolInvalid();
124 :
125 : protected:
126 : void SetTransformChanged();
127 : virtual void NewObjectInserted(const E3dObject* p3DObj);
128 : virtual void StructureChanged();
129 : basegfx::B3DRange RecalcBoundVolume() const;
130 :
131 : protected:
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
134 : // to protected area
135 : E3dObject();
136 : E3dObject(sal_Bool bIsFromChart);
137 :
138 : public:
139 : TYPEINFO();
140 : virtual void RecalcSnapRect();
141 : virtual void SetRectsDirty(sal_Bool bNotMyself = sal_False);
142 :
143 : virtual ~E3dObject();
144 :
145 : virtual sal_uInt32 GetObjInventor() const;
146 : virtual sal_uInt16 GetObjIdentifier() const;
147 :
148 : virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
149 :
150 : virtual void NbcSetLayer(SdrLayerID nLayer);
151 :
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;
158 :
159 : // Insert 3D object into the group; transfer to other owner!
160 : virtual void Insert3DObj(E3dObject* p3DObj);
161 : void Remove3DObj(E3dObject* p3DObj);
162 :
163 : E3dObject* GetParentObj() const;
164 : virtual E3dScene* GetScene() const;
165 :
166 : const basegfx::B3DRange& GetBoundVolume() const;
167 : void InvalidateBoundVolume();
168 :
169 : // calculate complete transformation including all parents
170 : const basegfx::B3DHomMatrix& GetFullTransform() const;
171 :
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);
176 :
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);
182 :
183 : // get wireframe polygon for local object. No transform is applied.
184 : basegfx::B3DPolyPolygon CreateWireframe() const;
185 :
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 );
192 :
193 : virtual SdrObjGeoData *NewGeoData() const;
194 : virtual void SaveGeoData(SdrObjGeoData& rGeo) const;
195 : virtual void RestGeoData(const SdrObjGeoData& rGeo);
196 :
197 : // get/set the selection
198 0 : bool GetSelected() const { return mbIsSelected; }
199 : void SetSelected(bool bNew);
200 :
201 : // break up
202 : virtual bool IsBreakObjPossible();
203 : virtual SdrAttrObj* GetBreakObj();
204 : };
205 :
206 : /*************************************************************************
207 : |*
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.
213 : |*
214 : \************************************************************************/
215 :
216 0 : class SVX_DLLPUBLIC E3dCompoundObject : public E3dObject
217 : {
218 : private:
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;
224 :
225 : protected:
226 : virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
227 :
228 : // material of the object
229 : Color aMaterialAmbientColor;
230 :
231 : // attributes for geometry creation
232 : unsigned bCreateNormals : 1;
233 : unsigned bCreateTexture : 1;
234 :
235 : protected:
236 : void SetDefaultAttributes(E3dDefaultAttributes& rDefault);
237 :
238 : // convert given basegfx::B3DPolyPolygon to screen coor
239 : basegfx::B2DPolyPolygon TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate);
240 :
241 : public :
242 : TYPEINFO();
243 :
244 : E3dCompoundObject();
245 : E3dCompoundObject(E3dDefaultAttributes& rDefault);
246 : virtual ~E3dCompoundObject();
247 :
248 : virtual basegfx::B2DPolyPolygon TakeXorPoly() const;
249 : virtual sal_uInt32 GetHdlCount() const;
250 : virtual void AddToHdlList(SdrHdlList& rHdlList) const;
251 :
252 : // DoubleSided: sal_True/FALSE
253 : sal_Bool GetDoubleSided() const
254 : { return ((const Svx3DDoubleSidedItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_DOUBLE_SIDED)).GetValue(); }
255 :
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(); }
259 :
260 : // NormalsInvert: sal_True/FALSE
261 : sal_Bool GetNormalsInvert() const
262 : { return ((const Svx3DNormalsInvertItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_NORMALS_INVERT)).GetValue(); }
263 :
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(); }
267 :
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(); }
271 :
272 : // Shadow3D: sal_True/FALSE
273 : sal_Bool GetShadow3D() const
274 : { return ((const Svx3DShadow3DItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_SHADOW_3D)).GetValue(); }
275 :
276 : // MaterialColor: Color
277 : Color GetMaterialColor() const
278 : { return ((const Svx3DMaterialColorItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_COLOR)).GetValue(); }
279 :
280 : // MaterialEmission: Color
281 : Color GetMaterialEmission() const
282 : { return ((const Svx3DMaterialEmissionItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_EMISSION)).GetValue(); }
283 :
284 : // MaterialSpecular: Color
285 : Color GetMaterialSpecular() const
286 : { return ((const Svx3DMaterialSpecularItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR)).GetValue(); }
287 :
288 : // MaterialSpecularIntensity:
289 : sal_uInt16 GetMaterialSpecularIntensity() const
290 : { return ((const Svx3DMaterialSpecularIntensityItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY)).GetValue(); }
291 :
292 : // TextureFilter: sal_True/FALSE
293 : sal_Bool GetTextureFilter() const
294 : { return ((const Svx3DTextureFilterItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_FILTER)).GetValue(); }
295 :
296 : // #i28528#
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(); }
300 :
301 : virtual sal_uInt16 GetObjIdentifier() const;
302 : virtual void RecalcSnapRect();
303 :
304 : // set/get parameters for geometry creation
305 : sal_Bool GetCreateNormals() const { return bCreateNormals; }
306 :
307 : sal_Bool GetCreateTexture() const { return bCreateTexture; }
308 :
309 : virtual E3dCompoundObject* Clone() const;
310 :
311 : // material of the object
312 : const Color& GetMaterialAmbientColor() const { return aMaterialAmbientColor; }
313 :
314 : bool IsAOrdNumRemapCandidate(E3dScene*& prScene) const;
315 : };
316 :
317 : #endif // _E3D_OBJ3D_HXX
318 :
319 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|