LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive3d - sdrattributecreator3d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 37 44 84.1 %
Date: 2015-06-13 12:38:46 Functions: 1 1 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             : #include <sdr/primitive3d/sdrattributecreator3d.hxx>
      21             : #include <svx/svx3ditems.hxx>
      22             : #include <svl/itemset.hxx>
      23             : #include <com/sun/star/drawing/NormalsKind.hpp>
      24             : #include <com/sun/star/drawing/TextureProjectionMode.hpp>
      25             : #include <com/sun/star/drawing/TextureKind2.hpp>
      26             : #include <com/sun/star/drawing/TextureMode.hpp>
      27             : #include <svx/xflclit.hxx>
      28             : #include <drawinglayer/attribute/materialattribute3d.hxx>
      29             : #include <drawinglayer/attribute/sdrobjectattribute3d.hxx>
      30             : 
      31             : 
      32             : 
      33             : namespace drawinglayer
      34             : {
      35             :     namespace primitive2d
      36             :     {
      37        9601 :         attribute::Sdr3DObjectAttribute* createNewSdr3DObjectAttribute(const SfxItemSet& rSet)
      38             :         {
      39             :             // get NormalsKind
      40        9601 :             ::com::sun::star::drawing::NormalsKind aNormalsKind(::com::sun::star::drawing::NormalsKind_SPECIFIC);
      41        9601 :             const sal_uInt16 nNormalsValue(static_cast<const Svx3DNormalsKindItem&>(rSet.Get(SDRATTR_3DOBJ_NORMALS_KIND)).GetValue());
      42             : 
      43        9601 :             if(1L == nNormalsValue)
      44             :             {
      45        3679 :                 aNormalsKind = ::com::sun::star::drawing::NormalsKind_FLAT;
      46             :             }
      47        5922 :             else if(2L == nNormalsValue)
      48             :             {
      49           0 :                 aNormalsKind = ::com::sun::star::drawing::NormalsKind_SPHERE;
      50             :             }
      51             : 
      52             :             // get NoermalsInvert flag
      53        9601 :             const bool bInvertNormals(static_cast<const SfxBoolItem&>(rSet.Get(SDRATTR_3DOBJ_NORMALS_INVERT)).GetValue());
      54             : 
      55             :             // get TextureProjectionX
      56        9601 :             ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC);
      57        9601 :             const sal_uInt16 nTextureValueX(static_cast<const Svx3DTextureProjectionXItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X)).GetValue());
      58             : 
      59        9601 :             if(1L == nTextureValueX)
      60             :             {
      61        4956 :                 aTextureProjectionX = ::com::sun::star::drawing::TextureProjectionMode_PARALLEL;
      62             :             }
      63        4645 :             else if(2L == nTextureValueX)
      64             :             {
      65           0 :                 aTextureProjectionX = ::com::sun::star::drawing::TextureProjectionMode_SPHERE;
      66             :             }
      67             : 
      68             :             // get TextureProjectionY
      69        9601 :             ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC);
      70        9601 :             const sal_uInt16 nTextureValueY(static_cast<const Svx3DTextureProjectionYItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y)).GetValue());
      71             : 
      72        9601 :             if(1L == nTextureValueY)
      73             :             {
      74        4460 :                 aTextureProjectionY = ::com::sun::star::drawing::TextureProjectionMode_PARALLEL;
      75             :             }
      76        5141 :             else if(2L == nTextureValueY)
      77             :             {
      78           0 :                 aTextureProjectionY = ::com::sun::star::drawing::TextureProjectionMode_SPHERE;
      79             :             }
      80             : 
      81             :             // get DoubleSided flag
      82        9601 :             const bool bDoubleSided(static_cast<const SfxBoolItem&>(rSet.Get(SDRATTR_3DOBJ_DOUBLE_SIDED)).GetValue());
      83             : 
      84             :             // get Shadow3D flag
      85        9601 :             const bool bShadow3D(static_cast<const SfxBoolItem&>(rSet.Get(SDRATTR_3DOBJ_SHADOW_3D)).GetValue());
      86             : 
      87             :             // get TextureFilter flag
      88        9601 :             const bool bTextureFilter(static_cast<const SfxBoolItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_FILTER)).GetValue());
      89             : 
      90             :             // get texture kind
      91             :             // TextureKind: 1 == Base3DTextureLuminance, 2 == Base3DTextureIntensity, 3 == Base3DTextureColor
      92        9601 :             ::com::sun::star::drawing::TextureKind2 aTextureKind(::com::sun::star::drawing::TextureKind2_LUMINANCE);
      93        9601 :             const sal_uInt16 nTextureKind(static_cast<const Svx3DTextureKindItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_KIND)).GetValue());
      94             : 
      95        9601 :             if(2 == nTextureKind)
      96             :             {
      97           0 :                 aTextureKind = ::com::sun::star::drawing::TextureKind2_INTENSITY;
      98             :             }
      99        9601 :             else if(3 == nTextureKind)
     100             :             {
     101        9601 :                 aTextureKind = ::com::sun::star::drawing::TextureKind2_COLOR;
     102             :             }
     103             : 
     104             :             // get texture mode
     105             :             // TextureMode: 1 == Base3DTextureReplace, 2 == Base3DTextureModulate, 3 == Base3DTextureBlend
     106        9601 :             ::com::sun::star::drawing::TextureMode aTextureMode(::com::sun::star::drawing::TextureMode_REPLACE);
     107        9601 :             const sal_uInt16 nTextureMode(static_cast<const Svx3DTextureModeItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_MODE)).GetValue());
     108             : 
     109        9601 :             if(2 == nTextureMode)
     110             :             {
     111        9601 :                 aTextureMode = ::com::sun::star::drawing::TextureMode_MODULATE;
     112             :             }
     113           0 :             else if(3 == nTextureMode)
     114             :             {
     115           0 :                 aTextureMode = ::com::sun::star::drawing::TextureMode_BLEND;
     116             :             }
     117             : 
     118             :             // get object color
     119        9601 :             const ::basegfx::BColor aObjectColor(static_cast<const XFillColorItem&>(rSet.Get(XATTR_FILLCOLOR)).GetColorValue().getBColor());
     120             : 
     121             :             // get specular color
     122       19202 :             const ::basegfx::BColor aSpecular(static_cast<const SvxColorItem&>(rSet.Get(SDRATTR_3DOBJ_MAT_SPECULAR)).GetValue().getBColor());
     123             : 
     124             :             // get emissive color
     125       19202 :             const ::basegfx::BColor aEmission(static_cast<const SvxColorItem&>(rSet.Get(SDRATTR_3DOBJ_MAT_EMISSION)).GetValue().getBColor());
     126             : 
     127             :             // get specular intensity
     128        9601 :             sal_uInt16 nSpecularIntensity(static_cast<const SfxUInt16Item&>(rSet.Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY)).GetValue());
     129             : 
     130        9601 :             if(nSpecularIntensity > 128)
     131             :             {
     132           0 :                 nSpecularIntensity = 128;
     133             :             }
     134             : 
     135             :             // get reduced line geometry
     136        9601 :             const bool bReducedLineGeometry(static_cast<const Svx3DReducedLineGeometryItem&>(rSet.Get(SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY)).GetValue());
     137             : 
     138             :             // prepare material
     139       19202 :             attribute::MaterialAttribute3D aMaterial(aObjectColor, aSpecular, aEmission, nSpecularIntensity);
     140             : 
     141             :             return new attribute::Sdr3DObjectAttribute(
     142             :                 aNormalsKind, aTextureProjectionX, aTextureProjectionY,
     143             :                 aTextureKind, aTextureMode, aMaterial,
     144       19202 :                 bInvertNormals, bDoubleSided, bShadow3D, bTextureFilter, bReducedLineGeometry);
     145             :         }
     146             :     } // end of namespace primitive2d
     147             : } // end of namespace sdr
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11