annotate Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1721:d4a8e2b19a65

new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 01 Dec 2020 12:51:57 +0100
parents b8d19f53aaca
children 802cb1272f3a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
16 *
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
22 #include <EmbeddedResources.h>
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include <emscripten.h>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #define DISPATCH_JAVASCRIPT_EVENT(name) \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 EM_ASM( \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 const customEvent = document.createEvent("CustomEvent"); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 customEvent.initCustomEvent(name, false, false, undefined); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 window.dispatchEvent(customEvent); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 );
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #define EXTERN_CATCH_EXCEPTIONS \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 catch (Orthanc::OrthancException& e) \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 { \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 LOG(ERROR) << "OrthancException: " << e.What(); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 DISPATCH_JAVASCRIPT_EVENT("StoneException"); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 } \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 catch (OrthancStone::StoneException& e) \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 { \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 LOG(ERROR) << "StoneException: " << e.What(); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 DISPATCH_JAVASCRIPT_EVENT("StoneException"); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 } \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 catch (std::exception& e) \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 { \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 LOG(ERROR) << "Runtime error: " << e.what(); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 DISPATCH_JAVASCRIPT_EVENT("StoneException"); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 } \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 catch (...) \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 { \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 LOG(ERROR) << "Native exception"; \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 DISPATCH_JAVASCRIPT_EVENT("StoneException"); \
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
57 // Orthanc framework includes
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 #include <Cache/MemoryObjectCache.h>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 #include <DicomFormat/DicomArray.h>
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
60 #include <DicomParsing/ParsedDicomFile.h>
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 #include <Images/Image.h>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 #include <Images/ImageProcessing.h>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 #include <Images/JpegReader.h>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 #include <Logging.h>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
66 // Stone includes
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
67 #include <Loaders/DicomResourcesLoader.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
68 #include <Loaders/SeriesMetadataLoader.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
69 #include <Loaders/SeriesThumbnailsLoader.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
70 #include <Messages/ObserverBase.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
71 #include <Oracle/ParseDicomFromWadoCommand.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
72 #include <Oracle/ParseDicomSuccessMessage.h>
1614
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1611
diff changeset
73 #include <Scene2D/ArrowSceneLayer.h>
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
74 #include <Scene2D/ColorTextureSceneLayer.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
75 #include <Scene2D/FloatTextureSceneLayer.h>
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1607
diff changeset
76 #include <Scene2D/MacroSceneLayer.h>
1615
f5d4bd7b5593 new class: OsiriXLayerFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1614
diff changeset
77 #include <Scene2D/OsiriXLayerFactory.h>
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
78 #include <Scene2D/PolylineSceneLayer.h>
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
79 #include <Scene2D/TextSceneLayer.h>
1558
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
80 #include <Scene2DViewport/ViewportController.h>
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
81 #include <StoneException.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
82 #include <Toolbox/DicomInstanceParameters.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
83 #include <Toolbox/GeometryToolbox.h>
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
84 #include <Toolbox/OsiriX/AngleAnnotation.h>
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
85 #include <Toolbox/OsiriX/CollectionOfAnnotations.h>
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
86 #include <Toolbox/OsiriX/LineAnnotation.h>
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
87 #include <Toolbox/OsiriX/TextAnnotation.h>
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
88 #include <Toolbox/SortedFrames.h>
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
89 #include <Viewport/DefaultViewportInteractor.h>
1591
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
90
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
91 // WebAssembly includes
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
92 #include <WebAssemblyCairoViewport.h>
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
93 #include <WebAssemblyLoadersContext.h>
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
94 #include <WebGLViewport.h>
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
95
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
97 #include <boost/math/special_functions/round.hpp>
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 #include <boost/make_shared.hpp>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 #include <stdio.h>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
102 #if !defined(STONE_WEB_VIEWER_EXPORT)
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
103 // We are not running ParseWebAssemblyExports.py, but we're compiling the wasm
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
104 # define STONE_WEB_VIEWER_EXPORT
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
105 #endif
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
106
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
107
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
108 #define FIX_LSD_479 1
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
109
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
110
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
111 enum STONE_WEB_VIEWER_EXPORT ThumbnailType
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 ThumbnailType_Image,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 ThumbnailType_NoPreview,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 ThumbnailType_Pdf,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 ThumbnailType_Video,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 ThumbnailType_Loading,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 ThumbnailType_Unknown
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
119 };
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
122 enum STONE_WEB_VIEWER_EXPORT DisplayedFrameQuality
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
124 DisplayedFrameQuality_None,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
125 DisplayedFrameQuality_Low,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
126 DisplayedFrameQuality_High
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
127 };
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
128
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
129
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
130 enum STONE_WEB_VIEWER_EXPORT WebViewerAction
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
131 {
1701
b5a8bf32d969 new configuration options: "CombinedToolEnabled", "CombinedToolBehaviour" and "DownloadAsJpegEnabled"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
132 WebViewerAction_Windowing,
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
133 WebViewerAction_Zoom,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
134 WebViewerAction_Pan,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
135 WebViewerAction_Rotate,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
136 WebViewerAction_Crosshair
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
137 };
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
141 static OrthancStone::MouseAction ConvertWebViewerAction(int action)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
142 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
143 switch (action)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
144 {
1701
b5a8bf32d969 new configuration options: "CombinedToolEnabled", "CombinedToolBehaviour" and "DownloadAsJpegEnabled"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
145 case WebViewerAction_Windowing:
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
146 return OrthancStone::MouseAction_GrayscaleWindowing;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
147
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
148 case WebViewerAction_Zoom:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
149 return OrthancStone::MouseAction_Zoom;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
150
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
151 case WebViewerAction_Pan:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
152 return OrthancStone::MouseAction_Pan;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
153
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
154 case WebViewerAction_Rotate:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
155 return OrthancStone::MouseAction_Rotate;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
156
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
157 case WebViewerAction_Crosshair:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
158 return OrthancStone::MouseAction_None;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
159
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
160 default:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
161 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
162 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
163 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
164
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
165
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
166
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 static const int PRIORITY_HIGH = -100;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 static const int PRIORITY_LOW = 100;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 static const int PRIORITY_NORMAL = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 static const unsigned int QUALITY_JPEG = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 static const unsigned int QUALITY_FULL = 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
174 static const unsigned int DEFAULT_CINE_RATE = 30;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
175
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
176
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 class ResourcesLoader : public OrthancStone::ObserverBase<ResourcesLoader>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 class IObserver : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 virtual ~IObserver()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 virtual void SignalResourcesLoaded() = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 virtual void SignalSeriesThumbnailLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 const std::string& seriesInstanceUid) = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 virtual void SignalSeriesMetadataLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 const std::string& seriesInstanceUid) = 0;
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
194
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
195 virtual void SignalSeriesPdfLoaded(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
196 const std::string& seriesInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
197 const std::string& pdf) = 0;
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
198
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
199 virtual void SignalMultiframeInstanceThumbnailLoaded(const std::string& sopInstanceUid,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
200 const std::string& jpeg) = 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 private:
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
204 OrthancStone::ILoadersContext& context_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 std::unique_ptr<IObserver> observer_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 OrthancStone::DicomSource source_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 size_t pending_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 boost::shared_ptr<OrthancStone::LoadedDicomResources> studies_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 boost::shared_ptr<OrthancStone::LoadedDicomResources> series_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 boost::shared_ptr<OrthancStone::DicomResourcesLoader> resourcesLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 boost::shared_ptr<OrthancStone::SeriesThumbnailsLoader> thumbnailsLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 boost::shared_ptr<OrthancStone::SeriesMetadataLoader> metadataLoader_;
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
213 std::set<std::string> scheduledMultiframeInstances_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
215 explicit ResourcesLoader(OrthancStone::ILoadersContext& context,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
216 const OrthancStone::DicomSource& source) :
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
217 context_(context),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 source_(source),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 pending_(0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 studies_(new OrthancStone::LoadedDicomResources(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID)),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 series_(new OrthancStone::LoadedDicomResources(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 void Handle(const OrthancStone::DicomResourcesLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 const Orthanc::SingleValueObject<Orthanc::ResourceType>& payload =
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 dynamic_cast<const Orthanc::SingleValueObject<Orthanc::ResourceType>&>(message.GetUserPayload());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 OrthancStone::LoadedDicomResources& dicom = *message.GetResources();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 LOG(INFO) << "resources loaded: " << dicom.GetSize()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 << ", " << Orthanc::EnumerationToString(payload.GetValue());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 if (payload.GetValue() == Orthanc::ResourceType_Series)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 for (size_t i = 0; i < dicom.GetSize(); i++)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 std::string studyInstanceUid, seriesInstanceUid;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 if (dicom.GetResource(i).LookupStringValue(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 studyInstanceUid, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 dicom.GetResource(i).LookupStringValue(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 seriesInstanceUid, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 thumbnailsLoader_->ScheduleLoadThumbnail(source_, "", studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 metadataLoader_->ScheduleLoadSeries(PRIORITY_LOW + 1, source_, studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 if (pending_ == 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 pending_ --;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 if (pending_ == 0 &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 observer_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 observer_->SignalResourcesLoaded();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 void Handle(const OrthancStone::SeriesThumbnailsLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 if (observer_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 observer_->SignalSeriesThumbnailLoaded(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 message.GetStudyInstanceUid(), message.GetSeriesInstanceUid());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 void Handle(const OrthancStone::SeriesMetadataLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 if (observer_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 observer_->SignalSeriesMetadataLoaded(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 message.GetStudyInstanceUid(), message.GetSeriesInstanceUid());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
284 void FetchInternal(const std::string& patientId,
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
285 const std::string& studyInstanceUid,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 const std::string& seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 // Firstly, load the study
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 Orthanc::DicomMap filter;
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
290
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
291 if (!patientId.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
292 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
293 filter.SetValue(Orthanc::DICOM_TAG_PATIENT_ID, patientId, false);
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
294 }
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
295
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
296 if (!studyInstanceUid.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
297 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
298 filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false);
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
299 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 std::set<Orthanc::DicomTag> tags;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 tags.insert(Orthanc::DICOM_TAG_STUDY_DESCRIPTION); // Necessary for Orthanc DICOMweb plugin
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 resourcesLoader_->ScheduleQido(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 studies_, PRIORITY_HIGH, source_, Orthanc::ResourceType_Study, filter, tags,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 new Orthanc::SingleValueObject<Orthanc::ResourceType>(Orthanc::ResourceType_Study));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 // Secondly, load the series
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 if (!seriesInstanceUid.empty())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 filter.SetValue(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, seriesInstanceUid, false);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 tags.insert(Orthanc::DICOM_TAG_SERIES_NUMBER); // Necessary for Google Cloud Platform
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 resourcesLoader_->ScheduleQido(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 series_, PRIORITY_HIGH, source_, Orthanc::ResourceType_Series, filter, tags,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 new Orthanc::SingleValueObject<Orthanc::ResourceType>(Orthanc::ResourceType_Series));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 pending_ += 2;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 }
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
322
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
323
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
324 class PdfInfo : public Orthanc::IDynamicObject
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
325 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
326 private:
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
327 std::string studyInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
328 std::string seriesInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
329
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
330 public:
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
331 PdfInfo(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
332 const std::string& seriesInstanceUid) :
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
333 studyInstanceUid_(studyInstanceUid),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
334 seriesInstanceUid_(seriesInstanceUid)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
335 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
336 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
337
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
338 const std::string& GetStudyInstanceUid() const
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
339 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
340 return studyInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
341 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
342
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
343 const std::string& GetSeriesInstanceUid() const
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
344 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
345 return seriesInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
346 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
347 };
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
348
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
349
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
350 void Handle(const OrthancStone::ParseDicomSuccessMessage& message)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
351 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
352 const PdfInfo& info = dynamic_cast<const PdfInfo&>(message.GetOrigin().GetPayload());
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
353
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
354 if (observer_.get() != NULL)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
355 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
356 std::string pdf;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
357 if (message.GetDicom().ExtractPdf(pdf))
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
358 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
359 observer_->SignalSeriesPdfLoaded(info.GetStudyInstanceUid(), info.GetSeriesInstanceUid(), pdf);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
360 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
361 else
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
362 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
363 LOG(ERROR) << "Unable to extract PDF from series: " << info.GetSeriesInstanceUid();
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
364 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
365 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
366 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
367
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
368 void FetchInstanceThumbnail(const std::string& studyInstanceUid,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
369 const std::string& seriesInstanceUid,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
370 const std::string& sopInstanceUid)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
371 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
372 if (scheduledMultiframeInstances_.find(sopInstanceUid) == scheduledMultiframeInstances_.end())
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
373 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
374 scheduledMultiframeInstances_.insert(sopInstanceUid);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
375
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
376 std::map<std::string, std::string> arguments;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
377 std::map<std::string, std::string> headers;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
378 arguments["viewport"] = (
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
379 boost::lexical_cast<std::string>(thumbnailsLoader_->GetThumbnailWidth()) + "," +
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
380 boost::lexical_cast<std::string>(thumbnailsLoader_->GetThumbnailHeight()));
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
381 headers["Accept"] = Orthanc::MIME_JPEG;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
382
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
383 const std::string uri = ("studies/" + studyInstanceUid + "/series/" + seriesInstanceUid +
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
384 "/instances/" + sopInstanceUid + "/frames/1/rendered");
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
385
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
386 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
387 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock());
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
388 lock->Schedule(
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
389 GetSharedObserver(), PRIORITY_LOW + 2, source_.CreateDicomWebCommand(
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
390 uri, arguments, headers, new Orthanc::SingleValueObject<std::string>(sopInstanceUid)));
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
391 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
392 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
393 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
394
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
395 void HandleInstanceThumbnail(const OrthancStone::HttpCommand::SuccessMessage& message)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
396 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
397 if (observer_.get() != NULL)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
398 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
399 const std::string& sopInstanceUid =
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
400 dynamic_cast<const Orthanc::SingleValueObject<std::string>&>(
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
401 message.GetOrigin().GetPayload()).GetValue();
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
402 observer_->SignalMultiframeInstanceThumbnailLoaded(sopInstanceUid, message.GetAnswer());
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
403 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
404 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
405
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 static boost::shared_ptr<ResourcesLoader> Create(OrthancStone::ILoadersContext::ILock& lock,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 const OrthancStone::DicomSource& source)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 {
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
410 boost::shared_ptr<ResourcesLoader> loader(new ResourcesLoader(lock.GetContext(), source));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 loader->resourcesLoader_ = OrthancStone::DicomResourcesLoader::Create(lock);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 loader->thumbnailsLoader_ = OrthancStone::SeriesThumbnailsLoader::Create(lock, PRIORITY_LOW);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 loader->metadataLoader_ = OrthancStone::SeriesMetadataLoader::Create(lock);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 loader->Register<OrthancStone::DicomResourcesLoader::SuccessMessage>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 *loader->resourcesLoader_, &ResourcesLoader::Handle);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 loader->Register<OrthancStone::SeriesThumbnailsLoader::SuccessMessage>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 *loader->thumbnailsLoader_, &ResourcesLoader::Handle);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 loader->Register<OrthancStone::SeriesMetadataLoader::SuccessMessage>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 *loader->metadataLoader_, &ResourcesLoader::Handle);
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
424
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
425 loader->Register<OrthancStone::ParseDicomSuccessMessage>(
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
426 lock.GetOracleObservable(), &ResourcesLoader::Handle);
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
427
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
428 loader->Register<OrthancStone::HttpCommand::SuccessMessage>(
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
429 lock.GetOracleObservable(), &ResourcesLoader::HandleInstanceThumbnail);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
430
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 return loader;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 void FetchAllStudies()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 {
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
436 FetchInternal("", "", "");
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
437 }
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
438
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
439 void FetchPatient(const std::string& patientId)
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
440 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
441 if (!patientId.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
442 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
443 FetchInternal(patientId, "", "");
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
444 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 void FetchStudy(const std::string& studyInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 {
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
449 if (!studyInstanceUid.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
450 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
451 FetchInternal("", studyInstanceUid, "");
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
452 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 void FetchSeries(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 const std::string& seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 {
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
458 if (!studyInstanceUid.empty() &&
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
459 !seriesInstanceUid.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
460 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
461 FetchInternal("", studyInstanceUid, seriesInstanceUid);
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
462 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 size_t GetStudiesCount() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 return studies_->GetSize();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 size_t GetSeriesCount() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 return series_->GetSize();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 void GetStudy(Orthanc::DicomMap& target,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
476 size_t i) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 target.Assign(studies_->GetResource(i));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 void GetSeries(Orthanc::DicomMap& target,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
482 size_t i) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 target.Assign(series_->GetResource(i));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 // Complement with the study-level tags
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 std::string studyInstanceUid;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 if (target.LookupStringValue(studyInstanceUid, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 studies_->HasResource(studyInstanceUid))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 studies_->MergeResource(target, studyInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 OrthancStone::SeriesThumbnailType GetSeriesThumbnail(std::string& image,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 std::string& mime,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
497 const std::string& seriesInstanceUid) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 return thumbnailsLoader_->GetSeriesThumbnail(image, mime, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 void FetchSeriesMetadata(int priority,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 const std::string& studyInstanceUid,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
504 const std::string& seriesInstanceUid) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 metadataLoader_->ScheduleLoadSeries(priority, source_, studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
509 bool IsSeriesComplete(const std::string& seriesInstanceUid) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 return accessor.IsComplete();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
515 bool LookupMultiframeSeries(std::map<std::string, unsigned int>& numberOfFramesPerInstance,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
516 const std::string& seriesInstanceUid)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
517 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
518 numberOfFramesPerInstance.clear();
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
519
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
520 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
521 if (accessor.IsComplete() &&
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
522 accessor.GetInstancesCount() >= 2)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
523 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
524 bool isMultiframe = false;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
525
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
526 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
527 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
528 OrthancStone::DicomInstanceParameters p(accessor.GetInstance(i));
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
529 numberOfFramesPerInstance[p.GetSopInstanceUid()] = p.GetNumberOfFrames();
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
530
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
531 if (p.GetNumberOfFrames() > 1)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
532 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
533 isMultiframe = true;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
534 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
535 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
536
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
537 if (isMultiframe)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
538 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
539 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
540 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
541 OrthancStone::DicomInstanceParameters p(accessor.GetInstance(i));
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
542 FetchInstanceThumbnail(p.GetStudyInstanceUid(), p.GetSeriesInstanceUid(), p.GetSopInstanceUid());
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
543 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
544 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
545
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
546 return isMultiframe;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
547 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
548 else
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
549 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
550 return false;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
551 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
552 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
553
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 bool SortSeriesFrames(OrthancStone::SortedFrames& target,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
555 const std::string& seriesInstanceUid) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 if (accessor.IsComplete())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 target.Clear();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 target.AddInstance(accessor.GetInstance(i));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 target.Sort();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 return true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 return false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577
1704
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
578 bool SortMultipartInstanceFrames(OrthancStone::SortedFrames& target,
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
579 const std::string& seriesInstanceUid,
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
580 const std::string& sopInstanceUid) const
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
581 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
582 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
583
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
584 if (accessor.IsComplete())
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
585 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
586 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
587 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
588 std::string s;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
589 if (accessor.GetInstance(i).LookupStringValue(s, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false) &&
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
590 s == sopInstanceUid)
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
591 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
592 target.Clear();
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
593 target.AddInstance(accessor.GetInstance(i));
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
594 target.Sort();
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
595 return true;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
596 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
597 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
598
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
599 return true;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
600 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
601 else
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
602 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
603 return false;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
604 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
605 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
606
1674
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
607 size_t GetSeriesNumberOfFrames(const std::string& seriesInstanceUid) const
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
608 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
609 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
610
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
611 if (accessor.IsComplete())
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
612 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
613 size_t count = 0;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
614
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
615 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
616 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
617 uint32_t f;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
618 if (accessor.GetInstance(i).ParseUnsignedInteger32(f, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES))
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
619 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
620 count += f;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
621 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
622 else
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
623 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
624 count++;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
625 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
626 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
627
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
628 return count;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
629 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
630 else
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
631 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
632 return 0;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
633 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
634 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
635
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 void AcquireObserver(IObserver* observer)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 observer_.reset(observer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 }
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
640
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
641 void FetchPdf(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
642 const std::string& seriesInstanceUid)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
643 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
644 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
645
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
646 if (accessor.IsComplete())
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
647 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
648 if (accessor.GetInstancesCount() > 1)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
649 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
650 LOG(INFO) << "Series with more than one instance, will show the first PDF: "
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
651 << seriesInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
652 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
653
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
654 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
655 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
656 std::string sopClassUid, sopInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
657 if (accessor.GetInstance(i).LookupStringValue(sopClassUid, Orthanc::DICOM_TAG_SOP_CLASS_UID, false) &&
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
658 accessor.GetInstance(i).LookupStringValue(sopInstanceUid, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false) &&
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
659 sopClassUid == "1.2.840.10008.5.1.4.1.1.104.1")
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
660 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
661 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock());
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
662 lock->Schedule(
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
663 GetSharedObserver(), PRIORITY_NORMAL, OrthancStone::ParseDicomFromWadoCommand::Create(
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
664 source_, studyInstanceUid, seriesInstanceUid, sopInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
665 false /* no transcoding */, Orthanc::DicomTransferSyntax_LittleEndianExplicit /* dummy value */,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
666 new PdfInfo(studyInstanceUid, seriesInstanceUid)));
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
667
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
668 return;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
669 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
670 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
671
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
672 LOG(WARNING) << "Series without a PDF: " << seriesInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
673 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
674 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
675 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 class FramesCache : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 class CachedImage : public Orthanc::ICacheable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
683 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
684 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 std::unique_ptr<Orthanc::ImageAccessor> image_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 unsigned int quality_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689 CachedImage(Orthanc::ImageAccessor* image,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
690 unsigned int quality) :
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691 image_(image),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692 quality_(quality)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
694 assert(image != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
696
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1565
diff changeset
697 virtual size_t GetMemoryUsage() const ORTHANC_OVERRIDE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
699 assert(image_.get() != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
700 return (image_->GetBytesPerPixel() * image_->GetPitch() * image_->GetHeight());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
701 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
702
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
703 const Orthanc::ImageAccessor& GetImage() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
704 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705 assert(image_.get() != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706 return *image_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709 unsigned int GetQuality() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 return quality_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 static std::string GetKey(const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
717 size_t frameNumber)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718 {
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
719 return sopInstanceUid + "|" + boost::lexical_cast<std::string>(frameNumber);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 Orthanc::MemoryObjectCache cache_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726 FramesCache()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728 SetMaximumSize(100 * 1024 * 1024); // 100 MB
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
729 //SetMaximumSize(1); // DISABLE CACHE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 size_t GetMaximumSize()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734 return cache_.GetMaximumSize();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
735 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737 void SetMaximumSize(size_t size)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
738 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739 cache_.SetMaximumSize(size);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
740 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
741
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 * Returns "true" iff the provided image has better quality than the
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744 * previously cached one, or if no cache was previously available.
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 bool Acquire(const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
747 size_t frameNumber,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748 Orthanc::ImageAccessor* image /* transfer ownership */,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 unsigned int quality)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 std::unique_ptr<Orthanc::ImageAccessor> protection(image);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 if (image == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 else if (image->GetFormat() != Orthanc::PixelFormat_Float32 &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 image->GetFormat() != Orthanc::PixelFormat_RGB24)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
763 const std::string& key = GetKey(sopInstanceUid, frameNumber);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765 bool invalidate = false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
767 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
768 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769 * Access the previous cached entry, with side effect of tagging
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770 * it as the most recently accessed frame (update of LRU recycling)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
772 Orthanc::MemoryObjectCache::Accessor accessor(cache_, key, false /* unique lock */);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774 if (accessor.IsValid())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776 const CachedImage& previous = dynamic_cast<const CachedImage&>(accessor.GetValue());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 // There is already a cached image for this frame
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779 if (previous.GetQuality() < quality)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 // The previously stored image has poorer quality
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782 invalidate = true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
783 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
784 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786 // No update in the quality, don't change the cache
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787 return false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792 invalidate = false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796 if (invalidate)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 cache_.Invalidate(key);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801 cache_.Acquire(key, new CachedImage(protection.release(), quality));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802 return true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
804
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 class Accessor : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
807 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 Orthanc::MemoryObjectCache::Accessor accessor_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810 const CachedImage& GetCachedImage() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 if (IsValid())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 return dynamic_cast<CachedImage&>(accessor_.GetValue());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
816 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823 Accessor(FramesCache& that,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824 const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
825 size_t frameNumber) :
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
826 accessor_(that.cache_, GetKey(sopInstanceUid, frameNumber), false /* shared lock */)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
827 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 bool IsValid() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832 return accessor_.IsValid();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 const Orthanc::ImageAccessor& GetImage() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
837 return GetCachedImage().GetImage();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
838 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
839
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840 unsigned int GetQuality() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842 return GetCachedImage().GetQuality();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
847
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
849 class SeriesCursor : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852 enum Action
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854 Action_FastPlus,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 Action_Plus,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 Action_None,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857 Action_Minus,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
858 Action_FastMinus
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
861 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862 std::vector<size_t> prefetch_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
863 int framesCount_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
864 int currentFrame_;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
865 bool isCircularPrefetch_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
866 int fastDelta_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 Action lastAction_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
868
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
869 int ComputeNextFrame(int currentFrame,
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
870 Action action,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
871 bool isCircular) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
873 if (framesCount_ == 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
874 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875 assert(currentFrame == 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
876 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
877 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
879 int nextFrame = currentFrame;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
880
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
881 switch (action)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
882 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
883 case Action_FastPlus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
884 nextFrame += fastDelta_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
885 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
886
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
887 case Action_Plus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
888 nextFrame += 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
889 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
890
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891 case Action_None:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
892 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894 case Action_Minus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 nextFrame -= 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 case Action_FastMinus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899 nextFrame -= fastDelta_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
902 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
903 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
904 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
906 if (isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
907 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
908 while (nextFrame < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
909 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
910 nextFrame += framesCount_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
912
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913 while (nextFrame >= framesCount_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915 nextFrame -= framesCount_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
916 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
917 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920 if (nextFrame < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
921 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922 nextFrame = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
923 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
924 else if (nextFrame >= framesCount_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
925 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
926 nextFrame = framesCount_ - 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
929
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
930 return nextFrame;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
931 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
932
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
933 void UpdatePrefetch()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936 * This method will order the frames of the series according to
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937 * the number of "actions" (i.e. mouse wheels) that are necessary
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
938 * to reach them, starting from the current frame. It is assumed
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
939 * that once one action is done, it is more likely that the user
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940 * will do the same action just afterwards.
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943 prefetch_.clear();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945 if (framesCount_ == 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947 return;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
948 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 prefetch_.reserve(framesCount_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
951
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
952 // Breadth-first search using a FIFO. The queue associates a frame
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
953 // and the action that is the most likely in this frame
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
954 typedef std::list< std::pair<int, Action> > Queue;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
955
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956 Queue queue;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
957 std::set<int> visited; // Frames that have already been visited
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
959 queue.push_back(std::make_pair(currentFrame_, lastAction_));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 while (!queue.empty())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963 int frame = queue.front().first;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964 Action previousAction = queue.front().second;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965 queue.pop_front();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
966
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
967 if (visited.find(frame) == visited.end())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
968 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
969 visited.insert(frame);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
970 prefetch_.push_back(frame);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
971
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
972 switch (previousAction)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
973 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
974 case Action_None:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
975 case Action_Plus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
976 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_Plus, isCircularPrefetch_), Action_Plus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
977 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_Minus, isCircularPrefetch_), Action_Minus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
978 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_FastPlus, isCircularPrefetch_), Action_FastPlus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
979 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_FastMinus, isCircularPrefetch_), Action_FastMinus));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
980 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
981
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
982 case Action_Minus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
983 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_Minus, isCircularPrefetch_), Action_Minus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
984 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_Plus, isCircularPrefetch_), Action_Plus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
985 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_FastMinus, isCircularPrefetch_), Action_FastMinus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
986 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_FastPlus, isCircularPrefetch_), Action_FastPlus));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
987 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
988
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
989 case Action_FastPlus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
990 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_FastPlus, isCircularPrefetch_), Action_FastPlus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
991 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_FastMinus, isCircularPrefetch_), Action_FastMinus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
992 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_Plus, isCircularPrefetch_), Action_Plus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
993 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_Minus, isCircularPrefetch_), Action_Minus));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
994 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
995
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
996 case Action_FastMinus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
997 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_FastMinus, isCircularPrefetch_), Action_FastMinus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
998 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_FastPlus, isCircularPrefetch_), Action_FastPlus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
999 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_Minus, isCircularPrefetch_), Action_Minus));
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1000 queue.push_back(std::make_pair(ComputeNextFrame(frame, Action_Plus, isCircularPrefetch_), Action_Plus));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1001 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1002
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1003 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1004 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1005 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1006 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1007 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1008
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1009 assert(prefetch_.size() == framesCount_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1010 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1011
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1012 bool CheckFrameIndex(int frame) const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1013 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1014 return ((framesCount_ == 0 && frame == 0) ||
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1015 (framesCount_ > 0 && frame >= 0 && frame < framesCount_));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1016 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1017
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1018 public:
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1565
diff changeset
1019 explicit SeriesCursor(size_t framesCount) :
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1020 framesCount_(framesCount),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021 currentFrame_(framesCount / 2), // Start at the middle frame
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1022 isCircularPrefetch_(false),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1023 lastAction_(Action_None)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1024 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 SetFastDelta(framesCount / 20);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1027 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028
1719
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1029 size_t GetFramesCount() const
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1030 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1031 return framesCount_;
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1032 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1033
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1034 void SetCircularPrefetch(bool isCircularPrefetch)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1035 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1036 isCircularPrefetch_ = isCircularPrefetch;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040 void SetFastDelta(int delta)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1041 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1042 fastDelta_ = (delta < 0 ? -delta : delta);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1043
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1044 if (fastDelta_ <= 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1045 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1046 fastDelta_ = 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1047 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1048 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1049
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1050 void SetCurrentIndex(size_t frame)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1051 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052 if (frame >= framesCount_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1055 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1056 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1057 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1058 currentFrame_ = frame;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1059 lastAction_ = Action_None;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1060 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1062 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1063
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064 size_t GetCurrentIndex() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 assert(CheckFrameIndex(currentFrame_));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067 return static_cast<size_t>(currentFrame_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1068 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1069
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1070 void Apply(Action action,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1071 bool isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1072 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1073 currentFrame_ = ComputeNextFrame(currentFrame_, action, isCircular);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1074 lastAction_ = action;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1075 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1076 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1077
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1078 size_t GetPrefetchSize() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1079 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1080 assert(prefetch_.size() == framesCount_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1081 return prefetch_.size();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1082 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1083
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1084 size_t GetPrefetchIndex(size_t i) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1085 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1086 if (i >= prefetch_.size())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1087 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1088 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1089 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1090 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1092 assert(CheckFrameIndex(prefetch_[i]));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1093 return static_cast<size_t>(prefetch_[i]);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1094 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1096 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1097
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1098
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1099
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1100
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
1101 /**
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
1102 * Returns a clipped line (out: x1, y1, x2, y2), in the coordinate
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
1103 * system of "instance1". Note that the frame of reference UID is not
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
1104 * checked by this function.
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
1105 **/
1646
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1106 static bool GetReferenceLineCoordinates(double& x1,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1107 double& y1,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1108 double& x2,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1109 double& y2,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1110 const OrthancStone::DicomInstanceParameters& instance1,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1111 unsigned int frame1,
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1112 const OrthancStone::CoordinateSystem3D& plane2)
1646
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1113 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1114 if (instance1.GetWidth() == 0 &&
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1115 instance1.GetHeight() == 0)
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1116 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1117 return false;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1118 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1119 else
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1120 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1121 /**
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1122 * Compute the 2D extent of the "instance1", expressed in
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1123 * centimeters, in the 2D plane defined by this DICOM instance.
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1124 *
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1125 * In a multiframe image (cf. "ExtractFrameOffsets()"), the plane of
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1126 * each frame is a translation of the plane of the first frame along
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1127 * its normal. As a consequence, the extent is the same for each
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1128 * frame, so we can ignore the frame number.
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1129 **/
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1130 OrthancStone::Extent2D extent;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1131
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1132 double ox = -instance1.GetPixelSpacingX() / 2.0;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1133 double oy = -instance1.GetPixelSpacingY() / 2.0;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1134 extent.AddPoint(ox, oy);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1135 extent.AddPoint(ox + instance1.GetPixelSpacingX() * static_cast<double>(instance1.GetWidth()),
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1136 oy + instance1.GetPixelSpacingY() * static_cast<double>(instance1.GetHeight()));
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1137
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1138 const OrthancStone::CoordinateSystem3D c1 = instance1.GetFrameGeometry(frame1);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1139
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1140 OrthancStone::Vector direction, origin;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1141
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1142 if (!extent.IsEmpty() &&
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1143 OrthancStone::GeometryToolbox::IntersectTwoPlanes(origin, direction,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1144 c1.GetOrigin(), c1.GetNormal(),
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1145 plane2.GetOrigin(), plane2.GetNormal()))
1646
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1146 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1147 double ax, ay, bx, by;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1148 c1.ProjectPoint(ax, ay, origin);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1149 c1.ProjectPoint(bx, by, origin + 100.0 * direction);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1150
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1151 return OrthancStone::GeometryToolbox::ClipLineToRectangle(
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1152 x1, y1, x2, y2,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1153 ax, ay, bx, by,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1154 extent.GetX1(), extent.GetY1(), extent.GetX2(), extent.GetY2());
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1155 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1156 else
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1157 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1158 return false;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1159 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1160 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1161 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1162
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1163
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1164
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1165 class ViewerViewport : public OrthancStone::ObserverBase<ViewerViewport>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1166 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1167 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1168 class IObserver : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1169 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1170 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1171 virtual ~IObserver()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1172 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1173 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1174
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1175 virtual void SignalSeriesDetailsReady(const ViewerViewport& viewport) = 0;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1176
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1177 virtual void SignalFrameUpdated(const ViewerViewport& viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1178 size_t currentFrame,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1179 size_t countFrames,
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1180 DisplayedFrameQuality quality,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1181 unsigned int instanceNumber) = 0;
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
1182
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1183 virtual void SignalCrosshair(const ViewerViewport& viewport,
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1184 const OrthancStone::Vector& click) = 0;
1694
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
1185
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
1186 virtual void SignalSynchronizedBrowsing(const ViewerViewport& viewport,
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
1187 const OrthancStone::Vector& click,
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
1188 const OrthancStone::Vector& normal) = 0;
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1189
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1190 virtual void SignalWindowingUpdated(const ViewerViewport& viewport,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1191 double windowingCenter,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1192 double windowingWidth) = 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1193 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1194
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1195 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1196 static const int LAYER_TEXTURE = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1197 static const int LAYER_REFERENCE_LINES = 1;
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1198 static const int LAYER_ANNOTATIONS = 2;
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1607
diff changeset
1199
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1200
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1201 class ICommand : public Orthanc::IDynamicObject
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1202 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1203 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1204 boost::shared_ptr<ViewerViewport> viewport_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1205
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1206 public:
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1565
diff changeset
1207 explicit ICommand(boost::shared_ptr<ViewerViewport> viewport) :
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1208 viewport_(viewport)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1209 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1210 if (viewport == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1211 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1212 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1213 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1214 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1215
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1216 virtual ~ICommand()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1217 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1218 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1219
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1220 ViewerViewport& GetViewport() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1221 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1222 assert(viewport_ != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1223 return *viewport_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1224 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1225
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1226 virtual void Handle(const OrthancStone::DicomResourcesLoader::SuccessMessage& message) const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1227 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1228 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1229 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1230
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1231 virtual void Handle(const OrthancStone::HttpCommand::SuccessMessage& message) const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1232 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1233 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1234 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1235
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1236 virtual void Handle(const OrthancStone::ParseDicomSuccessMessage& message) const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1237 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1238 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1239 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1240 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1241
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1242 class LoadSeriesDetailsFromInstance : public ICommand
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1243 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1244 public:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1245 explicit LoadSeriesDetailsFromInstance(boost::shared_ptr<ViewerViewport> viewport) :
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1246 ICommand(viewport)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1247 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1248 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1249
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1250 virtual void Handle(const OrthancStone::DicomResourcesLoader::SuccessMessage& message) const ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1251 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1252 if (message.GetResources()->GetSize() != 1)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1253 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1254 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1255 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1256
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1257 const Orthanc::DicomMap& dicom = message.GetResources()->GetResource(0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1258
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1259 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1260 OrthancStone::DicomInstanceParameters params(dicom);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1261
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1262 GetViewport().windowingPresetCenters_.resize(params.GetWindowingPresetsCount());
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1263 GetViewport().windowingPresetWidths_.resize(params.GetWindowingPresetsCount());
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1264
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1265 for (size_t i = 0; i < params.GetWindowingPresetsCount(); i++)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1266 {
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1267 LOG(INFO) << "Preset windowing " << (i + 1) << "/" << params.GetWindowingPresetsCount()
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1268 << ": " << params.GetWindowingPresetCenter(i)
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1269 << "," << params.GetWindowingPresetWidth(i);
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1270
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1271 GetViewport().windowingPresetCenters_[i] = params.GetWindowingPresetCenter(i);
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1272 GetViewport().windowingPresetWidths_[i] = params.GetWindowingPresetWidth(i);
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1273 }
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1274
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1275 if (params.GetWindowingPresetsCount() == 0)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1276 {
1677
51bab5188a13 start multiple preset windowings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1676
diff changeset
1277 LOG(INFO) << "No preset windowing";
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1278 }
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1279
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1280 GetViewport().SetWindowingPreset();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1281 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1282
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1283 uint32_t cineRate;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1284 if (dicom.ParseUnsignedInteger32(cineRate, Orthanc::DICOM_TAG_CINE_RATE) &&
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1285 cineRate > 0)
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1286 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1287 /**
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1288 * If we detect a cine sequence, start on the first frame
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1289 * instead of on the middle frame.
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1290 **/
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1291 GetViewport().cursor_->SetCurrentIndex(0);
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1292 GetViewport().cineRate_ = cineRate;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1293 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1294 else
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1295 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1296 GetViewport().cineRate_ = DEFAULT_CINE_RATE;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1297 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1298
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1299 GetViewport().Redraw();
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1300
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1301 if (GetViewport().observer_.get() != NULL)
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1302 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1303 GetViewport().observer_->SignalSeriesDetailsReady(GetViewport());
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1304 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1305 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1306 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1307
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1308
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1309 class SetLowQualityFrame : public ICommand
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1310 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1311 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1312 std::string sopInstanceUid_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1313 unsigned int frameNumber_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1314 float windowCenter_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1315 float windowWidth_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1316 bool isMonochrome1_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1317 bool isPrefetch_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1318
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1319 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1320 SetLowQualityFrame(boost::shared_ptr<ViewerViewport> viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1321 const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1322 unsigned int frameNumber,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1323 float windowCenter,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1324 float windowWidth,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1325 bool isMonochrome1,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1326 bool isPrefetch) :
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1327 ICommand(viewport),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1328 sopInstanceUid_(sopInstanceUid),
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1329 frameNumber_(frameNumber),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1330 windowCenter_(windowCenter),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1331 windowWidth_(windowWidth),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1332 isMonochrome1_(isMonochrome1),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1333 isPrefetch_(isPrefetch)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1334 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1335 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1336
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1337 virtual void Handle(const OrthancStone::HttpCommand::SuccessMessage& message) const ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1338 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1339 std::unique_ptr<Orthanc::JpegReader> jpeg(new Orthanc::JpegReader);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1340 jpeg->ReadFromMemory(message.GetAnswer());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1341
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1342 std::unique_ptr<Orthanc::ImageAccessor> converted;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1343
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1344 switch (jpeg->GetFormat())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1345 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1346 case Orthanc::PixelFormat_RGB24:
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1347 converted.reset(jpeg.release());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1348 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1349
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1350 case Orthanc::PixelFormat_Grayscale8:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1351 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1352 if (isMonochrome1_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1353 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1354 Orthanc::ImageProcessing::Invert(*jpeg);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1355 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1356
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1357 converted.reset(new Orthanc::Image(Orthanc::PixelFormat_Float32, jpeg->GetWidth(),
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1358 jpeg->GetHeight(), false));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1359
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1360 Orthanc::ImageProcessing::Convert(*converted, *jpeg);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1361
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1362 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1363
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1364 Orthanc::ImageProcessing::ShiftScale() computes "(x + offset) * scaling".
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1365 The system to solve is thus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1366
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1367 (0 + offset) * scaling = windowingCenter - windowingWidth / 2 [a]
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1368 (255 + offset) * scaling = windowingCenter + windowingWidth / 2 [b]
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1369
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1370 Resolution:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1371
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1372 [b - a] => 255 * scaling = windowingWidth
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1373 [a] => offset = (windowingCenter - windowingWidth / 2) / scaling
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1374
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1375 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1376
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1377 const float scaling = windowWidth_ / 255.0f;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1378 const float offset = (OrthancStone::LinearAlgebra::IsCloseToZero(scaling) ? 0 :
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1379 (windowCenter_ - windowWidth_ / 2.0f) / scaling);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1380
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1381 Orthanc::ImageProcessing::ShiftScale(*converted, offset, scaling, false);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1382 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1383 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1384
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1385 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1386 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1387 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1388
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1389 assert(converted.get() != NULL);
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1390 GetViewport().RenderCurrentSceneFromCommand(*converted, sopInstanceUid_, frameNumber_, DisplayedFrameQuality_Low);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1391 GetViewport().framesCache_->Acquire(sopInstanceUid_, frameNumber_, converted.release(), QUALITY_JPEG);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1392
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1393 if (isPrefetch_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1394 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1395 GetViewport().ScheduleNextPrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1396 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1397 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1398 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1399
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1400
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1401 class SetFullDicomFrame : public ICommand
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1402 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1403 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1404 std::string sopInstanceUid_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1405 unsigned int frameNumber_;
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1406 int priority_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1407 bool isPrefetch_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1408
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1409 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1410 SetFullDicomFrame(boost::shared_ptr<ViewerViewport> viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1411 const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1412 unsigned int frameNumber,
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1413 int priority,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1414 bool isPrefetch) :
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1415 ICommand(viewport),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1416 sopInstanceUid_(sopInstanceUid),
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1417 frameNumber_(frameNumber),
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1418 priority_(priority),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1419 isPrefetch_(isPrefetch)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1420 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1421 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1422
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1423 virtual void Handle(const OrthancStone::ParseDicomSuccessMessage& message) const ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1424 {
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1425 Apply(GetViewport(), message.GetDicom(), sopInstanceUid_, frameNumber_, priority_, isPrefetch_);
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1426
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1427 if (isPrefetch_)
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1428 {
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1429 GetViewport().ScheduleNextPrefetch();
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1430 }
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1431 }
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1432
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1433 static void Apply(ViewerViewport& viewport,
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1434 const Orthanc::ParsedDicomFile& dicom,
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1435 const std::string& sopInstanceUid,
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1436 unsigned int frameNumber,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1437 int priority,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1438 bool isPrefetch)
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1439 {
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1440 Orthanc::DicomMap tags;
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1441 dicom.ExtractDicomSummary(tags, ORTHANC_STONE_MAX_TAG_LENGTH);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1442
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1443 std::string s;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1444 if (!tags.LookupStringValue(s, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1445 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1446 // Safety check
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1447 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1448 }
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1449
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1450 std::unique_ptr<Orthanc::ImageAccessor> frame;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1451
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1452 try
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1453 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1454 frame.reset(dicom.DecodeFrame(frameNumber));
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1455 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1456 catch (Orthanc::OrthancException& e)
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1457 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1458 if (e.GetErrorCode() == Orthanc::ErrorCode_NotImplemented)
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1459 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1460 viewport.serverSideTranscoding_ = true;
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1461 LOG(INFO) << "Switching to server-side transcoding";
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1462 viewport.ScheduleLoadFullDicomFrame(sopInstanceUid, frameNumber, priority, isPrefetch);
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1463 return;
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1464 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1465 else
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1466 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1467 throw;
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1468 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1469 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1470
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1471 if (frame.get() == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1472 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1473 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1474 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1475
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1476 std::unique_ptr<Orthanc::ImageAccessor> converted;
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1477
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1478 if (frame->GetFormat() == Orthanc::PixelFormat_RGB24)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1479 {
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1480 converted.reset(frame.release());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1481 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1482 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1483 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1484 double a = 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1485 double b = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1486
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1487 double doseScaling;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1488 if (tags.ParseDouble(doseScaling, Orthanc::DICOM_TAG_DOSE_GRID_SCALING))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1489 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1490 a = doseScaling;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1491 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1492
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1493 double rescaleIntercept, rescaleSlope;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1494 if (tags.ParseDouble(rescaleIntercept, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1495 tags.ParseDouble(rescaleSlope, Orthanc::DICOM_TAG_RESCALE_SLOPE))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1496 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1497 a *= rescaleSlope;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1498 b = rescaleIntercept;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1499 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1500
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1501 converted.reset(new Orthanc::Image(Orthanc::PixelFormat_Float32, frame->GetWidth(), frame->GetHeight(), false));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1502 Orthanc::ImageProcessing::Convert(*converted, *frame);
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1503 Orthanc::ImageProcessing::ShiftScale2(*converted, b, a, false);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1504 }
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1505
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1506 assert(converted.get() != NULL);
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1507 viewport.RenderCurrentSceneFromCommand(*converted, sopInstanceUid, frameNumber, DisplayedFrameQuality_High);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1508 viewport.framesCache_->Acquire(sopInstanceUid, frameNumber, converted.release(), QUALITY_FULL);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1509 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1510 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1511
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1512
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1513 class PrefetchItem
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1514 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1515 private:
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1516 size_t cursorIndex_;
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1517 bool isFullQuality_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1518
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1519 public:
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1520 PrefetchItem(size_t cursorIndex,
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1521 bool isFullQuality) :
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1522 cursorIndex_(cursorIndex),
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1523 isFullQuality_(isFullQuality)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1524 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1525 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1526
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1527 size_t GetCursorIndex() const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1528 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1529 return cursorIndex_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1530 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1531
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1532 bool IsFullQuality() const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1533 {
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1534 return isFullQuality_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1535 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1536 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1537
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1538
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1539 std::unique_ptr<IObserver> observer_;
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1540 OrthancStone::WebAssemblyLoadersContext& context_;
1551
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
1541 boost::shared_ptr<OrthancStone::WebAssemblyViewport> viewport_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1542 boost::shared_ptr<OrthancStone::DicomResourcesLoader> loader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1543 OrthancStone::DicomSource source_;
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1544 boost::shared_ptr<FramesCache> framesCache_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1545 std::unique_ptr<OrthancStone::SortedFrames> frames_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1546 std::unique_ptr<SeriesCursor> cursor_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1547 float windowingCenter_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1548 float windowingWidth_;
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1549 std::vector<float> windowingPresetCenters_;
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1550 std::vector<float> windowingPresetWidths_;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1551 unsigned int cineRate_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1552 bool inverted_;
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1553 bool flipX_;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1554 bool flipY_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1555 bool fitNextContent_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1556 std::list<PrefetchItem> prefetchQueue_;
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1557 bool serverSideTranscoding_;
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1558 OrthancStone::Vector synchronizationOffset_;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1559 bool synchronizationEnabled_;
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1560 double centralPhysicalWidth_; // LSD-479
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1561 double centralPhysicalHeight_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1562
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1563 bool hasFocusOnInstance_;
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1564 std::string focusSopInstanceUid_;
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1565 size_t focusFrameNumber_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1566
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1567 boost::shared_ptr<OrthancStone::OsiriX::CollectionOfAnnotations> annotations_;
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1568
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1569 void ScheduleNextPrefetch()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1570 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1571 while (!prefetchQueue_.empty())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1572 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1573 size_t cursorIndex = prefetchQueue_.front().GetCursorIndex();
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1574 bool isFullQuality = prefetchQueue_.front().IsFullQuality();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1575 prefetchQueue_.pop_front();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1576
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1577 const std::string sopInstanceUid = frames_->GetInstanceOfFrame(cursorIndex).GetSopInstanceUid();
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1578 unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1579
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1580 {
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1581 FramesCache::Accessor accessor(*framesCache_, sopInstanceUid, frameNumber);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1582 if (!accessor.IsValid() ||
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1583 (isFullQuality && accessor.GetQuality() == 0))
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1584 {
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1585 if (isFullQuality)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1586 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1587 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_NORMAL, true);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1588 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1589 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1590 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1591 ScheduleLoadRenderedFrame(cursorIndex, PRIORITY_NORMAL, true);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1592 }
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1593
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1594 return; // We have found a new frame to cache, stop the lookup loop
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1595 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1596 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1597 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1598 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1599
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1600
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1601 void ClearViewport()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1602 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1603 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1604 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1605 lock->GetController().GetScene().DeleteLayer(LAYER_TEXTURE);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1606 //lock->GetCompositor().Refresh(lock->GetController().GetScene());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1607 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1608 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1609 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1610
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1611
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1612 /**
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1613 * NB: "frame" is only used to estimate the memory size to store 1
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1614 * frame, in order to avoid prefetching too much data.
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1615 **/
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1616 void SetupPrefetchAfterRendering(const Orthanc::ImageAccessor& frame,
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1617 DisplayedFrameQuality quality)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1618 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1619 const size_t cursorIndex = cursor_->GetCurrentIndex();
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1620
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1621 // Prepare prefetching
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1622 prefetchQueue_.clear();
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1623
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1624 if (1) // DISABLE PREFETCHING
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1625 {
1680
03afa09cfcf1 running the tests of the Orthanc Framework in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1679
diff changeset
1626 const size_t frameSize = frame.GetPitch() * frame.GetHeight();
03afa09cfcf1 running the tests of the Orthanc Framework in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1679
diff changeset
1627 size_t prefetchedSize = 0;
03afa09cfcf1 running the tests of the Orthanc Framework in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1679
diff changeset
1628
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1629 for (size_t i = 0; i < cursor_->GetPrefetchSize() && i < 16 &&
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1630 prefetchedSize <= framesCache_->GetMaximumSize() / 2; i++)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1631 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1632 size_t a = cursor_->GetPrefetchIndex(i);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1633 if (a != cursorIndex)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1634 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1635 prefetchQueue_.push_back(PrefetchItem(a, i < 2));
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1636 prefetchedSize += frameSize;
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1637 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1638 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1639 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1640
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1641 ScheduleNextPrefetch();
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1642
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1643 if (frames_.get() != NULL &&
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1644 cursor_.get() != NULL &&
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1645 observer_.get() != NULL)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1646 {
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1647 const Orthanc::DicomMap& instance = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()).GetTags();
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1648
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1649 uint32_t instanceNumber;
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1650 if (!instance.ParseUnsignedInteger32(instanceNumber, Orthanc::DICOM_TAG_INSTANCE_NUMBER))
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1651 {
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1652 instanceNumber = 0;
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1653 }
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1654
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1655 observer_->SignalFrameUpdated(*this, cursorIndex, frames_->GetFramesCount(), quality, instanceNumber);
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1656 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1657 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1658
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1659
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1660 void RenderCurrentScene(const Orthanc::ImageAccessor& frame,
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1661 const OrthancStone::DicomInstanceParameters& instance,
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1662 const OrthancStone::CoordinateSystem3D& plane)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1663 {
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1664 /**
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1665 * IMPORTANT - DO NOT use "instance.GetWidth()" and
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1666 * "instance.GetHeight()" in this method. Use the information from
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1667 * "frame" instead. Indeed, the "instance" information is taken
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1668 * from DICOMweb "/studies/.../series/.../metadata". But,
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1669 * "SeriesMetadataExtrapolatedTags" includes the "Columns" and
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1670 * "Rows" DICOM tags for performance, which make this information
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1671 * unreliable if the series includes instances with varying sizes
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1672 * (cf. LSD-479).
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1673 **/
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1674
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1675 bool isMonochrome1 = (instance.GetImageInformation().GetPhotometricInterpretation() ==
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1676 Orthanc::PhotometricInterpretation_Monochrome1);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1677
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1678 std::unique_ptr<OrthancStone::TextureBaseSceneLayer> layer;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1679
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1680 switch (frame.GetFormat())
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1681 {
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1682 case Orthanc::PixelFormat_RGB24:
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1683 layer.reset(new OrthancStone::ColorTextureSceneLayer(frame));
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1684 break;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1685
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1686 case Orthanc::PixelFormat_Float32:
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1687 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1688 std::unique_ptr<OrthancStone::FloatTextureSceneLayer> tmp(
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1689 new OrthancStone::FloatTextureSceneLayer(frame));
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1690 tmp->SetCustomWindowing(windowingCenter_, windowingWidth_);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1691 tmp->SetInverted(inverted_ ^ isMonochrome1);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1692 layer.reset(tmp.release());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1693 break;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1694 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1695
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1696 default:
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1697 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1698 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1699
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1700 assert(layer.get() != NULL);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1701
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1702 layer->SetLinearInterpolation(true);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1703 layer->SetFlipX(flipX_);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1704 layer->SetFlipY(flipY_);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1705
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1706 double pixelSpacingX, pixelSpacingY;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1707 OrthancStone::GeometryToolbox::GetPixelSpacing(pixelSpacingX, pixelSpacingY, instance.GetTags());
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1708
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1709 if (FIX_LSD_479)
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1710 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1711 /**
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1712 * Some series contain a first instance (secondary capture) that
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1713 * is completely different from others wrt. to resolution and
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1714 * pixel spacing. We make sure to rescale each frame to fit in a
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1715 * square that corresponds to the extent of the frame in the
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1716 * middle of the series.
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1717 **/
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1718 double physicalWidth = pixelSpacingX * static_cast<double>(frame.GetWidth());
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1719 double physicalHeight = pixelSpacingY * static_cast<double>(frame.GetHeight());
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1720
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1721 if (OrthancStone::LinearAlgebra::IsCloseToZero(physicalWidth) ||
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1722 OrthancStone::LinearAlgebra::IsCloseToZero(physicalHeight))
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1723 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1724 // Numerical instability, don't try further processing
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1725 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1726 }
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1727 else
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1728 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1729 double scale = std::max(centralPhysicalWidth_ / physicalWidth,
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1730 centralPhysicalHeight_ / physicalHeight);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1731 layer->SetPixelSpacing(pixelSpacingX * scale, pixelSpacingY * scale);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1732 layer->SetOrigin((centralPhysicalWidth_ - physicalWidth * scale) / 2.0,
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1733 (centralPhysicalHeight_ - physicalHeight * scale) / 2.0);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1734 }
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1735 }
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1736 else
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1737 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1738 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1739 }
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1740
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1741 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsLayer;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1742
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1743 if (annotations_)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1744 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1745 std::set<size_t> a;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1746 annotations_->LookupSopInstanceUid(a, instance.GetSopInstanceUid());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1747 if (plane.IsValid() &&
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1748 !a.empty())
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1749 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1750 annotationsLayer.reset(new OrthancStone::MacroSceneLayer);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1751 annotationsLayer->Reserve(a.size());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1752
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1753 OrthancStone::OsiriXLayerFactory factory;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1754 factory.SetColor(0, 255, 0);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1755
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1756 for (std::set<size_t>::const_iterator it = a.begin(); it != a.end(); ++it)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1757 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1758 const OrthancStone::OsiriX::Annotation& annotation = annotations_->GetAnnotation(*it);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1759 annotationsLayer->AddLayer(factory.Create(annotation, plane));
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1760 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1761 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1762 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1763
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1764 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1765
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1766 OrthancStone::Scene2D& scene = lock->GetController().GetScene();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1767
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1768 scene.SetLayer(LAYER_TEXTURE, layer.release());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1769
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1770 if (annotationsLayer.get() != NULL)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1771 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1772 scene.SetLayer(LAYER_ANNOTATIONS, annotationsLayer.release());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1773 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1774 else
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1775 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1776 scene.DeleteLayer(LAYER_ANNOTATIONS);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1777 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1778
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1779 if (fitNextContent_)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1780 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1781 lock->RefreshCanvasSize();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1782 lock->GetCompositor().FitContent(scene);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1783 fitNextContent_ = false;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1784 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1785
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1786 //lock->GetCompositor().Refresh(scene);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1787 lock->Invalidate();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1788 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1789
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1790
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1791 void RenderCurrentSceneFromCommand(const Orthanc::ImageAccessor& frame,
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1792 const std::string& loadedSopInstanceUid,
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1793 unsigned int loadedFrameNumber,
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1794 DisplayedFrameQuality quality)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1795 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1796 if (cursor_.get() != NULL &&
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1797 frames_.get() != NULL)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1798 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1799 const size_t cursorIndex = cursor_->GetCurrentIndex();
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1800 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1801 const size_t frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1802
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1803 // Only change the scene if the loaded frame still corresponds to the current cursor
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1804 if (instance.GetSopInstanceUid() == loadedSopInstanceUid &&
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1805 frameNumber == loadedFrameNumber)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1806 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1807 const OrthancStone::CoordinateSystem3D plane = frames_->GetFrameGeometry(cursorIndex);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1808
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1809 if (quality == DisplayedFrameQuality_Low)
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1810 {
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1811 FramesCache::Accessor accessor(*framesCache_, instance.GetSopInstanceUid(), frameNumber);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1812 if (accessor.IsValid() &&
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1813 accessor.GetQuality() == QUALITY_FULL)
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1814 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1815 // A high-res image was downloaded in between: Use this cached image instead of the low-res
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1816 RenderCurrentScene(accessor.GetImage(), instance, plane);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1817 SetupPrefetchAfterRendering(frame, DisplayedFrameQuality_High);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1818 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1819 else
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1820 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1821 // This frame is only available in low-res: Download the full DICOM
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1822 RenderCurrentScene(frame, instance, plane);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1823 SetupPrefetchAfterRendering(frame, quality);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1824
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1825 /**
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1826 * The command "SetupPrefetchAfterRendering()" must be
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1827 * after "SetupPrefetchAfterRendering(quality)", as the
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1828 * DICOM instance might already be cached by the oracle,
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1829 * which makes a call to "observer_->SignalFrameUpdated()"
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1830 * with a low quality, whereas the high quality is
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1831 * available.
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1832 **/
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1833 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1834 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1835 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1836 else
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1837 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1838 assert(quality == DisplayedFrameQuality_High);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1839 SetupPrefetchAfterRendering(frame, quality);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1840 RenderCurrentScene(frame, instance, plane);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1841 }
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1842 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1843 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1844 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1845
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1846 void ScheduleLoadFullDicomFrame(const std::string& sopInstanceUid,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1847 unsigned int frameNumber,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1848 int priority,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1849 bool isPrefetch)
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1850 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1851 if (frames_.get() != NULL)
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1852 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1853 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock());
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1854 lock->Schedule(
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1855 GetSharedObserver(), priority, OrthancStone::ParseDicomFromWadoCommand::Create(
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1856 source_, frames_->GetStudyInstanceUid(), frames_->GetSeriesInstanceUid(),
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1857 sopInstanceUid, serverSideTranscoding_,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1858 Orthanc::DicomTransferSyntax_LittleEndianExplicit,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1859 new SetFullDicomFrame(GetSharedObserver(), sopInstanceUid, frameNumber, priority, isPrefetch)));
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1860 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1861 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1862
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1863 void ScheduleLoadFullDicomFrame(size_t cursorIndex,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1864 int priority,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1865 bool isPrefetch)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1866 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1867 if (frames_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1868 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1869 std::string sopInstanceUid = frames_->GetInstanceOfFrame(cursorIndex).GetSopInstanceUid();
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1870 unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1871 ScheduleLoadFullDicomFrame(sopInstanceUid, frameNumber, priority, isPrefetch);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1872 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1873 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1874
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1875 void ScheduleLoadRenderedFrame(size_t cursorIndex,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1876 int priority,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1877 bool isPrefetch)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1878 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1879 if (!source_.HasDicomWebRendered())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1880 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1881 ScheduleLoadFullDicomFrame(cursorIndex, priority, isPrefetch);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1882 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1883 else if (frames_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1884 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1885 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1886 unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1887
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1888 /**
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1889 * If the full-resolution DICOM file is already available in the
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1890 * cache of the oracle, skip the loading of the "rendered".
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1891 **/
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1892 std::unique_ptr<OrthancStone::WebAssemblyOracle::CachedInstanceAccessor> accessor(
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1893 context_.AccessCachedInstance(instance.GetSopInstanceUid()));
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1894
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1895 if (accessor.get() != NULL &&
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1896 accessor->IsValid())
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1897 {
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1898 try
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1899 {
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1900 SetFullDicomFrame::Apply(*this, accessor->GetDicom(), instance.GetSopInstanceUid(),
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1901 frameNumber, priority, isPrefetch);
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1902 return;
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1903 }
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1904 catch (Orthanc::OrthancException&)
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1905 {
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1906 // This happens in the case of a JPEG2k image unsupported by DCMTK
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1907 }
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1908 }
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1909
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1910 bool isMonochrome1 = (instance.GetImageInformation().GetPhotometricInterpretation() ==
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1911 Orthanc::PhotometricInterpretation_Monochrome1);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1912
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1913 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() +
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1914 "/series/" + frames_->GetSeriesInstanceUid() +
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1915 "/instances/" + instance.GetSopInstanceUid() +
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1916 "/frames/" + boost::lexical_cast<std::string>(frameNumber + 1) + "/rendered");
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1917
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1918 std::map<std::string, std::string> headers, arguments;
1717
391c798e4dae fix for KNIX sample dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1714
diff changeset
1919 // arguments["quality"] = "10"; // Low-level quality for test purpose
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1920 arguments["window"] = (
1536
7b326e5ee97b reduce blinking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1534
diff changeset
1921 boost::lexical_cast<std::string>(windowingCenter_) + "," +
7b326e5ee97b reduce blinking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1534
diff changeset
1922 boost::lexical_cast<std::string>(windowingWidth_) + ",linear");
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1923
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1924 std::unique_ptr<OrthancStone::IOracleCommand> command(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1925 source_.CreateDicomWebCommand(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1926 uri, arguments, headers, new SetLowQualityFrame(
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1927 GetSharedObserver(), instance.GetSopInstanceUid(), frameNumber,
1536
7b326e5ee97b reduce blinking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1534
diff changeset
1928 windowingCenter_, windowingWidth_, isMonochrome1, isPrefetch)));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1929
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1930 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1931 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1932 lock->Schedule(GetSharedObserver(), priority, command.release());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1933 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1934 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1935 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1936
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1937 void UpdateCurrentTextureParameters()
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1938 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1939 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1940
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1941 if (lock->GetController().GetScene().HasLayer(LAYER_TEXTURE))
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1942 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1943 if (lock->GetController().GetScene().GetLayer(LAYER_TEXTURE).GetType() ==
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1944 OrthancStone::ISceneLayer::Type_FloatTexture)
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1945 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1946 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1947 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE)).
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1948 SetCustomWindowing(windowingCenter_, windowingWidth_);
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1949 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1950
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1951 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1952 OrthancStone::TextureBaseSceneLayer& layer =
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1953 dynamic_cast<OrthancStone::TextureBaseSceneLayer&>(
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1954 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE));
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1955
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1956 layer.SetFlipX(flipX_);
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1957 layer.SetFlipY(flipY_);
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1958 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1959
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1960 lock->Invalidate();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1961 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1962 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1963
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1964
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
1965 ViewerViewport(OrthancStone::WebAssemblyLoadersContext& context,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1966 const OrthancStone::DicomSource& source,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1967 const std::string& canvas,
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1968 boost::shared_ptr<FramesCache> cache,
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1969 bool softwareRendering) :
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1970 context_(context),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1971 source_(source),
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1972 framesCache_(cache),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1973 fitNextContent_(true),
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1974 flipX_(false),
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1975 flipY_(false),
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1976 hasFocusOnInstance_(false),
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1977 focusFrameNumber_(0),
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1978 synchronizationOffset_(OrthancStone::LinearAlgebra::CreateVector(0, 0, 0)),
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1979 synchronizationEnabled_(false),
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1980 centralPhysicalWidth_(1),
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1981 centralPhysicalHeight_(1)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1982 {
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1983 if (!framesCache_)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1984 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1985 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1986 }
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1987
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1988 if (softwareRendering)
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1989 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1990 LOG(INFO) << "Creating Cairo viewport in canvas: " << canvas;
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1991 viewport_ = OrthancStone::WebAssemblyCairoViewport::Create(canvas);
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1992 }
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1993 else
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1994 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1995 LOG(INFO) << "Creating WebGL viewport in canvas: " << canvas;
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1996 viewport_ = OrthancStone::WebGLViewport::Create(canvas);
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1997 }
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1998
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1999 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2000 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2001 std::string ttf;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2002 Orthanc::EmbeddedResources::GetFileResource(ttf, Orthanc::EmbeddedResources::UBUNTU_FONT);
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2003 lock->GetCompositor().SetFont(0, ttf, 24 /* font size */, Orthanc::Encoding_Latin1);
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2004 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2005
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2006 emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, OnWheel);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2007
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2008 SetWindowingPreset();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2009 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2010
1721
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2011
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2012 void Handle(const OrthancStone::ViewportController::GrayscaleWindowingChanged& message)
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2013 {
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2014 // This event is triggered by the windowing mouse action, from class "GrayscaleWindowingSceneTracker"
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2015 windowingCenter_ = message.GetWindowingCenter();
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2016 windowingWidth_ = message.GetWindowingWidth();
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2017
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2018 if (observer_.get() != NULL)
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2019 {
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2020 observer_->SignalWindowingUpdated(*this, message.GetWindowingCenter(), message.GetWindowingWidth());
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2021 }
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2022 }
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2023
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2024
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2025 static EM_BOOL OnWheel(int eventType,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2026 const EmscriptenWheelEvent *wheelEvent,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2027 void *userData)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2028 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2029 ViewerViewport& that = *reinterpret_cast<ViewerViewport*>(userData);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2030
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2031 if (that.frames_.get() != NULL &&
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2032 that.cursor_.get() != NULL)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2033 {
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2034 const bool isCtrl = wheelEvent->mouse.ctrlKey;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2035 const bool isShift = wheelEvent->mouse.shiftKey;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2036
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2037 const size_t previousCursorIndex = that.cursor_->GetCurrentIndex();
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2038
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2039 if (wheelEvent->deltaY < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2040 {
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2041 that.ChangeFrame(isCtrl ? SeriesCursor::Action_FastMinus :
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2042 SeriesCursor::Action_Minus, false /* not circular */);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2043 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2044 else if (wheelEvent->deltaY > 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2045 {
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2046 that.ChangeFrame(isCtrl ? SeriesCursor::Action_FastPlus :
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2047 SeriesCursor::Action_Plus, false /* not circular */);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2048 }
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2049
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2050 if (that.synchronizationEnabled_)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2051 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2052 const size_t currentCursorIndex = that.cursor_->GetCurrentIndex();
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2053
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2054 const OrthancStone::CoordinateSystem3D current =
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2055 that.frames_->GetFrameGeometry(currentCursorIndex);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2056
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2057 if (isShift &&
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2058 previousCursorIndex != currentCursorIndex)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2059 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2060 const OrthancStone::CoordinateSystem3D previous =
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2061 that.frames_->GetFrameGeometry(previousCursorIndex);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2062 that.synchronizationOffset_ += previous.GetOrigin() - current.GetOrigin();
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2063 }
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2064
1694
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2065 that.observer_->SignalSynchronizedBrowsing(
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2066 that, current.GetOrigin() + that.synchronizationOffset_, current.GetNormal());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2067 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2068 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2069
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2070 return true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2071 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2072
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2073 void Handle(const OrthancStone::DicomResourcesLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2074 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2075 dynamic_cast<const ICommand&>(message.GetUserPayload()).Handle(message);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2076 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2077
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2078 void Handle(const OrthancStone::HttpCommand::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2079 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2080 dynamic_cast<const ICommand&>(message.GetOrigin().GetPayload()).Handle(message);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2081 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2082
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2083 void Handle(const OrthancStone::ParseDicomSuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2084 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2085 dynamic_cast<const ICommand&>(message.GetOrigin().GetPayload()).Handle(message);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2086 }
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
2087
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2088 public:
1622
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2089 virtual ~ViewerViewport()
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2090 {
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2091 // Unregister the callbacks to avoid any call with a "void*" that
1623
74be0f498b08 Updated mechanism to avoid using deleted objects in RequestAnimationFrame callbacks.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1622
diff changeset
2092 // has been destroyed. "WebAssemblyViewport::CreateObjectCookie()"
1622
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2093 // provides a more advanced alternative.
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2094 emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, NULL);
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2095 }
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2096
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2097 static boost::shared_ptr<ViewerViewport> Create(OrthancStone::WebAssemblyLoadersContext& context,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2098 const OrthancStone::DicomSource& source,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2099 const std::string& canvas,
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2100 boost::shared_ptr<FramesCache> cache,
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2101 bool softwareRendering)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2102 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2103 boost::shared_ptr<ViewerViewport> viewport(
1675
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2104 new ViewerViewport(context, source, canvas, cache, softwareRendering));
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2105
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2106 {
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2107 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context.Lock());
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2108
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2109 viewport->loader_ = OrthancStone::DicomResourcesLoader::Create(*lock);
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2110 viewport->Register<OrthancStone::DicomResourcesLoader::SuccessMessage>(
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2111 *viewport->loader_, &ViewerViewport::Handle);
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2112
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2113 viewport->Register<OrthancStone::HttpCommand::SuccessMessage>(
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2114 lock->GetOracleObservable(), &ViewerViewport::Handle);
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2115
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2116 viewport->Register<OrthancStone::ParseDicomSuccessMessage>(
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2117 lock->GetOracleObservable(), &ViewerViewport::Handle);
6fa05252b085 don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1674
diff changeset
2118 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2119
1721
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2120 {
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2121 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport->viewport_->Lock());
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2122 viewport->Register<OrthancStone::ViewportController::GrayscaleWindowingChanged>(lock->GetController(), &ViewerViewport::Handle);
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2123 }
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2124
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2125 return viewport;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2126 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2127
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2128 void SetFrames(OrthancStone::SortedFrames* frames)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2129 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2130 if (frames == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2131 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2132 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2133 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2134
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2135 flipX_ = false;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2136 flipY_ = false;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2137 fitNextContent_ = true;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2138 cineRate_ = DEFAULT_CINE_RATE;
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2139 inverted_ = false;
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2140 serverSideTranscoding_ = false;
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2141 OrthancStone::LinearAlgebra::AssignVector(synchronizationOffset_, 0, 0, 0);
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2142
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2143 frames_.reset(frames);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2144 cursor_.reset(new SeriesCursor(frames_->GetFramesCount()));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2145
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2146 LOG(INFO) << "Number of frames in series: " << frames_->GetFramesCount();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2147
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2148 SetWindowingPreset();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2149 ClearViewport();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2150 prefetchQueue_.clear();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2151
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2152 if (observer_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2153 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2154 observer_->SignalFrameUpdated(*this, cursor_->GetCurrentIndex(),
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2155 frames_->GetFramesCount(), DisplayedFrameQuality_None, 0);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2156 }
1665
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2157
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2158 centralPhysicalWidth_ = 1;
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2159 centralPhysicalHeight_ = 1;
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2160
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2161 if (frames_->GetFramesCount() != 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2162 {
1665
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2163 const OrthancStone::DicomInstanceParameters& centralInstance = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex());
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2164
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2165 /**
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2166 * Avoid loading metadata if we know that this cannot be a
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2167 * "true" image with pixel data. Retrieving instance metadata on
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2168 * RTSTRUCT can lead to very large JSON whose parsing will
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2169 * freeze the browser for several seconds.
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2170 **/
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2171 const OrthancStone::SopClassUid uid = centralInstance.GetSopClassUid();
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2172 if (uid != OrthancStone::SopClassUid_EncapsulatedPdf &&
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2173 uid != OrthancStone::SopClassUid_RTDose &&
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2174 uid != OrthancStone::SopClassUid_RTPlan &&
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2175 uid != OrthancStone::SopClassUid_RTStruct &&
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2176 GetSeriesThumbnailType(uid) != OrthancStone::SeriesThumbnailType_Video)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2177 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2178 // Fetch the details of the series from the central instance
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2179 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() +
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2180 "/series/" + frames_->GetSeriesInstanceUid() +
1665
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2181 "/instances/" + centralInstance.GetSopInstanceUid() + "/metadata");
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2182
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2183 loader_->ScheduleGetDicomWeb(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2184 boost::make_shared<OrthancStone::LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID),
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2185 0, source_, uri, new LoadSeriesDetailsFromInstance(GetSharedObserver()));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2186 }
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2187
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2188 if (centralInstance.GetPixelSpacingX() != 0 &&
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2189 centralInstance.GetPixelSpacingY() != 0 &&
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2190 centralInstance.GetWidth() != 0 &&
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2191 centralInstance.GetHeight())
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2192 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2193 centralPhysicalWidth_ = (centralInstance.GetPixelSpacingX() *
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2194 static_cast<double>(centralInstance.GetWidth()));
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2195 centralPhysicalHeight_ = (centralInstance.GetPixelSpacingY() *
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2196 static_cast<double>(centralInstance.GetHeight()));
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2197 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2198 }
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2199
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2200 ApplyScheduledFocus();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2201 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2202
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2203
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2204 // This method is used when the layout of the HTML page changes,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2205 // which does not trigger the "emscripten_set_resize_callback()"
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2206 void UpdateSize(bool fitContent)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2207 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2208 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
1576
92fca2b3ba3d sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
2209 lock->RefreshCanvasSize();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2210
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2211 if (fitContent)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2212 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2213 lock->GetCompositor().FitContent(lock->GetController().GetScene());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2214 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2215
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2216 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2217 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2218
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2219 void AcquireObserver(IObserver* observer)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2220 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2221 observer_.reset(observer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2222 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2223
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2224 const std::string& GetCanvasId() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2225 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2226 assert(viewport_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2227 return viewport_->GetCanvasId();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2228 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2229
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2230
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2231 void Redraw()
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2232 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2233 if (cursor_.get() != NULL &&
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2234 frames_.get() != NULL)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2235 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2236 const size_t cursorIndex = cursor_->GetCurrentIndex();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2237
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2238 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2239 const size_t frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2240
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
2241 FramesCache::Accessor accessor(*framesCache_, instance.GetSopInstanceUid(), frameNumber);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2242 if (accessor.IsValid())
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2243 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2244 RenderCurrentScene(accessor.GetImage(), instance, frames_->GetFrameGeometry(cursorIndex));
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2245
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2246 DisplayedFrameQuality quality;
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2247
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2248 if (accessor.GetQuality() < QUALITY_FULL)
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2249 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2250 // This frame is only available in low-res: Download the full DICOM
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2251 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2252 quality = DisplayedFrameQuality_Low;
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2253 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2254 else
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2255 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2256 quality = DisplayedFrameQuality_High;
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2257 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2258
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
2259 SetupPrefetchAfterRendering(accessor.GetImage(), quality);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2260 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2261 else
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2262 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2263 // This frame is not cached yet: Load it
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2264 if (source_.HasDicomWebRendered())
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2265 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2266 ScheduleLoadRenderedFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2267 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2268 else
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2269 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2270 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2271 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2272 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2273 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2274 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2275
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2276
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2277 // Returns "true" iff the frame has indeed changed
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2278 bool ChangeFrame(SeriesCursor::Action action,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2279 bool isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2280 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2281 if (cursor_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2282 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2283 size_t previous = cursor_->GetCurrentIndex();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2284
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2285 cursor_->Apply(action, isCircular);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2286
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2287 size_t current = cursor_->GetCurrentIndex();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2288 if (previous != current)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2289 {
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2290 Redraw();
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2291 return true;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2292 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2293 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2294
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2295 return false;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2296 }
1719
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2297
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2298
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2299 void GoToFirstFrame()
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2300 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2301 if (cursor_.get() != NULL &&
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2302 cursor_->GetCurrentIndex() != 0)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2303 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2304 cursor_->SetCurrentIndex(0);
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2305 Redraw();
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2306 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2307 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2308
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2309
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2310 void GoToLastFrame()
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2311 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2312 if (cursor_.get() != NULL)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2313 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2314 size_t last = cursor_->GetFramesCount() - 1;
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2315 if (cursor_->GetCurrentIndex() != last)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2316 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2317 cursor_->SetCurrentIndex(last);
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2318 Redraw();
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2319 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2320 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2321 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2322
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2323
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2324 bool GetCurrentFrameOfReferenceUid(std::string& frameOfReferenceUid) const
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2325 {
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2326 if (cursor_.get() != NULL &&
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2327 frames_.get() != NULL)
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2328 {
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2329 frameOfReferenceUid = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()).GetFrameOfReferenceUid();
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2330 return true;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2331 }
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2332 else
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2333 {
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2334 return false;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2335 }
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2336 }
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2337
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2338 bool GetCurrentPlane(OrthancStone::CoordinateSystem3D& plane) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2339 {
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2340 if (cursor_.get() != NULL &&
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2341 frames_.get() != NULL)
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2342 {
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2343 plane = frames_->GetFrameGeometry(cursor_->GetCurrentIndex());
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2344 return true;
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2345 }
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2346 else
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2347 {
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2348 return false;
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2349 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2350 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2351
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2352 void UpdateReferenceLines(const std::list<const ViewerViewport*>& viewports)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2353 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2354 std::unique_ptr<OrthancStone::PolylineSceneLayer> layer(new OrthancStone::PolylineSceneLayer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2355
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2356 if (cursor_.get() != NULL &&
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2357 frames_.get() != NULL)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2358 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2359 const size_t cursorIndex = cursor_->GetCurrentIndex();
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2360 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2361 const unsigned int frame = frames_->GetFrameNumberInInstance(cursorIndex);
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2362
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2363 for (std::list<const ViewerViewport*>::const_iterator
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2364 it = viewports.begin(); it != viewports.end(); ++it)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2365 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2366 assert(*it != NULL);
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2367
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2368 OrthancStone::CoordinateSystem3D otherPlane;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2369 std::string otherFrameOfReferenceUid;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2370 if ((*it)->GetCurrentPlane(otherPlane) &&
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2371 (*it)->GetCurrentFrameOfReferenceUid(otherFrameOfReferenceUid) &&
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2372 otherFrameOfReferenceUid == instance.GetFrameOfReferenceUid())
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2373 {
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2374 double x1, y1, x2, y2;
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2375 if (GetReferenceLineCoordinates(x1, y1, x2, y2, instance, frame, otherPlane))
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2376 {
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2377 OrthancStone::PolylineSceneLayer::Chain chain;
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2378 chain.push_back(OrthancStone::ScenePoint2D(x1, y1));
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2379 chain.push_back(OrthancStone::ScenePoint2D(x2, y2));
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2380 layer->AddChain(chain, false, 0, 255, 0);
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2381 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2382 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2383 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2384 }
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2385
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2386 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2387 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2388
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2389 if (layer->GetChainsCount() == 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2390 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2391 lock->GetController().GetScene().DeleteLayer(LAYER_REFERENCE_LINES);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2392 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2393 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2394 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2395 lock->GetController().GetScene().SetLayer(LAYER_REFERENCE_LINES, layer.release());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2396 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2397
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2398 //lock->GetCompositor().Refresh(lock->GetController().GetScene());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2399 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2400 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2401 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2402
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2403
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2404 void ClearReferenceLines()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2405 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2406 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2407 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2408 lock->GetController().GetScene().DeleteLayer(LAYER_REFERENCE_LINES);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2409 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2410 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2411 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2412
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2413
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2414 void SetWindowingPreset()
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2415 {
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2416 assert(windowingPresetCenters_.size() == windowingPresetWidths_.size());
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2417
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2418 if (windowingPresetCenters_.empty())
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2419 {
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2420 SetWindowing(128, 256);
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2421 }
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2422 else
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2423 {
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2424 SetWindowing(windowingPresetCenters_[0], windowingPresetWidths_[0]);
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2425 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2426 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2427
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2428 void SetWindowing(float windowingCenter,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2429 float windowingWidth)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2430 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2431 windowingCenter_ = windowingCenter;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2432 windowingWidth_ = windowingWidth;
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2433 UpdateCurrentTextureParameters();
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2434
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2435 if (observer_.get() != NULL)
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2436 {
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2437 observer_->SignalWindowingUpdated(*this, windowingCenter, windowingWidth);
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2438 }
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2439 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2440
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2441 void FlipX()
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2442 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2443 flipX_ = !flipX_;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2444 UpdateCurrentTextureParameters();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2445 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2446
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2447 void FlipY()
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2448 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2449 flipY_ = !flipY_;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2450 UpdateCurrentTextureParameters();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2451 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2452
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2453 void Invert()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2454 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2455 inverted_ = !inverted_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2456
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2457 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2458 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2459
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2460 if (lock->GetController().GetScene().HasLayer(LAYER_TEXTURE) &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2461 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE).GetType() ==
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2462 OrthancStone::ISceneLayer::Type_FloatTexture)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2463 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2464 OrthancStone::FloatTextureSceneLayer& layer =
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2465 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2466 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2467
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2468 // NB: Using "IsInverted()" instead of "inverted_" is for
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2469 // compatibility with MONOCHROME1 images
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2470 layer.SetInverted(!layer.IsInverted());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2471 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2472 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2473 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2474 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2475
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2476
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2477
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2478 class Interactor : public OrthancStone::DefaultViewportInteractor
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2479 {
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2480 private:
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2481 ViewerViewport& viewer_;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2482 WebViewerAction leftAction_;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2483 WebViewerAction middleAction_;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2484 WebViewerAction rightAction_;
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2485
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2486 bool IsAction(const OrthancStone::PointerEvent& event,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2487 WebViewerAction action)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2488 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2489 switch (event.GetMouseButton())
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2490 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2491 case OrthancStone::MouseButton_Left:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2492 return (leftAction_ == action);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2493
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2494 case OrthancStone::MouseButton_Middle:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2495 return (middleAction_ == action);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2496
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2497 case OrthancStone::MouseButton_Right:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2498 return (rightAction_ == action);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2499
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2500 default:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2501 return false;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2502 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2503 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2504
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2505 public:
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2506 Interactor(ViewerViewport& viewer,
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2507 WebViewerAction leftAction,
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2508 WebViewerAction middleAction,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2509 WebViewerAction rightAction) :
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2510 viewer_(viewer),
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2511 leftAction_(leftAction),
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2512 middleAction_(middleAction),
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2513 rightAction_(rightAction)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2514 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2515 SetLeftButtonAction(ConvertWebViewerAction(leftAction));
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2516 SetMiddleButtonAction(ConvertWebViewerAction(middleAction));
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2517 SetRightButtonAction(ConvertWebViewerAction(rightAction));
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2518 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2519
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2520 virtual OrthancStone::IFlexiblePointerTracker* CreateTracker(
1607
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2521 boost::weak_ptr<OrthancStone::IViewport> viewport,
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2522 const OrthancStone::PointerEvent& event,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2523 unsigned int viewportWidth,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2524 unsigned int viewportHeight) ORTHANC_OVERRIDE
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2525 {
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2526 boost::shared_ptr<OrthancStone::IViewport> lock1(viewport.lock());
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2527
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2528 if (lock1 &&
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2529 IsAction(event, WebViewerAction_Crosshair))
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2530 {
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2531 OrthancStone::CoordinateSystem3D plane;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2532 if (viewer_.GetCurrentPlane(plane))
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2533 {
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2534 std::unique_ptr<OrthancStone::IViewport::ILock> lock2(lock1->Lock());
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2535
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2536 const OrthancStone::ScenePoint2D p = event.GetMainPosition();
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2537 double x = p.GetX();
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2538 double y = p.GetY();
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2539 lock2->GetController().GetCanvasToSceneTransform().Apply(x, y);
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2540
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2541 OrthancStone::Vector click = plane.MapSliceToWorldCoordinates(x, y);
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2542 if (viewer_.observer_.get() != NULL)
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2543 {
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2544 viewer_.observer_->SignalCrosshair(viewer_, click);
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2545 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2546 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2547
1580
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1579
diff changeset
2548 return NULL; // No need for a tracker, this is just a click
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2549 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2550 else
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2551 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2552 return DefaultViewportInteractor::CreateTracker(
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2553 viewport, event, viewportWidth, viewportHeight);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2554 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2555 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2556 };
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2557
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2558
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2559 void SetMouseButtonActions(WebViewerAction leftAction,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2560 WebViewerAction middleAction,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2561 WebViewerAction rightAction)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2562 {
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2563 assert(viewport_ != NULL);
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2564 viewport_->AcquireInteractor(new Interactor(*this, leftAction, middleAction, rightAction));
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2565 }
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2566
1578
1f812f4c95be comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1576
diff changeset
2567 void FitForPrint()
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2568 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2569 viewport_->FitForPrint();
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2570 }
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2571
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2572 void SetAnnotations(boost::shared_ptr<OrthancStone::OsiriX::CollectionOfAnnotations> annotations)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2573 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2574 annotations_ = annotations;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2575 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2576
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2577 void ScheduleFrameFocus(const std::string& sopInstanceUid,
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2578 unsigned int frameNumber)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2579 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2580 hasFocusOnInstance_ = true;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2581 focusSopInstanceUid_ = sopInstanceUid;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2582 focusFrameNumber_ = frameNumber;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2583
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2584 ApplyScheduledFocus();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2585 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2586
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2587 void ApplyScheduledFocus()
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2588 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2589 size_t cursorIndex;
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2590
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2591 if (hasFocusOnInstance_ &&
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2592 cursor_.get() != NULL &&
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2593 frames_.get() != NULL &&
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2594 frames_->LookupFrame(cursorIndex, focusSopInstanceUid_, focusFrameNumber_))
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2595 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2596 size_t current = cursor_->GetCurrentIndex();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2597
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2598 if (current != cursorIndex)
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2599 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2600 cursor_->SetCurrentIndex(cursorIndex);
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2601 Redraw();
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2602 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2604 hasFocusOnInstance_ = false;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2605 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2606 }
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2607
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2608 void FocusOnPoint(const OrthancStone::Vector& p)
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2609 {
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2610 //static const double MAX_DISTANCE = 0.5; // 0.5 cm => TODO parameter?
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2611 static const double MAX_DISTANCE = std::numeric_limits<double>::infinity();
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2612
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2613 size_t cursorIndex;
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2614 if (cursor_.get() != NULL &&
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2615 frames_.get() != NULL &&
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2616 frames_->FindClosestFrame(cursorIndex, p, MAX_DISTANCE))
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2617 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2618 cursor_->SetCurrentIndex(cursorIndex);
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2619 Redraw();
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2620 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2621 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2622
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2623 unsigned int GetCineRate() const
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2624 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2625 return cineRate_;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2626 }
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2627
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2628 void FormatWindowingPresets(Json::Value& target) const
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2629 {
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2630 assert(windowingPresetCenters_.size() == windowingPresetWidths_.size());
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2631
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2632 target = Json::arrayValue;
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2633
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2634 for (size_t i = 0; i < windowingPresetCenters_.size(); i++)
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2635 {
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2636 const float c = windowingPresetCenters_[i];
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2637 const float w = windowingPresetWidths_[i];
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2638
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2639 std::string name = "Preset";
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2640 if (windowingPresetCenters_.size() > 1)
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2641 {
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2642 name += " " + boost::lexical_cast<std::string>(i + 1);
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2643 }
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2644
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2645 Json::Value preset = Json::objectValue;
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2646 preset["name"] = name;
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2647 preset["center"] = c;
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2648 preset["width"] = w;
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2649 preset["info"] =
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2650 ("C " + boost::lexical_cast<std::string>(static_cast<int>(boost::math::iround<double>(c))) +
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2651 ", W " + boost::lexical_cast<std::string>(static_cast<int>(boost::math::iround<double>(w))));
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2652
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2653 target.append(preset);
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2654 }
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2655 }
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2656
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2657
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2658 void SetSynchronizedBrowsingEnabled(int enabled)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2659 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2660 OrthancStone::LinearAlgebra::AssignVector(synchronizationOffset_, 0, 0, 0);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2661 synchronizationEnabled_ = enabled;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2662 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2663 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2664
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2665
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2666
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2667
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2668
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2669 typedef std::map<std::string, boost::shared_ptr<ViewerViewport> > Viewports;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2670 static Viewports allViewports_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2671 static bool showReferenceLines_ = true;
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2672 static boost::shared_ptr<OrthancStone::OsiriX::CollectionOfAnnotations> annotations_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2673
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2674
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2675 static void UpdateReferenceLines()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2676 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2677 if (showReferenceLines_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2678 {
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2679 std::list<const ViewerViewport*> viewports;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2680
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2681 for (Viewports::const_iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2682 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2683 assert(it->second != NULL);
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2684 viewports.push_back(it->second.get());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2685 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2686
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2687 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2688 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2689 assert(it->second != NULL);
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2690 it->second->UpdateReferenceLines(viewports);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2691 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2692 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2693 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2694 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2695 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2696 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2697 assert(it->second != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2698 it->second->ClearReferenceLines();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2699 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2700 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2701 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2702
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2703
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2704 class WebAssemblyObserver : public ResourcesLoader::IObserver,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2705 public ViewerViewport::IObserver
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2706 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2707 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2708 virtual void SignalResourcesLoaded() ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2709 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2710 DISPATCH_JAVASCRIPT_EVENT("ResourcesLoaded");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2711 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2712
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2713 virtual void SignalSeriesThumbnailLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2714 const std::string& seriesInstanceUid) ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2715 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2716 EM_ASM({
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2717 const customEvent = document.createEvent("CustomEvent");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2718 customEvent.initCustomEvent("ThumbnailLoaded", false, false,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2719 { "studyInstanceUid" : UTF8ToString($0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2720 "seriesInstanceUid" : UTF8ToString($1) });
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2721 window.dispatchEvent(customEvent);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2722 },
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2723 studyInstanceUid.c_str(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2724 seriesInstanceUid.c_str());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2725 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2726
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2727 virtual void SignalSeriesMetadataLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2728 const std::string& seriesInstanceUid) ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2729 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2730 EM_ASM({
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2731 const customEvent = document.createEvent("CustomEvent");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2732 customEvent.initCustomEvent("MetadataLoaded", false, false,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2733 { "studyInstanceUid" : UTF8ToString($0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2734 "seriesInstanceUid" : UTF8ToString($1) });
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2735 window.dispatchEvent(customEvent);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2736 },
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2737 studyInstanceUid.c_str(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2738 seriesInstanceUid.c_str());
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2739
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2740 for (Viewports::const_iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2741 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2742 assert(it->second != NULL);
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2743 it->second->ApplyScheduledFocus();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2744 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2745 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2746
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2747 virtual void SignalSeriesDetailsReady(const ViewerViewport& viewport) ORTHANC_OVERRIDE
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2748 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2749 EM_ASM({
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2750 const customEvent = document.createEvent("CustomEvent");
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2751 customEvent.initCustomEvent("SeriesDetailsReady", false, false,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2752 { "canvasId" : UTF8ToString($0) });
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2753 window.dispatchEvent(customEvent);
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2754 },
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2755 viewport.GetCanvasId().c_str()
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2756 );
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2757 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2758
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2759 virtual void SignalFrameUpdated(const ViewerViewport& viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2760 size_t currentFrame,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2761 size_t countFrames,
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2762 DisplayedFrameQuality quality,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2763 unsigned int instanceNumber) ORTHANC_OVERRIDE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2764 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2765 EM_ASM({
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2766 const customEvent = document.createEvent("CustomEvent");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2767 customEvent.initCustomEvent("FrameUpdated", false, false,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2768 { "canvasId" : UTF8ToString($0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2769 "currentFrame" : $1,
1674
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
2770 "numberOfFrames" : $2,
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2771 "quality" : $3,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2772 "instanceNumber" : $4 });
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2773 window.dispatchEvent(customEvent);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2774 },
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2775 viewport.GetCanvasId().c_str(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2776 static_cast<int>(currentFrame),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2777 static_cast<int>(countFrames),
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2778 quality, instanceNumber);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2779
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2780 UpdateReferenceLines();
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2781 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2782
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2783 virtual void SignalCrosshair(const ViewerViewport& viewport,
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2784 const OrthancStone::Vector& click) ORTHANC_OVERRIDE
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2785 {
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2786 for (Viewports::const_iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2787 {
1694
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2788 // TODO - One could check the "Frame Of Reference UID" here
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2789 assert(it->second.get() != NULL);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2790 if (it->second.get() != &viewport)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2791 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2792 it->second->FocusOnPoint(click);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2793 }
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2794 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2795 }
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2796
1694
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2797 virtual void SignalSynchronizedBrowsing(const ViewerViewport& viewport,
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2798 const OrthancStone::Vector& click,
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2799 const OrthancStone::Vector& normal) ORTHANC_OVERRIDE
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2800 {
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2801 for (Viewports::const_iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2802 {
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2803 assert(it->second.get() != NULL);
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2804
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2805 OrthancStone::CoordinateSystem3D plane;
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2806 bool isOpposite;
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2807
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2808 if (it->second.get() != &viewport &&
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2809 it->second->GetCurrentPlane(plane) &&
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2810 OrthancStone::GeometryToolbox::IsParallelOrOpposite(isOpposite, plane.GetNormal(), normal))
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2811 {
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2812 it->second->FocusOnPoint(click);
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2813 }
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2814 }
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2815 }
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2816
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2817 virtual void SignalSeriesPdfLoaded(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2818 const std::string& seriesInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2819 const std::string& pdf) ORTHANC_OVERRIDE
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2820 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2821 EM_ASM({
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2822 const customEvent = document.createEvent("CustomEvent");
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2823 customEvent.initCustomEvent("PdfLoaded", false, false,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2824 { "studyInstanceUid" : UTF8ToString($0),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2825 "seriesInstanceUid" : UTF8ToString($1),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2826 "pdfPointer" : $2,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2827 "pdfSize": $3});
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2828 window.dispatchEvent(customEvent);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2829 },
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2830 studyInstanceUid.c_str(),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2831 seriesInstanceUid.c_str(),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2832 pdf.empty() ? 0 : reinterpret_cast<intptr_t>(pdf.c_str()), // Explicit conversion to an integer
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2833 pdf.size());
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2834 }
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2835
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2836
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2837 virtual void SignalMultiframeInstanceThumbnailLoaded(const std::string& sopInstanceUid,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2838 const std::string& jpeg) ORTHANC_OVERRIDE
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2839 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2840 std::string dataUriScheme;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2841 Orthanc::Toolbox::EncodeDataUriScheme(dataUriScheme, "image/jpeg", jpeg);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2842
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2843 EM_ASM({
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2844 const customEvent = document.createEvent("CustomEvent");
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2845 customEvent.initCustomEvent("MultiframeInstanceThumbnailLoaded", false, false,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2846 { "sopInstanceUid" : UTF8ToString($0),
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2847 "thumbnail" : UTF8ToString($1) });
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2848 window.dispatchEvent(customEvent);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2849 },
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2850 sopInstanceUid.c_str(),
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2851 dataUriScheme.c_str());
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
2852 }
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2853
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2854 virtual void SignalWindowingUpdated(const ViewerViewport& viewport,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2855 double windowingCenter,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2856 double windowingWidth) ORTHANC_OVERRIDE
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2857 {
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2858 EM_ASM({
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2859 const customEvent = document.createEvent("CustomEvent");
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2860 customEvent.initCustomEvent("WindowingUpdated", false, false,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2861 { "canvasId" : UTF8ToString($0),
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2862 "windowingCenter" : $1,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2863 "windowingWidth" : $2 });
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2864 window.dispatchEvent(customEvent);
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2865 },
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2866 viewport.GetCanvasId().c_str(),
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2867 static_cast<int>(boost::math::iround<double>(windowingCenter)),
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2868 static_cast<int>(boost::math::iround<double>(windowingWidth)));
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2869
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2870 UpdateReferenceLines();
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2871 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2872 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2873
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2874
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2875
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2876 static OrthancStone::DicomSource source_;
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
2877 static boost::shared_ptr<FramesCache> framesCache_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2878 static boost::shared_ptr<OrthancStone::WebAssemblyLoadersContext> context_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2879 static std::string stringBuffer_;
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2880 static bool softwareRendering_ = false;
1701
b5a8bf32d969 new configuration options: "CombinedToolEnabled", "CombinedToolBehaviour" and "DownloadAsJpegEnabled"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
2881 static WebViewerAction leftButtonAction_ = WebViewerAction_Windowing;
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2882 static WebViewerAction middleButtonAction_ = WebViewerAction_Pan;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2883 static WebViewerAction rightButtonAction_ = WebViewerAction_Zoom;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2884
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2885
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2886 static void FormatTags(std::string& target,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2887 const Orthanc::DicomMap& tags)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2888 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2889 Orthanc::DicomArray arr(tags);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2890 Json::Value v = Json::objectValue;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2891
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2892 for (size_t i = 0; i < arr.GetSize(); i++)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2893 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2894 const Orthanc::DicomElement& element = arr.GetElement(i);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2895 if (!element.GetValue().IsBinary() &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2896 !element.GetValue().IsNull())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2897 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2898 v[element.GetTag().Format()] = element.GetValue().GetContent();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2899 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2900 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2901
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2902 target = v.toStyledString();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2903 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2904
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2905
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2906 static ResourcesLoader& GetResourcesLoader()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2907 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2908 static boost::shared_ptr<ResourcesLoader> resourcesLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2909
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2910 if (!resourcesLoader_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2911 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2912 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_->Lock());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2913 resourcesLoader_ = ResourcesLoader::Create(*lock, source_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2914 resourcesLoader_->AcquireObserver(new WebAssemblyObserver);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2915 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2916
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2917 return *resourcesLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2918 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2919
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2920
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2921 static boost::shared_ptr<ViewerViewport> GetViewport(const std::string& canvas)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2922 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2923 Viewports::iterator found = allViewports_.find(canvas);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2924 if (found == allViewports_.end())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2925 {
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2926 boost::shared_ptr<ViewerViewport> viewport(
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
2927 ViewerViewport::Create(*context_, source_, canvas, framesCache_, softwareRendering_));
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2928 viewport->SetMouseButtonActions(leftButtonAction_, middleButtonAction_, rightButtonAction_);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2929 viewport->AcquireObserver(new WebAssemblyObserver);
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2930 viewport->SetAnnotations(annotations_);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2931 allViewports_[canvas] = viewport;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2932 return viewport;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2933 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2934 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2935 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2936 return found->second;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2937 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2938 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2939
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2940
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2941 extern "C"
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2942 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2943 int main(int argc, char const *argv[])
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2944 {
1665
f62f685e0eb2 avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1663
diff changeset
2945 printf("Initializing Stone\n");
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2946 Orthanc::InitializeFramework("", true);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2947 Orthanc::Logging::EnableInfoLevel(true);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2948 //Orthanc::Logging::EnableTraceLevel(true);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2949
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2950 context_.reset(new OrthancStone::WebAssemblyLoadersContext(1, 4, 1));
1663
fc883105ee11 enable cache of ParsedDicomFile in oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
2951 context_->SetDicomCacheSize(128 * 1024 * 1024); // 128MB
fc883105ee11 enable cache of ParsedDicomFile in oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
2952
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
2953 framesCache_.reset(new FramesCache);
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2954 annotations_.reset(new OrthancStone::OsiriX::CollectionOfAnnotations);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2955
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2956 DISPATCH_JAVASCRIPT_EVENT("StoneInitialized");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2957 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2958
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2959
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2960 EMSCRIPTEN_KEEPALIVE
1713
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
2961 void SetDicomWebRoot(const char* uri,
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
2962 int useRendered)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2963 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2964 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2965 {
1713
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
2966 source_.SetDicomWebSource(uri);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2967 source_.SetDicomWebRendered(useRendered != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2968 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2969 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2970 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2971
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2972
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2973 EMSCRIPTEN_KEEPALIVE
1713
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
2974 void SetDicomWebThroughOrthanc(const char* orthancRoot,
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
2975 const char* serverName,
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
2976 int hasRendered)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2977 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2978 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2979 {
1713
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
2980 context_->SetLocalOrthanc(orthancRoot);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2981 source_.SetDicomWebThroughOrthancSource(serverName);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2982 source_.SetDicomWebRendered(hasRendered != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2983 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2984 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2985 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2986
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2987
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2988 EMSCRIPTEN_KEEPALIVE
1714
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2989 void SetDicomCacheSize(int sizeMB)
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2990 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2991 try
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2992 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2993 if (sizeMB == 0)
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2994 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2995 LOG(WARNING) << "The DICOM cache is disabled";
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2996 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2997 else
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2998 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
2999 LOG(INFO) << "The DICOM cache size is set to " << sizeMB << "MB";
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3000 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3001
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3002 if (sizeMB >= 0)
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3003 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3004 context_->SetDicomCacheSize(sizeMB * 1024 * 1024);
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3005 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3006 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3007 EXTERN_CATCH_EXCEPTIONS;
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3008 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3009
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3010
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3011 EMSCRIPTEN_KEEPALIVE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3012 void FetchAllStudies()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3013 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3014 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3015 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3016 GetResourcesLoader().FetchAllStudies();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3017 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3018 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3019 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3020
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3021 EMSCRIPTEN_KEEPALIVE
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3022 void FetchPatient(const char* patientId)
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3023 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3024 try
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3025 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3026 GetResourcesLoader().FetchPatient(patientId);
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3027 }
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3028 EXTERN_CATCH_EXCEPTIONS;
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3029 }
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3030
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3031 EMSCRIPTEN_KEEPALIVE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3032 void FetchStudy(const char* studyInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3033 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3034 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3035 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3036 GetResourcesLoader().FetchStudy(studyInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3037 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3038 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3039 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3040
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3041 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3042 void FetchSeries(const char* studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3043 const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3044 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3045 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3046 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3047 GetResourcesLoader().FetchSeries(studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3048 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3049 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3050 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3051
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3052 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3053 int GetStudiesCount()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3054 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3055 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3056 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3057 return GetResourcesLoader().GetStudiesCount();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3058 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3059 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3060 return 0; // on exception
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3061 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3062
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3063 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3064 int GetSeriesCount()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3065 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3066 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3067 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3068 return GetResourcesLoader().GetSeriesCount();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3069 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3070 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3071 return 0; // on exception
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3072 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3073
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3074
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3075 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3076 const char* GetStringBuffer()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3077 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3078 return stringBuffer_.c_str();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3079 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3080
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3081
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3082 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3083 void LoadStudyTags(int i)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3084 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3085 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3086 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3087 if (i < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3088 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3089 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3090 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3091
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3092 Orthanc::DicomMap dicom;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3093 GetResourcesLoader().GetStudy(dicom, i);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3094 FormatTags(stringBuffer_, dicom);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3095 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3096 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3097 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3098
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3099
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3100 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3101 void LoadSeriesTags(int i)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3102 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3103 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3104 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3105 if (i < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3106 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3107 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3108 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3109
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3110 Orthanc::DicomMap dicom;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3111 GetResourcesLoader().GetSeries(dicom, i);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3112 FormatTags(stringBuffer_, dicom);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3113 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3114 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3115 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3116
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3117
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3118 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3119 int LoadSeriesThumbnail(const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3120 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3121 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3122 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3123 std::string image, mime;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3124 switch (GetResourcesLoader().GetSeriesThumbnail(image, mime, seriesInstanceUid))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3125 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3126 case OrthancStone::SeriesThumbnailType_Image:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3127 Orthanc::Toolbox::EncodeDataUriScheme(stringBuffer_, mime, image);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3128 return ThumbnailType_Image;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3129
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3130 case OrthancStone::SeriesThumbnailType_Pdf:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3131 return ThumbnailType_Pdf;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3132
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3133 case OrthancStone::SeriesThumbnailType_Video:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3134 return ThumbnailType_Video;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3135
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3136 case OrthancStone::SeriesThumbnailType_NotLoaded:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3137 return ThumbnailType_Loading;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3138
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3139 case OrthancStone::SeriesThumbnailType_Unsupported:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3140 return ThumbnailType_NoPreview;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3141
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3142 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3143 return ThumbnailType_Unknown;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3144 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3145 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3146 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3147 return ThumbnailType_Unknown;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3148 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3149
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3150
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3151 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3152 void SpeedUpFetchSeriesMetadata(const char* studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3153 const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3154 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3155 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3156 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3157 GetResourcesLoader().FetchSeriesMetadata(PRIORITY_HIGH, studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3158 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3159 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3160 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3161
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3162
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3163 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3164 int IsSeriesComplete(const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3165 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3166 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3167 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3168 return GetResourcesLoader().IsSeriesComplete(seriesInstanceUid) ? 1 : 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3169 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3170 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3171 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3172 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3173
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3174 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3175 int LoadSeriesInViewport(const char* canvas,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3176 const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3177 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3178 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3179 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3180 std::unique_ptr<OrthancStone::SortedFrames> frames(new OrthancStone::SortedFrames);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3181
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3182 if (GetResourcesLoader().SortSeriesFrames(*frames, seriesInstanceUid))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3183 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3184 GetViewport(canvas)->SetFrames(frames.release());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3185 return 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3186 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3187 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3188 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3189 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3190 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3191 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3192 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3193 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3194 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3195
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3196
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3197 EMSCRIPTEN_KEEPALIVE
1704
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3198 int LoadMultipartInstanceInViewport(const char* canvas,
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3199 const char* seriesInstanceUid,
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3200 const char* sopInstanceUid)
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3201 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3202 try
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3203 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3204 std::unique_ptr<OrthancStone::SortedFrames> frames(new OrthancStone::SortedFrames);
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3205
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3206 if (GetResourcesLoader().SortMultipartInstanceFrames(*frames, seriesInstanceUid, sopInstanceUid))
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3207 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3208 GetViewport(canvas)->SetFrames(frames.release());
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3209 return 1;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3210 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3211 else
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3212 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3213 return 0;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3214 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3215 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3216 EXTERN_CATCH_EXCEPTIONS;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3217 return 0;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3218 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3219
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3220
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3221 EMSCRIPTEN_KEEPALIVE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3222 void AllViewportsUpdateSize(int fitContent)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3223 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3224 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3225 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3226 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3227 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3228 assert(it->second != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3229 it->second->UpdateSize(fitContent != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3230 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3231 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3232 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3233 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3234
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3235
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3236 EMSCRIPTEN_KEEPALIVE
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3237 int DecrementFrame(const char* canvas,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3238 int isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3239 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3240 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3241 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3242 return GetViewport(canvas)->ChangeFrame(SeriesCursor::Action_Minus, isCircular) ? 1 : 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3243 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3244 EXTERN_CATCH_EXCEPTIONS;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3245 return 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3246 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3247
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3248
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3249 EMSCRIPTEN_KEEPALIVE
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3250 int IncrementFrame(const char* canvas,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3251 int isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3252 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3253 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3254 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3255 return GetViewport(canvas)->ChangeFrame(SeriesCursor::Action_Plus, isCircular) ? 1 : 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3256 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3257 EXTERN_CATCH_EXCEPTIONS;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3258 return 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3259 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3260
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3261
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3262 EMSCRIPTEN_KEEPALIVE
1719
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3263 void GoToFirstFrame(const char* canvas)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3264 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3265 try
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3266 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3267 GetViewport(canvas)->GoToFirstFrame();
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3268 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3269 EXTERN_CATCH_EXCEPTIONS;
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3270 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3271
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3272
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3273 EMSCRIPTEN_KEEPALIVE
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3274 void GoToLastFrame(const char* canvas)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3275 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3276 try
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3277 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3278 GetViewport(canvas)->GoToLastFrame();
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3279 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3280 EXTERN_CATCH_EXCEPTIONS;
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3281 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3282
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3283
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3284 EMSCRIPTEN_KEEPALIVE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3285 void ShowReferenceLines(int show)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3286 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3287 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3288 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3289 showReferenceLines_ = (show != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3290 UpdateReferenceLines();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3291 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3292 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3293 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3294
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3295
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3296 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3297 void SetWindowing(const char* canvas,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3298 int center,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3299 int width)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3300 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3301 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3302 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3303 GetViewport(canvas)->SetWindowing(center, width);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3304 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3305 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3306 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3307
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3308
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3309 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3310 void InvertContrast(const char* canvas)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3311 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3312 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3313 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3314 GetViewport(canvas)->Invert();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3315 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3316 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3317 }
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3318
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3319
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3320 EMSCRIPTEN_KEEPALIVE
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3321 void FlipX(const char* canvas)
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3322 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3323 try
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3324 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3325 GetViewport(canvas)->FlipX();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3326 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3327 EXTERN_CATCH_EXCEPTIONS;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3328 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3329
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3330
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3331 EMSCRIPTEN_KEEPALIVE
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3332 void FlipY(const char* canvas)
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3333 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3334 try
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3335 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3336 GetViewport(canvas)->FlipY();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3337 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3338 EXTERN_CATCH_EXCEPTIONS;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3339 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3340
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3341
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3342 EMSCRIPTEN_KEEPALIVE
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3343 void SetSoftwareRendering(int softwareRendering)
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3344 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3345 softwareRendering_ = softwareRendering;
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3346 }
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3347
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3348
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3349 EMSCRIPTEN_KEEPALIVE
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3350 int IsSoftwareRendering()
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3351 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3352 return softwareRendering_;
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3353 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3354
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3355
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3356 EMSCRIPTEN_KEEPALIVE
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3357 void SetMouseButtonActions(int leftAction,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3358 int middleAction,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3359 int rightAction)
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3360 {
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3361 try
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3362 {
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
3363 leftButtonAction_ = static_cast<WebViewerAction>(leftAction);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
3364 middleButtonAction_ = static_cast<WebViewerAction>(middleAction);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
3365 rightButtonAction_ = static_cast<WebViewerAction>(rightAction);
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3366
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3367 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3368 {
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3369 assert(it->second != NULL);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3370 it->second->SetMouseButtonActions(leftButtonAction_, middleButtonAction_, rightButtonAction_);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3371 }
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3372 }
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3373 EXTERN_CATCH_EXCEPTIONS;
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3374 }
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3375
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3376
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3377 EMSCRIPTEN_KEEPALIVE
1578
1f812f4c95be comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1576
diff changeset
3378 void FitForPrint()
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3379 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3380 try
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3381 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3382 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3383 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3384 assert(it->second != NULL);
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3385 it->second->FitForPrint();
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3386 }
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3387 }
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3388 EXTERN_CATCH_EXCEPTIONS;
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3389 }
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3390
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3391
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3392 // Side-effect: "GetStringBuffer()" is filled with the "Series
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3393 // Instance UID" of the first loaded annotation
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3394 EMSCRIPTEN_KEEPALIVE
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3395 int LoadOsiriXAnnotations(const char* xml,
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3396 int clearPreviousAnnotations)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3397 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3398 try
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3399 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3400 if (clearPreviousAnnotations)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3401 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3402 annotations_->Clear();
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3403 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3404
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3405 annotations_->LoadXml(xml);
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3406
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3407 // Force redraw, as the annotations might have changed
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3408 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3409 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3410 assert(it->second != NULL);
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3411 it->second->Redraw();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3412 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3413
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3414 if (annotations_->GetSize() == 0)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3415 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3416 stringBuffer_.clear();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3417 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3418 else
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3419 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3420 stringBuffer_ = annotations_->GetAnnotation(0).GetSeriesInstanceUid();
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3421 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3422
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3423 LOG(WARNING) << "Loaded " << annotations_->GetSize() << " annotations from OsiriX";
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3424 return 1;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3425 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3426 EXTERN_CATCH_EXCEPTIONS;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3427 return 0;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3428 }
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3429
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3430
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3431 EMSCRIPTEN_KEEPALIVE
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3432 void FocusFirstOsiriXAnnotation(const char* canvas)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3433 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3434 try
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3435 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3436 if (annotations_->GetSize() != 0)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3437 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3438 const OrthancStone::OsiriX::Annotation& annotation = annotations_->GetAnnotation(0);
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3439
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3440 boost::shared_ptr<ViewerViewport> viewport = GetViewport(canvas);
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3441 viewport->ScheduleFrameFocus(annotation.GetSopInstanceUid(), 0 /* focus on first frame */);
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3442
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3443 // Force redraw, as the annotations might already have changed
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3444 viewport->Redraw();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3445 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3446 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3447 EXTERN_CATCH_EXCEPTIONS;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3448 }
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3449
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3450
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3451 EMSCRIPTEN_KEEPALIVE
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3452 void FetchPdf(const char* studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3453 const char* seriesInstanceUid)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3454 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3455 try
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3456 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3457 LOG(INFO) << "Fetching PDF series: " << seriesInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3458 GetResourcesLoader().FetchPdf(studyInstanceUid, seriesInstanceUid);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3459 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3460 EXTERN_CATCH_EXCEPTIONS;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3461 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3462
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3463
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3464 EMSCRIPTEN_KEEPALIVE
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3465 unsigned int GetCineRate(const char* canvas)
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3466 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3467 try
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3468 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3469 return GetViewport(canvas)->GetCineRate();
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3470 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3471 EXTERN_CATCH_EXCEPTIONS;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3472 return 0;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3473 }
1674
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3474
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3475
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3476 EMSCRIPTEN_KEEPALIVE
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3477 unsigned int GetSeriesNumberOfFrames(const char* seriesInstanceUid)
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3478 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3479 try
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3480 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3481 return GetResourcesLoader().GetSeriesNumberOfFrames(seriesInstanceUid);
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3482 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3483 EXTERN_CATCH_EXCEPTIONS;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3484 return 0;
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3485 }
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3486
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3487
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3488 EMSCRIPTEN_KEEPALIVE
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3489 void LoadWindowingPresets(const char* canvas)
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3490 {
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3491 try
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3492 {
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3493 Json::Value v;
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3494 GetViewport(canvas)->FormatWindowingPresets(v);
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3495 stringBuffer_ = v.toStyledString();
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3496 }
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3497 EXTERN_CATCH_EXCEPTIONS;
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3498 }
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3499
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3500
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3501 EMSCRIPTEN_KEEPALIVE
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3502 void SetSynchronizedBrowsingEnabled(int enabled)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3503 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3504 try
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3505 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3506 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3507 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3508 assert(it->second != NULL);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3509 it->second->SetSynchronizedBrowsingEnabled(enabled);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3510 }
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3511 }
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3512 EXTERN_CATCH_EXCEPTIONS;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3513 }
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3514
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3515
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3516 EMSCRIPTEN_KEEPALIVE
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3517 int LoadMultiframeInstancesFromSeries(const char* seriesInstanceUid)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3518 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3519 try
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3520 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3521 std::map<std::string, unsigned int> numberOfFramesPerInstance;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3522 if (GetResourcesLoader().LookupMultiframeSeries(numberOfFramesPerInstance, seriesInstanceUid))
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3523 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3524 Json::Value json = Json::objectValue;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3525 for (std::map<std::string, unsigned int>::const_iterator it =
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3526 numberOfFramesPerInstance.begin(); it != numberOfFramesPerInstance.end(); ++it)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3527 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3528 json[it->first] = it->second;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3529 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3530
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3531 stringBuffer_ = json.toStyledString();
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3532 return true;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3533 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3534 else
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3535 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3536 return false;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3537 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3538 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3539 EXTERN_CATCH_EXCEPTIONS;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3540 return false;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3541 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3542 }