Mercurial > hg > orthanc-stone
annotate Framework/Radiography/RadiographyWindowingTracker.cpp @ 1236:358461330978 broker
global function GetWebGLViewportsRegistry()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Dec 2019 20:45:47 +0100 |
parents | 08cdcadfab14 |
children | 2d8ab34c8c91 |
rev | line source |
---|---|
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include "RadiographyWindowingTracker.h" |
1042
08cdcadfab14
allow using nearest neighbour interpolation while windowing
Alain Mazy <alain@mazy.be>
parents:
726
diff
changeset
|
23 #include "RadiographyWidget.h" |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include <Core/OrthancException.h> |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 namespace OrthancStone |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 class RadiographyWindowingTracker::UndoRedoCommand : public UndoRedoStack::ICommand |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 private: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 RadiographyScene& scene_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 float sourceCenter_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 float sourceWidth_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 float targetCenter_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 float targetWidth_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 public: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 UndoRedoCommand(const RadiographyWindowingTracker& tracker) : |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 scene_(tracker.scene_), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 sourceCenter_(tracker.sourceCenter_), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 sourceWidth_(tracker.sourceWidth_) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 scene_.GetWindowingWithDefault(targetCenter_, targetWidth_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 virtual void Undo() const |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 scene_.SetWindowing(sourceCenter_, sourceWidth_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 virtual void Redo() const |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 scene_.SetWindowing(targetCenter_, targetWidth_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 }; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 void RadiographyWindowingTracker::ComputeAxisEffect(int& deltaCenter, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 int& deltaWidth, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 int delta, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 Action actionNegative, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 Action actionPositive) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 if (delta < 0) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 switch (actionNegative) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 case Action_IncreaseWidth: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 deltaWidth = -delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 case Action_DecreaseWidth: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 deltaWidth = delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 case Action_IncreaseCenter: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 deltaCenter = -delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 case Action_DecreaseCenter: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 deltaCenter = delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 default: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 else if (delta > 0) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 switch (actionPositive) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 case Action_IncreaseWidth: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 deltaWidth = delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 case Action_DecreaseWidth: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 deltaWidth = -delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 case Action_IncreaseCenter: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 deltaCenter = delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 case Action_DecreaseCenter: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 deltaCenter = -delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 default: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 RadiographyWindowingTracker::RadiographyWindowingTracker(UndoRedoStack& undoRedoStack, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 RadiographyScene& scene, |
1042
08cdcadfab14
allow using nearest neighbour interpolation while windowing
Alain Mazy <alain@mazy.be>
parents:
726
diff
changeset
|
119 RadiographyWidget& widget, |
08cdcadfab14
allow using nearest neighbour interpolation while windowing
Alain Mazy <alain@mazy.be>
parents:
726
diff
changeset
|
120 ImageInterpolation interpolationDuringTracking, |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 int x, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 int y, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 Action leftAction, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 Action rightAction, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 Action upAction, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 Action downAction) : |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 undoRedoStack_(undoRedoStack), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 scene_(scene), |
1042
08cdcadfab14
allow using nearest neighbour interpolation while windowing
Alain Mazy <alain@mazy.be>
parents:
726
diff
changeset
|
129 widget_(widget), |
08cdcadfab14
allow using nearest neighbour interpolation while windowing
Alain Mazy <alain@mazy.be>
parents:
726
diff
changeset
|
130 initialWidgetInterpolation_(widget.GetInterpolation()), |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 clickX_(x), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 clickY_(y), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 leftAction_(leftAction), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 rightAction_(rightAction), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 upAction_(upAction), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 downAction_(downAction) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 scene_.GetWindowingWithDefault(sourceCenter_, sourceWidth_); |
1042
08cdcadfab14
allow using nearest neighbour interpolation while windowing
Alain Mazy <alain@mazy.be>
parents:
726
diff
changeset
|
139 widget_.SetInterpolation(interpolationDuringTracking); |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 float minValue, maxValue; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 scene.GetRange(minValue, maxValue); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 assert(minValue <= maxValue); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 float delta = (maxValue - minValue); |
455
e3a6e3bf5c7c
changed the windowing tracker sensitivity. It was not usable with 16bits full range
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
147 strength_ = delta / 1000.0f; // 1px move will change the ww/wc by 0.1% |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 if (strength_ < 1) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 strength_ = 1; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 void RadiographyWindowingTracker::Render(CairoContext& context, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 double zoom) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 void RadiographyWindowingTracker::MouseUp() |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 { |
1042
08cdcadfab14
allow using nearest neighbour interpolation while windowing
Alain Mazy <alain@mazy.be>
parents:
726
diff
changeset
|
165 widget_.SetInterpolation(initialWidgetInterpolation_); |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 undoRedoStack_.Add(new UndoRedoCommand(*this)); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 void RadiographyWindowingTracker::MouseMove(int displayX, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 int displayY, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 double sceneX, |
457
3b4df9925db6
added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents:
455
diff
changeset
|
173 double sceneY, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
457
diff
changeset
|
174 const std::vector<Deprecated::Touch>& displayTouches, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
457
diff
changeset
|
175 const std::vector<Deprecated::Touch>& sceneTouches) |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 // This follows the behavior of the Osimis Web viewer: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 // https://bitbucket.org/osimis/osimis-webviewer-plugin/src/master/frontend/src/app/viewport/image-plugins/windowing-viewport-tool.class.js |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 static const float SCALE = 1.0; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 int deltaCenter = 0; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 int deltaWidth = 0; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 ComputeAxisEffect(deltaCenter, deltaWidth, displayX - clickX_, leftAction_, rightAction_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 ComputeAxisEffect(deltaCenter, deltaWidth, displayY - clickY_, upAction_, downAction_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 float newCenter = sourceCenter_ + (deltaCenter / SCALE * strength_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 float newWidth = sourceWidth_ + (deltaWidth / SCALE * strength_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 scene_.SetWindowing(newCenter, newWidth); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 } |