Пример #1
0
CChartSerie* CChartCtrl::AddSerie(int Type)
{
	size_t Count = m_pSeriesList.size();

	size_t ColIndex = Count%10;
	CChartSerie* pNewLine = NULL;

	switch (Type)
	{
	case CChartSerie::stLineSerie:
		pNewLine = new CChartLineSerie(this);
		break;

	case CChartSerie::stPointsSerie:
		pNewLine = new CChartPointsSerie(this);
		break;

	case CChartSerie::stSurfaceSerie:
		pNewLine = new CChartSurfaceSerie(this);
		break;

	default:
		pNewLine = NULL;
		break;
	}

	if (pNewLine)
	{
		pNewLine->SetRect(m_PlottingRect);
		pNewLine->SetColor(pSeriesColorTable[ColIndex]);
		m_pSeriesList.push_back(pNewLine);
	}

	return pNewLine;
}
void CBase_SampleChart::ClearPeak(const CBase_AnalysisSample* pSample, DWORD dwFlag)
{
	EnableRefresh(false);
	if(dwFlag & FLAG_DATA_SOURCE)
	{
		CChartSerie* pSerie = GetMainSerie();
		if(pSerie) pSerie->ClearSerie();
	}
// 	if(dwFlag & FLAG_POINTS_BEGIN)
// 	{
// 		if(m_pBeginPoints) m_pBeginPoints->ClearSerie();
// 	}
// 	if(dwFlag & FLAG_POINTS_PEAK)
// 	{
// 		if(m_pPeakPoints) m_pPeakPoints->ClearSerie();
// 	}
// 	if(dwFlag & FLAG_POINTS_END)
// 	{
// 		if(m_pEndPoints) m_pEndPoints->ClearSerie();
// 	}
	if(dwFlag & FLAG_LINES_BASE)
	{
		CChartLineSerie* pLine = NULL;
		for(int i=0; i<=m_arrBaseLines.GetUpperBound(); i++)
		{
			pLine = m_arrBaseLines.GetAt(i);
			if(pLine) RemoveSerie(pLine->GetSerieId());
		}
		m_arrBaseLines.RemoveAll();
	}
	if(dwFlag & FLAG_LINES_DIVIDEBASE)
	{
		CChartLineSerie* pLine = NULL;
		for(int i=0; i<=m_arrDivideBaseLines.GetUpperBound(); i++)
		{
			pLine = m_arrDivideBaseLines.GetAt(i);
			if(pLine) RemoveSerie(pLine->GetSerieId());
		}
		m_arrDivideBaseLines.RemoveAll();
	}
	DWORD dwFMask = dwFlag & FLAGMASK_STRINGS_ASSISTANT;
	if(dwFMask == FLAGMASK_STRINGS_ASSISTANT)
	{
		//同时都删除,才清空		
		CSuperChartString* pSerie = NULL;
		for(int i=0; i<=m_arrAssistants.GetUpperBound(); i++)
		{
			pSerie = m_arrAssistants.GetAt(i);
			if(pSerie) RemoveChartString(pSerie);
		}
		m_arrAssistants.RemoveAll();
	}
	else if(dwFMask)
	{
		//否则,重画
		RedrawPeak(pSample, FLAGMASK_STRINGS_ASSISTANT & ~dwFMask);
	}
	EnableRefresh(true);
	RefreshCtrl();
}
Пример #3
0
CSize CChartLegend::GetSize(CDC* pDC) const
{
	CSize LegendSize;
	CSize TextSize;

	if (!m_bIsVisible)
	{
		LegendSize.cx = LegendSize.cy = 0;
		return LegendSize;
	}

	CFont* pOldFont;
	CFont NewFont;
	NewFont.CreatePointFont(m_iFontSize, (LPCTSTR)m_strFontName.c_str(),pDC);
	pOldFont = pDC->SelectObject(&NewFont);

	int Height = 4;		//Upper space
	int Width = 0;		
	int MaxTextWidth = 0;

	size_t SeriesCount = m_pParent->GetSeriesCount();
	int Drawn = 0;
	for (size_t i=0;i<SeriesCount;i++)
	{
		CChartSerie* pSerie = m_pParent->GetSerie(i);
		if ( (pSerie->GetName() == _T("")) || !pSerie->IsVisible() )
			continue;

		Drawn++;
		CSize BitmapSize =pSerie->GetLegendSize();
		TextSize = pDC->GetTextExtent(pSerie->GetName().c_str());

		if (TextSize.cy>BitmapSize.cy)
			Height += TextSize.cy + 2;
		else
			Height += BitmapSize.cy + 2;

		if ( (TextSize.cx + BitmapSize.cx + 6)> MaxTextWidth)
			MaxTextWidth = TextSize.cx + BitmapSize.cx + 6;
	}

	if (!Drawn)
	{
		LegendSize.cx = LegendSize.cy = 0;
		return LegendSize;
	}

	Width += MaxTextWidth + 6;
	LegendSize.cx = Width;
	LegendSize.cy = Height+2;

	pDC->SelectObject(pOldFont);
	DeleteObject(NewFont);
	return LegendSize;
}
void CBase_SampleChart::ClearCurve2DSeries()
{
	POSITION pos = m_mapCurve2DSeries.GetStartPosition();
	void* pv = NULL;
	CString key;
	while(pos)
	{
		m_mapCurve2DSeries.GetNextAssoc(pos, key, pv);
		CChartSerie* pSerie = (CChartSerie*)pv;
		if(pSerie) RemoveSerie(pSerie->GetSerieId());
	}
	m_mapCurve2DSeries.RemoveAll();
}
CChartSerie* CBase_SampleChart::CreateCurve2DSerie(const CString& group, const CString& serie)
{
	void* pV = NULL;
	if(m_mapCurve2DSeries.Lookup(group + _T("_") + serie, pV))
	{
		if(((CChartSerie*)pV)->SerieType == m_eSerieType) return (CChartSerie*)pV;
		else RemoveSerie(((CChartSerie*)pV)->GetSerieId()); 
	}

	CChartSerie* pSerie = CreateSerie();
	if(pSerie) pSerie->SetName((LPCTSTR)serie);
	m_mapCurve2DSeries.SetAt(group + _T("_") + serie, pSerie);
	return pSerie;
}
Пример #6
0
void CChartLegend::Draw(CDC *pDC)
{
	if (!pDC->GetSafeHdc())
		return;
	if (!m_bIsVisible)
		return;

	int YPos = 2;
	int MaxBitmapWidth = 0;
	bool bDraw = false;

	size_t SeriesCount = m_pParent->GetSeriesCount();
	size_t i=0;
	for (i=0;i<SeriesCount;i++)
	{
		CChartSerie* pSerie = m_pParent->GetSerie(i);
		if ( (pSerie->GetName() == _T("")) || !pSerie->IsVisible() )
			continue;

		bDraw = true;
		CSize BitmapSize = pSerie->GetLegendSize();
		if (BitmapSize.cx > MaxBitmapWidth)
			MaxBitmapWidth = BitmapSize.cx;
	}

	if (!bDraw)
		return;

	CPen SolidPen(PS_SOLID,0,RGB(0,0,0));
	CPen* pOldPen;
	CFont* pOldFont;
	CFont NewFont;
	NewFont.CreatePointFont(m_iFontSize,(LPCTSTR)m_strFontName.c_str(),pDC);

	//Fill back color
	CBrush m_BrushBack;
	m_BrushBack.CreateSolidBrush(m_ObjectColor) ;
	pDC->FillRect(m_ObjectRect,&m_BrushBack);
	COLORREF OldColor = pDC->SetBkColor(m_ObjectColor);

	pOldFont = pDC->SelectObject(&NewFont);
	pOldPen = pDC->SelectObject(&SolidPen);

	//Draw rectangle:
	pDC->MoveTo(m_ObjectRect.left,m_ObjectRect.top);
	pDC->LineTo(m_ObjectRect.right,m_ObjectRect.top);
	pDC->LineTo(m_ObjectRect.right,m_ObjectRect.bottom);
	pDC->LineTo(m_ObjectRect.left,m_ObjectRect.bottom);
	pDC->LineTo(m_ObjectRect.left,m_ObjectRect.top);

	CPoint UpperLeft;
	UpperLeft.x = m_ObjectRect.left;
	UpperLeft.y = m_ObjectRect.top + 4;
	for (i=0;i<SeriesCount;i++)
	{
		CChartSerie* pSerie = m_pParent->GetSerie(i);

		int NewHeight = pSerie->DrawLegend(pDC,UpperLeft,MaxBitmapWidth);
		UpperLeft.y += NewHeight+2;
	}

	pDC->SelectObject(pOldFont);
	DeleteObject(NewFont);
	pDC->SelectObject(pOldPen);
	DeleteObject(SolidPen);
	pDC->SetBkColor(OldColor);
}
Пример #7
0
void CChartLegend::Draw(CDC *pDC)
{
	if (!pDC->GetSafeHdc())
		return;
	if (!m_bIsVisible)
		return;
	if (m_ObjectRect.IsRectEmpty())
		return;

	CPen SolidPen(PS_SOLID,0,RGB(0,0,0));
	CPen* pOldPen;
	CFont* pOldFont;
	CFont NewFont;
	NewFont.CreatePointFont(m_iFontSize,m_strFontName.c_str(),pDC);

	// Draw the shadow
	if (m_bShadow)
	{
		CRect ShadowRect = m_ObjectRect;
		ShadowRect.OffsetRect(m_iShadowDepth,m_iShadowDepth);
		CBrush BrushShadow;
		BrushShadow.CreateSolidBrush(m_ShadowColor) ;
		pDC->FillRect(ShadowRect,&BrushShadow);
	}

	if (!m_bIsTransparent)
	{
		//Fill back color
		CBrush BrushBack;
		BrushBack.CreateSolidBrush(m_ObjectColor) ;
		pDC->FillRect(m_ObjectRect,&BrushBack);
	}

	pOldFont = pDC->SelectObject(&NewFont);
	pOldPen = pDC->SelectObject(&SolidPen);

	//Draw rectangle:
	pDC->MoveTo(m_ObjectRect.left,m_ObjectRect.top);
	pDC->LineTo(m_ObjectRect.right,m_ObjectRect.top);
	pDC->LineTo(m_ObjectRect.right,m_ObjectRect.bottom);
	pDC->LineTo(m_ObjectRect.left,m_ObjectRect.bottom);
	pDC->LineTo(m_ObjectRect.left,m_ObjectRect.top);

	int iPrevMode = pDC->SetBkMode(TRANSPARENT);
	CRect rectBitmap(m_ObjectRect.left+2,m_ObjectRect.top+5,
					 m_ObjectRect.left+2+m_BitmapSize.cx,
					 m_ObjectRect.top+6+m_BitmapSize.cy);
	int SeriesCount = m_pParent->GetSeriesCount();
	for (int i=0;i<SeriesCount;i++)
	{
		CChartSerie* pSerie = m_pParent->GetSerie(i);
		if ( (pSerie->GetName() == _T("")) || !pSerie->IsVisible() )
			continue;

		int MaxHeight = 0;
		CSize TextSize = pDC->GetTextExtent(pSerie->GetName().c_str());
		if (TextSize.cy > m_BitmapSize.cy)
		{
			pDC->ExtTextOut(rectBitmap.right+4,rectBitmap.top,ETO_CLIPPED,NULL,pSerie->GetName().c_str(),NULL);
			CRect rectTemp(rectBitmap);
			int YOffset = TextSize.cy/2 - rectBitmap.Height()/2;
			rectTemp.OffsetRect(0,YOffset);
			pSerie->DrawLegend(pDC,rectTemp);
			MaxHeight = TextSize.cy;
		}
		else
		{
			int YOffset = rectBitmap.CenterPoint().y - TextSize.cy/2;
			pDC->ExtTextOut(rectBitmap.right+4,YOffset,ETO_CLIPPED,NULL,pSerie->GetName().c_str(),NULL);
			MaxHeight = m_BitmapSize.cy;
			pSerie->DrawLegend(pDC,rectBitmap);
		}
		

		if (!m_bIsHorizontal)
			rectBitmap.OffsetRect(0,MaxHeight+2);
		else
			rectBitmap.OffsetRect(m_BitmapSize.cx+4+TextSize.cx+10,0);
	}

	pDC->SetBkMode(iPrevMode);
	pDC->SelectObject(pOldFont);
	DeleteObject(NewFont);
	pDC->SelectObject(pOldPen);
	DeleteObject(SolidPen);
}
Пример #8
0
void CChartLegend::UpdatePosition(CDC* pDC, const CRect& rcControl)
{
	CRect NewPosition;
	NewPosition.SetRectEmpty();
	if (!m_bIsVisible)
	{
		SetRect(NewPosition);
		return;
	}

	CFont* pOldFont;
	CFont NewFont;
	NewFont.CreatePointFont(m_iFontSize,m_strFontName.c_str(),pDC);
	pOldFont = pDC->SelectObject(&NewFont);

	int Height = 0;		
	int Width = 0;		
	int MaxText = 0;
	CSize TextSize;

	size_t SeriesCount = m_pParent->GetSeriesCount();
	int Drawn = 0;
	for (size_t i=0;i<SeriesCount;i++)
	{
		CChartSerie* pSerie = m_pParent->GetSerie(i);
		if ( (pSerie->GetName() == _T("")) || !pSerie->IsVisible() )
			continue;

		Drawn++;
		TextSize = pDC->GetTextExtent(pSerie->GetName().c_str());

		if (!m_bIsHorizontal)
		{
			if (TextSize.cy>m_BitmapSize.cy)
				Height += TextSize.cy + 2;
			else
				Height += m_BitmapSize.cy + 2;

			if (TextSize.cx > MaxText)
				MaxText = TextSize.cx;
		}
		else
		{
			Width += TextSize.cx + 4 + m_BitmapSize.cx + 10;
			if (TextSize.cy > MaxText)
				MaxText = TextSize.cy;
		}
	}
	pDC->SelectObject(pOldFont);
	DeleteObject(NewFont);

	if (!Drawn)
	{
		SetRect(NewPosition);
		return;
	}

	if (!m_bIsHorizontal)
	{
		Width += MaxText + m_BitmapSize.cx + 12;
		Height += 4 + 4 - 2;	// Top and bottom margins. -2 because space counted once too much
	}
	else
	{
		Width += 2 + 2 - 10;
		Height = 4 + max(m_BitmapSize.cy,MaxText) + 4;
	}
	
	if (!m_bDocked)
	{
		NewPosition.top = m_iTopPos;
		NewPosition.left = m_iLeftPos;
		NewPosition.bottom = m_iTopPos + Height + 2;
		NewPosition.right = m_iLeftPos + Width;
	}
	else
	{
		switch (m_DockSide)
		{
		case dsDockRight:
			NewPosition.top = ((rcControl.bottom-rcControl.top)/2) - ((Height + 2)/2);
			NewPosition.left = rcControl.right - (Width + 6);
			NewPosition.bottom = NewPosition.top + Height;
			NewPosition.right = NewPosition.left + Width;
			break;
		case dsDockLeft:
			NewPosition.top = ((rcControl.bottom-rcControl.top)/2) - ((Height + 2)/2);
			NewPosition.left = rcControl.left + 3; 
			NewPosition.bottom = NewPosition.top + Height;
			NewPosition.right = NewPosition.left + Width;
			break;
		case dsDockTop:
			NewPosition.top = rcControl.top + 3;  //((rcControl.bottom-rcControl.top)/2) - ((Height + 2)/2);
			NewPosition.left = ((rcControl.right-rcControl.left)/2) - (Width/2);  // rcControl.left + 3; 
			NewPosition.bottom = NewPosition.top + Height;
			NewPosition.right = NewPosition.left + Width;
			break;
		case dsDockBottom:
			NewPosition.top = rcControl.bottom - (Height + 2);  //((rcControl.bottom-rcControl.top)/2) - ((Height + 2)/2);
			NewPosition.left = ((rcControl.right-rcControl.left)/2) - (Width/2);  // rcControl.left + 3; 
			NewPosition.bottom = NewPosition.top + Height;
			NewPosition.right = NewPosition.left + Width;
			break;
		}
	}
	SetRect(NewPosition);
}
void CBase_SampleChart::RedrawPeakOnRealTime(const CBase_AnalysisSample* pSample, DWORD dwFlag, CBase_SampleChart::enumMode eMode, bool bRefresh)
{
	if(!pSample) return;
	EnableRefresh(false);

	if(dwFlag & FLAG_DATA_SOURCE)
	{
		CChartSerie* pSerie = GetMainSerie();
		if(pSerie)
		{
			pSerie->ClearSerie();
			const CArray<CCurveDataSingle>& m_srcData = pSample->m_dataMainCurve.m_arrayData;
			if(m_srcData.GetUpperBound() > -1)
			{
				pSerie->m_vPoints.InitPoints(m_srcData.GetUpperBound()+1);
				structMinMaxInfo mmi;
				GetBottomAxis()->GetMinMax(mmi.minx, mmi.maxx);
				GetLeftAxis()->GetMinMax(mmi.miny, mmi.maxy);
				bool bNeed = mmi.minx==0 && mmi.miny == 0 && mmi.maxx == 0 && mmi.maxy == 0;
				for (int i=0; i<=m_srcData.GetUpperBound(); ++i)
				{
					double x = m_srcData[i].dX;
					double y = m_srcData[i].dY;
					pSerie->m_vPoints.AddPoint(x, y);					
					if(mmi.minx > x) mmi.minx = x;
					if(mmi.maxx < x) mmi.maxx = x;
					if(mmi.miny > y) mmi.miny = y;
					if(mmi.maxy < y) mmi.maxy = y;
				}
				if(bNeed)
				{
					GetBottomAxis()->SetCoordinate(mmi.minx, mmi.maxx, COORDINATE_SET);
					GetLeftAxis()->SetCoordinate(mmi.miny, mmi.maxy, COORDINATE_SET);
				}
			}
		}
	}
	//const CPeakList* pPS = &pSample->m_cResultList;
	const CPeakList* pPS = &pSample->m_cPeakList;
	const CPeakList* pRT = &pSample->m_cAllRealTimePeakList; 
	
	if(dwFlag & FLAG_LINES_BASE)
	{
		//首先删除全部,再重新绘画
		if(eMode == MODE_SETALL) ClearPeak(pSample, FLAG_LINES_BASE);

		CChartLineSerie* pLine = NULL;
		for (int i=0; i<=pRT->m_cArrayData.GetUpperBound(); ++i)
		{
			pLine = CreateLineSerie();
			pLine->SetColor(m_crBaseLines);
			pLine->m_vPoints.AddPoint(pRT->m_cArrayData[i].m_dataBegin.dX, pRT->m_cArrayData[i].m_dataBegin.dY);
			pLine->m_vPoints.AddPoint(pRT->m_cArrayData[i].m_dataEnd.dX, pRT->m_cArrayData[i].m_dataEnd.dY);
			pLine->m_dwDPFlag = NULL;//不能在数据处理的曲线选择列表框中出现
			m_arrBaseLines.Add(pLine);
		}
	}
	if(dwFlag & FLAG_LINES_DIVIDEBASE)
	{
		CChartLineSerie* pLine = NULL;
		//首先删除全部,再重新绘画
		if(eMode == MODE_SETALL) ClearPeak(pSample, FLAG_LINES_DIVIDEBASE);

		for (int i=0; i<=pSample->m_arrayVLines.GetUpperBound(); ++i)
		{
			const CBase_AnalysisSample::structLine& line = pSample->m_arrayVLines.GetAt(i);
			pLine = CreateLineSerie();
			pLine->SetColor(m_crBaseLines);
			pLine->m_vPoints.AddPoint(line.begin.x, line.begin.y);
			pLine->m_vPoints.AddPoint(line.end.x, line.end.y);
			pLine->m_dwDPFlag = NULL;//不能在数据处理的曲线选择列表框中出现
			m_arrDivideBaseLines.Add(pLine);
		}
	}


	if((dwFlag & FLAG_STRINGS_RESERVEDTIME) || (dwFlag & FLAG_STRINGS_CONCENTRATION) || (dwFlag & FLAG_STRINGS_COMPONENTNAME) || (dwFlag & FLAG_STRINGS_FMJ) || (dwFlag & FLAG_STRINGS_FG))
	{
		
		//不管。首先删除全部,再重新绘画
		if(eMode == MODE_SETALL) ClearPeak(pSample, FLAGMASK_STRINGS_ASSISTANT);

		CString t;
		int i_upper_bound = pRT->m_cArrayData.GetUpperBound();
		for (int i=0; i<=i_upper_bound; ++i)
		{
			CString ass;
			const CPeakStandard& ps = pRT->m_cArrayData[i];
			if(dwFlag & FLAG_STRINGS_RESERVEDTIME) ass += CParamCommon::TimeString(ps.m_dReserveTime) + _T("/");
			if(dwFlag & FLAG_STRINGS_FMJ)
			{
				t.Format(_T("%.3f/"), ps.m_dArea);
				ass += t;
			}
			if(dwFlag & FLAG_STRINGS_FG)
			{
				t.Format(_T("%.3f/"), ps.m_dHeight);
				ass += t;
			}

			const CPeakStandard* pPSResult = GetPSByTime(pSample->m_cResultList, ps.m_dReserveTime);
			if(pPSResult)
			{
				if(dwFlag & FLAG_STRINGS_CONCENTRATION)
				{
					t.Format(_T("%.1f/"), pPSResult->m_dResultConcentration);
					ass += t;
				}
				if(dwFlag & FLAG_STRINGS_COMPONENTNAME)
				{
					ass += pPSResult->m_cStrComponentName;
					ass += _T('/');
				}
			}

			while(ass.Right(1) == _T("/")) ass.Delete(ass.GetLength()-1);
			//ass = _T("-->") + ass;
			CSuperChartString* pSerie = AddChartString(ps.m_dataTop.dX, ps.m_dataTop.dY, ass);
			pSerie->SetMustInPlottingRect(true);
			pSerie->Font.Color = m_crAssistants;
			pSerie->Font.SetSize(100);
			pSerie->Font.SetBold(550);
			pSerie->Font.SetAngle(600);
			pSerie->SetScreenOffset(-6, -8);
			pSerie->m_dwChartObjectFlag = CTWenChartObject::CHARTOBJECT_NOTINBZMANAGE;
			m_arrAssistants.Add(pSerie);
		}
	}
	EnableRefresh(true);
	if(bRefresh) RefreshCtrl();
}
void CBase_SampleChart::OnExportData()
{
	CString file = _T("C:/Points.csv");

	CFileDialog mFileDlg(FALSE,_T("csv"),_T("Points"),OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("csv文件|*.csv||"),this);
	DWORD dwVersion = GetVersion();
	DWORD dwWindowsMajorVersion =  (DWORD)(LOBYTE(LOWORD(dwVersion)));
	DWORD dwWindowsMinorVersion =  (DWORD)(HIBYTE(LOWORD(dwVersion)));
	if (dwVersion < 0x80000000) mFileDlg.m_ofn.lStructSize=88;//显示新的文件对话框
	else mFileDlg.m_ofn.lStructSize=76;//显示老的文件对话框
	mFileDlg.m_ofn.lpstrTitle= _T("保存到文件");
	if(mFileDlg.DoModal() !=IDOK ) return;
	file = mFileDlg.GetPathName();

	CString strSep = _T(",");
	CFile f;
	BOOL ret = f.Open(file,CFile::modeCreate | CFile::modeReadWrite);
	if(!ret)
	{
		MessageBox(_T("打开文件失败,可能是文件为只读属性或被占用"));
		return;
	}
	CString line(_T("时间"));
	//
	CArray<CChartSerie*, CChartSerie*> series;
	series.Add(m_pcCurveMain);
	unsigned maxCount = 0;
	CChartSerie* pSerieOfMaxCount = NULL;
	for(int i=0; i<=series.GetUpperBound(); ++i)
	{
		CChartSerie* pS = series.GetAt(i);
		unsigned c = pS->GetPointsCount();
		if(c > maxCount)
		{
			maxCount = c;
			pSerieOfMaxCount = pS;
		}
		line = line + strSep + pS->GetName().c_str();
	}
	//标题列
	{
		TWen_USES_CONVERSION;
		LPCSTR s=TWen_CT2A(line + _T("\r\n"));
		f.Write(s,strlen(s));
	}
	for(size_t i=0; i<maxCount; i++)
	{
		line.Format(_T("%.15f"), pSerieOfMaxCount->m_vPoints.m_pPoints[i].x);
		for(int j=0; j<=series.GetUpperBound(); ++j)
		{
			CChartSerie* pS = GetSerieByIndex(j);
			unsigned c = pS->GetPointsCount();
			CString v;
			if(c > i) v.Format(_T("%.15f"), pS->m_vPoints.m_pPoints[i].y);
			line = line + strSep + v;
		}
		{
			TWen_USES_CONVERSION;
			LPCSTR s=TWen_CT2A(line + _T("\r\n"));
			f.Write(s,strlen(s));
		}
	}
	f.Close();
	MessageBox(_T("数据已保存到文件[")+file+_T("]"));
}
void CBase_SampleChart::RefreshSample_Curve2DSeries(CBase_AnalysisSample* pSample ,const CString& dataFolder, bool bRefreshAxisRange)
{
	if(pSample)
	{
		CIADataCurve2D c2d;
		if(!PASUCCESS(pSample->GetIADataCurve2D(c2d))) return;
		structMinMaxInfo mmi;
		mmi.minx=0,mmi.miny=0,mmi.maxx=0,mmi.maxy=0;
		CString type;
		CIADataCurve2DSingle single;
		CString strMainGroup,strMainSerie;
		pSample->GetIADataCurve2D_MainInfo(&strMainGroup, &strMainSerie);
		long pos;
		c2d.BeginEnum(pos);
		while(c2d.GetNext(pos, type, single))
		{
			CString name,filename;
			single.BeginEnum();
			while(single.GetNext(name, filename))
			{
				void* pv = NULL;
				m_mapCurve2DVisibilites.Lookup(name, pv);
				void* pLine = NULL;
				bool bIsMain = strMainGroup == type && strMainSerie == name;
				if(bIsMain) continue;//主曲线由积分结果负责
				if(bIsMain) pLine = m_pcCurveMain;
				else m_mapCurve2DSeries.Lookup(name, pLine);
				if(pv)//需要绘画
				{
					if(bIsMain)
					{
						if(m_pcCurveMain)
						{
							m_pcCurveMain->ClearSerie();
							LoadSerieFromFile(mmi, m_pcCurveMain, dataFolder + filename);
							m_pcCurveMain->SetVisible(true);
						}
					}
					else
					{
						if(pLine == NULL)
						{
							CChartSerie* line = CreateCurve2DSerie(type, name);
							line->ClearSerie();
							LoadSerieFromFile(mmi, line, dataFolder + filename);
						}
						else ((CChartSerie*)pLine)->SetVisible(true);
					}
				}
				else
				{
					if(pLine) ((CChartSerie*)pLine)->SetVisible(false);
				}
			}
		}
		if(bRefreshAxisRange)
		{
			GetBottomAxis()->SetCoordinate(mmi.minx, mmi.maxx, COORDINATE_SET);
			GetLeftAxis()->SetCoordinate(mmi.miny, mmi.maxy, COORDINATE_SET);
		}
	}
}
void CBase_SampleChart::SetColor(DWORD dwFlag, COLORREF color)
{
	EnableRefresh(false);
	if(dwFlag & FLAG_DATA_SOURCE)
	{
		CChartSerie* pSerie = GetMainSerie();
		if(pSerie) pSerie->SetColor(color);
	}
// 	if(dwFlag & FLAG_POINTS_BEGIN)
// 	{
// 		if(m_pBeginPoints) m_pBeginPoints->SetColor(color);
// 	}
// 	if(dwFlag & FLAG_POINTS_PEAK)
// 	{
// 		if(m_pPeakPoints) m_pPeakPoints->SetColor(color);
// 	}
// 	if(dwFlag & FLAG_POINTS_END)
// 	{
// 		if(m_pEndPoints) m_pEndPoints->SetColor(color);
// 	}
	if(dwFlag & FLAG_LINES_BASE)
	{
		m_crBaseLines = color;
		CChartLineSerie* pLine = NULL;
		for(int i=0; i<=m_arrBaseLines.GetUpperBound(); i++)
		{
			pLine = m_arrBaseLines.GetAt(i);
			if(pLine) pLine->SetColor(color);
		}
	}
	if(dwFlag & FLAG_LINES_DIVIDEBASE)
	{
		m_crDivideBaseLines = color;
		CChartLineSerie* pLine = NULL;
		for(int i=0; i<=m_arrDivideBaseLines.GetUpperBound(); i++)
		{
			pLine = m_arrDivideBaseLines.GetAt(i);
			if(pLine) pLine->SetColor(color);
		}
	}
	if(dwFlag & FLAG_LINES_DIVIDEBASE)
	{
		m_crDivideBaseLines = color;
		CChartLineSerie* pLine = NULL;
		for(int i=0; i<=m_arrDivideBaseLines.GetUpperBound(); i++)
		{
			pLine = m_arrDivideBaseLines.GetAt(i);
			if(pLine) pLine->SetColor(color);
		}
	}
	DWORD dwFMask = dwFlag & FLAGMASK_STRINGS_ASSISTANT;
	if(dwFMask == FLAGMASK_STRINGS_ASSISTANT)
	{
		//同时都更改,才更改		
		m_crAssistants = color;
		CSuperChartString* pSerie = NULL;
		for(int i=0; i<=m_arrAssistants.GetUpperBound(); i++)
		{
			pSerie = m_arrAssistants.GetAt(i);
			if(pSerie) pSerie->Font.Color = m_crAssistants;
		}
	}//否则,无效
	EnableRefresh(true);
	RefreshCtrl();	
}