Mercurial > hg > orthanc-stone
annotate Framework/Applications/BasicApplicationContext.cpp @ 40:7207a407bcd8
shared copyright with osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 04 Jan 2017 16:37:42 +0100 |
parents | 9aace933cb64 |
children | 28956ed68280 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
40
7207a407bcd8
shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
31
diff
changeset
|
5 * Copyright (C) 2017 Osimis, Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #include "BasicApplicationContext.h" | |
35 | |
36 #include "../Toolbox/OrthancSeriesLoader.h" | |
37 #include "../Volumes/VolumeImageSimplePolicy.h" | |
38 #include "../Volumes/VolumeImageProgressivePolicy.h" | |
39 | |
40 namespace OrthancStone | |
41 { | |
31
9aace933cb64
sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
42 BasicApplicationContext::BasicApplicationContext(OrthancPlugins::IOrthancConnection& orthanc) : |
0 | 43 orthanc_(orthanc) |
44 { | |
45 } | |
46 | |
47 | |
48 BasicApplicationContext::~BasicApplicationContext() | |
49 { | |
50 for (Interactors::iterator it = interactors_.begin(); it != interactors_.end(); ++it) | |
51 { | |
52 assert(*it != NULL); | |
53 delete *it; | |
54 } | |
55 | |
56 for (Volumes::iterator it = volumes_.begin(); it != volumes_.end(); ++it) | |
57 { | |
58 assert(*it != NULL); | |
59 delete *it; | |
60 } | |
61 | |
62 for (StructureSets::iterator it = structureSets_.begin(); it != structureSets_.end(); ++it) | |
63 { | |
64 assert(*it != NULL); | |
65 delete *it; | |
66 } | |
67 } | |
68 | |
69 | |
70 IWidget& BasicApplicationContext::SetCentralWidget(IWidget* widget) // Takes ownership | |
71 { | |
72 viewport_.SetCentralWidget(widget); | |
73 return *widget; | |
74 } | |
75 | |
76 | |
77 VolumeImage& BasicApplicationContext::AddSeriesVolume(const std::string& series, | |
78 bool isProgressiveDownload, | |
79 size_t downloadThreadCount) | |
80 { | |
81 std::auto_ptr<VolumeImage> volume(new VolumeImage(new OrthancSeriesLoader(orthanc_, series))); | |
82 | |
83 if (isProgressiveDownload) | |
84 { | |
85 volume->SetDownloadPolicy(new VolumeImageProgressivePolicy); | |
86 } | |
87 else | |
88 { | |
89 volume->SetDownloadPolicy(new VolumeImageSimplePolicy); | |
90 } | |
91 | |
92 volume->SetThreadCount(downloadThreadCount); | |
93 | |
94 VolumeImage& result = *volume; | |
95 volumes_.push_back(volume.release()); | |
96 | |
97 return result; | |
98 } | |
99 | |
100 | |
101 DicomStructureSet& BasicApplicationContext::AddStructureSet(const std::string& instance) | |
102 { | |
103 std::auto_ptr<DicomStructureSet> structureSet(new DicomStructureSet(orthanc_, instance)); | |
104 | |
105 DicomStructureSet& result = *structureSet; | |
106 structureSets_.push_back(structureSet.release()); | |
107 | |
108 return result; | |
109 } | |
110 | |
111 | |
112 IWorldSceneInteractor& BasicApplicationContext::AddInteractor(IWorldSceneInteractor* interactor) | |
113 { | |
114 if (interactor == NULL) | |
115 { | |
116 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
117 } | |
118 | |
119 interactors_.push_back(interactor); | |
120 | |
121 return *interactor; | |
122 } | |
123 | |
124 | |
125 void BasicApplicationContext::Start() | |
126 { | |
127 for (Volumes::iterator it = volumes_.begin(); it != volumes_.end(); ++it) | |
128 { | |
129 assert(*it != NULL); | |
130 (*it)->Start(); | |
131 } | |
132 | |
133 viewport_.Start(); | |
134 } | |
135 | |
136 | |
137 void BasicApplicationContext::Stop() | |
138 { | |
139 viewport_.Stop(); | |
140 | |
141 for (Volumes::iterator it = volumes_.begin(); it != volumes_.end(); ++it) | |
142 { | |
143 assert(*it != NULL); | |
144 (*it)->Stop(); | |
145 } | |
146 } | |
147 } |