⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plotdata.cpp

📁 PSK31方式通信C++编写的原代码,可以通过声音传递数据.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
CDC MemDCB;
	k4 = m_rPlotsize.bottom;
//create memory DC pointers for the waterfall bitmap buffers
	MemDCA.CreateCompatibleDC( pDC );
	MemDCB.CreateCompatibleDC( pDC );
CBitmap* pbmOldA = MemDCA.SelectObject( &m_bmWaterA );
CBitmap* pbmOldB = MemDCB.SelectObject( &m_bmWaterB );
	if(m_NeedToClrBufs)
	{
		MemDCA.BitBlt( 0, 0, m_rPlotsize.right,k4, NULL, 0,0,BLACKNESS);
		MemDCB.BitBlt( 0, 0, m_rPlotsize.right,k4, NULL, 0,0,BLACKNESS);
		m_NeedToClrBufs = FALSE;
	}
	k3 = k4/3; //y starting point

	pDC->MoveTo( 0, k3-(k3*m_pDispBuf[m_XMinPos])/255);//move to first position
	for( x=m_XMinPos; x<m_XMaxPos; x++ )
	{
		y = k3-(k3*m_pDispBuf[x])/255;
		pDC->LineTo( m_TranslateTbl[x], y );		//draw to the next pt.
	}
	m_InputOverload = fnGetFFTData( (long*)m_pDispBuf,	m_XMinPos, m_XMaxPos );
	k2 = (m_XMaxPos-m_XMinPos+1);

	if(m_BufToggle) //use A buffer
	{
		// Copy lines from buf B to A shifted down 1 lines
		MemDCA.BitBlt( 0, 1, m_rPlotsize.right,k4-k3-1, &MemDCB, 0,0,SRCCOPY);
		// Draw top two new lines int to buf A
		for( x=0; x<m_rPlotsize.right; x++)
		{
			k1 = (x*k2)/m_rPlotsize.right + m_XMinPos;
			i = m_pDispBuf[k1];
			cr = m_pDoc->m_ColorTbl[i];		//RGB( i, i, i);
			MemDCA.SetPixel( x , 0, cr );
		}
		// copy buf A into main plot bitmap
		pDC->BitBlt( 0, k3,	m_rPlotsize.right,k4-k3, &MemDCA, 0,0,SRCCOPY);
	}
	else			// use B buffer
	{
		// Copy lines from buf A to B shifted down 1 lines
		MemDCB.BitBlt( 0, 1, m_rPlotsize.right,k4-k3-1, &MemDCA, 0,0,SRCCOPY);
		// Draw top two new lines int to buf B
		for( x=1; x<m_rPlotsize.right; x++)
		{
			k1 = (x*k2)/m_rPlotsize.right + m_XMinPos;
			i = m_pDispBuf[k1];
			cr = m_pDoc->m_ColorTbl[i];		//RGB( i, i, i);
			MemDCB.SetPixel( x , 0, cr );
		}
		// copy buf B into main plot bitmap
		pDC->BitBlt( 0, k3,	m_rPlotsize.right,k4-k3, &MemDCB, 0,0,SRCCOPY);
	}
	MemDCA.SelectObject( pbmOldA );
	MemDCB.SelectObject( pbmOldB );
	m_BufToggle = !m_BufToggle;
}

//////////////////////////////////////////////////////////////////////
// Plot Baseband Data as vector plot on top of spectrum graph
//////////////////////////////////////////////////////////////////////
void CPlotData::PlotOverlayVectData( CDC* pDC )
{
INT x,xc,yc;
long VectArray[16];
CBrush* pOldBrush;
CBrush Brush;
	Brush.CreateSolidBrush( RGB(0,0,0) );
	yc = m_rPlotsize.bottom/8;	// y center
	xc = yc;
	pOldBrush = pDC->SelectObject(&Brush);
	pDC->Ellipse( 0, 0, xc+xc, m_rPlotsize.bottom/4);	//draw circle
	pDC->SelectObject( pOldBrush );
	fnGetVectorData(VectArray,0);
	pDC->SelectObject(m_pPenC);
	for(x=0; x<16; x+=2)
	{
		pDC->MoveTo( xc,  yc );
		pDC->LineTo( xc+(yc*VectArray[x]/1000), 
							yc-((yc)*VectArray[x+1]/1000) );
	}
}
//////////////////////////////////////////////////////////////////////
// Plot Baseband Data as vector plot on top of waterfall graph
//////////////////////////////////////////////////////////////////////
void CPlotData::PlotOverlayVectDataWaterfall( CDC* pDC )
{
INT x,xc,yc;
long VectArray[16];
CBrush* pOldBrush;
CBrush Brush;
	Brush.CreateSolidBrush( RGB(0,0,0) );
	yc = m_rPlotsize.bottom - m_rPlotsize.bottom/8;	// y center
	xc = m_rPlotsize.bottom/8;
	pOldBrush = pDC->SelectObject(&Brush);
	pDC->Ellipse( 0, (3*m_rPlotsize.bottom)/4, 2*xc, m_rPlotsize.bottom);//draw circle
	pDC->SelectObject( pOldBrush );
	fnGetVectorData(VectArray,0);
	pDC->SelectObject(m_pPenC);
	for(x=0; x<16; x+=2)
	{
		pDC->MoveTo( xc,  yc );
		pDC->LineTo( xc+(xc*VectArray[x]/1000), 
							yc-(xc*VectArray[x+1]/1000) );
	}
}
//////////////////////////////////////////////////////////////////////
// Plot Sync position distribution
//////////////////////////////////////////////////////////////////////
void CPlotData::PlotSyncData( CDC* pDC )
{
INT x,y,i,k1,k2;
INT ys;
	fnGetSyncData( m_SyncData,0);
	y = m_rPlotsize.bottom;
	k1 = y;
	k2 = m_rPlotsize.right/16;
	pDC->SelectObject(m_pPenG);
	for( x=k2/2,i=0; i<16; i++,x+=k2)
	{
		ys = m_SyncData[i]*k1/1000;
		pDC->MoveTo( x, y );
		pDC->LineTo( x, y-ys );
	}
}

//////////////////////////////////////////////////////////////////////
// Plots the input data directly in the time domain
//////////////////////////////////////////////////////////////////////
void CPlotData::PlotInputData( CDC* pDC)
{
INT x,y,k1;
BOOL overload = FALSE;
	k1 = m_rPlotsize.bottom/2;		//center
	pDC->MoveTo( 0, k1);			//move to first position
	overload = fnGetRawData( (long*)m_pDispBuf, 0, m_rPlotsize.right );
	if(overload)
		pDC->SelectObject(m_pPenR);
	for( x=0; x<m_rPlotsize.right; x++ )
	{
		y = k1 + (k1*m_pDispBuf[x])/32767;
		pDC->LineTo( x, y );	//draw to the next pt.
	}
}


//////////////////////////////////////////////////////////////////////
// Sets the plot zoom factor and calculates all the new parameters.
//////////////////////////////////////////////////////////////////////
void CPlotData::SetZoom( INT zoom, BOOL Cent, INT fmin, INT fmax)
{
INT xdelta;
CString Msg;
INT maxbuf;
INT minbuf;
	minbuf = (2048*fmin)/8000;
	maxbuf = (2048*fmax)/8000;
	m_Zoom = zoom;
	xdelta = (maxbuf-minbuf-1)/zoom;
	if( !Cent )
	{
		if( (m_XCurPos <= m_XMinPos) || (m_XCurPos >= m_XMaxPos) )
			Cent = TRUE;
	}
	if( Cent )
	{
		// Try to center the cursor
		m_XMinPos = m_XCurPos - xdelta/2;
		m_XMaxPos = m_XCurPos + xdelta/2;
		if( m_XMinPos<minbuf )
		{
			m_XMinPos = minbuf;
			m_XMaxPos = xdelta + minbuf;
		}
		else
		{
			if( m_XMaxPos > maxbuf )
			{
				m_XMinPos = maxbuf-xdelta;
				if( m_XMinPos<minbuf )
					m_XMinPos = minbuf;
				m_XMaxPos = maxbuf;
			}
		}
	}
	if(m_XMaxPos == m_XMinPos)
		return;
	m_CursPos = 100*m_rPlotsize.right*( m_XCurPos - m_XMinPos)
					/(m_XMaxPos - m_XMinPos); 
	if( (m_CursPos%100) > 50 )		//round to nearest integer
		m_CursPos = m_CursPos/100 + 1;
	else
		m_CursPos = m_CursPos/100;

// The translate table is used to map DispBuf[] index's into
//		Screen plot coordinates.
	for(INT i=m_XMinPos; i<m_XMaxPos; i++)
	{
		m_TranslateTbl[i] = ( (i-m_XMinPos)*m_rPlotsize.right )
									/ (m_XMaxPos - m_XMinPos);
	}
}

//////////////////////////////////////////////////////////////////////
// Called when a user clicks on the plot window to place the plot cursor.
// Sets the plot cursor to the specified screen position.  The DispBuf[]
//   index is then calculated.  The cursor on the screen is then updated.
//////////////////////////////////////////////////////////////////////
void CPlotData::SetPlotCursorPos( INT pos )
{
	m_CursPos = pos - m_rPlot.left;
	m_XCurPos = (m_CursPos*(m_XMaxPos - m_XMinPos)
					/m_rPlotsize.right) + m_XMinPos;
}

void CPlotData::SetRewindPos(INT y)
{
INT rewblocks = 0;
INT waterstart;
	if( m_pDoc->m_pSettings->m_TabSel == FFT_DISPVIEW)
	{
		rewblocks = 99;
	}
	else
	{
		if( m_pDoc->m_pSettings->m_TabSel == WATERFALL_DISPVIEW)
		{
			waterstart = m_rPlot.Height()/3 + m_rPlot.top;
			if(	y > waterstart )
				rewblocks = y - waterstart;
			else
				rewblocks = 0;
		}
	}
	if(rewblocks!=0)
		fnRewindInput(rewblocks);
}

//////////////////////////////////////////////////////////////////////
// Called to clear the display buffers
//////////////////////////////////////////////////////////////////////
void CPlotData::ClearBuffers()
{
	for(INT i=0; i<DISPBUF_SIZE; i++)
		m_pDispBuf[i] = 0;
	m_NeedToClrBufs = TRUE;		// so waterfal buffers can get cleared
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -