LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofe3dlathe.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 36 0.0 %
Date: 2014-04-14 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <svx/sdr/contact/viewcontactofe3dlathe.hxx>
      22             : #include <svx/lathe3d.hxx>
      23             : #include <drawinglayer/primitive3d/sdrlatheprimitive3d.hxx>
      24             : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
      25             : #include <svx/sdr/primitive3d/sdrattributecreator3d.hxx>
      26             : #include <basegfx/polygon/b2dpolygontools.hxx>
      27             : 
      28             : 
      29             : 
      30             : namespace sdr
      31             : {
      32             :     namespace contact
      33             :     {
      34           0 :         ViewContactOfE3dLathe::ViewContactOfE3dLathe(E3dLatheObj& rLathe)
      35           0 :         :   ViewContactOfE3d(rLathe)
      36             :         {
      37           0 :         }
      38             : 
      39           0 :         ViewContactOfE3dLathe::~ViewContactOfE3dLathe()
      40             :         {
      41           0 :         }
      42             : 
      43           0 :         drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dLathe::createViewIndependentPrimitive3DSequence() const
      44             :         {
      45           0 :             drawinglayer::primitive3d::Primitive3DSequence xRetval;
      46           0 :             const SfxItemSet& rItemSet = GetE3dLatheObj().GetMergedItemSet();
      47             :             const drawinglayer::attribute::SdrLineFillShadowAttribute3D aAttribute(
      48           0 :                 drawinglayer::primitive2d::createNewSdrLineFillShadowAttribute(rItemSet, false));
      49             : 
      50             :             // get extrude geometry
      51           0 :             const basegfx::B2DPolyPolygon aPolyPolygon(GetE3dLatheObj().GetPolyPoly2D());
      52             : 
      53             :             // get 3D Object Attributes
      54           0 :             drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet);
      55             : 
      56             :             // calculate texture size. Use the polygon length of the longest polygon for
      57             :             // height and the rotated radius for width (using polygon center) to get a good
      58             :             // texture mapping
      59           0 :             const sal_uInt32 nPolygonCount(aPolyPolygon.count());
      60           0 :             double fPolygonMaxLength(0.0);
      61             : 
      62           0 :             for(sal_uInt32 a(0); a < nPolygonCount; a++)
      63             :             {
      64           0 :                 const basegfx::B2DPolygon aCandidate(aPolyPolygon.getB2DPolygon(a));
      65           0 :                 const double fPolygonLength(basegfx::tools::getLength(aCandidate));
      66           0 :                 fPolygonMaxLength = std::max(fPolygonMaxLength, fPolygonLength);
      67           0 :             }
      68             : 
      69           0 :             const basegfx::B2DRange aPolyPolygonRange(basegfx::tools::getRange(aPolyPolygon));
      70             :             const basegfx::B2DVector aTextureSize(
      71           0 :                 F_PI * fabs(aPolyPolygonRange.getCenter().getX()), // PI * d
      72           0 :                 fPolygonMaxLength);
      73             : 
      74             :             // get more data
      75           0 :             const sal_uInt32 nHorizontalSegments(GetE3dLatheObj().GetHorizontalSegments());
      76           0 :             const sal_uInt32 nVerticalSegments(GetE3dLatheObj().GetVerticalSegments());
      77           0 :             const double fDiagonal((double)GetE3dLatheObj().GetPercentDiagonal() / 100.0);
      78           0 :             const double fBackScale((double)GetE3dLatheObj().GetBackScale() / 100.0);
      79           0 :             const double fRotation(((double)GetE3dLatheObj().GetEndAngle() / 1800.0) * F_PI);
      80           0 :             const bool bSmoothNormals(GetE3dLatheObj().GetSmoothNormals()); // Plane itself
      81           0 :             const bool bSmoothLids(GetE3dLatheObj().GetSmoothLids()); // Front/back
      82           0 :             const bool bCharacterMode(GetE3dLatheObj().GetCharacterMode());
      83           0 :             const bool bCloseFront(GetE3dLatheObj().GetCloseFront());
      84           0 :             const bool bCloseBack(GetE3dLatheObj().GetCloseBack());
      85             : 
      86             :             // create primitive and add
      87           0 :             const basegfx::B3DHomMatrix aWorldTransform;
      88             :             const drawinglayer::primitive3d::Primitive3DReference xReference(
      89             :                 new drawinglayer::primitive3d::SdrLathePrimitive3D(
      90             :                     aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute,
      91             :                     aPolyPolygon, nHorizontalSegments, nVerticalSegments,
      92             :                     fDiagonal, fBackScale, fRotation,
      93           0 :                     bSmoothNormals, true, bSmoothLids, bCharacterMode, bCloseFront, bCloseBack));
      94           0 :             xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
      95             : 
      96             :             // delete 3D Object Attributes
      97           0 :             delete pSdr3DObjectAttribute;
      98             : 
      99           0 :             return xRetval;
     100             :         }
     101             :     } // end of namespace contact
     102             : } // end of namespace sdr
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10