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