LibreOffice Module svx (master)  1
dragmt3d.cxx
Go to the documentation of this file.
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 
21 #include <dragmt3d.hxx>
22 #include <o3tl/numeric.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/e3dundo.hxx>
29 #include <svx/strings.hrc>
35 #include <svx/e3dsceneupdater.hxx>
36 #include <vcl/ptrstyle.hxx>
37 #include <comphelper/lok.hxx>
38 
39 
41  SdrDragView &_rView,
42  const SdrMarkList& rMark,
43  E3dDragConstraint eConstr,
44  bool bFull)
45 : SdrDragMethod(_rView),
46  meConstraint(eConstr),
47  mbMoveFull(bFull),
48  mbMovedAtAll(false)
49 {
50  // Create a unit for all the 3D objects present in the selection
51  const size_t nCnt(rMark.GetMarkCount());
52 
53  if(mbMoveFull)
54  {
55  // for non-visible 3D objects fallback to wireframe interaction
56  for(size_t nObjs = 0; nObjs < nCnt; ++nObjs)
57  {
58  E3dObject* pE3dObj = dynamic_cast< E3dObject* >(rMark.GetMark(nObjs)->GetMarkedSdrObj());
59 
60  if(pE3dObj)
61  {
62  if(!pE3dObj->HasFillStyle() && !pE3dObj->HasLineStyle())
63  {
64  mbMoveFull = false;
65  break;
66  }
67  }
68  }
69  }
70 
71  for(size_t nObjs = 0; nObjs < nCnt; ++nObjs)
72  {
73  E3dObject* pE3dObj = dynamic_cast< E3dObject* >(rMark.GetMark(nObjs)->GetMarkedSdrObj());
74 
75  if(pE3dObj)
76  {
77  // fill new interaction unit
78  E3dDragMethodUnit aNewUnit(*pE3dObj);
79 
80  // get transformations
81  aNewUnit.maInitTransform = aNewUnit.maTransform = pE3dObj->GetTransform();
82 
83  if(nullptr != pE3dObj->getParentE3dSceneFromE3dObject())
84  {
85  // get transform between object and world, normally scene transform
87  aNewUnit.maInvDisplayTransform.invert();
88  }
89 
90  if(!mbMoveFull)
91  {
92  // create wireframe visualisation for parent coordinate system
93  aNewUnit.maWireframePoly.clear();
94  aNewUnit.maWireframePoly = pE3dObj->CreateWireframe();
95  aNewUnit.maWireframePoly.transform(aNewUnit.maTransform);
96  }
97 
98  // Determine FullBound
99  maFullBound.Union(pE3dObj->GetSnapRect());
100 
101  // Insert Unit
102  maGrp.push_back(aNewUnit);
103  }
104  }
105 }
106 
108 {
109  return OUString();
110 }
111 
112 // Create the wireframe model for all actions
113 
115 {
117  {
118  const sal_uInt32 nCnt(maGrp.size());
120 
121  for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
122  {
123  E3dDragMethodUnit& rCandidate = maGrp[nOb];
124  rCandidate.mnStartAngle = GetAngle(DragStat().GetStart() - DragStat().GetRef1());
125  rCandidate.mnLastAngle = 0;
126  }
127  }
128  else
129  {
131  }
132 
133  if(!mbMoveFull)
134  {
135  Show();
136  }
137 
138  return true;
139 }
140 
141 bool E3dDragMethod::EndSdrDrag(bool /*bCopy*/)
142 {
143  const sal_uInt32 nCnt(maGrp.size());
144 
145  if(!mbMoveFull)
146  {
147  // Hide wireframe
148  Hide();
149  }
150 
151  // Apply all transformations and create undo's
152  if(mbMovedAtAll)
153  {
154  const bool bUndo = getSdrDragView().IsUndoEnabled();
155  if( bUndo )
156  getSdrDragView().BegUndo(SvxResId(RID_SVX_3D_UNDO_ROTATE));
157  sal_uInt32 nOb(0);
158 
159  for(nOb=0;nOb<nCnt;nOb++)
160  {
161  E3dDragMethodUnit& rCandidate = maGrp[nOb];
162  E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
163  rCandidate.mr3DObj.SetTransform(rCandidate.maTransform);
164  if( bUndo )
165  {
167  std::make_unique<E3dRotateUndoAction>(
168  rCandidate.mr3DObj,
169  rCandidate.maInitTransform,
170  rCandidate.maTransform));
171  }
172  }
173  if( bUndo )
175  }
176 
177  return true;
178 }
179 
181 {
182  if(mbMoveFull)
183  {
184  if(mbMovedAtAll)
185  {
186  const sal_uInt32 nCnt(maGrp.size());
187 
188  for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
189  {
190  // Restore transformation
191  E3dDragMethodUnit& rCandidate = maGrp[nOb];
192  E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
193  rCandidate.mr3DObj.SetTransform(rCandidate.maInitTransform);
194  }
195  }
196  }
197  else
198  {
199  // Hide WireFrame
200  Hide();
201  }
202 }
203 
204 // Common MoveSdrDrag()
205 
206 void E3dDragMethod::MoveSdrDrag(const Point& /*rPnt*/)
207 {
208  mbMovedAtAll = true;
209 }
210 
211 // Draw the wire frame model
212 
213 // for migration from XOR to overlay
215  sdr::overlay::OverlayManager& rOverlayManager,
216  const sdr::contact::ObjectContact& rObjectContact)
217 {
218  // We do client-side object manipulation with the Kit API
220  return;
221 
222  const sal_uInt32 nCnt(maGrp.size());
223  basegfx::B2DPolyPolygon aResult;
224 
225  for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
226  {
227  E3dDragMethodUnit& rCandidate = maGrp[nOb];
229 
230  if(pPV && pPV->HasMarkedObjPageView())
231  {
232  const basegfx::B3DPolyPolygon aCandidate(rCandidate.maWireframePoly);
233  const sal_uInt32 nPlyCnt(aCandidate.count());
234 
235  if(nPlyCnt)
236  {
237  const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject());
238 
239  if(nullptr != pScene)
240  {
241  const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
243  const basegfx::B3DHomMatrix aWorldToView(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection() * aViewInfo3D.getOrientation());
244  const basegfx::B3DHomMatrix aTransform(aWorldToView * rCandidate.maDisplayTransform);
245 
246  // transform to relative scene coordinates
248 
249  // transform to 2D view coordinates
250  aPolyPolygon.transform(rVCScene.getObjectTransformation());
251 
252  aResult.append(aPolyPolygon);
253  }
254  }
255  }
256  }
257 
258  if(aResult.count())
259  {
260  std::unique_ptr<sdr::overlay::OverlayPolyPolygonStripedAndFilled> pNew(
262  aResult));
263 
265  std::move(pNew),
266  rObjectContact,
267  rOverlayManager);
268  }
269 }
270 
271 
273  const SdrMarkList& rMark,
274  E3dDragConstraint eConstr,
275  bool bFull)
276 : E3dDragMethod(_rView, rMark, eConstr, bFull)
277 {
278  // Get center of all selected objects in eye coordinates
279  const sal_uInt32 nCnt(maGrp.size());
280 
281  if(nCnt)
282  {
283  const E3dScene* pScene(maGrp[0].mr3DObj.getRootE3dSceneFromE3dObject());
284 
285  if(nullptr != pScene)
286  {
287  const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
289 
290  for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
291  {
292  E3dDragMethodUnit& rCandidate = maGrp[nOb];
293  basegfx::B3DPoint aObjCenter = rCandidate.mr3DObj.GetBoundVolume().getCenter();
294  const basegfx::B3DHomMatrix aTransform(aViewInfo3D.getOrientation() * rCandidate.maDisplayTransform * rCandidate.maInitTransform);
295 
296  aObjCenter = aTransform * aObjCenter;
297  maGlobalCenter += aObjCenter;
298  }
299 
300  // Divide by the number
301  if(nCnt > 1)
302  {
303  maGlobalCenter /= static_cast<double>(nCnt);
304  }
305 
306  // get rotate center and transform to 3D eye coordinates
307  basegfx::B2DPoint aRotCenter2D(Ref1().X(), Ref1().Y());
308 
309  // from world to relative scene using inverse getObjectTransformation()
310  basegfx::B2DHomMatrix aInverseObjectTransform(rVCScene.getObjectTransformation());
311  aInverseObjectTransform.invert();
312  aRotCenter2D = aInverseObjectTransform * aRotCenter2D;
313 
314  // from 3D view to 3D eye
315  basegfx::B3DPoint aRotCenter3D(aRotCenter2D.getX(), aRotCenter2D.getY(), 0.0);
316  basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
317  aInverseViewToEye.invert();
318  aRotCenter3D = aInverseViewToEye * aRotCenter3D;
319 
320  // Use X,Y of the RotCenter and depth of the common object centre
321  // as rotation point in the space
322  maGlobalCenter.setX(aRotCenter3D.getX());
323  maGlobalCenter.setY(aRotCenter3D.getY());
324  }
325  }
326 }
327 
328 
329 //The object is moved, determine the angle
330 
332 {
333  // call parent
335 
336  if(DragStat().CheckMinMoved(rPnt))
337  {
338  // Get modifier
339  sal_uInt16 nModifier = 0;
340  if(dynamic_cast<const E3dView*>(&getSdrDragView()))
341  {
342  const MouseEvent& rLastMouse = static_cast<E3dView&>(getSdrDragView()).GetMouseEvent();
343  nModifier = rLastMouse.GetModifier();
344  }
345 
346  // Rotate all objects
347  const sal_uInt32 nCnt(maGrp.size());
348 
349  for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
350  {
351  // Determine rotation angle
352  double fWAngle, fHAngle;
353  E3dDragMethodUnit& rCandidate = maGrp[nOb];
354 
356  {
357  fWAngle = NormAngle36000(GetAngle(rPnt - DragStat().GetRef1()) -
358  rCandidate.mnStartAngle) - rCandidate.mnLastAngle;
359  rCandidate.mnLastAngle = static_cast<long>(fWAngle) + rCandidate.mnLastAngle;
360  fWAngle /= 100.0;
361  fHAngle = 0.0;
362  }
363  else
364  {
365  if ((maFullBound.GetWidth() == 0) || (maFullBound.GetHeight() == 0))
366  throw o3tl::divide_by_zero();
367  fWAngle = 90.0 * static_cast<double>(rPnt.X() - maLastPos.X())
368  / static_cast<double>(maFullBound.GetWidth());
369  fHAngle = 90.0 * static_cast<double>(rPnt.Y() - maLastPos.Y())
370  / static_cast<double>(maFullBound.GetHeight());
371  }
372  long nSnap = 0;
373 
375  nSnap = 90;
376 
377  if(nSnap != 0)
378  {
379  fWAngle = static_cast<double>((static_cast<long>(fWAngle) + nSnap/2) / nSnap * nSnap);
380  fHAngle = static_cast<double>((static_cast<long>(fHAngle) + nSnap/2) / nSnap * nSnap);
381  }
382 
383  // to radians
384  fWAngle = basegfx::deg2rad(fWAngle);
385  fHAngle = basegfx::deg2rad(fHAngle);
386 
387  // Determine transformation
388  basegfx::B3DHomMatrix aRotMat;
390  {
391  if(nModifier & KEY_MOD2)
392  aRotMat.rotate(0.0, 0.0, fWAngle);
393  else
394  aRotMat.rotate(0.0, fWAngle, 0.0);
395  }
396  else if(E3dDragConstraint::Z & meConstraint)
397  {
398  if(nModifier & KEY_MOD2)
399  aRotMat.rotate(0.0, fWAngle, 0.0);
400  else
401  aRotMat.rotate(0.0, 0.0, fWAngle);
402  }
403  if(E3dDragConstraint::X & meConstraint)
404  {
405  aRotMat.rotate(fHAngle, 0.0, 0.0);
406  }
407 
408  const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject());
409 
410  if(nullptr != pScene)
411  {
412  // Transformation in eye coordinates, there rotate then and back
413  const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
415  basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
416  aInverseOrientation.invert();
417 
418  basegfx::B3DHomMatrix aTransMat(rCandidate.maDisplayTransform);
419  aTransMat *= aViewInfo3D.getOrientation();
421  aTransMat *= aRotMat;
423  aTransMat *= aInverseOrientation;
424  aTransMat *= rCandidate.maInvDisplayTransform;
425 
426  // ...and apply
427  rCandidate.maTransform *= aTransMat;
428 
429  if(mbMoveFull)
430  {
431  E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
432  rCandidate.mr3DObj.SetTransform(rCandidate.maTransform);
433  }
434  else
435  {
436  Hide();
437  rCandidate.maWireframePoly.transform(aTransMat);
438  Show();
439  }
440  }
441  }
442  maLastPos = rPnt;
443  DragStat().NextMove(rPnt);
444  }
445 }
446 
448 {
449  return PointerStyle::Rotate;
450 }
451 
452 // E3dDragMove. This drag method is only required for translations inside
453 // 3D scenes. If a 3D-scene itself moved, then this drag method will drag
454 // not be used.
455 
456 
458  const SdrMarkList& rMark,
459  SdrHdlKind eDrgHdl,
460  E3dDragConstraint eConstr,
461  bool bFull)
462 : E3dDragMethod(_rView, rMark, eConstr, bFull),
463  meWhatDragHdl(eDrgHdl)
464 {
465  switch(meWhatDragHdl)
466  {
467  case SdrHdlKind::Left:
469  break;
470  case SdrHdlKind::Right:
472  break;
473  case SdrHdlKind::Upper:
475  break;
476  case SdrHdlKind::Lower:
478  break;
481  break;
484  break;
487  break;
490  break;
491  default:
492  // Moving the object, SdrHdlKind::Move
493  break;
494  }
495 
496  // Override when IsResizeAtCenter()
497  if(getSdrDragView().IsResizeAtCenter())
498  {
501  }
502 }
503 
504 // The object is moved, determine the translations
505 
507 {
508  // call parent
510 
511  if(DragStat().CheckMinMoved(rPnt))
512  {
514  {
515  // Translation
516  // Determine the motion vector
517  const sal_uInt32 nCnt(maGrp.size());
518 
519  // Get modifier
520  sal_uInt16 nModifier(0);
521 
522  if(dynamic_cast<const E3dView*>(&getSdrDragView()))
523  {
524  const MouseEvent& rLastMouse = static_cast<E3dView&>(getSdrDragView()).GetMouseEvent();
525  nModifier = rLastMouse.GetModifier();
526  }
527 
528  for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
529  {
530  E3dDragMethodUnit& rCandidate = maGrp[nOb];
531  const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject());
532 
533  if(nullptr != pScene)
534  {
535  const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
537 
538  // move coor from 2d world to 3d Eye
539  basegfx::B2DPoint aGlobalMoveHead2D(static_cast<double>(rPnt.X() - maLastPos.X()), static_cast<double>(rPnt.Y() - maLastPos.Y()));
540  basegfx::B2DPoint aGlobalMoveTail2D(0.0, 0.0);
541  basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
542 
543  aInverseSceneTransform.invert();
544  aGlobalMoveHead2D = aInverseSceneTransform * aGlobalMoveHead2D;
545  aGlobalMoveTail2D = aInverseSceneTransform * aGlobalMoveTail2D;
546 
547  basegfx::B3DPoint aMoveHead3D(aGlobalMoveHead2D.getX(), aGlobalMoveHead2D.getY(), 0.5);
548  basegfx::B3DPoint aMoveTail3D(aGlobalMoveTail2D.getX(), aGlobalMoveTail2D.getY(), 0.5);
549  basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
550  aInverseViewToEye.invert();
551 
552  aMoveHead3D = aInverseViewToEye * aMoveHead3D;
553  aMoveTail3D = aInverseViewToEye * aMoveTail3D;
554 
555  // eventually switch movement from XY to XZ plane
556  if(nModifier & KEY_MOD2)
557  {
558  double fZwi = aMoveHead3D.getY();
559  aMoveHead3D.setY(aMoveHead3D.getZ());
560  aMoveHead3D.setZ(fZwi);
561 
562  fZwi = aMoveTail3D.getY();
563  aMoveTail3D.setY(aMoveTail3D.getZ());
564  aMoveTail3D.setZ(fZwi);
565  }
566 
567  // Motion vector from eye coordinates to parent coordinates
568  basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
569  aInverseOrientation.invert();
570  basegfx::B3DHomMatrix aCompleteTrans(rCandidate.maInvDisplayTransform * aInverseOrientation);
571 
572  aMoveHead3D = aCompleteTrans * aMoveHead3D;
573  aMoveTail3D = aCompleteTrans* aMoveTail3D;
574 
575  // build transformation
576  basegfx::B3DHomMatrix aTransMat;
577  basegfx::B3DPoint aTranslate(aMoveHead3D - aMoveTail3D);
578  aTransMat.translate(aTranslate.getX(), aTranslate.getY(), aTranslate.getZ());
579 
580  // ...and apply
581  rCandidate.maTransform *= aTransMat;
582 
583  if(mbMoveFull)
584  {
585  E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
586  rCandidate.mr3DObj.SetTransform(rCandidate.maTransform);
587  }
588  else
589  {
590  Hide();
591  rCandidate.maWireframePoly.transform(aTransMat);
592  Show();
593  }
594  }
595  }
596  }
597  else
598  {
599  // Scaling
600  // Determine scaling vector
601  Point aStartPos = DragStat().GetStart();
602  const sal_uInt32 nCnt(maGrp.size());
603 
604  for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
605  {
606  E3dDragMethodUnit& rCandidate = maGrp[nOb];
607  const basegfx::B3DPoint aObjectCenter(rCandidate.mr3DObj.GetBoundVolume().getCenter());
608  const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject());
609 
610  if(nullptr != pScene)
611  {
612  // transform from 2D world view to 3D eye
613  const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
615 
616  basegfx::B2DPoint aGlobalScaleStart2D(static_cast<double>(aStartPos.X()), static_cast<double>(aStartPos.Y()));
617  basegfx::B2DPoint aGlobalScaleNext2D(static_cast<double>(rPnt.X()), static_cast<double>(rPnt.Y()));
618  basegfx::B2DPoint aGlobalScaleFixPos2D(static_cast<double>(maScaleFixPos.X()), static_cast<double>(maScaleFixPos.Y()));
619  basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
620 
621  aInverseSceneTransform.invert();
622  aGlobalScaleStart2D = aInverseSceneTransform * aGlobalScaleStart2D;
623  aGlobalScaleNext2D = aInverseSceneTransform * aGlobalScaleNext2D;
624  aGlobalScaleFixPos2D = aInverseSceneTransform * aGlobalScaleFixPos2D;
625 
626  basegfx::B3DPoint aGlobalScaleStart3D(aGlobalScaleStart2D.getX(), aGlobalScaleStart2D.getY(), aObjectCenter.getZ());
627  basegfx::B3DPoint aGlobalScaleNext3D(aGlobalScaleNext2D.getX(), aGlobalScaleNext2D.getY(), aObjectCenter.getZ());
628  basegfx::B3DPoint aGlobalScaleFixPos3D(aGlobalScaleFixPos2D.getX(), aGlobalScaleFixPos2D.getY(), aObjectCenter.getZ());
629  basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
630 
631  aInverseViewToEye.invert();
632  basegfx::B3DPoint aScStart(aInverseViewToEye * aGlobalScaleStart3D);
633  basegfx::B3DPoint aScNext(aInverseViewToEye * aGlobalScaleNext3D);
634  basegfx::B3DPoint aScFixPos(aInverseViewToEye * aGlobalScaleFixPos3D);
635 
636  // constraints?
637  switch(meWhatDragHdl)
638  {
639  case SdrHdlKind::Left:
640  case SdrHdlKind::Right:
641  // to constrain on X -> Y equal
642  aScNext.setY(aScFixPos.getY());
643  break;
644  case SdrHdlKind::Upper:
645  case SdrHdlKind::Lower:
646  // constrain to Y -> X equal
647  aScNext.setX(aScFixPos.getX());
648  break;
649  default:
650  break;
651  }
652 
653  // get scale vector in eye coordinates
654  basegfx::B3DPoint aScaleVec(aScStart - aScFixPos);
655  aScaleVec.setZ(1.0);
656 
657  if(aScaleVec.getX() != 0.0)
658  {
659  aScaleVec.setX((aScNext.getX() - aScFixPos.getX()) / aScaleVec.getX());
660  }
661  else
662  {
663  aScaleVec.setX(1.0);
664  }
665 
666  if(aScaleVec.getY() != 0.0)
667  {
668  aScaleVec.setY((aScNext.getY() - aScFixPos.getY()) / aScaleVec.getY());
669  }
670  else
671  {
672  aScaleVec.setY(1.0);
673  }
674 
675  // SHIFT-key used?
676  if(getSdrDragView().IsOrtho())
677  {
678  if(fabs(aScaleVec.getX()) > fabs(aScaleVec.getY()))
679  {
680  // X is biggest
681  aScaleVec.setY(aScaleVec.getX());
682  }
683  else
684  {
685  // Y is biggest
686  aScaleVec.setX(aScaleVec.getY());
687  }
688  }
689 
690  // build transformation
691  basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
692  aInverseOrientation.invert();
693 
694  basegfx::B3DHomMatrix aNewTrans = rCandidate.maInitTransform;
695  aNewTrans *= rCandidate.maDisplayTransform;
696  aNewTrans *= aViewInfo3D.getOrientation();
697  aNewTrans.translate(-aScFixPos.getX(), -aScFixPos.getY(), -aScFixPos.getZ());
698  aNewTrans.scale(aScaleVec.getX(), aScaleVec.getY(), aScaleVec.getZ());
699  aNewTrans.translate(aScFixPos.getX(), aScFixPos.getY(), aScFixPos.getZ());
700  aNewTrans *= aInverseOrientation;
701  aNewTrans *= rCandidate.maInvDisplayTransform;
702 
703  // ...and apply
704  rCandidate.maTransform = aNewTrans;
705 
706  if(mbMoveFull)
707  {
708  E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
709  rCandidate.mr3DObj.SetTransform(rCandidate.maTransform);
710  }
711  else
712  {
713  Hide();
714  rCandidate.maWireframePoly.clear();
715  rCandidate.maWireframePoly = rCandidate.mr3DObj.CreateWireframe();
716  rCandidate.maWireframePoly.transform(rCandidate.maTransform);
717  Show();
718  }
719  }
720  }
721  }
722  maLastPos = rPnt;
723  DragStat().NextMove(rPnt);
724  }
725 }
726 
728 {
729  return PointerStyle::Move;
730 }
731 
732 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Point TopLeft() const
::std::vector< E3dDragMethodUnit > maGrp
Definition: dragmt3d.hxx:59
void setY(double fY)
void setX(double fX)
long GetWidth() const
sal_Int32 mnStartAngle
Definition: dragmt3d.hxx:39
size_t GetMarkCount() const
Definition: svdmark.hxx:179
long GetHeight() const
void transform(const basegfx::B3DHomMatrix &rMatrix)
SdrHdlKind meWhatDragHdl
Definition: dragmt3d.hxx:104
basegfx::B3DPoint maGlobalCenter
Definition: dragmt3d.hxx:88
const Point & GetStart() const
Definition: svddrag.hxx:92
Point BottomLeft() const
SdrHdlKind
Definition: svdhdl.hxx:52
bool IsUndoEnabled() const
Definition: svdedtv.cxx:1031
bool HasFillStyle() const
Definition: svdobj.cxx:2973
basegfx::B3DHomMatrix maDisplayTransform
Definition: dragmt3d.hxx:35
E3dDragRotate(SdrDragView &rView, const SdrMarkList &rMark, E3dDragConstraint eConstr, bool bFull)
Definition: dragmt3d.cxx:272
Point maLastPos
Definition: dragmt3d.hxx:61
void BegUndo()
Definition: svdedtv.hxx:179
double getZ() const
const drawinglayer::geometry::ViewInformation3D & getViewInformation3D(const ::basegfx::B3DRange &rContentRange) const
SdrMark * GetMark(size_t nNum) const
Definition: svdmark.cxx:234
B2DPolyPolygon createB2DPolyPolygonFromB3DPolyPolygon(const B3DPolyPolygon &rCandidate, const B3DHomMatrix &rMat)
const basegfx::B3DHomMatrix & GetTransform() const
Definition: obj3d.hxx:111
virtual const tools::Rectangle & GetSnapRect() const override
Definition: svdoattr.cxx:91
void scale(double fX, double fY, double fZ)
long NormAngle36000(long a)
Normalize angle to -180.00..179.99.
Definition: svdtrans.cxx:407
SdrDragStat & DragStat()
Definition: svddrgmt.hxx:163
Point RightCenter() const
double getX() const
sal_Int32 mnLastAngle
Definition: dragmt3d.hxx:40
B3DPoint getCenter() const
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
#define X
Point BottomCenter() const
sal_uInt32 count() const
E3dDragMethod(SdrDragView &rView, const SdrMarkList &rMark, E3dDragConstraint eConstr, bool bFull)
Definition: dragmt3d.cxx:40
bool IsRotateAllowed(bool b90Deg=false) const
Definition: svdedtv.cxx:374
Point LeftCenter() const
Point & Ref1() const
Definition: svddrgmt.hxx:165
void EndUndo()
Definition: svdedtv.cxx:278
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:67
Point BottomRight() const
SdrDragView & getSdrDragView()
Definition: svddrgmt.hxx:146
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdedtv.hxx:183
E3dScene * getParentE3dSceneFromE3dObject() const
Definition: obj3d.cxx:247
virtual PointerStyle GetSdrDragPointer() const override
Definition: dragmt3d.cxx:447
void SetRef1(const Point &pt)
Definition: svddrag.hxx:98
bool HasMarkedObjPageView() const
Definition: svdpagv.hxx:182
E3dDragMove(SdrDragView &rView, const SdrMarkList &rMark, SdrHdlKind eDrgHdl, E3dDragConstraint eConstr, bool bFull)
Definition: dragmt3d.cxx:457
basegfx::B3DHomMatrix maInitTransform
Definition: dragmt3d.hxx:37
basegfx::B3DPolyPolygon maWireframePoly
Definition: dragmt3d.hxx:34
E3dDragConstraint const meConstraint
Definition: dragmt3d.hxx:60
virtual bool EndSdrDrag(bool bCopy) override
Definition: dragmt3d.cxx:141
void transform(const basegfx::B2DHomMatrix &rMatrix)
virtual bool BeginSdrDrag() override
Definition: dragmt3d.cxx:114
void NextMove(const Point &rPnt)
Definition: svddrag.cxx:66
constexpr double deg2rad(double v)
const basegfx::B3DRange & GetBoundVolume() const
Definition: obj3d.cxx:289
const basegfx::B3DHomMatrix & GetFullTransform() const
Definition: obj3d.cxx:313
sal_uInt16 GetModifier() const
constexpr sal_uInt16 KEY_MOD2
basegfx::B3DHomMatrix maInvDisplayTransform
Definition: dragmt3d.hxx:36
long X() const
#define Y
bool HasLineStyle() const
Definition: svdobj.cxx:2978
void translate(double fX, double fY, double fZ)
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: dragmt3d.cxx:506
bool mbMovedAtAll
Definition: dragmt3d.hxx:64
virtual void SetTransform(const basegfx::B3DHomMatrix &rMatrix)
Definition: obj3d.cxx:343
Derived class of SdrView to edit 3D objects.
Definition: view3d.hxx:41
const basegfx::B2DHomMatrix & getObjectTransformation() const
tools::Rectangle & Union(const tools::Rectangle &rRect)
virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager &rOverlayManager, const sdr::contact::ObjectContact &rObjectContact) override
Definition: dragmt3d.cxx:214
E3dDragConstraint
Definition: def3d.hxx:32
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: dragmt3d.cxx:331
virtual PointerStyle GetSdrDragPointer() const override
Definition: dragmt3d.cxx:727
long GetAngle(const Point &rPnt)
The Y axis points down! The function negates the Y axis, when calculating the angle, such that GetAngle(Point(0,-1))=90 deg.
Definition: svdtrans.cxx:385
PointerStyle
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:310
Helper for 3d object changes affecting 2d geometry.
void rotate(double fAngleX, double fAngleY, double fAngleZ)
double getY() const
E3dObject & mr3DObj
Definition: dragmt3d.hxx:33
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: dragmt3d.cxx:206
basegfx::B3DHomMatrix maTransform
Definition: dragmt3d.hxx:38
virtual E3dScene * getRootE3dSceneFromE3dObject() const
Definition: obj3d.cxx:253
virtual void CancelSdrDrag() override
Definition: dragmt3d.cxx:180
Point maScaleFixPos
Definition: dragmt3d.hxx:105
basegfx::B3DPolyPolygon CreateWireframe() const
Definition: obj3d.cxx:354
Point TopRight() const
void setZ(double fZ)
virtual OUString GetSdrDragComment() const override
Definition: dragmt3d.cxx:107
bool mbMoveFull
Definition: dragmt3d.hxx:63
void insertNewlyCreatedOverlayObjectForSdrDragMethod(std::unique_ptr< sdr::overlay::OverlayObject > pOverlayObject, const sdr::contact::ObjectContact &rObjectContact, sdr::overlay::OverlayManager &rOverlayManager)
Definition: svddrgmt.cxx:337
Point Center() const
long Y() const
Point TopCenter() const
tools::Rectangle maFullBound
Definition: dragmt3d.hxx:62