Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/MeasureTrackers.cpp @ 700:059e1fd05fd6 refactor-viewport-controller
Introduced the ViewportController that sits between the application and the
Scene2D to handle the trackers and measuring tools. This is a work in progress.
The Scene2D is no longer an observable. Message sending is managed by the
ViewportController.
Move some refs to shared and weak to prevent lifetime issues.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Sun, 19 May 2019 16:26:17 +0200 |
parents | 8b6adfb62a2f |
children | 28b9e3a54200 |
comparison
equal
deleted
inserted
replaced
699:5c551f078c18 | 700:059e1fd05fd6 |
---|---|
25 | 25 |
26 namespace OrthancStone | 26 namespace OrthancStone |
27 { | 27 { |
28 | 28 |
29 CreateMeasureTracker::CreateMeasureTracker( | 29 CreateMeasureTracker::CreateMeasureTracker( |
30 Scene2DWPtr sceneW, | 30 ViewportControllerWPtr controllerW, |
31 std::vector<TrackerCommandPtr>& undoStack, | 31 std::vector<TrackerCommandPtr>& undoStack, |
32 std::vector<MeasureToolPtr>& measureTools) | 32 std::vector<MeasureToolPtr>& measureTools) |
33 : scene_(sceneW) | 33 : controllerW_(controllerW) |
34 , active_(true) | 34 , alive_(true) |
35 , undoStack_(undoStack) | 35 , undoStack_(undoStack) |
36 , measureTools_(measureTools) | 36 , measureTools_(measureTools) |
37 , commitResult_(true) | 37 , commitResult_(true) |
38 { | 38 { |
39 } | 39 } |
40 | 40 |
41 void CreateMeasureTracker::Cancel() | 41 void CreateMeasureTracker::Cancel() |
42 { | 42 { |
43 commitResult_ = false; | 43 commitResult_ = false; |
44 active_ = false; | 44 alive_ = false; |
45 } | 45 } |
46 | 46 |
47 bool CreateMeasureTracker::IsActive() const | 47 bool CreateMeasureTracker::IsAlive() const |
48 { | 48 { |
49 return active_; | 49 return alive_; |
50 } | 50 } |
51 | 51 |
52 CreateMeasureTracker::~CreateMeasureTracker() | 52 CreateMeasureTracker::~CreateMeasureTracker() |
53 { | 53 { |
54 // if the tracker completes successfully, we add the command | 54 // if the tracker completes successfully, we add the command |
58 if (commitResult_) | 58 if (commitResult_) |
59 undoStack_.push_back(command_); | 59 undoStack_.push_back(command_); |
60 else | 60 else |
61 command_->Undo(); | 61 command_->Undo(); |
62 } | 62 } |
63 | |
64 | |
65 OrthancStone::Scene2DPtr CreateMeasureTracker::GetScene() | |
66 { | |
67 return controllerW_.lock()->GetScene(); | |
68 } | |
69 | |
63 } | 70 } |
64 | 71 |
65 | 72 |