annotate Applications/Generic/NativeStoneApplicationContext.cpp @ 1013:53cc787bd7bc toa2019092301

- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced the ProjectPoint method because more tests need to be written. - ProjectPointOntoPlane2 is a faster version of GeometryToolbox::ProjectPointOntoPlane. Same remark as above. - DicomStructureSet.cpp now uses this optimized call.
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 23 Sep 2019 15:18:33 +0200
parents 4f2416d519b4
children e146743f6cdc 2d8ab34c8c91
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
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 418
diff changeset
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
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 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 516
diff changeset
27 Deprecated::IWidget& NativeStoneApplicationContext::GlobalMutexLocker::SetCentralWidget(Deprecated::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) :
418
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 386
diff changeset
49 StoneApplicationContext(broker),
385
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 {
516
11fa6f00e33c Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 440
diff changeset
54 srand(static_cast<unsigned int>(time(NULL)));
274
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 {
433
8999823db8b8 fix SetSize in SDL
am@osimis.io
parents: 418
diff changeset
60 boost::recursive_mutex::scoped_lock lock(globalMutex_);
385
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 }