1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_BASEGFX_POLYGON_B2DLINEGEOMETRY_HXX
21 #define INCLUDED_BASEGFX_POLYGON_B2DLINEGEOMETRY_HXX
23 #include <sal/types.h>
24 #include <basegfx/numeric/ftools.hxx>
25 #include <basegfx/polygon/b2dpolypolygon.hxx>
26 #include <basegfx/polygon/b2dpolygon.hxx>
27 #include <com/sun/star/drawing/LineCap.hpp>
28 #include <basegfx/basegfxdllapi.h>
36 /** Create line start/end geometry element, mostly arrows and things like that.
39 The polygon which needs to get that line ends and needs to have two points
43 The line start/end geometry. It is assumed that the tip is pointing
44 upwards. Result will be rotated and scaled to fit.
47 describes if creation is for start or end of candidate.
50 defines the size of the element, it's describing the target width in X
53 @param fDockingPosition needs to be in [0.0 ..1.0] range, where 0.0 means
54 that the tip of the arrow will be aligned with the polygon start, 1.0 means
55 the bottom. The default of 0.5 describes a centered arrow.
57 @param pConsumedLength
58 Using this parameter it is possible to get back how much from the candidate
59 geometry is overlapped by the created element (consumed).
61 @param fCandidateLength
62 This should contain the length of rCandidate to allow work without
63 again calculating the length (which may be expensive with beziers). If 0.0 is
64 given, the length is calculated on demand.
67 When it is necessary to count with the thickness of the line, it
68 makes sense to move the start position slightly - so define the shift.
71 The Line start and end polygon, correctly rotated and scaled
73 BASEGFX_DLLPUBLIC B2DPolyPolygon
createAreaGeometryForLineStartEnd(
74 const B2DPolygon
& rCandidate
,
75 const B2DPolyPolygon
& rArrow
,
78 double fCandidateLength
= 0.0, // 0.0 -> calculate self
79 double fDockingPosition
= 0.5, // 0->top, 1->bottom
80 double* pConsumedLength
= 0L,
83 /** create filled polygon geometry for lines with a line width
85 This method will create bezier based, fillable polygons which
86 will resample the curve if it was extended for the given half
87 line width. It will remove extrema positions from contained
88 bezier segments and get as close as possible and defined by
89 the given parameters to the ideal result.
91 It will check edges for trivial bezier to avoid unnecessary
92 bezier polygons. Care is taken to produce the in-between
93 polygon points (the ones original on the source poygon) since
94 it has showed that without those, the raster converters leave
98 The source polygon defining the hairline polygon path
100 @param fHalfLineWidth
101 The width of the line to one side
104 The LineJoin if the edges meeting in a point do not have a C1
108 The kind of cap, which is added to the line.
110 @param fMaxAllowedAngle
111 Allows to hand over the maximum allowed angle between an edge and
112 it's control vectors. The smaller, the more subdivisions will be
113 needed to create the filled geometry. Allowed range is cropped to
114 [F_PI2 .. 0.01 * F_PI2].
116 @param fMaxPartOfEdge
117 Allows to influence from with relative length of a control vector
118 compared to it's edge a split is forced. The smaller, the more
119 subdivisions will be needed to create the filled geometry. Allowed
120 range is cropped to [1.0 .. 0.01]
122 @praram fMiterMinimumAngle
123 The minimum wanted angle between two edges when edge rounding
124 is using miter. When an edge is smaller than this (tighter)
125 the usual fallback to bevel is used. Allowed range is cropped
126 to [F_PI .. 0.01 * F_PI].
129 The PolyPolygon containing the geometry of the extended line by
130 it's line width. Contains bezier segments and edge roundings as
133 BASEGFX_DLLPUBLIC B2DPolyPolygon
createAreaGeometry(
134 const B2DPolygon
& rCandidate
,
135 double fHalfLineWidth
,
136 B2DLineJoin eJoin
= B2DLINEJOIN_ROUND
,
137 com::sun::star::drawing::LineCap eCap
= com::sun::star::drawing::LineCap_BUTT
,
138 double fMaxAllowedAngle
= (12.5 * F_PI180
),
139 double fMaxPartOfEdge
= 0.4,
140 double fMiterMinimumAngle
= (15.0 * F_PI180
));
141 } // end of namespace tools
142 } // end of namespace basegfx
144 #endif // INCLUDED_BASEGFX_POLYGON_B2DLINEGEOMETRY_HXX
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */