Mercurial > hg > orthanc-stone
changeset 871:4bc8d9609447
Added support for measuring tool edition in TrackerSampleApp
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 25 Jun 2019 18:17:33 +0200 |
parents | d337f2704f79 |
children | 9953f16c304d 6e888cf6a48b |
files | Samples/Sdl/TrackerSampleApp.cpp |
diffstat | 1 files changed, 36 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Samples/Sdl/TrackerSampleApp.cpp Tue Jun 25 18:05:13 2019 +0200 +++ b/Samples/Sdl/TrackerSampleApp.cpp Tue Jun 25 18:17:33 2019 +0200 @@ -247,7 +247,7 @@ DisplayFloatingCtrlInfoText(e); } - else + else if (activeTracker_.get() != NULL) { HideInfoText(); //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)"; @@ -268,6 +268,32 @@ activeTracker_.reset(); } } + else + { + HideInfoText(); + + PointerEvent e; + e.AddPosition(compositor_->GetPixelCenterCoordinates(event.button.x, event.button.y)); + + ScenePoint2D scenePos = e.GetMainPosition().Apply( + controller_->GetScene()->GetCanvasToSceneTransform()); + //auto measureTools = GetController()->HitTestMeasureTools(scenePos); + //LOG(TRACE) << "# of hit tests: " << measureTools.size(); + + // this returns the collection of measuring tools where hit test is true + std::vector<boost::shared_ptr<MeasureTool> > measureTools = controller_->HitTestMeasureTools(scenePos); + + // let's refresh the measuring tools highlighted state + // first let's tag them as "unhighlighted" + controller_->ResetMeasuringToolsHighlight(); + + // then immediately take the first one and ask it to highlight the + // measuring tool UI part that is hot + if (measureTools.size() > 0) + { + measureTools[0]->Highlight(scenePos); + } + } } else if (event.type == SDL_MOUSEBUTTONUP) { @@ -596,6 +622,15 @@ boost::shared_ptr<IFlexiblePointerTracker> TrackerSampleApp::TrackerHitTest(const PointerEvent & e) { // std::vector<boost::shared_ptr<MeasureTool>> measureTools_; + ScenePoint2D scenePos = e.GetMainPosition().Apply( + controller_->GetScene()->GetCanvasToSceneTransform()); + + std::vector<boost::shared_ptr<MeasureTool> > measureTools = controller_->HitTestMeasureTools(scenePos); + + if (measureTools.size() > 0) + { + return measureTools[0]->CreateEditionTracker(e); + } return boost::shared_ptr<IFlexiblePointerTracker>(); }