Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _E3D_OBJ3D_HXX
30 : : #define _E3D_OBJ3D_HXX
31 : :
32 : : #include <svx/svdoattr.hxx>
33 : : #include <svx/svdobj.hxx>
34 : : #include <svx/volume3d.hxx>
35 : : #include <svx/def3d.hxx>
36 : : #include <svx/svdpage.hxx>
37 : : #include <svx/deflt3d.hxx>
38 : : #include <vcl/bitmap.hxx>
39 : : #include <svx/svx3ditems.hxx>
40 : : #include <svx/xflclit.hxx>
41 : : #include <svl/itemset.hxx>
42 : : #include <basegfx/polygon/b3dpolypolygon.hxx>
43 : : #include <basegfx/point/b2dpoint.hxx>
44 : : #include <basegfx/polygon/b2dpolygon.hxx>
45 : : #include <basegfx/vector/b2enums.hxx>
46 : : #include "svx/svxdllapi.h"
47 : :
48 : : //************************************************************
49 : : // Forward declaration
50 : : //************************************************************
51 : :
52 : : class SfxPoolItem;
53 : : class Viewport3D;
54 : : class E3dScene;
55 : : class E3dPolyScene;
56 : :
57 : : namespace basegfx { class B3DPolyPolygon; }
58 : : namespace sdr { namespace properties {
59 : : class BaseProperties;
60 : : class E3dProperties;
61 : : class E3dCompoundProperties;
62 : : class E3dExtrudeProperties;
63 : : class E3dLatheProperties;
64 : : class E3dSphereProperties;
65 : : }}
66 : :
67 : : /*************************************************************************
68 : : |*
69 : : |* GeoData relevant for undo actions
70 : : |*
71 : : \************************************************************************/
72 : :
73 [ # # ][ # # ]: 0 : class E3DObjGeoData : public SdrObjGeoData
74 : : {
75 : : public:
76 : : basegfx::B3DRange maLocalBoundVol; // surrounding volume of the object
77 : : basegfx::B3DHomMatrix maTransformation; // lokal transformations
78 : :
79 : : E3DObjGeoData() {}
80 : : };
81 : :
82 : : /*************************************************************************
83 : : |*
84 : : |* List for 3D objects
85 : : |*
86 : : \************************************************************************/
87 : :
88 : : class E3dObjList : public SdrObjList
89 : : {
90 : : public:
91 : : TYPEINFO();
92 : : E3dObjList(SdrModel* pNewModel = 0, SdrPage* pNewPage = 0, E3dObjList* pNewUpList = 0);
93 : : SVX_DLLPUBLIC E3dObjList(const E3dObjList& rSrcList);
94 : : SVX_DLLPUBLIC virtual ~E3dObjList();
95 : :
96 : : virtual void NbcInsertObject(SdrObject* pObj, sal_uIntPtr nPos=CONTAINER_APPEND, const SdrInsertReason* pReason=NULL);
97 : : virtual void InsertObject(SdrObject* pObj, sal_uIntPtr nPos=CONTAINER_APPEND, const SdrInsertReason* pReason=NULL);
98 : : virtual SdrObject* NbcRemoveObject(sal_uIntPtr nObjNum);
99 : : virtual SdrObject* RemoveObject(sal_uIntPtr nObjNum);
100 : : };
101 : :
102 : : /*************************************************************************
103 : : |*
104 : : |* Base class for 3D objects
105 : : |*
106 : : \************************************************************************/
107 : :
108 : : class SVX_DLLPUBLIC E3dObject : public SdrAttrObj
109 : : {
110 : : private:
111 : : // to allow sdr::properties::E3dProperties access to StructureChanged()
112 : : friend class sdr::properties::E3dProperties;
113 : :
114 : : // Allow everything for E3dObjList and E3dDragMethod
115 : : friend class E3dObjList;
116 : : friend class E3dDragMethod;
117 : :
118 : : protected:
119 : : virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
120 : :
121 : : E3dObjList maSubList; // child objects
122 : :
123 : : basegfx::B3DRange maLocalBoundVol; // surrounding volume of the object (from the geometry generation)
124 : : basegfx::B3DHomMatrix maTransformation; // local transformation
125 : : basegfx::B3DHomMatrix maFullTransform; // global transformation (including. parents)
126 : :
127 : : // Flags
128 : : unsigned mbTfHasChanged : 1;
129 : : unsigned mbIsSelected : 1;
130 : :
131 : : public:
132 : : void SetBoundVolInvalid();
133 : :
134 : : protected:
135 : : void SetTransformChanged();
136 : : virtual void NewObjectInserted(const E3dObject* p3DObj);
137 : : virtual void StructureChanged();
138 : : basegfx::B3DRange RecalcBoundVolume() const;
139 : :
140 : : protected:
141 : : // E3dObject is only a helper class (for E3DScene and E3DCompoundObject)
142 : : // and no instances should be created from anyone, so i move the constructors
143 : : // to protected area
144 : : E3dObject();
145 : : E3dObject(sal_Bool bIsFromChart);
146 : :
147 : : public:
148 : : TYPEINFO();
149 : : virtual void RecalcSnapRect();
150 : : virtual void SetRectsDirty(sal_Bool bNotMyself = sal_False);
151 : :
152 : : virtual ~E3dObject();
153 : :
154 : : virtual sal_uInt32 GetObjInventor() const;
155 : : virtual sal_uInt16 GetObjIdentifier() const;
156 : :
157 : : virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
158 : :
159 : : virtual void NbcSetLayer(SdrLayerID nLayer);
160 : :
161 : : virtual void SetObjList(SdrObjList* pNewObjList);
162 : : virtual void SetPage(SdrPage* pNewPage);
163 : : virtual void SetModel(SdrModel* pNewModel);
164 : : virtual void NbcMove(const Size& rSize);
165 : : virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
166 : : virtual SdrObjList* GetSubList() const;
167 : :
168 : : // Insert 3D object into the group; transfer to other owner!
169 : : virtual void Insert3DObj(E3dObject* p3DObj);
170 : : void Remove3DObj(E3dObject* p3DObj);
171 : :
172 : : E3dObject* GetParentObj() const;
173 : : virtual E3dScene* GetScene() const;
174 : :
175 : : const basegfx::B3DRange& GetBoundVolume() const;
176 : : void InvalidateBoundVolume();
177 : :
178 : : // calculate complete transformation including all parents
179 : : const basegfx::B3DHomMatrix& GetFullTransform() const;
180 : :
181 : : // get and (re)set transformation matrix
182 : : const basegfx::B3DHomMatrix& GetTransform() const;
183 : : virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix);
184 : : virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix);
185 : :
186 : : // 2D rotations, are implemented as a rotation around the Z axis
187 : : // which is vertical to the screen, plus a shift of the scene.
188 : : // This means that also the scene (E3dScene) must define this
189 : : // routine as virtual in its class.
190 : : virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs);
191 : :
192 : : // get wireframe polygon for local object. No transform is applied.
193 : : basegfx::B3DPolyPolygon CreateWireframe() const;
194 : :
195 : : // TakeObjName...() is for the display in the UI, for example "3 frames selected".
196 : : virtual void TakeObjNameSingul(String& rName) const;
197 : : virtual void TakeObjNamePlural(String& rName) const;
198 : : sal_uInt16 GetLogicalGroup() { return 0; }
199 : : virtual E3dObject* Clone() const;
200 : : E3dObject& operator=( const E3dObject& rObj );
201 : :
202 : : virtual SdrObjGeoData *NewGeoData() const;
203 : : virtual void SaveGeoData(SdrObjGeoData& rGeo) const;
204 : : virtual void RestGeoData(const SdrObjGeoData& rGeo);
205 : :
206 : : // get/set the selection
207 : : bool GetSelected() const { return mbIsSelected; }
208 : : void SetSelected(bool bNew);
209 : :
210 : : // break up
211 : : virtual sal_Bool IsBreakObjPossible();
212 : : virtual SdrAttrObj* GetBreakObj();
213 : : };
214 : :
215 : : /*************************************************************************
216 : : |*
217 : : |* Class for all compound objects (Cube, Lathe, Scene, Extrude)
218 : : |* This class saves some ISA queries and accelerates the behaviour
219 : : |* significantly, because all the attributes etc. are kept through this.
220 : : |* The polygons may only keep attributes if they are directly
221 : : |* subordinated to the scene.
222 : : |*
223 : : \************************************************************************/
224 : :
225 : : class SVX_DLLPUBLIC E3dCompoundObject : public E3dObject
226 : : {
227 : : private:
228 : : // to allow sdr::properties::E3dCompoundProperties access to SetGeometryValid()
229 : : friend class sdr::properties::E3dCompoundProperties;
230 : : friend class sdr::properties::E3dExtrudeProperties;
231 : : friend class sdr::properties::E3dLatheProperties;
232 : : friend class sdr::properties::E3dSphereProperties;
233 : :
234 : : protected:
235 : : virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
236 : :
237 : : // material of the object
238 : : Color aMaterialAmbientColor;
239 : :
240 : : // attributes for geometry creation
241 : : unsigned bCreateNormals : 1;
242 : : unsigned bCreateTexture : 1;
243 : :
244 : : protected:
245 : : void SetDefaultAttributes(E3dDefaultAttributes& rDefault);
246 : :
247 : : // convert given basegfx::B3DPolyPolygon to screen coor
248 : : basegfx::B2DPolyPolygon TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate);
249 : :
250 : : public :
251 : : TYPEINFO();
252 : :
253 : : E3dCompoundObject();
254 : : E3dCompoundObject(E3dDefaultAttributes& rDefault);
255 : : virtual ~E3dCompoundObject();
256 : :
257 : : virtual basegfx::B2DPolyPolygon TakeXorPoly() const;
258 : : virtual sal_uInt32 GetHdlCount() const;
259 : : virtual void AddToHdlList(SdrHdlList& rHdlList) const;
260 : :
261 : : // DoubleSided: sal_True/FALSE
262 : : sal_Bool GetDoubleSided() const
263 : : { return ((const Svx3DDoubleSidedItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_DOUBLE_SIDED)).GetValue(); }
264 : :
265 : : // NormalsKind: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE
266 : : sal_uInt16 GetNormalsKind() const
267 : : { return ((const Svx3DNormalsKindItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_NORMALS_KIND)).GetValue(); }
268 : :
269 : : // NormalsInvert: sal_True/FALSE
270 : : sal_Bool GetNormalsInvert() const
271 : : { return ((const Svx3DNormalsInvertItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_NORMALS_INVERT)).GetValue(); }
272 : :
273 : : // TextureProjX: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE
274 : : sal_uInt16 GetTextureProjectionX() const
275 : : { return ((const Svx3DTextureProjectionXItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X)).GetValue(); }
276 : :
277 : : // TextureProjY: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE
278 : : sal_uInt16 GetTextureProjectionY() const
279 : : { return ((const Svx3DTextureProjectionYItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y)).GetValue(); }
280 : :
281 : : // Shadow3D: sal_True/FALSE
282 : : sal_Bool GetShadow3D() const
283 : : { return ((const Svx3DShadow3DItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_SHADOW_3D)).GetValue(); }
284 : :
285 : : // MaterialColor: Color
286 : : Color GetMaterialColor() const
287 : : { return ((const Svx3DMaterialColorItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_COLOR)).GetValue(); }
288 : :
289 : : // MaterialEmission: Color
290 : : Color GetMaterialEmission() const
291 : : { return ((const Svx3DMaterialEmissionItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_EMISSION)).GetValue(); }
292 : :
293 : : // MaterialSpecular: Color
294 : : Color GetMaterialSpecular() const
295 : : { return ((const Svx3DMaterialSpecularItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR)).GetValue(); }
296 : :
297 : : // MaterialSpecularIntensity:
298 : : sal_uInt16 GetMaterialSpecularIntensity() const
299 : : { return ((const Svx3DMaterialSpecularIntensityItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY)).GetValue(); }
300 : :
301 : : // TextureFilter: sal_True/FALSE
302 : : sal_Bool GetTextureFilter() const
303 : : { return ((const Svx3DTextureFilterItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_FILTER)).GetValue(); }
304 : :
305 : : // #i28528#
306 : : // Added extra Item (Bool) for chart2 to be able to show reduced line geometry
307 : : sal_Bool GetReducedLineGeometry() const
308 : : { return ((const Svx3DReducedLineGeometryItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY)).GetValue(); }
309 : :
310 : : virtual sal_uInt16 GetObjIdentifier() const;
311 : : virtual void RecalcSnapRect();
312 : :
313 : : // set/get parameters for geometry creation
314 : : sal_Bool GetCreateNormals() const { return bCreateNormals; }
315 : :
316 : : sal_Bool GetCreateTexture() const { return bCreateTexture; }
317 : :
318 : : virtual E3dCompoundObject* Clone() const;
319 : :
320 : : // material of the object
321 : : const Color& GetMaterialAmbientColor() const { return aMaterialAmbientColor; }
322 : :
323 : : sal_Bool IsAOrdNumRemapCandidate(E3dScene*& prScene) const;
324 : : };
325 : :
326 : : #endif // _E3D_OBJ3D_HXX
327 : :
328 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|