private void Probe(Point destinationPoint) { Point sourcePointRounded = Point.Truncate(_selectedSpatialTransform.ConvertToSource(destinationPoint)); ToolSettings settings = ToolSettings.DefaultInstance; bool showPixelValue = settings.ShowRawPixelValue; bool showVoiValue = settings.ShowVOIPixelValue; Probe(sourcePointRounded, showPixelValue, showVoiValue); }
private void IncrementPan(int xIncrement, int yIncrement) { if (!CanPan()) { return; } ISpatialTransform transform = _operation.GetOriginator(this.SelectedPresentationImage); // Because the pan increment is in destination coordinates, we have to convert // them to source coordinates, since the transform translation is in source coordinates. // This will allow the pan to work properly irrespective of the zoom, flip and rotation. SizeF sourceIncrement = transform.ConvertToSource(new SizeF(xIncrement, yIncrement)); transform.TranslationX += sourceIncrement.Width; transform.TranslationY += sourceIncrement.Height; this.SelectedPresentationImage.Draw(); }
protected void DeserializeDisplayedArea(DisplayedAreaModuleIod dispAreaMod, out RectangleF displayedArea, T image) { ISpatialTransform spatialTransform = image.SpatialTransform; foreach (DisplayedAreaModuleIod.DisplayedAreaSelectionSequenceItem item in dispAreaMod.DisplayedAreaSelectionSequence) { var dictionary = !DeserializeIgnoreImageRelationship ? new ImageSopInstanceReferenceDictionary(item.ReferencedImageSequence, true) : null; if (dictionary == null || dictionary.ReferencesFrame(image.Frame.SopInstanceUid, image.Frame.FrameNumber)) { // get the displayed area of the image in source coordinates (stored values do not have sub-pixel accuracy) var displayRect = RectangleF.FromLTRB(item.DisplayedAreaTopLeftHandCorner.X, item.DisplayedAreaTopLeftHandCorner.Y, item.DisplayedAreaBottomRightHandCorner.X, item.DisplayedAreaBottomRightHandCorner.Y); displayRect = RectangleUtilities.ConvertToPositiveRectangle(displayRect); displayRect.Location = displayRect.Location - new SizeF(1, 1); displayRect.Size = displayRect.Size + new SizeF(1, 1); var centerDisplay = true; switch (item.PresentationSizeMode) { case DisplayedAreaModuleIod.PresentationSizeMode.Magnify: // displays selected area at specified magnification factor spatialTransform.Scale = (float)item.PresentationPixelMagnificationRatio.GetValueOrDefault(1); break; case DisplayedAreaModuleIod.PresentationSizeMode.TrueSize: // currently no support for determining true size, so default to scale area to fit case DisplayedAreaModuleIod.PresentationSizeMode.ScaleToFit: case DisplayedAreaModuleIod.PresentationSizeMode.None: default: if (spatialTransform is IImageSpatialTransform && displayRect.Location == new PointF(0, 0) && displayRect.Size == new SizeF(image.ImageGraphic.Columns, image.ImageGraphic.Rows)) { // if the display rect is the whole image, then take advantage of the built-in scale image to fit functionality IImageSpatialTransform iist = (IImageSpatialTransform)spatialTransform; iist.ScaleToFit = true; centerDisplay = false; // when ScaleToFit is true, the image will automatically be positioned correctly in the client area } else { var clientArea = image.ClientRectangle.Size; var displaySize = displayRect.Size; // if image is rotated 90 or 270, transpose width/height if (Math.Abs(Math.Round(Math.Sin(spatialTransform.RotationXY * Math.PI / 180))) > 0) { displaySize = new SizeF(displaySize.Height, displaySize.Width); } // compute the maximum magnification that allows the entire displayRect to be visible spatialTransform.Scale = Math.Min(clientArea.Width / displaySize.Width, clientArea.Height / displaySize.Height); } break; } if (centerDisplay) { // compute translation so that the displayRect is centered in the clientRect var displayCentre = GetRectangleCenter(displayRect); var clientCentre = spatialTransform.ConvertToSource(GetRectangleCenter(image.ClientRectangle)); spatialTransform.TranslationX = clientCentre.X - displayCentre.X; spatialTransform.TranslationY = clientCentre.Y - displayCentre.Y; } displayedArea = displayRect; return; } } displayedArea = new RectangleF(0, 0, image.ImageGraphic.Columns, image.ImageGraphic.Rows); }