LibreOffice Module basegfx (master) 1
b2dpolypolygon.hxx
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 * 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
20#pragma once
21
22#include <ostream>
23#include <vector>
24
25#include <sal/types.h>
26#include <o3tl/cow_wrapper.hxx>
30
31namespace basegfx
32{
33 class B2DHomMatrix;
34 class ImplB2DPolyPolygon;
35
37 {
38 private:
40
41 public:
43 B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon);
45 explicit B2DPolyPolygon(const B2DPolygon& rPolygon);
47
48 // assignment operator
51
53 void makeUnique();
54
55 // compare operators
56 bool operator==(const B2DPolyPolygon& rPolyPolygon) const;
57 bool operator!=(const B2DPolyPolygon& rPolyPolygon) const;
58
59 // polygon interface
60 sal_uInt32 count() const;
61
62 B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const;
63 void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon);
64
65 // test for curve
66 bool areControlPointsUsed() const;
67
68 // insert/append single polygon
69 void insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount = 1);
70 void append(const B2DPolygon& rPolygon, sal_uInt32 nCount = 1);
71 void reserve(sal_uInt32 nCount);
72
80 B2DPolyPolygon getDefaultAdaptiveSubdivision() const;
81
89 B2DRange getB2DRange() const;
90
91 // insert/append multiple polygons
92 void insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon);
93 void append(const B2DPolyPolygon& rPolyPolygon);
94
95 // remove
96 void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1);
97
98 // reset to empty state
99 void clear();
100
101 // closed state
102 bool isClosed() const;
103 void setClosed(bool bNew);
104
105 // flip polygon direction
106 void flip();
107
108 // test if tools::PolyPolygon has double points
109 bool hasDoublePoints() const;
110
111 // remove double points, at the begin/end and follow-ups, too
112 void removeDoublePoints();
113
114 // apply transformation given in matrix form to the polygon
115 void transform(const basegfx::B2DHomMatrix& rMatrix);
116
117 // polygon iterators (same iterator validity conditions as for vector)
118 const B2DPolygon* begin() const;
119 const B2DPolygon* end() const;
120 B2DPolygon* begin();
121 B2DPolygon* end();
122
123 // exclusive management op's for SystemDependentData at B2DPolygon
124 template<class T>
125 std::shared_ptr<T> getSystemDependentData() const
126 {
127 return std::static_pointer_cast<T>(getSystemDependantDataInternal(typeid(T).hash_code()));
128 }
129
130 template<class T, class... Args>
131 std::shared_ptr<T> addOrReplaceSystemDependentData(Args&&... args) const
132 {
133 std::shared_ptr<T> r = std::make_shared<T>(std::forward<Args>(args)...);
134
135 // tdf#129845 only add to buffer if a relevant buffer time is estimated
136 if(r->calculateCombinedHoldCyclesInSeconds() > 0)
137 {
139 addOrReplaceSystemDependentDataInternal(r2);
140 }
141
142 return r;
143 }
144
145 private:
146 void addOrReplaceSystemDependentDataInternal(SystemDependentData_SharedPtr& rData) const;
147 SystemDependentData_SharedPtr getSystemDependantDataInternal(size_t hash_code) const;
148 };
149
150 // typedef for a vector of B2DPolyPolygons
151 typedef ::std::vector< B2DPolyPolygon > B2DPolyPolygonVector;
152
153 template< typename charT, typename traits >
154 inline std::basic_ostream<charT, traits> & operator <<(
155 std::basic_ostream<charT, traits> & stream, const B2DPolyPolygon& poly )
156 {
157 stream << "[" << poly.count() << ":";
158 for (sal_uInt32 i = 0; i < poly.count(); i++)
159 {
160 if (i > 0)
161 stream << ",";
162 stream << poly.getB2DPolygon(i);
163 }
164 stream << "]";
165
166 return stream;
167 }
168
169} // end of namespace basegfx
170
171/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define BASEGFX_DLLPUBLIC
Definition: basegfxdllapi.h:35
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
B2DPolyPolygon & operator=(const B2DPolyPolygon &rPolyPolygon)
o3tl::cow_wrapper< ImplB2DPolyPolygon, o3tl::ThreadSafeRefCountingPolicy > mpPolyPolygon
std::shared_ptr< T > addOrReplaceSystemDependentData(Args &&... args) const
std::shared_ptr< T > getSystemDependentData() const
B2DPolyPolygon(const B2DPolyPolygon &rPolyPolygon)
B2DPolyPolygon & operator=(B2DPolyPolygon &&rPolyPolygon)
B2DPolyPolygon(B2DPolyPolygon &&rPolyPolygon)
sal_uInt32 count() const
A two-dimensional interval over doubles.
Definition: b2drange.hxx:54
Reference< XOutputStream > stream
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, BColor const &color)
Definition: bcolor.hxx:176
std::shared_ptr< SystemDependentData > SystemDependentData_SharedPtr
Definition: b2dpolygon.hxx:41
::std::vector< B2DPolyPolygon > B2DPolyPolygonVector
OUStringBuffer & remove(OUStringBuffer &rIn, sal_Unicode c)
int i
enumrange< T >::Iterator begin(enumrange< T >)
end
args
bool operator!=(const XclExpString &rLeft, const XclExpString &rRight)
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)