# HG changeset patch # User Sebastien Jodogne # Date 1539883754 -7200 # Node ID c7fdc8bac581b51b418b0954f172da4bb2be416d # Parent 3e42fc27eb919b33cd5c26334289e6b1aef1e2a0 creating GrayscaleBitmapStack diff -r 3e42fc27eb91 -r c7fdc8bac581 Applications/Samples/SampleApplicationBase.h --- 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, diff -r 3e42fc27eb91 -r c7fdc8bac581 Applications/Samples/SimpleViewerApplicationSingleFile.h --- 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(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(mainWidget_); + smartLoader_->SetFrameInWidget(widget, 0, instancesIdsPerSeriesId_[seriesId][0], 0); } virtual void OnPushButton1Clicked() {} diff -r 3e42fc27eb91 -r c7fdc8bac581 Applications/Samples/SingleFrameApplication.h --- 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(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 mainWidgetInteractor_; @@ -238,7 +244,7 @@ source_ = layer.get(); layer->LoadFrame(instance, frame); layer->RegisterObserverCallback(new Callable(*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_); } }; diff -r 3e42fc27eb91 -r c7fdc8bac581 Applications/Samples/SingleFrameEditorApplication.h --- 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 namespace OrthancStone { + + class GrayscaleBitmapStack : + public WorldSceneWidget, + public IObservable + { + public: + typedef OriginMessage GeometryChangedMessage; + typedef OriginMessage 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(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(); orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService())); - mainWidget_ = new LayerWidget(broker_, "main-widget"); + mainWidget_ = new GrayscaleBitmapStack(broker_, "main-widget"); - std::auto_ptr layer(new OrthancFrameLayerSource(broker_, *orthancApiClient_)); - source_ = layer.get(); - layer->LoadFrame(instance, frame); - mainWidget_->RegisterObserverCallback(new Callable(*this, &SingleFrameEditorApplication::OnGeometryChanged)); - mainWidget_->AddLayer(layer.release()); + dynamic_cast(mainWidget_)->RegisterObserverCallback( + new Callable + (*this, &SingleFrameEditorApplication::OnGeometryChanged)); mainWidget_->SetTransmitMouseOver(true);