-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHitlist.cpp
More file actions
71 lines (61 loc) · 1.41 KB
/
Copy pathHitlist.cpp
File metadata and controls
71 lines (61 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// This code is used to Track the position of various Nodes in the rendered
// view of the cave. These positions can be used by search engines and
// click detection code to find out where a node is.
#include "stdafx.h"
#include "hitlist.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
void CSearchableObjectList::AddObject(CRect& rect,CNode *pNode)
{
CSearchableObject *obj=new CSearchableObject(rect,pNode);
m_myArray.Add(obj);
}
CSearchableObject::CSearchableObject(CRect& rect,CNode *node):CRect(rect)
{
m_Node=node;
NormalizeRect(); // Windows does not handle PtInRect for unnormalized rects properly
}
CSearchableObject::~CSearchableObject()
{
m_Node=NULL;
}
CSearchableObjectList::CSearchableObjectList()
{
}
CSearchableObjectList::~CSearchableObjectList()
{
RemoveAll();
}
//Returns an array of all the points under the current cursor position
CPtrArray *CSearchableObjectList::HitTest(CPoint pt)
{
CPtrArray *ret=new CPtrArray;
for (int i=0;i<m_myArray.GetSize();i++)
{
if (m_myArray[i]->PtInRect(pt))
{
ret->Add((LPVOID)m_myArray[i]->GetNode());
}
}
if (ret->GetSize()==0)
{
delete ret;
return NULL;
}
else
{
return ret;
}
}
void CSearchableObjectList::RemoveAll()
{
for (int i=0;i<m_myArray.GetSize();i++)
{
delete m_myArray[i];
}
m_myArray.RemoveAll();
}