示例#1
0
        private void DrawGraph(GraphMode graphMode)
        {
            if (graphDirty)
            {
                if (this.vessel == null)
                {
                    this.vessel = VesselCache.SimulatedVessel.Borrow(EditorLogic.fetch.ship, VesselCache.SimCurves.Borrow(body));
                }

                if (!graphRequested)
                {
                    switch (graphMode)
                    {
                    case GraphMode.FlightEnvelope:
                        EnvelopeSurfGenerator.Calculate(vessel, body, 0, maxSpeed, speedStep, 0, maxAltitude, altitudeStep);
                        break;

                    case GraphMode.AoACurves:
                        AoACurveGenerator.Calculate(vessel, body, Altitude, Speed, -20f * Mathf.Deg2Rad, 20f * Mathf.Deg2Rad, 0.5f * Mathf.Deg2Rad);
                        break;

                    case GraphMode.VelocityCurves:
                        VelCurveGenerator.Calculate(vessel, body, Altitude, 0, maxSpeed, speedStep);
                        break;
                    }
                    graphRequested = true;
                }
                switch (GraphGenerator.Status)
                {
                case CalculationManager.RunStatus.PreStart:
                case CalculationManager.RunStatus.Cancelled:
                case CalculationManager.RunStatus.Running:
                    DrawProgressBar(GraphGenerator.PercentComplete);
                    break;

                case CalculationManager.RunStatus.Completed:
                    grapher.SetCollection(GraphGenerator.Graphables);
                    DrawGraph();
                    graphDirty = false;
                    break;
                }

                if (selectedCrossHairVect.x >= 0 && selectedCrossHairVect.y >= 0)
                {
                    selectedCrossHairVect = CrossHairsFromConditions(Altitude, Speed, AoA);
                    SetConditionsFromGraph(selectedCrossHairVect);
                    conditionDetails = GetConditionDetails(CurrentGraphMode, this.Altitude, this.Speed, CurrentGraphMode == GraphMode.AoACurves ? this.AoA : float.NaN, false);
                }
                else
                {
                    conditionDetails = "";
                }
            }
            else
            {
                DrawGraph();
            }
        }
示例#2
0
        private void DrawGraph(GraphMode graphMode, GraphSelect graphSelect)
        {
            if (graphDirty)
            {
                if (this.vessel == null)
                {
                    this.vessel = VesselCache.SimulatedVessel.Borrow(EditorLogic.fetch.ship, VesselCache.SimCurves.Borrow(body));
                }
                //this.vessel = new StockAero();

                switch (graphMode)
                {
                case GraphMode.FlightEnvelope:
                    if (!graphRequested)
                    {
                        EnvelopeSurfGenerator.Calculate(vessel, body, 0, maxSpeed, speedStep, 0, maxAltitude, altitudeStep);
                        graphRequested = true;
                    }
                    switch (EnvelopeSurfGenerator.Status)
                    {
                    case CalculationManager.RunStatus.PreStart:
                    case CalculationManager.RunStatus.Cancelled:
                    case CalculationManager.RunStatus.Running:
                        DrawProgressBar(EnvelopeSurfGenerator.PercentComplete);
                        break;

                    case CalculationManager.RunStatus.Completed:
                        /*for (int x = 0; x <= EnvelopeSurf.envelopePoints.GetUpperBound(0); x++)
                         * {
                         *  for (int y = 0; y <= EnvelopeSurf.envelopePoints.GetUpperBound(1); y++)
                         *  {
                         *      EnvelopeSurf.EnvelopePoint pt = EnvelopeSurf.envelopePoints[x, y];
                         *      //Debug.Log(String.Format("{0} / {1} / {2} / {3} / {4} / {5}", pt.altitude, pt.speed, pt.AoA_level, pt.Thrust_available, pt.Thrust_excess, pt.Accel_excess));
                         *      if(pt.speed == 930 && pt.altitude == 22200)
                         *      {
                         *          Debug.Log("AoA Level:        " + pt.AoA_level * 180 / Mathf.PI);
                         *          Debug.Log("Thrust Available: " + pt.Thrust_available);
                         *          Debug.Log("Excess Thrust:    " + pt.Thrust_excess);
                         *          Debug.Log("Excess Accel:     " + pt.Accel_excess);
                         *          Debug.Log("Speed:            " + pt.speed);
                         *          Debug.Log("Altitude:         " + pt.altitude);
                         *          Debug.Log("Force:            " + pt.force);
                         *          Debug.Log("LiftForce:        " + pt.liftforce);
                         *      }
                         *  }
                         * }//*/
                        grapher.Clear();
                        switch (graphSelect)
                        {
                        case GraphSelect.ExcessThrust:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Excess Thrust"));
                            break;

                        case GraphSelect.ExcessAcceleration:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Excess Acceleration"));
                            break;

                        case GraphSelect.ThrustAvailable:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Thrust Available"));
                            break;

                        case GraphSelect.LevelFlightAoA:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Level AoA"));
                            break;

                        case GraphSelect.MaxLiftAoA:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Max Lift AoA"));
                            break;

                        case GraphSelect.MaxLiftForce:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Max Lift"));
                            break;

                        case GraphSelect.LiftDragRatio:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Lift/Drag Ratio"));
                            break;

                        case GraphSelect.DragForce:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Drag"));
                            break;

                        case GraphSelect.LiftSlope:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Lift Slope"));
                            break;

                        case GraphSelect.PitchInput:
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Pitch Input"));
                            break;
                        }
                        if (WindTunnelSettings.ShowEnvelopeMask && (WindTunnelSettings.ShowEnvelopeMaskAlways || (CurrentGraphSelect != GraphSelect.ExcessThrust && CurrentGraphSelect != GraphSelect.ExcessAcceleration)))
                        {
                            grapher.Add(EnvelopeSurfGenerator.GetGraphableByName("Envelope Mask"));
                        }

                        graphDirty = false;
                        break;
                    }
                    break;

                case GraphMode.AoACurves:
                    if (!graphRequested)
                    {
                        AoACurveGenerator.Calculate(vessel, body, Altitude, Speed, -20f * Mathf.Deg2Rad, 20f * Mathf.Deg2Rad, 0.5f * Mathf.Deg2Rad);
                        graphRequested = true;
                    }
                    switch (AoACurveGenerator.Status)
                    {
                    case CalculationManager.RunStatus.PreStart:
                    case CalculationManager.RunStatus.Cancelled:
                    case CalculationManager.RunStatus.Running:
                        DrawProgressBar(AoACurveGenerator.PercentComplete);
                        break;

                    case CalculationManager.RunStatus.Completed:
                        grapher.Clear();
                        switch (graphSelect)
                        {
                        case GraphSelect.LiftForce:
                            grapher.Add(AoACurveGenerator.GetGraphableByName("Lift"));
                            break;

                        case GraphSelect.DragForce:
                            grapher.Add(AoACurveGenerator.GetGraphableByName("Drag"));
                            break;

                        case GraphSelect.LiftDragRatio:
                            grapher.Add(AoACurveGenerator.GetGraphableByName("Lift/Drag Ratio"));
                            break;

                        case GraphSelect.LiftSlope:
                            grapher.Add(AoACurveGenerator.GetGraphableByName("Lift Slope"));
                            break;

                        case GraphSelect.PitchInput:
                            grapher.Add(AoACurveGenerator.GetGraphableByName("Pitch Input"));
                            break;

                        case GraphSelect.Torque:
                            grapher.Add(AoACurveGenerator.GetGraphableByName("Torque"));
                            break;
                        }
                        graphDirty = false;
                        break;
                    }
                    break;

                case GraphMode.VelocityCurves:
                    if (!graphRequested)
                    {
                        VelCurveGenerator.Calculate(vessel, body, Altitude, 0, maxSpeed, speedStep);
                        graphRequested = true;
                    }
                    switch (VelCurveGenerator.Status)
                    {
                    case CalculationManager.RunStatus.PreStart:
                    case CalculationManager.RunStatus.Cancelled:
                    case CalculationManager.RunStatus.Running:
                        DrawProgressBar(VelCurveGenerator.PercentComplete);
                        break;

                    case CalculationManager.RunStatus.Completed:
                        grapher.Clear();
                        switch (graphSelect)
                        {
                        case GraphSelect.LevelFlightAoA:
                            grapher.Add(VelCurveGenerator.GetGraphableByName("Level AoA"));
                            break;

                        case GraphSelect.MaxLiftAoA:
                            grapher.Add(VelCurveGenerator.GetGraphableByName("Max Lift AoA"));
                            break;

                        case GraphSelect.ThrustAvailable:
                            grapher.Add(VelCurveGenerator.GetGraphableByName("Thrust Available"));
                            break;

                        case GraphSelect.LiftDragRatio:
                            grapher.Add(VelCurveGenerator.GetGraphableByName("Lift/Drag Ratio"));
                            break;

                        case GraphSelect.DragForce:
                            grapher.Add(VelCurveGenerator.GetGraphableByName("Drag"));
                            break;

                        case GraphSelect.LiftSlope:
                            grapher.Add(VelCurveGenerator.GetGraphableByName("Lift Slope"));
                            break;

                        case GraphSelect.PitchInput:
                            grapher.Add(VelCurveGenerator.GetGraphableByName("Pitch Input"));
                            break;
                        }
                        graphDirty = false;
                        break;
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException("graphMode");
                }

                if (GraphGenerator.Status == CalculationManager.RunStatus.Completed)
                {
                    //grapher.DrawGraphs();
                    DrawGraph();
                }

                if (selectedCrossHairVect.x >= 0 && selectedCrossHairVect.y >= 0)
                {
                    selectedCrossHairVect = CrossHairsFromConditions(Altitude, Speed, AoA);
                    SetConditionsFromGraph(selectedCrossHairVect);
                    conditionDetails = GetConditionDetails(CurrentGraphMode, this.Altitude, this.Speed, CurrentGraphMode == GraphMode.AoACurves ? this.AoA : float.NaN, false);
                }
                else
                {
                    conditionDetails = "";
                }
            }
            else
            {
                DrawGraph();
            }
        }