Ejemplo n.º 1
0
        public FieldViewModel(PlanViewModel plan, Beam beam)
        {
            Plan            = plan;
            Beam            = beam;
            DisplayName     = Beam.Id;
            PlotDisplayName = Plan.Plan.Id + ": " + Beam.Id;
            PlotColor       = OxyColors.Black;
            ControlPoints   = (from ControlPoint cp in beam.ControlPoints
                               select new ControlPointViewModel(cp)).ToArray();

            // Show field by default
            // (won't actually be shown until plan's ShowOnPlots is true)
            ShowOnPlots = true;

            Plan.PropertyChanged += PlanPropertyChanged;
        }
        public EdgePenaltyViewModel(MainViewModel mainViewModel,
                                    Patient patient, PlanSetup activePlan, IEnumerable <PlanSetup> plans)
        {
            MainViewModel = mainViewModel;

            UserMessaged += UserMessager.UserMessaged;

            Plans = new ObservableCollection <PlanViewModel>
                        (from plan in plans
                        select new PlanViewModel(patient, plan));

            foreach (PlanViewModel plan in Plans)
            {
                plan.PropertyChanged += OnPlanPropertyChanged;

                foreach (FieldViewModel field in plan.Fields)
                {
                    field.PropertyChanged += OnFieldPropertyChanged;
                }
            }

            // Select active plan and its fields for showing on plot
            PlanViewModel activePlanViewModel = Plans.FirstOrDefault(p => p.Plan == activePlan);

            if (activePlanViewModel != null)
            {
                activePlanViewModel.ShowOnPlots = true;
                foreach (FieldViewModel field in activePlanViewModel.Fields)
                {
                    field.ShowOnPlots = true;
                }
            }

            // Get all fields for all plans
            Fields = new ObservableCollection <FieldViewModel>
                         (from plan in Plans
                         from field in plan.Fields
                         select field);

            Courses = new ObservableCollection <CourseViewModel>
                          (from course in GetCourses(plans)
                          let fields = Fields.Where(f => f.Plan.Plan.Course == course)
                                       select new CourseViewModel(course, fields));

            EdgePenaltyCalculator = new EdgeMetric();

            WeightType = WeightTypes[0];

            HistogramViewModel = new HistogramViewModel(Plans);

            // Choose plot type (box or line) and histogram therapy type (VMAT or IMRT)
            // based on the type of the active plan
            var firstBeam = activePlan.Beams.FirstOrDefault();

            IsVmat = firstBeam != null && firstBeam.MLCPlanType == MLCPlanType.VMAT;
            OnIsVmatChanged();
            IsBoxPlot = !IsVmat;   // Box for IMRT, Line for VMAT
            OnIsBoxPlotChanged();

            PropertyChanged += OnPropertyChanged;
        }