Mercurial > hg > orthanc-stone
annotate Applications/Samples/SampleApplicationBase.h @ 1310:9bea7e15b519 broker
- first pass at changes to cope with the refactoring of the loading system
- global loader-related data accessible through ILoadersContext::ILock
- many changes in legacy loaders (CT, RTSTRUCT, DOSE) + loader cache
- NOT FINISHED! there are shared_from_this calls in ctors! this will crash!
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 09 Mar 2020 14:53:22 +0100 |
parents | 7ec8fea061b9 |
children |
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 | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
5 * Copyright (C) 2017-2020 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" |
732
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
25 #include "../../Framework/Deprecated/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 { |
1069 | 43 private: |
44 boost::shared_ptr<Deprecated::IWidget> mainWidget_; | |
326 | 45 |
0 | 46 public: |
288 | 47 virtual void Initialize(StoneApplicationContext* context, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
48 Deprecated::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
|
49 const boost::program_options::variables_map& parameters) ORTHANC_OVERRIDE |
285
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
50 { |
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
288
diff
changeset
|
51 } |
285
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
52 |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
53 virtual std::string GetTitle() const ORTHANC_OVERRIDE |
0 | 54 { |
55 return "Stone of Orthanc - Sample"; | |
56 } | |
242 | 57 |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
58 /** |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
59 * 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
|
60 * 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
|
61 */ |
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
62 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
|
63 |
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 virtual void Finalize() ORTHANC_OVERRIDE {} |
1069 | 66 |
67 virtual void SetCentralWidget(boost::shared_ptr<Deprecated::IWidget> widget) ORTHANC_OVERRIDE | |
68 { | |
69 mainWidget_ = widget; | |
70 } | |
71 | |
72 virtual boost::shared_ptr<Deprecated::IWidget> GetCentralWidget() ORTHANC_OVERRIDE | |
73 { | |
74 return mainWidget_; | |
75 } | |
326 | 76 |
77 #if ORTHANC_ENABLE_WASM==1 | |
78 // default implementations for a single canvas named "canvas" in the HTML and an emtpy WasmApplicationAdapter | |
79 | |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
80 virtual void InitializeWasm() ORTHANC_OVERRIDE |
326 | 81 { |
82 AttachWidgetToWasmViewport("canvas", mainWidget_); | |
83 } | |
84 | |
85 virtual WasmPlatformApplicationAdapter* CreateWasmApplicationAdapter(MessageBroker& broker) | |
86 { | |
87 return new WasmPlatformApplicationAdapter(broker, *this); | |
88 } | |
89 #endif | |
90 | |
91 }; | |
92 | |
93 // this application actually works in Qt and WASM | |
94 class SampleSingleCanvasWithButtonsApplicationBase : public SampleApplicationBase | |
95 { | |
96 public: | |
285
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
97 virtual void OnPushButton1Clicked() {} |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
98 virtual void OnPushButton2Clicked() {} |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
99 virtual void OnTool1Clicked() {} |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
100 virtual void OnTool2Clicked() {} |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
101 |
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
288
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 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
|
106 ) { |
285
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
107 pushButton1 = "action1"; |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
108 pushButton2 = "action2"; |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
109 tool1 = "tool1"; |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
110 tool2 = "tool2"; |
3c190e2bb3af
refactoring: ApplicationRunner + app hierarchy
am@osimis.io
parents:
274
diff
changeset
|
111 } |
242 | 112 |
326 | 113 #if ORTHANC_ENABLE_QT==1 |
114 virtual QStoneMainWindow* CreateQtMainWindow() { | |
115 return new SampleMainWindowWithButtons(dynamic_cast<OrthancStone::NativeStoneApplicationContext&>(*context_), *this); | |
116 } | |
117 #endif | |
118 | |
119 }; | |
307 | 120 |
326 | 121 // this application actually works in SDL and WASM |
122 class SampleSingleCanvasApplicationBase : public SampleApplicationBase | |
123 { | |
124 public: | |
125 | |
126 #if ORTHANC_ENABLE_QT==1 | |
127 virtual QStoneMainWindow* CreateQtMainWindow() { | |
128 return new SampleMainWindow(dynamic_cast<OrthancStone::NativeStoneApplicationContext&>(*context_), *this); | |
129 } | |
130 #endif | |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
134
diff
changeset
|
131 }; |
0 | 132 } |
133 } |