xref: /trunk/main/basegfx/inc/basegfx/tools/canvastools.hxx (revision 001d9c4210a3b4f4dd79baadbe10c57a5f64c3ea)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
25 #define _BGFX_TOOLS_CANVASTOOLS_HXX
26 
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/uno/Sequence.hxx>
29 #include <basegfx/basegfxdllapi.h>
30 
31 
32 namespace com { namespace sun { namespace star { namespace geometry
33 {
34     struct AffineMatrix2D;
35     struct AffineMatrix3D;
36     struct Matrix2D;
37     struct RealPoint2D;
38     struct RealSize2D;
39     struct RealRectangle2D;
40     struct RealRectangle3D;
41     struct IntegerPoint2D;
42     struct IntegerSize2D;
43     struct IntegerRectangle2D;
44     struct RealBezierSegment2D;
45 } } } }
46 
47 namespace com { namespace sun { namespace star { namespace rendering
48 {
49     class  XGraphicDevice;
50     class  XPolyPolygon2D;
51 } } } }
52 
53 namespace com { namespace sun { namespace star { namespace awt
54 {
55     struct Point;
56     struct Size;
57     struct Rectangle;
58 } } } }
59 
60 namespace basegfx
61 {
62     class B2DHomMatrix;
63     class B3DHomMatrix;
64     class B2DVector;
65     class B2DPoint;
66     class B2DRange;
67     class B3DRange;
68     class B2IVector;
69     class B2IPoint;
70     class B2IRange;
71     class B2DPolygon;
72     class B2DPolyPolygon;
73 
74     namespace unotools
75     {
76         // Polygon conversions
77         // ===================================================================
78 
79         BASEGFX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
80             xPolyPolygonFromB2DPolygon( const ::com::sun::star::uno::Reference<
81                                             ::com::sun::star::rendering::XGraphicDevice >&  xGraphicDevice,
82                                         const ::basegfx::B2DPolygon&                        rPoly    );
83 
84         BASEGFX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
85             xPolyPolygonFromB2DPolyPolygon( const ::com::sun::star::uno::Reference<
86                                                 ::com::sun::star::rendering::XGraphicDevice >&  xGraphicDevice,
87                                             const ::basegfx::B2DPolyPolygon&                    rPolyPoly    );
88 
89 
90         BASEGFX_DLLPUBLIC ::com::sun::star::uno::Sequence<
91             ::com::sun::star::uno::Sequence<
92                 ::com::sun::star::geometry::RealBezierSegment2D > >
93                     bezierSequenceSequenceFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly );
94 
95         BASEGFX_DLLPUBLIC ::com::sun::star::uno::Sequence<
96             ::com::sun::star::uno::Sequence<
97                 ::com::sun::star::geometry::RealPoint2D > >
98                     pointSequenceSequenceFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly );
99 
100         BASEGFX_DLLPUBLIC ::basegfx::B2DPolygon polygonFromPoint2DSequence(
101             const ::com::sun::star::uno::Sequence<
102                 ::com::sun::star::geometry::RealPoint2D >& rPoints );
103 
104         BASEGFX_DLLPUBLIC ::basegfx::B2DPolyPolygon polyPolygonFromPoint2DSequenceSequence(
105             const ::com::sun::star::uno::Sequence<
106                 ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& rPoints );
107 
108         BASEGFX_DLLPUBLIC ::basegfx::B2DPolygon polygonFromBezier2DSequence(
109             const ::com::sun::star::uno::Sequence<
110                 ::com::sun::star::geometry::RealBezierSegment2D >& rPoints );
111 
112         BASEGFX_DLLPUBLIC ::basegfx::B2DPolyPolygon polyPolygonFromBezier2DSequenceSequence(
113             const ::com::sun::star::uno::Sequence<
114                 ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& rPoints );
115 
116         BASEGFX_DLLPUBLIC ::basegfx::B2DPolyPolygon b2DPolyPolygonFromXPolyPolygon2D(
117             const ::com::sun::star::uno::Reference<
118                      ::com::sun::star::rendering::XPolyPolygon2D >& rPoly );
119 
120         // Matrix conversions
121         // ===================================================================
122 
123         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::AffineMatrix2D&
124             affineMatrixFromHomMatrix( ::com::sun::star::geometry::AffineMatrix2D&  matrix,
125                                        const ::basegfx::B2DHomMatrix&               transform);
126 
127         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::AffineMatrix3D& affineMatrixFromHomMatrix3D(
128             ::com::sun::star::geometry::AffineMatrix3D& matrix,
129             const ::basegfx::B3DHomMatrix& transform);
130 
131         BASEGFX_DLLPUBLIC ::basegfx::B2DHomMatrix&
132             homMatrixFromAffineMatrix( ::basegfx::B2DHomMatrix&                             transform,
133                                        const ::com::sun::star::geometry::AffineMatrix2D&    matrix );
134 
135         BASEGFX_DLLPUBLIC ::basegfx::B2DHomMatrix homMatrixFromAffineMatrix( const ::com::sun::star::geometry::AffineMatrix2D& matrix );
136         BASEGFX_DLLPUBLIC ::basegfx::B3DHomMatrix homMatrixFromAffineMatrix3D( const ::com::sun::star::geometry::AffineMatrix3D& matrix );
137 
138         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::Matrix2D&
139             matrixFromHomMatrix( ::com::sun::star::geometry::Matrix2D& matrix,
140                                  const ::basegfx::B2DHomMatrix&        transform);
141 
142         BASEGFX_DLLPUBLIC ::basegfx::B2DHomMatrix&
143             homMatrixFromMatrix( ::basegfx::B2DHomMatrix&                    transform,
144                                  const ::com::sun::star::geometry::Matrix2D& matrix );
145 
146         // Geometry conversions
147         // ===================================================================
148 
149         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::RealSize2D        size2DFromB2DSize( const ::basegfx::B2DVector& );
150         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::RealPoint2D       point2DFromB2DPoint( const ::basegfx::B2DPoint& );
151         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::RealRectangle2D   rectangle2DFromB2DRectangle( const ::basegfx::B2DRange& );
152         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::RealRectangle3D   rectangle3DFromB3DRectangle( const ::basegfx::B3DRange& );
153 
154         BASEGFX_DLLPUBLIC ::basegfx::B2DVector      b2DSizeFromRealSize2D( const ::com::sun::star::geometry::RealSize2D& );
155         BASEGFX_DLLPUBLIC ::basegfx::B2DPoint       b2DPointFromRealPoint2D( const ::com::sun::star::geometry::RealPoint2D& );
156         BASEGFX_DLLPUBLIC ::basegfx::B2DRange       b2DRectangleFromRealRectangle2D( const ::com::sun::star::geometry::RealRectangle2D& );
157         BASEGFX_DLLPUBLIC ::basegfx::B3DRange       b3DRectangleFromRealRectangle3D( const ::com::sun::star::geometry::RealRectangle3D& );
158 
159         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::IntegerSize2D         integerSize2DFromB2ISize( const ::basegfx::B2IVector& );
160         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::IntegerPoint2D    integerPoint2DFromB2IPoint( const ::basegfx::B2IPoint& );
161         BASEGFX_DLLPUBLIC ::com::sun::star::geometry::IntegerRectangle2D    integerRectangle2DFromB2IRectangle( const ::basegfx::B2IRange& );
162 
163         BASEGFX_DLLPUBLIC ::basegfx::B2IVector      b2ISizeFromIntegerSize2D( const ::com::sun::star::geometry::IntegerSize2D& );
164         BASEGFX_DLLPUBLIC ::basegfx::B2IPoint       b2IPointFromIntegerPoint2D( const ::com::sun::star::geometry::IntegerPoint2D& );
165         BASEGFX_DLLPUBLIC ::basegfx::B2IRange       b2IRectangleFromIntegerRectangle2D( const ::com::sun::star::geometry::IntegerRectangle2D& );
166 
167         BASEGFX_DLLPUBLIC ::com::sun::star::awt::Size       awtSizeFromB2ISize( const ::basegfx::B2IVector& );
168         BASEGFX_DLLPUBLIC ::com::sun::star::awt::Point          awtPointFromB2IPoint( const ::basegfx::B2IPoint& );
169         BASEGFX_DLLPUBLIC ::com::sun::star::awt::Rectangle  awtRectangleFromB2IRectangle( const ::basegfx::B2IRange& );
170 
171         BASEGFX_DLLPUBLIC ::basegfx::B2IVector      b2ISizeFromAwtSize( const ::com::sun::star::awt::Size& );
172         BASEGFX_DLLPUBLIC ::basegfx::B2IPoint       b2IPointFromAwtPoint( const ::com::sun::star::awt::Point& );
173         BASEGFX_DLLPUBLIC ::basegfx::B2IRange       b2IRectangleFromAwtRectangle( const ::com::sun::star::awt::Rectangle& );
174 
175         // Geometry comparisons
176         // ===================================================================
177 
178         BASEGFX_DLLPUBLIC bool RealSize2DAreEqual( const ::com::sun::star::geometry::RealSize2D& rA, const ::com::sun::star::geometry::RealSize2D& rB );
179         BASEGFX_DLLPUBLIC bool RealPoint2DAreEqual( const ::com::sun::star::geometry::RealPoint2D& rA, const ::com::sun::star::geometry::RealPoint2D& rB );
180         BASEGFX_DLLPUBLIC bool RealRectangle2DAreEqual( const ::com::sun::star::geometry::RealRectangle2D& rA, const ::com::sun::star::geometry::RealRectangle2D& rB );
181         BASEGFX_DLLPUBLIC bool RealRectangle3DAreEqual( const ::com::sun::star::geometry::RealRectangle3D& rA, const ::com::sun::star::geometry::RealRectangle3D& rB );
182         BASEGFX_DLLPUBLIC bool AffineMatrix2DAreEqual( const ::com::sun::star::geometry::AffineMatrix2D& rA, const ::com::sun::star::geometry::AffineMatrix2D& rB );
183 
184         BASEGFX_DLLPUBLIC bool IntegerSize2DAreEqual( const ::com::sun::star::geometry::IntegerSize2D& rA, const ::com::sun::star::geometry::IntegerSize2D& rB );
185         BASEGFX_DLLPUBLIC bool IntegerPoint2DAreEqual( const ::com::sun::star::geometry::IntegerPoint2D& rA, const ::com::sun::star::geometry::IntegerPoint2D& rB );
186         BASEGFX_DLLPUBLIC bool IntegerRectangle2DAreEqual( const ::com::sun::star::geometry::IntegerRectangle2D& rA, const ::com::sun::star::geometry::IntegerRectangle2D& rB );
187 
188         BASEGFX_DLLPUBLIC bool awtSizeAreEqual( const ::com::sun::star::awt::Size& rA, const ::com::sun::star::awt::Size& rB );
189         BASEGFX_DLLPUBLIC bool awtPointAreEqual( const ::com::sun::star::awt::Point& rA, const ::com::sun::star::awt::Point& rB );
190         BASEGFX_DLLPUBLIC bool awtRectangleAreEqual( const ::com::sun::star::awt::Rectangle& rA, const ::com::sun::star::awt::Rectangle& rB );
191 
192         /** Return smalltest integer range, which completely contains
193             given floating point range.
194 
195             @param rRange
196             Input range. Values must be within the representable
197             bounds of sal_Int32
198 
199             @return the closest integer range, which completely
200             contains rRange.
201          */
202         BASEGFX_DLLPUBLIC ::basegfx::B2IRange   b2ISurroundingRangeFromB2DRange( const ::basegfx::B2DRange& rRange );
203 
204         /** Return smalltest B2DRange with integer values, which
205             completely contains given floating point range.
206 
207             @param rRange
208             Input range.
209 
210             @return the closest B2DRange with integer coordinates,
211             which completely contains rRange.
212          */
213         BASEGFX_DLLPUBLIC ::basegfx::B2DRange   b2DSurroundingIntegerRangeFromB2DRange( const ::basegfx::B2DRange& rRange );
214 
215     }
216 }
217 
218 #endif /* _BGFX_TOOLS_CANVASTOOLS_HXX */
219