1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*f6e50924SAndrew Rist * distributed with this work for additional information
6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10*f6e50924SAndrew Rist *
11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist *
13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17*f6e50924SAndrew Rist * specific language governing permissions and limitations
18*f6e50924SAndrew Rist * under the License.
19*f6e50924SAndrew Rist *
20*f6e50924SAndrew Rist *************************************************************/
21*f6e50924SAndrew Rist
22*f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "svx/svdstr.hrc"
28cdf0e10cSrcweir #include "svx/svdglob.hxx"
29cdf0e10cSrcweir #include <svx/svdview.hxx>
30cdf0e10cSrcweir #include <svx/svdattr.hxx>
31cdf0e10cSrcweir #include <svx/svdpage.hxx>
32cdf0e10cSrcweir #include <svx/svdmodel.hxx>
33cdf0e10cSrcweir #include "svx/svditer.hxx"
34cdf0e10cSrcweir #include "svx/globl3d.hxx"
35cdf0e10cSrcweir #include <svx/camera3d.hxx>
36cdf0e10cSrcweir #include <svx/scene3d.hxx>
37cdf0e10cSrcweir #include <svx/polysc3d.hxx>
38cdf0e10cSrcweir #include <svx/cube3d.hxx>
39cdf0e10cSrcweir #include <svx/lathe3d.hxx>
40cdf0e10cSrcweir #include <svx/sphere3d.hxx>
41cdf0e10cSrcweir #include <svx/extrud3d.hxx>
42cdf0e10cSrcweir #include <svx/obj3d.hxx>
43cdf0e10cSrcweir #include <svx/xtable.hxx>
44cdf0e10cSrcweir #include <svx/xflclit.hxx>
45cdf0e10cSrcweir #include <vcl/svapp.hxx>
46cdf0e10cSrcweir #include <vcl/settings.hxx>
47cdf0e10cSrcweir #include <svx/xlnclit.hxx>
48cdf0e10cSrcweir #include <svl/metitem.hxx>
49cdf0e10cSrcweir #include <svx/xtable.hxx>
50cdf0e10cSrcweir #include <svx/xfillit.hxx>
51cdf0e10cSrcweir #include <svx/xlnwtit.hxx>
52cdf0e10cSrcweir #include <vcl/virdev.hxx>
53cdf0e10cSrcweir #include <tools/poly.hxx>
54cdf0e10cSrcweir #include <tools/b3dtrans.hxx>
55cdf0e10cSrcweir #include <svx/svxids.hrc>
56cdf0e10cSrcweir #include <editeng/colritem.hxx>
57cdf0e10cSrcweir #include <svx/e3ditem.hxx>
58cdf0e10cSrcweir #include <svx/xlntrit.hxx>
59cdf0e10cSrcweir #include <svx/xfltrit.hxx>
60cdf0e10cSrcweir #include <svx/svdpagv.hxx>
61cdf0e10cSrcweir #include <vcl/gradient.hxx>
62cdf0e10cSrcweir #include <vcl/metaact.hxx>
63cdf0e10cSrcweir #include <svx/svx3ditems.hxx>
64cdf0e10cSrcweir #include <svl/whiter.hxx>
65cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
66cdf0e10cSrcweir #include <editeng/eeitem.hxx>
67cdf0e10cSrcweir #include <svx/xgrscit.hxx>
68cdf0e10cSrcweir #include "svdoimp.hxx"
69cdf0e10cSrcweir #include <svx/sdr/properties/e3dproperties.hxx>
70cdf0e10cSrcweir #include <svx/sdr/properties/e3dcompoundproperties.hxx>
71cdf0e10cSrcweir #include <basegfx/polygon/b3dpolypolygontools.hxx>
72cdf0e10cSrcweir #include <basegfx/point/b3dpoint.hxx>
73cdf0e10cSrcweir #include <basegfx/vector/b3dvector.hxx>
74cdf0e10cSrcweir #include <svx/xlndsit.hxx>
75cdf0e10cSrcweir #include <basegfx/matrix/b3dhommatrix.hxx>
76cdf0e10cSrcweir #include <basegfx/polygon/b3dpolygon.hxx>
77cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
78cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
79cdf0e10cSrcweir #include <basegfx/polygon/b3dpolygontools.hxx>
80cdf0e10cSrcweir #include <svx/helperhittest3d.hxx>
81cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofe3d.hxx>
82cdf0e10cSrcweir #include <drawinglayer/geometry/viewinformation3d.hxx>
83cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
84cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofe3dscene.hxx>
85cdf0e10cSrcweir #include <basegfx/polygon/b3dpolypolygontools.hxx>
86cdf0e10cSrcweir #include <svx/e3dsceneupdater.hxx>
87cdf0e10cSrcweir
88cdf0e10cSrcweir #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
89cdf0e10cSrcweir
90cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
91cdf0e10cSrcweir
92cdf0e10cSrcweir using namespace com::sun::star;
93cdf0e10cSrcweir
94cdf0e10cSrcweir /*************************************************************************
95cdf0e10cSrcweir |*
96cdf0e10cSrcweir |* Liste fuer 3D-Objekte
97cdf0e10cSrcweir |*
98cdf0e10cSrcweir \************************************************************************/
99cdf0e10cSrcweir
100cdf0e10cSrcweir TYPEINIT1(E3dObjList, SdrObjList);
101cdf0e10cSrcweir
E3dObjList(SdrModel * pNewModel,SdrPage * pNewPage,E3dObjList * pNewUpList)102cdf0e10cSrcweir E3dObjList::E3dObjList(SdrModel* pNewModel, SdrPage* pNewPage, E3dObjList* pNewUpList)
103cdf0e10cSrcweir : SdrObjList(pNewModel, pNewPage, pNewUpList)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
E3dObjList(const E3dObjList & rSrcList)107cdf0e10cSrcweir E3dObjList::E3dObjList(const E3dObjList& rSrcList)
108cdf0e10cSrcweir : SdrObjList(rSrcList)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
~E3dObjList()112cdf0e10cSrcweir E3dObjList::~E3dObjList()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir }
115cdf0e10cSrcweir
NbcInsertObject(SdrObject * pObj,sal_uIntPtr nPos,const SdrInsertReason * pReason)116cdf0e10cSrcweir void E3dObjList::NbcInsertObject(SdrObject* pObj, sal_uIntPtr nPos, const SdrInsertReason* pReason)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir // Owner holen
119cdf0e10cSrcweir DBG_ASSERT(GetOwnerObj()->ISA(E3dObject), "AW: Einfuegen 3DObject in Parent != 3DObject");
120cdf0e10cSrcweir
121cdf0e10cSrcweir // Ist es ueberhaupt ein 3D-Objekt?
122cdf0e10cSrcweir if(pObj && pObj->ISA(E3dObject))
123cdf0e10cSrcweir {
124cdf0e10cSrcweir // Normales 3D Objekt, einfuegen mittels
125cdf0e10cSrcweir // call parent
126cdf0e10cSrcweir SdrObjList::NbcInsertObject(pObj, nPos, pReason);
127cdf0e10cSrcweir }
128cdf0e10cSrcweir else
129cdf0e10cSrcweir {
130cdf0e10cSrcweir // Kein 3D Objekt, fuege in Seite statt in Szene ein...
131cdf0e10cSrcweir GetOwnerObj()->GetPage()->InsertObject(pObj, nPos);
132cdf0e10cSrcweir }
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
InsertObject(SdrObject * pObj,sal_uIntPtr nPos,const SdrInsertReason * pReason)135cdf0e10cSrcweir void E3dObjList::InsertObject(SdrObject* pObj, sal_uIntPtr nPos, const SdrInsertReason* pReason)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir OSL_ENSURE(GetOwnerObj()->ISA(E3dObject), "Insert 3DObject in non-3D Parent");
138cdf0e10cSrcweir //E3DModifySceneSnapRectUpdater aUpdater(GetOwnerObj());
139cdf0e10cSrcweir
140cdf0e10cSrcweir // call parent
141cdf0e10cSrcweir SdrObjList::InsertObject(pObj, nPos, pReason);
142cdf0e10cSrcweir
143cdf0e10cSrcweir E3dScene* pScene = ((E3dObject*)GetOwnerObj())->GetScene();
144cdf0e10cSrcweir if(pScene)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir pScene->Cleanup3DDepthMapper();
147cdf0e10cSrcweir }
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
NbcRemoveObject(sal_uIntPtr nObjNum)150cdf0e10cSrcweir SdrObject* E3dObjList::NbcRemoveObject(sal_uIntPtr nObjNum)
151cdf0e10cSrcweir {
152cdf0e10cSrcweir DBG_ASSERT(GetOwnerObj()->ISA(E3dObject), "AW: Entfernen 3DObject aus Parent != 3DObject");
153cdf0e10cSrcweir //E3DModifySceneSnapRectUpdater aUpdater(GetOwnerObj());
154cdf0e10cSrcweir
155cdf0e10cSrcweir // call parent
156cdf0e10cSrcweir SdrObject* pRetval = SdrObjList::NbcRemoveObject(nObjNum);
157cdf0e10cSrcweir
158cdf0e10cSrcweir E3dScene* pScene = ((E3dObject*)GetOwnerObj())->GetScene();
159cdf0e10cSrcweir if(pScene)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir pScene->Cleanup3DDepthMapper();
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir return pRetval;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
RemoveObject(sal_uIntPtr nObjNum)167cdf0e10cSrcweir SdrObject* E3dObjList::RemoveObject(sal_uIntPtr nObjNum)
168cdf0e10cSrcweir {
169cdf0e10cSrcweir OSL_ENSURE(GetOwnerObj()->ISA(E3dObject), "3DObject is removed from non-3D Parent");
170cdf0e10cSrcweir //E3DModifySceneSnapRectUpdater aUpdater(GetOwnerObj());
171cdf0e10cSrcweir
172cdf0e10cSrcweir // call parent
173cdf0e10cSrcweir SdrObject* pRetval = SdrObjList::RemoveObject(nObjNum);
174cdf0e10cSrcweir
175cdf0e10cSrcweir E3dScene* pScene = ((E3dObject*)GetOwnerObj())->GetScene();
176cdf0e10cSrcweir if(pScene)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir pScene->Cleanup3DDepthMapper();
179cdf0e10cSrcweir }
180cdf0e10cSrcweir
181cdf0e10cSrcweir return pRetval;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184cdf0e10cSrcweir /*************************************************************************
185cdf0e10cSrcweir |*
186cdf0e10cSrcweir |* Konstruktor
187cdf0e10cSrcweir |*
188cdf0e10cSrcweir \************************************************************************/
189cdf0e10cSrcweir
190cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
191cdf0e10cSrcweir
CreateObjectSpecificProperties()192cdf0e10cSrcweir sdr::properties::BaseProperties* E3dObject::CreateObjectSpecificProperties()
193cdf0e10cSrcweir {
194cdf0e10cSrcweir return new sdr::properties::E3dProperties(*this);
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
198cdf0e10cSrcweir
199cdf0e10cSrcweir TYPEINIT1(E3dObject, SdrAttrObj);
200cdf0e10cSrcweir
E3dObject()201cdf0e10cSrcweir E3dObject::E3dObject()
202cdf0e10cSrcweir : maSubList(),
203cdf0e10cSrcweir maLocalBoundVol(),
204cdf0e10cSrcweir maTransformation(),
205cdf0e10cSrcweir maFullTransform(),
206cdf0e10cSrcweir mbTfHasChanged(true),
207cdf0e10cSrcweir mbIsSelected(false)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir bIs3DObj = true;
210cdf0e10cSrcweir maSubList.SetOwnerObj(this);
211cdf0e10cSrcweir maSubList.SetListKind(SDROBJLIST_GROUPOBJ);
212cdf0e10cSrcweir bClosedObj = true;
213cdf0e10cSrcweir }
214cdf0e10cSrcweir
215cdf0e10cSrcweir /*************************************************************************
216cdf0e10cSrcweir |*
217cdf0e10cSrcweir |* Destruktor
218cdf0e10cSrcweir |*
219cdf0e10cSrcweir \************************************************************************/
220cdf0e10cSrcweir
~E3dObject()221cdf0e10cSrcweir E3dObject::~E3dObject()
222cdf0e10cSrcweir {
223cdf0e10cSrcweir }
224cdf0e10cSrcweir
225cdf0e10cSrcweir /*************************************************************************
226cdf0e10cSrcweir |*
227cdf0e10cSrcweir |* Selektions-Flag setzen
228cdf0e10cSrcweir |*
229cdf0e10cSrcweir \************************************************************************/
230cdf0e10cSrcweir
SetSelected(bool bNew)231cdf0e10cSrcweir void E3dObject::SetSelected(bool bNew)
232cdf0e10cSrcweir {
233cdf0e10cSrcweir if((bool)mbIsSelected != bNew)
234cdf0e10cSrcweir {
235cdf0e10cSrcweir mbIsSelected = bNew;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir
238cdf0e10cSrcweir for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
241cdf0e10cSrcweir
242cdf0e10cSrcweir if(pCandidate)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir pCandidate->SetSelected(bNew);
245cdf0e10cSrcweir }
246cdf0e10cSrcweir }
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
249cdf0e10cSrcweir /*************************************************************************
250cdf0e10cSrcweir |*
251cdf0e10cSrcweir |* Aufbrechen, default-Implementierungen
252cdf0e10cSrcweir |*
253cdf0e10cSrcweir \************************************************************************/
254cdf0e10cSrcweir
IsBreakObjPossible()255cdf0e10cSrcweir sal_Bool E3dObject::IsBreakObjPossible()
256cdf0e10cSrcweir {
257cdf0e10cSrcweir return sal_False;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
GetBreakObj()260cdf0e10cSrcweir SdrAttrObj* E3dObject::GetBreakObj()
261cdf0e10cSrcweir {
262cdf0e10cSrcweir return 0L;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
265cdf0e10cSrcweir /*************************************************************************
266cdf0e10cSrcweir |*
267cdf0e10cSrcweir |* SetRectsDirty muss ueber die lokale SdrSubList gehen
268cdf0e10cSrcweir |*
269cdf0e10cSrcweir \************************************************************************/
270cdf0e10cSrcweir
SetRectsDirty(sal_Bool bNotMyself)271cdf0e10cSrcweir void E3dObject::SetRectsDirty(sal_Bool bNotMyself)
272cdf0e10cSrcweir {
273cdf0e10cSrcweir // call parent
274cdf0e10cSrcweir SdrAttrObj::SetRectsDirty(bNotMyself);
275cdf0e10cSrcweir
276cdf0e10cSrcweir for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
277cdf0e10cSrcweir {
278cdf0e10cSrcweir E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
279cdf0e10cSrcweir
280cdf0e10cSrcweir if(pCandidate)
281cdf0e10cSrcweir {
282cdf0e10cSrcweir pCandidate->SetRectsDirty(bNotMyself);
283cdf0e10cSrcweir }
284cdf0e10cSrcweir }
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
287cdf0e10cSrcweir /*************************************************************************
288cdf0e10cSrcweir |*
289cdf0e10cSrcweir |* Inventor zurueckgeben
290cdf0e10cSrcweir |*
291cdf0e10cSrcweir \************************************************************************/
292cdf0e10cSrcweir
GetObjInventor() const293cdf0e10cSrcweir sal_uInt32 E3dObject::GetObjInventor() const
294cdf0e10cSrcweir {
295cdf0e10cSrcweir return E3dInventor;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
298cdf0e10cSrcweir /*************************************************************************
299cdf0e10cSrcweir |*
300cdf0e10cSrcweir |* Identifier zurueckgeben
301cdf0e10cSrcweir |*
302cdf0e10cSrcweir \************************************************************************/
303cdf0e10cSrcweir
GetObjIdentifier() const304cdf0e10cSrcweir sal_uInt16 E3dObject::GetObjIdentifier() const
305cdf0e10cSrcweir {
306cdf0e10cSrcweir return E3D_OBJECT_ID;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir
309cdf0e10cSrcweir /*************************************************************************
310cdf0e10cSrcweir |*
311cdf0e10cSrcweir |* Faehigkeiten des Objektes feststellen
312cdf0e10cSrcweir |*
313cdf0e10cSrcweir \************************************************************************/
314cdf0e10cSrcweir
TakeObjInfo(SdrObjTransformInfoRec & rInfo) const315cdf0e10cSrcweir void E3dObject::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
316cdf0e10cSrcweir {
317cdf0e10cSrcweir rInfo.bResizeFreeAllowed = sal_True;
318cdf0e10cSrcweir rInfo.bResizePropAllowed = sal_True;
319cdf0e10cSrcweir rInfo.bRotateFreeAllowed = sal_True;
320cdf0e10cSrcweir rInfo.bRotate90Allowed = sal_True;
321cdf0e10cSrcweir rInfo.bMirrorFreeAllowed = sal_False;
322cdf0e10cSrcweir rInfo.bMirror45Allowed = sal_False;
323cdf0e10cSrcweir rInfo.bMirror90Allowed = sal_False;
324cdf0e10cSrcweir rInfo.bShearAllowed = sal_False;
325cdf0e10cSrcweir rInfo.bEdgeRadiusAllowed = sal_False;
326cdf0e10cSrcweir rInfo.bCanConvToPath = sal_False;
327cdf0e10cSrcweir
328cdf0e10cSrcweir // no transparence for 3d objects
329cdf0e10cSrcweir rInfo.bTransparenceAllowed = sal_False;
330cdf0e10cSrcweir
331cdf0e10cSrcweir // gradient depends on fillstyle
332cdf0e10cSrcweir // BM *** check if SetItem is NULL ***
333cdf0e10cSrcweir XFillStyle eFillStyle = ((XFillStyleItem&)(GetMergedItem(XATTR_FILLSTYLE))).GetValue();
334cdf0e10cSrcweir rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT);
335cdf0e10cSrcweir
336cdf0e10cSrcweir // Umwandeln von 3D-Koerpern in Gruppe von Polygonen:
337cdf0e10cSrcweir //
338cdf0e10cSrcweir // Erst mal nicht moeglich, da die Erzeugung einer Gruppe von
339cdf0e10cSrcweir // 2D-Polygonen notwendig waere, die tiefensortiert werden muessten,
340cdf0e10cSrcweir // also bei Durchdringugnen auch gegeneinander geschnitten werden
341cdf0e10cSrcweir // muessten. Auch die Texturkoorinaten waeren ein ungeloestes
342cdf0e10cSrcweir // Problem.
343cdf0e10cSrcweir rInfo.bCanConvToPoly = sal_False;
344cdf0e10cSrcweir rInfo.bCanConvToContour = sal_False;
345cdf0e10cSrcweir rInfo.bCanConvToPathLineToArea = sal_False;
346cdf0e10cSrcweir rInfo.bCanConvToPolyLineToArea = sal_False;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir
349cdf0e10cSrcweir /*************************************************************************
350cdf0e10cSrcweir |*
351cdf0e10cSrcweir |* Layer setzen
352cdf0e10cSrcweir |*
353cdf0e10cSrcweir \************************************************************************/
354cdf0e10cSrcweir
NbcSetLayer(SdrLayerID nLayer)355cdf0e10cSrcweir void E3dObject::NbcSetLayer(SdrLayerID nLayer)
356cdf0e10cSrcweir {
357cdf0e10cSrcweir SdrAttrObj::NbcSetLayer(nLayer);
358cdf0e10cSrcweir
359cdf0e10cSrcweir for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
362cdf0e10cSrcweir
363cdf0e10cSrcweir if(pCandidate)
364cdf0e10cSrcweir {
365cdf0e10cSrcweir pCandidate->NbcSetLayer(nLayer);
366cdf0e10cSrcweir }
367cdf0e10cSrcweir }
368cdf0e10cSrcweir }
369cdf0e10cSrcweir
370cdf0e10cSrcweir /*************************************************************************
371cdf0e10cSrcweir |*
372cdf0e10cSrcweir |* ObjList auch an SubList setzen
373cdf0e10cSrcweir |*
374cdf0e10cSrcweir \************************************************************************/
375cdf0e10cSrcweir
SetObjList(SdrObjList * pNewObjList)376cdf0e10cSrcweir void E3dObject::SetObjList(SdrObjList* pNewObjList)
377cdf0e10cSrcweir {
378cdf0e10cSrcweir SdrObject::SetObjList(pNewObjList);
379cdf0e10cSrcweir maSubList.SetUpList(pNewObjList);
380cdf0e10cSrcweir }
381cdf0e10cSrcweir
382cdf0e10cSrcweir /*************************************************************************
383cdf0e10cSrcweir |*
384cdf0e10cSrcweir |* Layer setzen
385cdf0e10cSrcweir |*
386cdf0e10cSrcweir \************************************************************************/
387cdf0e10cSrcweir
SetPage(SdrPage * pNewPage)388cdf0e10cSrcweir void E3dObject::SetPage(SdrPage* pNewPage)
389cdf0e10cSrcweir {
390cdf0e10cSrcweir SdrAttrObj::SetPage(pNewPage);
391cdf0e10cSrcweir maSubList.SetPage(pNewPage);
392cdf0e10cSrcweir }
393cdf0e10cSrcweir
394cdf0e10cSrcweir /*************************************************************************
395cdf0e10cSrcweir |*
396cdf0e10cSrcweir |* Layer setzen
397cdf0e10cSrcweir |*
398cdf0e10cSrcweir \************************************************************************/
399cdf0e10cSrcweir
SetModel(SdrModel * pNewModel)400cdf0e10cSrcweir void E3dObject::SetModel(SdrModel* pNewModel)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir SdrAttrObj::SetModel(pNewModel);
403cdf0e10cSrcweir maSubList.SetModel(pNewModel);
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir /*************************************************************************
407cdf0e10cSrcweir |*
408cdf0e10cSrcweir |* resize object, used from old 2d interfaces, e.g. in Move/Scale dialog
409cdf0e10cSrcweir |* (F4)
410cdf0e10cSrcweir |*
411cdf0e10cSrcweir \************************************************************************/
NbcResize(const Point & rRef,const Fraction & xFact,const Fraction & yFact)412cdf0e10cSrcweir void E3dObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
413cdf0e10cSrcweir {
414cdf0e10cSrcweir // Bewegung in X,Y im Augkoordinatensystem
415cdf0e10cSrcweir E3dScene* pScene = GetScene();
416cdf0e10cSrcweir
417cdf0e10cSrcweir if(pScene)
418cdf0e10cSrcweir {
419cdf0e10cSrcweir // transform pos from 2D world to 3D eye
420cdf0e10cSrcweir const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
421cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
422cdf0e10cSrcweir basegfx::B2DPoint aScaleCenter2D((double)rRef.X(), (double)rRef.Y());
423cdf0e10cSrcweir basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
424cdf0e10cSrcweir
425cdf0e10cSrcweir aInverseSceneTransform.invert();
426cdf0e10cSrcweir aScaleCenter2D = aInverseSceneTransform * aScaleCenter2D;
427cdf0e10cSrcweir
428cdf0e10cSrcweir basegfx::B3DPoint aScaleCenter3D(aScaleCenter2D.getX(), aScaleCenter2D.getY(), 0.5);
429cdf0e10cSrcweir basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
430cdf0e10cSrcweir
431cdf0e10cSrcweir aInverseViewToEye.invert();
432cdf0e10cSrcweir aScaleCenter3D = aInverseViewToEye * aScaleCenter3D;
433cdf0e10cSrcweir
434cdf0e10cSrcweir // scale-faktoren holen
435cdf0e10cSrcweir double fScaleX(xFact);
436cdf0e10cSrcweir double fScaleY(yFact);
437cdf0e10cSrcweir
438cdf0e10cSrcweir // build transform
439cdf0e10cSrcweir basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
440cdf0e10cSrcweir aInverseOrientation.invert();
441cdf0e10cSrcweir basegfx::B3DHomMatrix mFullTransform(GetFullTransform());
442cdf0e10cSrcweir basegfx::B3DHomMatrix mTrans(mFullTransform);
443cdf0e10cSrcweir
444cdf0e10cSrcweir mTrans *= aViewInfo3D.getOrientation();
445cdf0e10cSrcweir mTrans.translate(-aScaleCenter3D.getX(), -aScaleCenter3D.getY(), -aScaleCenter3D.getZ());
446cdf0e10cSrcweir mTrans.scale(fScaleX, fScaleY, 1.0);
447cdf0e10cSrcweir mTrans.translate(aScaleCenter3D.getX(), aScaleCenter3D.getY(), aScaleCenter3D.getZ());
448cdf0e10cSrcweir mTrans *= aInverseOrientation;
449cdf0e10cSrcweir mFullTransform.invert();
450cdf0e10cSrcweir mTrans *= mFullTransform;
451cdf0e10cSrcweir
452cdf0e10cSrcweir // anwenden
453cdf0e10cSrcweir basegfx::B3DHomMatrix mObjTrans(GetTransform());
454cdf0e10cSrcweir mObjTrans *= mTrans;
455cdf0e10cSrcweir
456cdf0e10cSrcweir E3DModifySceneSnapRectUpdater aUpdater(this);
457cdf0e10cSrcweir SetTransform(mObjTrans);
458cdf0e10cSrcweir }
459cdf0e10cSrcweir }
460cdf0e10cSrcweir
461cdf0e10cSrcweir /*************************************************************************
462cdf0e10cSrcweir |*
463cdf0e10cSrcweir |* Objekt verschieben in 2D, wird bei Cursortasten benoetigt
464cdf0e10cSrcweir |*
465cdf0e10cSrcweir \************************************************************************/
NbcMove(const Size & rSize)466cdf0e10cSrcweir void E3dObject::NbcMove(const Size& rSize)
467cdf0e10cSrcweir {
468cdf0e10cSrcweir // Bewegung in X,Y im Augkoordinatensystem
469cdf0e10cSrcweir E3dScene* pScene = GetScene();
470cdf0e10cSrcweir
471cdf0e10cSrcweir if(pScene)
472cdf0e10cSrcweir {
473cdf0e10cSrcweir // Abmessungen der Szene in 3D und 2D als Vergleich
474cdf0e10cSrcweir Rectangle aRect = pScene->GetSnapRect();
475cdf0e10cSrcweir
476cdf0e10cSrcweir // Transformation Weltkoordinaten bis eine VOR Objektkoordinaten holen
477cdf0e10cSrcweir basegfx::B3DHomMatrix mInvDispTransform;
478cdf0e10cSrcweir if(GetParentObj())
479cdf0e10cSrcweir {
480cdf0e10cSrcweir mInvDispTransform = GetParentObj()->GetFullTransform();
481cdf0e10cSrcweir mInvDispTransform.invert();
482cdf0e10cSrcweir }
483cdf0e10cSrcweir
484cdf0e10cSrcweir // BoundVolume from 3d world to 3d eye
485cdf0e10cSrcweir const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
486cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
487cdf0e10cSrcweir basegfx::B3DRange aEyeVol(pScene->GetBoundVolume());
488cdf0e10cSrcweir aEyeVol.transform(aViewInfo3D.getOrientation());
489cdf0e10cSrcweir
490cdf0e10cSrcweir // build relative movement vector in eye coordinates
491cdf0e10cSrcweir basegfx::B3DPoint aMove(
492cdf0e10cSrcweir (double)rSize.Width() * aEyeVol.getWidth() / (double)aRect.GetWidth(),
493cdf0e10cSrcweir (double)-rSize.Height() * aEyeVol.getHeight() / (double)aRect.GetHeight(),
494cdf0e10cSrcweir 0.0);
495cdf0e10cSrcweir basegfx::B3DPoint aPos(0.0, 0.0, 0.0);
496cdf0e10cSrcweir
497cdf0e10cSrcweir // movement vektor to local coordinates of objects' parent
498cdf0e10cSrcweir basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
499cdf0e10cSrcweir aInverseOrientation.invert();
500cdf0e10cSrcweir basegfx::B3DHomMatrix aCompleteTrans(mInvDispTransform * aInverseOrientation);
501cdf0e10cSrcweir
502cdf0e10cSrcweir aMove = aCompleteTrans * aMove;
503cdf0e10cSrcweir aPos = aCompleteTrans * aPos;
504cdf0e10cSrcweir
505cdf0e10cSrcweir // build transformation and apply
506cdf0e10cSrcweir basegfx::B3DHomMatrix aTranslate;
507cdf0e10cSrcweir aTranslate.translate(aMove.getX() - aPos.getX(), aMove.getY() - aPos.getY(), aMove.getZ() - aPos.getZ());
508cdf0e10cSrcweir
509cdf0e10cSrcweir E3DModifySceneSnapRectUpdater aUpdater(pScene);
510cdf0e10cSrcweir SetTransform(aTranslate * GetTransform());
511cdf0e10cSrcweir }
512cdf0e10cSrcweir }
513cdf0e10cSrcweir
514cdf0e10cSrcweir /*************************************************************************
515cdf0e10cSrcweir |*
516cdf0e10cSrcweir |* liefere die Sublist, aber nur dann, wenn darin Objekte enthalten sind !
517cdf0e10cSrcweir |*
518cdf0e10cSrcweir \************************************************************************/
519cdf0e10cSrcweir
GetSubList() const520cdf0e10cSrcweir SdrObjList* E3dObject::GetSubList() const
521cdf0e10cSrcweir {
522cdf0e10cSrcweir return &(const_cast< E3dObjList& >(maSubList));
523cdf0e10cSrcweir }
524cdf0e10cSrcweir
525cdf0e10cSrcweir /*************************************************************************
526cdf0e10cSrcweir |*
527cdf0e10cSrcweir |* SnapRect berechnen
528cdf0e10cSrcweir |*
529cdf0e10cSrcweir \************************************************************************/
530cdf0e10cSrcweir
RecalcSnapRect()531cdf0e10cSrcweir void E3dObject::RecalcSnapRect()
532cdf0e10cSrcweir {
533cdf0e10cSrcweir maSnapRect = Rectangle();
534cdf0e10cSrcweir
535cdf0e10cSrcweir for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
536cdf0e10cSrcweir {
537cdf0e10cSrcweir E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
538cdf0e10cSrcweir
539cdf0e10cSrcweir if(pCandidate)
540cdf0e10cSrcweir {
541cdf0e10cSrcweir maSnapRect.Union(pCandidate->GetSnapRect());
542cdf0e10cSrcweir }
543cdf0e10cSrcweir }
544cdf0e10cSrcweir }
545cdf0e10cSrcweir
546cdf0e10cSrcweir /*************************************************************************
547cdf0e10cSrcweir |*
548cdf0e10cSrcweir |* Einfuegen eines 3D-Objekts an den Parent weitermelden, damit dieser
549cdf0e10cSrcweir |* ggf. eine Sonderbehandlung fuer spezielle Objekte durchfuehren kann
550cdf0e10cSrcweir |* (z.B. Light/Label in E3dScene)
551cdf0e10cSrcweir |*
552cdf0e10cSrcweir \************************************************************************/
553cdf0e10cSrcweir
NewObjectInserted(const E3dObject * p3DObj)554cdf0e10cSrcweir void E3dObject::NewObjectInserted(const E3dObject* p3DObj)
555cdf0e10cSrcweir {
556cdf0e10cSrcweir if(GetParentObj())
557cdf0e10cSrcweir GetParentObj()->NewObjectInserted(p3DObj);
558cdf0e10cSrcweir }
559cdf0e10cSrcweir
560cdf0e10cSrcweir /*************************************************************************
561cdf0e10cSrcweir |*
562cdf0e10cSrcweir |* Parent ueber Aenderung der Struktur (z.B. durch Transformation)
563cdf0e10cSrcweir |* informieren; dabei wird das Objekt, in welchem die Aenderung
564cdf0e10cSrcweir |* aufgetreten ist, uebergeben
565cdf0e10cSrcweir |*
566cdf0e10cSrcweir \************************************************************************/
567cdf0e10cSrcweir
StructureChanged()568cdf0e10cSrcweir void E3dObject::StructureChanged()
569cdf0e10cSrcweir {
570cdf0e10cSrcweir if ( GetParentObj() )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir GetParentObj()->InvalidateBoundVolume();
573cdf0e10cSrcweir GetParentObj()->StructureChanged();
574cdf0e10cSrcweir }
575cdf0e10cSrcweir }
576cdf0e10cSrcweir
577cdf0e10cSrcweir /*************************************************************************
578cdf0e10cSrcweir |*
579cdf0e10cSrcweir |* 3D-Objekt einfuegen
580cdf0e10cSrcweir |*
581cdf0e10cSrcweir \************************************************************************/
582cdf0e10cSrcweir
Insert3DObj(E3dObject * p3DObj)583cdf0e10cSrcweir void E3dObject::Insert3DObj(E3dObject* p3DObj)
584cdf0e10cSrcweir {
585cdf0e10cSrcweir DBG_ASSERT(p3DObj, "Insert3DObj mit NULL-Zeiger!");
586cdf0e10cSrcweir SdrPage* pPg = pPage;
587cdf0e10cSrcweir maSubList.InsertObject(p3DObj);
588cdf0e10cSrcweir pPage = pPg;
589cdf0e10cSrcweir InvalidateBoundVolume();
590cdf0e10cSrcweir NewObjectInserted(p3DObj);
591cdf0e10cSrcweir StructureChanged();
592cdf0e10cSrcweir }
593cdf0e10cSrcweir
Remove3DObj(E3dObject * p3DObj)594cdf0e10cSrcweir void E3dObject::Remove3DObj(E3dObject* p3DObj)
595cdf0e10cSrcweir {
596cdf0e10cSrcweir DBG_ASSERT(p3DObj, "Remove3DObj mit NULL-Zeiger!");
597cdf0e10cSrcweir
598cdf0e10cSrcweir if(p3DObj->GetParentObj() == this)
599cdf0e10cSrcweir {
600cdf0e10cSrcweir SdrPage* pPg = pPage;
601cdf0e10cSrcweir maSubList.RemoveObject(p3DObj->GetOrdNum());
602cdf0e10cSrcweir pPage = pPg;
603cdf0e10cSrcweir
604cdf0e10cSrcweir InvalidateBoundVolume();
605cdf0e10cSrcweir StructureChanged();
606cdf0e10cSrcweir }
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir /*************************************************************************
610cdf0e10cSrcweir |*
611cdf0e10cSrcweir |* Parent holen
612cdf0e10cSrcweir |*
613cdf0e10cSrcweir \************************************************************************/
614cdf0e10cSrcweir
GetParentObj() const615cdf0e10cSrcweir E3dObject* E3dObject::GetParentObj() const
616cdf0e10cSrcweir {
617cdf0e10cSrcweir E3dObject* pRetval = NULL;
618cdf0e10cSrcweir
619cdf0e10cSrcweir if(GetObjList()
620cdf0e10cSrcweir && GetObjList()->GetOwnerObj()
621cdf0e10cSrcweir && GetObjList()->GetOwnerObj()->ISA(E3dObject))
622cdf0e10cSrcweir pRetval = ((E3dObject*)GetObjList()->GetOwnerObj());
623cdf0e10cSrcweir return pRetval;
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
626cdf0e10cSrcweir /*************************************************************************
627cdf0e10cSrcweir |*
628cdf0e10cSrcweir |* Uebergeordnetes Szenenobjekt bestimmen
629cdf0e10cSrcweir |*
630cdf0e10cSrcweir \************************************************************************/
631cdf0e10cSrcweir
GetScene() const632cdf0e10cSrcweir E3dScene* E3dObject::GetScene() const
633cdf0e10cSrcweir {
634cdf0e10cSrcweir if(GetParentObj())
635cdf0e10cSrcweir return GetParentObj()->GetScene();
636cdf0e10cSrcweir return NULL;
637cdf0e10cSrcweir }
638cdf0e10cSrcweir
639cdf0e10cSrcweir /*************************************************************************
640cdf0e10cSrcweir |*
641cdf0e10cSrcweir |* umschliessendes Volumen inklusive aller Kindobjekte berechnen
642cdf0e10cSrcweir |*
643cdf0e10cSrcweir \************************************************************************/
644cdf0e10cSrcweir
RecalcBoundVolume() const645cdf0e10cSrcweir basegfx::B3DRange E3dObject::RecalcBoundVolume() const
646cdf0e10cSrcweir {
647cdf0e10cSrcweir basegfx::B3DRange aRetval;
648cdf0e10cSrcweir const sal_uInt32 nObjCnt(maSubList.GetObjCount());
649cdf0e10cSrcweir
650cdf0e10cSrcweir if(nObjCnt)
651cdf0e10cSrcweir {
652cdf0e10cSrcweir for(sal_uInt32 a(0); a < nObjCnt; a++)
653cdf0e10cSrcweir {
654cdf0e10cSrcweir const E3dObject* p3DObject = dynamic_cast< const E3dObject* >(maSubList.GetObj(a));
655cdf0e10cSrcweir
656cdf0e10cSrcweir if(p3DObject)
657cdf0e10cSrcweir {
658cdf0e10cSrcweir basegfx::B3DRange aLocalRange(p3DObject->GetBoundVolume());
659cdf0e10cSrcweir aLocalRange.transform(p3DObject->GetTransform());
660cdf0e10cSrcweir aRetval.expand(aLocalRange);
661cdf0e10cSrcweir }
662cdf0e10cSrcweir }
663cdf0e10cSrcweir }
664cdf0e10cSrcweir else
665cdf0e10cSrcweir {
666cdf0e10cSrcweir // single 3D object
667cdf0e10cSrcweir const sdr::contact::ViewContactOfE3d* pVCOfE3D = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&GetViewContact());
668cdf0e10cSrcweir
669cdf0e10cSrcweir if(pVCOfE3D)
670cdf0e10cSrcweir {
671cdf0e10cSrcweir // BoundVolume is without 3D object transformation, use correct sequence
672cdf0e10cSrcweir const drawinglayer::primitive3d::Primitive3DSequence xLocalSequence(pVCOfE3D->getVIP3DSWithoutObjectTransform());
673cdf0e10cSrcweir
674cdf0e10cSrcweir if(xLocalSequence.hasElements())
675cdf0e10cSrcweir {
676cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > aEmptyParameters;
677cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation3D aLocalViewInformation3D(aEmptyParameters);
678cdf0e10cSrcweir
679cdf0e10cSrcweir aRetval = drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(
680cdf0e10cSrcweir xLocalSequence, aLocalViewInformation3D);
681cdf0e10cSrcweir }
682cdf0e10cSrcweir }
683cdf0e10cSrcweir }
684cdf0e10cSrcweir
685cdf0e10cSrcweir return aRetval;
686cdf0e10cSrcweir }
687cdf0e10cSrcweir
688cdf0e10cSrcweir /*************************************************************************
689cdf0e10cSrcweir |*
690cdf0e10cSrcweir |* umschliessendes Volumen zurueckgeben und ggf. neu berechnen
691cdf0e10cSrcweir |*
692cdf0e10cSrcweir \************************************************************************/
693cdf0e10cSrcweir
GetBoundVolume() const694cdf0e10cSrcweir const basegfx::B3DRange& E3dObject::GetBoundVolume() const
695cdf0e10cSrcweir {
696cdf0e10cSrcweir if(maLocalBoundVol.isEmpty())
697cdf0e10cSrcweir {
698cdf0e10cSrcweir const_cast< E3dObject* >(this)->maLocalBoundVol = RecalcBoundVolume();
699cdf0e10cSrcweir }
700cdf0e10cSrcweir
701cdf0e10cSrcweir return maLocalBoundVol;
702cdf0e10cSrcweir }
703cdf0e10cSrcweir
InvalidateBoundVolume()704cdf0e10cSrcweir void E3dObject::InvalidateBoundVolume()
705cdf0e10cSrcweir {
706cdf0e10cSrcweir maLocalBoundVol.reset();
707cdf0e10cSrcweir }
708cdf0e10cSrcweir
709cdf0e10cSrcweir /*************************************************************************
710cdf0e10cSrcweir |*
711cdf0e10cSrcweir |* Aederung des BoundVolumes an alle Kindobjekte weitergeben
712cdf0e10cSrcweir |*
713cdf0e10cSrcweir \************************************************************************/
714cdf0e10cSrcweir
SetBoundVolInvalid()715cdf0e10cSrcweir void E3dObject::SetBoundVolInvalid()
716cdf0e10cSrcweir {
717cdf0e10cSrcweir InvalidateBoundVolume();
718cdf0e10cSrcweir
719cdf0e10cSrcweir for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
720cdf0e10cSrcweir {
721cdf0e10cSrcweir E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
722cdf0e10cSrcweir
723cdf0e10cSrcweir if(pCandidate)
724cdf0e10cSrcweir {
725cdf0e10cSrcweir pCandidate->SetBoundVolInvalid();
726cdf0e10cSrcweir }
727cdf0e10cSrcweir }
728cdf0e10cSrcweir }
729cdf0e10cSrcweir
730cdf0e10cSrcweir /*************************************************************************
731cdf0e10cSrcweir |*
732cdf0e10cSrcweir |* Aederung der Transformation an alle Kindobjekte weitergeben
733cdf0e10cSrcweir |*
734cdf0e10cSrcweir \************************************************************************/
735cdf0e10cSrcweir
SetTransformChanged()736cdf0e10cSrcweir void E3dObject::SetTransformChanged()
737cdf0e10cSrcweir {
738cdf0e10cSrcweir InvalidateBoundVolume();
739cdf0e10cSrcweir mbTfHasChanged = true;
740cdf0e10cSrcweir
741cdf0e10cSrcweir for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
742cdf0e10cSrcweir {
743cdf0e10cSrcweir E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
744cdf0e10cSrcweir
745cdf0e10cSrcweir if(pCandidate)
746cdf0e10cSrcweir {
747cdf0e10cSrcweir pCandidate->SetTransformChanged();
748cdf0e10cSrcweir }
749cdf0e10cSrcweir }
750cdf0e10cSrcweir }
751cdf0e10cSrcweir
752cdf0e10cSrcweir /*************************************************************************
753cdf0e10cSrcweir |*
754cdf0e10cSrcweir |* hierarchische Transformation ueber alle Parents bestimmen, in
755cdf0e10cSrcweir |* maFullTransform ablegen und diese zurueckgeben
756cdf0e10cSrcweir |*
757cdf0e10cSrcweir \************************************************************************/
758cdf0e10cSrcweir
GetFullTransform() const759cdf0e10cSrcweir const basegfx::B3DHomMatrix& E3dObject::GetFullTransform() const
760cdf0e10cSrcweir {
761cdf0e10cSrcweir if(mbTfHasChanged)
762cdf0e10cSrcweir {
763cdf0e10cSrcweir basegfx::B3DHomMatrix aNewFullTransformation(maTransformation);
764cdf0e10cSrcweir
765cdf0e10cSrcweir if ( GetParentObj() )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir aNewFullTransformation = GetParentObj()->GetFullTransform() * aNewFullTransformation;
768cdf0e10cSrcweir }
769cdf0e10cSrcweir
770cdf0e10cSrcweir const_cast< E3dObject* >(this)->maFullTransform = aNewFullTransformation;
771cdf0e10cSrcweir const_cast< E3dObject* >(this)->mbTfHasChanged = false;
772cdf0e10cSrcweir }
773cdf0e10cSrcweir
774cdf0e10cSrcweir return maFullTransform;
775cdf0e10cSrcweir }
776cdf0e10cSrcweir
777cdf0e10cSrcweir /*************************************************************************
778cdf0e10cSrcweir |*
779cdf0e10cSrcweir |* Transformationsmatrix abfragen
780cdf0e10cSrcweir |*
781cdf0e10cSrcweir \************************************************************************/
782cdf0e10cSrcweir
GetTransform() const783cdf0e10cSrcweir const basegfx::B3DHomMatrix& E3dObject::GetTransform() const
784cdf0e10cSrcweir {
785cdf0e10cSrcweir return maTransformation;
786cdf0e10cSrcweir }
787cdf0e10cSrcweir
788cdf0e10cSrcweir /*************************************************************************
789cdf0e10cSrcweir |*
790cdf0e10cSrcweir |* Transformationsmatrix setzen
791cdf0e10cSrcweir |*
792cdf0e10cSrcweir \************************************************************************/
793cdf0e10cSrcweir
NbcSetTransform(const basegfx::B3DHomMatrix & rMatrix)794cdf0e10cSrcweir void E3dObject::NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix)
795cdf0e10cSrcweir {
796cdf0e10cSrcweir if(maTransformation != rMatrix)
797cdf0e10cSrcweir {
798cdf0e10cSrcweir maTransformation = rMatrix;
799cdf0e10cSrcweir SetTransformChanged();
800cdf0e10cSrcweir StructureChanged();
801cdf0e10cSrcweir }
802cdf0e10cSrcweir }
803cdf0e10cSrcweir
804cdf0e10cSrcweir /*************************************************************************
805cdf0e10cSrcweir |*
806cdf0e10cSrcweir |* Transformationsmatrix setzen mit Repaint-Broadcast
807cdf0e10cSrcweir |*
808cdf0e10cSrcweir \************************************************************************/
809cdf0e10cSrcweir
SetTransform(const basegfx::B3DHomMatrix & rMatrix)810cdf0e10cSrcweir void E3dObject::SetTransform(const basegfx::B3DHomMatrix& rMatrix)
811cdf0e10cSrcweir {
812cdf0e10cSrcweir if(rMatrix != maTransformation)
813cdf0e10cSrcweir {
814cdf0e10cSrcweir // #110094#-14 SendRepaintBroadcast();
815cdf0e10cSrcweir NbcSetTransform(rMatrix);
816cdf0e10cSrcweir SetChanged();
817cdf0e10cSrcweir BroadcastObjectChange();
818cdf0e10cSrcweir if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle());
819cdf0e10cSrcweir }
820cdf0e10cSrcweir }
821cdf0e10cSrcweir
822cdf0e10cSrcweir /*************************************************************************
823cdf0e10cSrcweir |*
824cdf0e10cSrcweir |* Linien fuer die Wireframe-Darstellung des Objekts dem uebergebenen
825cdf0e10cSrcweir |* basegfx::B3DPolygon hinzufuegen
826cdf0e10cSrcweir |*
827cdf0e10cSrcweir \************************************************************************/
828cdf0e10cSrcweir
CreateWireframe() const829cdf0e10cSrcweir basegfx::B3DPolyPolygon E3dObject::CreateWireframe() const
830cdf0e10cSrcweir {
831cdf0e10cSrcweir const basegfx::B3DRange aBoundVolume(GetBoundVolume());
832cdf0e10cSrcweir return basegfx::tools::createCubePolyPolygonFromB3DRange(aBoundVolume);
833cdf0e10cSrcweir }
834cdf0e10cSrcweir
835cdf0e10cSrcweir /*************************************************************************
836cdf0e10cSrcweir |*
837cdf0e10cSrcweir |* Get the name of the object (singular)
838cdf0e10cSrcweir |*
839cdf0e10cSrcweir \************************************************************************/
840cdf0e10cSrcweir
TakeObjNameSingul(XubString & rName) const841cdf0e10cSrcweir void E3dObject::TakeObjNameSingul(XubString& rName) const
842cdf0e10cSrcweir {
843cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNameSingulObj3d);
844cdf0e10cSrcweir
845cdf0e10cSrcweir String aName( GetName() );
846cdf0e10cSrcweir if(aName.Len())
847cdf0e10cSrcweir {
848cdf0e10cSrcweir rName += sal_Unicode(' ');
849cdf0e10cSrcweir rName += sal_Unicode('\'');
850cdf0e10cSrcweir rName += aName;
851cdf0e10cSrcweir rName += sal_Unicode('\'');
852cdf0e10cSrcweir }
853cdf0e10cSrcweir }
854cdf0e10cSrcweir
855cdf0e10cSrcweir /*************************************************************************
856cdf0e10cSrcweir |*
857cdf0e10cSrcweir |* Get the name of the object (plural)
858cdf0e10cSrcweir |*
859cdf0e10cSrcweir \************************************************************************/
860cdf0e10cSrcweir
TakeObjNamePlural(XubString & rName) const861cdf0e10cSrcweir void E3dObject::TakeObjNamePlural(XubString& rName) const
862cdf0e10cSrcweir {
863cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNamePluralObj3d);
864cdf0e10cSrcweir }
865cdf0e10cSrcweir
866cdf0e10cSrcweir /*************************************************************************
867cdf0e10cSrcweir |*
868cdf0e10cSrcweir |* Zuweisungsoperator
869cdf0e10cSrcweir |*
870cdf0e10cSrcweir \************************************************************************/
871cdf0e10cSrcweir
operator =(const SdrObject & rObj)872cdf0e10cSrcweir void E3dObject::operator=(const SdrObject& rObj)
873cdf0e10cSrcweir {
874cdf0e10cSrcweir SdrObject::operator=(rObj);
875cdf0e10cSrcweir
876cdf0e10cSrcweir const E3dObject& r3DObj = (const E3dObject&) rObj;
877cdf0e10cSrcweir if (r3DObj.GetSubList())
878cdf0e10cSrcweir {
879cdf0e10cSrcweir maSubList.CopyObjects(*r3DObj.GetSubList());
880cdf0e10cSrcweir }
881cdf0e10cSrcweir
882cdf0e10cSrcweir // BoundVol kann uebernommen werden, da die Childs auch kopiert werden
883cdf0e10cSrcweir maLocalBoundVol = r3DObj.maLocalBoundVol;
884cdf0e10cSrcweir maTransformation = r3DObj.maTransformation;
885cdf0e10cSrcweir
886cdf0e10cSrcweir // Da sich der Parent geaendert haben kann, Gesamttransformation beim
887cdf0e10cSrcweir // naechsten Mal auf jeden Fall neu bestimmen
888cdf0e10cSrcweir SetTransformChanged();
889cdf0e10cSrcweir
890cdf0e10cSrcweir // Selektionsstatus kopieren
891cdf0e10cSrcweir mbIsSelected = r3DObj.mbIsSelected;
892cdf0e10cSrcweir }
893cdf0e10cSrcweir
894cdf0e10cSrcweir /*************************************************************************
895cdf0e10cSrcweir |*
896cdf0e10cSrcweir |* erstelle neues GeoData-Objekt
897cdf0e10cSrcweir |*
898cdf0e10cSrcweir \************************************************************************/
899cdf0e10cSrcweir
NewGeoData() const900cdf0e10cSrcweir SdrObjGeoData *E3dObject::NewGeoData() const
901cdf0e10cSrcweir {
902cdf0e10cSrcweir // Theoretisch duerfen auch nur Szenen ihre GeoDatas erstellen und verwalten !!
903cdf0e10cSrcweir // AW: Dies stimmt nicht mehr, diese Stelle ist mit der neuen Engine OK!
904cdf0e10cSrcweir return new E3DObjGeoData;
905cdf0e10cSrcweir }
906cdf0e10cSrcweir
907cdf0e10cSrcweir /*************************************************************************
908cdf0e10cSrcweir |*
909cdf0e10cSrcweir |* uebergebe aktuelle werte an das GeoData-Objekt
910cdf0e10cSrcweir |*
911cdf0e10cSrcweir \************************************************************************/
912cdf0e10cSrcweir
SaveGeoData(SdrObjGeoData & rGeo) const913cdf0e10cSrcweir void E3dObject::SaveGeoData(SdrObjGeoData& rGeo) const
914cdf0e10cSrcweir {
915cdf0e10cSrcweir SdrAttrObj::SaveGeoData (rGeo);
916cdf0e10cSrcweir
917cdf0e10cSrcweir ((E3DObjGeoData &) rGeo).maLocalBoundVol = maLocalBoundVol;
918cdf0e10cSrcweir ((E3DObjGeoData &) rGeo).maTransformation = maTransformation;
919cdf0e10cSrcweir }
920cdf0e10cSrcweir
921cdf0e10cSrcweir /*************************************************************************
922cdf0e10cSrcweir |*
923cdf0e10cSrcweir |* uebernehme werte aus dem GeoData-Objekt
924cdf0e10cSrcweir |*
925cdf0e10cSrcweir \************************************************************************/
926cdf0e10cSrcweir
RestGeoData(const SdrObjGeoData & rGeo)927cdf0e10cSrcweir void E3dObject::RestGeoData(const SdrObjGeoData& rGeo)
928cdf0e10cSrcweir {
929cdf0e10cSrcweir maLocalBoundVol = ((E3DObjGeoData &) rGeo).maLocalBoundVol;
930cdf0e10cSrcweir E3DModifySceneSnapRectUpdater aUpdater(this);
931cdf0e10cSrcweir NbcSetTransform(((E3DObjGeoData &) rGeo).maTransformation);
932cdf0e10cSrcweir SdrAttrObj::RestGeoData (rGeo);
933cdf0e10cSrcweir }
934cdf0e10cSrcweir
935cdf0e10cSrcweir /*************************************************************************
936cdf0e10cSrcweir |*
937cdf0e10cSrcweir |* Rotation eines 3d-Koerpers
938cdf0e10cSrcweir |*
939cdf0e10cSrcweir \************************************************************************/
940cdf0e10cSrcweir // 2D-rotation eines 3D-Koerpers, normalerweise macht das die Szene selbst
941cdf0e10cSrcweir // Ist aber eine korrekte Implementierung, denn alles was passiert ist eine
942cdf0e10cSrcweir // Rotation um die Achse die senkrecht auf dem Bildschirm steht und zwar
943cdf0e10cSrcweir // unabhaengig davon, wie die Szene bisher gedreht worden ist.
944cdf0e10cSrcweir
NbcRotate(const Point & rRef,long nWink,double sn,double cs)945cdf0e10cSrcweir void E3dObject::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
946cdf0e10cSrcweir {
947cdf0e10cSrcweir // Also derzeit sind die Klebepunkte relativ zum aOutRect der Szene definiert. Vor dem Drehen
948cdf0e10cSrcweir // werden die Klebepunkte relativ zur Seite definiert. Sie nehmen an der Drehung der Szene noch nicht Teil
949cdf0e10cSrcweir // dafuer gibt es den
950cdf0e10cSrcweir SetGlueReallyAbsolute(sal_True);
951cdf0e10cSrcweir
952cdf0e10cSrcweir // SendRepaintBroadcast();
953cdf0e10cSrcweir double fWinkelInRad = nWink/100 * F_PI180;
954cdf0e10cSrcweir
955cdf0e10cSrcweir basegfx::B3DHomMatrix aRotateZ;
956cdf0e10cSrcweir aRotateZ.rotate(0.0, 0.0, fWinkelInRad);
957cdf0e10cSrcweir NbcSetTransform(aRotateZ * GetTransform());
958cdf0e10cSrcweir
959cdf0e10cSrcweir SetRectsDirty(); // Veranlasst eine Neuberechnung aller BoundRects
960cdf0e10cSrcweir NbcRotateGluePoints(rRef,nWink,sn,cs); // Rotiert die Klebepunkte (die haben noch Koordinaten relativ
961cdf0e10cSrcweir // zum Urpsung des Blattes
962cdf0e10cSrcweir SetGlueReallyAbsolute(sal_False); // ab jetzt sind sie wieder relativ zum BoundRect (also dem aOutRect definiert)
963cdf0e10cSrcweir }
964cdf0e10cSrcweir
965cdf0e10cSrcweir /*************************************************************************/
966cdf0e10cSrcweir
967cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
968cdf0e10cSrcweir
CreateObjectSpecificProperties()969cdf0e10cSrcweir sdr::properties::BaseProperties* E3dCompoundObject::CreateObjectSpecificProperties()
970cdf0e10cSrcweir {
971cdf0e10cSrcweir return new sdr::properties::E3dCompoundProperties(*this);
972cdf0e10cSrcweir }
973cdf0e10cSrcweir
974cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
975cdf0e10cSrcweir
976cdf0e10cSrcweir TYPEINIT1(E3dCompoundObject, E3dObject);
977cdf0e10cSrcweir
978cdf0e10cSrcweir /*************************************************************************
979cdf0e10cSrcweir |*
980cdf0e10cSrcweir |* Konstruktor
981cdf0e10cSrcweir |*
982cdf0e10cSrcweir \************************************************************************/
983cdf0e10cSrcweir
E3dCompoundObject()984cdf0e10cSrcweir E3dCompoundObject::E3dCompoundObject()
985cdf0e10cSrcweir : E3dObject(),
986cdf0e10cSrcweir aMaterialAmbientColor(),
987cdf0e10cSrcweir bCreateNormals(false),
988cdf0e10cSrcweir bCreateTexture(false)
989cdf0e10cSrcweir {
990cdf0e10cSrcweir // Defaults setzen
991cdf0e10cSrcweir E3dDefaultAttributes aDefault;
992cdf0e10cSrcweir SetDefaultAttributes(aDefault);
993cdf0e10cSrcweir }
994cdf0e10cSrcweir
E3dCompoundObject(E3dDefaultAttributes & rDefault)995cdf0e10cSrcweir E3dCompoundObject::E3dCompoundObject(E3dDefaultAttributes& rDefault)
996cdf0e10cSrcweir : E3dObject(),
997cdf0e10cSrcweir aMaterialAmbientColor(),
998cdf0e10cSrcweir bCreateNormals(false),
999cdf0e10cSrcweir bCreateTexture(false)
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir // Defaults setzen
1002cdf0e10cSrcweir SetDefaultAttributes(rDefault);
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir
SetDefaultAttributes(E3dDefaultAttributes & rDefault)1005cdf0e10cSrcweir void E3dCompoundObject::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir // Defaults setzen
1008cdf0e10cSrcweir aMaterialAmbientColor = rDefault.GetDefaultAmbientColor();
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir bCreateNormals = rDefault.GetDefaultCreateNormals();
1011cdf0e10cSrcweir bCreateTexture = rDefault.GetDefaultCreateTexture();
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir
1014cdf0e10cSrcweir /*************************************************************************
1015cdf0e10cSrcweir |*
1016cdf0e10cSrcweir |* Destruktor
1017cdf0e10cSrcweir |*
1018cdf0e10cSrcweir \************************************************************************/
1019cdf0e10cSrcweir
~E3dCompoundObject()1020cdf0e10cSrcweir E3dCompoundObject::~E3dCompoundObject ()
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir /*************************************************************************
1025cdf0e10cSrcweir |*
1026cdf0e10cSrcweir |* Drag-Polygon zurueckgeben
1027cdf0e10cSrcweir |*
1028cdf0e10cSrcweir \************************************************************************/
1029cdf0e10cSrcweir
TakeXorPoly() const1030cdf0e10cSrcweir basegfx::B2DPolyPolygon E3dCompoundObject::TakeXorPoly() const
1031cdf0e10cSrcweir {
1032cdf0e10cSrcweir basegfx::B2DPolyPolygon aRetval;
1033cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > aEmptyParameters;
1034cdf0e10cSrcweir drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
1035cdf0e10cSrcweir E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this);
1036cdf0e10cSrcweir
1037cdf0e10cSrcweir if(pRootScene)
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
1040cdf0e10cSrcweir const basegfx::B3DPolyPolygon aCubePolyPolygon(CreateWireframe());
1041cdf0e10cSrcweir aRetval = basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aCubePolyPolygon,
1042cdf0e10cSrcweir aViewInfo3D.getObjectToView() * GetTransform());
1043cdf0e10cSrcweir aRetval.transform(rVCScene.getObjectTransformation());
1044cdf0e10cSrcweir }
1045cdf0e10cSrcweir
1046cdf0e10cSrcweir return aRetval;
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir /*************************************************************************
1050cdf0e10cSrcweir |*
1051cdf0e10cSrcweir |* Anzahl der Handles zurueckgeben
1052cdf0e10cSrcweir |*
1053cdf0e10cSrcweir \************************************************************************/
1054cdf0e10cSrcweir
GetHdlCount() const1055cdf0e10cSrcweir sal_uInt32 E3dCompoundObject::GetHdlCount() const
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir // 8 Eckpunkte + 1 E3dVolumeMarker (= Wireframe-Darstellung)
1058cdf0e10cSrcweir return 9L;
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir /*************************************************************************
1062cdf0e10cSrcweir |*
1063cdf0e10cSrcweir |* Handle-Liste fuellen
1064cdf0e10cSrcweir |*
1065cdf0e10cSrcweir \************************************************************************/
1066cdf0e10cSrcweir
AddToHdlList(SdrHdlList & rHdlList) const1067cdf0e10cSrcweir void E3dCompoundObject::AddToHdlList(SdrHdlList& rHdlList) const
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > aEmptyParameters;
1070cdf0e10cSrcweir drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
1071cdf0e10cSrcweir E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this);
1072cdf0e10cSrcweir
1073cdf0e10cSrcweir if(pRootScene)
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir const basegfx::B3DRange aBoundVolume(GetBoundVolume());
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir if(!aBoundVolume.isEmpty())
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
1080cdf0e10cSrcweir
1081cdf0e10cSrcweir for(sal_uInt32 a(0); a < 8; a++)
1082cdf0e10cSrcweir {
1083cdf0e10cSrcweir basegfx::B3DPoint aPos3D;
1084cdf0e10cSrcweir
1085cdf0e10cSrcweir switch(a)
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir case 0 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMinZ()); break;
1088cdf0e10cSrcweir case 1 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break;
1089cdf0e10cSrcweir case 2 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMinZ()); break;
1090cdf0e10cSrcweir case 3 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break;
1091cdf0e10cSrcweir case 4 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMinZ()); break;
1092cdf0e10cSrcweir case 5 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break;
1093cdf0e10cSrcweir case 6 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMinZ()); break;
1094cdf0e10cSrcweir case 7 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break;
1095cdf0e10cSrcweir }
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir // to 3d view coor
1098cdf0e10cSrcweir aPos3D *= aViewInfo3D.getObjectToView() * GetTransform();
1099cdf0e10cSrcweir
1100cdf0e10cSrcweir // create 2d relative scene
1101cdf0e10cSrcweir basegfx::B2DPoint aPos2D(aPos3D.getX(), aPos3D.getY());
1102cdf0e10cSrcweir
1103cdf0e10cSrcweir // to 2d world coor
1104cdf0e10cSrcweir aPos2D *= rVCScene.getObjectTransformation();
1105cdf0e10cSrcweir
1106cdf0e10cSrcweir rHdlList.AddHdl(new SdrHdl(Point(basegfx::fround(aPos2D.getX()), basegfx::fround(aPos2D.getY())), HDL_BWGT));
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir
1111cdf0e10cSrcweir const basegfx::B2DPolyPolygon aPolyPolygon(TakeXorPoly());
1112cdf0e10cSrcweir
1113cdf0e10cSrcweir if(aPolyPolygon.count())
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir E3dVolumeMarker* pVolMarker = new E3dVolumeMarker(aPolyPolygon);
1116cdf0e10cSrcweir rHdlList.AddHdl(pVolMarker);
1117cdf0e10cSrcweir }
1118cdf0e10cSrcweir }
1119cdf0e10cSrcweir
1120cdf0e10cSrcweir /*************************************************************************
1121cdf0e10cSrcweir |*
1122cdf0e10cSrcweir |* Identifier zurueckgeben
1123cdf0e10cSrcweir |*
1124cdf0e10cSrcweir \************************************************************************/
1125cdf0e10cSrcweir
GetObjIdentifier() const1126cdf0e10cSrcweir sal_uInt16 E3dCompoundObject::GetObjIdentifier() const
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir return E3D_COMPOUNDOBJ_ID;
1129cdf0e10cSrcweir }
1130cdf0e10cSrcweir
1131cdf0e10cSrcweir /*************************************************************************
1132cdf0e10cSrcweir |*
1133cdf0e10cSrcweir |* SnapRect berechnen
1134cdf0e10cSrcweir |*
1135cdf0e10cSrcweir \************************************************************************/
1136cdf0e10cSrcweir
RecalcSnapRect()1137cdf0e10cSrcweir void E3dCompoundObject::RecalcSnapRect()
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > aEmptyParameters;
1140cdf0e10cSrcweir drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
1141cdf0e10cSrcweir E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this);
1142cdf0e10cSrcweir maSnapRect = Rectangle();
1143cdf0e10cSrcweir
1144cdf0e10cSrcweir if(pRootScene)
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir // get VC of 3D candidate
1147cdf0e10cSrcweir const sdr::contact::ViewContactOfE3d* pVCOfE3D = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&GetViewContact());
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir if(pVCOfE3D)
1150cdf0e10cSrcweir {
1151cdf0e10cSrcweir // get 3D primitive sequence
1152cdf0e10cSrcweir const drawinglayer::primitive3d::Primitive3DSequence xLocalSequence(pVCOfE3D->getViewIndependentPrimitive3DSequence());
1153cdf0e10cSrcweir
1154cdf0e10cSrcweir if(xLocalSequence.hasElements())
1155cdf0e10cSrcweir {
1156cdf0e10cSrcweir // get BoundVolume
1157cdf0e10cSrcweir basegfx::B3DRange aBoundVolume(drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(
1158cdf0e10cSrcweir xLocalSequence, aViewInfo3D));
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir // transform bound volume to relative scene coordinates
1161cdf0e10cSrcweir aBoundVolume.transform(aViewInfo3D.getObjectToView());
1162cdf0e10cSrcweir
1163cdf0e10cSrcweir // build 2d relative scene range
1164cdf0e10cSrcweir basegfx::B2DRange aSnapRange(
1165cdf0e10cSrcweir aBoundVolume.getMinX(), aBoundVolume.getMinY(),
1166cdf0e10cSrcweir aBoundVolume.getMaxX(), aBoundVolume.getMaxY());
1167cdf0e10cSrcweir
1168cdf0e10cSrcweir // transform to 2D world coordiantes
1169cdf0e10cSrcweir const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
1170cdf0e10cSrcweir aSnapRange.transform(rVCScene.getObjectTransformation());
1171cdf0e10cSrcweir
1172cdf0e10cSrcweir // snap to integer
1173cdf0e10cSrcweir maSnapRect = Rectangle(
1174cdf0e10cSrcweir sal_Int32(floor(aSnapRange.getMinX())), sal_Int32(floor(aSnapRange.getMinY())),
1175cdf0e10cSrcweir sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY())));
1176cdf0e10cSrcweir }
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir }
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir /*************************************************************************
1182cdf0e10cSrcweir |*
1183cdf0e10cSrcweir |* Copy-Operator
1184cdf0e10cSrcweir |*
1185cdf0e10cSrcweir \************************************************************************/
1186cdf0e10cSrcweir
operator =(const SdrObject & rObj)1187cdf0e10cSrcweir void E3dCompoundObject::operator=(const SdrObject& rObj)
1188cdf0e10cSrcweir {
1189cdf0e10cSrcweir // erstmal alle Childs kopieren
1190cdf0e10cSrcweir E3dObject::operator=(rObj);
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir // weitere Parameter kopieren
1193cdf0e10cSrcweir const E3dCompoundObject& r3DObj = (const E3dCompoundObject&) rObj;
1194cdf0e10cSrcweir
1195cdf0e10cSrcweir bCreateNormals = r3DObj.bCreateNormals;
1196cdf0e10cSrcweir bCreateTexture = r3DObj.bCreateTexture;
1197cdf0e10cSrcweir aMaterialAmbientColor = r3DObj.aMaterialAmbientColor;
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir /*************************************************************************
1201cdf0e10cSrcweir |*
1202cdf0e10cSrcweir |* Parameter Geometrieerzeugung setzen
1203cdf0e10cSrcweir |*
1204cdf0e10cSrcweir \************************************************************************/
1205cdf0e10cSrcweir
SetCreateNormals(sal_Bool bNew)1206cdf0e10cSrcweir void E3dCompoundObject::SetCreateNormals(sal_Bool bNew)
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir if(bCreateNormals != bNew)
1209cdf0e10cSrcweir {
1210cdf0e10cSrcweir bCreateNormals = bNew;
1211cdf0e10cSrcweir ActionChanged();
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir
SetCreateTexture(sal_Bool bNew)1215cdf0e10cSrcweir void E3dCompoundObject::SetCreateTexture(sal_Bool bNew)
1216cdf0e10cSrcweir {
1217cdf0e10cSrcweir if(bCreateTexture != bNew)
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir bCreateTexture = bNew;
1220cdf0e10cSrcweir ActionChanged();
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir
1224cdf0e10cSrcweir /*************************************************************************
1225cdf0e10cSrcweir |*
1226cdf0e10cSrcweir |* Material des Objektes
1227cdf0e10cSrcweir |*
1228cdf0e10cSrcweir \************************************************************************/
1229cdf0e10cSrcweir
SetMaterialAmbientColor(const Color & rColor)1230cdf0e10cSrcweir void E3dCompoundObject::SetMaterialAmbientColor(const Color& rColor)
1231cdf0e10cSrcweir {
1232cdf0e10cSrcweir if(aMaterialAmbientColor != rColor)
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir aMaterialAmbientColor = rColor;
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir }
1237cdf0e10cSrcweir
1238cdf0e10cSrcweir /*************************************************************************
1239cdf0e10cSrcweir |*
1240cdf0e10cSrcweir |* convert given basegfx::B3DPolyPolygon to screen coor
1241cdf0e10cSrcweir |*
1242cdf0e10cSrcweir \************************************************************************/
1243cdf0e10cSrcweir
TransformToScreenCoor(const basegfx::B3DPolyPolygon & rCandidate)1244cdf0e10cSrcweir basegfx::B2DPolyPolygon E3dCompoundObject::TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate)
1245cdf0e10cSrcweir {
1246cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > aEmptyParameters;
1247cdf0e10cSrcweir drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
1248cdf0e10cSrcweir E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this);
1249cdf0e10cSrcweir basegfx::B2DPolyPolygon aRetval;
1250cdf0e10cSrcweir
1251cdf0e10cSrcweir if(pRootScene)
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir aRetval = basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(rCandidate,
1254cdf0e10cSrcweir aViewInfo3D.getObjectToView() * GetTransform());
1255cdf0e10cSrcweir const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
1256cdf0e10cSrcweir aRetval.transform(rVCScene.getObjectTransformation());
1257cdf0e10cSrcweir }
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir return aRetval;
1260cdf0e10cSrcweir }
1261cdf0e10cSrcweir
IsAOrdNumRemapCandidate(E3dScene * & prScene) const1262cdf0e10cSrcweir sal_Bool E3dCompoundObject::IsAOrdNumRemapCandidate(E3dScene*& prScene) const
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir if(GetObjList()
1265cdf0e10cSrcweir && GetObjList()->GetOwnerObj()
1266cdf0e10cSrcweir && GetObjList()->GetOwnerObj()->ISA(E3dScene))
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir prScene = (E3dScene*)GetObjList()->GetOwnerObj();
1269cdf0e10cSrcweir return sal_True;
1270cdf0e10cSrcweir }
1271cdf0e10cSrcweir
1272cdf0e10cSrcweir return sal_False;
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir
1275cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1276cdf0e10cSrcweir // eof
1277