Update git submodules
[LibreOffice.git] / include / drawinglayer / primitive2d / embedded3dprimitive2d.hxx
blob092a21ddf980628c7e38f7dce3a46f67c17234e2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <drawinglayer/drawinglayerdllapi.h>
24 #include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx>
25 #include <drawinglayer/primitive3d/baseprimitive3d.hxx>
26 #include <drawinglayer/geometry/viewinformation3d.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
30 // Embedded3DPrimitive2D class
32 namespace drawinglayer::primitive2d
34 /** Embedded3DPrimitive2D class
36 This is a helper primitive which allows embedding of single 3D
37 primitives to the 2D primitive logic. It will get the scene it's
38 involved and thus the 3D transformation. With this information it
39 is able to provide 2D range data for a 3D primitive.
41 This primitive will not be visualized and decomposes to a yellow
42 2D rectangle to visualize that this should never be visualized
44 class DRAWINGLAYER_DLLPUBLIC Embedded3DPrimitive2D final : public BufferedDecompositionPrimitive2D
46 private:
47 /// the sequence of 3d primitives
48 primitive3d::Primitive3DContainer mxChildren3D;
50 /// the 2D scene object transformation
51 basegfx::B2DHomMatrix maObjectTransformation;
53 /// the 3D transformations
54 geometry::ViewInformation3D maViewInformation3D;
56 /** if the embedded 3D primitives contain shadow, these parameters are needed
57 to extract the shadow which is a sequence of 2D primitives and may expand
58 the 2D range. Since every single 3D object in a scene may individually
59 have shadow or not, these values need to be provided and prepared. The shadow
60 distance itself (a 2D transformation) is part of the 3D shadow definition
62 basegfx::B3DVector maLightNormal;
63 double mfShadowSlant;
64 basegfx::B3DRange maScene3DRange;
66 /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked)
67 Primitive2DContainer maShadowPrimitives;
69 /// #i96669# add simple range buffering for this primitive
70 basegfx::B2DRange maB2DRange;
72 /** flag if given 3D geometry is already checked for shadow definitions and 2d shadows
73 are created in maShadowPrimitives
75 bool mbShadow3DChecked : 1;
77 /// private helpers
78 bool impGetShadow3D() const;
80 /// local decomposition.
81 virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
83 public:
84 /// constructor
85 Embedded3DPrimitive2D(
86 primitive3d::Primitive3DContainer xChildren3D,
87 basegfx::B2DHomMatrix aObjectTransformation,
88 geometry::ViewInformation3D aViewInformation3D,
89 const basegfx::B3DVector& rLightNormal,
90 double fShadowSlant,
91 const basegfx::B3DRange& rScene3DRange);
93 /// data read access
94 const primitive3d::Primitive3DContainer& getChildren3D() const { return mxChildren3D; }
95 const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; }
96 const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; }
97 const basegfx::B3DVector& getLightNormal() const { return maLightNormal; }
98 double getShadowSlant() const { return mfShadowSlant; }
99 const basegfx::B3DRange& getScene3DRange() const { return maScene3DRange; }
101 /// compare operator
102 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
104 /// get range
105 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
107 /// provide unique ID
108 virtual sal_uInt32 getPrimitive2DID() const override;
110 } // end of namespace drawinglayer::primitive2d
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */