Mercurial > hg > orthanc-stone
annotate Applications/Generic/NativeStoneApplicationContext.cpp @ 1205:6009c59d8676 broker
fix to sdl
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 02 Dec 2019 14:32:05 +0100 |
parents | 5d1b0d2f4b15 |
children | 0ca50d275b9a |
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 |
291 | 22 #include "NativeStoneApplicationContext.h" |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
23 #include "../../Platforms/Generic/OracleWebService.h" |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
24 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
25 namespace OrthancStone |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
26 { |
1069 | 27 void NativeStoneApplicationContext::GlobalMutexLocker::SetCentralWidget( |
28 boost::shared_ptr<Deprecated::IWidget> widget) | |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
29 { |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
30 that_.centralViewport_.SetCentralWidget(widget); |
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 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
33 |
291 | 34 void NativeStoneApplicationContext::UpdateThread(NativeStoneApplicationContext* that) |
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 while (!that->stopped_) |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
37 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
38 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
39 GlobalMutexLocker locker(*that); |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
385
diff
changeset
|
40 locker.GetCentralViewport().DoAnimation(); |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
41 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
42 |
277 | 43 boost::this_thread::sleep(boost::posix_time::milliseconds(that->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 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
46 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
47 |
1060
e146743f6cdc
removing file MessageBroker.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
48 NativeStoneApplicationContext::NativeStoneApplicationContext() : |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
49 stopped_(true), |
277 | 50 updateDelayInMs_(100) // By default, 100ms between each refresh of the content |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
51 { |
516
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
440
diff
changeset
|
52 srand(static_cast<unsigned int>(time(NULL))); |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
53 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
54 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
55 |
291 | 56 void NativeStoneApplicationContext::Start() |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
57 { |
433 | 58 boost::recursive_mutex::scoped_lock lock(globalMutex_); |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
59 |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
60 if (stopped_ && |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
385
diff
changeset
|
61 centralViewport_.HasAnimation()) |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
62 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
63 stopped_ = false; |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
64 updateThread_ = boost::thread(UpdateThread, this); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
65 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
66 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
67 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
68 |
291 | 69 void NativeStoneApplicationContext::Stop() |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
70 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
71 stopped_ = true; |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
72 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
73 if (updateThread_.joinable()) |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
74 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
75 updateThread_.join(); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
76 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
77 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
78 } |