Mercurial > hg > orthanc-stone
annotate Applications/Samples/CtPetDoseStructFusion/Wasm/CtPetDoseStructFusionWasmApplicationAdapter.cpp @ 540:7428c5dfa5df ct-pet-dose-struct
Initial commit non working app
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 19 Mar 2019 16:29:07 +0100 |
parents | |
children |
rev | line source |
---|---|
540
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include "CtPetDoseStructFusionWasmApplicationAdapter.h" |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 namespace CtPetDoseStructFusion |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 CtPetDoseStructFusionWasmApplicationAdapter::CtPetDoseStructFusionWasmApplicationAdapter(MessageBroker &broker, CtPetDoseStructFusionApplication &application) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 : WasmPlatformApplicationAdapter(broker, application), |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 viewerApplication_(application) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 application.RegisterObserverCallback(new Callable<CtPetDoseStructFusionWasmApplicationAdapter, CtPetDoseStructFusionApplication::StatusUpdatedMessage>(*this, &CtPetDoseStructFusionWasmApplicationAdapter::OnStatusUpdated)); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 void CtPetDoseStructFusionWasmApplicationAdapter::OnStatusUpdated(const CtPetDoseStructFusionApplication::StatusUpdatedMessage &message) |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 { |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 Json::Value statusJson; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 message.status_.ToJson(statusJson); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 Json::Value event; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 event["event"] = "appStatusUpdated"; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 event["data"] = statusJson; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 Json::StreamWriterBuilder builder; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter()); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 std::ostringstream outputStr; |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 writer->write(event, &outputStr); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 NotifyStatusUpdateFromCppToWebWithString(outputStr.str()); |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 } |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 |
7428c5dfa5df
Initial commit non working app
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 } // namespace CtPetDoseStructFusion |