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.
116 lines
3.2 KiB
116 lines
3.2 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: SurfaceCLD.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of SurfaceCLD.cpp
|
|
//----------------------------------------------------------------------------
|
|
// SurfaceCLD.cpp: implementation of the CSurfaceCLD class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
#include "SurfaceCLD.h"
|
|
#include "..\..\LgLib\LgAux.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
CSurfaceCLD::CSurfaceCLD()
|
|
{
|
|
m_dRange = 100.0;
|
|
m_dScale = 1.0;
|
|
m_dDR = asin( 1.0 ) / 90.0;
|
|
m_dCommonZero = 0;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSurfaceCLD::CSurfaceCLD") );
|
|
}
|
|
|
|
CSurfaceCLD::~CSurfaceCLD()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSurfaceCLD::~CSurfaceCLD") );
|
|
}
|
|
|
|
void CSurfaceCLD::DrawTarget( double range, COLORREF color )
|
|
{
|
|
int hx = GetSize().cx / 2;
|
|
int hy = GetSize().cy / 2;
|
|
|
|
int x = (INT)( cos( m_dCommonZero * m_dDR ) * range * 2 * hx / ( m_dScale * m_dRange ) ) + hx;
|
|
int y = (INT)( -sin( m_dCommonZero * m_dDR ) * range * 2 * hy / ( m_dScale * m_dRange ) ) + hy;
|
|
|
|
int rx = (INT)( cos( m_dCommonZero * m_dDR ) * m_dRange * hx / ( m_dScale * m_dRange ) );
|
|
int ry = (INT)( -sin( m_dCommonZero * m_dDR ) * m_dRange * hy / ( m_dScale * m_dRange ) );
|
|
|
|
x -= rx;
|
|
y -= ry;
|
|
|
|
CPen pen( PS_SOLID, 1, color );
|
|
CBrush brush( color );
|
|
|
|
CPen *pPen = (CPen*)SelectObject( &pen );
|
|
CBrush *pBrush = (CBrush*)SelectObject( &brush );
|
|
|
|
CRect rect( x - 2, y - 2, x + 2, y + 2 );
|
|
Ellipse( &rect );
|
|
|
|
SelectObject( pPen );
|
|
SelectObject( pBrush );
|
|
}
|
|
|
|
void CSurfaceCLD::Create( int cx, int cy, COLORREF color )
|
|
{
|
|
COLORREF LsgColor[] = { RGB( 0, 0x6F, 0 ), RGB( 0, 0x5F, 0 ), RGB( 0x7F, 0x7F, 0 ), RGB( 0x7F, 0x7F, 0x7F ) };
|
|
|
|
CLgMemoryDC::Create( cx, cy, LsgColor[1] );
|
|
|
|
int hx = GetSize().cx / 2;
|
|
int hy = GetSize().cy / 2;
|
|
|
|
// fill all field
|
|
{
|
|
CRect rect( 0, 0, GetSize().cx, GetSize().cy );
|
|
CBrush brush( RGB( 0, 0x5F, 0 ) );
|
|
FillRect( &rect, &brush );
|
|
}
|
|
|
|
// draw guarded line
|
|
int x = (INT)( cos( m_dCommonZero * m_dDR ) * m_dRange * hx / ( m_dScale * m_dRange ) );
|
|
int y = (INT)( -sin( m_dCommonZero * m_dDR ) * m_dRange * hy / ( m_dScale * m_dRange ) );
|
|
|
|
CPen pen( PS_SOLID, 3, RGB( 0x7F, 0x7F, 0 ) );
|
|
CPen *pPen = (CPen*)SelectObject( &pen );
|
|
CBrush brush( RGB( 0x7F, 0x7F, 0 ) );
|
|
CBrush *pBrush = (CBrush*)SelectObject( &brush );
|
|
|
|
MoveTo( hx - x, hy - y );
|
|
LineTo( hx + x, hy + y );
|
|
|
|
CRect rect( hx - x - 5, hy - y - 5, hx - x + 5, hy - y + 5 );
|
|
Ellipse( &rect );
|
|
|
|
SelectObject( pBrush );
|
|
SelectObject( pPen );
|
|
}
|
|
|
|
void CSurfaceCLD::SetRange( double dRange )
|
|
{
|
|
m_dRange = dRange;
|
|
Create( GetSize().cx, GetSize().cy );
|
|
}
|
|
|
|
void CSurfaceCLD::SetCommonZero( double dCommonZero )
|
|
{
|
|
m_dCommonZero = dCommonZero;
|
|
Create( GetSize().cx, GetSize().cy );
|
|
}
|