Mercurial > hg > orthanc-stone
diff Applications/Samples/SingleFrameApplication.h @ 325:37ab9d83dc9b am-2
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
author | am@osimis.io |
---|---|
date | Tue, 16 Oct 2018 11:30:00 +0200 |
parents | ce4405d98b92 |
children | 612238b3f3e8 |
line wrap: on
line diff
--- a/Applications/Samples/SingleFrameApplication.h Tue Oct 16 08:59:23 2018 +0200 +++ b/Applications/Samples/SingleFrameApplication.h Tue Oct 16 11:30:00 2018 +0200 @@ -34,7 +34,7 @@ { class SingleFrameApplication : public SampleApplicationBase, - private ILayerSource::IObserver + public IObserver { private: class Interactor : public IWorldSceneInteractor @@ -51,6 +51,7 @@ virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget, const ViewportGeometry& view, MouseButton button, + KeyboardModifiers modifiers, double x, double y, IStatusBar* statusBar) @@ -148,7 +149,7 @@ slice_ = index; #if 1 - widget_->SetSlice(source_->GetSlice(slice_).GetGeometry()); + mainWidget_->SetSlice(source_->GetSlice(slice_).GetGeometry()); #else // TEST for scene extents - Rotate the axes double a = 15.0 / 180.0 * M_PI; @@ -169,46 +170,29 @@ } - virtual void NotifyGeometryReady(const ILayerSource& source) + void OnMainWidgetGeometryReady(const ILayerSource::GeometryReadyMessage& message) { // Once the geometry of the series is downloaded from Orthanc, - // display its first slice, and adapt the viewport to fit this + // display its middle slice, and adapt the viewport to fit this // slice - if (source_ == &source) + if (source_ == &message.origin_) { SetSlice(source_->GetSliceCount() / 2); } - widget_->SetDefaultView(); - } - - virtual void NotifyGeometryError(const ILayerSource& source) - { + mainWidget_->SetDefaultView(); } - virtual void NotifyContentChange(const ILayerSource& source) - { - } + LayerWidget* mainWidget_; // ownership is transfered to the application context + std::unique_ptr<Interactor> mainWidgetInteractor_; + std::unique_ptr<OrthancApiClient> orthancApiClient_; - virtual void NotifySliceChange(const ILayerSource& source, - const Slice& slice) - { - } - - virtual void NotifyLayerReady(std::auto_ptr<ILayerRenderer>& layer, - const ILayerSource& source, - const CoordinateSystem3D& slice, - bool isError) - { - } + const OrthancFrameLayerSource* source_; + unsigned int slice_; - LayerWidget* widget_; - const OrthancFrameLayerSource* source_; - unsigned int slice_; - public: - SingleFrameApplication() : - widget_(NULL), + SingleFrameApplication(MessageBroker& broker) : + IObserver(broker), source_(NULL), slice_(0) { @@ -229,11 +213,14 @@ options.add(generic); } - virtual void Initialize(IStatusBar& statusBar, + virtual void Initialize(StoneApplicationContext* context, + IStatusBar& statusBar, const boost::program_options::variables_map& parameters) { using namespace OrthancStone; + context_ = context; + statusBar.SetMessage("Use the key \"s\" to reinitialize the layout"); if (parameters.count("instance") != 1) @@ -245,17 +232,14 @@ std::string instance = parameters["instance"].as<std::string>(); int frame = parameters["frame"].as<unsigned int>(); - std::auto_ptr<LayerWidget> widget(new LayerWidget); + orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService())); + mainWidget_ = new LayerWidget(broker_, "main-widget"); -#if 1 - std::auto_ptr<OrthancFrameLayerSource> layer - (new OrthancFrameLayerSource(context_->GetWebService())); - //layer->SetImageQuality(SliceImageQuality_Jpeg50); + std::auto_ptr<OrthancFrameLayerSource> layer(new OrthancFrameLayerSource(broker_, *orthancApiClient_)); + source_ = layer.get(); layer->LoadFrame(instance, frame); - //layer->LoadSeries("6f1b492a-e181e200-44e51840-ef8db55e-af529ab6"); - layer->Register(*this); - source_ = layer.get(); - widget->AddLayer(layer.release()); + layer->RegisterObserverCallback(new Callable<SingleFrameApplication, ILayerSource::GeometryReadyMessage>(*this, &SingleFrameApplication::OnMainWidgetGeometryReady)); + mainWidget_->AddLayer(layer.release()); RenderStyle s; @@ -264,53 +248,17 @@ s.interpolation_ = ImageInterpolation_Bilinear; } - //s.drawGrid_ = true; - widget->SetLayerStyle(0, s); -#else - // 0178023P** - // Extent of the CT layer: (-35.068 -20.368) => (34.932 49.632) - std::auto_ptr<OrthancFrameLayerSource> ct; - ct.reset(new OrthancFrameLayerSource(context_->GetWebService())); - //ct->LoadInstance("c804a1a2-142545c9-33b32fe2-3df4cec0-a2bea6d6", 0); - //ct->LoadInstance("4bd4304f-47478948-71b24af2-51f4f1bc-275b6c1b", 0); // BAD SLICE - //ct->SetImageQuality(SliceImageQuality_Jpeg50); - ct->LoadSeries("dd069910-4f090474-7d2bba07-e5c10783-f9e4fb1d"); - - ct->Register(*this); - widget->AddLayer(ct.release()); - - std::auto_ptr<OrthancFrameLayerSource> pet; - pet.reset(new OrthancFrameLayerSource(context_->GetWebService())); - //pet->LoadInstance("a1c4dc6b-255d27f0-88069875-8daed730-2f5ee5c6", 0); - pet->LoadSeries("aabad2e7-80702b5d-e599d26c-4f13398e-38d58a9e"); - pet->Register(*this); - source_ = pet.get(); - widget->AddLayer(pet.release()); + mainWidget_->SetLayerStyle(0, s); + mainWidget_->SetTransmitMouseOver(true); - { - RenderStyle s; - //s.drawGrid_ = true; - s.alpha_ = 1; - widget->SetLayerStyle(0, s); - } + mainWidgetInteractor_.reset(new Interactor(*this)); + mainWidget_->SetInteractor(*mainWidgetInteractor_); + } - { - RenderStyle s; - //s.drawGrid_ = true; - s.SetColor(255, 0, 0); // Draw missing PET layer in red - s.alpha_ = 0.5; - s.applyLut_ = true; - s.lut_ = Orthanc::EmbeddedResources::COLORMAP_JET; - s.interpolation_ = ImageInterpolation_Bilinear; - widget->SetLayerStyle(1, s); - } -#endif + virtual void Finalize() {} + virtual IWidget* GetCentralWidget() {return mainWidget_;} + }; - widget_ = widget.get(); - widget_->SetTransmitMouseOver(true); - widget_->SetInteractor(context_->AddInteractor(new Interactor(*this))); - context_->SetCentralWidget(widget.release()); - } - }; + } }