LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - embedded3dprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 46 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 6 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/primitive2d/embedded3dprimitive2d.hxx>
      21             : #include <basegfx/polygon/b2dpolygon.hxx>
      22             : #include <basegfx/polygon/b2dpolygontools.hxx>
      23             : #include <basegfx/color/bcolor.hxx>
      24             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      25             : #include <basegfx/tools/canvastools.hxx>
      26             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      27             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      28             : #include <drawinglayer/geometry/viewinformation3d.hxx>
      29             : #include <drawinglayer/processor3d/shadow3dextractor.hxx>
      30             : 
      31             : 
      32             : 
      33             : using namespace com::sun::star;
      34             : 
      35             : 
      36             : 
      37             : namespace drawinglayer
      38             : {
      39             :     namespace primitive2d
      40             :     {
      41           0 :         bool Embedded3DPrimitive2D::impGetShadow3D(const geometry::ViewInformation2D& /*rViewInformation*/) const
      42             :         {
      43           0 :             osl::MutexGuard aGuard( m_aMutex );
      44             : 
      45             :             // create on demand
      46           0 :             if(!mbShadow3DChecked && getChildren3D().hasElements())
      47             :             {
      48             :                 // create shadow extraction processor
      49             :                 processor3d::Shadow3DExtractingProcessor aShadowProcessor(
      50           0 :                     getViewInformation3D(),
      51           0 :                     getObjectTransformation(),
      52           0 :                     getLightNormal(),
      53             :                     getShadowSlant(),
      54           0 :                     getScene3DRange());
      55             : 
      56             :                 // process local primitives
      57           0 :                 aShadowProcessor.process(getChildren3D());
      58             : 
      59             :                 // fetch result and set checked flag
      60           0 :                 const_cast< Embedded3DPrimitive2D* >(this)->maShadowPrimitives = aShadowProcessor.getPrimitive2DSequence();
      61           0 :                 const_cast< Embedded3DPrimitive2D* >(this)->mbShadow3DChecked = true;
      62             :             }
      63             : 
      64             :             // return if there are shadow primitives
      65           0 :             return maShadowPrimitives.hasElements();
      66             :         }
      67             : 
      68           0 :         Primitive2DSequence Embedded3DPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      69             :         {
      70             :             // use info to create a yellow 2d rectangle, similar to empty 3d scenes and/or groups
      71           0 :             const basegfx::B2DRange aLocal2DRange(getB2DRange(rViewInformation));
      72           0 :             const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aLocal2DRange));
      73           0 :             const basegfx::BColor aYellow(1.0, 1.0, 0.0);
      74           0 :             const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(aOutline, aYellow));
      75             : 
      76           0 :             return Primitive2DSequence(&xRef, 1L);
      77             :         }
      78             : 
      79           0 :         Embedded3DPrimitive2D::Embedded3DPrimitive2D(
      80             :             const primitive3d::Primitive3DSequence& rxChildren3D,
      81             :             const basegfx::B2DHomMatrix& rObjectTransformation,
      82             :             const geometry::ViewInformation3D& rViewInformation3D,
      83             :             const basegfx::B3DVector& rLightNormal,
      84             :             double fShadowSlant,
      85             :             const basegfx::B3DRange& rScene3DRange)
      86             :         :   BufferedDecompositionPrimitive2D(),
      87             :             mxChildren3D(rxChildren3D),
      88             :             maObjectTransformation(rObjectTransformation),
      89             :             maViewInformation3D(rViewInformation3D),
      90             :             maLightNormal(rLightNormal),
      91             :             mfShadowSlant(fShadowSlant),
      92             :             maScene3DRange(rScene3DRange),
      93             :             maShadowPrimitives(),
      94             :             maB2DRange(),
      95           0 :             mbShadow3DChecked(false)
      96             :         {
      97           0 :             maLightNormal.normalize();
      98           0 :         }
      99             : 
     100           0 :         bool Embedded3DPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     101             :         {
     102           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     103             :             {
     104           0 :                 const Embedded3DPrimitive2D& rCompare = static_cast< const Embedded3DPrimitive2D& >(rPrimitive);
     105             : 
     106           0 :                 return (primitive3d::arePrimitive3DSequencesEqual(getChildren3D(), rCompare.getChildren3D())
     107           0 :                     && getObjectTransformation() == rCompare.getObjectTransformation()
     108           0 :                     && getViewInformation3D() == rCompare.getViewInformation3D()
     109           0 :                     && getLightNormal() == rCompare.getLightNormal()
     110           0 :                     && getShadowSlant() == rCompare.getShadowSlant()
     111           0 :                     && getScene3DRange() == rCompare.getScene3DRange());
     112             :             }
     113             : 
     114           0 :             return false;
     115             :         }
     116             : 
     117           0 :         basegfx::B2DRange Embedded3DPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
     118             :         {
     119           0 :             if(maB2DRange.isEmpty())
     120             :             {
     121             :                 // use the 3d transformation stack to create a projection of the 3D range
     122           0 :                 basegfx::B3DRange a3DRange(primitive3d::getB3DRangeFromPrimitive3DSequence(getChildren3D(), getViewInformation3D()));
     123           0 :                 a3DRange.transform(getViewInformation3D().getObjectToView());
     124             : 
     125             :                 // create 2d range from projected 3d and transform with scene's object transformation
     126           0 :                 basegfx::B2DRange aNewRange;
     127           0 :                 aNewRange.expand(basegfx::B2DPoint(a3DRange.getMinX(), a3DRange.getMinY()));
     128           0 :                 aNewRange.expand(basegfx::B2DPoint(a3DRange.getMaxX(), a3DRange.getMaxY()));
     129           0 :                 aNewRange.transform(getObjectTransformation());
     130             : 
     131             :                 // cehck for 3D shadows and their 2D projections. If those exist, they need to be
     132             :                 // taken into account
     133           0 :                 if(impGetShadow3D(rViewInformation))
     134             :                 {
     135           0 :                     const basegfx::B2DRange aShadow2DRange(getB2DRangeFromPrimitive2DSequence(maShadowPrimitives, rViewInformation));
     136             : 
     137           0 :                     if(!aShadow2DRange.isEmpty())
     138             :                     {
     139           0 :                         aNewRange.expand(aShadow2DRange);
     140             :                     }
     141             :                 }
     142             : 
     143             :                 // assign to buffered value
     144           0 :                 const_cast< Embedded3DPrimitive2D* >(this)->maB2DRange = aNewRange;
     145             :             }
     146             : 
     147           0 :             return maB2DRange;
     148             :         }
     149             : 
     150             :         // provide unique ID
     151           0 :         ImplPrimitive2DIDBlock(Embedded3DPrimitive2D, PRIMITIVE2D_ID_EMBEDDED3DPRIMITIVE2D)
     152             : 
     153             :     } // end of namespace primitive2d
     154             : } // end of namespace drawinglayer
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11