644
|
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 "CreateLineMeasureTracker.h"
|
|
22 #include <Core/OrthancException.h>
|
|
23
|
|
24 using namespace Orthanc;
|
|
25
|
|
26 namespace OrthancStone
|
|
27 {
|
|
28 CreateLineMeasureTracker::CreateLineMeasureTracker(
|
|
29 Scene2D& scene,
|
|
30 std::vector<TrackerCommandPtr>& undoStack,
|
|
31 std::vector<MeasureToolPtr>& measureTools,
|
|
32 const PointerEvent& e)
|
|
33 : CreateMeasureTracker(scene, undoStack, measureTools)
|
|
34 {
|
|
35 command_.reset(
|
|
36 new CreateLineMeasureCommand(
|
|
37 scene,
|
|
38 measureTools,
|
|
39 e.GetMainPosition().Apply(scene.GetCanvasToSceneTransform())));
|
|
40 }
|
|
41
|
|
42 CreateLineMeasureTracker::~CreateLineMeasureTracker()
|
|
43 {
|
|
44
|
|
45 }
|
|
46
|
|
47 void CreateLineMeasureTracker::PointerMove(const PointerEvent& event)
|
|
48 {
|
|
49 if (!active_)
|
|
50 {
|
|
51 throw OrthancException(ErrorCode_InternalError,
|
|
52 "Internal error: wrong state in CreateLineMeasureTracker::"
|
|
53 "PointerMove: active_ == false");
|
|
54 }
|
|
55
|
|
56 ScenePoint2D scenePos = event.GetMainPosition().Apply(
|
|
57 scene_.GetCanvasToSceneTransform());
|
|
58
|
|
59 //LOG(TRACE) << "scenePos.GetX() = " << scenePos.GetX() << " " <<
|
|
60 // "scenePos.GetY() = " << scenePos.GetY();
|
|
61
|
|
62 CreateLineMeasureTracker* concreteThis =
|
|
63 dynamic_cast<CreateLineMeasureTracker*>(this);
|
|
64 assert(concreteThis != NULL);
|
|
65 command_->Update(scenePos);
|
|
66 }
|
|
67
|
|
68 void CreateLineMeasureTracker::PointerUp(const PointerEvent& e)
|
|
69 {
|
|
70 // TODO: the current app does not prevent multiple PointerDown AND
|
|
71 // PointerUp to be sent to the tracker.
|
|
72 // Unless we augment the PointerEvent structure with the button index,
|
|
73 // we cannot really tell if this pointer up event matches the initial
|
|
74 // pointer down event. Let's make it simple for now.
|
|
75 active_ = false;
|
|
76 }
|
|
77
|
|
78 void CreateLineMeasureTracker::PointerDown(const PointerEvent& e)
|
|
79 {
|
|
80 LOG(WARNING) << "Additional touches (fingers, pen, mouse buttons...) "
|
|
81 "are ignored when the line measure creation tracker is active";
|
|
82 }
|
|
83 }
|