#include "stdafx.h"
#include "SChartWnd.h"
 
namespace SOUI
{
	double Func(double x, double y)
	{
		return 2.0/((x+1.0)*(x+1.0)+y*y+2.0)+1.0/((x-1.0)*(x-1.0)+y*y+1.0);
	}

	SChartWnd::SChartWnd()
	{
		m_bFocusable = TRUE;
	}
 
 
	SChartWnd::~SChartWnd()
	{
	}
 
//	void SChartWnd::OnPaint(IRenderTarget *pRT)
//	{
		
//	}
	int SChartWnd::OnCreate(LPVOID lpVoid)
	{
		SetFocus();
		HWND hWndHost = GetContainer()->GetHostHwnd();
		hChartWnd = CreateSubChartWnd(hWndHost, kTypeContour);

		GetChart(hChartWnd)->SetFieldFcn(Func);
		GetChart(hChartWnd)->SetPlotRange(-4.0, 4.0, -4.0, 4.0);
		GetChart(hChartWnd)->SetContourPrecision(8);

		return 0;
	}
	void SChartWnd::OnSize(UINT nType, CSize size)
	{
		CRect rt;
		GetClientRect(&rt);
		::MoveWindow(hChartWnd, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top, TRUE);
	}
}