# HG changeset patch # User am@osimis.io # Date 1535102819 -7200 # Node ID f21ba24685702cd4155bc75f0fa7ea49fa6d17b3 # Parent d7d91d96b9d86f39cf75e037a49c2418b6cd1a2b force all Widgets to have a name to ease debugging diff -r d7d91d96b9d8 -r f21ba2468570 Applications/Samples/SimpleViewerApplication.h --- a/Applications/Samples/SimpleViewerApplication.h Fri Aug 24 09:11:06 2018 +0200 +++ b/Applications/Samples/SimpleViewerApplication.h Fri Aug 24 11:26:59 2018 +0200 @@ -40,6 +40,51 @@ public IObserver { private: + class ThumbnailInteractor : public IWorldSceneInteractor + { + private: + SimpleViewerApplication& application_; + public: + ThumbnailInteractor(SimpleViewerApplication& application) : + application_(application) + { + } + + virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget, + const ViewportGeometry& view, + MouseButton button, + double x, + double y, + IStatusBar* statusBar) + { + if (button == MouseButton_Left) + { + statusBar->SetMessage("trying to drag the thumbnail from " + widget.GetName()); + } + return NULL; + } + virtual void MouseOver(CairoContext& context, + WorldSceneWidget& widget, + const ViewportGeometry& view, + double x, + double y, + IStatusBar* statusBar) + {} + + virtual void MouseWheel(WorldSceneWidget& widget, + MouseWheelDirection direction, + KeyboardModifiers modifiers, + IStatusBar* statusBar) + {} + + virtual void KeyPressed(WorldSceneWidget& widget, + char key, + KeyboardModifiers modifiers, + IStatusBar* statusBar) + {}; + + }; + class Interactor : public IWorldSceneInteractor { private: @@ -123,9 +168,10 @@ std::unique_ptr interactor_; + std::unique_ptr thumbnailInteractor_; LayoutWidget* mainLayout_; LayoutWidget* thumbnailsLayout_; - LayerWidget* mainViewport_; + LayerWidget* mainWidget_; std::vector thumbnails_; std::vector instances_; @@ -179,24 +225,24 @@ statusBar_ = &statusBar; {// initialize viewports and layout - mainLayout_ = new LayoutWidget(); + mainLayout_ = new LayoutWidget("main-layout"); mainLayout_->SetPadding(10); mainLayout_->SetBackgroundCleared(true); mainLayout_->SetBackgroundColor(0, 0, 0); mainLayout_->SetHorizontal(); - thumbnailsLayout_ = new LayoutWidget(); + thumbnailsLayout_ = new LayoutWidget("thumbnail-layout"); thumbnailsLayout_->SetPadding(10); thumbnailsLayout_->SetBackgroundCleared(true); thumbnailsLayout_->SetBackgroundColor(50, 50, 50); thumbnailsLayout_->SetVertical(); - mainViewport_ = new LayerWidget(broker_, "main-viewport"); - mainViewport_->RegisterObserver(*this); + mainWidget_ = new LayerWidget(broker_, "main-viewport"); + mainWidget_->RegisterObserver(*this); // hierarchy mainLayout_->AddWidget(thumbnailsLayout_); - mainLayout_->AddWidget(mainViewport_); + mainLayout_->AddWidget(mainWidget_); // sources smartLoader_.reset(new SmartLoader(broker_, context_->GetWebService())); @@ -204,7 +250,8 @@ mainLayout_->SetTransmitMouseOver(true); interactor_.reset(new Interactor(*this)); - mainViewport_->SetInteractor(*interactor_); + mainWidget_->SetInteractor(*interactor_); + thumbnailInteractor_.reset(new ThumbnailInteractor(*this)); } statusBar.SetMessage("Use the key \"s\" to reinitialize the layout"); @@ -257,6 +304,7 @@ thumbnailsLayout_->AddWidget(thumbnailWidget); thumbnailWidget->RegisterObserver(*this); thumbnailWidget->AddLayer(smartLoader_->GetFrame(instanceId, 0)); + //thumbnailWidget->SetInteractor(*thumbnailInteractor_); } void SelectStudy(const std::string& studyId) @@ -298,7 +346,7 @@ currentInstanceIndex_ = (currentInstanceIndex_ + 1) % instances_.size(); - mainViewport_->ReplaceLayer(0, smartLoader_->GetFrame(instances_[currentInstanceIndex_], 0)); + mainWidget_->ReplaceLayer(0, smartLoader_->GetFrame(instances_[currentInstanceIndex_], 0)); } }; diff -r d7d91d96b9d8 -r f21ba2468570 Applications/Sdl/BasicSdlApplicationContext.h --- a/Applications/Sdl/BasicSdlApplicationContext.h Fri Aug 24 09:11:06 2018 +0200 +++ b/Applications/Sdl/BasicSdlApplicationContext.h Fri Aug 24 11:26:59 2018 +0200 @@ -24,7 +24,6 @@ #include "../../Framework/Viewport/WidgetViewport.h" #include "../../Framework/Volumes/ISlicedVolume.h" #include "../../Framework/Volumes/IVolumeLoader.h" -#include "../../Framework/Widgets/IWorldSceneInteractor.h" #include #include diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/CairoWidget.cpp --- a/Framework/Widgets/CairoWidget.cpp Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/CairoWidget.cpp Fri Aug 24 11:26:59 2018 +0200 @@ -32,6 +32,10 @@ return true; } + CairoWidget::CairoWidget(const std::string& name) + : WidgetBase(name) + { + } void CairoWidget::SetSize(unsigned int width, unsigned int height) diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/CairoWidget.h --- a/Framework/Widgets/CairoWidget.h Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/CairoWidget.h Fri Aug 24 11:26:59 2018 +0200 @@ -38,6 +38,8 @@ int y) = 0; public: + CairoWidget(const std::string& name); + virtual void SetSize(unsigned int width, unsigned int height); diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/LayerWidget.cpp --- a/Framework/Widgets/LayerWidget.cpp Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/LayerWidget.cpp Fri Aug 24 11:26:59 2018 +0200 @@ -360,10 +360,10 @@ LayerWidget::LayerWidget(MessageBroker& broker, const std::string& name) : + WorldSceneWidget(name), IObserver(broker), IObservable(broker), - started_(false), - name_(name) + started_(false) { DeclareHandledMessage(MessageType_LayerSource_GeometryReady); DeclareHandledMessage(MessageType_LayerSource_ContentChanged); @@ -524,7 +524,7 @@ size_t i; if (LookupLayer(i, source)) { - LOG(INFO) << ": Geometry ready for layer " << i << " in " << name_; + LOG(INFO) << ": Geometry ready for layer " << i << " in " << GetName(); changedLayers_[i] = true; //layers_[i]->ScheduleLayerCreation(slice_); diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/LayerWidget.h --- a/Framework/Widgets/LayerWidget.h Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/LayerWidget.h Fri Aug 24 11:26:59 2018 +0200 @@ -48,7 +48,6 @@ std::auto_ptr currentScene_; std::auto_ptr pendingScene_; std::vector changedLayers_; - std::string name_; bool LookupLayer(size_t& index /* out */, const ILayerSource& layer) const; @@ -95,8 +94,6 @@ public: virtual ~LayerWidget(); - const std::string& GetName() const {return name_;} - size_t AddLayer(ILayerSource* layer); // Takes ownership void ReplaceLayer(size_t layerIndex, ILayerSource* layer); // Takes ownership diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/LayoutWidget.cpp --- a/Framework/Widgets/LayoutWidget.cpp Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/LayoutWidget.cpp Fri Aug 24 11:26:59 2018 +0200 @@ -265,7 +265,8 @@ } - LayoutWidget::LayoutWidget() : + LayoutWidget::LayoutWidget(const std::string& name) : + WidgetBase(name), isHorizontal_(true), width_(0), height_(0), diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/LayoutWidget.h --- a/Framework/Widgets/LayoutWidget.h Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/LayoutWidget.h Fri Aug 24 11:26:59 2018 +0200 @@ -49,7 +49,7 @@ void ComputeChildrenExtents(); public: - LayoutWidget(); + LayoutWidget(const std::string& name); virtual ~LayoutWidget(); diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/TestCairoWidget.cpp --- a/Framework/Widgets/TestCairoWidget.cpp Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/TestCairoWidget.cpp Fri Aug 24 11:26:59 2018 +0200 @@ -77,7 +77,8 @@ } - TestCairoWidget::TestCairoWidget(bool animate) : + TestCairoWidget::TestCairoWidget(const std::string& name, bool animate) : + CairoWidget(name), width_(0), height_(0), value_(1), diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/TestCairoWidget.h --- a/Framework/Widgets/TestCairoWidget.h Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/TestCairoWidget.h Fri Aug 24 11:26:59 2018 +0200 @@ -43,7 +43,7 @@ int y); public: - TestCairoWidget(bool animate); + TestCairoWidget(const std::string& name, bool animate); virtual void SetSize(unsigned int width, unsigned int height); diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/TestWorldSceneWidget.cpp --- a/Framework/Widgets/TestWorldSceneWidget.cpp Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/TestWorldSceneWidget.cpp Fri Aug 24 11:26:59 2018 +0200 @@ -110,7 +110,8 @@ } - TestWorldSceneWidget::TestWorldSceneWidget(bool animate) : + TestWorldSceneWidget::TestWorldSceneWidget(const std::string& name, bool animate) : + WorldSceneWidget(name), interactor_(new Interactor), animate_(animate), count_(0) diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/TestWorldSceneWidget.h --- a/Framework/Widgets/TestWorldSceneWidget.h Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/TestWorldSceneWidget.h Fri Aug 24 11:26:59 2018 +0200 @@ -43,7 +43,7 @@ const ViewportGeometry& view); public: - TestWorldSceneWidget(bool animate); + TestWorldSceneWidget(const std::string& name, bool animate); virtual Extent2D GetSceneExtent(); diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/WidgetBase.cpp --- a/Framework/Widgets/WidgetBase.cpp Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/WidgetBase.cpp Fri Aug 24 11:26:59 2018 +0200 @@ -101,12 +101,13 @@ } - WidgetBase::WidgetBase() : + WidgetBase::WidgetBase(const std::string& name) : parent_(NULL), viewport_(NULL), statusBar_(NULL), backgroundCleared_(false), - transmitMouseOver_(false) + transmitMouseOver_(false), + name_(name) { backgroundColor_[0] = 0; backgroundColor_[1] = 0; diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/WidgetBase.h --- a/Framework/Widgets/WidgetBase.h Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/WidgetBase.h Fri Aug 24 11:26:59 2018 +0200 @@ -36,6 +36,7 @@ bool backgroundCleared_; uint8_t backgroundColor_[3]; bool transmitMouseOver_; + std::string name_; protected: void ClearBackgroundOrthanc(Orthanc::ImageAccessor& target) const; @@ -52,7 +53,7 @@ } public: - WidgetBase(); + WidgetBase(const std::string& name); virtual void SetDefaultView() { @@ -105,5 +106,11 @@ } virtual void NotifyChange(); + + const std::string& GetName() const + { + return name_; + } + }; } diff -r d7d91d96b9d8 -r f21ba2468570 Framework/Widgets/WorldSceneWidget.h --- a/Framework/Widgets/WorldSceneWidget.h Fri Aug 24 09:11:06 2018 +0200 +++ b/Framework/Widgets/WorldSceneWidget.h Fri Aug 24 11:26:59 2018 +0200 @@ -75,7 +75,8 @@ void SetSceneExtent(ViewportGeometry& geometry); public: - WorldSceneWidget() : + WorldSceneWidget(const std::string& name) : + CairoWidget(name), interactor_(NULL) { }