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.
137 lines
4.0 KiB
137 lines
4.0 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: HiddenZoneList.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of HiddenZoneList.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "HiddenZoneList.h"
|
|
#include "HiddenZone.h"
|
|
#include "..\..\LgLib\LgAux.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
BOOL CHiddenZoneList::Draw( CDC *pDC, CPoint *pCenter, double dScaleToPixel, double dRotateAngle )
|
|
{
|
|
// log info
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CHiddenZoneList::Draw", "Start..." );
|
|
|
|
const COLORREF LgsColor[] = { 0x00000000, 0x00AF0000, 0x00FF0000,
|
|
0x00AF00AF, 0x00FF00FF, 0x0000AF00 };
|
|
|
|
double dz = 3.14 / 180.0 * dRotateAngle;
|
|
|
|
for( INT i = 0; i < GetCount(); i ++ )
|
|
{
|
|
CLgDeviceLGS::LGS_HZ_POLYGON &polygon = GetAt(i);
|
|
|
|
if( !polygon.GetCount() )
|
|
continue;
|
|
|
|
LPPOINT pZonePoint = new POINT[ polygon.GetCount() ];
|
|
if( !pZonePoint )
|
|
continue;
|
|
|
|
for( int j = 0; j < polygon.GetCount(); j ++ )
|
|
{
|
|
CLgDPoint &point = polygon[ j % polygon.GetCount() ];
|
|
|
|
// rotate hidden zone
|
|
double xp = cos( dz ) * point.x + sin( dz ) * point.y;
|
|
double yp = - sin( dz ) * point.x + cos( dz ) * point.y;
|
|
|
|
pZonePoint[j].x = (int)(pCenter->x + xp * dScaleToPixel + 0.5);
|
|
pZonePoint[j].y = (int)(pCenter->y + yp * dScaleToPixel + 0.5);
|
|
}
|
|
|
|
CPen pen( pOn[ polygon.bType ] ? PS_SOLID : PS_DOT, 1, LgsColor[ polygon.bType ] );
|
|
CPen *pPen = (CPen*)pDC->SelectObject( &pen );
|
|
INT nBkMode = pDC->SetBkMode( TRANSPARENT );
|
|
|
|
if( pOn[polygon.bType] )
|
|
{
|
|
CBrush brush( HS_DIAGCROSS, LgsColor[polygon.bType] );
|
|
CBrush *pBrush = (CBrush*)pDC->SelectObject( &brush );
|
|
pDC->Polygon( pZonePoint, polygon.GetCount() );
|
|
pDC->SelectObject( pBrush );
|
|
}
|
|
else
|
|
{
|
|
pDC->MoveTo( pZonePoint[polygon.GetCount()-1].x, pZonePoint[polygon.GetCount()-1].y );
|
|
pDC->PolylineTo( pZonePoint, polygon.GetCount() );
|
|
}
|
|
|
|
pDC->SetBkMode( nBkMode );
|
|
pDC->SelectObject( pPen );
|
|
|
|
delete [] pZonePoint;
|
|
}
|
|
|
|
// log info
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CHiddenZoneList::Draw", "Done" );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDoplerHiddenZoneList::Draw( CDC *pDC, CPoint *pCenter, double dScaleToPixel, double dRotateAngle )
|
|
{
|
|
// draw hidden zones
|
|
INT hx = dScaleToPixel;
|
|
INT hy = dScaleToPixel;
|
|
|
|
HDC hDC = pDC->GetSafeHdc();
|
|
|
|
const double pi = asin(1.0) * 2.0;
|
|
const double d2pi = pi / 180.0;
|
|
|
|
HBRUSH hNullBrush = (HBRUSH)::GetStockObject( NULL_BRUSH );
|
|
HBRUSH hNormalBrush = ::CreateHatchBrush(HS_DIAGCROSS, RGB(0x7F,0x7F,0x7F));
|
|
|
|
HPEN hPen = ::CreatePen(PS_DOT, 1, RGB(0x7F,0x7F,0x7F));
|
|
HPEN hOldPen = (HPEN)::SelectObject(hDC, hPen);
|
|
HBRUSH hBrush = bEnable ? hNormalBrush : hNullBrush;
|
|
HBRUSH hOldBrush = (HBRUSH)::SelectObject(hDC, hBrush);
|
|
INT nBkMode = ::SetBkMode( hDC, TRANSPARENT );
|
|
|
|
for( INT i = 0; i < nCount; i++ )
|
|
{
|
|
CLgDeviceDopler::PDOPLER_MASK pMask1 = pMask + i;
|
|
|
|
double dStartAngle = d2pi * (dRotateAngle + pMask1->nStartAngle);
|
|
double dStopAngle = d2pi * (dRotateAngle + pMask1->nStopAngle);
|
|
|
|
// rotate coordinates
|
|
POINT p[2] =
|
|
{
|
|
{ hx * cos( dStartAngle ) + pCenter->x,
|
|
-hy * sin( dStartAngle ) + pCenter->y },
|
|
{ hx * cos( dStopAngle ) + pCenter->x,
|
|
-hx * sin( dStopAngle ) + pCenter->y },
|
|
};
|
|
|
|
POINT sp = p[0];
|
|
POINT ep = p[1];
|
|
|
|
::Pie( hDC, pCenter->x - hx, pCenter->y - hy, pCenter->x + hx, pCenter->y + hy, sp.x, sp.y, ep.x, ep.y );
|
|
}
|
|
|
|
::SelectObject(hDC, hOldBrush);
|
|
::SetBkMode( hDC, nBkMode );
|
|
::DeleteObject(hNormalBrush);
|
|
::SelectObject(hDC, hOldPen);
|
|
::DeleteObject(hPen);
|
|
|
|
return TRUE;
|
|
}
|