diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/drawinglayer/primitive3d | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/drawinglayer/primitive3d')
20 files changed, 2107 insertions, 0 deletions
diff --git a/include/drawinglayer/primitive3d/baseprimitive3d.hxx b/include/drawinglayer/primitive3d/baseprimitive3d.hxx new file mode 100644 index 000000000000..974c47d9e485 --- /dev/null +++ b/include/drawinglayer/primitive3d/baseprimitive3d.hxx @@ -0,0 +1,213 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_BASEPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_BASEPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <cppuhelper/compbase1.hxx> +#include <boost/utility.hpp> +#include <com/sun/star/graphic/XPrimitive3D.hpp> +#include <comphelper/broadcasthelper.hxx> +#include <basegfx/range/b3drange.hxx> + +////////////////////////////////////////////////////////////////////////////// +/** defines for DeclPrimitrive3DIDBlock and ImplPrimitrive3DIDBlock + Added to be able to simply change identification stuff later, e.g. add + a identification string and/or ID to the interface and to the implementation + ATM used to delclare implement getPrimitive3DID() + */ + +#define DeclPrimitrive3DIDBlock() \ + virtual sal_uInt32 getPrimitive3DID() const; + +#define ImplPrimitrive3DIDBlock(TheClass, TheID) \ + sal_uInt32 TheClass::getPrimitive3DID() const { return TheID; } + +////////////////////////////////////////////////////////////////////////////// +// predefines + +namespace drawinglayer { namespace geometry { + class ViewInformation3D; +}} + +namespace drawinglayer { namespace primitive3d { + /// typedefs for basePrimitive3DImplBase, Primitive3DSequence and Primitive3DReference + typedef cppu::WeakComponentImplHelper1< ::com::sun::star::graphic::XPrimitive3D > BasePrimitive3DImplBase; + typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive3D > Primitive3DReference; + typedef ::com::sun::star::uno::Sequence< Primitive3DReference > Primitive3DSequence; +}} + +////////////////////////////////////////////////////////////////////////////// +// basePrimitive3D class + +namespace drawinglayer +{ + namespace primitive3d + { + /** BasePrimitive3D class + + Baseclass for all C++ implementations of com::sun::star::graphic::XPrimitive2D + + The description/functionality is identical with the 2D case in baseprimitive2d.hxx, + please see there for detailed information. + + Current Basic 3D Primitives are: + + - PolygonHairlinePrimitive3D (for 3D hairlines) + - PolyPolygonMaterialPrimitive3D (for 3D filled plane polygons) + + That's all for 3D! + */ + class DRAWINGLAYER_DLLPUBLIC BasePrimitive3D + : private boost::noncopyable, + protected comphelper::OBaseMutex, + public BasePrimitive3DImplBase + { + private: + protected: + public: + // constructor/destructor + BasePrimitive3D(); + virtual ~BasePrimitive3D(); + + /** the ==operator is mainly needed to allow testing newly-created high level primitives against their last + incarnation which buffers/holds the decompositionsThe default implementation + uses getPrimitive3DID()-calls to test if it's the same ID at last. Overloaded implementation are then + based on this implementation. + */ + virtual bool operator==( const BasePrimitive3D& rPrimitive ) const; + bool operator!=( const BasePrimitive3D& rPrimitive ) const { return !operator==(rPrimitive); } + + /** This method is for places where using the C++ implementation directly is possible. The subprocessing + and range merging is more efficient when working directly on basegfx::B3DRange. The default implementation + will use getDecomposition results to create the range + */ + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /** provide unique ID for fast identifying of known primitive implementations in renderers. These use + the defines from primitivetypes3d.hxx to define unique IDs. + */ + virtual sal_uInt32 getPrimitive3DID() const = 0; + + /// The default implementation returns an empty sequence + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + // + // Methods from XPrimitive3D + // + + /** The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It + will get the ViewInformation from the ViewParameters for that purpose + */ + virtual Primitive3DSequence SAL_CALL getDecomposition( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rViewParameters ) throw ( ::com::sun::star::uno::RuntimeException ); + + /** the getRange default implemenation will use getDecomposition to create the range information from merging + getRange results from the single local decomposition primitives. + */ + 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 ); + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// BufferedDecompositionPrimitive3D class + +namespace drawinglayer +{ + namespace primitive3d + { + /** BufferedDecompositionPrimitive3D class + + Baseclass for all C++ implementations of com::sun::star::graphic::XPrimitive2D + + The description/functionality is identical with the 2D case in baseprimitive2d.hxx, + please see there for detailed information + */ + class DRAWINGLAYER_DLLPUBLIC BufferedDecompositionPrimitive3D + : public BasePrimitive3D + { + private: + /// a sequence used for buffering the last create3DDecomposition() result + Primitive3DSequence maBuffered3DDecomposition; + + protected: + /** access methods to maBuffered3DDecomposition. The usage of this methods may allow + later thread-safe stuff to be added if needed. Only to be used by getDecomposition() + implementations for buffering the last decomposition. + */ + const Primitive3DSequence& getBuffered3DDecomposition() const { return maBuffered3DDecomposition; } + void setBuffered3DDecomposition(const Primitive3DSequence& rNew) { maBuffered3DDecomposition = rNew; } + + /** method which is to be used to implement the local decomposition of a 2D primitive. The default + implementation will just return an empty decomposition + */ + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + // constructor + BufferedDecompositionPrimitive3D(); + + /** The getDecomposition default implementation will on demand use create3DDecomposition() if + maBuffered3DDecomposition is empty. It will set maBuffered3DDecomposition to this obtained decomposition + to buffer it. If the decomposition is also ViewInformation-dependent, this method needs to be + overloaded and the ViewInformation for the last decomposition needs to be remembered, too, and + be used in the next call to decide if the buffered decomposition may be reused or not. + */ + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// tooling + +namespace drawinglayer +{ + namespace primitive3d + { + /// get B3DRange from a given Primitive3DReference + basegfx::B3DRange DRAWINGLAYER_DLLPUBLIC getB3DRangeFromPrimitive3DReference(const Primitive3DReference& rCandidate, const geometry::ViewInformation3D& aViewInformation); + + /// get range3D from a given Primitive3DSequence + basegfx::B3DRange DRAWINGLAYER_DLLPUBLIC getB3DRangeFromPrimitive3DSequence(const Primitive3DSequence& rCandidate, const geometry::ViewInformation3D& aViewInformation); + + /** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) + and using compare operator + */ + bool DRAWINGLAYER_DLLPUBLIC arePrimitive3DReferencesEqual(const Primitive3DReference& rA, const Primitive3DReference& rB); + + /// compare two Primitive3DReferences for equality, uses arePrimitive3DReferencesEqual internally + bool DRAWINGLAYER_DLLPUBLIC arePrimitive3DSequencesEqual(const Primitive3DSequence& rA, const Primitive3DSequence& rB); + + /// concatenate sequence + void DRAWINGLAYER_DLLPUBLIC appendPrimitive3DSequenceToPrimitive3DSequence(Primitive3DSequence& rDest, const Primitive3DSequence& rSource); + + /// concatenate single Primitive3D + void DRAWINGLAYER_DLLPUBLIC appendPrimitive3DReferenceToPrimitive3DSequence(Primitive3DSequence& rDest, const Primitive3DReference& rSource); + + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_BASEPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx b/include/drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx new file mode 100644 index 000000000000..3be15ad5e8bb --- /dev/null +++ b/include/drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_PRIMITIVETYPES3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_PRIMITIVETYPES3D_HXX + +////////////////////////////////////////////////////////////////////////////// +// define ranges for other libraries + +#define PRIMITIVE3D_ID_RANGE_DRAWINGLAYER (0 << 16) + +////////////////////////////////////////////////////////////////////////////// +// local primitives + +#define PRIMITIVE3D_ID_GROUPPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 0) +#define PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 1) +#define PRIMITIVE3D_ID_MODIFIEDCOLORPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 2) +#define PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 3) +#define PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 4) +#define PRIMITIVE3D_ID_POLYGONTUBEPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 5) +#define PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 6) +#define PRIMITIVE3D_ID_SDRCUBEPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 7) +#define PRIMITIVE3D_ID_SDREXTRUDEPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 8) +#define PRIMITIVE3D_ID_SDRLATHEPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 9) +#define PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 10) +#define PRIMITIVE3D_ID_SDRSPHEREPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 11) +#define PRIMITIVE3D_ID_SHADOWPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 12) +#define PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 13) +#define PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 14) +#define PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 15) +#define PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 16) +#define PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 17) +#define PRIMITIVE3D_ID_HIDDENGEOMETRYPRIMITIVE3D (PRIMITIVE3D_ID_RANGE_DRAWINGLAYER| 18) + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_PRIMITIVETYPES3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/groupprimitive3d.hxx b/include/drawinglayer/primitive3d/groupprimitive3d.hxx new file mode 100644 index 000000000000..d8d3f5b77446 --- /dev/null +++ b/include/drawinglayer/primitive3d/groupprimitive3d.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_GROUPPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_GROUPPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** GroupPrimitive3D class + + Baseclass for all grouping 3D primitives + + The description/functionality is identical with the 2D case in groupprimitive2d.hxx, + please see there for detailed information. + + Current Basic 3D StatePrimitives are: + + - ModifiedColorPrimitive3D (for a stack of color modifications) + - ShadowPrimitive3D (for 3D objects with shadow; this is a special case + since the shadow of a 3D primitive is a 2D primitive set) + - TexturePrimitive3D (with the following variations) + - GradientTexturePrimitive3D (for 3D gradient fill) + - BitmapTexturePrimitive3D (for 3D Bitmap fill) + - TransparenceTexturePrimitive3D (for 3D transparence) + - HatchTexturePrimitive3D (for 3D hatch fill) + - TransformPrimitive3D (for a transformation stack) + */ + class DRAWINGLAYER_DLLPUBLIC GroupPrimitive3D : public BasePrimitive3D + { + private: + /// the children. Declared private since this shall never be changed at all after construction + Primitive3DSequence maChildren; + + public: + /// constructor + explicit GroupPrimitive3D(const Primitive3DSequence& rChildren); + + /// data read access + Primitive3DSequence getChildren() const { return maChildren; } + + /// compare operator + virtual bool operator==( const BasePrimitive3D& rPrimitive ) const; + + /// local decomposition. Implementation will just return children + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_GROUPPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx b/include/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx new file mode 100644 index 000000000000..981027a1615b --- /dev/null +++ b/include/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/textureprimitive3d.hxx> +#include <drawinglayer/attribute/fillhatchattribute.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** HatchTexturePrimitive3D class + + HatchTexturePrimitive3D is derived from GroupPrimitive3D, but implements + a decomposition which is complicated enough for buffering. Since the group + primitive has no default buffering, it is necessary here to add a local + buffering mechanism for the decomposition + */ + class DRAWINGLAYER_DLLPUBLIC HatchTexturePrimitive3D : public TexturePrimitive3D + { + private: + /// the hatch definition + attribute::FillHatchAttribute maHatch; + + /// the buffered decomposed hatch + Primitive3DSequence maBuffered3DDecomposition; + + protected: + /// helper: local decomposition + Primitive3DSequence impCreate3DDecomposition() const; + + /// local access methods to maBufferedDecomposition + const Primitive3DSequence& getBuffered3DDecomposition() const { return maBuffered3DDecomposition; } + void setBuffered3DDecomposition(const Primitive3DSequence& rNew) { maBuffered3DDecomposition = rNew; } + + public: + /// constructor + HatchTexturePrimitive3D( + const attribute::FillHatchAttribute& rHatch, + const Primitive3DSequence& rChildren, + const basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + + /// data read access + const attribute::FillHatchAttribute& getHatch() const { return maHatch; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// local decomposition. + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/hiddengeometryprimitive3d.hxx b/include/drawinglayer/primitive3d/hiddengeometryprimitive3d.hxx new file mode 100644 index 000000000000..7fe7359b4824 --- /dev/null +++ b/include/drawinglayer/primitive3d/hiddengeometryprimitive3d.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HIDDENGEOMETRYPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HIDDENGEOMETRYPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + // This primitive is used to represent geometry for non-visible objects, + // e.g. a 3D cube without fill attributes. To still be able to use + // primitives for HitTest functionality, the 3d decompositions produce + // an as much as possible simplified fill geometry encapsulated in this + // primtive when there is no fill geometry. Currently, the 3d hit test + // uses only areas, so maybe in a further enchanced version this will change + // to 'if neither filled nor lines' creation criteria. The whole primitive + // decomposes to nothing, so no one not knowing it will be influenced. Only + // helper processors for hit test (and maybe BoundRect extractors) will + // use it and it's children subcontent. + class DRAWINGLAYER_DLLPUBLIC HiddenGeometryPrimitive3D : public GroupPrimitive3D + { + public: + explicit HiddenGeometryPrimitive3D(const Primitive3DSequence& rChildren); + + // despite returning an empty decomposition since it's no visualisation data, + // range calculation is intended to use hidden geometry, so + // the local implementation will return the children's range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// The default implementation returns an empty sequence + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + // provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HIDDENGEOMETRYPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx b/include/drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx new file mode 100644 index 000000000000..0e5fe4329e12 --- /dev/null +++ b/include/drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> +#include <basegfx/color/bcolormodifier.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** ModifiedColorPrimitive3D class + + This primitive is a grouping primitive and allows to define + how the colors of it's child content shall be modified for + visualisation. Please see the ModifiedColorPrimitive2D + description for more info. + */ + class DRAWINGLAYER_DLLPUBLIC ModifiedColorPrimitive3D : public GroupPrimitive3D + { + private: + /// The ColorModifier to use + basegfx::BColorModifier maColorModifier; + + public: + /// constructor + ModifiedColorPrimitive3D( + const Primitive3DSequence& rChildren, + const basegfx::BColorModifier& rColorModifier); + + /// data read access + const basegfx::BColorModifier& getColorModifier() const { return maColorModifier; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/polygonprimitive3d.hxx b/include/drawinglayer/primitive3d/polygonprimitive3d.hxx new file mode 100644 index 000000000000..62fb60265732 --- /dev/null +++ b/include/drawinglayer/primitive3d/polygonprimitive3d.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/polygon/b3dpolygon.hxx> +#include <drawinglayer/attribute/lineattribute.hxx> +#include <drawinglayer/attribute/strokeattribute.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** PolygonHairlinePrimitive3D class + + This primitive defines a Hairline in 3D. Since hairlines are view-dependent, + this primitive is view-dependent, too. + + This is one of the non-decomposable 3D primitives, so a renderer + should proccess it. + */ + class DRAWINGLAYER_DLLPUBLIC PolygonHairlinePrimitive3D : public BasePrimitive3D + { + private: + /// the hairline geometry + basegfx::B3DPolygon maPolygon; + + /// the hairline color + basegfx::BColor maBColor; + + public: + /// constructor + PolygonHairlinePrimitive3D( + const basegfx::B3DPolygon& rPolygon, + const basegfx::BColor& rBColor); + + /// data read access + const basegfx::B3DPolygon& getB3DPolygon() const { return maPolygon; } + const basegfx::BColor& getBColor() const { return maBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// get range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** PolygonStrokePrimitive3D class + + This primitive defines a 3D line with line width, line join, line color + and stroke attributes. It will be decomposed dependent on the definition + to the needed primitives, e.g. filled Tubes for fat lines. + */ + class DRAWINGLAYER_DLLPUBLIC PolygonStrokePrimitive3D : public BufferedDecompositionPrimitive3D + { + private: + /// the line geometry + basegfx::B3DPolygon maPolygon; + + /// the line attributes like width, join and color + attribute::LineAttribute maLineAttribute; + + /// the line stroking (if used) + attribute::StrokeAttribute maStrokeAttribute; + + protected: + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + /// constructor + PolygonStrokePrimitive3D( + const basegfx::B3DPolygon& rPolygon, + const attribute::LineAttribute& rLineAttribute, + const attribute::StrokeAttribute& rStrokeAttribute); + + /// data read access + basegfx::B3DPolygon getB3DPolygon() const { return maPolygon; } + const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } + const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/polygontubeprimitive3d.hxx b/include/drawinglayer/primitive3d/polygontubeprimitive3d.hxx new file mode 100644 index 000000000000..56f7dc4b4d4a --- /dev/null +++ b/include/drawinglayer/primitive3d/polygontubeprimitive3d.hxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/polygonprimitive3d.hxx> + +////////////////////////////////////////////////////////////////////////////// +// predefines + +namespace basegfx { + class B3DPolyPolygon; + class B3DHomMatrix; +} + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** PolygonStrokePrimitive3D class + + This 3D primitive extends a 3D hairline to a 3D tube which is + e.g. used for fat lines in 3D. It's decomposition will create all + 3D objects needed for the line tubes and the edge roundings + in full 3D. + */ + class DRAWINGLAYER_DLLPUBLIC PolygonTubePrimitive3D : public PolygonHairlinePrimitive3D + { + private: + /// hold the last decompositon since it's expensive + Primitive3DSequence maLast3DDecomposition; + + /// visualisation parameters + double mfRadius; + double mfDegreeStepWidth; + double mfMiterMinimumAngle; + basegfx::B2DLineJoin maLineJoin; + com::sun::star::drawing::LineCap maLineCap; + + protected: + /** access methods to maLast3DDecomposition. The usage of this methods may allow + later thread-safe stuff to be added if needed. Only to be used by getDecomposition() + implementations for buffering the last decomposition. + */ + const Primitive3DSequence& getLast3DDecomposition() const { return maLast3DDecomposition; } + void setLast3DDecomposition(const Primitive3DSequence& rNew) { maLast3DDecomposition = rNew; } + + /// local decomposition. + Primitive3DSequence impCreate3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + /// constructor + PolygonTubePrimitive3D( + const basegfx::B3DPolygon& rPolygon, + const basegfx::BColor& rBColor, + double fRadius, + basegfx::B2DLineJoin aLineJoin, + com::sun::star::drawing::LineCap aLineCap, + double fDegreeStepWidth = 10.0 * F_PI180, + double fMiterMinimumAngle = 15.0 * F_PI180); + + /// data read access + double getRadius() const { return mfRadius; } + double getDegreeStepWidth() const { return mfDegreeStepWidth; } + double getMiterMinimumAngle() const { return mfMiterMinimumAngle; } + basegfx::B2DLineJoin getLineJoin() const { return maLineJoin; } + com::sun::star::drawing::LineCap getLineCap() const { return maLineCap; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /** local decomposition. Use own buffering since we are not derived from + BufferedDecompositionPrimitive3D + */ + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/polypolygonprimitive3d.hxx b/include/drawinglayer/primitive3d/polypolygonprimitive3d.hxx new file mode 100644 index 000000000000..7f916afe978c --- /dev/null +++ b/include/drawinglayer/primitive3d/polypolygonprimitive3d.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#include <basegfx/polygon/b3dpolypolygon.hxx> +#include <drawinglayer/attribute/materialattribute3d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** PolyPolygonMaterialPrimitive3D class + + This primitive defines a planar 3D PolyPolygon filled with a single color. + This is one of the non-decomposable primitives, so a renderer + should proccess it. + + It is assumed here that the PolyPolgon is a single plane in 3D. + */ + class DRAWINGLAYER_DLLPUBLIC PolyPolygonMaterialPrimitive3D : public BasePrimitive3D + { + private: + /// the PolyPolygon geometry + basegfx::B3DPolyPolygon maPolyPolygon; + + /// the fill parameters + attribute::MaterialAttribute3D maMaterial; + + /// bitfield + unsigned mbDoubleSided : 1; + + public: + /// constructor + PolyPolygonMaterialPrimitive3D( + const basegfx::B3DPolyPolygon& rPolyPolygon, + const attribute::MaterialAttribute3D& rMaterial, + bool bDoubleSided); + + /// data read access + const basegfx::B3DPolyPolygon& getB3DPolyPolygon() const { return maPolyPolygon; } + const attribute::MaterialAttribute3D& getMaterial() const { return maMaterial; } + bool getDoubleSided() const { return mbDoubleSided; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// get range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx new file mode 100644 index 000000000000..513d120c5343 --- /dev/null +++ b/include/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** SdrCubePrimitive3D class + + This 3D primitive expands the SdrPrimitive3D to a 3D cube definition. + The cube is implicitely in unit coordinates and the given transformation + defines it's geometry in space. + */ + class DRAWINGLAYER_DLLPUBLIC SdrCubePrimitive3D : public SdrPrimitive3D + { + protected: + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + /// constructor + SdrCubePrimitive3D( + const basegfx::B3DHomMatrix& rTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute); + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// get range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx b/include/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx new file mode 100644 index 000000000000..ffe0e2cea676 --- /dev/null +++ b/include/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#include <com/sun/star/drawing/TextureProjectionMode.hpp> +#include <vector> + +////////////////////////////////////////////////////////////////////////////// +// predefines + +namespace basegfx { + class B3DPolygon; + class B3DPolyPolygon; + class B3DHomMatrix; + class B2DVector; +} + +namespace drawinglayer { namespace attribute { + class SdrLineAttribute; + class SdrFillAttribute; + class Sdr3DObjectAttribute; + class FillGradientAttribute; + class SdrShadowAttribute; +}} + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + // #i98295# + basegfx::B3DRange DRAWINGLAYER_DLLPUBLIC getRangeFrom3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill); + void DRAWINGLAYER_DLLPUBLIC applyNormalsKindSphereTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill, const basegfx::B3DRange& rRange); + void DRAWINGLAYER_DLLPUBLIC applyNormalsKindFlatTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill); + void DRAWINGLAYER_DLLPUBLIC applyNormalsInvertTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill); + + // #i98314# + void DRAWINGLAYER_DLLPUBLIC applyTextureTo3DGeometry( + ::com::sun::star::drawing::TextureProjectionMode eModeX, + ::com::sun::star::drawing::TextureProjectionMode eModeY, + ::std::vector< basegfx::B3DPolyPolygon >& rFill, + const basegfx::B3DRange& rRange, + const basegfx::B2DVector& rTextureSize); + + Primitive3DSequence DRAWINGLAYER_DLLPUBLIC create3DPolyPolygonLinePrimitives( + const basegfx::B3DPolyPolygon& rUnitPolyPolygon, + const basegfx::B3DHomMatrix& rObjectTransform, + const attribute::SdrLineAttribute& rLine); + + Primitive3DSequence DRAWINGLAYER_DLLPUBLIC create3DPolyPolygonFillPrimitives( + const ::std::vector< basegfx::B3DPolyPolygon >& r3DPolyPolygonVector, + const basegfx::B3DHomMatrix& rObjectTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::Sdr3DObjectAttribute& aSdr3DObjectAttribute, + const attribute::SdrFillAttribute& rFill, + const attribute::FillGradientAttribute& rFillGradient); + + Primitive3DSequence DRAWINGLAYER_DLLPUBLIC createShadowPrimitive3D( + const Primitive3DSequence& rSource, + const attribute::SdrShadowAttribute& rShadow, + bool bShadow3D); + + Primitive3DSequence DRAWINGLAYER_DLLPUBLIC createHiddenGeometryPrimitives3D( + const ::std::vector< basegfx::B3DPolyPolygon >& r3DPolyPolygonVector, + const basegfx::B3DHomMatrix& rObjectTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::Sdr3DObjectAttribute& aSdr3DObjectAttribute); + + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx b/include/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx new file mode 100644 index 000000000000..d741b4c1b223 --- /dev/null +++ b/include/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <basegfx/polygon/b3dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <vector> + +////////////////////////////////////////////////////////////////////////////// +// predefines + +namespace drawinglayer { namespace geometry { + class ViewInformation3D; +}} + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** SliceType3D definition */ + enum SliceType3D + { + SLICETYPE3D_REGULAR, // normal geoemtry Slice3D + SLICETYPE3D_FRONTCAP, // front cap + SLICETYPE3D_BACKCAP // back cap + }; + + /// class to hold one Slice3D + class DRAWINGLAYER_DLLPUBLIC Slice3D + { + protected: + basegfx::B3DPolyPolygon maPolyPolygon; + SliceType3D maSliceType; + + public: + Slice3D( + const basegfx::B2DPolyPolygon& rPolyPolygon, + const basegfx::B3DHomMatrix& aTransform, + SliceType3D aSliceType = SLICETYPE3D_REGULAR) + : maPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPolygon)), + maSliceType(aSliceType) + { + maPolyPolygon.transform(aTransform); + } + + explicit Slice3D( + const basegfx::B3DPolyPolygon& rPolyPolygon, + SliceType3D aSliceType = SLICETYPE3D_REGULAR) + : maPolyPolygon(rPolyPolygon), + maSliceType(aSliceType) + { + } + + // data access + const basegfx::B3DPolyPolygon& getB3DPolyPolygon() const { return maPolyPolygon; } + SliceType3D getSliceType() const { return maSliceType; } + }; + + /// typedef for a group of Slice3Ds + typedef ::std::vector< Slice3D > Slice3DVector; + + /// helpers for creation + void DRAWINGLAYER_DLLPUBLIC createLatheSlices( + Slice3DVector& rSliceVector, + const basegfx::B2DPolyPolygon& rSource, + double fBackScale, + double fDiagonal, + double fRotation, + sal_uInt32 nSteps, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack); + + void DRAWINGLAYER_DLLPUBLIC createExtrudeSlices( + Slice3DVector& rSliceVector, + const basegfx::B2DPolyPolygon& rSource, + double fBackScale, + double fDiagonal, + double fDepth, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack); + + /// helpers for geometry extraction + basegfx::B3DPolyPolygon DRAWINGLAYER_DLLPUBLIC extractHorizontalLinesFromSlice(const Slice3DVector& rSliceVector, bool bCloseHorLines); + basegfx::B3DPolyPolygon DRAWINGLAYER_DLLPUBLIC extractVerticalLinesFromSlice(const Slice3DVector& rSliceVector); + + void DRAWINGLAYER_DLLPUBLIC extractPlanesFromSlice( + ::std::vector< basegfx::B3DPolyPolygon >& rFill, + const Slice3DVector& rSliceVector, + bool bCreateNormals, + bool bSmoothHorizontalNormals, + bool bSmoothNormals, + bool bSmoothLids, + bool bClosed, + double fSmoothNormalsMix, + double fSmoothLidsMix, + bool bCreateTextureCoordinates, + const basegfx::B2DHomMatrix& rTexTransform); + + void DRAWINGLAYER_DLLPUBLIC createReducedOutlines( + const geometry::ViewInformation3D& rViewInformation, + const basegfx::B3DHomMatrix& rObjectTransform, + const basegfx::B3DPolygon& rLoopA, + const basegfx::B3DPolygon& rLoopB, + basegfx::B3DPolyPolygon& rTarget); + + } // end of namespace overlay +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx new file mode 100644 index 000000000000..055e7e71dd4c --- /dev/null +++ b/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** SdrExtrudePrimitive3D class + + This 3D primitive expands the SdrPrimitive3D to a 3D extrude definition. + The given 2D PolyPolygon geometry is imagined as lying on the XY-plane in 3D + and gets extruded in Z-Direction by Depth. + + Various possibilities e.g. for creating diagonals (edge roudings in 3D) + and similar are given. + + The decomposition will create all necessary 3D planes for visualisation. + */ + class DRAWINGLAYER_DLLPUBLIC SdrExtrudePrimitive3D : public SdrPrimitive3D + { + private: + /// geometry helper for slices + basegfx::B2DPolyPolygon maCorrectedPolyPolygon; + Slice3DVector maSlices; + + /// primitive geometry data + basegfx::B2DPolyPolygon maPolyPolygon; + double mfDepth; + double mfDiagonal; + double mfBackScale; + + /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition + geometry::ViewInformation3D* mpLastRLGViewInformation; + + /// bitfield + unsigned mbSmoothNormals : 1; // Plane self + unsigned mbSmoothHorizontalNormals : 1; // always + unsigned mbSmoothLids : 1; // Front/back + unsigned mbCharacterMode : 1; + unsigned mbCloseFront : 1; + unsigned mbCloseBack : 1; + + /// create slices + void impCreateSlices(); + + /// get (evtl. create) slices + const Slice3DVector& getSlices() const; + + protected: + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + /// constructor + SdrExtrudePrimitive3D( + const basegfx::B3DHomMatrix& rTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute, + const basegfx::B2DPolyPolygon& rPolyPolygon, + double fDepth, + double fDiagonal, + double fBackScale, + bool bSmoothNormals, + bool bSmoothHorizontalNormals, + bool bSmoothLids, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack); + virtual ~SdrExtrudePrimitive3D(); + + /// data read access + const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; } + double getDepth() const { return mfDepth; } + double getDiagonal() const { return mfDiagonal; } + double getBackScale() const { return mfBackScale; } + bool getSmoothNormals() const { return mbSmoothNormals; } + bool getSmoothHorizontalNormals() const { return mbSmoothHorizontalNormals; } + bool getSmoothLids() const { return mbSmoothLids; } + bool getCharacterMode() const { return mbCharacterMode; } + bool getCloseFront() const { return mbCloseFront; } + bool getCloseBack() const { return mbCloseBack; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// get range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// Overloaded to allow for reduced line mode to decide if to buffer decomposition or not + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx new file mode 100644 index 000000000000..7632e8e5985c --- /dev/null +++ b/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx @@ -0,0 +1,147 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** SdrLathePrimitive3D class + + This 3D primitive expands the SdrPrimitive3D to a 3D rotation definition. + The given 2D PolyPolygon geometry is imagined as lying on the XY-plane in 3D + and gets rotated around the Y-Axis. + + Various possibilities e.g. for creating diagonals (edge roudings in 3D) + and similar are given. + + The decomposition will create all necessary 3D planes for visualisation. + */ + class DRAWINGLAYER_DLLPUBLIC SdrLathePrimitive3D : public SdrPrimitive3D + { + private: + /// geometry helper for slices + basegfx::B2DPolyPolygon maCorrectedPolyPolygon; + Slice3DVector maSlices; + + /// primitive geometry data + basegfx::B2DPolyPolygon maPolyPolygon; + sal_uInt32 mnHorizontalSegments; + sal_uInt32 mnVerticalSegments; + double mfDiagonal; + double mfBackScale; + double mfRotation; + + /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition + geometry::ViewInformation3D* mpLastRLGViewInformation; + + /// bitfield + unsigned mbSmoothNormals : 1; // Plane self + unsigned mbSmoothHorizontalNormals : 1; // always + unsigned mbSmoothLids : 1; // Front/back + unsigned mbCharacterMode : 1; + unsigned mbCloseFront : 1; + unsigned mbCloseBack : 1; + + /// create slices + void impCreateSlices(); + + /// get (evtl. create) slices + const Slice3DVector& getSlices() const; + + protected: + /// local helpers + void impCreateOutlines( + const geometry::ViewInformation3D& rViewInformation, + const basegfx::B3DPolygon& rLoopA, + const basegfx::B3DPolygon& rLoopB, + basegfx::B3DPolyPolygon& rTarget) const; + + bool impHasCutWith( + const basegfx::B2DPolygon& rPoly, + const basegfx::B2DPoint& rStart, + const basegfx::B2DPoint& rEnd) const; + + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + /// constructor + SdrLathePrimitive3D( + const basegfx::B3DHomMatrix& rTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute, + const basegfx::B2DPolyPolygon& rPolyPolygon, + sal_uInt32 nHorizontalSegments, + sal_uInt32 nVerticalSegments, + double fDiagonal, + double fBackScale, + double fRotation, + bool bSmoothNormals, + bool bSmoothHorizontalNormals, + bool bSmoothLids, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack); + virtual ~SdrLathePrimitive3D(); + + /// data read access + const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; } + sal_uInt32 getHorizontalSegments() const { return mnHorizontalSegments; } + sal_uInt32 getVerticalSegments() const { return mnVerticalSegments; } + double getDiagonal() const { return mfDiagonal; } + double getBackScale() const { return mfBackScale; } + double getRotation() const { return mfRotation; } + bool getSmoothNormals() const { return mbSmoothNormals; } + bool getSmoothHorizontalNormals() const { return mbSmoothHorizontalNormals; } + bool getSmoothLids() const { return mbSmoothLids; } + bool getCharacterMode() const { return mbCharacterMode; } + bool getCloseFront() const { return mbCloseFront; } + bool getCloseBack() const { return mbCloseBack; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// get range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// Overloaded to allow for reduced line mode to decide if to buffer decomposition or not + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx new file mode 100644 index 000000000000..2d9976224e6b --- /dev/null +++ b/include/drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRPOLYPOLYGONPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRPOLYPOLYGONPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** SdrPolyPolygonPrimitive3D class + + This 3D primitive defines a PolyPolgon in space which may have + Line- and FillStyles and extra 3D surface attributes. It is assumed + that the given 3D PolyPolgon (which may contain texture and normal + information) is planar in 3D. + + The decomposition will include all needed 3D data for visualisation, + including FatLines and fill styles. + */ + class DRAWINGLAYER_DLLPUBLIC SdrPolyPolygonPrimitive3D : public SdrPrimitive3D + { + private: + /// the planar polyPolygon evtl with normals and texture coordinates + basegfx::B3DPolyPolygon maPolyPolygon3D; + + protected: + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + /// constructor + SdrPolyPolygonPrimitive3D( + const basegfx::B3DPolyPolygon& rPolyPolygon3D, + const basegfx::B3DHomMatrix& rTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute); + + /// data access + const basegfx::B3DPolyPolygon& getPolyPolygon3D() const { return maPolyPolygon3D; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// get range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRPOLYPOLYGONPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/sdrprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrprimitive3d.hxx new file mode 100644 index 000000000000..6563f5172f67 --- /dev/null +++ b/include/drawinglayer/primitive3d/sdrprimitive3d.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <drawinglayer/attribute/sdrallattribute3d.hxx> +#include <drawinglayer/primitive3d/sdrextrudelathetools3d.hxx> +#include <drawinglayer/attribute/sdrobjectattribute3d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + /** SdrPrimitive3D class + + Base class for the more complicated geometric primitives, so + derive from buffered primitive to allow overloading of + create3DDecomposition there. + */ + namespace primitive3d + { + class DRAWINGLAYER_DLLPUBLIC SdrPrimitive3D : public BufferedDecompositionPrimitive3D + { + private: + /// object surface attributes + basegfx::B3DHomMatrix maTransform; + basegfx::B2DVector maTextureSize; + attribute::SdrLineFillShadowAttribute3D maSdrLFSAttribute; + attribute::Sdr3DObjectAttribute maSdr3DObjectAttribute; + + protected: + /** Standard implementation for primitive3D which + will use maTransform as range and expand by evtl. line width / 2 + */ + basegfx::B3DRange getStandard3DRange() const; + + /** implementation for primitive3D which + will use given Slice3Ds and expand by evtl. line width / 2 + */ + basegfx::B3DRange get3DRangeFromSlices(const Slice3DVector& rSlices) const; + + public: + /// constructor + SdrPrimitive3D( + const basegfx::B3DHomMatrix& rTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute); + + /// data read access + const basegfx::B3DHomMatrix& getTransform() const { return maTransform; } + const basegfx::B2DVector& getTextureSize() const { return maTextureSize; } + const attribute::SdrLineFillShadowAttribute3D& getSdrLFSAttribute() const { return maSdrLFSAttribute; } + const attribute::Sdr3DObjectAttribute getSdr3DObjectAttribute() const { return maSdr3DObjectAttribute; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx new file mode 100644 index 000000000000..48e7ee42ceb2 --- /dev/null +++ b/include/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRSPHEREPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRSPHEREPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** SdrSpherePrimitive3D class + + This 3D primitive expands the SdrPrimitive3D to a 3D sphere definition. + The sphere is implicitely in unit coordinates and the given transformation + defines it's geometry in space. + */ + class DRAWINGLAYER_DLLPUBLIC SdrSpherePrimitive3D : public SdrPrimitive3D + { + private: + /// additional geometry definitions + sal_uInt32 mnHorizontalSegments; + sal_uInt32 mnVerticalSegments; + + protected: + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + /// constructor + SdrSpherePrimitive3D( + const basegfx::B3DHomMatrix& rTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute, + sal_uInt32 nHorizontalSegments, + sal_uInt32 nVerticalSegments); + + /// data read access + sal_uInt32 getHorizontalSegments() const { return mnHorizontalSegments; } + sal_uInt32 getVerticalSegments() const { return mnVerticalSegments; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// get range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRSPHEREPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/shadowprimitive3d.hxx b/include/drawinglayer/primitive3d/shadowprimitive3d.hxx new file mode 100644 index 000000000000..76be7e7742f4 --- /dev/null +++ b/include/drawinglayer/primitive3d/shadowprimitive3d.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** ShadowPrimitive3D class + + This 3D grouping primitive is used to define a shadow for + 3d geometry by embedding it. The shadow of 3D objects are + 2D polygons, so the shadow transformation is a 2D transformation. + + If the Shadow3D flag is set, the shadow definition has to be + combined with the scene and camera definition to create the correct + projected shadow 2D-Polygons. + */ + class DRAWINGLAYER_DLLPUBLIC ShadowPrimitive3D : public GroupPrimitive3D + { + protected: + /// 2D shadow definition + basegfx::B2DHomMatrix maShadowTransform; + basegfx::BColor maShadowColor; + double mfShadowTransparence; + + /// bitfield + unsigned mbShadow3D : 1; + + public: + /// constructor + ShadowPrimitive3D( + const basegfx::B2DHomMatrix& rShadowTransform, + const basegfx::BColor& rShadowColor, + double fShadowTransparence, + bool bShadow3D, + const Primitive3DSequence& rChildren); + + /// data read access + const basegfx::B2DHomMatrix& getShadowTransform() const { return maShadowTransform; } + const basegfx::BColor& getShadowColor() const { return maShadowColor; } + double getShadowTransparence() const { return mfShadowTransparence; } + bool getShadow3D() const { return mbShadow3D; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/textureprimitive3d.hxx b/include/drawinglayer/primitive3d/textureprimitive3d.hxx new file mode 100644 index 000000000000..1ce8e9bcd57c --- /dev/null +++ b/include/drawinglayer/primitive3d/textureprimitive3d.hxx @@ -0,0 +1,230 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> +#include <drawinglayer/attribute/fillbitmapattribute.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <drawinglayer/attribute/fillgradientattribute.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** TexturePrimitive3D class + + This 3D grouping primitive is used to define a texture for + 3d geometry by embedding it. It is used as bae class for + extended texture definitions + */ + class DRAWINGLAYER_DLLPUBLIC TexturePrimitive3D : public GroupPrimitive3D + { + private: + /// texture geometry definition + basegfx::B2DVector maTextureSize; + + /// bitfield + /// flag if texture shall be modulated with white interpolated color + unsigned mbModulate : 1; + + /// flag if texture shall be filtered + unsigned mbFilter : 1; + + public: + /// constructor + TexturePrimitive3D( + const Primitive3DSequence& rChildren, + const basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + + /// data read access + const basegfx::B2DVector& getTextureSize() const { return maTextureSize; } + bool getModulate() const { return mbModulate; } + bool getFilter() const { return mbFilter; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** UnifiedTransparenceTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a unified + transparence texture definition. All 3D primitives + embedded here will be shown with the given transparency. + */ + class DRAWINGLAYER_DLLPUBLIC UnifiedTransparenceTexturePrimitive3D : public TexturePrimitive3D + { + private: + /// transparency definition + double mfTransparence; + + public: + /// constructor + UnifiedTransparenceTexturePrimitive3D( + double fTransparence, + const Primitive3DSequence& rChildren); + + /// data read access + double getTransparence() const { return mfTransparence; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// own getB3DRange implementation to include transparent geometries to BoundRect calculations + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// local decomposition. + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** GradientTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a gradient texture + definition. All 3D primitives embedded here will be shown with the + defined gradient. + */ + class DRAWINGLAYER_DLLPUBLIC GradientTexturePrimitive3D : public TexturePrimitive3D + { + private: + /// the gradient definition + attribute::FillGradientAttribute maGradient; + + public: + /// constructor + GradientTexturePrimitive3D( + const attribute::FillGradientAttribute& rGradient, + const Primitive3DSequence& rChildren, + const basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + + /// data read access + const attribute::FillGradientAttribute& getGradient() const { return maGradient; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** BitmapTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a bitmap texture + definition. All 3D primitives embedded here will be shown with the + defined bitmap (maybe tiled if defined). + */ + class DRAWINGLAYER_DLLPUBLIC BitmapTexturePrimitive3D : public TexturePrimitive3D + { + private: + /// bitmap fill attribute + attribute::FillBitmapAttribute maFillBitmapAttribute; + + public: + /// constructor + BitmapTexturePrimitive3D( + const attribute::FillBitmapAttribute& rFillBitmapAttribute, + const Primitive3DSequence& rChildren, + const basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + + /// data read access + const attribute::FillBitmapAttribute& getFillBitmapAttribute() const { return maFillBitmapAttribute; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** TransparenceTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a transparence texture + definition. For transparence definition, a gradient is used. The values in + that gradient will be interpreted as luminance Transparence-Values. All 3D + primitives embedded here will be shown with the defined transparence. + */ + class DRAWINGLAYER_DLLPUBLIC TransparenceTexturePrimitive3D : public GradientTexturePrimitive3D + { + public: + /// constructor + TransparenceTexturePrimitive3D( + const attribute::FillGradientAttribute& rGradient, + const Primitive3DSequence& rChildren, + const basegfx::B2DVector& rTextureSize); + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive3d/transformprimitive3d.hxx b/include/drawinglayer/primitive3d/transformprimitive3d.hxx new file mode 100644 index 000000000000..85a88a330d77 --- /dev/null +++ b/include/drawinglayer/primitive3d/transformprimitive3d.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> +#include <basegfx/matrix/b3dhommatrix.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /** TransformPrimitive3D class + + This is one of the basic grouping 3D primitives and it provides + embedding a sequence of primitives (a geometry) into a + 3D transformation. + + Please see the description for TransformPrimitive2D since these + primitives are pretty similar. + */ + class DRAWINGLAYER_DLLPUBLIC TransformPrimitive3D : public GroupPrimitive3D + { + private: + // the 3D transformation to apply + basegfx::B3DHomMatrix maTransformation; + + public: + /// constructor + TransformPrimitive3D( + const basegfx::B3DHomMatrix& rTransformation, + const Primitive3DSequence& rChildren); + + /// data read access + const basegfx::B3DHomMatrix& getTransformation() const { return maTransformation; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const; + + /// get range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |