X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FGUI%2FState.fs;h=a1ae0521c01ea831a35876f05053eef6d4052366;hp=45025366d91c3eb4d78533cb5ac35b3f49b6bf1d;hb=999a48b8eb25c92e4403c9280fd4fe68f9bc4b7b;hpb=f4fdf61ef98b913129ddb771392c0bcb1475e6fb diff --git a/Parasitemia/Parasitemia/GUI/State.fs b/Parasitemia/Parasitemia/GUI/State.fs index 4502536..a1ae052 100644 --- a/Parasitemia/Parasitemia/GUI/State.fs +++ b/Parasitemia/Parasitemia/GUI/State.fs @@ -1,6 +1,7 @@ module Parasitemia.GUI.State open System.Collections.Generic +open System.Windows open Emgu.CV open Emgu.CV.Structure @@ -9,17 +10,17 @@ open Types type State () = let sourceImages = List() - let mutable currentImage = -1 + member val CurrentImage: SourceImage option = None with get, set member val FilePath: string = "" with get, set member val PatientID: string = "" with get, set member this.Save () = - let data = { Pia.sources = List.ofSeq sourceImages; Pia.patientID = this.PatientID } - Pia.save this.FilePath data + let data = { PiaZ.sources = List.ofSeq sourceImages; PiaZ.patientID = this.PatientID } + PiaZ.save this.FilePath data member this.Load () = - let data = Pia.load this.FilePath + let data = PiaZ.load this.FilePath this.PatientID <- data.patientID sourceImages.Clear() sourceImages.InsertRange(0, data.sources) @@ -27,12 +28,21 @@ type State () = member this.AddSourceImage (filePath: string) : SourceImage = let srcImg = { num = sourceImages.Count + 1; rbcs = []; img = new Image(filePath) } sourceImages.Add(srcImg) - if sourceImages.Count = 1 - then - currentImage <- 1 srcImg - member x.SourceImages : SourceImage seq = + member this.SetResult (num: int) (cells: Cell list) = + let sourceImage = sourceImages.Find(fun srcImg -> srcImg.num = num) + sourceImage.rbcs <- cells + |> List.filter (fun cell -> match cell.cellClass with HealthyRBC | InfectedRBC -> true | _ -> false ) + |> List.mapi (fun i cell -> + { num = i + infected = cell.cellClass = InfectedRBC + setManually = false + center = Point(float cell.center.X, float cell.center.Y) + size = Size(float cell.elements.Width, float cell.elements.Height) + stainArea = cell.stainArea }) + + member this.SourceImages : SourceImage seq = sourceImages :> SourceImage seq member this.Reset () =