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.
184 lines
4.9 KiB
184 lines
4.9 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: Visual.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of Visual.cpp
|
|
//----------------------------------------------------------------------------
|
|
// Visual.cpp: implementation of the CVisual class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
//#include "chicago.h"
|
|
#include "Visual.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CVisual::CVisual()
|
|
{
|
|
m_strName = "noname";
|
|
m_nState = UNKNOWN;
|
|
m_nType = VISUAL;
|
|
m_pBitmap = NULL;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVisual::CVisual") );
|
|
}
|
|
|
|
CVisual::~CVisual()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVisual::~CVisual") );
|
|
}
|
|
|
|
COLORREF CVisual::GetStateColor( BOOL bInverse )
|
|
{
|
|
return GetStateColor( m_nState, bInverse );
|
|
}
|
|
|
|
void CVisual::GetStateString( CString& str )
|
|
{
|
|
str = GetName() + " " + GetStateString( m_nState );
|
|
}
|
|
|
|
COLORREF CVisual::GetStateColor( int nState, BOOL bInverse )
|
|
{
|
|
COLORREF color;
|
|
switch( nState )
|
|
{
|
|
case UNKNOWN: color = RGB( 0x00, 0x00, 0xFF ); break;
|
|
case NORMAL: color = (bInverse) ? RGB( 0x00, 0x7F, 0x00 ) : RGB( 0x00, 0xFF, 0x00 ); break;
|
|
case TIMEOUT: color = (bInverse) ? RGB( 0x7F, 0x7F, 0x00 ) : RGB( 0xFF, 0xFF, 0x00 ); break;
|
|
case ALARM: color = (bInverse) ? RGB( 0x7F, 0x00, 0x00 ) : RGB( 0xFF, 0x00, 0x00 ); break;
|
|
case POSTALARM: color = (bInverse) ? RGB( 0xFF, 0x00, 0x00 ) : RGB( 0x00, 0xFF, 0x00 ); break;
|
|
case DISABLE: color = (bInverse) ? RGB( 0x7F, 0x7F, 0x7F ) : RGB( 0xFF, 0xFF, 0xFF ); break;
|
|
}
|
|
return color;
|
|
}
|
|
|
|
LPCTSTR CVisual::GetStateString( int nState )
|
|
{
|
|
LPCTSTR pStr = NULL;
|
|
switch( nState )
|
|
{
|
|
case UNKNOWN: pStr = _T( "state unknown" ); break;
|
|
case NORMAL: pStr = _T( "normally work" ); break;
|
|
case TIMEOUT: pStr = _T( "not response" ); break;
|
|
case ALARM: pStr = _T( "send alarm" ); break;
|
|
case DISABLE: pStr = _T( "disabled" ); break;
|
|
case POSTALARM: pStr = _T( "alarm disapeared" ); break;
|
|
}
|
|
return pStr;
|
|
}
|
|
|
|
BOOL CVisual::GetBlinkState()
|
|
{
|
|
switch( m_nState )
|
|
{
|
|
case TIMEOUT:
|
|
case ALARM:
|
|
case POSTALARM:
|
|
case DISABLE:
|
|
return TRUE;
|
|
case UNKNOWN:
|
|
case NORMAL:
|
|
default:
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
BOOL CVisual::PaintBounds( CDC *pDC, CRect &viewRect, CSize &mapSize, SDPOINT &mapShift, double mapScale, BOOL bInverse, BOOL bBigSize, CRect *pUpdateRect )
|
|
{
|
|
SDPOINT shift( m_Position.x - mapShift.x, m_Position.y - mapShift.y );
|
|
|
|
CPoint p = CalcDrawPoint( viewRect, mapSize, shift, mapScale );
|
|
|
|
if( !viewRect.PtInRect(p) ) return FALSE;
|
|
|
|
COLORREF color = RGB( 0xFF, 0x00, 0xFF );
|
|
CRect rect;
|
|
CPen pen( PS_SOLID, 2, color );
|
|
// int nOldRop2 = pDC->SetROP2( R2_XORPEN );
|
|
CPen *pOldPen = pDC->SelectObject( &pen );
|
|
if( /*bBigSize*/1 )
|
|
{
|
|
int dx = 26;
|
|
int dy = 12;
|
|
pDC->MoveTo( p.x - dx, p.y - dy );
|
|
pDC->LineTo( p.x + dx, p.y - dy );
|
|
pDC->LineTo( p.x + dx, p.y + dy );
|
|
pDC->LineTo( p.x - dx, p.y + dy );
|
|
pDC->LineTo( p.x - dx, p.y - dy );
|
|
rect.SetRect( p.x - dx - 1, p.y - dy - 1, p.x + dx + 1, p.y + dy + 1 );
|
|
}
|
|
else
|
|
{
|
|
/* pDC->MoveTo( p.x - 2, p.y - 2 );
|
|
pDC->LineTo( p.x + 2, p.y - 2 );
|
|
pDC->LineTo( p.x + 2, p.y + 2 );
|
|
pDC->LineTo( p.x - 2, p.y + 2 );
|
|
pDC->LineTo( p.x - 2, p.y - 2 );
|
|
rect.SetRect( p.x - 2, p.y - 2, p.x + 2, p.y + 2 );
|
|
*/ }
|
|
pDC->SelectObject( pOldPen );
|
|
// pDC->SetROP2( nOldRop2 );
|
|
|
|
if( pUpdateRect ) *pUpdateRect = rect;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CVisual::Reset()
|
|
{
|
|
if( GetState() != DISABLE )
|
|
SetState( UNKNOWN );
|
|
}
|
|
|
|
void CVisual::OnUIMapDraw( CLgUIMapObjectWnd *pMap, CDC *pDC, BOOL bActive, BOOL bOddUpdate )
|
|
{
|
|
CLgDPoint dp( m_Position.x, m_Position.y );
|
|
CPoint p = pMap->AreaToWindow( &dp );
|
|
|
|
CRect rect;
|
|
if( bActive && !bOddUpdate )
|
|
rect.SetRect( p.x - 4, p.y - 4, p.x + 4, p.y + 4 );
|
|
else
|
|
rect.SetRect( p.x - 2, p.y - 2, p.x + 2, p.y + 2 );
|
|
|
|
pDC->FillSolidRect( &rect, GetStateColor( bOddUpdate ) );
|
|
}
|
|
|
|
BOOL CVisual::OnUIMapHitTest( CLgUIMapObjectWnd *pMap, CLgDRect *pRect )
|
|
{
|
|
CLgDPoint dp( m_Position.x, m_Position.y );
|
|
|
|
return pRect->PtInRect( dp );
|
|
}
|
|
|
|
void CVisual::OnUIMapDrawBackground( CLgUIMapObjectWnd *pMap, CDC *pDC )
|
|
{
|
|
CLgDPoint dp( m_Position.x, m_Position.y );
|
|
|
|
CPoint center = pMap->AreaToWindow( &dp );
|
|
|
|
OnDrawBackground( pDC, center, pMap->GetMeterToPixelScale() );
|
|
}
|
|
|
|
void CVisual::OnDrawBackground( CDC *pDC, CPoint center, double dMeterToPixelScale )
|
|
{
|
|
|
|
}
|