LCOV - code coverage report
Current view: top level - include/basegfx/vector - b2ivector.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 15 15 100.0 %
Date: 2014-04-11 Functions: 6 6 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             :     // predeclaration
      32             :     class B2DHomMatrix;
      33             : 
      34             :     /** Base Point class with two sal_Int32 values
      35             : 
      36             :         This class derives all operators and common handling for
      37             :         a 2D data class from B2ITuple. All necessary extensions
      38             :         which are special for 2D Vectors are added here.
      39             : 
      40             :         @see B2ITuple
      41             :     */
      42      930437 :     class BASEGFX_DLLPUBLIC B2IVector : public ::basegfx::B2ITuple
      43             :     {
      44             :     public:
      45             :         /** Create a 2D Vector
      46             : 
      47             :             The vector is initialized to (0, 0)
      48             :         */
      49      930438 :         B2IVector()
      50      930438 :         :   B2ITuple()
      51      930438 :         {}
      52             : 
      53             :         /** Create a 2D Vector
      54             : 
      55             :             @param nX
      56             :             This parameter is used to initialize the X-coordinate
      57             :             of the 2D Vector.
      58             : 
      59             :             @param nY
      60             :             This parameter is used to initialize the Y-coordinate
      61             :             of the 2D Vector.
      62             :         */
      63     5750898 :         B2IVector(sal_Int32 nX, sal_Int32 nY)
      64     5750898 :         :   B2ITuple(nX, nY)
      65     5750898 :         {}
      66             : 
      67             :         /** Create a copy of a 2D Vector
      68             : 
      69             :             @param rVec
      70             :             The 2D Vector which will be copied.
      71             :         */
      72      758047 :         B2IVector(const B2IVector& rVec)
      73      758047 :         :   B2ITuple(rVec)
      74      758047 :         {}
      75             : 
      76             :         /** constructor with tuple to allow copy-constructing
      77             :             from B2ITuple-based classes
      78             :         */
      79     5216258 :         B2IVector(const ::basegfx::B2ITuple& rTuple)
      80     5216258 :         :   B2ITuple(rTuple)
      81     5216258 :         {}
      82             : 
      83    12643903 :         ~B2IVector()
      84    12643903 :         {}
      85             : 
      86             :         /** *=operator to allow usage from B2IVector, too
      87             :         */
      88             :         B2IVector& operator*=( const B2IVector& rPnt )
      89             :         {
      90             :             mnX *= rPnt.mnX;
      91             :             mnY *= rPnt.mnY;
      92             :             return *this;
      93             :         }
      94             : 
      95             :         /** *=operator to allow usage from B2IVector, too
      96             :         */
      97             :         B2IVector& operator*=(sal_Int32 t)
      98             :         {
      99             :             mnX *= t;
     100             :             mnY *= t;
     101             :             return *this;
     102             :         }
     103             : 
     104             :         /** assignment operator to allow assigning the results
     105             :             of B2ITuple calculations
     106             :         */
     107             :         B2IVector& operator=( const ::basegfx::B2ITuple& rVec );
     108             : 
     109             :         /** Set the length of this 2D Vector
     110             : 
     111             :             @param fLen
     112             :             The to be achieved length of the 2D Vector
     113             :         */
     114             :         B2IVector& setLength(double fLen);
     115             : 
     116             :         /** Calculate the Scalar with another 2D Vector
     117             : 
     118             :             @param rVec
     119             :             The second 2D Vector
     120             : 
     121             :             @return
     122             :             The Scalar value of the two involved 2D Vectors
     123             :         */
     124             :         double scalar( const B2IVector& rVec ) const;
     125             : 
     126             :         /** Transform vector by given transformation matrix.
     127             : 
     128             :             Since this is a vector, translational components of the
     129             :             matrix are disregarded.
     130             :         */
     131             :         B2IVector& operator*=( const B2DHomMatrix& rMat );
     132             :     };
     133             : 
     134             :     // external operators
     135             : 
     136             :     /** Transform vector by given transformation matrix.
     137             : 
     138             :         Since this is a vector, translational components of the
     139             :         matrix are disregarded.
     140             :     */
     141             :     BASEGFX_DLLPUBLIC B2IVector operator*( const B2DHomMatrix& rMat, const B2IVector& rVec );
     142             : 
     143             : } // end of namespace basegfx
     144             : 
     145             : template< typename charT, typename traits >
     146             : inline std::basic_ostream<charT, traits> & operator <<(
     147             :     std::basic_ostream<charT, traits> & stream, const basegfx::B2IVector& vector )
     148             : {
     149             :     return stream << "(" << vector.getX() << "," << vector.getY() << ")";
     150             : }
     151             : 
     152             : #endif // INCLUDED_BASEGFX_VECTOR_B2IVECTOR_HXX
     153             : 
     154             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10