예제 #1
0
 public void Set()
 {
     if (parent.ActiveText != this.name.Text && parent.Active != -1)
     {
         var elements = new Structures.OrbitalElements()
         {
             semilatusrectum        = SLRScale.Value * AU,
             eccentricity           = EScale.Value,
             inclination            = IncScale.Value * deg,
             ascendingNodeLongitude = ANLScale.Value * deg,
             periapsisArgument      = PAScale.Value * deg,
             trueAnomaly            = TAScale.Value * deg
         };
         body = new Structures.Body(menu.new_bodies.FirstOrDefault(b => b.body.name == parent.ActiveText).body, elements);
     }
     body.name    = this.name.Text;
     body.stdGrav = Math.Pow(Math.E, MassScale.Value) * G * 1e22;
     body.radius  = RadiusScale.Value * 1e3;
     body.color   = new Vector3(RScale.Value, GScale.Value, BScale.Value);
 }
예제 #2
0
        public BodyBox(Menu menu, bool homogeneous = false, int spacing = 3) : base(homogeneous, spacing)
        {
            body            = new Structures.Body();
            name            = new Entry();
            name.IsEditable = true;
            name.Changed   += new EventHandler(menu.OnNameChanged);
            ResetParents();
            MassScale             = new Scale(Orientation.Vertical, 0.1, 50, 0.01);
            RadiusScale           = new Scale(Orientation.Vertical, 0.1, 1000000, 0.1);
            SLRScale              = new Scale(Orientation.Vertical, 0.1, 50, 0.01);
            EScale                = new Scale(Orientation.Vertical, 0, ECCENTRICITY_MAX, 0.001);
            IncScale              = new Scale(Orientation.Vertical, 0, 180, 0.01);
            ANLScale              = new Scale(Orientation.Vertical, 0, 359.99, 0.01);
            PAScale               = new Scale(Orientation.Vertical, 0, 359.99, 0.01);
            TAScale               = new Scale(Orientation.Vertical, 0, 359.99, 0.01);
            RScale                = new Scale(Orientation.Horizontal, 0, 1, 0.01);
            RScale.Value          = 1;
            GScale                = new Scale(Orientation.Horizontal, 0, 1, 0.01);
            GScale.Value          = 1;
            BScale                = new Scale(Orientation.Horizontal, 0, 1, 0.01);
            BScale.Value          = 1;
            CenterButton          = new CheckButton("Focusable");
            DeleteButton          = new Button("Delete");
            DeleteButton.Clicked += new EventHandler(OnDeleteClick);

            parent.Changed      += new EventHandler(OnParentChange);
            MassScale.Inverted   = true;
            RadiusScale.Inverted = true;
            SLRScale.Inverted    = true;
            EScale.Inverted      = true;
            IncScale.Inverted    = true;
            ANLScale.Inverted    = true;
            PAScale.Inverted     = true;
            TAScale.Inverted     = true;
            var pBox = new VBox(homogeneous: false, spacing: 3);

            pBox.PackStart(new Label("Parent Body"), false, false, 3); pBox.PackStart(parent, true, true, 3);
            var mBox = new VBox(homogeneous: false, spacing: 3);

            mBox.PackStart(new Label("ln(m)"), false, false, 3); mBox.PackStart(MassScale, true, true, 3);
            var rBox = new VBox(homogeneous: false, spacing: 3);

            rBox.PackStart(new Label("r (km)"), false, false, 3); rBox.PackStart(RadiusScale, true, true, 3);
            var slrBox = new VBox(homogeneous: false, spacing: 3);

            slrBox.PackStart(new Label("ρ (AU)"), false, false, 3); slrBox.PackStart(SLRScale, true, true, 3);
            var eBox = new VBox(homogeneous: false, spacing: 3);

            eBox.PackStart(new Label("e"), false, false, 3); eBox.PackStart(EScale, true, true, 3);
            var incBox = new VBox(homogeneous: false, spacing: 3);

            incBox.PackStart(new Label("i (°)"), false, false, 3); incBox.PackStart(IncScale, true, true, 3);
            var anlBox = new VBox(homogeneous: false, spacing: 3);

            anlBox.PackStart(new Label("Ω (°)"), false, false, 3); anlBox.PackStart(ANLScale, true, true, 3);
            var paBox = new VBox(homogeneous: false, spacing: 3);

            paBox.PackStart(new Label("ω (°)"), false, false, 3); paBox.PackStart(PAScale, true, true, 3);
            var taBox = new VBox(homogeneous: false, spacing: 3);

            taBox.PackStart(new Label("ν (°)"), false, false, 3); taBox.PackStart(TAScale, true, true, 3);

            this.PackStart(name, true, true, 3);
            this.PackStart(pBox, false, false, 3);
            this.PackStart(mBox, true, true, 3);
            this.PackStart(rBox, true, true, 3);
            this.PackStart(slrBox, true, true, 3);
            this.PackStart(eBox, true, true, 3);
            this.PackStart(incBox, true, true, 3);
            this.PackStart(anlBox, true, true, 3);
            this.PackStart(paBox, true, true, 3);
            this.PackStart(taBox, true, true, 3);

            var colorbox = new VBox(homogeneous: false, spacing: 3);

            colorbox.PackStart(new Label("RGB"), false, false, 3);
            colorbox.PackStart(RScale, true, true, 3);
            colorbox.PackStart(GScale, true, true, 3);
            colorbox.PackStart(BScale, true, true, 3);

            this.PackStart(colorbox, true, true, 3);
            var optionsbox = new VBox(homogeneous: false, spacing: 3);

            optionsbox.PackStart(CenterButton, true, true, 3);
            optionsbox.PackStart(DeleteButton, true, true, 3);
            this.PackStart(optionsbox, true, true, 3);
        }