/src/libreoffice/include/drawinglayer/primitive3d/baseprimitive3d.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 <comphelper/compbase.hxx> |
25 | | #include <com/sun/star/graphic/XPrimitive3D.hpp> |
26 | | #include <deque> |
27 | | |
28 | | |
29 | | /** defines for DeclPrimitive3DIDBlock and ImplPrimitive3DIDBlock |
30 | | Added to be able to simply change identification stuff later, e.g. add |
31 | | an identification string and/or ID to the interface and to the implementation |
32 | | ATM used to declare implement getPrimitive3DID() |
33 | | */ |
34 | | |
35 | | #define DeclPrimitive3DIDBlock() \ |
36 | | virtual sal_uInt32 getPrimitive3DID() const override; |
37 | | |
38 | | #define ImplPrimitive3DIDBlock(TheClass, TheID) \ |
39 | 0 | sal_uInt32 TheClass::getPrimitive3DID() const { return TheID; }Unexecuted instantiation: drawinglayer::primitive3d::ModifiedColorPrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::SdrCubePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::SdrExtrudePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::SdrLathePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::SdrPolyPolygonPrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::SdrSpherePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::ShadowPrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::UnifiedTransparenceTexturePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::GradientTexturePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::BitmapTexturePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::TransparenceTexturePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::TransformPrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::GroupPrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::HatchTexturePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::HiddenGeometryPrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::PolygonHairlinePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::PolygonStrokePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::PolygonTubePrimitive3D::getPrimitive3DID() const Unexecuted instantiation: drawinglayer::primitive3d::PolyPolygonMaterialPrimitive3D::getPrimitive3DID() const |
40 | | |
41 | | |
42 | | // predefines |
43 | | |
44 | | namespace drawinglayer::geometry { |
45 | | class ViewInformation3D; |
46 | | } |
47 | | |
48 | | namespace basegfx { class B3DRange; } |
49 | | |
50 | | namespace drawinglayer::primitive3d { |
51 | | /// typedefs for basePrimitive3DImplBase, Primitive3DContainer and Primitive3DReference |
52 | | typedef comphelper::WeakComponentImplHelper< css::graphic::XPrimitive3D > BasePrimitive3DImplBase; |
53 | | typedef css::uno::Reference< css::graphic::XPrimitive3D > Primitive3DReference; |
54 | | |
55 | | class SAL_WARN_UNUSED DRAWINGLAYER_DLLPUBLIC Primitive3DContainer : public std::deque< Primitive3DReference > |
56 | | { |
57 | | public: |
58 | 9.79k | explicit Primitive3DContainer() {} |
59 | 0 | explicit Primitive3DContainer( size_type count ) : deque(count) {} |
60 | 0 | Primitive3DContainer( const Primitive3DContainer& other ) : deque(other) {} |
61 | 0 | Primitive3DContainer( Primitive3DContainer&& other ) noexcept : deque(std::move(other)) {} |
62 | 0 | Primitive3DContainer( std::initializer_list<Primitive3DReference> init ) : deque(init) {} |
63 | | template <class Iter> |
64 | | Primitive3DContainer(Iter first, Iter last) : deque(first, last) {} |
65 | | |
66 | | void append(const Primitive3DContainer& rSource); |
67 | 0 | Primitive3DContainer& operator=(const Primitive3DContainer& r) { deque::operator=(r); return *this; } |
68 | 0 | Primitive3DContainer& operator=(Primitive3DContainer&& r) noexcept { deque::operator=(std::move(r)); return *this; } |
69 | | bool operator==(const Primitive3DContainer& rB) const; |
70 | 0 | bool operator!=(const Primitive3DContainer& rB) const { return !operator==(rB); } |
71 | | basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& aViewInformation) const; |
72 | | }; |
73 | | } |
74 | | |
75 | | |
76 | | // basePrimitive3D class |
77 | | |
78 | | namespace drawinglayer::primitive3d |
79 | | { |
80 | | /** BasePrimitive3D class |
81 | | |
82 | | Baseclass for all C++ implementations of css::graphic::XPrimitive2D |
83 | | |
84 | | The description/functionality is identical with the 2D case in baseprimitive2d.hxx, |
85 | | please see there for detailed information. |
86 | | |
87 | | Current Basic 3D Primitives are: |
88 | | |
89 | | - PolygonHairlinePrimitive3D (for 3D hairlines) |
90 | | - PolyPolygonMaterialPrimitive3D (for 3D filled plane polygons) |
91 | | |
92 | | That's all for 3D! |
93 | | */ |
94 | | class DRAWINGLAYER_DLLPUBLIC BasePrimitive3D |
95 | | : public BasePrimitive3DImplBase |
96 | | { |
97 | | BasePrimitive3D(const BasePrimitive3D&) = delete; |
98 | | BasePrimitive3D& operator=( const BasePrimitive3D& ) = delete; |
99 | | public: |
100 | | // constructor/destructor |
101 | | BasePrimitive3D(); |
102 | | virtual ~BasePrimitive3D() override; |
103 | | |
104 | | /** the ==operator is mainly needed to allow testing newly-created high level primitives against their last |
105 | | incarnation which buffers/holds the decompositions. The default implementation |
106 | | uses getPrimitive3DID()-calls to test if it's the same ID at last. |
107 | | Overridden implementation are then based on this implementation. |
108 | | */ |
109 | | virtual bool operator==( const BasePrimitive3D& rPrimitive ) const; |
110 | 0 | bool operator!=( const BasePrimitive3D& rPrimitive ) const { return !operator==(rPrimitive); } |
111 | | |
112 | | /** This method is for places where using the C++ implementation directly is possible. The subprocessing |
113 | | and range merging is more efficient when working directly on basegfx::B3DRange. The default implementation |
114 | | will use getDecomposition results to create the range |
115 | | */ |
116 | | virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; |
117 | | |
118 | | /** provide unique ID for fast identifying of known primitive implementations in renderers. These use |
119 | | the defines from primitivetypes3d.hxx to define unique IDs. |
120 | | */ |
121 | | virtual sal_uInt32 getPrimitive3DID() const = 0; |
122 | | |
123 | | /// The default implementation returns an empty sequence |
124 | | virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; |
125 | | |
126 | | |
127 | | // Methods from XPrimitive3D |
128 | | |
129 | | |
130 | | /** The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It |
131 | | will get the ViewInformation from the ViewParameters for that purpose |
132 | | */ |
133 | | virtual css::uno::Sequence< ::css::uno::Reference< ::css::graphic::XPrimitive3D > > SAL_CALL getDecomposition( const css::uno::Sequence< css::beans::PropertyValue >& rViewParameters ) override final; |
134 | | |
135 | | /** the getRange default implementation will use getDecomposition to create the range information from merging |
136 | | getRange results from the single local decomposition primitives. |
137 | | */ |
138 | | virtual css::geometry::RealRectangle3D SAL_CALL getRange( const css::uno::Sequence< css::beans::PropertyValue >& rViewParameters ) override final; |
139 | | }; |
140 | | |
141 | | } // end of namespace drawinglayer::primitive2d |
142 | | |
143 | | |
144 | | // BufferedDecompositionPrimitive3D class |
145 | | |
146 | | namespace drawinglayer::primitive3d |
147 | | { |
148 | | /** BufferedDecompositionPrimitive3D class |
149 | | |
150 | | Baseclass for all C++ implementations of css::graphic::XPrimitive2D |
151 | | |
152 | | The description/functionality is identical with the 2D case in baseprimitive2d.hxx, |
153 | | please see there for detailed information |
154 | | */ |
155 | | class DRAWINGLAYER_DLLPUBLIC BufferedDecompositionPrimitive3D |
156 | | : public BasePrimitive3D |
157 | | { |
158 | | private: |
159 | | /// a sequence used for buffering the last create3DDecomposition() result |
160 | | Primitive3DContainer maBuffered3DDecomposition; |
161 | | |
162 | | protected: |
163 | | /** access methods to maBuffered3DDecomposition. The usage of this methods may allow |
164 | | later thread-safe stuff to be added if needed. Only to be used by getDecomposition() |
165 | | implementations for buffering the last decomposition. |
166 | | */ |
167 | 0 | const Primitive3DContainer& getBuffered3DDecomposition() const { return maBuffered3DDecomposition; } |
168 | 0 | void setBuffered3DDecomposition(const Primitive3DContainer& rNew) { maBuffered3DDecomposition = rNew; } |
169 | | |
170 | | /** method which is to be used to implement the local decomposition of a 2D primitive. The default |
171 | | implementation will just return an empty decomposition |
172 | | */ |
173 | | virtual Primitive3DContainer create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; |
174 | | |
175 | | public: |
176 | | // constructor |
177 | | BufferedDecompositionPrimitive3D(); |
178 | | |
179 | | /** The getDecomposition default implementation will on demand use create3DDecomposition() if |
180 | | maBuffered3DDecomposition is empty. It will set maBuffered3DDecomposition to this obtained decomposition |
181 | | to buffer it. If the decomposition is also ViewInformation-dependent, this method needs to be |
182 | | overridden and the ViewInformation for the last decomposition needs to be remembered, too, and |
183 | | be used in the next call to decide if the buffered decomposition may be reused or not. |
184 | | */ |
185 | | virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override; |
186 | | }; |
187 | | |
188 | | } // end of namespace drawinglayer::primitive3d |
189 | | |
190 | | |
191 | | // tooling |
192 | | |
193 | | namespace drawinglayer::primitive3d |
194 | | { |
195 | | /// get B3DRange from a given Primitive3DReference |
196 | | basegfx::B3DRange DRAWINGLAYER_DLLPUBLIC getB3DRangeFromPrimitive3DReference(const Primitive3DReference& rCandidate, const geometry::ViewInformation3D& aViewInformation); |
197 | | |
198 | | /** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) |
199 | | and using compare operator |
200 | | */ |
201 | | bool DRAWINGLAYER_DLLPUBLIC arePrimitive3DReferencesEqual(const Primitive3DReference& rA, const Primitive3DReference& rB); |
202 | | |
203 | | } // end of namespace drawinglayer::primitive3d |
204 | | |
205 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |