summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArmin Le Grand (Collabora) <Armin.Le.Grand@me.com>2020-02-14 12:32:42 +0100
committerAndras Timar <andras.timar@collabora.com>2020-04-28 22:42:40 +0200
commit55c1016740d901668ae2766a5191b24bddb2d2f5 (patch)
tree1f705228284a19cdc8c96f9f174a1b3420107812 /include
parenta87e78df635d4a8e745bfffcf33d022d2a498afa (diff)
tdf#130655 added callback interface to ::applyLineDashing
This version of the tooling method allows to avoid collecting line snippets in a return value PolyPolygon. Instead, offer lambda functions to get callbacks for created snippets. The original method using a B2DPolyPolygon return value is adapted to already use this, so serves as example of usage and ensures that only one identical algorithm is used. Change-Id: Ie306968a895ad280fc2425fb40b3244769216ba0
Diffstat (limited to 'include')
-rw-r--r--include/basegfx/polygon/b2dpolygontools.hxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx
index 57b9130b4399..9defd76ef548 100644
--- a/include/basegfx/polygon/b2dpolygontools.hxx
+++ b/include/basegfx/polygon/b2dpolygontools.hxx
@@ -20,6 +20,9 @@
#ifndef INCLUDED_BASEGFX_POLYGON_B2DPOLYGONTOOLS_HXX
#define INCLUDED_BASEGFX_POLYGON_B2DPOLYGONTOOLS_HXX
+#include <vector>
+#include <functional>
+
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/vector/b2dvector.hxx>
#include <basegfx/range/b2drectangle.hxx>
@@ -27,7 +30,6 @@
#include <basegfx/polygon/b2dpolygontriangulator.hxx>
#include <com/sun/star/drawing/PointSequence.hpp>
#include <com/sun/star/drawing/FlagSequence.hpp>
-#include <vector>
#include <basegfx/basegfxdllapi.h>
#include <o3tl/typed_flags_set.hxx>
@@ -188,9 +190,29 @@ namespace basegfx
@param fFullDashDotLen
The summed-up length of the rDotDashArray. If zero, it will
be calculated internally.
+
+ There is now a 2nd version that allows to provide callback
+ functions that get called when a snippet of a line/gap is
+ produced and needs to be added. This allows to use it like
+ a 'pipeline'. When using this (e.g. the 1st version uses
+ this internally to guarantee the same algorithm is used)
+ it is not needed to accumulate a potentially huge number
+ of polygons in the result-polyPolygons, but e.g. consume
+ them directly in the caller. Example is renderinmg a
+ dashed line but without creating the potentially huge amount
+ of polygons.
+ The 2nd version will also merge first/last line/gap snippets
+ if the input polygon is closed and the start/end-points match
+ accordingly - at the cost that this will be delivered last.
*/
BASEGFX_DLLPUBLIC void applyLineDashing(
const B2DPolygon& rCandidate,
+ const std::vector<double>& rDotDashArray,
+ std::function<void(const basegfx::B2DPolygon& rSnippet)> aLineTargetCallback,
+ std::function<void(const basegfx::B2DPolygon& rSnippet)> aGapTargetCallback = std::function<void(const basegfx::B2DPolygon&)>(),
+ double fDotDashLength = 0.0);
+ BASEGFX_DLLPUBLIC void applyLineDashing(
+ const B2DPolygon& rCandidate,
const ::std::vector<double>& rDotDashArray,
B2DPolyPolygon* pLineTarget,
B2DPolyPolygon* pGapTarget = nullptr,