Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/OneGesturePointerTracker.cpp @ 722:28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
tools are now handled by the ViewportController. Multi-touch does not crash
trackers anymore.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 21 May 2019 10:27:54 +0200 |
parents | f45fca2ebd10 |
children | c0fcb2757b0a |
comparison
equal
deleted
inserted
replaced
721:af0aa0c149fa | 722:28b9e3a54200 |
---|---|
21 | 21 |
22 #include "OneGesturePointerTracker.h" | 22 #include "OneGesturePointerTracker.h" |
23 | 23 |
24 #include <Core/OrthancException.h> | 24 #include <Core/OrthancException.h> |
25 | 25 |
26 #include <Framework/StoneException.h> | |
27 | |
26 using namespace Orthanc; | 28 using namespace Orthanc; |
27 | 29 |
28 namespace OrthancStone | 30 namespace OrthancStone |
29 { | 31 { |
30 OneGesturePointerTracker::OneGesturePointerTracker( | 32 OneGesturePointerTracker::OneGesturePointerTracker( |
31 ViewportControllerWPtr controllerW) | 33 ViewportControllerWPtr controllerW) |
32 : controllerW_(controllerW) | 34 : controllerW_(controllerW) |
33 , alive_(true) | 35 , alive_(true) |
36 , currentTouchCount_(1) | |
34 { | 37 { |
35 } | 38 } |
36 | 39 |
37 void OneGesturePointerTracker::PointerUp(const PointerEvent& event) | 40 void OneGesturePointerTracker::PointerUp(const PointerEvent& event) |
38 { | 41 { |
39 alive_ = false; | 42 // pointer up is only called for the LAST up event in case of a multi-touch |
43 // gesture | |
44 ORTHANC_ASSERT(currentTouchCount_ > 0, "Wrong state in tracker"); | |
45 currentTouchCount_--; | |
46 LOG(INFO) << "currentTouchCount_ becomes: " << currentTouchCount_; | |
47 if (currentTouchCount_ == 0) | |
48 { | |
49 LOG(INFO) << "currentTouchCount_ == 0 --> alive_ = false"; | |
50 alive_ = false; | |
51 } | |
40 } | 52 } |
41 | 53 |
42 void OneGesturePointerTracker::PointerDown(const PointerEvent& event) | 54 void OneGesturePointerTracker::PointerDown(const PointerEvent& event) |
43 { | 55 { |
44 throw OrthancException(ErrorCode_InternalError, "Wrong state in tracker"); | 56 // additional touches are not taken into account but we need to count |
57 // the number of active touches | |
58 currentTouchCount_++; | |
59 LOG(INFO) << "currentTouchCount_ becomes: " << currentTouchCount_; | |
45 } | 60 } |
46 | 61 |
47 bool OneGesturePointerTracker::IsAlive() const | 62 bool OneGesturePointerTracker::IsAlive() const |
48 { | 63 { |
49 return alive_; | 64 return alive_; |