示例#1
0
        public PedigreeGenerator(int Width, int Height, Patient proband)
        {
            height = Height;
            width  = Width;


            //pedigreeControl1 = new PedigreeControl();
            pedigreeControl1      = new PedigreeControl(false);
            pedigreeLegend1       = new PedigreeLegend();
            pedigreeComment1      = new PedigreeComment();
            pedigreeTitleBlock1   = new PedigreeTitleBlock();
            sysDefaultAnnotations = new PedigreeAnnotationList("-1");
            sysDefaultAnnotations.BackgroundListLoad();
            pedigreeSettingsForm1 = new PedigreeSettingsForm(sysDefaultAnnotations);

            if (proband != null)
            {
                if (proband.guiPreferences.Count == 0)
                {
                    GUIPreference gp = new GUIPreference();
                    gp.BackgroundLoadWork();
                    proband.guiPreferences.Add(gp);
                }
            }
        }
示例#2
0
        /**************************************************************************************************/
        private GUIPreference getBestFitExistingGuiPreference(bool exactMatchOnly)
        {
            List <GUIPreference> localList = proband.guiPreferences.ConvertAll(x => (GUIPreference)x);
            String parentFormText          = "";

            if (localList.Count == 0)
            {
                GUIPreference guiPreference;
                //String parentFormText = (this.ParentForm != null) ? this.ParentForm.Text : "";

                guiPreference = new GUIPreference(proband, DateTime.Now, "", parentFormText, width, height, true);
                HraModelChangedEventArgs args = new HraModelChangedEventArgs(null);
                args.Persist = true;
                proband.guiPreferences.AddToList(guiPreference, args);
                return(guiPreference);
            }
            else
            {
                GUIPreference guiPreference = null;
                foreach (GUIPreference gp in localList)
                {
                    //if (guiPreference == null)
                    guiPreference = gp;
                }
                return(guiPreference);
            }
        }
示例#3
0
文件: MetaData.cs 项目: mahitosh/HRA4
 /**************************************************************************************************/
 public MetaData()
 {
     Diseases     = new DiseaseList();
     GeneticTests = new GeneticTestList();
     Users        = new UserList();
     UserGroups   = new UserGroupList();
     OrderTypes   = new OrderTypesList();
     Mutations    = new MutationList();
     SystemWideDefaultPedigreePrefs  = new GUIPreference();
     CurrentUserDefaultPedigreePrefs = new GUIPreference();
     ApptProviders = new ApptProviderList();
     KbVariants    = new VariantsFromKB();
     BrOvCdsRecs   = new AllBrOvCdsRecs();
     Globals       = new GlobalSettings();
 }
示例#4
0
 internal void SetVariantLabel(string label, GUIPreference currentGuiPrefs)
 {
     if (variantLabel.InvokeRequired)
     {
         SetVariantLabelCallback aoc = SetVariantLabel;
         object[] args = new object[1];
         args[0] = label;
         args[1] = currentGuiPrefs;
         this.Invoke(aoc, args);
     }
     else
     {
         variantLabel.Text = label;
         int width  = this.ComputeOptimalWidth();
         int height = this.ComputeOptimalHeight();
         if (currentGuiPrefs != null)
         {
             currentGuiPrefs.GUIPreference_TitleWidth  = width;
             currentGuiPrefs.GUIPreference_TitleHeight = height;
         }
     }
 }
示例#5
0
        private void GeneratePedigree()
        {
            int MaxWidth  = width;
            int MaxHeight = height;

            bool new_gui_pref = true;

            if (proband.guiPreferences.Count == 0)
            {
                new_gui_pref = true;
            }

            pedigreeTitleBlock1.NameText = proband.name;
            pedigreeTitleBlock1.MRN      = proband.unitnum;
            pedigreeTitleBlock1.DOB      = proband.dob;

            pedigreeComment1.proband = proband;
            pedigreeComment1.Text    = proband.family_comment;

            proband.FHx.SetIDsFromRelationships();
            pedigreeControl1.ForceLoadFamily(proband.FHx);

            currentPrefs = getBestFitExistingGuiPreference(false);
            pedigreeControl1.currentPrefs = currentPrefs;



            if (string.IsNullOrEmpty(proband.family_comment))
            {
                pedigreeComment1.Visible = false;
            }

            if (pedigreeControl1.currentPrefs.GUIPreference_width != 0 && pedigreeControl1.currentPrefs.GUIPreference_height != 0)
            {
                //pedigreeControl1.Width = pedigreeControl1.currentPrefs.GUIPreference_width;
                //pedigreeControl1.Height = pedigreeControl1.currentPrefs.GUIPreference_height;

                //width = pedigreeControl1.currentPrefs.GUIPreference_width;
                //height = pedigreeControl1.currentPrefs.GUIPreference_height;

                if (!new_gui_pref)
                {
                    pedigreeControl1.Width  = pedigreeControl1.currentPrefs.GUIPreference_width;
                    pedigreeControl1.Height = pedigreeControl1.currentPrefs.GUIPreference_height;

                    width  = pedigreeControl1.currentPrefs.GUIPreference_width;
                    height = pedigreeControl1.currentPrefs.GUIPreference_height;
                }
                else
                {
                    pedigreeControl1.Width  = width;
                    pedigreeControl1.Height = height;
                }
                float x = pedigreeControl1.model.parameters.scale = ((float)pedigreeControl1.currentPrefs.GUIPreference_zoomValue) / 100.0f;

                pedigreeControl1.model.parameters.scale = 0.65f * x;
                //pedigreeControl1.model.parameters.scale = (float)height / (float)pedigreeControl1.currentPrefs.GUIPreference_height * x;
                //pedigreeControl1.model.parameters.scale = (float)width / (float)pedigreeControl1.currentPrefs.GUIPreference_width * x;

                pedigreeControl1.model.parameters.hOffset = (int)(((width / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayXMax / 2));
                pedigreeControl1.model.parameters.vOffset = (int)(((height / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayYMax / 2));

                foreach (PedigreeIndividual pi in pedigreeControl1.model.individuals)
                {
                    foreach (ClincalObservation co in pi.HraPerson.PMH.Observations)
                    {
                        pedigreeLegend1.AddSingleObservation(co, false);
                        pedigreeLegend1.Visible = true;
                    }
                }
            }
            if (new_gui_pref)
            {
                int minx = int.MaxValue;
                int maxx = int.MinValue;

                int miny = int.MaxValue;
                int maxy = int.MinValue;

                foreach (PedigreeIndividual pi in pedigreeControl1.model.individuals)
                {
                    foreach (ClincalObservation co in pi.HraPerson.PMH.Observations)
                    {
                        pedigreeLegend1.AddSingleObservation(co, false);
                        pedigreeLegend1.Visible = true;
                    }
                    if (pi.HraPerson.x_norm == int.MinValue)
                    {
                        pi.HraPerson.x_norm = (int)(pi.point.x - (pedigreeControl1.model.displayXMax / 2));
                    }

                    if (pi.HraPerson.y_norm == int.MinValue)
                    {
                        pi.HraPerson.y_norm = (int)(pi.point.y - (pedigreeControl1.model.displayYMax / 2));
                    }


                    if (pi.HraPerson.x_norm < minx)
                    {
                        minx = pi.HraPerson.x_norm;
                    }

                    if (pi.HraPerson.x_norm > maxx)
                    {
                        maxx = pi.HraPerson.x_norm;
                    }

                    if (pi.HraPerson.y_norm < miny)
                    {
                        miny = pi.HraPerson.y_norm;
                    }

                    if (pi.HraPerson.y_norm > maxx)
                    {
                        maxy = pi.HraPerson.y_norm;
                    }
                }

                maxx += 60;
                minx -= 60;

                float zoom = (float)((double)width / (double)(maxx - minx));
                if (zoom < 1.0f)
                {
                    pedigreeControl1.model.parameters.scale   = zoom;
                    pedigreeControl1.model.parameters.hOffset = (int)(((width / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayXMax / 2));
                    pedigreeControl1.model.parameters.vOffset = (int)(((height / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayYMax / 2));
                }
                else
                {
                    pedigreeControl1.model.parameters.scale   = 1;
                    pedigreeControl1.model.parameters.hOffset = (int)(((width / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayXMax / 2));
                    pedigreeControl1.model.parameters.vOffset = (int)(((height / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayYMax / 2));
                }

                if (pedigreeControl1.model.parameters.scale > 0 && pedigreeControl1.model.parameters.scale < 2.0f)
                {
                    pedigreeControl1.currentPrefs.GUIPreference_zoomValue = (int)(150.0f * pedigreeControl1.model.parameters.scale);
                }

                pedigreeControl1.controller.SetMode("SELF_ORGANIZING");
                int counter = 0;
                while (pedigreeControl1.model.converged == false && counter < 200)     //for (int i = 0; i < 100; i++)
                {
                    pedigreeControl1.controller.IncrementLayout();
                    counter++;
                }

                pedigreeControl1.CenterIndividuals();
            }

            ApplyPrefs();


            if (new_gui_pref)
            {
                //pedigreeLegend1.Location = new Point(pedigreeTitleBlock1.Location.X + pedigreeTitleBlock1.Width + 10, pedigreeTitleBlock1.Location.Y);
            }

            if (showBrcaScores)
            {
                pedigreeSettingsForm1.showBrcaScores();
            }
            else
            {
                pedigreeSettingsForm1.hideBrcaScores();
            }

            if (showMmrScores)
            {
                pedigreeSettingsForm1.showMmrScores();
            }
            else
            {
                pedigreeSettingsForm1.hideMmrScores();
            }

            pedigreeControl1.model.parameters.annotation_areas = pedigreeSettingsForm1.annotation_areas;

            pedigreeControl1.model.FamilialVariants = FamilialVariants;

            image = new Bitmap(width, height);

            Graphics g = Graphics.FromImage(image);

            pedigreeControl1.DrawFromView(g, width, height);

            pedigreeTitleBlock1.DrawToBitmapWithBorder(image, new Rectangle(pedigreeTitleBlock1.Location, pedigreeTitleBlock1.Size));

            if (string.IsNullOrEmpty(proband.Patient_Comment) == false && pedigreeComment1.Visible)
            {
                pedigreeComment1.DrawToBitmapWithBorder(image, new Rectangle(pedigreeComment1.Location, pedigreeComment1.Size));
            }
            if (pedigreeLegend1.Visible)
            {
                pedigreeLegend1.DrawToBitmapWithBorder(image, new Rectangle(pedigreeLegend1.Location, pedigreeLegend1.Size));
            }



            float MaxRatio = MaxWidth / (float)MaxHeight;
            float ImgRatio = image.Width / (float)image.Height;

            if (image.Width > MaxWidth)
            {
                image = new Bitmap(image, new Size(MaxWidth, (int)Math.Round(MaxWidth /
                                                                             ImgRatio, 0)));
            }

            if (image.Height > MaxHeight)
            {
                image = new Bitmap(image, new Size((int)Math.Round(MaxWidth * ImgRatio,
                                                                   0), MaxHeight));
            }
        }
示例#6
0
        private void GeneratePedigree()
        {
            pedigreeTitleBlock1.NameText = proband.name;
            pedigreeTitleBlock1.MRN      = proband.unitnum;
            pedigreeTitleBlock1.DOB      = proband.dob;

            pedigreeComment1.proband = proband;
            pedigreeComment1.Text    = proband.family_comment;

            proband.FHx.SetIDsFromRelationships();
            pedigreeControl1.ForceLoadFamily(proband.FHx);

            currentPrefs = getBestFitExistingGuiPreference(false);
            pedigreeControl1.currentPrefs = currentPrefs;

            ShowComments();

            if (pedigreeControl1.currentPrefs.GUIPreference_width != 0 && pedigreeControl1.currentPrefs.GUIPreference_height != 0)
            {
                pedigreeControl1.Width  = width;
                pedigreeControl1.Height = height;

                float x = pedigreeControl1.model.parameters.scale = ((float)pedigreeControl1.currentPrefs.GUIPreference_zoomValue) / 100.0f;

                pedigreeControl1.model.parameters.scale = 0.65f * x;

                pedigreeControl1.model.parameters.hOffset = (int)(((width / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayXMax / 2));
                pedigreeControl1.model.parameters.vOffset = (int)(((height / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayYMax / 2));
            }

            AddObservations();

            pedigreeControl1.model.individuals.ForEach(SetNorms);
            var maxx = pedigreeControl1.model.individuals.Max(pi => pi.HraPerson.x_norm);
            var minx = pedigreeControl1.model.individuals.Min(pi => pi.HraPerson.x_norm);
            var maxy = pedigreeControl1.model.individuals.Max(pi => pi.HraPerson.y_norm);
            var miny = pedigreeControl1.model.individuals.Min(pi => pi.HraPerson.y_norm);

            maxx += 60;
            minx -= 60;
            maxy += 80;
            miny -= 20;

            int pedigreeHeight = maxy - miny;

            this.height = pedigreeHeight;

            //TODO not sure if this is optimal - may want to determine if scale is limited by x or y and scale accordingly
            float zoom = (float)((double)width / (double)(maxx - minx));

            if (zoom < 1.0f)
            {
                pedigreeControl1.model.parameters.scale   = zoom;
                pedigreeControl1.model.parameters.hOffset = (int)(((width / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayXMax / 2));
                pedigreeControl1.model.parameters.vOffset = (int)(((height / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayYMax / 2));
            }
            else
            {
                pedigreeControl1.model.parameters.scale   = 1;
                pedigreeControl1.model.parameters.hOffset = (int)(((width / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayXMax / 2));
                pedigreeControl1.model.parameters.vOffset = (int)(((height / 2) / pedigreeControl1.model.parameters.scale) - (float)(pedigreeControl1.model.displayYMax / 2));
            }

            if (pedigreeControl1.model.parameters.scale > 0 && pedigreeControl1.model.parameters.scale < 2.0f)
            {
                pedigreeControl1.currentPrefs.GUIPreference_zoomValue = (int)(150.0f * pedigreeControl1.model.parameters.scale);
            }

            pedigreeControl1.controller.SetMode("SELF_ORGANIZING");
            int counter = 0;

            while (pedigreeControl1.model.converged == false && counter < 200)     //for (int i = 0; i < 100; i++)
            {
                pedigreeControl1.controller.IncrementLayout();
                counter++;
            }

            pedigreeControl1.CenterIndividuals();

            ApplyPrefs();

            ShowBrcaScores();

            ShowMmrScores();

            pedigreeControl1.model.parameters.annotation_areas = pedigreeSettingsForm1.annotation_areas;

            pedigreeControl1.model.FamilialVariants = FamilialVariants;

            Rectangle legendLayout;
            Rectangle commentBoxLayout;
            Rectangle titleBlockLayout;
            Rectangle pedigreeRegionLayout;
            Rectangle backdropLayout;
            int       totalHeight;

            ComputePedigreeLayout(width, height,
                                  out legendLayout,
                                  out commentBoxLayout,
                                  out titleBlockLayout,
                                  out pedigreeRegionLayout,
                                  out backdropLayout,
                                  out totalHeight);

            image = new Bitmap(width, totalHeight);

            Control canvasControl = new Control
            {
                BackColor = Color.White,
                Width     = backdropLayout.Width,
                Height    = backdropLayout.Height
            };

            canvasControl.DrawToBitmap(image, backdropLayout);

            pedigreeControl1.DrawToBitmap(image, pedigreeRegionLayout);

            pedigreeTitleBlock1.DrawToBitmapWithBorder(image, titleBlockLayout);

            if (string.IsNullOrEmpty(proband.Patient_Comment) == false && pedigreeComment1.Visible)
            {
                pedigreeComment1.DrawToBitmapWithBorder(image, commentBoxLayout);
            }
            if (pedigreeLegend1.Visible)
            {
                pedigreeLegend1.DrawToBitmapWithBorder(image, legendLayout);
            }
        }