comparison Framework/Scene2DViewport/MeasureTrackers.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 059e1fd05fd6
children 8e31b174ab26
comparison
equal deleted inserted replaced
721:af0aa0c149fa 722:28b9e3a54200
24 using namespace Orthanc; 24 using namespace Orthanc;
25 25
26 namespace OrthancStone 26 namespace OrthancStone
27 { 27 {
28 28
29 CreateMeasureTracker::CreateMeasureTracker( 29 CreateMeasureTracker::CreateMeasureTracker(ViewportControllerWPtr controllerW)
30 ViewportControllerWPtr controllerW,
31 std::vector<TrackerCommandPtr>& undoStack,
32 std::vector<MeasureToolPtr>& measureTools)
33 : controllerW_(controllerW) 30 : controllerW_(controllerW)
34 , alive_(true) 31 , alive_(true)
35 , undoStack_(undoStack)
36 , measureTools_(measureTools)
37 , commitResult_(true) 32 , commitResult_(true)
38 { 33 {
39 } 34 }
40 35
41 void CreateMeasureTracker::Cancel() 36 void CreateMeasureTracker::Cancel()
54 // if the tracker completes successfully, we add the command 49 // if the tracker completes successfully, we add the command
55 // to the undo stack 50 // to the undo stack
56 51
57 // otherwise, we simply undo it 52 // otherwise, we simply undo it
58 if (commitResult_) 53 if (commitResult_)
59 undoStack_.push_back(command_); 54 controllerW_.lock()->PushCommand(command_);
60 else 55 else
61 command_->Undo(); 56 command_->Undo();
62 } 57 }
63
64 58
65 OrthancStone::Scene2DPtr CreateMeasureTracker::GetScene() 59 OrthancStone::Scene2DPtr CreateMeasureTracker::GetScene()
66 { 60 {
67 return controllerW_.lock()->GetScene(); 61 return controllerW_.lock()->GetScene();
68 } 62 }