annotate Applications/Sdl/BasicSdlApplicationContext.h @ 273:f21ba2468570 am-2

force all Widgets to have a name to ease debugging
author am@osimis.io
date Fri, 24 Aug 2018 11:26:59 +0200
parents 46c5296d867e
children
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 #pragma once
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
23
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
24 #include "../../Framework/Viewport/WidgetViewport.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
25 #include "../../Framework/Volumes/ISlicedVolume.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
26 #include "../../Framework/Volumes/IVolumeLoader.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
27
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
28 #include <list>
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
29 #include <boost/thread.hpp>
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
30 #include "../BasicApplicationContext.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
31
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
32 namespace OrthancStone
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
33 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
34 class BasicSdlApplicationContext : public BasicApplicationContext
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
35 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
36 private:
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
37
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
38 static void UpdateThread(BasicSdlApplicationContext* that);
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
39
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
40 boost::mutex globalMutex_;
233
68856534f005 added layout to VSOL, SDL & wasm working
am@osimis.io
parents: 222
diff changeset
41 std::unique_ptr<WidgetViewport> centralViewport_;
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
42 boost::thread updateThread_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
43 bool stopped_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
44 unsigned int updateDelay_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
45
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
46 public:
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
47 class GlobalMutexLocker: public boost::noncopyable
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
48 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
49 boost::mutex::scoped_lock lock_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
50 public:
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
51 GlobalMutexLocker(BasicSdlApplicationContext& that):
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
52 lock_(that.globalMutex_)
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
53 {}
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
54 };
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
55
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
56 // class ViewportLocker : public boost::noncopyable
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
57 // {
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
58 // private:
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
59 // boost::mutex::scoped_lock lock_;
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
60 // IViewport& viewport_;
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
61
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
62 // public:
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
63 // ViewportLocker(BasicSdlApplicationContext& that) :
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
64 // lock_(that.viewportMutex_),
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
65 // viewport_(*(that.centralViewport_.get()))
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
66 // {
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
67 // }
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
68
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
69 // IViewport& GetViewport() const
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
70 // {
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
71 // return viewport_;
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
72 // }
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
73 // };
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
74
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
75
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
76 BasicSdlApplicationContext();
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
77
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
78 virtual ~BasicSdlApplicationContext() {}
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
79
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
80 virtual IWidget& SetCentralWidget(IWidget* widget); // Takes ownership
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
81 IViewport& GetCentralViewport() {return *(centralViewport_.get());}
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
82
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
83 void Start();
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
84
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
85 void Stop();
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
86
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
87 void SetUpdateDelay(unsigned int delay) // In milliseconds
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
88 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
89 updateDelay_ = delay;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
90 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
91 };
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
92 }