# HG changeset patch # User am@osimis.io # Date 1530616796 -7200 # Node ID 65562a28fe0575ca9e4e4f53f76d9f1055e625c7 # Parent abc1c62319478876a50576a6b8d1dc475d4b68ec fixes for WASM diff -r abc1c6231947 -r 65562a28fe05 Platforms/Wasm/CMakeLists.txt --- a/Platforms/Wasm/CMakeLists.txt Tue Jul 03 11:49:02 2018 +0200 +++ b/Platforms/Wasm/CMakeLists.txt Tue Jul 03 13:19:56 2018 +0200 @@ -61,6 +61,7 @@ macro(BuildSample Target Header Sample) add_executable(${Target} + ${STONE_WASM_SOURCES} ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainWasm.cpp # ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationContext.cpp diff -r abc1c6231947 -r 65562a28fe05 Platforms/Wasm/Defaults.cpp --- a/Platforms/Wasm/Defaults.cpp Tue Jul 03 11:49:02 2018 +0200 +++ b/Platforms/Wasm/Defaults.cpp Tue Jul 03 13:19:56 2018 +0200 @@ -67,6 +67,7 @@ printf("CreateWasmApplication\n"); application.reset(CreateUserApplication(broker)); + WasmWebService::SetBroker(broker); startupParametersBuilder.Clear(); } @@ -86,7 +87,6 @@ application->DeclareStartupOptions(options); startupParametersBuilder.GetStartupParameters(parameters, options); - WasmWebService::SetBroker(broker); context.reset(new OrthancStone::BasicApplicationContext(OrthancStone::WasmWebService::GetInstance())); application->Initialize(context.get(), statusBar_, parameters); application->InitializeWasm(); diff -r abc1c6231947 -r 65562a28fe05 Platforms/Wasm/WasmWebService.h --- a/Platforms/Wasm/WasmWebService.h Tue Jul 03 11:49:02 2018 +0200 +++ b/Platforms/Wasm/WasmWebService.h Tue Jul 03 13:19:56 2018 +0200 @@ -23,6 +23,7 @@ { if (broker_ == NULL) { + printf("WasmWebService::GetInstance(): broker not initialized\n"); throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } static WasmWebService instance(*broker_); diff -r abc1c6231947 -r 65562a28fe05 Platforms/Wasm/wasm-application.ts --- a/Platforms/Wasm/wasm-application.ts Tue Jul 03 11:49:02 2018 +0200 +++ b/Platforms/Wasm/wasm-application.ts Tue Jul 03 13:19:56 2018 +0200 @@ -10,6 +10,7 @@ // global functions var WasmWebService_NotifyError: Function = null; var WasmWebService_NotifySuccess: Function = null; +var WasmWebService_SetBaseUri: Function = null; var NotifyUpdateContent: Function = null; var SetStartupParameter: Function = null; var CreateWasmApplication: Function = null; @@ -66,10 +67,12 @@ } -function _InitializeWasmApplication(canvasId: string): void { +function _InitializeWasmApplication(canvasId: string, orthancBaseUrl: string): void { /************************************** */ CreateWasmApplication(); + WasmWebService_SetBaseUri(orthancBaseUrl); + // parse uri and transmit the parameters to the app before initializing it var parameters = GetUriParameters(); @@ -104,15 +107,16 @@ WasmWebService_NotifySuccess = StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']); WasmWebService_NotifyError = StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']); + WasmWebService_SetBaseUri = StoneFrameworkModule.cwrap('WasmWebService_SetBaseUri', null, ['string']); NotifyUpdateContent = StoneFrameworkModule.cwrap('NotifyUpdateContent', null, []); - StoneFrameworkModule.ccall('WasmWebService_SetBaseUri', null, ['string'], [orthancBaseUrl]); + console.log("Connecting C++ methods to JS methods - done - 2"); // Prevent scrolling document.body.addEventListener('touchmove', function (event) { event.preventDefault(); }, false); - _InitializeWasmApplication("canvas"); + _InitializeWasmApplication("canvas", orthancBaseUrl); }); } \ No newline at end of file diff -r abc1c6231947 -r 65562a28fe05 Resources/CMake/OrthancStoneConfiguration.cmake --- a/Resources/CMake/OrthancStoneConfiguration.cmake Tue Jul 03 11:49:02 2018 +0200 +++ b/Resources/CMake/OrthancStoneConfiguration.cmake Tue Jul 03 13:19:56 2018 +0200 @@ -160,10 +160,13 @@ else() list(APPEND APPLICATIONS_SOURCES ${ORTHANC_STONE_ROOT}/Applications/Wasm/StartupParametersBuilder.cpp + ) + + set(STONE_WASM_SOURCES ${ORTHANC_STONE_ROOT}/Platforms/Wasm/Defaults.cpp ${ORTHANC_STONE_ROOT}/Platforms/Wasm/WasmWebService.cpp ${ORTHANC_STONE_ROOT}/Platforms/Wasm/WasmViewport.cpp - ) + ) endif() list(APPEND ORTHANC_STONE_SOURCES