1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_BASEPRIMITIVE3D_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_BASEPRIMITIVE3D_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
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>
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()
38 #define DeclPrimitive3DIDBlock() \
39 virtual sal_uInt32 getPrimitive3DID() const;
41 #define ImplPrimitive3DIDBlock(TheClass, TheID) \
42 sal_uInt32 TheClass::getPrimitive3DID() const { return TheID; }
44 //////////////////////////////////////////////////////////////////////////////
47 namespace drawinglayer
{ namespace geometry
{
48 class ViewInformation3D
;
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
;
58 //////////////////////////////////////////////////////////////////////////////
59 // basePrimitive3D class
61 namespace drawinglayer
65 /** BasePrimitive3D class
67 Baseclass for all C++ implementations of com::sun::star::graphic::XPrimitive2D
69 The description/functionality is identical with the 2D case in baseprimitive2d.hxx,
70 please see there for detailed information.
72 Current Basic 3D Primitives are:
74 - PolygonHairlinePrimitive3D (for 3D hairlines)
75 - PolyPolygonMaterialPrimitive3D (for 3D filled plane polygons)
79 class DRAWINGLAYER_DLLPUBLIC BasePrimitive3D
80 : private boost::noncopyable
,
81 protected comphelper::OBaseMutex
,
82 public BasePrimitive3DImplBase
87 // constructor/destructor
89 virtual ~BasePrimitive3D();
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. Overloaded implementation are then
94 based on this implementation.
96 virtual bool operator==( const BasePrimitive3D
& rPrimitive
) const;
97 bool operator!=( const BasePrimitive3D
& rPrimitive
) const { return !operator==(rPrimitive
); }
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
103 virtual basegfx::B3DRange
getB3DRange(const geometry::ViewInformation3D
& rViewInformation
) const;
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.
108 virtual sal_uInt32
getPrimitive3DID() const = 0;
110 /// The default implementation returns an empty sequence
111 virtual Primitive3DSequence
get3DDecomposition(const geometry::ViewInformation3D
& rViewInformation
) const;
114 // Methods from XPrimitive3D
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
120 virtual Primitive3DSequence SAL_CALL
getDecomposition( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rViewParameters
) throw ( ::com::sun::star::uno::RuntimeException
);
122 /** the getRange default implemenation will use getDecomposition to create the range information from merging
123 getRange results from the single local decomposition primitives.
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
);
127 } // end of namespace primitive3d
128 } // end of namespace drawinglayer
130 //////////////////////////////////////////////////////////////////////////////
131 // BufferedDecompositionPrimitive3D class
133 namespace drawinglayer
135 namespace primitive3d
137 /** BufferedDecompositionPrimitive3D class
139 Baseclass for all C++ implementations of com::sun::star::graphic::XPrimitive2D
141 The description/functionality is identical with the 2D case in baseprimitive2d.hxx,
142 please see there for detailed information
144 class DRAWINGLAYER_DLLPUBLIC BufferedDecompositionPrimitive3D
145 : public BasePrimitive3D
148 /// a sequence used for buffering the last create3DDecomposition() result
149 Primitive3DSequence maBuffered3DDecomposition
;
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.
156 const Primitive3DSequence
& getBuffered3DDecomposition() const { return maBuffered3DDecomposition
; }
157 void setBuffered3DDecomposition(const Primitive3DSequence
& rNew
) { maBuffered3DDecomposition
= rNew
; }
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
162 virtual Primitive3DSequence
create3DDecomposition(const geometry::ViewInformation3D
& rViewInformation
) const;
166 BufferedDecompositionPrimitive3D();
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 overloaded 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.
174 virtual Primitive3DSequence
get3DDecomposition(const geometry::ViewInformation3D
& rViewInformation
) const;
176 } // end of namespace primitive3d
177 } // end of namespace drawinglayer
179 //////////////////////////////////////////////////////////////////////////////
182 namespace drawinglayer
184 namespace primitive3d
186 /// get B3DRange from a given Primitive3DReference
187 basegfx::B3DRange DRAWINGLAYER_DLLPUBLIC
getB3DRangeFromPrimitive3DReference(const Primitive3DReference
& rCandidate
, const geometry::ViewInformation3D
& aViewInformation
);
189 /// get range3D from a given Primitive3DSequence
190 basegfx::B3DRange DRAWINGLAYER_DLLPUBLIC
getB3DRangeFromPrimitive3DSequence(const Primitive3DSequence
& rCandidate
, const geometry::ViewInformation3D
& aViewInformation
);
192 /** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D)
193 and using compare operator
195 bool DRAWINGLAYER_DLLPUBLIC
arePrimitive3DReferencesEqual(const Primitive3DReference
& rA
, const Primitive3DReference
& rB
);
197 /// compare two Primitive3DReferences for equality, uses arePrimitive3DReferencesEqual internally
198 bool DRAWINGLAYER_DLLPUBLIC
arePrimitive3DSequencesEqual(const Primitive3DSequence
& rA
, const Primitive3DSequence
& rB
);
200 /// concatenate sequence
201 void DRAWINGLAYER_DLLPUBLIC
appendPrimitive3DSequenceToPrimitive3DSequence(Primitive3DSequence
& rDest
, const Primitive3DSequence
& rSource
);
203 /// concatenate single Primitive3D
204 void DRAWINGLAYER_DLLPUBLIC
appendPrimitive3DReferenceToPrimitive3DSequence(Primitive3DSequence
& rDest
, const Primitive3DReference
& rSource
);
206 } // end of namespace primitive3d
207 } // end of namespace drawinglayer
209 //////////////////////////////////////////////////////////////////////////////
211 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_BASEPRIMITIVE3D_HXX
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */