internal GraphicObject(GraphicObjectType graphicObject, params PointXYZ[] pointXYZs) { _graphicObject = graphicObject; PointXYZs = pointXYZs; }
static private void GraphicObjectTest(string studyDirectoryPath, string outputFileName, bool colorSoftcopy, string seriesDescription, GraphicObjectType figureType, string text = "", bool useBoundingBox = false, bool showAnchor = false) { string[] files = Directory.GetFiles(studyDirectoryPath); string sourceFilePath = files.Single(a => DicomFile.Open(a).Dataset.GetSingleValue <string>(DicomTag.Modality) != "PR"); var pre = CreatePresentationState(new[] { sourceFilePath }, colorSoftcopy, seriesDescription); const float minThickness = 1F; const float maxThickness = 8F; for (float y = maxThickness; y + y * 0.25F + maxThickness * 0.5F <= pre.Rows; y += y * 0.25F + maxThickness * 2F) { int count = 0; for (float x = maxThickness; x + x * 0.25F + maxThickness * 0.5F <= pre.Columns; x += x * 0.25F + maxThickness * 2F, count++) { float height = y * 0.25F; float width = x * 0.25F; float diameter = Math.Min(width, height) * 0.5F; float thickness = minThickness + (maxThickness - minThickness) * (x / pre.Columns); ColorMine.ColorSpaces.Hsv color = new ColorMine.ColorSpaces.Hsv { H = ((x + width) / pre.Columns) * 360, S = ((1F - (y) / pre.Rows)), V = (1F - ((y) / pre.Rows)) }; switch (figureType) { case GraphicObjectType.Point: AddPoint(pre, x, y, thickness, colorSoftcopy ? color : null); break; case GraphicObjectType.Polyline: AddPolyline(pre, x, y, width, height, thickness, colorSoftcopy ? color : null); break; case GraphicObjectType.Interpolated: AddInterpolated(pre, x, y, width, height, thickness, colorSoftcopy ? color : null); break; case GraphicObjectType.Circle: AddCircle(pre, x, y, diameter, thickness, colorSoftcopy ? color : null); break; case GraphicObjectType.Ellipse: AddEllipse(pre, x, y, width, height, thickness, colorSoftcopy ? color : null); break; case GraphicObjectType.Text: AddPolyline(pre, x, y, width, height, minThickness, null); AddText(pre, text, x, y, width, height, count % 3, count % 4, useBoundingBox, showAnchor, colorSoftcopy ? color : null); break; } } } if (figureType == GraphicObjectType.Text && !useBoundingBox) { AddText(pre, text, pre.Columns * 0.5F, pre.Rows, 0, 0, 0, 0, false, showAnchor, colorSoftcopy ? new ColorMine.ColorSpaces.Rgb { R = 255, G = 255, B = 255 } : null); AddText(pre, text, pre.Columns, pre.Rows * 0.5F, 0, 0, 0, 0, false, showAnchor, colorSoftcopy ? new ColorMine.ColorSpaces.Rgb { R = 255, G = 255, B = 255 } : null); } string destFilePath = Path.Combine(studyDirectoryPath, Path.GetFileNameWithoutExtension(outputFileName) + ".dcm"); EnsureDirectories(Path.GetDirectoryName(destFilePath)); new DicomFile(pre.PresentationStateDataset).Save(destFilePath); }