示例#1
0
 private IEnumerable <DicomImagePlane> GetTargetImagePlanes(IImageBox imageBox)
 {
     for (int i = imageBox.DisplaySet.PresentationImages.Count - 1; i >= 0; --i)
     {
         DicomImagePlane targetImagePlane = DicomImagePlane.FromImage(imageBox.DisplaySet.PresentationImages[i]);
         if (targetImagePlane != null && _referencePlane.IsInSameFrameOfReference(targetImagePlane))
         {
             yield return(targetImagePlane);
         }
     }
 }
示例#2
0
 private static IEnumerable <DicomImagePlane> GetAllImagePlanes(IImageBox imageBox)
 {
     if (imageBox.DisplaySet != null)
     {
         for (int index = imageBox.DisplaySet.PresentationImages.Count - 1; index >= 0; --index)
         {
             DicomImagePlane targetPlane = DicomImagePlane.FromImage(imageBox.DisplaySet.PresentationImages[index]);
             if (targetPlane != null)
             {
                 yield return(targetPlane);
             }
         }
     }
 }
示例#3
0
 private IEnumerable <DicomImagePlane> GetPlanesParallelToReferencePlane()
 {
     foreach (IPresentationImage image in CurrentReferenceImage.ParentDisplaySet.PresentationImages.Where(i => !(i is BasicPresentationImage3D)))
     {
         DicomImagePlane plane = DicomImagePlane.FromImage(image);
         if (plane != null)
         {
             if (_currentReferenceImagePlane.IsInSameFrameOfReference(plane) &&
                 _currentReferenceImagePlane.IsParallelTo(plane, _oneDegreeInRadians))
             {
                 yield return(plane);
             }
         }
     }
 }
        private void SetCurrentReferencePlane()
        {
            if (CurrentReferenceImage == this.SelectedPresentationImage)
            {
                return;
            }

            _currentReferenceImagePlane = DicomImagePlane.FromImage(this.SelectedPresentationImage);
            if (_currentReferenceImagePlane == null)
            {
                return;
            }

            ReferenceLineCompositeGraphic referenceLineCompositeGraphic =
                _coordinator.GetReferenceLineCompositeGraphic(CurrentReferenceImage);
        }
示例#5
0
        private void SynchronizeImageBox(IImageBox referenceImageBox, IImageBox targetImageBox)
        {
            if (referenceImageBox.TopLeftPresentationImage == null)
            {
                return;
            }

            if (targetImageBox.TopLeftPresentationImage == null)
            {
                return;
            }

            DicomImagePlane referenceImagePlane = DicomImagePlane.FromImage(referenceImageBox.TopLeftPresentationImage);

            if (referenceImagePlane == null)
            {
                return;
            }

            IEnumerable <DicomImagePlane> targetImagePlanes = GetAllImagePlanes(targetImageBox);
            DicomImagePlane targetImagePlane = GetClosestParallelImagePlane(referenceImagePlane, targetImagePlanes);

            if (targetImagePlane == null)
            {
                return;
            }
            // Original
            int lastIndex = targetImageBox.TopLeftPresentationImageIndex;

            targetImageBox.TopLeftPresentationImage = targetImagePlane.SourceImage;

            if (lastIndex != targetImageBox.TopLeftPresentationImageIndex)
            {
                if (!_imageBoxesToDraw.Contains(targetImageBox))
                {
                    _imageBoxesToDraw.Add(targetImageBox);
                }
            }

            //if (GlobalData.direct > 0)
            //    targetImageBox.TopLeftPresentationImageIndex = lastIndex + 1;
            //else if (GlobalData.direct < 0)
            //    targetImageBox.TopLeftPresentationImageIndex = lastIndex - 1;

            //if (!_imageBoxesToDraw.Contains(targetImageBox))
            //    _imageBoxesToDraw.Add(targetImageBox);
        }
        private void RefreshReferenceLines(IPresentationImage targetImage)
        {
            try
            {
                DicomImagePlane targetImagePlane = DicomImagePlane.FromImage(targetImage);
                if (targetImagePlane == null)
                {
                    return;
                }

                ReferenceLineCompositeGraphic referenceLineCompositeGraphic = _coordinator.GetReferenceLineCompositeGraphic(targetImage);
                if (referenceLineCompositeGraphic == null)
                {
                    return;
                }
                //bool showReferenceLines = this.Active && _currentReferenceImagePlane != null &&
                //    _currentReferenceImagePlane.IsInSameFrameOfReference(targetImagePlane);

                bool showReferenceLines = targetImage.ParentDisplaySet.ImageBox.ShowReferenceLine;
                if (!showReferenceLines)
                {
                    referenceLineCompositeGraphic.HideAllReferenceLines();
                    return;
                }

                int i = 0;

                foreach (ReferenceLine referenceLine in GetAllReferenceLines(targetImagePlane))
                {
                    ReferenceLineGraphic referenceLineGraphic = referenceLineCompositeGraphic[i++];
                    referenceLineGraphic.Point1  = referenceLine.StartPoint;
                    referenceLineGraphic.Point2  = referenceLine.EndPoint;
                    referenceLineGraphic.Text    = referenceLine.Label;
                    referenceLineGraphic.Visible = true;
                }
                // make any that aren't valid invisible.

                for (int j = i; j < referenceLineCompositeGraphic.Graphics.Count; ++j)
                {
                    referenceLineCompositeGraphic[j].Visible = false;
                }
            }
            catch (Exception ex)
            {
                Platform.Log(LogLevel.Error, ex.ToString());
            }
        }
示例#7
0
 private void CalibrateFrameOfReferenceForVisibleImageBoxes()
 {
     foreach (IImageBox referenceImageBox in this.ImageViewer.PhysicalWorkspace.ImageBoxes)
     {
         DicomImagePlane referencePlane = DicomImagePlane.FromImage(referenceImageBox.TopLeftPresentationImage);
         if (referencePlane != null)
         {
             foreach (IImageBox imageBox in GetTargetImageBoxes(referenceImageBox))
             {
                 DicomImagePlane targetPlane = DicomImagePlane.FromImage(imageBox.TopLeftPresentationImage);
                 if (targetPlane != null)
                 {
                     _frameOfReferenceCalibrator.Calibrate(referencePlane, targetPlane);
                 }
             }
         }
     }
 }
示例#8
0
        private void RefreshReferenceLines(IPresentationImage targetImage)
        {
            DicomImagePlane targetImagePlane = DicomImagePlane.FromImage(targetImage);

            if (targetImagePlane == null)
            {
                return;
            }

            ReferenceLineCompositeGraphic referenceLineCompositeGraphic = _coordinator.GetReferenceLineCompositeGraphic(targetImage);

            if (referenceLineCompositeGraphic == null)
            {
                return;
            }

            bool showReferenceLines = this.Active && _currentReferenceImagePlane != null &&
                                      _currentReferenceImagePlane.IsInSameFrameOfReference(targetImagePlane);

            if (!showReferenceLines)
            {
                referenceLineCompositeGraphic.HideAllReferenceLines();
                return;
            }

            int i = 0;

            foreach (ReferenceLine referenceLine in GetAllReferenceLines(targetImagePlane))
            {
                ReferenceLineGraphic referenceLineGraphic = referenceLineCompositeGraphic[i++];
                referenceLineGraphic.Point1  = referenceLine.StartPoint;
                referenceLineGraphic.Point2  = referenceLine.EndPoint;
                referenceLineGraphic.Text    = referenceLine.Label;
                referenceLineGraphic.Visible = true;
            }

            // make any that aren't valid invisible.
            for (int j = i; j < referenceLineCompositeGraphic.Graphics.Count; ++j)
            {
                referenceLineCompositeGraphic[j].Visible = false;
            }
        }
        private void SetCurrentReferencePlane(IPresentationImage image)
        {
            if (CurrentReferenceImage == this.SelectedPresentationImage)
            {
                return;
            }

            _currentReferenceImagePlane = DicomImagePlane.FromImage(image);
            if (_currentReferenceImagePlane == null)
            {
                return;
            }

            ReferenceLineCompositeGraphic referenceLineCompositeGraphic =
                _coordinator.GetReferenceLineCompositeGraphic(CurrentReferenceImage);

            //Hide the current image's reference lines

            //if (referenceLineCompositeGraphic != null)
            //    referenceLineCompositeGraphic.HideAllReferenceLines();
        }
示例#10
0
 private bool Start()
 {
     _referencePlane = DicomImagePlane.FromImage(base.SelectedPresentationImage);
     return(_referencePlane != null);
 }
        private IEnumerable <ReferenceLine> GetAllReferenceLines(DicomImagePlane targetImagePlane)
        {
            if (!ShowCrossReferenceLines)
            {
                ReferenceLine firstReferenceLine = null;
                ReferenceLine lastReferenceLine  = null;
                if (ShowFirstAndLastReferenceLines)
                {
                    GetFirstAndLastReferenceLines(targetImagePlane, out firstReferenceLine, out lastReferenceLine);
                }

                if (firstReferenceLine != null)
                {
                    yield return(firstReferenceLine);
                }

                if (lastReferenceLine != null)
                {
                    yield return(lastReferenceLine);
                }

                //return 'current' last, so it draws on top of the others.
                ReferenceLine currentReferenceLine = GetReferenceLine(_currentReferenceImagePlane, targetImagePlane);
                if (currentReferenceLine != null)
                {
                    yield return(currentReferenceLine);
                }
            }
            else
            {
                foreach (IPresentationImage currentImage in GetAllVisibleImages())
                {
                    _currentReferenceImagePlane = DicomImagePlane.FromImage(currentImage);
                    if (_currentReferenceImagePlane == null)
                    {
                        continue;
                    }
                    //
                    if (_currentReferenceImagePlane.IsInSameFrameOfReference(targetImagePlane) == false)
                    {
                        continue;
                    }
                    ReferenceLine firstReferenceLine = null;
                    ReferenceLine lastReferenceLine  = null;
                    if (ShowFirstAndLastReferenceLines)
                    {
                        GetFirstAndLastReferenceLines(targetImagePlane, out firstReferenceLine, out lastReferenceLine);
                    }

                    if (firstReferenceLine != null)
                    {
                        yield return(firstReferenceLine);
                    }

                    if (lastReferenceLine != null)
                    {
                        yield return(lastReferenceLine);
                    }

                    //return 'current' last, so it draws on top of the others.
                    ReferenceLine currentReferenceLine = GetReferenceLine(_currentReferenceImagePlane, targetImagePlane);
                    if (currentReferenceLine != null)
                    {
                        yield return(currentReferenceLine);
                    }
                }
            }
        }