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