LCOV - code coverage report
Current view: top level - include/drawinglayer/primitive2d - sceneprimitive2d.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 6 100.0 %
Date: 2015-06-13 12:38:46 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SCENEPRIMITIVE2D_HXX
      21             : #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SCENEPRIMITIVE2D_HXX
      22             : 
      23             : #include <drawinglayer/drawinglayerdllapi.h>
      24             : 
      25             : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
      26             : #include <drawinglayer/primitive3d/baseprimitive3d.hxx>
      27             : #include <drawinglayer/geometry/viewinformation3d.hxx>
      28             : #include <basegfx/matrix/b2dhommatrix.hxx>
      29             : #include <vcl/bitmapex.hxx>
      30             : #include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
      31             : #include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
      32             : #include <drawinglayer/attribute/sdrlightattribute3d.hxx>
      33             : 
      34             : 
      35             : 
      36             : namespace drawinglayer
      37             : {
      38             :     namespace primitive2d
      39             :     {
      40             :         /** ScenePrimitive2D class
      41             : 
      42             :             This primitive defines a 3D scene as a 2D primitive and is the anchor point
      43             :             for a 3D visualisation. The decomposition is view-dependent and will try to
      44             :             re-use already rendered 3D content.
      45             : 
      46             :             The rendering is done using the default-3D renderer from basegfx which supports
      47             :             AntiAliasing.
      48             : 
      49             :             The 2D primitive's geometric range is defined completely by the
      50             :             ObjectTransformation combined with evtl. 2D shadows from the 3D objects. The
      51             :             shadows of 3D objects are 2D polygons, projected with the 3D transformation.
      52             : 
      53             :             This is the class a renderer may process directly when he wants to implement
      54             :             an own (e.g. system-specific) 3D renderer.
      55             :          */
      56          48 :         class DRAWINGLAYER_DLLPUBLIC ScenePrimitive2D : public BufferedDecompositionPrimitive2D
      57             :         {
      58             :         private:
      59             :             /// the 3D geometry definition
      60             :             primitive3d::Primitive3DSequence                    mxChildren3D;
      61             : 
      62             :             /// 3D scene attribute set
      63             :             attribute::SdrSceneAttribute                        maSdrSceneAttribute;
      64             : 
      65             :             /// lighting attribute set
      66             :             attribute::SdrLightingAttribute                     maSdrLightingAttribute;
      67             : 
      68             :             /// object transformation for scene for 2D definition
      69             :             basegfx::B2DHomMatrix                               maObjectTransformation;
      70             : 
      71             :             /// scene transformation set and object transformation
      72             :             geometry::ViewInformation3D                         maViewInformation3D;
      73             : 
      74             :             /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked)
      75             :             Primitive2DSequence                                 maShadowPrimitives;
      76             : 
      77             :             /// bitfield
      78             :             /** flag if given 3D geometry is already cheched for shadow definitions and 2d shadows
      79             :                 are created in maShadowPrimitives
      80             :              */
      81             :             bool                                                mbShadow3DChecked : 1;
      82             : 
      83             :             /// the last used NewDiscreteSize and NewUnitVisiblePart definitions for decomposition
      84             :             double                                              mfOldDiscreteSizeX;
      85             :             double                                              mfOldDiscreteSizeY;
      86             :             basegfx::B2DRange                                   maOldUnitVisiblePart;
      87             : 
      88             :             /** the last created BitmapEx, e.g. for fast HitTest. This does not really need
      89             :                 memory since BitmapEx is internally RefCounted
      90             :              */
      91             :             BitmapEx                                            maOldRenderedBitmap;
      92             : 
      93             :             /// private helpers
      94             :             bool impGetShadow3D(const geometry::ViewInformation2D& rViewInformation) const;
      95             :             void calculateDiscreteSizes(
      96             :                 const geometry::ViewInformation2D& rViewInformation,
      97             :                 basegfx::B2DRange& rDiscreteRange,
      98             :                 basegfx::B2DRange& rVisibleDiscreteRange,
      99             :                 basegfx::B2DRange& rUnitVisibleRange) const;
     100             : 
     101             :         protected:
     102             :             /// local decomposition.
     103             :             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
     104             : 
     105             :         public:
     106             :             /// public helpers
     107             :             /** Geometry extractor. Shadow will be added as in create2DDecomposition, but
     108             :                 the 3D content is not converted to a bitmap visualisation but to projected 2D gemetry. This
     109             :                 helper is useful e.g. for Contour extraction or HitTests.
     110             :               */
     111             :             Primitive2DSequence getGeometry2D() const;
     112             :             Primitive2DSequence getShadow2D(const geometry::ViewInformation2D& rViewInformation) const;
     113             : 
     114             :             /** Fast HitTest which uses the last buffered BitmapEx from the last
     115             :                 rendered area if available. The return value describes if the check
     116             :                 could be done with the current information, so do NOT use o_rResult
     117             :                 when it returns false. o_rResult will be changed on return true and
     118             :                 then contains a definitive answer if content of this scene is hit or
     119             :                 not. On return false, it is normally necessary to use the geometric
     120             :                 HitTest (see CutFindProcessor usages). The given HitPoint
     121             :                 has to be in logic coordinates in scene's ObjectCoordinateSystem.
     122             :              */
     123             :             bool tryToCheckLastVisualisationDirectHit(const basegfx::B2DPoint& rLogicHitPoint, bool& o_rResult) const;
     124             : 
     125             :             /// constructor
     126             :             ScenePrimitive2D(
     127             :                 const primitive3d::Primitive3DSequence& rxChildren3D,
     128             :                 const attribute::SdrSceneAttribute& rSdrSceneAttribute,
     129             :                 const attribute::SdrLightingAttribute& rSdrLightingAttribute,
     130             :                 const basegfx::B2DHomMatrix& rObjectTransformation,
     131             :                 const geometry::ViewInformation3D& rViewInformation3D);
     132             : 
     133             :             /// data read access
     134         116 :             const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; }
     135          86 :             const attribute::SdrSceneAttribute& getSdrSceneAttribute() const { return maSdrSceneAttribute; }
     136          71 :             const attribute::SdrLightingAttribute& getSdrLightingAttribute() const { return maSdrLightingAttribute; }
     137         218 :             const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; }
     138         101 :             const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; }
     139             : 
     140             :             /// compare operator
     141             :             virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
     142             : 
     143             :             /// get range
     144             :             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
     145             : 
     146             :             /// provide unique ID
     147             :             DeclPrimitive2DIDBlock()
     148             : 
     149             :             /// get local decomposition. Override since this decomposition is view-dependent
     150             :             virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
     151             :         };
     152             :     } // end of namespace primitive2d
     153             : } // end of namespace drawinglayer
     154             : 
     155             : 
     156             : 
     157             : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SCENEPRIMITIVE2D_HXX
     158             : 
     159             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11