コード例 #1
0
ファイル: DocumentText.cs プロジェクト: zooid/RhinoUserText
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var panel_id = Views.UserStringsPanelControl.PanelId;
            var visible  = Panels.IsPanelVisible(panel_id);

            if (mode == RunMode.Scripted)
            {
                var go = new Rhino.Input.Custom.GetOption();
                go.SetCommandPrompt(LOC.STR("Choose document text option"));
                var hide_index   = go.AddOption("Hide");
                var show_index   = go.AddOption("Show");
                var toggle_index = go.AddOption("Toggle");
                go.Get();
                if (go.CommandResult() != Result.Success)
                {
                    return(go.CommandResult());
                }

                var option = go.Option();
                if (null == option)
                {
                    return(Result.Failure);
                }

                var index = option.Index;
                if (index == hide_index)
                {
                    if (visible)
                    {
                        Panels.ClosePanel(panel_id);
                    }
                }
                else if (index == show_index)
                {
                    if (!visible)
                    {
                        Panels.OpenPanel(panel_id);
                    }
                }
                else if (index == toggle_index)
                {
                    if (visible)
                    {
                        Panels.ClosePanel(panel_id);
                    }
                    else
                    {
                        Panels.OpenPanel(panel_id);
                    }
                }
            }
            else
            {
                Panels.OpenPanel(panel_id);
            }



            return(Result.Success);
        }
コード例 #2
0
        protected override Rhino.Commands.Result RunCommand(Rhino.RhinoDoc doc, Rhino.Commands.RunMode mode)
        {
            System.Guid panelId  = SampleCsPanelUserControl.PanelId;
            bool        bVisible = Rhino.UI.Panels.IsPanelVisible(panelId);

            string prompt = (bVisible)
        ? "Sample panel is visible. New value"
        : "Sample Manager panel is hidden. New value";

            Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
            int hide_index   = go.AddOption("Hide");
            int show_index   = go.AddOption("Show");
            int toggle_index = go.AddOption("Toggle");

            go.Get();
            if (go.CommandResult() != Rhino.Commands.Result.Success)
            {
                return(go.CommandResult());
            }

            Rhino.Input.Custom.CommandLineOption option = go.Option();
            if (null == option)
            {
                return(Rhino.Commands.Result.Failure);
            }

            int index = option.Index;

            if (index == hide_index)
            {
                if (bVisible)
                {
                    Rhino.UI.Panels.ClosePanel(panelId);
                }
            }
            else if (index == show_index)
            {
                if (!bVisible)
                {
                    Rhino.UI.Panels.OpenPanel(panelId);
                }
            }
            else if (index == toggle_index)
            {
                if (bVisible)
                {
                    Rhino.UI.Panels.ClosePanel(panelId);
                }
                else
                {
                    Rhino.UI.Panels.OpenPanel(panelId);
                }
            }

            return(Rhino.Commands.Result.Success);
        }
コード例 #3
0
    public static Rhino.Commands.Result SpriteDrawing(RhinoDoc doc)
    {
        var sprite_mode  = new Rhino.Input.Custom.OptionToggle(m_draw_single_sprite, "SpriteList", "SingleSprite");
        var size_option  = new Rhino.Input.Custom.OptionDouble(m_sprite_size);
        var space_option = new Rhino.Input.Custom.OptionToggle(m_draw_world_location, "Screen", "World");
        var go           = new Rhino.Input.Custom.GetOption();

        go.SetCommandPrompt("Sprite drawing mode");
        go.AddOptionToggle("Mode", ref sprite_mode);
        go.AddOptionDouble("Size", ref size_option);
        go.AddOptionToggle("DrawSpace", ref space_option);
        int option_go   = go.AddOption("Spin");
        int option_file = go.AddOption("FileSprite");

        Rhino.Display.DisplayPipeline.PostDrawObjects      += DisplayPipeline_PostDrawObjects;
        Rhino.Display.DisplayPipeline.CalculateBoundingBox += DisplayPipeline_CalculateBoundingBox;

        doc.Views.Redraw();
        while (go.Get() == Rhino.Input.GetResult.Option)
        {
            m_draw_single_sprite  = sprite_mode.CurrentValue;
            m_sprite_size         = (float)size_option.CurrentValue;
            m_draw_world_location = space_option.CurrentValue;
            if (go.OptionIndex() == option_go)
            {
                var gs = new Rhino.Input.Custom.GetOption();
                gs.SetCommandPrompt("press enter/escape to end");
                gs.SetWaitDuration(1);

                var vp = doc.Views.ActiveView.MainViewport;
                while (gs.Get() == Rhino.Input.GetResult.Timeout)
                {
                    vp.Rotate(0.1, Vector3d.ZAxis, Point3d.Origin);
                    doc.Views.Redraw();
                }
            }
            else if (go.OptionIndex() == option_file)
            {
                var dlg = new Rhino.UI.OpenFileDialog();
                if (dlg.ShowDialog())
                {
                    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(dlg.FileName);
                    m_sprite = new Rhino.Display.DisplayBitmap(bmp);
                }
                doc.Views.Redraw();
            }
            else
            {
                doc.Views.Redraw();
            }
        }

        Rhino.Display.DisplayPipeline.PostDrawObjects      -= DisplayPipeline_PostDrawObjects;
        Rhino.Display.DisplayPipeline.CalculateBoundingBox -= DisplayPipeline_CalculateBoundingBox;
        return(Rhino.Commands.Result.Success);
    }
コード例 #4
0
    protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
    {
      var sprite_mode = new Rhino.Input.Custom.OptionToggle(m_draw_single_sprite, "SpriteList", "SingleSprite");
      var size_option = new Rhino.Input.Custom.OptionDouble(m_sprite_size);
      var space_option = new Rhino.Input.Custom.OptionToggle(m_draw_world_location, "Screen", "World");
      var go = new Rhino.Input.Custom.GetOption();
      go.SetCommandPrompt("Sprite drawing mode");
      go.AddOptionToggle("Mode", ref sprite_mode);
      go.AddOptionDouble("Size", ref size_option);
      go.AddOptionToggle("DrawSpace", ref space_option);
      int option_go = go.AddOption("Spin");
      int option_file = go.AddOption("FileSprite");

      Rhino.Display.DisplayPipeline.PostDrawObjects += DisplayPipeline_PostDrawObjects;
      Rhino.Display.DisplayPipeline.CalculateBoundingBox += DisplayPipeline_CalculateBoundingBox;

      doc.Views.Redraw();
      while (go.Get() == Rhino.Input.GetResult.Option)
      {
        m_draw_single_sprite = sprite_mode.CurrentValue;
        m_sprite_size = (float)size_option.CurrentValue;
        m_draw_world_location = space_option.CurrentValue;
        if (go.OptionIndex() == option_go)
        {
          var gs = new Rhino.Input.Custom.GetOption();
          gs.SetCommandPrompt("press enter/escape to end");
          gs.SetWaitDuration(1);

          var vp = doc.Views.ActiveView.MainViewport;
          while (gs.Get() == Rhino.Input.GetResult.Timeout)
          {
            vp.Rotate(0.1, Vector3d.ZAxis, Point3d.Origin);
            doc.Views.Redraw();
          }
        }
        else if (go.OptionIndex() == option_file)
        {
          System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
          if (dlg.ShowDialog(RhinoApp.MainWindow()) == System.Windows.Forms.DialogResult.OK)
          {
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(dlg.FileName);
            m_sprite = new Rhino.Display.DisplayBitmap(bmp);
          }
          doc.Views.Redraw();
        }
        else
          doc.Views.Redraw();
      }

      Rhino.Display.DisplayPipeline.PostDrawObjects -= DisplayPipeline_PostDrawObjects;
      Rhino.Display.DisplayPipeline.CalculateBoundingBox -= DisplayPipeline_CalculateBoundingBox;
      return Rhino.Commands.Result.Success;
    }
コード例 #5
0
ファイル: ToolParam.cs プロジェクト: AxisArch/Axis
        protected override GH_GetterResult Prompt_Singular(ref IGH_Goo value)
        {
            Rhino.Input.Custom.GetPoint gpC = new Rhino.Input.Custom.GetPoint();
            gpC.SetCommandPrompt("Set default tool center point.");
            gpC.AcceptNothing(true);

            Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
            go.SetCommandPrompt("Set default tool.");
            go.AcceptNothing(true);
            go.AddOption("True");

            switch (go.Get())
            {
            case Rhino.Input.GetResult.Option:
                if (go.Option().EnglishName == "True")
                {
                    value = ABBTool.Default;
                }
                return(GH_GetterResult.success);

            case Rhino.Input.GetResult.Nothing:
                return(GH_GetterResult.accept);

            default:
                return(GH_GetterResult.cancel);
            }
        }
コード例 #6
0
    public static Rhino.Commands.Result ShowSurfaceDirection(Rhino.RhinoDoc doc)
    {
        Rhino.DocObjects.ObjRef objref;
        var rc = Rhino.Input.RhinoGet.GetOneObject("Select surface or polysurface for direction display",
                                                   false,
                                                   Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.PolysrfFilter,
                                                   out objref);

        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }

        var brep = objref.Brep();

        if (brep == null)
        {
            return(Rhino.Commands.Result.Failure);
        }

        bool bIsSolid = brep.IsSolid;

        TestSurfaceDirConduit conduit = new TestSurfaceDirConduit(brep);

        conduit.Enabled = true;
        doc.Views.Redraw();

        var gf = new Rhino.Input.Custom.GetOption();

        gf.SetCommandPrompt("Press enter when done");
        gf.AcceptNothing(true);
        if (!bIsSolid)
        {
            gf.AddOption("Flip");
        }

        for (; ;)
        {
            var res = gf.Get();
            if (res == Rhino.Input.GetResult.Option)
            {
                conduit.Flip = !conduit.Flip;
                doc.Views.Redraw();
                continue;
            }
            if (res == Rhino.Input.GetResult.Nothing)
            {
                if (!bIsSolid && conduit.Flip)
                {
                    brep.Flip();
                    doc.Objects.Replace(objref, brep);
                }
            }
            break;
        }

        conduit.Enabled = false;
        doc.Views.Redraw();
        return(Rhino.Commands.Result.Success);
    }
コード例 #7
0
        protected override Rhino.Commands.Result RunCommand(Rhino.RhinoDoc doc, Rhino.Commands.RunMode mode)
        {
            System.Guid panelId = SampleCsPanelUserControl.PanelId;
              bool bVisible = Rhino.UI.Panels.IsPanelVisible(panelId);

              string prompt = (bVisible)
            ? "Sample panel is visible. New value"
            : "Sample Manager panel is hidden. New value";

              Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
              int hide_index = go.AddOption("Hide");
              int show_index = go.AddOption("Show");
              int toggle_index = go.AddOption("Toggle");

              go.Get();
              if (go.CommandResult() != Rhino.Commands.Result.Success)
            return go.CommandResult();

              Rhino.Input.Custom.CommandLineOption option = go.Option();
              if (null == option)
            return Rhino.Commands.Result.Failure;

              int index = option.Index;

              if (index == hide_index)
              {
            if (bVisible)
              Rhino.UI.Panels.ClosePanel(panelId);
              }
              else if (index == show_index)
              {
            if (!bVisible)
              Rhino.UI.Panels.OpenPanel(panelId);
              }
              else if (index == toggle_index)
              {
            if (bVisible)
              Rhino.UI.Panels.ClosePanel(panelId);
            else
              Rhino.UI.Panels.OpenPanel(panelId);
              }

              return Rhino.Commands.Result.Success;
        }
コード例 #8
0
        protected override Rhino.Commands.Result RunCommand(Rhino.RhinoDoc doc, Rhino.Commands.RunMode mode)
        {
            var panel_id = Views.SampleCsEtoPanel.PanelId;
              var visible = Rhino.UI.Panels.IsPanelVisible(panel_id);

              var prompt = (visible)
            ? "Sample panel is visible. New value"
            : "Sample panel is hidden. New value";

              var go = new Rhino.Input.Custom.GetOption();
              go.SetCommandPrompt(prompt);
              var hide_index = go.AddOption("Hide");
              var show_index = go.AddOption("Show");
              var toggle_index = go.AddOption("Toggle");
              go.Get();
              if (go.CommandResult() != Rhino.Commands.Result.Success)
            return go.CommandResult();

              var option = go.Option();
              if (null == option)
            return Rhino.Commands.Result.Failure;

              var index = option.Index;
              if (index == hide_index)
              {
            if (visible)
              Rhino.UI.Panels.ClosePanel(panel_id);
              }
              else if (index == show_index)
              {
            if (!visible)
              Rhino.UI.Panels.OpenPanel(panel_id);
              }
              else if (index == toggle_index)
              {
            if (visible)
              Rhino.UI.Panels.ClosePanel(panel_id);
            else
              Rhino.UI.Panels.OpenPanel(panel_id);
              }

              return Rhino.Commands.Result.Success;
        }
コード例 #9
0
        private bool SetPageUnit(RhinoDoc doc)
        {
            bool result = false;

            try
            {
                Rhino.Input.Custom.GetOption getOption = new Rhino.Input.Custom.GetOption();
                getOption.SetCommandPrompt("Set Page Units");

                foreach (string unit in optionValues)
                {
                    getOption.AddOption(unit);
                }

                getOption.Get();
                if (getOption.CommandResult() != Rhino.Commands.Result.Success)
                {
                    return(false);
                }

                string selectedUnit = getOption.Option().EnglishName;
                switch (selectedUnit)
                {
                case "Inch":
                    doc.AdjustPageUnitSystem(UnitSystem.Inches, true);
                    break;

                case "Foot":
                    doc.AdjustPageUnitSystem(UnitSystem.Feet, true);
                    break;

                case "Millimeter":
                    doc.AdjustPageUnitSystem(UnitSystem.Millimeters, true);
                    break;

                case "Centimeter":
                    doc.AdjustPageUnitSystem(UnitSystem.Centimeters, true);
                    break;

                case "Meter":
                    doc.AdjustPageUnitSystem(UnitSystem.Meters, true);
                    break;
                }

                doc.Views.Redraw();
                result = true;
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(result);
        }
コード例 #10
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.Display.RhinoView view = doc.Views.ActiveView;
            if (null == view)
            {
                return(Result.Failure);
            }

            Rhino.Display.RhinoViewport          viewport           = view.ActiveViewport;
            Rhino.Display.DisplayModeDescription currentDisplayMode = viewport.DisplayMode;
            Rhino.RhinoApp.WriteLine("Viewport in {0} display.", currentDisplayMode.EnglishName);

            Rhino.Display.DisplayModeDescription[] displayModes = Rhino.Display.DisplayModeDescription.GetDisplayModes();

            Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
            go.SetCommandPrompt("Select new display mode");
            go.AcceptNothing(true);

            foreach (Rhino.Display.DisplayModeDescription displayMode in displayModes)
            {
                string displayName = FormatValidDisplayName(displayMode.EnglishName);
                go.AddOption(displayName);
            }

            Rhino.Input.GetResult rc = go.Get();
            switch (rc)
            {
            case Rhino.Input.GetResult.Option:
            {
                int optionIndex = go.Option().Index;
                if (optionIndex > 0 && optionIndex <= displayModes.Length)
                {
                    Rhino.Display.DisplayModeDescription newDisplayMode = displayModes[optionIndex - 1];
                    if (newDisplayMode.Id != currentDisplayMode.Id)
                    {
                        viewport.DisplayMode = newDisplayMode;
                        view.Redraw();
                        Rhino.RhinoApp.WriteLine("Viewport set to {0} display.", viewport.DisplayMode.EnglishName);
                    }
                }
            }
            break;

            case Rhino.Input.GetResult.Cancel:
                return(Result.Cancel);

            default:
                break;
            }

            return(Result.Success);
        }
コード例 #11
0
ファイル: MotionTypeParam.cs プロジェクト: AxisArch/Axis
        protected override GH_GetterResult Prompt_Singular(ref GH_Integer value)
        {
            Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
            go.SetCommandPrompt("Set default motion type.");
            go.AcceptNothing(true);
            go.AddOption("True");

            switch (go.Get())
            {
            case Rhino.Input.GetResult.Option:
                if (go.Option().EnglishName == "True")
                {
                    value = new GH_Integer((int)MotionType.Linear);
                }
                return(GH_GetterResult.success);

            case Rhino.Input.GetResult.Nothing:
                return(GH_GetterResult.accept);

            default:
                return(GH_GetterResult.cancel);
            }
        }
コード例 #12
0
    // The following example code demonstrates how to modify advanced display settings using
    // the Rhino SDK. In this example, a display mode's mesh wireframe thickness (in pixels)
    // will be modified.
    public static Rhino.Commands.Result AdvancedDisplay(Rhino.RhinoDoc doc)
    {
        // Use the display attributes manager to build a list of display modes.
        // Note, these are copies of the originals...
        DisplayModeDescription[] display_modes = DisplayModeDescription.GetDisplayModes();
        if (display_modes == null || display_modes.Length < 1)
        {
            return(Rhino.Commands.Result.Failure);
        }

        // Construct an options picker so the user can pick which
        // display mode they want modified
        Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
        go.SetCommandPrompt("Display mode to modify mesh thickness");
        List <int> opt_list = new List <int>();

        for (int i = 0; i < display_modes.Length; i++)
        {
            string english_name = display_modes[i].EnglishName;
            english_name = english_name.Replace("_", "");
            english_name = english_name.Replace(" ", "");
            english_name = english_name.Replace("-", "");
            english_name = english_name.Replace(",", "");
            english_name = english_name.Replace(".", "");
            int index = go.AddOption(english_name);
            opt_list.Add(index);
        }

        // Get the command option
        go.Get();
        if (go.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(go.CommandResult());
        }

        int selected_index = go.Option().Index;
        DisplayModeDescription selected_description = null;

        for (int i = 0; i < opt_list.Count; i++)
        {
            if (opt_list[i] == selected_index)
            {
                selected_description = display_modes[i];
                break;
            }
        }

        // Validate...
        if (selected_description == null)
        {
            return(Rhino.Commands.Result.Failure);
        }

        // Modify the desired display mode. In this case, we
        // will just set the mesh wireframe thickness to zero.
        selected_description.DisplayAttributes.MeshSpecificAttributes.MeshWireThickness = 0;
        // Use the display attributes manager to update the display mode.
        DisplayModeDescription.UpdateDisplayMode(selected_description);

        // Force the document to regenerate.
        doc.Views.Redraw();
        return(Rhino.Commands.Result.Success);
    }
コード例 #13
0
            ///<summary> This gets called when when the user runs this command.</summary> 
            protected override Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
            {
                SourceConduit m_source_conduit = SourceConduit.Instance;

                Rhino.Input.Custom.GetObject GO = new Rhino.Input.Custom.GetObject();
                GO.SetCommandPrompt("Select source curve...");
                GO.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
                GO.AddOption("TrafficWelsh");
                GO.AddOption("TrafficFHWA");
                GO.AddOption("AircraftANCON");
                GO.AddOption("Custom");
                //GO.AddOptionList("SourceType", new List<string>() { "TrafficWelshStandard", "TrafficFHWA Standard", "Custom" }, 2);
                GO.GroupSelect = false;
                GO.SubObjectSelect = false;
                GO.EnableClearObjectsOnEntry(false);
                GO.EnableUnselectObjectsOnExit(false);
                GO.DeselectAllBeforePostSelect = false;

                int pavement = 0;
                double SPLW = 0;
                double[] SWL = new double[] { 120, 120, 120, 120, 120, 120, 120, 120 };
                double velocity = 83;
                double delta = 45;
                double choice = 0;
                for (; ; )
                {
                    Rhino.Input.GetResult GR = GO.GetMultiple(1, 1);
                    int type = GO.OptionIndex();
                    if (GR == Rhino.Input.GetResult.Option)
                    {
                        choice = (int)type;
                        //type = GO.Option().EnglishName;
                        if (type == 1)//"Traffic (Welsh Standard)")
                        {
                            Rhino.Input.RhinoGet.GetNumber("Input basis road sound pressure level at 1 m from street...", false, ref SPLW);
                            SPLW += 8;
                        }
                        else if (type == 2)//"Traffic (FHWA Standard)")
                        {
                            ///Described at:
                            ///http://www.fhwa.dot.gov/environment/noise/traffic_noise_model/old_versions/tnm_version_10/tech_manual/tnm03.cfm#tnma2

                            double s = 0;
                            //int i = 0;

                            Rhino.Input.RhinoGet.GetNumber("Enter the speed of traffic on this road (in kph)...", false, ref s);

                            ///Pavement
                            Rhino.Input.Custom.GetOption GOpt = new Rhino.Input.Custom.GetOption();
                            GOpt.SetCommandPrompt("Pavement type...");
                            GOpt.AddOption("Average_DGAC_PCC)");
                            GOpt.AddOption("DGAC_Asphalt");
                            GOpt.AddOption("PCC_Concrete");
                            GOpt.AddOption("OGAC_OpenGradedAsphalt");
                            GOpt.AcceptNothing(false);
                            GOpt.Get();
                            pavement = GOpt.OptionIndex();

                            ///Vehicle tallies
                            double[] Veh = new double[5] { 0, 0, 0, 0, 0 };
                            Rhino.Input.RhinoGet.GetNumber("Enter the number of automobiles per hour...", false, ref Veh[0]);
                            Rhino.Input.RhinoGet.GetNumber("Enter the number of medium trucks per hour...", false, ref Veh[1]);
                            Rhino.Input.RhinoGet.GetNumber("Enter the number of heavy trucks per hour...", false, ref Veh[2]);
                            Rhino.Input.RhinoGet.GetNumber("Enter the number of buses per hour...", false, ref Veh[3]);
                            Rhino.Input.RhinoGet.GetNumber("Enter the number of motorcycles per hour...", false, ref Veh[4]);

                            bool throttle = false;
                            int t = 0;
                            Rhino.Input.RhinoGet.GetBool("Full throttle?", false, "Yes", "No", ref throttle);
                            t = (throttle) ? 1 : 0;
                            double root2 = Math.Sqrt(2);
                            double vtot = 0;
                            double[] Es = new double[8] { 0, 0, 0, 0, 0, 0, 0, 0 };

                            for (int v = 0; v < 5; v++)
                            {
                                double A = FHWATraffic[v][pavement][t][0];
                                double B = FHWATraffic[v][pavement][t][1];
                                double C = FHWATraffic[v][pavement][t][2];
                                double D1 = FHWATraffic[v][pavement][t][3];
                                double D2 = FHWATraffic[v][pavement][t][4];
                                double E1 = FHWATraffic[v][pavement][t][5];
                                double E2 = FHWATraffic[v][pavement][t][6];
                                double F1 = FHWATraffic[v][pavement][t][7];
                                double F2 = FHWATraffic[v][pavement][t][8];
                                double G1 = FHWATraffic[v][pavement][t][9];
                                double G2 = FHWATraffic[v][pavement][t][10];
                                double H1 = FHWATraffic[v][pavement][t][11];
                                double H2 = FHWATraffic[v][pavement][t][12];
                                double I1 = FHWATraffic[v][pavement][t][13];
                                double I2 = FHWATraffic[v][pavement][t][14];
                                double J1 = FHWATraffic[v][pavement][t][15];
                                double J2 = FHWATraffic[v][pavement][t][16];

                                vtot += Veh[v];

                                for (int oct = 0; oct < 8; oct++)
                                {
                                    double f = 62.5 * Math.Pow(2, oct);
                                    double[] freq = new double[3] { f / root2, f, f * root2 };

                                    for (int oct3 = 0; oct3 < 3; oct3++)
                                    {
                                        double Ea = Math.Pow(0.6214 * s, A / 10) * Math.Pow(10, B / 10) + Math.Pow(10, C / 10);
                                        double logf = Math.Log10(freq[oct3]);
                                        double Ls = 10 * Math.Log10(Ea) + (D1 + 0.6214 * D2 * s) + (E1 + 0.6214 * E2 * s) * logf
                                            + (F1 + 0.6214 * F2 * s) * logf * logf + (G1 + 0.6214 * G2 * s) * logf * logf * logf
                                            + (H1 + 0.6214 * H2 * s) * logf * logf * logf * logf + (I1 + 0.6214 * I2 * s) * logf * logf * logf * logf * logf
                                            + (J1 + 0.6214 * J2 * s) * logf * logf * logf * logf * logf * logf;
                                        Es[oct] += 0.0476 * Math.Pow(10, Ls / 10) * Veh[v] / s;
                                    }
                                }
                            }

                            double[] Awt = new double[8] { -26, -16, -9, -3, 0, 1.2, 1, -1 };
                            double dmod = 10 * Math.Log10(1 / (Utilities.Numerics.PiX2 * 15));

                            for (int oct = 0; oct < 8; oct++)
                            {
                                SWL[oct] = 10 * Math.Log10(Es[oct]) - Awt[oct] - dmod;//
                            }
                        }
                        else if (type == 3)//"Aircraft (ANCON-derived)")
                        {
                            Rhino.Input.Custom.GetOption GOpt = new Rhino.Input.Custom.GetOption();
                            GOpt.SetCommandPrompt("Takeoff or Landing?");
                            GOpt.AddOption("Takeoff");
                            GOpt.AddOption("Landing");
                            GOpt.AddOption("Both");
                            GOpt.AcceptNothing(false);
                            GOpt.Get();
                            int TL_Choice = GOpt.OptionIndex();

                            double SWLA = 150;

                            Rhino.Input.RhinoGet.GetNumber("What is the broadband sound power of the aircraft (in dBA)?", false, ref SWLA);
                            Rhino.Input.RhinoGet.GetNumber("What is the maximum velocity of the aircraft in m/s?", false, ref velocity);
                            Rhino.Input.RhinoGet.GetNumber("What is the slant angle for this aircraft?", false, ref delta);

                            double[][] Aircraft_Normalization = new double[3][] {
                                //new double[8]{ -12, -10.5, -12, -15, -20, -27, -40, -44},
                                //new double[8]{-11, -13, -12, -13.5, -18, -21, -25, -35},
                                //new double[8]{-11, -10.5, -12, -13.5, -18, -21, -25, -35}
                            new double[8] { 6.191472203, 7.691472203, 6.191472203, 3.191472203, -1.808527797, -8.808527797,-21.8085278, -25.8085278},
                            new double[8] { 5.6783811710, 3.6783811710, 4.678381171, 3.178381171, -1.321618829, -4.321618829, -8.321618829, -18.32161883},
                            new double[8] { 5.678381171, 6.178381171, 4.678381171, 3.178381171, -1.321618829, -4.321618829, -8.321618829, -18.32161883}
                            };

                            for (int oct = 0; oct < 8; oct++)
                            {
                                SWL[oct] = SWLA + Aircraft_Normalization[TL_Choice-1][oct];//
                            }
                        }
                        //    continue;
                        //    //return Result.Success;
                        //}
                    }
                    else if (GR == Rhino.Input.GetResult.Object)
                    {
                        for (int i = 0; i < GO.ObjectCount; i++)
                        {
                            Rhino.DocObjects.ObjRef obj = GO.Object(i);

                            Rhino.DocObjects.RhinoObject rhObj = doc.Objects.Find(obj.ObjectId);

                            rhObj.Attributes.Name = "Acoustical Source";

                            if (choice == 1)//"Traffic (Welsh Standard)")
                            {
                                rhObj.Geometry.SetUserString("SourceType", "Traffic (Welsh)");
                                for (int oct = 0; oct < 8; oct++) SWL[oct] = SPLW + WelshTraffic[oct];
                            }
                            else if (choice == 2)//"Traffic (FWHA Standard)")
                            {
                                rhObj.Geometry.SetUserString("SourceType", "Traffic (FHWA)");
                            }
                            else if (choice == 3)//"Aircraft (ANCON-derived)")
                            {
                                rhObj.Geometry.SetUserString("SourceType", "Aircraft (ANCON derived)");
                                rhObj.Geometry.SetUserString("Velocity", velocity.ToString());
                                rhObj.Geometry.SetUserString("delta", delta.ToString());
                            }
                            else
                            {
                                Rhino.Input.RhinoGet.GetNumber("62.5 Hz. Sound Power Level", true, ref SWL[0]);
                                Rhino.Input.RhinoGet.GetNumber("125 Hz. Sound Power Level", true, ref SWL[1]);
                                Rhino.Input.RhinoGet.GetNumber("250 Hz. Sound Power Level", true, ref SWL[2]);
                                Rhino.Input.RhinoGet.GetNumber("500 Hz. Sound Power Level", true, ref SWL[3]);
                                Rhino.Input.RhinoGet.GetNumber("1000 Hz. Sound Power Level", true, ref SWL[4]);
                                Rhino.Input.RhinoGet.GetNumber("2000 Hz. Sound Power Level", true, ref SWL[5]);
                                Rhino.Input.RhinoGet.GetNumber("4000 Hz. Sound Power Level", true, ref SWL[6]);
                                Rhino.Input.RhinoGet.GetNumber("8000 Hz. Sound Power Level", true, ref SWL[7]);
                            }

                            rhObj.Geometry.SetUserString("SWL", Utilities.PachTools.EncodeSourcePower(SWL));
                            rhObj.Geometry.SetUserString("Phase", "0;0;0;0;0;0;0;0");
                            doc.Objects.ModifyAttributes(rhObj, rhObj.Attributes, true);

                            m_source_conduit.SetSource(rhObj);
                        }

                        doc.Views.Redraw();
                        return Result.Success;
                    }
                    else return Result.Cancel;
                }
            }
コード例 #14
0
            ///<summary> This gets called when when the user runs this command.</summary> 
            protected override Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
            {
                SourceConduit m_source_conduit = SourceConduit.Instance;

                Rhino.Geometry.Point3d Pt;

                Rhino.Input.RhinoGet.GetPoint("Select Location of speaker's mouth...", false, out Pt);

                Rhino.Input.Custom.GetOption GOpt_type = new Rhino.Input.Custom.GetOption();
                Rhino.Input.Custom.GetOption GOpt_act = new Rhino.Input.Custom.GetOption();

                GOpt_type.SetCommandPrompt("Pick what kind of speaker this is...");
                GOpt_type.AddOption("Man");
                GOpt_type.AddOption("Woman");
                GOpt_type.AddOption("Child");
                GOpt_type.AcceptNothing(false);
                GOpt_type.Get();

                Rhino.Input.Custom.GetOption GOpt = new Rhino.Input.Custom.GetOption();
                GOpt_act.SetCommandPrompt("Pick the best descriptor of vocal effort...");
                GOpt_act.AddOption("SoftOrWhispered");
                GOpt_act.AddOption("Conversation");
                GOpt_act.AddOption("CompetingConversation");
                GOpt_act.AddOption("Singing");
                GOpt_act.AddOption("Shouting");
                GOpt_act.AcceptNothing(false);
                GOpt_act.Get();

                double[] SPL = new double[0];

                switch (GOpt_type.OptionIndex())
                {
                    case 0:
                        SPL = Males[GOpt_act.OptionIndex()-1];
                        break;
                    case 1:
                        SPL = Females[GOpt_act.OptionIndex()-1];
                        break;
                    case 2:
                        SPL = Children[GOpt_act.OptionIndex()-1];
                        break;
                }

                Rhino.DocObjects.RhinoObject rhObj = doc.Objects.Find(doc.Objects.AddPoint(Pt));
                rhObj.Attributes.Name = "Acoustical Source";
                rhObj.Geometry.SetUserString("SourceType", "0");
                for (int i = 0; i < 8; i++) SPL[i] += 11;
                rhObj.Geometry.SetUserString("SWL", Utilities.PachTools.EncodeSourcePower(SPL));
                rhObj.Geometry.SetUserString("Phase", "0;0;0;0;0;0;0;0");
                doc.Objects.ModifyAttributes(rhObj, rhObj.Attributes, true);

                m_source_conduit.SetSource(rhObj);
                doc.Views.Redraw();

                Rhino.RhinoApp.WriteLine("Apologies, but at this time, human sources are treated as omnidirectional, which is great if you are trying to ");
                Rhino.RhinoApp.WriteLine("characterize speech, but not so good if you are trying to simulate an exact individual in the act of speaking...");
                Rhino.RhinoApp.WriteLine("If you happen to know of a good database with human speech directivity, or would otherwise like to contribute, please let me know. --Arthur");

                return Result.Success;
            }
コード例 #15
0
            ///<summary> This gets called when when the user runs this command.</summary> 
            protected override Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
            {
                SourceConduit m_source_conduit = SourceConduit.Instance;

                //Rhino.DocObjects.ObjRef location;

                string type = "custom";

                Rhino.Input.Custom.GetObject GO = new Rhino.Input.Custom.GetObject();
                GO.SetCommandPrompt("Select source surface...");
                GO.GeometryFilter = Rhino.DocObjects.ObjectType.Brep;
                GO.AddOption("Crowd");
                GO.GroupSelect = false;
                GO.SubObjectSelect = false;
                GO.EnableClearObjectsOnEntry(false);
                GO.EnableUnselectObjectsOnExit(false);
                GO.DeselectAllBeforePostSelect = false;

                int Men = 100, Women = 100, Kids = 100, effort = 0;

                do
                {
                    Rhino.Input.GetResult GR = GO.Get();

                    if (GR == Rhino.Input.GetResult.Option)
                    {
                        type = GO.Option().EnglishName;
                        if (type == "Crowd")
                        {
                            Rhino.Input.RhinoGet.GetInteger("Number of Men in Crowd...", true, ref Men);
                            Rhino.Input.RhinoGet.GetInteger("Number of Women in Crowd...", true, ref Women);
                            Rhino.Input.RhinoGet.GetInteger("Number of Children in Crowd...", true, ref Kids);

                            Rhino.Input.Custom.GetOption GOpt = new Rhino.Input.Custom.GetOption();
                            GOpt.SetCommandPrompt("Speech Activity");
                            GOpt.AddOption("SoftOrWhispered");
                            GOpt.AddOption("Conversation");
                            GOpt.AddOption("CompetingConversation");
                            GOpt.AddOption("Singing");
                            GOpt.AddOption("AllShouting");
                            GOpt.AcceptNothing(false);

                            GOpt.Get();
                            effort = GOpt.OptionIndex() - 1;
                        }
                        continue;
                    }
                    else if (GR == Rhino.Input.GetResult.Object)
                    {
                        for (int i = 0; i < GO.ObjectCount; i++)
                        {
                            Rhino.DocObjects.ObjRef obj = GO.Object(i);

                            Rhino.DocObjects.RhinoObject rhObj = doc.Objects.Find(obj.ObjectId);

                            double Area = (rhObj.Geometry as Rhino.Geometry.Brep).GetArea();

                            rhObj.Attributes.Name = "Acoustical Source";
                            rhObj.Geometry.SetUserString("SourceType", "");

                            double[] SPL = new double[] { 120, 120, 120, 120, 120, 120, 120, 120 };

                            if (type == "Crowd")
                            {
                                //double mod = (effort < 3) ? .5 : 1;

                                //Correct for tightly packed spaces, and competing speech.
                                //if (Area / (Men + Women + Kids) < 3.0f)
                                //{
                                //    //In overcrowded scenarios, vocal effort escalates as such:
                                //    //whispering becomes conversation.
                                //    //conversation becomes competing conversation.
                                //    //competing conversation becomes shouting.
                                //    //Singing stays singing... I'm pretty sure experienced singers wouldn't start shouting...
                                //    if (effort < 2) effort++;
                                //    else effort = 4;
                                //}

                                for (int oct = 0; oct < 8; oct++)
                                {
                                    double Power = Men * Math.Pow(10, Males[effort][oct] / 10) + Women * Math.Pow(10, Females[effort][oct] / 10) + Kids * Math.Pow(10, Children[effort][oct] / 10);
                                    //Power /= (Area);
                                    SPL[oct] = 10 * Math.Log10(Power) + 11;
                                }
                            }
                            else
                            {
                                Rhino.Input.RhinoGet.GetNumber("62.5 Hz. Sound Power Level", true, ref SPL[0]);
                                Rhino.Input.RhinoGet.GetNumber("125 Hz. Sound Power Level", true, ref SPL[1]);
                                Rhino.Input.RhinoGet.GetNumber("250 Hz. Sound Power Level", true, ref SPL[2]);
                                Rhino.Input.RhinoGet.GetNumber("500 Hz. Sound Power Level", true, ref SPL[3]);
                                Rhino.Input.RhinoGet.GetNumber("1000 Hz. Sound Power Level", true, ref SPL[4]);
                                Rhino.Input.RhinoGet.GetNumber("2000 Hz. Sound Power Level", true, ref SPL[5]);
                                Rhino.Input.RhinoGet.GetNumber("4000 Hz. Sound Power Level", true, ref SPL[6]);
                                Rhino.Input.RhinoGet.GetNumber("8000 Hz. Sound Power Level", true, ref SPL[7]);
                            }

                            rhObj.Geometry.SetUserString("SWL", Utilities.PachTools.EncodeSourcePower(SPL));
                            rhObj.Geometry.SetUserString("Phase", "0;0;0;0;0;0;0;0");
                            doc.Objects.ModifyAttributes(rhObj, rhObj.Attributes, true);

                            m_source_conduit.SetSource(rhObj);
                        }

                        doc.Views.Redraw();
                        return Result.Success;
                    }
                    else return Result.Cancel;
                } while (true);
            }
コード例 #16
0
ファイル: rhinosdkget.cs プロジェクト: austinlaw/rhinocommon
 /// <summary>Easy to use bool getter.</summary>
 /// <param name="prompt">Command prompt.</param>
 /// <param name="acceptNothing">If true, the user can press enter.</param>
 /// <param name="offPrompt">The 'false/off' message.</param>
 /// <param name="onPrompt">The 'true/on' message.</param>
 /// <param name="boolValue">Default bool value set to this and returned here.</param>
 /// <returns>The getter result based on user choice.
 /// <para>Commands.Result.Success - got value.</para>
 /// <para>Commands.Result.Nothing - user pressed enter.</para>
 /// <para>Commands.Result.Cancel - user cancelled value getting.</para>
 /// </returns>
 public static Commands.Result GetBool(string prompt, bool acceptNothing, string offPrompt, string onPrompt, ref bool boolValue)
 {
   Commands.Result result = Commands.Result.Failure;
   using (Rhino.Input.Custom.GetOption get = new Rhino.Input.Custom.GetOption())
   {
     get.SetCommandPrompt(prompt);
     get.AcceptNothing(acceptNothing);
     if (acceptNothing)
       get.SetDefaultString(boolValue ? onPrompt : offPrompt);
     int onValue = get.AddOption(onPrompt);
     int offValue = get.AddOption(offPrompt);
     get.Get();
     result = get.CommandResult();
     if (result == Commands.Result.Success && get.Result() == GetResult.Option)
     {
       Rhino.Input.Custom.CommandLineOption option = get.Option();
       if (null != option)
       {
         if (option.Index == onValue)
           boolValue = true;
         else if (option.Index == offValue)
           boolValue = false;
       }
     }
   }
   return result;
 }