Line data Source code
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 : #ifndef _BGFX_VECTOR_B2IVECTOR_HXX
21 : #define _BGFX_VECTOR_B2IVECTOR_HXX
22 :
23 : #include <basegfx/tuple/b2ituple.hxx>
24 : #include <basegfx/vector/b2enums.hxx>
25 : #include <basegfx/basegfxdllapi.h>
26 :
27 : namespace basegfx
28 : {
29 : // predeclaration
30 : class B2DHomMatrix;
31 :
32 : /** Base Point class with two sal_Int32 values
33 :
34 : This class derives all operators and common handling for
35 : a 2D data class from B2ITuple. All necessary extensions
36 : which are special for 2D Vectors are added here.
37 :
38 : @see B2ITuple
39 : */
40 : class BASEGFX_DLLPUBLIC B2IVector : public ::basegfx::B2ITuple
41 : {
42 : public:
43 : /** Create a 2D Vector
44 :
45 : The vector is initialized to (0, 0)
46 : */
47 : B2IVector()
48 : : B2ITuple()
49 : {}
50 :
51 : /** Create a 2D Vector
52 :
53 : @param nX
54 : This parameter is used to initialize the X-coordinate
55 : of the 2D Vector.
56 :
57 : @param nY
58 : This parameter is used to initialize the Y-coordinate
59 : of the 2D Vector.
60 : */
61 0 : B2IVector(sal_Int32 nX, sal_Int32 nY)
62 0 : : B2ITuple(nX, nY)
63 0 : {}
64 :
65 : /** Create a copy of a 2D Vector
66 :
67 : @param rVec
68 : The 2D Vector which will be copied.
69 : */
70 0 : B2IVector(const B2IVector& rVec)
71 0 : : B2ITuple(rVec)
72 0 : {}
73 :
74 : /** constructor with tuple to allow copy-constructing
75 : from B2ITuple-based classes
76 : */
77 : B2IVector(const ::basegfx::B2ITuple& rTuple)
78 : : B2ITuple(rTuple)
79 : {}
80 :
81 0 : ~B2IVector()
82 0 : {}
83 :
84 : /** *=operator to allow usage from B2IVector, too
85 : */
86 : B2IVector& operator*=( const B2IVector& rPnt )
87 : {
88 : mnX *= rPnt.mnX;
89 : mnY *= rPnt.mnY;
90 : return *this;
91 : }
92 :
93 : /** *=operator to allow usage from B2IVector, too
94 : */
95 : B2IVector& operator*=(sal_Int32 t)
96 : {
97 : mnX *= t;
98 : mnY *= t;
99 : return *this;
100 : }
101 :
102 : /** assignment operator to allow assigning the results
103 : of B2ITuple calculations
104 : */
105 : B2IVector& operator=( const ::basegfx::B2ITuple& rVec );
106 :
107 : /** Set the length of this 2D Vector
108 :
109 : @param fLen
110 : The to be achieved length of the 2D Vector
111 : */
112 : B2IVector& setLength(double fLen);
113 :
114 : /** Calculate the Scalar with another 2D Vector
115 :
116 : @param rVec
117 : The second 2D Vector
118 :
119 : @return
120 : The Scalar value of the two involved 2D Vectors
121 : */
122 : double scalar( const B2IVector& rVec ) const;
123 :
124 : /** Transform vector by given transformation matrix.
125 :
126 : Since this is a vector, translational components of the
127 : matrix are disregarded.
128 : */
129 : B2IVector& operator*=( const B2DHomMatrix& rMat );
130 : };
131 :
132 : // external operators
133 : //////////////////////////////////////////////////////////////////////////
134 :
135 : /** Transform vector by given transformation matrix.
136 :
137 : Since this is a vector, translational components of the
138 : matrix are disregarded.
139 : */
140 : BASEGFX_DLLPUBLIC B2IVector operator*( const B2DHomMatrix& rMat, const B2IVector& rVec );
141 :
142 : } // end of namespace basegfx
143 :
144 : #endif /* _BGFX_VECTOR_B2IVECTOR_HXX */
145 :
146 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|