fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / engine3d / dragmt3d.cxx
blobccc796eb6dbe52b070972a2b0c1cc03f46b9947c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <dragmt3d.hxx>
22 #include <tools/shl.hxx>
23 #include <svx/svdpagv.hxx>
24 #include <svx/dialmgr.hxx>
25 #include <svx/svddrgmt.hxx>
26 #include <svx/svdtrans.hxx>
27 #include <svx/obj3d.hxx>
28 #include <svx/polysc3d.hxx>
29 #include <svx/e3dundo.hxx>
30 #include <svx/dialogs.hrc>
31 #include <svx/sdr/overlay/overlaypolypolygon.hxx>
32 #include <svx/sdr/overlay/overlaymanager.hxx>
33 #include <basegfx/polygon/b2dpolypolygontools.hxx>
34 #include <svx/sdr/contact/viewcontactofe3dscene.hxx>
35 #include <drawinglayer/geometry/viewinformation3d.hxx>
36 #include <svx/e3dsceneupdater.hxx>
38 TYPEINIT1(E3dDragMethod, SdrDragMethod);
40 E3dDragMethod::E3dDragMethod (
41 SdrDragView &_rView,
42 const SdrMarkList& rMark,
43 E3dDragConstraint eConstr,
44 sal_Bool bFull)
45 : SdrDragMethod(_rView),
46 meConstraint(eConstr),
47 mbMoveFull(bFull),
48 mbMovedAtAll(sal_False)
50 // Create a unit for all the 3D objects present in the selection
51 const long nCnt(rMark.GetMarkCount());
52 static bool bDoInvalidate(false);
53 long nObjs(0);
55 if(mbMoveFull)
57 // for non-visible 3D objects fallback to wireframe interaction
58 bool bInvisibleObjects(false);
60 for(nObjs = 0;!bInvisibleObjects && nObjs < nCnt;nObjs++)
62 E3dObject* pE3dObj = dynamic_cast< E3dObject* >(rMark.GetMark(nObjs)->GetMarkedSdrObj());
64 if(pE3dObj)
66 if(!pE3dObj->HasFillStyle() && !pE3dObj->HasLineStyle())
68 bInvisibleObjects = true;
73 if(bInvisibleObjects)
75 mbMoveFull = false;
79 for(nObjs = 0;nObjs < nCnt;nObjs++)
81 E3dObject* pE3dObj = dynamic_cast< E3dObject* >(rMark.GetMark(nObjs)->GetMarkedSdrObj());
83 if(pE3dObj)
85 // fill new interaction unit
86 E3dDragMethodUnit aNewUnit;
87 aNewUnit.mp3DObj = pE3dObj;
89 // get transformations
90 aNewUnit.maInitTransform = aNewUnit.maTransform = pE3dObj->GetTransform();
92 if(pE3dObj->GetParentObj())
94 // get transform between object and world, normally scene transform
95 aNewUnit.maInvDisplayTransform = aNewUnit.maDisplayTransform = pE3dObj->GetParentObj()->GetFullTransform();
96 aNewUnit.maInvDisplayTransform.invert();
99 // Invalidate SnapRects of the objects involved, to force a
100 // recalculation for setting the marker
101 if(bDoInvalidate)
103 pE3dObj->SetRectsDirty();
106 if(!mbMoveFull)
108 // create wireframe visualisation for parent coordinate system
109 aNewUnit.maWireframePoly.clear();
110 aNewUnit.maWireframePoly = pE3dObj->CreateWireframe();
111 aNewUnit.maWireframePoly.transform(aNewUnit.maTransform);
114 // Determine FullBound
115 maFullBound.Union(pE3dObj->GetSnapRect());
117 // Insert Unit
118 maGrp.push_back(aNewUnit);
123 void E3dDragMethod::TakeSdrDragComment(XubString& /*rStr*/) const
127 // Create the wireframe model for all actions
129 bool E3dDragMethod::BeginSdrDrag()
131 if(E3DDRAG_CONSTR_Z == meConstraint)
133 const sal_uInt32 nCnt(maGrp.size());
134 DragStat().Ref1() = maFullBound.Center();
136 for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
138 E3dDragMethodUnit& rCandidate = maGrp[nOb];
139 rCandidate.mnStartAngle = GetAngle(DragStat().GetStart() - DragStat().GetRef1());
140 rCandidate.mnLastAngle = 0;
143 else
145 maLastPos = DragStat().GetStart();
148 if(!mbMoveFull)
150 Show();
153 return sal_True;
156 bool E3dDragMethod::EndSdrDrag(bool /*bCopy*/)
158 const sal_uInt32 nCnt(maGrp.size());
160 if(!mbMoveFull)
162 // Hide wireframe
163 Hide();
166 // Apply all transformations and create undo's
167 if(mbMovedAtAll)
169 const bool bUndo = getSdrDragView().IsUndoEnabled();
170 if( bUndo )
171 getSdrDragView().BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_ROTATE));
172 sal_uInt32 nOb(0);
174 for(nOb=0;nOb<nCnt;nOb++)
176 E3dDragMethodUnit& rCandidate = maGrp[nOb];
177 E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
178 rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
179 if( bUndo )
181 getSdrDragView().AddUndo(new E3dRotateUndoAction(rCandidate.mp3DObj->GetModel(),
182 rCandidate.mp3DObj, rCandidate.maInitTransform,
183 rCandidate.maTransform));
186 if( bUndo )
187 getSdrDragView().EndUndo();
190 return sal_True;
193 void E3dDragMethod::CancelSdrDrag()
195 if(mbMoveFull)
197 if(mbMovedAtAll)
199 const sal_uInt32 nCnt(maGrp.size());
201 for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
203 // Restore transformation
204 E3dDragMethodUnit& rCandidate = maGrp[nOb];
205 E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
206 rCandidate.mp3DObj->SetTransform(rCandidate.maInitTransform);
210 else
212 // Hide WireFrame
213 Hide();
217 // Common MoveSdrDrag()
219 void E3dDragMethod::MoveSdrDrag(const Point& /*rPnt*/)
221 mbMovedAtAll = true;
224 // Draw the wire frame model
226 // for migration from XOR to overlay
227 void E3dDragMethod::CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager)
229 const sal_uInt32 nCnt(maGrp.size());
230 basegfx::B2DPolyPolygon aResult;
232 for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
234 E3dDragMethodUnit& rCandidate = maGrp[nOb];
235 SdrPageView* pPV = getSdrDragView().GetSdrPageView();
237 if(pPV && pPV->HasMarkedObjPageView())
239 const basegfx::B3DPolyPolygon aCandidate(rCandidate.maWireframePoly);
240 const sal_uInt32 nPlyCnt(aCandidate.count());
242 if(nPlyCnt)
244 const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
245 const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
246 const basegfx::B3DHomMatrix aWorldToView(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection() * aViewInfo3D.getOrientation());
247 const basegfx::B3DHomMatrix aTransform(aWorldToView * rCandidate.maDisplayTransform);
249 // transform to relative scene coordinates
250 basegfx::B2DPolyPolygon aPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aCandidate, aTransform));
252 // transform to 2D view coordinates
253 aPolyPolygon.transform(rVCScene.getObjectTransformation());
255 aResult.append(aPolyPolygon);
260 if(aResult.count())
262 ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aResult);
263 rOverlayManager.add(*pNew);
264 addToOverlayObjectList(*pNew);
268 /*************************************************************************
270 E3dDragRotate
272 *************************************************************************/
274 TYPEINIT1(E3dDragRotate, E3dDragMethod);
276 E3dDragRotate::E3dDragRotate(SdrDragView &_rView,
277 const SdrMarkList& rMark,
278 E3dDragConstraint eConstr,
279 sal_Bool bFull)
280 : E3dDragMethod(_rView, rMark, eConstr, bFull)
282 // Get center of all selected objects in eye coordinates
283 const sal_uInt32 nCnt(maGrp.size());
285 if(nCnt)
287 const E3dScene *pScene = maGrp[0].mp3DObj->GetScene();
289 if(pScene)
291 const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
292 const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
294 for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
296 E3dDragMethodUnit& rCandidate = maGrp[nOb];
297 basegfx::B3DPoint aObjCenter = rCandidate.mp3DObj->GetBoundVolume().getCenter();
298 const basegfx::B3DHomMatrix aTransform(aViewInfo3D.getOrientation() * rCandidate.maDisplayTransform * rCandidate.maInitTransform);
300 aObjCenter = aTransform * aObjCenter;
301 maGlobalCenter += aObjCenter;
304 // Divide by the number
305 if(nCnt > 1)
307 maGlobalCenter /= (double)nCnt;
310 // get rotate center and transform to 3D eye coordinates
311 basegfx::B2DPoint aRotCenter2D(Ref1().X(), Ref1().Y());
313 // from world to relative scene using inverse getObjectTransformation()
314 basegfx::B2DHomMatrix aInverseObjectTransform(rVCScene.getObjectTransformation());
315 aInverseObjectTransform.invert();
316 aRotCenter2D = aInverseObjectTransform * aRotCenter2D;
318 // from 3D view to 3D eye
319 basegfx::B3DPoint aRotCenter3D(aRotCenter2D.getX(), aRotCenter2D.getY(), 0.0);
320 basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
321 aInverseViewToEye.invert();
322 aRotCenter3D = aInverseViewToEye * aRotCenter3D;
324 // Use X,Y of the RotCenter and depth of the common object centre
325 // as rotation point in the space
326 maGlobalCenter.setX(aRotCenter3D.getX());
327 maGlobalCenter.setY(aRotCenter3D.getY());
333 //The object is moved, determine the angle
335 void E3dDragRotate::MoveSdrDrag(const Point& rPnt)
337 // call parent
338 E3dDragMethod::MoveSdrDrag(rPnt);
340 if(DragStat().CheckMinMoved(rPnt))
342 // Get modifier
343 sal_uInt16 nModifier = 0;
344 if(getSdrDragView().ISA(E3dView))
346 const MouseEvent& rLastMouse = ((E3dView&)getSdrDragView()).GetMouseEvent();
347 nModifier = rLastMouse.GetModifier();
350 // Rotate all objects
351 const sal_uInt32 nCnt(maGrp.size());
353 for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
355 // Determine rotation angle
356 double fWAngle, fHAngle;
357 E3dDragMethodUnit& rCandidate = maGrp[nOb];
359 if(E3DDRAG_CONSTR_Z == meConstraint)
361 fWAngle = NormAngle360(GetAngle(rPnt - DragStat().GetRef1()) -
362 rCandidate.mnStartAngle) - rCandidate.mnLastAngle;
363 rCandidate.mnLastAngle = (long)fWAngle + rCandidate.mnLastAngle;
364 fWAngle /= 100.0;
365 fHAngle = 0.0;
367 else
369 fWAngle = 90.0 * (double)(rPnt.X() - maLastPos.X())
370 / (double)maFullBound.GetWidth();
371 fHAngle = 90.0 * (double)(rPnt.Y() - maLastPos.Y())
372 / (double)maFullBound.GetHeight();
374 long nSnap = 0;
376 if(!getSdrDragView().IsRotateAllowed(sal_False))
377 nSnap = 90;
379 if(nSnap != 0)
381 fWAngle = (double)(((long) fWAngle + nSnap/2) / nSnap * nSnap);
382 fHAngle = (double)(((long) fHAngle + nSnap/2) / nSnap * nSnap);
385 // to radians
386 fWAngle *= F_PI180;
387 fHAngle *= F_PI180;
389 // Determine transformation
390 basegfx::B3DHomMatrix aRotMat;
391 if(E3DDRAG_CONSTR_Y & meConstraint)
393 if(nModifier & KEY_MOD2)
394 aRotMat.rotate(0.0, 0.0, fWAngle);
395 else
396 aRotMat.rotate(0.0, fWAngle, 0.0);
398 else if(E3DDRAG_CONSTR_Z & meConstraint)
400 if(nModifier & KEY_MOD2)
401 aRotMat.rotate(0.0, fWAngle, 0.0);
402 else
403 aRotMat.rotate(0.0, 0.0, fWAngle);
405 if(E3DDRAG_CONSTR_X & meConstraint)
407 aRotMat.rotate(fHAngle, 0.0, 0.0);
410 // Transformation in eye coordinates, there rotate then and back
411 const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
412 const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
413 basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
414 aInverseOrientation.invert();
416 basegfx::B3DHomMatrix aTransMat(rCandidate.maDisplayTransform);
417 aTransMat *= aViewInfo3D.getOrientation();
418 aTransMat.translate(-maGlobalCenter.getX(), -maGlobalCenter.getY(), -maGlobalCenter.getZ());
419 aTransMat *= aRotMat;
420 aTransMat.translate(maGlobalCenter.getX(), maGlobalCenter.getY(), maGlobalCenter.getZ());
421 aTransMat *= aInverseOrientation;
422 aTransMat *= rCandidate.maInvDisplayTransform;
424 // ...and apply
425 rCandidate.maTransform *= aTransMat;
427 if(mbMoveFull)
429 E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
430 rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
432 else
434 Hide();
435 rCandidate.maWireframePoly.transform(aTransMat);
436 Show();
439 maLastPos = rPnt;
440 DragStat().NextMove(rPnt);
444 Pointer E3dDragRotate::GetSdrDragPointer() const
446 return Pointer(POINTER_ROTATE);
449 // E3dDragMove. This drag method is only required for translations inside
450 // 3D scenes. If a 3D-scene itself moved, then this drag method will drag
451 // not be used.
453 TYPEINIT1(E3dDragMove, E3dDragMethod);
455 E3dDragMove::E3dDragMove(SdrDragView &_rView,
456 const SdrMarkList& rMark,
457 SdrHdlKind eDrgHdl,
458 E3dDragConstraint eConstr,
459 sal_Bool bFull)
460 : E3dDragMethod(_rView, rMark, eConstr, bFull),
461 meWhatDragHdl(eDrgHdl)
463 switch(meWhatDragHdl)
465 case HDL_LEFT:
466 maScaleFixPos = maFullBound.RightCenter();
467 break;
468 case HDL_RIGHT:
469 maScaleFixPos = maFullBound.LeftCenter();
470 break;
471 case HDL_UPPER:
472 maScaleFixPos = maFullBound.BottomCenter();
473 break;
474 case HDL_LOWER:
475 maScaleFixPos = maFullBound.TopCenter();
476 break;
477 case HDL_UPLFT:
478 maScaleFixPos = maFullBound.BottomRight();
479 break;
480 case HDL_UPRGT:
481 maScaleFixPos = maFullBound.BottomLeft();
482 break;
483 case HDL_LWLFT:
484 maScaleFixPos = maFullBound.TopRight();
485 break;
486 case HDL_LWRGT:
487 maScaleFixPos = maFullBound.TopLeft();
488 break;
489 default:
490 // Moving the object, HDL_MOVE
491 break;
494 // Override when IsResizeAtCenter()
495 if(getSdrDragView().IsResizeAtCenter())
497 meWhatDragHdl = HDL_USER;
498 maScaleFixPos = maFullBound.Center();
502 // The object is moved, determine the translations
504 void E3dDragMove::MoveSdrDrag(const Point& rPnt)
506 // call parent
507 E3dDragMethod::MoveSdrDrag(rPnt);
509 if(DragStat().CheckMinMoved(rPnt))
511 if(HDL_MOVE == meWhatDragHdl)
513 // Translation
514 // Determine the motion vector
515 const sal_uInt32 nCnt(maGrp.size());
517 // Get modifier
518 sal_uInt16 nModifier(0);
520 if(getSdrDragView().ISA(E3dView))
522 const MouseEvent& rLastMouse = ((E3dView&)getSdrDragView()).GetMouseEvent();
523 nModifier = rLastMouse.GetModifier();
526 for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
528 E3dDragMethodUnit& rCandidate = maGrp[nOb];
529 const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
530 const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
532 // move coor from 2d world to 3d Eye
533 basegfx::B2DPoint aGlobalMoveHead2D((double)(rPnt.X() - maLastPos.X()), (double)(rPnt.Y() - maLastPos.Y()));
534 basegfx::B2DPoint aGlobalMoveTail2D(0.0, 0.0);
535 basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
537 aInverseSceneTransform.invert();
538 aGlobalMoveHead2D = aInverseSceneTransform * aGlobalMoveHead2D;
539 aGlobalMoveTail2D = aInverseSceneTransform * aGlobalMoveTail2D;
541 basegfx::B3DPoint aMoveHead3D(aGlobalMoveHead2D.getX(), aGlobalMoveHead2D.getY(), 0.5);
542 basegfx::B3DPoint aMoveTail3D(aGlobalMoveTail2D.getX(), aGlobalMoveTail2D.getY(), 0.5);
543 basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
544 aInverseViewToEye.invert();
546 aMoveHead3D = aInverseViewToEye * aMoveHead3D;
547 aMoveTail3D = aInverseViewToEye * aMoveTail3D;
549 // eventually switch movement from XY to XZ plane
550 if(nModifier & KEY_MOD2)
552 double fZwi = aMoveHead3D.getY();
553 aMoveHead3D.setY(aMoveHead3D.getZ());
554 aMoveHead3D.setZ(fZwi);
556 fZwi = aMoveTail3D.getY();
557 aMoveTail3D.setY(aMoveTail3D.getZ());
558 aMoveTail3D.setZ(fZwi);
561 // Motion vector from eye coordinates to parent coordinates
562 basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
563 aInverseOrientation.invert();
564 basegfx::B3DHomMatrix aCompleteTrans(rCandidate.maInvDisplayTransform * aInverseOrientation);
566 aMoveHead3D = aCompleteTrans * aMoveHead3D;
567 aMoveTail3D = aCompleteTrans* aMoveTail3D;
569 // build transformation
570 basegfx::B3DHomMatrix aTransMat;
571 basegfx::B3DPoint aTranslate(aMoveHead3D - aMoveTail3D);
572 aTransMat.translate(aTranslate.getX(), aTranslate.getY(), aTranslate.getZ());
574 // ...and apply
575 rCandidate.maTransform *= aTransMat;
577 if(mbMoveFull)
579 E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
580 rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
582 else
584 Hide();
585 rCandidate.maWireframePoly.transform(aTransMat);
586 Show();
590 else
592 // Scaling
593 // Determine scaling vector
594 Point aStartPos = DragStat().GetStart();
595 const sal_uInt32 nCnt(maGrp.size());
597 for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
599 E3dDragMethodUnit& rCandidate = maGrp[nOb];
600 const basegfx::B3DPoint aObjectCenter(rCandidate.mp3DObj->GetBoundVolume().getCenter());
602 // transform from 2D world view to 3D eye
603 const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
604 const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
606 basegfx::B2DPoint aGlobalScaleStart2D((double)(aStartPos.X()), (double)(aStartPos.Y()));
607 basegfx::B2DPoint aGlobalScaleNext2D((double)(rPnt.X()), (double)(rPnt.Y()));
608 basegfx::B2DPoint aGlobalScaleFixPos2D((double)(maScaleFixPos.X()), (double)(maScaleFixPos.Y()));
609 basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
611 aInverseSceneTransform.invert();
612 aGlobalScaleStart2D = aInverseSceneTransform * aGlobalScaleStart2D;
613 aGlobalScaleNext2D = aInverseSceneTransform * aGlobalScaleNext2D;
614 aGlobalScaleFixPos2D = aInverseSceneTransform * aGlobalScaleFixPos2D;
616 basegfx::B3DPoint aGlobalScaleStart3D(aGlobalScaleStart2D.getX(), aGlobalScaleStart2D.getY(), aObjectCenter.getZ());
617 basegfx::B3DPoint aGlobalScaleNext3D(aGlobalScaleNext2D.getX(), aGlobalScaleNext2D.getY(), aObjectCenter.getZ());
618 basegfx::B3DPoint aGlobalScaleFixPos3D(aGlobalScaleFixPos2D.getX(), aGlobalScaleFixPos2D.getY(), aObjectCenter.getZ());
619 basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
621 aInverseViewToEye.invert();
622 basegfx::B3DPoint aScStart(aInverseViewToEye * aGlobalScaleStart3D);
623 basegfx::B3DPoint aScNext(aInverseViewToEye * aGlobalScaleNext3D);
624 basegfx::B3DPoint aScFixPos(aInverseViewToEye * aGlobalScaleFixPos3D);
626 // constraints?
627 switch(meWhatDragHdl)
629 case HDL_LEFT:
630 case HDL_RIGHT:
631 // to constrain on X -> Y equal
632 aScNext.setY(aScFixPos.getY());
633 break;
634 case HDL_UPPER:
635 case HDL_LOWER:
636 // constrain to auf Y -> X equal
637 aScNext.setX(aScFixPos.getX());
638 break;
639 default:
640 break;
643 // get scale vector in eye coordinates
644 basegfx::B3DPoint aScaleVec(aScStart - aScFixPos);
645 aScaleVec.setZ(1.0);
647 if(aScaleVec.getX() != 0.0)
649 aScaleVec.setX((aScNext.getX() - aScFixPos.getX()) / aScaleVec.getX());
651 else
653 aScaleVec.setX(1.0);
656 if(aScaleVec.getY() != 0.0)
658 aScaleVec.setY((aScNext.getY() - aScFixPos.getY()) / aScaleVec.getY());
660 else
662 aScaleVec.setY(1.0);
665 // SHIFT-key used?
666 if(getSdrDragView().IsOrtho())
668 if(fabs(aScaleVec.getX()) > fabs(aScaleVec.getY()))
670 // X is biggest
671 aScaleVec.setY(aScaleVec.getX());
673 else
675 // Y is biggest
676 aScaleVec.setX(aScaleVec.getY());
680 // build transformation
681 basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
682 aInverseOrientation.invert();
684 basegfx::B3DHomMatrix aNewTrans = rCandidate.maInitTransform;
685 aNewTrans *= rCandidate.maDisplayTransform;
686 aNewTrans *= aViewInfo3D.getOrientation();
687 aNewTrans.translate(-aScFixPos.getX(), -aScFixPos.getY(), -aScFixPos.getZ());
688 aNewTrans.scale(aScaleVec.getX(), aScaleVec.getY(), aScaleVec.getZ());
689 aNewTrans.translate(aScFixPos.getX(), aScFixPos.getY(), aScFixPos.getZ());
690 aNewTrans *= aInverseOrientation;
691 aNewTrans *= rCandidate.maInvDisplayTransform;
693 // ...and apply
694 rCandidate.maTransform = aNewTrans;
696 if(mbMoveFull)
698 E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
699 rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
701 else
703 Hide();
704 rCandidate.maWireframePoly.clear();
705 rCandidate.maWireframePoly = rCandidate.mp3DObj->CreateWireframe();
706 rCandidate.maWireframePoly.transform(rCandidate.maTransform);
707 Show();
711 maLastPos = rPnt;
712 DragStat().NextMove(rPnt);
716 Pointer E3dDragMove::GetSdrDragPointer() const
718 return Pointer(POINTER_MOVE);
721 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */