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