示例#1
0
        public void InitializeRender(EventType eventType, viz.Context context)
        {
            switch (eventType)
            {
            case EventType.Monitor:
                Debug.Assert(this.monitorData != null);
                if ((this.monitorData.imageWidth != 0) && (this.monitorData.imageHeight != 0) && (this.monitorData.sharedDepthFrame != null))
                {
                    DepthPlugin.CreateTextures(this.monitorData, context);
                    if (this.monitorData.depthMap != null)
                    {
                        unsafe
                        {
                            this.monitorData.depthMap.UpdateData((ushort *)this.monitorData.sharedDepthFrame.Buffer, this.monitorData.sharedDepthFrame.Size);
                        }
                    }
                }
                break;

            case EventType.Inspection:
                Debug.Assert(this.inspectionData != null);
                if ((this.inspectionData.imageWidth != 0) && (this.inspectionData.imageHeight != 0) && (this.inspectionData.sharedDepthFrame != null))
                {
                    DepthPlugin.CreateTextures(this.inspectionData, context);
                    if (this.inspectionData.depthMap != null)
                    {
                        unsafe
                        {
                            this.inspectionData.depthMap.UpdateData((ushort *)this.inspectionData.sharedDepthFrame.Buffer, this.inspectionData.sharedDepthFrame.Size);
                        }
                    }
                }
                break;
            }
        }
示例#2
0
        private void HandleEvent(EventType eventType, KStudioEvent eventObj, EventTypePluginData data)
        {
            Debug.Assert(data != null);

            if (eventObj != null)
            {
                bool doDataEvent    = false;
                bool doVisibleEvent = false;

                if ((eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.Depth) ||
                    (eventObj.EventStreamDataTypeId == HackKStudioEventStreamDataTypeIds.DepthMonitor))
                {
                    lock (this.lockObj)
                    {
                        bool isSelectedData = (this.selectedData == data);

                        HGlobalBuffer newSharedFrame = eventObj.GetRetainableEventDataBuffer();
                        doVisibleEvent        = isSelectedData && (newSharedFrame == null) != (data.sharedDepthFrame == null);
                        data.sharedDepthFrame = newSharedFrame;

                        uint newWidth  = nui.Constants.STREAM_DEPTH_WIDTH;
                        uint newHeight = nui.Constants.STREAM_DEPTH_HEIGHT;

                        if ((data.depthMap == null) || (newWidth != data.imageWidth) || (newHeight != data.imageHeight))
                        {
                            viz.Context context = null;
                            if (this.pluginService != null)
                            {
                                context = this.pluginService.GetContext(eventType);
                            }

                            data.imageWidth  = newWidth;
                            data.imageHeight = newHeight;

                            DepthPlugin.CreateTextures(data, context);
                        }

                        if (data.sharedDepthFrame != null)
                        {
                            unsafe
                            {
                                data.depthMap.UpdateData((ushort *)data.sharedDepthFrame.Buffer, data.sharedDepthFrame.Size);
                            }
                        }

                        if (DepthPlugin.UpdateSelectedPixelValue(data))
                        {
                            doDataEvent = isSelectedData;
                        }
                    }

                    if (doVisibleEvent)
                    {
                        this.RaisePropertyChanged("HasSelected2DPixelData");
                    }

                    if (doDataEvent)
                    {
                        this.RaisePropertyChanged("Selected2DPixelDepth");
                    }
                }
            }
        }