📄 scatter.h
字号:
LineTo(x[i], y[i]);
if (m_bEnableLegend && Index > 0 && Name)
Legend(cr, Index, Name);
::SelectObject(m_hDC, hOldPen);
::DeleteObject(hPen);
}
///////////////////////////////////////////////////////////////////////////////
// CXLogYLinear operations
template<class T>
bool CXLogYLinear<T>::SetRange(double xmin, double ymin, double xmax, double ymax)
{
m_nAxesType = XLOG;
if (xmin < 0.000001 || xmax < 0.000001)
{
::MessageBox(NULL, "The X minimum value must be larger than 0.000001", "Warning", MB_ICONWARNING);
return false;
}
m_Scale.xmin = log10(xmin);
m_Scale.ymin = ymin;
m_Scale.xmax = log10(xmax);
m_Scale.ymax = ymax;
m_nXStep = (int)(m_Scale.xmax - m_Scale.xmin);
return true;
}
template<class T>
void CXLogYLinear<T>::XAxis()
{
int xb, yb, xe, ye;
int i, j, k = 1;
char str[32];
float value;
yb = GB;
for(i = 1; i <= m_nXStep; i ++)
{
for(j = 1; j <= 10; j ++)
{
if (k == 0)
ye = GB + m_bM / 7;
else
ye = GB + m_bM / 14;
xb = xe = (int)(log10(j) * PX / m_nXStep + 1.0 * (i-1) * PX / m_nXStep + GL);
if (j == 1)
{
value = (float)(pow(10.0, m_Scale.xmin) * pow(10.0, i - 1));
Format(m_nXDecimal, str, value);
PrintString(xb, GB + m_bM / 5, 0, str);
}
if ((i != 1 || j != 1) && (i != m_nXStep || j != 10))
DrawLine(xb, yb, xe, ye);
k = 1;
}
k=0;
}
value = (float)(pow(10.0, m_Scale.xmin) * pow(10.0, i - 1));
Format(m_nXDecimal, str, value);
PrintString(GR, GB + m_bM / 5, 0, str);
}
template<class T>
void CXLogYLinear<T>::Grid()
{
int i, j, k;
HPEN hPen = ::CreatePen(PS_DOT, 0, m_nGridColor);
HPEN hOldPen = (HPEN)::SelectObject(m_hDC, hPen);
for(i = 1; i < m_nXStep; i ++)
for(k = 2; k <= 10; k ++)
{
j = (int)(log10(k) * PX / m_nXStep + 1.0 * (i - 1) * PX / m_nXStep + GL);
DrawLine(j, GT + 1, j, GB - 1);
}
for(k = 2; k < 10; k ++)
{
j = (int)(log10(k) * PX / m_nXStep + 1.0 * (m_nXStep - 1) * PX / m_nXStep + GL);
DrawLine(j, GT + 1, j, GB - 1);
}
for(i = 1; i < YGridTicks; i ++)
{
j = GT + (int)(1.0 * i * (GB-GT) / YGridTicks);
DrawLine(GL + 1, j, GR - 1, j);
}
::SelectObject(m_hDC, hOldPen);
::DeleteObject(hPen);
}
template<class T>
POINT CXLogYLinear<T>::GetPoint(T x, T y)
{
m_Pt.x = (LONG)((log10(x) - m_Scale.xmin) / m_Scale.dx) + GL;
m_Pt.y = (LONG)(GB - (y - m_Scale.ymin) / m_Scale.dy);
return m_Pt;
}
template<class T>
void CXLogYLinear<T>::GetValue(POINT& pt, T& x, T& y)
{
x = (T)pow(10, m_Scale.xmin + (pt.x - GL) * m_Scale.dx);
y = (T)(m_Scale.ymin + (GB - pt.y) * m_Scale.dy);
}
///////////////////////////////////////////////////////////////////////////////
// CXLinearYLog operations
template<class T>
bool CXLinearYLog<T>::SetRange(double xmin, double ymin, double xmax, double ymax)
{
m_nAxesType = YLOG;
if (ymin < 0.000001 || ymax < 0.000001)
{
::MessageBox(NULL, "The Y minimum value must be larger than 0.000001", "Warning", MB_ICONWARNING);
return false;
}
m_Scale.xmin = xmin;
m_Scale.ymin = log10(ymin);
m_Scale.xmax = xmax;
m_Scale.ymax = log10(ymax);
m_nYStep = (int)(m_Scale.ymax - m_Scale.ymin);
return true;
}
template<class T>
void CXLinearYLog<T>::YAxis()
{
int xb, yb, xe, ye;
int i, j, k = 1;
char str[32];
float value;
xe = GL;
for(i = 1; i <= m_nYStep; i ++)
{
for(j = 1; j <= 10; j ++)
{
if (k == 0)
xb = GL - m_lM / 10;
else
xb = GL - m_lM / 20;
yb = ye = GB - (int)(log10(j) * PY / m_nYStep + 1.0 * (i - 1) * PY / m_nYStep);
if (j == 1)
{
value = (float)(pow(10.0, m_Scale.ymin) * pow(10.0, i - 1));
Format(m_nYDecimal, str, value);
PrintString(GL - m_lM / 6, yb, 0, str);
}
if ((i != 1 || j != 1) && (i != m_nYStep || j != 10))
DrawLine(xb, yb, xe, ye);
k = 1;
}
k=0;
}
value = (float)(pow(10.0, m_Scale.ymin) * pow(10.0, i - 1));
Format(m_nYDecimal, str, value);
PrintString(GL - m_lM / 6, yb, 0, str);
}
template<class T>
void CXLinearYLog<T>::Grid()
{
int i, j, k;
HPEN hPen = ::CreatePen(PS_DOT, 0, m_nGridColor);
HPEN hOldPen = (HPEN)::SelectObject(m_hDC, hPen);
for(i = 1; i < XGridTicks; i ++)
{
j = GL + (int)(1.0 * i * (GR-GL) / XGridTicks);
DrawLine(j, GT + 1, j, GB - 1);
}
for(i = 1; i < m_nYStep; i ++)
for(k = 2; k <= 10; k ++)
{
j = GB - (int)(log10(k) * PY / m_nYStep + 1.0 * (i - 1) * PY / m_nYStep);
DrawLine(GL + 1, j, GR - 1, j);
}
for(k = 2; k < 10; k ++)
{
j = GB - (int)(log10(k) * PY / m_nYStep + 1.0 * (m_nYStep - 1) * PY / m_nYStep);
DrawLine(GL + 1, j, GR - 1, j);
}
::SelectObject(m_hDC, hOldPen);
::DeleteObject(hPen);
}
template<class T>
POINT CXLinearYLog<T>::GetPoint(T x, T y)
{
m_Pt.x = (LONG)((x - m_Scale.xmin) / m_Scale.dx) + GL;
m_Pt.y = (LONG)(GB - (log10(y) - m_Scale.ymin) / m_Scale.dy);
return m_Pt;
}
template<class T>
void CXLinearYLog<T>::GetValue(POINT& pt, T& x, T& y)
{
x = (T)(m_Scale.xmin + (pt.x - GL) * m_Scale.dx);
y = (T)pow(10, (m_Scale.ymin + (GB - pt.y) * m_Scale.dy));
}
///////////////////////////////////////////////////////////////////////////////
// CXLogYLog operations
template<class T>
bool CXLogYLog<T>::SetRange(double xmin, double ymin, double xmax, double ymax)
{
m_nAxesType = XYLOG;
if (xmin < 0.000001 || xmax < 0.000001)
{
::MessageBox(NULL, "The X minimum value must be larger than 0.000001", "Warning", MB_ICONWARNING);
return false;
}
if (ymin < 0.000001 || ymax < 0.000001)
{
::MessageBox(NULL, "The Y minimum value must be larger than 0.000001", "Warning", MB_ICONWARNING);
return false;
}
m_Scale.xmin = log10(xmin);
m_Scale.ymin = log10(ymin);
m_Scale.xmax = log10(xmax);
m_Scale.ymax = log10(ymax);
m_nXStep = (int)(m_Scale.xmax - m_Scale.xmin);
m_nYStep = (int)(m_Scale.ymax - m_Scale.ymin);
return true;
}
template<class T>
void CXLogYLog<T>::XAxis()
{
int xb, yb, xe, ye;
int i, j, k = 1;
char str[32];
float value;
yb = GB;
for(i = 1; i <= m_nXStep; i ++)
{
for(j = 1; j <= 10; j ++)
{
if (k == 0)
ye = GB + m_bM / 7;
else
ye = GB + m_bM / 14;
xb = xe = (int)(log10(j) * PX / m_nXStep + 1.0 * (i-1) * PX / m_nXStep + GL);
if (j == 1)
{
value = (float)(pow(10.0, m_Scale.xmin) * pow(10.0, i - 1));
Format(m_nXDecimal, str, value);
PrintString(xb, GB + m_bM / 5, 0, str);
}
if ((i != 1 || j != 1) && (i != m_nXStep || j != 10))
DrawLine(xb, yb, xe, ye);
k = 1;
}
k=0;
}
value = (float)(pow(10.0, m_Scale.xmin) * pow(10.0, i - 1));
Format(m_nXDecimal, str, value);
PrintString(GR, GB + m_bM / 5, 0, str);
}
template<class T>
void CXLogYLog<T>::YAxis()
{
int xb, yb, xe, ye;
int i, j, k = 1;
char str[32];
float value;
xe = GL;
for(i = 1; i <= m_nYStep; i ++)
{
for(j = 1; j <= 10; j ++)
{
if (k == 0)
xb = GL - m_lM / 10;
else
xb = GL - m_lM / 20;
yb = ye = GB - (int)(log10(j) * PY / m_nYStep + 1.0 * (i - 1) * PY / m_nYStep);
if (j == 1)
{
value = (float)(pow(10.0, m_Scale.ymin) * pow(10.0, i - 1));
Format(m_nYDecimal, str, value);
PrintString(GL - m_lM / 6, yb, 0, str);
}
if ((i != 1 || j != 1) && (i != m_nYStep || j != 10))
DrawLine(xb, yb, xe, ye);
k = 1;
}
k=0;
}
value = (float)(pow(10.0, m_Scale.ymin) * pow(10.0, i - 1));
Format(m_nYDecimal, str, value);
PrintString(GL - m_lM / 6, yb, 0, str);
}
template<class T>
void CXLogYLog<T>::Grid()
{
int i, j, k;
HPEN hPen = ::CreatePen(PS_DOT, 0, m_nGridColor);
HPEN hOldPen = (HPEN)::SelectObject(m_hDC, hPen);
for(i = 1; i < m_nXStep; i ++)
for(k = 2; k <= 10; k ++)
{
j = (int)(log10(k) * PX / m_nXStep + 1.0 * (i - 1) * PX / m_nXStep + GL);
DrawLine(j, GT + 1, j, GB - 1);
}
for(k = 2; k < 10; k ++)
{
j = (int)(log10(k) * PX / m_nXStep + 1.0 * (m_nXStep - 1) * PX / m_nXStep + GL);
DrawLine(j, GT + 1, j, GB - 1);
}
for(i = 1; i < m_nYStep; i ++)
for(k = 2; k <= 10; k ++)
{
j = GB - (int)(log10(k) * PY / m_nYStep + 1.0 * (i - 1) * PY / m_nYStep);
DrawLine(GL + 1, j, GR - 1, j);
}
for(k = 2; k < 10; k ++)
{
j = GB - (int)(log10(k) * PY / m_nYStep + 1.0 * (m_nYStep - 1) * PY / m_nYStep);
DrawLine(GL + 1, j, GR - 1, j);
}
::SelectObject(m_hDC, hOldPen);
::DeleteObject(hPen);
}
template<class T>
POINT CXLogYLog<T>::GetPoint(T x, T y)
{
m_Pt.x = (LONG)((log10(x) - m_Scale.xmin) / m_Scale.dx) + GL;
m_Pt.y = (LONG)(GB - (log10(y) - m_Scale.ymin) / m_Scale.dy);
return m_Pt;
}
template<class T>
void CXLogYLog<T>::GetValue(POINT& pt, T& x, T& y)
{
x = (T)pow(10, (m_Scale.xmin + (pt.x - GL) * m_Scale.dx));
y = (T)pow(10, (m_Scale.ymin + (GB - pt.y) * m_Scale.dy));
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -