Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "fucon3d.hxx"
31 : : #include <vcl/waitobj.hxx>
32 : :
33 : : #include <svx/svxids.hrc>
34 : : #include <svl/aeitem.hxx>
35 : : #include <sfx2/app.hxx>
36 : : #include <sfx2/dispatch.hxx>
37 : : #include <sfx2/viewfrm.hxx>
38 : : #include <tools/poly.hxx>
39 : :
40 : : #include <math.h>
41 : : #include <svx/globl3d.hxx>
42 : : #include <svx/scene3d.hxx>
43 : : #include <svx/sphere3d.hxx>
44 : : #include <svx/cube3d.hxx>
45 : : #include <svx/lathe3d.hxx>
46 : : #include <svx/camera3d.hxx>
47 : :
48 : : #include "app.hrc"
49 : : #include "res_bmp.hrc"
50 : : #include "View.hxx"
51 : : #include "Window.hxx"
52 : : #include "ViewShell.hxx"
53 : : #include "drawdoc.hxx"
54 : : #include "ViewShellBase.hxx"
55 : : #include "ToolBarManager.hxx"
56 : : #include <svx/svx3ditems.hxx>
57 : :
58 : : #include <svx/polysc3d.hxx>
59 : : #include <basegfx/polygon/b2dpolygontools.hxx>
60 : :
61 : : namespace sd {
62 : :
63 [ # # ][ # # ]: 0 : TYPEINIT1( FuConstruct3dObject, FuConstruct );
64 : :
65 : : /*************************************************************************
66 : : |*
67 : : |* Konstruktor
68 : : |*
69 : : \************************************************************************/
70 : :
71 : 0 : FuConstruct3dObject::FuConstruct3dObject (
72 : : ViewShell* pViewSh,
73 : : ::sd::Window* pWin,
74 : : ::sd::View* pView,
75 : : SdDrawDocument* pDoc,
76 : : SfxRequest& rReq)
77 : 0 : : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
78 : : {
79 : 0 : }
80 : :
81 : 0 : FunctionReference FuConstruct3dObject::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
82 : : {
83 : : FuConstruct3dObject* pFunc;
84 [ # # ][ # # ]: 0 : FunctionReference xFunc( pFunc = new FuConstruct3dObject( pViewSh, pWin, pView, pDoc, rReq ) );
85 [ # # ]: 0 : xFunc->DoExecute(rReq);
86 : 0 : pFunc->SetPermanent(bPermanent);
87 : 0 : return xFunc;
88 : : }
89 : :
90 : 0 : void FuConstruct3dObject::DoExecute( SfxRequest& rReq )
91 : : {
92 : 0 : FuConstruct::DoExecute( rReq );
93 : 0 : mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
94 : : ToolBarManager::TBG_FUNCTION,
95 [ # # ]: 0 : ToolBarManager::msDrawingObjectToolBar);
96 : 0 : }
97 : :
98 : : /*************************************************************************
99 : : |*
100 : : |* MouseButtonDown-event
101 : : |*
102 : : \************************************************************************/
103 : :
104 : 0 : E3dCompoundObject* FuConstruct3dObject::ImpCreateBasic3DShape()
105 : : {
106 : 0 : E3dCompoundObject* p3DObj = NULL;
107 : :
108 [ # # # # : 0 : switch (nSlotId)
# # # # ]
109 : : {
110 : : default:
111 : : case SID_3D_CUBE:
112 : : {
113 : : p3DObj = new E3dCubeObj(
114 : 0 : mpView->Get3DDefaultAttributes(),
115 : : ::basegfx::B3DPoint(-2500, -2500, -2500),
116 [ # # ][ # # ]: 0 : ::basegfx::B3DVector(5000, 5000, 5000));
117 : 0 : break;
118 : : }
119 : :
120 : : case SID_3D_SPHERE:
121 : : {
122 : : p3DObj = new E3dSphereObj(
123 : 0 : mpView->Get3DDefaultAttributes(),
124 : : ::basegfx::B3DPoint(0, 0, 0),
125 [ # # ][ # # ]: 0 : ::basegfx::B3DVector(5000, 5000, 5000));
126 : 0 : break;
127 : : }
128 : :
129 : : case SID_3D_SHELL:
130 : : {
131 [ # # ]: 0 : XPolygon aXPoly(Point (0, 1250), 2500, 2500, 0, 900, sal_False);
132 [ # # ]: 0 : aXPoly.Scale(5.0, 5.0);
133 : :
134 [ # # ]: 0 : ::basegfx::B2DPolygon aB2DPolygon(aXPoly.getB2DPolygon());
135 [ # # ][ # # ]: 0 : if(aB2DPolygon.areControlPointsUsed())
136 : : {
137 [ # # ][ # # ]: 0 : aB2DPolygon = ::basegfx::tools::adaptiveSubdivideByAngle(aB2DPolygon);
[ # # ]
138 : : }
139 [ # # ][ # # ]: 0 : p3DObj = new E3dLatheObj(mpView->Get3DDefaultAttributes(), ::basegfx::B2DPolyPolygon(aB2DPolygon));
[ # # ][ # # ]
140 : :
141 : : // Dies ist ein offenes Objekt, muss daher defaultmaessig
142 : : // doppelseitig behandelt werden
143 [ # # ][ # # ]: 0 : p3DObj->SetMergedItem(Svx3DDoubleSidedItem(sal_True));
[ # # ]
144 [ # # ][ # # ]: 0 : break;
145 : : }
146 : :
147 : : case SID_3D_HALF_SPHERE:
148 : : {
149 [ # # ]: 0 : XPolygon aXPoly(Point (0, 1250), 2500, 2500, 0, 900, sal_False);
150 [ # # ]: 0 : aXPoly.Scale(5.0, 5.0);
151 : :
152 [ # # ]: 0 : aXPoly.Insert(0, Point (2400*5, 1250*5), XPOLY_NORMAL);
153 [ # # ]: 0 : aXPoly.Insert(0, Point (2000*5, 1250*5), XPOLY_NORMAL);
154 [ # # ]: 0 : aXPoly.Insert(0, Point (1500*5, 1250*5), XPOLY_NORMAL);
155 [ # # ]: 0 : aXPoly.Insert(0, Point (1000*5, 1250*5), XPOLY_NORMAL);
156 [ # # ]: 0 : aXPoly.Insert(0, Point (500*5, 1250*5), XPOLY_NORMAL);
157 [ # # ]: 0 : aXPoly.Insert(0, Point (250*5, 1250*5), XPOLY_NORMAL);
158 [ # # ]: 0 : aXPoly.Insert(0, Point (50*5, 1250*5), XPOLY_NORMAL);
159 [ # # ]: 0 : aXPoly.Insert(0, Point (0*5, 1250*5), XPOLY_NORMAL);
160 : :
161 [ # # ]: 0 : ::basegfx::B2DPolygon aB2DPolygon(aXPoly.getB2DPolygon());
162 [ # # ][ # # ]: 0 : if(aB2DPolygon.areControlPointsUsed())
163 : : {
164 [ # # ][ # # ]: 0 : aB2DPolygon = ::basegfx::tools::adaptiveSubdivideByAngle(aB2DPolygon);
[ # # ]
165 : : }
166 [ # # ][ # # ]: 0 : p3DObj = new E3dLatheObj(mpView->Get3DDefaultAttributes(), ::basegfx::B2DPolyPolygon(aB2DPolygon));
[ # # ][ # # ]
167 [ # # ][ # # ]: 0 : break;
168 : : }
169 : :
170 : : case SID_3D_TORUS:
171 : : {
172 [ # # ]: 0 : ::basegfx::B2DPolygon aB2DPolygon(::basegfx::tools::createPolygonFromCircle(::basegfx::B2DPoint(1000.0, 0.0), 500.0));
173 [ # # ][ # # ]: 0 : if(aB2DPolygon.areControlPointsUsed())
174 : : {
175 [ # # ][ # # ]: 0 : aB2DPolygon = ::basegfx::tools::adaptiveSubdivideByAngle(aB2DPolygon);
[ # # ]
176 : : }
177 [ # # ][ # # ]: 0 : p3DObj = new E3dLatheObj(mpView->Get3DDefaultAttributes(), ::basegfx::B2DPolyPolygon(aB2DPolygon));
[ # # ][ # # ]
178 [ # # ]: 0 : break;
179 : : }
180 : :
181 : : case SID_3D_CYLINDER:
182 : : {
183 [ # # ]: 0 : ::basegfx::B2DPolygon aInnerPoly;
184 : :
185 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(0, 1000*5));
186 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(50*5, 1000*5));
187 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(100*5, 1000*5));
188 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(200*5, 1000*5));
189 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(300*5, 1000*5));
190 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(400*5, 1000*5));
191 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(450*5, 1000*5));
192 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(500*5, 1000*5));
193 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(500*5, -1000*5));
194 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(450*5, -1000*5));
195 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(400*5, -1000*5));
196 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(300*5, -1000*5));
197 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(200*5, -1000*5));
198 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(100*5, -1000*5));
199 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(50*5, -1000*5));
200 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(0*5, -1000*5));
201 [ # # ]: 0 : aInnerPoly.setClosed(true);
202 : :
203 [ # # ][ # # ]: 0 : p3DObj = new E3dLatheObj(mpView->Get3DDefaultAttributes(), ::basegfx::B2DPolyPolygon(aInnerPoly));
[ # # ][ # # ]
204 [ # # ]: 0 : break;
205 : : }
206 : :
207 : : case SID_3D_CONE:
208 : : {
209 [ # # ]: 0 : ::basegfx::B2DPolygon aInnerPoly;
210 : :
211 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(0, -1000*5));
212 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(25*5, -900*5));
213 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(50*5, -800*5));
214 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(100*5, -600*5));
215 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(200*5, -200*5));
216 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(300*5, 200*5));
217 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(400*5, 600*5));
218 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(500*5, 1000*5));
219 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(400*5, 1000*5));
220 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(300*5, 1000*5));
221 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(200*5, 1000*5));
222 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(100*5, 1000*5));
223 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(50*5, 1000*5));
224 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(0*5, 1000*5));
225 [ # # ]: 0 : aInnerPoly.setClosed(true);
226 : :
227 [ # # ][ # # ]: 0 : p3DObj = new E3dLatheObj(mpView->Get3DDefaultAttributes(), ::basegfx::B2DPolyPolygon(aInnerPoly));
[ # # ][ # # ]
228 [ # # ]: 0 : break;
229 : : }
230 : :
231 : : case SID_3D_PYRAMID:
232 : : {
233 [ # # ]: 0 : ::basegfx::B2DPolygon aInnerPoly;
234 : :
235 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(0, -1000*5));
236 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(25*5, -900*5));
237 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(50*5, -800*5));
238 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(100*5, -600*5));
239 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(200*5, -200*5));
240 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(300*5, 200*5));
241 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(400*5, 600*5));
242 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(500*5, 1000*5));
243 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(400*5, 1000*5));
244 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(300*5, 1000*5));
245 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(200*5, 1000*5));
246 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(100*5, 1000*5));
247 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(50*5, 1000*5));
248 [ # # ]: 0 : aInnerPoly.append(::basegfx::B2DPoint(0, 1000*5));
249 [ # # ]: 0 : aInnerPoly.setClosed(true);
250 : :
251 [ # # ][ # # ]: 0 : p3DObj = new E3dLatheObj(mpView->Get3DDefaultAttributes(), ::basegfx::B2DPolyPolygon(aInnerPoly));
[ # # ][ # # ]
252 [ # # ][ # # ]: 0 : p3DObj->SetMergedItem(Svx3DHorizontalSegmentsItem(4));
[ # # ]
253 [ # # ]: 0 : break;
254 : : }
255 : : }
256 : :
257 : 0 : return p3DObj;
258 : : }
259 : :
260 : 0 : void FuConstruct3dObject::ImpPrepareBasic3DShape(E3dCompoundObject* p3DObj, E3dScene *pScene)
261 : : {
262 : 0 : Camera3D &aCamera = (Camera3D&) pScene->GetCamera ();
263 : :
264 : : // get transformed BoundVolume of the new object
265 [ # # ]: 0 : basegfx::B3DRange aBoundVol;
266 [ # # ]: 0 : basegfx::B3DRange aObjVol(p3DObj->GetBoundVolume());
267 [ # # ][ # # ]: 0 : aObjVol.transform(p3DObj->GetTransform());
268 [ # # ]: 0 : aBoundVol.expand(aObjVol);
269 [ # # ]: 0 : double fDeepth(aBoundVol.getDepth());
270 : :
271 [ # # ]: 0 : aCamera.SetPRP(::basegfx::B3DPoint(0.0, 0.0, 1000.0));
272 [ # # ][ # # ]: 0 : aCamera.SetPosition(::basegfx::B3DPoint(0.0, 0.0, mpView->GetDefaultCamPosZ() + fDeepth / 2));
273 [ # # ][ # # ]: 0 : aCamera.SetFocalLength(mpView->GetDefaultCamFocal());
274 [ # # ]: 0 : pScene->SetCamera(aCamera);
275 [ # # ]: 0 : basegfx::B3DHomMatrix aTransformation;
276 : :
277 [ # # # # : 0 : switch (nSlotId)
# # ]
278 : : {
279 : : case SID_3D_CUBE:
280 : : {
281 [ # # ]: 0 : aTransformation.rotate(DEG2RAD(20), 0.0, 0.0);
282 : : }
283 : 0 : break;
284 : :
285 : : case SID_3D_SPHERE:
286 : : {
287 : : }
288 : 0 : break;
289 : :
290 : : case SID_3D_SHELL:
291 : : case SID_3D_HALF_SPHERE:
292 : : {
293 [ # # ]: 0 : aTransformation.rotate(DEG2RAD(200), 0.0, 0.0);
294 : : }
295 : 0 : break;
296 : :
297 : : case SID_3D_CYLINDER:
298 : : case SID_3D_CONE:
299 : : case SID_3D_PYRAMID:
300 : : {
301 : : }
302 : 0 : break;
303 : :
304 : : case SID_3D_TORUS:
305 : : {
306 [ # # ]: 0 : aTransformation.rotate(DEG2RAD(90), 0.0, 0.0);
307 : : }
308 : 0 : break;
309 : :
310 : : default:
311 : : {
312 : : }
313 : 0 : break;
314 : : }
315 : :
316 [ # # ][ # # ]: 0 : pScene->SetTransform(aTransformation * pScene->GetTransform());
[ # # ][ # # ]
317 : :
318 [ # # ]: 0 : SfxItemSet aAttr (mpViewShell->GetPool());
319 [ # # ][ # # ]: 0 : pScene->SetMergedItemSetAndBroadcast(aAttr);
[ # # ]
320 : 0 : }
321 : :
322 : 0 : sal_Bool FuConstruct3dObject::MouseButtonDown(const MouseEvent& rMEvt)
323 : : {
324 : 0 : sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
325 : :
326 [ # # ][ # # ]: 0 : if ( rMEvt.IsLeft() && !mpView->IsAction() )
[ # # ]
327 : : {
328 [ # # ]: 0 : Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
329 : :
330 [ # # ]: 0 : mpWindow->CaptureMouse();
331 [ # # ]: 0 : sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
332 : :
333 : 0 : E3dCompoundObject* p3DObj = NULL;
334 : :
335 [ # # ][ # # ]: 0 : WaitObject aWait( (Window*)mpViewShell->GetActiveWindow() );
336 : :
337 [ # # ]: 0 : p3DObj = ImpCreateBasic3DShape();
338 [ # # ]: 0 : E3dScene* pScene = mpView->SetCurrent3DObj(p3DObj);
339 : :
340 [ # # ]: 0 : ImpPrepareBasic3DShape(p3DObj, pScene);
341 [ # # ]: 0 : bReturn = mpView->BegCreatePreparedObject(aPnt, nDrgLog, pScene);
342 : :
343 : 0 : SdrObject* pObj = mpView->GetCreateObj();
344 : :
345 [ # # ]: 0 : if (pObj)
346 : : {
347 [ # # ]: 0 : SfxItemSet aAttr(mpDoc->GetPool());
348 [ # # ]: 0 : SetStyleSheet(aAttr, pObj);
349 : :
350 : : // LineStyle rausnehmen
351 [ # # ][ # # ]: 0 : aAttr.Put(XLineStyleItem (XLINE_NONE));
[ # # ]
352 : :
353 [ # # ][ # # ]: 0 : pObj->SetMergedItemSet(aAttr);
354 [ # # ]: 0 : }
355 : : }
356 : :
357 : 0 : return bReturn;
358 : : }
359 : :
360 : : /*************************************************************************
361 : : |*
362 : : |* MouseMove-event
363 : : |*
364 : : \************************************************************************/
365 : :
366 : 0 : sal_Bool FuConstruct3dObject::MouseMove(const MouseEvent& rMEvt)
367 : : {
368 : 0 : return FuConstruct::MouseMove(rMEvt);
369 : : }
370 : :
371 : : /*************************************************************************
372 : : |*
373 : : |* MouseButtonUp-event
374 : : |*
375 : : \************************************************************************/
376 : :
377 : 0 : sal_Bool FuConstruct3dObject::MouseButtonUp(const MouseEvent& rMEvt)
378 : : {
379 : 0 : sal_Bool bReturn = sal_False;
380 : :
381 [ # # ][ # # ]: 0 : if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
[ # # ]
382 : : {
383 : 0 : mpView->EndCreateObj(SDRCREATE_FORCEEND);
384 : 0 : bReturn = sal_True;
385 : : }
386 : :
387 [ # # ][ # # ]: 0 : bReturn = FuConstruct::MouseButtonUp(rMEvt) || bReturn;
388 : :
389 [ # # ]: 0 : if (!bPermanent)
390 : 0 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
391 : :
392 : 0 : return bReturn;
393 : : }
394 : :
395 : : /*************************************************************************
396 : : |*
397 : : |* Tastaturereignisse bearbeiten
398 : : |*
399 : : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
400 : : |* sal_False.
401 : : |*
402 : : \************************************************************************/
403 : :
404 : 0 : sal_Bool FuConstruct3dObject::KeyInput(const KeyEvent& rKEvt)
405 : : {
406 : 0 : return( FuConstruct::KeyInput(rKEvt) );
407 : : }
408 : :
409 : : /*************************************************************************
410 : : |*
411 : : |* Function aktivieren
412 : : |*
413 : : \************************************************************************/
414 : :
415 : 0 : void FuConstruct3dObject::Activate()
416 : : {
417 : 0 : mpView->SetCurrentObj(OBJ_NONE);
418 : :
419 : 0 : FuConstruct::Activate();
420 : 0 : }
421 : :
422 : : /*************************************************************************
423 : : |*
424 : : |* Function deaktivieren
425 : : |*
426 : : \************************************************************************/
427 : :
428 : 0 : void FuConstruct3dObject::Deactivate()
429 : : {
430 : 0 : FuConstruct::Deactivate();
431 : 0 : }
432 : :
433 : 0 : SdrObject* FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
434 : : {
435 : :
436 [ # # ]: 0 : E3dCompoundObject* p3DObj = ImpCreateBasic3DShape();
437 : :
438 : : // E3dView::SetCurrent3DObj part
439 : : // get transformed BoundVolume of the object
440 [ # # ]: 0 : basegfx::B3DRange aObjVol(p3DObj->GetBoundVolume());
441 [ # # ][ # # ]: 0 : aObjVol.transform(p3DObj->GetTransform());
442 : 0 : basegfx::B3DRange aVolume(aObjVol);
443 [ # # ]: 0 : double fW(aVolume.getWidth());
444 [ # # ]: 0 : double fH(aVolume.getHeight());
445 [ # # ]: 0 : Rectangle a3DRect(0, 0, (long)fW, (long)fH);
446 [ # # ][ # # ]: 0 : E3dScene* pScene = new E3dPolyScene(mpView->Get3DDefaultAttributes());
447 : :
448 : : // copied code from E3dView::InitScene
449 [ # # ]: 0 : double fCamZ(aVolume.getMaxZ() + ((fW + fH) / 4.0));
450 [ # # ]: 0 : Camera3D aCam(pScene->GetCamera());
451 : 0 : aCam.SetAutoAdjustProjection(sal_False);
452 [ # # ]: 0 : aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
453 : 0 : ::basegfx::B3DPoint aLookAt;
454 [ # # ]: 0 : double fDefaultCamPosZ = mpView->GetDefaultCamPosZ();
455 [ # # ]: 0 : ::basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ);
456 [ # # ]: 0 : aCam.SetPosAndLookAt(aCamPos, aLookAt);
457 [ # # ][ # # ]: 0 : aCam.SetFocalLength(mpView->GetDefaultCamFocal());
458 [ # # ][ # # ]: 0 : aCam.SetDefaults(::basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ), aLookAt, mpView->GetDefaultCamFocal());
459 [ # # ]: 0 : pScene->SetCamera(aCam);
460 : :
461 [ # # ]: 0 : pScene->Insert3DObj(p3DObj);
462 [ # # ]: 0 : pScene->NbcSetSnapRect(a3DRect);
463 [ # # ]: 0 : pScene->SetModel(mpDoc);
464 : :
465 [ # # ]: 0 : ImpPrepareBasic3DShape(p3DObj, pScene);
466 : :
467 [ # # ]: 0 : SfxItemSet aAttr(mpDoc->GetPool());
468 [ # # ]: 0 : SetStyleSheet(aAttr, p3DObj);
469 [ # # ][ # # ]: 0 : aAttr.Put(XLineStyleItem (XLINE_NONE));
[ # # ]
470 [ # # ]: 0 : p3DObj->SetMergedItemSet(aAttr);
471 : :
472 : : // make object interactive at once
473 [ # # ]: 0 : pScene->SetRectsDirty();
474 : :
475 : : // Take care of restrictions for the rectangle
476 : 0 : Rectangle aRect(rRectangle);
477 : :
478 [ # # # # ]: 0 : switch(nID)
479 : : {
480 : : case SID_3D_CUBE:
481 : : case SID_3D_SPHERE:
482 : : case SID_3D_TORUS:
483 : : {
484 : : // force quadratic
485 [ # # ]: 0 : ImpForceQuadratic(aRect);
486 : 0 : break;
487 : : }
488 : :
489 : : case SID_3D_SHELL:
490 : : case SID_3D_HALF_SPHERE:
491 : : {
492 : : // force horizontal layout
493 : 0 : break;
494 : : }
495 : :
496 : : case SID_3D_CYLINDER:
497 : : case SID_3D_CONE:
498 : : case SID_3D_PYRAMID:
499 : : {
500 : : // force vertical layout
501 : 0 : break;
502 : : }
503 : : }
504 : :
505 : : // use changed rectangle, not original one
506 [ # # ]: 0 : pScene->SetLogicRect(aRect);
507 : :
508 [ # # ][ # # ]: 0 : return pScene;
509 : : }
510 : :
511 : : } // end of namespace sd
512 : :
513 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|