LibreOffice Module svx (master)  1
viewcontactofe3dcube.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 
22 #include <svx/cube3d.hxx>
27 #include <memory>
28 
29 
30 namespace sdr::contact
31 {
33  : ViewContactOfE3d(rCubeObj)
34  {
35  }
36 
38  {
39  }
40 
42  {
44  const SfxItemSet& rItemSet = GetE3dCubeObj().GetMergedItemSet();
47 
48  // get cube geometry and use as translation and scaling for unit cube
49  basegfx::B3DRange aCubeRange;
50  const basegfx::B3DVector aCubeSize(GetE3dCubeObj().GetCubeSize());
51  const basegfx::B3DPoint aCubePosition(GetE3dCubeObj().GetCubePos());
52  basegfx::B3DHomMatrix aWorldTransform;
53 
54  if(GetE3dCubeObj().GetPosIsCenter())
55  {
56  const basegfx::B3DVector aHalfCubeSize(aCubeSize / 2.0);
57  aCubeRange.expand(aCubePosition - aHalfCubeSize);
58  aCubeRange.expand(aCubePosition + aHalfCubeSize);
59  }
60  else
61  {
62  aCubeRange.expand(aCubePosition);
63  aCubeRange.expand(aCubePosition + aCubeSize);
64  }
65 
66  // add scale and translate to world transformation
67  const basegfx::B3DVector abjectRange(aCubeRange.getRange());
68  aWorldTransform.scale(abjectRange.getX(), abjectRange.getY(), abjectRange.getZ());
69  aWorldTransform.translate(aCubeRange.getMinX(), aCubeRange.getMinY(), aCubeRange.getMinZ());
70 
71  // get 3D Object Attributes
72  std::unique_ptr<drawinglayer::attribute::Sdr3DObjectAttribute> pSdr3DObjectAttribute(drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet));
73 
74  // calculate texture size to get a perfect mapping for
75  // the front/back sides
76  const basegfx::B2DVector aTextureSize(aCubeSize.getX(), aCubeSize.getY());
77 
78  // create primitive and add
81  aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute));
82  xRetval = { xReference };
83 
84  return xRetval;
85  }
86 
87 } // end of namespace
88 
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual drawinglayer::primitive3d::Primitive3DContainer createViewIndependentPrimitive3DContainer() const override
double getMinZ() const
const E3dCubeObj & GetE3dCubeObj() const
void scale(double fX, double fY, double fZ)
attribute::Sdr3DObjectAttribute * createNewSdr3DObjectAttribute(const SfxItemSet &rSet)
attribute::SdrLineFillShadowAttribute3D createNewSdrLineFillShadowAttribute(const SfxItemSet &rSet, bool bSuppressFill)
double getMinX() const
void expand(const B3DTuple &rTuple)
double getMinY() const
css::uno::Reference< css::graphic::XPrimitive3D > Primitive3DReference
void translate(double fX, double fY, double fZ)
B3DVector getRange() const
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1890