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_PRIMITIVE2D_FILLHATCHPRIMITIVE2D_HXX
21 : #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLHATCHPRIMITIVE2D_HXX
22 :
23 : #include <drawinglayer/drawinglayerdllapi.h>
24 :
25 : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 : #include <drawinglayer/primitive2d/primitivetools2d.hxx>
27 : #include <drawinglayer/attribute/fillhatchattribute.hxx>
28 : #include <basegfx/color/bcolor.hxx>
29 :
30 :
31 : // FillHatchPrimitive2D class
32 :
33 : namespace drawinglayer
34 : {
35 : namespace primitive2d
36 : {
37 : /** FillHatchPrimitive2D class
38 :
39 : This class defines a hatch filling for a rectangular area. The
40 : Range is defined by the Transformation, the hatch by the FillHatchAttribute.
41 : If the background is to be filled, a flag in FillHatchAttribute is set and
42 : the BColor defines the background color.
43 :
44 : #i120230# This primitive is now evtl. metric dependent due to the value
45 : MinimalDiscreteDistance in the FillHatchAttribute if the value is not zero.
46 : This is used for a more appealing, VCL-like visualisation by not letting the
47 : distances get too small between lines.
48 :
49 : The decomposition will deliver the hatch lines.
50 : */
51 2966 : class DRAWINGLAYER_DLLPUBLIC FillHatchPrimitive2D : public DiscreteMetricDependentPrimitive2D
52 : {
53 : private:
54 : /// the geometrically visible area
55 : basegfx::B2DRange maOutputRange;
56 :
57 : /// the area the gradient definition is based on
58 : /// in the simplest case identical to OutputRange
59 : basegfx::B2DRange maDefinitionRange;
60 :
61 : /// the hatch definition
62 : attribute::FillHatchAttribute maFillHatch;
63 :
64 : /// hatch background color (if used)
65 : basegfx::BColor maBColor;
66 :
67 : protected:
68 : /// local decomposition.
69 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
70 :
71 : public:
72 : /// constructors. The one without definition range will use output range as definition range
73 : FillHatchPrimitive2D(
74 : const basegfx::B2DRange& rOutputRange,
75 : const basegfx::BColor& rBColor,
76 : const attribute::FillHatchAttribute& rFillHatch);
77 : FillHatchPrimitive2D(
78 : const basegfx::B2DRange& rOutputRange,
79 : const basegfx::B2DRange& rDefinitionRange,
80 : const basegfx::BColor& rBColor,
81 : const attribute::FillHatchAttribute& rFillHatch);
82 :
83 : /// data read access
84 579 : const basegfx::B2DRange& getOutputRange() const { return maOutputRange; }
85 6 : const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; }
86 630 : const attribute::FillHatchAttribute& getFillHatch() const { return maFillHatch; }
87 573 : const basegfx::BColor& getBColor() const { return maBColor; }
88 :
89 : /// compare operator
90 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
91 :
92 : /// get range
93 : virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
94 :
95 : /// Override standard getDecomposition to be view-dependent here
96 : virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
97 :
98 : /// provide unique ID
99 : DeclPrimitive2DIDBlock()
100 : };
101 : } // end of namespace primitive2d
102 : } // end of namespace drawinglayer
103 :
104 :
105 :
106 : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLHATCHPRIMITIVE2D_HXX
107 :
108 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|