1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EMBEDDED3DPRIMITIVE2D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EMBEDDED3DPRIMITIVE2D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
29 #include <drawinglayer/primitive3d/baseprimitive3d.hxx>
30 #include <drawinglayer/geometry/viewinformation3d.hxx>
31 #include <basegfx/matrix/b2dhommatrix.hxx>
32 
33 //////////////////////////////////////////////////////////////////////////////
34 // Embedded3DPrimitive2D class
35 
36 namespace drawinglayer
37 {
38 	namespace primitive2d
39 	{
40         /** Embedded3DPrimitive2D class
41 
42             This is a helper primitive which allows embedding of single 3D
43             primitives to the 2D primitive logic. It will get the scene it's
44             involved and thus the 3D transformation. With this information it
45             is able to provide 2D range data for a 3D primitive.
46 
47             This primitive will not be visualized and decomposes to a yellow
48             2D rectangle to visualize that this should never be visualized
49          */
50 		class DRAWINGLAYER_DLLPUBLIC Embedded3DPrimitive2D : public BufferedDecompositionPrimitive2D
51 		{
52 		private:
53 			/// the sequence of 3d primitives
54 			primitive3d::Primitive3DSequence				    mxChildren3D;
55 
56 			/// the 2D scene object transformation
57 			basegfx::B2DHomMatrix							    maObjectTransformation;
58 
59 			/// the 3D transformations
60 			geometry::ViewInformation3D						    maViewInformation3D;
61 
62 			/** if the embedded 3D primitives contain shadow, these parameters are needed
63 			    to extract the shadow wich is a sequence od 2D primitives and may expand
64 			    the 2D range. Since every single 3D object in a scene may individually
65 			    have shadow or not, these values need to be provided and prepared. The shadow
66 			    distance itself (a 2D transformation) is part of the 3D shadow definition
67              */
68 			basegfx::B3DVector								    maLightNormal;
69 			double											    mfShadowSlant;
70             basegfx::B3DRange                                   maScene3DRange;
71 
72 			/// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked)
73 			Primitive2DSequence									maShadowPrimitives;
74 
75 			/// #i96669# add simple range buffering for this primitive
76 			basegfx::B2DRange									maB2DRange;
77 
78 			/// bitfield
79 			/** flag if given 3D geometry is already cheched for shadow definitions and 2d shadows
80 			    are created in maShadowPrimitives
81              */
82 			unsigned											mbShadow3DChecked : 1;
83 
84 			/// private helpers
85 			bool impGetShadow3D(const geometry::ViewInformation2D& rViewInformation) const;
86 
87         protected:
88 			/// local decomposition.
89 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
90 
91 		public:
92             /// constructor
93 			Embedded3DPrimitive2D(
94 				const primitive3d::Primitive3DSequence& rxChildren3D,
95 				const basegfx::B2DHomMatrix& rObjectTransformation,
96 				const geometry::ViewInformation3D& rViewInformation3D,
97 				const basegfx::B3DVector& rLightNormal,
98 				double fShadowSlant,
99                 const basegfx::B3DRange& rScene3DRange);
100 
101 			/// data read access
getChildren3D() const102 			const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; }
getObjectTransformation() const103 			const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; }
getViewInformation3D() const104 			const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; }
getLightNormal() const105 			const basegfx::B3DVector& getLightNormal() const { return maLightNormal; }
getShadowSlant() const106 			double getShadowSlant() const { return mfShadowSlant; }
getScene3DRange() const107             const basegfx::B3DRange& getScene3DRange() const { return maScene3DRange; }
108 
109 			/// compare operator
110 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
111 
112 			/// get range
113 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
114 
115 			/// provide unique ID
116 			DeclPrimitrive2DIDBlock()
117 		};
118 	} // end of namespace primitive2d
119 } // end of namespace drawinglayer
120 
121 //////////////////////////////////////////////////////////////////////////////
122 
123 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EMBEDDED3DPRIMITIVE2D_HXX
124 
125 //////////////////////////////////////////////////////////////////////////////
126 // eof
127