/src/libreoffice/include/svx/xpoly.hxx
Line | Count | Source |
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 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | #ifndef INCLUDED_SVX_XPOLY_HXX |
20 | | #define INCLUDED_SVX_XPOLY_HXX |
21 | | |
22 | | #include <basegfx/polygon/b2dpolypolygon.hxx> |
23 | | #include <svx/svxdllapi.h> |
24 | | #include <o3tl/cow_wrapper.hxx> |
25 | | #include <tools/poly.hxx> |
26 | | #include <tools/degree.hxx> |
27 | | |
28 | | class Point; |
29 | | namespace tools { class Rectangle; } |
30 | | namespace tools { |
31 | | class Polygon; |
32 | | } |
33 | | |
34 | 282k | #define XPOLY_APPEND 0xFFFF |
35 | | |
36 | | // Class XPolygon has a point-array and a flag-array, which contains information about a particular point |
37 | | |
38 | | class ImpXPolygon; |
39 | | |
40 | | class SVXCORE_DLLPUBLIC XPolygon final |
41 | | { |
42 | | o3tl::cow_wrapper< ImpXPolygon > m_pImpXPolygon; |
43 | | |
44 | | // auxiliary functions for Bezier conversion |
45 | | SAL_DLLPRIVATE void SubdivideBezier(sal_uInt16 nPos, bool bCalcFirst, double fT); |
46 | | SAL_DLLPRIVATE void GenBezArc(const Point& rCenter, tools::Long nRx, tools::Long nRy, |
47 | | tools::Long nXHdl, tools::Long nYHdl, Degree100 nStart, Degree100 nEnd, |
48 | | sal_uInt16 nQuad, sal_uInt16 nFirst); |
49 | | SAL_DLLPRIVATE static bool CheckAngles(Degree100& nStart, Degree100 nEnd, Degree100& nA1, Degree100& nA2); |
50 | | |
51 | | public: |
52 | | SAL_DLLPRIVATE XPolygon( sal_uInt16 nSize=16 ); |
53 | | SAL_DLLPRIVATE XPolygon( const XPolygon& ); |
54 | | SAL_DLLPRIVATE XPolygon( XPolygon&& ); |
55 | | XPolygon( const tools::Polygon& rPoly ); |
56 | | XPolygon( const tools::Rectangle& rRect, tools::Long nRx = 0, tools::Long nRy = 0 ); |
57 | | XPolygon( const Point& rCenter, tools::Long nRx, tools::Long nRy, |
58 | | Degree100 nStartAngle = 0_deg100, Degree100 nEndAngle = 36000_deg100, |
59 | | bool bClose = true ); |
60 | | |
61 | | ~XPolygon(); |
62 | | |
63 | | sal_uInt16 GetSize() const; |
64 | | |
65 | | SAL_DLLPRIVATE void SetPointCount( sal_uInt16 nPoints ); |
66 | | SAL_DLLPRIVATE sal_uInt16 GetPointCount() const; |
67 | | |
68 | | void Insert( sal_uInt16 nPos, const Point& rPt, PolyFlags eFlags ); |
69 | | SAL_DLLPRIVATE void Insert( sal_uInt16 nPos, const XPolygon& rXPoly ); |
70 | | SAL_DLLPRIVATE void Remove( sal_uInt16 nPos, sal_uInt16 nCount ); |
71 | | SAL_DLLPRIVATE void Move( tools::Long nHorzMove, tools::Long nVertMove ); |
72 | | SAL_DLLPRIVATE tools::Rectangle GetBoundRect() const; |
73 | | |
74 | | const Point& operator[]( sal_uInt16 nPos ) const; |
75 | | Point& operator[]( sal_uInt16 nPos ); |
76 | | SAL_DLLPRIVATE XPolygon& operator=( const XPolygon& ); |
77 | | SAL_DLLPRIVATE XPolygon& operator=( XPolygon&& ); |
78 | | SAL_DLLPRIVATE bool operator==( const XPolygon& rXPoly ) const; |
79 | | |
80 | | SAL_DLLPRIVATE PolyFlags GetFlags( sal_uInt16 nPos ) const; |
81 | | SAL_DLLPRIVATE void SetFlags( sal_uInt16 nPos, PolyFlags eFlags ); |
82 | | SAL_DLLPRIVATE bool IsControl(sal_uInt16 nPos) const; |
83 | | SAL_DLLPRIVATE bool IsSmooth(sal_uInt16 nPos) const; |
84 | | |
85 | | // distance between two points |
86 | | SAL_DLLPRIVATE double CalcDistance(sal_uInt16 nP1, sal_uInt16 nP2); |
87 | | |
88 | | // Bezier conversion |
89 | | SAL_DLLPRIVATE void CalcSmoothJoin(sal_uInt16 nCenter, sal_uInt16 nDrag, sal_uInt16 nPnt); |
90 | | SAL_DLLPRIVATE void CalcTangent(sal_uInt16 nCenter, sal_uInt16 nPrev, sal_uInt16 nNext); |
91 | | SAL_DLLPRIVATE void PointsToBezier(sal_uInt16 nFirst); |
92 | | |
93 | | // transformations |
94 | | void Scale(double fSx, double fSy); |
95 | | SAL_DLLPRIVATE void Distort(const tools::Rectangle& rRefRect, const XPolygon& rDistortedRect); |
96 | | |
97 | | // #116512# convert to basegfx::B2DPolygon and return |
98 | | basegfx::B2DPolygon getB2DPolygon() const; |
99 | | |
100 | | // #116512# constructor to convert from basegfx::B2DPolygon |
101 | | // #i76339# made explicit |
102 | | SAL_DLLPRIVATE explicit XPolygon(const basegfx::B2DPolygon& rPolygon); |
103 | | }; |
104 | | |
105 | | // Class XPolyPolygon; like PolyPolygon, composed of XPolygons instead of Polygons |
106 | | |
107 | | class ImpXPolyPolygon; |
108 | | |
109 | | class XPolyPolygon final |
110 | | { |
111 | | o3tl::cow_wrapper< ImpXPolyPolygon > m_pImpXPolyPolygon; |
112 | | |
113 | | public: |
114 | | XPolyPolygon(); |
115 | | XPolyPolygon( const XPolyPolygon& ); |
116 | | XPolyPolygon( XPolyPolygon&& ); |
117 | | |
118 | | ~XPolyPolygon(); |
119 | | |
120 | | void Insert( XPolygon&& rXPoly ); |
121 | | void Insert( const XPolyPolygon& rXPoly ); |
122 | | void Remove( sal_uInt16 nPos ); |
123 | | const XPolygon& GetObject( sal_uInt16 nPos ) const; |
124 | | |
125 | | void Clear(); |
126 | | sal_uInt16 Count() const; |
127 | | |
128 | | tools::Rectangle GetBoundRect() const; |
129 | | |
130 | | const XPolygon& operator[]( sal_uInt16 nPos ) const |
131 | 3 | { return GetObject( nPos ); } |
132 | | XPolygon& operator[]( sal_uInt16 nPos ); |
133 | | |
134 | | XPolyPolygon& operator=( const XPolyPolygon& ); |
135 | | XPolyPolygon& operator=( XPolyPolygon&& ); |
136 | | |
137 | | // transformations |
138 | | void Distort(const tools::Rectangle& rRefRect, const XPolygon& rDistortedRect); |
139 | | |
140 | | // #116512# convert to basegfx::B2DPolyPolygon and return |
141 | | basegfx::B2DPolyPolygon getB2DPolyPolygon() const; |
142 | | |
143 | | // #116512# constructor to convert from basegfx::B2DPolyPolygon |
144 | | // #i76339# made explicit |
145 | | explicit XPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon); |
146 | | }; |
147 | | |
148 | | #endif // INCLUDED_SVX_XPOLY_HXX |
149 | | |
150 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |