Example #1
0
 private void ShowMmrScores()
 {
     if (showMmrScores)
     {
         pedigreeSettingsForm1.showMmrScores();
     }
     else
     {
         pedigreeSettingsForm1.hideMmrScores();
     }
 }
Example #2
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));
            }
        }