bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / basegfx / polygon / b2dpolypolygon.hxx
blob65e3b97cfc96fb4a8ab1f764578529d71763c97c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_BASEGFX_POLYGON_B2DPOLYPOLYGON_HXX
21 #define INCLUDED_BASEGFX_POLYGON_B2DPOLYPOLYGON_HXX
23 #include <ostream>
24 #include <vector>
26 #include <sal/types.h>
27 #include <o3tl/cow_wrapper.hxx>
28 #include <basegfx/range/b2drange.hxx>
29 #include <basegfx/basegfxdllapi.h>
30 #include <basegfx/polygon/b2dpolygon.hxx>
32 class ImplB2DPolyPolygon;
34 namespace basegfx
36 class B2DHomMatrix;
39 namespace basegfx
41 class BASEGFX_DLLPUBLIC B2DPolyPolygon
43 public:
44 typedef o3tl::cow_wrapper< ImplB2DPolyPolygon > ImplType;
46 private:
47 ImplType mpPolyPolygon;
49 public:
50 B2DPolyPolygon();
51 B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon);
52 B2DPolyPolygon(B2DPolyPolygon&& rPolyPolygon);
53 explicit B2DPolyPolygon(const B2DPolygon& rPolygon);
54 ~B2DPolyPolygon();
56 // assignment operator
57 B2DPolyPolygon& operator=(const B2DPolyPolygon& rPolyPolygon);
58 B2DPolyPolygon& operator=(B2DPolyPolygon&& rPolyPolygon);
60 /// unshare this poly-polygon (and all included polygons) with all internally shared instances
61 void makeUnique();
63 // compare operators
64 bool operator==(const B2DPolyPolygon& rPolyPolygon) const;
65 bool operator!=(const B2DPolyPolygon& rPolyPolygon) const;
67 // polygon interface
68 sal_uInt32 count() const;
70 B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const;
71 void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon);
73 // test for curve
74 bool areControlPointsUsed() const;
76 // insert/append single polygon
77 void insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount = 1);
78 void append(const B2DPolygon& rPolygon, sal_uInt32 nCount = 1);
80 /** Default adaptive subdivision access
82 For details refer to B2DPolygon::getDefaultAdaptiveSubdivision()
84 @return
85 The default subdivision of this polygon
87 B2DPolyPolygon getDefaultAdaptiveSubdivision() const;
89 /** Get the B2DRange (Rectangle dimensions) of this B2DPolyPolygon
91 For details refer to B2DPolygon::getB2DRange()
93 @return
94 The outer range of the bezier curve/polygon
96 B2DRange getB2DRange() const;
98 // insert/append multiple polygons
99 void insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon);
100 void append(const B2DPolyPolygon& rPolyPolygon);
102 // remove
103 void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1);
105 // reset to empty state
106 void clear();
108 // closed state
109 bool isClosed() const;
110 void setClosed(bool bNew);
112 // flip polygon direction
113 void flip();
115 // test if tools::PolyPolygon has double points
116 bool hasDoublePoints() const;
118 // remove double points, at the begin/end and follow-ups, too
119 void removeDoublePoints();
121 // apply transformation given in matrix form to the polygon
122 void transform(const basegfx::B2DHomMatrix& rMatrix);
124 // polygon iterators (same iterator validity conditions as for vector)
125 const B2DPolygon* begin() const;
126 const B2DPolygon* end() const;
127 B2DPolygon* begin();
128 B2DPolygon* end();
130 // exclusive management op's for SystemDependentData at B2DPolygon
131 template<class T>
132 std::shared_ptr<T> getSystemDependentData() const
134 return std::static_pointer_cast<T>(getSystemDependantDataInternal(typeid(T).hash_code()));
137 template<class T, class... Args>
138 std::shared_ptr<T> addOrReplaceSystemDependentData(SystemDependentDataManager& manager, Args&&... args) const
140 std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
141 basegfx::SystemDependentData_SharedPtr r2(r);
142 addOrReplaceSystemDependentDataInternal(r2);
143 return r;
146 private:
147 void addOrReplaceSystemDependentDataInternal(SystemDependentData_SharedPtr& rData) const;
148 SystemDependentData_SharedPtr getSystemDependantDataInternal(size_t hash_code) const;
151 // typedef for a vector of B2DPolyPolygons
152 typedef ::std::vector< B2DPolyPolygon > B2DPolyPolygonVector;
154 template< typename charT, typename traits >
155 inline std::basic_ostream<charT, traits> & operator <<(
156 std::basic_ostream<charT, traits> & stream, const B2DPolyPolygon& poly )
158 stream << "[" << poly.count() << ":";
159 for (sal_uInt32 i = 0; i < poly.count(); i++)
161 if (i > 0)
162 stream << ",";
163 stream << poly.getB2DPolygon(i);
165 stream << "]";
167 return stream;
170 } // end of namespace basegfx
172 #endif // INCLUDED_BASEGFX_POLYGON_B2DPOLYPOLYGON_HXX
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */