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.

85 lines
2.5 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//////////////////////////////////////////////////////////////////////////////
//文件 Unit.h
//主要功能:
//
//程序编写: 2005-12-07
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Point2D.h"
class AFX_EXT_CLASS CUnit
{
public:
CUnit();
virtual ~CUnit();
enum EType
{
UNIT_KM = 0, //公里 kilometres
UNIT_M = 1, //米 metre
UNIT_DM = 2, //分米 decimeter
UNIT_CM = 3, //厘米 centimeter
UNIT_MM = 4, //毫米 millimetres
UNIT_SECOND = 5, //秒 second60分之一分
UNIT_MS = 6, //毫秒 millisecond
UNIT_FOOT = 7, //英尺 foot = 304.8mm
UNIT_INCH = 8, //英寸 inch = 25.4mm
UNIT_MILE = 9, //英里 mile = 1.609*1e6mm
UNIT_YARD = 10, //码 yard = 914.4mm
UNIT_SEA_MILE = 11, //海里 nautical mile = 1852000mm
UNIT_RUSSIAN_MILE = 12, //俄里 Russian mile = 1.0668*1e6mm
UNIT_RUSSIAN_UNIT_OF_LENGTH = 13, //俄丈 Russian unit of length = 2133.6mm
UNIT_JAPANESE_MILE = 14, //日里 Japanese mile = 3.9273*1e6mm
UNIT_JAPANESE_FOOT = 15, //日尺 Japanese foot = 303mm;
//经纬度单位定义
UNIT_DEGREE = 16, //度(360度)
UNIT_DMS = 17, //度分秒,即±DDDMMSS.SSSS格式
UNIT_MINUTE = 18, //分(60分之一度)
UNIT_RADIAN = 19, //弧度
UNIT_GRAD = 20 //梯度 1梯度=0.015707963267949弧度
};
double Millimetres(double data, EType unit); //转换为毫米
double Millimetres(EType unit);
double Millimetres(int unit);
double Meter(double data, EType unit); //转换为米
double Meter(EType unit);
double GetMillisecondPerCM() { return msPerCM; }
double msPerCM; //(毫秒/厘米)
};
////////////////////////////////////////////////////////////////////
//单位选择模式有两种:
// 0为实际坐标模式输出单位与图件实际坐标单位相同
// 1为打印单位模式固定单位为毫米
class AFX_EXT_CLASS CUnitTransform : public CUnit
{
public:
CUnitTransform();
double toPrintUnit(double dRealVal); //将实际单位转换为打印单位(毫米)
double toRealUnit(double dPrintVal); //将打印单位转换为实际单位
CSize8 toPrintUnit(CSize8 sz); //将实际单位转换为打印单位(毫米)
CSize8 toRealUnit(CSize8 sz); //将打印单位转换为实际单位
void SetTransform(double scale, int nUnit);
void SetTransform(double scale, EType eUnit);
int GetUnit() { return (int)m_unit; } //获得当前显示单位
double GetScale() { return m_dScaleFactor; }
int GetShowUnit(); //获得当前显示单位
public:
double m_dScaleFactor; //比例: 1:m_dScaleFactor
EType m_unit; //当前单位
int m_nMode; //单位选择模式
};