LCOV - code coverage report
Current view: top level - drawinglayer/source/geometry - viewinformation3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 78 238 32.8 %
Date: 2012-08-25 Functions: 27 41 65.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 58 472 12.3 %

           Branch data     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/geometry/viewinformation3d.hxx>
      21                 :            : #include <basegfx/range/b3drange.hxx>
      22                 :            : #include <basegfx/matrix/b3dhommatrix.hxx>
      23                 :            : #include <com/sun/star/geometry/AffineMatrix3D.hpp>
      24                 :            : #include <com/sun/star/geometry/RealRectangle3D.hpp>
      25                 :            : #include <basegfx/tools/canvastools.hxx>
      26                 :            : 
      27                 :            : //////////////////////////////////////////////////////////////////////////////
      28                 :            : 
      29                 :            : using namespace com::sun::star;
      30                 :            : 
      31                 :            : //////////////////////////////////////////////////////////////////////////////
      32                 :            : 
      33                 :            : namespace drawinglayer
      34                 :            : {
      35                 :            :     namespace geometry
      36                 :            :     {
      37                 :            :         /** Implementation class for ViewInformation3D
      38                 :            :         */
      39 [ +  - ][ +  - ]:       8407 :         class ImpViewInformation3D
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      40                 :            :         {
      41                 :            :         private:
      42                 :            :             // ViewInformation3D implementation can change refcount, so we have only
      43                 :            :             // two memory regions for pairs of ViewInformation3D/ImpViewInformation3D
      44                 :            :             friend class ::drawinglayer::geometry::ViewInformation3D;
      45                 :            : 
      46                 :            :             // the refcounter. 0 means exclusively used
      47                 :            :             sal_uInt32                                  mnRefCount;
      48                 :            : 
      49                 :            :             // the 3D transformations
      50                 :            :             // Object to World. This may change and being adapted when entering 3D transformation
      51                 :            :             // groups
      52                 :            :             basegfx::B3DHomMatrix                       maObjectTransformation;
      53                 :            : 
      54                 :            :             // World to Camera. This includes VRP, VPN and VUV camera coordinate system
      55                 :            :             basegfx::B3DHomMatrix                       maOrientation;
      56                 :            : 
      57                 :            :             // Camera to Device with X,Y and Z [-1.0 .. 1.0]. This is the
      58                 :            :             // 3D to 2D projection which may be parallell or perspective. When it is perspective,
      59                 :            :             // the last line of the homogen matrix will NOT be unused
      60                 :            :             basegfx::B3DHomMatrix                       maProjection;
      61                 :            : 
      62                 :            :             // Device to View with X,Y and Z [0.0 .. 1.0]. This converts from -1 to 1 coordinates
      63                 :            :             // in camera coordinate system to 0 to 1 in unit 2D coordinates. This way it stays
      64                 :            :             // view-independent. To get discrete coordinates, the 2D transformation of a scene
      65                 :            :             // as 2D object needs to be involved
      66                 :            :             basegfx::B3DHomMatrix                       maDeviceToView;
      67                 :            : 
      68                 :            :             // Object to View is the linear combination of all four transformations. It's
      69                 :            :             // buffered to avoid too much matrix multiplying and created on demand
      70                 :            :             basegfx::B3DHomMatrix                       maObjectToView;
      71                 :            : 
      72                 :            :             // the point in time
      73                 :            :             double                                      mfViewTime;
      74                 :            : 
      75                 :            :             // the complete PropertyValue representation (if already created)
      76                 :            :             uno::Sequence< beans::PropertyValue >       mxViewInformation;
      77                 :            : 
      78                 :            :             // the extra PropertyValues; does not contain the transformations
      79                 :            :             uno::Sequence< beans::PropertyValue >       mxExtendedInformation;
      80                 :            : 
      81                 :            :             // the local UNO API strings
      82                 :          0 :             const ::rtl::OUString& getNamePropertyObjectTransformation()
      83                 :            :             {
      84 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("ObjectTransformation"));
         [ #  # ][ #  # ]
      85                 :          0 :                 return s_sNameProperty;
      86                 :            :             }
      87                 :            : 
      88                 :          0 :             const ::rtl::OUString& getNamePropertyOrientation()
      89                 :            :             {
      90 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("Orientation"));
         [ #  # ][ #  # ]
      91                 :          0 :                 return s_sNameProperty;
      92                 :            :             }
      93                 :            : 
      94                 :          0 :             const ::rtl::OUString& getNamePropertyProjection()
      95                 :            :             {
      96 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("Projection"));
         [ #  # ][ #  # ]
      97                 :          0 :                 return s_sNameProperty;
      98                 :            :             }
      99                 :            : 
     100                 :          0 :             const ::rtl::OUString& getNamePropertyProjection_30()
     101                 :            :             {
     102 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("Projection30"));
         [ #  # ][ #  # ]
     103                 :          0 :                 return s_sNameProperty;
     104                 :            :             }
     105                 :            : 
     106                 :          0 :             const ::rtl::OUString& getNamePropertyProjection_31()
     107                 :            :             {
     108 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("Projection31"));
         [ #  # ][ #  # ]
     109                 :          0 :                 return s_sNameProperty;
     110                 :            :             }
     111                 :            : 
     112                 :          0 :             const ::rtl::OUString& getNamePropertyProjection_32()
     113                 :            :             {
     114 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("Projection32"));
         [ #  # ][ #  # ]
     115                 :          0 :                 return s_sNameProperty;
     116                 :            :             }
     117                 :            : 
     118                 :          0 :             const ::rtl::OUString& getNamePropertyProjection_33()
     119                 :            :             {
     120 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("Projection33"));
         [ #  # ][ #  # ]
     121                 :          0 :                 return s_sNameProperty;
     122                 :            :             }
     123                 :            : 
     124                 :          0 :             const ::rtl::OUString& getNamePropertyDeviceToView()
     125                 :            :             {
     126 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("DeviceToView"));
         [ #  # ][ #  # ]
     127                 :          0 :                 return s_sNameProperty;
     128                 :            :             }
     129                 :            : 
     130                 :          0 :             const ::rtl::OUString& getNamePropertyTime()
     131                 :            :             {
     132 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString s_sNamePropertyTime(RTL_CONSTASCII_USTRINGPARAM("Time"));
         [ #  # ][ #  # ]
     133                 :          0 :                 return s_sNamePropertyTime;
     134                 :            :             }
     135                 :            : 
     136                 :            :             // a central PropertyValue parsing method to allow transportatin of
     137                 :            :             // all ViewParameters using UNO API
     138                 :       8407 :             void impInterpretPropertyValues(const uno::Sequence< beans::PropertyValue >& rViewParameters)
     139                 :            :             {
     140         [ -  + ]:       8407 :                 if(rViewParameters.hasElements())
     141                 :            :                 {
     142                 :          0 :                     const sal_Int32 nCount(rViewParameters.getLength());
     143                 :          0 :                     sal_Int32 nExtendedInsert(0);
     144                 :            : 
     145                 :            :                     // prepare extended information for filtering. Maximum size is nCount
     146                 :          0 :                     mxExtendedInformation.realloc(nCount);
     147                 :            : 
     148         [ #  # ]:          0 :                     for(sal_Int32 a(0); a < nCount; a++)
     149                 :            :                     {
     150                 :          0 :                         const beans::PropertyValue& rProp = rViewParameters[a];
     151                 :            : 
     152         [ #  # ]:          0 :                         if(rProp.Name == getNamePropertyObjectTransformation())
     153                 :            :                         {
     154                 :          0 :                             com::sun::star::geometry::AffineMatrix3D aAffineMatrix3D;
     155         [ #  # ]:          0 :                             rProp.Value >>= aAffineMatrix3D;
     156 [ #  # ][ #  # ]:          0 :                             maObjectTransformation = basegfx::unotools::homMatrixFromAffineMatrix3D(aAffineMatrix3D);
                 [ #  # ]
     157                 :            :                         }
     158         [ #  # ]:          0 :                         else if(rProp.Name == getNamePropertyOrientation())
     159                 :            :                         {
     160                 :          0 :                             com::sun::star::geometry::AffineMatrix3D aAffineMatrix3D;
     161         [ #  # ]:          0 :                             rProp.Value >>= aAffineMatrix3D;
     162 [ #  # ][ #  # ]:          0 :                             maOrientation = basegfx::unotools::homMatrixFromAffineMatrix3D(aAffineMatrix3D);
                 [ #  # ]
     163                 :            :                         }
     164         [ #  # ]:          0 :                         else if(rProp.Name == getNamePropertyProjection())
     165                 :            :                         {
     166                 :            :                             // projection may be defined using a frustum in which case the last line of
     167                 :            :                             // the 4x4 matrix is not (0,0,0,1). Since AffineMatrix3D does not support that,
     168                 :            :                             // these four values need to be treated extra
     169         [ #  # ]:          0 :                             const double f_30(maProjection.get(3, 0));
     170         [ #  # ]:          0 :                             const double f_31(maProjection.get(3, 1));
     171         [ #  # ]:          0 :                             const double f_32(maProjection.get(3, 2));
     172         [ #  # ]:          0 :                             const double f_33(maProjection.get(3, 3));
     173                 :            : 
     174                 :          0 :                             com::sun::star::geometry::AffineMatrix3D aAffineMatrix3D;
     175         [ #  # ]:          0 :                             rProp.Value >>= aAffineMatrix3D;
     176 [ #  # ][ #  # ]:          0 :                             maProjection = basegfx::unotools::homMatrixFromAffineMatrix3D(aAffineMatrix3D);
                 [ #  # ]
     177                 :            : 
     178         [ #  # ]:          0 :                             maProjection.set(3, 0, f_30);
     179         [ #  # ]:          0 :                             maProjection.set(3, 1, f_31);
     180         [ #  # ]:          0 :                             maProjection.set(3, 2, f_32);
     181         [ #  # ]:          0 :                             maProjection.set(3, 3, f_33);
     182                 :            :                         }
     183         [ #  # ]:          0 :                         else if(rProp.Name == getNamePropertyProjection_30())
     184                 :            :                         {
     185                 :          0 :                             double f_30(0.0);
     186                 :          0 :                             rProp.Value >>= f_30;
     187         [ #  # ]:          0 :                             maProjection.set(3, 0, f_30);
     188                 :            :                         }
     189         [ #  # ]:          0 :                         else if(rProp.Name == getNamePropertyProjection_31())
     190                 :            :                         {
     191                 :          0 :                             double f_31(0.0);
     192                 :          0 :                             rProp.Value >>= f_31;
     193         [ #  # ]:          0 :                             maProjection.set(3, 1, f_31);
     194                 :            :                         }
     195         [ #  # ]:          0 :                         else if(rProp.Name == getNamePropertyProjection_32())
     196                 :            :                         {
     197                 :          0 :                             double f_32(0.0);
     198                 :          0 :                             rProp.Value >>= f_32;
     199         [ #  # ]:          0 :                             maProjection.set(3, 2, f_32);
     200                 :            :                         }
     201         [ #  # ]:          0 :                         else if(rProp.Name == getNamePropertyProjection_33())
     202                 :            :                         {
     203                 :          0 :                             double f_33(1.0);
     204                 :          0 :                             rProp.Value >>= f_33;
     205         [ #  # ]:          0 :                             maProjection.set(3, 3, f_33);
     206                 :            :                         }
     207         [ #  # ]:          0 :                         else if(rProp.Name == getNamePropertyDeviceToView())
     208                 :            :                         {
     209                 :          0 :                             com::sun::star::geometry::AffineMatrix3D aAffineMatrix3D;
     210         [ #  # ]:          0 :                             rProp.Value >>= aAffineMatrix3D;
     211 [ #  # ][ #  # ]:          0 :                             maDeviceToView = basegfx::unotools::homMatrixFromAffineMatrix3D(aAffineMatrix3D);
                 [ #  # ]
     212                 :            :                         }
     213         [ #  # ]:          0 :                         else if(rProp.Name == getNamePropertyTime())
     214                 :            :                         {
     215                 :          0 :                             rProp.Value >>= mfViewTime;
     216                 :            :                         }
     217                 :            :                         else
     218                 :            :                         {
     219                 :            :                             // extra information; add to filtered information
     220                 :          0 :                             mxExtendedInformation[nExtendedInsert++] = rProp;
     221                 :            :                         }
     222                 :            :                     }
     223                 :            : 
     224                 :            :                     // extra information size is now known; realloc to final size
     225                 :          0 :                     mxExtendedInformation.realloc(nExtendedInsert);
     226                 :            :                 }
     227                 :       8407 :             }
     228                 :            : 
     229                 :            :             // central method to create a Sequence of PropertyValues containing he complete
     230                 :            :             // data set
     231                 :          0 :             void impFillViewInformationFromContent()
     232                 :            :             {
     233         [ #  # ]:          0 :                 uno::Sequence< beans::PropertyValue > xRetval;
     234         [ #  # ]:          0 :                 const bool bObjectTransformationUsed(!maObjectTransformation.isIdentity());
     235         [ #  # ]:          0 :                 const bool bOrientationUsed(!maOrientation.isIdentity());
     236         [ #  # ]:          0 :                 const bool bProjectionUsed(!maProjection.isIdentity());
     237         [ #  # ]:          0 :                 const bool bDeviceToViewUsed(!maDeviceToView.isIdentity());
     238                 :          0 :                 const bool bTimeUsed(0.0 < mfViewTime);
     239                 :          0 :                 const bool bExtraInformation(mxExtendedInformation.hasElements());
     240                 :            : 
     241                 :            :                 // projection may be defined using a frustum in which case the last line of
     242                 :            :                 // the 4x4 matrix is not (0,0,0,1). Since AffineMatrix3D does not support that,
     243                 :            :                 // these four values need to be treated extra
     244 [ #  # ][ #  # ]:          0 :                 const bool bProjectionUsed_30(bProjectionUsed && !basegfx::fTools::equalZero(maProjection.get(3, 0)));
         [ #  # ][ #  # ]
                 [ #  # ]
     245 [ #  # ][ #  # ]:          0 :                 const bool bProjectionUsed_31(bProjectionUsed && !basegfx::fTools::equalZero(maProjection.get(3, 1)));
         [ #  # ][ #  # ]
                 [ #  # ]
     246 [ #  # ][ #  # ]:          0 :                 const bool bProjectionUsed_32(bProjectionUsed && !basegfx::fTools::equalZero(maProjection.get(3, 2)));
         [ #  # ][ #  # ]
                 [ #  # ]
     247 [ #  # ][ #  # ]:          0 :                 const bool bProjectionUsed_33(bProjectionUsed && !basegfx::fTools::equal(maProjection.get(3, 3), 1.0));
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     248                 :            : 
     249                 :          0 :                 sal_uInt32 nIndex(0);
     250                 :            :                 const sal_uInt32 nCount(
     251                 :            :                     (bObjectTransformationUsed ? 1 : 0) +
     252                 :            :                     (bOrientationUsed ? 1 : 0) +
     253                 :            :                     (bProjectionUsed ? 1 : 0) +
     254                 :            :                     (bProjectionUsed_30 ? 1 : 0) +
     255                 :            :                     (bProjectionUsed_31 ? 1 : 0) +
     256                 :            :                     (bProjectionUsed_32 ? 1 : 0) +
     257                 :            :                     (bProjectionUsed_33 ? 1 : 0) +
     258                 :            :                     (bDeviceToViewUsed ? 1 : 0) +
     259                 :            :                     (bTimeUsed ? 1 : 0) +
     260 [ #  # ][ #  # ]:          0 :                     (bExtraInformation ? mxExtendedInformation.getLength() : 0));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     261                 :            : 
     262         [ #  # ]:          0 :                 mxViewInformation.realloc(nCount);
     263                 :            : 
     264         [ #  # ]:          0 :                 if(bObjectTransformationUsed)
     265                 :            :                 {
     266                 :          0 :                     com::sun::star::geometry::AffineMatrix3D aAffineMatrix3D;
     267         [ #  # ]:          0 :                     basegfx::unotools::affineMatrixFromHomMatrix3D(aAffineMatrix3D, maObjectTransformation);
     268 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Name = getNamePropertyObjectTransformation();
     269 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Value <<= aAffineMatrix3D;
     270                 :          0 :                     nIndex++;
     271                 :            :                 }
     272                 :            : 
     273         [ #  # ]:          0 :                 if(bOrientationUsed)
     274                 :            :                 {
     275                 :          0 :                     com::sun::star::geometry::AffineMatrix3D aAffineMatrix3D;
     276         [ #  # ]:          0 :                     basegfx::unotools::affineMatrixFromHomMatrix3D(aAffineMatrix3D, maOrientation);
     277 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Name = getNamePropertyOrientation();
     278 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Value <<= aAffineMatrix3D;
     279                 :          0 :                     nIndex++;
     280                 :            :                 }
     281                 :            : 
     282         [ #  # ]:          0 :                 if(bProjectionUsed)
     283                 :            :                 {
     284                 :          0 :                     com::sun::star::geometry::AffineMatrix3D aAffineMatrix3D;
     285         [ #  # ]:          0 :                     basegfx::unotools::affineMatrixFromHomMatrix3D(aAffineMatrix3D, maProjection);
     286 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Name = getNamePropertyProjection();
     287 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Value <<= aAffineMatrix3D;
     288                 :          0 :                     nIndex++;
     289                 :            :                 }
     290                 :            : 
     291         [ #  # ]:          0 :                 if(bProjectionUsed_30)
     292                 :            :                 {
     293 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Name = getNamePropertyProjection_30();
     294 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Value <<= maProjection.get(3, 0);
                 [ #  # ]
     295                 :          0 :                     nIndex++;
     296                 :            :                 }
     297                 :            : 
     298         [ #  # ]:          0 :                 if(bProjectionUsed_31)
     299                 :            :                 {
     300 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Name = getNamePropertyProjection_31();
     301 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Value <<= maProjection.get(3, 1);
                 [ #  # ]
     302                 :          0 :                     nIndex++;
     303                 :            :                 }
     304                 :            : 
     305         [ #  # ]:          0 :                 if(bProjectionUsed_32)
     306                 :            :                 {
     307 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Name = getNamePropertyProjection_32();
     308 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Value <<= maProjection.get(3, 2);
                 [ #  # ]
     309                 :          0 :                     nIndex++;
     310                 :            :                 }
     311                 :            : 
     312         [ #  # ]:          0 :                 if(bProjectionUsed_33)
     313                 :            :                 {
     314 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Name = getNamePropertyProjection_33();
     315 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Value <<= maProjection.get(3, 3);
                 [ #  # ]
     316                 :          0 :                     nIndex++;
     317                 :            :                 }
     318                 :            : 
     319         [ #  # ]:          0 :                 if(bDeviceToViewUsed)
     320                 :            :                 {
     321                 :          0 :                     com::sun::star::geometry::AffineMatrix3D aAffineMatrix3D;
     322         [ #  # ]:          0 :                     basegfx::unotools::affineMatrixFromHomMatrix3D(aAffineMatrix3D, maDeviceToView);
     323 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Name = getNamePropertyDeviceToView();
     324 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Value <<= aAffineMatrix3D;
     325                 :          0 :                     nIndex++;
     326                 :            :                 }
     327                 :            : 
     328         [ #  # ]:          0 :                 if(bTimeUsed)
     329                 :            :                 {
     330 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Name = getNamePropertyTime();
     331 [ #  # ][ #  # ]:          0 :                     mxViewInformation[nIndex].Value <<= mfViewTime;
     332                 :          0 :                     nIndex++;
     333                 :            :                 }
     334                 :            : 
     335         [ #  # ]:          0 :                 if(bExtraInformation)
     336                 :            :                 {
     337                 :          0 :                     const sal_Int32 nExtra(mxExtendedInformation.getLength());
     338                 :            : 
     339         [ #  # ]:          0 :                     for(sal_Int32 a(0); a < nExtra; a++)
     340                 :            :                     {
     341 [ #  # ][ #  # ]:          0 :                         mxViewInformation[nIndex++] = mxExtendedInformation[a];
     342                 :            :                     }
     343         [ #  # ]:          0 :                 }
     344                 :          0 :             }
     345                 :            : 
     346                 :            :         public:
     347                 :       4342 :             ImpViewInformation3D(
     348                 :            :                 const basegfx::B3DHomMatrix& rObjectTransformation,
     349                 :            :                 const basegfx::B3DHomMatrix& rOrientation,
     350                 :            :                 const basegfx::B3DHomMatrix& rProjection,
     351                 :            :                 const basegfx::B3DHomMatrix& rDeviceToView,
     352                 :            :                 double fViewTime,
     353                 :            :                 const uno::Sequence< beans::PropertyValue >& rExtendedParameters)
     354                 :            :             :   mnRefCount(0),
     355                 :            :                 maObjectTransformation(rObjectTransformation),
     356                 :            :                 maOrientation(rOrientation),
     357                 :            :                 maProjection(rProjection),
     358                 :            :                 maDeviceToView(rDeviceToView),
     359                 :            :                 mfViewTime(fViewTime),
     360                 :            :                 mxViewInformation(),
     361 [ +  - ][ +  - ]:       4342 :                 mxExtendedInformation()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     362                 :            :             {
     363         [ +  - ]:       4342 :                 impInterpretPropertyValues(rExtendedParameters);
     364                 :       4342 :             }
     365                 :            : 
     366                 :       4065 :             explicit ImpViewInformation3D(const uno::Sequence< beans::PropertyValue >& rViewParameters)
     367                 :            :             :   mnRefCount(0),
     368                 :            :                 maObjectTransformation(),
     369                 :            :                 maOrientation(),
     370                 :            :                 maProjection(),
     371                 :            :                 maDeviceToView(),
     372                 :            :                 mfViewTime(),
     373                 :            :                 mxViewInformation(rViewParameters),
     374 [ +  - ][ +  - ]:       4065 :                 mxExtendedInformation()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     375                 :            :             {
     376         [ +  - ]:       4065 :                 impInterpretPropertyValues(rViewParameters);
     377                 :       4065 :             }
     378                 :            : 
     379                 :          2 :             ImpViewInformation3D()
     380                 :            :             :   mnRefCount(0),
     381                 :            :                 maObjectTransformation(),
     382                 :            :                 maOrientation(),
     383                 :            :                 maProjection(),
     384                 :            :                 maDeviceToView(),
     385                 :            :                 mfViewTime(),
     386                 :            :                 mxViewInformation(),
     387 [ +  - ][ +  - ]:          2 :                 mxExtendedInformation()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     388                 :            :             {
     389                 :          2 :             }
     390                 :            : 
     391                 :       4810 :             const basegfx::B3DHomMatrix& getObjectTransformation() const { return maObjectTransformation; }
     392                 :       4749 :             const basegfx::B3DHomMatrix& getOrientation() const { return maOrientation; }
     393                 :       4213 :             const basegfx::B3DHomMatrix& getProjection() const { return maProjection; }
     394                 :       4198 :             const basegfx::B3DHomMatrix& getDeviceToView() const { return maDeviceToView; }
     395                 :       3787 :             double getViewTime() const { return mfViewTime; }
     396                 :            : 
     397                 :       4148 :             const basegfx::B3DHomMatrix& getObjectToView() const
     398                 :            :             {
     399                 :            :                 // on demand WorldToView creation
     400         [ +  - ]:       4148 :                 ::osl::Mutex m_mutex;
     401                 :            : 
     402 [ +  - ][ +  + ]:       4148 :                 if(maObjectToView.isIdentity())
     403                 :            :                 {
     404 [ +  - ][ +  - ]:       3569 :                     const_cast< ImpViewInformation3D* >(this)->maObjectToView = maDeviceToView * maProjection * maOrientation * maObjectTransformation;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     405                 :            :                 }
     406                 :            : 
     407         [ +  - ]:       4148 :                 return maObjectToView;
     408                 :            :             }
     409                 :            : 
     410                 :          0 :             const uno::Sequence< beans::PropertyValue >& getViewInformationSequence() const
     411                 :            :             {
     412         [ #  # ]:          0 :                 ::osl::Mutex m_mutex;
     413                 :            : 
     414         [ #  # ]:          0 :                 if(!mxViewInformation.hasElements())
     415                 :            :                 {
     416         [ #  # ]:          0 :                     const_cast< ImpViewInformation3D* >(this)->impFillViewInformationFromContent();
     417                 :            :                 }
     418                 :            : 
     419         [ #  # ]:          0 :                 return mxViewInformation;
     420                 :            :             }
     421                 :            : 
     422                 :       3787 :             const uno::Sequence< beans::PropertyValue >& getExtendedInformationSequence() const
     423                 :            :             {
     424                 :       3787 :                 return mxExtendedInformation;
     425                 :            :             }
     426                 :            : 
     427                 :          0 :             bool operator==(const ImpViewInformation3D& rCandidate) const
     428                 :            :             {
     429                 :          0 :                 return (maObjectTransformation == rCandidate.maObjectTransformation
     430                 :          0 :                     && maOrientation == rCandidate.maOrientation
     431                 :          0 :                     && maProjection == rCandidate.maProjection
     432                 :          0 :                     && maDeviceToView == rCandidate.maDeviceToView
     433                 :            :                     && mfViewTime == rCandidate.mfViewTime
     434 [ #  # ][ #  # ]:          0 :                     && mxExtendedInformation == rCandidate.mxExtendedInformation);
           [ #  #  #  #  
             #  #  #  # ]
     435                 :            :             }
     436                 :            : 
     437                 :       7397 :             static ImpViewInformation3D* get_global_default()
     438                 :            :             {
     439                 :            :                 static ImpViewInformation3D* pDefault = 0;
     440                 :            : 
     441         [ +  + ]:       7397 :                 if(!pDefault)
     442                 :            :                 {
     443         [ +  - ]:          2 :                     pDefault = new ImpViewInformation3D();
     444                 :            : 
     445                 :            :                     // never delete; start with RefCount 1, not 0
     446                 :          2 :                     pDefault->mnRefCount++;
     447                 :            :                 }
     448                 :            : 
     449                 :       7397 :                 return pDefault;
     450                 :            :             }
     451                 :            :         };
     452                 :            :     } // end of anonymous namespace
     453                 :            : } // end of namespace drawinglayer
     454                 :            : 
     455                 :            : //////////////////////////////////////////////////////////////////////////////
     456                 :            : 
     457                 :            : namespace drawinglayer
     458                 :            : {
     459                 :            :     namespace geometry
     460                 :            :     {
     461                 :       4342 :         ViewInformation3D::ViewInformation3D(
     462                 :            :             const basegfx::B3DHomMatrix& rObjectObjectTransformation,
     463                 :            :             const basegfx::B3DHomMatrix& rOrientation,
     464                 :            :             const basegfx::B3DHomMatrix& rProjection,
     465                 :            :             const basegfx::B3DHomMatrix& rDeviceToView,
     466                 :            :             double fViewTime,
     467                 :            :             const uno::Sequence< beans::PropertyValue >& rExtendedParameters)
     468                 :            :         :   mpViewInformation3D(new ImpViewInformation3D(
     469                 :            :                 rObjectObjectTransformation, rOrientation, rProjection,
     470         [ +  - ]:       4342 :                 rDeviceToView, fViewTime, rExtendedParameters))
     471                 :            :         {
     472                 :       4342 :         }
     473                 :            : 
     474                 :       4065 :         ViewInformation3D::ViewInformation3D(const uno::Sequence< beans::PropertyValue >& rViewParameters)
     475         [ +  - ]:       4065 :         :   mpViewInformation3D(new ImpViewInformation3D(rViewParameters))
     476                 :            :         {
     477                 :       4065 :         }
     478                 :            : 
     479                 :       3903 :         ViewInformation3D::ViewInformation3D()
     480                 :       3903 :         :   mpViewInformation3D(ImpViewInformation3D::get_global_default())
     481                 :            :         {
     482                 :       3903 :             mpViewInformation3D->mnRefCount++;
     483                 :       3903 :         }
     484                 :            : 
     485                 :       3878 :         ViewInformation3D::ViewInformation3D(const ViewInformation3D& rCandidate)
     486                 :       3878 :         :   mpViewInformation3D(rCandidate.mpViewInformation3D)
     487                 :            :         {
     488         [ +  - ]:       3878 :             ::osl::Mutex m_mutex;
     489         [ +  - ]:       3878 :             mpViewInformation3D->mnRefCount++;
     490                 :       3878 :         }
     491                 :            : 
     492                 :      16188 :         ViewInformation3D::~ViewInformation3D()
     493                 :            :         {
     494         [ +  - ]:      16188 :             ::osl::Mutex m_mutex;
     495                 :            : 
     496         [ +  + ]:      16188 :             if(mpViewInformation3D->mnRefCount)
     497                 :            :             {
     498                 :      11668 :                 mpViewInformation3D->mnRefCount--;
     499                 :            :             }
     500                 :            :             else
     501                 :            :             {
     502 [ +  - ][ +  - ]:       4520 :                 delete mpViewInformation3D;
     503         [ +  - ]:      16188 :             }
     504                 :      16188 :         }
     505                 :            : 
     506                 :       3494 :         bool ViewInformation3D::isDefault() const
     507                 :            :         {
     508                 :       3494 :             return mpViewInformation3D == ImpViewInformation3D::get_global_default();
     509                 :            :         }
     510                 :            : 
     511                 :       7933 :         ViewInformation3D& ViewInformation3D::operator=(const ViewInformation3D& rCandidate)
     512                 :            :         {
     513         [ +  - ]:       7933 :             ::osl::Mutex m_mutex;
     514                 :            : 
     515         [ +  + ]:       7933 :             if(mpViewInformation3D->mnRefCount)
     516                 :            :             {
     517                 :       4046 :                 mpViewInformation3D->mnRefCount--;
     518                 :            :             }
     519                 :            :             else
     520                 :            :             {
     521 [ +  - ][ +  - ]:       3887 :                 delete mpViewInformation3D;
     522                 :            :             }
     523                 :            : 
     524                 :       7933 :             mpViewInformation3D = rCandidate.mpViewInformation3D;
     525                 :       7933 :             mpViewInformation3D->mnRefCount++;
     526                 :            : 
     527         [ +  - ]:       7933 :             return *this;
     528                 :            :         }
     529                 :            : 
     530                 :          0 :         bool ViewInformation3D::operator==(const ViewInformation3D& rCandidate) const
     531                 :            :         {
     532         [ #  # ]:          0 :             if(rCandidate.mpViewInformation3D == mpViewInformation3D)
     533                 :            :             {
     534                 :          0 :                 return true;
     535                 :            :             }
     536                 :            : 
     537         [ #  # ]:          0 :             if(rCandidate.isDefault() != isDefault())
     538                 :            :             {
     539                 :          0 :                 return false;
     540                 :            :             }
     541                 :            : 
     542                 :          0 :             return (*rCandidate.mpViewInformation3D == *mpViewInformation3D);
     543                 :            :         }
     544                 :            : 
     545                 :       4810 :         const basegfx::B3DHomMatrix& ViewInformation3D::getObjectTransformation() const
     546                 :            :         {
     547                 :       4810 :             return mpViewInformation3D->getObjectTransformation();
     548                 :            :         }
     549                 :            : 
     550                 :       4749 :         const basegfx::B3DHomMatrix& ViewInformation3D::getOrientation() const
     551                 :            :         {
     552                 :       4749 :             return mpViewInformation3D->getOrientation();
     553                 :            :         }
     554                 :            : 
     555                 :       4213 :         const basegfx::B3DHomMatrix& ViewInformation3D::getProjection() const
     556                 :            :         {
     557                 :       4213 :             return mpViewInformation3D->getProjection();
     558                 :            :         }
     559                 :            : 
     560                 :       4198 :         const basegfx::B3DHomMatrix& ViewInformation3D::getDeviceToView() const
     561                 :            :         {
     562                 :       4198 :             return mpViewInformation3D->getDeviceToView();
     563                 :            :         }
     564                 :            : 
     565                 :       4148 :         const basegfx::B3DHomMatrix& ViewInformation3D::getObjectToView() const
     566                 :            :         {
     567                 :       4148 :             return mpViewInformation3D->getObjectToView();
     568                 :            :         }
     569                 :            : 
     570                 :       3787 :         double ViewInformation3D::getViewTime() const
     571                 :            :         {
     572                 :       3787 :             return mpViewInformation3D->getViewTime();
     573                 :            :         }
     574                 :            : 
     575                 :          0 :         const uno::Sequence< beans::PropertyValue >& ViewInformation3D::getViewInformationSequence() const
     576                 :            :         {
     577                 :          0 :             return mpViewInformation3D->getViewInformationSequence();
     578                 :            :         }
     579                 :            : 
     580                 :       3787 :         const uno::Sequence< beans::PropertyValue >& ViewInformation3D::getExtendedInformationSequence() const
     581                 :            :         {
     582                 :       3787 :             return mpViewInformation3D->getExtendedInformationSequence();
     583                 :            :         }
     584                 :            :     } // end of namespace geometry
     585                 :            : } // end of namespace drawinglayer
     586                 :            : 
     587                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10