// returns index of added item (or (-1))
int CLineChartCtrl::Add(const COLORREF lcolor, const UINT nLower, const UINT nUpper,
								const DWORD dwItemData, LINECHARTITEMPOSCFN lpfnPcfn)
{
	ASSERT(nLower < nUpper);
	CLineChartItem	*pItem=new CLineChartItem(lcolor, nUpper, nLower, dwItemData, lpfnPcfn);
#ifdef _DEBUG
	ASSERT(pItem != NULL);
#else
	if (NULL == pItem)
		return (-1);
#endif

	try 
	{
		const int	nIndex=m_items.Add(pItem);

		InvalidateCtrl();
		return nIndex;
	}
	catch (CMemoryException* e)
	{
		if (pItem !=NULL) 
			delete pItem;
		e->Delete();
		return (-1);
	}
}
Exemple #2
0
void COScopeCtrl::SetXUnits(CString string, CString XMin, CString XMax)
{
	m_str.XUnits = string;
	m_str.XMin = XMin;
	m_str.XMax = XMax;
	InvalidateCtrl(false);
}
Exemple #3
0
void COScopeCtrl::SetYUnits(CString string, CString YMin, CString YMax)
{
	m_str.YUnits = string;
	m_str.YMin = YMin;
	m_str.YMax = YMax;
	InvalidateCtrl();
}
Exemple #4
0
//##ModelId=43B25EC101D4
void CStarWarsCtrl::OnTimer(UINT nIDEvent) 
{
	if (nIDEvent == 1)
		InvalidateCtrl();

	CStatic::OnTimer(nIDEvent);
}
Exemple #5
0
void COScopeCtrl::SetPlotColor(COLORREF color)
{
 m_crPlotColor = color;
 m_penPlot.DeleteObject();
 m_penPlot.CreatePen(PS_SOLID, 0, m_crPlotColor);
 // clear out the existing garbage, re-start with a clean plot
 InvalidateCtrl();
}
void COScopeCtrl::SetGridColor(COLORREF color)
{
  m_crGridColor = color ;

  // clear out the existing garbage, re-start with a clean plot
  InvalidateCtrl() ;

}  // SetGridColor
Exemple #7
0
void COScopeCtrl::SetBackgroundColor(COLORREF color)
{
 m_crBackColor = color;
 m_brushBack.DeleteObject();
 m_brushBack.CreateSolidBrush(m_crBackColor);
 // clear out the existing garbage, re-start with a clean plot
 InvalidateCtrl();
}
void COScopeCtrl::SetYUnits(CString string)
{
  m_strYUnitsString = string ;

  // clear out the existing garbage, re-start with a clean plot
  InvalidateCtrl() ;

}  // SetYUnits
Exemple #9
0
void COScopeCtrl::Reset(double sNewPeriod)
{
	bool bStoppedPrev = bStopped;
	bStopped = false;
	if (sLastPeriod != sNewPeriod  ||  bStoppedPrev) {
		sLastPeriod = sNewPeriod;
		InvalidateCtrl();
	}
}
Exemple #10
0
void COScopeCtrl::Reset()
{
 m_point_position = 0;
 m_points.clear();
 m_dPreviousPosition = 0.0;
 // to clear the existing data (in the form of a bitmap)
 // simply invalidate the entire control
 InvalidateCtrl();
}
Exemple #11
0
void COScopeCtrl::SetRange(double dLower, double dUpper, int nDecimalPlaces)
{
 ASSERT(dUpper > dLower);
 m_dLowerLimit = dLower;
 m_dUpperLimit = dUpper;
 m_nYDecimals = nDecimalPlaces;
 m_dRange = m_dUpperLimit - m_dLowerLimit;
 m_dVerticalFactor = (double)m_rectPlot.Height() / m_dRange;
 InvalidateCtrl();
}
Exemple #12
0
void COScopeCtrl::SetRange(double dLower, double dUpper, int iTrend)
{
	ASSERT(dUpper > dLower);
	
	m_PlotData[iTrend].dLowerLimit     = dLower;
	m_PlotData[iTrend].dUpperLimit     = dUpper;
	m_PlotData[iTrend].dRange          = m_PlotData[iTrend].dUpperLimit - m_PlotData[iTrend].dLowerLimit;
	m_PlotData[iTrend].dVerticalFactor = (double)m_nPlotHeight / m_PlotData[iTrend].dRange; 
	InvalidateCtrl();
}
Exemple #13
0
void COScopeCtrl::SetBackgroundColor(const wxColour& cr)
{

	if (m_bgColour == cr) {
		return;
	}

	m_bgColour = cr;
	brushBack= *(wxTheBrushList->FindOrCreateBrush(cr, wxSOLID));
	InvalidateCtrl() ;
}
Exemple #14
0
void COScopeCtrl::SetRange(double dLower, double dUpper, int nDecimalPlaces)
{
 ASSERT(dUpper > dLower);

 m_dLowerLimit     = dLower;
 m_dUpperLimit     = dUpper;
 m_nYDecimals      = nDecimalPlaces;
 m_dRange          = m_dUpperLimit - m_dLowerLimit;
 m_dVerticalFactor = (double)m_rectPlot.Height() / m_dRange;
  
 // clear out the existing garbage, re-start with a clean plot
 InvalidateCtrl();
}
Exemple #15
0
BOOL COScopeCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID) 
{
 BOOL result;
 static CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW);

 result = CWnd::CreateEx(WS_EX_CLIENTEDGE | WS_EX_STATICEDGE, className, NULL, dwStyle,
                          rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
                          pParentWnd->GetSafeHwnd(), (HMENU)nID);
 if (result != 0)
  InvalidateCtrl();

 return result;
}
Exemple #16
0
void COScopeCtrl::OnSysColorChange()
{
	if (m_bitmapOldGrid.m_hObject)
		m_dcGrid.SelectObject(m_bitmapOldGrid.Detach());
	VERIFY( m_dcGrid.DeleteDC() );

	if (m_bitmapOldPlot.m_hObject)
		m_dcPlot.SelectObject(m_bitmapOldPlot.Detach());
	VERIFY( m_dcPlot.DeleteDC() );

	CWnd::OnSysColorChange();
	InvalidateCtrl(false);
}
Exemple #17
0
void COScopeCtrl::OnSize(UINT nType, int cx, int cy)
{
	if (!cx && !cy)
		return;

	//int iTrend;
	CWnd::OnSize(nType, cx, cy);
	
	// NOTE: OnSize automatically gets called during the setup of the control
	
	GetClientRect(m_rectClient);
	m_nClientHeight = m_rectClient.Height();
	m_nClientWidth = m_rectClient.Width();
	
	//MORPH - Moved every thing into the InvalidateCtrl as m_rectPlot is modifyed in
	/*
	// the "left" coordinate and "width" will be modified in InvalidateCtrl to be based on the width 
	// of the y axis scaling
	m_rectPlot.left = 20;
	m_rectPlot.top = 10;
	m_rectPlot.right = m_rectClient.right - 10;
	m_rectPlot.bottom = m_rectClient.bottom - 3 - (abs(sm_logFontAxis.lfHeight) + 2)*2 - 3;
	
	m_nPlotHeight = m_rectPlot.Height();
	m_nPlotWidth = m_rectPlot.Width();
	
	// set the scaling factor for now, this can be adjusted in the SetRange functions
	for (iTrend = 0; iTrend < m_NTrends; iTrend ++)
		m_PlotData[iTrend].dVerticalFactor = (double)m_nPlotHeight / m_PlotData[iTrend].dRange;
	*/
	// destroy and recreate the grid bitmap
	CClientDC dc(this);
	if (m_bitmapOldGrid.m_hObject && m_bitmapGrid.GetSafeHandle() && m_dcGrid.GetSafeHdc())
	{
		m_dcGrid.SelectObject(m_bitmapOldGrid.Detach());
		m_bitmapGrid.DeleteObject();
		m_bitmapGrid.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
		m_bitmapOldGrid.Attach(SelectObject(m_dcGrid, m_bitmapGrid));
	}
	
	// destroy and recreate the plot bitmap
	if (m_bitmapOldPlot.m_hObject && m_bitmapPlot.GetSafeHandle() && m_dcPlot.GetSafeHdc())
	{
		m_dcPlot.SelectObject(m_bitmapOldPlot.Detach());
		m_bitmapPlot.DeleteObject();
		m_bitmapPlot.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
		m_bitmapOldPlot.Attach(SelectObject(m_dcPlot, m_bitmapPlot));
	}
	
	InvalidateCtrl();
}
Exemple #18
0
void COScopeCtrl::Reset()
{
	// Clear all points
	for (int i = 0; i < m_NTrends; i++)
	{
		m_PlotData[i].dPreviousPosition = 0.0;
		m_PlotData[i].nPrevY = -1;

		for (int iTrend = 0; iTrend < m_NTrends; iTrend++)
			m_PlotData[iTrend].lstPoints.RemoveAll();
	}

	InvalidateCtrl();
}
Exemple #19
0
void COScopeCtrl::SetRanges(double dLower, double dUpper)
{
	ASSERT( dUpper > dLower );

	int iTrend;
	for (iTrend = 0; iTrend < m_NTrends; iTrend ++)
	{
		m_PlotData[iTrend].dLowerLimit     = dLower;
		m_PlotData[iTrend].dUpperLimit     = dUpper;
		m_PlotData[iTrend].dRange          = m_PlotData[iTrend].dUpperLimit - m_PlotData[iTrend].dLowerLimit;
		m_PlotData[iTrend].dVerticalFactor = (double)m_nPlotHeight / m_PlotData[iTrend].dRange; 
	}
	InvalidateCtrl();
}
Exemple #20
0
void COScopeCtrl::SetRange(float fLower, float fUpper, unsigned iTrend)
{
	PlotData_t* ppds = pdsTrends+iTrend;
	if ((ppds->fLowerLimit == fLower) && (ppds->fUpperLimit == fUpper))
		return;
	ppds->fLowerLimit = fLower;
	ppds->fUpperLimit = fUpper;
	ppds->fVertScale = (float)m_rectPlot.GetHeight() / (fUpper-fLower);
	ppds->yPrev = GetPlotY(ppds->fPrev, ppds);

	if (iTrend == 0) {
		InvalidateCtrl();
	} else {
		InvalidateGraph();
	}
}
Exemple #21
0
BOOL COScopeCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID) 
{
	BOOL result;
	static CString className = AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, AfxGetApp()->LoadStandardCursor(IDC_ARROW));
	
	result = CWnd::CreateEx(/*WS_EX_CLIENTEDGE*/ // strong (default) border
							WS_EX_STATICEDGE,	// lightweight border
							className, NULL, dwStyle, 
							rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
							pParentWnd->GetSafeHwnd(), (HMENU)nID);
	if (result != 0)
		InvalidateCtrl();
	InitWindowStyles(this);
	
	ready = true;
	return result;
}
Exemple #22
0
/////////////////////////////////////////////////////////////////////////////
// Set Trend Ratio
//
// This allows us to set a ratio for a trend in our plot.  Basically, this
// trend will be divided by whatever the ratio was set to, so that we can have
// big numbers and little numbers in the same plot.  Wrote this especially for
// šMule.
//
// iTrend is an integer specifying which trend of this plot we should set the
// ratio for.
//
// iRatio is an integer defining what we should divide this trend's data by.
// For example, to have a 1:2 ratio of Y-Scale to this trend, iRatio would be 2.
// iRatio is 1 by default (No change in scale of data for this trend)
// This function now borrows a bit from šMule Plus v1
//
void COScopeCtrl::SetTrendRatio(int iTrend, UINT iRatio)
{
	ASSERT(iTrend < m_NTrends && iRatio > 0);	// iTrend must be a valid trend in this plot.

	if (iRatio != (UINT)m_PlotData[iTrend].iTrendRatio) {
		double dTrendModifier = (double)m_PlotData[iTrend].iTrendRatio / iRatio;
		m_PlotData[iTrend].iTrendRatio = iRatio;

		int iCnt = m_PlotData[iTrend].lstPoints.GetCount();
		for (int i = 0; i < iCnt; i++)
		{	
			POSITION pos = m_PlotData[iTrend].lstPoints.FindIndex(i);
			if (pos)
				m_PlotData[iTrend].lstPoints.SetAt(pos,m_PlotData[iTrend].lstPoints.GetAt(pos) * dTrendModifier);
		}
		InvalidateCtrl();
	}
}
Exemple #23
0
BOOL CFFTDisp::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID )
//Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	BOOL result ;
	static CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW) ;

	result = CWnd::CreateEx(WS_EX_CLIENTEDGE | WS_EX_STATICEDGE, 
						  className, NULL, dwStyle, 
						  rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
						  pParentWnd->GetSafeHwnd(), (HMENU)nID) ;
	if (result != 0)
		InvalidateCtrl() ;

	return result ;

	//return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
Exemple #24
0
//##ModelId=43B25EC1003F
void CStarWarsCtrl::PreSubclassWindow() 
{
	CClientDC dc(this);

	GetClientRect(m_rectClient);

	// initialize stars
	for (int i = 0; i < NUM_STARS; i++)
	{
		m_StarArray[i].x = getrandom(0, 1024);
		m_StarArray[i].x -= 512;
		m_StarArray[i].y = getrandom(0, 1024);
		m_StarArray[i].y -= 512;
		m_StarArray[i].z = getrandom(0, 512);
		m_StarArray[i].z -= 256;
	}
/*
	m_TextLines.Add("A long time ago");
	m_TextLines.Add("");
	m_TextLines.Add("in a galaxy far far away");
	m_TextLines.Add("");
	m_TextLines.Add("this application was programmed by");
	m_TextLines.Add("");
	m_TextLines.Add("Pablo van der Meer");
	m_TextLines.Add("");
	m_TextLines.Add("Have fun!");
*/	
	m_nScrollPos = m_rectClient.Height();

	// calculate speed so that it scroll the same speed on a different machine
	DWORD t1 = GetTickCount();
	InvalidateCtrl();
	DWORD t2 = GetTickCount();

	t2 -= t1; // = 50 on my system

	m_nScrollSpeed = (m_nScrollSpeed * t2)/50;

	SetTimer(1, 75, NULL);

	CStatic::PreSubclassWindow();
}
void COScopeCtrl::SetRange(double dLower, double dUpper, int nDecimalPlaces)
{
	ASSERT(dUpper > dLower) ;

	m_dLowerLimit     = dLower ;
	m_dUpperLimit     = dUpper ;
	m_nYDecimals      = nDecimalPlaces ;
	m_dRange          = m_dUpperLimit - m_dLowerLimit ;
	m_dVerticalFactor = (double)m_nPlotHeight / m_dRange ; 

	// clear out the existing garbage, re-start with a clean plot
	InvalidateCtrl(false) ;
	if (m_bStopSample == TRUE)
	{
		unsigned int uiPos = 0;
		uiPos = m_pParentWnd->GetDlgItem(IDC_SCROLLBAR_GRAPHVIEW)->GetScrollPos(SB_HORZ);
		// 向滚动条发送消息
		m_pParentWnd->SendMessage(WM_HSCROLL, MAKELONG(SB_THUMBPOSITION, uiPos), 
			(LPARAM)m_pParentWnd->GetDlgItem(IDC_SCROLLBAR_GRAPHVIEW)->GetSafeHwnd());
	}

}  // SetRange
BOOL CLineChartCtrl::SetRange (const int nIndex, const UINT nLower, const UINT nUpper, const BOOL fInvalidate)
{
	if (nIndex >= m_items.GetSize())
		return FALSE;

	ASSERT(nLower < nUpper);
	CLineChartItem	*pItem=m_items.GetAt(nIndex);
#ifdef _DEBUG
	ASSERT(pItem != NULL);
#else
	if (NULL == pItem)
		return FALSE;
#endif

	pItem->m_nLower = nLower;
	pItem->m_nUpper = nUpper;

	if (fInvalidate)
		InvalidateCtrl();

	return TRUE;
}
Exemple #27
0
void CSetPgApps::DoEnableControls(WORD nGroupCtrlId)
{
	bool bAllowed = false;

	const AppSettings* pApp = NULL;
	int iCur = (int)SendDlgItemMessage(mh_Dlg, lbAppDistinct, LB_GETCURSEL, 0,0);
	if (iCur >= 0)
		pApp = gpSet->GetAppSettings(iCur);
	if (pApp && pApp->AppNames)
	{
		bAllowed = true;
	}

	for (size_t i = 0; i < countof(DistinctControls); i++)
	{
		if (nGroupCtrlId && (nGroupCtrlId != DistinctControls[i].nOverrideID))
			continue;

		bool bEnabled = bAllowed
			? (DistinctControls[i].nOverrideID ? isChecked2(mh_Child, DistinctControls[i].nOverrideID) : true)
			: FALSE;

		HWND hDlgCtrl = DistinctControls[i].nOverrideID ? mh_Child : mh_Dlg;

		if (DistinctControls[i].nOverrideID)
		{
			enableDlgItem(hDlgCtrl, DistinctControls[i].nOverrideID, bAllowed);
			if (!bAllowed)
				checkDlgButton(hDlgCtrl, DistinctControls[i].nOverrideID, BST_UNCHECKED);
		}

		_ASSERTE(DistinctControls[i].nCtrls[countof(DistinctControls[i].nCtrls)-1]==0 && "Overflow check of nCtrls[]")

		CSetDlgLists::EnableDlgItems(hDlgCtrl, DistinctControls[i].nCtrls, countof(DistinctControls[i].nCtrls), bEnabled);
	}

	InvalidateCtrl(mh_Child, FALSE);
}
Exemple #28
0
void COScopeCtrl::SetRange(double dLower, double dUpper, int nDecimalPlaces)
{
  ASSERT(dUpper > dLower) ;

  m_dLowerLimit     = dLower ;
  m_dUpperLimit     = dUpper ;
  m_nYDecimals      = nDecimalPlaces ;
  m_dRange          = m_dUpperLimit - m_dLowerLimit ;
  m_dVerticalFactor = (double)m_nPlotHeight / m_dRange ; 
  
  // clear out the existing garbage, re-start with a clean plot
  InvalidateCtrl() ;

  // Auto Ranging
  if(m_bWrapped )  // see if data points have wrapped  
  {    
	  m_dPreviousPosition = m_pdblDataPoints[(m_nDataIndex+1)%m_nBufferSize];
	  for( int i = ((m_nDataIndex+1)%m_nBufferSize); i != m_nDataIndex; i = (i + 1)%m_nBufferSize)
	  {      
		  m_dCurrentPosition = m_pdblDataPoints[i];
		  DrawPoint() ;
	  }  
  }  
  else if( m_nDataIndex != 0 )  // see if any data points have been stored  
  {    
	  m_dPreviousPosition = m_pdblDataPoints[0];
	  for( int i = 0; i < m_nDataIndex; i++)
	  {      
		  m_dCurrentPosition = m_pdblDataPoints[i];
		  DrawPoint();
	  }
  }

	// We don't need to erase, because we're blitting - berise
	Invalidate(FALSE);

}  // SetRange
Exemple #29
0
void COScopeCtrl::OnSize(wxSizeEvent& WXUNUSED(evt))
{
	// This gets called repeatedly as the user resizes the app;
	// we use the timer mechanism through InvalidateCtrl to avoid unnecessary redrawing
	// NOTE: OnSize automatically gets called during the setup of the control
	if(GetClientRect() == m_rectClient) {
		return;
	}

	m_rectClient = GetClientRect();
	if (m_rectClient.GetWidth() < 1 || m_rectClient.GetHeight() < 1) {
		return;
	}

	// the "left" coordinate and "width" will be modified in
	// InvalidateCtrl to be based on the y axis scaling
	m_rectPlot.SetLeft(20);
	m_rectPlot.SetTop(10);
	m_rectPlot.SetRight(std::max<int>(m_rectPlot.GetLeft() + 1, m_rectClient.GetRight() - 40));
	m_rectPlot.SetBottom(std::max<int>(m_rectPlot.GetTop() + 1, m_rectClient.GetBottom() - 25));

	PlotData_t* ppds = pdsTrends;
	for(unsigned iTrend=0; iTrend<nTrends; ++iTrend, ++ppds) {
		ppds->fVertScale = (float)m_rectPlot.GetHeight() / (ppds->fUpperLimit-ppds->fLowerLimit);
		ppds->yPrev = GetPlotY(ppds->fPrev, ppds);
	}

	if (!m_bmapGrid.IsOk() || (m_rectClient != wxSize(m_bmapGrid.GetWidth(), m_bmapGrid.GetHeight()))) {
		m_bmapGrid.Create(m_rectClient.GetWidth(), m_rectClient.GetHeight());
	}
	if (!m_bmapPlot.IsOk() || (m_rectPlot != wxSize(m_bmapPlot.GetWidth(), m_bmapPlot.GetHeight()))) {
		m_bmapPlot.Create(m_rectPlot.GetWidth(), m_rectPlot.GetHeight());
	}

	InvalidateCtrl();
}
Exemple #30
0
void CFFTDisp::OnSize(UINT nType, int cx, int cy) 
{
	CWnd::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	GetClientRect(m_rectPlot);  
	m_nClientHeight = m_rectPlot.Height();
	m_nClientWidth  = m_rectPlot.Width();
	m_dwPicWidth = (m_nClientWidth - FFT_LEFT_MARGIN * 2) / FFT_NUM_HORZ * FFT_NUM_HORZ;
	// 显示点数与视图大小一致
	//m_dwDot = (m_nClientWidth - FFT_LEFT_MARGIN * 2) / FFT_NUM_HORZ * FFT_NUM_HORZ;
	if ( cx > 0 && cy > 0 )
	{
		// 图像大小发生变化时,修改背景DC和图像DC的大小
		InvalidateCtrl();
		// 重画图像
		//DrawSpectrum();
		CSingleLock slDataBuf( &m_csFftDataBuf );
		slDataBuf.Lock();
		DrawCurve();
		slDataBuf.Unlock();
	}
	
}