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