1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EMBEDDED3DPRIMITIVE2D_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EMBEDDED3DPRIMITIVE2D_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 #include <drawinglayer/primitive3d/baseprimitive3d.hxx>
27 #include <drawinglayer/geometry/viewinformation3d.hxx>
28 #include <basegfx/matrix/b2dhommatrix.hxx>
31 // Embedded3DPrimitive2D class
33 namespace drawinglayer
37 /** Embedded3DPrimitive2D class
39 This is a helper primitive which allows embedding of single 3D
40 primitives to the 2D primitive logic. It will get the scene it's
41 involved and thus the 3D transformation. With this information it
42 is able to provide 2D range data for a 3D primitive.
44 This primitive will not be visualized and decomposes to a yellow
45 2D rectangle to visualize that this should never be visualized
47 class DRAWINGLAYER_DLLPUBLIC Embedded3DPrimitive2D
: public BufferedDecompositionPrimitive2D
50 /// the sequence of 3d primitives
51 primitive3d::Primitive3DSequence mxChildren3D
;
53 /// the 2D scene object transformation
54 basegfx::B2DHomMatrix maObjectTransformation
;
56 /// the 3D transformations
57 geometry::ViewInformation3D maViewInformation3D
;
59 /** if the embedded 3D primitives contain shadow, these parameters are needed
60 to extract the shadow which is a sequence od 2D primitives and may expand
61 the 2D range. Since every single 3D object in a scene may individually
62 have shadow or not, these values need to be provided and prepared. The shadow
63 distance itself (a 2D transformation) is part of the 3D shadow definition
65 basegfx::B3DVector maLightNormal
;
67 basegfx::B3DRange maScene3DRange
;
69 /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked)
70 Primitive2DSequence maShadowPrimitives
;
72 /// #i96669# add simple range buffering for this primitive
73 basegfx::B2DRange maB2DRange
;
76 /** flag if given 3D geometry is already cheched for shadow definitions and 2d shadows
77 are created in maShadowPrimitives
79 bool mbShadow3DChecked
: 1;
82 bool impGetShadow3D(const geometry::ViewInformation2D
& rViewInformation
) const;
85 /// local decomposition.
86 virtual Primitive2DSequence
create2DDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const SAL_OVERRIDE
;
90 Embedded3DPrimitive2D(
91 const primitive3d::Primitive3DSequence
& rxChildren3D
,
92 const basegfx::B2DHomMatrix
& rObjectTransformation
,
93 const geometry::ViewInformation3D
& rViewInformation3D
,
94 const basegfx::B3DVector
& rLightNormal
,
96 const basegfx::B3DRange
& rScene3DRange
);
99 const primitive3d::Primitive3DSequence
& getChildren3D() const { return mxChildren3D
; }
100 const basegfx::B2DHomMatrix
& getObjectTransformation() const { return maObjectTransformation
; }
101 const geometry::ViewInformation3D
& getViewInformation3D() const { return maViewInformation3D
; }
102 const basegfx::B3DVector
& getLightNormal() const { return maLightNormal
; }
103 double getShadowSlant() const { return mfShadowSlant
; }
104 const basegfx::B3DRange
& getScene3DRange() const { return maScene3DRange
; }
107 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const SAL_OVERRIDE
;
110 virtual basegfx::B2DRange
getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const SAL_OVERRIDE
;
112 /// provide unique ID
113 DeclPrimitive2DIDBlock()
115 } // end of namespace primitive2d
116 } // end of namespace drawinglayer
120 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EMBEDDED3DPRIMITIVE2D_HXX
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */