annotate OrthancStone/Sources/Viewport/DefaultViewportInteractor.cpp @ 1748:b6a6ad64192a

FastParseVector : manually written code to parse strings like 3.1315\-1.2e12\2344.5\123 into boost::numeric::ublas::vector<double> + tests
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 22 Feb 2021 14:55:13 +0100
parents 9ac2a65d4172
children fdc6a8089eb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
15 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1579
diff changeset
16 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
18 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
19 * <http://www.gnu.org/licenses/>.
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "DefaultViewportInteractor.h"
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "../Scene2D/GrayscaleWindowingSceneTracker.h"
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "../Scene2D/PanSceneTracker.h"
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../Scene2D/RotateSceneTracker.h"
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "../Scene2D/ZoomSceneTracker.h"
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
29 #include <OrthancException.h>
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
30
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
33 IFlexiblePointerTracker* DefaultViewportInteractor::CreateTrackerInternal(
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
34 boost::weak_ptr<IViewport> viewport,
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
35 MouseAction action,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
36 const PointerEvent& event,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
37 unsigned int viewportWidth,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
38 unsigned int viewportHeight)
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
39 {
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
40 switch (action)
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
41 {
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1561
diff changeset
42 case MouseAction_None:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1561
diff changeset
43 return NULL;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1561
diff changeset
44
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
45 case MouseAction_Rotate:
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
46 return new RotateSceneTracker(viewport, event);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
47
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
48 case MouseAction_GrayscaleWindowing:
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
49 return new GrayscaleWindowingSceneTracker(
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
50 viewport, windowingLayer_, event, viewportWidth, viewportHeight);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
51
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
52 case MouseAction_Pan:
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
53 return new PanSceneTracker(viewport, event);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
54
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
55 case MouseAction_Zoom:
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
56 return new ZoomSceneTracker(viewport, event, viewportHeight);
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1561
diff changeset
57
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
58 default:
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
59 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
60 }
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
61 }
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
62
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
63
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 IFlexiblePointerTracker* DefaultViewportInteractor::CreateTracker(
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
65 boost::weak_ptr<IViewport> viewport,
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
66 const PointerEvent& event,
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
67 unsigned int viewportWidth,
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
68 unsigned int viewportHeight)
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
70 MouseAction action;
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
71
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 switch (event.GetMouseButton())
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 case MouseButton_Left:
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
75 action = leftButtonAction_;
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
76 break;
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 case MouseButton_Middle:
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
79 action = middleButtonAction_;
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
80 break;
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 case MouseButton_Right:
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
83 action = rightButtonAction_;
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
84 break;
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 default:
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 return NULL;
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
89
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
90 return CreateTrackerInternal(viewport, action, event, viewportWidth, viewportHeight);
1557
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
a6f339d8e4c2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 }