Mercurial > hg > orthanc-stone
comparison Applications/Samples/SingleFrameApplication.h @ 1068:04a95ee91327 broker
recovery of OrthancStoneSingleFrame
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 15 Oct 2019 19:36:57 +0200 |
parents | b537002f83a9 |
children | 5d1b0d2f4b15 |
comparison
equal
deleted
inserted
replaced
1067:05b2e71ed145 | 1068:04a95ee91327 |
---|---|
125 }; | 125 }; |
126 | 126 |
127 | 127 |
128 void OffsetSlice(int offset) | 128 void OffsetSlice(int offset) |
129 { | 129 { |
130 if (source_ != NULL) | 130 if (source_) |
131 { | 131 { |
132 int slice = static_cast<int>(slice_) + offset; | 132 int slice = static_cast<int>(slice_) + offset; |
133 | 133 |
134 if (slice < 0) | 134 if (slice < 0) |
135 { | 135 { |
147 } | 147 } |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 | 151 |
152 Deprecated::SliceViewerWidget& GetMainWidget() | |
153 { | |
154 return *dynamic_cast<Deprecated::SliceViewerWidget*>(mainWidget_); | |
155 } | |
156 | |
157 | |
158 void SetSlice(size_t index) | 152 void SetSlice(size_t index) |
159 { | 153 { |
160 if (source_ != NULL && | 154 if (source_ && |
161 index < source_->GetSlicesCount()) | 155 index < source_->GetSlicesCount()) |
162 { | 156 { |
163 slice_ = static_cast<unsigned int>(index); | 157 slice_ = static_cast<unsigned int>(index); |
164 | 158 |
165 #if 1 | 159 #if 1 |
166 GetMainWidget().SetSlice(source_->GetSlice(slice_).GetGeometry()); | 160 widget_->SetSlice(source_->GetSlice(slice_).GetGeometry()); |
167 #else | 161 #else |
168 // TEST for scene extents - Rotate the axes | 162 // TEST for scene extents - Rotate the axes |
169 double a = 15.0 / 180.0 * boost::math::constants::pi<double>(); | 163 double a = 15.0 / 180.0 * boost::math::constants::pi<double>(); |
170 | 164 |
171 #if 1 | 165 #if 1 |
187 void OnMainWidgetGeometryReady(const Deprecated::IVolumeSlicer::GeometryReadyMessage& message) | 181 void OnMainWidgetGeometryReady(const Deprecated::IVolumeSlicer::GeometryReadyMessage& message) |
188 { | 182 { |
189 // Once the geometry of the series is downloaded from Orthanc, | 183 // Once the geometry of the series is downloaded from Orthanc, |
190 // display its middle slice, and adapt the viewport to fit this | 184 // display its middle slice, and adapt the viewport to fit this |
191 // slice | 185 // slice |
192 if (source_ == &message.GetOrigin()) | 186 if (source_ && |
187 source_.get() == &message.GetOrigin()) | |
193 { | 188 { |
194 SetSlice(source_->GetSlicesCount() / 2); | 189 SetSlice(source_->GetSlicesCount() / 2); |
195 } | 190 } |
196 | 191 |
197 GetMainWidget().FitContent(); | 192 widget_->FitContent(); |
198 } | 193 } |
199 | 194 |
195 boost::shared_ptr<Deprecated::SliceViewerWidget> widget_; | |
200 std::auto_ptr<Interactor> mainWidgetInteractor_; | 196 std::auto_ptr<Interactor> mainWidgetInteractor_; |
201 const Deprecated::DicomSeriesVolumeSlicer* source_; | 197 boost::shared_ptr<Deprecated::DicomSeriesVolumeSlicer> source_; |
202 unsigned int slice_; | 198 unsigned int slice_; |
203 | 199 |
204 public: | 200 public: |
205 SingleFrameApplication() : | 201 SingleFrameApplication() : |
206 source_(NULL), | |
207 slice_(0) | 202 slice_(0) |
208 { | 203 { |
209 } | 204 } |
210 | 205 |
211 virtual void DeclareStartupOptions(boost::program_options::options_description& options) | 206 virtual void DeclareStartupOptions(boost::program_options::options_description& options) |
240 } | 235 } |
241 | 236 |
242 std::string instance = parameters["instance"].as<std::string>(); | 237 std::string instance = parameters["instance"].as<std::string>(); |
243 int frame = parameters["frame"].as<unsigned int>(); | 238 int frame = parameters["frame"].as<unsigned int>(); |
244 | 239 |
245 mainWidget_ = new Deprecated::SliceViewerWidget("main-widget"); | 240 widget_.reset(new Deprecated::SliceViewerWidget("main-widget")); |
246 | 241 mainWidget_ = widget_.get(); // TODO - awful |
247 std::auto_ptr<Deprecated::DicomSeriesVolumeSlicer> layer(new Deprecated::DicomSeriesVolumeSlicer(context->GetOrthancApiClient())); | 242 |
248 source_ = layer.get(); | 243 boost::shared_ptr<Deprecated::DicomSeriesVolumeSlicer> layer(new Deprecated::DicomSeriesVolumeSlicer); |
244 layer->Connect(context->GetOrthancApiClient()); | |
245 source_ = layer; | |
249 layer->LoadFrame(instance, frame); | 246 layer->LoadFrame(instance, frame); |
250 Register<Deprecated::IVolumeSlicer::GeometryReadyMessage>(*layer, &SingleFrameApplication::OnMainWidgetGeometryReady); | 247 Register<Deprecated::IVolumeSlicer::GeometryReadyMessage>(*layer, &SingleFrameApplication::OnMainWidgetGeometryReady); |
251 GetMainWidget().AddLayer(layer.release()); | 248 widget_->AddLayer(layer); |
252 | 249 |
253 Deprecated::RenderStyle s; | 250 Deprecated::RenderStyle s; |
254 | 251 |
255 if (parameters["smooth"].as<bool>()) | 252 if (parameters["smooth"].as<bool>()) |
256 { | 253 { |
257 s.interpolation_ = ImageInterpolation_Bilinear; | 254 s.interpolation_ = ImageInterpolation_Bilinear; |
258 } | 255 } |
259 | 256 |
260 GetMainWidget().SetLayerStyle(0, s); | 257 widget_->SetLayerStyle(0, s); |
261 GetMainWidget().SetTransmitMouseOver(true); | 258 widget_->SetTransmitMouseOver(true); |
262 | 259 |
263 mainWidgetInteractor_.reset(new Interactor(*this)); | 260 mainWidgetInteractor_.reset(new Interactor(*this)); |
264 GetMainWidget().SetInteractor(*mainWidgetInteractor_); | 261 widget_->SetInteractor(*mainWidgetInteractor_); |
265 } | 262 } |
266 }; | 263 }; |
267 | 264 |
268 | 265 |
269 } | 266 } |