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 <basegfx/numeric/ftools.hxx>
24 #include <basegfx/polygon/b2dpolypolygon.hxx>
25 #include <basegfx/polygon/b2dpolygon.hxx>
26 #include <com/sun/star/drawing/LineCap.hpp>
27 #include <basegfx/basegfxdllapi.h>
28 #include <basegfx/polygon/b2dpolygontriangulator.hxx>
34 /** Create line start/end geometry element, mostly arrows and things like that.
37 The polygon which needs to get that line ends and needs to have two points
41 The line start/end geometry. It is assumed that the tip is pointing
42 upwards. Result will be rotated and scaled to fit.
45 describes if creation is for start or end of candidate.
48 defines the size of the element, it's describing the target width in X
51 @param fDockingPosition needs to be in [0.0 ..1.0] range, where 0.0 means
52 that the tip of the arrow will be aligned with the polygon start, 1.0 means
53 the bottom. The default of 0.5 describes a centered arrow.
55 @param pConsumedLength
56 Using this parameter it is possible to get back how much from the candidate
57 geometry is overlapped by the created element (consumed).
59 @param fCandidateLength
60 This should contain the length of rCandidate to allow work without
61 again calculating the length (which may be expensive with beziers). If 0.0 is
62 given, the length is calculated on demand.
65 When it is necessary to count with the thickness of the line, it
66 makes sense to move the start position slightly - so define the shift.
69 The Line start and end polygon, correctly rotated and scaled
71 BASEGFX_DLLPUBLIC B2DPolyPolygon
createAreaGeometryForLineStartEnd(
72 const B2DPolygon
& rCandidate
,
73 const B2DPolyPolygon
& rArrow
,
76 double fCandidateLength
, // 0.0 -> calculate self
77 double fDockingPosition
, // 0->top, 1->bottom
78 double* pConsumedLength
= nullptr,
81 /** create filled polygon geometry for lines with a line width
83 This method will create bezier based, fillable polygons which
84 will resample the curve if it was extended for the given half
85 line width. It will remove extrema positions from contained
86 bezier segments and get as close as possible and defined by
87 the given parameters to the ideal result.
89 It will check edges for trivial bezier to avoid unnecessary
90 bezier polygons. Care is taken to produce the in-between
91 polygon points (the ones original on the source polygon) since
92 it has showed that without those, the raster converters leave
96 The source polygon defining the hairline polygon path
99 The width of the line to one side
102 The LineJoin if the edges meeting in a point do not have a C1
106 The kind of cap, which is added to the line.
108 @param fMaxAllowedAngle
109 Allows to hand over the maximum allowed angle between an edge and
110 it's control vectors. The smaller, the more subdivisions will be
111 needed to create the filled geometry. Allowed range is cropped to
112 [F_PI2 .. 0.01 * F_PI2].
114 @param fMaxPartOfEdge
115 Allows to influence from with relative length of a control vector
116 compared to its edge a split is forced. The smaller, the more
117 subdivisions will be needed to create the filled geometry. Allowed
118 range is cropped to [1.0 .. 0.01]
120 @param fMiterMinimumAngle
121 The minimum wanted angle between two edges when edge rounding
122 is using miter. When an edge is smaller than this (tighter)
123 the usual fallback to bevel is used. Allowed range is cropped
124 to [F_PI .. 0.01 * F_PI].
127 If given, the method will additionally add the created geometry as
131 The tools::PolyPolygon containing the geometry of the extended line by
132 it's line width. Contains bezier segments and edge roundings as
135 BASEGFX_DLLPUBLIC B2DPolyPolygon
createAreaGeometry(
136 const B2DPolygon
& rCandidate
,
137 double fHalfLineWidth
,
139 css::drawing::LineCap eCap
,
140 double fMaxAllowedAngle
= basegfx::deg2rad(12.5),
141 double fMaxPartOfEdge
= 0.4,
142 double fMiterMinimumAngle
= basegfx::deg2rad(15.0),
143 basegfx::triangulator::B2DTriangleVector
* pTriangles
= nullptr);
145 } // end of namespace utils
146 } // end of namespace basegfx
148 #endif // INCLUDED_BASEGFX_POLYGON_B2DLINEGEOMETRY_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */