public bool SetBrachyPlanSetup(BrachyPlanSetup bs) { PlanSetup = bs; BrachyPlanSetup = bs; //Notify OnBrachyPlanSetupChanged(bs); OnPlanSetupChanged(bs); return(BrachyPlanSetup != null); }
public string GetTechnique(PlanSetup ps) { if (ps is BrachyPlanSetup) { BrachyPlanSetup brachy = ps as BrachyPlanSetup; if (brachy.NumberOfPdrPulses != null) { return("PDR"); } else { Catheter c = brachy.Catheters.FirstOrDefault(); if (c != null) { return(c.TreatmentUnit.DoseRateMode); } } } else { Beam beam = ps.Beams.FirstOrDefault(); if (beam != null) { if (beam.GantryDirection != VMS.TPS.Common.Model.Types.GantryDirection.None) { return((beam.MLCPlanType == VMS.TPS.Common.Model.Types.MLCPlanType.VMAT) ? "VMAT" : "ARC"); } else { return((beam.MLCPlanType == VMS.TPS.Common.Model.Types.MLCPlanType.DoseDynamic) ? "IMRT" : "STATIC"); } } } return(""); }
private string SetText() { // Retrieve the count of plans displayed in Scope Window int scopePlanCount = _plans.Count(); if (scopePlanCount == 0) { MessageBox.Show("Scope Window does not contain any plans."); return(""); } // Retrieve names for different types of plans List <string> externalPlanIds = new List <string>(); List <string> brachyPlanIds = new List <string>(); List <string> protonPlanIds = new List <string>(); foreach (var ps in _plans) { if (ps is BrachyPlanSetup) { brachyPlanIds.Add(ps.Id); } else if (ps is IonPlanSetup) { protonPlanIds.Add(ps.Id); } else { externalPlanIds.Add(ps.Id); } } // Construct output message string message = string.Format("Hello {0}, the number of plans in Scope Window is {1}.", _user.Name, scopePlanCount); if (externalPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are external beam plans.", string.Join(", ", externalPlanIds)); } if (brachyPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are brachytherapy plans.", string.Join(", ", brachyPlanIds)); } if (protonPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are proton plans.", string.Join(", ", protonPlanIds)); } // Display additional information. Use the active plan if available. PlanSetup plan = _plan != null ? _plan : _plans.ElementAt(0); message += string.Format("\n\nAdditional details for plan {0}:", plan.Id); // Access the structure set of the plan if (plan.StructureSet != null) { Image image = plan.StructureSet.Image; var structures = plan.StructureSet.Structures; message += string.Format("\n* Image ID: {0}", image.Id); message += string.Format("\n* Size of the Structure Set associated with the plan: {0}.", structures.Count()); foreach (Structure s in structures) { message += String.Format("\n\t-{0}: {1:F2}cc", s.Id, s.Volume); } } message += string.Format("\n* Number of Fractions: {0}.", plan.NumberOfFractions); message += String.Format("\n* Dose Per Fraction: {0}", plan.DosePerFraction); // Handle brachytherapy plans separately from external beam plans if (plan is BrachyPlanSetup) { BrachyPlanSetup brachyPlan = (BrachyPlanSetup)plan; var catheters = brachyPlan.Catheters; var seedCollections = brachyPlan.SeedCollections; message += string.Format("\n* Number of Catheters: {0}.", catheters.Count()); message += string.Format("\n* Number of Seed Collections: {0}.", seedCollections.Count()); } else { var beams = plan.Beams; message += string.Format("\n* Number of Beams: {0}.", beams.Count()); foreach (Beam b in beams.OrderBy(x => x.BeamNumber)) { message += String.Format("\n\t-{0}: {1}MU", b.Id, b.Meterset.Value); } } if (plan is IonPlanSetup) { IonPlanSetup ionPlan = plan as IonPlanSetup; IonBeam beam = ionPlan.IonBeams.FirstOrDefault(); if (beam != null) { message += string.Format("\n* Number of Lateral Spreaders in first beam: {0}.", beam.LateralSpreadingDevices.Count()); message += string.Format("\n* Number of Range Modulators in first beam: {0}.", beam.RangeModulators.Count()); message += string.Format("\n* Number of Range Shifters in first beam: {0}.", beam.RangeShifters.Count()); } } // MessageBox.Show(message); return(message); }
public void Execute(ScriptContext context, System.Windows.Window window, ScriptEnvironment environment) { // Retrieve the count of plans displayed in Scope Window int scopePlanCount = context.PlansInScope.Count(); if (scopePlanCount == 0) { MessageBox.Show("Scope Window does not contain any plans."); return; } // Retrieve names for different types of plans List <string> externalPlanIds = new List <string>(); List <string> brachyPlanIds = new List <string>(); List <string> protonPlanIds = new List <string>(); foreach (var ps in context.PlansInScope) { if (ps is BrachyPlanSetup) { brachyPlanIds.Add(ps.Id); } else if (ps is IonPlanSetup) { protonPlanIds.Add(ps.Id); } else { externalPlanIds.Add(ps.Id); } } // Construct output message string message = string.Format("Hello {0}, the number of plans in Scope Window is {1}.", context.CurrentUser.Name, scopePlanCount); if (externalPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are external beam plans.", string.Join(", ", externalPlanIds)); } if (brachyPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are brachytherapy plans.", string.Join(", ", brachyPlanIds)); } if (protonPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are proton plans.", string.Join(", ", protonPlanIds)); } // Display additional information. Use the active plan if available. PlanSetup plan = context.PlanSetup != null ? context.PlanSetup : context.PlansInScope.ElementAt(0); message += string.Format("\n\nAdditional details for plan {0}:", plan.Id); // TODO Show fraction message message += string.Format("Number of fractions : {0}\n", plan.NumberOfFractions); message += string.Format("Dose per fraction : {0}\n", plan.PlannedDosePerFraction.ToString()); // Access the structure set of the plan if (plan.StructureSet != null) { Image image = plan.StructureSet.Image; var structures = plan.StructureSet.Structures; message += string.Format("\n* Image ID: {0}", image.Id); message += string.Format("\n* Size of the Structure Set associated with the plan: {0}.\n", structures.Count()); // TODO show structure info each foreach (var structureSingle in plan.StructureSet.Structures) { // check validation if (!structureSingle.IsEmpty) { message += string.Format("{0} in volume {1:F2} cc" + Environment.NewLine, structureSingle.Name, structureSingle.Volume); } } } // message += string.Format("\n* Number of Fractions: {0}.", plan.NumberOfFractions); // Handle brachytherapy plans separately from external beam plans if (plan is BrachyPlanSetup) { BrachyPlanSetup brachyPlan = (BrachyPlanSetup)plan; var catheters = brachyPlan.Catheters; var seedCollections = brachyPlan.SeedCollections; message += string.Format("\n* Number of Catheters: {0}.", catheters.Count()); message += string.Format("\n* Number of Seed Collections: {0}.", seedCollections.Count()); } else { var beams = plan.Beams; message += string.Format("\n* Number of Beams: {0}." + Environment.NewLine, beams.Count()); // TODO show info of beams foreach (Beam beamSingle in plan.Beams.OrderBy(x => x.BeamNumber)) { message += string.Format("Beam name equal to {0} , ", beamSingle.Id); message += string.Format("and MeterSet = {0}" + Environment.NewLine, beamSingle.Meterset.Value.ToString() + " " + beamSingle.Meterset.Unit.ToString()); } } if (plan is IonPlanSetup) { IonPlanSetup ionPlan = plan as IonPlanSetup; IonBeam beam = ionPlan.IonBeams.FirstOrDefault(); if (beam != null) { message += string.Format("\n* Number of Lateral Spreaders in first beam: {0}.", beam.LateralSpreadingDevices.Count()); message += string.Format("\n* Number of Range Modulators in first beam: {0}.", beam.RangeModulators.Count()); message += string.Format("\n* Number of Range Shifters in first beam: {0}.", beam.RangeShifters.Count()); } } // MessageBox.Show(message); window.Content = message; }
public void Execute(ScriptContext context, System.Windows.Window window, ScriptEnvironment environment) { // Retrieve the count of plans displayed in Scope Window int scopePlanCount = context.PlansInScope.Count(); if (scopePlanCount == 0) { MessageBox.Show("Scope Window does not contain any plans."); return; } // Retrieve names for different types of plans List <string> externalPlanIds = new List <string>(); List <string> brachyPlanIds = new List <string>(); List <string> protonPlanIds = new List <string>(); foreach (var ps in context.PlansInScope) { // KK: "is" compares the type. Equiv to ps.GetType() == typeof(BrachyPlanSetup)) if (ps is BrachyPlanSetup) { brachyPlanIds.Add(ps.Id); } else if (ps is IonPlanSetup) { protonPlanIds.Add(ps.Id); } else { externalPlanIds.Add(ps.Id); } } // Construct output message string message = string.Format("Hello {0}, the number of plans in Scope Window is {1}.", context.CurrentUser.Name, scopePlanCount); if (externalPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are external beam plans.", string.Join(", ", externalPlanIds)); } if (brachyPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are brachytherapy plans.", string.Join(", ", brachyPlanIds)); } if (protonPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are proton plans.", string.Join(", ", protonPlanIds)); } // Display additional information. Use the active plan if available. PlanSetup plan = context.PlanSetup != null ? context.PlanSetup : context.PlansInScope.ElementAt(0); message += string.Format("\n\nAdditional details for plan {0}:", plan.Id); // Access the structure set of the plan if (plan.StructureSet != null) { Common.Model.API.Image image = plan.StructureSet.Image; var structures = plan.StructureSet.Structures; message += string.Format("\n* Image ID: {0}", image.Id); message += string.Format("\n* Size of the Structure Set associated with the plan: {0}.", structures.Count()); string structureNames = ""; foreach (var s in structures) { structureNames += String.Format("\n\t{0}: volume is {1:F2} cc.", s.Id, s.Volume); } message += structureNames; } message += string.Format("\n* Number of Fractions: {0}.", plan.NumberOfFractions); message += string.Format("\n \t Dose per Fraction: {0}.", plan.DosePerFraction); // Handle brachytherapy plans separately from external beam plans if (plan is BrachyPlanSetup) { BrachyPlanSetup brachyPlan = (BrachyPlanSetup)plan; var catheters = brachyPlan.Catheters; var seedCollections = brachyPlan.SeedCollections; message += string.Format("\n* Number of Catheters: {0}.", catheters.Count()); message += string.Format("\n* Number of Seed Collections: {0}.", seedCollections.Count()); } else { var beams = plan.Beams; message += string.Format("\n* Number of Beams: {0}.", beams.Count()); string beamNames = ""; foreach (var b in beams.OrderBy(x => x.BeamNumber)) { beamNames += String.Format("\n\t{0} has {1} MU.", b.Id, b.Meterset.Value); } message += beamNames; } if (plan is IonPlanSetup) { IonPlanSetup ionPlan = plan as IonPlanSetup; IonBeam beam = ionPlan.IonBeams.FirstOrDefault(); if (beam != null) { message += string.Format("\n* Number of Lateral Spreaders in first beam: {0}.", beam.LateralSpreadingDevices.Count()); message += string.Format("\n* Number of Range Modulators in first beam: {0}.", beam.RangeModulators.Count()); message += string.Format("\n* Number of Range Shifters in first beam: {0}.", beam.RangeShifters.Count()); } } //MessageBox.Show(message); window.Background = Brushes.Blue; window.Content = new TextBlock { Foreground = Brushes.White, FontFamily = new FontFamily("Ariel"), FontSize = 18, Text = message }; //window.Content = message; }
public void OnBrachyPlanSetupChanged(BrachyPlanSetup ps) { BrachyPlanSetupChanged?.Invoke(ps); }