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