//---------------------------------------------------------------------------- // Laser Guard Ltd. // Copyright © 2000-2002. All Rights Reserved. // Version 1.0 01/01/2000 // Last modification: 08/10/2003 // PROJECT: // SUBSYSTEM: // FILE: LgUISiteSensor.cpp // AUTHOR: Sergey Chizhevskiy // OVERVIEW // ~~~~~~~~ // Source file of LgUISiteSensor.cpp //---------------------------------------------------------------------------- #include "stdafx.h" #include "LgUISiteSensor.h" #include "LgUISiteCamera.h" #include "LgUISiteSensorWnd.h" #include "LgUISiteTroubleWnd.h" #include "LgUISiteEngine.h" #include "..\UICamera\LgUICameraVideoWnd.h" CLgUISiteSensor::CLgUISiteSensor( HAL_OBJECT_ID nID ) : CLgHALSensor( nID ) { m_Position.x = (rand() % 100) / 100.0; m_Position.y = (rand() % 100) / 100.0; } CLgUISiteSensor::~CLgUISiteSensor() { CLgLink::Unlink(); } void CLgUISiteSensor::OnUIMapDraw( CLgUIMapObjectWnd *pMap, CDC *pDC, BOOL bActive, BOOL bOddUpdate ) { CLgDPoint dp( m_Position.x, m_Position.y ); CRect r; pMap->GetClientRect( &r ); // draw sensor representation CPoint p = pMap->AreaToWindow( &dp ); CRect rect; if( bActive && !bOddUpdate ) rect.SetRect( p.x - 2, p.y - 2, p.x + 2, p.y + 2 ); else rect.SetRect( p.x - 1, p.y - 1, p.x + 1, p.y + 1 ); pDC->FillSolidRect( &rect, RGB(0,0,255) ); } void CLgUISiteSensor::OnUIMapDrawBackground( CLgUIMapObjectWnd *pMap, CDC *pDC ) { } BOOL CLgUISiteSensor::OnUIMapHitTest( CLgUIMapObjectWnd *pMap, CLgDRect *pRect ) { if( !pRect->PtInRect( m_Position ) ) return FALSE; CLgUISiteEngine *pEngine = *this; if( !pEngine ) { // critical error! ASSERT( NULL ); return TRUE; } // try to activate sensor pEngine->OnActivateSensor( this ); return TRUE; }