LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofe3dlathe.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 36 36 100.0 %
Date: 2014-11-03 Functions: 6 6 100.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 <sdr/contact/viewcontactofe3dlathe.hxx>
      22             : #include <svx/lathe3d.hxx>
      23             : #include <drawinglayer/primitive3d/sdrlatheprimitive3d.hxx>
      24             : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
      25             : #include <sdr/primitive3d/sdrattributecreator3d.hxx>
      26             : #include <basegfx/polygon/b2dpolygontools.hxx>
      27             : #include <boost/scoped_ptr.hpp>
      28             : 
      29             : 
      30             : namespace sdr
      31             : {
      32             :     namespace contact
      33             :     {
      34          96 :         ViewContactOfE3dLathe::ViewContactOfE3dLathe(E3dLatheObj& rLathe)
      35          96 :         :   ViewContactOfE3d(rLathe)
      36             :         {
      37          96 :         }
      38             : 
      39         192 :         ViewContactOfE3dLathe::~ViewContactOfE3dLathe()
      40             :         {
      41         192 :         }
      42             : 
      43         392 :         drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dLathe::createViewIndependentPrimitive3DSequence() const
      44             :         {
      45         392 :             drawinglayer::primitive3d::Primitive3DSequence xRetval;
      46         392 :             const SfxItemSet& rItemSet = GetE3dLatheObj().GetMergedItemSet();
      47             :             const drawinglayer::attribute::SdrLineFillShadowAttribute3D aAttribute(
      48         784 :                 drawinglayer::primitive2d::createNewSdrLineFillShadowAttribute(rItemSet, false));
      49             : 
      50             :             // get extrude geometry
      51         784 :             const basegfx::B2DPolyPolygon aPolyPolygon(GetE3dLatheObj().GetPolyPoly2D());
      52             : 
      53             :             // get 3D Object Attributes
      54         784 :             boost::scoped_ptr<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         392 :             const sal_uInt32 nPolygonCount(aPolyPolygon.count());
      60         392 :             double fPolygonMaxLength(0.0);
      61             : 
      62        1294 :             for(sal_uInt32 a(0); a < nPolygonCount; a++)
      63             :             {
      64         902 :                 const basegfx::B2DPolygon aCandidate(aPolyPolygon.getB2DPolygon(a));
      65         902 :                 const double fPolygonLength(basegfx::tools::getLength(aCandidate));
      66         902 :                 fPolygonMaxLength = std::max(fPolygonMaxLength, fPolygonLength);
      67         902 :             }
      68             : 
      69         392 :             const basegfx::B2DRange aPolyPolygonRange(basegfx::tools::getRange(aPolyPolygon));
      70             :             const basegfx::B2DVector aTextureSize(
      71         784 :                 F_PI * fabs(aPolyPolygonRange.getCenter().getX()), // PI * d
      72        1176 :                 fPolygonMaxLength);
      73             : 
      74             :             // get more data
      75         392 :             const sal_uInt32 nHorizontalSegments(GetE3dLatheObj().GetHorizontalSegments());
      76         392 :             const sal_uInt32 nVerticalSegments(GetE3dLatheObj().GetVerticalSegments());
      77         392 :             const double fDiagonal((double)GetE3dLatheObj().GetPercentDiagonal() / 100.0);
      78         392 :             const double fBackScale((double)GetE3dLatheObj().GetBackScale() / 100.0);
      79         392 :             const double fRotation(((double)GetE3dLatheObj().GetEndAngle() / 1800.0) * F_PI);
      80         392 :             const bool bSmoothNormals(GetE3dLatheObj().GetSmoothNormals()); // Plane itself
      81         392 :             const bool bSmoothLids(GetE3dLatheObj().GetSmoothLids()); // Front/back
      82         392 :             const bool bCharacterMode(GetE3dLatheObj().GetCharacterMode());
      83         392 :             const bool bCloseFront(GetE3dLatheObj().GetCloseFront());
      84         392 :             const bool bCloseBack(GetE3dLatheObj().GetCloseBack());
      85             : 
      86             :             // create primitive and add
      87         784 :             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         784 :                     bSmoothNormals, true, bSmoothLids, bCharacterMode, bCloseFront, bCloseBack));
      94         392 :             xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
      95             : 
      96         784 :             return xRetval;
      97             :         }
      98             :     } // end of namespace contact
      99         651 : } // end of namespace sdr
     100             : 
     101             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10