Esempio n. 1
0
        /// <summary>
        /// Renders the Xray image on the CPU.
        /// </summary>
        /// <param name="bsource"></param>
        /// <param name="sourceObject"></param>
        /// <param name="viewObject"></param>
        /// <param name="xrayImageEffect"></param>
        /// <param name="trimatEffect"></param>
        /// <param name="effects"></param>
        /// <param name="displayWidth"></param>
        /// <param name="displayHeight"></param>
        /// <param name="adornerLayerManager"></param>
        /// <param name="displayAnnotations"></param>
        /// <param name="displayMeasurements"></param>
        /// <returns>The newly rendered bitmap.</returns>
        public static BitmapSource GetRenderedXrayImage(BitmapSource bsource,
                                                        SourceObject sourceObject,
                                                        ViewObject viewObject,
                                                        ShaderEffect xrayOrTrimateImageEffect,
                                                        List<Effect> effects,
                                                        double displayWidth,
                                                        double displayHeight,
                                                        AdornerLayerManager adornerLayerManager,
                                                        bool displayAnnotations,
                                                        bool displayMeasurements)
        {
            if (xrayOrTrimateImageEffect != null && xrayOrTrimateImageEffect.GetType() == typeof(XrayImageEffect))
            {
                RenderXrayImage_XRayImageEffect(ref bsource, (XrayImageEffect)xrayOrTrimateImageEffect, sourceObject);
            }
            //else if (xrayOrTrimateImageEffect.GetType() == typeof(TrimatEffect))
            //{
            //    RenderXrayImage_TrimatEffect(ref bsource, (TrimatEffect)xrayOrTrimateImageEffect, sourceObject, viewObject);
            //}
            foreach (Effect effect in effects)
            {
                ApplyEffectToBitmap(ref bsource, effect);
            }
            if (displayAnnotations)
            {
                RenderAnnotations(ref bsource, displayWidth, displayHeight, adornerLayerManager);
            }
            if (displayMeasurements)
            {
                RenderMeasurements(ref bsource, displayWidth, displayHeight, adornerLayerManager);
            }

            return bsource;
        }
Esempio n. 2
0
 public void Setup (ViewObject content)
 {
     AOIXRayView.Setup(content, new History(), null);
     AOIXRayView.CollapseDualEnergy(true);
 }
Esempio n. 3
0
        private List<ViewObject> GetImageData()
        {
            List<ViewObject> ret = new List<ViewObject>();

            MemoryStream tipMS = null;

            bool injectTIP = false;

            TIPStatus tipStatus;

            if (m_CaseObj.caseType == CaseType.FTICase)
            {
                DataAttachment ftiAttachment = null;
                foreach (DataAttachment attachment in m_CaseObj.attachments.GetFTIImageAttachments())
                {
                    tipMS = attachment.attachmentData;
                    injectTIP = true;
                    ftiAttachment = attachment;
                    break;
                }

                m_CaseObj.attachments.Remove(ftiAttachment);
            }

            foreach (DataAttachment attachment in m_CaseObj.attachments.GetXrayImageAttachments())
            {
                MemoryStream ms = attachment.attachmentData;

                System.Windows.Rect view0Rect = new System.Windows.Rect();
                System.Windows.Rect view1Rect = new System.Windows.Rect();

                if (injectTIP)
                {
                    tipStatus = new TIPStatus();

                    _PxeAccess.OpenPXEImageFromMemoryWithTIP(ms, tipMS, ref tipStatus);

                    if (tipStatus.injectionsucess == 0)
                    {
                        m_CaseObj.IsCaseEditable = false;
                        m_SysConfig.SelectedArchiveDuringAutoSelect = true;
                        m_DisplayFTIError = true;
                    }
                    else
                    {
                        view0Rect = new System.Windows.Rect(new Point((double)tipStatus.injectLocation_view0.left,
                                                       (double)tipStatus.injectLocation_view0.top),
                                             new Point((double)tipStatus.injectLocation_view0.right,
                                                       (double)tipStatus.injectLocation_view0.bottom));

                        view1Rect = new System.Windows.Rect(new Point((double)tipStatus.injectLocation_view1.left,
                                                       (double)tipStatus.injectLocation_view1.top),
                                             new Point((double)tipStatus.injectLocation_view1.right,
                                                       (double)tipStatus.injectLocation_view1.bottom));
                    }
                }
                else
                {
                    _PxeAccess.OpenPXEImageFromMemory(ms);
                }

                if (_PxeAccess.GetPxeHeader().sequenceNum != null)
                {
                    if (m_CaseObj.scanInfo == null)
                    {
                        m_CaseObj.scanInfo = new ScanInfo();
                    }

                    if (m_CaseObj.scanInfo.container == null)
                    {
                        m_CaseObj.scanInfo.container = new Container();
                    }

                    m_CaseObj.scanInfo.container.SequenceNum = _PxeAccess.GetPxeHeader().sequenceNum.ToString();
                }

                if (_PxeAccess.GetPxeHeader().batchNumber != null)
                {
                    if (m_CaseObj.scanInfo == null)
                    {
                        m_CaseObj.scanInfo = new ScanInfo();
                    }

                    if (m_CaseObj.scanInfo.conveyance == null)
                    {
                        m_CaseObj.scanInfo.conveyance = new Conveyance();
                    }

                    m_CaseObj.scanInfo.conveyance.BatchNum = _PxeAccess.GetPxeHeader().batchNumber.ToString();
                }

                if (_PxeAccess.GetPxeHeader().viewBuffer_0.isValidView != 0)
                {
                    SourceObject highEnergy = null;
                    SourceObject lowEnergy = null;
                    ViewType viewType = ViewType.Unknown;

                    int width = (int)_PxeAccess.GetPxeHeader().viewBuffer_0.width;
                    int height = (int)_PxeAccess.GetPxeHeader().viewBuffer_0.height;

                    if (_PxeAccess.GetPxeHeader().viewBuffer_0.isDualEnergy != 0)
                    {
                        highEnergy = new SourceObject(_PxeAccess.GetImageBuffer("RawH"), width, height, m_SysConfig.FlipView1XAxis, m_SysConfig.FlipView1YAxis);
                        lowEnergy = new SourceObject(_PxeAccess.GetImageBuffer("RawL"), width, height, m_SysConfig.FlipView1XAxis, m_SysConfig.FlipView1YAxis);
                        viewType = ViewType.DualEnergy;
                    }
                    else if (width > 0 && height > 0 && _PxeAccess.GetPxeHeader().viewBuffer_0.isHighEnergy != 0)
                    {
                        highEnergy = new SourceObject(_PxeAccess.GetImageBuffer("RawH"), width, height, m_SysConfig.FlipView1XAxis, m_SysConfig.FlipView1YAxis);
                        viewType = ViewType.HighEnergy;
                    }
                    else if (width > 0 && height > 0 && _PxeAccess.GetPxeHeader().viewBuffer_0.isHighEnergy == 0)
                    {
                        lowEnergy = new SourceObject(_PxeAccess.GetImageBuffer("RawL"), width, height, m_SysConfig.FlipView1XAxis, m_SysConfig.FlipView1YAxis);
                        viewType = ViewType.LowEnergy;
                    }

                    ViewObject viewObj = new ViewObject("View0",
                                                        _PxeAccess.GetPxeHeader().pxeIndex,
                                                        viewType,
                                                        highEnergy,
                                                        lowEnergy,
                                                        _PxeAccess.GetPxeHeader().detectorsPerBoard,
                                                        _PxeAccess.GetPxeHeader().bitsPerPixel,
                                                        _PxeAccess.GetPxeHeader().samplingSpeed,
                                                        _PxeAccess.GetPxeHeader().samplingSpace,
                                                        GetAnnotationsForView("View0"));

                    if (injectTIP)
                    {
                        viewObj.TIPMarkings = new List<System.Windows.Rect>();
                        viewObj.TIPMarkings.Add(view0Rect);
                    }

                    ret.Add(viewObj);
                }

                if (_PxeAccess.GetPxeHeader().viewBuffer_1.isValidView != 0)
                {
                    SourceObject highEnergy = null;
                    SourceObject lowEnergy = null;
                    ViewType viewType = ViewType.Unknown;

                    int width = (int)_PxeAccess.GetPxeHeader().viewBuffer_1.width;
                    int height = (int)_PxeAccess.GetPxeHeader().viewBuffer_1.height;

                    if (_PxeAccess.GetPxeHeader().viewBuffer_0.isDualEnergy != 0)
                    {
                        highEnergy = new SourceObject(_PxeAccess.GetImageBuffer("RawH1"), width, height, m_SysConfig.FlipView2XAxis, m_SysConfig.FlipView2YAxis);
                        lowEnergy = new SourceObject(_PxeAccess.GetImageBuffer("RawL1"), width, height, m_SysConfig.FlipView2XAxis, m_SysConfig.FlipView2YAxis);
                        viewType = ViewType.DualEnergy;
                    }
                    else if (width > 0 && height > 0 && _PxeAccess.GetPxeHeader().viewBuffer_0.isHighEnergy != 0)
                    {
                        highEnergy = new SourceObject(_PxeAccess.GetImageBuffer("RawH1"), width, height, m_SysConfig.FlipView2XAxis, m_SysConfig.FlipView2YAxis);
                        viewType = ViewType.HighEnergy;
                    }
                    else if (width > 0 && height > 0 && _PxeAccess.GetPxeHeader().viewBuffer_0.isHighEnergy == 0)
                    {
                        lowEnergy = new SourceObject(_PxeAccess.GetImageBuffer("RawL1"), width, height, m_SysConfig.FlipView2XAxis, m_SysConfig.FlipView2YAxis);
                        viewType = ViewType.LowEnergy;
                    }

                    ViewObject viewObj = new ViewObject("View1",
                                                        _PxeAccess.GetPxeHeader().pxeIndex,
                                                        viewType,
                                                        highEnergy,
                                                        lowEnergy,
                                                        _PxeAccess.GetPxeHeader().detectorsPerBoard,
                                                        _PxeAccess.GetPxeHeader().bitsPerPixel,
                                                        _PxeAccess.GetPxeHeader().samplingSpeed,
                                                        _PxeAccess.GetPxeHeader().samplingSpace,
                                                        GetAnnotationsForView("View1"));

                    if (injectTIP)
                    {
                        viewObj.TIPMarkings = new List<System.Windows.Rect>();
                        viewObj.TIPMarkings.Add(view1Rect);
                    }

                    ret.Add(viewObj);
                }
            }

            return ret;
        }
Esempio n. 4
0
        public XRayImage (ViewObject viewObject, StatusBarItems statusBarItems, History history, SysConfiguration SysConfig)
        {
            InitializeComponent();
            CultureResources.registerDataProvider(this);

            m_MagnifierSettings.IsMagniferEnabled = false;
            m_MagnifierSettings.Radius = 0;
            m_MagnifierSettings.MagnFactor = 2.0;
            m_MagnifierSettings.AspectRatio = 0;
            m_MaxDetectorsPerBoard = viewObject.MaxDetectorsPerBoard;
            m_bitsPerPixel = viewObject.BitsPerPixel;
            m_ViewObject = viewObject;
            m_statusBarItems = statusBarItems;

            XRayView_ContextMenu.Opened += new RoutedEventHandler(XRayView_ContextMenu_Changed);
            XRayView_ContextMenu.Closed += new RoutedEventHandler(XRayView_ContextMenu_Changed);

            MainXRayView.Setup(viewObject, history, SysConfig);

            MainXRayView.Cursor = Cursors.Hand;
            MainXRayView.MainImage.MouseMove += new MouseEventHandler(Img_MouseMove);
            MainXRayView.MainImage.MouseLeave += new MouseEventHandler(Img_MouseLeave);

            MainXRayView.Magnifier_Panel.SizeChanged += new SizeChangedEventHandler(Magnifier_SizeChanged);
            MainXRayView.Magnifier_Panel.MouseMove += new MouseEventHandler(Magnifier_MouseMove);
            MainXRayView.Magnifier_Panel.MouseLeftButtonDown += new MouseButtonEventHandler(Magnifier_MouseMove);

            if (viewObject.TIPMarkings != null)
            {
                HideFTILocations();

                //foreach (Rect rect in viewObject.TIPMarkings)
                //{
                //    MainXRayView.adonerImageObject.TIPAdorner.Add(rect);
                //}
            }

            MainXRayView.AlgServerRequestEvent += new AlgServerRequestEventHandler(MainXRayView_AlgServerRequestEvent);
        }
Esempio n. 5
0
        public void Dispose ()
        {
            CultureResources.getDataProvider().DataChanged -= this.CultureResources_DataChanged;
            HistoryList.IsOpen = false;

            PseudoColor_ComboBox.Items.Clear();
            PseudoColor_ComboBox = null;

            m_Filters.Clear();
            m_Filters = null;

            m_FilterManager.Dispose();
            m_FilterManager = null;

            m_SourceObject = null;
            m_History = null;

            PanAndZoomControl.Content = null;
            PanAndZoomControl = null;

            m_ViewObject.Dispose();
            m_ViewObject = null;
        }
Esempio n. 6
0
        public void Setup (ViewObject content, History history, SysConfiguration sysConfig)
        {
            if (!IsSetup)
            {
                m_ViewObject = content;

                m_History = history;
                m_History.CurrentHistoryChangedEvent += new CurrentHistoryChanged(ApplyHistory);

                if (m_ViewObject.HighEnergy != null)
                {
                    m_SourceObject = m_ViewObject.HighEnergy;
                    HEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/HEOn.png", UriKind.Relative));
                    LEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/LEOff.png", UriKind.Relative));
                }
                else if (m_ViewObject.LowEnergy != null)
                {
                    m_SourceObject = m_ViewObject.LowEnergy;
                    HEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/HEOff.png", UriKind.Relative));
                    LEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/LEOn.png", UriKind.Relative));
                }
                else
                {
                    throw new Exception();
                }

                if (m_ViewObject.LowEnergy == null ||
                    m_ViewObject.HighEnergy == null)
                {
                    XRayDualEnergy_ToolBar.Visibility = Visibility.Collapsed;
                }
                else
                {
                    HistoryDualEnergy dualEnergy = new HistoryDualEnergy();
                    dualEnergy.name = "HighEnergy";
                    m_History.SetFirstStep(dualEnergy);
                }

                if (sysConfig != null)
                {
                    m_sysConfig = sysConfig;
                    CreateUserMacroControls();
                    Macro_Toolbar.Visibility = Visibility.Visible;
                }

                CreateBufferControls();

                CreateFilterControls();

                CreateColorMappingControls();

                MainImage.Source = m_SourceObject.Source;
                MainImage.Height = m_SourceObject.Height;
                MainImage.Width = m_SourceObject.Width;
                
                HistoryBuffer buffer = new HistoryBuffer();
                buffer.name = "Original Gray Scale";

                m_History.SetFirstStep(buffer);

                HistoryList.DataContext = m_History.Step;

                IsApplyHistoryFromSetup = true;

                m_History.ApplyStep();

                IsApplyHistoryFromSetup = false;

                IsSetup = true;
            }
        }
Esempio n. 7
0
 public void Setup (ViewObject viewObj)
 {
     m_ViewObject = viewObj;
 }
Esempio n. 8
0
        protected void CreateWindow (Point startPoint, Point endPoint)
        {
            startPoint = FitPointInImage(startPoint);
            endPoint = FitPointInImage(endPoint);
            
            for (int index = m_AOIWindows.Count - 1; index >= 0; index--)
            {
                if (m_AOIWindows[index].IsLoaded == false)
                {
                    m_AOIWindows.RemoveAt(index);
                }
            }

            //TODO: This needs to be configurable
            if (m_AOIWindows.Count >= 3)
            {
                return;
            }


            if (startPoint.X > endPoint.X)
            {
                double temp = endPoint.X;
                endPoint.X = startPoint.X;
                startPoint.X = temp;
            }

            if (startPoint.Y > endPoint.Y)
            {
                double temp = endPoint.Y;
                endPoint.Y = startPoint.Y;
                startPoint.Y = temp;
            }

            SourceObject highEnergy = null;
            SourceObject lowEnergy = null;
            SourceObject trimat = null;
            ViewType viewType = ViewType.Unknown;

            if (m_ViewObject.HighEnergy != null)
            {
                double heightratio = m_ViewObject.HighEnergy.Height / base.ActualHeight;
                double widthratio = m_ViewObject.HighEnergy.Width / base.ActualWidth;

                int StartX = (int)(startPoint.X * widthratio);
                int StartY = (int)(startPoint.Y * heightratio);
                int EndX = (int)(endPoint.X * widthratio);
                int EndY = (int)(endPoint.Y * heightratio);

                int width = EndX - StartX;
                int height = EndY - StartY;

                float[] data = new float[width * height];

                for (int j = StartY, k = 0; j < EndY; j++, k++)
                {
                    for (int i = StartX, l = 0; i < EndX; i++, l++)
                    {
                        data[(k * width) + l] = m_ViewObject.HighEnergy.Data[(j * m_ViewObject.HighEnergy.Width) + i];
                    }
                }

                highEnergy = new SourceObject(data, width, height, false, false);
                viewType = ViewType.HighEnergy;
            }

            if (m_ViewObject.LowEnergy != null)
            {
                double heightratio = m_ViewObject.LowEnergy.Height / base.ActualHeight;
                double widthratio = m_ViewObject.LowEnergy.Width / base.ActualWidth;

                int StartX = (int)(startPoint.X * widthratio);
                int StartY = (int)(startPoint.Y * heightratio);
                int EndX = (int)(endPoint.X * widthratio);
                int EndY = (int)(endPoint.Y * heightratio);

                int width = EndX - StartX;
                int height = EndY - StartY;

                float[] data = new float[width * height];

                for (int j = StartY, k = 0; j < EndY; j++, k++)
                {
                    for (int i = StartX, l = 0; i < EndX; i++, l++)
                    {
                        data[(k * width) + l] = m_ViewObject.LowEnergy.Data[(j * m_ViewObject.LowEnergy.Width) + i];
                    }
                }

                lowEnergy = new SourceObject(data, width, height, false, false);
                viewType = ViewType.LowEnergy;
            }

            ViewObject viewObj = new ViewObject(m_ViewObject.Name, m_ViewObject.ImageIndex, viewType, highEnergy, lowEnergy, m_ViewObject.MaxDetectorsPerBoard, m_ViewObject.BitsPerPixel, m_ViewObject.SamplingSpeed, m_ViewObject.SamplingSpace, new List<AnnotationInfo>());
            try
            {
                AOIWindow window = new AOIWindow();
                window.AlgServerRequestEvent += new AlgServerRequestEventHandler(AOIWindow_AlgServerRequestEvent);
                window.Setup(viewObj);
                window.AOIXRayView.MainImage.Width = (int)(endPoint.X - startPoint.X);
                window.AOIXRayView.MainImage.Height = (int)(endPoint.Y - startPoint.Y);
                window.Show();

                foreach (AOIWindow aoiWindow in m_AOIWindows)
                {
                    if (window.Top == aoiWindow.Top && (window.Left == aoiWindow.Left))
                    {
                        window.Top = aoiWindow.Top + 25;
                        window.Left = aoiWindow.Left + 25;
                    }
                }

                m_AOIWindows.Add(window);
            }
            catch (Exception ex)
            {

            }
        }