Mercurial > hg > orthanc-stone
changeset 336:c7fdc8bac581 am-2
creating GrayscaleBitmapStack
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 18 Oct 2018 19:29:14 +0200 |
parents | 3e42fc27eb91 |
children | c4d4213f095c |
files | Applications/Samples/SampleApplicationBase.h Applications/Samples/SimpleViewerApplicationSingleFile.h Applications/Samples/SingleFrameApplication.h Applications/Samples/SingleFrameEditorApplication.h |
diffstat | 4 files changed, 57 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Samples/SampleApplicationBase.h Thu Oct 18 10:54:46 2018 +0200 +++ b/Applications/Samples/SampleApplicationBase.h Thu Oct 18 19:29:14 2018 +0200 @@ -22,7 +22,7 @@ #pragma once #include "../../Applications/IStoneApplication.h" -#include "../../Framework/Widgets/LayerWidget.h" +#include "../../Framework/Widgets/WorldSceneWidget.h" #if ORTHANC_ENABLE_WASM==1 #include "../../Platforms/Wasm/WasmPlatformApplicationAdapter.h" @@ -42,7 +42,7 @@ { protected: BaseCommandBuilder commandBuilder_; - LayerWidget* mainWidget_; // ownership is transfered to the application context + WorldSceneWidget* mainWidget_; // ownership is transfered to the application context public: virtual void Initialize(StoneApplicationContext* context,
--- a/Applications/Samples/SimpleViewerApplicationSingleFile.h Thu Oct 18 10:54:46 2018 +0200 +++ b/Applications/Samples/SimpleViewerApplicationSingleFile.h Thu Oct 18 19:29:14 2018 +0200 @@ -351,9 +351,10 @@ LoadThumbnailForSeries(seriesId, instancesIdsPerSeriesId_[seriesId][0]); // if this is the first thumbnail loaded, load the first instance in the mainWidget - if (mainWidget_->GetLayerCount() == 0) + LayerWidget& widget = *dynamic_cast<LayerWidget*>(mainWidget_); + if (widget.GetLayerCount() == 0) { - smartLoader_->SetFrameInWidget(*mainWidget_, 0, instancesIdsPerSeriesId_[seriesId][0], 0); + smartLoader_->SetFrameInWidget(widget, 0, instancesIdsPerSeriesId_[seriesId][0], 0); } } } @@ -381,7 +382,8 @@ void SelectSeriesInMainViewport(const std::string& seriesId) { - smartLoader_->SetFrameInWidget(*mainWidget_, 0, instancesIdsPerSeriesId_[seriesId][0], 0); + LayerWidget& widget = *dynamic_cast<LayerWidget*>(mainWidget_); + smartLoader_->SetFrameInWidget(widget, 0, instancesIdsPerSeriesId_[seriesId][0], 0); } virtual void OnPushButton1Clicked() {}
--- a/Applications/Samples/SingleFrameApplication.h Thu Oct 18 10:54:46 2018 +0200 +++ b/Applications/Samples/SingleFrameApplication.h Thu Oct 18 19:29:14 2018 +0200 @@ -140,6 +140,12 @@ } } } + + + LayerWidget& GetMainWidget() + { + return *dynamic_cast<LayerWidget*>(mainWidget_); + } void SetSlice(size_t index) @@ -150,7 +156,7 @@ slice_ = index; #if 1 - mainWidget_->SetSlice(source_->GetSlice(slice_).GetGeometry()); + GetMainWidget().SetSlice(source_->GetSlice(slice_).GetGeometry()); #else // TEST for scene extents - Rotate the axes double a = 15.0 / 180.0 * M_PI; @@ -181,7 +187,7 @@ SetSlice(source_->GetSliceCount() / 2); } - mainWidget_->FitContent(); + GetMainWidget().FitContent(); } std::auto_ptr<Interactor> mainWidgetInteractor_; @@ -238,7 +244,7 @@ source_ = layer.get(); layer->LoadFrame(instance, frame); layer->RegisterObserverCallback(new Callable<SingleFrameApplication, ILayerSource::GeometryReadyMessage>(*this, &SingleFrameApplication::OnMainWidgetGeometryReady)); - mainWidget_->AddLayer(layer.release()); + GetMainWidget().AddLayer(layer.release()); RenderStyle s; @@ -247,11 +253,11 @@ s.interpolation_ = ImageInterpolation_Bilinear; } - mainWidget_->SetLayerStyle(0, s); - mainWidget_->SetTransmitMouseOver(true); + GetMainWidget().SetLayerStyle(0, s); + GetMainWidget().SetTransmitMouseOver(true); mainWidgetInteractor_.reset(new Interactor(*this)); - mainWidget_->SetInteractor(*mainWidgetInteractor_); + GetMainWidget().SetInteractor(*mainWidgetInteractor_); } };
--- a/Applications/Samples/SingleFrameEditorApplication.h Thu Oct 18 10:54:46 2018 +0200 +++ b/Applications/Samples/SingleFrameEditorApplication.h Thu Oct 18 19:29:14 2018 +0200 @@ -24,12 +24,41 @@ #include "SampleApplicationBase.h" #include "../../Framework/Layers/OrthancFrameLayerSource.h" -#include "../../Framework/Widgets/LayerWidget.h" #include <Core/Logging.h> namespace OrthancStone { + + class GrayscaleBitmapStack : + public WorldSceneWidget, + public IObservable + { + public: + typedef OriginMessage<MessageType_Widget_GeometryChanged, GrayscaleBitmapStack> GeometryChangedMessage; + typedef OriginMessage<MessageType_Widget_ContentChanged, GrayscaleBitmapStack> ContentChangedMessage; + + protected: + virtual Extent2D GetSceneExtent() + { + } + + virtual bool RenderScene(CairoContext& context, + const ViewportGeometry& view) + { + } + + public: + GrayscaleBitmapStack(MessageBroker& broker, + const std::string& name) : + WorldSceneWidget(name), + IObservable(broker) + { + } + + }; + + namespace Samples { class SingleFrameEditorApplication : @@ -94,12 +123,9 @@ { if (statusBar != NULL) { - Vector p = dynamic_cast<LayerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y); - char buf[64]; - sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)", - p[0] / 10.0, p[1] / 10.0, p[2] / 10.0); - //statusBar->SetMessage(buf); + sprintf(buf, "X = %.02f Y = %.02f (in cm)", x / 10.0, y / 10.0); + statusBar->SetMessage(buf); } } @@ -151,9 +177,8 @@ } }; - void OnGeometryChanged(const LayerWidget::GeometryChangedMessage& message) + void OnGeometryChanged(const GrayscaleBitmapStack::GeometryChangedMessage& message) { - mainWidget_->SetSlice(source_->GetSlice(slice_).GetGeometry()); mainWidget_->FitContent(); } @@ -205,13 +230,12 @@ int frame = parameters["frame"].as<unsigned int>(); orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService())); - mainWidget_ = new LayerWidget(broker_, "main-widget"); + mainWidget_ = new GrayscaleBitmapStack(broker_, "main-widget"); - std::auto_ptr<OrthancFrameLayerSource> layer(new OrthancFrameLayerSource(broker_, *orthancApiClient_)); - source_ = layer.get(); - layer->LoadFrame(instance, frame); - mainWidget_->RegisterObserverCallback(new Callable<SingleFrameEditorApplication, LayerWidget::GeometryChangedMessage>(*this, &SingleFrameEditorApplication::OnGeometryChanged)); - mainWidget_->AddLayer(layer.release()); + dynamic_cast<GrayscaleBitmapStack*>(mainWidget_)->RegisterObserverCallback( + new Callable<SingleFrameEditorApplication, + GrayscaleBitmapStack::GeometryChangedMessage> + (*this, &SingleFrameEditorApplication::OnGeometryChanged)); mainWidget_->SetTransmitMouseOver(true);