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
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fpoint.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-09-20 23:59:01 +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
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
FPoint& FPoint::operator = (const FPoint& p)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
xpos = p.xpos;
|
|
|
|
ypos = p.ypos;
|
|
|
|
return *this;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
FPoint& FPoint::operator += (const FPoint& p)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-11-21 22:15:14 +01:00
|
|
|
xpos = xpos + p.xpos;
|
|
|
|
ypos = ypos + p.ypos;
|
2016-11-02 00:37:58 +01:00
|
|
|
return *this;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
FPoint& FPoint::operator -= (const FPoint& p)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-11-21 22:15:14 +01:00
|
|
|
xpos = xpos - p.xpos;
|
|
|
|
ypos = ypos - p.ypos;
|
2016-11-02 00:37:58 +01:00
|
|
|
return *this;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FPoint::setX (int x)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-11-21 22:15:14 +01:00
|
|
|
xpos = x;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FPoint::setY (int y)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-11-21 22:15:14 +01:00
|
|
|
ypos = y;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FPoint::setPoint (int x, int y)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-11-21 22:15:14 +01:00
|
|
|
xpos = x;
|
|
|
|
ypos = y;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
bool FPoint::isNull() const
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01: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)
|
|
|
|
{
|
2018-11-21 22:15:14 +01:00
|
|
|
int x, y;
|
2018-04-16 02:24:37 +02:00
|
|
|
instr >> x;
|
|
|
|
instr >> y;
|
|
|
|
p.setPoint (x, y);
|
|
|
|
return instr;
|
|
|
|
}
|
2018-09-20 23:59:01 +02:00
|
|
|
|
|
|
|
} // namespace finalcut
|