Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/MeasureTrackers.cpp @ 1331:ab81ee8fce1f broker
- Viewport is not passed and stored as a shared_ptr instead
of raw reference.
- ViewportController can now be injected with an undo
stack (not a ctor param anymore, as a preparation for the
move of the undo stack to an interactor)
- Added (temp) flag to disable emscripten events registration
in the WebAssemblyViewport (because legacy client code
deals with them directly)
- Added emscripten_clear_timeout in ~WebGLViewportsRegistry
- Removed GenericToolbox::HoldingRef whose responsibility is
better served with proper callback un-registration.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 30 Mar 2020 14:23:46 +0200 |
parents | a5326ce4f24b |
children | 30deba7bc8e2 |
comparison
equal
deleted
inserted
replaced
1329:8d3e669f01a2 | 1331:ab81ee8fce1f |
---|---|
22 #include <Core/OrthancException.h> | 22 #include <Core/OrthancException.h> |
23 | 23 |
24 namespace OrthancStone | 24 namespace OrthancStone |
25 { | 25 { |
26 | 26 |
27 CreateMeasureTracker::CreateMeasureTracker(IViewport& viewport) | 27 CreateMeasureTracker::CreateMeasureTracker(boost::shared_ptr<IViewport> viewport) |
28 : viewport_(viewport) | 28 : viewport_(viewport) |
29 , alive_(true) | 29 , alive_(true) |
30 , commitResult_(true) | 30 , commitResult_(true) |
31 { | 31 { |
32 } | 32 } |
46 { | 46 { |
47 // if the tracker completes successfully, we add the command | 47 // if the tracker completes successfully, we add the command |
48 // to the undo stack | 48 // to the undo stack |
49 // otherwise, we simply undo it | 49 // otherwise, we simply undo it |
50 | 50 |
51 std::unique_ptr<IViewport::ILock> lock(viewport_.Lock()); | 51 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
52 ViewportController& controller = lock->GetController(); | 52 ViewportController& controller = lock->GetController(); |
53 | 53 |
54 if (commitResult_) | 54 if (commitResult_) |
55 lock->GetController().PushCommand(command_); | 55 lock->GetController().PushCommand(command_); |
56 else | 56 else |
57 command_->Undo(); | 57 command_->Undo(); |
58 | 58 |
59 lock->Invalidate(); | 59 lock->Invalidate(); |
60 } | 60 } |
61 | 61 |
62 EditMeasureTracker::EditMeasureTracker(IViewport& viewport, const PointerEvent& e) | 62 EditMeasureTracker::EditMeasureTracker(boost::shared_ptr<IViewport> viewport, const PointerEvent& e) |
63 : viewport_(viewport) | 63 : viewport_(viewport) |
64 , alive_(true) | 64 , alive_(true) |
65 , commitResult_(true) | 65 , commitResult_(true) |
66 { | 66 { |
67 std::unique_ptr<IViewport::ILock> lock(viewport_.Lock()); | 67 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
68 ViewportController& controller = lock->GetController(); | 68 ViewportController& controller = lock->GetController(); |
69 | 69 |
70 originalClickPosition_ = e.GetMainPosition().Apply( | 70 originalClickPosition_ = e.GetMainPosition().Apply( |
71 controller.GetScene().GetCanvasToSceneTransform()); | 71 controller.GetScene().GetCanvasToSceneTransform()); |
72 } | 72 } |
86 { | 86 { |
87 // if the tracker completes successfully, we add the command | 87 // if the tracker completes successfully, we add the command |
88 // to the undo stack | 88 // to the undo stack |
89 // otherwise, we simply undo it | 89 // otherwise, we simply undo it |
90 | 90 |
91 std::unique_ptr<IViewport::ILock> lock(viewport_.Lock()); | 91 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
92 ViewportController& controller = lock->GetController(); | 92 ViewportController& controller = lock->GetController(); |
93 | 93 |
94 if (commitResult_) | 94 if (commitResult_) |
95 lock->GetController().PushCommand(command_); | 95 lock->GetController().PushCommand(command_); |
96 else | 96 else |