Mercurial > hg > orthanc-stone
comparison Samples/Common/MeasureTrackers.cpp @ 632:500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
when calling it ==> BumpRevision has been added to base class
- Added some docs
= Added GetMinDepth + GetMaxDepth to Scene2D (to alleviate the need for app-
specific "Z depth registry" : clients may simply add a new layer on top or at
the bottom of the existing layer set.
- Added the line tracker measurement tools, commands and trackers. Generic base
classes + Line measure
- started work on the line measure handles
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Thu, 09 May 2019 10:41:31 +0200 |
parents | |
children | 104c379f3f1b f939f449482c |
comparison
equal
deleted
inserted
replaced
618:0925b27e8750 | 632:500c3f70b6c2 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 #include "MeasureTrackers.h" | |
22 #include <Core/OrthancException.h> | |
23 | |
24 using namespace Orthanc; | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 | |
29 CreateMeasureTracker::CreateMeasureTracker( | |
30 Scene2D& scene, | |
31 std::vector<TrackerCommandPtr>& undoStack, | |
32 std::vector<MeasureToolPtr>& measureTools) | |
33 : scene_(scene) | |
34 , undoStack_(undoStack) | |
35 , measureTools_(measureTools) | |
36 , commitResult_(true) | |
37 { | |
38 } | |
39 | |
40 CreateMeasureTracker::~CreateMeasureTracker() | |
41 { | |
42 // if the tracker completes successfully, we add the command | |
43 // to the undo stack | |
44 | |
45 // otherwise, we simply undo it | |
46 if (commitResult_) | |
47 undoStack_.push_back(command_); | |
48 else | |
49 command_->Undo(); | |
50 } | |
51 | |
52 CreateLineMeasureTracker::CreateLineMeasureTracker( | |
53 Scene2D& scene, | |
54 std::vector<TrackerCommandPtr>& undoStack, | |
55 std::vector<MeasureToolPtr>& measureTools, | |
56 const PointerEvent& e) | |
57 : CreateMeasureTracker(scene, undoStack, measureTools) | |
58 { | |
59 command_.reset( | |
60 new CreateLineMeasureCommand( | |
61 scene, | |
62 measureTools, | |
63 e.GetMainPosition().Apply(scene.GetCanvasToSceneTransform()))); | |
64 } | |
65 | |
66 CreateLineMeasureTracker::~CreateLineMeasureTracker() | |
67 { | |
68 | |
69 } | |
70 | |
71 void CreateMeasureTracker::Update(const PointerEvent& event) | |
72 { | |
73 ScenePoint2D scenePos = event.GetMainPosition().Apply( | |
74 scene_.GetCanvasToSceneTransform()); | |
75 | |
76 LOG(TRACE) << "scenePos.GetX() = " << scenePos.GetX() << " " << | |
77 "scenePos.GetY() = " << scenePos.GetY(); | |
78 | |
79 CreateLineMeasureTracker* concreteThis = | |
80 dynamic_cast<CreateLineMeasureTracker*>(this); | |
81 assert(concreteThis != NULL); | |
82 command_->Update(scenePos); | |
83 } | |
84 | |
85 void CreateMeasureTracker::Release() | |
86 { | |
87 commitResult_ = false; | |
88 } | |
89 | |
90 } | |
91 | |
92 |