annotate Applications/Generic/NativeStoneApplicationContext.cpp @ 386:e33659decec5

renamed UpdateContent() as DoAnimation()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Nov 2018 17:06:28 +0100
parents 6cc3ce74dc05
children c23df8b3433b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
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
87376a645ee1 renaming
am@osimis.io
parents: 277
diff changeset
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 {
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
27 IWidget& NativeStoneApplicationContext::GlobalMutexLocker::SetCentralWidget(IWidget* widget)
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
28 {
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
29 that_.centralViewport_.SetCentralWidget(widget);
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
30 return *widget;
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
87376a645ee1 renaming
am@osimis.io
parents: 277
diff changeset
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
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 274
diff changeset
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
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
48 NativeStoneApplicationContext::NativeStoneApplicationContext(MessageBroker& broker) :
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
49 broker_(broker),
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
50 centralViewport_(broker),
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
51 stopped_(true),
277
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 274
diff changeset
52 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
53 {
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
54 srand(time(NULL));
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
55 }
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
56
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
57
291
87376a645ee1 renaming
am@osimis.io
parents: 277
diff changeset
58 void NativeStoneApplicationContext::Start()
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
59 {
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
60 boost::mutex::scoped_lock lock(globalMutex_);
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
61
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
62 if (stopped_ &&
386
e33659decec5 renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 385
diff changeset
63 centralViewport_.HasAnimation())
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
64 {
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
65 stopped_ = false;
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
66 updateThread_ = boost::thread(UpdateThread, this);
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 }
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
69
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
70
291
87376a645ee1 renaming
am@osimis.io
parents: 277
diff changeset
71 void NativeStoneApplicationContext::Stop()
274
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 stopped_ = true;
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 if (updateThread_.joinable())
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 updateThread_.join();
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 }
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
80 }