void CMyHistorgram::DrawLine(vector<CPoint> pointList, int lineStyle, int lineWidth, COLOR color)
{
	CPen newPen;
	newPen.CreatePen(lineStyle, lineWidth, color);
	m_pDC->SelectObject(&newPen);
	CPoint point;
	int mode;
	if (pointList.size())
	{
		point.x = (pointList[0].x - xMinValue) / xUnit;
		point.y = m_rect.bottom - (pointList[0].y - yMinValue) / yUnit;
		m_pDC->MoveTo(point);

		mode = pointList[0].y;
		m_modeIndex = pointList[0].x;
	}
	for (int i = 1; i < pointList.size(); i++)
	{
		point.x = (pointList[i].x - xMinValue) / xUnit;
		point.y = m_rect.bottom - (pointList[i].y - yMinValue) / yUnit;
		m_pDC->LineTo(point);

		if (pointList[i].y>mode)
		{
			mode = pointList[i].y;
			m_modeIndex = pointList[i].x;
		}
	}
	if (m_bShowEXDX)
	{
		if (pointList.size())
		{
			//m_pDC->MoveTo((m_modeIndex - xMinValue) / xUnit, m_rect.bottom);
			//m_pDC->LineTo((m_modeIndex - xMinValue) / xUnit, m_rect.top);

			m_meanValue = GetMeanValue(pointList);
			m_variance = GetVariance(pointList, m_meanValue);

			CFont font;
			font.CreatePointFont(160, _T("宋体"));
			CFont*def_font = m_pDC->SelectObject(&font);  //选择该字体进入PDC

			CString tempStr;
			tempStr.Format(_T("EX = %.2f"), m_meanValue);
			m_pDC->TextOut(m_rect.left + 40, m_rect.top + 20, tempStr);
			tempStr.Format(_T("DX = %.2f"), m_variance);
			m_pDC->TextOut(m_rect.left + 40, m_rect.top + 60, tempStr);

			m_pDC->SelectObject(def_font);//恢复PDC的缺省字体
			font.DeleteObject();//释放font对象
		}
	}

	
}
Exemplo n.º 2
0
void MgFeatureNumericFunctions::CalculateDistribution(VECTOR& values, VECTOR& distValues)
{
    STRING funcName;
    int numCats;
    double dataMin, dataMax;
    INT32 funcCode = -1;

    // Get the arguments from the FdoFunction
    STRING propertyName;
    bool supported = MgServerFeatureUtil::FindCustomFunction(m_customFunction, funcCode);

    if (supported)
    {
        switch(funcCode)
        {
            case EQUAL_CATEGORY: // Equal Category
            {
                MgServerFeatureUtil::GetArguments(m_customFunction, propertyName, numCats, dataMin, dataMax, m_type);
                GetEqualCategories(values, numCats, dataMin, dataMax, distValues);
                break;
            }
            case STDEV_CATEGORY: // StdDev Category
            {
                MgServerFeatureUtil::GetArguments(m_customFunction, propertyName, numCats, dataMin, dataMax, m_type);
                GetStandardDeviationCategories(values, numCats, dataMin, dataMax, distValues);
                break;
            }
            case QUANTILE_CATEGORY: // Quantile Category
            {
                MgServerFeatureUtil::GetArguments(m_customFunction, propertyName, numCats, dataMin, dataMax, m_type);
                GetQuantileCategories(values, numCats, dataMin, dataMax, distValues);
                break;
            }
            case JENK_CATEGORY: // Jenk Category
            {
                MgServerFeatureUtil::GetArguments(m_customFunction, propertyName, numCats, dataMin, dataMax, m_type);
                GetJenksCategories(values, numCats, dataMin, dataMax, distValues);
                break;
            }
            case MINIMUM:
            {
                GetMinimum(values,distValues);
                break;
            }
            case MAXIMUM:
            {
                GetMaximum(values,distValues);
                break;
            }
            case MEAN:
            {
                GetMeanValue(values,distValues);
                break;
            }
            case STANDARD_DEV:
            {
                GetStandardDeviation(values,distValues);
                break;
            }
            case UNIQUE:
            {
                MgUniqueFunction<double>::Execute(values, distValues);
                break;
            }
        }
    }
}