annotate Platforms/Wasm/Defaults.h @ 427:3f9017db1738 am-vsol-upgrade-radiography-export

wip
author am@osimis.io
date Fri, 23 Nov 2018 16:06:23 +0100
parents 3e6e10a5a6c8
children 7105a0bad250
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
1 #pragma once
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
2
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
3 #include <emscripten/emscripten.h>
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
4
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
5 #include <Framework/dev.h>
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
6 #include <Framework/Viewport/WidgetViewport.h>
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
7 #include <Framework/Widgets/LayoutWidget.h>
288
8c8da145fefa renamings and doc
am@osimis.io
parents: 287
diff changeset
8 #include <Applications/IStoneApplication.h>
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 288
diff changeset
9 #include <Platforms/Wasm/WasmPlatformApplicationAdapter.h>
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
10
233
68856534f005 added layout to VSOL, SDL & wasm working
am@osimis.io
parents: 229
diff changeset
11 typedef OrthancStone::WidgetViewport* ViewportHandle; // the objects exchanged between JS and C++
227
c8f11437a6fd getting ready for multiple viewports
am@osimis.io
parents: 223
diff changeset
12
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
13 #ifdef __cplusplus
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
14 extern "C" {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
15 #endif
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
16
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
17 // JS methods accessible from C++
229
b0ba3b38a23c ScheduleRedraw can handle multiple viewports
am@osimis.io
parents: 228
diff changeset
18 extern void ScheduleWebViewportRedrawFromCpp(ViewportHandle cppViewportHandle);
287
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 278
diff changeset
19 extern void UpdateStoneApplicationStatusFromCpp(const char* statusUpdateMessage);
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
20
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
21 // C++ methods accessible from JS
229
b0ba3b38a23c ScheduleRedraw can handle multiple viewports
am@osimis.io
parents: 228
diff changeset
22 extern void EMSCRIPTEN_KEEPALIVE CreateWasmApplication(ViewportHandle cppViewportHandle);
254
abc1c6231947 cleanup
am@osimis.io
parents: 253
diff changeset
23 extern void EMSCRIPTEN_KEEPALIVE SetStartupParameter(const char* keyc, const char* value);
abc1c6231947 cleanup
am@osimis.io
parents: 253
diff changeset
24
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
25
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
26 #ifdef __cplusplus
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
27 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
28 #endif
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
29
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 288
diff changeset
30 // these methods must be implemented in the custom app "mainWasm.cpp"
288
8c8da145fefa renamings and doc
am@osimis.io
parents: 287
diff changeset
31 extern OrthancStone::IStoneApplication* CreateUserApplication(OrthancStone::MessageBroker& broker);
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 288
diff changeset
32 extern OrthancStone::WasmPlatformApplicationAdapter* CreateWasmApplicationAdapter(OrthancStone::MessageBroker& broker, OrthancStone::IStoneApplication* application);
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
33
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
34 namespace OrthancStone {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
35
287
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 278
diff changeset
36 // default Observer to trigger Viewport redraw when something changes in the Viewport
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
37 class ViewportContentChangedObserver : public IObserver
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
38 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
39 private:
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
40 // Flag to avoid flooding JavaScript with redundant Redraw requests
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
41 bool isScheduled_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
42
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
43 public:
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
44 ViewportContentChangedObserver(MessageBroker& broker) :
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
45 IObserver(broker),
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
46 isScheduled_(false)
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
47 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
48 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
49
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
50 void Reset()
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
51 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
52 isScheduled_ = false;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
53 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
54
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
55 void OnViewportChanged(const IViewport::ViewportChangedMessage& message)
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
56 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
57 if (!isScheduled_)
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
58 {
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
59 ScheduleWebViewportRedrawFromCpp((ViewportHandle)&message.GetOrigin()); // loosing constness when transmitted to Web
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
60 isScheduled_ = true;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
61 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
62 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
63 };
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
64
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
65 // default status bar to log messages on the console/stdout
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
66 class StatusBar : public OrthancStone::IStatusBar
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
67 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
68 public:
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
69 virtual void ClearMessage()
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
70 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
71 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
72
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
73 virtual void SetMessage(const std::string& message)
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
74 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
75 printf("%s\n", message.c_str());
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
76 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
77 };
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
78 }