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_EMBEDDED3DPRIMITIVE2D_HXX
21 : #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EMBEDDED3DPRIMITIVE2D_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 :
30 : //////////////////////////////////////////////////////////////////////////////
31 : // Embedded3DPrimitive2D class
32 :
33 : namespace drawinglayer
34 : {
35 : namespace primitive2d
36 : {
37 : /** Embedded3DPrimitive2D class
38 :
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.
43 :
44 : This primitive will not be visualized and decomposes to a yellow
45 : 2D rectangle to visualize that this should never be visualized
46 : */
47 0 : class DRAWINGLAYER_DLLPUBLIC Embedded3DPrimitive2D : public BufferedDecompositionPrimitive2D
48 : {
49 : private:
50 : /// the sequence of 3d primitives
51 : primitive3d::Primitive3DSequence mxChildren3D;
52 :
53 : /// the 2D scene object transformation
54 : basegfx::B2DHomMatrix maObjectTransformation;
55 :
56 : /// the 3D transformations
57 : geometry::ViewInformation3D maViewInformation3D;
58 :
59 : /** if the embedded 3D primitives contain shadow, these parameters are needed
60 : to extract the shadow wich 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
64 : */
65 : basegfx::B3DVector maLightNormal;
66 : double mfShadowSlant;
67 : basegfx::B3DRange maScene3DRange;
68 :
69 : /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked)
70 : Primitive2DSequence maShadowPrimitives;
71 :
72 : /// #i96669# add simple range buffering for this primitive
73 : basegfx::B2DRange maB2DRange;
74 :
75 : /// bitfield
76 : /** flag if given 3D geometry is already cheched for shadow definitions and 2d shadows
77 : are created in maShadowPrimitives
78 : */
79 : unsigned mbShadow3DChecked : 1;
80 :
81 : /// private helpers
82 : bool impGetShadow3D(const geometry::ViewInformation2D& rViewInformation) const;
83 :
84 : protected:
85 : /// local decomposition.
86 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
87 :
88 : public:
89 : /// constructor
90 : Embedded3DPrimitive2D(
91 : const primitive3d::Primitive3DSequence& rxChildren3D,
92 : const basegfx::B2DHomMatrix& rObjectTransformation,
93 : const geometry::ViewInformation3D& rViewInformation3D,
94 : const basegfx::B3DVector& rLightNormal,
95 : double fShadowSlant,
96 : const basegfx::B3DRange& rScene3DRange);
97 :
98 : /// data read access
99 0 : const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; }
100 0 : const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; }
101 0 : const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; }
102 0 : const basegfx::B3DVector& getLightNormal() const { return maLightNormal; }
103 0 : double getShadowSlant() const { return mfShadowSlant; }
104 0 : const basegfx::B3DRange& getScene3DRange() const { return maScene3DRange; }
105 :
106 : /// compare operator
107 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
108 :
109 : /// get range
110 : virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
111 :
112 : /// provide unique ID
113 : DeclPrimitrive2DIDBlock()
114 : };
115 : } // end of namespace primitive2d
116 : } // end of namespace drawinglayer
117 :
118 : //////////////////////////////////////////////////////////////////////////////
119 :
120 : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EMBEDDED3DPRIMITIVE2D_HXX
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|