Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/MeasureTrackers.cpp @ 866:c71ef52602a0 toa2019062501
Added the ability to edit existing measuring tools (demo not updated yet)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 25 Jun 2019 17:54:46 +0200 |
parents | e42b491f1fb2 |
children | 0aff28f15ea2 |
comparison
equal
deleted
inserted
replaced
865:a29c13497557 | 866:c71ef52602a0 |
---|---|
44 | 44 |
45 CreateMeasureTracker::~CreateMeasureTracker() | 45 CreateMeasureTracker::~CreateMeasureTracker() |
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 | |
50 // otherwise, we simply undo it | 49 // otherwise, we simply undo it |
51 if (commitResult_) | 50 if (commitResult_) |
52 controllerW_.lock()->PushCommand(command_); | 51 controllerW_.lock()->PushCommand(command_); |
53 else | 52 else |
54 command_->Undo(); | 53 command_->Undo(); |
57 boost::shared_ptr<Scene2D> CreateMeasureTracker::GetScene() | 56 boost::shared_ptr<Scene2D> CreateMeasureTracker::GetScene() |
58 { | 57 { |
59 return controllerW_.lock()->GetScene(); | 58 return controllerW_.lock()->GetScene(); |
60 } | 59 } |
61 | 60 |
61 EditMeasureTracker::EditMeasureTracker(boost::weak_ptr<ViewportController> controllerW, const PointerEvent& e) | |
62 : controllerW_(controllerW) | |
63 , alive_(true) | |
64 , commitResult_(true) | |
65 { | |
66 boost::shared_ptr<ViewportController> controller = controllerW.lock(); | |
67 originalClickPosition_ = e.GetMainPosition().Apply(controller->GetScene()->GetCanvasToSceneTransform()); | |
68 } | |
69 | |
70 boost::shared_ptr<Scene2D> EditMeasureTracker::GetScene() | |
71 { | |
72 return controllerW_.lock()->GetScene(); | |
73 } | |
74 | |
75 void EditMeasureTracker::Cancel() | |
76 { | |
77 commitResult_ = false; | |
78 alive_ = false; | |
79 } | |
80 | |
81 bool EditMeasureTracker::IsAlive() const | |
82 { | |
83 return alive_; | |
84 } | |
85 | |
86 EditMeasureTracker::~EditMeasureTracker() | |
87 { | |
88 // if the tracker completes successfully, we add the command | |
89 // to the undo stack | |
90 // otherwise, we simply undo it | |
91 if (commitResult_) | |
92 controllerW_.lock()->PushCommand(command_); | |
93 else | |
94 command_->Undo(); | |
95 } | |
62 } | 96 } |
63 | 97 |
64 | 98 |