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

Generated by: LCOV version 1.11