LCOV - code coverage report
Current view: top level - libreoffice/drawinglayer/source/attribute - sdrobjectattribute3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 82 0.0 %
Date: 2012-12-27 Functions: 0 32 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             : #include <drawinglayer/attribute/sdrobjectattribute3d.hxx>
      21             : #include <drawinglayer/attribute/materialattribute3d.hxx>
      22             : 
      23             : //////////////////////////////////////////////////////////////////////////////
      24             : 
      25             : namespace drawinglayer
      26             : {
      27             :     namespace attribute
      28             :     {
      29           0 :         class ImpSdr3DObjectAttribute
      30             :         {
      31             :         public:
      32             :             // refcounter
      33             :             sal_uInt32                              mnRefCount;
      34             : 
      35             :             // 3D object attribute definitions
      36             :             ::com::sun::star::drawing::NormalsKind              maNormalsKind;              // normals type (0..2)
      37             :             ::com::sun::star::drawing::TextureProjectionMode    maTextureProjectionX;       // texture projection type X (0..2)
      38             :             ::com::sun::star::drawing::TextureProjectionMode    maTextureProjectionY;       // texture projection type Y (0..2)
      39             :             ::com::sun::star::drawing::TextureKind2             maTextureKind;              // texture kind (see uno API)
      40             :             ::com::sun::star::drawing::TextureMode              maTextureMode;              // texture kind (see uno API)
      41             :             MaterialAttribute3D                                 maMaterial;                 // object, specular and emissive colors, SpecularIntensity
      42             : 
      43             :             // bitfield
      44             :             unsigned                                            mbNormalsInvert : 1;        // invert normals
      45             :             unsigned                                            mbDoubleSided : 1;          // surfaces are double sided
      46             :             unsigned                                            mbShadow3D : 1;             // display shadow in 3D (if on), params for that are at scene
      47             :             unsigned                                            mbTextureFilter : 1;        // filter texture to make more smooth
      48             :             unsigned                                            mbReducedLineGeometry : 1;  // use reduced line geometry (object specific)
      49             : 
      50           0 :             ImpSdr3DObjectAttribute(
      51             :                 ::com::sun::star::drawing::NormalsKind  aNormalsKind,
      52             :                 ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX,
      53             :                 ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY,
      54             :                 ::com::sun::star::drawing::TextureKind2 aTextureKind,
      55             :                 ::com::sun::star::drawing::TextureMode aTextureMode,
      56             :                 const MaterialAttribute3D& rMaterial,
      57             :                 bool bNormalsInvert,
      58             :                 bool bDoubleSided,
      59             :                 bool bShadow3D,
      60             :                 bool bTextureFilter,
      61             :                 bool bReducedLineGeometry)
      62             :             :   mnRefCount(0),
      63             :                 maNormalsKind(aNormalsKind),
      64             :                 maTextureProjectionX(aTextureProjectionX),
      65             :                 maTextureProjectionY(aTextureProjectionY),
      66             :                 maTextureKind(aTextureKind),
      67             :                 maTextureMode(aTextureMode),
      68             :                 maMaterial(rMaterial),
      69             :                 mbNormalsInvert(bNormalsInvert),
      70             :                 mbDoubleSided(bDoubleSided),
      71             :                 mbShadow3D(bShadow3D),
      72             :                 mbTextureFilter(bTextureFilter),
      73           0 :                 mbReducedLineGeometry(bReducedLineGeometry)
      74             :             {
      75           0 :             }
      76             : 
      77             :             // data read access
      78           0 :             ::com::sun::star::drawing::NormalsKind getNormalsKind() const { return maNormalsKind; }
      79           0 :             ::com::sun::star::drawing::TextureProjectionMode getTextureProjectionX() const { return maTextureProjectionX; }
      80           0 :             ::com::sun::star::drawing::TextureProjectionMode getTextureProjectionY() const { return maTextureProjectionY; }
      81           0 :             ::com::sun::star::drawing::TextureKind2 getTextureKind() const { return maTextureKind; }
      82           0 :             ::com::sun::star::drawing::TextureMode getTextureMode() const { return maTextureMode; }
      83           0 :             const MaterialAttribute3D& getMaterial() const { return maMaterial; }
      84           0 :             bool getNormalsInvert() const { return mbNormalsInvert; }
      85           0 :             bool getDoubleSided() const { return mbDoubleSided; }
      86           0 :             bool getShadow3D() const { return mbShadow3D; }
      87           0 :             bool getTextureFilter() const { return mbTextureFilter; }
      88           0 :             bool getReducedLineGeometry() const { return mbReducedLineGeometry; }
      89             : 
      90           0 :             bool operator==(const ImpSdr3DObjectAttribute& rCandidate) const
      91             :             {
      92           0 :                 return (getNormalsKind() == rCandidate.getNormalsKind()
      93           0 :                     && getTextureProjectionX() == rCandidate.getTextureProjectionX()
      94           0 :                     && getTextureProjectionY() == rCandidate.getTextureProjectionY()
      95           0 :                     && getTextureKind() == rCandidate.getTextureKind()
      96           0 :                     && getTextureMode() == rCandidate.getTextureMode()
      97           0 :                     && getMaterial() == rCandidate.getMaterial()
      98           0 :                     && getNormalsInvert() == rCandidate.getNormalsInvert()
      99           0 :                     && getDoubleSided() == rCandidate.getDoubleSided()
     100           0 :                     && getShadow3D() == rCandidate.getShadow3D()
     101           0 :                     && getTextureFilter() == rCandidate.getTextureFilter()
     102           0 :                     && getReducedLineGeometry() == rCandidate.getReducedLineGeometry());
     103             :             }
     104             : 
     105           0 :             static ImpSdr3DObjectAttribute* get_global_default()
     106             :             {
     107             :                 static ImpSdr3DObjectAttribute* pDefault = 0;
     108             : 
     109           0 :                 if(!pDefault)
     110             :                 {
     111             :                     pDefault = new ImpSdr3DObjectAttribute(
     112             :                         ::com::sun::star::drawing::NormalsKind_SPECIFIC,
     113             :                         ::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC,
     114             :                         ::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC,
     115             :                         ::com::sun::star::drawing::TextureKind2_LUMINANCE,
     116             :                         ::com::sun::star::drawing::TextureMode_REPLACE,
     117             :                         MaterialAttribute3D(),
     118             :                         false,
     119             :                         false,
     120             :                         false,
     121             :                         false,
     122           0 :                         false);
     123             : 
     124             :                     // never delete; start with RefCount 1, not 0
     125           0 :                     pDefault->mnRefCount++;
     126             :                 }
     127             : 
     128           0 :                 return pDefault;
     129             :             }
     130             :         };
     131             : 
     132           0 :         Sdr3DObjectAttribute::Sdr3DObjectAttribute(
     133             :             ::com::sun::star::drawing::NormalsKind  aNormalsKind,
     134             :             ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX,
     135             :             ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY,
     136             :             ::com::sun::star::drawing::TextureKind2 aTextureKind,
     137             :             ::com::sun::star::drawing::TextureMode aTextureMode,
     138             :             const MaterialAttribute3D& rMaterial,
     139             :             bool bNormalsInvert,
     140             :             bool bDoubleSided,
     141             :             bool bShadow3D,
     142             :             bool bTextureFilter,
     143             :             bool bReducedLineGeometry)
     144             :         :   mpSdr3DObjectAttribute(new ImpSdr3DObjectAttribute(
     145             :                 aNormalsKind, aTextureProjectionX, aTextureProjectionY, aTextureKind, aTextureMode,
     146           0 :                 rMaterial, bNormalsInvert, bDoubleSided, bShadow3D, bTextureFilter, bReducedLineGeometry))
     147             :         {
     148           0 :         }
     149             : 
     150           0 :         Sdr3DObjectAttribute::Sdr3DObjectAttribute(const Sdr3DObjectAttribute& rCandidate)
     151           0 :         :   mpSdr3DObjectAttribute(rCandidate.mpSdr3DObjectAttribute)
     152             :         {
     153           0 :             mpSdr3DObjectAttribute->mnRefCount++;
     154           0 :         }
     155             : 
     156           0 :         Sdr3DObjectAttribute::~Sdr3DObjectAttribute()
     157             :         {
     158           0 :             if(mpSdr3DObjectAttribute->mnRefCount)
     159             :             {
     160           0 :                 mpSdr3DObjectAttribute->mnRefCount--;
     161             :             }
     162             :             else
     163             :             {
     164           0 :                 delete mpSdr3DObjectAttribute;
     165             :             }
     166           0 :         }
     167             : 
     168           0 :         bool Sdr3DObjectAttribute::isDefault() const
     169             :         {
     170           0 :             return mpSdr3DObjectAttribute == ImpSdr3DObjectAttribute::get_global_default();
     171             :         }
     172             : 
     173           0 :         Sdr3DObjectAttribute& Sdr3DObjectAttribute::operator=(const Sdr3DObjectAttribute& rCandidate)
     174             :         {
     175           0 :             if(rCandidate.mpSdr3DObjectAttribute != mpSdr3DObjectAttribute)
     176             :             {
     177           0 :                 if(mpSdr3DObjectAttribute->mnRefCount)
     178             :                 {
     179           0 :                     mpSdr3DObjectAttribute->mnRefCount--;
     180             :                 }
     181             :                 else
     182             :                 {
     183           0 :                     delete mpSdr3DObjectAttribute;
     184             :                 }
     185             : 
     186           0 :                 mpSdr3DObjectAttribute = rCandidate.mpSdr3DObjectAttribute;
     187           0 :                 mpSdr3DObjectAttribute->mnRefCount++;
     188             :             }
     189             : 
     190           0 :             return *this;
     191             :         }
     192             : 
     193           0 :         bool Sdr3DObjectAttribute::operator==(const Sdr3DObjectAttribute& rCandidate) const
     194             :         {
     195           0 :             if(rCandidate.mpSdr3DObjectAttribute == mpSdr3DObjectAttribute)
     196             :             {
     197           0 :                 return true;
     198             :             }
     199             : 
     200           0 :             if(rCandidate.isDefault() != isDefault())
     201             :             {
     202           0 :                 return false;
     203             :             }
     204             : 
     205           0 :             return (*rCandidate.mpSdr3DObjectAttribute == *mpSdr3DObjectAttribute);
     206             :         }
     207             : 
     208           0 :         ::com::sun::star::drawing::NormalsKind Sdr3DObjectAttribute::getNormalsKind() const
     209             :         {
     210           0 :             return mpSdr3DObjectAttribute->getNormalsKind();
     211             :         }
     212             : 
     213           0 :         ::com::sun::star::drawing::TextureProjectionMode Sdr3DObjectAttribute::getTextureProjectionX() const
     214             :         {
     215           0 :             return mpSdr3DObjectAttribute->getTextureProjectionX();
     216             :         }
     217             : 
     218           0 :         ::com::sun::star::drawing::TextureProjectionMode Sdr3DObjectAttribute::getTextureProjectionY() const
     219             :         {
     220           0 :             return mpSdr3DObjectAttribute->getTextureProjectionY();
     221             :         }
     222             : 
     223           0 :         ::com::sun::star::drawing::TextureKind2 Sdr3DObjectAttribute::getTextureKind() const
     224             :         {
     225           0 :             return mpSdr3DObjectAttribute->getTextureKind();
     226             :         }
     227             : 
     228           0 :         ::com::sun::star::drawing::TextureMode Sdr3DObjectAttribute::getTextureMode() const
     229             :         {
     230           0 :             return mpSdr3DObjectAttribute->getTextureMode();
     231             :         }
     232             : 
     233           0 :         const MaterialAttribute3D& Sdr3DObjectAttribute::getMaterial() const
     234             :         {
     235           0 :             return mpSdr3DObjectAttribute->getMaterial();
     236             :         }
     237             : 
     238           0 :         bool Sdr3DObjectAttribute::getNormalsInvert() const
     239             :         {
     240           0 :             return mpSdr3DObjectAttribute->getNormalsInvert();
     241             :         }
     242             : 
     243           0 :         bool Sdr3DObjectAttribute::getDoubleSided() const
     244             :         {
     245           0 :             return mpSdr3DObjectAttribute->getDoubleSided();
     246             :         }
     247             : 
     248           0 :         bool Sdr3DObjectAttribute::getShadow3D() const
     249             :         {
     250           0 :             return mpSdr3DObjectAttribute->getShadow3D();
     251             :         }
     252             : 
     253           0 :         bool Sdr3DObjectAttribute::getTextureFilter() const
     254             :         {
     255           0 :             return mpSdr3DObjectAttribute->getTextureFilter();
     256             :         }
     257             : 
     258           0 :         bool Sdr3DObjectAttribute::getReducedLineGeometry() const
     259             :         {
     260           0 :             return mpSdr3DObjectAttribute->getReducedLineGeometry();
     261             :         }
     262             : 
     263             :     } // end of namespace attribute
     264             : } // end of namespace drawinglayer
     265             : 
     266             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10