1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLHATCHPRIMITIVE2D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLHATCHPRIMITIVE2D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive2d/primitivetools2d.hxx>
29 #include <drawinglayer/attribute/fillhatchattribute.hxx>
30 #include <basegfx/color/bcolor.hxx>
31 
32 //////////////////////////////////////////////////////////////////////////////
33 // FillHatchPrimitive2D class
34 
35 namespace drawinglayer
36 {
37     namespace primitive2d
38     {
39         /** FillHatchPrimitive2D class
40 
41             This class defines a hatch filling for a rectangular area. The
42             Range is defined by the Transformation, the hatch by the FillHatchAttribute.
43             If the background is to be filled, a flag in FillHatchAttribute is set and
44             the BColor defines the background color.
45 
46             #120230# This primitive is now evtl. metric dependent due to the value
47             MinimalDiscreteDistance in the FillHatchAttribute if the value is not zero.
48             This is used for a more appealing, VCL-like visualisation by not letting the
49             distances get too small between lines.
50 
51             The decomposition will deliver the hatch lines.
52          */
53         class DRAWINGLAYER_DLLPUBLIC FillHatchPrimitive2D : public DiscreteMetricDependentPrimitive2D
54         {
55         private:
56             /// the geometrically visible area
57             basegfx::B2DRange                       maOutputRange;
58 
59             /// the area the gradient definition is based on
60             /// in the simplest case identical to OutputRange
61             basegfx::B2DRange                       maDefinitionRange;
62 
63             /// the hatch definition
64             attribute::FillHatchAttribute           maFillHatch;
65 
66             /// hatch background color (if used)
67             basegfx::BColor                         maBColor;
68 
69         protected:
70             /// local decomposition.
71             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
72 
73         public:
74             /// constructors. The one without definition range will use output range as definition range
75             FillHatchPrimitive2D(
76                 const basegfx::B2DRange& rOutputRange,
77                 const basegfx::BColor& rBColor,
78                 const attribute::FillHatchAttribute& rFillHatch);
79             FillHatchPrimitive2D(
80                 const basegfx::B2DRange& rOutputRange,
81                 const basegfx::B2DRange& rDefinitionRange,
82                 const basegfx::BColor& rBColor,
83                 const attribute::FillHatchAttribute& rFillHatch);
84 
85             /// data read access
getOutputRange() const86             const basegfx::B2DRange& getOutputRange() const { return maOutputRange; }
getDefinitionRange() const87             const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; }
getFillHatch() const88             const attribute::FillHatchAttribute& getFillHatch() const { return maFillHatch; }
getBColor() const89             const basegfx::BColor& getBColor() const { return maBColor; }
90 
91             /// compare operator
92             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
93 
94             /// get range
95             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
96 
97             /// get local decomposition. Overloaded since this decomposition is view-dependent
98             virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
99 
100             /// provide unique ID
101             DeclPrimitrive2DIDBlock()
102         };
103     } // end of namespace primitive2d
104 } // end of namespace drawinglayer
105 
106 //////////////////////////////////////////////////////////////////////////////
107 
108 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLHATCHPRIMITIVE2D_HXX
109 
110 //////////////////////////////////////////////////////////////////////////////
111 // eof
112