Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SCENEPRIMITIVE2D_HXX
30 : : #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SCENEPRIMITIVE2D_HXX
31 : :
32 : : #include <drawinglayer/drawinglayerdllapi.h>
33 : :
34 : : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
35 : : #include <drawinglayer/primitive3d/baseprimitive3d.hxx>
36 : : #include <drawinglayer/geometry/viewinformation3d.hxx>
37 : : #include <basegfx/matrix/b2dhommatrix.hxx>
38 : : #include <vcl/bitmapex.hxx>
39 : : #include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
40 : : #include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
41 : : #include <drawinglayer/attribute/sdrlightattribute3d.hxx>
42 : :
43 : : //////////////////////////////////////////////////////////////////////////////
44 : :
45 : : namespace drawinglayer
46 : : {
47 : : namespace primitive2d
48 : : {
49 : : /** ScenePrimitive2D class
50 : :
51 : : This primitive defines a 3D scene as a 2D primitive and is the anchor point
52 : : for a 3D visualisation. The decomposition is view-dependent and will try to
53 : : re-use already rendered 3D content.
54 : :
55 : : The rendering is done using the default-3D renderer from basegfx which supports
56 : : AntiAliasing.
57 : :
58 : : The 2D primitive's geometric range is defined completely by the
59 : : ObjectTransformation combined with evtl. 2D shadows from the 3D objects. The
60 : : shadows of 3D objects are 2D polygons, projected with the 3D transformation.
61 : :
62 : : This is the class a renderer may process directly when he wants to implement
63 : : an own (e.g. system-specific) 3D renderer.
64 : : */
65 [ + - ][ + - ]: 30 : class DRAWINGLAYER_DLLPUBLIC ScenePrimitive2D : public BufferedDecompositionPrimitive2D
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
66 : : {
67 : : private:
68 : : /// the 3D geometry definition
69 : : primitive3d::Primitive3DSequence mxChildren3D;
70 : :
71 : : /// 3D scene attribute set
72 : : attribute::SdrSceneAttribute maSdrSceneAttribute;
73 : :
74 : : /// lighting attribute set
75 : : attribute::SdrLightingAttribute maSdrLightingAttribute;
76 : :
77 : : /// object transformation for scene for 2D definition
78 : : basegfx::B2DHomMatrix maObjectTransformation;
79 : :
80 : : /// scene transformation set and object transformation
81 : : geometry::ViewInformation3D maViewInformation3D;
82 : :
83 : : /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked)
84 : : Primitive2DSequence maShadowPrimitives;
85 : :
86 : : /// bitfield
87 : : /** flag if given 3D geometry is already cheched for shadow definitions and 2d shadows
88 : : are created in maShadowPrimitives
89 : : */
90 : : unsigned mbShadow3DChecked : 1;
91 : :
92 : : /// the last used NewDiscreteSize and NewUnitVisiblePart definitions for decomposition
93 : : double mfOldDiscreteSizeX;
94 : : double mfOldDiscreteSizeY;
95 : : basegfx::B2DRange maOldUnitVisiblePart;
96 : :
97 : : /** the last created BitmapEx, e.g. for fast HitTest. This does not really need
98 : : memory since BitmapEx is internally RefCounted
99 : : */
100 : : BitmapEx maOldRenderedBitmap;
101 : :
102 : : /// private helpers
103 : : bool impGetShadow3D(const geometry::ViewInformation2D& rViewInformation) const;
104 : : void calculateDiscreteSizes(
105 : : const geometry::ViewInformation2D& rViewInformation,
106 : : basegfx::B2DRange& rDiscreteRange,
107 : : basegfx::B2DRange& rVisibleDiscreteRange,
108 : : basegfx::B2DRange& rUnitVisibleRange) const;
109 : :
110 : : protected:
111 : : /// local decomposition.
112 : : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
113 : :
114 : : public:
115 : : /// public helpers
116 : : /** Geometry extractor. Shadow will be added as in create2DDecomposition, but
117 : : the 3D content is not converted to a bitmap visualisation but to projected 2D gemetry. This
118 : : helper is useful e.g. for Contour extraction or HitTests.
119 : : */
120 : : Primitive2DSequence getGeometry2D() const;
121 : : Primitive2DSequence getShadow2D(const geometry::ViewInformation2D& rViewInformation) const;
122 : :
123 : : /** Fast HitTest which uses the last buffered BitmapEx from the last
124 : : rendered area if available. The return value describes if the check
125 : : could be done with the current information, so do NOT use o_rResult
126 : : when it returns false. o_rResult will be changed on return true and
127 : : then contains a definitive answer if content of this scene is hit or
128 : : not. On return false, it is normally necessary to use the geometric
129 : : HitTest (see CutFindProcessor usages). The given HitPoint
130 : : has to be in logic coordinates in scene's ObjectCoordinateSystem.
131 : : */
132 : : bool tryToCheckLastVisualisationDirectHit(const basegfx::B2DPoint& rLogicHitPoint, bool& o_rResult) const;
133 : :
134 : : /// constructor
135 : : ScenePrimitive2D(
136 : : const primitive3d::Primitive3DSequence& rxChildren3D,
137 : : const attribute::SdrSceneAttribute& rSdrSceneAttribute,
138 : : const attribute::SdrLightingAttribute& rSdrLightingAttribute,
139 : : const basegfx::B2DHomMatrix& rObjectTransformation,
140 : : const geometry::ViewInformation3D& rViewInformation3D);
141 : :
142 : : /// data read access
143 : 60 : const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; }
144 : 30 : const attribute::SdrSceneAttribute& getSdrSceneAttribute() const { return maSdrSceneAttribute; }
145 : 15 : const attribute::SdrLightingAttribute& getSdrLightingAttribute() const { return maSdrLightingAttribute; }
146 : 150 : const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; }
147 : 45 : const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; }
148 : :
149 : : /// compare operator
150 : : virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
151 : :
152 : : /// get range
153 : : virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
154 : :
155 : : /// provide unique ID
156 : : DeclPrimitrive2DIDBlock()
157 : :
158 : : /// get local decomposition. Overloaded since this decomposition is view-dependent
159 : : virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
160 : : };
161 : : } // end of namespace primitive2d
162 : : } // end of namespace drawinglayer
163 : :
164 : : //////////////////////////////////////////////////////////////////////////////
165 : :
166 : : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SCENEPRIMITIVE2D_HXX
167 : :
168 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|