Mercurial > hg > orthanc-stone
comparison Applications/Sdl/BasicSdlApplicationContext.h @ 222:84844649a8fd am
continued: reusable applications
author | am@osimis.io |
---|---|
date | Tue, 12 Jun 2018 17:21:15 +0200 |
parents | |
children | 68856534f005 |
comparison
equal
deleted
inserted
replaced
221:d7b2590744f8 | 222:84844649a8fd |
---|---|
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-2018 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 "../../Framework/Viewport/WidgetViewport.h" | |
25 #include "../../Framework/Volumes/ISlicedVolume.h" | |
26 #include "../../Framework/Volumes/IVolumeLoader.h" | |
27 #include "../../Framework/Widgets/IWorldSceneInteractor.h" | |
28 #include "../../Platforms/Generic/OracleWebService.h" | |
29 | |
30 #include <list> | |
31 #include <boost/thread.hpp> | |
32 #include "../BasicApplicationContext.h" | |
33 | |
34 namespace OrthancStone | |
35 { | |
36 class BasicSdlApplicationContext : public BasicApplicationContext | |
37 { | |
38 private: | |
39 | |
40 static void UpdateThread(BasicSdlApplicationContext* that); | |
41 | |
42 Oracle oracle_; | |
43 OracleWebService webService_; | |
44 boost::mutex viewportMutex_; | |
45 WidgetViewport centralViewport_; | |
46 boost::thread updateThread_; | |
47 bool stopped_; | |
48 unsigned int updateDelay_; | |
49 | |
50 public: | |
51 class ViewportLocker : public boost::noncopyable | |
52 { | |
53 private: | |
54 boost::mutex::scoped_lock lock_; | |
55 IViewport& viewport_; | |
56 | |
57 public: | |
58 ViewportLocker(BasicSdlApplicationContext& that) : | |
59 lock_(that.viewportMutex_), | |
60 viewport_(that.centralViewport_) | |
61 { | |
62 } | |
63 | |
64 IViewport& GetViewport() const | |
65 { | |
66 return viewport_; | |
67 } | |
68 }; | |
69 | |
70 | |
71 BasicSdlApplicationContext(Orthanc::WebServiceParameters& orthanc); | |
72 | |
73 virtual ~BasicSdlApplicationContext() {} | |
74 | |
75 virtual IWidget& SetCentralWidget(IWidget* widget); // Takes ownership | |
76 | |
77 virtual IWebService& GetWebService() | |
78 { | |
79 return webService_; | |
80 } | |
81 | |
82 void Start(); | |
83 | |
84 void Stop(); | |
85 | |
86 void SetUpdateDelay(unsigned int delay) // In milliseconds | |
87 { | |
88 updateDelay_ = delay; | |
89 } | |
90 }; | |
91 } |