Mercurial > hg > orthanc-stone
annotate Applications/Samples/SampleApplicationBase.h @ 590:5430bcffba57
FloatTextureSceneLayer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Apr 2019 11:33:57 +0200 |
parents | 79bb0a02d1cc |
children | 4f2416d519b4 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
288
diff
changeset
|
16 * |
47 | 17 * You should have received a copy of the GNU Affero General Public License |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
288 | 24 #include "../../Applications/IStoneApplication.h" |
336
c7fdc8bac581
creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
326
diff
changeset
|
25 #include "../../Framework/Widgets/WorldSceneWidget.h" |
326 | 26 |
27 #if ORTHANC_ENABLE_WASM==1 | |
28 #include "../../Platforms/Wasm/WasmPlatformApplicationAdapter.h" | |
29 #include "../../Platforms/Wasm/Defaults.h" | |
30 #endif | |
31 | |
32 #if ORTHANC_ENABLE_QT==1 | |
33 #include "Qt/SampleMainWindow.h" | |
34 #include "Qt/SampleMainWindowWithButtons.h" | |
35 #endif | |
0 | 36 |
37 namespace OrthancStone | |
38 { | |
39 namespace Samples | |
40 { | |
288 | 41 class SampleApplicationBase : public IStoneApplication |
0 | 42 { |
307 | 43 protected: |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
44 // ownership is transferred to the application context |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
45 WorldSceneWidget* mainWidget_; |
326 | 46 |
0 | 47 public: |
288 | 48 virtual void Initialize(StoneApplicationContext* context, |
285
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
49 IStatusBar& statusBar, |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
50 const boost::program_options::variables_map& parameters) ORTHANC_OVERRIDE |
285
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
51 { |
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
288
diff
changeset
|
52 } |
285
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
53 |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
54 virtual std::string GetTitle() const ORTHANC_OVERRIDE |
0 | 55 { |
56 return "Stone of Orthanc - Sample"; | |
57 } | |
242 | 58 |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
59 /** |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
60 * In the basic samples, the commands are handled by the platform adapter and NOT |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
61 * by the application handler |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
62 */ |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
63 virtual void HandleSerializedMessage(const char* data) ORTHANC_OVERRIDE {}; |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
64 |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
65 |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
66 virtual void Finalize() ORTHANC_OVERRIDE {} |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
67 virtual IWidget* GetCentralWidget() ORTHANC_OVERRIDE {return mainWidget_;} |
326 | 68 |
69 #if ORTHANC_ENABLE_WASM==1 | |
70 // default implementations for a single canvas named "canvas" in the HTML and an emtpy WasmApplicationAdapter | |
71 | |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
72 virtual void InitializeWasm() ORTHANC_OVERRIDE |
326 | 73 { |
74 AttachWidgetToWasmViewport("canvas", mainWidget_); | |
75 } | |
76 | |
77 virtual WasmPlatformApplicationAdapter* CreateWasmApplicationAdapter(MessageBroker& broker) | |
78 { | |
79 return new WasmPlatformApplicationAdapter(broker, *this); | |
80 } | |
81 #endif | |
82 | |
83 }; | |
84 | |
85 // this application actually works in Qt and WASM | |
86 class SampleSingleCanvasWithButtonsApplicationBase : public SampleApplicationBase | |
87 { | |
88 public: | |
285
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
89 virtual void OnPushButton1Clicked() {} |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
90 virtual void OnPushButton2Clicked() {} |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
91 virtual void OnTool1Clicked() {} |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
92 virtual void OnTool2Clicked() {} |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
93 |
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
288
diff
changeset
|
94 virtual void GetButtonNames(std::string& pushButton1, |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
288
diff
changeset
|
95 std::string& pushButton2, |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
288
diff
changeset
|
96 std::string& tool1, |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
288
diff
changeset
|
97 std::string& tool2 |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
288
diff
changeset
|
98 ) { |
285
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
99 pushButton1 = "action1"; |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
100 pushButton2 = "action2"; |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
101 tool1 = "tool1"; |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
102 tool2 = "tool2"; |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
103 } |
242 | 104 |
326 | 105 #if ORTHANC_ENABLE_QT==1 |
106 virtual QStoneMainWindow* CreateQtMainWindow() { | |
107 return new SampleMainWindowWithButtons(dynamic_cast<OrthancStone::NativeStoneApplicationContext&>(*context_), *this); | |
108 } | |
109 #endif | |
110 | |
111 }; | |
307 | 112 |
326 | 113 // this application actually works in SDL and WASM |
114 class SampleSingleCanvasApplicationBase : public SampleApplicationBase | |
115 { | |
116 public: | |
117 | |
118 #if ORTHANC_ENABLE_QT==1 | |
119 virtual QStoneMainWindow* CreateQtMainWindow() { | |
120 return new SampleMainWindow(dynamic_cast<OrthancStone::NativeStoneApplicationContext&>(*context_), *this); | |
121 } | |
122 #endif | |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
134
diff
changeset
|
123 }; |
0 | 124 } |
125 } |