/// <summary> /// calculates all limbs as defined by limb calculator /// </summary> /// <param name="sender">the object</param> /// <param name="e">the routed event</param> private void LimbOption_Click(object sender, RoutedEventArgs e) { /*Create an array of type tuple<double,double,List<List<Point3D>>> * as limbs will all be calculated before displaying history loader * results, not partic. efficient but fine given the restriction.*/ //gets all the planes by calling volume calculator //kinect sensor check is here, can't use coord mapper otherwise. if (KinectSensor.KinectSensors.Count > 0) { Tuple <List <List <Point3D> >, double> T = PlanePuller.pullAll(pcd); List <List <Point3D> > planes = T.Item1; /*Requires generated model, raw depth array and previous*/ List <Tuple <double, double, List <List <Point3D> > > > result = windowScanner.determineLimb(pcd, VolumeCalculator.calculateApproxWeight(volume)); if (windowHistory == null) { windowHistory = new HistoryLoader(); windowHistory.Owner = this; windowHistory.history.Visibility = Visibility.Collapsed; System.Diagnostics.Debug.WriteLine("History loader was null, now set."); } windowHistory.limbcircum.Visibility = Visibility.Visible; windowHistory.history.Visibility = Visibility.Visible; windowHistory.runtimeTab.SelectedIndex = 1; windowHistory.Show(); windowHistory.visualiseLimbs(result, 1, 1); } else { MessageBoxResult result = System.Windows.MessageBox.Show(this, "You need a Kinect to perform this action.", "Kinect Sensor Missing", MessageBoxButton.OK, MessageBoxImage.Stop); } }
/// <summary> /// displays a new scan loader screen /// </summary> /// <param name="sender">the object</param> /// <param name="e">the routed event</param> private void NewScan_Click(object sender, RoutedEventArgs e) { if (this.noSensor()) { return; } this.shutAnyWindows(); this.resetButtons(); this.kinectInterp.calibrate(); windowScanner = new ScanLoader((int)ScanLoader.OperationModes.CaptureNewCloud); windowScanner.Owner = this; windowScanner.Show(); windowHistory = new HistoryLoader(); windowHistory.Owner = this; windowHistory.history.Visibility = Visibility.Collapsed; }
/// <summary> /// fine tunes the point cloud (just removes floor) /// </summary> /// <param name="sender">the object</param> /// <param name="e">the routed event</param> private void RemoveFeet_Click(object sender, RoutedEventArgs e) { for (int i = 0; i < pcdl.Count; i++) { pcdl[i].deleteFloor(); if ((this.windowPatient.nameText.Text.CompareTo("Greg Corbett")) == 0) { pcdl[i].deleteFloor(); //again } } this.calculate.IsEnabled = true; this.measurement.IsEnabled = true; this.shutAnyWindows(); windowScanner = new ScanLoader((int)ScanLoader.OperationModes.ShowExistingResults); windowScanner.Owner = this; // Do UI stuff on UI thread this.export1.IsEnabled = false; this.export2.IsEnabled = false; this.removefloor.IsEnabled = true; //define windowHistory = new HistoryLoader(); windowHistory.Owner = this; windowHistory.history.Visibility = Visibility.Collapsed; // Background thread to get all the heavy computation off of the UI thread /* * BackgroundWorker B = new BackgroundWorker(); */ //TODO Confirm we don't need this - the point cloud is loaded and stitched already? //B.DoWork += new DoWorkEventHandler(loadScanThread); /* * // Catch the progress update events * B.WorkerReportsProgress = true; * B.ProgressChanged += new ProgressChangedEventHandler((obj, args) => * { * windowScanner.loadingwidgetcontrol.UpdateProgressBy(args.ProgressPercentage); * if (args.UserState != null) * { * if (args.UserState is string) * { * System.Diagnostics.Debug.WriteLine((string)args.UserState); * } * else if (args.UserState is Action) * { * ((Action)args.UserState)(); * } * } * }); * B.RunWorkerCompleted += new RunWorkerCompletedEventHandler((obj, args) => * {*/ windowScanner.processCloudList(pcdl, windowScanner.loadingwidgetcontrol); /* * }); * * * // GOOO!!! Pass the file name so it can be loaded * B.RunWorkerAsync(null); */ }
/// <summary> /// runs the volume calculation subroutine on an open point cloud/patient /// </summary> /// <param name="sender">the object</param> /// <param name="e">the routed event</param> private void VolumeOption_Click(object sender, RoutedEventArgs e) { //Static call to volume calculation method, pass persistent point cloud object if (windowHistory == null) { windowHistory = new HistoryLoader(); windowHistory.Owner = this; windowHistory.history.Visibility = Visibility.Collapsed; System.Diagnostics.Debug.WriteLine("History loader was null, now set."); } windowHistory.limbcircum.Visibility = Visibility.Collapsed; Tuple <List <List <Point3D> >, double> T = PlanePuller.pullAll(pcd); List <List <Point3D> > planes = T.Item1; double increment = T.Item2; volume = VolumeCalculator.volume1stApprox(planes, increment); volume = Math.Round(volume, 4); List <double> areaList = AreaCalculator.getAllAreas(planes); windowHistory.areaList = areaList; windowHistory.runtimeTab.SelectedIndex = 0; windowHistory.visualisePlanes(planes, 1); windowHistory.voloutput.Content = volume + "m\u00B3"; windowHistory.heightoutput.Content = HeightCalculator.getHeight(pcd) + "m"; windowHistory.scantime.Content = "Weight (Est): " + VolumeCalculator.calculateApproxWeight(volume) + "kg"; windowHistory.scanfileref.Content = "BMI Measure: " + VolumeCalculator.calculateBMI(HeightCalculator.getHeight(pcd), VolumeCalculator.calculateApproxWeight(volume)); windowHistory.scanvoxel.Content = "Siri (%BF): " + VolumeCalculator.calculateSiri(volume, VolumeCalculator.calculateApproxWeight(volume), HeightCalculator.getHeight(pcd)) + "%"; //show Runtime viewer (aka results,history) windowHistory.Show(); List <Tuple <DateTime, double> > records = this.getTimeStampsAndVals((int)Convert.ToInt64(windowPatient.patientIDExisting.Content)); int historyLookBack = 5; if ((records != null) && (records.Count > 0)) { int size = Math.Min(records.Count, historyLookBack); KeyValuePair <DateTime, double>[] records2 = new KeyValuePair <DateTime, double> [size]; for (int i = 0; i < size; i++) { records2[i] = new KeyValuePair <DateTime, double>(records[i].Item1, records[i].Item2); } //set change in volume... may need refinement if (size != 0) { double change = 0; change = (volume - records[records.Count - 1].Item2) / records[records.Count - 1].Item2;//may need to become records[records.Count-2].Item2 later windowHistory.volchangeoutput.Content = Math.Round(100 * change, 2) + "%"; } else { windowHistory.volchangeoutput.Content = "Not Enough Data"; windowHistory.volchart.Visibility = Visibility.Collapsed; } //setData ((LineSeries)(windowHistory.volchart.Series[0])).ItemsSource = records2; } else { windowHistory.volchangeoutput.Content = "Not Enough Data"; windowHistory.volchart.Visibility = Visibility.Collapsed; } }