Mercurial > hg > orthanc-stone
comparison Applications/BasicApplicationContext.h @ 53:c2dc924f1a63 wasm
removing threading out of the framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Apr 2017 16:57:49 +0200 |
parents | b340879da9bd |
children | d20e25cfcf3a |
comparison
equal
deleted
inserted
replaced
52:37e504582af6 | 53:c2dc924f1a63 |
---|---|
25 #include "../../Framework/Viewport/WidgetViewport.h" | 25 #include "../../Framework/Viewport/WidgetViewport.h" |
26 #include "../../Framework/Widgets/IWorldSceneInteractor.h" | 26 #include "../../Framework/Widgets/IWorldSceneInteractor.h" |
27 #include "../../Framework/Toolbox/DicomStructureSet.h" | 27 #include "../../Framework/Toolbox/DicomStructureSet.h" |
28 | 28 |
29 #include <list> | 29 #include <list> |
30 #include <boost/thread.hpp> | |
30 | 31 |
31 namespace OrthancStone | 32 namespace OrthancStone |
32 { | 33 { |
33 class BasicApplicationContext : public boost::noncopyable | 34 class BasicApplicationContext : public boost::noncopyable |
34 { | 35 { |
35 private: | 36 private: |
36 typedef std::list<ISliceableVolume*> Volumes; | 37 typedef std::list<ISliceableVolume*> Volumes; |
37 typedef std::list<IWorldSceneInteractor*> Interactors; | 38 typedef std::list<IWorldSceneInteractor*> Interactors; |
38 typedef std::list<DicomStructureSet*> StructureSets; | 39 typedef std::list<DicomStructureSet*> StructureSets; |
39 | 40 |
41 static void UpdateThread(BasicApplicationContext* that); | |
42 | |
40 OrthancPlugins::IOrthancConnection& orthanc_; | 43 OrthancPlugins::IOrthancConnection& orthanc_; |
41 | 44 |
45 boost::mutex viewportMutex_; | |
42 WidgetViewport viewport_; | 46 WidgetViewport viewport_; |
43 Volumes volumes_; | 47 Volumes volumes_; |
44 Interactors interactors_; | 48 Interactors interactors_; |
45 StructureSets structureSets_; | 49 StructureSets structureSets_; |
50 boost::thread updateThread_; | |
51 bool stopped_; | |
52 unsigned int updateDelay_; | |
46 | 53 |
47 public: | 54 public: |
55 class ViewportLocker : public boost::noncopyable | |
56 { | |
57 private: | |
58 boost::mutex::scoped_lock lock_; | |
59 IViewport& viewport_; | |
60 | |
61 public: | |
62 ViewportLocker(BasicApplicationContext& that) : | |
63 lock_(that.viewportMutex_), | |
64 viewport_(that.viewport_) | |
65 { | |
66 } | |
67 | |
68 IViewport& GetViewport() const | |
69 { | |
70 return viewport_; | |
71 } | |
72 }; | |
73 | |
74 | |
48 BasicApplicationContext(OrthancPlugins::IOrthancConnection& orthanc); | 75 BasicApplicationContext(OrthancPlugins::IOrthancConnection& orthanc); |
49 | 76 |
50 ~BasicApplicationContext(); | 77 ~BasicApplicationContext(); |
51 | 78 |
52 IWidget& SetCentralWidget(IWidget* widget); // Takes ownership | 79 IWidget& SetCentralWidget(IWidget* widget); // Takes ownership |
53 | |
54 IViewport& GetViewport() | |
55 { | |
56 return viewport_; | |
57 } | |
58 | 80 |
59 OrthancPlugins::IOrthancConnection& GetOrthancConnection() | 81 OrthancPlugins::IOrthancConnection& GetOrthancConnection() |
60 { | 82 { |
61 return orthanc_; | 83 return orthanc_; |
62 } | 84 } |
70 IWorldSceneInteractor& AddInteractor(IWorldSceneInteractor* interactor); | 92 IWorldSceneInteractor& AddInteractor(IWorldSceneInteractor* interactor); |
71 | 93 |
72 void Start(); | 94 void Start(); |
73 | 95 |
74 void Stop(); | 96 void Stop(); |
97 | |
98 void SetUpdateDelay(unsigned int delay) // In milliseconds | |
99 { | |
100 updateDelay_ = delay; | |
101 } | |
75 }; | 102 }; |
76 } | 103 } |