/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 | | |
29 | | |
30 | | // Embedded3DPrimitive2D class |
31 | | |
32 | | namespace drawinglayer::primitive2d |
33 | | { |
34 | | /** Embedded3DPrimitive2D class |
35 | | |
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. |
40 | | |
41 | | This primitive will not be visualized and decomposes to a yellow |
42 | | 2D rectangle to visualize that this should never be visualized |
43 | | */ |
44 | | class DRAWINGLAYER_DLLPUBLIC Embedded3DPrimitive2D final : public BufferedDecompositionPrimitive2D |
45 | | { |
46 | | private: |
47 | | /// the sequence of 3d primitives |
48 | | primitive3d::Primitive3DContainer mxChildren3D; |
49 | | |
50 | | /// the 2D scene object transformation |
51 | | basegfx::B2DHomMatrix maObjectTransformation; |
52 | | |
53 | | /// the 3D transformations |
54 | | geometry::ViewInformation3D maViewInformation3D; |
55 | | |
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 |
61 | | */ |
62 | | basegfx::B3DVector maLightNormal; |
63 | | double mfShadowSlant; |
64 | | basegfx::B3DRange maScene3DRange; |
65 | | |
66 | | /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked) |
67 | | Primitive2DContainer maShadowPrimitives; |
68 | | |
69 | | /// #i96669# add simple range buffering for this primitive |
70 | | basegfx::B2DRange maB2DRange; |
71 | | |
72 | | /** flag if given 3D geometry is already checked for shadow definitions and 2d shadows |
73 | | are created in maShadowPrimitives |
74 | | */ |
75 | | bool mbShadow3DChecked : 1; |
76 | | |
77 | | /// private helpers |
78 | | bool impGetShadow3D() const; |
79 | | |
80 | | /// local decomposition. |
81 | | virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override; |
82 | | |
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); |
92 | | |
93 | | /// data read access |
94 | 0 | const primitive3d::Primitive3DContainer& getChildren3D() const { return mxChildren3D; } |
95 | 0 | const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } |
96 | 0 | const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; } |
97 | 0 | const basegfx::B3DVector& getLightNormal() const { return maLightNormal; } |
98 | 0 | double getShadowSlant() const { return mfShadowSlant; } |
99 | 0 | const basegfx::B3DRange& getScene3DRange() const { return maScene3DRange; } |
100 | | |
101 | | /// compare operator |
102 | | virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
103 | | |
104 | | /// get range |
105 | | virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; |
106 | | |
107 | | /// provide unique ID |
108 | | virtual sal_uInt32 getPrimitive2DID() const override; |
109 | | }; |
110 | | } // end of namespace drawinglayer::primitive2d |
111 | | |
112 | | |
113 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |