2019-09-04 18:26:26 +02:00
|
|
|
#include "pch.h"
|
2019-12-17 11:21:46 +03:00
|
|
|
#include "Zone.h"
|
|
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
Zone::Zone(const RECT& zoneRect, const ZoneIndex zoneIndex) :
|
|
|
|
|
m_rect(zoneRect),
|
|
|
|
|
m_index(zoneIndex)
|
2020-09-08 12:06:54 +02:00
|
|
|
{
|
2020-10-14 09:00:50 +02:00
|
|
|
}
|
2020-04-20 18:09:10 +02:00
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
Zone::Zone(const Zone& other) :
|
|
|
|
|
m_rect(other.m_rect),
|
|
|
|
|
m_index(other.m_index)
|
2020-10-14 09:00:50 +02:00
|
|
|
{
|
2022-10-31 13:44:25 +02:00
|
|
|
}
|
2020-04-20 18:09:10 +02:00
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
ZoneIndex Zone::Id() const noexcept
|
|
|
|
|
{
|
|
|
|
|
return m_index;
|
|
|
|
|
}
|
2020-04-20 18:09:10 +02:00
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
bool Zone::IsValid() const noexcept
|
|
|
|
|
{
|
|
|
|
|
return m_index >= 0 && isValid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RECT Zone::GetZoneRect() const noexcept
|
|
|
|
|
{
|
|
|
|
|
return m_rect;
|
|
|
|
|
}
|
2020-04-20 18:09:10 +02:00
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
long Zone::GetZoneArea() const noexcept
|
2019-09-04 18:26:26 +02:00
|
|
|
{
|
2022-10-31 13:44:25 +02:00
|
|
|
return max(m_rect.bottom - m_rect.top, 0) * max(m_rect.right - m_rect.left, 0);
|
2019-12-17 12:34:45 +03:00
|
|
|
}
|
2022-10-31 13:44:25 +02:00
|
|
|
|
|
|
|
|
bool Zone::isValid() const noexcept
|
|
|
|
|
{
|
|
|
|
|
int width = m_rect.right - m_rect.left;
|
|
|
|
|
int height = m_rect.bottom - m_rect.top;
|
|
|
|
|
return m_rect.left >= ZoneConstants::MAX_NEGATIVE_SPACING &&
|
|
|
|
|
m_rect.right >= ZoneConstants::MAX_NEGATIVE_SPACING &&
|
|
|
|
|
m_rect.top >= ZoneConstants::MAX_NEGATIVE_SPACING &&
|
|
|
|
|
m_rect.bottom >= ZoneConstants::MAX_NEGATIVE_SPACING &&
|
|
|
|
|
width >= 0 && height >= 0;
|
|
|
|
|
}
|