annotate Framework/Scene2DViewport/CreateAngleMeasureTracker.cpp @ 1020:ac88989817e3 toa2019093001

TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor + added DeleteMeasureCommand + moved the various concrete measuring tool-related classes to their pre-assigned file locations (everything was crammed into MeasureCommands.* files up to this commit) + added double-click handler to GuiAdapter (for TOA implementation of "delete measuring tool on double-click")
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 30 Sep 2019 10:41:06 +0200
parents 0aff28f15ea2
children e146743f6cdc 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 *
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 *
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 *
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19 **/
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 #include "CreateAngleMeasureTracker.h"
1020
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
22 #include "CreateAngleMeasureCommand.h"
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
23
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #include <Core/OrthancException.h>
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 namespace OrthancStone
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 CreateAngleMeasureTracker::CreateAngleMeasureTracker(
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29 MessageBroker& broker,
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 738
diff changeset
30 boost::weak_ptr<ViewportController> controllerW,
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 const PointerEvent& e)
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
32 : CreateMeasureTracker(controllerW)
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 , state_(CreatingSide1)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 command_.reset(
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 new CreateAngleMeasureCommand(
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 broker,
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
38 controllerW,
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 818
diff changeset
39 e.GetMainPosition().Apply(GetScene().GetCanvasToSceneTransform())));
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 CreateAngleMeasureTracker::~CreateAngleMeasureTracker()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 void CreateAngleMeasureTracker::PointerMove(const PointerEvent& event)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 {
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
48 if (!alive_)
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 {
738
8e31b174ab26 removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
50 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 "Internal error: wrong state in CreateAngleMeasureTracker::"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 "PointerMove: active_ == false");
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 ScenePoint2D scenePos = event.GetMainPosition().Apply(
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 818
diff changeset
56 GetScene().GetCanvasToSceneTransform());
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 switch (state_)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 case CreatingSide1:
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 GetCommand()->SetCenter(scenePos);
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 break;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 case CreatingSide2:
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 GetCommand()->SetSide2End(scenePos);
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 break;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 default:
738
8e31b174ab26 removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
67 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 "Wrong state in CreateAngleMeasureTracker::"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 "PointerMove: state_ invalid");
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 //LOG(TRACE) << "scenePos.GetX() = " << scenePos.GetX() << " " <<
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 // "scenePos.GetY() = " << scenePos.GetY();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 void CreateAngleMeasureTracker::PointerUp(const PointerEvent& e)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 // TODO: the current app does not prevent multiple PointerDown AND
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 // PointerUp to be sent to the tracker.
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 // Unless we augment the PointerEvent structure with the button index,
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 // we cannot really tell if this pointer up event matches the initial
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81 // pointer down event. Let's make it simple for now.
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 switch (state_)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 case CreatingSide1:
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 state_ = CreatingSide2;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 break;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 case CreatingSide2:
738
8e31b174ab26 removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
89 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 "Wrong state in CreateAngleMeasureTracker::"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 "PointerUp: state_ == CreatingSide2 ; this should not happen");
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 break;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 default:
738
8e31b174ab26 removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
94 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 "Wrong state in CreateAngleMeasureTracker::"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96 "PointerMove: state_ invalid");
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 void CreateAngleMeasureTracker::PointerDown(const PointerEvent& e)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 switch (state_)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104 case CreatingSide1:
738
8e31b174ab26 removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
105 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 "Wrong state in CreateAngleMeasureTracker::"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 "PointerDown: state_ == CreatingSide1 ; this should not happen");
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
108 break;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 case CreatingSide2:
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110 // we are done
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
111 alive_ = false;
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112 break;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 default:
738
8e31b174ab26 removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
114 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115 "Wrong state in CreateAngleMeasureTracker::"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116 "PointerMove: state_ invalid");
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 738
diff changeset
120 boost::shared_ptr<CreateAngleMeasureCommand> CreateAngleMeasureTracker::GetCommand()
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 return boost::dynamic_pointer_cast<CreateAngleMeasureCommand>(command_);
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 }