tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / include / drawinglayer / primitive2d / sceneprimitive2d.hxx
blob5965962a7013159e3150bc38a92da48906c8a185
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <drawinglayer/drawinglayerdllapi.h>
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 <vcl/bitmapex.hxx>
29 #include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
30 #include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
32 namespace drawinglayer::primitive2d
34 /** ScenePrimitive2D class
36 This primitive defines a 3D scene as a 2D primitive and is the anchor point
37 for a 3D visualisation. The decomposition is view-dependent and will try to
38 re-use already rendered 3D content.
40 The rendering is done using the default-3D renderer from basegfx which supports
41 AntiAliasing.
43 The 2D primitive's geometric range is defined completely by the
44 ObjectTransformation combined with evtl. 2D shadows from the 3D objects. The
45 shadows of 3D objects are 2D polygons, projected with the 3D transformation.
47 This is the class a renderer may process directly when he wants to implement
48 an own (e.g. system-specific) 3D renderer.
50 class DRAWINGLAYER_DLLPUBLIC ScenePrimitive2D final : public BufferedDecompositionPrimitive2D
52 private:
53 /// the 3D geometry definition
54 primitive3d::Primitive3DContainer mxChildren3D;
56 /// 3D scene attribute set
57 attribute::SdrSceneAttribute maSdrSceneAttribute;
59 /// lighting attribute set
60 attribute::SdrLightingAttribute maSdrLightingAttribute;
62 /// object transformation for scene for 2D definition
63 basegfx::B2DHomMatrix maObjectTransformation;
65 /// scene transformation set and object transformation
66 geometry::ViewInformation3D maViewInformation3D;
68 /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked)
69 Primitive2DContainer maShadowPrimitives;
71 /** flag if given 3D geometry is already checked for shadow definitions and 2d shadows
72 are created in maShadowPrimitives
74 bool mbShadow3DChecked : 1;
76 /// the last used NewDiscreteSize and NewUnitVisiblePart definitions for decomposition
77 double mfOldDiscreteSizeX;
78 double mfOldDiscreteSizeY;
79 basegfx::B2DRange maOldUnitVisiblePart;
81 /** the last created BitmapEx, e.g. for fast HitTest. This does not really need
82 memory since BitmapEx is internally RefCounted
84 BitmapEx maOldRenderedBitmap;
86 /// private helpers
87 bool impGetShadow3D() const;
88 void calculateDiscreteSizes(
89 const geometry::ViewInformation2D& rViewInformation,
90 basegfx::B2DRange& rDiscreteRange,
91 basegfx::B2DRange& rVisibleDiscreteRange,
92 basegfx::B2DRange& rUnitVisibleRange) const;
94 /// local decomposition.
95 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override;
97 public:
98 /// public helpers
99 /** Geometry extractor. Shadow will be added as in create2DDecomposition, but
100 the 3D content is not converted to a bitmap visualisation but to projected 2D geometry. This
101 helper is useful e.g. for Contour extraction or HitTests.
103 Primitive2DContainer getGeometry2D() const;
104 Primitive2DContainer getShadow2D() const;
106 /** Fast HitTest which uses the last buffered BitmapEx from the last
107 rendered area if available. The return value describes if the check
108 could be done with the current information, so do NOT use o_rResult
109 when it returns false. o_rResult will be changed on return true and
110 then contains a definitive answer if content of this scene is hit or
111 not. On return false, it is normally necessary to use the geometric
112 HitTest (see CutFindProcessor usages). The given HitPoint
113 has to be in logic coordinates in scene's ObjectCoordinateSystem.
115 bool tryToCheckLastVisualisationDirectHit(const basegfx::B2DPoint& rLogicHitPoint, bool& o_rResult) const;
117 /// constructor
118 ScenePrimitive2D(
119 primitive3d::Primitive3DContainer xChildren3D,
120 attribute::SdrSceneAttribute aSdrSceneAttribute,
121 attribute::SdrLightingAttribute aSdrLightingAttribute,
122 basegfx::B2DHomMatrix aObjectTransformation,
123 geometry::ViewInformation3D aViewInformation3D);
125 /// data read access
126 const primitive3d::Primitive3DContainer& getChildren3D() const { return mxChildren3D; }
127 const attribute::SdrSceneAttribute& getSdrSceneAttribute() const { return maSdrSceneAttribute; }
128 const attribute::SdrLightingAttribute& getSdrLightingAttribute() const { return maSdrLightingAttribute; }
129 const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; }
130 const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; }
132 /// compare operator
133 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
135 /// get range
136 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
138 /// provide unique ID
139 virtual sal_uInt32 getPrimitive2DID() const override;
141 /// get local decomposition. Override since this decomposition is view-dependent
142 virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
144 } // end of namespace drawinglayer::primitive2d
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */