annotate Samples/WebAssembly/BasicMPR.cpp @ 984:35ed6812d639 toa2019090602

Build fix
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 06 Sep 2019 11:46:51 +0200
parents 0965b665c653
children 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
23 #include "dev.h"
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
24
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <emscripten.h>
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "../../Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h"
824
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
28 #include "../../Framework/Oracle/SleepOracleCommand.h"
825
9a6c7a5dcb76 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
29 #include "../../Framework/Oracle/WebAssemblyOracle.h"
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include "../../Framework/Scene2D/GrayscaleStyleConfigurator.h"
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include "../../Framework/StoneInitialization.h"
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include "../../Framework/Volumes/VolumeSceneLayerSource.h"
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 namespace OrthancStone
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
37 class VolumeSlicerWidget : public IObserver
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 private:
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 OrthancStone::WebAssemblyViewport viewport_;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 std::auto_ptr<VolumeSceneLayerSource> source_;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 VolumeProjection projection_;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 std::vector<CoordinateSystem3D> planes_;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 size_t currentPlane_;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 void Handle(const DicomVolumeImage::GeometryReadyMessage& message)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 LOG(INFO) << "Geometry is available";
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 const VolumeImageGeometry& geometry = message.GetOrigin().GetGeometry();
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 const unsigned int depth = geometry.GetProjectionDepth(projection_);
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 currentPlane_ = depth / 2;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 planes_.resize(depth);
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 for (unsigned int z = 0; z < depth; z++)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 planes_[z] = geometry.GetProjectionSlice(projection_, z);
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
822
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
61
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
62 Refresh();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
63
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
64 viewport_.FitContent();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 public:
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
68 VolumeSlicerWidget(MessageBroker& broker,
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 const std::string& canvas,
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 VolumeProjection projection) :
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 IObserver(broker),
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 viewport_(broker, canvas),
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 projection_(projection),
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 currentPlane_(0)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 void UpdateSize()
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 viewport_.UpdateSize();
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 void SetSlicer(int layerDepth,
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 const boost::shared_ptr<IVolumeSlicer>& slicer,
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 IObservable& loader,
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 ILayerStyleConfigurator* configurator)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 if (source_.get() != NULL)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls,
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 "Only one slicer can be registered");
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 loader.RegisterObserverCallback(
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
95 new Callable<VolumeSlicerWidget, DicomVolumeImage::GeometryReadyMessage>
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
96 (*this, &VolumeSlicerWidget::Handle));
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 source_.reset(new VolumeSceneLayerSource(viewport_.GetScene(), layerDepth, slicer));
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 if (configurator != NULL)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 source_->SetConfigurator(configurator);
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 void Refresh()
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 if (source_.get() != NULL &&
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 currentPlane_ < planes_.size())
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 source_->Update(planes_[currentPlane_]);
822
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
112 viewport_.Refresh();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
115
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
116 size_t GetSlicesCount() const
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
117 {
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
118 return planes_.size();
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
119 }
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
120
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
121 void Scroll(int delta)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
122 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
123 if (!planes_.empty())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
124 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
125 int tmp = static_cast<int>(currentPlane_) + delta;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
126 unsigned int next;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
127
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
128 if (tmp < 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
129 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
130 next = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
131 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
132 else if (tmp >= static_cast<int>(planes_.size()))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
133 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
134 next = planes_.size() - 1;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
135 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
136 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
137 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
138 next = static_cast<size_t>(tmp);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
139 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
140
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
141 if (next != currentPlane_)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
142 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
143 currentPlane_ = next;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
144 Refresh();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
145 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
146 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
147 }
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 };
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 boost::shared_ptr<OrthancStone::DicomVolumeImage> ct_(new OrthancStone::DicomVolumeImage);
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> loader_;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
158 std::auto_ptr<OrthancStone::VolumeSlicerWidget> widget1_;
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
159 std::auto_ptr<OrthancStone::VolumeSlicerWidget> widget2_;
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
160 std::auto_ptr<OrthancStone::VolumeSlicerWidget> widget3_;
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 OrthancStone::MessageBroker broker_;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 OrthancStone::WebAssemblyOracle oracle_(broker_);
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 EM_BOOL OnWindowResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 try
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
170 if (widget1_.get() != NULL)
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
172 widget1_->UpdateSize();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
175 if (widget2_.get() != NULL)
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
177 widget2_->UpdateSize();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
180 if (widget3_.get() != NULL)
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
182 widget3_->UpdateSize();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 catch (Orthanc::OrthancException& e)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 LOG(ERROR) << "Exception while updating canvas size: " << e.What();
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 return true;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 EM_BOOL OnAnimationFrame(double time, void *userData)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 try
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
200 if (widget1_.get() != NULL)
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
202 widget1_->Refresh();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
205 if (widget2_.get() != NULL)
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
207 widget2_->Refresh();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
210 if (widget3_.get() != NULL)
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
212 widget3_->Refresh();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 return true;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 catch (Orthanc::OrthancException& e)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 LOG(ERROR) << "Exception in the animation loop, stopping now: " << e.What();
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 return false;
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
225 static bool ctrlDown_ = false;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
226
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
227
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
228 EM_BOOL OnMouseWheel(int eventType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
229 const EmscriptenWheelEvent *wheelEvent,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
230 void *userData)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
231 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
232 try
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
233 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
234 if (userData != NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
235 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
236 int delta = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
238 if (wheelEvent->deltaY < 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
239 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
240 delta = -1;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
241 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
242
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
243 if (wheelEvent->deltaY > 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
244 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
245 delta = 1;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
246 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
247
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
248 OrthancStone::VolumeSlicerWidget& widget =
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
249 *reinterpret_cast<OrthancStone::VolumeSlicerWidget*>(userData);
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
250
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
251 if (ctrlDown_)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
252 {
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
253 delta *= static_cast<int>(widget.GetSlicesCount() / 10);
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
254 }
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
255
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
256 widget.Scroll(delta);
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
257 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
258 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
259 catch (Orthanc::OrthancException& e)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
260 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
261 LOG(ERROR) << "Exception in the wheel event: " << e.What();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
262 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
263
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
264 return true;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
265 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
266
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
267
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
268 EM_BOOL OnKeyDown(int eventType,
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
269 const EmscriptenKeyboardEvent *keyEvent,
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
270 void *userData)
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
271 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
272 ctrlDown_ = keyEvent->ctrlKey;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
273 return false;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
274 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
275
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
276
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
277 EM_BOOL OnKeyUp(int eventType,
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
278 const EmscriptenKeyboardEvent *keyEvent,
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
279 void *userData)
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
280 {
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
281 ctrlDown_ = false;
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
282 return false;
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
283 }
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
284
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
285
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
286
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
287
824
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
288 namespace OrthancStone
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
289 {
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
290 class TestSleep : public IObserver
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
291 {
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
292 private:
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
293 WebAssemblyOracle& oracle_;
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
294
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
295 void Schedule()
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
296 {
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
297 oracle_.Schedule(*this, new OrthancStone::SleepOracleCommand(2000));
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
298 }
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
299
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
300 void Handle(const SleepOracleCommand::TimeoutMessage& message)
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
301 {
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
302 LOG(INFO) << "TIMEOUT";
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
303 Schedule();
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
304 }
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
305
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
306 public:
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
307 TestSleep(MessageBroker& broker,
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
308 WebAssemblyOracle& oracle) :
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
309 IObserver(broker),
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
310 oracle_(oracle)
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
311 {
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
312 oracle.RegisterObserverCallback(
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
313 new Callable<TestSleep, SleepOracleCommand::TimeoutMessage>
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
314 (*this, &TestSleep::Handle));
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
315
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
316 LOG(INFO) << "STARTING";
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
317 Schedule();
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
318 }
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
319 };
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
320
831
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
321 //static TestSleep testSleep(broker_, oracle_);
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
322 }
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
323
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
324
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
325
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
326 static std::map<std::string, std::string> arguments_;
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
327
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
328 static bool GetArgument(std::string& value,
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
329 const std::string& key)
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
330 {
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
331 std::map<std::string, std::string>::const_iterator found = arguments_.find(key);
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
332
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
333 if (found == arguments_.end())
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
334 {
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
335 return false;
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
336 }
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
337 else
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
338 {
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
339 value = found->second;
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
340 return true;
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
341 }
824
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
342 }
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
343
15d493101c1e support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 823
diff changeset
344
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 extern "C"
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 int main(int argc, char const *argv[])
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 OrthancStone::StoneInitialize();
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 Orthanc::Logging::EnableInfoLevel(true);
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 // Orthanc::Logging::EnableTraceLevel(true);
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 EM_ASM(window.dispatchEvent(new CustomEvent("WebAssemblyLoaded")););
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 EMSCRIPTEN_KEEPALIVE
831
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
356 void SetArgument(const char* key, const char* value)
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
357 {
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
358 // This is called for each GET argument (cf. "app.js")
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
359 LOG(INFO) << "Received GET argument: [" << key << "] = [" << value << "]";
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
360 arguments_[key] = value;
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
361 }
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
362
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
363 EMSCRIPTEN_KEEPALIVE
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 void Initialize()
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 try
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 {
831
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
368 oracle_.SetOrthancRoot("..");
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
369
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 loader_.reset(new OrthancStone::OrthancSeriesVolumeProgressiveLoader(ct_, oracle_, oracle_));
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
372 widget1_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas1", OrthancStone::VolumeProjection_Axial));
835
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
373 {
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
374 std::auto_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator);
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
375 style->SetLinearInterpolation(true);
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
376 style->SetWindowing(OrthancStone::ImageWindowing_Bone);
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
377 widget1_->SetSlicer(0, loader_, *loader_, style.release());
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
378 }
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
379 widget1_->UpdateSize();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
381 widget2_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas2", OrthancStone::VolumeProjection_Coronal));
835
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
382 {
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
383 std::auto_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator);
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
384 style->SetLinearInterpolation(true);
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
385 style->SetWindowing(OrthancStone::ImageWindowing_Bone);
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
386 widget2_->SetSlicer(0, loader_, *loader_, style.release());
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
387 }
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
388 widget2_->UpdateSize();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
390 widget3_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas3", OrthancStone::VolumeProjection_Sagittal));
835
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
391 {
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
392 std::auto_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator);
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
393 style->SetLinearInterpolation(true);
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
394 style->SetWindowing(OrthancStone::ImageWindowing_Bone);
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
395 widget3_->SetSlicer(0, loader_, *loader_, style.release());
0965b665c653 windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
396 }
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
397 widget3_->UpdateSize();
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 emscripten_set_resize_callback("#window", NULL, false, OnWindowResize);
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
400
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
401 emscripten_set_wheel_callback("mycanvas1", widget1_.get(), false, OnMouseWheel);
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
402 emscripten_set_wheel_callback("mycanvas2", widget2_.get(), false, OnMouseWheel);
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
403 emscripten_set_wheel_callback("mycanvas3", widget3_.get(), false, OnMouseWheel);
823
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 822
diff changeset
404
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
405 emscripten_set_keydown_callback("#window", NULL, false, OnKeyDown);
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 825
diff changeset
406 emscripten_set_keyup_callback("#window", NULL, false, OnKeyUp);
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 emscripten_request_animation_frame_loop(OnAnimationFrame, NULL);
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409
831
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
410
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
411 std::string ct;
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
412 if (GetArgument(ct, "ct"))
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
413 {
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
414 //loader_->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa");
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
415 loader_->LoadSeries(ct);
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
416 }
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
417 else
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
418 {
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
419 LOG(ERROR) << "No Orthanc identifier for the CT series was provided";
d71cf8504159 handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 826
diff changeset
420 }
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 catch (Orthanc::OrthancException& e)
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 {
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 LOG(ERROR) << "Exception during Initialize(): " << e.What();
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 }
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 }