annotate Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1815:b81775f1b196

New tools for annotations: segment length, circle, angle and eraser
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 May 2021 18:07:52 +0200
parents 53f3411bf94b
children dccdc7e59929
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
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1722
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
1495
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>
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
73 #include <Scene2D/AnnotationsSceneLayer.h>
1614
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1611
diff changeset
74 #include <Scene2D/ArrowSceneLayer.h>
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
75 #include <Scene2D/ColorTextureSceneLayer.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
76 #include <Scene2D/FloatTextureSceneLayer.h>
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1607
diff changeset
77 #include <Scene2D/MacroSceneLayer.h>
1615
f5d4bd7b5593 new class: OsiriXLayerFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1614
diff changeset
78 #include <Scene2D/OsiriXLayerFactory.h>
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
79 #include <Scene2D/PolylineSceneLayer.h>
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
80 #include <Scene2D/TextSceneLayer.h>
1558
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
81 #include <Scene2DViewport/ViewportController.h>
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
82 #include <StoneException.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
83 #include <Toolbox/DicomInstanceParameters.h>
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
84 #include <Toolbox/GeometryToolbox.h>
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
85 #include <Toolbox/OsiriX/AngleAnnotation.h>
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
86 #include <Toolbox/OsiriX/CollectionOfAnnotations.h>
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
87 #include <Toolbox/OsiriX/LineAnnotation.h>
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
88 #include <Toolbox/OsiriX/TextAnnotation.h>
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
89 #include <Toolbox/SortedFrames.h>
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
90 #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
91
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
92 // WebAssembly includes
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
93 #include <WebAssemblyCairoViewport.h>
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
94 #include <WebAssemblyLoadersContext.h>
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
95 #include <WebGLViewport.h>
5887a4f8594b moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1580
diff changeset
96
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
98 #include <boost/math/special_functions/round.hpp>
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 #include <boost/make_shared.hpp>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 #include <stdio.h>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
103 #if !defined(STONE_WEB_VIEWER_EXPORT)
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
104 // 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
105 # define STONE_WEB_VIEWER_EXPORT
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
106 #endif
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
107
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
108
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
109 #define FIX_LSD_479 1
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
110
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
111
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
112 enum STONE_WEB_VIEWER_EXPORT ThumbnailType
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 ThumbnailType_Image,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 ThumbnailType_NoPreview,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 ThumbnailType_Pdf,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 ThumbnailType_Video,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 ThumbnailType_Loading,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 ThumbnailType_Unknown
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
120 };
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
123 enum STONE_WEB_VIEWER_EXPORT DisplayedFrameQuality
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
125 DisplayedFrameQuality_None,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
126 DisplayedFrameQuality_Low,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
127 DisplayedFrameQuality_High
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
128 };
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
129
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
130
1632
9a4c09361f3e removed annoying warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
131 enum STONE_WEB_VIEWER_EXPORT WebViewerAction
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
132 {
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
133 WebViewerAction_None,
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
134
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
135 WebViewerAction_Windowing,
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
136 WebViewerAction_Zoom,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
137 WebViewerAction_Pan,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
138 WebViewerAction_Rotate,
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
139 WebViewerAction_Crosshair,
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
140
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
141 WebViewerAction_CreateAngle,
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
142 WebViewerAction_CreateCircle,
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
143 WebViewerAction_CreateSegment,
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
144 WebViewerAction_RemoveMeasure
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
145 };
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
149 static OrthancStone::MouseAction ConvertWebViewerAction(int action)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
150 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
151 switch (action)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
152 {
1701
b5a8bf32d969 new configuration options: "CombinedToolEnabled", "CombinedToolBehaviour" and "DownloadAsJpegEnabled"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
153 case WebViewerAction_Windowing:
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
154 return OrthancStone::MouseAction_GrayscaleWindowing;
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 case WebViewerAction_Zoom:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
157 return OrthancStone::MouseAction_Zoom;
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 case WebViewerAction_Pan:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
160 return OrthancStone::MouseAction_Pan;
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 case WebViewerAction_Rotate:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
163 return OrthancStone::MouseAction_Rotate;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
164
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
165 case WebViewerAction_None:
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
166 case WebViewerAction_Crosshair:
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
167 case WebViewerAction_CreateAngle:
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
168 case WebViewerAction_CreateCircle:
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
169 case WebViewerAction_CreateSegment:
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
170 case WebViewerAction_RemoveMeasure:
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
171 return OrthancStone::MouseAction_None;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
172
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
173 default:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
174 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
175 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
176 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
177
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
178
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
179
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 static const int PRIORITY_HIGH = -100;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 static const int PRIORITY_LOW = 100;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 static const int PRIORITY_NORMAL = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 static const unsigned int QUALITY_JPEG = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 static const unsigned int QUALITY_FULL = 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
187 static const unsigned int DEFAULT_CINE_RATE = 30;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
188
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
189
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 class ResourcesLoader : public OrthancStone::ObserverBase<ResourcesLoader>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 class IObserver : public boost::noncopyable
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 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 virtual ~IObserver()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 virtual void SignalResourcesLoaded() = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 virtual void SignalSeriesThumbnailLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 const std::string& seriesInstanceUid) = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 virtual void SignalSeriesMetadataLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 const std::string& seriesInstanceUid) = 0;
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
207
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
208 virtual void SignalSeriesPdfLoaded(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
209 const std::string& seriesInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
210 const std::string& pdf) = 0;
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
211
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
212 virtual void SignalMultiframeInstanceThumbnailLoaded(const std::string& sopInstanceUid,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
213 const std::string& jpeg) = 0;
1495
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 private:
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
217 OrthancStone::ILoadersContext& context_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 std::unique_ptr<IObserver> observer_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 OrthancStone::DicomSource source_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 size_t pending_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 boost::shared_ptr<OrthancStone::LoadedDicomResources> studies_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 boost::shared_ptr<OrthancStone::LoadedDicomResources> series_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 boost::shared_ptr<OrthancStone::DicomResourcesLoader> resourcesLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 boost::shared_ptr<OrthancStone::SeriesThumbnailsLoader> thumbnailsLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 boost::shared_ptr<OrthancStone::SeriesMetadataLoader> metadataLoader_;
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
226 std::set<std::string> scheduledMultiframeInstances_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
228 explicit ResourcesLoader(OrthancStone::ILoadersContext& context,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
229 const OrthancStone::DicomSource& source) :
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
230 context_(context),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 source_(source),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 pending_(0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 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
234 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
235 {
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 void Handle(const OrthancStone::DicomResourcesLoader::SuccessMessage& message)
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 const Orthanc::SingleValueObject<Orthanc::ResourceType>& payload =
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 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
242
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 OrthancStone::LoadedDicomResources& dicom = *message.GetResources();
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 LOG(INFO) << "resources loaded: " << dicom.GetSize()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 << ", " << Orthanc::EnumerationToString(payload.GetValue());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 if (payload.GetValue() == Orthanc::ResourceType_Series)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 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
251 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 std::string studyInstanceUid, seriesInstanceUid;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 if (dicom.GetResource(i).LookupStringValue(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 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
255 dicom.GetResource(i).LookupStringValue(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 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
257 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 thumbnailsLoader_->ScheduleLoadThumbnail(source_, "", studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 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
260 }
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 if (pending_ == 0)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 pending_ --;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 if (pending_ == 0 &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 observer_.get() != NULL)
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 observer_->SignalResourcesLoaded();
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 }
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 void Handle(const OrthancStone::SeriesThumbnailsLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 if (observer_.get() != NULL)
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 observer_->SignalSeriesThumbnailLoaded(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 message.GetStudyInstanceUid(), message.GetSeriesInstanceUid());
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 void Handle(const OrthancStone::SeriesMetadataLoader::SuccessMessage& message)
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 if (observer_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 observer_->SignalSeriesMetadataLoaded(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 message.GetStudyInstanceUid(), message.GetSeriesInstanceUid());
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
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
297 void FetchInternal(const std::string& patientId,
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
298 const std::string& studyInstanceUid,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 const std::string& seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 // Firstly, load the study
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 Orthanc::DicomMap filter;
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
303
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
304 if (!patientId.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
305 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
306 filter.SetValue(Orthanc::DICOM_TAG_PATIENT_ID, patientId, false);
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
307 }
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
308
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
309 if (!studyInstanceUid.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
310 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
311 filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false);
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
312 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 std::set<Orthanc::DicomTag> tags;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 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
316
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 resourcesLoader_->ScheduleQido(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 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
319 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
320
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 // Secondly, load the series
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 if (!seriesInstanceUid.empty())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 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
325 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 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
328
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 resourcesLoader_->ScheduleQido(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 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
331 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
332
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 pending_ += 2;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 }
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
335
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
336
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
337 class PdfInfo : public Orthanc::IDynamicObject
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
338 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
339 private:
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
340 std::string studyInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
341 std::string seriesInstanceUid_;
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 public:
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
344 PdfInfo(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
345 const std::string& seriesInstanceUid) :
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
346 studyInstanceUid_(studyInstanceUid),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
347 seriesInstanceUid_(seriesInstanceUid)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
348 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
349 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
350
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
351 const std::string& GetStudyInstanceUid() const
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
352 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
353 return studyInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
354 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
355
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
356 const std::string& GetSeriesInstanceUid() const
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
357 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
358 return seriesInstanceUid_;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
359 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
360 };
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
361
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
362
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
363 void Handle(const OrthancStone::ParseDicomSuccessMessage& message)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
364 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
365 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
366
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
367 if (observer_.get() != NULL)
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 std::string pdf;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
370 if (message.GetDicom().ExtractPdf(pdf))
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
371 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
372 observer_->SignalSeriesPdfLoaded(info.GetStudyInstanceUid(), info.GetSeriesInstanceUid(), pdf);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
373 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
374 else
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
375 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
376 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
377 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
378 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
379 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
380
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
381 void FetchInstanceThumbnail(const std::string& studyInstanceUid,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
382 const std::string& seriesInstanceUid,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
383 const std::string& sopInstanceUid)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
384 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
385 if (scheduledMultiframeInstances_.find(sopInstanceUid) == scheduledMultiframeInstances_.end())
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
386 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
387 scheduledMultiframeInstances_.insert(sopInstanceUid);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
388
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
389 std::map<std::string, std::string> arguments;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
390 std::map<std::string, std::string> headers;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
391 arguments["viewport"] = (
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
392 boost::lexical_cast<std::string>(thumbnailsLoader_->GetThumbnailWidth()) + "," +
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
393 boost::lexical_cast<std::string>(thumbnailsLoader_->GetThumbnailHeight()));
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
394 headers["Accept"] = Orthanc::MIME_JPEG;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
395
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
396 const std::string uri = ("studies/" + studyInstanceUid + "/series/" + seriesInstanceUid +
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
397 "/instances/" + sopInstanceUid + "/frames/1/rendered");
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
398
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
399 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
400 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock());
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
401 lock->Schedule(
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
402 GetSharedObserver(), PRIORITY_LOW + 2, source_.CreateDicomWebCommand(
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
403 uri, arguments, headers, new Orthanc::SingleValueObject<std::string>(sopInstanceUid)));
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
404 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
405 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
406 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
407
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
408 void HandleInstanceThumbnail(const OrthancStone::HttpCommand::SuccessMessage& message)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
409 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
410 if (observer_.get() != NULL)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
411 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
412 const std::string& sopInstanceUid =
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
413 dynamic_cast<const Orthanc::SingleValueObject<std::string>&>(
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
414 message.GetOrigin().GetPayload()).GetValue();
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
415 observer_->SignalMultiframeInstanceThumbnailLoaded(sopInstanceUid, message.GetAnswer());
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
416 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
417 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
418
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 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
421 const OrthancStone::DicomSource& source)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 {
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
423 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
424
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 loader->resourcesLoader_ = OrthancStone::DicomResourcesLoader::Create(lock);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 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
427 loader->metadataLoader_ = OrthancStone::SeriesMetadataLoader::Create(lock);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 loader->Register<OrthancStone::DicomResourcesLoader::SuccessMessage>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 *loader->resourcesLoader_, &ResourcesLoader::Handle);
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 loader->Register<OrthancStone::SeriesThumbnailsLoader::SuccessMessage>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 *loader->thumbnailsLoader_, &ResourcesLoader::Handle);
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 loader->Register<OrthancStone::SeriesMetadataLoader::SuccessMessage>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 *loader->metadataLoader_, &ResourcesLoader::Handle);
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
437
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
438 loader->Register<OrthancStone::ParseDicomSuccessMessage>(
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
439 lock.GetOracleObservable(), &ResourcesLoader::Handle);
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
440
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
441 loader->Register<OrthancStone::HttpCommand::SuccessMessage>(
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
442 lock.GetOracleObservable(), &ResourcesLoader::HandleInstanceThumbnail);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
443
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 return loader;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 void FetchAllStudies()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 {
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
449 FetchInternal("", "", "");
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
450 }
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
451
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
452 void FetchPatient(const std::string& patientId)
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
453 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
454 if (!patientId.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
455 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
456 FetchInternal(patientId, "", "");
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
457 }
1495
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 void FetchStudy(const std::string& studyInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 {
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
462 if (!studyInstanceUid.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
463 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
464 FetchInternal("", studyInstanceUid, "");
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
465 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 void FetchSeries(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 const std::string& seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 {
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
471 if (!studyInstanceUid.empty() &&
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
472 !seriesInstanceUid.empty())
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
473 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
474 FetchInternal("", studyInstanceUid, seriesInstanceUid);
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
475 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 size_t GetStudiesCount() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 return studies_->GetSize();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 size_t GetSeriesCount() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 return series_->GetSize();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 void GetStudy(Orthanc::DicomMap& target,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
489 size_t i) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 target.Assign(studies_->GetResource(i));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 void GetSeries(Orthanc::DicomMap& target,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
495 size_t i) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 target.Assign(series_->GetResource(i));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 // Complement with the study-level tags
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 std::string studyInstanceUid;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 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
502 studies_->HasResource(studyInstanceUid))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 studies_->MergeResource(target, studyInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 OrthancStone::SeriesThumbnailType GetSeriesThumbnail(std::string& image,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 std::string& mime,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
510 const std::string& seriesInstanceUid) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 return thumbnailsLoader_->GetSeriesThumbnail(image, mime, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 void FetchSeriesMetadata(int priority,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 const std::string& studyInstanceUid,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
517 const std::string& seriesInstanceUid) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 metadataLoader_->ScheduleLoadSeries(priority, source_, studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
522 bool IsSeriesComplete(const std::string& seriesInstanceUid) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 return accessor.IsComplete();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
528 bool LookupMultiframeSeries(std::map<std::string, unsigned int>& numberOfFramesPerInstance,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
529 const std::string& seriesInstanceUid)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
530 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
531 numberOfFramesPerInstance.clear();
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
532
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
533 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
534 if (accessor.IsComplete() &&
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
535 accessor.GetInstancesCount() >= 2)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
536 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
537 bool isMultiframe = false;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
538
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
539 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
540 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
541 OrthancStone::DicomInstanceParameters p(accessor.GetInstance(i));
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
542 numberOfFramesPerInstance[p.GetSopInstanceUid()] = p.GetNumberOfFrames();
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
543
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
544 if (p.GetNumberOfFrames() > 1)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
545 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
546 isMultiframe = true;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
547 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
548 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
549
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
550 if (isMultiframe)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
551 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
552 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
553 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
554 OrthancStone::DicomInstanceParameters p(accessor.GetInstance(i));
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
555 FetchInstanceThumbnail(p.GetStudyInstanceUid(), p.GetSeriesInstanceUid(), p.GetSopInstanceUid());
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
556 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
557 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
558
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
559 return isMultiframe;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
560 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
561 else
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
562 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
563 return false;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
564 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
565 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
566
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 bool SortSeriesFrames(OrthancStone::SortedFrames& target,
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
568 const std::string& seriesInstanceUid) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
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 if (accessor.IsComplete())
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 target.Clear();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 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
577 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 target.AddInstance(accessor.GetInstance(i));
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 target.Sort();
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 return true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 return false;
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
1704
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
591 bool SortMultipartInstanceFrames(OrthancStone::SortedFrames& target,
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
592 const std::string& seriesInstanceUid,
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
593 const std::string& sopInstanceUid) const
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
594 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
595 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
596
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
597 if (accessor.IsComplete())
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
598 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
599 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
600 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
601 std::string s;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
602 if (accessor.GetInstance(i).LookupStringValue(s, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false) &&
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
603 s == sopInstanceUid)
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
604 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
605 target.Clear();
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
606 target.AddInstance(accessor.GetInstance(i));
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
607 target.Sort();
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
608 return true;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
609 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
610 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
611
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
612 return true;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
613 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
614 else
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
615 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
616 return false;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
617 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
618 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
619
1674
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
620 size_t GetSeriesNumberOfFrames(const std::string& seriesInstanceUid) const
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
621 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
622 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
623
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
624 if (accessor.IsComplete())
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
625 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
626 size_t count = 0;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
627
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
628 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
629 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
630 uint32_t f;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
631 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
632 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
633 count += f;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
634 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
635 else
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
636 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
637 count++;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
638 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
639 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
640
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
641 return count;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
642 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
643 else
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
644 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
645 return 0;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
646 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
647 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
648
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 void AcquireObserver(IObserver* observer)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651 observer_.reset(observer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 }
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
653
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
654 void FetchPdf(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
655 const std::string& seriesInstanceUid)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
656 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
657 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
658
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
659 if (accessor.IsComplete())
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
660 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
661 if (accessor.GetInstancesCount() > 1)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
662 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
663 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
664 << seriesInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
665 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
666
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
667 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
668 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
669 std::string sopClassUid, sopInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
670 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
671 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
672 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
673 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
674 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock());
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
675 lock->Schedule(
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
676 GetSharedObserver(), PRIORITY_NORMAL, OrthancStone::ParseDicomFromWadoCommand::Create(
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
677 source_, studyInstanceUid, seriesInstanceUid, sopInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
678 false /* no transcoding */, Orthanc::DicomTransferSyntax_LittleEndianExplicit /* dummy value */,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
679 new PdfInfo(studyInstanceUid, seriesInstanceUid)));
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
680
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
681 return;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
682 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
683 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
684
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
685 LOG(WARNING) << "Series without a PDF: " << seriesInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
686 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
687 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688 };
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
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 class FramesCache : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
694 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 class CachedImage : public Orthanc::ICacheable
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 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698 std::unique_ptr<Orthanc::ImageAccessor> image_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
699 unsigned int quality_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
700
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
701 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
702 CachedImage(Orthanc::ImageAccessor* image,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
703 unsigned int quality) :
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
704 image_(image),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705 quality_(quality)
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 assert(image != NULL);
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
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1565
diff changeset
710 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
711 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 assert(image_.get() != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 return (image_->GetBytesPerPixel() * image_->GetPitch() * image_->GetHeight());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 const Orthanc::ImageAccessor& GetImage() const
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 assert(image_.get() != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719 return *image_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722 unsigned int GetQuality() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724 return quality_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 }
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
729 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
730 size_t frameNumber)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 {
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
732 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
733 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734
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 Orthanc::MemoryObjectCache cache_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
738 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739 FramesCache()
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 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
742 //SetMaximumSize(1); // DISABLE CACHE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 }
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 size_t GetMaximumSize()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 return cache_.GetMaximumSize();
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 void SetMaximumSize(size_t size)
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 cache_.SetMaximumSize(size);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 * 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
757 * 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
758 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 bool Acquire(const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
760 size_t frameNumber,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 Orthanc::ImageAccessor* image /* transfer ownership */,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762 unsigned int quality)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764 std::unique_ptr<Orthanc::ImageAccessor> protection(image);
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 if (image == NULL)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
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 else if (image->GetFormat() != Orthanc::PixelFormat_Float32 &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771 image->GetFormat() != Orthanc::PixelFormat_RGB24)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
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
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
776 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
777
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 bool invalidate = false;
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 {
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 * 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
783 * 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
784 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785 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
786
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787 if (accessor.IsValid())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 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
790
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 // 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
792 if (previous.GetQuality() < quality)
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 // The previously stored image has poorer quality
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 invalidate = true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799 // 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
800 return false;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801 }
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 else
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 invalidate = false;
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809 if (invalidate)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 cache_.Invalidate(key);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 }
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 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
815 return true;
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 class Accessor : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821 Orthanc::MemoryObjectCache::Accessor accessor_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823 const CachedImage& GetCachedImage() const
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 (IsValid())
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 return dynamic_cast<CachedImage&>(accessor_.GetValue());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 Accessor(FramesCache& that,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
837 const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
838 size_t frameNumber) :
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
839 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
840 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843 bool IsValid() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 return accessor_.IsValid();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
847
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848 const Orthanc::ImageAccessor& GetImage() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
849 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850 return GetCachedImage().GetImage();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853 unsigned int GetQuality() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 return GetCachedImage().GetQuality();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
858 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
861
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862 class SeriesCursor : public boost::noncopyable
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 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865 enum Action
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 Action_FastPlus,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
868 Action_Plus,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
869 Action_None,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
870 Action_Minus,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
871 Action_FastMinus
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
873
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
874 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875 std::vector<size_t> prefetch_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
876 int framesCount_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
877 int currentFrame_;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
878 bool isCircularPrefetch_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
879 int fastDelta_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
880 Action lastAction_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
881
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
882 int ComputeNextFrame(int currentFrame,
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
883 Action action,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
884 bool isCircular) const
1495
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 if (framesCount_ == 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
887 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
888 assert(currentFrame == 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
889 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
890 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
892 int nextFrame = currentFrame;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894 switch (action)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 case Action_FastPlus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 nextFrame += fastDelta_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 case Action_Plus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901 nextFrame += 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
902 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
903
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
904 case Action_None:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905 break;
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 case Action_Minus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
908 nextFrame -= 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
909 break;
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 case Action_FastMinus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
912 nextFrame -= fastDelta_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913 break;
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 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
916 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
917 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
919 if (isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
921 while (nextFrame < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
923 nextFrame += framesCount_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
924 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
925
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
926 while (nextFrame >= framesCount_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928 nextFrame -= framesCount_;
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 else
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 if (nextFrame < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935 nextFrame = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937 else if (nextFrame >= framesCount_)
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 nextFrame = framesCount_ - 1;
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 }
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 return nextFrame;
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 void UpdatePrefetch()
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 * 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
950 * 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
951 * 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
952 * 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
953 * will do the same action just afterwards.
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
954 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
955
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956 prefetch_.clear();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
957
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958 if (framesCount_ == 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
959 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960 return;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963 prefetch_.reserve(framesCount_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965 // 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
966 // 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
967 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
968
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
969 Queue queue;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
970 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
971
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
972 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
973
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
974 while (!queue.empty())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
975 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
976 int frame = queue.front().first;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
977 Action previousAction = queue.front().second;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
978 queue.pop_front();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
979
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
980 if (visited.find(frame) == visited.end())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
981 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
982 visited.insert(frame);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
983 prefetch_.push_back(frame);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
984
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
985 switch (previousAction)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
986 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
987 case Action_None:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
988 case Action_Plus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
989 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
990 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
991 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
992 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
993 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
994
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
995 case Action_Minus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
996 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
997 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
998 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
999 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
1000 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1001
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1002 case Action_FastPlus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1003 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
1004 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
1005 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
1006 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
1007 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1008
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1009 case Action_FastMinus:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1010 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
1011 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
1012 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
1013 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
1014 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1015
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1016 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1017 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1018 }
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1022 assert(prefetch_.size() == framesCount_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1023 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1024
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 bool CheckFrameIndex(int frame) const
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 return ((framesCount_ == 0 && frame == 0) ||
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028 (framesCount_ > 0 && frame >= 0 && frame < framesCount_));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1029 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1030
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1031 public:
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1565
diff changeset
1032 explicit SeriesCursor(size_t framesCount) :
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1033 framesCount_(framesCount),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034 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
1035 isCircularPrefetch_(false),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 lastAction_(Action_None)
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 SetFastDelta(framesCount / 20);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1041
1719
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1042 size_t GetFramesCount() const
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1043 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1044 return framesCount_;
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1045 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
1046
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1047 void SetCircularPrefetch(bool isCircularPrefetch)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1048 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1049 isCircularPrefetch_ = isCircularPrefetch;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1050 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1051 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 void SetFastDelta(int delta)
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 fastDelta_ = (delta < 0 ? -delta : delta);
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 if (fastDelta_ <= 0)
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 fastDelta_ = 1;
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 void SetCurrentIndex(size_t frame)
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 if (frame >= framesCount_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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 else
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 currentFrame_ = frame;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1072 lastAction_ = Action_None;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1073 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1074 }
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1077 size_t GetCurrentIndex() const
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 assert(CheckFrameIndex(currentFrame_));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1080 return static_cast<size_t>(currentFrame_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1081 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1082
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1083 void Apply(Action action,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1084 bool isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1085 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1086 currentFrame_ = ComputeNextFrame(currentFrame_, action, isCircular);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1087 lastAction_ = action;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1088 UpdatePrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1089 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1090
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091 size_t GetPrefetchSize() const
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 assert(prefetch_.size() == framesCount_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1094 return prefetch_.size();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1096
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1097 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
1098 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1099 if (i >= prefetch_.size())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1100 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1101 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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 else
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 assert(CheckFrameIndex(prefetch_[i]));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1106 return static_cast<size_t>(prefetch_[i]);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1107 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1108 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1109 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1110
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1113
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
1114 /**
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
1115 * 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
1116 * 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
1117 * checked by this function.
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
1118 **/
1646
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1119 static bool GetReferenceLineCoordinates(double& x1,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1120 double& y1,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1121 double& x2,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1122 double& y2,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1123 const OrthancStone::DicomInstanceParameters& instance1,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1124 unsigned int frame1,
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1125 const OrthancStone::CoordinateSystem3D& plane2)
1646
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1126 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1127 if (instance1.GetWidth() == 0 &&
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1128 instance1.GetHeight() == 0)
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1129 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1130 return false;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1131 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1132 else
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1133 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1134 /**
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1135 * Compute the 2D extent of the "instance1", expressed in
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1136 * 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
1137 *
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1138 * In a multiframe image (cf. "ExtractFrameOffsets()"), the plane of
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1139 * 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
1140 * 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
1141 * frame, so we can ignore the frame number.
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1142 **/
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1143 OrthancStone::Extent2D extent;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1144
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1145 double ox = -instance1.GetPixelSpacingX() / 2.0;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1146 double oy = -instance1.GetPixelSpacingY() / 2.0;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1147 extent.AddPoint(ox, oy);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1148 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
1149 oy + instance1.GetPixelSpacingY() * static_cast<double>(instance1.GetHeight()));
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1150
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1151 const OrthancStone::CoordinateSystem3D c1 = instance1.GetFrameGeometry(frame1);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1152
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1153 OrthancStone::Vector direction, origin;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1154
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1155 if (!extent.IsEmpty() &&
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1156 OrthancStone::GeometryToolbox::IntersectTwoPlanes(origin, direction,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1157 c1.GetOrigin(), c1.GetNormal(),
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1158 plane2.GetOrigin(), plane2.GetNormal()))
1646
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1159 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1160 double ax, ay, bx, by;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1161 c1.ProjectPoint(ax, ay, origin);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1162 c1.ProjectPoint(bx, by, origin + 100.0 * direction);
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1163
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1164 return OrthancStone::GeometryToolbox::ClipLineToRectangle(
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1165 x1, y1, x2, y2,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1166 ax, ay, bx, by,
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1167 extent.GetX1(), extent.GetY1(), extent.GetX2(), extent.GetY2());
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1168 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1169 else
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1170 {
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1171 return false;
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1172 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1173 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1174 }
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1175
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1176
4e14735e98f8 preparing to remove FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1177
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1178 class StoneAnnotationsRegistry : public boost::noncopyable
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1179 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1180 private:
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1181 class Index
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1182 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1183 private:
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1184 std::string sopInstanceUid_;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1185 size_t frame_;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1186
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1187 public:
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1188 Index(const std::string& sopInstanceUid,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1189 size_t frame) :
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1190 sopInstanceUid_(sopInstanceUid),
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1191 frame_(frame)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1192 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1193 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1194
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1195 const std::string& GetSopInstanceUid() const
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1196 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1197 return sopInstanceUid_;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1198 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1199
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1200 size_t GetFrame() const
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1201 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1202 return frame_;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1203 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1204
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1205 bool operator< (const Index& other) const
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1206 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1207 if (sopInstanceUid_ < other.sopInstanceUid_)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1208 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1209 return true;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1210 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1211 else if (sopInstanceUid_ > other.sopInstanceUid_)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1212 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1213 return false;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1214 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1215 else
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1216 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1217 return frame_ < other.frame_;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1218 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1219 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1220 };
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1221
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1222 typedef std::map<Index, Json::Value*> Content;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1223
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1224 Content content_;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1225
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1226 void Clear()
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1227 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1228 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1229 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1230 assert(it->second != NULL);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1231 delete it->second;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1232 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1233
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1234 content_.clear();
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1235 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1236
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1237 StoneAnnotationsRegistry()
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1238 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1239 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1240
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1241 public:
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1242 ~StoneAnnotationsRegistry()
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1243 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1244 Clear();
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1245 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1246
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1247 static StoneAnnotationsRegistry& GetInstance()
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1248 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1249 static StoneAnnotationsRegistry singleton;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1250 return singleton;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1251 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1252
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1253 void Save(const std::string& sopInstanceUid,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1254 size_t frame,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1255 const OrthancStone::AnnotationsSceneLayer& layer)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1256 {
1814
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1813
diff changeset
1257 std::unique_ptr<Json::Value> serialized(new Json::Value);
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1258 layer.Serialize(*serialized);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1259
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1260 const Index index(sopInstanceUid, frame);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1261
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1262 Content::iterator found = content_.find(index);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1263 if (found == content_.end())
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1264 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1265 content_[index] = serialized.release();
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1266 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1267 else
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1268 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1269 assert(found->second != NULL);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1270 delete found->second;
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1271 found->second = serialized.release();
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1272 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1273 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1274
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1275 void Load(OrthancStone::AnnotationsSceneLayer& layer,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1276 const std::string& sopInstanceUid,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1277 size_t frame) const
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1278 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1279 const Index index(sopInstanceUid, frame);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1280
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1281 Content::const_iterator found = content_.find(index);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1282 if (found == content_.end())
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1283 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1284 layer.Clear();
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1285 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1286 else
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1287 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1288 assert(found->second != NULL);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1289 layer.Unserialize(*found->second);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1290 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1291 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1292 };
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1293
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1294
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1295
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1296 class ViewerViewport : public OrthancStone::ObserverBase<ViewerViewport>
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1297 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1298 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1299 class IObserver : public boost::noncopyable
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1300 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1301 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1302 virtual ~IObserver()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1303 {
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
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1306 virtual void SignalSeriesDetailsReady(const ViewerViewport& viewport) = 0;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1307
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1308 virtual void SignalFrameUpdated(const ViewerViewport& viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1309 size_t currentFrame,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1310 size_t countFrames,
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1311 DisplayedFrameQuality quality,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1312 unsigned int instanceNumber) = 0;
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
1313
1811
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
1314 // "click" is a 3D vector in world coordinates
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1315 virtual void SignalCrosshair(const ViewerViewport& viewport,
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1316 const OrthancStone::Vector& click) = 0;
1694
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
1317
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
1318 virtual void SignalSynchronizedBrowsing(const ViewerViewport& viewport,
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
1319 const OrthancStone::Vector& click,
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
1320 const OrthancStone::Vector& normal) = 0;
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1321
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1322 virtual void SignalWindowingUpdated(const ViewerViewport& viewport,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1323 double windowingCenter,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1324 double windowingWidth) = 0;
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1325
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1326 virtual void SignalStoneAnnotationsChanged(const ViewerViewport& viewport,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1327 const std::string& sopInstanceUid,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1328 size_t frame) = 0;
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
1329
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
1330 virtual void SignalStoneAnnotationAdded(const ViewerViewport& viewport) = 0;
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
1331
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
1332 virtual void SignalStoneAnnotationRemoved(const ViewerViewport& viewport) = 0;
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1335 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1336 static const int LAYER_TEXTURE = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1337 static const int LAYER_REFERENCE_LINES = 1;
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1338 static const int LAYER_ANNOTATIONS_OSIRIX = 2;
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1339 static const int LAYER_ANNOTATIONS_STONE = 3;
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1607
diff changeset
1340
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1341
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1342 class ICommand : public Orthanc::IDynamicObject
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1343 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1344 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1345 boost::shared_ptr<ViewerViewport> viewport_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1346
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1347 public:
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1565
diff changeset
1348 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
1349 viewport_(viewport)
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 if (viewport == NULL)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1354 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1355 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1356
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1357 virtual ~ICommand()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1358 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1359 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1360
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1361 ViewerViewport& GetViewport() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1362 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1363 assert(viewport_ != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1364 return *viewport_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1365 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1366
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1367 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
1368 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1369 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1370 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1371
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1372 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
1373 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1374 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1375 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1376
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1377 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
1378 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1379 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1380 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1381 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1382
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1383 class LoadSeriesDetailsFromInstance : public ICommand
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1384 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1385 public:
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1386 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
1387 ICommand(viewport)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1388 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1389 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1390
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1391 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
1392 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1393 if (message.GetResources()->GetSize() != 1)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1394 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1395 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1396 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1397
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1398 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
1399
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1400 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1401 OrthancStone::DicomInstanceParameters params(dicom);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1402
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1403 GetViewport().windowingPresetCenters_.resize(params.GetWindowingPresetsCount());
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1404 GetViewport().windowingPresetWidths_.resize(params.GetWindowingPresetsCount());
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1405
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1406 for (size_t i = 0; i < params.GetWindowingPresetsCount(); i++)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1407 {
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1408 LOG(INFO) << "Preset windowing " << (i + 1) << "/" << params.GetWindowingPresetsCount()
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1409 << ": " << params.GetWindowingPresetCenter(i)
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1410 << "," << params.GetWindowingPresetWidth(i);
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1411
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1412 GetViewport().windowingPresetCenters_[i] = params.GetWindowingPresetCenter(i);
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1413 GetViewport().windowingPresetWidths_[i] = params.GetWindowingPresetWidth(i);
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1414 }
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
1415
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1416 if (params.GetWindowingPresetsCount() == 0)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1417 {
1677
51bab5188a13 start multiple preset windowings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1676
diff changeset
1418 LOG(INFO) << "No preset windowing";
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1419 }
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1420
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1421 GetViewport().SetWindowingPreset();
1495
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
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1424 uint32_t cineRate;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1425 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
1426 cineRate > 0)
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1427 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1428 /**
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1429 * 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
1430 * instead of on the middle frame.
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1431 **/
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1432 GetViewport().cursor_->SetCurrentIndex(0);
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1433 GetViewport().cineRate_ = cineRate;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1434 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1435 else
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1436 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1437 GetViewport().cineRate_ = DEFAULT_CINE_RATE;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1438 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1439
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1440 GetViewport().Redraw();
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1441
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1442 if (GetViewport().observer_.get() != NULL)
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1443 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1444 GetViewport().observer_->SignalSeriesDetailsReady(GetViewport());
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1445 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1446 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1447 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1448
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1449
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1450 class SetLowQualityFrame : public ICommand
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1451 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1452 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1453 std::string sopInstanceUid_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1454 unsigned int frameNumber_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1455 float windowCenter_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1456 float windowWidth_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1457 bool isMonochrome1_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1458 bool isPrefetch_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1459
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1460 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1461 SetLowQualityFrame(boost::shared_ptr<ViewerViewport> viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1462 const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1463 unsigned int frameNumber,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1464 float windowCenter,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1465 float windowWidth,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1466 bool isMonochrome1,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1467 bool isPrefetch) :
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1468 ICommand(viewport),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1469 sopInstanceUid_(sopInstanceUid),
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1470 frameNumber_(frameNumber),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1471 windowCenter_(windowCenter),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1472 windowWidth_(windowWidth),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1473 isMonochrome1_(isMonochrome1),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1474 isPrefetch_(isPrefetch)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1475 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1476 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1477
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1478 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
1479 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1480 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
1481 jpeg->ReadFromMemory(message.GetAnswer());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1482
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1483 std::unique_ptr<Orthanc::ImageAccessor> converted;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1484
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1485 switch (jpeg->GetFormat())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1486 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1487 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
1488 converted.reset(jpeg.release());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1489 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1490
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1491 case Orthanc::PixelFormat_Grayscale8:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1492 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1493 if (isMonochrome1_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1494 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1495 Orthanc::ImageProcessing::Invert(*jpeg);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1496 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1497
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1498 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
1499 jpeg->GetHeight(), false));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1500
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1501 Orthanc::ImageProcessing::Convert(*converted, *jpeg);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1502
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1503 /**
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1504
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1505 Orthanc::ImageProcessing::ShiftScale() computes "(x + offset) * scaling".
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1506 The system to solve is thus:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1507
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1508 (0 + offset) * scaling = windowingCenter - windowingWidth / 2 [a]
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1509 (255 + offset) * scaling = windowingCenter + windowingWidth / 2 [b]
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1510
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1511 Resolution:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1512
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1513 [b - a] => 255 * scaling = windowingWidth
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1514 [a] => offset = (windowingCenter - windowingWidth / 2) / scaling
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1515
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1516 **/
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1517
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1518 const float scaling = windowWidth_ / 255.0f;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1519 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
1520 (windowCenter_ - windowWidth_ / 2.0f) / scaling);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1521
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1522 Orthanc::ImageProcessing::ShiftScale(*converted, offset, scaling, false);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1523 break;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1524 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1525
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1526 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1527 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1528 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1529
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1530 assert(converted.get() != NULL);
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1531 GetViewport().RenderCurrentSceneFromCommand(*converted, sopInstanceUid_, frameNumber_, DisplayedFrameQuality_Low);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1532 GetViewport().framesCache_->Acquire(sopInstanceUid_, frameNumber_, converted.release(), QUALITY_JPEG);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1533
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1534 if (isPrefetch_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1535 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1536 GetViewport().ScheduleNextPrefetch();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1537 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1538 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1539 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1540
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1541
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1542 class SetFullDicomFrame : public ICommand
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1543 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1544 private:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1545 std::string sopInstanceUid_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1546 unsigned int frameNumber_;
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1547 int priority_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1548 bool isPrefetch_;
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1549 bool serverSideTranscoding_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1550
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1551 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1552 SetFullDicomFrame(boost::shared_ptr<ViewerViewport> viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1553 const std::string& sopInstanceUid,
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1554 unsigned int frameNumber,
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1555 int priority,
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1556 bool isPrefetch,
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1557 bool serverSideTranscoding) :
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1558 ICommand(viewport),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1559 sopInstanceUid_(sopInstanceUid),
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1560 frameNumber_(frameNumber),
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1561 priority_(priority),
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1562 isPrefetch_(isPrefetch),
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1563 serverSideTranscoding_(serverSideTranscoding)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1564 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1565 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1566
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1567 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
1568 {
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1569 std::unique_ptr<Orthanc::ImageAccessor> frame;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1570
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1571 try
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1572 {
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1573 frame.reset(message.GetDicom().DecodeFrame(frameNumber_));
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1574 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1575 catch (Orthanc::OrthancException& e)
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1576 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1577 if (e.GetErrorCode() == Orthanc::ErrorCode_NotImplemented)
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1578 {
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1579 if (!serverSideTranscoding_)
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1580 {
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1581 // If we haven't tried server-side rendering yet, give it a try
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1582 LOG(INFO) << "Switching to server-side transcoding";
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1583 GetViewport().serverSideTranscoding_ = true;
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1584 GetViewport().ScheduleLoadFullDicomFrame(sopInstanceUid_, frameNumber_, priority_, isPrefetch_);
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1585 }
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1586 return;
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1587 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1588 else
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1589 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1590 throw;
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1591 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1592 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1593
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1594 if (frame.get() == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1595 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1596 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1597 }
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1598 else
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1599 {
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1600 Apply(GetViewport(), message.GetDicom(), frame.release(), sopInstanceUid_, frameNumber_);
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1601
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1602 if (isPrefetch_)
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1603 {
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1604 GetViewport().ScheduleNextPrefetch();
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1605 }
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1606 }
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1607 }
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1608
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1609 static void Apply(ViewerViewport& viewport,
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1610 const Orthanc::ParsedDicomFile& dicom,
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1611 Orthanc::ImageAccessor* f,
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1612 const std::string& sopInstanceUid,
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1613 unsigned int frameNumber)
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1614 {
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1615 std::unique_ptr<Orthanc::ImageAccessor> frameProtection(f);
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1616
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1617 Orthanc::DicomMap tags;
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1618 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
1619
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1620 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
1621
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1622 if (frameProtection->GetFormat() == Orthanc::PixelFormat_RGB24)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1623 {
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1624 converted.reset(frameProtection.release());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1625 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1626 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1627 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1628 double a = 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1629 double b = 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1630
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1631 double doseScaling;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1632 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
1633 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1634 a = doseScaling;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1635 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1636
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1637 double rescaleIntercept, rescaleSlope;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1638 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
1639 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
1640 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1641 a *= rescaleSlope;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1642 b = rescaleIntercept;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1643 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1644
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1645 converted.reset(new Orthanc::Image(Orthanc::PixelFormat_Float32, frameProtection->GetWidth(), frameProtection->GetHeight(), false));
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
1646 Orthanc::ImageProcessing::Convert(*converted, *frameProtection);
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1647 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
1648 }
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1649
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1650 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
1651 viewport.RenderCurrentSceneFromCommand(*converted, sopInstanceUid, frameNumber, DisplayedFrameQuality_High);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1652 viewport.framesCache_->Acquire(sopInstanceUid, frameNumber, converted.release(), QUALITY_FULL);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1653 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1654 };
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1657 class PrefetchItem
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1658 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1659 private:
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1660 size_t cursorIndex_;
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1661 bool isFullQuality_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1662
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1663 public:
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1664 PrefetchItem(size_t cursorIndex,
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1665 bool isFullQuality) :
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1666 cursorIndex_(cursorIndex),
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1667 isFullQuality_(isFullQuality)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1668 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1669 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1670
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1671 size_t GetCursorIndex() const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1672 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1673 return cursorIndex_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1674 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1675
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1676 bool IsFullQuality() const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1677 {
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1678 return isFullQuality_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1679 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1680 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1681
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1682
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1683 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
1684 OrthancStone::WebAssemblyLoadersContext& context_;
1551
c54bc5bffd01 software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
1685 boost::shared_ptr<OrthancStone::WebAssemblyViewport> viewport_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1686 boost::shared_ptr<OrthancStone::DicomResourcesLoader> loader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1687 OrthancStone::DicomSource source_;
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1688 boost::shared_ptr<FramesCache> framesCache_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1689 std::unique_ptr<OrthancStone::SortedFrames> frames_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1690 std::unique_ptr<SeriesCursor> cursor_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1691 float windowingCenter_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1692 float windowingWidth_;
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1693 std::vector<float> windowingPresetCenters_;
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
1694 std::vector<float> windowingPresetWidths_;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
1695 unsigned int cineRate_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1696 bool inverted_;
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1697 bool flipX_;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
1698 bool flipY_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1699 bool fitNextContent_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1700 std::list<PrefetchItem> prefetchQueue_;
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
1701 bool serverSideTranscoding_;
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1702 OrthancStone::Vector synchronizationOffset_;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
1703 bool synchronizationEnabled_;
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1704 double centralPhysicalWidth_; // LSD-479
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1705 double centralPhysicalHeight_;
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1706
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1707 bool hasFocusOnInstance_;
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
1708 std::string focusSopInstanceUid_;
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1709 size_t focusFrameNumber_;
1811
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
1710
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
1711 // The coordinates of OsiriX annotations are expressed in 3D world coordinates
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
1712 boost::shared_ptr<OrthancStone::OsiriX::CollectionOfAnnotations> osiriXAnnotations_;
1811
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
1713
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
1714 // The coordinates of Stone annotations are expressed in 2D
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
1715 // coordinates of the current texture, with (0,0) corresponding to
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
1716 // the center of the top-left pixel
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
1717 boost::shared_ptr<OrthancStone::AnnotationsSceneLayer> stoneAnnotations_;
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
1718
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
1719
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1720 void ScheduleNextPrefetch()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1721 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1722 while (!prefetchQueue_.empty())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1723 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1724 size_t cursorIndex = prefetchQueue_.front().GetCursorIndex();
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1725 bool isFullQuality = prefetchQueue_.front().IsFullQuality();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1726 prefetchQueue_.pop_front();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1727
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1728 const std::string sopInstanceUid = frames_->GetInstanceOfFrame(cursorIndex).GetSopInstanceUid();
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1729 unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1730
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1731 {
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1732 FramesCache::Accessor accessor(*framesCache_, sopInstanceUid, frameNumber);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1733 if (!accessor.IsValid() ||
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1734 (isFullQuality && accessor.GetQuality() == 0))
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1735 {
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1736 if (isFullQuality)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1737 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1738 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_NORMAL, true);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1739 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1740 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1741 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
1742 ScheduleLoadRenderedFrame(cursorIndex, PRIORITY_NORMAL, true);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1743 }
1670
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1744
24462a259d8d comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
1745 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
1746 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1747 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1748 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1749 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1750
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1751
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1752 void ClearViewport()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1753 {
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 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
1756 lock->GetController().GetScene().DeleteLayer(LAYER_TEXTURE);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1757 //lock->GetCompositor().Refresh(lock->GetController().GetScene());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1758 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1759 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1760 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1761
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1762
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1763 /**
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1764 * NB: "frame" is only used to estimate the memory size to store 1
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1765 * frame, in order to avoid prefetching too much data.
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1766 **/
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1767 void SetupPrefetchAfterRendering(const Orthanc::ImageAccessor& frame,
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1768 DisplayedFrameQuality quality)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1769 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1770 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
1771
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1772 // Prepare prefetching
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1773 prefetchQueue_.clear();
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1774
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1775 if (1) // DISABLE PREFETCHING
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1776 {
1680
03afa09cfcf1 running the tests of the Orthanc Framework in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1679
diff changeset
1777 const size_t frameSize = frame.GetPitch() * frame.GetHeight();
03afa09cfcf1 running the tests of the Orthanc Framework in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1679
diff changeset
1778 size_t prefetchedSize = 0;
03afa09cfcf1 running the tests of the Orthanc Framework in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1679
diff changeset
1779
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1780 for (size_t i = 0; i < cursor_->GetPrefetchSize() && i < 16 &&
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1781 prefetchedSize <= framesCache_->GetMaximumSize() / 2; i++)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1782 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1783 size_t a = cursor_->GetPrefetchIndex(i);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1784 if (a != cursorIndex)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1785 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1786 prefetchQueue_.push_back(PrefetchItem(a, i < 2));
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1787 prefetchedSize += frameSize;
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1788 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1789 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1790 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1791
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1792 ScheduleNextPrefetch();
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1793
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1794 if (frames_.get() != NULL &&
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1795 cursor_.get() != NULL &&
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1796 observer_.get() != NULL)
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1797 {
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1798 const Orthanc::DicomMap& instance = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()).GetTags();
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1799
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1800 uint32_t instanceNumber;
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1801 if (!instance.ParseUnsignedInteger32(instanceNumber, Orthanc::DICOM_TAG_INSTANCE_NUMBER))
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1802 {
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1803 instanceNumber = 0;
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1804 }
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1805
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
1806 observer_->SignalFrameUpdated(*this, cursorIndex, frames_->GetFramesCount(), quality, instanceNumber);
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1807 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1808 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1809
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1810
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1811 void RenderCurrentScene(const Orthanc::ImageAccessor& frame,
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1812 const OrthancStone::DicomInstanceParameters& instance,
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1813 size_t frameIndex,
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1814 const OrthancStone::CoordinateSystem3D& plane)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1815 {
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1816 /**
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1817 * IMPORTANT - DO NOT use "instance.GetWidth()" and
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1818 * "instance.GetHeight()" in this method. Use the information from
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1819 * "frame" instead. Indeed, the "instance" information is taken
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1820 * from DICOMweb "/studies/.../series/.../metadata". But,
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1821 * "SeriesMetadataExtrapolatedTags" includes the "Columns" and
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1822 * "Rows" DICOM tags for performance, which make this information
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1823 * unreliable if the series includes instances with varying sizes
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1824 * (cf. LSD-479).
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1825 **/
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1826
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1827 bool isMonochrome1 = (instance.GetImageInformation().GetPhotometricInterpretation() ==
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1828 Orthanc::PhotometricInterpretation_Monochrome1);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1829
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1830 std::unique_ptr<OrthancStone::TextureBaseSceneLayer> layer;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1831
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1832 switch (frame.GetFormat())
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1833 {
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1834 case Orthanc::PixelFormat_RGB24:
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1835 layer.reset(new OrthancStone::ColorTextureSceneLayer(frame));
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1836 break;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1837
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1838 case Orthanc::PixelFormat_Float32:
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1839 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1840 std::unique_ptr<OrthancStone::FloatTextureSceneLayer> tmp(
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1841 new OrthancStone::FloatTextureSceneLayer(frame));
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1842 tmp->SetCustomWindowing(windowingCenter_, windowingWidth_);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1843 tmp->SetInverted(inverted_ ^ isMonochrome1);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1844 layer.reset(tmp.release());
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1845 break;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1846 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1847
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1848 default:
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1849 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1850 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1851
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1852 assert(layer.get() != NULL);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1853
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1854 layer->SetLinearInterpolation(true);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1855 layer->SetFlipX(flipX_);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1856 layer->SetFlipY(flipY_);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1857
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1858 double pixelSpacingX, pixelSpacingY;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1859 OrthancStone::GeometryToolbox::GetPixelSpacing(pixelSpacingX, pixelSpacingY, instance.GetTags());
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1860
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1861 if (FIX_LSD_479)
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1862 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1863 /**
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1864 * Some series contain a first instance (secondary capture) that
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1865 * is completely different from others wrt. to resolution and
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1866 * pixel spacing. We make sure to rescale each frame to fit in a
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1867 * square that corresponds to the extent of the frame in the
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1868 * middle of the series.
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1869 **/
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1870 double physicalWidth = pixelSpacingX * static_cast<double>(frame.GetWidth());
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1871 double physicalHeight = pixelSpacingY * static_cast<double>(frame.GetHeight());
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1872
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1873 if (OrthancStone::LinearAlgebra::IsCloseToZero(physicalWidth) ||
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1874 OrthancStone::LinearAlgebra::IsCloseToZero(physicalHeight))
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1875 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1876 // Numerical instability, don't try further processing
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1877 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1878 }
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1879 else
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1880 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1881 double scale = std::max(centralPhysicalWidth_ / physicalWidth,
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1882 centralPhysicalHeight_ / physicalHeight);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1883 layer->SetPixelSpacing(pixelSpacingX * scale, pixelSpacingY * scale);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1884 layer->SetOrigin((centralPhysicalWidth_ - physicalWidth * scale) / 2.0,
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1885 (centralPhysicalHeight_ - physicalHeight * scale) / 2.0);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1886 }
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1887 }
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1888 else
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1889 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1890 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY);
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1891 }
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1892
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1893 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsOsiriX;
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1894
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
1895 if (osiriXAnnotations_)
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1896 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1897 std::set<size_t> a;
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
1898 osiriXAnnotations_->LookupSopInstanceUid(a, instance.GetSopInstanceUid());
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1899 if (plane.IsValid() &&
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1900 !a.empty())
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1901 {
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1902 annotationsOsiriX.reset(new OrthancStone::MacroSceneLayer);
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1903 // annotationsOsiriX->Reserve(a.size());
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1904
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1905 OrthancStone::OsiriXLayerFactory factory;
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1906 factory.SetColor(0, 255, 0);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1907
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1908 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
1909 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
1910 const OrthancStone::OsiriX::Annotation& annotation = osiriXAnnotations_->GetAnnotation(*it);
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1911 annotationsOsiriX->AddLayer(factory.Create(annotation, plane));
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1912 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1913 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1914 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1915
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1916 StoneAnnotationsRegistry::GetInstance().Load(*stoneAnnotations_, instance.GetSopInstanceUid(), frameIndex);
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
1917
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1918 {
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1919 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1920
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1921 OrthancStone::Scene2D& scene = lock->GetController().GetScene();
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1922
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1923 scene.SetLayer(LAYER_TEXTURE, layer.release());
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1924
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1925 if (annotationsOsiriX.get() != NULL)
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1926 {
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1927 scene.SetLayer(LAYER_ANNOTATIONS_OSIRIX, annotationsOsiriX.release());
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1928 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1929 else
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1930 {
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1931 scene.DeleteLayer(LAYER_ANNOTATIONS_OSIRIX);
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1932 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1933
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1934 stoneAnnotations_->Render(scene); // Necessary for "FitContent()" to work
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1935
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1936 if (fitNextContent_)
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1937 {
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1938 lock->RefreshCanvasSize();
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1939 lock->GetCompositor().FitContent(scene);
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1940 stoneAnnotations_->Render(scene);
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1941 fitNextContent_ = false;
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1942 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1943
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1944 //lock->GetCompositor().Refresh(scene);
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
1945 lock->Invalidate();
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1946 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1947 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1948
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
1949
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1950 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
1951 const std::string& loadedSopInstanceUid,
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1952 unsigned int loadedFrameNumber,
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1953 DisplayedFrameQuality quality)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1954 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1955 if (cursor_.get() != NULL &&
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1956 frames_.get() != NULL)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1957 {
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1958 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
1959 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
1960 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
1961
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1962 // 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
1963 if (instance.GetSopInstanceUid() == loadedSopInstanceUid &&
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1964 frameNumber == loadedFrameNumber)
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1965 {
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1966 const OrthancStone::CoordinateSystem3D plane = frames_->GetFrameGeometry(cursorIndex);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1967
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1968 if (quality == DisplayedFrameQuality_Low)
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1969 {
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1970 FramesCache::Accessor accessor(*framesCache_, instance.GetSopInstanceUid(), frameNumber);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1971 if (accessor.IsValid() &&
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1972 accessor.GetQuality() == QUALITY_FULL)
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 // A high-res image was downloaded in between: Use this cached image instead of the low-res
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1975 RenderCurrentScene(accessor.GetImage(), instance, frameNumber, plane);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1976 SetupPrefetchAfterRendering(frame, DisplayedFrameQuality_High);
1671
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 else
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
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1981 RenderCurrentScene(frame, instance, frameNumber, plane);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1982 SetupPrefetchAfterRendering(frame, quality);
1671
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 /**
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1985 * The command "SetupPrefetchAfterRendering()" must be
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1986 * after "SetupPrefetchAfterRendering(quality)", as the
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1987 * DICOM instance might already be cached by the oracle,
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1988 * which makes a call to "observer_->SignalFrameUpdated()"
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1989 * with a low quality, whereas the high quality is
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1990 * available.
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1991 **/
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1992 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1993 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1994 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1995 else
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1996 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
1997 assert(quality == DisplayedFrameQuality_High);
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
1998 SetupPrefetchAfterRendering(frame, quality);
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
1999 RenderCurrentScene(frame, instance, frameNumber, plane);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2000 }
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2001 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2002 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2003 }
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2004
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2005 void ScheduleLoadFullDicomFrame(const std::string& sopInstanceUid,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2006 unsigned int frameNumber,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2007 int priority,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2008 bool isPrefetch)
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2009 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2010 if (frames_.get() != NULL)
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2011 {
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2012 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock());
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2013 lock->Schedule(
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2014 GetSharedObserver(), priority, OrthancStone::ParseDicomFromWadoCommand::Create(
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2015 source_, frames_->GetStudyInstanceUid(), frames_->GetSeriesInstanceUid(),
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2016 sopInstanceUid, serverSideTranscoding_,
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2017 Orthanc::DicomTransferSyntax_LittleEndianExplicit,
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2018 new SetFullDicomFrame(GetSharedObserver(), sopInstanceUid, frameNumber, priority, isPrefetch, serverSideTranscoding_)));
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2019 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2020 }
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2021
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2022 void ScheduleLoadFullDicomFrame(size_t cursorIndex,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2023 int priority,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2024 bool isPrefetch)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2025 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2026 if (frames_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2027 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2028 std::string sopInstanceUid = frames_->GetInstanceOfFrame(cursorIndex).GetSopInstanceUid();
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2029 unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2030 ScheduleLoadFullDicomFrame(sopInstanceUid, frameNumber, priority, isPrefetch);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2031 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2032 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2033
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2034 void ScheduleLoadRenderedFrame(size_t cursorIndex,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2035 int priority,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2036 bool isPrefetch)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2037 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2038 if (!source_.HasDicomWebRendered())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2039 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2040 ScheduleLoadFullDicomFrame(cursorIndex, priority, isPrefetch);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2041 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2042 else if (frames_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2043 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2044 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2045 unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2046
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
2047 /**
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
2048 * If the full-resolution DICOM file is already available in the
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2049 * cache of the oracle, bypass the loading of the "rendered" and
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2050 * use the cached DICOM file.
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
2051 **/
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
2052 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
2053 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
2054
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
2055 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
2056 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
2057 {
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
2058 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
2059 {
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2060 std::unique_ptr<Orthanc::ImageAccessor> frame(accessor->GetDicom().DecodeFrame(frameNumber));
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2061 SetFullDicomFrame::Apply(*this, accessor->GetDicom(), frame.release(), instance.GetSopInstanceUid(), frameNumber);
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2062 return; // Success
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
2063 }
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
2064 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
2065 {
1722
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2066 /**
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2067 * This happens if the cached DICOM file uses a transfer
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2068 * syntax that is not supported by DCMTK (such as
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2069 * JPEG2k). Fallback to "/rendered" in order to re-download
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2070 * the DICOM file using server-side transcoding. This
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2071 * happens on WRIX dataset.
802cb1272f3a fix for the WRIX dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
2072 **/
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
2073 }
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
2074 }
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
2075
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2076 bool isMonochrome1 = (instance.GetImageInformation().GetPhotometricInterpretation() ==
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2077 Orthanc::PhotometricInterpretation_Monochrome1);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2078
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2079 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() +
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2080 "/series/" + frames_->GetSeriesInstanceUid() +
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2081 "/instances/" + instance.GetSopInstanceUid() +
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
2082 "/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
2083
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2084 std::map<std::string, std::string> headers, arguments;
1717
391c798e4dae fix for KNIX sample dataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1714
diff changeset
2085 // arguments["quality"] = "10"; // Low-level quality for test purpose
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2086 arguments["window"] = (
1536
7b326e5ee97b reduce blinking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1534
diff changeset
2087 boost::lexical_cast<std::string>(windowingCenter_) + "," +
7b326e5ee97b reduce blinking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1534
diff changeset
2088 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
2089
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2090 std::unique_ptr<OrthancStone::IOracleCommand> command(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2091 source_.CreateDicomWebCommand(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2092 uri, arguments, headers, new SetLowQualityFrame(
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2093 GetSharedObserver(), instance.GetSopInstanceUid(), frameNumber,
1536
7b326e5ee97b reduce blinking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1534
diff changeset
2094 windowingCenter_, windowingWidth_, isMonochrome1, isPrefetch)));
1495
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 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2097 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
2098 lock->Schedule(GetSharedObserver(), priority, command.release());
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 }
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
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2103 void UpdateCurrentTextureParameters()
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2104 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2105 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
2106
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2107 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
2108 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2109 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
2110 OrthancStone::ISceneLayer::Type_FloatTexture)
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2111 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2112 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2113 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE)).
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2114 SetCustomWindowing(windowingCenter_, windowingWidth_);
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2115 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2116
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2117 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2118 OrthancStone::TextureBaseSceneLayer& layer =
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2119 dynamic_cast<OrthancStone::TextureBaseSceneLayer&>(
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2120 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE));
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2121
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2122 layer.SetFlipX(flipX_);
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2123 layer.SetFlipY(flipY_);
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2124 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2125
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2126 lock->Invalidate();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2127 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2128 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2129
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2130
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
2131 ViewerViewport(OrthancStone::WebAssemblyLoadersContext& context,
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2132 const OrthancStone::DicomSource& source,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2133 const std::string& canvas,
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2134 boost::shared_ptr<FramesCache> cache,
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2135 bool softwareRendering) :
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2136 context_(context),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2137 source_(source),
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
2138 framesCache_(cache),
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2139 fitNextContent_(true),
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2140 flipX_(false),
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
2141 flipY_(false),
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2142 hasFocusOnInstance_(false),
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2143 focusFrameNumber_(0),
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2144 synchronizationOffset_(OrthancStone::LinearAlgebra::CreateVector(0, 0, 0)),
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2145 synchronizationEnabled_(false),
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2146 centralPhysicalWidth_(1),
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2147 centralPhysicalHeight_(1)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2148 {
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
2149 if (!framesCache_)
1495
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2152 }
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2153
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2154 if (softwareRendering)
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2155 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2156 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
2157 viewport_ = OrthancStone::WebAssemblyCairoViewport::Create(canvas);
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2158 }
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2159 else
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2160 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2161 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
2162 viewport_ = OrthancStone::WebGLViewport::Create(canvas);
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2163 }
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2164
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2165 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2166 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2167 std::string ttf;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2168 Orthanc::EmbeddedResources::GetFileResource(ttf, Orthanc::EmbeddedResources::UBUNTU_FONT);
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2169 lock->GetCompositor().SetFont(0, ttf, 16 /* font size */, Orthanc::Encoding_Latin1);
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2170 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2171
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2172 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
2173
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2174 SetWindowingPreset();
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2175
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2176 stoneAnnotations_.reset(new OrthancStone::AnnotationsSceneLayer(LAYER_ANNOTATIONS_STONE));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2177 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2178
1721
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2179
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2180 void Handle(const OrthancStone::ViewportController::GrayscaleWindowingChanged& message)
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2181 {
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2182 // This event is triggered by the windowing mouse action, from class "GrayscaleWindowingSceneTracker"
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2183 windowingCenter_ = message.GetWindowingCenter();
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2184 windowingWidth_ = message.GetWindowingWidth();
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2185
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2186 if (observer_.get() != NULL)
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2187 {
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2188 observer_->SignalWindowingUpdated(*this, message.GetWindowingCenter(), message.GetWindowingWidth());
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2189 }
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2190 }
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2191
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2192
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2193 static EM_BOOL OnWheel(int eventType,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2194 const EmscriptenWheelEvent *wheelEvent,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2195 void *userData)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2196 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2197 ViewerViewport& that = *reinterpret_cast<ViewerViewport*>(userData);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2198
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2199 if (that.frames_.get() != NULL &&
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2200 that.cursor_.get() != NULL)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2201 {
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2202 const bool isCtrl = wheelEvent->mouse.ctrlKey;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2203 const bool isShift = wheelEvent->mouse.shiftKey;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2204
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2205 const size_t previousCursorIndex = that.cursor_->GetCurrentIndex();
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2206
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2207 if (wheelEvent->deltaY < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2208 {
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2209 that.ChangeFrame(isCtrl ? SeriesCursor::Action_FastMinus :
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2210 SeriesCursor::Action_Minus, false /* not circular */);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2211 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2212 else if (wheelEvent->deltaY > 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2213 {
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2214 that.ChangeFrame(isCtrl ? SeriesCursor::Action_FastPlus :
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2215 SeriesCursor::Action_Plus, false /* not circular */);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2216 }
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2217
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2218 if (that.synchronizationEnabled_)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2219 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2220 const size_t currentCursorIndex = that.cursor_->GetCurrentIndex();
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2221
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2222 const OrthancStone::CoordinateSystem3D current =
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2223 that.frames_->GetFrameGeometry(currentCursorIndex);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2224
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2225 if (isShift &&
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2226 previousCursorIndex != currentCursorIndex)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2227 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2228 const OrthancStone::CoordinateSystem3D previous =
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2229 that.frames_->GetFrameGeometry(previousCursorIndex);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2230 that.synchronizationOffset_ += previous.GetOrigin() - current.GetOrigin();
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2231 }
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2232
1694
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2233 that.observer_->SignalSynchronizedBrowsing(
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
2234 that, current.GetOrigin() + that.synchronizationOffset_, current.GetNormal());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2235 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2236 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2237
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2238 return true;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2239 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2240
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2241 void Handle(const OrthancStone::DicomResourcesLoader::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2242 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2243 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
2244 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2245
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2246 void Handle(const OrthancStone::HttpCommand::SuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2247 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2248 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
2249 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2250
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2251 void Handle(const OrthancStone::ParseDicomSuccessMessage& message)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2252 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2253 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
2254 }
1600
b253b79906fa clarifying variable names: frameIndex vs numberIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
2255
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2256
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2257 void RefreshAnnotations(bool save)
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2258 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2259 {
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2260 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2261 stoneAnnotations_->Render(lock->GetController().GetScene());
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2262 lock->Invalidate();
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2263 }
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2264
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2265 if (save)
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2266 {
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2267 if (cursor_.get() != NULL &&
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2268 frames_.get() != NULL)
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2269 {
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2270 const size_t cursorIndex = cursor_->GetCurrentIndex();
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2271 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2272 const size_t frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2273
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2274 StoneAnnotationsRegistry::GetInstance().Save(instance.GetSopInstanceUid(), frameNumber, *stoneAnnotations_);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2275
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2276 if (observer_.get() != NULL)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2277 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2278 observer_->SignalStoneAnnotationsChanged(*this, instance.GetSopInstanceUid(), frameNumber);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2279 }
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2280 }
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2281 }
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2282 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2283
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2284 void Handle(const OrthancStone::ViewportController::SceneTransformChanged& message)
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2285 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2286 RefreshAnnotations(false /* don't save */);
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2287 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2288
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2289 void Handle(const OrthancStone::AnnotationsSceneLayer::AnnotationChangedMessage& message)
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2290 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2291 RefreshAnnotations(true /* save */);
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2292 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2293
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2294 void Handle(const OrthancStone::AnnotationsSceneLayer::AnnotationAddedMessage& message)
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2295 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2296 RefreshAnnotations(true /* save */);
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2297
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2298 if (observer_.get() != NULL)
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2299 {
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2300 observer_->SignalStoneAnnotationAdded(*this);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2301 }
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2302 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2303
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2304 void Handle(const OrthancStone::AnnotationsSceneLayer::AnnotationRemovedMessage& message)
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2305 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2306 RefreshAnnotations(true /* save */);
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2307
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2308 if (observer_.get() != NULL)
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2309 {
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2310 observer_->SignalStoneAnnotationRemoved(*this);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2311 }
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2312 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2313
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2314 public:
1622
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2315 virtual ~ViewerViewport()
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2316 {
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2317 // 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
2318 // 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
2319 // 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
2320 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
2321 }
0f8d6791b403 fix build by making the destructor of ViewerViewport public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1620
diff changeset
2322
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
2323 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
2324 const OrthancStone::DicomSource& source,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2325 const std::string& canvas,
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2326 boost::shared_ptr<FramesCache> cache,
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
2327 bool softwareRendering)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2328 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2329 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
2330 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
2331
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
2332 {
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
2333 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
2334
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
2335 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
2336 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
2337 *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
2338
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
2339 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
2340 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
2341
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
2342 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
2343 lock->GetOracleObservable(), &ViewerViewport::Handle);
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2344
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2345 viewport->Register<OrthancStone::AnnotationsSceneLayer::AnnotationChangedMessage>(
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2346 *viewport->stoneAnnotations_, &ViewerViewport::Handle);
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2347
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2348 viewport->Register<OrthancStone::AnnotationsSceneLayer::AnnotationAddedMessage>(
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2349 *viewport->stoneAnnotations_, &ViewerViewport::Handle);
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2350
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2351 viewport->Register<OrthancStone::AnnotationsSceneLayer::AnnotationRemovedMessage>(
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2352 *viewport->stoneAnnotations_, &ViewerViewport::Handle);
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
2353 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2354
1721
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2355 {
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2356 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport->viewport_->Lock());
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2357 viewport->Register<OrthancStone::ViewportController::GrayscaleWindowingChanged>(lock->GetController(), &ViewerViewport::Handle);
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2358 viewport->Register<OrthancStone::ViewportController::SceneTransformChanged>(lock->GetController(), &ViewerViewport::Handle);
1721
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2359 }
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1720
diff changeset
2360
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2361 return viewport;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2362 }
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 void SetFrames(OrthancStone::SortedFrames* frames)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2365 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2366 if (frames == NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2367 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2368 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
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
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2371 flipX_ = false;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2372 flipY_ = false;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2373 fitNextContent_ = true;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2374 cineRate_ = DEFAULT_CINE_RATE;
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2375 inverted_ = false;
1682
84fe7089ccaa switch to server-side transcoding on failed decoding (for jpeg2k)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
2376 serverSideTranscoding_ = false;
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2377 OrthancStone::LinearAlgebra::AssignVector(synchronizationOffset_, 0, 0, 0);
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2378
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2379 frames_.reset(frames);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2380 cursor_.reset(new SeriesCursor(frames_->GetFramesCount()));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2381
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2382 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
2383
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2384 SetWindowingPreset();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2385 ClearViewport();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2386 prefetchQueue_.clear();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2387
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2388 if (observer_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2389 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2390 observer_->SignalFrameUpdated(*this, cursor_->GetCurrentIndex(),
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2391 frames_->GetFramesCount(), DisplayedFrameQuality_None, 0);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2392 }
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
2393
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2394 centralPhysicalWidth_ = 1;
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2395 centralPhysicalHeight_ = 1;
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2396
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2397 if (frames_->GetFramesCount() != 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2398 {
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
2399 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
2400
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
2401 /**
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
2402 * 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
2403 * "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
2404 * 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
2405 * 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
2406 **/
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
2407 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
2408 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
2409 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
2410 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
2411 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
2412 GetSeriesThumbnailType(uid) != OrthancStone::SeriesThumbnailType_Video)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2413 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2414 // 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
2415 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() +
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2416 "/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
2417 "/instances/" + centralInstance.GetSopInstanceUid() + "/metadata");
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2418
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2419 loader_->ScheduleGetDicomWeb(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2420 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
2421 0, source_, uri, new LoadSeriesDetailsFromInstance(GetSharedObserver()));
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2422 }
1695
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2423
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2424 if (centralInstance.GetPixelSpacingX() != 0 &&
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2425 centralInstance.GetPixelSpacingY() != 0 &&
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2426 centralInstance.GetWidth() != 0 &&
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2427 centralInstance.GetHeight())
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2428 {
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2429 centralPhysicalWidth_ = (centralInstance.GetPixelSpacingX() *
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2430 static_cast<double>(centralInstance.GetWidth()));
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2431 centralPhysicalHeight_ = (centralInstance.GetPixelSpacingY() *
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2432 static_cast<double>(centralInstance.GetHeight()));
a691ab50d416 support of series with instances of varying resolutions - LSD-479
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
2433 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2434 }
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2435
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2436 ApplyScheduledFocus();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2437 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2438
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2439
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2440 // 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
2441 // 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
2442 void UpdateSize(bool fitContent)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2443 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2444 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
2445 lock->RefreshCanvasSize();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2446
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2447 if (fitContent)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2448 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2449 lock->GetCompositor().FitContent(lock->GetController().GetScene());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2450 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2451
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2452 stoneAnnotations_->ClearHover();
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2453 stoneAnnotations_->Render(lock->GetController().GetScene());
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2454
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2455 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2456 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2457
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2458 void AcquireObserver(IObserver* observer)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2459 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2460 observer_.reset(observer);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2461 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2462
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2463 const std::string& GetCanvasId() const
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2464 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2465 assert(viewport_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2466 return viewport_->GetCanvasId();
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
1669
d82a141e08d7 make the viewer work even if missing cache space
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2469
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2470 void Redraw()
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2471 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2472 if (cursor_.get() != NULL &&
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2473 frames_.get() != NULL)
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2474 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2475 const size_t cursorIndex = cursor_->GetCurrentIndex();
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2476
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2477 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2478 const size_t frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2479
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
2480 FramesCache::Accessor accessor(*framesCache_, instance.GetSopInstanceUid(), frameNumber);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2481 if (accessor.IsValid())
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2482 {
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2483 RenderCurrentScene(accessor.GetImage(), instance, frameNumber, frames_->GetFrameGeometry(cursorIndex));
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2484
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2485 DisplayedFrameQuality quality;
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2486
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2487 if (accessor.GetQuality() < QUALITY_FULL)
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2488 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2489 // 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
2490 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2491 quality = DisplayedFrameQuality_Low;
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2492 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2493 else
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2494 {
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2495 quality = DisplayedFrameQuality_High;
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2496 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2497
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
2498 SetupPrefetchAfterRendering(accessor.GetImage(), quality);
1671
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2499 }
2c2512918a0f fix in prefetching
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
2500 else
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2501 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2502 // This frame is not cached yet: Load it
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2503 if (source_.HasDicomWebRendered())
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2504 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2505 ScheduleLoadRenderedFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2506 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2507 else
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2508 {
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2509 ScheduleLoadFullDicomFrame(cursorIndex, PRIORITY_HIGH, false /* not a prefetch */);
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2510 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2511 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2512 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2513 }
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2514
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2515
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2516 // Returns "true" iff the frame has indeed changed
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2517 bool ChangeFrame(SeriesCursor::Action action,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2518 bool isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2519 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2520 if (cursor_.get() != NULL)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2521 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2522 size_t previous = cursor_->GetCurrentIndex();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2523
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2524 cursor_->Apply(action, isCircular);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2525
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2526 size_t current = cursor_->GetCurrentIndex();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2527 if (previous != current)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2528 {
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2529 Redraw();
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2530 return true;
1495
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 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2533
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2534 return false;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2535 }
1719
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2536
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2537
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2538 void GoToFirstFrame()
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2539 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2540 if (cursor_.get() != NULL &&
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2541 cursor_->GetCurrentIndex() != 0)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2542 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2543 cursor_->SetCurrentIndex(0);
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2544 Redraw();
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2545 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2546 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2547
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2548
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2549 void GoToLastFrame()
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2550 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2551 if (cursor_.get() != NULL)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2552 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2553 size_t last = cursor_->GetFramesCount() - 1;
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2554 if (cursor_->GetCurrentIndex() != last)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2555 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2556 cursor_->SetCurrentIndex(last);
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2557 Redraw();
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2558 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2559 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
2560 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2561
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2562
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2563 bool GetCurrentFrameOfReferenceUid(std::string& frameOfReferenceUid) const
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2564 {
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2565 if (cursor_.get() != NULL &&
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2566 frames_.get() != NULL)
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2567 {
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2568 frameOfReferenceUid = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()).GetFrameOfReferenceUid();
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2569 return true;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2570 }
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2571 else
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2572 {
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2573 return false;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2574 }
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2575 }
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2576
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2577 bool GetCurrentPlane(OrthancStone::CoordinateSystem3D& plane) const
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2578 {
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2579 if (cursor_.get() != NULL &&
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2580 frames_.get() != NULL)
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2581 {
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2582 plane = frames_->GetFrameGeometry(cursor_->GetCurrentIndex());
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2583 return true;
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2584 }
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2585 else
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2586 {
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2587 return false;
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2588 }
1495
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
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2591 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
2592 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2593 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
2594
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2595 if (cursor_.get() != NULL &&
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2596 frames_.get() != NULL)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2597 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2598 const size_t cursorIndex = cursor_->GetCurrentIndex();
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2599 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2600 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
2601
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2602 for (std::list<const ViewerViewport*>::const_iterator
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2603 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
2604 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2605 assert(*it != NULL);
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2606
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2607 OrthancStone::CoordinateSystem3D otherPlane;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2608 std::string otherFrameOfReferenceUid;
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2609 if ((*it)->GetCurrentPlane(otherPlane) &&
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2610 (*it)->GetCurrentFrameOfReferenceUid(otherFrameOfReferenceUid) &&
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2611 otherFrameOfReferenceUid == instance.GetFrameOfReferenceUid())
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2612 {
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2613 double x1, y1, x2, y2;
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2614 if (GetReferenceLineCoordinates(x1, y1, x2, y2, instance, frame, otherPlane))
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2615 {
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2616 OrthancStone::PolylineSceneLayer::Chain chain;
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2617 chain.push_back(OrthancStone::ScenePoint2D(x1, y1));
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2618 chain.push_back(OrthancStone::ScenePoint2D(x2, y2));
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2619 layer->AddChain(chain, false, 0, 255, 0);
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2620 }
1495
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 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2623 }
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2624
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2625 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2626 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
2627
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2628 if (layer->GetChainsCount() == 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2629 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2630 lock->GetController().GetScene().DeleteLayer(LAYER_REFERENCE_LINES);
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 else
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 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
2635 }
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 //lock->GetCompositor().Refresh(lock->GetController().GetScene());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2638 lock->Invalidate();
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2642
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2643 void ClearReferenceLines()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2644 {
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 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
2647 lock->GetController().GetScene().DeleteLayer(LAYER_REFERENCE_LINES);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2648 lock->Invalidate();
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
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2652
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2653 void SetWindowingPreset()
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2654 {
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2655 assert(windowingPresetCenters_.size() == windowingPresetWidths_.size());
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2656
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2657 if (windowingPresetCenters_.empty())
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2658 {
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2659 SetWindowing(128, 256);
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2660 }
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2661 else
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2662 {
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2663 SetWindowing(windowingPresetCenters_[0], windowingPresetWidths_[0]);
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2664 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2665 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2666
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2667 void SetWindowing(float windowingCenter,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2668 float windowingWidth)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2669 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2670 windowingCenter_ = windowingCenter;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2671 windowingWidth_ = windowingWidth;
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2672 UpdateCurrentTextureParameters();
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2673
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2674 if (observer_.get() != NULL)
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2675 {
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2676 observer_->SignalWindowingUpdated(*this, windowingCenter, windowingWidth);
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
2677 }
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2678 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2679
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2680 void FlipX()
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2681 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2682 flipX_ = !flipX_;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2683 UpdateCurrentTextureParameters();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2684 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2685
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2686 void FlipY()
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2687 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2688 flipY_ = !flipY_;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
2689 UpdateCurrentTextureParameters();
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2690 }
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 void Invert()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2693 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2694 inverted_ = !inverted_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2695
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2696 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2697 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
2698
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2699 if (lock->GetController().GetScene().HasLayer(LAYER_TEXTURE) &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2700 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE).GetType() ==
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2701 OrthancStone::ISceneLayer::Type_FloatTexture)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2702 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2703 OrthancStone::FloatTextureSceneLayer& layer =
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2704 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2705 lock->GetController().GetScene().GetLayer(LAYER_TEXTURE));
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2706
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2707 // 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
2708 // compatibility with MONOCHROME1 images
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2709 layer.SetInverted(!layer.IsInverted());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2710 lock->Invalidate();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2711 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2712 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2713 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2714
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2715
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2716
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2717 class Interactor : public OrthancStone::DefaultViewportInteractor
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2718 {
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2719 private:
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2720 ViewerViewport& viewer_;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2721 WebViewerAction leftAction_;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2722 WebViewerAction middleAction_;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2723 WebViewerAction rightAction_;
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2724
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2725 bool IsAction(const OrthancStone::PointerEvent& event,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2726 WebViewerAction action)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2727 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2728 switch (event.GetMouseButton())
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2729 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2730 case OrthancStone::MouseButton_Left:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2731 return (leftAction_ == action);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2732
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2733 case OrthancStone::MouseButton_Middle:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2734 return (middleAction_ == action);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2735
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2736 case OrthancStone::MouseButton_Right:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2737 return (rightAction_ == action);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2738
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2739 default:
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2740 return false;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2741 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2742 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2743
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2744 public:
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2745 Interactor(ViewerViewport& viewer,
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2746 WebViewerAction leftAction,
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2747 WebViewerAction middleAction,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2748 WebViewerAction rightAction) :
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2749 viewer_(viewer),
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2750 leftAction_(leftAction),
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2751 middleAction_(middleAction),
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2752 rightAction_(rightAction)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2753 {
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2754 SetLeftButtonAction(ConvertWebViewerAction(leftAction));
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2755 SetMiddleButtonAction(ConvertWebViewerAction(middleAction));
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2756 SetRightButtonAction(ConvertWebViewerAction(rightAction));
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2757 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2758
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2759 virtual OrthancStone::IFlexiblePointerTracker* CreateTracker(
1607
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2760 boost::weak_ptr<OrthancStone::IViewport> viewport,
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2761 const OrthancStone::PointerEvent& event,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2762 unsigned int viewportWidth,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2763 unsigned int viewportHeight) ORTHANC_OVERRIDE
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2764 {
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2765 boost::shared_ptr<OrthancStone::IViewport> lock1(viewport.lock());
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2766
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2767 if (lock1 &&
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2768 IsAction(event, WebViewerAction_Crosshair))
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2769 {
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2770 OrthancStone::CoordinateSystem3D plane;
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2771 if (viewer_.GetCurrentPlane(plane))
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2772 {
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2773 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
2774
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2775 const OrthancStone::ScenePoint2D p = event.GetMainPosition();
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2776 double x = p.GetX();
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2777 double y = p.GetY();
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2778 lock2->GetController().GetCanvasToSceneTransform().Apply(x, y);
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2779
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2780 OrthancStone::Vector click = plane.MapSliceToWorldCoordinates(x, y);
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2781 if (viewer_.observer_.get() != NULL)
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2782 {
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2783 viewer_.observer_->SignalCrosshair(viewer_, click);
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2784 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2785 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2786
1580
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1579
diff changeset
2787 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
2788 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2789 else
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2790 {
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2791 // Only the left mouse button can be used to edit/create/remove annotations
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2792 if (event.GetMouseButton() == OrthancStone::MouseButton_Left)
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2793 {
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2794 switch (leftAction_)
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2795 {
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2796 case WebViewerAction_CreateAngle:
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2797 viewer_.stoneAnnotations_->SetActiveTool(OrthancStone::AnnotationsSceneLayer::Tool_Angle);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2798 break;
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2799
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2800 case WebViewerAction_CreateCircle:
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2801 viewer_.stoneAnnotations_->SetActiveTool(OrthancStone::AnnotationsSceneLayer::Tool_Circle);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2802 break;
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2803
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2804 case WebViewerAction_CreateSegment:
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2805 viewer_.stoneAnnotations_->SetActiveTool(OrthancStone::AnnotationsSceneLayer::Tool_Segment);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2806 break;
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2807
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2808 case WebViewerAction_RemoveMeasure:
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2809 viewer_.stoneAnnotations_->SetActiveTool(OrthancStone::AnnotationsSceneLayer::Tool_Remove);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2810 break;
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2811
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2812 default:
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2813 viewer_.stoneAnnotations_->SetActiveTool(OrthancStone::AnnotationsSceneLayer::Tool_Edit);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2814 break;
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2815 }
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2816
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2817 {
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2818 std::unique_ptr<OrthancStone::IViewport::ILock> lock2(lock1->Lock());
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2819
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2820 std::unique_ptr<OrthancStone::IFlexiblePointerTracker> t;
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2821 t.reset(viewer_.stoneAnnotations_->CreateTracker(event.GetMainPosition(), lock2->GetController().GetScene()));
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2822
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2823 if (t.get() != NULL)
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2824 {
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2825 return t.release();
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
2826 }
1809
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2827 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2828 }
79a5838739a6 starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1795
diff changeset
2829
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2830 return DefaultViewportInteractor::CreateTracker(
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2831 viewport, event, viewportWidth, viewportHeight);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2832 }
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2833 }
1811
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2834
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2835 virtual bool HasMouseHover() const ORTHANC_OVERRIDE
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2836 {
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2837 return true;
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2838 }
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2839
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2840 virtual void HandleMouseHover(OrthancStone::IViewport& viewport,
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2841 const OrthancStone::PointerEvent& event) ORTHANC_OVERRIDE
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2842 {
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2843 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport.Lock());
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2844
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2845 if (viewer_.stoneAnnotations_->SetMouseHover(event.GetMainPosition(), lock->GetController().GetScene()))
1811
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2846 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2847 viewer_.stoneAnnotations_->Render(lock->GetController().GetScene());
1811
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2848 lock->Invalidate();
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2849 }
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2850 }
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2851 };
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2852
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2853
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2854 void SetMouseButtonActions(WebViewerAction leftAction,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2855 WebViewerAction middleAction,
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2856 WebViewerAction rightAction)
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2857 {
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2858 assert(viewport_ != NULL);
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2859 viewport_->AcquireInteractor(new Interactor(*this, leftAction, middleAction, rightAction));
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
2860 }
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2861
1578
1f812f4c95be comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1576
diff changeset
2862 void FitForPrint()
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2863 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2864 viewport_->FitForPrint();
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
2865 }
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2866
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2867 void SetOsiriXAnnotations(boost::shared_ptr<OrthancStone::OsiriX::CollectionOfAnnotations> annotations)
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2868 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2869 osiriXAnnotations_ = annotations;
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2870 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
2871
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2872 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
2873 unsigned int frameNumber)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2874 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2875 hasFocusOnInstance_ = true;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2876 focusSopInstanceUid_ = sopInstanceUid;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2877 focusFrameNumber_ = frameNumber;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2878
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2879 ApplyScheduledFocus();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2880 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2881
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2882 void ApplyScheduledFocus()
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2883 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2884 size_t cursorIndex;
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2885
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2886 if (hasFocusOnInstance_ &&
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2887 cursor_.get() != NULL &&
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2888 frames_.get() != NULL &&
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2889 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
2890 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2891 size_t current = cursor_->GetCurrentIndex();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2892
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2893 if (current != cursorIndex)
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2894 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2895 cursor_->SetCurrentIndex(cursorIndex);
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2896 Redraw();
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2897 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2898
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2899 hasFocusOnInstance_ = false;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2900 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2901 }
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2902
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2903 void FocusOnPoint(const OrthancStone::Vector& p)
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2904 {
1649
d77618883551 verification of FrameOfReferenceUID in reference lines
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1648
diff changeset
2905 //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
2906 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
2907
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2908 size_t cursorIndex;
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2909 if (cursor_.get() != NULL &&
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2910 frames_.get() != NULL &&
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2911 frames_->FindClosestFrame(cursorIndex, p, MAX_DISTANCE))
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2912 {
1667
9584df157a9e clarifying variable names
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1666
diff changeset
2913 cursor_->SetCurrentIndex(cursorIndex);
1668
ab1bc8de1798 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1667
diff changeset
2914 Redraw();
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2915 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
2916 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2917
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2918 unsigned int GetCineRate() const
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2919 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2920 return cineRate_;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
2921 }
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2922
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2923 void FormatWindowingPresets(Json::Value& target) const
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2924 {
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2925 assert(windowingPresetCenters_.size() == windowingPresetWidths_.size());
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2926
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2927 target = Json::arrayValue;
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2928
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2929 for (size_t i = 0; i < windowingPresetCenters_.size(); i++)
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2930 {
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2931 const float c = windowingPresetCenters_[i];
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2932 const float w = windowingPresetWidths_[i];
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2933
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2934 std::string name = "Preset";
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2935 if (windowingPresetCenters_.size() > 1)
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2936 {
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2937 name += " " + boost::lexical_cast<std::string>(i + 1);
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2938 }
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2939
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2940 Json::Value preset = Json::objectValue;
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2941 preset["name"] = name;
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2942 preset["center"] = c;
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2943 preset["width"] = w;
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2944 preset["info"] =
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2945 ("C " + boost::lexical_cast<std::string>(static_cast<int>(boost::math::iround<double>(c))) +
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2946 ", W " + boost::lexical_cast<std::string>(static_cast<int>(boost::math::iround<double>(w))));
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2947
1681
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2948 target.append(preset);
f2e8b3ac1dcd handling multiple windowing presets in the Stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
2949 }
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
2950 }
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2951
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2952
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2953 void SetSynchronizedBrowsingEnabled(int enabled)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2954 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2955 OrthancStone::LinearAlgebra::AssignVector(synchronizationOffset_, 0, 0, 0);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2956 synchronizationEnabled_ = enabled;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
2957 }
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2958
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2959
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2960 void SignalStoneAnnotationsChanged(const std::string& sopInstanceUid,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2961 size_t frame)
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2962 {
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2963 if (cursor_.get() != NULL &&
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2964 frames_.get() != NULL)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2965 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2966 const size_t cursorIndex = cursor_->GetCurrentIndex();
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2967 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(cursorIndex);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2968 const size_t frameNumber = frames_->GetFrameNumberInInstance(cursorIndex);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2969
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2970 if (instance.GetSopInstanceUid() == sopInstanceUid &&
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2971 frameNumber == frame)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2972 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2973 StoneAnnotationsRegistry::GetInstance().Load(*stoneAnnotations_, instance.GetSopInstanceUid(), frame);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2974
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2975 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2976 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2977 stoneAnnotations_->Render(lock->GetController().GetScene());
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2978 lock->Invalidate();
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2979 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2980 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
2981 }
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2982 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2983 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2984
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2985
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2986
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2987
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2988
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2989 typedef std::map<std::string, boost::shared_ptr<ViewerViewport> > Viewports;
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2990
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2991 static Viewports allViewports_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2992 static bool showReferenceLines_ = true;
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
2993 static boost::shared_ptr<OrthancStone::OsiriX::CollectionOfAnnotations> osiriXAnnotations_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2994
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2995
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2996 static void UpdateReferenceLines()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2997 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2998 if (showReferenceLines_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2999 {
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
3000 std::list<const ViewerViewport*> viewports;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3001
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3002 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
3003 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3004 assert(it->second != NULL);
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
3005 viewports.push_back(it->second.get());
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3006 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3007
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3008 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
3009 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3010 assert(it->second != NULL);
1647
adff3cd78775 removed class FrameExtent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
3011 it->second->UpdateReferenceLines(viewports);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3012 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3013 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3014 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3015 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3016 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
3017 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3018 assert(it->second != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3019 it->second->ClearReferenceLines();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3020 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3021 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3022 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3023
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3024
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3025 class WebAssemblyObserver : public ResourcesLoader::IObserver,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3026 public ViewerViewport::IObserver
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3027 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3028 public:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3029 virtual void SignalResourcesLoaded() ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3030 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3031 DISPATCH_JAVASCRIPT_EVENT("ResourcesLoaded");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3032 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3033
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3034 virtual void SignalSeriesThumbnailLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3035 const std::string& seriesInstanceUid) ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3036 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3037 EM_ASM({
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3038 const customEvent = document.createEvent("CustomEvent");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3039 customEvent.initCustomEvent("ThumbnailLoaded", false, false,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3040 { "studyInstanceUid" : UTF8ToString($0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3041 "seriesInstanceUid" : UTF8ToString($1) });
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3042 window.dispatchEvent(customEvent);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3043 },
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3044 studyInstanceUid.c_str(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3045 seriesInstanceUid.c_str());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3046 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3047
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3048 virtual void SignalSeriesMetadataLoaded(const std::string& studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3049 const std::string& seriesInstanceUid) ORTHANC_OVERRIDE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3050 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3051 EM_ASM({
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3052 const customEvent = document.createEvent("CustomEvent");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3053 customEvent.initCustomEvent("MetadataLoaded", false, false,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3054 { "studyInstanceUid" : UTF8ToString($0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3055 "seriesInstanceUid" : UTF8ToString($1) });
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3056 window.dispatchEvent(customEvent);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3057 },
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3058 studyInstanceUid.c_str(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3059 seriesInstanceUid.c_str());
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3060
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3061 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
3062 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3063 assert(it->second != NULL);
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3064 it->second->ApplyScheduledFocus();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3065 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3066 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3067
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3068 virtual void SignalSeriesDetailsReady(const ViewerViewport& viewport) ORTHANC_OVERRIDE
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3069 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3070 EM_ASM({
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3071 const customEvent = document.createEvent("CustomEvent");
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3072 customEvent.initCustomEvent("SeriesDetailsReady", false, false,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3073 { "canvasId" : UTF8ToString($0) });
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3074 window.dispatchEvent(customEvent);
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3075 },
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3076 viewport.GetCanvasId().c_str()
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3077 );
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3078 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3079
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3080 virtual void SignalFrameUpdated(const ViewerViewport& viewport,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3081 size_t currentFrame,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3082 size_t countFrames,
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3083 DisplayedFrameQuality quality,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3084 unsigned int instanceNumber) ORTHANC_OVERRIDE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3085 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3086 EM_ASM({
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3087 const customEvent = document.createEvent("CustomEvent");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3088 customEvent.initCustomEvent("FrameUpdated", false, false,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3089 { "canvasId" : UTF8ToString($0),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3090 "currentFrame" : $1,
1674
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3091 "numberOfFrames" : $2,
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3092 "quality" : $3,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3093 "instanceNumber" : $4 });
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3094 window.dispatchEvent(customEvent);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3095 },
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3096 viewport.GetCanvasId().c_str(),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3097 static_cast<int>(currentFrame),
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3098 static_cast<int>(countFrames),
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3099 quality, instanceNumber);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3100
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3101 UpdateReferenceLines();
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
3102 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
3103
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3104 virtual void SignalCrosshair(const ViewerViewport& viewport,
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3105 const OrthancStone::Vector& click) ORTHANC_OVERRIDE
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
3106 {
1811
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
3107 if (click.size() != 3u)
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
3108 {
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
3109 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
3110 }
fdc6a8089eb9 hovering of annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
3111
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
3112 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
3113 {
1694
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3114 // TODO - One could check the "Frame Of Reference UID" here
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3115 assert(it->second.get() != NULL);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3116 if (it->second.get() != &viewport)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3117 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3118 it->second->FocusOnPoint(click);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3119 }
1648
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
3120 }
4a43106bc122 cross-hair starts to work
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1647
diff changeset
3121 }
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3122
1694
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3123 virtual void SignalSynchronizedBrowsing(const ViewerViewport& viewport,
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3124 const OrthancStone::Vector& click,
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3125 const OrthancStone::Vector& normal) ORTHANC_OVERRIDE
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3126 {
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3127 for (Viewports::const_iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3128 {
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3129 assert(it->second.get() != NULL);
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3130
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3131 OrthancStone::CoordinateSystem3D plane;
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3132 bool isOpposite;
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3133
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3134 if (it->second.get() != &viewport &&
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3135 it->second->GetCurrentPlane(plane) &&
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3136 OrthancStone::GeometryToolbox::IsParallelOrOpposite(isOpposite, plane.GetNormal(), normal))
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3137 {
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3138 it->second->FocusOnPoint(click);
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3139 }
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3140 }
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3141 }
7226b68e2742 print button
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
3142
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3143 virtual void SignalSeriesPdfLoaded(const std::string& studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3144 const std::string& seriesInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3145 const std::string& pdf) ORTHANC_OVERRIDE
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3146 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3147 EM_ASM({
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3148 const customEvent = document.createEvent("CustomEvent");
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3149 customEvent.initCustomEvent("PdfLoaded", false, false,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3150 { "studyInstanceUid" : UTF8ToString($0),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3151 "seriesInstanceUid" : UTF8ToString($1),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3152 "pdfPointer" : $2,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3153 "pdfSize": $3});
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3154 window.dispatchEvent(customEvent);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3155 },
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3156 studyInstanceUid.c_str(),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3157 seriesInstanceUid.c_str(),
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3158 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
3159 pdf.size());
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3160 }
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3161
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3162
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3163 virtual void SignalMultiframeInstanceThumbnailLoaded(const std::string& sopInstanceUid,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3164 const std::string& jpeg) ORTHANC_OVERRIDE
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3165 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3166 std::string dataUriScheme;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3167 Orthanc::Toolbox::EncodeDataUriScheme(dataUriScheme, "image/jpeg", jpeg);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3168
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3169 EM_ASM({
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3170 const customEvent = document.createEvent("CustomEvent");
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3171 customEvent.initCustomEvent("MultiframeInstanceThumbnailLoaded", false, false,
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3172 { "sopInstanceUid" : UTF8ToString($0),
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3173 "thumbnail" : UTF8ToString($1) });
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3174 window.dispatchEvent(customEvent);
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3175 },
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3176 sopInstanceUid.c_str(),
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3177 dataUriScheme.c_str());
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3178 }
1720
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3179
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3180 virtual void SignalWindowingUpdated(const ViewerViewport& viewport,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3181 double windowingCenter,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3182 double windowingWidth) ORTHANC_OVERRIDE
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3183 {
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3184 EM_ASM({
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3185 const customEvent = document.createEvent("CustomEvent");
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3186 customEvent.initCustomEvent("WindowingUpdated", false, false,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3187 { "canvasId" : UTF8ToString($0),
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3188 "windowingCenter" : $1,
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3189 "windowingWidth" : $2 });
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3190 window.dispatchEvent(customEvent);
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3191 },
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3192 viewport.GetCanvasId().c_str(),
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3193 static_cast<int>(boost::math::iround<double>(windowingCenter)),
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3194 static_cast<int>(boost::math::iround<double>(windowingWidth)));
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3195
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3196 UpdateReferenceLines();
b8d19f53aaca display the instance number, and the wc/ww info (work-in-progress)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1719
diff changeset
3197 }
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3198
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3199 virtual void SignalStoneAnnotationsChanged(const ViewerViewport& viewport,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3200 const std::string& sopInstanceUid,
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3201 size_t frame) ORTHANC_OVERRIDE
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3202 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3203 for (Viewports::const_iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3204 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3205 assert(it->second.get() != NULL);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3206
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3207 if (it->second.get() != &viewport)
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3208 {
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3209 it->second->SignalStoneAnnotationsChanged(sopInstanceUid, frame);
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3210 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3211 }
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3212 }
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3213
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3214 virtual void SignalStoneAnnotationAdded(const ViewerViewport& viewport) ORTHANC_OVERRIDE
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3215 {
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3216 EM_ASM({
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3217 const customEvent = document.createEvent("CustomEvent");
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3218 customEvent.initCustomEvent("StoneAnnotationAdded", false, false,
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3219 { "canvasId" : UTF8ToString($0) });
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3220 window.dispatchEvent(customEvent);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3221 },
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3222 viewport.GetCanvasId().c_str());
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3223 }
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3224
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3225 virtual void SignalStoneAnnotationRemoved(const ViewerViewport& viewport) ORTHANC_OVERRIDE
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3226 {
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3227 EM_ASM({
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3228 const customEvent = document.createEvent("CustomEvent");
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3229 customEvent.initCustomEvent("StoneAnnotationRemoved", false, false,
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3230 { "canvasId" : UTF8ToString($0) });
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3231 window.dispatchEvent(customEvent);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3232 },
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3233 viewport.GetCanvasId().c_str());
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3234 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3235 };
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3236
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3237
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3238
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3239 static OrthancStone::DicomSource source_;
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
3240 static boost::shared_ptr<FramesCache> framesCache_;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3241 static boost::shared_ptr<OrthancStone::WebAssemblyLoadersContext> context_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3242 static std::string stringBuffer_;
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3243 static bool softwareRendering_ = false;
1701
b5a8bf32d969 new configuration options: "CombinedToolEnabled", "CombinedToolBehaviour" and "DownloadAsJpegEnabled"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
3244 static WebViewerAction leftButtonAction_ = WebViewerAction_Windowing;
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
3245 static WebViewerAction middleButtonAction_ = WebViewerAction_Pan;
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
3246 static WebViewerAction rightButtonAction_ = WebViewerAction_Zoom;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3247
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3248
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3249 static void FormatTags(std::string& target,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3250 const Orthanc::DicomMap& tags)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3251 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3252 Orthanc::DicomArray arr(tags);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3253 Json::Value v = Json::objectValue;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3254
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3255 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
3256 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3257 const Orthanc::DicomElement& element = arr.GetElement(i);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3258 if (!element.GetValue().IsBinary() &&
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3259 !element.GetValue().IsNull())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3260 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3261 v[element.GetTag().Format()] = element.GetValue().GetContent();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3262 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3263 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3264
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3265 target = v.toStyledString();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3266 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3267
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3268
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3269 static ResourcesLoader& GetResourcesLoader()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3270 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3271 static boost::shared_ptr<ResourcesLoader> resourcesLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3272
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3273 if (!resourcesLoader_)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3274 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3275 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
3276 resourcesLoader_ = ResourcesLoader::Create(*lock, source_);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3277 resourcesLoader_->AcquireObserver(new WebAssemblyObserver);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3278 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3279
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3280 return *resourcesLoader_;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3281 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3282
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3283
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3284 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
3285 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3286 Viewports::iterator found = allViewports_.find(canvas);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3287 if (found == allViewports_.end())
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3288 {
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3289 boost::shared_ptr<ViewerViewport> viewport(
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
3290 ViewerViewport::Create(*context_, source_, canvas, framesCache_, softwareRendering_));
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3291 viewport->SetMouseButtonActions(leftButtonAction_, middleButtonAction_, rightButtonAction_);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3292 viewport->AcquireObserver(new WebAssemblyObserver);
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3293 viewport->SetOsiriXAnnotations(osiriXAnnotations_);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3294 allViewports_[canvas] = viewport;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3295 return viewport;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3296 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3297 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3298 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3299 return found->second;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3300 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3301 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3302
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3303
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3304 extern "C"
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3305 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3306 int main(int argc, char const *argv[])
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3307 {
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
3308 printf("Initializing Stone\n");
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3309 Orthanc::InitializeFramework("", true);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3310 Orthanc::Logging::EnableInfoLevel(true);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3311 //Orthanc::Logging::EnableTraceLevel(true);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3312
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3313 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
3314 context_->SetDicomCacheSize(128 * 1024 * 1024); // 128MB
fc883105ee11 enable cache of ParsedDicomFile in oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
3315
1676
5e76d5e8167a limit the amount of frames to be prefetched
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1675
diff changeset
3316 framesCache_.reset(new FramesCache);
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3317 osiriXAnnotations_.reset(new OrthancStone::OsiriX::CollectionOfAnnotations);
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3318
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3319 {
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3320 // TODO - TEST
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3321 OrthancStone::AnnotationsSceneLayer l(0);
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3322 l.AddSegmentAnnotation(OrthancStone::ScenePoint2D(0, 0),
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3323 OrthancStone::ScenePoint2D(100, 100));
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3324 l.AddAngleAnnotation(OrthancStone::ScenePoint2D(100, 50),
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3325 OrthancStone::ScenePoint2D(150, 40),
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3326 OrthancStone::ScenePoint2D(200, 50));
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3327 l.AddCircleAnnotation(OrthancStone::ScenePoint2D(50, 200),
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3328 OrthancStone::ScenePoint2D(100, 250));
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3329 l.SetActiveTool(OrthancStone::AnnotationsSceneLayer::Tool_Edit);
1813
53aa3f72b539 synchronization of annotations across viewports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1812
diff changeset
3330 StoneAnnotationsRegistry::GetInstance().Save("1.2.840.113543.6.6.4.7.64234348190163144631511103849051737563212", 0, l);
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3331 }
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3332
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3333
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3334 DISPATCH_JAVASCRIPT_EVENT("StoneInitialized");
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3335 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3336
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3337
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3338 EMSCRIPTEN_KEEPALIVE
1713
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
3339 void SetDicomWebRoot(const char* uri,
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
3340 int useRendered)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3341 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3342 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3343 {
1713
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
3344 source_.SetDicomWebSource(uri);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3345 source_.SetDicomWebRendered(useRendered != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3346 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3347 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3348 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3349
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3350
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3351 EMSCRIPTEN_KEEPALIVE
1713
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
3352 void SetDicomWebThroughOrthanc(const char* orthancRoot,
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
3353 const char* serverName,
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
3354 int hasRendered)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3355 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3356 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3357 {
1713
aec45e0b2528 configuration option "DicomWebRoot"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
3358 context_->SetLocalOrthanc(orthancRoot);
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3359 source_.SetDicomWebThroughOrthancSource(serverName);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3360 source_.SetDicomWebRendered(hasRendered != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3361 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3362 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3363 }
1761
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3364
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3365
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3366 EMSCRIPTEN_KEEPALIVE
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3367 void AddHttpHeader(const char* header,
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3368 const char* value)
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3369 {
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3370 try
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3371 {
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3372 source_.AddHttpHeader(header, value);
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3373 }
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3374 EXTERN_CATCH_EXCEPTIONS;
28755e42c007 Fix issue #197 (Support for passing credentials with all HTTP requests)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
3375 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3376
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3377
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3378 EMSCRIPTEN_KEEPALIVE
1714
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3379 void SetDicomCacheSize(int sizeMB)
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3380 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3381 try
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3382 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3383 if (sizeMB == 0)
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3384 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3385 LOG(WARNING) << "The DICOM cache is disabled";
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3386 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3387 else
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3388 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3389 LOG(INFO) << "The DICOM cache size is set to " << sizeMB << "MB";
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3390 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3391
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3392 if (sizeMB >= 0)
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3393 {
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3394 context_->SetDicomCacheSize(sizeMB * 1024 * 1024);
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3395 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3396 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3397 EXTERN_CATCH_EXCEPTIONS;
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3398 }
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3399
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3400
a878e807cd96 configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1713
diff changeset
3401 EMSCRIPTEN_KEEPALIVE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3402 void FetchAllStudies()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3403 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3404 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3405 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3406 GetResourcesLoader().FetchAllStudies();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3407 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3408 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3409 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3410
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3411 EMSCRIPTEN_KEEPALIVE
1702
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3412 void FetchPatient(const char* patientId)
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3413 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3414 try
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3415 {
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3416 GetResourcesLoader().FetchPatient(patientId);
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3417 }
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3418 EXTERN_CATCH_EXCEPTIONS;
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3419 }
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3420
bc40b6450261 "patient" GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
3421 EMSCRIPTEN_KEEPALIVE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3422 void FetchStudy(const char* studyInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3423 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3424 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3425 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3426 GetResourcesLoader().FetchStudy(studyInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3427 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3428 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3429 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3430
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3431 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3432 void FetchSeries(const char* studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3433 const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3434 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3435 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3436 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3437 GetResourcesLoader().FetchSeries(studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3438 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3439 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3440 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3441
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3442 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3443 int GetStudiesCount()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3444 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3445 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3446 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3447 return GetResourcesLoader().GetStudiesCount();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3448 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3449 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3450 return 0; // on exception
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3451 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3452
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3453 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3454 int GetSeriesCount()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3455 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3456 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3457 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3458 return GetResourcesLoader().GetSeriesCount();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3459 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3460 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3461 return 0; // on exception
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3462 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3463
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3464
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3465 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3466 const char* GetStringBuffer()
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3467 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3468 return stringBuffer_.c_str();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3469 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3470
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3471
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3472 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3473 void LoadStudyTags(int i)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3474 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3475 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3476 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3477 if (i < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3478 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3479 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3480 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3481
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3482 Orthanc::DicomMap dicom;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3483 GetResourcesLoader().GetStudy(dicom, i);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3484 FormatTags(stringBuffer_, dicom);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3485 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3486 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3487 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3488
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3489
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3490 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3491 void LoadSeriesTags(int i)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3492 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3493 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3494 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3495 if (i < 0)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3496 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3497 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3498 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3499
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3500 Orthanc::DicomMap dicom;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3501 GetResourcesLoader().GetSeries(dicom, i);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3502 FormatTags(stringBuffer_, dicom);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3503 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3504 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3505 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3506
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3507
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3508 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3509 int LoadSeriesThumbnail(const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3510 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3511 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3512 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3513 std::string image, mime;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3514 switch (GetResourcesLoader().GetSeriesThumbnail(image, mime, seriesInstanceUid))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3515 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3516 case OrthancStone::SeriesThumbnailType_Image:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3517 Orthanc::Toolbox::EncodeDataUriScheme(stringBuffer_, mime, image);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3518 return ThumbnailType_Image;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3519
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3520 case OrthancStone::SeriesThumbnailType_Pdf:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3521 return ThumbnailType_Pdf;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3522
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3523 case OrthancStone::SeriesThumbnailType_Video:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3524 return ThumbnailType_Video;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3525
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3526 case OrthancStone::SeriesThumbnailType_NotLoaded:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3527 return ThumbnailType_Loading;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3528
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3529 case OrthancStone::SeriesThumbnailType_Unsupported:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3530 return ThumbnailType_NoPreview;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3531
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3532 default:
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3533 return ThumbnailType_Unknown;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3534 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3535 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3536 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3537 return ThumbnailType_Unknown;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3538 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3539
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3540
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3541 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3542 void SpeedUpFetchSeriesMetadata(const char* studyInstanceUid,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3543 const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3544 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3545 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3546 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3547 GetResourcesLoader().FetchSeriesMetadata(PRIORITY_HIGH, studyInstanceUid, seriesInstanceUid);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3548 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3549 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3550 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3551
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3552
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3553 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3554 int IsSeriesComplete(const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3555 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3556 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3557 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3558 return GetResourcesLoader().IsSeriesComplete(seriesInstanceUid) ? 1 : 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3559 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3560 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3561 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3562 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3563
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3564 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3565 int LoadSeriesInViewport(const char* canvas,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3566 const char* seriesInstanceUid)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3567 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3568 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3569 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3570 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
3571
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3572 if (GetResourcesLoader().SortSeriesFrames(*frames, seriesInstanceUid))
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3573 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3574 GetViewport(canvas)->SetFrames(frames.release());
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3575 return 1;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3576 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3577 else
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3578 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3579 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3580 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3581 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3582 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3583 return 0;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3584 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3585
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3586
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3587 EMSCRIPTEN_KEEPALIVE
1704
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3588 int LoadMultipartInstanceInViewport(const char* canvas,
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3589 const char* seriesInstanceUid,
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3590 const char* sopInstanceUid)
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3591 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3592 try
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3593 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3594 std::unique_ptr<OrthancStone::SortedFrames> frames(new OrthancStone::SortedFrames);
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3595
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3596 if (GetResourcesLoader().SortMultipartInstanceFrames(*frames, seriesInstanceUid, sopInstanceUid))
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3597 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3598 GetViewport(canvas)->SetFrames(frames.release());
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3599 return 1;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3600 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3601 else
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3602 {
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3603 return 0;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3604 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3605 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3606 EXTERN_CATCH_EXCEPTIONS;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3607 return 0;
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3608 }
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3609
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3610
902d13889ae4 LoadMultipartInstanceInViewport() in C++
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1703
diff changeset
3611 EMSCRIPTEN_KEEPALIVE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3612 void AllViewportsUpdateSize(int fitContent)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3613 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3614 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3615 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3616 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
3617 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3618 assert(it->second != NULL);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3619 it->second->UpdateSize(fitContent != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3620 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3621 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3622 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3623 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3624
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3625
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3626 EMSCRIPTEN_KEEPALIVE
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3627 int DecrementFrame(const char* canvas,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3628 int isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3629 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3630 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3631 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3632 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
3633 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3634 EXTERN_CATCH_EXCEPTIONS;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3635 return 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3636 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3637
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3638
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3639 EMSCRIPTEN_KEEPALIVE
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3640 int IncrementFrame(const char* canvas,
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3641 int isCircular)
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3642 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3643 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3644 {
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3645 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
3646 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3647 EXTERN_CATCH_EXCEPTIONS;
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3648 return 0;
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3649 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3650
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3651
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3652 EMSCRIPTEN_KEEPALIVE
1719
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3653 void GoToFirstFrame(const char* canvas)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3654 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3655 try
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3656 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3657 GetViewport(canvas)->GoToFirstFrame();
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3658 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3659 EXTERN_CATCH_EXCEPTIONS;
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3660 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3661
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3662
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3663 EMSCRIPTEN_KEEPALIVE
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3664 void GoToLastFrame(const char* canvas)
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3665 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3666 try
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3667 {
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3668 GetViewport(canvas)->GoToLastFrame();
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3669 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3670 EXTERN_CATCH_EXCEPTIONS;
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3671 }
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3672
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3673
9a1f79d21a3f added buttons to go to the first and last frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1717
diff changeset
3674 EMSCRIPTEN_KEEPALIVE
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3675 void ShowReferenceLines(int show)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3676 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3677 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3678 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3679 showReferenceLines_ = (show != 0);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3680 UpdateReferenceLines();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3681 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3682 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3683 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3684
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3685
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3686 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3687 void SetWindowing(const char* canvas,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3688 int center,
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3689 int width)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3690 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3691 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3692 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3693 GetViewport(canvas)->SetWindowing(center, width);
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3694 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3695 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3696 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3697
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3698
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3699 EMSCRIPTEN_KEEPALIVE
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3700 void InvertContrast(const char* canvas)
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3701 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3702 try
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3703 {
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3704 GetViewport(canvas)->Invert();
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3705 }
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3706 EXTERN_CATCH_EXCEPTIONS;
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3707 }
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3708
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3709
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3710 EMSCRIPTEN_KEEPALIVE
1554
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3711 void FlipX(const char* canvas)
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3712 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3713 try
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3714 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3715 GetViewport(canvas)->FlipX();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3716 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3717 EXTERN_CATCH_EXCEPTIONS;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3718 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3719
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3720
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3721 EMSCRIPTEN_KEEPALIVE
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3722 void FlipY(const char* canvas)
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3723 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3724 try
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3725 {
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3726 GetViewport(canvas)->FlipY();
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3727 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3728 EXTERN_CATCH_EXCEPTIONS;
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3729 }
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3730
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3731
6d14ed6163b1 flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1552
diff changeset
3732 EMSCRIPTEN_KEEPALIVE
1552
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3733 void SetSoftwareRendering(int softwareRendering)
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3734 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3735 softwareRendering_ = softwareRendering;
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3736 }
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3737
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3738
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3739 EMSCRIPTEN_KEEPALIVE
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3740 int IsSoftwareRendering()
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3741 {
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3742 return softwareRendering_;
a4d82f1bcb10 user preferences: not for diagnostic use, software rendering
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1551
diff changeset
3743 }
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3744
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3745
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3746 EMSCRIPTEN_KEEPALIVE
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3747 void SetMouseButtonActions(int leftAction,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3748 int middleAction,
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3749 int rightAction)
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3750 {
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3751 try
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3752 {
1579
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
3753 leftButtonAction_ = static_cast<WebViewerAction>(leftAction);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
3754 middleButtonAction_ = static_cast<WebViewerAction>(middleAction);
c476b0d5e59c skeleton for cross-hair tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
3755 rightButtonAction_ = static_cast<WebViewerAction>(rightAction);
1561
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3756
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3757 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3758 {
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3759 assert(it->second != NULL);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3760 it->second->SetMouseButtonActions(leftButtonAction_, middleButtonAction_, rightButtonAction_);
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3761 }
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3762 }
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3763 EXTERN_CATCH_EXCEPTIONS;
cf652990abb1 tunable mouse actions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
3764 }
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3765
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3766
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3767 EMSCRIPTEN_KEEPALIVE
1815
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3768 int GetLeftMouseButtonAction()
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3769 {
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3770 return static_cast<int>(leftButtonAction_);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3771 }
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3772
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3773
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3774 EMSCRIPTEN_KEEPALIVE
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3775 int GetMiddleMouseButtonAction()
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3776 {
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3777 return static_cast<int>(middleButtonAction_);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3778 }
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3779
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3780
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3781 EMSCRIPTEN_KEEPALIVE
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3782 int GetRightMouseButtonAction()
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3783 {
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3784 return static_cast<int>(rightButtonAction_);
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3785 }
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3786
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3787
b81775f1b196 New tools for annotations: segment length, circle, angle and eraser
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1814
diff changeset
3788 EMSCRIPTEN_KEEPALIVE
1578
1f812f4c95be comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1576
diff changeset
3789 void FitForPrint()
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3790 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3791 try
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3792 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3793 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3794 {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3795 assert(it->second != NULL);
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3796 it->second->FitForPrint();
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3797 }
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3798 }
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3799 EXTERN_CATCH_EXCEPTIONS;
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
3800 }
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3801
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3802
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3803 // 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
3804 // Instance UID" of the first loaded annotation
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3805 EMSCRIPTEN_KEEPALIVE
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3806 int LoadOsiriXAnnotations(const char* xml,
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3807 int clearPreviousAnnotations)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3808 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3809 try
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3810 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3811 if (clearPreviousAnnotations)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3812 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3813 osiriXAnnotations_->Clear();
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3814 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3815
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3816 osiriXAnnotations_->LoadXml(xml);
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3817
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3818 // Force redraw, as the annotations might have changed
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3819 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3820 {
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3821 assert(it->second != NULL);
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3822 it->second->Redraw();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3823 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3824
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3825 if (osiriXAnnotations_->GetSize() == 0)
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3826 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3827 stringBuffer_.clear();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3828 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3829 else
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3830 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3831 stringBuffer_ = osiriXAnnotations_->GetAnnotation(0).GetSeriesInstanceUid();
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3832 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3833
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3834 LOG(WARNING) << "Loaded " << osiriXAnnotations_->GetSize() << " annotations from OsiriX";
1593
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3835 return 1;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3836 }
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3837 EXTERN_CATCH_EXCEPTIONS;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3838 return 0;
b782f78aed42 rendering osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1591
diff changeset
3839 }
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3840
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3841
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3842 EMSCRIPTEN_KEEPALIVE
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3843 void FocusFirstOsiriXAnnotation(const char* canvas)
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3844 {
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3845 try
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3846 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3847 if (osiriXAnnotations_->GetSize() != 0)
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3848 {
1812
db341679dc9f ViewerViewport::StoneAnnotationsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1811
diff changeset
3849 const OrthancStone::OsiriX::Annotation& annotation = osiriXAnnotations_->GetAnnotation(0);
1603
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3850
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3851 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
3852 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
3853
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3854 // 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
3855 viewport->Redraw();
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3856 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3857 }
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3858 EXTERN_CATCH_EXCEPTIONS;
595c0952ef7e focusing on osirix annotations in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3859 }
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3860
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3861
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3862 EMSCRIPTEN_KEEPALIVE
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3863 void FetchPdf(const char* studyInstanceUid,
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3864 const char* seriesInstanceUid)
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3865 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3866 try
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3867 {
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3868 LOG(INFO) << "Fetching PDF series: " << seriesInstanceUid;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3869 GetResourcesLoader().FetchPdf(studyInstanceUid, seriesInstanceUid);
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3870 }
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3871 EXTERN_CATCH_EXCEPTIONS;
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
3872 }
1672
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3873
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3874
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3875 EMSCRIPTEN_KEEPALIVE
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3876 unsigned int GetCineRate(const char* canvas)
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3877 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3878 try
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3879 {
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3880 return GetViewport(canvas)->GetCineRate();
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3881 }
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3882 EXTERN_CATCH_EXCEPTIONS;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3883 return 0;
570398585b5f start support of cine sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
3884 }
1674
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3885
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3886
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3887 EMSCRIPTEN_KEEPALIVE
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3888 unsigned int GetSeriesNumberOfFrames(const char* seriesInstanceUid)
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3889 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3890 try
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3891 {
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3892 return GetResourcesLoader().GetSeriesNumberOfFrames(seriesInstanceUid);
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3893 }
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3894 EXTERN_CATCH_EXCEPTIONS;
0621e523b670 number of frames in badge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
3895 return 0;
1679
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3896 }
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3897
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3898
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3899 EMSCRIPTEN_KEEPALIVE
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3900 void LoadWindowingPresets(const char* canvas)
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3901 {
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3902 try
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3903 {
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3904 Json::Value v;
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3905 GetViewport(canvas)->FormatWindowingPresets(v);
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3906 stringBuffer_ = v.toStyledString();
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3907 }
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3908 EXTERN_CATCH_EXCEPTIONS;
5b8b88e5bfd6 successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1677
diff changeset
3909 }
1693
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3910
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3911
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3912 EMSCRIPTEN_KEEPALIVE
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3913 void SetSynchronizedBrowsingEnabled(int enabled)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3914 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3915 try
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3916 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3917 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3918 {
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3919 assert(it->second != NULL);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3920 it->second->SetSynchronizedBrowsingEnabled(enabled);
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3921 }
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3922 }
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3923 EXTERN_CATCH_EXCEPTIONS;
eafb10992e73 synchronized browsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1682
diff changeset
3924 }
1703
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3925
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3926
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3927 EMSCRIPTEN_KEEPALIVE
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3928 int LoadMultiframeInstancesFromSeries(const char* seriesInstanceUid)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3929 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3930 try
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3931 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3932 std::map<std::string, unsigned int> numberOfFramesPerInstance;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3933 if (GetResourcesLoader().LookupMultiframeSeries(numberOfFramesPerInstance, seriesInstanceUid))
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3934 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3935 Json::Value json = Json::objectValue;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3936 for (std::map<std::string, unsigned int>::const_iterator it =
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3937 numberOfFramesPerInstance.begin(); it != numberOfFramesPerInstance.end(); ++it)
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3938 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3939 json[it->first] = it->second;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3940 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3941
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3942 stringBuffer_ = json.toStyledString();
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3943 return true;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3944 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3945 else
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3946 {
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3947 return false;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3948 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3949 }
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3950 EXTERN_CATCH_EXCEPTIONS;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3951 return false;
76c590a62755 start work on series with multiple multiframe instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
3952 }
1495
fb74ed5d8c22 initial commit of the Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3953 }