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