RasterProcessTool/RasterMainWidgetGUI/RasterMainWidget/pointxy.h

100 lines
2.0 KiB
C
Raw Permalink Normal View History

2025-02-07 09:16:22 +00:00
#pragma once
#include <QtCore/QtGlobal>
#include <QtCore/QPoint>
#include <QtCore/QPointF>
#include <QtCore/QDebug>
namespace LAMPMainWidget {
class PointXY {
public:
PointXY() = default;
PointXY(double x, double y) : mX(x), mY(y) {}
PointXY(const PointXY &other) = default;
PointXY(PointXY &&other) = default;
explicit PointXY(const QPointF &other) : mX(other.x()), mY(other.y()) {}
explicit PointXY(const QPoint &other) : mX(double(other.x())), mY(double(other.y())) {}
~PointXY() = default;
public:
/**
* x
* @param x x
*/
void setX(double const x) { mX = x; }
/**
* y
* @param y y
*/
void
setY(double const y) { mY = y; }
/**
* xy
* @param x x
* @param y y
*/
void set(double const x, double const y) {
mX = x;
mY = y;
}
/**
* x
* @return x
*/
double x() const { return mX; }
/**
* y
* @return y
*/
double y() const { return mY; }
/**
* (mX, mY)(x,y)
* @param x x
* @param y y
* @return
*/
double distance(double x, double y) const;
/**
* (mX, mY)p
* @param p
* @return
*/
double distance(const PointXY &p) const { return distance(p.mX, p.mY); }
/**
* xyscalar
* @param scalar
*/
void multiply(double scalar) {
mX *= scalar;
mY *= scalar;
}
/**
* WKT
* @return WKT
*/
QString toWKT() const;
public:
bool operator==(const PointXY &other);
bool operator!=(const PointXY &other) { return !(*this == other); }
PointXY &operator=(const PointXY &other);
PointXY &operator=(const QPointF &other);
PointXY &operator=(const QPoint &other);
private:
double mX;
double mY;
};
}
QDebug operator<<(QDebug debug, const LAMPMainWidget::PointXY &point);