Mercurial > hg > orthanc-stone
comparison Platforms/Wasm/wasm-application-runner.ts @ 313:8bdc6112bc2e am-2
initial resize of canvas
author | am@osimis.io |
---|---|
date | Wed, 03 Oct 2018 17:01:05 +0200 |
parents | ed1a4302154f |
children | 97f16214dc5e |
comparison
equal
deleted
inserted
replaced
312:a91ad36b684c | 313:8bdc6112bc2e |
---|---|
27 | 27 |
28 setTimeout(UpdateContentThread, 100); // Update the viewport content every 100ms if need be | 28 setTimeout(UpdateContentThread, 100); // Update the viewport content every 100ms if need be |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 function GetUriParameters() { | 32 function GetUriParameters(): Map<string, string> { |
33 var parameters = window.location.search.substr(1); | 33 var parameters = window.location.search.substr(1); |
34 | 34 |
35 if (parameters != null && | 35 if (parameters != null && |
36 parameters != '') { | 36 parameters != '') { |
37 var result = {}; | 37 var result = new Map<string, string>(); |
38 var tokens = parameters.split('&'); | 38 var tokens = parameters.split('&'); |
39 | 39 |
40 for (var i = 0; i < tokens.length; i++) { | 40 for (var i = 0; i < tokens.length; i++) { |
41 var tmp = tokens[i].split('='); | 41 var tmp = tokens[i].split('='); |
42 if (tmp.length == 2) { | 42 if (tmp.length == 2) { |
45 } | 45 } |
46 | 46 |
47 return result; | 47 return result; |
48 } | 48 } |
49 else { | 49 else { |
50 return {}; | 50 return new Map<string, string>(); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 // function UpdateWebApplication(statusUpdateMessage: string) { | 54 // function UpdateWebApplication(statusUpdateMessage: string) { |
55 // console.log(statusUpdateMessage); | 55 // console.log(statusUpdateMessage); |
56 // } | 56 // } |
57 | 57 |
58 function _InitializeWasmApplication(canvasId: string, orthancBaseUrl: string): void { | 58 function _InitializeWasmApplication(canvasIds: string[], orthancBaseUrl: string): void { |
59 | 59 |
60 /************************************** */ | |
61 CreateWasmApplication(); | 60 CreateWasmApplication(); |
62 WasmWebService_SetBaseUri(orthancBaseUrl); | 61 WasmWebService_SetBaseUri(orthancBaseUrl); |
63 | 62 |
64 | 63 |
65 // parse uri and transmit the parameters to the app before initializing it | 64 // parse uri and transmit the parameters to the app before initializing it |
66 var parameters = GetUriParameters(); | 65 let parameters = GetUriParameters(); |
67 | 66 |
68 for (var key in parameters) { | 67 for (let key in parameters) { |
69 if (parameters.hasOwnProperty(key)) { | 68 if (parameters.hasOwnProperty(key)) { |
70 SetStartupParameter(key, parameters[key]); | 69 SetStartupParameter(key, parameters[key]); |
71 } | 70 } |
72 } | 71 } |
73 | 72 |
74 StartWasmApplication(); | 73 StartWasmApplication(); |
75 /************************************** */ | 74 |
75 // trigger a first resize of the canvas that have just been initialized | |
76 for (let canvasId of canvasIds) { | |
77 Stone.WasmViewport.GetFromCanvasId(canvasId).Resize(); | |
78 } | |
76 | 79 |
77 UpdateContentThread(); | 80 UpdateContentThread(); |
78 } | 81 } |
79 | 82 |
80 function InitializeWasmApplication(wasmModuleName: string, orthancBaseUrl: string) { | 83 function InitializeWasmApplication(wasmModuleName: string, orthancBaseUrl: string, canvasIds: string[]) { |
81 | 84 |
82 Stone.Framework.Configure(wasmModuleName); | 85 Stone.Framework.Configure(wasmModuleName); |
83 | 86 |
84 // Wait for the Orthanc Framework to be initialized (this initializes | 87 // Wait for the Orthanc Framework to be initialized (this initializes |
85 // the WebAssembly environment) and then, create and initialize the Wasm application | 88 // the WebAssembly environment) and then, create and initialize the Wasm application |
105 // Prevent scrolling | 108 // Prevent scrolling |
106 document.body.addEventListener('touchmove', function (event) { | 109 document.body.addEventListener('touchmove', function (event) { |
107 event.preventDefault(); | 110 event.preventDefault(); |
108 }, false); | 111 }, false); |
109 | 112 |
110 _InitializeWasmApplication("canvas", orthancBaseUrl); | 113 _InitializeWasmApplication(canvasIds, orthancBaseUrl); |
111 }); | 114 }); |
112 } | 115 } |