LCOV - code coverage report
Current view: top level - include/basegfx/vector - b2ivector.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 16 16 100.0 %
Date: 2015-06-13 12:38:46 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11