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.
156 lines
4.4 KiB
156 lines
4.4 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: CameraPositionWnd.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of CameraPositionWnd.cpp
|
|
//----------------------------------------------------------------------------
|
|
// CameraPositionWnd.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "multiipiclient.h"
|
|
#include "CameraPositionWnd.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CCameraPositionWnd
|
|
|
|
CCameraPositionWnd::CCameraPositionWnd()
|
|
{
|
|
m_PTZ.dPan = m_PTZ.dTilt = m_PTZ.dZoom = 0;
|
|
m_bSynchronized = FALSE;
|
|
}
|
|
|
|
CCameraPositionWnd::~CCameraPositionWnd()
|
|
{
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CCameraPositionWnd, CWnd)
|
|
//{{AFX_MSG_MAP(CCameraPositionWnd)
|
|
ON_WM_PAINT()
|
|
ON_WM_SIZE()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
BOOL CCameraPositionWnd::Create( CWnd* pParentWnd, CRect &rect )
|
|
{
|
|
CString strClassName = ::AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW, LoadCursor( NULL, IDC_ARROW ), NULL, NULL );
|
|
|
|
if( !CWnd::Create( strClassName, NULL, WS_CHILD | WS_VISIBLE, rect, pParentWnd, 0 ) )
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CCameraPositionWnd::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
OnDraw( &m_MemoryDC );
|
|
|
|
CRect rect;
|
|
GetClientRect( &rect );
|
|
|
|
dc.BitBlt( 0, 0, rect.Width(), rect.Height(), &m_MemoryDC, 0, 0, SRCCOPY );
|
|
}
|
|
|
|
void CCameraPositionWnd::OnDraw( CDC *pDC )
|
|
{
|
|
CRect rect;
|
|
GetClientRect( &rect );
|
|
|
|
rect.left -= rect.Width() * 2 / 5;
|
|
rect.top -= rect.Height() * 2 / 5;
|
|
|
|
// calculate positions
|
|
double d = 3.0 + (1.0 - m_PTZ.dZoom) * 21.0;
|
|
INT w = rect.Width() / 2;
|
|
INT h = rect.Height() / 2;
|
|
double r = h;// * ( 0.2 + m_PTZ.dZoom * 0.8 );
|
|
INT x1 = (INT)( ( cos( ( m_PTZ.dTilt + d ) / 360.0 * 6.2831 ) ) * r + w ) + rect.left;
|
|
INT y1 = (INT)( ( sin( ( m_PTZ.dTilt + d ) / 360.0 * 6.2831 ) ) * r + h ) + rect.top;
|
|
INT x2 = (INT)( ( cos( ( m_PTZ.dTilt - d ) / 360.0 * 6.2831 ) ) * r + w ) + rect.left;
|
|
INT y2 = (INT)( ( sin( ( m_PTZ.dTilt - d ) / 360.0 * 6.2831 ) ) * r + h ) + rect.top;
|
|
|
|
// redraw
|
|
pDC->FillSolidRect( rect, RGB(0,0,0) );
|
|
|
|
// draw
|
|
POINT p[] = { { x1, y1 }, { x2, y2 }, { w, h } };
|
|
// pDC->Polygon( p, 3 );
|
|
// pDC->MoveTo( x1, y1 );
|
|
// pDC->LineTo( w, h );
|
|
// pDC->LineTo( x2, y2 );
|
|
// POINT p[] = { { x1, y1 }, { x2, y2 } };
|
|
|
|
COLORREF color = m_bSynchronized ? RGB(0,255,0) : RGB(255,0,0);
|
|
CBrush brush( color );
|
|
CPen pen( PS_SOLID, 1, color );
|
|
|
|
CBrush *pBrush = pDC->SelectObject( &brush );
|
|
CPen *pPen = pDC->SelectObject( &pen );
|
|
|
|
rect.SetRect( (INT)(w-r+rect.top), (INT)(h-r+rect.top), (INT)(w+r+rect.top), (INT)(h+r+rect.top) );
|
|
pDC->Pie( &rect, p[0], p[1] );
|
|
|
|
// select old pen
|
|
// pDC->SelectObject( pPen );
|
|
// CPen pen1( PS_SOLID, 10, RGB(0xFF,0xFF,0xFF) );
|
|
// pPen = pDC->SelectObject( &pen1 );
|
|
/*
|
|
GetClientRect( &rect );
|
|
double l = ( sqrt( pow( rect.Width(), 2 ) + pow( rect.Height(), 2 ) ) - rect.Width() ) / 4;
|
|
|
|
w = l;
|
|
h = l;
|
|
r = h * ( 0.2 + m_PTZ.dZoom * 0.8 ) * 2;
|
|
x1 = (INT)( ( cos( ( m_PTZ.dTilt + d ) / 360.0 * 6.2831 ) ) * r + w );
|
|
y1 = (INT)( ( sin( ( m_PTZ.dTilt + d ) / 360.0 * 6.2831 ) ) * r + h );
|
|
x2 = (INT)( ( cos( ( m_PTZ.dTilt - d ) / 360.0 * 6.2831 ) ) * r + w );
|
|
y2 = (INT)( ( sin( ( m_PTZ.dTilt - d ) / 360.0 * 6.2831 ) ) * r + h );
|
|
|
|
POINT p1[] = { { x1, y1 }, { x2, y2 }, { w, h } };
|
|
rect.SetRect( (INT)(-r), (INT)(rect.Height()-r*2), (INT)(r), (INT)(rect.Height()) );
|
|
pDC->Pie( &rect, p1[0], p1[1] );
|
|
*/
|
|
/*
|
|
pDC->MoveTo( 0, rect.bottom - (INT)l );
|
|
x1 = (INT)( ( cos( m_PTZ.dTilt / 360.0 * 6.2831 ) ) * l );
|
|
y1 = (INT)( ( sin( m_PTZ.dTilt / 360.0 * 6.2831 ) ) * l ) + rect.bottom - (INT)l;
|
|
pDC->LineTo( x1, y1 );
|
|
*/
|
|
pDC->SelectObject( pPen );
|
|
pDC->SelectObject( pBrush );
|
|
}
|
|
|
|
void CCameraPositionWnd::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CWnd::OnSize(nType, cx, cy);
|
|
|
|
m_MemoryDC.Create( cx, cy );
|
|
}
|
|
|
|
void CCameraPositionWnd::SetPosition( double pan, double tilt, double zoom, BOOL bSynch )
|
|
{
|
|
m_PTZ.dPan = pan;
|
|
m_PTZ.dTilt = tilt;
|
|
m_PTZ.dZoom = zoom;
|
|
m_bSynchronized = bSynch;
|
|
|
|
if( GetSafeHwnd() )
|
|
InvalidateRect( NULL );
|
|
}
|