Mercurial > hg > orthanc-stone
annotate Applications/Generic/NativeStoneApplicationContext.h @ 627:b7fd0471281c am-dev
fix CodeGeneration unit tests
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Wed, 08 May 2019 10:51:41 +0200 |
parents | a750f11892ec |
children | 4f2416d519b4 |
rev | line source |
---|---|
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
1 /** |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
2 * Stone of Orthanc |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
6 * |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
11 * |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
16 * |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
19 **/ |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
20 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
21 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
22 #pragma once |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
23 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
24 #include "../../Framework/Viewport/WidgetViewport.h" |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
25 #include "../../Framework/Volumes/ISlicedVolume.h" |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
26 #include "../../Framework/Volumes/IVolumeLoader.h" |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
27 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
28 #include <list> |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
29 #include <boost/thread.hpp> |
288 | 30 #include "../StoneApplicationContext.h" |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
31 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
32 namespace OrthancStone |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
33 { |
291 | 34 class NativeStoneApplicationContext : public StoneApplicationContext |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
35 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
36 private: |
291 | 37 static void UpdateThread(NativeStoneApplicationContext* that); |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
38 |
433 | 39 boost::recursive_mutex globalMutex_; |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
40 WidgetViewport centralViewport_; |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
41 boost::thread updateThread_; |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
42 bool stopped_; |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
43 unsigned int updateDelayInMs_; |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
44 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
45 public: |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
46 class GlobalMutexLocker: public boost::noncopyable |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
47 { |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
48 private: |
433 | 49 NativeStoneApplicationContext& that_; |
50 boost::recursive_mutex::scoped_lock lock_; | |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
51 |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
52 public: |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
53 GlobalMutexLocker(NativeStoneApplicationContext& that) : |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
54 that_(that), |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
55 lock_(that.globalMutex_) |
334
c34784e5f299
compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
56 { |
c34784e5f299
compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
57 } |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
58 |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
59 IWidget& SetCentralWidget(IWidget* widget); // Takes ownership |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
60 |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
61 IViewport& GetCentralViewport() |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
62 { |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
63 return that_.centralViewport_; |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
64 } |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
65 |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
66 void SetUpdateDelay(unsigned int delayInMs) |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
67 { |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
68 that_.updateDelayInMs_ = delayInMs; |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
69 } |
418 | 70 |
71 MessageBroker& GetMessageBroker() | |
72 { | |
73 return that_.GetMessageBroker(); | |
74 } | |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
75 }; |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
76 |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
77 NativeStoneApplicationContext(MessageBroker& broker); |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
78 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
79 void Start(); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
80 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
81 void Stop(); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
82 }; |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
83 } |