Mercurial > hg > orthanc-stone
comparison Applications/BasicApplicationContext.cpp @ 221:d7b2590744f8 am
wip: building applications reusable in SDL and WASM
author | am@osimis.io |
---|---|
date | Mon, 11 Jun 2018 14:01:02 +0200 |
parents | fccffbf99ba1 |
children | 84844649a8fd |
comparison
equal
deleted
inserted
replaced
219:26e3bfe30e66 | 221:d7b2590744f8 |
---|---|
46 { | 46 { |
47 srand(time(NULL)); | 47 srand(time(NULL)); |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 BasicApplicationContext::~BasicApplicationContext() | |
52 { | |
53 for (Interactors::iterator it = interactors_.begin(); it != interactors_.end(); ++it) | |
54 { | |
55 assert(*it != NULL); | |
56 delete *it; | |
57 } | |
58 | |
59 for (SlicedVolumes::iterator it = slicedVolumes_.begin(); it != slicedVolumes_.end(); ++it) | |
60 { | |
61 assert(*it != NULL); | |
62 delete *it; | |
63 } | |
64 | |
65 for (VolumeLoaders::iterator it = volumeLoaders_.begin(); it != volumeLoaders_.end(); ++it) | |
66 { | |
67 assert(*it != NULL); | |
68 delete *it; | |
69 } | |
70 } | |
71 | |
72 | |
73 IWidget& BasicApplicationContext::SetCentralWidget(IWidget* widget) // Takes ownership | 51 IWidget& BasicApplicationContext::SetCentralWidget(IWidget* widget) // Takes ownership |
74 { | 52 { |
75 viewport_.SetCentralWidget(widget); | 53 centralViewport_.SetCentralWidget(widget); |
76 return *widget; | 54 return *widget; |
77 } | |
78 | |
79 | |
80 ISlicedVolume& BasicApplicationContext::AddSlicedVolume(ISlicedVolume* volume) | |
81 { | |
82 if (volume == NULL) | |
83 { | |
84 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
85 } | |
86 else | |
87 { | |
88 slicedVolumes_.push_back(volume); | |
89 return *volume; | |
90 } | |
91 } | |
92 | |
93 | |
94 IVolumeLoader& BasicApplicationContext::AddVolumeLoader(IVolumeLoader* loader) | |
95 { | |
96 if (loader == NULL) | |
97 { | |
98 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
99 } | |
100 else | |
101 { | |
102 volumeLoaders_.push_back(loader); | |
103 return *loader; | |
104 } | |
105 } | |
106 | |
107 | |
108 IWorldSceneInteractor& BasicApplicationContext::AddInteractor(IWorldSceneInteractor* interactor) | |
109 { | |
110 if (interactor == NULL) | |
111 { | |
112 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
113 } | |
114 | |
115 interactors_.push_back(interactor); | |
116 | |
117 return *interactor; | |
118 } | 55 } |
119 | 56 |
120 | 57 |
121 void BasicApplicationContext::Start() | 58 void BasicApplicationContext::Start() |
122 { | 59 { |
123 oracle_.Start(); | 60 oracle_.Start(); |
124 | 61 |
125 if (viewport_.HasUpdateContent()) | 62 if (centralViewport_.HasUpdateContent()) |
126 { | 63 { |
127 stopped_ = false; | 64 stopped_ = false; |
128 updateThread_ = boost::thread(UpdateThread, this); | 65 updateThread_ = boost::thread(UpdateThread, this); |
129 } | 66 } |
130 } | 67 } |