comparison Applications/Samples/Deprecated/SampleApplicationBase.h @ 1347:bfd77672d825 broker

Moved Application/Samples/* to Application/Samples/Deprecated/*
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 07 Apr 2020 14:29:01 +0200
parents Applications/Samples/SampleApplicationBase.h@7ec8fea061b9
children c53a4667f895
comparison
equal deleted inserted replaced
1346:df8bf351c23f 1347:bfd77672d825
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
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.
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
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #pragma once
23
24 #include "../../Applications/IStoneApplication.h"
25 #include "../../Framework/Deprecated/Widgets/WorldSceneWidget.h"
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
36
37 namespace OrthancStone
38 {
39 namespace Samples
40 {
41 class SampleApplicationBase : public IStoneApplication
42 {
43 private:
44 boost::shared_ptr<Deprecated::IWidget> mainWidget_;
45
46 public:
47 virtual void Initialize(StoneApplicationContext* context,
48 Deprecated::IStatusBar& statusBar,
49 const boost::program_options::variables_map& parameters) ORTHANC_OVERRIDE
50 {
51 }
52
53 virtual std::string GetTitle() const ORTHANC_OVERRIDE
54 {
55 return "Stone of Orthanc - Sample";
56 }
57
58 /**
59 * In the basic samples, the commands are handled by the platform adapter and NOT
60 * by the application handler
61 */
62 virtual void HandleSerializedMessage(const char* data) ORTHANC_OVERRIDE {};
63
64
65 virtual void Finalize() ORTHANC_OVERRIDE {}
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 }
76
77 #if ORTHANC_ENABLE_WASM==1
78 // default implementations for a single canvas named "canvas" in the HTML and an emtpy WasmApplicationAdapter
79
80 virtual void InitializeWasm() ORTHANC_OVERRIDE
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:
97 virtual void OnPushButton1Clicked() {}
98 virtual void OnPushButton2Clicked() {}
99 virtual void OnTool1Clicked() {}
100 virtual void OnTool2Clicked() {}
101
102 virtual void GetButtonNames(std::string& pushButton1,
103 std::string& pushButton2,
104 std::string& tool1,
105 std::string& tool2
106 ) {
107 pushButton1 = "action1";
108 pushButton2 = "action2";
109 tool1 = "tool1";
110 tool2 = "tool2";
111 }
112
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 };
120
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
131 };
132 }
133 }