comparison Samples/README.md @ 1381:f4a06ad1580b

Branch broker is now the new default
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 22 Apr 2020 14:05:47 +0200
parents 5b750a4e1b52
children 62dc0d737e7b
comparison
equal deleted inserted replaced
1375:4431ffdcc2a4 1381:f4a06ad1580b
1 General
2 =======
3 These samples assume that a recent version of Orthanc is checked out in an
4 `orthanc` folder next to the `orthanc-stone` folder. Let's call the top folder
5 the `devroot` folder. This name does not matter and is not used anywhere.
6
7 Here's the directory layout that we suggest:
8
9 ```
10 devroot/
11 |
12 +- orthanc/
13 |
14 +- orthanc-stone/
15 |
16 ...
17 ```
18
19 Orthanc can be retrieved with:
20 ```
21 hg clone https://hg.orthanc-server.com/orthanc
22 ```
23
24 Furthermore, the samples usually assume that an Orthanc is running locally,
25 without authentication, on port 8042. The samples can easily be tweaked if
26 your setup is different.
27
28 When Dicom resources are to be displayed, their IDs can be supplied in the
29 various ways suitable for the platform (command-line arguments, URL parameters
30 or through the GUI)
31
32
33 WebAssembly samples
34 ===================
35
36 Building the WebAssembly samples require the Emscripten SDK
37 (https://emscripten.org/). This SDK goes far beyond the simple compilation to
38 the wasm (Web Assembly) bytecode and provides a comprehensive library that
39 eases porting native C and C++ programs and libraries. The Emscripten SDK also
40 makes it easy to generate the companion Javascript files requires to use a
41 wasm module in a web application.
42
43 Although Emscripten runs on all major platforms, Stone of Orthanc is developed
44 and tested with the Linux version of Emscripten.
45
46 Emscripten runs perfectly fine under the Windows Subsystem for Linux (that is
47 the environment used quite often by the Stone of Orthanc team)
48
49 **Important note:** The following examples **and the build scripts** will
50 assume that you have installed the Emscripten SDK in `~/apps/emsdk`.
51
52 The following packages should get you going (a Debian-like distribution such
53 as Debian or Ubuntu is assumed)
54
55 ```
56 sudo apt-get update
57 sudo apt-get install -y build-essential curl wget git python cmake pkg-config
58 sudo apt-get install -y mercurial unzip npm ninja-build p7zip-full gettext-base
59 ```
60
61 SingleFrameViewer
62 -----------------
63
64 This sample application displays a single frame of a Dicom instance that can
65 be loaded from Orthanc, either by using the Orthanc REST API or through the
66 Dicomweb server functionality of Orthanc.
67
68 This barebones sample uses plain Javascript and requires the
69 Emscripten toolchain and cmake, in addition to a few standard packages.
70
71 Here's how you can build it: create the following script (for instance,
72 `build-wasm-SingleFrameViewer.sh`) one level above the orthanc-stone repository,
73 thus, in the folder we have called `devroot`.
74
75 If you feel confident, you can also simply read the following script and
76 enter the commands interactively in the terminal.
77
78 ```
79 #!/bin/bash
80
81 if [ ! -d "orthanc-stone" ]; then
82 echo "This script must be run from the folder one level above orthanc-stone"
83 exit 1
84 fi
85
86 if [[ ! $# -eq 1 ]]; then
87 echo "Usage:"
88 echo " $0 [BUILD_TYPE]"
89 echo ""
90 echo " with:"
91 echo " BUILD_TYPE = Debug, RelWithDebInfo or Release"
92 echo ""
93 exit 1
94 fi
95
96 # define the variables that we'll use
97 buildType=$1
98 buildFolderName="`pwd`/out/build-stone-wasm-SingleFrameViewer-$buildType"
99 installFolderName="`pwd`/out/install-stone-wasm-SingleFrameViewer-$buildType"
100
101 # configure the environment to use Emscripten
102 . ~/apps/emsdk/emsdk_env.sh
103
104
105 mkdir -p $buildFolderName
106
107 # change current folder to the build folder
108 pushd $buildFolderName
109
110 emcmake cmake -G "Ninja" \
111 -DCMAKE_BUILD_TYPE=$buildType \
112 -DCMAKE_INSTALL_PREFIX=$installFolderName \
113 -DSTATIC_BUILD=ON -DOPENSSL_NO_CAPIENG=ON -DALLOW_DOWNLOADS=ON \
114 ../orthanc-stone/Samples/WebAssembly/SingleFrameViewer
115
116 # perform build + installation
117 ninja install
118
119 # restore the original working folder
120 popd
121
122 echo "If all went well, the output files can be found in $installFolderName:"
123
124 ls $installFolderName```
125 ```
126
127 Simply navigate to the dev root, and execute the script:
128
129 ```
130 ./build-wasm-SingleFrameViewer.sh RelWithDebInfo
131 ```
132
133 I suggest that you do *not* use the `Debug` confirmation unless you really
134 need it, for the additional checks that are made will lead to a very long
135 build time and much slower execution (more severe than with a native non-wasm
136 target)
137
138 Native samples
139 =================
140
141 SdlSimpleViewer
142 ---------------
143
144 ### Windows build
145
146 Here's how to build the SdlSimpleViewer example using Visual Studio 2019
147 (the shell is Powershell, but the legacy shell can also be used with some
148 tweaks). This example is meant to be launched from the folder above
149 orthanc-stone.
150
151 ```
152 # create the build folder and navigate to it
153 $buildDir = "build-stone-sdlviewer-msvc16-x64"
154
155 if (-not (Test-Path $buildDir)) {
156 mkdir -p $buildDir | Out-Null
157 }
158
159 cd $buildDir
160
161 # perform the configuration
162 cmake -G "Visual Studio 16 2019" -A x64 `
163 -DMSVC_MULTIPLE_PROCESSES=ON `
164 -DALLOW_DOWNLOADS=ON `
165 -DSTATIC_BUILD=ON `
166 -DOPENSSL_NO_CAPIENG=ON `
167 ../orthanc-stone/Samples/Sdl/SimpleViewer
168
169 $solutionPath = ls -filter *.sln
170 Write-Host "Solution file(s) available at: $solutionPath"
171 ```
172
173 The initial configuration step will be quite lengthy, for CMake needs to
174 setup its internal cache based on your environment and build tools.
175
176 Subsequent runs will be several orders of magnitude faster!
177
178 One the solution (.sln) file is ready, you can open it using the Visual Studio
179 IDE and choose Build --> Build solution.
180
181 An alternative is to execute `cmake --build .` in the build folder created by
182 the script.
183