Mercurial > hg > orthanc-stone
annotate Applications/Sdl/BasicSdlApplicationContext.h @ 273:f21ba2468570 am-2
force all Widgets to have a name to ease debugging
author | am@osimis.io |
---|---|
date | Fri, 24 Aug 2018 11:26:59 +0200 |
parents | 46c5296d867e |
children |
rev | line source |
---|---|
222 | 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 | |
28 #include <list> | |
29 #include <boost/thread.hpp> | |
30 #include "../BasicApplicationContext.h" | |
31 | |
32 namespace OrthancStone | |
33 { | |
34 class BasicSdlApplicationContext : public BasicApplicationContext | |
35 { | |
36 private: | |
37 | |
38 static void UpdateThread(BasicSdlApplicationContext* that); | |
39 | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
40 boost::mutex globalMutex_; |
233 | 41 std::unique_ptr<WidgetViewport> centralViewport_; |
222 | 42 boost::thread updateThread_; |
43 bool stopped_; | |
44 unsigned int updateDelay_; | |
45 | |
46 public: | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
47 class GlobalMutexLocker: public boost::noncopyable |
222 | 48 { |
49 boost::mutex::scoped_lock lock_; | |
50 public: | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
51 GlobalMutexLocker(BasicSdlApplicationContext& that): |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
52 lock_(that.globalMutex_) |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
53 {} |
222 | 54 }; |
55 | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
56 // class ViewportLocker : public boost::noncopyable |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
57 // { |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
58 // private: |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
59 // boost::mutex::scoped_lock lock_; |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
60 // IViewport& viewport_; |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
61 |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
62 // public: |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
63 // ViewportLocker(BasicSdlApplicationContext& that) : |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
64 // lock_(that.viewportMutex_), |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
65 // viewport_(*(that.centralViewport_.get())) |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
66 // { |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
67 // } |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
68 |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
69 // IViewport& GetViewport() const |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
70 // { |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
71 // return viewport_; |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
72 // } |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
73 // }; |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
74 |
222 | 75 |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
76 BasicSdlApplicationContext(); |
222 | 77 |
78 virtual ~BasicSdlApplicationContext() {} | |
79 | |
80 virtual IWidget& SetCentralWidget(IWidget* widget); // Takes ownership | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
81 IViewport& GetCentralViewport() {return *(centralViewport_.get());} |
222 | 82 |
83 void Start(); | |
84 | |
85 void Stop(); | |
86 | |
87 void SetUpdateDelay(unsigned int delay) // In milliseconds | |
88 { | |
89 updateDelay_ = delay; | |
90 } | |
91 }; | |
92 } |