annotate Applications/Sdl/BasicSdlApplicationContext.cpp @ 261:58ad26032bd6 am-2

removed unused file
author am@osimis.io
date Tue, 17 Jul 2018 14:44:26 +0200
parents 092db46c6291
children 46c5296d867e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
1 /**
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
2 * Stone of Orthanc
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
6 *
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
10 * the License, or (at your option) any later version.
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
11 *
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
15 * Affero General Public License for more details.
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
16 *
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
19 **/
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
20
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
21
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
22 #include "BasicSdlApplicationContext.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
23
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
24 namespace OrthancStone
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
25 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
26 IWidget& BasicSdlApplicationContext::SetCentralWidget(IWidget* widget) // Takes ownership
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
27 {
233
68856534f005 added layout to VSOL, SDL & wasm working
am@osimis.io
parents: 222
diff changeset
28 centralViewport_->SetCentralWidget(widget);
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
29 return *widget;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
30 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
31
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
32
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
33 void BasicSdlApplicationContext::UpdateThread(BasicSdlApplicationContext* that)
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
34 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
35 while (!that->stopped_)
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
36 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
37 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
38 ViewportLocker locker(*that);
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
39 locker.GetViewport().UpdateContent();
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
40 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
41
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
42 boost::this_thread::sleep(boost::posix_time::milliseconds(that->updateDelay_));
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
43 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
44 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
45
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
46
242
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 233
diff changeset
47 BasicSdlApplicationContext::BasicSdlApplicationContext(OracleWebService& webService) : // Orthanc::WebServiceParameters& orthanc, WidgetViewport* centralViewport) :
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 233
diff changeset
48 BasicApplicationContext(webService),
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 233
diff changeset
49 oracleWebService_(&webService),
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 233
diff changeset
50 // oracle_(viewportMutex_, 4), // Use 4 threads to download
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 233
diff changeset
51 // webService_(oracle_, orthanc),
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 233
diff changeset
52 // centralViewport_(centralViewport),
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 233
diff changeset
53 centralViewport_(new OrthancStone::WidgetViewport()),
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
54 stopped_(true),
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
55 updateDelay_(100) // By default, 100ms between each refresh of the content
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
56 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
57 srand(time(NULL));
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
58 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
59
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
60
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
61 void BasicSdlApplicationContext::Start()
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
62 {
242
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 233
diff changeset
63 oracleWebService_->Start();
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
64
233
68856534f005 added layout to VSOL, SDL & wasm working
am@osimis.io
parents: 222
diff changeset
65 if (centralViewport_->HasUpdateContent())
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
66 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
67 stopped_ = false;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
68 updateThread_ = boost::thread(UpdateThread, this);
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
69 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
70 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
71
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
72
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
73 void BasicSdlApplicationContext::Stop()
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
74 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
75 stopped_ = true;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
76
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
77 if (updateThread_.joinable())
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
78 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
79 updateThread_.join();
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
80 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
81
242
092db46c6291 improved SDL/Wasm unification
am@osimis.io
parents: 233
diff changeset
82 oracleWebService_->Stop();
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
83 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
84 }