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 _BGFX_POLYGON_B2DLINEGEOMETRY_HXX 25 #define _BGFX_POLYGON_B2DLINEGEOMETRY_HXX 26 27 #include <sal/types.h> 28 #include <basegfx/numeric/ftools.hxx> 29 #include <basegfx/polygon/b2dpolypolygon.hxx> 30 #include <basegfx/polygon/b2dpolygon.hxx> 31 #include <com/sun/star/drawing/LineCap.hpp> 32 #include <basegfx/basegfxdllapi.h> 33 34 ////////////////////////////////////////////////////////////////////////////// 35 36 namespace basegfx 37 { 38 namespace tools 39 { 40 /** Create line start/end geometry element, mostly arrows and things like that. 41 42 @param rCandidate 43 The polygon which needs to get that line ends and needs to have two points 44 at least. 45 46 @param rArrow 47 The line start/end geometry. It is assumed that the tip is pointing 48 upwards. Result will be rotated and scaled to fit. 49 50 @param bStart 51 describes if creation is for start or end of candidate. 52 53 @param fWidth 54 defines the size of the element, it's describing the target width in X 55 of the arrow. 56 57 @param fDockingPosition needs to be in [0.0 ..1.0] range, where 0.0 means 58 that the tip of the arrow will be aligned with the polygon start, 1.0 means 59 the bottom. The default of 0.5 describes a centered arrow. 60 61 @param pConsumedLength 62 Using this parameter it is possible to get back how much from the candidate 63 geometry is overlapped by the created element (consumed). 64 65 @param fCandidateLength 66 This should contain the length of rCandidate to allow work without 67 again calculating the length (which may be expensive with beziers). If 0.0 is 68 given, the length is calculated on demand. 69 70 @return 71 The Line start and end polygon, correctly rotated and scaled 72 */ 73 BASEGFX_DLLPUBLIC B2DPolyPolygon createAreaGeometryForLineStartEnd( 74 const B2DPolygon& rCandidate, 75 const B2DPolyPolygon& rArrow, 76 bool bStart, 77 double fWidth, 78 double fCandidateLength = 0.0, // 0.0 -> calculate self 79 double fDockingPosition = 0.5, // 0->top, 1->bottom 80 double* pConsumedLength = 0L); 81 82 /** create filled polygon geometry for lines with a line width 83 84 This method will create bezier based, fillable polygons which 85 will resample the curve if it was extended for the given half 86 line width. It will remove extrema positions from contained 87 bezier segments and get as close as possible and defined by 88 the given parameters to the ideal result. 89 90 It will check edges for trivial bezier to avoid unnecessary 91 bezier polygons. Care is taken to produce the in-between 92 polygon points (the ones original on the source poygon) since 93 it has showed that without those, the raster converters leave 94 non-filled gaps. 95 96 @param rCandidate 97 The source polygon defining the hairline polygon path 98 99 @param fHalfLineWidth 100 The width of the line to one side 101 102 @param eJoin 103 The LineJoin if the edges meeting in a point do not have a C1 104 or C2 continuity 105 106 @param eCap 107 The kind of cap, which is added to the line. 108 109 @param fMaxAllowedAngle 110 Allows to hand over the maximum allowed angle between an edge and 111 it's control vectors. The smaller, the more subdivisions will be 112 needed to create the filled geometry. Allowed range is cropped to 113 [F_PI2 .. 0.01 * F_PI2]. 114 115 @param fMaxPartOfEdge 116 Allows to influence from with relative length of a control vector 117 compared to it's edge a split is forced. The smaller, the more 118 subdivisions will be needed to create the filled geometry. Allowed 119 range is cropped to [1.0 .. 0.01] 120 121 @praram fMiterMinimumAngle 122 The minimum wanted angle between two edges when edge rounding 123 is using miter. When an edge is smaller than this (tighter) 124 the usual fallback to bevel is used. Allowed range is cropped 125 to [F_PI .. 0.01 * F_PI]. 126 127 @return 128 The PolyPolygon containing the geometry of the extended line by 129 it's line width. Contains bezier segments and edge roundings as 130 needed and defined. 131 */ 132 BASEGFX_DLLPUBLIC B2DPolyPolygon createAreaGeometry( 133 const B2DPolygon& rCandidate, 134 double fHalfLineWidth, 135 B2DLineJoin eJoin = B2DLINEJOIN_ROUND, 136 com::sun::star::drawing::LineCap eCap = com::sun::star::drawing::LineCap_BUTT, 137 double fMaxAllowedAngle = (12.5 * F_PI180), 138 double fMaxPartOfEdge = 0.4, 139 double fMiterMinimumAngle = (15.0 * F_PI180)); 140 } // end of namespace tools 141 } // end of namespace basegfx 142 143 ////////////////////////////////////////////////////////////////////////////// 144 145 #endif /* _BGFX_POLYGON_B2DLINEGEOMETRY_HXX */ 146 // eof 147