Exemple #1
0
        private void Aircraft_OnUpdateAircraft(Aircraft sender, Aircraft.AircraftUpdateEventArgs e)
        {
            switch(e.UpdateType)
            {
                case Aircraft.AircraftUpdateEventArgs.Update_Type.Closed:
                    {
                        //remove the instance usercontrol
                        InstanceUC iuc = null;
                        foreach (Control c in flowLayoutPanel1.Controls)
                            if (c.GetType() == typeof(InstanceUC))
                                if ((c as InstanceUC).aircraft == sender)
                                    iuc = (c as InstanceUC);

                        if (iuc != null)
                            flowLayoutPanel1.Controls.Remove(iuc);

                        //remove the constraint usercontrol
                        ConstraintsUC cuc = null;
                        foreach (Control c in flowLayoutPanel2.Controls)
                            if (c.GetType() == typeof(ConstraintsUC))
                                if ((c as ConstraintsUC).DispAircraft == sender)
                                    cuc = (c as ConstraintsUC);

                        if (cuc != null)
                            flowLayoutPanel2.Controls.Remove(cuc);

                        //finally remove this aircraft from our list of designs
                        designs.Remove(sender);
                    }; break;
            }
        }
Exemple #2
0
        public void SetAircraft(Aircraft ap)
        {
            if (ap == null)
                return;

            //if the displayed aircraft is the one we want to change to, dont bother changing
            if (m_ap != null && m_ap == ap)
                return;

            this.SuspendLayout();
            this.flowLayoutPanel1.Controls.Clear();

            m_ap = ap;
            this.designLabel.Text = m_ap.Configuration_Name;
            //this.pictureBox1.Image = m_ap.PrimaryInstance.Geometry_Image;
            this.pictureBox1.Image = GeometryModeler.DrawAirplane(m_ap, GeometryModeler.Views.Isomeric);

            RefreshValues();

            foreach (AVL_File.Surface surf in ap.Initial_AVL_File.Surfaces)
            {
                SurfaceUC suc = new SurfaceUC(surf);
                this.flowLayoutPanel1.Controls.Add(suc);
            }

            this.cmdPrmpButton.Visible = true;

            foreach (Control c in flowLayoutPanel2.Controls)
                c.Visible = true;

            this.revertButton.Enabled = m_ap.HasBackup;

            this.ResumeLayout();
        }
Exemple #3
0
 public InstanceUC(Aircraft instance)
 {
     aircraft = instance;
     InitializeComponent();
     this.configLabel.Text = aircraft.Configuration_Name;
     if (aircraft.PrimaryInstance != null)
         this.pictureBox1.Image = aircraft.PrimaryInstance.Geometry_Image;
     AVL_Instance.OnUpdateMessages += new MessageEventHandler(AVL_Instance_OnUpdateMessages);
 }
Exemple #4
0
 public ConstraintsUC(Aircraft ac)
     : this()
 {
     DispAircraft = ac;
     if (DispAircraft.PrimaryInstance != null)
         this.pictureBox1.Image = DispAircraft.PrimaryInstance.Geometry_Image;
     Aircraft.OnUpdateAircraft += new Aircraft.UpdateEventHandler(Aircraft_OnUpdateAircraft);
     AVL_Instance.OnUpdateMessages += new MessageEventHandler(AVL_Instance_OnUpdateMessages);
     PopulateData();
 }
Exemple #5
0
        public AVL_Instance(Aircraft aircraft)
        {
            m_aircraft = aircraft;

            AVL_Process = new Process();
            AVL_Process.StartInfo.FileName = Properties.Settings.Default.AVL_Location;
            AVL_Process.StartInfo.UseShellExecute = false;
            AVL_Process.StartInfo.CreateNoWindow = true;
            AVL_Process.StartInfo.RedirectStandardOutput = true;
            AVL_Process.StartInfo.RedirectStandardInput = true;
            AVL_Process.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
        }
 public static Image DrawAirplane(Aircraft ac, Views view, string selected_SurfName, int secHighlight)
 {
     switch (view)
     {
         case Views.Isomeric:
             return DrawAirplane(ac, 35, 0, -45, selected_SurfName, secHighlight);
         case Views.Planform:
             return DrawAirplane(ac, 0, 0, 0, selected_SurfName, secHighlight);
         case Views.Side:
             return DrawAirplane(ac, 0, 0, -90, selected_SurfName, secHighlight);
         case Views.Front:
             return DrawAirplane(ac, 90, 0, -90, selected_SurfName, secHighlight);
         default: goto case 0;
     }
 }
Exemple #7
0
        private void Aircraft_OnUpdateAircraft(Aircraft sender, Aircraft.AircraftUpdateEventArgs e)
        {
            if (sender != DispAircraft)
                return;

            if (this.InvokeRequired)
                this.Invoke((MethodInvoker)delegate { Aircraft_OnUpdateAircraft(sender, e); });
            else
            {
                //if we add a new case, repopulate the lists
                if (e.UpdateType == Aircraft.AircraftUpdateEventArgs.Update_Type.Added_Case)
                    PopulateData();
                //if a case has ended, find that listview item and change picture and status
                else if (e.UpdateType == Aircraft.AircraftUpdateEventArgs.Update_Type.Ended_Case)
                {
                    this.statusLabel.Text = "Executing Cases, Finished Case " + ((int)e.Message).ToString();

                    for (int i = 0; i < this.DispAircraft.Analyze_Cases.Count; i++)
                    {
                        if (this.DispAircraft.Analyze_Cases[i].Case_Index != (int)e.Message)
                            continue;
                        ListViewItem lvi = listView1.Groups[0].Items[i];
                        lvi.ImageIndex = 1;
                        lvi.SubItems[2].Text = "Finished";
                        break;
                    }
                    if ((int)e.Message == listView1.Groups[0].Items.Count - 1)
                    {
                        this.statusLabel.Text = "Finished executing all cases";
                        runCaseButton.Enabled = true;
                    }
                }
                //if a case has just started, find that listview item and change picture and status
                else if (e.UpdateType == Aircraft.AircraftUpdateEventArgs.Update_Type.Started_Case)
                {
                    for (int i = 0; i < this.DispAircraft.Analyze_Cases.Count; i++)
                    {
                        if (this.DispAircraft.Analyze_Cases[i].Case_Index != (int)e.Message)
                            continue;
                        ListViewItem lvi = listView1.Groups[0].Items[i];
                        lvi.ImageIndex = 4;//replace this with a 'pending' image
                        lvi.SubItems[2].Text = "Working";
                        break;
                    }
                }
            }
        }
Exemple #8
0
 /// <summary>
 /// Creates a new instance of AVL_Instance, and specifing the *.avl file to load
 /// </summary>
 /// <param name="FullFileName">Full path and name of the file to open</param>
 public AVL_Instance(string FullFileName, Aircraft aircraft)
     : this(aircraft)
 {
     Vehicle_File = FullFileName;
     FileInfo finfo = new FileInfo(Vehicle_File);
     AVL_Process.StartInfo.WorkingDirectory = finfo.DirectoryName;
 }
 public static Image DrawAirplane(Aircraft ac, Views view)
 {
     return DrawAirplane(ac, view, string.Empty, -1);
 }
Exemple #10
0
        private void plotTrefftz(Aircraft ac, Run_Case rc, Chart c)
        {
            //if there is a mixup between the aircraft and run case, stop
            if (!ac.Analyze_Cases.Contains(rc))
                return;

            if(rc.Strip_Forces.Count > 0)
            {
                //this does it for each surface
                foreach (string s in rc.Strip_Forces.Keys)
                {
                    double[] Yle = new double[rc.Strip_Forces[s].GetLength(0)];
                    double[] cl = new double[rc.Strip_Forces[s].GetLength(0)];
                    double[] cl_c_cref = new double[rc.Strip_Forces[s].GetLength(0)];
                    for (int i = 0; i < Yle.Length; i++)
                    {
                        Yle[i] = (rc.Strip_Forces[s])[i, 0];
                        cl[i] = (rc.Strip_Forces[s])[i, 9];
                        cl_c_cref[i] = (rc.Strip_Forces[s])[i, 1];
                    }
                    PlotSpline(c, Yle, cl, main_Lines == 0 ? "cl" : "cl " + s + main_Lines.ToString(), Color.Green, main_Lines == 0, true);
                    PlotSpline(c, Yle, cl_c_cref, main_Lines == 0 ? "cl*(c/cref)" : "cl*(c/cref) " + s + main_Lines.ToString(), Color.Orange, main_Lines == 0, true);
                    main_Lines++;
                }
                c.ChartAreas[0].AxisX.Minimum = -1;
                c.ChartAreas[0].AxisX.Maximum = 1;
                c.ChartAreas[0].AxisX.Title = "Spanwise Location";
                c.ChartAreas[0].AxisY.Title = "Section Lift Coefficient";
            }
        }
Exemple #11
0
        private void Aircraft_OnUpdateAircraft(Aircraft sender, Aircraft.AircraftUpdateEventArgs e)
        {
            if (this.InvokeRequired)
                this.Invoke((MethodInvoker)delegate { Aircraft_OnUpdateAircraft(sender, e); });
            else
            {
                switch (e.UpdateType)
                {
                    case Aircraft.AircraftUpdateEventArgs.Update_Type.File_Load:
                    case Aircraft.AircraftUpdateEventArgs.Update_Type.File_Save:
                        {
                            foreach (ListViewGroup lvg in listView1.Groups)
                                if (lvg.Header == sender.Configuration_Name)
                                    return;

                            this.listView1.Groups.Add(sender.Configuration_Name, sender.Configuration_Name);
                        }; break;
                    case Aircraft.AircraftUpdateEventArgs.Update_Type.Closed:
                        {
                            if (listView1.Groups.Count > 0)
                            {
                                if (listView1.Groups[sender.Configuration_Name] != null)
                                {
                                    for (int i = listView1.Groups[sender.Configuration_Name].Items.Count; i > 0; i--)
                                        listView1.Items.Remove(listView1.Groups[sender.Configuration_Name].Items[i - 1]);

                                    listView1.Groups[sender.Configuration_Name].Items.Clear();
                                    listView1.Groups.Remove(listView1.Groups[sender.Configuration_Name]);
                                    RefreshAllCharts();
                                }
                            }
                        }; break;
                    case Aircraft.AircraftUpdateEventArgs.Update_Type.Ended_Case:
                        {
                            int runIndex = (int)e.Message;
                            string key = sender.Configuration_Name + "~~~" + runIndex.ToString();
                            if (!listView1.Items.ContainsKey(key))
                            {
                                ListViewItem lvi = listView1.Items.Add(key, sender.Analyze_Cases[runIndex].CaseNotes, 0);
                                lvi.Group = listView1.Groups[sender.Configuration_Name];
                            }
                            else
                            {
                                ListViewItem lvi = listView1.Items[key];
                                lvi.Text = sender.Analyze_Cases[runIndex].CaseNotes;
                            }
                            RefreshAllCharts();
                        }; break;
                    case Aircraft.AircraftUpdateEventArgs.Update_Type.Removed_Case:
                        {
                            int runIndex = (int)e.Message;
                            string key = sender.Configuration_Name + "~~~" + runIndex.ToString();
                            listView1.Items.RemoveByKey(key);
                        }; break;
                }
            }
        }
Exemple #12
0
 /// <summary>
 /// For each run analyzed, get the value of the desired property
 /// </summary>
 /// <param name="ac"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 private static object[] GetValueAllRuns(Aircraft ac, PropertyInfo info)
 {
     List<object> values = new List<object>();
     foreach (Run_Case rc in ac.Analyze_Cases)
     {
         //skip cases that are not finished
         if (rc.Current_Status != Run_Case.Case_Status.Finished)
             continue;
         var val = GetPropertyValue(info, rc);
         if (val != null)//should we strip out the nulls? I think yes
             values.Add(val);
     }
     return values.ToArray();
 }
Exemple #13
0
 public static Image DrawAirplane(Aircraft ac, Views view)
 {
     return(DrawAirplane(ac, view, string.Empty, -1));
 }
Exemple #14
0
        private void Clear()
        {
            if (this.IsDisposed)
                return;

            this.SuspendLayout();
            m_ap = null;
            this.flowLayoutPanel1.Controls.Clear();

            this.pictureBox1.Image = null;
            this.designLabel.Text = String.Empty;
            this.srefTextBox.TextBoxText = String.Empty;
            this.crefTextBox.TextBoxText = String.Empty;
            this.brefTextBox.TextBoxText = String.Empty;

            this.xrefTextBox.TextBoxText = String.Empty;
            this.yrefTextBox.TextBoxText = String.Empty;
            this.zrefTextBox.TextBoxText = String.Empty;

            this.cdpTextBox.TextBoxText = String.Empty;
            this.machTextBox.TextBoxText = String.Empty;

            foreach (Control c in flowLayoutPanel2.Controls)
                c.Visible = false;

            this.cmdPrmpButton.Visible = false;

            this.ResumeLayout();
        }
Exemple #15
0
 private void Aircraft_OnUpdateAircraft(Aircraft sender, Aircraft.AircraftUpdateEventArgs e)
 {
     //if we are showing an aircraft and that aircraft raises a message, act
     if (m_ap != null && sender == m_ap)
     {
         switch (e.UpdateType)
         {
             case Aircraft.AircraftUpdateEventArgs.Update_Type.File_Load:
                 {
                     m_ap = null;
                     SetAircraft(sender);
                 }; break;
             case Aircraft.AircraftUpdateEventArgs.Update_Type.Closed: this.Clear(); break;
         }
     }
 }
Exemple #16
0
 public static Image DrawAirplane(Aircraft ac, double Yaw_Angle, double Pitch_Angle, double Roll_Angle)
 {
     return(DrawAirplane(ac, Yaw_Angle, Pitch_Angle, Roll_Angle, string.Empty, -1));
 }
Exemple #17
0
 public static Image DrawAirplane(Aircraft ac, double Yaw_Angle, double Pitch_Angle, double Roll_Angle)
 {
     return DrawAirplane(ac, Yaw_Angle, Pitch_Angle, Roll_Angle, string.Empty, -1);
 }
Exemple #18
0
        public static Image DrawAirplane(Aircraft ac, double Yaw_Angle, double Pitch_Angle, double Roll_Angle, string selected_SurfName, int secHighlight)
        {
            Bitmap bm = new Bitmap(500, 500);

            double xmin = double.MaxValue;
            double ymin = double.MaxValue;
            double xmax = double.MinValue;
            double ymax = double.MinValue;

            //We gather a list of all the lines that will make up the aircraft in 3D coordinates (as doubles!)
            List <Line3D> AllLines = new List <Line3D>();

            foreach (AVL_File.Surface surf in ac.Initial_AVL_File.Surfaces)
            {
                if (!string.IsNullOrEmpty(selected_SurfName) && surf.Name == selected_SurfName && secHighlight >= 0)
                {
                    AllLines.AddRange(DrawSurface(surf, secHighlight));
                }
                else
                {
                    AllLines.AddRange(DrawSurface(surf));
                }
            }
            //draw the axis
            //AllLines.AddRange(DrawAxis());

            //rotate points, and get bounding box
            foreach (Line3D l3d in AllLines)
            {
                for (int i = 0; i < l3d.Count; i++)
                {
                    Point3D translated = Point3D.Rotate(l3d.Points[i], Yaw_Angle, Pitch_Angle, Roll_Angle);
                    //bounding x check
                    if (translated.X < xmin)
                    {
                        xmin = translated.X;
                    }
                    else if (translated.X > xmax)
                    {
                        xmax = translated.X;
                    }
                    //bounding y check
                    if (translated.Y < ymin)
                    {
                        ymin = translated.Y;
                    }
                    else if (translated.Y > ymax)
                    {
                        ymax = translated.Y;
                    }

                    l3d.Points[i] = translated;
                }
            }

            double scaleFactor = xmax - xmin > ymax - ymin ? (double)bm.Width / (xmax - xmin) : (double)bm.Height / (ymax - ymin);

            //now to paint the picture
            using (var graphics = Graphics.FromImage(bm))
            {
                graphics.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

                //center the image
                float yshift = (float)(Math.Abs(ymin) * scaleFactor + (bm.Height - (ymax - ymin) * scaleFactor) / 2);
                float xshift = (float)(Math.Abs(xmin) * scaleFactor + (bm.Width - (xmax - xmin) * scaleFactor) / 2);
                graphics.TranslateTransform(xshift, yshift);

                //draw all the lines, we project to the XY-plane simply by ignoring the Z dimension, since this is post-rotation
                for (int i = 0; i < AllLines.Count; i++)
                {
                    if (AllLines[i].Count == 0)
                    {
                        continue;
                    }

                    PointF[] pts2D = new PointF[AllLines[i].Count];
                    for (int j = 0; j < AllLines[i].Count; j++)
                    {
                        pts2D[j] = new PointF((float)(AllLines[i].Points[j].X * scaleFactor), (float)(AllLines[i].Points[j].Y * scaleFactor));
                    }

                    graphics.DrawLines(new Pen(AllLines[i].LineColor), pts2D);
                }
            }

            return(bm);
        }
Exemple #19
0
        private void Aircraft_OnUpdateAircraft(Aircraft sender, Aircraft.AircraftUpdateEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker) delegate { Aircraft_OnUpdateAircraft(sender, e); });
            }
            else
            {
                switch (e.UpdateType)
                {
                case Aircraft.AircraftUpdateEventArgs.Update_Type.File_Load:
                case Aircraft.AircraftUpdateEventArgs.Update_Type.File_Save:
                {
                    foreach (ListViewGroup lvg in listView1.Groups)
                    {
                        if (lvg.Header == sender.Configuration_Name)
                        {
                            return;
                        }
                    }

                    this.listView1.Groups.Add(sender.Configuration_Name, sender.Configuration_Name);
                }; break;

                case Aircraft.AircraftUpdateEventArgs.Update_Type.Closed:
                {
                    if (listView1.Groups.Count > 0)
                    {
                        if (listView1.Groups[sender.Configuration_Name] != null)
                        {
                            for (int i = listView1.Groups[sender.Configuration_Name].Items.Count; i > 0; i--)
                            {
                                listView1.Items.Remove(listView1.Groups[sender.Configuration_Name].Items[i - 1]);
                            }

                            listView1.Groups[sender.Configuration_Name].Items.Clear();
                            listView1.Groups.Remove(listView1.Groups[sender.Configuration_Name]);
                            RefreshAllCharts();
                        }
                    }
                }; break;

                case Aircraft.AircraftUpdateEventArgs.Update_Type.Ended_Case:
                {
                    int    runIndex = (int)e.Message;
                    string key      = sender.Configuration_Name + "~~~" + runIndex.ToString();
                    if (!listView1.Items.ContainsKey(key))
                    {
                        ListViewItem lvi = listView1.Items.Add(key, sender.Analyze_Cases[runIndex].CaseNotes, 0);
                        lvi.Group = listView1.Groups[sender.Configuration_Name];
                    }
                    else
                    {
                        ListViewItem lvi = listView1.Items[key];
                        lvi.Text = sender.Analyze_Cases[runIndex].CaseNotes;
                    }
                    RefreshAllCharts();
                }; break;

                case Aircraft.AircraftUpdateEventArgs.Update_Type.Removed_Case:
                {
                    int    runIndex = (int)e.Message;
                    string key      = sender.Configuration_Name + "~~~" + runIndex.ToString();
                    listView1.Items.RemoveByKey(key);
                }; break;
                }
            }
        }
Exemple #20
0
        private void newFileButton_Click(object sender, EventArgs e)
        {
            //here we create a new default airplane
            InputBox ib = new InputBox("Create a new aircraft design", "Name of new design:");
            if(ib.ShowDialog()== System.Windows.Forms.DialogResult.OK)
            {
                if (ib.InputText == string.Empty)
                    return;

                Aircraft ac = new Aircraft();
                ac.Initial_AVL_File.Title = ib.InputText;

                //make wing surface
                AVL_File.Surface wingSurf = new AVL_File.Surface("Wing", ac.Initial_AVL_File);
                AVL_File.Surface.Section startSec = new AVL_File.Surface.Section(wingSurf);
                startSec.Chord = 12;
                wingSurf.Sections.Add(startSec);
                AVL_File.Surface.Section endsec = new AVL_File.Surface.Section(wingSurf);
                endsec.Chord = 12;
                endsec.Y_LeadingEdge = 20;
                wingSurf.Sections.Add(endsec);

                ac.Initial_AVL_File.Surfaces.Add(wingSurf);

                //make hstab surface
                AVL_File.Surface hSurf = new AVL_File.Surface("HTail", ac.Initial_AVL_File);
                AVL_File.Surface.Section startHSec = new AVL_File.Surface.Section(hSurf);
                startHSec.Chord = 7;
                startHSec.X_LeadingEdge = 30;
                hSurf.Sections.Add(startHSec);
                AVL_File.Surface.Section endHsec = new AVL_File.Surface.Section(hSurf);
                endHsec.Chord = 7;
                endHsec.X_LeadingEdge = 30;
                endHsec.Y_LeadingEdge = 9;
                hSurf.Sections.Add(endHsec);

                ac.Initial_AVL_File.Surfaces.Add(hSurf);

                ac.Initial_AVL_File.Sref = 480;
                ac.Initial_AVL_File.Bref = 40;
                ac.Initial_AVL_File.Cref = 12;
                ac.Initial_AVL_File.Xref = 3;

                this.designs.Add(ac);

                InstanceUC iuc = new InstanceUC(ac);
                this.flowLayoutPanel1.Controls.Add(iuc);
                iuc.Click += new EventHandler(iuc_Click);

                System.Threading.Thread.Sleep(75);
                ConstraintsUC cuc = new ConstraintsUC(ac);
                cuc.Height = flowLayoutPanel2.Height - 25;
                this.flowLayoutPanel2.Controls.Add(cuc);
            }
        }
Exemple #21
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog fd = new OpenFileDialog();
            fd.Title = "AVL Vehicle File";
            fd.Multiselect = true;
            fd.Filter = "AVL Files (*.avl)|*.avl";
            fd.InitialDirectory = Properties.Settings.Default.AVL_Location;

            if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (string file in fd.FileNames)
                {
                    if (!fd.CheckFileExists)
                        return;

                    Aircraft des = new Aircraft(file);
                    designs.Add(des);

                    InstanceUC iuc = new InstanceUC(des);
                    this.flowLayoutPanel1.Controls.Add(iuc);
                    iuc.Click += new EventHandler(iuc_Click);

                    System.Threading.Thread.Sleep(75);
                    ConstraintsUC cuc = new ConstraintsUC(des);
                    cuc.Height = flowLayoutPanel2.Height-25;
                    this.flowLayoutPanel2.Controls.Add(cuc);
                    //RibbonButton rb = new RibbonButton(des.Configuration_Name.Substring(0, 10));
                    //if (des.PrimaryInstance.Geometry_Image != null)
                    //    rb.Image = des.PrimaryInstance.Geometry_Image.GetThumbnailImage(40, 40, new Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
                    //aircraftButtonList.Buttons.Add(rb);
                    //rb.Visible = true;
                }
            }
        }
Exemple #22
0
        public static Image DrawAirplane(Aircraft ac, double Yaw_Angle, double Pitch_Angle, double Roll_Angle, string selected_SurfName, int secHighlight)
        {
            Bitmap bm = new Bitmap(500, 500);

            double xmin = double.MaxValue;
            double ymin = double.MaxValue;
            double xmax = double.MinValue;
            double ymax = double.MinValue;

            //We gather a list of all the lines that will make up the aircraft in 3D coordinates (as doubles!)
            List<Line3D> AllLines = new List<Line3D>();
            foreach (AVL_File.Surface surf in ac.Initial_AVL_File.Surfaces)
            {
                if (!string.IsNullOrEmpty(selected_SurfName) && surf.Name == selected_SurfName && secHighlight >= 0)
                    AllLines.AddRange(DrawSurface(surf, secHighlight));
                else
                    AllLines.AddRange(DrawSurface(surf));
            }
            //draw the axis
            //AllLines.AddRange(DrawAxis());

            //rotate points, and get bounding box
            foreach (Line3D l3d in AllLines)
            {
                for (int i = 0; i < l3d.Count; i++)
                {
                    Point3D translated = Point3D.Rotate(l3d.Points[i], Yaw_Angle, Pitch_Angle, Roll_Angle);
                    //bounding x check
                    if (translated.X < xmin)
                        xmin = translated.X;
                    else if (translated.X > xmax)
                        xmax = translated.X;
                    //bounding y check
                    if (translated.Y < ymin)
                        ymin = translated.Y;
                    else if (translated.Y > ymax)
                        ymax = translated.Y;

                    l3d.Points[i] = translated;
                }
            }

            double scaleFactor = xmax-xmin > ymax-ymin ? (double)bm.Width / (xmax-xmin) : (double)bm.Height / (ymax-ymin);

            //now to paint the picture
            using (var graphics = Graphics.FromImage(bm))
            {
                graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

                //center the image
                float yshift = (float)(Math.Abs(ymin) * scaleFactor + (bm.Height - (ymax - ymin) * scaleFactor) / 2);
                float xshift = (float)(Math.Abs(xmin) * scaleFactor + (bm.Width - (xmax - xmin) * scaleFactor) / 2);
                graphics.TranslateTransform(xshift, yshift);

                //draw all the lines, we project to the XY-plane simply by ignoring the Z dimension, since this is post-rotation
                for (int i = 0; i < AllLines.Count; i++)
                {
                    if (AllLines[i].Count == 0)
                        continue;

                    PointF[] pts2D = new PointF[AllLines[i].Count];
                    for (int j = 0; j < AllLines[i].Count; j++)
                        pts2D[j] = new PointF((float)(AllLines[i].Points[j].X * scaleFactor), (float)(AllLines[i].Points[j].Y * scaleFactor));

                    graphics.DrawLines(new Pen(AllLines[i].LineColor), pts2D);
                }
            }

            return bm;
        }
 private void iuc_OnSelected(InstanceUC sender, InstanceUC.SelectedChangedEventArgs e)
 {
     if (e.Selected)
     {
         this.selected_Aircraft = sender.aircraft;
         primaryVarCombobox_SelectedIndexChanged(sender, null);
         additionalVarCombobox_SelectedIndexChanged(sender, null);
         DefineControlSurfaceOptions(primaryExtraCombobox);
         DefineControlSurfaceOptions(additionalExtraCombobox);
         listView1.Items.Clear();
     }
 }