You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.5 KiB
C++
121 lines
2.5 KiB
C++
#pragma once
|
|
#include "MLVector.h"
|
|
|
|
class MLPoint;
|
|
class MLPlNode;
|
|
class MLPline;
|
|
#define MLDRect MLRect
|
|
|
|
class MLRect
|
|
{
|
|
public:
|
|
MLRect(void);
|
|
MLRect(double left, double top, double right, double bottom);
|
|
MLRect(const MLVector& dPt1, const MLVector& dPt2);
|
|
MLRect(const MLPoint& dPt1, const MLPoint& dPt2);
|
|
MLRect(const MLPlNode& dPt1, const MLPlNode& dPt2);
|
|
MLRect(const MLRect& dRect);
|
|
|
|
explicit MLRect(const QRectF& rect);
|
|
explicit MLRect(const QPointF& dPt1, const QPointF& dPt2);
|
|
~MLRect(void);
|
|
|
|
// 元素数
|
|
__declspec(property(get=getName, put = setName)) char* name;
|
|
__declspec(property(get=getTop, put = setTop)) double top;
|
|
__declspec(property(get=getLeft, put = setLeft)) double left;
|
|
__declspec(property(get=getBottom, put = setBottom)) double bottom;
|
|
__declspec(property(get=getRight, put = setRight)) double right;
|
|
__declspec(property(get=getValid, put = setValid)) bool valid;
|
|
|
|
public:
|
|
const char* getName() const;
|
|
void setName(char* name);
|
|
|
|
void setTop(double top);
|
|
double getTop() const;
|
|
double& getTop();
|
|
|
|
void setLeft(double left);
|
|
double getLeft() const;
|
|
|
|
void setBottom(double bottom);
|
|
double getBottom() const;
|
|
double& getBottom();
|
|
|
|
void setRight(double right);
|
|
double getRight() const;
|
|
|
|
void setValid(bool valid);
|
|
bool getValid() const;
|
|
|
|
// 设置矩形坐标
|
|
void setRect(double left, double top, double right, double bottom);
|
|
void setRect(const MLPoint& dPt1, const MLPoint& dPt2);
|
|
|
|
// 设置矩形为空
|
|
void setEmpty();
|
|
|
|
// 矩形是否为空
|
|
bool isEmpty() const;
|
|
|
|
// 宽度
|
|
double width() const;
|
|
|
|
// 高度
|
|
double height()const ;
|
|
|
|
// 四点坐标
|
|
MLPoint topLeft();
|
|
MLPoint bottomRight();
|
|
MLPoint rightTop();
|
|
MLPoint leftBottom();
|
|
|
|
// 得到矩形中心点
|
|
MLPoint centerPoint();
|
|
|
|
bool operator ==(const MLRect& other) const;
|
|
bool operator !=(const MLRect& other) const;
|
|
|
|
// 规则矩形坐标
|
|
void normalizeRect();
|
|
|
|
// 转化为线
|
|
MLPline toPline() const;
|
|
|
|
QRectF toQRectF() const;
|
|
|
|
QRect toQRect() const;
|
|
|
|
// 点在矩形内
|
|
bool contains(const MLPoint& point);
|
|
bool contains(double dbx, double dby) const;
|
|
bool contains(const MLPline& pline);
|
|
|
|
// 偏移
|
|
void offset(double dx, double dy);
|
|
void offset(const MLPoint& point);
|
|
|
|
// 移动
|
|
void moveTo(const MLPoint& point);
|
|
void moveTo(const QPointF& pointF);
|
|
|
|
// 读取矩形坐标
|
|
void readRect(QDataStream& in);
|
|
void readRect(FILE* fr);
|
|
|
|
// 输出矩形坐标
|
|
void writeRect(QDataStream& out);
|
|
void writeRect(FILE* fw);
|
|
|
|
private:
|
|
char m_name[32];
|
|
double m_left;
|
|
double m_top;
|
|
double m_right;
|
|
double m_bottom;
|
|
|
|
bool m_valid;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|