-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserEvents.cpp
More file actions
81 lines (62 loc) · 1.78 KB
/
UserEvents.cpp
File metadata and controls
81 lines (62 loc) · 1.78 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
72
73
74
75
76
77
78
79
80
81
#include "UserEvents.h"
vtkStandardNewMacro(UserEvents);
UserEvents::UserEvents(){
}
void UserEvents::OnLeftDoubleClick(){
FindPokedRenderer(Interactor->GetEventPosition()[0], Interactor->GetEventPosition()[1]);
if (CurrentRenderer == nullptr)
{
return;
}
GrabFocus(EventCallbackCommand);
}
void UserEvents::OnLeftButtonDown(){
FindPokedRenderer(Interactor->GetEventPosition()[0], Interactor->GetEventPosition()[1]);
if (CurrentRenderer == nullptr)
{
return;
}
GrabFocus(EventCallbackCommand);
SetTimerDuration(1);
UseTimersOn();
StartTimer();
//----------------------
NumberOfClicks++;
if (NumberOfClicks == 1) {
start = std::chrono::system_clock::now();
}
if (NumberOfClicks == 2) {
end = std::chrono::system_clock::now();
}
int pickPosition[2];
this->GetInteractor()->GetEventPosition(pickPosition);
int xdist = pickPosition[0] - this->PreviousPosition[0];
int ydist = pickPosition[1] - this->PreviousPosition[1];
this->PreviousPosition[0] = pickPosition[0];
this->PreviousPosition[1] = pickPosition[1];
int moveDistance = (int)(xdist * xdist + ydist * ydist);
if (abs(std::chrono::duration<double>(end - start).count()) > doubleClickTimeLimit) {
NumberOfClicks = 1;
start = std::chrono::system_clock::now();
}
if (moveDistance > (ResetPixelDistance * ResetPixelDistance)) {
NumberOfClicks = 1;
}
if (NumberOfClicks == 2) {
OnLeftDoubleClick();
NumberOfClicks = 0;
EndTimer();
}
}
void UserEvents::OnLeftButtonUp() {
EndTimer();
if (Interactor) {
ReleaseFocus();
}
}
void UserEvents::OnTimer() {
if (CurrentRenderer == nullptr) {
return;
}
Scrolling();
}