|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
//文件 SXY.h
|
|
|
//主要功能:
|
|
|
// 基础类库
|
|
|
//程序编写: 2005-12-07
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#pragma once
|
|
|
#include "rect8.h"
|
|
|
#include ".\angle.h"
|
|
|
|
|
|
namespace NBase
|
|
|
{
|
|
|
|
|
|
//Extend中的参数
|
|
|
#define EXTEND_MODE_DEFAULT 0 //居左上
|
|
|
#define EXTEND_MODE_STRECH 1 //拉伸
|
|
|
#define EXTEND_MODE_CENTER 2 //居中
|
|
|
#define EXTEND_MODE_HEIGHT 3 //按高度满屏显示
|
|
|
#define EXTEND_MODE_WIDTH 4 //按宽度满屏显示
|
|
|
|
|
|
class AFX_EXT_CLASS CSXY :
|
|
|
public CRect8
|
|
|
{
|
|
|
public:
|
|
|
CSXY(void);
|
|
|
virtual ~CSXY(void);
|
|
|
|
|
|
virtual int Create(CDC* pDC, BOOL bSetViewRect = TRUE);
|
|
|
virtual void Clear(void);
|
|
|
|
|
|
virtual CPoint GetScreen(double x, double y);
|
|
|
virtual CPoint2D GetScreen8(double x, double y);
|
|
|
|
|
|
virtual double GetScreenWidth8(double v);
|
|
|
virtual double GetScreenHeight8(double v);
|
|
|
virtual long GetScreenWidth(double v);
|
|
|
virtual long GetScreenHeight(double v);
|
|
|
|
|
|
int CreateAngle(double angle, double x0, double y0);
|
|
|
void DeleteAngle(void);
|
|
|
|
|
|
//坐标变换
|
|
|
virtual long GetSX(double x);
|
|
|
virtual long GetSY(double y);
|
|
|
virtual double GetRX(long x);
|
|
|
virtual double GetRY(long y);
|
|
|
virtual double GetSX8(double x);
|
|
|
virtual double GetSY8(double y);
|
|
|
virtual double GetRX(double x);
|
|
|
virtual double GetRY(double y);
|
|
|
|
|
|
virtual CRect8 GetReal(CRect& sr);
|
|
|
virtual CPoint2D GetReal(CPoint& point);
|
|
|
virtual CPoint2D GetReal(long x,long y);
|
|
|
virtual CPoint2D GetReal(double x,double y);
|
|
|
virtual CRect8 GetReal(CRect8& screenRect);
|
|
|
virtual CPoint2D GetReal(CPoint2D& pointScreen);
|
|
|
|
|
|
virtual CPoint GetScreen(CPoint2D& pt);
|
|
|
virtual CRect GetScreen(CRect8& rect);
|
|
|
virtual CRect8 GetScreen8(CRect8& rect);
|
|
|
|
|
|
virtual double GetRealWidth(long sw);
|
|
|
virtual double GetRealHeight(long sh);
|
|
|
virtual double GetRealWidth(double screenWidth);
|
|
|
virtual double GetRealHeight(double screenHeight);
|
|
|
virtual CSize GetScreenSize(CSize8& sz);
|
|
|
virtual CSize8 GetScreenSize8(CSize8& sz);
|
|
|
virtual CSize8 GetRealSize(CSize& sz);
|
|
|
virtual CSize8 GetRealSize(CSize8& sz);
|
|
|
|
|
|
void Extend(CRect8& rect, CRect& rtScreenWindow,int IsStrech);
|
|
|
void Extend(CRect8& rect, CRect8& rtScreenWindow,int IsStrech);
|
|
|
void Extend(CRect& rtScreenWindow,int IsStrech);
|
|
|
void Extend(CRect8& rtScreenWindow,int IsStrech);
|
|
|
void Reduce(double cc);
|
|
|
|
|
|
void SetScale(double ScaleX, double ScaleY); //参数单位:1实际单位代表的毫米长度
|
|
|
void GetScale(double& ScaleX, double& ScaleY); //参数单位:1实际单位代表的毫米长度
|
|
|
void SetCustomDPI(double dCustomDPI); //设置显示分辨率, 参数为每英寸的点阵数
|
|
|
|
|
|
void operator=(CSXY& dc);
|
|
|
|
|
|
CDC* GetDC(void);
|
|
|
void SetViewRect(CRect rect);
|
|
|
// 按实际坐标设置显示范围
|
|
|
// void SetViewRectReal(CRect rect);
|
|
|
CRect GetViewRect(void);
|
|
|
|
|
|
CRect8 GetRealRect(void);
|
|
|
void SetRealRect(CRect8 realRect);
|
|
|
|
|
|
CRect8 m_screenRect; //指向屏幕的窗口坐标,之前为CRect型,为了插入符号的准确,改为了CRect8,与CRect存取的结构一样
|
|
|
double PixelPerUnitX;
|
|
|
double PixelPerUnitY; //每单位象素个数
|
|
|
double UnitX;
|
|
|
double UnitY; //毫米/象素
|
|
|
CAngle* m_pAngle;
|
|
|
|
|
|
protected:
|
|
|
CDC *pDC;
|
|
|
CRect m_ViewRect;
|
|
|
CRect8 m_RealRect;
|
|
|
};
|
|
|
|
|
|
AFX_INLINE CDC* CSXY::GetDC(void)
|
|
|
{
|
|
|
return pDC;
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
using namespace NBase;
|