LibreOffice Module svx (master)  1
viewcontactofe3dlathe.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/lathe3d.hxx>
27 
28 
29 namespace sdr::contact
30 {
32  : ViewContactOfE3d(rLathe)
33  {
34  }
35 
37  {
38  }
39 
41  {
43  const SfxItemSet& rItemSet = GetE3dLatheObj().GetMergedItemSet();
46 
47  // get extrude geometry
48  const basegfx::B2DPolyPolygon aPolyPolygon(GetE3dLatheObj().GetPolyPoly2D());
49 
50  // get 3D Object Attributes
52 
53  // calculate texture size. Use the polygon length of the longest polygon for
54  // height and the rotated radius for width (using polygon center) to get a good
55  // texture mapping
56  double fPolygonMaxLength(0.0);
57 
58  for(auto const& rCandidate : aPolyPolygon)
59  {
60  const double fPolygonLength(basegfx::utils::getLength(rCandidate));
61  fPolygonMaxLength = std::max(fPolygonMaxLength, fPolygonLength);
62  }
63 
64  const basegfx::B2DRange aPolyPolygonRange(basegfx::utils::getRange(aPolyPolygon));
65  const basegfx::B2DVector aTextureSize(
66  M_PI * fabs(aPolyPolygonRange.getCenter().getX()), // PI * d
67  fPolygonMaxLength);
68 
69  // get more data
70  const sal_uInt32 nHorizontalSegments(GetE3dLatheObj().GetHorizontalSegments());
71  const sal_uInt32 nVerticalSegments(GetE3dLatheObj().GetVerticalSegments());
72  const double fDiagonal(static_cast<double>(GetE3dLatheObj().GetPercentDiagonal()) / 100.0);
73  const double fBackScale(static_cast<double>(GetE3dLatheObj().GetBackScale()) / 100.0);
74  const double fRotation(basegfx::deg2rad<10>(GetE3dLatheObj().GetEndAngle()));
75  const bool bSmoothNormals(GetE3dLatheObj().GetSmoothNormals()); // Plane itself
76  const bool bSmoothLids(GetE3dLatheObj().GetSmoothLids()); // Front/back
77  const bool bCharacterMode(GetE3dLatheObj().GetCharacterMode());
78  const bool bCloseFront(GetE3dLatheObj().GetCloseFront());
79  const bool bCloseBack(GetE3dLatheObj().GetCloseBack());
80 
81  // create primitive and add
82  const basegfx::B3DHomMatrix aWorldTransform;
85  aWorldTransform, aTextureSize, aAttribute, aSdr3DObjectAttribute,
86  aPolyPolygon, nHorizontalSegments, nVerticalSegments,
87  fDiagonal, fBackScale, fRotation,
88  bSmoothNormals, bSmoothLids, bCharacterMode, bCloseFront, bCloseBack));
89  xRetval = { xReference };
90 
91  return xRetval;
92  }
93 
94 } // end of namespace
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
B2DPoint getCenter() const
attribute::SdrLineFillShadowAttribute3D createNewSdrLineFillShadowAttribute(const SfxItemSet &rSet, bool bSuppressFill)
css::uno::Reference< css::graphic::XPrimitive3D > Primitive3DReference
B2DRange getRange(const B2DPolygon &rCandidate)
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1972
double getLength(const B2DPolygon &rCandidate)
const E3dLatheObj & GetE3dLatheObj() const
double getX() const
attribute::Sdr3DObjectAttribute createNewSdr3DObjectAttribute(const SfxItemSet &rSet)
virtual drawinglayer::primitive3d::Primitive3DContainer createViewIndependentPrimitive3DContainer() const override