Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX
21 : #define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX
22 :
23 : #include <drawinglayer/drawinglayerdllapi.h>
24 :
25 : #include <drawinglayer/primitive3d/sdrprimitive3d.hxx>
26 : #include <basegfx/polygon/b2dpolypolygon.hxx>
27 :
28 : //////////////////////////////////////////////////////////////////////////////
29 :
30 : namespace drawinglayer
31 : {
32 : namespace primitive3d
33 : {
34 : /** SdrExtrudePrimitive3D class
35 :
36 : This 3D primitive expands the SdrPrimitive3D to a 3D extrude definition.
37 : The given 2D PolyPolygon geometry is imagined as lying on the XY-plane in 3D
38 : and gets extruded in Z-Direction by Depth.
39 :
40 : Various possibilities e.g. for creating diagonals (edge roudings in 3D)
41 : and similar are given.
42 :
43 : The decomposition will create all necessary 3D planes for visualisation.
44 : */
45 : class DRAWINGLAYER_DLLPUBLIC SdrExtrudePrimitive3D : public SdrPrimitive3D
46 : {
47 : private:
48 : /// geometry helper for slices
49 : basegfx::B2DPolyPolygon maCorrectedPolyPolygon;
50 : Slice3DVector maSlices;
51 :
52 : /// primitive geometry data
53 : basegfx::B2DPolyPolygon maPolyPolygon;
54 : double mfDepth;
55 : double mfDiagonal;
56 : double mfBackScale;
57 :
58 : /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition
59 : geometry::ViewInformation3D* mpLastRLGViewInformation;
60 :
61 : /// bitfield
62 : unsigned mbSmoothNormals : 1; // Plane self
63 : unsigned mbSmoothHorizontalNormals : 1; // always
64 : unsigned mbSmoothLids : 1; // Front/back
65 : unsigned mbCharacterMode : 1;
66 : unsigned mbCloseFront : 1;
67 : unsigned mbCloseBack : 1;
68 :
69 : /// create slices
70 : void impCreateSlices();
71 :
72 : /// get (evtl. create) slices
73 : const Slice3DVector& getSlices() const;
74 :
75 : protected:
76 : /// local decomposition.
77 : virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const;
78 :
79 : public:
80 : /// constructor
81 : SdrExtrudePrimitive3D(
82 : const basegfx::B3DHomMatrix& rTransform,
83 : const basegfx::B2DVector& rTextureSize,
84 : const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
85 : const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute,
86 : const basegfx::B2DPolyPolygon& rPolyPolygon,
87 : double fDepth,
88 : double fDiagonal,
89 : double fBackScale,
90 : bool bSmoothNormals,
91 : bool bSmoothHorizontalNormals,
92 : bool bSmoothLids,
93 : bool bCharacterMode,
94 : bool bCloseFront,
95 : bool bCloseBack);
96 : virtual ~SdrExtrudePrimitive3D();
97 :
98 : /// data read access
99 0 : const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; }
100 0 : double getDepth() const { return mfDepth; }
101 0 : double getDiagonal() const { return mfDiagonal; }
102 0 : double getBackScale() const { return mfBackScale; }
103 0 : bool getSmoothNormals() const { return mbSmoothNormals; }
104 0 : bool getSmoothHorizontalNormals() const { return mbSmoothHorizontalNormals; }
105 0 : bool getSmoothLids() const { return mbSmoothLids; }
106 0 : bool getCharacterMode() const { return mbCharacterMode; }
107 0 : bool getCloseFront() const { return mbCloseFront; }
108 0 : bool getCloseBack() const { return mbCloseBack; }
109 :
110 : /// compare operator
111 : virtual bool operator==(const BasePrimitive3D& rPrimitive) const;
112 :
113 : /// get range
114 : virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const;
115 :
116 : /// Overloaded to allow for reduced line mode to decide if to buffer decomposition or not
117 : virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const;
118 :
119 : /// provide unique ID
120 : DeclPrimitrive3DIDBlock()
121 : };
122 : } // end of namespace primitive3d
123 : } // end of namespace drawinglayer
124 :
125 : //////////////////////////////////////////////////////////////////////////////
126 :
127 : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX
128 :
129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|