finalcut/src/fpoint.cpp

103 lines
3.3 KiB
C++
Raw Normal View History

2017-11-04 07:03:53 +01:00
/***********************************************************************
* fpoint.cpp - Point with an x and y coordinate *
* *
* This file is part of the Final Cut widget toolkit *
* *
2018-04-16 02:24:37 +02:00
* Copyright 2014-2018 Markus Gans *
2017-11-04 07:03:53 +01:00
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* as published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* The Final Cut is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
2015-05-23 13:35:12 +02:00
#include "final/fpoint.h"
2015-05-23 13:35:12 +02:00
namespace finalcut
{
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
// class FPoint
//----------------------------------------------------------------------
FPoint::~FPoint() // destructor
2015-09-22 04:18:20 +02:00
{ }
2015-05-23 13:35:12 +02:00
// public methods of FPoint
//----------------------------------------------------------------------
FPoint& FPoint::operator = (const FPoint& p)
2015-05-23 13:35:12 +02:00
{
xpos = p.xpos;
ypos = p.ypos;
return *this;
2015-05-23 13:35:12 +02:00
}
//----------------------------------------------------------------------
FPoint& FPoint::operator += (const FPoint& p)
2015-05-23 13:35:12 +02:00
{
xpos = short(xpos + p.xpos);
ypos = short(ypos + p.ypos);
return *this;
2015-05-23 13:35:12 +02:00
}
//----------------------------------------------------------------------
FPoint& FPoint::operator -= (const FPoint& p)
2015-05-23 13:35:12 +02:00
{
xpos = short(xpos - p.xpos);
ypos = short(ypos - p.ypos);
return *this;
2015-05-23 13:35:12 +02:00
}
//----------------------------------------------------------------------
void FPoint::setX (int x)
2015-05-23 13:35:12 +02:00
{
xpos = short(x);
}
//----------------------------------------------------------------------
void FPoint::setY (int y)
2015-05-23 13:35:12 +02:00
{
ypos = short(y);
2015-05-23 13:35:12 +02:00
}
//----------------------------------------------------------------------
void FPoint::setPoint (int x, int y)
2015-05-23 13:35:12 +02:00
{
xpos = short(x);
ypos = short(y);
2015-05-23 13:35:12 +02:00
}
//----------------------------------------------------------------------
bool FPoint::isNull() const
2015-05-23 13:35:12 +02:00
{
return xpos == 0 && ypos == 0;
2015-05-23 13:35:12 +02:00
}
2018-04-16 02:24:37 +02:00
//----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, const FPoint& p)
{
outstr << p.getX() << " " << p.getY();
return outstr;
}
//----------------------------------------------------------------------
std::istream& operator >> (std::istream& instr, FPoint& p)
{
short x, y;
instr >> x;
instr >> y;
p.setPoint (x, y);
return instr;
}
} // namespace finalcut