/////////////////////////////////////////////////////////////////////// // Make a linear ramp of data and display it. /////////////////////////////////////////////////////////////////////// private void GenerateRamps() { // Make A Frame 200x400 pixels ushort[] frame1 = new ushort[200 * 400]; for (int pix = 0; pix < 200 * 400; pix++) { frame1[pix] = (ushort)(pix % 400); } // Make A Frame 300x500 pixels with a 1k bias ushort[] frame2 = new ushort[300 * 500]; for (int pix = 0; pix < 300 * 500; pix++) { frame2[pix] = (ushort)((pix % 500) + 1000); } // Get the addin file manager var datamgr = LightFieldApplication.DataManager; if (datamgr != null) { RegionOfInterest roi = new RegionOfInterest(0, 0, 400, 200, 1, 1); RegionOfInterest roi2 = new RegionOfInterest(0, 0, 500, 300, 1, 1); // Simple Single Region IImageDataSet imageData = datamgr.CreateImageDataSet(frame1, roi, ImageDataFormat.MonochromeUnsigned16); RegionOfInterest[] rois = { roi, roi2 }; List <Array> buffers = new List <Array>(); buffers.Add(frame1); buffers.Add(frame2); // Complex Set Containing Two Regions IImageDataSet imageDataSets = datamgr.CreateImageDataSet(buffers, rois, ImageDataFormat.MonochromeUnsigned16); IDisplay display = LightFieldApplication.DisplayManager; if (display != null) { // Select Data File Compare Mode & 3 Vertical Windows display.ShowDisplay(DisplayLocation.ExperimentWorkspace, DisplayLayout.TwoHorizontal); IDisplayViewer view = null; // Modify the underlying data a little bit before displaying it. ModifyDataExample(imageData, 0); // Put the simple data in window 0 view = display.GetDisplay(DisplayLocation.ExperimentWorkspace, 0); view.Display("SimpleRamp", imageData); // Modify the underlying data a little bit before displaying it. ModifyDataExample(imageDataSets, 1); // Put the complex data in window 1 view = display.GetDisplay(DisplayLocation.ExperimentWorkspace, 1); view.Display("ComplexRamp", imageDataSets); } } }
//////////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////////// private void LoadFileButton_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = ""; // Default file name dlg.DefaultExt = ".spe"; // Default file extension dlg.Filter = "LightField Data (*.spe)|*.spe"; // Filter files by extension // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Data Workspace if (selectedLocation_ == DisplayLocation.DataWorkspace) { BuildDisplayControls(display_.DisplayFileInDataWorkspace(dlg.FileName)); } // Data Workspace Comparison + Experiment else { IDisplayViewer viewer = display_.GetDisplay(selectedLocation_, selectedIndex_); viewer.Display(dlg.FileName); BuildDisplayControls(viewer); } } }
/////////////////////////////////////////////////////////////////////// // Show 4 Plots of Cos vs Sine in Quad Display // 1.) Generates Raw Data // 2.) Builds IImageData(s) with the raw data from the DataManager. // 3.) Gets 4 Displays and Puts 2 Waveforms in each display. /////////////////////////////////////////////////////////////////////// private void PlotSinAndCos() { // Make two curves (720 = 2*PI so its a full cycle) ushort[] cosine = new ushort[720]; ushort[] sine = new ushort[720]; // Generate Curves (Amplitude 100) for (int pix = 0; pix < 720; pix++) { // Convert To Angle double angle = Math.PI * ((double)pix - 360) / 180.0; // Compute Points cosine[pix] = (ushort)((double)100 * (Math.Cos(angle) + (double)1)); sine[pix] = (ushort)((double)100 * (Math.Sin(angle) + (double)1)); } // Get the data manager var datamgr = LightFieldApplication.DataManager; if (datamgr != null) { RegionOfInterest roi = new RegionOfInterest(0, 0, 720, 1, 1, 1); // Create Blobs IImageDataSet cosData = datamgr.CreateImageDataSet(cosine, roi, ImageDataFormat.MonochromeUnsigned16); IImageDataSet sineData = datamgr.CreateImageDataSet(sine, roi, ImageDataFormat.MonochromeUnsigned16); // Get The Display Object IDisplay display = LightFieldApplication.DisplayManager; if (display != null) { // Select Data File Compare Mode & 4 Even Windows display.ShowDisplay(DisplayLocation.ExperimentWorkspace, DisplayLayout.FourEven); IDisplayViewer view = null; // Put the data in all 4 windows for (int i = 0; i <= 3; i++) { view = display.GetDisplay(DisplayLocation.ExperimentWorkspace, i); view.Display("Cosine", cosData); IDisplaySource sinSource = display.Create("Sine", sineData); view.Add(sinSource); } } } }