2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fpoint.h - Point with an x and y coordinate *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2019-01-16 16:00:15 +01:00
|
|
|
* Copyright 2014-2019 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/>. *
|
|
|
|
***********************************************************************/
|
2017-10-02 07:32:33 +02:00
|
|
|
|
|
|
|
/* Standalone class
|
|
|
|
* ════════════════
|
|
|
|
*
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FPoint ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FPOINT_H
|
|
|
|
#define FPOINT_H
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-10-31 00:41:59 +01:00
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2018-04-16 02:24:37 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
2017-10-31 00:41:59 +01:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FPoint
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FPoint
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Constructors
|
2018-12-03 03:22:36 +01:00
|
|
|
FPoint () = default;
|
2017-09-11 03:06:02 +02:00
|
|
|
FPoint (const FPoint&); // copy constructor
|
2019-07-31 23:57:35 +02:00
|
|
|
FPoint (FPoint&&); // move constructor
|
2017-09-11 03:06:02 +02:00
|
|
|
FPoint (int, int);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FPoint();
|
|
|
|
|
|
|
|
// Overloaded operators
|
|
|
|
FPoint& operator = (const FPoint&);
|
2019-07-29 02:34:58 +02:00
|
|
|
FPoint& operator = (FPoint&&);
|
2017-09-11 03:06:02 +02:00
|
|
|
FPoint& operator += (const FPoint&);
|
|
|
|
FPoint& operator -= (const FPoint&);
|
|
|
|
|
2019-01-16 16:00:15 +01:00
|
|
|
friend bool operator == (const FPoint&, const FPoint&);
|
|
|
|
friend bool operator != (const FPoint&, const FPoint&);
|
2018-10-22 01:26:24 +02:00
|
|
|
friend FPoint operator + (const FPoint&, const FPoint&);
|
|
|
|
friend FPoint operator - (const FPoint&, const FPoint&);
|
|
|
|
friend FPoint operator - (const FPoint&);
|
2018-04-16 02:24:37 +02:00
|
|
|
friend std::ostream& operator << (std::ostream&, const FPoint&);
|
|
|
|
friend std::istream& operator >> (std::istream&, FPoint&);
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Accessors
|
|
|
|
virtual const char* getClassName();
|
2018-12-31 06:18:39 +01:00
|
|
|
int getX() const;
|
|
|
|
int getY() const;
|
|
|
|
void setX (int);
|
|
|
|
void setY (int);
|
2019-01-21 03:42:18 +01:00
|
|
|
void setPoint (const FPoint&);
|
2018-12-31 06:18:39 +01:00
|
|
|
void setPoint (int, int);
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Inquiry
|
2019-01-16 16:00:15 +01:00
|
|
|
bool isOrigin() const;
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Point references
|
2018-12-31 06:18:39 +01:00
|
|
|
int& x_ref();
|
|
|
|
int& y_ref();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
private:
|
2019-09-04 23:57:31 +02:00
|
|
|
// Data members
|
2018-12-03 03:22:36 +01:00
|
|
|
int xpos{0};
|
|
|
|
int ypos{0};
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// FPoint inline functions
|
2017-08-11 10:50:39 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FPoint::FPoint (const FPoint& p) // copy constructor
|
|
|
|
: xpos(p.xpos)
|
|
|
|
, ypos(p.ypos)
|
|
|
|
{ }
|
|
|
|
|
2019-07-31 23:57:35 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FPoint::FPoint (FPoint&& p) // move constructor
|
|
|
|
: xpos(p.xpos)
|
|
|
|
, ypos(p.ypos)
|
|
|
|
{ p.xpos = p.ypos = 0; }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FPoint::FPoint (int x, int y)
|
2018-11-21 22:15:14 +01:00
|
|
|
: xpos(x)
|
|
|
|
, ypos(y)
|
2015-09-20 05:44:50 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool operator == (const FPoint& p1, const FPoint& p2)
|
|
|
|
{ return p1.xpos == p2.xpos && p1.ypos == p2.ypos; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool operator != (const FPoint& p1, const FPoint& p2)
|
|
|
|
{ return p1.xpos != p2.xpos || p1.ypos != p2.ypos; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FPoint operator + (const FPoint& p1, const FPoint& p2)
|
2017-09-15 01:31:02 +02:00
|
|
|
{ return FPoint(p1.xpos + p2.xpos, p1.ypos + p2.ypos); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FPoint operator - (const FPoint& p1, const FPoint& p2)
|
2017-09-15 01:31:02 +02:00
|
|
|
{ return FPoint(p1.xpos - p2.xpos, p1.ypos - p2.ypos); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FPoint operator - (const FPoint& p)
|
|
|
|
{ return FPoint(-p.xpos, -p.ypos); }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FPoint::getClassName()
|
|
|
|
{ return "FPoint"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FPoint::getX() const
|
|
|
|
{ return xpos; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FPoint::getY() const
|
|
|
|
{ return ypos; }
|
|
|
|
|
2019-01-21 03:42:18 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FPoint::setPoint (const FPoint& p)
|
|
|
|
{ setPoint(p.xpos, p.ypos); }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-11-21 22:15:14 +01:00
|
|
|
inline int& FPoint::x_ref()
|
2016-11-02 00:37:58 +01:00
|
|
|
{ return xpos; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-11-21 22:15:14 +01:00
|
|
|
inline int& FPoint::y_ref()
|
2016-11-02 00:37:58 +01:00
|
|
|
{ return ypos; }
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FPOINT_H
|