LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofe3dscene.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 153 160 95.6 %
Date: 2012-08-25 Functions: 16 17 94.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 160 302 53.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svx/sdr/contact/viewcontactofe3dscene.hxx>
      30                 :            : #include <svx/polysc3d.hxx>
      31                 :            : #include <svx/sdr/contact/displayinfo.hxx>
      32                 :            : #include <svx/sdr/contact/viewobjectcontact.hxx>
      33                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      34                 :            : #include <basegfx/color/bcolor.hxx>
      35                 :            : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      36                 :            : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
      37                 :            : #include <svx/sdr/contact/viewobjectcontactofe3dscene.hxx>
      38                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      39                 :            : #include <basegfx/range/b3drange.hxx>
      40                 :            : #include <drawinglayer/primitive3d/baseprimitive3d.hxx>
      41                 :            : #include <svx/sdr/contact/viewcontactofe3d.hxx>
      42                 :            : #include <drawinglayer/primitive2d/sceneprimitive2d.hxx>
      43                 :            : #include <drawinglayer/primitive3d/transformprimitive3d.hxx>
      44                 :            : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
      45                 :            : 
      46                 :            : //////////////////////////////////////////////////////////////////////////////
      47                 :            : 
      48                 :            : using namespace com::sun::star;
      49                 :            : 
      50                 :            : //////////////////////////////////////////////////////////////////////////////
      51                 :            : 
      52                 :            : namespace
      53                 :            : {
      54                 :            :     // pActiveVC is only true if ghosted is still activated and maybe needs to be switched off in this path
      55                 :      20387 :     void createSubPrimitive3DVector(
      56                 :            :         const sdr::contact::ViewContact& rCandidate,
      57                 :            :         drawinglayer::primitive3d::Primitive3DSequence& o_rAllTarget,
      58                 :            :         drawinglayer::primitive3d::Primitive3DSequence* o_pVisibleTarget,
      59                 :            :         const SetOfByte* pVisibleLayerSet,
      60                 :            :         const bool bTestSelectedVisibility)
      61                 :            :     {
      62         [ -  + ]:      20387 :         const sdr::contact::ViewContactOfE3dScene* pViewContactOfE3dScene = dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(&rCandidate);
      63                 :            : 
      64         [ +  + ]:      20387 :         if(pViewContactOfE3dScene)
      65                 :            :         {
      66                 :      10400 :             const sal_uInt32 nChildrenCount(rCandidate.GetObjectCount());
      67                 :            : 
      68         [ +  + ]:      10400 :             if(nChildrenCount)
      69                 :            :             {
      70                 :            :                 // provide new collection sequences
      71         [ +  - ]:       5330 :                 drawinglayer::primitive3d::Primitive3DSequence aNewAllTarget;
      72         [ +  - ]:       5330 :                 drawinglayer::primitive3d::Primitive3DSequence aNewVisibleTarget;
      73                 :            : 
      74                 :            :                 // add children recursively
      75         [ +  + ]:      25056 :                 for(sal_uInt32 a(0L); a < nChildrenCount; a++)
      76                 :            :                 {
      77                 :            :                     createSubPrimitive3DVector(
      78         [ +  - ]:      19726 :                         rCandidate.GetViewContact(a),
      79                 :            :                         aNewAllTarget,
      80                 :            :                         o_pVisibleTarget ? &aNewVisibleTarget : 0,
      81                 :            :                         pVisibleLayerSet,
      82 [ +  + ][ +  - ]:      39452 :                         bTestSelectedVisibility);
      83                 :            :                 }
      84                 :            : 
      85                 :            :                 // create transform primitive for the created content combining content and transformtion
      86                 :            :                 const drawinglayer::primitive3d::Primitive3DReference xReference(new drawinglayer::primitive3d::TransformPrimitive3D(
      87                 :       5330 :                     pViewContactOfE3dScene->GetE3dScene().GetTransform(),
      88 [ +  - ][ +  - ]:       5330 :                     aNewAllTarget));
         [ +  - ][ +  - ]
      89                 :            : 
      90                 :            :                 // add created content to all target
      91         [ +  - ]:       5330 :                 drawinglayer::primitive3d::appendPrimitive3DReferenceToPrimitive3DSequence(o_rAllTarget, xReference);
      92                 :            : 
      93                 :            :                 // add created content to visibiel target if exists
      94         [ +  + ]:       5330 :                 if(o_pVisibleTarget)
      95                 :            :                 {
      96         [ +  - ]:        174 :                     drawinglayer::primitive3d::appendPrimitive3DReferenceToPrimitive3DSequence(*o_pVisibleTarget, xReference);
      97 [ +  - ][ +  - ]:       5330 :                 }
      98                 :            :             }
      99                 :            :         }
     100                 :            :         else
     101                 :            :         {
     102                 :            :             // access view independent representation of rCandidate
     103         [ -  + ]:       9987 :             const sdr::contact::ViewContactOfE3d* pViewContactOfE3d = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&rCandidate);
     104                 :            : 
     105         [ +  - ]:       9987 :             if(pViewContactOfE3d)
     106                 :            :             {
     107         [ +  - ]:       9987 :                 drawinglayer::primitive3d::Primitive3DSequence xPrimitive3DSeq(pViewContactOfE3d->getViewIndependentPrimitive3DSequence());
     108                 :            : 
     109         [ +  - ]:       9987 :                 if(xPrimitive3DSeq.hasElements())
     110                 :            :                 {
     111                 :            :                     // add to all target vector
     112         [ +  - ]:       9987 :                     drawinglayer::primitive3d::appendPrimitive3DSequenceToPrimitive3DSequence(o_rAllTarget, xPrimitive3DSeq);
     113                 :            : 
     114         [ +  + ]:       9987 :                     if(o_pVisibleTarget)
     115                 :            :                     {
     116                 :            :                         // test visibility. Primitive is visible when both tests are true (AND)
     117                 :        537 :                         bool bVisible(true);
     118                 :            : 
     119         [ +  - ]:        537 :                         if(pVisibleLayerSet)
     120                 :            :                         {
     121                 :            :                             // test layer visibility
     122                 :        537 :                             const E3dObject& rE3dObject = pViewContactOfE3d->GetE3dObject();
     123         [ +  - ]:        537 :                             const SdrLayerID aLayerID(rE3dObject.GetLayer());
     124                 :            : 
     125                 :        537 :                             bVisible = pVisibleLayerSet->IsSet(aLayerID);
     126                 :            :                         }
     127                 :            : 
     128 [ +  - ][ -  + ]:        537 :                         if(bVisible && bTestSelectedVisibility)
     129                 :            :                         {
     130                 :            :                             // test selected visibility (see 3D View's DrawMarkedObj implementation)
     131                 :          0 :                             const E3dObject& rE3dObject = pViewContactOfE3d->GetE3dObject();
     132                 :            : 
     133                 :          0 :                             bVisible = rE3dObject.GetSelected();
     134                 :            :                         }
     135                 :            : 
     136 [ +  - ][ +  - ]:        537 :                         if(bVisible && o_pVisibleTarget)
     137                 :            :                         {
     138                 :            :                             // add to visible target vector
     139         [ +  - ]:        537 :                             drawinglayer::primitive3d::appendPrimitive3DSequenceToPrimitive3DSequence(*o_pVisibleTarget, xPrimitive3DSeq);
     140                 :            :                         }
     141                 :            :                     }
     142         [ +  - ]:       9987 :                 }
     143                 :            :             }
     144                 :            :         }
     145                 :      20387 :     }
     146                 :            : } // end of anonymous namespace
     147                 :            : 
     148                 :            : //////////////////////////////////////////////////////////////////////////////
     149                 :            : 
     150                 :            : namespace sdr
     151                 :            : {
     152                 :            :     namespace contact
     153                 :            :     {
     154                 :            :         // Create a Object-Specific ViewObjectContact, set ViewContact and
     155                 :            :         // ObjectContact. Always needs to return something.
     156                 :        335 :         ViewObjectContact& ViewContactOfE3dScene::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
     157                 :            :         {
     158         [ +  - ]:        335 :             ViewObjectContact* pRetval = new ViewObjectContactOfE3dScene(rObjectContact, *this);
     159                 :            :             DBG_ASSERT(pRetval, "ViewContactOfE3dScene::CreateObjectSpecificViewObjectContact() failed (!)");
     160                 :            : 
     161                 :        335 :             return *pRetval;
     162                 :            :         }
     163                 :            : 
     164                 :        736 :         ViewContactOfE3dScene::ViewContactOfE3dScene(E3dScene& rScene)
     165                 :            :         :   ViewContactOfSdrObj(rScene),
     166                 :            :             maViewInformation3D(),
     167                 :            :             maObjectTransformation(),
     168                 :            :             maSdrSceneAttribute(),
     169 [ +  - ][ +  - ]:        736 :             maSdrLightingAttribute()
         [ +  - ][ +  - ]
     170                 :            :         {
     171                 :        736 :         }
     172                 :            : 
     173                 :        555 :         void ViewContactOfE3dScene::createViewInformation3D(const basegfx::B3DRange& rContentRange)
     174                 :            :         {
     175         [ +  - ]:        555 :             basegfx::B3DHomMatrix aTransformation;
     176         [ +  - ]:        555 :             basegfx::B3DHomMatrix aOrientation;
     177         [ +  - ]:        555 :             basegfx::B3DHomMatrix aProjection;
     178         [ +  - ]:        555 :             basegfx::B3DHomMatrix aDeviceToView;
     179                 :            : 
     180                 :            :             // create transformation (scene as group's transformation)
     181                 :            :             // For historical reasons, the outmost scene's transformation is handles as part of the
     182                 :            :             // view transformation. This means that the BoundRect of the contained 3D Objects is
     183                 :            :             // without that transformation and makes it necessary to NOT add the first scene to the
     184                 :            :             // Primitive3DSequence of contained objects.
     185                 :            :             {
     186 [ +  - ][ +  - ]:        555 :                 aTransformation = GetE3dScene().GetTransform();
     187                 :            :             }
     188                 :            : 
     189                 :            :             // create orientation (world to camera coordinate system)
     190                 :            :             {
     191                 :            :                 // calculate orientation from VRP, VPN and VUV
     192                 :        555 :                 const B3dCamera& rSceneCamera = GetE3dScene().GetCameraSet();
     193                 :        555 :                 const basegfx::B3DPoint aVRP(rSceneCamera.GetVRP());
     194                 :        555 :                 const basegfx::B3DVector aVPN(rSceneCamera.GetVRP());
     195                 :        555 :                 const basegfx::B3DVector aVUV(rSceneCamera.GetVUV());
     196                 :            : 
     197         [ +  - ]:        555 :                 aOrientation.orientation(aVRP, aVPN, aVUV);
     198                 :            :             }
     199                 :            : 
     200                 :            :             // create projection (camera coordinate system to relative 2d where X,Y and Z are [0.0 .. 1.0])
     201                 :            :             {
     202         [ +  - ]:        555 :                 const basegfx::B3DHomMatrix aWorldToCamera(aOrientation * aTransformation);
     203                 :        555 :                 basegfx::B3DRange aCameraRange(rContentRange);
     204         [ +  - ]:        555 :                 aCameraRange.transform(aWorldToCamera);
     205                 :            : 
     206                 :            :                 // remember Z-Values, but change orientation
     207         [ +  - ]:        555 :                 const double fMinZ(-aCameraRange.getMaxZ());
     208         [ +  - ]:        555 :                 const double fMaxZ(-aCameraRange.getMinZ());
     209                 :            : 
     210                 :            :                 // construct temorary matrix from world to device. Use unit values here to measure expansion
     211         [ +  - ]:        555 :                 basegfx::B3DHomMatrix aWorldToDevice(aWorldToCamera);
     212         [ +  - ]:        555 :                 const drawinglayer::attribute::SdrSceneAttribute& rSdrSceneAttribute = getSdrSceneAttribute();
     213                 :            : 
     214 [ +  - ][ +  + ]:        555 :                 if(::com::sun::star::drawing::ProjectionMode_PERSPECTIVE == rSdrSceneAttribute.getProjectionMode())
     215                 :            :                 {
     216         [ +  - ]:         75 :                     aWorldToDevice.frustum(-1.0, 1.0, -1.0, 1.0, fMinZ, fMaxZ);
     217                 :            :                 }
     218                 :            :                 else
     219                 :            :                 {
     220         [ +  - ]:        480 :                     aWorldToDevice.ortho(-1.0, 1.0, -1.0, 1.0, fMinZ, fMaxZ);
     221                 :            :                 }
     222                 :            : 
     223                 :            :                 // create B3DRange in device. This will create the real used ranges
     224                 :            :                 // in camera space. Do not use the Z-Values, though.
     225                 :        555 :                 basegfx::B3DRange aDeviceRange(rContentRange);
     226         [ +  - ]:        555 :                 aDeviceRange.transform(aWorldToDevice);
     227                 :            : 
     228                 :            :                 // set projection
     229 [ +  - ][ +  + ]:        555 :                 if(::com::sun::star::drawing::ProjectionMode_PERSPECTIVE == rSdrSceneAttribute.getProjectionMode())
     230                 :            :                 {
     231                 :            :                     aProjection.frustum(
     232                 :            :                         aDeviceRange.getMinX(), aDeviceRange.getMaxX(),
     233                 :            :                         aDeviceRange.getMinY(), aDeviceRange.getMaxY(),
     234 [ +  - ][ +  - ]:         75 :                         fMinZ, fMaxZ);
         [ +  - ][ +  - ]
                 [ +  - ]
     235                 :            :                 }
     236                 :            :                 else
     237                 :            :                 {
     238                 :            :                     aProjection.ortho(
     239                 :            :                         aDeviceRange.getMinX(), aDeviceRange.getMaxX(),
     240                 :            :                         aDeviceRange.getMinY(), aDeviceRange.getMaxY(),
     241 [ +  - ][ +  - ]:        480 :                         fMinZ, fMaxZ);
         [ +  - ][ +  - ]
                 [ +  - ]
     242 [ +  - ][ +  - ]:        555 :                 }
     243                 :            :             }
     244                 :            : 
     245                 :            :             // create device to view transform
     246                 :            :             {
     247                 :            :                 // create standard deviceToView projection for geometry
     248                 :            :                 // input is [-1.0 .. 1.0] in X,Y and Z. bring to [0.0 .. 1.0]. Also
     249                 :            :                 // necessary to flip Y due to screen orientation
     250                 :            :                 // Z is not needed, but will also be brought to [0.0 .. 1.0]
     251         [ +  - ]:        555 :                 aDeviceToView.scale(0.5, -0.5, 0.5);
     252         [ +  - ]:        555 :                 aDeviceToView.translate(0.5, 0.5, 0.5);
     253                 :            :             }
     254                 :            : 
     255         [ +  - ]:        555 :             const uno::Sequence< beans::PropertyValue > aEmptyProperties;
     256                 :            :             maViewInformation3D = drawinglayer::geometry::ViewInformation3D(
     257                 :            :                 aTransformation, aOrientation, aProjection,
     258 [ +  - ][ +  - ]:        555 :                 aDeviceToView, 0.0, aEmptyProperties);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     259                 :        555 :         }
     260                 :            : 
     261                 :        555 :         void ViewContactOfE3dScene::createObjectTransformation()
     262                 :            :         {
     263                 :            :             // create 2d Object Transformation from relative point in 2d scene to world
     264                 :        555 :             const Rectangle& rRectangle = GetE3dScene().GetSnapRect();
     265                 :            : 
     266                 :        555 :             maObjectTransformation.set(0, 0, rRectangle.getWidth());
     267                 :        555 :             maObjectTransformation.set(1, 1, rRectangle.getHeight());
     268                 :        555 :             maObjectTransformation.set(0, 2, rRectangle.Left());
     269                 :        555 :             maObjectTransformation.set(1, 2, rRectangle.Top());
     270                 :        555 :         }
     271                 :            : 
     272                 :        555 :         void ViewContactOfE3dScene::createSdrSceneAttribute()
     273                 :            :         {
     274                 :        555 :             const SfxItemSet& rItemSet = GetE3dScene().GetMergedItemSet();
     275         [ +  - ]:        555 :             maSdrSceneAttribute = drawinglayer::primitive2d::createNewSdrSceneAttribute(rItemSet);
     276                 :        555 :         }
     277                 :            : 
     278                 :          9 :         void ViewContactOfE3dScene::createSdrLightingAttribute()
     279                 :            :         {
     280                 :          9 :             const SfxItemSet& rItemSet = GetE3dScene().GetMergedItemSet();
     281         [ +  - ]:          9 :             maSdrLightingAttribute = drawinglayer::primitive2d::createNewSdrLightingAttribute(rItemSet);
     282                 :          9 :         }
     283                 :            : 
     284                 :         15 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3dScene::createScenePrimitive2DSequence(
     285                 :            :             const SetOfByte* pLayerVisibility) const
     286                 :            :         {
     287                 :         15 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
     288         [ +  - ]:         15 :             const sal_uInt32 nChildrenCount(GetObjectCount());
     289                 :            : 
     290         [ +  - ]:         15 :             if(nChildrenCount)
     291                 :            :             {
     292                 :            :                 // create 3d scene primitive with visible content tested against rLayerVisibility
     293         [ +  - ]:         15 :                 drawinglayer::primitive3d::Primitive3DSequence aAllSequence;
     294         [ +  - ]:         15 :                 drawinglayer::primitive3d::Primitive3DSequence aVisibleSequence;
     295                 :         15 :                 const bool bTestLayerVisibility(0 != pLayerVisibility);
     296                 :         15 :                 const bool bTestSelectedVisibility(GetE3dScene().GetDrawOnlySelected());
     297 [ #  # ][ -  + ]:         15 :                 const bool bTestVisibility(bTestLayerVisibility || bTestSelectedVisibility);
     298                 :            : 
     299                 :            :                 // add children recursively. Do NOT start with (*this), this would create
     300                 :            :                 // a 3D transformPrimitive for the start scene. While this is theoretically not
     301                 :            :                 // a bad thing, for historical reasons the transformation of the outmost scene
     302                 :            :                 // is seen as part of the ViewTransformation (see text in createViewInformation3D)
     303         [ +  + ]:         30 :                 for(sal_uInt32 a(0L); a < nChildrenCount; a++)
     304                 :            :                 {
     305                 :            :                     createSubPrimitive3DVector(
     306         [ +  - ]:         15 :                         GetViewContact(a),
     307                 :            :                         aAllSequence,
     308                 :            :                         bTestLayerVisibility ? &aVisibleSequence : 0,
     309                 :            :                         bTestLayerVisibility ? pLayerVisibility : 0,
     310 [ +  - ][ +  - ]:         30 :                         bTestSelectedVisibility);
                 [ +  - ]
     311                 :            :                 }
     312                 :            : 
     313         [ +  - ]:         15 :                 const sal_uInt32 nAllSize(aAllSequence.hasElements() ? aAllSequence.getLength() : 0);
     314         [ +  - ]:         15 :                 const sal_uInt32 nVisibleSize(aVisibleSequence.hasElements() ? aVisibleSequence.getLength() : 0);
     315                 :            : 
     316 [ +  - ][ -  + ]:         15 :                 if((bTestVisibility && nVisibleSize) || nAllSize)
                 [ #  # ]
     317                 :            :                 {
     318                 :            :                     // for getting the 3D range using getB3DRangeFromPrimitive3DSequence a ViewInformation3D
     319                 :            :                     // needs to be given for evtl. decompositions. At the same time createViewInformation3D
     320                 :            :                     // currently is based on creating the target-ViewInformation3D using a given range. To
     321                 :            :                     // get the true range, use a neutral ViewInformation3D here. This leaves all matrices
     322                 :            :                     // on identity and the time on 0.0.
     323         [ +  - ]:         15 :                     const uno::Sequence< beans::PropertyValue > aEmptyProperties;
     324         [ +  - ]:         15 :                     const drawinglayer::geometry::ViewInformation3D aNeutralViewInformation3D(aEmptyProperties);
     325                 :            :                     const basegfx::B3DRange aContentRange(
     326         [ +  - ]:         15 :                         drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(aAllSequence, aNeutralViewInformation3D));
     327                 :            : 
     328                 :            :                     // create 2d primitive 3dscene with generated sub-list from collector
     329                 :            :                     const drawinglayer::primitive2d::Primitive2DReference xReference(
     330                 :            :                         new drawinglayer::primitive2d::ScenePrimitive2D(
     331                 :            :                             bTestVisibility ? aVisibleSequence : aAllSequence,
     332                 :            :                             getSdrSceneAttribute(),
     333                 :            :                             getSdrLightingAttribute(),
     334                 :            :                             getObjectTransformation(),
     335 [ +  - ][ +  - ]:         15 :                             getViewInformation3D(aContentRange)));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     336                 :            : 
     337 [ +  - ][ +  - ]:         15 :                     xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
         [ +  - ][ +  - ]
                 [ +  - ]
     338 [ +  - ][ +  - ]:         15 :                 }
     339                 :            :             }
     340                 :            : 
     341                 :            :             // always append an invisible outline for the cases where no visible content exists
     342                 :            :             drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
     343                 :            :                 drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
     344 [ +  - ][ +  - ]:         15 :                     false, getObjectTransformation()));
                 [ +  - ]
     345                 :            : 
     346                 :         15 :             return xRetval;
     347                 :            :         }
     348                 :            : 
     349                 :          0 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3dScene::createViewIndependentPrimitive2DSequence() const
     350                 :            :         {
     351                 :          0 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
     352                 :            : 
     353 [ #  # ][ #  # ]:          0 :             if(GetObjectCount())
     354                 :            :             {
     355                 :            :                 // create a default ScenePrimitive2D (without visibility test of members)
     356 [ #  # ][ #  # ]:          0 :                 xRetval = createScenePrimitive2DSequence(0);
                 [ #  # ]
     357                 :            :             }
     358                 :            : 
     359                 :          0 :             return xRetval;
     360                 :            :         }
     361                 :            : 
     362                 :       3167 :         void ViewContactOfE3dScene::ActionChanged()
     363                 :            :         {
     364                 :            :             // call parent
     365                 :       3167 :             ViewContactOfSdrObj::ActionChanged();
     366                 :            : 
     367                 :            :             // mark locally cached values as invalid
     368         [ +  - ]:       3167 :             maViewInformation3D = drawinglayer::geometry::ViewInformation3D();
     369                 :       3167 :             maObjectTransformation.identity();
     370         [ +  - ]:       3167 :             maSdrSceneAttribute = drawinglayer::attribute::SdrSceneAttribute();
     371         [ +  - ]:       3167 :             maSdrLightingAttribute = drawinglayer::attribute::SdrLightingAttribute();
     372                 :       3167 :         }
     373                 :            : 
     374                 :       3404 :         const drawinglayer::geometry::ViewInformation3D& ViewContactOfE3dScene::getViewInformation3D() const
     375                 :            :         {
     376         [ +  + ]:       3404 :             if(maViewInformation3D.isDefault())
     377                 :            :             {
     378                 :            :                 // this version will create the content range on demand locally and thus is less
     379                 :            :                 // performant than the other one. Since the information is buffered the planned
     380                 :            :                 // behaviour is that the version with the given range is used initially.
     381         [ +  - ]:        496 :                 basegfx::B3DRange aContentRange(getAllContentRange3D());
     382                 :            : 
     383 [ +  - ][ +  + ]:        496 :                 if(aContentRange.isEmpty())
     384                 :            :                 {
     385                 :            :                     // empty scene, no 3d action should be necessary. Prepare some
     386                 :            :                     // fallback size
     387                 :            :                     OSL_FAIL("No need to get ViewInformation3D from an empty scene (!)");
     388         [ +  - ]:         14 :                     aContentRange.expand(basegfx::B3DPoint(-100.0, -100.0, -100.0));
     389         [ +  - ]:         14 :                     aContentRange.expand(basegfx::B3DPoint( 100.0,  100.0,  100.0));
     390                 :            :                 }
     391                 :            : 
     392         [ +  - ]:        496 :                 const_cast < ViewContactOfE3dScene* >(this)->createViewInformation3D(aContentRange);
     393                 :            :             }
     394                 :            : 
     395                 :       3404 :             return maViewInformation3D;
     396                 :            :         }
     397                 :            : 
     398                 :         90 :         const drawinglayer::geometry::ViewInformation3D& ViewContactOfE3dScene::getViewInformation3D(const basegfx::B3DRange& rContentRange) const
     399                 :            :         {
     400         [ +  + ]:         90 :             if(maViewInformation3D.isDefault())
     401                 :            :             {
     402                 :         59 :                 const_cast < ViewContactOfE3dScene* >(this)->createViewInformation3D(rContentRange);
     403                 :            :             }
     404                 :            : 
     405                 :         90 :             return maViewInformation3D;
     406                 :            :         }
     407                 :            : 
     408                 :       3509 :         const basegfx::B2DHomMatrix& ViewContactOfE3dScene::getObjectTransformation() const
     409                 :            :         {
     410         [ +  + ]:       3509 :             if(maObjectTransformation.isIdentity())
     411                 :            :             {
     412                 :        555 :                 const_cast < ViewContactOfE3dScene* >(this)->createObjectTransformation();
     413                 :            :             }
     414                 :            : 
     415                 :       3509 :             return maObjectTransformation;
     416                 :            :         }
     417                 :            : 
     418                 :        570 :         const drawinglayer::attribute::SdrSceneAttribute& ViewContactOfE3dScene::getSdrSceneAttribute() const
     419                 :            :         {
     420         [ +  + ]:        570 :             if(maSdrSceneAttribute.isDefault())
     421                 :            :             {
     422                 :        555 :                 const_cast < ViewContactOfE3dScene* >(this)->createSdrSceneAttribute();
     423                 :            :             }
     424                 :            : 
     425                 :        570 :             return maSdrSceneAttribute;
     426                 :            :         }
     427                 :            : 
     428                 :         15 :         const drawinglayer::attribute::SdrLightingAttribute& ViewContactOfE3dScene::getSdrLightingAttribute() const
     429                 :            :         {
     430         [ +  + ]:         15 :             if(maSdrLightingAttribute.isDefault())
     431                 :            :             {
     432                 :          9 :                 const_cast < ViewContactOfE3dScene* >(this)->createSdrLightingAttribute();
     433                 :            :             }
     434                 :            : 
     435                 :         15 :             return maSdrLightingAttribute;
     436                 :            :         }
     437                 :            : 
     438                 :        646 :         drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dScene::getAllPrimitive3DSequence() const
     439                 :            :         {
     440                 :        646 :             drawinglayer::primitive3d::Primitive3DSequence aAllPrimitive3DSequence;
     441         [ +  - ]:        646 :             const sal_uInt32 nChildrenCount(GetObjectCount());
     442                 :            : 
     443                 :            :             // add children recursively. Do NOT start with (*this), this would create
     444                 :            :             // a 3D transformPrimitive for the start scene. While this is theoretically not
     445                 :            :             // a bad thing, for historical reasons the transformation of the outmost scene
     446                 :            :             // is seen as part of the ViewTransformation (see text in createViewInformation3D)
     447         [ +  + ]:       1292 :             for(sal_uInt32 a(0L); a < nChildrenCount; a++)
     448                 :            :             {
     449 [ +  - ][ +  - ]:        646 :                 createSubPrimitive3DVector(GetViewContact(a), aAllPrimitive3DSequence, 0, 0, false);
     450                 :            :             }
     451                 :            : 
     452                 :        646 :             return aAllPrimitive3DSequence;
     453                 :            :         }
     454                 :            : 
     455                 :        646 :         basegfx::B3DRange ViewContactOfE3dScene::getAllContentRange3D() const
     456                 :            :         {
     457         [ +  - ]:        646 :             const drawinglayer::primitive3d::Primitive3DSequence xAllSequence(getAllPrimitive3DSequence());
     458         [ +  - ]:        646 :             basegfx::B3DRange aAllContentRange3D;
     459                 :            : 
     460         [ +  - ]:        646 :             if(xAllSequence.hasElements())
     461                 :            :             {
     462                 :            :                 // for getting the 3D range using getB3DRangeFromPrimitive3DSequence a ViewInformation3D
     463                 :            :                 // needs to be given for evtl. decompositions. Use a neutral ViewInformation3D here. This
     464                 :            :                 // leaves all matrices on identity and the time on 0.0.
     465         [ +  - ]:        646 :                 const uno::Sequence< beans::PropertyValue > aEmptyProperties;
     466         [ +  - ]:        646 :                 const drawinglayer::geometry::ViewInformation3D aNeutralViewInformation3D(aEmptyProperties);
     467                 :            : 
     468 [ +  - ][ +  - ]:        646 :                 aAllContentRange3D = drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(xAllSequence, aNeutralViewInformation3D);
                 [ +  - ]
     469                 :            :             }
     470                 :            : 
     471         [ +  - ]:        646 :             return aAllContentRange3D;
     472                 :            :         }
     473                 :            :     } // end of namespace contact
     474                 :            : } // end of namespace sdr
     475                 :            : 
     476                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10