xref: /aoo4110/main/svx/inc/svx/scene3d.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _E3D_SCENE3D_HXX
25 #define _E3D_SCENE3D_HXX
26 
27 #include <svx/camera3d.hxx>
28 #include <tools/b3dtrans.hxx>
29 #include <tools/time.hxx>
30 #include <svx/svxdllapi.h>
31 #include <svx/obj3d.hxx>
32 
33 namespace sdr {	namespace properties {
34 	class BaseProperties;
35 	class E3dSceneProperties;
36 }}
37 
38 namespace drawinglayer { namespace geometry {
39 	class ViewInformation3D;
40 }}
41 
42 /*************************************************************************
43 |*
44 |* GeoData relevant fuer Undo-Actions
45 |*
46 \************************************************************************/
47 
48 class E3DSceneGeoData : public E3DObjGeoData
49 {
50 public:
51 	Camera3D					aCamera;
52 
E3DSceneGeoData()53 	E3DSceneGeoData() {}
54 };
55 
56 // #110988#
57 class Imp3DDepthRemapper;
58 
59 /*************************************************************************
60 |*
61 |* Basisklasse fuer 3D-Szenen
62 |*
63 \************************************************************************/
64 
65 class SVX_DLLPUBLIC E3dScene : public E3dObject
66 {
67 private:
68 	// to allow sdr::properties::E3dSceneProperties access to StructureChanged()
69 	friend class sdr::properties::E3dSceneProperties;
70 
71 protected:
72 	virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
73 	virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
74 
75     // Transformationen
76 	B3dCamera					aCameraSet;
77 	Camera3D					aCamera;
78 
79 	// #110988#
80 	Imp3DDepthRemapper*			mp3DDepthRemapper;
81 
82 	// Flag to determine if only selected objects should be drawn
83 	unsigned					bDrawOnlySelected		: 1;
84 
85 	virtual void NewObjectInserted(const E3dObject* p3DObj);
86 	virtual void StructureChanged();
87 
88 	void RebuildLists();
89 
90 	virtual void Notify(SfxBroadcaster &rBC, const SfxHint  &rHint);
91 
92 protected:
93 	void SetDefaultAttributes(E3dDefaultAttributes& rDefault);
94 
95 	// #110988#
96 	void ImpCleanup3DDepthMapper();
97 
98 public:
99 	TYPEINFO();
100 	E3dScene();
101 	E3dScene(E3dDefaultAttributes& rDefault);
102 	virtual ~E3dScene();
103 
104 	virtual void SetBoundRectDirty();
105 
106     // access to cleanup of depth mapper
Cleanup3DDepthMapper()107     void Cleanup3DDepthMapper() { ImpCleanup3DDepthMapper(); }
108 
109 	virtual basegfx::B2DPolyPolygon TakeXorPoly() const;
110 
111 	// #110988#
112 	sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
113 
114 	// Perspective: enum ProjectionType	{ PR_PARALLEL, PR_PERSPECTIVE }
GetPerspective() const115 	ProjectionType GetPerspective() const
116 		{ return (ProjectionType)((const Svx3DPerspectiveItem&)GetObjectItemSet().Get(SDRATTR_3DSCENE_PERSPECTIVE)).GetValue(); }
117 
118 	// Distance:
GetDistance() const119 	double GetDistance() const
120 		{ return (double)((const Svx3DDistanceItem&)GetObjectItemSet().Get(SDRATTR_3DSCENE_DISTANCE)).GetValue(); }
121 
122 	// Focal length: before cm, now 1/10th mm (*100)
GetFocalLength() const123 	double GetFocalLength() const
124 		{ return ((const Svx3DFocalLengthItem&)GetObjectItemSet().Get(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue(); }
125 
126 	// Two sided lighting:
GetTwoSidedLighting() const127 	sal_Bool GetTwoSidedLighting() const
128 		{ return ((const Svx3DTwoSidedLightingItem&)GetObjectItemSet().Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING)).GetValue(); }
129 
130 	// Lightcolor:
GetLightColor1() const131 	Color GetLightColor1() const
132 		{ return ((const Svx3DLightcolor1Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue(); }
GetLightColor2() const133 	Color GetLightColor2() const
134 		{ return ((const Svx3DLightcolor2Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue(); }
GetLightColor3() const135 	Color GetLightColor3() const
136 		{ return ((const Svx3DLightcolor3Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue(); }
GetLightColor4() const137 	Color GetLightColor4() const
138 		{ return ((const Svx3DLightcolor4Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue(); }
GetLightColor5() const139 	Color GetLightColor5() const
140 		{ return ((const Svx3DLightcolor5Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue(); }
GetLightColor6() const141 	Color GetLightColor6() const
142 		{ return ((const Svx3DLightcolor6Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue(); }
GetLightColor7() const143 	Color GetLightColor7() const
144 		{ return ((const Svx3DLightcolor7Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue(); }
GetLightColor8() const145 	Color GetLightColor8() const
146 		{ return ((const Svx3DLightcolor8Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue(); }
147 
148 	// Ambient color:
GetGlobalAmbientColor() const149 	Color GetGlobalAmbientColor() const
150 		{ return ((const Svx3DAmbientcolorItem&)GetObjectItemSet().Get(SDRATTR_3DSCENE_AMBIENTCOLOR)).GetValue(); }
151 
152 	// Light on/off:
GetLightOnOff1() const153 	sal_Bool GetLightOnOff1() const
154 		{ return ((const Svx3DLightOnOff1Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue(); }
GetLightOnOff2() const155 	sal_Bool GetLightOnOff2() const
156 		{ return ((const Svx3DLightOnOff2Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue(); }
GetLightOnOff3() const157 	sal_Bool GetLightOnOff3() const
158 		{ return ((const Svx3DLightOnOff3Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue(); }
GetLightOnOff4() const159 	sal_Bool GetLightOnOff4() const
160 		{ return ((const Svx3DLightOnOff4Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue(); }
GetLightOnOff5() const161 	sal_Bool GetLightOnOff5() const
162 		{ return ((const Svx3DLightOnOff5Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue(); }
GetLightOnOff6() const163 	sal_Bool GetLightOnOff6() const
164 		{ return ((const Svx3DLightOnOff6Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue(); }
GetLightOnOff7() const165 	sal_Bool GetLightOnOff7() const
166 		{ return ((const Svx3DLightOnOff7Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue(); }
GetLightOnOff8() const167 	sal_Bool GetLightOnOff8() const
168 		{ return ((const Svx3DLightOnOff8Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue(); }
169 
170 	// Light direction:
GetLightDirection1() const171 	basegfx::B3DVector GetLightDirection1() const
172 		{ return ((const Svx3DLightDirection1Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue(); }
GetLightDirection2() const173 	basegfx::B3DVector GetLightDirection2() const
174 		{ return ((const Svx3DLightDirection2Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue(); }
GetLightDirection3() const175 	basegfx::B3DVector GetLightDirection3() const
176 		{ return ((const Svx3DLightDirection3Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue(); }
GetLightDirection4() const177 	basegfx::B3DVector GetLightDirection4() const
178 		{ return ((const Svx3DLightDirection4Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue(); }
GetLightDirection5() const179 	basegfx::B3DVector GetLightDirection5() const
180 		{ return ((const Svx3DLightDirection5Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue(); }
GetLightDirection6() const181 	basegfx::B3DVector GetLightDirection6() const
182 		{ return ((const Svx3DLightDirection6Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue(); }
GetLightDirection7() const183 	basegfx::B3DVector GetLightDirection7() const
184 		{ return ((const Svx3DLightDirection7Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue(); }
GetLightDirection8() const185 	basegfx::B3DVector GetLightDirection8() const
186 		{ return ((const Svx3DLightDirection8Item&)GetObjectItemSet().Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue(); }
187 
188 	// ShadowSlant:
GetShadowSlant() const189 	sal_uInt16 GetShadowSlant() const
190 		{ return ((const Svx3DShadowSlantItem&)GetObjectItemSet().Get(SDRATTR_3DSCENE_SHADOW_SLANT)).GetValue(); }
191 
192 	// ShadeMode: 0 == FLAT, 1 == PHONG, 2 == SMOOTH, 3 == ForceDraft
GetShadeMode() const193 	sal_uInt16 GetShadeMode() const
194 		{ return ((const Svx3DShadeModeItem&)GetObjectItemSet().Get(SDRATTR_3DSCENE_SHADE_MODE)).GetValue(); }
195 
196 	// set flag to draw only selected
SetDrawOnlySelected(sal_Bool bNew)197 	void SetDrawOnlySelected(sal_Bool bNew) { bDrawOnlySelected = bNew; }
GetDrawOnlySelected() const198 	bool GetDrawOnlySelected() const { return bDrawOnlySelected; }
199 	virtual sal_uInt16 GetObjIdentifier() const;
200 
201 	virtual void	NbcSetSnapRect(const Rectangle& rRect);
202 	virtual void	NbcMove(const Size& rSize);
203 	virtual void	NbcResize(const Point& rRef, const Fraction& rXFact,
204 												 const Fraction& rYFact);
205 	virtual void	RecalcSnapRect();
206 
207 	virtual E3dScene* GetScene() const;
208 	void SetCamera(const Camera3D& rNewCamera);
GetCamera() const209 	const Camera3D& GetCamera() const { return aCamera; }
210     void removeAllNonSelectedObjects();
211 
212 	virtual void operator=(const SdrObject&);
213 
214 	virtual SdrObjGeoData *NewGeoData() const;
215 	virtual void          SaveGeoData(SdrObjGeoData& rGeo) const;
216 	virtual void          RestGeoData(const SdrObjGeoData& rGeo);
217 
218 	virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix);
219 	virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix);
220 
221 	virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs);
222 	void RotateScene(const Point& rRef, long nWink, double sn, double cs);
223 
224 	// TakeObjName...() ist fuer die Anzeige in der UI, z.B. "3 Rahmen selektiert".
225 	virtual void TakeObjNameSingul(String& rName) const;
226 	virtual void TakeObjNamePlural(String& rName) const;
227 
228 	// Transformationen rausgeben
GetCameraSet()229 	B3dCamera& GetCameraSet() { return aCameraSet; }
230 
231 	// Aufbrechen
232 	virtual sal_Bool IsBreakObjPossible();
233 
234 	basegfx::B3DVector GetShadowPlaneDirection() const;
235 	void SetShadowPlaneDirection(const basegfx::B3DVector& rVec);
236 
237 	// Polygon das waehrend des Erzeugens aufgezogen wird
238 	virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const;
239 
240 	// create moves
241 	virtual FASTBOOL BegCreate(SdrDragStat& rStat);
242 	virtual FASTBOOL MovCreate(SdrDragStat& rStat); // sal_True=Xor muss repainted werden
243 	virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
244 	virtual FASTBOOL BckCreate(SdrDragStat& rStat);
245 	virtual void BrkCreate(SdrDragStat& rStat);
246 };
247 
248 #endif			// _E3D_SCENE3D_HXX
249