You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
589 lines
13 KiB
589 lines
13 KiB
|
4 weeks ago
|
|
||
|
|
// 7350WavDlg.cpp : implementation file
|
||
|
|
//
|
||
|
|
|
||
|
|
#include "stdafx.h"
|
||
|
|
#include "7350Wav.h"
|
||
|
|
#include "7350WavDlg.h"
|
||
|
|
#include "math.h"
|
||
|
|
|
||
|
|
#ifndef M_PI
|
||
|
|
#define M_PI 3.14159265359
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#define MAX_SIZE 1024000 //in words
|
||
|
|
#define MBufCount 16 //Buffer count to be set
|
||
|
|
#define TrigCount 1 //Total Trigger Count
|
||
|
|
|
||
|
|
#ifdef _DEBUG
|
||
|
|
#define new DEBUG_NEW
|
||
|
|
#endif
|
||
|
|
|
||
|
|
CRect plotRect;
|
||
|
|
|
||
|
|
#define PCI7350_DIO_STATUS_TIMER 1
|
||
|
|
|
||
|
|
U16 gInBuf[MAX_SIZE], gOutBuf[MAX_SIZE];
|
||
|
|
U16 *gDOBufferAddr[MBufCount]; //Buffer array to be set
|
||
|
|
U16 gBufferID[MBufCount]; //Buffer ID returned
|
||
|
|
U32 gWriteCount = 10000; //Data count per one buffer to be written
|
||
|
|
|
||
|
|
|
||
|
|
// CAboutDlg dialog used for App About
|
||
|
|
|
||
|
|
class CAboutDlg : public CDialog
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CAboutDlg();
|
||
|
|
|
||
|
|
// Dialog Data
|
||
|
|
enum { IDD = IDD_ABOUTBOX };
|
||
|
|
|
||
|
|
protected:
|
||
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||
|
|
|
||
|
|
// Implementation
|
||
|
|
protected:
|
||
|
|
DECLARE_MESSAGE_MAP()
|
||
|
|
};
|
||
|
|
|
||
|
|
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||
|
|
{
|
||
|
|
CDialog::DoDataExchange(pDX);
|
||
|
|
}
|
||
|
|
|
||
|
|
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||
|
|
END_MESSAGE_MAP()
|
||
|
|
|
||
|
|
|
||
|
|
// C7350WavDlg dialog
|
||
|
|
|
||
|
|
|
||
|
|
C7350WavDlg::C7350WavDlg(I16 hCard, CWnd* pParent /*=NULL*/)
|
||
|
|
: CDialog(C7350WavDlg::IDD, pParent)
|
||
|
|
{
|
||
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||
|
|
|
||
|
|
m_hCard = hCard;
|
||
|
|
|
||
|
|
OnBrush = OffBrush = NULL;
|
||
|
|
|
||
|
|
n_PlotWidth = -1;
|
||
|
|
n_PlotHeight = -1;
|
||
|
|
|
||
|
|
min_val = 0x00;
|
||
|
|
max_val = 0xFFFF;
|
||
|
|
|
||
|
|
m_dwDISamples = 128000;
|
||
|
|
|
||
|
|
m_nTimer = -1;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void C7350WavDlg::DoDataExchange(CDataExchange* pDX)
|
||
|
|
{
|
||
|
|
CDialog::DoDataExchange(pDX);
|
||
|
|
}
|
||
|
|
|
||
|
|
BEGIN_MESSAGE_MAP(C7350WavDlg, CDialog)
|
||
|
|
ON_WM_SYSCOMMAND()
|
||
|
|
ON_WM_PAINT()
|
||
|
|
ON_WM_QUERYDRAGICON()
|
||
|
|
//}}AFX_MSG_MAP
|
||
|
|
ON_WM_DESTROY()
|
||
|
|
ON_BN_CLICKED(IDC_BT_START, &C7350WavDlg::OnStart)
|
||
|
|
ON_BN_CLICKED(IDC_BT_STOP, &C7350WavDlg::OnStop)
|
||
|
|
ON_WM_TIMER()
|
||
|
|
// ON_WM_VSCROLL()
|
||
|
|
END_MESSAGE_MAP()
|
||
|
|
|
||
|
|
|
||
|
|
// C7350WavDlg message handlers
|
||
|
|
|
||
|
|
BOOL C7350WavDlg::OnInitDialog()
|
||
|
|
{
|
||
|
|
I16 err;
|
||
|
|
int i;
|
||
|
|
CString strTemp;
|
||
|
|
|
||
|
|
CDialog::OnInitDialog();
|
||
|
|
|
||
|
|
// Add "About..." menu item to system menu.
|
||
|
|
|
||
|
|
// IDM_ABOUTBOX must be in the system command range.
|
||
|
|
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
||
|
|
ASSERT(IDM_ABOUTBOX < 0xF000);
|
||
|
|
|
||
|
|
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
||
|
|
if (pSysMenu != NULL)
|
||
|
|
{
|
||
|
|
BOOL bNameValid;
|
||
|
|
CString strAboutMenu;
|
||
|
|
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
|
||
|
|
ASSERT(bNameValid);
|
||
|
|
if (!strAboutMenu.IsEmpty())
|
||
|
|
{
|
||
|
|
pSysMenu->AppendMenu(MF_SEPARATOR);
|
||
|
|
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Set the icon for this dialog. The framework does this automatically
|
||
|
|
// when the application's main window is not a dialog
|
||
|
|
SetIcon(m_hIcon, TRUE); // Set big icon
|
||
|
|
SetIcon(m_hIcon, FALSE); // Set small icon
|
||
|
|
|
||
|
|
strTemp.Format( TEXT("This sample performs continuous DI acquisition with %d external retrigger (AFI0)"), TrigCount );
|
||
|
|
SetDlgItemText( IDC_STATIC_01, strTemp );
|
||
|
|
|
||
|
|
if( gWriteCount * MBufCount > MAX_SIZE )
|
||
|
|
{
|
||
|
|
AfxMessageBox( TEXT(" WriteCount * MBufCOunt > MAX_SZIE ") );
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
for(i=0; i<MBufCount; i++)
|
||
|
|
{
|
||
|
|
gDOBufferAddr[i] = gOutBuf + (gWriteCount*i);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// TODO: Add extra initialization here
|
||
|
|
x_divider = 5; y_divider = 2;
|
||
|
|
|
||
|
|
OnBrush = CreateSolidBrush( RGB(255,0,0) );
|
||
|
|
OffBrush = CreateSolidBrush( RGB(125,0,0) );
|
||
|
|
|
||
|
|
RedPen.CreatePen( PS_SOLID, 1, RGB(255,0,0));
|
||
|
|
GreenPen.CreatePen( PS_SOLID, 1, RGB(0,255,0));
|
||
|
|
|
||
|
|
if( n_PlotWidth == -1 && n_PlotHeight == -1 )
|
||
|
|
{
|
||
|
|
((CWnd*)GetDlgItem(IDC_STATIC_DRAW))->GetWindowRect(&plotRect);
|
||
|
|
ScreenToClient(&plotRect);
|
||
|
|
|
||
|
|
n_PlotWidth = min( plotRect.Width(), 512);
|
||
|
|
n_PlotHeight = plotRect.Height() - 10;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// Set the default DI Sample
|
||
|
|
SetDlgItemInt( IDC_EDIT_SAMPLE, (UINT)(m_dwDISamples) );
|
||
|
|
|
||
|
|
err = DIO_VoltLevelConfig(m_hCard, P7350_PortDIO, VoltLevel_3R3);
|
||
|
|
if( err!=NoError )
|
||
|
|
{
|
||
|
|
strTemp.Format( TEXT("DIO_VoltLevelConfig Error = %d"), err);
|
||
|
|
AfxMessageBox( strTemp );
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* Set Input or Output for DIO Port
|
||
|
|
*/
|
||
|
|
err = DIO_PortConfig(m_hCard, P7350_DIO_A, INPUT_PORT);
|
||
|
|
if( err!=NoError )
|
||
|
|
{
|
||
|
|
strTemp.Format( TEXT("DIO_PortConfig(P7350_DIO_A) Error = %d"), err);
|
||
|
|
AfxMessageBox( strTemp );
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
|
||
|
|
err = DIO_PortConfig(m_hCard, P7350_DIO_B, OUTPUT_PORT);
|
||
|
|
if( err!=NoError )
|
||
|
|
{
|
||
|
|
strTemp.Format( TEXT("DIO_PortConfig(P7350_DIO_B) Error = %d"), err);
|
||
|
|
AfxMessageBox( strTemp );
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
err = DIO_PortConfig(m_hCard, P7350_DIO_C, INPUT_PORT);
|
||
|
|
if( err!=NoError )
|
||
|
|
{
|
||
|
|
strTemp.Format( TEXT("DIO_PortConfig(P7350_DIO_C) Error = %d"), err);
|
||
|
|
AfxMessageBox( strTemp );
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
err = DIO_PortConfig(m_hCard, P7350_DIO_D, OUTPUT_PORT);
|
||
|
|
if( err!=NoError )
|
||
|
|
{
|
||
|
|
strTemp.Format( TEXT("DIO_PortConfig(P7350_DIO_D) Error = %d"), err);
|
||
|
|
AfxMessageBox( strTemp );
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/*
|
||
|
|
* Set DI Configurations
|
||
|
|
*/
|
||
|
|
err = DI_7350_Config(m_hCard, 16, P7350_FreeRun, P7350_WAIT_EXTTRG, P7350_IntSampledCLK);
|
||
|
|
if( err!=NoError )
|
||
|
|
{
|
||
|
|
strTemp.Format( TEXT("DI_7350_Config() Error = %d"), err);
|
||
|
|
AfxMessageBox( strTemp );
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* Set DO Configurations
|
||
|
|
*/
|
||
|
|
err = DO_7350_Config(m_hCard, 16, P7350_FreeRun, P7350_WAIT_NO, P7350_IntSampledCLK);
|
||
|
|
if( err!=NoError )
|
||
|
|
{
|
||
|
|
strTemp.Format( TEXT("DO_7350_Config() Error = %d"), err);
|
||
|
|
AfxMessageBox( strTemp );
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* Set DI Trigger and HandShake Configurations
|
||
|
|
*/
|
||
|
|
err = DI_7350_TrigHSConfig( m_hCard,
|
||
|
|
0/*TrigConfig*/,
|
||
|
|
0/*DI_IPOL*/,
|
||
|
|
0/*DI_REQSrc*/,
|
||
|
|
0/*DI_ACKSrc*/,
|
||
|
|
0/*DI_TRIGSrc*/,
|
||
|
|
P7350_AFI_0/*StartTrigSrc*/,
|
||
|
|
0/*PauseTrigSrc*/,
|
||
|
|
0/*SoftTrigOutSrc*/,
|
||
|
|
0/*SoftTrigOutLength*/,
|
||
|
|
1
|
||
|
|
);
|
||
|
|
|
||
|
|
for (i=0; i<MAX_SIZE; i++)
|
||
|
|
gOutBuf[i] = (U16)(sin((double)i/5000*M_PI)*0x7fff)+0x8000;
|
||
|
|
for (i=0; i<MAX_SIZE; i++)
|
||
|
|
gInBuf[i] = (U16)(i%65536);
|
||
|
|
|
||
|
|
/*
|
||
|
|
* Setup the allocated buffers -
|
||
|
|
* Driver will build the memory descriptor for the specifed buffer
|
||
|
|
* to do DMA operation.
|
||
|
|
*/
|
||
|
|
|
||
|
|
for(i=0; i<MBufCount; i++)
|
||
|
|
{
|
||
|
|
err = DO_ContMultiBufferSetup(m_hCard, gDOBufferAddr[i], gWriteCount, &gBufferID[i]);
|
||
|
|
if( err!=NoError )
|
||
|
|
{
|
||
|
|
strTemp.Format( TEXT("DO_7350_Config() Error = %d"), err);
|
||
|
|
AfxMessageBox( strTemp );
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
||
|
|
}
|
||
|
|
|
||
|
|
void C7350WavDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
||
|
|
{
|
||
|
|
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
||
|
|
{
|
||
|
|
CAboutDlg dlgAbout;
|
||
|
|
dlgAbout.DoModal();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
CDialog::OnSysCommand(nID, lParam);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// If you add a minimize button to your dialog, you will need the code below
|
||
|
|
// to draw the icon. For MFC applications using the document/view model,
|
||
|
|
// this is automatically done for you by the framework.
|
||
|
|
|
||
|
|
void C7350WavDlg::OnPaint()
|
||
|
|
{
|
||
|
|
if (IsIconic())
|
||
|
|
{
|
||
|
|
CPaintDC dc(this); // device context for painting
|
||
|
|
|
||
|
|
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
||
|
|
|
||
|
|
// Center icon in client rectangle
|
||
|
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
||
|
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
||
|
|
CRect rect;
|
||
|
|
GetClientRect(&rect);
|
||
|
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
||
|
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
||
|
|
|
||
|
|
// Draw the icon
|
||
|
|
dc.DrawIcon(x, y, m_hIcon);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
redraw_display_area();
|
||
|
|
CDialog::OnPaint();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// The system calls this function to obtain the cursor to display while the user drags
|
||
|
|
// the minimized window.
|
||
|
|
HCURSOR C7350WavDlg::OnQueryDragIcon()
|
||
|
|
{
|
||
|
|
return static_cast<HCURSOR>(m_hIcon);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void C7350WavDlg::OnDestroy()
|
||
|
|
{
|
||
|
|
U32 count;
|
||
|
|
|
||
|
|
CDialog::OnDestroy();
|
||
|
|
|
||
|
|
// TODO: Add your message handler code here
|
||
|
|
if( OnBrush != NULL )
|
||
|
|
::DeleteObject( OnBrush );
|
||
|
|
|
||
|
|
if( OffBrush != NULL )
|
||
|
|
::DeleteObject( OffBrush );
|
||
|
|
|
||
|
|
RedPen.DeleteObject();
|
||
|
|
GreenPen.DeleteObject();
|
||
|
|
|
||
|
|
if( m_nTimer != -1 )
|
||
|
|
{
|
||
|
|
KillTimer( m_nTimer );
|
||
|
|
m_nTimer = -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
DI_AsyncClear( m_hCard, &count );
|
||
|
|
}
|
||
|
|
|
||
|
|
void C7350WavDlg::OnStart()
|
||
|
|
{
|
||
|
|
// TODO: Add your control notification handler code here
|
||
|
|
U32 dwDISamples;
|
||
|
|
I16 err;
|
||
|
|
CString strMsg;
|
||
|
|
int i;
|
||
|
|
|
||
|
|
dwDISamples = GetDlgItemInt( IDC_EDIT_SAMPLE );
|
||
|
|
|
||
|
|
if( dwDISamples > MAX_SIZE)
|
||
|
|
{
|
||
|
|
m_dwDISamples = MAX_SIZE; //at most 1000K samples DMA
|
||
|
|
AfxMessageBox(TEXT("This sample supports at most 1000K words DMA transfer\nOnly perform 100K words DMA transfer."));
|
||
|
|
}
|
||
|
|
else if( (dwDISamples %4) != 0 )
|
||
|
|
{
|
||
|
|
AfxMessageBox(TEXT("Misalignment error, the input buffer must be 32-bit alignment "));
|
||
|
|
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
m_dwDISamples = dwDISamples;
|
||
|
|
}
|
||
|
|
|
||
|
|
err = DO_ContMultiBufferStart(m_hCard, 0, 1000000);
|
||
|
|
if(err!=NoError)
|
||
|
|
{
|
||
|
|
strMsg.Format(TEXT("DO_ContMultiBufferStart Error = %d"), err);
|
||
|
|
AfxMessageBox( strMsg );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
err = DI_ContReadPort (m_hCard, 0, gInBuf, m_dwDISamples, 1000000, ASYNCH_OP);
|
||
|
|
if (err < 0)
|
||
|
|
{
|
||
|
|
strMsg.Format(TEXT("DI_ContReadPort Error = %d"), err);
|
||
|
|
AfxMessageBox( strMsg );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// clear display area
|
||
|
|
redraw_display_area();
|
||
|
|
|
||
|
|
if( m_nTimer == -1 )
|
||
|
|
{
|
||
|
|
m_nTimer = SetTimer( PCI7350_DIO_STATUS_TIMER, 50, NULL );
|
||
|
|
}
|
||
|
|
|
||
|
|
GetDlgItem( IDC_BT_START )->EnableWindow( FALSE );
|
||
|
|
GetDlgItem( IDC_BT_STOP )->EnableWindow( TRUE );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void C7350WavDlg::OnStop()
|
||
|
|
{
|
||
|
|
// TODO: Add your control notification handler code here
|
||
|
|
U32 count;
|
||
|
|
|
||
|
|
if( m_nTimer != -1 )
|
||
|
|
{
|
||
|
|
KillTimer( m_nTimer );
|
||
|
|
m_nTimer = -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
DI_AsyncClear(m_hCard, &count);
|
||
|
|
DO_AsyncClear(m_hCard, &count);
|
||
|
|
|
||
|
|
|
||
|
|
GetDlgItem( IDC_BT_START )->EnableWindow( TRUE );
|
||
|
|
GetDlgItem( IDC_BT_STOP )->EnableWindow( FALSE);
|
||
|
|
}
|
||
|
|
|
||
|
|
void C7350WavDlg::OnTimer(UINT_PTR nIDEvent)
|
||
|
|
{
|
||
|
|
// TODO: Add your message handler code here and/or call default
|
||
|
|
BOOLEAN bDIStopped;
|
||
|
|
U32 count;
|
||
|
|
I16 err;
|
||
|
|
|
||
|
|
err = DI_AsyncCheck( m_hCard, &bDIStopped, &count );
|
||
|
|
if( bDIStopped )
|
||
|
|
{
|
||
|
|
// stop timer
|
||
|
|
KillTimer( m_nTimer );
|
||
|
|
m_nTimer = -1;
|
||
|
|
|
||
|
|
// reset the Button status
|
||
|
|
GetDlgItem( IDC_BT_START )->EnableWindow( TRUE );
|
||
|
|
GetDlgItem( IDC_BT_STOP )->EnableWindow( FALSE );
|
||
|
|
|
||
|
|
err = DI_AsyncClear( m_hCard, &count );
|
||
|
|
err = DO_AsyncClear( m_hCard, &count );
|
||
|
|
|
||
|
|
display_buffer_data(gInBuf);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
CDialog::OnTimer(nIDEvent);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void C7350WavDlg::display_buffer_data(U16* pBuf)
|
||
|
|
{
|
||
|
|
CClientDC dc_plot(this);
|
||
|
|
int nDraw_Bottom;
|
||
|
|
|
||
|
|
int newY, oldY = -1;
|
||
|
|
int newX, oldX = -1;
|
||
|
|
U32 index, di_data;
|
||
|
|
|
||
|
|
nDraw_Bottom = ( plotRect.bottom - 5 );
|
||
|
|
dc_plot.SelectObject( &GreenPen );
|
||
|
|
|
||
|
|
for( index=0; index<m_dwDISamples; index++ )
|
||
|
|
{
|
||
|
|
di_data = pBuf[index];
|
||
|
|
|
||
|
|
newY = (int)( nDraw_Bottom - (n_PlotHeight * ((double)di_data/0x0000ffff) ) );
|
||
|
|
newX = (int)( index*n_PlotWidth/m_dwDISamples + plotRect.left );
|
||
|
|
|
||
|
|
if ( index == 0 )
|
||
|
|
{
|
||
|
|
dc_plot.MoveTo( newX, newY );
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
dc_plot.MoveTo( oldX, oldY );
|
||
|
|
}
|
||
|
|
|
||
|
|
dc_plot.LineTo( newX, newY );
|
||
|
|
oldX = newX; oldY = newY;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void C7350WavDlg::redraw_display_area(void)
|
||
|
|
{
|
||
|
|
CPen *oldPen;
|
||
|
|
|
||
|
|
int oldMode;
|
||
|
|
COLORREF oldColor;
|
||
|
|
|
||
|
|
CString y_lable;
|
||
|
|
|
||
|
|
CPen minor_tick( PS_SOLID,1,RGB(132,130,132) );
|
||
|
|
// CPen y_grid( PS_SOLID,1,RGB(206,203,132) );
|
||
|
|
|
||
|
|
int i, x_intv, y_intv;
|
||
|
|
// long total_sec;
|
||
|
|
|
||
|
|
CClientDC dc_plot(this);
|
||
|
|
|
||
|
|
// draw the base-line for x-y axises
|
||
|
|
oldPen = (CPen *)dc_plot.SelectStockObject(BLACK_PEN);
|
||
|
|
|
||
|
|
// redraw the background
|
||
|
|
dc_plot.FillSolidRect( plotRect, RGB(0,0,0) );
|
||
|
|
|
||
|
|
// Re-Draw the AREA for Y-Lable
|
||
|
|
{
|
||
|
|
CBrush DIALOG_BRUSH;
|
||
|
|
CRect redraw_area, full_client;
|
||
|
|
|
||
|
|
GetClientRect(&full_client);
|
||
|
|
ScreenToClient(&full_client);
|
||
|
|
|
||
|
|
redraw_area.left = full_client.left;
|
||
|
|
redraw_area.top = plotRect.top - 5;
|
||
|
|
redraw_area.right = plotRect.left - 3;
|
||
|
|
redraw_area.bottom = plotRect.bottom + 10;
|
||
|
|
|
||
|
|
DIALOG_BRUSH.CreateSysColorBrush( COLOR_3DFACE );
|
||
|
|
|
||
|
|
dc_plot.FillRect( redraw_area, &DIALOG_BRUSH );
|
||
|
|
|
||
|
|
DIALOG_BRUSH.DeleteObject();
|
||
|
|
}
|
||
|
|
|
||
|
|
dc_plot.MoveTo( plotRect.left - 3, plotRect.top );
|
||
|
|
dc_plot.LineTo( plotRect.left - 3, plotRect.bottom );
|
||
|
|
|
||
|
|
// calculate the interval for tick/grid
|
||
|
|
y_intv = (plotRect.Height() - 10) /y_divider;
|
||
|
|
x_intv = plotRect.Width()/x_divider;
|
||
|
|
|
||
|
|
|
||
|
|
// set the color for tick
|
||
|
|
oldColor = dc_plot.SetTextColor( RGB(0,0,0) );
|
||
|
|
oldMode = dc_plot.SetBkMode( TRANSPARENT );
|
||
|
|
|
||
|
|
for( i=0; i<= y_divider; i++ )
|
||
|
|
{
|
||
|
|
CString tick_str;
|
||
|
|
CRect tmp_rect, tick_rect;
|
||
|
|
|
||
|
|
// draw the tick for y-axis
|
||
|
|
dc_plot.MoveTo( plotRect.left -12, plotRect.bottom -5 - (i*y_intv) );
|
||
|
|
dc_plot.LineTo( plotRect.left -3, plotRect.bottom -5 - (i*y_intv) );
|
||
|
|
|
||
|
|
tick_str.Format( _T("0x%04X"), ( ((max_val-min_val)/y_divider) * i)+min_val );
|
||
|
|
|
||
|
|
// calculate the rectangle for text
|
||
|
|
dc_plot.DrawText( tick_str, &tmp_rect, DT_CALCRECT|DT_SINGLELINE );
|
||
|
|
tick_rect.right = plotRect.left -14;
|
||
|
|
tick_rect.left = tick_rect.right - tmp_rect.Width();
|
||
|
|
tick_rect.top = plotRect.bottom -5 - (i*y_intv) - tmp_rect.Height()/2;
|
||
|
|
tick_rect.bottom = tick_rect.top + tmp_rect.Height();
|
||
|
|
|
||
|
|
// draw the text
|
||
|
|
dc_plot.DrawText( tick_str, &tick_rect, DT_SINGLELINE|DT_RIGHT );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
// draw the minor_tick for Y axises
|
||
|
|
dc_plot.SelectObject(&minor_tick);
|
||
|
|
for( i=0; i< y_divider; i++ )
|
||
|
|
{
|
||
|
|
dc_plot.MoveTo( plotRect.left -9, plotRect.bottom -5 - (i*y_intv) - y_intv/2 );
|
||
|
|
dc_plot.LineTo( plotRect.left -4, plotRect.bottom -5 - (i*y_intv) - y_intv/2 );
|
||
|
|
}
|
||
|
|
|
||
|
|
dc_plot.SetTextColor( oldColor );
|
||
|
|
dc_plot.SetBkMode( oldMode );
|
||
|
|
dc_plot.SelectObject( oldPen );
|
||
|
|
}
|
||
|
|
|
||
|
|
|