/src/libreoffice/sd/source/ui/func/fucon3d.cxx
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #include <fucon3d.hxx> |
21 | | |
22 | | #include <svx/svxids.hrc> |
23 | | #include <sfx2/dispatch.hxx> |
24 | | #include <sfx2/viewfrm.hxx> |
25 | | #include <tools/poly.hxx> |
26 | | |
27 | | #include <svx/xlineit0.hxx> |
28 | | #include <svx/scene3d.hxx> |
29 | | #include <svx/sphere3d.hxx> |
30 | | #include <svx/cube3d.hxx> |
31 | | #include <svx/lathe3d.hxx> |
32 | | #include <svx/camera3d.hxx> |
33 | | |
34 | | #include <vcl/weld.hxx> |
35 | | |
36 | | #include <app.hrc> |
37 | | |
38 | | #include <View.hxx> |
39 | | #include <Window.hxx> |
40 | | #include <ViewShell.hxx> |
41 | | #include <drawdoc.hxx> |
42 | | #include <ViewShellBase.hxx> |
43 | | #include <ToolBarManager.hxx> |
44 | | #include <svx/svx3ditems.hxx> |
45 | | |
46 | | #include <basegfx/polygon/b2dpolygontools.hxx> |
47 | | |
48 | | using namespace com::sun::star; |
49 | | |
50 | | namespace sd { |
51 | | |
52 | | |
53 | | FuConstruct3dObject::FuConstruct3dObject ( |
54 | | ViewShell& rViewSh, |
55 | | ::sd::Window* pWin, |
56 | | ::sd::View* pView, |
57 | | SdDrawDocument& rDoc, |
58 | | SfxRequest& rReq) |
59 | 0 | : FuConstruct(rViewSh, pWin, pView, rDoc, rReq) |
60 | 0 | { |
61 | 0 | } |
62 | | |
63 | | rtl::Reference<FuPoor> FuConstruct3dObject::Create( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq, bool bPermanent ) |
64 | 0 | { |
65 | 0 | FuConstruct3dObject* pFunc; |
66 | 0 | rtl::Reference<FuPoor> xFunc( pFunc = new FuConstruct3dObject( rViewSh, pWin, pView, rDoc, rReq ) ); |
67 | 0 | xFunc->DoExecute(rReq); |
68 | 0 | pFunc->SetPermanent(bPermanent); |
69 | 0 | return xFunc; |
70 | 0 | } |
71 | | |
72 | | void FuConstruct3dObject::DoExecute( SfxRequest& rReq ) |
73 | 0 | { |
74 | 0 | FuConstruct::DoExecute( rReq ); |
75 | 0 | mrViewShell.GetViewShellBase().GetToolBarManager()->SetToolBar( |
76 | 0 | ToolBarManager::ToolBarGroup::Function, |
77 | 0 | ToolBarManager::msDrawingObjectToolBar); |
78 | 0 | } |
79 | | |
80 | | rtl::Reference<E3dCompoundObject> FuConstruct3dObject::ImpCreateBasic3DShape() |
81 | 0 | { |
82 | 0 | rtl::Reference<E3dCompoundObject> p3DObj; |
83 | |
|
84 | 0 | switch (nSlotId) |
85 | 0 | { |
86 | 0 | default: |
87 | 0 | case SID_3D_CUBE: |
88 | 0 | { |
89 | 0 | p3DObj = new E3dCubeObj( |
90 | 0 | mpView->getSdrModelFromSdrView(), |
91 | 0 | mpView->Get3DDefaultAttributes(), |
92 | 0 | ::basegfx::B3DPoint(-2500, -2500, -2500), |
93 | 0 | ::basegfx::B3DVector(5000, 5000, 5000)); |
94 | 0 | break; |
95 | 0 | } |
96 | | |
97 | 0 | case SID_3D_SPHERE: |
98 | 0 | { |
99 | 0 | p3DObj = new E3dSphereObj( |
100 | 0 | mpView->getSdrModelFromSdrView(), |
101 | 0 | mpView->Get3DDefaultAttributes(), |
102 | 0 | ::basegfx::B3DPoint(0, 0, 0), |
103 | 0 | ::basegfx::B3DVector(5000, 5000, 5000)); |
104 | 0 | break; |
105 | 0 | } |
106 | | |
107 | 0 | case SID_3D_SHELL: |
108 | 0 | { |
109 | 0 | XPolygon aXPoly(Point (0, 1250), 2500, 2500, 0_deg100, 9000_deg100, false); |
110 | 0 | aXPoly.Scale(5.0, 5.0); |
111 | |
|
112 | 0 | ::basegfx::B2DPolygon aB2DPolygon(aXPoly.getB2DPolygon()); |
113 | 0 | if(aB2DPolygon.areControlPointsUsed()) |
114 | 0 | { |
115 | 0 | aB2DPolygon = ::basegfx::utils::adaptiveSubdivideByAngle(aB2DPolygon); |
116 | 0 | } |
117 | 0 | p3DObj = new E3dLatheObj( |
118 | 0 | mpView->getSdrModelFromSdrView(), |
119 | 0 | mpView->Get3DDefaultAttributes(), |
120 | 0 | ::basegfx::B2DPolyPolygon(aB2DPolygon)); |
121 | | |
122 | | /* this is an open object, therefore it has to be handled double- |
123 | | sided by default */ |
124 | 0 | p3DObj->SetMergedItem(makeSvx3DDoubleSidedItem(true)); |
125 | 0 | break; |
126 | 0 | } |
127 | | |
128 | 0 | case SID_3D_HALF_SPHERE: |
129 | 0 | { |
130 | 0 | XPolygon aXPoly(Point (0, 1250), 2500, 2500, 0_deg100, 9000_deg100, false); |
131 | 0 | aXPoly.Scale(5.0, 5.0); |
132 | |
|
133 | 0 | aXPoly.Insert(0, Point (2400*5, 1250*5), PolyFlags::Normal); |
134 | 0 | aXPoly.Insert(0, Point (2000*5, 1250*5), PolyFlags::Normal); |
135 | 0 | aXPoly.Insert(0, Point (1500*5, 1250*5), PolyFlags::Normal); |
136 | 0 | aXPoly.Insert(0, Point (1000*5, 1250*5), PolyFlags::Normal); |
137 | 0 | aXPoly.Insert(0, Point (500*5, 1250*5), PolyFlags::Normal); |
138 | 0 | aXPoly.Insert(0, Point (250*5, 1250*5), PolyFlags::Normal); |
139 | 0 | aXPoly.Insert(0, Point (50*5, 1250*5), PolyFlags::Normal); |
140 | 0 | aXPoly.Insert(0, Point (0, 1250*5), PolyFlags::Normal); |
141 | |
|
142 | 0 | ::basegfx::B2DPolygon aB2DPolygon(aXPoly.getB2DPolygon()); |
143 | 0 | if(aB2DPolygon.areControlPointsUsed()) |
144 | 0 | { |
145 | 0 | aB2DPolygon = ::basegfx::utils::adaptiveSubdivideByAngle(aB2DPolygon); |
146 | 0 | } |
147 | 0 | p3DObj = new E3dLatheObj( |
148 | 0 | mpView->getSdrModelFromSdrView(), |
149 | 0 | mpView->Get3DDefaultAttributes(), |
150 | 0 | ::basegfx::B2DPolyPolygon(aB2DPolygon)); |
151 | 0 | break; |
152 | 0 | } |
153 | | |
154 | 0 | case SID_3D_TORUS: |
155 | 0 | { |
156 | 0 | ::basegfx::B2DPolygon aB2DPolygon(::basegfx::utils::createPolygonFromCircle(::basegfx::B2DPoint(1000.0, 0.0), 500.0)); |
157 | 0 | if(aB2DPolygon.areControlPointsUsed()) |
158 | 0 | { |
159 | 0 | aB2DPolygon = ::basegfx::utils::adaptiveSubdivideByAngle(aB2DPolygon); |
160 | 0 | } |
161 | 0 | p3DObj = new E3dLatheObj( |
162 | 0 | mpView->getSdrModelFromSdrView(), |
163 | 0 | mpView->Get3DDefaultAttributes(), |
164 | 0 | ::basegfx::B2DPolyPolygon(aB2DPolygon)); |
165 | 0 | break; |
166 | 0 | } |
167 | | |
168 | 0 | case SID_3D_CYLINDER: |
169 | 0 | { |
170 | 0 | ::basegfx::B2DPolygon aInnerPoly; |
171 | |
|
172 | 0 | aInnerPoly.append(::basegfx::B2DPoint(0, 1000*5)); |
173 | 0 | aInnerPoly.append(::basegfx::B2DPoint(50*5, 1000*5)); |
174 | 0 | aInnerPoly.append(::basegfx::B2DPoint(100*5, 1000*5)); |
175 | 0 | aInnerPoly.append(::basegfx::B2DPoint(200*5, 1000*5)); |
176 | 0 | aInnerPoly.append(::basegfx::B2DPoint(300*5, 1000*5)); |
177 | 0 | aInnerPoly.append(::basegfx::B2DPoint(400*5, 1000*5)); |
178 | 0 | aInnerPoly.append(::basegfx::B2DPoint(450*5, 1000*5)); |
179 | 0 | aInnerPoly.append(::basegfx::B2DPoint(500*5, 1000*5)); |
180 | 0 | aInnerPoly.append(::basegfx::B2DPoint(500*5, -1000*5)); |
181 | 0 | aInnerPoly.append(::basegfx::B2DPoint(450*5, -1000*5)); |
182 | 0 | aInnerPoly.append(::basegfx::B2DPoint(400*5, -1000*5)); |
183 | 0 | aInnerPoly.append(::basegfx::B2DPoint(300*5, -1000*5)); |
184 | 0 | aInnerPoly.append(::basegfx::B2DPoint(200*5, -1000*5)); |
185 | 0 | aInnerPoly.append(::basegfx::B2DPoint(100*5, -1000*5)); |
186 | 0 | aInnerPoly.append(::basegfx::B2DPoint(50*5, -1000*5)); |
187 | 0 | aInnerPoly.append(::basegfx::B2DPoint(0, -1000*5)); |
188 | 0 | aInnerPoly.setClosed(true); |
189 | |
|
190 | 0 | p3DObj = new E3dLatheObj( |
191 | 0 | mpView->getSdrModelFromSdrView(), |
192 | 0 | mpView->Get3DDefaultAttributes(), |
193 | 0 | ::basegfx::B2DPolyPolygon(aInnerPoly)); |
194 | 0 | break; |
195 | 0 | } |
196 | | |
197 | 0 | case SID_3D_CONE: |
198 | 0 | { |
199 | 0 | ::basegfx::B2DPolygon aInnerPoly; |
200 | |
|
201 | 0 | aInnerPoly.append(::basegfx::B2DPoint(0, -1000*5)); |
202 | 0 | aInnerPoly.append(::basegfx::B2DPoint(25*5, -900*5)); |
203 | 0 | aInnerPoly.append(::basegfx::B2DPoint(50*5, -800*5)); |
204 | 0 | aInnerPoly.append(::basegfx::B2DPoint(100*5, -600*5)); |
205 | 0 | aInnerPoly.append(::basegfx::B2DPoint(200*5, -200*5)); |
206 | 0 | aInnerPoly.append(::basegfx::B2DPoint(300*5, 200*5)); |
207 | 0 | aInnerPoly.append(::basegfx::B2DPoint(400*5, 600*5)); |
208 | 0 | aInnerPoly.append(::basegfx::B2DPoint(500*5, 1000*5)); |
209 | 0 | aInnerPoly.append(::basegfx::B2DPoint(400*5, 1000*5)); |
210 | 0 | aInnerPoly.append(::basegfx::B2DPoint(300*5, 1000*5)); |
211 | 0 | aInnerPoly.append(::basegfx::B2DPoint(200*5, 1000*5)); |
212 | 0 | aInnerPoly.append(::basegfx::B2DPoint(100*5, 1000*5)); |
213 | 0 | aInnerPoly.append(::basegfx::B2DPoint(50*5, 1000*5)); |
214 | 0 | aInnerPoly.append(::basegfx::B2DPoint(0, 1000*5)); |
215 | 0 | aInnerPoly.setClosed(true); |
216 | |
|
217 | 0 | p3DObj = new E3dLatheObj( |
218 | 0 | mpView->getSdrModelFromSdrView(), |
219 | 0 | mpView->Get3DDefaultAttributes(), |
220 | 0 | ::basegfx::B2DPolyPolygon(aInnerPoly)); |
221 | 0 | break; |
222 | 0 | } |
223 | | |
224 | 0 | case SID_3D_PYRAMID: |
225 | 0 | { |
226 | 0 | ::basegfx::B2DPolygon aInnerPoly; |
227 | |
|
228 | 0 | aInnerPoly.append(::basegfx::B2DPoint(0, -1000*5)); |
229 | 0 | aInnerPoly.append(::basegfx::B2DPoint(25*5, -900*5)); |
230 | 0 | aInnerPoly.append(::basegfx::B2DPoint(50*5, -800*5)); |
231 | 0 | aInnerPoly.append(::basegfx::B2DPoint(100*5, -600*5)); |
232 | 0 | aInnerPoly.append(::basegfx::B2DPoint(200*5, -200*5)); |
233 | 0 | aInnerPoly.append(::basegfx::B2DPoint(300*5, 200*5)); |
234 | 0 | aInnerPoly.append(::basegfx::B2DPoint(400*5, 600*5)); |
235 | 0 | aInnerPoly.append(::basegfx::B2DPoint(500*5, 1000*5)); |
236 | 0 | aInnerPoly.append(::basegfx::B2DPoint(400*5, 1000*5)); |
237 | 0 | aInnerPoly.append(::basegfx::B2DPoint(300*5, 1000*5)); |
238 | 0 | aInnerPoly.append(::basegfx::B2DPoint(200*5, 1000*5)); |
239 | 0 | aInnerPoly.append(::basegfx::B2DPoint(100*5, 1000*5)); |
240 | 0 | aInnerPoly.append(::basegfx::B2DPoint(50*5, 1000*5)); |
241 | 0 | aInnerPoly.append(::basegfx::B2DPoint(0, 1000*5)); |
242 | 0 | aInnerPoly.setClosed(true); |
243 | |
|
244 | 0 | p3DObj = new E3dLatheObj( |
245 | 0 | mpView->getSdrModelFromSdrView(), |
246 | 0 | mpView->Get3DDefaultAttributes(), |
247 | 0 | ::basegfx::B2DPolyPolygon(aInnerPoly)); |
248 | 0 | p3DObj->SetMergedItem(makeSvx3DHorizontalSegmentsItem(4)); |
249 | 0 | break; |
250 | 0 | } |
251 | 0 | } |
252 | | |
253 | 0 | return p3DObj; |
254 | 0 | } |
255 | | |
256 | | void FuConstruct3dObject::ImpPrepareBasic3DShape(E3dCompoundObject const * p3DObj, E3dScene *pScene) |
257 | 0 | { |
258 | 0 | Camera3D aCamera = pScene->GetCamera (); |
259 | | |
260 | | // get transformed BoundVolume of the new object |
261 | 0 | basegfx::B3DRange aBoundVol; |
262 | 0 | basegfx::B3DRange aObjVol(p3DObj->GetBoundVolume()); |
263 | 0 | aObjVol.transform(p3DObj->GetTransform()); |
264 | 0 | aBoundVol.expand(aObjVol); |
265 | 0 | double fDeepth(aBoundVol.getDepth()); |
266 | |
|
267 | 0 | aCamera.SetPRP(::basegfx::B3DPoint(0.0, 0.0, 1000.0)); |
268 | 0 | aCamera.SetPosition(::basegfx::B3DPoint(0.0, 0.0, mpView->GetDefaultCamPosZ() + fDeepth / 2)); |
269 | 0 | aCamera.SetFocalLength(mpView->GetDefaultCamFocal()); |
270 | 0 | pScene->SetCamera(aCamera); |
271 | 0 | basegfx::B3DHomMatrix aTransformation; |
272 | |
|
273 | 0 | switch (nSlotId) |
274 | 0 | { |
275 | 0 | case SID_3D_CUBE: |
276 | 0 | { |
277 | 0 | aTransformation.rotate(basegfx::deg2rad(20), 0.0, 0.0); |
278 | 0 | } |
279 | 0 | break; |
280 | | |
281 | 0 | case SID_3D_SHELL: |
282 | 0 | case SID_3D_HALF_SPHERE: |
283 | 0 | { |
284 | 0 | aTransformation.rotate(basegfx::deg2rad(200), 0.0, 0.0); |
285 | 0 | } |
286 | 0 | break; |
287 | | |
288 | 0 | case SID_3D_SPHERE: |
289 | 0 | case SID_3D_CYLINDER: |
290 | 0 | case SID_3D_CONE: |
291 | 0 | case SID_3D_PYRAMID: |
292 | 0 | { |
293 | 0 | } |
294 | 0 | break; |
295 | | |
296 | 0 | case SID_3D_TORUS: |
297 | 0 | { |
298 | 0 | aTransformation.rotate(basegfx::deg2rad(90), 0.0, 0.0); |
299 | 0 | } |
300 | 0 | break; |
301 | | |
302 | 0 | default: |
303 | 0 | { |
304 | 0 | } |
305 | 0 | break; |
306 | 0 | } |
307 | | |
308 | 0 | pScene->SetTransform(aTransformation * pScene->GetTransform()); |
309 | |
|
310 | 0 | SfxItemSet aAttr (mrViewShell.GetPool()); |
311 | 0 | pScene->SetMergedItemSetAndBroadcast(aAttr); |
312 | 0 | } |
313 | | |
314 | | bool FuConstruct3dObject::MouseButtonDown(const MouseEvent& rMEvt) |
315 | 0 | { |
316 | 0 | bool bReturn = FuConstruct::MouseButtonDown(rMEvt); |
317 | |
|
318 | 0 | if ( rMEvt.IsLeft() && !mpView->IsAction() ) |
319 | 0 | { |
320 | 0 | Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); |
321 | |
|
322 | 0 | mpWindow->CaptureMouse(); |
323 | 0 | sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() ); |
324 | |
|
325 | 0 | weld::WaitObject aWait(mrViewShell.GetFrameWeld()); |
326 | |
|
327 | 0 | rtl::Reference<E3dCompoundObject> p3DObj = ImpCreateBasic3DShape(); |
328 | 0 | rtl::Reference<E3dScene> pScene = mpView->SetCurrent3DObj(p3DObj.get()); |
329 | |
|
330 | 0 | ImpPrepareBasic3DShape(p3DObj.get(), pScene.get()); |
331 | 0 | bReturn = mpView->BegCreatePreparedObject(aPnt, nDrgLog, pScene.get()); |
332 | |
|
333 | 0 | SdrObject* pObj = mpView->GetCreateObj(); |
334 | |
|
335 | 0 | if (pObj) |
336 | 0 | { |
337 | 0 | SfxItemSet aAttr(mrDoc.GetPool()); |
338 | 0 | SetStyleSheet(aAttr, pObj); |
339 | | |
340 | | // extract LineStyle |
341 | 0 | aAttr.Put(XLineStyleItem (drawing::LineStyle_NONE)); |
342 | |
|
343 | 0 | pObj->SetMergedItemSet(aAttr); |
344 | 0 | } |
345 | 0 | } |
346 | |
|
347 | 0 | return bReturn; |
348 | 0 | } |
349 | | |
350 | | bool FuConstruct3dObject::MouseButtonUp(const MouseEvent& rMEvt) |
351 | 0 | { |
352 | 0 | if (rMEvt.IsLeft() && IsIgnoreUnexpectedMouseButtonUp()) |
353 | 0 | return false; |
354 | | |
355 | 0 | bool bReturn = false; |
356 | |
|
357 | 0 | if ( mpView->IsCreateObj() && rMEvt.IsLeft() ) |
358 | 0 | { |
359 | 0 | if( mpView->EndCreateObj( SdrCreateCmd::ForceEnd ) ) |
360 | 0 | { |
361 | 0 | bReturn = true; |
362 | 0 | } |
363 | 0 | else |
364 | 0 | { |
365 | | //Drag was too small to create object, so insert default object at click pos |
366 | 0 | Point aClickPos(mpWindow->PixelToLogic(rMEvt.GetPosPixel())); |
367 | 0 | sal_uInt32 nDefaultObjectSize(1000); |
368 | 0 | sal_Int32 nCenterOffset(-sal_Int32(nDefaultObjectSize / 2)); |
369 | 0 | aClickPos.AdjustX(nCenterOffset); |
370 | 0 | aClickPos.AdjustY(nCenterOffset); |
371 | |
|
372 | 0 | SdrPageView *pPV = mpView->GetSdrPageView(); |
373 | |
|
374 | 0 | if(mpView->IsSnapEnabled()) |
375 | 0 | aClickPos = mpView->GetSnapPos(aClickPos, pPV); |
376 | |
|
377 | 0 | ::tools::Rectangle aNewObjectRectangle(aClickPos, Size(nDefaultObjectSize, nDefaultObjectSize)); |
378 | 0 | rtl::Reference<SdrObject> pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle); |
379 | |
|
380 | 0 | bReturn = mpView->InsertObjectAtView(pObjDefault.get(), *pPV, SdrInsertFlags::SETDEFLAYER | SdrInsertFlags::SETDEFATTR); |
381 | 0 | } |
382 | 0 | } |
383 | 0 | bReturn = FuConstruct::MouseButtonUp(rMEvt) || bReturn; |
384 | |
|
385 | 0 | if (!bPermanent) |
386 | 0 | mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON); |
387 | |
|
388 | 0 | return bReturn; |
389 | 0 | } |
390 | | |
391 | | void FuConstruct3dObject::Activate() |
392 | 0 | { |
393 | 0 | mpView->SetCurrentObj(SdrObjKind::NONE); |
394 | |
|
395 | 0 | FuConstruct::Activate(); |
396 | 0 | } |
397 | | |
398 | | rtl::Reference<SdrObject> FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) |
399 | 0 | { |
400 | |
|
401 | 0 | rtl::Reference<E3dCompoundObject> p3DObj = ImpCreateBasic3DShape(); |
402 | | |
403 | | // E3dView::SetCurrent3DObj part |
404 | | // get transformed BoundVolume of the object |
405 | 0 | basegfx::B3DRange aObjVol(p3DObj->GetBoundVolume()); |
406 | 0 | aObjVol.transform(p3DObj->GetTransform()); |
407 | 0 | basegfx::B3DRange aVolume(aObjVol); |
408 | 0 | double fW(aVolume.getWidth()); |
409 | 0 | double fH(aVolume.getHeight()); |
410 | 0 | ::tools::Rectangle a3DRect(0, 0, static_cast<::tools::Long>(fW), static_cast<::tools::Long>(fH)); |
411 | 0 | rtl::Reference< E3dScene > pScene(new E3dScene(mrDoc)); |
412 | | |
413 | | // copied code from E3dView::InitScene |
414 | 0 | double fCamZ(aVolume.getMaxZ() + ((fW + fH) / 4.0)); |
415 | 0 | Camera3D aCam(pScene->GetCamera()); |
416 | 0 | aCam.SetAutoAdjustProjection(false); |
417 | 0 | aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH); |
418 | 0 | ::basegfx::B3DPoint aLookAt; |
419 | 0 | double fDefaultCamPosZ = mpView->GetDefaultCamPosZ(); |
420 | 0 | ::basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ); |
421 | 0 | aCam.SetPosAndLookAt(aCamPos, aLookAt); |
422 | 0 | aCam.SetFocalLength(mpView->GetDefaultCamFocal()); |
423 | 0 | pScene->SetCamera(aCam); |
424 | 0 | pScene->InsertObject(p3DObj.get()); |
425 | 0 | pScene->NbcSetSnapRect(a3DRect); |
426 | 0 | ImpPrepareBasic3DShape(p3DObj.get(), pScene.get()); |
427 | 0 | SfxItemSet aAttr(mrDoc.GetPool()); |
428 | 0 | SetStyleSheet(aAttr, p3DObj.get()); |
429 | 0 | aAttr.Put(XLineStyleItem (drawing::LineStyle_NONE)); |
430 | 0 | p3DObj->SetMergedItemSet(aAttr); |
431 | | |
432 | | // make object interactive at once |
433 | 0 | pScene->SetBoundAndSnapRectsDirty(); |
434 | | |
435 | | // Take care of restrictions for the rectangle |
436 | 0 | ::tools::Rectangle aRect(rRectangle); |
437 | |
|
438 | 0 | switch(nID) |
439 | 0 | { |
440 | 0 | case SID_3D_CUBE: |
441 | 0 | case SID_3D_SPHERE: |
442 | 0 | case SID_3D_TORUS: |
443 | 0 | { |
444 | | // force quadratic |
445 | 0 | ImpForceQuadratic(aRect); |
446 | 0 | break; |
447 | 0 | } |
448 | | |
449 | 0 | case SID_3D_SHELL: |
450 | 0 | case SID_3D_HALF_SPHERE: |
451 | 0 | { |
452 | | // force horizontal layout |
453 | 0 | break; |
454 | 0 | } |
455 | | |
456 | 0 | case SID_3D_CYLINDER: |
457 | 0 | case SID_3D_CONE: |
458 | 0 | case SID_3D_PYRAMID: |
459 | 0 | { |
460 | | // force vertical layout |
461 | 0 | break; |
462 | 0 | } |
463 | 0 | } |
464 | | |
465 | | // use changed rectangle, not original one |
466 | 0 | pScene->SetLogicRect(aRect); |
467 | |
|
468 | 0 | return pScene; |
469 | 0 | } |
470 | | |
471 | | } // end of namespace sd |
472 | | |
473 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |