Old fashion design for PC-104
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.
 
 
 
 
 

103 lines
2.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: HiddenZone.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of HiddenZone.cpp
//----------------------------------------------------------------------------
#include "stdafx.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
CHiddenZone::CHiddenZone()
{
m_pPoint = NULL;
m_nPoint = 0;
m_nType = 0;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CHiddenZone::CHiddenZone") );
}
CHiddenZone::~CHiddenZone()
{
RemoveAll();
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CHiddenZone::~CHiddenZone") );
}
BOOL CHiddenZone::Copy( CHiddenZone *pHiddenZone )
{
RemoveAll();
for( int i = 0; i < pHiddenZone->GetCount(); i++ )
Add( *pHiddenZone->GetAt(i) );
return TRUE;
}
bool CHiddenZone::Add( CLgDPoint dPoint, int nIndex )
{
if( nIndex < 0 )
return false;
m_nPoint ++;
m_pPoint = (CLgDPoint*) realloc( m_pPoint, sizeof(CLgDPoint) * m_nPoint );
if( nIndex >= m_nPoint )
nIndex = m_nPoint - 1;
MoveMemory( &m_pPoint[ nIndex + 1], &m_pPoint[ nIndex ], m_nPoint - nIndex - 1 );
m_pPoint[ nIndex ] = dPoint;
return true;
}
bool CHiddenZone::Remove( int nIndex )
{
if( nIndex < 0 || nIndex >= m_nPoint )
return false;
MoveMemory( &m_pPoint[ nIndex ], &m_pPoint[ nIndex + 1 ], m_nPoint - nIndex - 1 );
m_nPoint --;
m_pPoint = (CLgDPoint*) realloc( m_pPoint, sizeof(CLgDPoint) * m_nPoint );
return true;
}
void CHiddenZone::RemoveAll()
{
if( m_pPoint )
{
free( m_pPoint );
m_pPoint = NULL;
}
m_nPoint = 0;
}
CLgDPoint *CHiddenZone::GetAt( int nIndex )
{
return ( nIndex >= 0 && nIndex < m_nPoint ) ? &m_pPoint[ nIndex ] : NULL;
}
CLgDPoint *CHiddenZone::operator[] ( int nIndex )
{
return GetAt( nIndex );
}