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