Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_svx / scene3d.hxx
blobe37e6357e47b553ab96d3edeb236f61b11f431e4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scene3d.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _E3D_SCENE3D_HXX
32 #define _E3D_SCENE3D_HXX
34 #ifndef _CAMERA3D_HXX
35 #include <bf_svx/camera3d.hxx>
36 #endif
38 #ifndef _E3D_LIGHT3D_HXX
39 #include <bf_svx/light3d.hxx>
40 #endif
42 #ifndef _E3D_LABEL3D_HXX
43 #include <bf_svx/label3d.hxx>
44 #endif
46 #ifndef _B3D_BASE3D_HXX
47 #include <bf_goodies/base3d.hxx>
48 #endif
50 #ifndef _B3D_B3DTRANS_HXX
51 #include <bf_goodies/b3dtrans.hxx>
52 #endif
54 #ifndef _TOOLS_TIME_HXX
55 #include <tools/time.hxx>
56 #endif
57 namespace binfilter {
59 //************************************************************
60 // Defines
61 //************************************************************
63 #define E3D_SORT_NO_SORTING 0x00000001
64 #define E3D_SORT_FAST_SORTING 0x00000002
65 #define E3D_SORT_IN_PARENTS 0x00000004
66 #define E3D_SORT_NON_POLYOBJ 0x00000008
67 #define E3D_SORT_LOOKUP_FIELD 0x00000010
68 #define E3D_SORT_TEST_LENGTH 0x00000020
70 /*************************************************************************
72 |* GeoData relevant fuer Undo-Actions
74 \************************************************************************/
76 class E3DSceneGeoData : public E3DObjGeoData
78 public:
79 Camera3D aCamera;
80 E3dLabelList aLabelList;
82 E3DSceneGeoData() {}
85 /*************************************************************************
87 |* Basisklasse fuer 3D-Szenen
89 \************************************************************************/
91 class E3dScene : public E3dObject
93 protected:
94 // Transformationen
95 B3dCamera aCameraSet;
97 // Beleuchtung
98 B3dLightGroup aLightGroup;
100 Camera3D aCamera;
101 E3dLabelList aLabelList;
103 long nSaveStatus;
104 long nRestStatus;
106 UINT32 nSortingMode;
108 // Zeit, die der letzte Paint() benoetigte
109 Time aPaintTime;
111 // Darstellungsqualitaet, wird in Base3D verwendet
112 UINT8 nDisplayQuality;
114 // BOOLean Flags
115 unsigned bDoubleBuffered : 1;
116 unsigned bClipping : 1;
117 unsigned bFitInSnapRect : 1;
118 unsigned bDither : 1;
120 // Merker, ob die Szene urspruenglich selektiert war
121 unsigned bWasSelectedWhenCopy : 1;
123 // Flag to determine if only selected objects should be drawn
124 unsigned bDrawOnlySelected : 1;
126 // static range data
127 const static sal_uInt16 mnSceneRangeData[4];
128 const static sal_uInt16 mnAllRangeData[4];
130 virtual void NewObjectInserted(const E3dObject* p3DObj);
131 virtual void StructureChanged(const E3dObject* p3DObj);
133 void RebuildLists();
134 virtual void ForceDefaultAttr();
136 virtual void SFX_NOTIFY(SfxBroadcaster &rBC,
137 const TypeId &rBCType,
138 const SfxHint &rHint,
139 const TypeId &rHintType);
142 protected:
143 void SetDefaultAttributes(E3dDefaultAttributes& rDefault);
144 void ImpSetLightItemsFromLightGroup();
145 void ImpSetSceneItemsFromCamera();
147 public:
148 TYPEINFO();
149 E3dScene();
150 virtual ~E3dScene();
152 // Perspective: enum ProjectionType { PR_PARALLEL, PR_PERSPECTIVE }
153 ProjectionType GetPerspective() const
154 { return (ProjectionType)((const Svx3DPerspectiveItem&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_PERSPECTIVE)).GetValue(); }
156 // Distance:
157 double GetDistance() const
158 { return (double)((const Svx3DDistanceItem&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_DISTANCE)).GetValue(); }
160 // Focal length: before cm, now 1/10th mm (*100)
161 double GetFocalLength() const
162 { return ((const Svx3DFocalLengthItem&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue(); }
164 // Two sided lighting:
165 BOOL GetTwoSidedLighting() const
166 { return ((const Svx3DTwoSidedLightingItem&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING)).GetValue(); }
168 // Lightcolor:
169 Color GetLightColor1() const
170 { return ((const Svx3DLightcolor1Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue(); }
171 Color GetLightColor2() const
172 { return ((const Svx3DLightcolor2Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue(); }
173 Color GetLightColor3() const
174 { return ((const Svx3DLightcolor3Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue(); }
175 Color GetLightColor4() const
176 { return ((const Svx3DLightcolor4Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue(); }
177 Color GetLightColor5() const
178 { return ((const Svx3DLightcolor5Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue(); }
179 Color GetLightColor6() const
180 { return ((const Svx3DLightcolor6Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue(); }
181 Color GetLightColor7() const
182 { return ((const Svx3DLightcolor7Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue(); }
183 Color GetLightColor8() const
184 { return ((const Svx3DLightcolor8Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue(); }
186 // Ambient color:
187 Color GetGlobalAmbientColor() const
188 { return ((const Svx3DAmbientcolorItem&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_AMBIENTCOLOR)).GetValue(); }
190 // Light on/off:
191 BOOL GetLightOnOff1() const
192 { return ((const Svx3DLightOnOff1Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue(); }
193 BOOL GetLightOnOff2() const
194 { return ((const Svx3DLightOnOff2Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue(); }
195 BOOL GetLightOnOff3() const
196 { return ((const Svx3DLightOnOff3Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue(); }
197 BOOL GetLightOnOff4() const
198 { return ((const Svx3DLightOnOff4Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue(); }
199 BOOL GetLightOnOff5() const
200 { return ((const Svx3DLightOnOff5Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue(); }
201 BOOL GetLightOnOff6() const
202 { return ((const Svx3DLightOnOff6Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue(); }
203 BOOL GetLightOnOff7() const
204 { return ((const Svx3DLightOnOff7Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue(); }
205 BOOL GetLightOnOff8() const
206 { return ((const Svx3DLightOnOff8Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue(); }
208 // Light direction:
209 Vector3D GetLightDirection1() const
210 { return ((const Svx3DLightDirection1Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue(); }
211 Vector3D GetLightDirection2() const
212 { return ((const Svx3DLightDirection2Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue(); }
213 Vector3D GetLightDirection3() const
214 { return ((const Svx3DLightDirection3Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue(); }
215 Vector3D GetLightDirection4() const
216 { return ((const Svx3DLightDirection4Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue(); }
217 Vector3D GetLightDirection5() const
218 { return ((const Svx3DLightDirection5Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue(); }
219 Vector3D GetLightDirection6() const
220 { return ((const Svx3DLightDirection6Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue(); }
221 Vector3D GetLightDirection7() const
222 { return ((const Svx3DLightDirection7Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue(); }
223 Vector3D GetLightDirection8() const
224 { return ((const Svx3DLightDirection8Item&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue(); }
226 // ShadowSlant:
227 sal_uInt16 GetShadowSlant() const
228 { return ((const Svx3DShadowSlantItem&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_SHADOW_SLANT)).GetValue(); }
230 // ShadeMode: 0 == FLAT, 1 == PHONG, 2 == SMOOTH, 3 == ForceDraft
231 sal_uInt16 GetShadeMode() const
232 { return ((const Svx3DShadeModeItem&)GetUnmergedItemSet().Get(SDRATTR_3DSCENE_SHADE_MODE)).GetValue(); }
234 // set flag to draw only selected
235 void SetDrawOnlySelected(BOOL bNew) { bDrawOnlySelected = bNew; }
236 BOOL DoDrawOnlySelected() const { return bDrawOnlySelected; }
238 virtual Volume3D FitInSnapRect();
242 virtual void NbcSetSnapRect(const Rectangle& rRect);
243 virtual void NbcResize(const Point& rRef, const Fraction& rXFact,
244 const Fraction& rYFact);
245 virtual void RecalcSnapRect();
247 // Paint MUSS ueberladen werden
248 virtual FASTBOOL Paint(ExtOutputDevice&, const SdrPaintInfoRec&) const = 0;
250 virtual E3dScene* GetScene() const;
252 // TransformationSet vorbereiten
253 void InitTransformationSet();
255 Time GetLastPaintTime() { return aPaintTime; }
257 // Darstellungsqualitaet
258 void SetDisplayQuality(UINT8 nNew) { nDisplayQuality = nNew; }
259 UINT8 GetDisplayQuality() { return nDisplayQuality; }
261 void SetCamera(const Camera3D& rNewCamera);
262 const Camera3D& GetCamera() const { return aCamera; }
264 FASTBOOL IsDoubleBuffered() const { return bDoubleBuffered; }
266 // Clipping auf umschliessendes Rechteck der Szene
267 // (Double Buffering ist immer geclipt!)
268 FASTBOOL IsClipping() const { return bClipping; }
270 void CorrectSceneDimensions();
271 FASTBOOL IsFitInSnapRect() const { return bFitInSnapRect; }
273 void FitSnapRectToBoundVol();
274 virtual void WriteData(SvStream& rOut) const;
275 virtual void ReadData(const SdrObjIOHeader& rHead, SvStream& rIn);
278 virtual SdrObjGeoData *NewGeoData() const;
279 virtual void SaveGeoData(SdrObjGeoData& rGeo) const;
280 virtual void RestGeoData(const SdrObjGeoData& rGeo);
282 // ItemSet access
283 virtual const SfxItemSet& GetItemSet() const;
284 virtual void ItemSetChanged(const SfxItemSet& rSet);
286 // private support routines for ItemSet access. NULL pointer means clear item.
287 virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = 0);
288 virtual void PostItemChange(const sal_uInt16 nWhich);
290 // pre- and postprocessing for objects for saving
291 virtual void PreSave();
292 virtual void PostSave();
294 virtual void NbcSetStyleSheet(SfxStyleSheet* pNewStyleSheet, FASTBOOL bDontRemoveHardAttr);
295 virtual SfxStyleSheet* GetStyleSheet() const;
298 // TakeObjName...() ist fuer die Anzeige in der UI, z.B. "3 Rahmen selektiert".
300 void SetSortingMode(UINT32 nMode) {nSortingMode = nMode;}
301 UINT32 GetSortingMode() {return nSortingMode;}
303 // Transformationen rausgeben
304 B3dCamera& GetCameraSet() { return aCameraSet; }
306 // Beleuchtung rausgeben
307 B3dLightGroup& GetLightGroup() { return aLightGroup; }
309 // LightGroup aus geladenen PointObj's fuellen
310 void FillLightGroup();
312 // Licht-Objekte rauswerfen
313 void RemoveLightObjects();
315 // Licht-Objekte erzeugen, um kompatibel zur 4.0
316 // speichern zu koennen
317 void CreateLightObjectsFromLightGroup();
319 // Lichter zaehlen
320 UINT16 CountNumberOfLights();
322 // Dithering
323 BOOL GetDither() { return bDither; }
324 void SetDither(BOOL bNew) { bDither = bNew; }
326 // Marker fuer WasSelectedWhenCopy
327 BOOL GetWasSelectedWhenCopy() { return bWasSelectedWhenCopy; }
328 void SetWasSelectedWhenCopy(BOOL bNew) { bWasSelectedWhenCopy = bNew; }
330 // Aufbrechen
332 // ItemPool fuer dieses Objekt wechseln
333 virtual void MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel = NULL );
335 void SetShadowPlaneDirection(const Vector3D& rVec);
338 }//end of namespace binfilter
339 #endif // _E3D_SCENE3D_HXX