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