# HG changeset patch # User Sebastien Jodogne # Date 1667041341 -7200 # Node ID d71acf30970ac3202a796e95bcf51412234833a4 # Parent 5a434f5889f8e8b9dbcd5d88d2f6bf1efdfd8ba0 fixed serialization of pixel probes diff -r 5a434f5889f8 -r d71acf30970a Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Sat Oct 29 11:57:00 2022 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Sat Oct 29 13:02:21 2022 +0200 @@ -2307,6 +2307,7 @@ scene.DeleteLayer(LAYER_ORIENTATION_MARKERS); } + stoneAnnotations_->UpdateProbes(scene); stoneAnnotations_->Render(scene); // Necessary for "FitContent()" to work if (fitNextContent_) diff -r 5a434f5889f8 -r d71acf30970a OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp --- a/OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp Sat Oct 29 11:57:00 2022 +0200 +++ b/OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp Sat Oct 29 13:02:21 2022 +0200 @@ -225,6 +225,8 @@ virtual void SignalMove(GeometricPrimitive& primitive, const Scene2D& scene) = 0; + virtual void UpdateProbe(const Scene2D& scene) = 0; + virtual void Serialize(Json::Value& target) = 0; }; @@ -887,6 +889,10 @@ UpdateLabel(); } + virtual void UpdateProbe(const Scene2D& scene) ORTHANC_OVERRIDE + { + } + virtual void Serialize(Json::Value& target) ORTHANC_OVERRIDE { target = Json::objectValue; @@ -929,7 +935,31 @@ Handle& handle_; Text& label_; - void UpdateLabel(const Scene2D& scene) + public: + PixelProbeAnnotation(AnnotationsSceneLayer& that, + Units units, + const ScenePoint2D& p, + int probedLayer) : + Annotation(that, units), + probedLayer_(probedLayer), + handle_(AddTypedPrimitive(new Handle(*this, p))), + label_(AddTypedPrimitive(new Text(that, *this))) + { + label_.SetColor(COLOR_TEXT); + } + + Handle& GetHandle() const + { + return handle_; + } + + virtual void SignalMove(GeometricPrimitive& primitive, + const Scene2D& scene) ORTHANC_OVERRIDE + { + UpdateProbe(scene); + } + + virtual void UpdateProbe(const Scene2D& scene) ORTHANC_OVERRIDE { TextSceneLayer content; @@ -962,32 +992,6 @@ label_.SetContent(content); } - public: - PixelProbeAnnotation(AnnotationsSceneLayer& that, - Units units, - const ScenePoint2D& p, - const Scene2D& scene, - int probedLayer) : - Annotation(that, units), - probedLayer_(probedLayer), - handle_(AddTypedPrimitive(new Handle(*this, p))), - label_(AddTypedPrimitive(new Text(that, *this))) - { - label_.SetColor(COLOR_TEXT); - UpdateLabel(scene); - } - - Handle& GetHandle() const - { - return handle_; - } - - virtual void SignalMove(GeometricPrimitive& primitive, - const Scene2D& scene) ORTHANC_OVERRIDE - { - UpdateLabel(scene); - } - virtual void Serialize(Json::Value& target) ORTHANC_OVERRIDE { target = Json::objectValue; @@ -1006,10 +1010,9 @@ source[KEY_X].isNumeric() && source[KEY_Y].isNumeric()) { - Scene2D dummyScene; // TODO new PixelProbeAnnotation(target, units, ScenePoint2D(source[KEY_X].asDouble(), source[KEY_Y].asDouble()), - dummyScene, probedLayer); + probedLayer); } else { @@ -1123,6 +1126,10 @@ UpdateLabel(); } + virtual void UpdateProbe(const Scene2D& scene) ORTHANC_OVERRIDE + { + } + virtual void Serialize(Json::Value& target) ORTHANC_OVERRIDE { target = Json::objectValue; @@ -1273,6 +1280,10 @@ UpdateLabel(); } + virtual void UpdateProbe(const Scene2D& scene) ORTHANC_OVERRIDE + { + } + virtual void Serialize(Json::Value& target) ORTHANC_OVERRIDE { target = Json::objectValue; @@ -1488,7 +1499,8 @@ int probedLayer) : that_(that) { - new PixelProbeAnnotation(that, units, sceneClick, scene, probedLayer); + PixelProbeAnnotation* annotation = new PixelProbeAnnotation(that, units, sceneClick, probedLayer); + annotation->UpdateProbe(scene); } virtual void PointerMove(const PointerEvent& event, @@ -1899,4 +1911,14 @@ } } } + + + void AnnotationsSceneLayer::UpdateProbes(const Scene2D& scene) + { + for (Annotations::const_iterator it = annotations_.begin(); it != annotations_.end(); ++it) + { + assert(*it != NULL); + (*it)->UpdateProbe(scene); + } + } } diff -r 5a434f5889f8 -r d71acf30970a OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.h --- a/OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.h Sat Oct 29 11:57:00 2022 +0200 +++ b/OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.h Sat Oct 29 13:02:21 2022 +0200 @@ -146,5 +146,7 @@ { return probedLayer_; } + + void UpdateProbes(const Scene2D& scene); }; }