コード例 #1
0
        void UpdateCellFusions(MedicalViewerFusion refFusion, int subCellIndex, int index)
        {
            for (int i = 0; i < _cell.SubCells.Count; i++)
            {
                if (i == subCellIndex)
                {
                    continue;
                }

                if (_cell.SubCells[i].Fusion.Count <= index)
                {
                    continue;
                }

                MedicalViewerFusion fusion = _cell.SubCells[i].Fusion[index];
                fusion.Center           = refFusion.Center;
                fusion.ColorPalette     = refFusion.ColorPalette;
                fusion.DisplayRectangle = new RectangleF(refFusion.DisplayRectangle.X, refFusion.DisplayRectangle.Y, refFusion.DisplayRectangle.Width, refFusion.DisplayRectangle.Height);
                fusion.Fit         = refFusion.Fit;
                fusion.FusionScale = refFusion.FusionScale;
                fusion.OffsetX     = refFusion.OffsetX;
                fusion.OffsetY     = refFusion.OffsetY;
                fusion.Rotation    = refFusion.Rotation;
                fusion.Scale       = refFusion.Scale;
                fusion.Width       = refFusion.Width;
            }
        }
コード例 #2
0
        private void AdjustFusionImage_Edit(object sender, AnnRectangleObject fusionEditRect)
        {
            int subCellIndex = _cell.ActiveSubCell;
            int index        = _cmbFusedIndex.SelectedIndex;

            MedicalViewerFusion fusion = _cell.SubCells[subCellIndex].Fusion[index];

            AnnContainer _Container = GetContainer(_cell, fusionEditRect);

            fusion.Rotation = (float)fusionEditRect.Angle;

            LeadPointD[] pt = new LeadPointD[1];


            LeadRectD rect = _Container.Mapper.RectFromContainerCoordinates(fusionEditRect.Rect, AnnFixedStateOperations.None);

            Rectangle displayRect = _cell.GetDisplayedImageRectangle();

            rect.Offset(-displayRect.Left, -displayRect.Top);


            pt[0].X = (float)(rect.X + rect.Width / 2);
            pt[0].Y = (float)(rect.Y + rect.Height / 2);

            LeadPointD point = LeadPointD.Create(pt[0].X, pt[0].Y);


            _cell.AutomationContainer.Mapper.Transform.TransformPoints(pt);

            float normalizedXPosition = (float)(((float)point.X - (float)displayRect.Width / 2) / fusion.FusedImage.Width * 100 / _cell.GetScale(subCellIndex));
            float normalizedYPosition = (float)(((float)point.Y - (float)displayRect.Height / 2) / fusion.FusedImage.Height * 100 / _cell.GetScale(subCellIndex));

            float scaleX = (float)((rect.Width / fusion.FusedImage.Width) * 100 / _cell.GetScale(subCellIndex));
            float scaleY = (float)((rect.Height / fusion.FusedImage.Height) * 100 / _cell.GetScale(subCellIndex));

            if (scaleX == 0)
            {
                scaleX = 0.1F;
            }

            if (scaleY == 0)
            {
                scaleY = 0.1F;
            }

            RectangleF rectangle = new RectangleF(normalizedXPosition, normalizedYPosition, Math.Abs(scaleX), Math.Abs(scaleY));

            fusion.DisplayRectangle = rectangle;

            UpdateFusionUI(index);

            CellData cellData = (CellData)_cell.Tag;

            if (cellData.SyncCellFusion)
            {
                UpdateCellFusions(fusion, subCellIndex, index);
            }

            _cell.Invalidate();
        }
コード例 #3
0
        private void _btnReset_Click(object sender, EventArgs e)
        {
            int subCellIndex = _cell.ActiveSubCell;
            int index        = _cmbFusedIndex.SelectedIndex;

            _cmbOrgImagePalette.SelectedIndex = 0;

            UpdatePalettePreview(_cmbOrgImagePalette, _orgImagePalettePreview);

            if (index >= 0 && _cell.SubCells[subCellIndex].Fusion.Count > index)
            {
                MedicalViewerSubCell subCell = _cell.SubCells[subCellIndex];
                MedicalViewerFusion  fusion  = subCell.Fusion[index];

                MedicalViewerFusion tmpFusion = new MedicalViewerFusion();
                tmpFusion.FusedImage = fusion.FusedImage;

                SuspendUpdate();
                _txtWLWidth.Text  = tmpFusion.Width.ToString();
                _txtWLCenter.Text = tmpFusion.Center.ToString();

                _txtScaleX.Text = "100.000";
                _txtScaleY.Text = "100.000";

                _txtOffsetX.Text = "0.000";
                _txtOffsetY.Text = "0.000";

                _txtRotate.Text = "0.000";

                _chkFit.Checked = true;

                _cmbPalette.SelectedIndex = 0;

                ResumeUpdate();

                UpdateFusion();

                _txtRotate.Refresh();

                _txtOffsetX.Refresh();
                _txtOffsetY.Refresh();

                _txtScaleX.Refresh();
                _txtScaleY.Refresh();

                _chkFit.Refresh();

                _cmbPalette.Refresh();
                resetOffset();
            }
        }
コード例 #4
0
        private void UpdateFusionEditRectangle(int index)
        {
            int subCellIndex = _cell.ActiveSubCell;

            MedicalViewerSubCell subCell        = _cell.SubCells[subCellIndex];
            MedicalViewerFusion  fusion         = _cell.SubCells[subCellIndex].Fusion[index];
            AnnRectangleObject   fusionEditRect = ((AnnRectangleObject)subCell.AnnotationContainer.Children[index]);
            double scaleRatio = _cell.GetScale(subCellIndex) / 100;

            Point location = _cell.GetDisplayedImageRectangle().Location;

            AnnContainer container = subCell.AnnotationContainer;
            double       scale     = _cell.GetScale(subCellIndex);

            LeadSizeD fusionEditRectSize = new LeadSizeD();

            fusionEditRectSize.Width  = fusion.FusedImage.Width * fusion.DisplayRectangle.Width * scale / 100;
            fusionEditRectSize.Height = fusion.FusedImage.Height * fusion.DisplayRectangle.Height * scale / 100;

            fusionEditRectSize = container.Mapper.SizeToContainerCoordinates(fusionEditRectSize);

            LeadPointD fusionEditRectPos = new LeadPointD();

            fusionEditRectPos.X = (subCell.AnnotationContainer.Size.Width - fusionEditRectSize.Width) / 2;
            fusionEditRectPos.Y = (subCell.AnnotationContainer.Size.Height - fusionEditRectSize.Height) / 2;

            //container.Bounds
            fusionEditRect.Rect = new LeadRectD(fusionEditRectPos, fusionEditRectSize);

            AnnContainer _Container = GetContainer(_cell, fusionEditRect);

            fusionEditRect.Rotate(fusion.Rotation, new LeadPointD(_Container.Size.Width / 2, _Container.Size.Height / 2));
            LeadPointD point = LeadPointD.Create(fusion.DisplayRectangle.X * fusion.FusedImage.Width * scaleRatio + location.X, fusion.DisplayRectangle.Y * fusion.FusedImage.Height * scaleRatio + location.Y);

            point = _Container.Mapper.PointToContainerCoordinates(point);
            fusionEditRect.Translate(point.X, point.Y);

            fusionEditRect.RotateCenter = new LeadPointD(fusionEditRect.Rect.Left + (fusionEditRect.Rect.Width / 2), fusionEditRect.Rect.Top + (fusionEditRect.Rect.Height / 2));

            _cell.RefreshAnnotation();
            _cell.Automation.Invalidate(LeadRectD.Empty);
            _cell.Invalidate();
        }
コード例 #5
0
        private void UpdateFusionUI(int index)
        {
            SuspendUpdate();
            int subCellIndex = _cell.ActiveSubCell;

            _cmbOrgImagePalette.SelectedIndex = (int)_cell.SubCells[subCellIndex].PaletteType;

            if (index >= 0 && _cell.SubCells[subCellIndex].Fusion.Count > index)
            {
                MedicalViewerSubCell subCell = _cell.SubCells[subCellIndex];
                MedicalViewerFusion  fusion  = subCell.Fusion[index];

                _cmbPalette.SelectedIndex = (int)fusion.ColorPalette;
                _txtWLWidth.Text          = fusion.Width.ToString();
                _txtWLCenter.Text         = fusion.Center.ToString();

                UpdatePalettePreview(_cmbPalette, _palettePreview);

                _txtOffsetX.Text = (fusion.DisplayRectangle.X * fusion.FusedImage.Width).ToString("#0.000");
                _txtOffsetY.Text = (fusion.DisplayRectangle.Y * fusion.FusedImage.Height).ToString("#0.000");

                _chkFit.Checked = (Math.Abs(fusion.DisplayRectangle.Width - 1) < 0.0001 && Math.Abs(fusion.DisplayRectangle.Height - 1) < 0.0001);

                _txtScaleX.Text    = (fusion.DisplayRectangle.Width * 100).ToString("#0.000");
                _txtScaleX.Enabled = !_chkFit.Checked;
                _txtScaleY.Text    = (fusion.DisplayRectangle.Height * 100).ToString("#0.000");
                _txtScaleY.Enabled = !_chkFit.Checked;

                _txtRotate.Text = fusion.Rotation.ToString("#0.000");

                _txtRotate.Refresh();

                _txtOffsetX.Refresh();
                _txtOffsetY.Refresh();

                _txtScaleX.Refresh();
                _txtScaleY.Refresh();
                _chkFit.Refresh();
            }

            ResumeUpdate();
        }
コード例 #6
0
        private void _btnAdd_Click(object sender, EventArgs e)
        {
            string      seriesName;
            string      seriesPath;
            RasterImage image = _form.LoadFusionDicom(out seriesName, out seriesPath, this);

            if (image == null)
            {
                return;
            }

            _listFusionImages.Items.Add(seriesName);
            _cellFusionPaths.Add(seriesPath);
            _weightList.Add(_listFusionImages.Items.Count == 1 ? 50 : /*GetFusionDefaultValue()*/ 0);

            int index = _listFusionImages.Items.Count - 1;

            MedicalViewerFusion fusion = new MedicalViewerFusion();

            fusion.FusedImage  = image;
            fusion.FusionScale = _weightList[index] / 100.0f;


            RasterImage virtualImage = _cell.VirtualImage[_cell.ActiveSubCell].Image;

            float fitScaleX = virtualImage.Width * 1.0f / image.Width;
            float fitScaleY = virtualImage.Height * 1.0f / image.Height;

            fusion.DisplayRectangle = new RectangleF(0, 0, fitScaleX, fitScaleY);
            _images.Add(image);

            _cell.SubCells[_cell.ActiveSubCell].Fusion.Add(fusion);

            AddFusionEditRectangle(_cell.SubCells[_cell.ActiveSubCell]);

            _listFusionImages.SelectedIndex = index;

            UpdateText();
            UpdateUI();
        }
コード例 #7
0
        private void UpdateFusion()
        {
            if (!_update)
            {
                return;
            }

            int subCellIndex = _cell.ActiveSubCell;
            int index        = _cmbFusedIndex.SelectedIndex;

            MedicalViewerSubCell subCell = _cell.SubCells[subCellIndex];
            MedicalViewerFusion  fusion  = subCell.Fusion[index];

            UpdatePalettePreview(_cmbPalette, _palettePreview);

            if (_txtWLWidth.Text == "")
            {
                fusion.Width = 1;
            }
            else
            {
                fusion.Width = Convert.ToInt32(_txtWLWidth.Text);
            }

            if (_txtWLCenter.Text == "")
            {
                fusion.Center = 0;
            }
            else
            {
                fusion.Center = Convert.ToInt32(_txtWLCenter.Text);
            }

            fusion.ColorPalette = (MedicalViewerPaletteType)_cmbPalette.SelectedIndex;

            if (_txtOffsetX.Text == "")
            {
                fusion.DisplayRectangle = new RectangleF(0, fusion.DisplayRectangle.Y, fusion.DisplayRectangle.Width, fusion.DisplayRectangle.Height);
            }
            else
            {
                try
                {
                    float offsetX = float.Parse(_txtOffsetX.Text) / fusion.FusedImage.Width;
                    fusion.DisplayRectangle = new RectangleF(offsetX, fusion.DisplayRectangle.Y, fusion.DisplayRectangle.Width, fusion.DisplayRectangle.Height);
                }
                catch { }
            }

            if (_txtOffsetY.Text == "")
            {
                fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, 0, fusion.DisplayRectangle.Width, fusion.DisplayRectangle.Height);
            }
            else
            {
                try
                {
                    float offsetY = float.Parse(_txtOffsetY.Text) / fusion.FusedImage.Height;
                    fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, offsetY, fusion.DisplayRectangle.Width, fusion.DisplayRectangle.Height);
                }
                catch { }
            }


            RasterImage image = _cell.VirtualImage[subCellIndex].Image;

            float fitScaleX = image.Width * 1.0f / fusion.FusedImage.Width;
            float fitScaleY = image.Height * 1.0f / fusion.FusedImage.Height;

            float xScale = 0.001f;

            if (_txtScaleX.Text != "")
            {
                xScale = Math.Max(xScale, float.Parse(_txtScaleX.Text));
            }

            float yScale = 0.001f;

            if (_txtScaleY.Text != "")
            {
                yScale = Math.Max(yScale, float.Parse(_txtScaleY.Text));
            }

            if (_txtScaleX.Text == "")
            {
                fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, fusion.DisplayRectangle.Y, 1, fusion.DisplayRectangle.Height);
            }
            else
            {
                fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, fusion.DisplayRectangle.Y, _chkFit.Checked ? fitScaleX : xScale / 100.0f, fusion.DisplayRectangle.Height);
            }

            if (_txtScaleY.Text == "")
            {
                fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, fusion.DisplayRectangle.Y, fusion.DisplayRectangle.Width, 1);
            }
            else
            {
                fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, fusion.DisplayRectangle.Y, fusion.DisplayRectangle.Width, _chkFit.Checked ? fitScaleY : yScale / 100.0f);
            }

            if (_txtRotate.Text == "")
            {
                fusion.Rotation = 0;
            }
            else
            {
                try
                {
                    fusion.Rotation = float.Parse(_txtRotate.Text);
                }
                catch { }
            }


            UpdateFusionEditRectangle(index);

            CellData cellData = (CellData)_cell.Tag;

            if (cellData.SyncCellFusion)
            {
                UpdateCellFusions(fusion, subCellIndex, index);
            }
        }