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.
232 lines
6.2 KiB
232 lines
6.2 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 27/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LgSubSiteDlg.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of LgSubSiteDlg.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "lglibreport.h"
|
|
#include "LgSubSiteDlg.h"
|
|
#include "LgReportDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
CLgSubSiteDlg::CLgSubSiteDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CLgSubSiteDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CLgSubSiteDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
m_pReportDlg = NULL;
|
|
m_bPosition = FALSE;
|
|
m_bDirty = TRUE;
|
|
}
|
|
|
|
|
|
void CLgSubSiteDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CLgSubSiteDlg)
|
|
// NOTE: the ClassWizard will add DDX and DDV calls here
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CLgSubSiteDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CLgSubSiteDlg)
|
|
ON_WM_PAINT()
|
|
ON_WM_SIZE()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CLgSubSiteDlg message handlers
|
|
|
|
BOOL CLgSubSiteDlg::Create(CLgReportDlg *pReportDlg, CWnd *pParentWnd, CRect *pRect )
|
|
{
|
|
m_pReportDlg = pReportDlg;
|
|
|
|
if( !CDialog::Create( IDD, pParentWnd ) )
|
|
return FALSE;
|
|
|
|
ShowWindow( SW_SHOW );
|
|
|
|
CRect rect;
|
|
|
|
if( pRect )
|
|
rect = *pRect;
|
|
else
|
|
pParentWnd->GetClientRect( &rect );
|
|
|
|
MoveWindow( &rect );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CLgSubSiteDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this);
|
|
|
|
dc.BitBlt( 0, 0, m_MemoryDC.GetSize().cx, m_MemoryDC.GetSize().cy, &m_MemoryDC, 0, 0, SRCCOPY );
|
|
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgSubSiteDlg::OnPaint"), _T("") );
|
|
}
|
|
|
|
void CLgSubSiteDlg::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CDialog::OnSize(nType, cx, cy);
|
|
|
|
m_MemoryDC.Create( cx, cy );
|
|
m_MemoryOriginalDC.Create( cx, cy );
|
|
m_Rect.SetRect( 0, 0, cx, cy );
|
|
m_bPosition = FALSE;
|
|
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgSubSiteDlg::OnSize"), _T("") );
|
|
}
|
|
|
|
BOOL CLgSubSiteDlg::Draw( CLgImageJPEG *pJpeg )
|
|
{
|
|
if( !pJpeg && !m_bDirty )
|
|
return TRUE;
|
|
|
|
CSize size = m_MemoryDC.GetSize();
|
|
|
|
m_MemoryOriginalDC.Create( size.cx, size.cy );
|
|
m_Rect.SetRect( 0, 0, size.cx, size.cy );
|
|
|
|
if( pJpeg )
|
|
{
|
|
CLgImageDIB dib;
|
|
if( dib.Create( pJpeg ) )
|
|
{
|
|
CSize bgSize( static_cast<LPBITMAPINFOHEADER>(dib)->biWidth,
|
|
static_cast<LPBITMAPINFOHEADER>(dib)->biHeight );
|
|
|
|
double dAspectSrc = (double)bgSize.cx / (double)bgSize.cy;
|
|
double dAspectDst = (double)size.cx / (double)size.cy;
|
|
|
|
if( dAspectSrc < dAspectDst ) m_Rect.SetRect( 0, 0, (INT)( size.cy * dAspectSrc ), size.cy );
|
|
else m_Rect.SetRect( 0, 0, size.cx, (INT)( size.cx / dAspectSrc ) );
|
|
|
|
INT nDeltaX = size.cx - m_Rect.Width();
|
|
INT nDeltaY = size.cy - m_Rect.Height();
|
|
|
|
m_Rect.OffsetRect( nDeltaX / 2, nDeltaY / 2 );
|
|
|
|
dib.Draw( m_MemoryOriginalDC.GetSafeHdc(), &m_Rect );
|
|
|
|
m_bDirty = TRUE;
|
|
}
|
|
}
|
|
|
|
m_MemoryDC.BitBlt( 0, 0, size.cx, size.cy, &m_MemoryOriginalDC, 0, 0, SRCCOPY );
|
|
|
|
m_Position.x = m_Position.y = 0;
|
|
|
|
CClientDC dc( this );
|
|
dc.BitBlt( 0, 0, m_MemoryDC.GetSize().cx, m_MemoryDC.GetSize().cy, &m_MemoryDC, 0, 0, SRCCOPY );
|
|
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgSubSiteDlg::Draw"), _T("") );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
#define TARGET_SIZE 4
|
|
|
|
BOOL CLgSubSiteDlg::DrawPosition( REPORT_EVENT_BASE *pEvent )
|
|
{
|
|
CClientDC dc( this );
|
|
|
|
// restore background after cross
|
|
if( m_bPosition )
|
|
{
|
|
dc.BitBlt( m_Position.x - TARGET_SIZE - 1, m_Position.y - TARGET_SIZE - 1, TARGET_SIZE * 2 + 2, TARGET_SIZE * 2 + 2,
|
|
&m_MemoryDC, m_Position.x - TARGET_SIZE - 1, m_Position.y - TARGET_SIZE - 1, SRCCOPY );
|
|
m_bPosition = FALSE;
|
|
}
|
|
|
|
if( !pEvent || !pEvent->bPositionValid )
|
|
return TRUE;
|
|
|
|
m_bPosition = TRUE;
|
|
m_Position.x = (INT)( pEvent->fPositionX * m_Rect.Width() ) + m_Rect.left;
|
|
m_Position.y = (INT)( pEvent->fPositionY * m_Rect.Height() ) + m_Rect.top;
|
|
|
|
DrawCross();
|
|
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgSubSiteDlg::DrawPosition"), _T("") );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CLgSubSiteDlg::DrawTarget( REPORT_EVENT_BASE *pEvent )
|
|
{
|
|
if( !pEvent || !pEvent->bPositionValid )
|
|
return TRUE;
|
|
|
|
INT x = (INT)( pEvent->fPositionX * m_Rect.Width() ) + m_Rect.left;
|
|
INT y = (INT)( pEvent->fPositionY * m_Rect.Height() ) + m_Rect.top;
|
|
|
|
CPen pen( PS_SOLID, 2, RGB( 0xFF,0x3F,0x3F ) );
|
|
|
|
CPen *pPen = m_MemoryDC.SelectObject( &pen );
|
|
m_MemoryDC.Rectangle( x - 1, y - 1, x + 1, y + 1 );
|
|
m_MemoryDC.SelectObject( pPen );
|
|
|
|
CClientDC dc( this );
|
|
dc.BitBlt( x - 1, y - 1, 2 + 1, 2 + 1, &m_MemoryDC, x - 1, y - 1, SRCCOPY );
|
|
|
|
DrawCross();
|
|
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgSubSiteDlg::DrawTarget"), _T("") );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CLgSubSiteDlg::ClearTarget()
|
|
{
|
|
CClientDC dc( this );
|
|
|
|
if( !m_MemoryDC.BitBlt( 0, 0, m_MemoryOriginalDC.GetSize().cx, m_MemoryOriginalDC.GetSize().cy, &m_MemoryOriginalDC, 0, 0, SRCCOPY ) )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgSubSiteDlg::ClearTarget"), _T("Restore orinal failed") );
|
|
|
|
if( !dc.BitBlt( 0, 0, m_MemoryOriginalDC.GetSize().cx, m_MemoryOriginalDC.GetSize().cy, &m_MemoryOriginalDC, 0, 0, SRCCOPY ) )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgSubSiteDlg::ClearTarget"), _T("Paint orinal failed") );
|
|
|
|
m_bPosition = FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CLgSubSiteDlg::DrawCross()
|
|
{
|
|
if( !m_bPosition )
|
|
return FALSE;
|
|
|
|
CClientDC dc( this );
|
|
|
|
CPen pen( PS_SOLID, 2, RGB( 0xFF,0xFF,0xFF ) );
|
|
|
|
CPen *pPen = dc.SelectObject( &pen );
|
|
|
|
dc.MoveTo( m_Position.x - TARGET_SIZE, m_Position.y - TARGET_SIZE );
|
|
dc.LineTo( m_Position.x + TARGET_SIZE, m_Position.y + TARGET_SIZE );
|
|
|
|
dc.MoveTo( m_Position.x + TARGET_SIZE, m_Position.y - TARGET_SIZE );
|
|
dc.LineTo( m_Position.x - TARGET_SIZE, m_Position.y + TARGET_SIZE );
|
|
|
|
dc.SelectObject( pPen );
|
|
|
|
return TRUE;
|
|
}
|