void CRegisterValueAnalyzerDlg::OnBnClickedAxisautomaticCheck()
{

	CChartAxis* pAxis = GetSelectedAxis();
	if ( ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->GetCheck() == 1)
		pAxis->SetAutomatic(true);
	else
	{
		TCHAR szBuffer[255];
		double MinVal=0, MaxVal=0;
		m_AxisMinValEdit.GetWindowText(szBuffer,254);
		//		MinVal = _tstof(szBuffer);
		MinVal = _tcstod(szBuffer, NULL);
		m_AxisMaxValEdit.GetWindowText(szBuffer,254);
		//		MaxVal = _tstof(szBuffer);
		MaxVal = _tcstod(szBuffer, NULL);

		if (MinVal > MaxVal)
		{
			MessageBox(_T("MinVal > MaxVal"),_T("Error"),MB_OK);
			((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(1);
			return;
		}
		pAxis->SetAutomatic(false);
		pAxis->SetMinMax(MinVal,MaxVal);
	}
	m_ChartCtrl.RefreshCtrl();
}
void CRegisterValueAnalyzerDlg::OnEnKillfocusAxislabelEdit()
{
	CChartAxis* pAxis = GetSelectedAxis();
	TCHAR szBuffer[255];
	GetDlgItem(IDC_AXISLABEL_EDIT)->GetWindowText(szBuffer,254);
	pAxis->GetLabel()->SetText(szBuffer);
	m_ChartCtrl.RefreshCtrl();	
}
void CRegisterValueAnalyzerDlg::OnBnClickedAxisinvertedCheck()
{
	CChartAxis* pAxis = GetSelectedAxis();
	if ( ((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->GetCheck() == 1)
		pAxis->SetInverted(true);
	else
		pAxis->SetInverted(false);	
	m_ChartCtrl.RefreshCtrl();	
}
void CRegisterValueAnalyzerDlg::OnBnClickedTopaxisRadio()
{
	CChartAxis* pAxis = m_ChartCtrl.GetTopAxis();
	if (pAxis->IsVisible())
		((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(1);
	else
		((CButton*)GetDlgItem(IDC_AXISVISIBLE_CHECK))->SetCheck(0);
	if (pAxis->GetGrid()->IsVisible())
		((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(1);
	else
		((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->SetCheck(0);
	if (pAxis->IsAutomatic())
		((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(1);
	else
		((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(0);
	if (pAxis->IsInverted())
		((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(1);
	else
		((CButton*)GetDlgItem(IDC_AXISINVERTED_CHECK))->SetCheck(0);
	if (pAxis->ScrollBarEnabled())
		((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(1);
	else
		((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->SetCheck(0);

	TChartString AxisLabel = pAxis->GetLabel()->GetText();
	GetDlgItem(IDC_AXISLABEL_EDIT)->SetWindowText(AxisLabel.c_str());

	double Min=0, Max=0;
	CString strBuff;
	pAxis->GetMinMax(Min,Max);
	strBuff.Format(_T("%.2f"),Min);
	GetDlgItem(IDC_AXISMINVAL_EDIT)->SetWindowText(strBuff);
	strBuff.Format(_T("%.2f"),Max);
	GetDlgItem(IDC_AXISMAXVAL_EDIT)->SetWindowText(strBuff);	
}
void CRegisterValueAnalyzerDlg::OnEnKillfocusAxismaxvalEdit()
{
	CChartAxis* pAxis = GetSelectedAxis();
	TCHAR szBuffer[255];
	double MinVal=0, MaxVal=0;
	m_AxisMinValEdit.GetWindowText(szBuffer,254);
	//	MinVal = _tstof(szBuffer);
	MinVal = _tcstod(szBuffer, NULL);
	m_AxisMaxValEdit.GetWindowText(szBuffer,254);
	//	MaxVal = _tstof(szBuffer);
	MaxVal = _tcstod(szBuffer, NULL);

	if (MinVal > MaxVal)
	{
		MessageBox(_T("MinVal > MaxVal"),_T("Error"),MB_OK);
		return;
	}
	pAxis->SetMinMax(MinVal,MaxVal);

	m_ChartCtrl.RefreshCtrl();
}
Example #6
0
CChartCtrl::CChartCtrl()
{
	RegisterWindowClass();

	m_BorderColor = RGB(0,0,0);
	BackColor = GetSysColor(COLOR_BTNFACE);
	EdgeType = EDGE_RAISED;

	CChartAxis* pBottom = new CChartAxis(this,true);
	CChartAxis* pLeft = new CChartAxis(this,false);
	CChartAxis* pTop = new CChartAxis(this,true);
	pTop->SetVisible(false);
	pTop->SetSecondary(true);
	CChartAxis* pRight = new CChartAxis(this,false);
	pRight->SetVisible(false);
	pRight->SetSecondary(true);

	m_pAxisList.push_back(pBottom);
	m_pAxisList.push_back(pLeft);
	m_pAxisList.push_back(pTop);
	m_pAxisList.push_back(pRight);

	m_pLegend = new CChartLegend(this);
	m_pTitles = new CChartTitle(this);
	
	m_bMemDCCreated = false;
	m_bPanEnabled = true;
	m_bRMouseDown = false;

	m_bZoomEnabled = true;
	m_bLMouseDown = false;
}
void CChartCtrl::AttachCustomSerie(CChartSerie* pNewSeries,
								   bool bSecondaryHorizAxis,
								   bool bSecondaryVertAxis)
{
	//AFX_MANAGE_STATE(AfxGetStaticModuleState()); 

	size_t ColIndex = m_mapSeries.size()%10;

	CChartAxis* pHorizAxis = NULL;
	CChartAxis* pVertAxis = NULL;
	if (bSecondaryHorizAxis)
		pHorizAxis = m_pAxes[TopAxis];
	else
		pHorizAxis = m_pAxes[BottomAxis];
	if (bSecondaryVertAxis)
		pVertAxis = m_pAxes[RightAxis];
	else
		pVertAxis = m_pAxes[LeftAxis];

	ASSERT(pHorizAxis != NULL);
	ASSERT(pVertAxis != NULL);

	if (pNewSeries)
	{
		pNewSeries->SetPlottingRect(m_PlottingRect);
		pNewSeries->SetColor(pSeriesColorTable[ColIndex]);
		pNewSeries->m_pHorizontalAxis = pHorizAxis;
		pNewSeries->m_pVerticalAxis = pVertAxis;
		m_mapSeries[pNewSeries->GetSerieId()] = pNewSeries;

		EnableRefresh(false);
		pVertAxis->RegisterSeries(pNewSeries);
		pVertAxis->RefreshAutoAxis();
		pHorizAxis->RegisterSeries(pNewSeries);
		pHorizAxis->RefreshAutoAxis();

		// The series will need to be redrawn so we need to refresh the control
		RefreshCtrl();
		EnableRefresh(true);
	}
}
void CRegisterValueAnalyzerDlg::OnBnClickedAxisscrollbarCheck()
{
	CChartAxis* pAxis = GetSelectedAxis();
	bool bShow = ((CButton*)GetDlgItem(IDC_AXISSCROLLBAR_CHECK))->GetCheck() == 1;
	pAxis->EnableScrollBar(bShow);
}
Example #9
0
void CChartCtrl::OnLButtonUp(UINT nFlags, CPoint point) 
{
	m_bLMouseDown = false;
	if (m_bZoomEnabled)
	{
		if ( (m_rectZoomArea.left > m_rectZoomArea.right) ||
			 (m_rectZoomArea.top > m_rectZoomArea.bottom))
		{
			GetBottomAxis()->UndoZoom();
			GetTopAxis()->UndoZoom();
			GetLeftAxis()->UndoZoom();
			GetRightAxis()->UndoZoom();
		}
		else
		{
			CChartAxis* pBottom = GetBottomAxis();
			double MinVal = 0;			
			double MaxVal = 0;
			
			if (pBottom->IsInverted())
			{
				MaxVal = pBottom->ScreenToValue(m_rectZoomArea.left);
				MinVal = pBottom->ScreenToValue(m_rectZoomArea.right);
			}
			else
			{
				MinVal = pBottom->ScreenToValue(m_rectZoomArea.left);
				MaxVal = pBottom->ScreenToValue(m_rectZoomArea.right);
			}
			pBottom->SetZoomMinMax(MinVal,MaxVal);

			CChartAxis* pLeft = GetLeftAxis();
			if (pLeft->IsInverted())
			{
				MaxVal = pLeft->ScreenToValue(m_rectZoomArea.bottom);
				MinVal = pLeft->ScreenToValue(m_rectZoomArea.top);
			}
			else
			{
				MinVal = pLeft->ScreenToValue(m_rectZoomArea.bottom);
				MaxVal = pLeft->ScreenToValue(m_rectZoomArea.top);
			}
			pLeft->SetZoomMinMax(MinVal,MaxVal);

			CChartAxis* pTop = GetTopAxis();
			if (pTop->IsInverted())
			{
				MaxVal = pTop->ScreenToValue(m_rectZoomArea.left);
				MinVal = pTop->ScreenToValue(m_rectZoomArea.right);
			}
			else
			{
				MinVal = pTop->ScreenToValue(m_rectZoomArea.left);
				MaxVal = pTop->ScreenToValue(m_rectZoomArea.right);
			}
			pTop->SetZoomMinMax(MinVal,MaxVal);

			CChartAxis* pRight = GetRightAxis();
			if (pRight->IsInverted())
			{
				MaxVal = pRight->ScreenToValue(m_rectZoomArea.bottom);
				MinVal = pRight->ScreenToValue(m_rectZoomArea.top);
			}
			else
			{
				MinVal = pRight->ScreenToValue(m_rectZoomArea.bottom);
				MaxVal = pRight->ScreenToValue(m_rectZoomArea.top);
			}
			pRight->SetZoomMinMax(MinVal,MaxVal);
		}

		RefreshCtrl();
	}

	CWnd::OnLButtonUp(nFlags, point);
}
	void CNormalsChartsCtrl::Update()
	{
		string ID;

		if (m_pStation)
		{
			ID = m_pStation->m_ID;
		}

		CWVariables variables = m_pStation->GetVariables();
		CGraphVector chartsDefine = GetCharts(variables);


		if (ID != m_lastStationID ||
			chartsDefine != m_lastChartsDefine ||
			m_zoom != m_lastZoom)
		{


			m_lastStationID = ID;
			m_charts.clear();
			m_splitters.clear();
			m_scrollHelper->ScrollToOrigin(true, true);

			if (m_pStation != NULL && !ID.empty())
			{
				CWaitCursor waitCursor;
				CRegistry registry("Charts");

				//pre-compute total graphics height 
				int totalHeight = 0;
				for (CGraphVector::iterator it1 = chartsDefine.begin(); it1 != chartsDefine.end(); it1++)
					totalHeight += max(50, min(800, registry.GetValue<int>("height" + to_string(it1->m_series.front().m_variable), 150)));

				CRect rect;
				GetClientRectSB(this, rect);
				if (totalHeight > rect.Height())//if they have a scrollbar, remove width of crolbar
					rect.right -= ::GetSystemMetrics(SM_CXVSCROLL);


				int width = int(rect.Width()*m_zoom);// -10;
				int height = 0;


				int top = 0;
				for (CGraphVector::iterator it1 = chartsDefine.begin(); it1 != chartsDefine.end(); it1++)
				{
					int firstVar = it1->m_series.front().m_variable;
					int height = max(50, min(800, registry.GetValue<int>("height" + to_string(firstVar), 150)));

					CChartCtrlPtr pChart;
					pChart.reset(new CChartCtrl);
					pChart->Create(this, CRect(0, top, width, top + height), CHART_BASE_ID + firstVar, WS_CHILD | WS_VISIBLE);
					top += height;

					pChart->EnableRefresh(false);

					TChartString title = UtilWin::ToUTF16(it1->m_title);
					pChart->GetTitle()->SetVisible(title.empty());
					if (!title.empty())
						pChart->GetTitle()->AddString(title);

					pChart->GetLegend()->SetVisible(it1->m_bShowLegend);
					pChart->GetLegend()->DockLegend(CChartLegend::dsDockBottomLeft);
					pChart->GetLegend()->EnableShadow(false);
					pChart->GetLegend()->EnableBorder(false);
					pChart->GetLegend()->SetTransparent(true);

					pChart->SetPanEnabled(false);
					pChart->SetZoomEnabled(false);
					pChart->SetBackGradient(RGB(250, 250, 250), RGB(200, 200, 200), gtVertical);
					pChart->SetLineInfoEnabled(true);

					//****************
					//X
					CTPeriod period(CTRef(YEAR_NOT_INIT, JANUARY, 0, 0, CTM(CTM::MONTHLY, CTM::OVERALL_YEARS)), CTRef(YEAR_NOT_INIT, DECEMBER, 0, 0, CTM(CTM::MONTHLY, CTM::OVERALL_YEARS)));
					CChartTRefAxis* pAxisX = (CChartTRefAxis*)pChart->GetAxis(CChartCtrl::BottomAxis);
					if (pAxisX == NULL)
					{
						pAxisX = new CChartTRefAxis;
						pAxisX->SetMinMax(period.Begin(), period.End());
						pAxisX->SetReferenceTick(period.Begin());

						pAxisX->SetPanZoomEnabled(false);
						pAxisX->EnableScrollBar(false);
						pAxisX->SetAutoHideScrollBar(false);
						pAxisX->GetGrid()->SetBackColor(gtAlternate2, RGB(235, 235, 255), RGB(245, 245, 255));
						pChart->AttachCustomAxis(pAxisX, CChartCtrl::BottomAxis);
						TChartString lable = UtilWin::ToUTF16(it1->m_Xtitle);
						if (!lable.empty())
							pAxisX->GetLabel()->SetText(lable);
					}

					ENSURE(pAxisX);

					for (CGraphSerieVector::iterator it2 = it1->m_series.begin(); it2 != it1->m_series.end(); it2++)
					{
						//****************
						//Y
						CChartCtrl::EAxisPos axis = it2->m_YAxis == 0 ? CChartCtrl::LeftAxis : CChartCtrl::RightAxis;
						CChartAxis* pAxisY = pChart->GetAxis(axis);
						if (pAxisY == NULL)
						{
							pAxisY = pChart->CreateStandardAxis(axis);
							pAxisY->SetAutomatic(true);
							pAxisY->SetPanZoomEnabled(false);
							pAxisY->EnableScrollBar(false);
							pAxisY->SetAutoHideScrollBar(false);
							TChartString lable = UtilWin::ToUTF16((it2->m_YAxis == 0) ? it1->m_Ytitle1 : it1->m_Ytitle2);
							pAxisY->GetLabel()->SetText(lable);

							//if (it2->m_YAxis == 1)
								//pAxisY->GetGrid()->SetVisible(false);
						}

						ENSURE(pAxisY);

						//****************
						//Series
						CChartXYSerie * pTheSerie = NULL;
						if (it2->m_type == CGraph::XY)
						{
							CChartPointsExSerie* pSerie = new CChartPointsExSerie(pChart.get());
							pChart->AttachCustomSerie(pSerie, false, it2->m_YAxis != 0);

							//general
							TChartString varName = WBSF::convert(GetFieldHeader(it2->m_variable));
							pSerie->SetName(varName);
							pSerie->EnableShadow(it2->m_bEnableShadow);
							pSerie->SetShadowDepth(it2->m_shadowDepth);
							pSerie->SetShadowColor(it2->m_shadowColor);

							//point
							pSerie->SetPointType((CChartPointsExSerie::PointType)it2->m_symbolType);
							pSerie->SetPointSize(it2->m_symbolWidth, it2->m_symbolHeight);
							pSerie->SetColor(it2->m_symbolColor);
							pSerie->SetFillPoint(it2->m_bSymbolFilled);
							pSerie->SetPointFillColor(it2->m_symbolFillColor);
							//line
							pSerie->SetLineStyle((CChartPointsExSerie::LineType)it2->m_lineStyle);
							pSerie->SetLineWidth(it2->m_lineWidth);
							pSerie->SetLineColor(it2->m_lineColor);
							pSerie->SetLineSmooth(it2->m_bLineSmoothed);
							//surface
							pSerie->SetSurfaceFillStyle((CChartPointsExSerie::FillStyle)it2->m_fillStyle);
							pSerie->SetSurfaceFillColor(it2->m_fillColor);
							pSerie->EnableTooltip(true);

							pTheSerie = pSerie;
						}
						else if (it2->m_type == CGraph::HISTOGRAM)
						{
							CChartBarSerie* pSerie = new CChartBarSerie(pChart.get());
							pChart->AttachCustomSerie(pSerie, false, it2->m_YAxis != 0);

							//general
							TChartString varName = WBSF::convert(GetFieldHeader(it2->m_variable));
							pSerie->SetName(varName);

							//histogram
							pSerie->SetHorizontal(it2->m_histDirection == CGraphSerie::HIST_HORIZONTAL);
							pSerie->SetBarWidth(it2->m_histBarWidth);
							pSerie->SetColor(it2->m_histBarColor);
							pSerie->SetBorderWidth(it2->m_histBorderWidth);
							pSerie->SetBorderColor(it2->m_histBorderColor);
							pSerie->EnableTooltip(true);

							pTheSerie = pSerie;
						}
						else if (it2->m_type == CGraph::CANDLE_STICK)
						{
							CChartCandlestickSerie* pSeries = new CChartCandlestickSerie(pChart.get());
						}
						else if (it2->m_type == CGraph::BOX_PLOT)
						{
							assert(false); //todo
						}



						if (it2->m_type == CGraph::XY || it2->m_type == CGraph::HISTOGRAM)
						{
							size_t f = it2->m_variable;

							SChartXYPoint* pPoints = new SChartXYPoint[12];

							int ii = 0;
							for (size_t m = 0; m < 12; m++)
							{
								pPoints[ii].X = period.Begin()+m;
								pPoints[ii].Y = (*m_pStation)[m][f];
								ii++;
							}

							pTheSerie->SetSeriesOrdering(poNoOrdering);
							pTheSerie->SetPoints(pPoints, (int)ii);

							delete pPoints;
						}
						else
						{

						}
					}

					m_charts.push_back(pChart);


					//add splitter
					CSplitterControlPtr pSplitter(new CSplitterControl);
					pSplitter->Create(WS_CHILD | WS_VISIBLE, CRect(-m_scrollHelper->GetScrollPos().cx, top, -m_scrollHelper->GetScrollPos().cx + width, top + STD_GAP), this, SPLITTER_BASE_ID + firstVar, SPS_HORIZONTAL | SPS_DELTA_NOTIFY | SPS_DOWN_MOVE);
					m_splitters.push_back(pSplitter);
					top += STD_GAP;
				}

				ASSERT(m_splitters.size() == m_charts.size());
				for (int i = 0; i < m_splitters.size(); i++)
				{
					m_splitters[i]->RegisterLinkedWindow(SPLS_LINKED_UP, m_charts[i].get());

					for (int j = i + 1; j < m_charts.size(); j++)
					{
						m_splitters[i]->RegisterLinkedWindow(SPLS_LINKED_DOWN, m_charts[j].get());
						m_splitters[i]->RegisterLinkedWindow(SPLS_LINKED_DOWN, m_splitters[j].get());
					}
				}

				UpdateScrollHelper();

				//enable char redraw
				CWaitCursor cursor;
				//#pragma omp parrallel for
				for (CChartCtrlMap::iterator it = m_charts.begin(); it != m_charts.end(); it++)
				{
					(*it)->EnableRefresh(true);
				}
			}
		}
	}
Example #11
0
BOOL CAntimonyDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	m_brush.CreateSolidBrush(RGB(0, 122, 204));
	m_font.CreatePointFont(120, L"微软雅黑");
	m_font1.CreatePointFont(150, L"微软雅黑");
	m_font2.CreatePointFont(200, L"微软雅黑");
	m_font3.CreatePointFont(170, L"微软雅黑");
	m_font4.CreatePointFont(240, L"微软雅黑");
	setbtColor(&m_btfeature, RGB(0, 122, 204));
	m_btfeature.SetFont(&m_font1);
	m_btfeature.setfalseColor(RGB(255, 255, 0));
	setbtColor(&m_realTimePic, RGB(0, 122, 204));
	m_realTimePic.SetFont(&m_font1);
	m_realTimePic.setfalseColor(RGB(255, 255, 0));
	setbtColor(&m_btcurve, RGB(0, 122, 204));
	m_btcurve.SetFont(&m_font1);
	m_btcurve.setfalseColor(RGB(255, 255, 0));
	setbtColor(&m_flowEffect, RGB(241, 196, 15));
	m_flowEffect.SetFont(&m_font1);
	m_flowEffect.setfalseColor(RGB(255, 255, 255));
	setbtColor(&m_btflowEffect, RGB(241, 196, 15));
	m_btflowEffect.SetFont(&m_font4);
	m_btflowEffect.setfalseColor(RGB(255, 255, 255));
	setbtColor(&m_suggest, RGB(230, 127, 34));
	m_suggest.SetFont(&m_font1);
	m_suggest.setfalseColor(RGB(255, 255, 255));
	setbtColor(&m_btsuggest, RGB(230, 127, 34));
	m_btsuggest.SetFont(&m_font3);
	m_btsuggest.setfalseColor(RGB(255, 255, 255));
	setbtColor(&m_workCondition, RGB(232, 76, 61));
	m_workCondition.SetFont(&m_font1);
	m_workCondition.setfalseColor(RGB(255, 255, 255));
	setbtColor(&m_btworkCondition, RGB(232, 76, 61));
	m_btworkCondition.SetFont(&m_font3);
	m_btworkCondition.setfalseColor(RGB(255, 255, 255));
	setbtColor(&m_play, RGB(0, 122, 204));
	m_play.SetIcon(IDI_PLAY);
	setbtColor(&m_pause, RGB(0, 122, 204));
	m_pause.SetIcon(IDI_PAUSE);

	GetDlgItem(IDC_SHOWAVIS)->GetClientRect(&picrect);
	//showVedio();
	///////////////////////////为特征曲线图添加数值型的坐标轴///////////////////////////
	CChartAxis *pAxis = NULL;
	//pAxis = m_chartSize.CreateStandardAxis(CChartCtrl::BottomAxis);
	//pAxis->SetAutomatic(true);
	pAxis = m_chartSize.CreateStandardAxis(CChartCtrl::LeftAxis);
	pAxis->SetAutomatic(true);
	pAxis = m_chartSize.CreateStandardAxis(CChartCtrl::BottomAxis);
	pAxis->SetAutomatic(true);
	pAxis = m_chartSpeed.CreateStandardAxis(CChartCtrl::LeftAxis);
	pAxis->SetAutomatic(true);
	pAxis = m_chartSpeed.CreateStandardAxis(CChartCtrl::BottomAxis);
	pAxis->SetAutomatic(true);
	pAxis = m_chartTexture.CreateStandardAxis(CChartCtrl::LeftAxis);
	pAxis->SetAutomatic(true);
	pAxis = m_chartTexture.CreateStandardAxis(CChartCtrl::BottomAxis);
	pAxis->SetAutomatic(true);
	pAxis = m_chartColor.CreateStandardAxis(CChartCtrl::LeftAxis);
	pAxis->SetAutomatic(true);
	pAxis = m_chartColor.CreateStandardAxis(CChartCtrl::BottomAxis);
	pAxis->SetAutomatic(true);


	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////为特征曲线图添加左标题与下标题//////////////////////////
	CChartAxisLabel* pLabel = NULL;

	TChartString str1 = _T("泡沫大小");
	TChartString str2 = _T("泡沫速度");
	TChartString str3 = _T("泡沫稳定度");
	TChartString str4 = _T("红色分量");


	pAxis = m_chartSize.GetLeftAxis();
	if (pAxis)
		pLabel = pAxis->GetLabel();
	if (pLabel)
		pLabel->SetText(str1);
	pAxis = m_chartSpeed.GetLeftAxis();
	if (pAxis)
		pLabel = pAxis->GetLabel();
	if (pLabel)
		pLabel->SetText(str2);
	pAxis = m_chartTexture.GetLeftAxis();
	if (pAxis)
		pLabel = pAxis->GetLabel();
	if (pLabel)
		pLabel->SetText(str3);
	pAxis = m_chartColor.GetLeftAxis();
	if (pAxis)
		pLabel = pAxis->GetLabel();
	if (pLabel)
		pLabel->SetText(str4);
	// 	str1 = _T("数值坐标轴");
	// 	pAxis = m_chartCtr.GetBottomAxis();
	// 	if (pAxis)
	// 		pLabel = pAxis->GetLabel();
	// 	if (pLabel)
	// 		pLabel->SetText(str1);
	/////////////////////////////////////////////////////////////////////////////////

	for (int i = 0; i < 100; i++)
	{
		xxa[i] = xxb[i] = xxc[i] = xxd[i] = i;
//		yya[i] = yyb[i] = yyc[i] = yyd[i] = sin(float(i));
	}

	SetTimer(5, 500, NULL);
	SetTimer(6, 500, NULL);
	SetTimer(7, 500, NULL);
	SetTimer(8, 500, NULL);
	AfxBeginThread(threadVedio,this);
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常:  OCX 属性页应返回 FALSE
}
	void CWeatherChartsCtrl::Update()
	{
		string ID;
		CWVariablesCounter varCounts;
		bool bHourly = false;

		if (m_pStation)
		{
			ID = m_pStation->m_ID;
			varCounts = m_pStation->GetVariablesCount();
			//variables &= varCounts.GetVariables();
			for (size_t i = H_FIRST_VAR; i < NB_VAR_H; i++)
				if (m_variables.any() && !m_variables[i])
					varCounts[i] = CCountPeriod();

			bHourly = m_pStation->IsHourly();
		}



		CGraphVector chartsDefine = GetCharts(varCounts, bHourly);
		bool bValidPeriod = m_period.Begin() <= m_period.End();

		if (ID != m_lastStationID ||
			m_TM != m_lastTM ||
			m_stat != m_lastStat ||
			chartsDefine != m_lastChartsDefine ||
			((m_period != m_lastPeriod) && bValidPeriod) ||
			m_zoom != m_lastZoom)
		{


			m_lastStationID = ID;
			m_lastTM = m_TM;
			m_lastStat = m_stat;
			m_lastPeriod = m_period;

			m_charts.clear();
			m_splitters.clear();
			m_scrollHelper->ScrollToOrigin(true, true);

			if (m_pStation != NULL && !ID.empty())
			{


				CWaitCursor waitCursor;
				CRegistry registry("Charts");

				//pre-compute total graphics height 
				int totalHeight = 0;
				for (CGraphVector::iterator it1 = chartsDefine.begin(); it1 != chartsDefine.end(); it1++)
					totalHeight += max(50, min(800, registry.GetValue<int>("height" + to_string(it1->m_series.front().m_variable), 150)));

				CRect rect;
				GetClientRectSB(this, rect);
				if (totalHeight > rect.Height())//if they have a scrollbar, remove width of crolbar
					rect.right -= ::GetSystemMetrics(SM_CXVSCROLL);





				CTPeriod entirePeriod = m_pStation->GetEntireTPeriod(m_TM);
				CTPeriod period = entirePeriod;
				if (m_bPeriodEnable && m_period.IsInit())
				{
					period = m_period;
					period.Transform(m_TM);
				}
				else
				{
					int MAX_DATA_SIZE = registry.GetValue<int>("MaxDataSize", 10000);
					if (period.GetNbRef() > MAX_DATA_SIZE)
						period.End() = period.Begin() + MAX_DATA_SIZE;
				}



				int width = int(rect.Width()*m_zoom);// -10;
				int height = 0;


				int top = 0;
				for (CGraphVector::iterator it1 = chartsDefine.begin(); it1 != chartsDefine.end(); it1++)
				{
					int firstVar = it1->m_series.front().m_variable;
					int height = max(50, min(800, registry.GetValue<int>("height" + to_string(firstVar), 150)));

					CChartCtrlPtr pChart;
					pChart.reset(new CChartCtrl);
					//pChart->Create(this, CRect(-m_scrollHelper->GetScrollPos().cx, top, -m_scrollHelper->GetScrollPos().cx + width, top + height), CHART_BASE_ID + firstVar, WS_CHILD | WS_VISIBLE);
					pChart->Create(this, CRect(0, top, width, top + height), CHART_BASE_ID + firstVar, WS_CHILD | WS_VISIBLE);
					top += height;

					pChart->EnableRefresh(false);

					TChartString title = ToUTF16(it1->m_title);
					pChart->GetTitle()->SetVisible(title.empty());
					if (!title.empty())
						pChart->GetTitle()->AddString(title);

					pChart->GetLegend()->SetVisible(it1->m_bShowLegend);
					pChart->GetLegend()->DockLegend(CChartLegend::dsDockBottomLeft);
					pChart->GetLegend()->EnableShadow(false);
					pChart->GetLegend()->EnableBorder(false);
					pChart->GetLegend()->SetTransparent(true);

					pChart->SetPanEnabled(false);
					pChart->SetZoomEnabled(false);
					pChart->SetBackGradient(RGB(250, 250, 250), RGB(200, 200, 200), gtVertical);
					pChart->SetLineInfoEnabled(true);

					//****************
					//X

					CChartTRefAxis* pAxisX = (CChartTRefAxis*)pChart->GetAxis(CChartCtrl::BottomAxis);
					if (pAxisX == NULL)
					{
						pAxisX = new CChartTRefAxis;
						pAxisX->SetMinMax(period.Begin().GetRef(), period.End().GetRef());
						pAxisX->SetReferenceTick(period.Begin());

						pAxisX->SetPanZoomEnabled(false);
						pAxisX->EnableScrollBar(false);
						pAxisX->SetAutoHideScrollBar(false);
						pAxisX->GetGrid()->SetBackColor(gtAlternate2, RGB(235, 235, 255), RGB(245, 245, 255));
						pChart->AttachCustomAxis(pAxisX, CChartCtrl::BottomAxis);
						TChartString lable = ToUTF16(it1->m_Xtitle);
						if (!lable.empty())
							pAxisX->GetLabel()->SetText(lable);
					}

					ENSURE(pAxisX);

					for (CGraphSerieVector::iterator it2 = it1->m_series.begin(); it2 != it1->m_series.end(); it2++)
					{
						//****************
						//Y
						CChartCtrl::EAxisPos axis = it2->m_YAxis == 0 ? CChartCtrl::LeftAxis : CChartCtrl::RightAxis;
						CChartAxis* pAxisY = pChart->GetAxis(axis);
						if (pAxisY == NULL)
						{
							pAxisY = pChart->CreateStandardAxis(axis);
							pAxisY->SetAutomatic(true);
							pAxisY->SetPanZoomEnabled(false);
							pAxisY->EnableScrollBar(false);
							pAxisY->SetAutoHideScrollBar(false);
							TChartString lable = ToUTF16((it2->m_YAxis == 0) ? it1->m_Ytitle1 : it1->m_Ytitle2);
							pAxisY->GetLabel()->SetText(lable);

							//if (it2->m_YAxis == 1)
								//pAxisY->GetGrid()->SetVisible(false);
						}

						ENSURE(pAxisY);

						//****************
						//Series
						CChartXYSerie * pTheSerie = NULL;
						if (it2->m_type == CGraph::XY)
						{
							CChartPointsExSerie* pSerie = new CChartPointsExSerie(pChart.get());
							pChart->AttachCustomSerie(pSerie, false, it2->m_YAxis != 0);

							//general
							TChartString varName = WBSF::convert(GetVariableName(it2->m_variable));
							pSerie->SetName(varName);
							pSerie->EnableShadow(it2->m_bEnableShadow);
							pSerie->SetShadowDepth(it2->m_shadowDepth);
							pSerie->SetShadowColor(it2->m_shadowColor);

							//point
							pSerie->SetPointType((CChartPointsExSerie::PointType)it2->m_symbolType);
							pSerie->SetPointSize(it2->m_symbolWidth, it2->m_symbolHeight);
							pSerie->SetColor(it2->m_symbolColor);
							pSerie->SetFillPoint(it2->m_bSymbolFilled);
							pSerie->SetPointFillColor(it2->m_symbolFillColor);
							//line
							pSerie->SetLineStyle((CChartPointsExSerie::LineType)it2->m_lineStyle);
							pSerie->SetLineWidth(it2->m_lineWidth);
							pSerie->SetLineColor(it2->m_lineColor);
							pSerie->SetLineSmooth(it2->m_bLineSmoothed);
							//surface
							pSerie->SetSurfaceFillStyle((CChartPointsExSerie::FillStyle)it2->m_fillStyle);
							pSerie->SetSurfaceFillColor(it2->m_fillColor);
							pSerie->EnableTooltip(true);

							pTheSerie = pSerie;
						}
						else if (it2->m_type == CGraph::HISTOGRAM)
						{
							CChartBarSerie* pSerie = new CChartBarSerie(pChart.get());
							pChart->AttachCustomSerie(pSerie, false, it2->m_YAxis != 0);

							//general
							TChartString varName = WBSF::convert(GetVariableName(it2->m_variable));
							pSerie->SetName(varName);

							//histogram
							pSerie->SetHorizontal(it2->m_histDirection == CGraphSerie::HIST_HORIZONTAL);
							pSerie->SetBarWidth(it2->m_histBarWidth);
							pSerie->SetColor(it2->m_histBarColor);
							pSerie->SetBorderWidth(it2->m_histBorderWidth);
							pSerie->SetBorderColor(it2->m_histBorderColor);
							pSerie->EnableTooltip(true);

							pTheSerie = pSerie;
						}
						else if (it2->m_type == CGraph::CANDLE_STICK)
						{
							CChartCandlestickSerie* pSeries = new CChartCandlestickSerie(pChart.get());
						}
						else if (it2->m_type == CGraph::BOX_PLOT)
						{
							assert(false); //todo
						}



						if (it2->m_type == CGraph::XY || it2->m_type == CGraph::HISTOGRAM)
						{
							TVarH var = TVarH(it2->m_variable);

							SChartXYPoint* pPoints = new SChartXYPoint[period.size()];
							bool bIsFirstMissing = false;

							int ii = 0;
							for (CTRef TRef = period.Begin(); TRef <= period.End() /*&& ii < numberPoints*/; TRef++)
							{
								bool bInside = entirePeriod.IsInside(TRef);
								bool bIsInit = bInside && (*m_pStation)[TRef][var].IsInit();//don't access data to not create over data

								double x = bIsInit ? TRef.GetRef() : CHART_MISSING_VALUE;
								double y = bIsInit ? (*m_pStation)[TRef][var][m_stat] : CHART_MISSING_VALUE;
								//it2->m_statistic
								if (bIsInit || bIsFirstMissing)
								{
									pPoints[ii].X = x;
									pPoints[ii].Y = y;
									ii++;

									bIsFirstMissing = bIsInit;
								}
							}

							pTheSerie->SetSeriesOrdering(poNoOrdering);
							pTheSerie->SetPoints(pPoints, (int)ii);

							delete pPoints;
						}
						else
						{

						}
					}

					m_charts.push_back(pChart);


					//add splitter
					CSplitterControlPtr pSplitter(new CSplitterControl);
					pSplitter->Create(WS_CHILD | WS_VISIBLE, CRect(-m_scrollHelper->GetScrollPos().cx, top, -m_scrollHelper->GetScrollPos().cx + width, top + STD_GAP), this, SPLITTER_BASE_ID + firstVar, SPS_HORIZONTAL | SPS_DELTA_NOTIFY | SPS_DOWN_MOVE);
					m_splitters.push_back(pSplitter);
					top += STD_GAP;
				}

				ASSERT(m_splitters.size() == m_charts.size());
				for (int i = 0; i < m_splitters.size(); i++)
				{
					m_splitters[i]->RegisterLinkedWindow(SPLS_LINKED_UP, m_charts[i].get());

					for (int j = i + 1; j < m_charts.size(); j++)
					{
						m_splitters[i]->RegisterLinkedWindow(SPLS_LINKED_DOWN, m_charts[j].get());
						m_splitters[i]->RegisterLinkedWindow(SPLS_LINKED_DOWN, m_splitters[j].get());
					}
				}

				UpdateScrollHelper();

				//enable char redraw
				CWaitCursor cursor;
				//#pragma omp parrallel for
				for (CChartCtrlMap::iterator it = m_charts.begin(); it != m_charts.end(); it++)
				{
					(*it)->EnableRefresh(true);
				}
			}
		}
	}
void CRegisterValueAnalyzerDlg::OnBnClickedAxisgridvisCheck()
{
	CChartAxis* pAxis = GetSelectedAxis();
	if ( ((CButton*)GetDlgItem(IDC_AXISGRIDVIS_CHECK))->GetCheck() == 1)
		pAxis->GetGrid()->SetVisible(true);
	else
		pAxis->GetGrid()->SetVisible(false);
	m_ChartCtrl.RefreshCtrl();
}