MCPcopy Create free account
hub / github.com/MITK/MITK / OnMouseMoved

Method OnMouseMoved

Modules/Segmentation/src/Interactions/mitkRegionGrowingTool.cpp:375–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375void mitk::RegionGrowingTool::OnMouseMoved(StateMachineAction*, InteractionEvent* interactionEvent)
376{
377 auto* positionEvent = dynamic_cast<mitk::InteractionPositionEvent*>(interactionEvent);
378 if (nullptr == positionEvent)
379 {
380 return;
381 }
382
383 if (m_ReferenceSlice.IsNull())
384 {
385 return;
386 }
387
388 // Get geometry and indices
389 mitk::BaseGeometry::Pointer workingSliceGeometry;
390 workingSliceGeometry = m_WorkingSlice->GetGeometry();
391 itk::Index<2> indexInWorkingSlice2D;
392 indexInWorkingSlice2D[0] = m_SeedPoint[0];
393 indexInWorkingSlice2D[1] = m_SeedPoint[1];
394
395 m_ScreenYDifference += positionEvent->GetPointerPositionOnScreen()[1] - m_LastScreenPosition[1];
396 m_ScreenXDifference += positionEvent->GetPointerPositionOnScreen()[0] - m_LastScreenPosition[0];
397 m_LastScreenPosition = Point2I(positionEvent->GetPointerPositionOnScreen());
398
399 // Moving the mouse up and down adjusts the width of the threshold window,
400 // moving it left and right shifts the threshold window
401 m_Thresholds[0] = std::min(
402 m_SeedValue, m_InitialThresholds[0] - (m_ScreenYDifference - m_ScreenXDifference) * m_MouseDistanceScaleFactor);
403 m_Thresholds[1] = std::max(
404 m_SeedValue, m_InitialThresholds[1] + (m_ScreenYDifference + m_ScreenXDifference) * m_MouseDistanceScaleFactor);
405
406 // Do not exceed the pixel type extrema of the reference slice, though
407 m_Thresholds[0] = std::max(m_ThresholdExtrema[0], m_Thresholds[0]);
408 m_Thresholds[1] = std::min(m_ThresholdExtrema[1], m_Thresholds[1]);
409
410 // Perform region growing again and show the result
411 mitk::Image::Pointer resultImage = mitk::Image::New();
412 AccessFixedDimensionByItk_3(
413 m_ReferenceSlice, StartRegionGrowing, 2, indexInWorkingSlice2D, m_Thresholds, resultImage);
414 resultImage->SetGeometry(workingSliceGeometry);
415
416 // Update the contour
417 if (resultImage.IsNotNull() && m_ConnectedComponentValue >= 1)
418 {
419 float isoOffset = 0.33;
420
421 mitk::ImageToContourModelFilter::Pointer contourExtractor = mitk::ImageToContourModelFilter::New();
422 contourExtractor->SetInput(resultImage);
423 contourExtractor->SetContourValue(m_ConnectedComponentValue - isoOffset);
424 contourExtractor->Update();
425 ContourModel::Pointer resultContour = ContourModel::New();
426 resultContour = contourExtractor->GetOutput();
427
428 // Show contour
429 if (resultContour.IsNotNull())
430 {
431 ContourModel::Pointer resultContourWorld = FeedbackContourTool::BackProjectContourFrom2DSlice(
432 workingSliceGeometry, FeedbackContourTool::ProjectContourTo2DSlice(m_WorkingSlice, resultContour));

Callers

nothing calls this directly

Calls 13

GetGeometryMethod · 0.80
IsNotNullMethod · 0.80
SetContourValueMethod · 0.80
GetSenderMethod · 0.80
NewFunction · 0.50
IsNullMethod · 0.45
SetGeometryMethod · 0.45
SetInputMethod · 0.45
UpdateMethod · 0.45
GetOutputMethod · 0.45
ForceImmediateUpdateMethod · 0.45

Tested by

no test coverage detected