Mercurial > hg > orthanc-stone
changeset 273:f21ba2468570 am-2
force all Widgets to have a name to ease debugging
author | am@osimis.io |
---|---|
date | Fri, 24 Aug 2018 11:26:59 +0200 |
parents | d7d91d96b9d8 |
children | dc1beee33134 |
files | Applications/Samples/SimpleViewerApplication.h Applications/Sdl/BasicSdlApplicationContext.h Framework/Widgets/CairoWidget.cpp Framework/Widgets/CairoWidget.h Framework/Widgets/LayerWidget.cpp Framework/Widgets/LayerWidget.h Framework/Widgets/LayoutWidget.cpp Framework/Widgets/LayoutWidget.h Framework/Widgets/TestCairoWidget.cpp Framework/Widgets/TestCairoWidget.h Framework/Widgets/TestWorldSceneWidget.cpp Framework/Widgets/TestWorldSceneWidget.h Framework/Widgets/WidgetBase.cpp Framework/Widgets/WidgetBase.h Framework/Widgets/WorldSceneWidget.h |
diffstat | 15 files changed, 87 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- 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> interactor_; + std::unique_ptr<ThumbnailInteractor> thumbnailInteractor_; LayoutWidget* mainLayout_; LayoutWidget* thumbnailsLayout_; - LayerWidget* mainViewport_; + LayerWidget* mainWidget_; std::vector<LayerWidget*> thumbnails_; std::vector<std::string> 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)); } };
--- 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 <list> #include <boost/thread.hpp>
--- 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)
--- 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);
--- 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_);
--- 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<Scene> currentScene_; std::auto_ptr<Scene> pendingScene_; std::vector<bool> 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
--- 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),
--- 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();
--- 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),
--- 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);
--- 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)
--- 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();
--- 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;
--- 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_; + } + }; }
--- 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) { }