1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
29 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
30 
31 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
32 #include <drawinglayer/attribute/fillgradientattribute.hxx>
33 
34 //////////////////////////////////////////////////////////////////////////////
35 // predefines
36 
37 namespace basegfx { class B2DPolygon; }
38 
39 //////////////////////////////////////////////////////////////////////////////
40 // FillGradientPrimitive2D class
41 
42 namespace drawinglayer
43 {
44 	namespace primitive2d
45 	{
46         /** FillGradientPrimitive2D class
47 
48             This class defines a gradient filling for a rectangular area. The
49             Range is defined by the Transformation, the gradient by the FillGradientAttribute.
50 
51             The decomposition will deliver the decomposed gradient, e.g. for an ellipse
52             gradient the various ellipses in various color steps will be created.
53 
54             I have added functionality to create both versions of filled decompositions:
55             Those who overlap and non-overlapping ones. The overlapping version is the
56             default one since it works with and without AntiAliasing. The non-overlapping
57             version is used in the MetafilePrimitive2D decomposition when the old XOR
58             paint was recorded.
59          */
60 		class FillGradientPrimitive2D : public BufferedDecompositionPrimitive2D
61 		{
62 		private:
63             /// the geometric definition
64 			basegfx::B2DRange						maObjectRange;
65 
66             /// the gradient definition
67 			attribute::FillGradientAttribute		maFillGradient;
68 
69             /// local helpers
70             void generateMatricesAndColors(
71                 std::vector< basegfx::B2DHomMatrix >& rMatrices,
72                 std::vector< basegfx::BColor >& rColors) const;
73             Primitive2DSequence createOverlappingFill(
74                 const std::vector< basegfx::B2DHomMatrix >& rMatrices,
75                 const std::vector< basegfx::BColor >& rColors,
76                 const basegfx::B2DPolygon& rUnitPolygon) const;
77             Primitive2DSequence createNonOverlappingFill(
78                 const std::vector< basegfx::B2DHomMatrix >& rMatrices,
79                 const std::vector< basegfx::BColor >& rColors,
80                 const basegfx::B2DPolygon& rUnitPolygon) const;
81 
82 		protected:
83             /// local helper
84     		Primitive2DSequence createFill(bool bOverlapping) const;
85 
86             /// local decomposition.
87 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
88 
89 		public:
90             /// constructor
91 			FillGradientPrimitive2D(
92 				const basegfx::B2DRange& rObjectRange,
93 				const attribute::FillGradientAttribute& rFillGradient);
94 
95 			/// data read access
96 			const basegfx::B2DRange& getObjectRange() const { return maObjectRange; }
97 			const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; }
98 
99 			/// compare operator
100 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
101 
102 			/// get range
103 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
104 
105 			/// provide unique ID
106 			DeclPrimitrive2DIDBlock()
107 		};
108 	} // end of namespace primitive2d
109 } // end of namespace drawinglayer
110 
111 //////////////////////////////////////////////////////////////////////////////
112 
113 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
114 
115 //////////////////////////////////////////////////////////////////////////////
116 // eof
117