LibreOffice Module basegfx (master) 1
numbertools.cxx
Go to the documentation of this file.
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
14
15#include <rtl/strbuf.hxx>
16#include <rtl/math.hxx>
17
18namespace basegfx::utils
19{
20 B2DPolyPolygon number2PolyPolygon(double fValue, sal_Int32 nTotalDigits, sal_Int32 nDecPlaces, bool bLitSegments)
21 {
22 // config here
23 // {
24 const double fSpace=0.2;
25 // }
26 // config here
27
28 OStringBuffer aNum;
29 rtl::math::doubleToStringBuffer(aNum,
30 fValue,
31 rtl_math_StringFormat_F,
32 nDecPlaces, '.',
33 nullptr, ',');
34
35 B2DPolyPolygon aRes;
36 B2DHomMatrix aMat;
37 double fCurrX=std::max(nTotalDigits-aNum.getLength(),
38 sal_Int32(0)) * (1.0+fSpace);
39 for( sal_Int32 i=0; i<aNum.getLength(); ++i )
40 {
42 bLitSegments);
43
44 aMat.identity();
45 aMat.translate(fCurrX,0.0);
46 aCurr.transform(aMat);
47
48 fCurrX += 1.0+fSpace;
49
50 aRes.append(aCurr);
51 }
52
53 return aRes;
54 }
55
56}
57
58/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void translate(double fX, double fY)
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
void transform(const basegfx::B2DHomMatrix &rMatrix)
B2DPolyPolygon number2PolyPolygon(double fValue, sal_Int32 nTotalDigits, sal_Int32 nDecPlaces, bool bLitSegments)
Creates polypolygon with the given number as seven-segment digits.
Definition: numbertools.cxx:20
B2DPolyPolygon createSevenSegmentPolyPolygon(char nNumber, bool bLitSegments)
Creates polypolygon for seven-segment display number.
int i