Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX
30 : : #define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX
31 : :
32 : : #include <drawinglayer/drawinglayerdllapi.h>
33 : :
34 : : #include <drawinglayer/primitive3d/sdrprimitive3d.hxx>
35 : : #include <basegfx/polygon/b2dpolypolygon.hxx>
36 : :
37 : : //////////////////////////////////////////////////////////////////////////////
38 : :
39 : : namespace drawinglayer
40 : : {
41 : : namespace primitive3d
42 : : {
43 : : /** SdrLathePrimitive3D class
44 : :
45 : : This 3D primitive expands the SdrPrimitive3D to a 3D rotation definition.
46 : : The given 2D PolyPolygon geometry is imagined as lying on the XY-plane in 3D
47 : : and gets rotated around the Y-Axis.
48 : :
49 : : Various possibilities e.g. for creating diagonals (edge roudings in 3D)
50 : : and similar are given.
51 : :
52 : : The decomposition will create all necessary 3D planes for visualisation.
53 : : */
54 : : class DRAWINGLAYER_DLLPUBLIC SdrLathePrimitive3D : public SdrPrimitive3D
55 : : {
56 : : private:
57 : : /// geometry helper for slices
58 : : basegfx::B2DPolyPolygon maCorrectedPolyPolygon;
59 : : Slice3DVector maSlices;
60 : :
61 : : /// primitive geometry data
62 : : basegfx::B2DPolyPolygon maPolyPolygon;
63 : : sal_uInt32 mnHorizontalSegments;
64 : : sal_uInt32 mnVerticalSegments;
65 : : double mfDiagonal;
66 : : double mfBackScale;
67 : : double mfRotation;
68 : :
69 : : /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition
70 : : geometry::ViewInformation3D* mpLastRLGViewInformation;
71 : :
72 : : /// bitfield
73 : : unsigned mbSmoothNormals : 1; // Plane self
74 : : unsigned mbSmoothHorizontalNormals : 1; // always
75 : : unsigned mbSmoothLids : 1; // Front/back
76 : : unsigned mbCharacterMode : 1;
77 : : unsigned mbCloseFront : 1;
78 : : unsigned mbCloseBack : 1;
79 : :
80 : : /// create slices
81 : : void impCreateSlices();
82 : :
83 : : /// get (evtl. create) slices
84 : : const Slice3DVector& getSlices() const;
85 : :
86 : : protected:
87 : : /// local helpers
88 : : void impCreateOutlines(
89 : : const geometry::ViewInformation3D& rViewInformation,
90 : : const basegfx::B3DPolygon& rLoopA,
91 : : const basegfx::B3DPolygon& rLoopB,
92 : : basegfx::B3DPolyPolygon& rTarget) const;
93 : :
94 : : bool impHasCutWith(
95 : : const basegfx::B2DPolygon& rPoly,
96 : : const basegfx::B2DPoint& rStart,
97 : : const basegfx::B2DPoint& rEnd) const;
98 : :
99 : : /// local decomposition.
100 : : virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const;
101 : :
102 : : public:
103 : : /// constructor
104 : : SdrLathePrimitive3D(
105 : : const basegfx::B3DHomMatrix& rTransform,
106 : : const basegfx::B2DVector& rTextureSize,
107 : : const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
108 : : const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute,
109 : : const basegfx::B2DPolyPolygon& rPolyPolygon,
110 : : sal_uInt32 nHorizontalSegments,
111 : : sal_uInt32 nVerticalSegments,
112 : : double fDiagonal,
113 : : double fBackScale,
114 : : double fRotation,
115 : : bool bSmoothNormals,
116 : : bool bSmoothHorizontalNormals,
117 : : bool bSmoothLids,
118 : : bool bCharacterMode,
119 : : bool bCloseFront,
120 : : bool bCloseBack);
121 : : virtual ~SdrLathePrimitive3D();
122 : :
123 : : /// data read access
124 : 0 : const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; }
125 : 0 : sal_uInt32 getHorizontalSegments() const { return mnHorizontalSegments; }
126 : 0 : sal_uInt32 getVerticalSegments() const { return mnVerticalSegments; }
127 : 0 : double getDiagonal() const { return mfDiagonal; }
128 : 0 : double getBackScale() const { return mfBackScale; }
129 : 0 : double getRotation() const { return mfRotation; }
130 : 0 : bool getSmoothNormals() const { return mbSmoothNormals; }
131 : 0 : bool getSmoothHorizontalNormals() const { return mbSmoothHorizontalNormals; }
132 : 0 : bool getSmoothLids() const { return mbSmoothLids; }
133 : 0 : bool getCharacterMode() const { return mbCharacterMode; }
134 : 0 : bool getCloseFront() const { return mbCloseFront; }
135 : 0 : bool getCloseBack() const { return mbCloseBack; }
136 : :
137 : : /// compare operator
138 : : virtual bool operator==(const BasePrimitive3D& rPrimitive) const;
139 : :
140 : : /// get range
141 : : virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const;
142 : :
143 : : /// Overloaded to allow for reduced line mode to decide if to buffer decomposition or not
144 : : virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const;
145 : :
146 : : /// provide unique ID
147 : : DeclPrimitrive3DIDBlock()
148 : : };
149 : : } // end of namespace primitive3d
150 : : } // end of namespace drawinglayer
151 : :
152 : : //////////////////////////////////////////////////////////////////////////////
153 : :
154 : : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX
155 : :
156 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|