Mercurial > hg > orthanc-stone
annotate Samples/WebAssembly/RtViewer/OSBOLETE.cpp @ 1406:5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Thu, 30 Apr 2020 00:25:55 +0200 |
parents | 24bcff8ea58f |
children | 15173a383a00 |
rev | line source |
---|---|
1384
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include <Framework/Viewport/WebAssemblyViewport.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 #include <Framework/Scene2D/OpenGLCompositor.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 #include <Framework/Scene2D/PanSceneTracker.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 #include <Framework/Scene2D/RotateSceneTracker.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 #include <Framework/Scene2D/ZoomSceneTracker.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 #include <Framework/Scene2DViewport/UndoStack.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 #include <Framework/Scene2DViewport/ViewportController.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 #include <Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 #include <Framework/Oracle/SleepOracleCommand.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 #include <Framework/Oracle/WebAssemblyOracle.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 #include <Framework/Scene2D/GrayscaleStyleConfigurator.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 #include <Framework/StoneInitialization.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 #include <Framework/Volumes/VolumeSceneLayerSource.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 #include <Core/OrthancException.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 #include <emscripten/html5.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 #include <emscripten.h> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 #include <boost/make_shared.hpp> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 class ViewportManager; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 static const unsigned int FONT_SIZE = 32; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 boost::shared_ptr<OrthancStone::DicomVolumeImage> ct_(new OrthancStone::DicomVolumeImage); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> loader_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 std::unique_ptr<ViewportManager> widget1_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 std::unique_ptr<ViewportManager> widget2_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 std::unique_ptr<ViewportManager> widget3_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 //OrthancStone::MessageBroker broker_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 //OrthancStone::WebAssemblyOracle oracle_(broker_); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 std::unique_ptr<OrthancStone::IFlexiblePointerTracker> tracker_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 static std::map<std::string, std::string> arguments_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 static bool ctrlDown_ = false; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 #if 0 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 // use the one from WebAssemblyViewport |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 static OrthancStone::PointerEvent* ConvertMouseEvent( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 const EmscriptenMouseEvent& source, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 OrthancStone::IViewport& viewport) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 std::unique_ptr<OrthancStone::PointerEvent> target( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 new OrthancStone::PointerEvent); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 target->AddPosition(viewport.GetPixelCenterCoordinates( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 source.targetX, source.targetY)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 target->SetAltModifier(source.altKey); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 target->SetControlModifier(source.ctrlKey); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 target->SetShiftModifier(source.shiftKey); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 return target.release(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 #endif |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 EM_BOOL OnMouseEvent(int eventType, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 const EmscriptenMouseEvent *mouseEvent, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 void *userData) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 if (mouseEvent != NULL && |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 userData != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 boost::shared_ptr<OrthancStone::WebGLViewport>& viewport = |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 *reinterpret_cast<boost::shared_ptr<OrthancStone::WebGLViewport>*>(userData); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 std::unique_ptr<OrthancStone::IViewport::ILock> lock = (*viewport)->Lock(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 ViewportController& controller = lock->GetController(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 Scene2D& scene = controller.GetScene(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 switch (eventType) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 case EMSCRIPTEN_EVENT_CLICK: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 static unsigned int count = 0; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 char buf[64]; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 sprintf(buf, "click %d", count++); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 std::unique_ptr<OrthancStone::TextSceneLayer> layer(new OrthancStone::TextSceneLayer); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 layer->SetText(buf); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 scene.SetLayer(100, layer.release()); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 lock->Invalidate(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 break; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 case EMSCRIPTEN_EVENT_MOUSEDOWN: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
112 boost::shared_ptr<OrthancStone::IFlexiblePointerTracker> t; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 std::unique_ptr<OrthancStone::PointerEvent> event( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 ConvertMouseEvent(*mouseEvent, controller->GetViewport())); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 switch (mouseEvent->button) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 case 0: // Left button |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 emscripten_console_log("Creating RotateSceneTracker"); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 t.reset(new OrthancStone::RotateSceneTracker( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 viewport, *event)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 break; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 case 1: // Middle button |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 emscripten_console_log("Creating PanSceneTracker"); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 LOG(INFO) << "Creating PanSceneTracker" ; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 t.reset(new OrthancStone::PanSceneTracker( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 viewport, *event)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 break; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 case 2: // Right button |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 emscripten_console_log("Creating ZoomSceneTracker"); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 t.reset(new OrthancStone::ZoomSceneTracker( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
136 viewport, *event, controller->GetViewport().GetCanvasWidth())); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 break; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 default: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 break; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 if (t.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 tracker_.reset( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 new OrthancStone::ActiveTracker(t, controller->GetViewport().GetCanvasIdentifier())); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 controller->GetViewport().Refresh(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 break; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
153 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 case EMSCRIPTEN_EVENT_MOUSEMOVE: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 if (tracker_.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
157 std::unique_ptr<OrthancStone::PointerEvent> event( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 ConvertMouseEvent(*mouseEvent, controller->GetViewport())); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
159 tracker_->PointerMove(*event); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 controller->GetViewport().Refresh(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 break; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
164 case EMSCRIPTEN_EVENT_MOUSEUP: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
165 if (tracker_.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
166 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 std::unique_ptr<OrthancStone::PointerEvent> event( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 ConvertMouseEvent(*mouseEvent, controller->GetViewport())); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 tracker_->PointerUp(*event); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 controller->GetViewport().Refresh(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 if (!tracker_->IsAlive()) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 tracker_.reset(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 break; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 default: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 break; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 return true; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 void SetupEvents(const std::string& canvas, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 boost::shared_ptr<OrthancStone::WebGLViewport>& viewport) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 emscripten_set_mousedown_callback(canvas.c_str(), &viewport, false, OnMouseEvent); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
189 emscripten_set_mousemove_callback(canvas.c_str(), &viewport, false, OnMouseEvent); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
190 emscripten_set_mouseup_callback(canvas.c_str(), &viewport, false, OnMouseEvent); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 class ViewportManager : public OrthanStone::ObserverBase<ViewportManager> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
195 private: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
196 OrthancStone::WebAssemblyViewport viewport_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
197 std::unique_ptr<VolumeSceneLayerSource> source_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
198 VolumeProjection projection_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
199 std::vector<CoordinateSystem3D> planes_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
200 size_t currentPlane_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
201 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
202 void Handle(const DicomVolumeImage::GeometryReadyMessage& message) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
203 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
204 LOG(INFO) << "Geometry is available"; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
206 const VolumeImageGeometry& geometry = message.GetOrigin().GetGeometry(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
207 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
208 const unsigned int depth = geometry.GetProjectionDepth(projection_); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 // select an initial cutting plane halfway through the volume |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
211 currentPlane_ = depth / 2; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
212 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
213 planes_.resize(depth); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
214 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
215 for (unsigned int z = 0; z < depth; z++) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
216 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
217 planes_[z] = geometry.GetProjectionSlice(projection_, z); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
218 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
219 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
220 Refresh(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
221 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
222 viewport_.FitContent(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
223 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
224 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 public: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 ViewportManager(const std::string& canvas, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 VolumeProjection projection) : |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 projection_(projection), |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
229 currentPlane_(0) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
230 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
231 viewport_ = OrthancStone::WebGLViewport::Create(canvas); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
232 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
233 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
234 void UpdateSize() |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
235 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
236 viewport_.UpdateSize(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
237 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
238 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
239 void SetSlicer(int layerDepth, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
240 const boost::shared_ptr<IVolumeSlicer>& slicer, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
241 IObservable& loader, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
242 ILayerStyleConfigurator* configurator) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
243 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
244 if (source_.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
245 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
246 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
247 "Only one slicer can be registered"); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
248 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
249 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 loader.RegisterObserverCallback( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
251 new Callable<ViewportManager, DicomVolumeImage::GeometryReadyMessage> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
252 (*this, &ViewportManager::Handle)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
253 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
254 source_.reset(new VolumeSceneLayerSource(viewport_.GetScene(), layerDepth, slicer)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
255 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
256 if (configurator != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
257 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
258 source_->SetConfigurator(configurator); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
259 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
260 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
261 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
262 void Refresh() |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
263 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
264 if (source_.get() != NULL && |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
265 currentPlane_ < planes_.size()) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
266 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
267 source_->Update(planes_[currentPlane_]); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
268 viewport_.Refresh(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
269 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
270 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
271 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
272 size_t GetSlicesCount() const |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
273 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
274 return planes_.size(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
275 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
276 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
277 void Scroll(int delta) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
278 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
279 if (!planes_.empty()) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
280 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
281 int tmp = static_cast<int>(currentPlane_) + delta; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 unsigned int next; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
283 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
284 if (tmp < 0) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
285 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
286 next = 0; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
287 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
288 else if (tmp >= static_cast<int>(planes_.size())) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
289 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
290 next = planes_.size() - 1; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
291 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
292 else |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
293 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
294 next = static_cast<size_t>(tmp); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
295 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
296 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
297 if (next != currentPlane_) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
298 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
299 currentPlane_ = next; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
300 Refresh(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
301 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
302 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
303 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
304 }; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
305 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
306 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
307 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
308 EM_BOOL OnWindowResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
309 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
310 try |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
311 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
312 if (widget1_.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
313 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
314 widget1_->UpdateSize(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
315 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
316 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
317 if (widget2_.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
318 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
319 widget2_->UpdateSize(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
320 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
321 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
322 if (widget3_.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
323 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
324 widget3_->UpdateSize(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
325 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
326 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
327 catch (Orthanc::OrthancException& e) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
328 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
329 LOG(ERROR) << "Exception while updating canvas size: " << e.What(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
330 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
331 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
332 return true; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
333 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
334 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
335 EM_BOOL OnAnimationFrame(double time, void *userData) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
336 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
337 try |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
338 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
339 if (widget1_.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
340 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
341 widget1_->Refresh(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
342 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
343 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
344 if (widget2_.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
345 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
346 widget2_->Refresh(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
347 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
348 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
349 if (widget3_.get() != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
350 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
351 widget3_->Refresh(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
352 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
353 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
354 return true; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
355 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
356 catch (Orthanc::OrthancException& e) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
357 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
358 LOG(ERROR) << "Exception in the animation loop, stopping now: " << e.What(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
359 return false; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
360 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
361 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
362 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
363 EM_BOOL OnMouseWheel(int eventType, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
364 const EmscriptenWheelEvent *wheelEvent, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
365 void *userData) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
366 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
367 try |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
368 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
369 if (userData != NULL) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
370 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
371 int delta = 0; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
372 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
373 if (wheelEvent->deltaY < 0) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
374 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
375 delta = -1; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
376 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
377 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
378 if (wheelEvent->deltaY > 0) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
379 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
380 delta = 1; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
381 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
382 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
383 OrthancStone::ViewportManager& widget = |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
384 *reinterpret_cast<OrthancStone::ViewportManager*>(userData); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
385 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
386 if (ctrlDown_) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
387 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
388 delta *= static_cast<int>(widget.GetSlicesCount() / 10); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
389 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
390 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
391 widget.Scroll(delta); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
392 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
393 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
394 catch (Orthanc::OrthancException& e) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
395 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
396 LOG(ERROR) << "Exception in the wheel event: " << e.What(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
397 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
398 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
399 return true; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
400 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
401 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
402 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
403 EM_BOOL OnKeyDown(int eventType, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
404 const EmscriptenKeyboardEvent *keyEvent, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
405 void *userData) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
406 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
407 ctrlDown_ = keyEvent->ctrlKey; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
408 return false; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
409 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
410 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
411 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
412 EM_BOOL OnKeyUp(int eventType, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
413 const EmscriptenKeyboardEvent *keyEvent, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
414 void *userData) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
415 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
416 ctrlDown_ = false; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
417 return false; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
418 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
419 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
420 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
421 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
422 #if 0 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
423 namespace OrthancStone |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
424 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
425 class TestSleep : public IObserver |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
426 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
427 private: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
428 WebAssemblyOracle& oracle_; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
429 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
430 void Schedule() |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
431 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
432 oracle_.Schedule(*this, new OrthancStone::SleepOracleCommand(2000)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
433 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
434 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
435 void Handle(const SleepOracleCommand::TimeoutMessage& message) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
436 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
437 LOG(INFO) << "TIMEOUT"; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
438 Schedule(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
439 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
440 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
441 public: |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
442 TestSleep(MessageBroker& broker, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
443 WebAssemblyOracle& oracle) : |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
444 IObserver(broker), |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
445 oracle_(oracle) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
446 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
447 oracle.RegisterObserverCallback( |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
448 new Callable<TestSleep, SleepOracleCommand::TimeoutMessage> |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
449 (*this, &TestSleep::Handle)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
450 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
451 LOG(INFO) << "STARTING"; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
452 Schedule(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
453 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
454 }; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
455 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
456 //static TestSleep testSleep(broker_, oracle_); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
457 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
458 #endif |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
459 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
460 static bool GetArgument(std::string& value, |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
461 const std::string& key) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
462 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
463 std::map<std::string, std::string>::const_iterator found = arguments_.find(key); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
464 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
465 if (found == arguments_.end()) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
466 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
467 return false; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
468 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
469 else |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
470 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
471 value = found->second; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
472 return true; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
473 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
474 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
475 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
476 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
477 extern "C" |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
478 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
479 int main(int argc, char const *argv[]) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
480 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
481 OrthancStone::StoneInitialize(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
482 Orthanc::Logging::EnableInfoLevel(true); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
483 // Orthanc::Logging::EnableTraceLevel(true); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
484 EM_ASM(window.dispatchEvent(new CustomEvent("WebAssemblyLoaded"));); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
485 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
486 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
487 EMSCRIPTEN_KEEPALIVE |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
488 void SetArgument(const char* key, const char* value) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
489 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
490 // This is called for each GET argument (cf. "app.js") |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
491 LOG(INFO) << "Received GET argument: [" << key << "] = [" << value << "]"; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
492 arguments_[key] = value; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
493 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
494 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
495 EMSCRIPTEN_KEEPALIVE |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
496 void Initialize() |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
497 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
498 try |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
499 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
500 oracle_.SetOrthancRoot(".."); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
501 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
502 loader_.reset(new OrthancStone::OrthancSeriesVolumeProgressiveLoader(ct_, oracle_, oracle_)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
503 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
504 widget1_.reset(new OrthancStone::ViewportManager("mycanvas1", OrthancStone::VolumeProjection_Axial)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
505 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
506 std::unique_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
507 style->SetLinearInterpolation(true); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
508 style->SetWindowing(OrthancStone::ImageWindowing_Bone); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
509 widget1_->SetSlicer(0, loader_, *loader_, style.release()); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
510 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
511 widget1_->UpdateSize(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
512 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
513 widget2_.reset(new OrthancStone::ViewportManager("mycanvas2", OrthancStone::VolumeProjection_Coronal)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
514 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
515 std::unique_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
516 style->SetLinearInterpolation(true); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
517 style->SetWindowing(OrthancStone::ImageWindowing_Bone); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
518 widget2_->SetSlicer(0, loader_, *loader_, style.release()); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
519 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
520 widget2_->UpdateSize(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
521 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
522 widget3_.reset(new OrthancStone::ViewportManager("mycanvas3", OrthancStone::VolumeProjection_Sagittal)); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
523 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
524 std::unique_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
525 style->SetLinearInterpolation(true); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
526 style->SetWindowing(OrthancStone::ImageWindowing_Bone); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
527 widget3_->SetSlicer(0, loader_, *loader_, style.release()); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
528 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
529 widget3_->UpdateSize(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
530 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
531 emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, false, OnWindowResize); // DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 !! |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
532 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
533 emscripten_set_wheel_callback("#mycanvas1", widget1_.get(), false, OnMouseWheel); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
534 emscripten_set_wheel_callback("#mycanvas2", widget2_.get(), false, OnMouseWheel); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
535 emscripten_set_wheel_callback("#mycanvas3", widget3_.get(), false, OnMouseWheel); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
536 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
537 emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, false, OnKeyDown); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
538 emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, false, OnKeyUp); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
539 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
540 //emscripten_request_animation_frame_loop(OnAnimationFrame, NULL); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
541 |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
542 std::string ct; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
543 if (GetArgument(ct, "ct")) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
544 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
545 //loader_->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
546 loader_->LoadSeries(ct); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
547 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
548 else |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
549 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
550 LOG(ERROR) << "No Orthanc identifier for the CT series was provided"; |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
551 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
552 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
553 catch (Orthanc::OrthancException& e) |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
554 { |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
555 LOG(ERROR) << "Exception during Initialize(): " << e.What(); |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
556 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
557 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
558 } |
24bcff8ea58f
RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
559 |