annotate Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1675:6fa05252b085

don't load low-quality image if the parsed dicom file is cached by the oracle
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 23 Nov 2020 18:09:14 +0100
parents 0621e523b670
children 5e76d5e8167a
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 #include <boost/make_shared.hpp>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 #include <stdio.h>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
101 #if !defined(STONE_WEB_VIEWER_EXPORT)
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
102 // 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
103 # define STONE_WEB_VIEWER_EXPORT
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
104 #endif
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
105
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 enum STONE_WEB_VIEWER_EXPORT ThumbnailType
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 ThumbnailType_Image,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 ThumbnailType_NoPreview,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 ThumbnailType_Pdf,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 ThumbnailType_Video,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 ThumbnailType_Loading,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 ThumbnailType_Unknown
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
115 };
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
118 enum STONE_WEB_VIEWER_EXPORT DisplayedFrameQuality
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
120 DisplayedFrameQuality_None,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
121 DisplayedFrameQuality_Low,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
122 DisplayedFrameQuality_High
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
123 };
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
124
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
125
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
126 enum STONE_WEB_VIEWER_EXPORT WebViewerAction
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
127 {
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
128 WebViewerAction_GrayscaleWindowing,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
129 WebViewerAction_Zoom,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
130 WebViewerAction_Pan,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
131 WebViewerAction_Rotate,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
132 WebViewerAction_Crosshair
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
133 };
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
137 static OrthancStone::MouseAction ConvertWebViewerAction(int action)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
138 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
139 switch (action)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
140 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
141 case WebViewerAction_GrayscaleWindowing:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
142 return OrthancStone::MouseAction_GrayscaleWindowing;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
143
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
144 case WebViewerAction_Zoom:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
145 return OrthancStone::MouseAction_Zoom;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
146
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
147 case WebViewerAction_Pan:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
148 return OrthancStone::MouseAction_Pan;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
149
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
150 case WebViewerAction_Rotate:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
151 return OrthancStone::MouseAction_Rotate;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
152
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
153 case WebViewerAction_Crosshair:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
154 return OrthancStone::MouseAction_None;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
155
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
156 default:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
157 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
158 }
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
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
161
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
162
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 static const int PRIORITY_HIGH = -100;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 static const int PRIORITY_LOW = 100;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 static const int PRIORITY_NORMAL = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 static const unsigned int QUALITY_JPEG = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 static const unsigned int QUALITY_FULL = 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
170 static const unsigned int DEFAULT_CINE_RATE = 30;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
171
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
172
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 class ResourcesLoader : public OrthancStone::ObserverBase<ResourcesLoader>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 class IObserver : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 virtual ~IObserver()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 {
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 virtual void SignalResourcesLoaded() = 0;
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 virtual void SignalSeriesThumbnailLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 const std::string& seriesInstanceUid) = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 virtual void SignalSeriesMetadataLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 const std::string& seriesInstanceUid) = 0;
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
190
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
191 virtual void SignalSeriesPdfLoaded(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
192 const std::string& seriesInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
193 const std::string& pdf) = 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 private:
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
197 OrthancStone::ILoadersContext& context_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 std::unique_ptr<IObserver> observer_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 OrthancStone::DicomSource source_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 size_t pending_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 boost::shared_ptr<OrthancStone::LoadedDicomResources> studies_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 boost::shared_ptr<OrthancStone::LoadedDicomResources> series_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 boost::shared_ptr<OrthancStone::DicomResourcesLoader> resourcesLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 boost::shared_ptr<OrthancStone::SeriesThumbnailsLoader> thumbnailsLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 boost::shared_ptr<OrthancStone::SeriesMetadataLoader> metadataLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
207 explicit ResourcesLoader(OrthancStone::ILoadersContext& context,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
208 const OrthancStone::DicomSource& source) :
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
209 context_(context),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 source_(source),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 pending_(0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 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
213 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
214 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 void Handle(const OrthancStone::DicomResourcesLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 const Orthanc::SingleValueObject<Orthanc::ResourceType>& payload =
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 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
221
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 OrthancStone::LoadedDicomResources& dicom = *message.GetResources();
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 LOG(INFO) << "resources loaded: " << dicom.GetSize()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 << ", " << Orthanc::EnumerationToString(payload.GetValue());
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 if (payload.GetValue() == Orthanc::ResourceType_Series)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 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
230 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 std::string studyInstanceUid, seriesInstanceUid;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 if (dicom.GetResource(i).LookupStringValue(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 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
234 dicom.GetResource(i).LookupStringValue(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 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
236 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 thumbnailsLoader_->ScheduleLoadThumbnail(source_, "", studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 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
239 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 if (pending_ == 0)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 else
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 pending_ --;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 if (pending_ == 0 &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 observer_.get() != NULL)
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 observer_->SignalResourcesLoaded();
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 }
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 void Handle(const OrthancStone::SeriesThumbnailsLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 if (observer_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 observer_->SignalSeriesThumbnailLoaded(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 message.GetStudyInstanceUid(), message.GetSeriesInstanceUid());
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 void Handle(const OrthancStone::SeriesMetadataLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 if (observer_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 observer_->SignalSeriesMetadataLoaded(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 message.GetStudyInstanceUid(), message.GetSeriesInstanceUid());
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 void FetchInternal(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 const std::string& seriesInstanceUid)
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 // Firstly, load the study
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 Orthanc::DicomMap filter;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false);
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 std::set<Orthanc::DicomTag> tags;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 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
285
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 resourcesLoader_->ScheduleQido(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 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
288 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
289
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 // Secondly, load the series
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 if (!seriesInstanceUid.empty())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 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
294 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 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
297
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 resourcesLoader_->ScheduleQido(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 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
300 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
301
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 pending_ += 2;
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
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
305
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
306 class PdfInfo : public Orthanc::IDynamicObject
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
307 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
308 private:
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
309 std::string studyInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
310 std::string seriesInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
311
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
312 public:
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
313 PdfInfo(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
314 const std::string& seriesInstanceUid) :
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
315 studyInstanceUid_(studyInstanceUid),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
316 seriesInstanceUid_(seriesInstanceUid)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
317 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
318 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
319
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
320 const std::string& GetStudyInstanceUid() const
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
321 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
322 return studyInstanceUid_;
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
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
325 const std::string& GetSeriesInstanceUid() const
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
326 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
327 return seriesInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
328 }
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
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
331
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
332 void Handle(const OrthancStone::ParseDicomSuccessMessage& message)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
333 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
334 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
335
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
336 if (observer_.get() != NULL)
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 std::string pdf;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
339 if (message.GetDicom().ExtractPdf(pdf))
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
340 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
341 observer_->SignalSeriesPdfLoaded(info.GetStudyInstanceUid(), info.GetSeriesInstanceUid(), pdf);
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 else
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 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
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
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 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
352 const OrthancStone::DicomSource& source)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 {
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
354 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
355
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 loader->resourcesLoader_ = OrthancStone::DicomResourcesLoader::Create(lock);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 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
358 loader->metadataLoader_ = OrthancStone::SeriesMetadataLoader::Create(lock);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 loader->Register<OrthancStone::DicomResourcesLoader::SuccessMessage>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 *loader->resourcesLoader_, &ResourcesLoader::Handle);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 loader->Register<OrthancStone::SeriesThumbnailsLoader::SuccessMessage>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 *loader->thumbnailsLoader_, &ResourcesLoader::Handle);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 loader->Register<OrthancStone::SeriesMetadataLoader::SuccessMessage>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 *loader->metadataLoader_, &ResourcesLoader::Handle);
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
368
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
369 loader->Register<OrthancStone::ParseDicomSuccessMessage>(
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
370 lock.GetOracleObservable(), &ResourcesLoader::Handle);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 return loader;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 void FetchAllStudies()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 FetchInternal("", "");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 void FetchStudy(const std::string& studyInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 FetchInternal(studyInstanceUid, "");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 void FetchSeries(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 const std::string& seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 FetchInternal(studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 size_t GetStudiesCount() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 return studies_->GetSize();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 size_t GetSeriesCount() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 return series_->GetSize();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 void GetStudy(Orthanc::DicomMap& target,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 size_t i)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 target.Assign(studies_->GetResource(i));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 void GetSeries(Orthanc::DicomMap& target,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 size_t i)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 target.Assign(series_->GetResource(i));
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 // Complement with the study-level tags
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 std::string studyInstanceUid;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 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
415 studies_->HasResource(studyInstanceUid))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 studies_->MergeResource(target, studyInstanceUid);
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 OrthancStone::SeriesThumbnailType GetSeriesThumbnail(std::string& image,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 std::string& mime,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 const std::string& seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 return thumbnailsLoader_->GetSeriesThumbnail(image, mime, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 void FetchSeriesMetadata(int priority,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 const std::string& seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 metadataLoader_->ScheduleLoadSeries(priority, source_, studyInstanceUid, seriesInstanceUid);
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 bool IsSeriesComplete(const std::string& seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 return accessor.IsComplete();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 bool SortSeriesFrames(OrthancStone::SortedFrames& target,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 const std::string& seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
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 if (accessor.IsComplete())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 target.Clear();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 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
451 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 target.AddInstance(accessor.GetInstance(i));
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 target.Sort();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 return true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 return false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 }
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
1674
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
465 size_t GetSeriesNumberOfFrames(const std::string& seriesInstanceUid) const
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
466 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
467 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
468
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
469 if (accessor.IsComplete())
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
470 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
471 size_t count = 0;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
472
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
473 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
474 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
475 uint32_t f;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
476 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
477 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
478 count += f;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
479 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
480 else
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
481 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
482 count++;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
483 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
484 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
485
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
486 return count;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
487 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
488 else
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
489 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
490 return 0;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
491 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
492 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
493
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 void AcquireObserver(IObserver* observer)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 observer_.reset(observer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 }
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
498
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
499 void FetchPdf(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
500 const std::string& seriesInstanceUid)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
501 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
502 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
503
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
504 if (accessor.IsComplete())
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
505 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
506 if (accessor.GetInstancesCount() > 1)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
507 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
508 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
509 << seriesInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
510 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
511
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
512 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
513 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
514 std::string sopClassUid, sopInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
515 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
516 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
517 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
518 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
519 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock());
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
520 lock->Schedule(
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
521 GetSharedObserver(), PRIORITY_NORMAL, OrthancStone::ParseDicomFromWadoCommand::Create(
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
522 source_, studyInstanceUid, seriesInstanceUid, sopInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
523 false /* no transcoding */, Orthanc::DicomTransferSyntax_LittleEndianExplicit /* dummy value */,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
524 new PdfInfo(studyInstanceUid, seriesInstanceUid)));
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
525
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
526 return;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
527 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
528 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
529
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
530 LOG(WARNING) << "Series without a PDF: " << seriesInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
531 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
532 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 class FramesCache : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 class CachedImage : public Orthanc::ICacheable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 std::unique_ptr<Orthanc::ImageAccessor> image_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 unsigned int quality_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 CachedImage(Orthanc::ImageAccessor* image,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 unsigned int quality) :
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 image_(image),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550 quality_(quality)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 assert(image != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1565
diff changeset
555 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
556 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 assert(image_.get() != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 return (image_->GetBytesPerPixel() * image_->GetPitch() * image_->GetHeight());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 }
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 const Orthanc::ImageAccessor& GetImage() const
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 assert(image_.get() != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 return *image_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 }
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 unsigned int GetQuality() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 return quality_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 }
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
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 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
575 size_t frameNumber)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 {
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
577 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
578 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 Orthanc::MemoryObjectCache cache_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 FramesCache()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 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
587 //SetMaximumSize(1); // DISABLE CACHE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590 size_t GetMaximumSize()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 return cache_.GetMaximumSize();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 void SetMaximumSize(size_t size)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 cache_.SetMaximumSize(size);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 * 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
602 * 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
603 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 bool Acquire(const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
605 size_t frameNumber,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 Orthanc::ImageAccessor* image /* transfer ownership */,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607 unsigned int quality)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 std::unique_ptr<Orthanc::ImageAccessor> protection(image);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 if (image == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 else if (image->GetFormat() != Orthanc::PixelFormat_Float32 &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 image->GetFormat() != Orthanc::PixelFormat_RGB24)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
621 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
622
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 bool invalidate = false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 * 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
628 * 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
629 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 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
631
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 if (accessor.IsValid())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634 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
635
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 // 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
637 if (previous.GetQuality() < quality)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 // The previously stored image has poorer quality
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640 invalidate = true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
644 // 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
645 return false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 invalidate = false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 if (invalidate)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656 cache_.Invalidate(key);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659 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
660 return true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
662
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 class Accessor : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666 Orthanc::MemoryObjectCache::Accessor accessor_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
667
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
668 const CachedImage& GetCachedImage() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 if (IsValid())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672 return dynamic_cast<CachedImage&>(accessor_.GetValue());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
674 else
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681 Accessor(FramesCache& that,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
683 size_t frameNumber) :
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
684 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
685 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 }
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 bool IsValid() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
690 return accessor_.IsValid();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 const Orthanc::ImageAccessor& GetImage() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
694 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 return GetCachedImage().GetImage();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
696 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
697
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698 unsigned int GetQuality() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
699 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
700 return GetCachedImage().GetQuality();
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 };
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707 class SeriesCursor : public boost::noncopyable
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 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 enum Action
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 Action_FastPlus,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 Action_Plus,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714 Action_None,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715 Action_Minus,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 Action_FastMinus
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 std::vector<size_t> prefetch_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 int framesCount_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722 int currentFrame_;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
723 bool isCircularPrefetch_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724 int fastDelta_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 Action lastAction_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727 int ComputeNextFrame(int currentFrame,
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
728 Action action,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
729 bool isCircular) const
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 if (framesCount_ == 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733 assert(currentFrame == 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734 return 0;
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 int nextFrame = currentFrame;
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 switch (action)
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 case Action_FastPlus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 nextFrame += fastDelta_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 case Action_Plus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 nextFrame += 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 case Action_None:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 case Action_Minus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 nextFrame -= 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 case Action_FastMinus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 nextFrame -= fastDelta_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 break;
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 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
764 if (isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766 while (nextFrame < 0)
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 nextFrame += framesCount_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771 while (nextFrame >= framesCount_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
772 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773 nextFrame -= framesCount_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774 }
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 else
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 if (nextFrame < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 nextFrame = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782 else if (nextFrame >= framesCount_)
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 nextFrame = framesCount_ - 1;
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 return nextFrame;
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 void UpdatePrefetch()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792 {
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 * 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
795 * 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
796 * 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
797 * 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
798 * will do the same action just afterwards.
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 prefetch_.clear();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803 if (framesCount_ == 0)
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 return;
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 prefetch_.reserve(framesCount_);
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 // 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
811 // 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
812 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
813
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 Queue queue;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 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
816
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817 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
818
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 while (!queue.empty())
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 int frame = queue.front().first;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822 Action previousAction = queue.front().second;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823 queue.pop_front();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
825 if (visited.find(frame) == visited.end())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
826 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
827 visited.insert(frame);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828 prefetch_.push_back(frame);
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 switch (previousAction)
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 case Action_None:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 case Action_Plus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
834 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
835 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
836 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
837 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
838 break;
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 case Action_Minus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
841 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
842 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
843 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
844 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
845 break;
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 case Action_FastPlus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
848 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
849 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
850 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
851 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
852 break;
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 case Action_FastMinus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
855 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
856 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
857 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
858 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
859 break;
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 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
863 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
864 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
866
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 assert(prefetch_.size() == framesCount_);
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
870 bool CheckFrameIndex(int frame) const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
871 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872 return ((framesCount_ == 0 && frame == 0) ||
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
873 (framesCount_ > 0 && frame >= 0 && frame < framesCount_));
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
876 public:
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1565
diff changeset
877 explicit SeriesCursor(size_t framesCount) :
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878 framesCount_(framesCount),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
879 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
880 isCircularPrefetch_(false),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
881 lastAction_(Action_None)
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 SetFastDelta(framesCount / 20);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
884 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
885 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
886
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
887 void SetCircularPrefetch(bool isCircularPrefetch)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
888 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
889 isCircularPrefetch_ = isCircularPrefetch;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
890 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
892
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893 void SetFastDelta(int delta)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 fastDelta_ = (delta < 0 ? -delta : delta);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 if (fastDelta_ <= 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899 fastDelta_ = 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 }
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
903 void SetCurrentIndex(size_t frame)
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 if (frame >= framesCount_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
906 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
907 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
908 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
909 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
910 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911 currentFrame_ = frame;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
912 lastAction_ = Action_None;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913 UpdatePrefetch();
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 }
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 size_t GetCurrentIndex() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919 assert(CheckFrameIndex(currentFrame_));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920 return static_cast<size_t>(currentFrame_);
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
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
923 void Apply(Action action,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
924 bool isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
925 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
926 currentFrame_ = ComputeNextFrame(currentFrame_, action, isCircular);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927 lastAction_ = action;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928 UpdatePrefetch();
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
931 size_t GetPrefetchSize() const
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 assert(prefetch_.size() == framesCount_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934 return prefetch_.size();
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
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
937 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
938 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
939 if (i >= prefetch_.size())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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 else
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 assert(CheckFrameIndex(prefetch_[i]));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 return static_cast<size_t>(prefetch_[i]);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947 }
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
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
953
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
954 /**
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
955 * 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
956 * 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
957 * checked by this function.
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
958 **/
1646
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
959 static bool GetReferenceLineCoordinates(double& x1,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
960 double& y1,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
961 double& x2,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
962 double& y2,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
963 const OrthancStone::DicomInstanceParameters& instance1,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
964 unsigned int frame1,
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
965 const OrthancStone::CoordinateSystem3D& plane2)
1646
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
966 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
967 if (instance1.GetWidth() == 0 &&
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
968 instance1.GetHeight() == 0)
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
969 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
970 return false;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
971 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
972 else
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
973 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
974 /**
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
975 * Compute the 2D extent of the "instance1", expressed in
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
976 * 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
977 *
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
978 * In a multiframe image (cf. "ExtractFrameOffsets()"), the plane of
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
979 * 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
980 * 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
981 * frame, so we can ignore the frame number.
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
982 **/
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
983 OrthancStone::Extent2D extent;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
984
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
985 double ox = -instance1.GetPixelSpacingX() / 2.0;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
986 double oy = -instance1.GetPixelSpacingY() / 2.0;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
987 extent.AddPoint(ox, oy);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
988 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
989 oy + instance1.GetPixelSpacingY() * static_cast<double>(instance1.GetHeight()));
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
990
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
991 const OrthancStone::CoordinateSystem3D c1 = instance1.GetFrameGeometry(frame1);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
992
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
993 OrthancStone::Vector direction, origin;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
994
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
995 if (!extent.IsEmpty() &&
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
996 OrthancStone::GeometryToolbox::IntersectTwoPlanes(origin, direction,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
997 c1.GetOrigin(), c1.GetNormal(),
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
998 plane2.GetOrigin(), plane2.GetNormal()))
1646
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
999 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1000 double ax, ay, bx, by;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1001 c1.ProjectPoint(ax, ay, origin);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1002 c1.ProjectPoint(bx, by, origin + 100.0 * direction);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1003
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1004 return OrthancStone::GeometryToolbox::ClipLineToRectangle(
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1005 x1, y1, x2, y2,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1006 ax, ay, bx, by,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1007 extent.GetX1(), extent.GetY1(), extent.GetX2(), extent.GetY2());
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1008 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1009 else
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1010 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1011 return false;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1012 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1013 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1014 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1015
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1016
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1017
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1018 class ViewerViewport : public OrthancStone::ObserverBase<ViewerViewport>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1019 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1020 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021 class IObserver : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1022 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1023 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1024 virtual ~IObserver()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1027
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1028 virtual void SignalSeriesDetailsReady(const ViewerViewport& viewport) = 0;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1029
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1030 virtual void SignalFrameUpdated(const ViewerViewport& viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1031 size_t currentFrame,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1032 size_t countFrames,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1033 DisplayedFrameQuality quality) = 0;
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
1034
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
1035 virtual void SignalCrosshair(const OrthancStone::Vector& click) = 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039 static const int LAYER_TEXTURE = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040 static const int LAYER_REFERENCE_LINES = 1;
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1041 static const int LAYER_ANNOTATIONS = 2;
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1607
diff changeset
1042
1495
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 class ICommand : public Orthanc::IDynamicObject
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 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1047 boost::shared_ptr<ViewerViewport> viewport_;
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 public:
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1565
diff changeset
1050 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
1051 viewport_(viewport)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 if (viewport == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1055 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1056 }
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1059 virtual ~ICommand()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1060 {
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 ViewerViewport& GetViewport() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 assert(viewport_ != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 return *viewport_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067 }
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 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
1070 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1071 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1072 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1073
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1074 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
1075 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1076 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1079 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
1080 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1081 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
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 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1084
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1085 class LoadSeriesDetailsFromInstance : public ICommand
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1086 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1087 public:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1088 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
1089 ICommand(viewport)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1090 {
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1093 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
1094 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 if (message.GetResources()->GetSize() != 1)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
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 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
1101
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1102 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1103 OrthancStone::DicomInstanceParameters params(dicom);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1104
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1105 if (params.HasDefaultWindowing())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1106 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1107 GetViewport().defaultWindowingCenter_ = params.GetDefaultWindowingCenter();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1108 GetViewport().defaultWindowingWidth_ = params.GetDefaultWindowingWidth();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1109 LOG(INFO) << "Default windowing: " << params.GetDefaultWindowingCenter()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1110 << "," << params.GetDefaultWindowingWidth();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1111
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1112 GetViewport().windowingCenter_ = params.GetDefaultWindowingCenter();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1113 GetViewport().windowingWidth_ = params.GetDefaultWindowingWidth();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1114 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1115 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1116 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1117 LOG(INFO) << "No default windowing";
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1118 GetViewport().ResetDefaultWindowing();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1119 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1120 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1121
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1122 uint32_t cineRate;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1123 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
1124 cineRate > 0)
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1125 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1126 /**
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1127 * 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
1128 * instead of on the middle frame.
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1129 **/
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1130 GetViewport().cursor_->SetCurrentIndex(0);
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1131 GetViewport().cineRate_ = cineRate;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1132 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1133 else
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1134 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1135 GetViewport().cineRate_ = DEFAULT_CINE_RATE;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1136 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1137
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1138 GetViewport().Redraw();
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1139
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1140 if (GetViewport().observer_.get() != NULL)
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1141 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1142 GetViewport().observer_->SignalSeriesDetailsReady(GetViewport());
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1143 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1144 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1145 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1146
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1147
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1148 class SetLowQualityFrame : public ICommand
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1149 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1150 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1151 std::string sopInstanceUid_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1152 unsigned int frameNumber_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1153 float windowCenter_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1154 float windowWidth_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1155 bool isMonochrome1_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1156 bool isPrefetch_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1157
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1158 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1159 SetLowQualityFrame(boost::shared_ptr<ViewerViewport> viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1160 const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1161 unsigned int frameNumber,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1162 float windowCenter,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1163 float windowWidth,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1164 bool isMonochrome1,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1165 bool isPrefetch) :
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1166 ICommand(viewport),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1167 sopInstanceUid_(sopInstanceUid),
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1168 frameNumber_(frameNumber),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1169 windowCenter_(windowCenter),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1170 windowWidth_(windowWidth),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1171 isMonochrome1_(isMonochrome1),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1172 isPrefetch_(isPrefetch)
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1175
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1176 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
1177 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1178 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
1179 jpeg->ReadFromMemory(message.GetAnswer());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1180
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1181 std::unique_ptr<Orthanc::ImageAccessor> converted;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1182
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1183 switch (jpeg->GetFormat())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1184 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1185 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
1186 converted.reset(jpeg.release());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1187 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1188
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1189 case Orthanc::PixelFormat_Grayscale8:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1190 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1191 if (isMonochrome1_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1192 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1193 Orthanc::ImageProcessing::Invert(*jpeg);
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
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1196 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
1197 jpeg->GetHeight(), false));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1198
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1199 Orthanc::ImageProcessing::Convert(*converted, *jpeg);
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 /**
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 Orthanc::ImageProcessing::ShiftScale() computes "(x + offset) * scaling".
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1204 The system to solve is thus:
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 (0 + offset) * scaling = windowingCenter - windowingWidth / 2 [a]
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1207 (255 + offset) * scaling = windowingCenter + windowingWidth / 2 [b]
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1208
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1209 Resolution:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1210
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1211 [b - a] => 255 * scaling = windowingWidth
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1212 [a] => offset = (windowingCenter - windowingWidth / 2) / scaling
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 const float scaling = windowWidth_ / 255.0f;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1217 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
1218 (windowCenter_ - windowWidth_ / 2.0f) / scaling);
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 Orthanc::ImageProcessing::ShiftScale(*converted, offset, scaling, false);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1221 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1222 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1223
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1224 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1225 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1226 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1227
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1228 assert(converted.get() != NULL);
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1229 GetViewport().RenderCurrentSceneFromCommand(*converted, sopInstanceUid_, frameNumber_, DisplayedFrameQuality_Low);
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1230 GetViewport().cache_->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
1231
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1232 if (isPrefetch_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1233 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1234 GetViewport().ScheduleNextPrefetch();
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 }
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
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 class SetFullDicomFrame : public ICommand
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1241 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1242 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1243 std::string sopInstanceUid_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1244 unsigned int frameNumber_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1245 bool isPrefetch_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1246
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1247 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1248 SetFullDicomFrame(boost::shared_ptr<ViewerViewport> viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1249 const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1250 unsigned int frameNumber,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1251 bool isPrefetch) :
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1252 ICommand(viewport),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1253 sopInstanceUid_(sopInstanceUid),
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1254 frameNumber_(frameNumber),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1255 isPrefetch_(isPrefetch)
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 }
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 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
1260 {
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
1261 Apply(GetViewport(), message.GetDicom(), sopInstanceUid_, frameNumber_);
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
1262
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
1263 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
1264 {
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
1265 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
1266 }
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
1267 }
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
1268
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
1269 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
1270 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
1271 const std::string& sopInstanceUid,
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
1272 unsigned int frameNumber)
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
1273 {
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1274 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
1275 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
1276
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1277 std::string s;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1278 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
1279 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1280 // Safety check
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1281 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1282 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1283
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
1284 std::unique_ptr<Orthanc::ImageAccessor> frame(dicom.DecodeFrame(frameNumber));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1285
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1286 if (frame.get() == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1287 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1288 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1289 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1290
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1291 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
1292
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1293 if (frame->GetFormat() == Orthanc::PixelFormat_RGB24)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1294 {
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1295 converted.reset(frame.release());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1296 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1297 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1298 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1299 double a = 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1300 double b = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1301
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1302 double doseScaling;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1303 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
1304 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1305 a = doseScaling;
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1308 double rescaleIntercept, rescaleSlope;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1309 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
1310 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
1311 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1312 a *= rescaleSlope;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1313 b = rescaleIntercept;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1314 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1315
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1316 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
1317 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
1318 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
1319 }
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1320
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1321 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
1322 viewport.RenderCurrentSceneFromCommand(*converted, sopInstanceUid, frameNumber, DisplayedFrameQuality_High);
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
1323 viewport.cache_->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
1324 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1325 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1326
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1327
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1328 class PrefetchItem
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1329 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1330 private:
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1331 size_t cursorIndex_;
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1332 bool isFullQuality_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1333
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1334 public:
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1335 PrefetchItem(size_t cursorIndex,
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1336 bool isFullQuality) :
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1337 cursorIndex_(cursorIndex),
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1338 isFullQuality_(isFullQuality)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1339 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1340 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1341
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1342 size_t GetCursorIndex() const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1343 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1344 return cursorIndex_;
1495
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
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1347 bool IsFullQuality() const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1348 {
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1349 return isFullQuality_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1350 }
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1353
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1354 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
1355 OrthancStone::WebAssemblyLoadersContext& context_;
1551
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
1356 boost::shared_ptr<OrthancStone::WebAssemblyViewport> viewport_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1357 boost::shared_ptr<OrthancStone::DicomResourcesLoader> loader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1358 OrthancStone::DicomSource source_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1359 boost::shared_ptr<FramesCache> cache_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1360 std::unique_ptr<OrthancStone::SortedFrames> frames_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1361 std::unique_ptr<SeriesCursor> cursor_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1362 float windowingCenter_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1363 float windowingWidth_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1364 float defaultWindowingCenter_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1365 float defaultWindowingWidth_;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1366 unsigned int cineRate_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1367 bool inverted_;
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1368 bool flipX_;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1369 bool flipY_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1370 bool fitNextContent_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1371 bool isCtrlDown_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1372 std::list<PrefetchItem> prefetchQueue_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1373
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1374
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1375 bool hasFocusOnInstance_;
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1376 std::string focusSopInstanceUid_;
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1377 size_t focusFrameNumber_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1378
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1379 boost::shared_ptr<OrthancStone::OsiriX::CollectionOfAnnotations> annotations_;
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1380
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1381 void ScheduleNextPrefetch()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1382 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1383 while (!prefetchQueue_.empty())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1384 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1385 size_t cursorIndex = prefetchQueue_.front().GetCursorIndex();
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1386 bool isFullQuality = prefetchQueue_.front().IsFullQuality();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1387 prefetchQueue_.pop_front();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1388
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1389 const std::string sopInstanceUid = frames_->GetInstanceOfFrame(cursorIndex).GetSopInstanceUid();
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1390 unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1391
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1392 {
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1393 FramesCache::Accessor accessor(*cache_, sopInstanceUid, frameNumber);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1394 if (!accessor.IsValid() ||
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1395 (isFullQuality && accessor.GetQuality() == 0))
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1396 {
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1397 if (isFullQuality)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1398 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1399 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_NORMAL, true);
1495
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 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1402 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1403 ScheduleLoadRenderedFrame(cursorIndex, PRIORITY_NORMAL, true);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1404 }
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1405
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1406 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
1407 }
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1410 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1411
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1412
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1413 void ResetDefaultWindowing()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1414 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1415 defaultWindowingCenter_ = 128;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1416 defaultWindowingWidth_ = 256;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1417
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1418 windowingCenter_ = defaultWindowingCenter_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1419 windowingWidth_ = defaultWindowingWidth_;
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 inverted_ = false;
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1424
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1425 void ClearViewport()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1426 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1427 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1428 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
1429 lock->GetController().GetScene().DeleteLayer(LAYER_TEXTURE);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1430 //lock->GetCompositor().Refresh(lock->GetController().GetScene());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1431 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1432 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1433 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1434
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1435
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1436 void SaveCurrentWindowing()
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1437 {
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1438 // Save the current windowing (that could have been altered by
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1439 // GrayscaleWindowingSceneTracker), so that it can be reused
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1440 // by the next frames
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1441
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1442 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1443
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1444 OrthancStone::Scene2D& scene = lock->GetController().GetScene();
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1445
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1446 if (scene.HasLayer(LAYER_TEXTURE) &&
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1447 scene.GetLayer(LAYER_TEXTURE).GetType() == OrthancStone::ISceneLayer::Type_FloatTexture)
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1448 {
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1449 OrthancStone::FloatTextureSceneLayer& layer =
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1450 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(scene.GetLayer(LAYER_TEXTURE));
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1451 layer.GetWindowing(windowingCenter_, windowingWidth_);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1452 }
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1453 }
1644
4796fb60999e removing methods from SortedFrames to simplify api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1633
diff changeset
1454
4796fb60999e removing methods from SortedFrames to simplify api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1633
diff changeset
1455
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1456 void SetupPrefetchAfterRendering(DisplayedFrameQuality quality)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1457 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1458 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
1459
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1460 // Prepare prefetching
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1461 prefetchQueue_.clear();
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1462
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1463 if (1) // TODO - DISABLE PREFETCHING
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1464 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1465 for (size_t i = 0; i < cursor_->GetPrefetchSize() && i < 16; i++)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1466 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1467 size_t a = cursor_->GetPrefetchIndex(i);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1468 if (a != cursorIndex)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1469 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1470 prefetchQueue_.push_back(PrefetchItem(a, i < 2));
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1471 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1472 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1473 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1474
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1475 ScheduleNextPrefetch();
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1476
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1477 if (observer_.get() != NULL)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1478 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1479 observer_->SignalFrameUpdated(*this, cursor_->GetCurrentIndex(),
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1480 frames_->GetFramesCount(), quality);
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1481 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1482 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1483
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1484
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1485 void RenderCurrentScene(const Orthanc::ImageAccessor& frame,
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1486 const OrthancStone::DicomInstanceParameters& instance,
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1487 const OrthancStone::CoordinateSystem3D& plane)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1488 {
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1489 SaveCurrentWindowing();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1490
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1491 bool isMonochrome1 = (instance.GetImageInformation().GetPhotometricInterpretation() ==
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1492 Orthanc::PhotometricInterpretation_Monochrome1);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1493
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1494 std::unique_ptr<OrthancStone::TextureBaseSceneLayer> layer;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1495
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1496 switch (frame.GetFormat())
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1497 {
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1498 case Orthanc::PixelFormat_RGB24:
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1499 layer.reset(new OrthancStone::ColorTextureSceneLayer(frame));
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1500 break;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1501
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1502 case Orthanc::PixelFormat_Float32:
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1503 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1504 std::unique_ptr<OrthancStone::FloatTextureSceneLayer> tmp(
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1505 new OrthancStone::FloatTextureSceneLayer(frame));
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1506 tmp->SetCustomWindowing(windowingCenter_, windowingWidth_);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1507 tmp->SetInverted(inverted_ ^ isMonochrome1);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1508 layer.reset(tmp.release());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1509 break;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1510 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1511
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1512 default:
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1513 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
1495
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
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1516 assert(layer.get() != NULL);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1517
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1518 layer->SetLinearInterpolation(true);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1519 layer->SetFlipX(flipX_);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1520 layer->SetFlipY(flipY_);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1521
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1522 double pixelSpacingX, pixelSpacingY;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1523 OrthancStone::GeometryToolbox::GetPixelSpacing(pixelSpacingX, pixelSpacingY, instance.GetTags());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1524 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1525
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1526 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsLayer;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1527
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1528 if (annotations_)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1529 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1530 std::set<size_t> a;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1531 annotations_->LookupSopInstanceUid(a, instance.GetSopInstanceUid());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1532 if (plane.IsValid() &&
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1533 !a.empty())
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1534 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1535 annotationsLayer.reset(new OrthancStone::MacroSceneLayer);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1536 annotationsLayer->Reserve(a.size());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1537
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1538 OrthancStone::OsiriXLayerFactory factory;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1539 factory.SetColor(0, 255, 0);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1540
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1541 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
1542 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1543 const OrthancStone::OsiriX::Annotation& annotation = annotations_->GetAnnotation(*it);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1544 annotationsLayer->AddLayer(factory.Create(annotation, plane));
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1545 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1546 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1547 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1548
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1549 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1550
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1551 OrthancStone::Scene2D& scene = lock->GetController().GetScene();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1552
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1553 scene.SetLayer(LAYER_TEXTURE, layer.release());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1554
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1555 if (annotationsLayer.get() != NULL)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1556 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1557 scene.SetLayer(LAYER_ANNOTATIONS, annotationsLayer.release());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1558 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1559 else
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1560 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1561 scene.DeleteLayer(LAYER_ANNOTATIONS);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1562 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1563
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1564 if (fitNextContent_)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1565 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1566 lock->RefreshCanvasSize();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1567 lock->GetCompositor().FitContent(scene);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1568 fitNextContent_ = false;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1569 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1570
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1571 //lock->GetCompositor().Refresh(scene);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1572 lock->Invalidate();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1573 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1574
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1575
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1576 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
1577 const std::string& loadedSopInstanceUid,
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1578 unsigned int loadedFrameNumber,
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1579 DisplayedFrameQuality quality)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1580 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1581 if (cursor_.get() != NULL &&
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1582 frames_.get() != NULL)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1583 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1584 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
1585 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
1586 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
1587
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1588 // 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
1589 if (instance.GetSopInstanceUid() == loadedSopInstanceUid &&
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1590 frameNumber == loadedFrameNumber)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1591 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1592 const OrthancStone::CoordinateSystem3D plane = frames_->GetFrameGeometry(cursorIndex);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1593
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1594 if (quality == DisplayedFrameQuality_Low)
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1595 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1596 FramesCache::Accessor accessor(*cache_, instance.GetSopInstanceUid(), frameNumber);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1597 if (accessor.IsValid() &&
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1598 accessor.GetQuality() == QUALITY_FULL)
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1599 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1600 // 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
1601 RenderCurrentScene(accessor.GetImage(), instance, plane);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1602 SetupPrefetchAfterRendering(DisplayedFrameQuality_High);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1603 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1604 else
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1605 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1606 // 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
1607 RenderCurrentScene(frame, instance, plane);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1608 SetupPrefetchAfterRendering(quality);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1609
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1610 /**
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1611 * The command "SetupPrefetchAfterRendering()" must be
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1612 * after "SetupPrefetchAfterRendering(quality)", as the
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1613 * DICOM instance might already be cached by the oracle,
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1614 * which makes a call to "observer_->SignalFrameUpdated()"
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1615 * with a low quality, whereas the high quality is
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1616 * available.
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1617 **/
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1618 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1619 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1620 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1621 else
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1622 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1623 assert(quality == DisplayedFrameQuality_High);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1624 SetupPrefetchAfterRendering(quality);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1625 RenderCurrentScene(frame, instance, plane);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1626 }
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1627 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1628 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1629 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1630
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1631 void ScheduleLoadFullDicomFrame(size_t cursorIndex,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1632 int priority,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1633 bool isPrefetch)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1634 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1635 if (frames_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1636 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1637 std::string sopInstanceUid = frames_->GetInstanceOfFrame(cursorIndex).GetSopInstanceUid();
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1638 unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1639
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1640 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1641 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
1642 lock->Schedule(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1643 GetSharedObserver(), priority, OrthancStone::ParseDicomFromWadoCommand::Create(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1644 source_, frames_->GetStudyInstanceUid(), frames_->GetSeriesInstanceUid(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1645 sopInstanceUid, false /* transcoding (TODO) */,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1646 Orthanc::DicomTransferSyntax_LittleEndianExplicit /* TODO */,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1647 new SetFullDicomFrame(GetSharedObserver(), sopInstanceUid, frameNumber, isPrefetch)));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1648 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1649 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1650 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1651
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1652 void ScheduleLoadRenderedFrame(size_t cursorIndex,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1653 int priority,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1654 bool isPrefetch)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1655 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1656 if (!source_.HasDicomWebRendered())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1657 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1658 ScheduleLoadFullDicomFrame(cursorIndex, priority, isPrefetch);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1659 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1660 else if (frames_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1661 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1662 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1663 unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1664
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
1665 /**
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
1666 * 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
1667 * 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
1668 **/
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
1669 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
1670 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
1671
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
1672 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
1673 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
1674 {
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
1675 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
1676 {
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
1677 SetFullDicomFrame::Apply(*this, accessor->GetDicom(), instance.GetSopInstanceUid(), frameNumber);
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
1678 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
1679 }
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
1680 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
1681 {
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
1682 // 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
1683 }
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
1684 }
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
1685
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1686 bool isMonochrome1 = (instance.GetImageInformation().GetPhotometricInterpretation() ==
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1687 Orthanc::PhotometricInterpretation_Monochrome1);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1688
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1689 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() +
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1690 "/series/" + frames_->GetSeriesInstanceUid() +
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1691 "/instances/" + instance.GetSopInstanceUid() +
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1692 "/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
1693
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1694 std::map<std::string, std::string> headers, arguments;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1695 arguments["window"] = (
1536
7b326e5ee97b reduce blinking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1534
diff changeset
1696 boost::lexical_cast<std::string>(windowingCenter_) + "," +
7b326e5ee97b reduce blinking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1534
diff changeset
1697 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
1698
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1699 std::unique_ptr<OrthancStone::IOracleCommand> command(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1700 source_.CreateDicomWebCommand(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1701 uri, arguments, headers, new SetLowQualityFrame(
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1702 GetSharedObserver(), instance.GetSopInstanceUid(), frameNumber,
1536
7b326e5ee97b reduce blinking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1534
diff changeset
1703 windowingCenter_, windowingWidth_, isMonochrome1, isPrefetch)));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1704
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1705 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1706 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
1707 lock->Schedule(GetSharedObserver(), priority, command.release());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1708 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1709 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1710 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1711
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1712 void UpdateCurrentTextureParameters()
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1713 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1714 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
1715
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1716 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
1717 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1718 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
1719 OrthancStone::ISceneLayer::Type_FloatTexture)
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1720 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1721 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1722 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE)).
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1723 SetCustomWindowing(windowingCenter_, windowingWidth_);
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1724 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1725
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1726 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1727 OrthancStone::TextureBaseSceneLayer& layer =
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1728 dynamic_cast<OrthancStone::TextureBaseSceneLayer&>(
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1729 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE));
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1730
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1731 layer.SetFlipX(flipX_);
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1732 layer.SetFlipY(flipY_);
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1733 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1734
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1735 lock->Invalidate();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1736 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1737 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1738
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1739
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
1740 ViewerViewport(OrthancStone::WebAssemblyLoadersContext& context,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1741 const OrthancStone::DicomSource& source,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1742 const std::string& canvas,
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1743 boost::shared_ptr<FramesCache> cache,
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1744 bool softwareRendering) :
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1745 context_(context),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1746 source_(source),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1747 cache_(cache),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1748 fitNextContent_(true),
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1749 isCtrlDown_(false),
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1750 flipX_(false),
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1751 flipY_(false),
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1752 hasFocusOnInstance_(false),
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1753 focusFrameNumber_(0)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1754 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1755 if (!cache_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1756 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1757 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1758 }
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1759
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1760 if (softwareRendering)
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1761 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1762 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
1763 viewport_ = OrthancStone::WebAssemblyCairoViewport::Create(canvas);
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1764 }
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1765 else
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1766 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1767 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
1768 viewport_ = OrthancStone::WebGLViewport::Create(canvas);
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1769 }
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1770
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1771 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1772 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1773 std::string ttf;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1774 Orthanc::EmbeddedResources::GetFileResource(ttf, Orthanc::EmbeddedResources::UBUNTU_FONT);
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1775 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
1776 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1777
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1778 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
1779 emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1780 emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1781
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1782 ResetDefaultWindowing();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1783 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1784
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1785 static EM_BOOL OnKey(int eventType,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1786 const EmscriptenKeyboardEvent *event,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1787 void *userData)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1788 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1789 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1790 * WARNING: There is a problem with Firefox 71 that seems to mess
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1791 * the "ctrlKey" value.
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1792 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1793
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1794 ViewerViewport& that = *reinterpret_cast<ViewerViewport*>(userData);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1795 that.isCtrlDown_ = event->ctrlKey;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1796 return false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1797 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1798
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1799
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1800 static EM_BOOL OnWheel(int eventType,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1801 const EmscriptenWheelEvent *wheelEvent,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1802 void *userData)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1803 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1804 ViewerViewport& that = *reinterpret_cast<ViewerViewport*>(userData);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1805
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1806 if (that.cursor_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1807 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1808 if (wheelEvent->deltaY < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1809 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1810 that.ChangeFrame(that.isCtrlDown_ ? SeriesCursor::Action_FastMinus : SeriesCursor::Action_Minus, false /* not circular */);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1811 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1812 else if (wheelEvent->deltaY > 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1813 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1814 that.ChangeFrame(that.isCtrlDown_ ? SeriesCursor::Action_FastPlus : SeriesCursor::Action_Plus, false /* not circular */);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1815 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1816 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1817
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1818 return true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1819 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1820
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1821 void Handle(const OrthancStone::DicomResourcesLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1822 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1823 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
1824 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1825
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1826 void Handle(const OrthancStone::HttpCommand::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1827 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1828 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
1829 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1830
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1831 void Handle(const OrthancStone::ParseDicomSuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1832 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1833 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
1834 }
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1835
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1836 public:
1622
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
1837 virtual ~ViewerViewport()
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
1838 {
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
1839 // 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
1840 // 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
1841 // 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
1842 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
1843 emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, NULL);
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
1844 emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, NULL);
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
1845 }
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
1846
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
1847 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
1848 const OrthancStone::DicomSource& source,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1849 const std::string& canvas,
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1850 boost::shared_ptr<FramesCache> cache,
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
1851 bool softwareRendering)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1852 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1853 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
1854 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
1855
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
1856 {
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
1857 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
1858
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
1859 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
1860 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
1861 *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
1862
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
1863 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
1864 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
1865
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
1866 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
1867 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
1868 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1869
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1870 return viewport;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1871 }
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 void SetFrames(OrthancStone::SortedFrames* frames)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1874 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1875 if (frames == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1876 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1877 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
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
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1880 flipX_ = false;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1881 flipY_ = false;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1882 fitNextContent_ = true;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1883 cineRate_ = DEFAULT_CINE_RATE;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1884
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1885 frames_.reset(frames);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1886 cursor_.reset(new SeriesCursor(frames_->GetFramesCount()));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1887
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1888 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
1889
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1890 ResetDefaultWindowing();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1891 ClearViewport();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1892 prefetchQueue_.clear();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1893
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1894 if (observer_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1895 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1896 observer_->SignalFrameUpdated(*this, cursor_->GetCurrentIndex(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1897 frames_->GetFramesCount(), DisplayedFrameQuality_None);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1898 }
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
1899
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1900 if (frames_->GetFramesCount() != 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1901 {
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
1902 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
1903
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
1904 /**
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
1905 * 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
1906 * "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
1907 * 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
1908 * 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
1909 **/
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
1910 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
1911 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
1912 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
1913 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
1914 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
1915 GetSeriesThumbnailType(uid) != OrthancStone::SeriesThumbnailType_Video)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1916 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1917 // 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
1918 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() +
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1919 "/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
1920 "/instances/" + centralInstance.GetSopInstanceUid() + "/metadata");
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1921
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1922 loader_->ScheduleGetDicomWeb(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1923 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
1924 0, source_, uri, new LoadSeriesDetailsFromInstance(GetSharedObserver()));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1925 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1926 }
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1927
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1928 ApplyScheduledFocus();
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
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1931
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1932 // 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
1933 // 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
1934 void UpdateSize(bool fitContent)
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 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
1937 lock->RefreshCanvasSize();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1938
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1939 if (fitContent)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1940 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1941 lock->GetCompositor().FitContent(lock->GetController().GetScene());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1942 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1943
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1944 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1945 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1946
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1947 void AcquireObserver(IObserver* observer)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1948 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1949 observer_.reset(observer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1950 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1951
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1952 const std::string& GetCanvasId() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1953 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1954 assert(viewport_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1955 return viewport_->GetCanvasId();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1956 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1957
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1958
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1959 void Redraw()
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1960 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1961 DisplayedFrameQuality quality = DisplayedFrameQuality_None;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1962
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1963 if (cursor_.get() != NULL &&
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1964 frames_.get() != NULL)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1965 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1966 const size_t cursorIndex = cursor_->GetCurrentIndex();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1967
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1968 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1969 const size_t frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1970
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1971 FramesCache::Accessor accessor(*cache_, instance.GetSopInstanceUid(), frameNumber);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1972 if (accessor.IsValid())
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1973 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1974 RenderCurrentScene(accessor.GetImage(), instance, frames_->GetFrameGeometry(cursorIndex));
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1975
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1976 DisplayedFrameQuality quality;
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1977
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1978 if (accessor.GetQuality() < QUALITY_FULL)
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1979 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1980 // 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
1981 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1982 quality = DisplayedFrameQuality_Low;
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1983 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1984 else
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1985 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1986 quality = DisplayedFrameQuality_High;
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1987 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1988
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1989 SetupPrefetchAfterRendering(quality);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1990 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1991 else
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1992 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1993 // This frame is not cached yet: Load it
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1994 if (source_.HasDicomWebRendered())
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1995 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1996 ScheduleLoadRenderedFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1997 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1998 else
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1999 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2000 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2001 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2002 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2003 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2004 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2005
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2006
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2007 // Returns "true" iff the frame has indeed changed
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2008 bool ChangeFrame(SeriesCursor::Action action,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2009 bool isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2010 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2011 if (cursor_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2012 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2013 size_t previous = cursor_->GetCurrentIndex();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2014
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2015 cursor_->Apply(action, isCircular);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2016
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2017 size_t current = cursor_->GetCurrentIndex();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2018 if (previous != current)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2019 {
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2020 Redraw();
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2021 return true;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2022 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2023 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2024
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2025 return false;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2026 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2027
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2028
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2029 bool GetCurrentFrameOfReferenceUid(std::string& frameOfReferenceUid) const
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2030 {
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2031 if (cursor_.get() != NULL &&
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2032 frames_.get() != NULL)
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2033 {
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2034 frameOfReferenceUid = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()).GetFrameOfReferenceUid();
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2035 return true;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2036 }
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2037 else
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2038 {
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2039 return false;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2040 }
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2041 }
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2042
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2043 bool GetCurrentPlane(OrthancStone::CoordinateSystem3D& plane) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2044 {
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2045 if (cursor_.get() != NULL &&
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2046 frames_.get() != NULL)
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2047 {
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2048 plane = frames_->GetFrameGeometry(cursor_->GetCurrentIndex());
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2049 return true;
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2050 }
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2051 else
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2052 {
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2053 return false;
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2054 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2055 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2056
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2057 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
2058 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2059 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
2060
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2061 if (cursor_.get() != NULL &&
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2062 frames_.get() != NULL)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2063 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2064 const size_t cursorIndex = cursor_->GetCurrentIndex();
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2065 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2066 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
2067
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2068 for (std::list<const ViewerViewport*>::const_iterator
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2069 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
2070 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2071 assert(*it != NULL);
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2072
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2073 OrthancStone::CoordinateSystem3D otherPlane;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2074 std::string otherFrameOfReferenceUid;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2075 if ((*it)->GetCurrentPlane(otherPlane) &&
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2076 (*it)->GetCurrentFrameOfReferenceUid(otherFrameOfReferenceUid) &&
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2077 otherFrameOfReferenceUid == instance.GetFrameOfReferenceUid())
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2078 {
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2079 double x1, y1, x2, y2;
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2080 if (GetReferenceLineCoordinates(x1, y1, x2, y2, instance, frame, otherPlane))
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2081 {
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2082 OrthancStone::PolylineSceneLayer::Chain chain;
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2083 chain.push_back(OrthancStone::ScenePoint2D(x1, y1));
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2084 chain.push_back(OrthancStone::ScenePoint2D(x2, y2));
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2085 layer->AddChain(chain, false, 0, 255, 0);
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2086 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2087 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2088 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2089 }
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2090
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2091 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2092 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
2093
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2094 if (layer->GetChainsCount() == 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2095 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2096 lock->GetController().GetScene().DeleteLayer(LAYER_REFERENCE_LINES);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2097 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2098 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2099 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2100 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
2101 }
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 //lock->GetCompositor().Refresh(lock->GetController().GetScene());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2104 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2105 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2106 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2107
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2108
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2109 void ClearReferenceLines()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2110 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2111 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2112 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
2113 lock->GetController().GetScene().DeleteLayer(LAYER_REFERENCE_LINES);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2114 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2115 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2116 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2117
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2118
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2119 void SetDefaultWindowing()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2120 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2121 SetWindowing(defaultWindowingCenter_, defaultWindowingWidth_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2122 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2123
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2124 void SetWindowing(float windowingCenter,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2125 float windowingWidth)
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 windowingCenter_ = windowingCenter;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2128 windowingWidth_ = windowingWidth;
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2129 UpdateCurrentTextureParameters();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2130 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2131
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2132 void FlipX()
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2133 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2134 flipX_ = !flipX_;
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2135 SaveCurrentWindowing();
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2136 UpdateCurrentTextureParameters();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2137 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2138
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2139 void FlipY()
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2140 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2141 flipY_ = !flipY_;
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2142 SaveCurrentWindowing();
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2143 UpdateCurrentTextureParameters();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2144 }
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 void Invert()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2147 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2148 inverted_ = !inverted_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2149
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2150 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2151 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
2152
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2153 if (lock->GetController().GetScene().HasLayer(LAYER_TEXTURE) &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2154 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE).GetType() ==
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2155 OrthancStone::ISceneLayer::Type_FloatTexture)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2156 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2157 OrthancStone::FloatTextureSceneLayer& layer =
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2158 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2159 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2160
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2161 // 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
2162 // compatibility with MONOCHROME1 images
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2163 layer.SetInverted(!layer.IsInverted());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2164 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2165 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2166 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2167 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2168
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2169
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2170
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2171 class Interactor : public OrthancStone::DefaultViewportInteractor
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2172 {
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2173 private:
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2174 ViewerViewport& viewer_;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2175 WebViewerAction leftAction_;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2176 WebViewerAction middleAction_;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2177 WebViewerAction rightAction_;
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2178
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2179 bool IsAction(const OrthancStone::PointerEvent& event,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2180 WebViewerAction action)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2181 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2182 switch (event.GetMouseButton())
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2183 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2184 case OrthancStone::MouseButton_Left:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2185 return (leftAction_ == action);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2186
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2187 case OrthancStone::MouseButton_Middle:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2188 return (middleAction_ == action);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2189
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2190 case OrthancStone::MouseButton_Right:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2191 return (rightAction_ == action);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2192
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2193 default:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2194 return false;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2195 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2196 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2197
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2198 public:
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2199 Interactor(ViewerViewport& viewer,
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2200 WebViewerAction leftAction,
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2201 WebViewerAction middleAction,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2202 WebViewerAction rightAction) :
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2203 viewer_(viewer),
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2204 leftAction_(leftAction),
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2205 middleAction_(middleAction),
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2206 rightAction_(rightAction)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2207 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2208 SetLeftButtonAction(ConvertWebViewerAction(leftAction));
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2209 SetMiddleButtonAction(ConvertWebViewerAction(middleAction));
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2210 SetRightButtonAction(ConvertWebViewerAction(rightAction));
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2211 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2212
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2213 virtual OrthancStone::IFlexiblePointerTracker* CreateTracker(
1607
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2214 boost::weak_ptr<OrthancStone::IViewport> viewport,
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2215 const OrthancStone::PointerEvent& event,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2216 unsigned int viewportWidth,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2217 unsigned int viewportHeight) ORTHANC_OVERRIDE
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2218 {
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2219 boost::shared_ptr<OrthancStone::IViewport> lock1(viewport.lock());
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2220
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2221 if (lock1 &&
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2222 IsAction(event, WebViewerAction_Crosshair))
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2223 {
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2224 OrthancStone::CoordinateSystem3D plane;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2225 if (viewer_.GetCurrentPlane(plane))
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2226 {
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2227 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
2228
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2229 const OrthancStone::ScenePoint2D p = event.GetMainPosition();
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2230 double x = p.GetX();
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2231 double y = p.GetY();
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2232 lock2->GetController().GetCanvasToSceneTransform().Apply(x, y);
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2233
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2234 OrthancStone::Vector click = plane.MapSliceToWorldCoordinates(x, y);
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2235 if (viewer_.observer_.get() != NULL)
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2236 {
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2237 viewer_.observer_->SignalCrosshair(click);
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2238 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2239 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2240
1580
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1579
diff changeset
2241 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
2242 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2243 else
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2244 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2245 return DefaultViewportInteractor::CreateTracker(
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2246 viewport, event, viewportWidth, viewportHeight);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2247 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2248 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2249 };
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2250
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2251
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2252 void SetMouseButtonActions(WebViewerAction leftAction,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2253 WebViewerAction middleAction,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2254 WebViewerAction rightAction)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2255 {
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2256 assert(viewport_ != NULL);
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2257 viewport_->AcquireInteractor(new Interactor(*this, leftAction, middleAction, rightAction));
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2258 }
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2259
1578
1f812f4c95be comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1576
diff changeset
2260 void FitForPrint()
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2261 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2262 viewport_->FitForPrint();
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2263 }
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2264
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2265 void SetAnnotations(boost::shared_ptr<OrthancStone::OsiriX::CollectionOfAnnotations> annotations)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2266 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2267 annotations_ = annotations;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2268 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2269
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2270 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
2271 unsigned int frameNumber)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2272 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2273 hasFocusOnInstance_ = true;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2274 focusSopInstanceUid_ = sopInstanceUid;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2275 focusFrameNumber_ = frameNumber;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2276
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2277 ApplyScheduledFocus();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2278 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2279
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2280 void ApplyScheduledFocus()
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2281 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2282 size_t cursorIndex;
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2283
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2284 if (hasFocusOnInstance_ &&
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2285 cursor_.get() != NULL &&
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2286 frames_.get() != NULL &&
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2287 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
2288 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2289 size_t current = cursor_->GetCurrentIndex();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2290
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2291 if (current != cursorIndex)
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2292 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2293 cursor_->SetCurrentIndex(cursorIndex);
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2294 Redraw();
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2295 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2296
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2297 hasFocusOnInstance_ = false;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2298 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2299 }
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2300
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2301 void FocusOnPoint(const OrthancStone::Vector& p)
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2302 {
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2303 //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
2304 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
2305
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2306 size_t cursorIndex;
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2307 if (cursor_.get() != NULL &&
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2308 frames_.get() != NULL &&
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2309 frames_->FindClosestFrame(cursorIndex, p, MAX_DISTANCE))
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2310 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2311 cursor_->SetCurrentIndex(cursorIndex);
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2312 Redraw();
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2313 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2314 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2315
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2316 unsigned int GetCineRate() const
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2317 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2318 return cineRate_;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2319 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2320 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2321
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2322
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2323
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2324
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2325
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2326 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
2327 static Viewports allViewports_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2328 static bool showReferenceLines_ = true;
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2329 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
2330
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2331
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2332 static void UpdateReferenceLines()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2333 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2334 if (showReferenceLines_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2335 {
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2336 std::list<const ViewerViewport*> viewports;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2337
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2338 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
2339 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2340 assert(it->second != NULL);
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2341 viewports.push_back(it->second.get());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2342 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2343
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2344 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
2345 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2346 assert(it->second != NULL);
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2347 it->second->UpdateReferenceLines(viewports);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2348 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2349 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2350 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2351 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2352 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
2353 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2354 assert(it->second != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2355 it->second->ClearReferenceLines();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2356 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2357 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2358 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2359
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2360
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2361 class WebAssemblyObserver : public ResourcesLoader::IObserver,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2362 public ViewerViewport::IObserver
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2363 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2364 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2365 virtual void SignalResourcesLoaded() ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2366 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2367 DISPATCH_JAVASCRIPT_EVENT("ResourcesLoaded");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2368 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2369
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2370 virtual void SignalSeriesThumbnailLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2371 const std::string& seriesInstanceUid) ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2372 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2373 EM_ASM({
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2374 const customEvent = document.createEvent("CustomEvent");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2375 customEvent.initCustomEvent("ThumbnailLoaded", false, false,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2376 { "studyInstanceUid" : UTF8ToString($0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2377 "seriesInstanceUid" : UTF8ToString($1) });
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2378 window.dispatchEvent(customEvent);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2379 },
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2380 studyInstanceUid.c_str(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2381 seriesInstanceUid.c_str());
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 virtual void SignalSeriesMetadataLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2385 const std::string& seriesInstanceUid) ORTHANC_OVERRIDE
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 EM_ASM({
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2388 const customEvent = document.createEvent("CustomEvent");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2389 customEvent.initCustomEvent("MetadataLoaded", false, false,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2390 { "studyInstanceUid" : UTF8ToString($0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2391 "seriesInstanceUid" : UTF8ToString($1) });
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2392 window.dispatchEvent(customEvent);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2393 },
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2394 studyInstanceUid.c_str(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2395 seriesInstanceUid.c_str());
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2396
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2397 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
2398 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2399 assert(it->second != NULL);
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2400 it->second->ApplyScheduledFocus();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2401 }
1495
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
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2404 virtual void SignalSeriesDetailsReady(const ViewerViewport& viewport) ORTHANC_OVERRIDE
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2405 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2406 EM_ASM({
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2407 const customEvent = document.createEvent("CustomEvent");
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2408 customEvent.initCustomEvent("SeriesDetailsReady", false, false,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2409 { "canvasId" : UTF8ToString($0) });
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2410 window.dispatchEvent(customEvent);
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2411 },
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2412 viewport.GetCanvasId().c_str()
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2413 );
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2414 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2415
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2416 virtual void SignalFrameUpdated(const ViewerViewport& viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2417 size_t currentFrame,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2418 size_t countFrames,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2419 DisplayedFrameQuality quality) ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2420 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2421 EM_ASM({
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2422 const customEvent = document.createEvent("CustomEvent");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2423 customEvent.initCustomEvent("FrameUpdated", false, false,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2424 { "canvasId" : UTF8ToString($0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2425 "currentFrame" : $1,
1674
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
2426 "numberOfFrames" : $2,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2427 "quality" : $3 });
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2428 window.dispatchEvent(customEvent);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2429 },
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2430 viewport.GetCanvasId().c_str(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2431 static_cast<int>(currentFrame),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2432 static_cast<int>(countFrames),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2433 quality);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2434
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2435 UpdateReferenceLines();
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2436 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2437
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2438 virtual void SignalCrosshair(const OrthancStone::Vector& click) ORTHANC_OVERRIDE
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2439 {
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2440 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
2441 {
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2442 assert(it->second != NULL);
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2443 it->second->FocusOnPoint(click);
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2444 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2445 }
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2446
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2447 virtual void SignalSeriesPdfLoaded(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2448 const std::string& seriesInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2449 const std::string& pdf) ORTHANC_OVERRIDE
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2450 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2451 EM_ASM({
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2452 const customEvent = document.createEvent("CustomEvent");
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2453 customEvent.initCustomEvent("PdfLoaded", false, false,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2454 { "studyInstanceUid" : UTF8ToString($0),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2455 "seriesInstanceUid" : UTF8ToString($1),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2456 "pdfPointer" : $2,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2457 "pdfSize": $3});
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2458 window.dispatchEvent(customEvent);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2459 },
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2460 studyInstanceUid.c_str(),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2461 seriesInstanceUid.c_str(),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2462 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
2463 pdf.size());
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2464 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2465 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2466
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2469 static OrthancStone::DicomSource source_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2470 static boost::shared_ptr<FramesCache> cache_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2471 static boost::shared_ptr<OrthancStone::WebAssemblyLoadersContext> context_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2472 static std::string stringBuffer_;
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2473 static bool softwareRendering_ = false;
1663
fc883105ee11 enable cache of ParsedDicomFile in oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
2474 static WebViewerAction leftButtonAction_ = WebViewerAction_GrayscaleWindowing;
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2475 static WebViewerAction middleButtonAction_ = WebViewerAction_Pan;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2476 static WebViewerAction rightButtonAction_ = WebViewerAction_Zoom;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2477
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2478
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2479 static void FormatTags(std::string& target,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2480 const Orthanc::DicomMap& tags)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2481 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2482 Orthanc::DicomArray arr(tags);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2483 Json::Value v = Json::objectValue;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2484
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2485 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
2486 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2487 const Orthanc::DicomElement& element = arr.GetElement(i);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2488 if (!element.GetValue().IsBinary() &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2489 !element.GetValue().IsNull())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2490 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2491 v[element.GetTag().Format()] = element.GetValue().GetContent();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2492 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2493 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2494
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2495 target = v.toStyledString();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2496 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2497
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2498
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2499 static ResourcesLoader& GetResourcesLoader()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2500 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2501 static boost::shared_ptr<ResourcesLoader> resourcesLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2502
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2503 if (!resourcesLoader_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2504 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2505 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
2506 resourcesLoader_ = ResourcesLoader::Create(*lock, source_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2507 resourcesLoader_->AcquireObserver(new WebAssemblyObserver);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2508 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2509
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2510 return *resourcesLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2511 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2512
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2513
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2514 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
2515 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2516 Viewports::iterator found = allViewports_.find(canvas);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2517 if (found == allViewports_.end())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2518 {
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2519 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
2520 ViewerViewport::Create(*context_, source_, canvas, cache_, softwareRendering_));
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2521 viewport->SetMouseButtonActions(leftButtonAction_, middleButtonAction_, rightButtonAction_);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2522 viewport->AcquireObserver(new WebAssemblyObserver);
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2523 viewport->SetAnnotations(annotations_);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2524 allViewports_[canvas] = viewport;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2525 return viewport;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2526 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2527 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2528 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2529 return found->second;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2530 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2531 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2532
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2533
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2534 extern "C"
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2535 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2536 int main(int argc, char const *argv[])
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2537 {
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
2538 printf("Initializing Stone\n");
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2539 Orthanc::InitializeFramework("", true);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2540 Orthanc::Logging::EnableInfoLevel(true);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2541 //Orthanc::Logging::EnableTraceLevel(true);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2542
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2543 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
2544 context_->SetDicomCacheSize(128 * 1024 * 1024); // 128MB
fc883105ee11 enable cache of ParsedDicomFile in oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
2545
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2546 cache_.reset(new FramesCache);
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2547 annotations_.reset(new OrthancStone::OsiriX::CollectionOfAnnotations);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2548
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2549 DISPATCH_JAVASCRIPT_EVENT("StoneInitialized");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2550 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2551
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2552
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2553 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2554 void SetOrthancRoot(const char* uri,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2555 int useRendered)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2556 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2557 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2558 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2559 context_->SetLocalOrthanc(uri); // For "source_.SetDicomWebThroughOrthancSource()"
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2560 source_.SetDicomWebSource(std::string(uri) + "/dicom-web");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2561 source_.SetDicomWebRendered(useRendered != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2562 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2563 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2564 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2565
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2566
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2567 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2568 void SetDicomWebServer(const char* serverName,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2569 int hasRendered)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2570 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2571 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2572 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2573 source_.SetDicomWebThroughOrthancSource(serverName);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2574 source_.SetDicomWebRendered(hasRendered != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2575 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2576 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2577 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2578
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2579
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2580 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2581 void FetchAllStudies()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2582 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2583 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2584 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2585 GetResourcesLoader().FetchAllStudies();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2586 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2587 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2588 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2589
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2590 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2591 void FetchStudy(const char* studyInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2592 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2593 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2594 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2595 GetResourcesLoader().FetchStudy(studyInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2596 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2597 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2598 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2599
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2600 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2601 void FetchSeries(const char* studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2602 const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2603 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2604 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2605 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2606 GetResourcesLoader().FetchSeries(studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2607 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2608 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2609 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2610
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2611 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2612 int GetStudiesCount()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2613 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2614 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2615 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2616 return GetResourcesLoader().GetStudiesCount();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2617 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2618 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2619 return 0; // on exception
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2620 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2621
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2622 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2623 int GetSeriesCount()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2624 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2625 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2626 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2627 return GetResourcesLoader().GetSeriesCount();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2628 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2629 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2630 return 0; // on exception
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2631 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2632
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2633
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2634 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2635 const char* GetStringBuffer()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2636 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2637 return stringBuffer_.c_str();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2638 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2639
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2640
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2641 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2642 void LoadStudyTags(int i)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2643 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2644 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2645 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2646 if (i < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2647 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2648 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2649 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2650
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2651 Orthanc::DicomMap dicom;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2652 GetResourcesLoader().GetStudy(dicom, i);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2653 FormatTags(stringBuffer_, dicom);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2654 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2655 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2656 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2657
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2658
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2659 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2660 void LoadSeriesTags(int i)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2661 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2662 try
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 if (i < 0)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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 Orthanc::DicomMap dicom;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2670 GetResourcesLoader().GetSeries(dicom, i);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2671 FormatTags(stringBuffer_, dicom);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2672 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2673 EXTERN_CATCH_EXCEPTIONS;
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
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 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2678 int LoadSeriesThumbnail(const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2679 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2680 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2681 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2682 std::string image, mime;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2683 switch (GetResourcesLoader().GetSeriesThumbnail(image, mime, seriesInstanceUid))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2684 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2685 case OrthancStone::SeriesThumbnailType_Image:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2686 Orthanc::Toolbox::EncodeDataUriScheme(stringBuffer_, mime, image);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2687 return ThumbnailType_Image;
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 case OrthancStone::SeriesThumbnailType_Pdf:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2690 return ThumbnailType_Pdf;
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 case OrthancStone::SeriesThumbnailType_Video:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2693 return ThumbnailType_Video;
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 case OrthancStone::SeriesThumbnailType_NotLoaded:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2696 return ThumbnailType_Loading;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2697
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2698 case OrthancStone::SeriesThumbnailType_Unsupported:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2699 return ThumbnailType_NoPreview;
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 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2702 return ThumbnailType_Unknown;
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2705 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2706 return ThumbnailType_Unknown;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2707 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2708
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 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2711 void SpeedUpFetchSeriesMetadata(const char* studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2712 const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2713 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2714 try
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 GetResourcesLoader().FetchSeriesMetadata(PRIORITY_HIGH, studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2717 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2718 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2719 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2720
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2721
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2722 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2723 int IsSeriesComplete(const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2724 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2725 try
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 return GetResourcesLoader().IsSeriesComplete(seriesInstanceUid) ? 1 : 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2728 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2729 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2730 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2731 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2732
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2733 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2734 int LoadSeriesInViewport(const char* canvas,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2735 const char* seriesInstanceUid)
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 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2738 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2739 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
2740
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2741 if (GetResourcesLoader().SortSeriesFrames(*frames, seriesInstanceUid))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2742 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2743 GetViewport(canvas)->SetFrames(frames.release());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2744 return 1;
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 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2747 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2748 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2749 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2750 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2751 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2752 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2753 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2754
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2755
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2756 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2757 void AllViewportsUpdateSize(int fitContent)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2758 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2759 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2760 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2761 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
2762 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2763 assert(it->second != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2764 it->second->UpdateSize(fitContent != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2765 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2766 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2767 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2768 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2769
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2770
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2771 EMSCRIPTEN_KEEPALIVE
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2772 int DecrementFrame(const char* canvas,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2773 int isCircular)
1495
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 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2776 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2777 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
2778 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2779 EXTERN_CATCH_EXCEPTIONS;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2780 return 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2781 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2782
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2783
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2784 EMSCRIPTEN_KEEPALIVE
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2785 int IncrementFrame(const char* canvas,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2786 int isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2787 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2788 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2789 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2790 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
2791 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2792 EXTERN_CATCH_EXCEPTIONS;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2793 return 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2794 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2795
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2796
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2797 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2798 void ShowReferenceLines(int show)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2799 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2800 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2801 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2802 showReferenceLines_ = (show != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2803 UpdateReferenceLines();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2804 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2805 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2806 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2807
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2808
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2809 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2810 void SetDefaultWindowing(const char* canvas)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2811 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2812 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2813 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2814 GetViewport(canvas)->SetDefaultWindowing();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2815 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2816 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2817 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2818
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2819
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2820 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2821 void SetWindowing(const char* canvas,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2822 int center,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2823 int width)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2824 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2825 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2826 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2827 GetViewport(canvas)->SetWindowing(center, width);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2828 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2829 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2830 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2831
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2832
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2833 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2834 void InvertContrast(const char* canvas)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2835 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2836 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2837 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2838 GetViewport(canvas)->Invert();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2839 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2840 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2841 }
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2842
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2843
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2844 EMSCRIPTEN_KEEPALIVE
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2845 void FlipX(const char* canvas)
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2846 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2847 try
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2848 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2849 GetViewport(canvas)->FlipX();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2850 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2851 EXTERN_CATCH_EXCEPTIONS;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2852 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2853
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2854
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2855 EMSCRIPTEN_KEEPALIVE
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2856 void FlipY(const char* canvas)
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2857 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2858 try
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2859 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2860 GetViewport(canvas)->FlipY();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2861 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2862 EXTERN_CATCH_EXCEPTIONS;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2863 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2864
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2865
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2866 EMSCRIPTEN_KEEPALIVE
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2867 void SetSoftwareRendering(int softwareRendering)
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2868 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2869 softwareRendering_ = softwareRendering;
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2870 }
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2871
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2872
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2873 EMSCRIPTEN_KEEPALIVE
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2874 int IsSoftwareRendering()
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2875 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2876 return softwareRendering_;
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2877 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2878
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2879
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2880 EMSCRIPTEN_KEEPALIVE
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2881 void SetMouseButtonActions(int leftAction,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2882 int middleAction,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2883 int rightAction)
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2884 {
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2885 try
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2886 {
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2887 leftButtonAction_ = static_cast<WebViewerAction>(leftAction);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2888 middleButtonAction_ = static_cast<WebViewerAction>(middleAction);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2889 rightButtonAction_ = static_cast<WebViewerAction>(rightAction);
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2890
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2891 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2892 {
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2893 assert(it->second != NULL);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2894 it->second->SetMouseButtonActions(leftButtonAction_, middleButtonAction_, rightButtonAction_);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2895 }
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2896 }
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2897 EXTERN_CATCH_EXCEPTIONS;
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2898 }
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2899
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2900
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2901 EMSCRIPTEN_KEEPALIVE
1578
1f812f4c95be comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1576
diff changeset
2902 void FitForPrint()
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2903 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2904 try
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2905 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2906 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2907 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2908 assert(it->second != NULL);
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2909 it->second->FitForPrint();
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2910 }
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2911 }
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2912 EXTERN_CATCH_EXCEPTIONS;
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2913 }
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2914
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2915
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2916 // 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
2917 // Instance UID" of the first loaded annotation
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2918 EMSCRIPTEN_KEEPALIVE
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2919 int LoadOsiriXAnnotations(const char* xml,
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2920 int clearPreviousAnnotations)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2921 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2922 try
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2923 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2924 if (clearPreviousAnnotations)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2925 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2926 annotations_->Clear();
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2927 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2928
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2929 annotations_->LoadXml(xml);
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2930
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2931 // Force redraw, as the annotations might have changed
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2932 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2933 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2934 assert(it->second != NULL);
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2935 it->second->Redraw();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2936 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2937
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2938 if (annotations_->GetSize() == 0)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2939 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2940 stringBuffer_.clear();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2941 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2942 else
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2943 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2944 stringBuffer_ = annotations_->GetAnnotation(0).GetSeriesInstanceUid();
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2945 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2946
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2947 LOG(WARNING) << "Loaded " << annotations_->GetSize() << " annotations from OsiriX";
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2948 return 1;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2949 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2950 EXTERN_CATCH_EXCEPTIONS;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2951 return 0;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2952 }
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2953
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2954
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2955 EMSCRIPTEN_KEEPALIVE
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2956 void FocusFirstOsiriXAnnotation(const char* canvas)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2957 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2958 try
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2959 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2960 if (annotations_->GetSize() != 0)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2961 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2962 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
2963
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2964 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
2965 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
2966
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2967 // 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
2968 viewport->Redraw();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2969 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2970 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2971 EXTERN_CATCH_EXCEPTIONS;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2972 }
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2973
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2974
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2975 EMSCRIPTEN_KEEPALIVE
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2976 void FetchPdf(const char* studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2977 const char* seriesInstanceUid)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2978 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2979 try
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2980 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2981 LOG(INFO) << "Fetching PDF series: " << seriesInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2982 GetResourcesLoader().FetchPdf(studyInstanceUid, seriesInstanceUid);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2983 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2984 EXTERN_CATCH_EXCEPTIONS;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
2985 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2986
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2987
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2988 EMSCRIPTEN_KEEPALIVE
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2989 unsigned int GetCineRate(const char* canvas)
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2990 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2991 try
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2992 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2993 return GetViewport(canvas)->GetCineRate();
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2994 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2995 EXTERN_CATCH_EXCEPTIONS;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2996 return 0;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2997 }
1674
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
2998
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
2999
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3000 EMSCRIPTEN_KEEPALIVE
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3001 unsigned int GetSeriesNumberOfFrames(const char* seriesInstanceUid)
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3002 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3003 try
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3004 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3005 return GetResourcesLoader().GetSeriesNumberOfFrames(seriesInstanceUid);
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3006 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3007 EXTERN_CATCH_EXCEPTIONS;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3008 return 0;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3009 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3010 }