comparison Applications/BasicApplicationContext.cpp @ 51:b340879da9bd

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Apr 2017 14:50:20 +0200
parents Framework/Applications/BasicApplicationContext.cpp@28956ed68280
children c2dc924f1a63 4cff7b1ed31d
comparison
equal deleted inserted replaced
49:c45f368de5c0 51:b340879da9bd
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017 Osimis, Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #include "BasicApplicationContext.h"
23
24 #include "../../Framework/Toolbox/OrthancSeriesLoader.h"
25 #include "../../Framework/Volumes/VolumeImageSimplePolicy.h"
26 #include "../../Framework/Volumes/VolumeImageProgressivePolicy.h"
27
28 namespace OrthancStone
29 {
30 BasicApplicationContext::BasicApplicationContext(OrthancPlugins::IOrthancConnection& orthanc) :
31 orthanc_(orthanc)
32 {
33 }
34
35
36 BasicApplicationContext::~BasicApplicationContext()
37 {
38 for (Interactors::iterator it = interactors_.begin(); it != interactors_.end(); ++it)
39 {
40 assert(*it != NULL);
41 delete *it;
42 }
43
44 for (Volumes::iterator it = volumes_.begin(); it != volumes_.end(); ++it)
45 {
46 assert(*it != NULL);
47 delete *it;
48 }
49
50 for (StructureSets::iterator it = structureSets_.begin(); it != structureSets_.end(); ++it)
51 {
52 assert(*it != NULL);
53 delete *it;
54 }
55 }
56
57
58 IWidget& BasicApplicationContext::SetCentralWidget(IWidget* widget) // Takes ownership
59 {
60 viewport_.SetCentralWidget(widget);
61 return *widget;
62 }
63
64
65 VolumeImage& BasicApplicationContext::AddSeriesVolume(const std::string& series,
66 bool isProgressiveDownload,
67 size_t downloadThreadCount)
68 {
69 std::auto_ptr<VolumeImage> volume(new VolumeImage(new OrthancSeriesLoader(orthanc_, series)));
70
71 if (isProgressiveDownload)
72 {
73 volume->SetDownloadPolicy(new VolumeImageProgressivePolicy);
74 }
75 else
76 {
77 volume->SetDownloadPolicy(new VolumeImageSimplePolicy);
78 }
79
80 volume->SetThreadCount(downloadThreadCount);
81
82 VolumeImage& result = *volume;
83 volumes_.push_back(volume.release());
84
85 return result;
86 }
87
88
89 DicomStructureSet& BasicApplicationContext::AddStructureSet(const std::string& instance)
90 {
91 std::auto_ptr<DicomStructureSet> structureSet(new DicomStructureSet(orthanc_, instance));
92
93 DicomStructureSet& result = *structureSet;
94 structureSets_.push_back(structureSet.release());
95
96 return result;
97 }
98
99
100 IWorldSceneInteractor& BasicApplicationContext::AddInteractor(IWorldSceneInteractor* interactor)
101 {
102 if (interactor == NULL)
103 {
104 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
105 }
106
107 interactors_.push_back(interactor);
108
109 return *interactor;
110 }
111
112
113 void BasicApplicationContext::Start()
114 {
115 for (Volumes::iterator it = volumes_.begin(); it != volumes_.end(); ++it)
116 {
117 assert(*it != NULL);
118 (*it)->Start();
119 }
120
121 viewport_.Start();
122 }
123
124
125 void BasicApplicationContext::Stop()
126 {
127 viewport_.Stop();
128
129 for (Volumes::iterator it = volumes_.begin(); it != volumes_.end(); ++it)
130 {
131 assert(*it != NULL);
132 (*it)->Stop();
133 }
134 }
135 }