xref: /aoo41x/main/svx/source/engine3d/scene3d.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "svx/svdstr.hrc"
32*cdf0e10cSrcweir #include "svx/svdglob.hxx"
33*cdf0e10cSrcweir #include "svx/svditer.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #if defined( UNX ) || defined( ICC )
36*cdf0e10cSrcweir #include <stdlib.h>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #include "svx/globl3d.hxx"
39*cdf0e10cSrcweir #include <svx/svdpage.hxx>
40*cdf0e10cSrcweir #include <svl/style.hxx>
41*cdf0e10cSrcweir #include <svx/scene3d.hxx>
42*cdf0e10cSrcweir #include <svx/e3dundo.hxx>
43*cdf0e10cSrcweir #include <svx/svdtrans.hxx>
44*cdf0e10cSrcweir #include <svx/svxids.hrc>
45*cdf0e10cSrcweir #include <editeng/colritem.hxx>
46*cdf0e10cSrcweir #include <svx/e3ditem.hxx>
47*cdf0e10cSrcweir #include <svx/xlntrit.hxx>
48*cdf0e10cSrcweir #include <svx/xfltrit.hxx>
49*cdf0e10cSrcweir #include <svx/svx3ditems.hxx>
50*cdf0e10cSrcweir #include <svl/whiter.hxx>
51*cdf0e10cSrcweir #include <svx/xflftrit.hxx>
52*cdf0e10cSrcweir #include <svx/sdr/properties/e3dsceneproperties.hxx>
53*cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofe3dscene.hxx>
54*cdf0e10cSrcweir #include <svx/svddrag.hxx>
55*cdf0e10cSrcweir #include <helperminimaldepth3d.hxx>
56*cdf0e10cSrcweir #include <algorithm>
57*cdf0e10cSrcweir #include <drawinglayer/geometry/viewinformation3d.hxx>
58*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
59*cdf0e10cSrcweir #include <svx/e3dsceneupdater.hxx>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #define ITEMVALUE(ItemSet,Id,Cast)	((const Cast&)(ItemSet).Get(Id)).GetValue()
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
64*cdf0e10cSrcweir // #110988#
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir class ImpRemap3DDepth
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir 	sal_uInt32					mnOrdNum;
69*cdf0e10cSrcweir 	double						mfMinimalDepth;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	// bitfield
72*cdf0e10cSrcweir 	unsigned					mbIsScene : 1;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir public:
75*cdf0e10cSrcweir 	ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth);
76*cdf0e10cSrcweir 	ImpRemap3DDepth(sal_uInt32 nOrdNum);
77*cdf0e10cSrcweir 	~ImpRemap3DDepth();
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 	// for ::std::sort
80*cdf0e10cSrcweir 	bool operator<(const ImpRemap3DDepth& rComp) const;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	sal_uInt32 GetOrdNum() const { return mnOrdNum; }
83*cdf0e10cSrcweir 	sal_Bool IsScene() const { return mbIsScene; }
84*cdf0e10cSrcweir };
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth)
87*cdf0e10cSrcweir :	mnOrdNum(nOrdNum),
88*cdf0e10cSrcweir 	mfMinimalDepth(fMinimalDepth),
89*cdf0e10cSrcweir 	mbIsScene(sal_False)
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum)
94*cdf0e10cSrcweir :	mnOrdNum(nOrdNum),
95*cdf0e10cSrcweir 	mbIsScene(sal_True)
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir ImpRemap3DDepth::~ImpRemap3DDepth()
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir bool ImpRemap3DDepth::operator<(const ImpRemap3DDepth& rComp) const
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	if(IsScene())
106*cdf0e10cSrcweir 	{
107*cdf0e10cSrcweir 		return sal_False;
108*cdf0e10cSrcweir 	}
109*cdf0e10cSrcweir 	else
110*cdf0e10cSrcweir 	{
111*cdf0e10cSrcweir 		if(rComp.IsScene())
112*cdf0e10cSrcweir 		{
113*cdf0e10cSrcweir 			return sal_True;
114*cdf0e10cSrcweir 		}
115*cdf0e10cSrcweir 		else
116*cdf0e10cSrcweir 		{
117*cdf0e10cSrcweir 			return mfMinimalDepth < rComp.mfMinimalDepth;
118*cdf0e10cSrcweir 		}
119*cdf0e10cSrcweir 	}
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir // typedefs for a vector of ImpRemap3DDepths
123*cdf0e10cSrcweir typedef ::std::vector< ImpRemap3DDepth > ImpRemap3DDepthVector;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
126*cdf0e10cSrcweir // #110988#
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir class Imp3DDepthRemapper
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir 	ImpRemap3DDepthVector		maVector;
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir public:
133*cdf0e10cSrcweir 	Imp3DDepthRemapper(E3dScene& rScene);
134*cdf0e10cSrcweir 	~Imp3DDepthRemapper();
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
137*cdf0e10cSrcweir };
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir Imp3DDepthRemapper::Imp3DDepthRemapper(E3dScene& rScene)
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir 	// only called when rScene.GetSubList() and nObjCount > 1L
142*cdf0e10cSrcweir 	SdrObjList* pList = rScene.GetSubList();
143*cdf0e10cSrcweir 	const sal_uInt32 nObjCount(pList->GetObjCount());
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 	for(sal_uInt32 a(0L); a < nObjCount; a++)
146*cdf0e10cSrcweir 	{
147*cdf0e10cSrcweir 		SdrObject* pCandidate = pList->GetObj(a);
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 		if(pCandidate)
150*cdf0e10cSrcweir 		{
151*cdf0e10cSrcweir 			if(pCandidate->ISA(E3dCompoundObject))
152*cdf0e10cSrcweir 			{
153*cdf0e10cSrcweir 				// single 3d object, calc depth
154*cdf0e10cSrcweir                 const double fMinimalDepth(getMinimalDepthInViewCoordinates(static_cast< const E3dCompoundObject& >(*pCandidate)));
155*cdf0e10cSrcweir 				ImpRemap3DDepth aEntry(a, fMinimalDepth);
156*cdf0e10cSrcweir 				maVector.push_back(aEntry);
157*cdf0e10cSrcweir 			}
158*cdf0e10cSrcweir 			else
159*cdf0e10cSrcweir 			{
160*cdf0e10cSrcweir 				// scene, use standard entry for scene
161*cdf0e10cSrcweir 				ImpRemap3DDepth aEntry(a);
162*cdf0e10cSrcweir 				maVector.push_back(aEntry);
163*cdf0e10cSrcweir 			}
164*cdf0e10cSrcweir 		}
165*cdf0e10cSrcweir 	}
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 	// now, we need to sort the maVector by it's members minimal depth. The
168*cdf0e10cSrcweir 	// smaller, the nearer to the viewer.
169*cdf0e10cSrcweir 	::std::sort(maVector.begin(), maVector.end());
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir Imp3DDepthRemapper::~Imp3DDepthRemapper()
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir sal_uInt32 Imp3DDepthRemapper::RemapOrdNum(sal_uInt32 nOrdNum) const
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir 	if(nOrdNum < maVector.size())
179*cdf0e10cSrcweir 	{
180*cdf0e10cSrcweir 		nOrdNum = maVector[(maVector.size() - 1) - nOrdNum].GetOrdNum();
181*cdf0e10cSrcweir 	}
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 	return nOrdNum;
184*cdf0e10cSrcweir }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
187*cdf0e10cSrcweir // BaseProperties section
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir sdr::properties::BaseProperties* E3dScene::CreateObjectSpecificProperties()
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir 	return new sdr::properties::E3dSceneProperties(*this);
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
195*cdf0e10cSrcweir // #110094# DrawContact section
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir sdr::contact::ViewContact* E3dScene::CreateObjectSpecificViewContact()
198*cdf0e10cSrcweir {
199*cdf0e10cSrcweir 	return new sdr::contact::ViewContactOfE3dScene(*this);
200*cdf0e10cSrcweir }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir TYPEINIT1(E3dScene, E3dObject);
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir /*************************************************************************
207*cdf0e10cSrcweir |*
208*cdf0e10cSrcweir |* E3dScene-Konstruktor
209*cdf0e10cSrcweir |*
210*cdf0e10cSrcweir \************************************************************************/
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir E3dScene::E3dScene()
213*cdf0e10cSrcweir :	E3dObject(),
214*cdf0e10cSrcweir 	aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
215*cdf0e10cSrcweir 	mp3DDepthRemapper(0L),
216*cdf0e10cSrcweir 	bDrawOnlySelected(false)
217*cdf0e10cSrcweir {
218*cdf0e10cSrcweir 	// Defaults setzen
219*cdf0e10cSrcweir 	E3dDefaultAttributes aDefault;
220*cdf0e10cSrcweir 	SetDefaultAttributes(aDefault);
221*cdf0e10cSrcweir }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir E3dScene::E3dScene(E3dDefaultAttributes& rDefault)
224*cdf0e10cSrcweir :	E3dObject(),
225*cdf0e10cSrcweir 	aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
226*cdf0e10cSrcweir 	mp3DDepthRemapper(0L),
227*cdf0e10cSrcweir 	bDrawOnlySelected(false)
228*cdf0e10cSrcweir {
229*cdf0e10cSrcweir 	// Defaults setzen
230*cdf0e10cSrcweir 	SetDefaultAttributes(rDefault);
231*cdf0e10cSrcweir }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir void E3dScene::SetDefaultAttributes(E3dDefaultAttributes& /*rDefault*/)
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir 	// Fuer OS/2 die FP-Exceptions abschalten
236*cdf0e10cSrcweir #if defined(OS2)
237*cdf0e10cSrcweir #define SC_FPEXCEPTIONS_ON()	_control87( MCW_EM, 0 )
238*cdf0e10cSrcweir #define SC_FPEXCEPTIONS_OFF()	_control87( MCW_EM, MCW_EM )
239*cdf0e10cSrcweir 	SC_FPEXCEPTIONS_OFF();
240*cdf0e10cSrcweir #endif
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 	// Fuer WIN95/NT die FP-Exceptions abschalten
243*cdf0e10cSrcweir #if defined(WNT)
244*cdf0e10cSrcweir #define SC_FPEXCEPTIONS_ON()	_control87( _MCW_EM, 0 )
245*cdf0e10cSrcweir #define SC_FPEXCEPTIONS_OFF()	_control87( _MCW_EM, _MCW_EM )
246*cdf0e10cSrcweir 	SC_FPEXCEPTIONS_OFF();
247*cdf0e10cSrcweir #endif
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	// Defaults setzen
250*cdf0e10cSrcweir 	aCamera.SetViewWindow(-2, -2, 4, 4);
251*cdf0e10cSrcweir 	aCameraSet.SetDeviceRectangle(-2, 2, -2, 2);
252*cdf0e10cSrcweir 	aCamera.SetDeviceWindow(Rectangle(0, 0, 10, 10));
253*cdf0e10cSrcweir 	Rectangle aRect(0, 0, 10, 10);
254*cdf0e10cSrcweir 	aCameraSet.SetViewportRectangle(aRect);
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 	// set defaults for Camera from ItemPool
257*cdf0e10cSrcweir 	aCamera.SetProjection(GetPerspective());
258*cdf0e10cSrcweir 	basegfx::B3DPoint aActualPosition(aCamera.GetPosition());
259*cdf0e10cSrcweir 	double fNew = GetDistance();
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 	if(fabs(fNew - aActualPosition.getZ()) > 1.0)
262*cdf0e10cSrcweir 	{
263*cdf0e10cSrcweir 		aCamera.SetPosition( basegfx::B3DPoint( aActualPosition.getX(), aActualPosition.getY(), fNew) );
264*cdf0e10cSrcweir 	}
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 	fNew = GetFocalLength() / 100.0;
267*cdf0e10cSrcweir 	aCamera.SetFocalLength(fNew);
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir /*************************************************************************
271*cdf0e10cSrcweir |*
272*cdf0e10cSrcweir |* Destruktor
273*cdf0e10cSrcweir |*
274*cdf0e10cSrcweir \************************************************************************/
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir E3dScene::~E3dScene()
277*cdf0e10cSrcweir {
278*cdf0e10cSrcweir 	// #110988#
279*cdf0e10cSrcweir 	ImpCleanup3DDepthMapper();
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir basegfx::B2DPolyPolygon E3dScene::TakeXorPoly() const
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir 	const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(GetViewContact());
285*cdf0e10cSrcweir 	const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
286*cdf0e10cSrcweir 	const basegfx::B3DPolyPolygon aCubePolyPolygon(CreateWireframe());
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aRetval(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aCubePolyPolygon,
289*cdf0e10cSrcweir 		aViewInfo3D.getObjectToView()));
290*cdf0e10cSrcweir 	aRetval.transform(rVCScene.getObjectTransformation());
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 	return aRetval;
293*cdf0e10cSrcweir }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir // #110988#
296*cdf0e10cSrcweir void E3dScene::ImpCleanup3DDepthMapper()
297*cdf0e10cSrcweir {
298*cdf0e10cSrcweir 	if(mp3DDepthRemapper)
299*cdf0e10cSrcweir 	{
300*cdf0e10cSrcweir 		delete mp3DDepthRemapper;
301*cdf0e10cSrcweir 		mp3DDepthRemapper = 0L;
302*cdf0e10cSrcweir 	}
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir // #110988#
306*cdf0e10cSrcweir sal_uInt32 E3dScene::RemapOrdNum(sal_uInt32 nNewOrdNum) const
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	if(!mp3DDepthRemapper)
309*cdf0e10cSrcweir 	{
310*cdf0e10cSrcweir 		const sal_uInt32 nObjCount(GetSubList() ? GetSubList()->GetObjCount() : 0L);
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 		if(nObjCount > 1L)
313*cdf0e10cSrcweir 		{
314*cdf0e10cSrcweir 			((E3dScene*)this)->mp3DDepthRemapper = new Imp3DDepthRemapper((E3dScene&)(*this));
315*cdf0e10cSrcweir 		}
316*cdf0e10cSrcweir 	}
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 	if(mp3DDepthRemapper)
319*cdf0e10cSrcweir 	{
320*cdf0e10cSrcweir 		return mp3DDepthRemapper->RemapOrdNum(nNewOrdNum);
321*cdf0e10cSrcweir 	}
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	return nNewOrdNum;
324*cdf0e10cSrcweir }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir /*************************************************************************
327*cdf0e10cSrcweir |*
328*cdf0e10cSrcweir |* Identifier zurueckgeben
329*cdf0e10cSrcweir |*
330*cdf0e10cSrcweir \************************************************************************/
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir sal_uInt16 E3dScene::GetObjIdentifier() const
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir 	return E3D_SCENE_ID;
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir void E3dScene::SetBoundRectDirty()
338*cdf0e10cSrcweir {
339*cdf0e10cSrcweir 	E3dScene* pScene = GetScene();
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 	if(pScene == this)
342*cdf0e10cSrcweir 	{
343*cdf0e10cSrcweir 	    // avoid resetting aOutRect which in case of a 3D scene used as 2d object
344*cdf0e10cSrcweir 		// is model data,not re-creatable view data
345*cdf0e10cSrcweir 	}
346*cdf0e10cSrcweir 	else
347*cdf0e10cSrcweir 	{
348*cdf0e10cSrcweir 		// if not the outmost scene it is used as group in 3d, call parent
349*cdf0e10cSrcweir 		E3dObject::SetBoundRectDirty();
350*cdf0e10cSrcweir 	}
351*cdf0e10cSrcweir }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir /*************************************************************************
354*cdf0e10cSrcweir |*
355*cdf0e10cSrcweir |* SetSnapRect
356*cdf0e10cSrcweir |*
357*cdf0e10cSrcweir \************************************************************************/
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir void E3dScene::NbcSetSnapRect(const Rectangle& rRect)
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir 	SetRectsDirty();
362*cdf0e10cSrcweir 	E3dObject::NbcSetSnapRect(rRect);
363*cdf0e10cSrcweir 	aCamera.SetDeviceWindow(rRect);
364*cdf0e10cSrcweir 	aCameraSet.SetViewportRectangle((Rectangle&)rRect);
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir 	// #110988#
367*cdf0e10cSrcweir 	ImpCleanup3DDepthMapper();
368*cdf0e10cSrcweir }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir /*************************************************************************
371*cdf0e10cSrcweir |*
372*cdf0e10cSrcweir |* Objekt verschieben
373*cdf0e10cSrcweir |*
374*cdf0e10cSrcweir \************************************************************************/
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir void E3dScene::NbcMove(const Size& rSize)
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir 	Rectangle aNewSnapRect = GetSnapRect();
379*cdf0e10cSrcweir 	MoveRect(aNewSnapRect, rSize);
380*cdf0e10cSrcweir 	NbcSetSnapRect(aNewSnapRect);
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir /*************************************************************************
384*cdf0e10cSrcweir |*
385*cdf0e10cSrcweir |* Objekt Resizen
386*cdf0e10cSrcweir |*
387*cdf0e10cSrcweir \************************************************************************/
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir void E3dScene::NbcResize(const Point& rRef, const Fraction& rXFact,
390*cdf0e10cSrcweir 											const Fraction& rYFact)
391*cdf0e10cSrcweir {
392*cdf0e10cSrcweir 	Rectangle aNewSnapRect = GetSnapRect();
393*cdf0e10cSrcweir 	ResizeRect(aNewSnapRect, rRef, rXFact, rYFact);
394*cdf0e10cSrcweir 	NbcSetSnapRect(aNewSnapRect);
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir /*************************************************************************
398*cdf0e10cSrcweir |*
399*cdf0e10cSrcweir |* Neue Kamera setzen, und dabei die Szene und ggf. das BoundVolume
400*cdf0e10cSrcweir |* als geaendert markieren
401*cdf0e10cSrcweir |*
402*cdf0e10cSrcweir \************************************************************************/
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir void E3dScene::SetCamera(const Camera3D& rNewCamera)
405*cdf0e10cSrcweir {
406*cdf0e10cSrcweir 	// Alte Kamera setzen
407*cdf0e10cSrcweir 	aCamera = rNewCamera;
408*cdf0e10cSrcweir 	((sdr::properties::E3dSceneProperties&)GetProperties()).SetSceneItemsFromCamera();
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 	SetRectsDirty();
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir 	// Neue Kamera aus alter fuellen
413*cdf0e10cSrcweir 	Camera3D& rCam = (Camera3D&)GetCamera();
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 	// Ratio abschalten
416*cdf0e10cSrcweir 	if(rCam.GetAspectMapping() == AS_NO_MAPPING)
417*cdf0e10cSrcweir 		GetCameraSet().SetRatio(0.0);
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir 	// Abbildungsgeometrie setzen
420*cdf0e10cSrcweir 	basegfx::B3DPoint aVRP(rCam.GetViewPoint());
421*cdf0e10cSrcweir 	basegfx::B3DVector aVPN(aVRP - rCam.GetVRP());
422*cdf0e10cSrcweir 	basegfx::B3DVector aVUV(rCam.GetVUV());
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 	// #91047# use SetViewportValues() to set VRP, VPN and VUV as vectors, too.
425*cdf0e10cSrcweir 	// Else these values would not be exported/imported correctly.
426*cdf0e10cSrcweir 	GetCameraSet().SetViewportValues(aVRP, aVPN, aVUV);
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 	// Perspektive setzen
429*cdf0e10cSrcweir 	GetCameraSet().SetPerspective(rCam.GetProjection() == PR_PERSPECTIVE);
430*cdf0e10cSrcweir 	GetCameraSet().SetViewportRectangle((Rectangle&)rCam.GetDeviceWindow());
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 	// #110988#
433*cdf0e10cSrcweir 	ImpCleanup3DDepthMapper();
434*cdf0e10cSrcweir }
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir /*************************************************************************
437*cdf0e10cSrcweir |*
438*cdf0e10cSrcweir |* 3D-Objekt einfuegen
439*cdf0e10cSrcweir |*
440*cdf0e10cSrcweir \************************************************************************/
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir void E3dScene::NewObjectInserted(const E3dObject* p3DObj)
443*cdf0e10cSrcweir {
444*cdf0e10cSrcweir 	E3dObject::NewObjectInserted(p3DObj);
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir 	if ( p3DObj == this )
447*cdf0e10cSrcweir 		return;
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 	// #110988#
450*cdf0e10cSrcweir 	ImpCleanup3DDepthMapper();
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir /*************************************************************************
454*cdf0e10cSrcweir |*
455*cdf0e10cSrcweir |* Parent ueber Aenderung eines Childs informieren
456*cdf0e10cSrcweir |*
457*cdf0e10cSrcweir \************************************************************************/
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir void E3dScene::StructureChanged()
460*cdf0e10cSrcweir {
461*cdf0e10cSrcweir 	E3dObject::StructureChanged();
462*cdf0e10cSrcweir 	SetRectsDirty();
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir 	// #110988#
465*cdf0e10cSrcweir 	ImpCleanup3DDepthMapper();
466*cdf0e10cSrcweir }
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir /*************************************************************************
469*cdf0e10cSrcweir |*
470*cdf0e10cSrcweir |* Uebergeordnetes Szenenobjekt bestimmen
471*cdf0e10cSrcweir |*
472*cdf0e10cSrcweir \************************************************************************/
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir E3dScene* E3dScene::GetScene() const
475*cdf0e10cSrcweir {
476*cdf0e10cSrcweir 	if(GetParentObj())
477*cdf0e10cSrcweir 		return GetParentObj()->GetScene();
478*cdf0e10cSrcweir 	else
479*cdf0e10cSrcweir 		return (E3dScene*)this;
480*cdf0e10cSrcweir }
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir void E3dScene::removeAllNonSelectedObjects()
483*cdf0e10cSrcweir {
484*cdf0e10cSrcweir 	E3DModifySceneSnapRectUpdater aUpdater(this);
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir     for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
487*cdf0e10cSrcweir     {
488*cdf0e10cSrcweir 		SdrObject* pObj = maSubList.GetObj(a);
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir         if(pObj)
491*cdf0e10cSrcweir 		{
492*cdf0e10cSrcweir             bool bRemoveObject(false);
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir             if(pObj->ISA(E3dScene))
495*cdf0e10cSrcweir             {
496*cdf0e10cSrcweir                 E3dScene* pScene = (E3dScene*)pObj;
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir                 // iterate over this sub-scene
499*cdf0e10cSrcweir                 pScene->removeAllNonSelectedObjects();
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir                 // check object count. Empty scenes can be deleted
502*cdf0e10cSrcweir                 const sal_uInt32 nObjCount(pScene->GetSubList() ? pScene->GetSubList()->GetObjCount() : 0);
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir                 if(!nObjCount)
505*cdf0e10cSrcweir 			    {
506*cdf0e10cSrcweir                     // all objects removed, scene can be removed, too
507*cdf0e10cSrcweir                     bRemoveObject = true;
508*cdf0e10cSrcweir 			    }
509*cdf0e10cSrcweir 			}
510*cdf0e10cSrcweir             else if(pObj->ISA(E3dCompoundObject))
511*cdf0e10cSrcweir 			{
512*cdf0e10cSrcweir                 E3dCompoundObject* pCompound = (E3dCompoundObject*)pObj;
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir 			    if(!pCompound->GetSelected())
515*cdf0e10cSrcweir 				{
516*cdf0e10cSrcweir                     bRemoveObject = true;
517*cdf0e10cSrcweir 				}
518*cdf0e10cSrcweir 			}
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir             if(bRemoveObject)
521*cdf0e10cSrcweir 			{
522*cdf0e10cSrcweir 			    maSubList.NbcRemoveObject(pObj->GetOrdNum());
523*cdf0e10cSrcweir 			    a--;
524*cdf0e10cSrcweir                 SdrObject::Free(pObj);
525*cdf0e10cSrcweir             }
526*cdf0e10cSrcweir         }
527*cdf0e10cSrcweir     }
528*cdf0e10cSrcweir }
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir /*************************************************************************
531*cdf0e10cSrcweir |*
532*cdf0e10cSrcweir |* Zuweisungsoperator
533*cdf0e10cSrcweir |*
534*cdf0e10cSrcweir \************************************************************************/
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir void E3dScene::operator=(const SdrObject& rObj)
537*cdf0e10cSrcweir {
538*cdf0e10cSrcweir 	E3dObject::operator=(rObj);
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir 	const E3dScene& r3DObj = (const E3dScene&) rObj;
541*cdf0e10cSrcweir 	aCamera			 = r3DObj.aCamera;
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir 	// neu ab 377:
544*cdf0e10cSrcweir 	aCameraSet = r3DObj.aCameraSet;
545*cdf0e10cSrcweir 	((sdr::properties::E3dSceneProperties&)GetProperties()).SetSceneItemsFromCamera();
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir     // SetSnapRect(r3DObj.GetSnapRect());
548*cdf0e10cSrcweir 	InvalidateBoundVolume();
549*cdf0e10cSrcweir 	RebuildLists();
550*cdf0e10cSrcweir 	SetRectsDirty();
551*cdf0e10cSrcweir 
552*cdf0e10cSrcweir 	// #110988#
553*cdf0e10cSrcweir 	ImpCleanup3DDepthMapper();
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir     // #i101941#
556*cdf0e10cSrcweir     // After a Scene as model object is cloned, the used
557*cdf0e10cSrcweir     // ViewContactOfE3dScene is created and partially used
558*cdf0e10cSrcweir     // to calculate Bound/SnapRects, but - since quite some
559*cdf0e10cSrcweir     // values are buffered at the VC - not really well
560*cdf0e10cSrcweir     // initialized. It would be possible to always watch for
561*cdf0e10cSrcweir     // preconditions of buffered data, but this would be expensive
562*cdf0e10cSrcweir     // and would create a lot of short living data structures.
563*cdf0e10cSrcweir     // It is currently better to flush that data, e.g. by using
564*cdf0e10cSrcweir     // ActionChanged at the VC which will for this class
565*cdf0e10cSrcweir     // flush that cached data and initalize it's valid reconstruction
566*cdf0e10cSrcweir     GetViewContact().ActionChanged();
567*cdf0e10cSrcweir }
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir /*************************************************************************
570*cdf0e10cSrcweir |*
571*cdf0e10cSrcweir |* Licht- und Labelobjektlisten neu aufbauen (nach Laden, Zuweisung)
572*cdf0e10cSrcweir |*
573*cdf0e10cSrcweir \************************************************************************/
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir void E3dScene::RebuildLists()
576*cdf0e10cSrcweir {
577*cdf0e10cSrcweir 	// zuerst loeschen
578*cdf0e10cSrcweir 	SdrLayerID nCurrLayerID = GetLayer();
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir 	SdrObjListIter a3DIterator(maSubList, IM_FLAT);
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir 	// dann alle Objekte in der Szene pruefen
583*cdf0e10cSrcweir 	while ( a3DIterator.IsMore() )
584*cdf0e10cSrcweir 	{
585*cdf0e10cSrcweir 		E3dObject* p3DObj = (E3dObject*) a3DIterator.Next();
586*cdf0e10cSrcweir 		p3DObj->NbcSetLayer(nCurrLayerID);
587*cdf0e10cSrcweir 		NewObjectInserted(p3DObj);
588*cdf0e10cSrcweir 	}
589*cdf0e10cSrcweir }
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir /*************************************************************************
592*cdf0e10cSrcweir |*
593*cdf0e10cSrcweir |* erstelle neues GeoData-Objekt
594*cdf0e10cSrcweir |*
595*cdf0e10cSrcweir \************************************************************************/
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir SdrObjGeoData *E3dScene::NewGeoData() const
598*cdf0e10cSrcweir {
599*cdf0e10cSrcweir 	return new E3DSceneGeoData;
600*cdf0e10cSrcweir }
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir /*************************************************************************
603*cdf0e10cSrcweir |*
604*cdf0e10cSrcweir |* uebergebe aktuelle werte an das GeoData-Objekt
605*cdf0e10cSrcweir |*
606*cdf0e10cSrcweir \************************************************************************/
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir void E3dScene::SaveGeoData(SdrObjGeoData& rGeo) const
609*cdf0e10cSrcweir {
610*cdf0e10cSrcweir 	E3dObject::SaveGeoData (rGeo);
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir 	((E3DSceneGeoData &) rGeo).aCamera = aCamera;
613*cdf0e10cSrcweir }
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir /*************************************************************************
616*cdf0e10cSrcweir |*
617*cdf0e10cSrcweir |* uebernehme werte aus dem GeoData-Objekt
618*cdf0e10cSrcweir |*
619*cdf0e10cSrcweir \************************************************************************/
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir void E3dScene::RestGeoData(const SdrObjGeoData& rGeo)
622*cdf0e10cSrcweir {
623*cdf0e10cSrcweir 	// #i94832# removed E3DModifySceneSnapRectUpdater here.
624*cdf0e10cSrcweir     // It should not be needed, is already part of E3dObject::RestGeoData
625*cdf0e10cSrcweir 	E3dObject::RestGeoData (rGeo);
626*cdf0e10cSrcweir 	SetCamera (((E3DSceneGeoData &) rGeo).aCamera);
627*cdf0e10cSrcweir }
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir /*************************************************************************
630*cdf0e10cSrcweir |*
631*cdf0e10cSrcweir |* Am StyleSheet wurde etwas geaendert, also Scene aendern
632*cdf0e10cSrcweir |*
633*cdf0e10cSrcweir \************************************************************************/
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir void E3dScene::Notify(SfxBroadcaster &rBC, const SfxHint  &rHint)
636*cdf0e10cSrcweir {
637*cdf0e10cSrcweir 	SetRectsDirty();
638*cdf0e10cSrcweir 	E3dObject::Notify(rBC, rHint);
639*cdf0e10cSrcweir }
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir /*************************************************************************
642*cdf0e10cSrcweir |*
643*cdf0e10cSrcweir \************************************************************************/
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir void E3dScene::RotateScene (const Point& rRef, long /*nWink*/, double sn, double cs)
646*cdf0e10cSrcweir {
647*cdf0e10cSrcweir 	Point UpperLeft, LowerRight, Center, NewCenter;
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir 	UpperLeft = aOutRect.TopLeft();
650*cdf0e10cSrcweir 	LowerRight = aOutRect.BottomRight();
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 	long dxOutRectHalf = labs(UpperLeft.X() - LowerRight.X());
653*cdf0e10cSrcweir 	dxOutRectHalf /= 2;
654*cdf0e10cSrcweir 	long dyOutRectHalf = labs(UpperLeft.Y() - LowerRight.Y());
655*cdf0e10cSrcweir 	dyOutRectHalf /= 2;
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir 	Rectangle RectQuelle(aOutRect), RectZiel(aOutRect);
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir 	   // Nur der Mittelpunkt wird bewegt. Die Ecken werden von NbcMove bewegt.
660*cdf0e10cSrcweir 	   // Fuer das Drehen wird von mir ein kartesisches Koordinatensystem verwendet in dem der Drehpunkt
661*cdf0e10cSrcweir 	   // der Nullpunkt ist und die Y- Achse nach oben ansteigt, die X-Achse nach rechts.
662*cdf0e10cSrcweir 	   // Dies muss bei den Y-Werten beachtet werden. (Auf dem Blatt zeigt die Y-Achse nach unten
663*cdf0e10cSrcweir 	Center.X() = (UpperLeft.X() + dxOutRectHalf) - rRef.X();
664*cdf0e10cSrcweir 	Center.Y() = -((UpperLeft.Y() + dyOutRectHalf) - rRef.Y());
665*cdf0e10cSrcweir 				  // Ein paar Spezialfaelle zuerst abhandeln (n*90 Grad n ganzzahlig)
666*cdf0e10cSrcweir     if (sn==1.0 && cs==0.0) { // 90deg
667*cdf0e10cSrcweir 		NewCenter.X() = -Center.Y();
668*cdf0e10cSrcweir 		NewCenter.Y() = -Center.X();
669*cdf0e10cSrcweir     } else if (sn==0.0 && cs==-1.0) { // 180deg
670*cdf0e10cSrcweir 		NewCenter.X() = -Center.X();
671*cdf0e10cSrcweir 		NewCenter.Y() = -Center.Y();
672*cdf0e10cSrcweir     } else if (sn==-1.0 && cs==0.0) { // 270deg
673*cdf0e10cSrcweir 		NewCenter.X() =  Center.Y();
674*cdf0e10cSrcweir 		NewCenter.Y() = -Center.X();
675*cdf0e10cSrcweir 	}
676*cdf0e10cSrcweir 	else          // Hier wird um einen beliebigen Winkel in mathematisch positiver Richtung gedreht!
677*cdf0e10cSrcweir 	{             // xneu = x * cos(alpha) - y * sin(alpha)
678*cdf0e10cSrcweir 				  // yneu = x * sin(alpha) + y * cos(alpha)
679*cdf0e10cSrcweir 				  // Unten Rechts wird nicht gedreht: die Seiten von RectQuelle muessen parallel
680*cdf0e10cSrcweir 				  // zu den Koordinatenachsen bleiben.
681*cdf0e10cSrcweir 		NewCenter.X() = (long) (Center.X() * cs - Center.Y() * sn);
682*cdf0e10cSrcweir 		NewCenter.Y() = (long) (Center.X() * sn + Center.Y() * cs);
683*cdf0e10cSrcweir 	}
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir 	Size Differenz;
686*cdf0e10cSrcweir 	Point DiffPoint = (NewCenter - Center);
687*cdf0e10cSrcweir 	Differenz.Width() = DiffPoint.X();
688*cdf0e10cSrcweir 	Differenz.Height() = -DiffPoint.Y();  // Man beachte dass die Y-Achse nach unten positiv gezaehlt wird.
689*cdf0e10cSrcweir 	NbcMove (Differenz);  // fuehrt die eigentliche Koordinatentransformation durch.
690*cdf0e10cSrcweir }
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir /*************************************************************************
693*cdf0e10cSrcweir |*
694*cdf0e10cSrcweir |* Get the name of the object (singular)
695*cdf0e10cSrcweir |*
696*cdf0e10cSrcweir \************************************************************************/
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir void E3dScene::TakeObjNameSingul(XubString& rName) const
699*cdf0e10cSrcweir {
700*cdf0e10cSrcweir 	rName=ImpGetResStr(STR_ObjNameSingulScene3d);
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir 	String aName( GetName() );
703*cdf0e10cSrcweir 	if(aName.Len())
704*cdf0e10cSrcweir 	{
705*cdf0e10cSrcweir 		rName += sal_Unicode(' ');
706*cdf0e10cSrcweir 		rName += sal_Unicode('\'');
707*cdf0e10cSrcweir 		rName += aName;
708*cdf0e10cSrcweir 		rName += sal_Unicode('\'');
709*cdf0e10cSrcweir 	}
710*cdf0e10cSrcweir }
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir /*************************************************************************
713*cdf0e10cSrcweir |*
714*cdf0e10cSrcweir |* Get the name of the object (plural)
715*cdf0e10cSrcweir |*
716*cdf0e10cSrcweir \************************************************************************/
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir void E3dScene::TakeObjNamePlural(XubString& rName) const
719*cdf0e10cSrcweir {
720*cdf0e10cSrcweir 	rName=ImpGetResStr(STR_ObjNamePluralScene3d);
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir /*************************************************************************
724*cdf0e10cSrcweir |*
725*cdf0e10cSrcweir |* Die NbcRotate-Routine ueberlaedt die des SdrObject. Die Idee ist die Scene
726*cdf0e10cSrcweir |* drehen zu koennen und relativ zur Lage der Scene dann auch die Objekte
727*cdf0e10cSrcweir |* in der Scene
728*cdf0e10cSrcweir |*
729*cdf0e10cSrcweir \************************************************************************/
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir void E3dScene::NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix)
732*cdf0e10cSrcweir {
733*cdf0e10cSrcweir     if(maTransformation != rMatrix)
734*cdf0e10cSrcweir     {
735*cdf0e10cSrcweir 		// call parent
736*cdf0e10cSrcweir 		E3dObject::NbcSetTransform(rMatrix);
737*cdf0e10cSrcweir 	}
738*cdf0e10cSrcweir }
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir void E3dScene::SetTransform(const basegfx::B3DHomMatrix& rMatrix)
741*cdf0e10cSrcweir {
742*cdf0e10cSrcweir     if(rMatrix != maTransformation)
743*cdf0e10cSrcweir     {
744*cdf0e10cSrcweir 		// call parent
745*cdf0e10cSrcweir 		E3dObject::SetTransform(rMatrix);
746*cdf0e10cSrcweir 	}
747*cdf0e10cSrcweir }
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir void E3dScene::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
750*cdf0e10cSrcweir {
751*cdf0e10cSrcweir 	// Also derzeit sind die Klebepunkte relativ zum aOutRect der Szene definiert. Vor dem Drehen
752*cdf0e10cSrcweir 	// werden die Klebepunkte relativ zur Seite definiert. Sie nehmen an der Drehung der Szene noch nicht Teil
753*cdf0e10cSrcweir 	// dafuer gibt es den
754*cdf0e10cSrcweir 	SetGlueReallyAbsolute(sal_True);
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir 	// So dass war die Szene, ab jetzt kommen die Objekte in der Szene
757*cdf0e10cSrcweir     // 3D-Objekte gibt es nur ein einziges das kann zwar mehrere Flaechen haben aber die Flaechen
758*cdf0e10cSrcweir 	// muessen ja nicht zusammenhaengend sein
759*cdf0e10cSrcweir 	// es ermoeglicht den Zugriff auf Kindobjekte
760*cdf0e10cSrcweir 	// Ich gehe also die gesamte Liste durch und rotiere um die Z-Achse die durch den
761*cdf0e10cSrcweir 	// Mittelpunkt von aOutRect geht (Satz von Steiner), also RotateZ
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir 	RotateScene (rRef, nWink, sn, cs);  // Rotiert die Szene
764*cdf0e10cSrcweir 	double fWinkelInRad = nWink/100 * F_PI180;
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir 	basegfx::B3DHomMatrix aRotation;
767*cdf0e10cSrcweir 	aRotation.rotate(0.0, 0.0, fWinkelInRad);
768*cdf0e10cSrcweir 	NbcSetTransform(aRotation * GetTransform());
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir 	SetRectsDirty();    // Veranlasst eine Neuberechnung aller BoundRects
771*cdf0e10cSrcweir 	NbcRotateGluePoints(rRef,nWink,sn,cs);  // Rotiert die Klebepunkte (die haben noch Koordinaten relativ
772*cdf0e10cSrcweir 											// zum Urpsung des Blattes
773*cdf0e10cSrcweir 	SetGlueReallyAbsolute(sal_False);  // ab jetzt sind sie wieder relativ zum BoundRect (also dem aOutRect definiert)
774*cdf0e10cSrcweir 	SetRectsDirty();
775*cdf0e10cSrcweir }
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir /*************************************************************************
778*cdf0e10cSrcweir |*
779*cdf0e10cSrcweir |* SnapRect berechnen
780*cdf0e10cSrcweir |*
781*cdf0e10cSrcweir \************************************************************************/
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir void E3dScene::RecalcSnapRect()
784*cdf0e10cSrcweir {
785*cdf0e10cSrcweir 	E3dScene* pScene = GetScene();
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir 	if(pScene == this)
788*cdf0e10cSrcweir 	{
789*cdf0e10cSrcweir 		// Szene wird als 2D-Objekt benutzt, nimm SnapRect aus der
790*cdf0e10cSrcweir 		// 2D Bildschrimdarstellung
791*cdf0e10cSrcweir 		Camera3D& rCam = (Camera3D&)pScene->GetCamera();
792*cdf0e10cSrcweir 		maSnapRect = rCam.GetDeviceWindow();
793*cdf0e10cSrcweir 	}
794*cdf0e10cSrcweir 	else
795*cdf0e10cSrcweir 	{
796*cdf0e10cSrcweir 		// Szene ist selbst Mitglied einer anderen Szene, hole das
797*cdf0e10cSrcweir 		// SnapRect als zusammengesetztes Objekt
798*cdf0e10cSrcweir 		E3dObject::RecalcSnapRect();
799*cdf0e10cSrcweir 	}
800*cdf0e10cSrcweir }
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir /*************************************************************************
803*cdf0e10cSrcweir |*
804*cdf0e10cSrcweir |* Aufbrechen
805*cdf0e10cSrcweir |*
806*cdf0e10cSrcweir \************************************************************************/
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir sal_Bool E3dScene::IsBreakObjPossible()
809*cdf0e10cSrcweir {
810*cdf0e10cSrcweir 	// Szene ist aufzubrechen, wenn alle Mitglieder aufzubrechen sind
811*cdf0e10cSrcweir 	SdrObjListIter a3DIterator(maSubList, IM_DEEPWITHGROUPS);
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir 	while ( a3DIterator.IsMore() )
814*cdf0e10cSrcweir 	{
815*cdf0e10cSrcweir 		E3dObject* pObj = (E3dObject*) a3DIterator.Next();
816*cdf0e10cSrcweir 		DBG_ASSERT(pObj->ISA(E3dObject), "AW: In Szenen sind nur 3D-Objekte erlaubt!");
817*cdf0e10cSrcweir 		if(!pObj->IsBreakObjPossible())
818*cdf0e10cSrcweir 			return sal_False;
819*cdf0e10cSrcweir 	}
820*cdf0e10cSrcweir 
821*cdf0e10cSrcweir 	return sal_True;
822*cdf0e10cSrcweir }
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir basegfx::B3DVector E3dScene::GetShadowPlaneDirection() const
825*cdf0e10cSrcweir {
826*cdf0e10cSrcweir 	double fWink = (double)GetShadowSlant() * F_PI180;
827*cdf0e10cSrcweir 	basegfx::B3DVector aShadowPlaneDir(0.0, sin(fWink), cos(fWink));
828*cdf0e10cSrcweir 	aShadowPlaneDir.normalize();
829*cdf0e10cSrcweir 	return aShadowPlaneDir;
830*cdf0e10cSrcweir }
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir void E3dScene::SetShadowPlaneDirection(const basegfx::B3DVector& rVec)
833*cdf0e10cSrcweir {
834*cdf0e10cSrcweir 	sal_uInt16 nSceneShadowSlant = (sal_uInt16)((atan2(rVec.getY(), rVec.getZ()) / F_PI180) + 0.5);
835*cdf0e10cSrcweir 	GetProperties().SetObjectItemDirect(Svx3DShadowSlantItem(nSceneShadowSlant));
836*cdf0e10cSrcweir }
837*cdf0e10cSrcweir 
838*cdf0e10cSrcweir basegfx::B2DPolyPolygon E3dScene::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
839*cdf0e10cSrcweir {
840*cdf0e10cSrcweir 	return TakeXorPoly();
841*cdf0e10cSrcweir }
842*cdf0e10cSrcweir 
843*cdf0e10cSrcweir FASTBOOL E3dScene::BegCreate(SdrDragStat& rStat)
844*cdf0e10cSrcweir {
845*cdf0e10cSrcweir 	rStat.SetOrtho4Possible();
846*cdf0e10cSrcweir 	Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
847*cdf0e10cSrcweir 	aRect1.Justify();
848*cdf0e10cSrcweir 	rStat.SetActionRect(aRect1);
849*cdf0e10cSrcweir 	NbcSetSnapRect(aRect1);
850*cdf0e10cSrcweir 	return sal_True;
851*cdf0e10cSrcweir }
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir FASTBOOL E3dScene::MovCreate(SdrDragStat& rStat)
854*cdf0e10cSrcweir {
855*cdf0e10cSrcweir 	Rectangle aRect1;
856*cdf0e10cSrcweir 	rStat.TakeCreateRect(aRect1);
857*cdf0e10cSrcweir 	aRect1.Justify();
858*cdf0e10cSrcweir 	rStat.SetActionRect(aRect1);
859*cdf0e10cSrcweir 	NbcSetSnapRect(aRect1);
860*cdf0e10cSrcweir 	SetBoundRectDirty();
861*cdf0e10cSrcweir 	bSnapRectDirty=sal_True;
862*cdf0e10cSrcweir 	return sal_True;
863*cdf0e10cSrcweir }
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir FASTBOOL E3dScene::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
866*cdf0e10cSrcweir {
867*cdf0e10cSrcweir 	Rectangle aRect1;
868*cdf0e10cSrcweir 	rStat.TakeCreateRect(aRect1);
869*cdf0e10cSrcweir 	aRect1.Justify();
870*cdf0e10cSrcweir 	NbcSetSnapRect(aRect1);
871*cdf0e10cSrcweir 	SetRectsDirty();
872*cdf0e10cSrcweir 	return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
873*cdf0e10cSrcweir }
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir FASTBOOL E3dScene::BckCreate(SdrDragStat& /*rStat*/)
876*cdf0e10cSrcweir {
877*cdf0e10cSrcweir 	return sal_False;
878*cdf0e10cSrcweir }
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir void E3dScene::BrkCreate(SdrDragStat& /*rStat*/)
881*cdf0e10cSrcweir {
882*cdf0e10cSrcweir }
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir // eof
885