diff options
Diffstat (limited to 'drawinglayer/inc/primitive3d')
6 files changed, 586 insertions, 0 deletions
diff --git a/drawinglayer/inc/primitive3d/hatchtextureprimitive3d.hxx b/drawinglayer/inc/primitive3d/hatchtextureprimitive3d.hxx new file mode 100644 index 0000000000..a60c4da9d0 --- /dev/null +++ b/drawinglayer/inc/primitive3d/hatchtextureprimitive3d.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 . + */ + +#pragma once + +#include <primitive3d/textureprimitive3d.hxx> +#include <drawinglayer/attribute/fillhatchattribute.hxx> + + +namespace drawinglayer::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 HatchTexturePrimitive3D final : public TexturePrimitive3D + { + /// the hatch definition + attribute::FillHatchAttribute maHatch; + + /// the buffered decomposed hatch + Primitive3DContainer maBuffered3DDecomposition; + + /// helper: local decomposition + Primitive3DContainer impCreate3DDecomposition() const; + + /// local access methods to maBufferedDecomposition + const Primitive3DContainer& getBuffered3DDecomposition() const { return maBuffered3DDecomposition; } + + public: + /// constructor + HatchTexturePrimitive3D( + attribute::FillHatchAttribute aHatch, + const Primitive3DContainer& 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 override; + + /// local decomposition. + virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + +} // end of namespace drawinglayer::primitive3d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/hiddengeometryprimitive3d.hxx b/drawinglayer/inc/primitive3d/hiddengeometryprimitive3d.hxx new file mode 100644 index 0000000000..45de83380b --- /dev/null +++ b/drawinglayer/inc/primitive3d/hiddengeometryprimitive3d.hxx @@ -0,0 +1,57 @@ +/* -*- 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 . + */ + +#pragma once + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> + + +namespace drawinglayer::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 + // primitive when there is no fill geometry. Currently, the 3d hit test + // uses only areas, so maybe in a further enhanced 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 its children subcontent. + class HiddenGeometryPrimitive3D final : public GroupPrimitive3D + { + public: + explicit HiddenGeometryPrimitive3D(const Primitive3DContainer& 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 override; + + /// The default implementation returns an empty sequence + virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override; + + // provide unique ID + DeclPrimitive3DIDBlock() + }; + +} // end of namespace drawinglayer::primitive3d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/polygontubeprimitive3d.hxx b/drawinglayer/inc/primitive3d/polygontubeprimitive3d.hxx new file mode 100644 index 0000000000..38372977e1 --- /dev/null +++ b/drawinglayer/inc/primitive3d/polygontubeprimitive3d.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 . + */ + +#pragma once + +#include <drawinglayer/primitive3d/polygonprimitive3d.hxx> + + +namespace drawinglayer::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 PolygonTubePrimitive3D final : public PolygonHairlinePrimitive3D + { + /// hold the last decomposition since it's expensive + Primitive3DContainer maLast3DDecomposition; + + /// visualisation parameters + double mfRadius; + double mfDegreeStepWidth; + double mfMiterMinimumAngle; + basegfx::B2DLineJoin maLineJoin; + css::drawing::LineCap maLineCap; + + /** 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 Primitive3DContainer& getLast3DDecomposition() const { return maLast3DDecomposition; } + + /// local decomposition. + Primitive3DContainer impCreate3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + /// constructor + PolygonTubePrimitive3D( + const basegfx::B3DPolygon& rPolygon, + const basegfx::BColor& rBColor, + double fRadius, + basegfx::B2DLineJoin aLineJoin, + css::drawing::LineCap aLineCap, + double fDegreeStepWidth = basegfx::deg2rad(10.0), + double fMiterMinimumAngle = basegfx::deg2rad(15.0)); + + /// data read access + double getRadius() const { return mfRadius; } + double getDegreeStepWidth() const { return mfDegreeStepWidth; } + double getMiterMinimumAngle() const { return mfMiterMinimumAngle; } + basegfx::B2DLineJoin getLineJoin() const { return maLineJoin; } + css::drawing::LineCap getLineCap() const { return maLineCap; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /** local decomposition. Use own buffering since we are not derived from + BufferedDecompositionPrimitive3D + */ + virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + +} // end of namespace drawinglayer::primitive3d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/sdrdecompositiontools3d.hxx b/drawinglayer/inc/primitive3d/sdrdecompositiontools3d.hxx new file mode 100644 index 0000000000..6e549289b2 --- /dev/null +++ b/drawinglayer/inc/primitive3d/sdrdecompositiontools3d.hxx @@ -0,0 +1,87 @@ +/* -*- 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 . + */ + +#pragma once + +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#include <com/sun/star/drawing/TextureProjectionMode.hpp> +#include <vector> + + +// predefines + +namespace basegfx { + class B3DPolyPolygon; + class B3DHomMatrix; + class B2DVector; +} + +namespace drawinglayer::attribute { + class SdrLineAttribute; + class SdrFillAttribute; + class Sdr3DObjectAttribute; + class FillGradientAttribute; + class SdrShadowAttribute; +} + + +namespace drawinglayer::primitive3d + { + // #i98295# + basegfx::B3DRange getRangeFrom3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill); + void applyNormalsKindSphereTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill, const basegfx::B3DRange& rRange); + void applyNormalsKindFlatTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill); + void applyNormalsInvertTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill); + + // #i98314# + void applyTextureTo3DGeometry( + css::drawing::TextureProjectionMode eModeX, + css::drawing::TextureProjectionMode eModeY, + ::std::vector< basegfx::B3DPolyPolygon >& rFill, + const basegfx::B3DRange& rRange, + const basegfx::B2DVector& rTextureSize); + + Primitive3DContainer create3DPolyPolygonLinePrimitives( + const basegfx::B3DPolyPolygon& rUnitPolyPolygon, + const basegfx::B3DHomMatrix& rObjectTransform, + const attribute::SdrLineAttribute& rLine); + + Primitive3DContainer 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); + + Primitive3DContainer createShadowPrimitive3D( + const Primitive3DContainer& rSource, + const attribute::SdrShadowAttribute& rShadow, + bool bShadow3D); + + Primitive3DContainer createHiddenGeometryPrimitives3D( + const ::std::vector< basegfx::B3DPolyPolygon >& r3DPolyPolygonVector, + const basegfx::B3DHomMatrix& rObjectTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::Sdr3DObjectAttribute& aSdr3DObjectAttribute); + +} // end of namespace drawinglayer::primitive3d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/shadowprimitive3d.hxx b/drawinglayer/inc/primitive3d/shadowprimitive3d.hxx new file mode 100644 index 0000000000..06d4e9f49d --- /dev/null +++ b/drawinglayer/inc/primitive3d/shadowprimitive3d.hxx @@ -0,0 +1,73 @@ +/* -*- 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 . + */ + +#pragma once + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> + + +namespace drawinglayer::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 ShadowPrimitive3D final : public GroupPrimitive3D + { + /// 2D shadow definition + basegfx::B2DHomMatrix maShadowTransform; + basegfx::BColor maShadowColor; + double mfShadowTransparence; + + bool mbShadow3D : 1; + + public: + /// constructor + ShadowPrimitive3D( + basegfx::B2DHomMatrix aShadowTransform, + const basegfx::BColor& rShadowColor, + double fShadowTransparence, + bool bShadow3D, + const Primitive3DContainer& 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 override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + +} // end of namespace drawinglayer::primitive3d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/textureprimitive3d.hxx b/drawinglayer/inc/primitive3d/textureprimitive3d.hxx new file mode 100644 index 0000000000..56586217bd --- /dev/null +++ b/drawinglayer/inc/primitive3d/textureprimitive3d.hxx @@ -0,0 +1,207 @@ +/* -*- 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 . + */ + +#pragma once + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> +#include <drawinglayer/attribute/fillgraphicattribute.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <drawinglayer/attribute/fillgradientattribute.hxx> + + +namespace drawinglayer::primitive3d + { + /** TexturePrimitive3D class + + This 3D grouping primitive is used to define a texture for + 3d geometry by embedding it. It is used as base class for + extended texture definitions + */ + class TexturePrimitive3D : public GroupPrimitive3D + { + private: + /// texture geometry definition + basegfx::B2DVector maTextureSize; + + /// flag if texture shall be modulated with white interpolated color + bool mbModulate : 1; + + /// flag if texture shall be filtered + bool mbFilter : 1; + + public: + /// constructor + TexturePrimitive3D( + const Primitive3DContainer& 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 override; + }; + +} // end of namespace drawinglayer::primitive3d + + +namespace drawinglayer::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 UnifiedTransparenceTexturePrimitive3D final : public TexturePrimitive3D + { + private: + /// transparency definition + double mfTransparence; + + public: + /// constructor + UnifiedTransparenceTexturePrimitive3D( + double fTransparence, + const Primitive3DContainer& rChildren); + + /// data read access + double getTransparence() const { return mfTransparence; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /// own getB3DRange implementation to include transparent geometries to BoundRect calculations + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const override; + + /// local decomposition. + virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + +} // end of namespace drawinglayer::primitive3d + + +namespace drawinglayer::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 GradientTexturePrimitive3D : public TexturePrimitive3D + { + private: + /// the gradient definition + attribute::FillGradientAttribute maGradient; + + public: + /// constructor + GradientTexturePrimitive3D( + attribute::FillGradientAttribute aGradient, + const Primitive3DContainer& 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 override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + +} // end of namespace drawinglayer::primitive3d + + +namespace drawinglayer::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 BitmapTexturePrimitive3D final : public TexturePrimitive3D + { + private: + /// bitmap fill attribute + attribute::FillGraphicAttribute maFillGraphicAttribute; + + public: + /// constructor + BitmapTexturePrimitive3D( + const attribute::FillGraphicAttribute& rFillGraphicAttribute, + const Primitive3DContainer& rChildren, + const basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + + /// data read access + const attribute::FillGraphicAttribute& getFillGraphicAttribute() const { return maFillGraphicAttribute; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + +} // end of namespace drawinglayer::primitive3d + + +namespace drawinglayer::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 TransparenceTexturePrimitive3D final : public GradientTexturePrimitive3D + { + public: + /// constructor + TransparenceTexturePrimitive3D( + const attribute::FillGradientAttribute& rGradient, + const Primitive3DContainer& rChildren, + const basegfx::B2DVector& rTextureSize); + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + +} // end of namespace drawinglayer::primitive3d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |