protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      m_doc = doc;

      m_window = new Window {Title = "Object ID and Thread ID", Width = 500, Height = 75};
      m_label = new Label();
      m_window.Content = m_label;
      new System.Windows.Interop.WindowInteropHelper(m_window).Owner = Rhino.RhinoApp.MainWindowHandle();
      m_window.Show();


      // register the rhinoObjectAdded method with the AddRhinoObject event
      RhinoDoc.AddRhinoObject += RhinoObjectAdded;

      // add a sphere from the main UI thread.  All is good
      AddSphere(new Point3d(0,0,0));

      // add a sphere from a secondary thread. Not good: the rhinoObjectAdded method
      // doesn't work well when called from another thread
      var add_sphere_delegate = new Action<Point3d>(AddSphere);
      add_sphere_delegate.BeginInvoke(new Point3d(0, 10, 0), null, null);

      // handle the AddRhinoObject event with rhinoObjectAddedSafe which is
      // desgined to work no matter which thread the call is comming from.
      RhinoDoc.AddRhinoObject -= RhinoObjectAdded;
      RhinoDoc.AddRhinoObject += RhinoObjectAddedSafe;

      // try again adding a sphere from a secondary thread.  All is good!
      add_sphere_delegate.BeginInvoke(new Point3d(0, 20, 0), null, null);

      doc.Views.Redraw();

      return Result.Success;
    }
예제 #2
0
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      // view and view names
      var active_view_name = doc.Views.ActiveView.ActiveViewport.Name;

      var non_active_views = 
        doc.Views
        .Where(v => v.ActiveViewport.Name != active_view_name)
        .ToDictionary(v => v.ActiveViewport.Name, v => v);

      // get name of view to set active
      var gs = new GetString();
      gs.SetCommandPrompt("Name of view to set active");
      gs.AcceptNothing(true);
      gs.SetDefaultString(active_view_name);
      foreach (var view_name in non_active_views.Keys)
        gs.AddOption(view_name);
      var result = gs.Get();
      if (gs.CommandResult() != Result.Success)
        return gs.CommandResult();

      var selected_view_name = 
        result == GetResult.Option ? gs.Option().EnglishName : gs.StringResult();

      if (selected_view_name != active_view_name)
        if (non_active_views.ContainsKey(selected_view_name))
          doc.Views.ActiveView = non_active_views[selected_view_name];
        else
          RhinoApp.WriteLine("\"{0}\" is not a view name", selected_view_name);

      return Rhino.Commands.Result.Success;
    }
예제 #3
0
        private RunMode runMode = RunMode.UNKNOWN; //not used anywhere for now but may come handy in the future

        #endregion Fields

        #region Constructors

        internal ConfigurationService()
        {
            var appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location);
            var sparkMaster = Environment.GetEnvironmentVariable("spark.master"); //set by CSharpRunner when launching driver process
            if (sparkMaster == null)
            {
                configuration = new SparkCLRDebugConfiguration(appConfig);
                runMode = RunMode.DEBUG;
            }
            else if (sparkMaster.StartsWith("local"))
            {
                configuration = new SparkCLRLocalConfiguration(appConfig);
                runMode = RunMode.LOCAL;
            }
            else if (sparkMaster.StartsWith("spark://"))
            {
                configuration = new SparkCLRConfiguration(appConfig);
                runMode = RunMode.CLUSTER;
            }
            else if (sparkMaster.Equals("yarn-client", StringComparison.OrdinalIgnoreCase) || sparkMaster.Equals("yarn-cluster", StringComparison.OrdinalIgnoreCase))
            {
                configuration = new SparkCLRConfiguration(appConfig);
                runMode = RunMode.YARN;
            }
            else
            {
                throw new NotSupportedException(string.Format("Spark master value {0} not recognized", sparkMaster));
            }

            logger.LogInfo(string.Format("ConfigurationService runMode is {0}", runMode));
        }
예제 #4
0
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      // Get the name of the instance definition to rename
      string instance_definition_name = "";
      var rc = RhinoGet.GetString("Name of block to delete", true, ref instance_definition_name);
      if (rc != Result.Success)
        return rc;
      if (string.IsNullOrWhiteSpace(instance_definition_name))
        return Result.Nothing;
     
      // Verify instance definition exists
      var instance_definition = doc.InstanceDefinitions.Find(instance_definition_name, true);
      if (instance_definition == null) {
        RhinoApp.WriteLine("Block \"{0}\" not found.", instance_definition_name);
        return Result.Nothing;
      }

      // Verify instance definition can be deleted
      if (instance_definition.IsReference) {
        RhinoApp.WriteLine("Unable to delete block \"{0}\".", instance_definition_name);
        return Result.Nothing;
      }

      // delete block and all references
      if (!doc.InstanceDefinitions.Delete(instance_definition.Index, true, true)) {
        RhinoApp.WriteLine("Could not delete {0} block", instance_definition.Name);
        return Result.Failure;
      }

      return Result.Success;
    }
    /// <summary>
    /// Commmand.RunCommand override
    /// </summary>
    protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        Rhino.Commands.Result rc = Rhino.Commands.Result.Success;

        if (!_bIsLoaded)
        {
          string script = ScriptFromResources(ResourceName, Password);
          if (!string.IsNullOrEmpty(script))
          {
        string macro = string.Format("_-RunScript ({0})", script);
        if (RhinoApp.RunScript(macro, false))
          _bIsLoaded = true;
        else
          rc = Result.Failure;
          }
        }

        if (rc == Result.Success)
        {
          string macro = string.Format("_-RunScript ({0})", EnglishName);
          RhinoApp.RunScript(macro, false);
        }

        return rc;
    }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Loop loop = new Loop();
            loop.Run(doc);

            return Result.Success;
        }
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      ObjRef[] obj_refs;
      var rc = RhinoGet.GetMultipleObjects("Select hatches to replace", false, ObjectType.Hatch, out obj_refs);
      if (rc != Result.Success || obj_refs == null)
        return rc;

      var gs = new GetString();
      gs.SetCommandPrompt("Name of replacement hatch pattern");
      gs.AcceptNothing(false);
      gs.Get();
      if (gs.CommandResult() != Result.Success)
        return gs.CommandResult();
      var hatch_name = gs.StringResult();

      var pattern_index = doc.HatchPatterns.Find(hatch_name, true);

      if (pattern_index < 0)
      {
        RhinoApp.WriteLine("The hatch pattern \"{0}\" not found  in the document.", hatch_name);
        return Result.Nothing;
      }

      foreach (var obj_ref in obj_refs)
      {
        var hatch_object = obj_ref.Object() as HatchObject;
        if (hatch_object.HatchGeometry.PatternIndex != pattern_index)
        {
          hatch_object.HatchGeometry.PatternIndex = pattern_index;
          hatch_object.CommitChanges();
        }
      }
      doc.Views.Redraw();
      return Result.Success;
    }
예제 #8
0
파일: RobotConsole.cs 프로젝트: maesi/prgsy
        /// <summary>
        /// Initialisiert die Roboter-Konsole mit den dazugehörigen LED's und Schalter.
        /// </summary>
        public RobotConsole(RunMode aRunMode)
        {
            if (aRunMode == RunMode.Virtual)
            {
                digitalIn = new DigitalInSim();
                digitalOut = new DigitalOutSim();
            }
            else
            {
                digitalIn = new DigitalInHW(Constants.IOConsoleSWITCH);
                digitalOut = new DigitalOutHW(Constants.IOConsoleLED);
            }

            this.leds = new Led[4];
            for (int i = 0; i < this.leds.Length; i++)
            {
                leds[i] = new Led((Leds)i, digitalOut);
                if (i % 2 == 0)
                {
                    leds[i].LedEnabled = false;
                }
            }

            this.switches = new Switch[4];
            for (int i = 0; i < this.switches.Length; i++)
            {
                switches[i] = new Switch((Switches)i, digitalIn);
                switches[i].SwitchStateChanged += new EventHandler<SwitchEventArgs>(RobotConsole_SwitchStateChanged);
            }
        }
        protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode)
        {
            // TODO: start here modifying the behaviour of your command.
              // ---
              RhinoApp.WriteLine ("The {0} command will add a line right now.", EnglishName);

              Point3d pt0;
              using (GetPoint getPointAction = new GetPoint ()) {
            getPointAction.SetCommandPrompt ("Please select the start point");
            if (getPointAction.Get () != GetResult.Point) {
              RhinoApp.WriteLine ("No start point was selected.");
              return getPointAction.CommandResult ();
            }
            pt0 = getPointAction.Point ();
              }

              Point3d pt1;
              using (GetPoint getPointAction = new GetPoint ()) {
            getPointAction.SetCommandPrompt ("Please select the end point");
            getPointAction.SetBasePoint (pt0, true);
            getPointAction.DrawLineFromPoint (pt0, true);
            if (getPointAction.Get () != GetResult.Point) {
              RhinoApp.WriteLine ("No end point was selected.");
              return getPointAction.CommandResult ();
            }
            pt1 = getPointAction.Point ();
              }

              doc.Objects.AddLine (pt0, pt1);
              doc.Views.Redraw ();
              RhinoApp.WriteLine ("The {0} command added one line to the document.", EnglishName);

              return Result.Success;
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            List<Guid> geometryObjects_for_deletion = new List<Guid>();
            foreach (Rhino.DocObjects.Layer layer in doc.Layers)
            {
                if (layer.Name.ToLower() == "lights") continue;
                if (layer.Name.ToLower() == "objects")
                {
                    RhinoApp.WriteLine("Giving up on Layer Objects");
                    continue;
                }
                if (layer.Name.ToLower().StartsWith("keep"))
                {
                    RhinoApp.WriteLine("Giving up on Layer " + layer.Name);
                    continue;
                }
                RhinoApp.WriteLine(layer.LayerIndex.ToString() + ")(" + layer.Name + ":" + layer.ToString());
                RhinoObject[] rhobjs = doc.Objects.FindByLayer(layer.Name);
                foreach (RhinoObject robj in rhobjs)
                {
                    if (robj.ObjectType == ObjectType.Light) continue;
                    geometryObjects_for_deletion.Add(robj.Id);
                }
            }

            doc.Objects.Delete(geometryObjects_for_deletion,true);

            doc.Views.Redraw();

            return Result.Success;
        }
예제 #11
0
 void Read()
 {
     if (!File.Exists(_fileName))
         return;
     var lines = File.ReadAllLines(_fileName);
     foreach (var l in lines) {
         var tmp = l.Split(new char[]{'='}, StringSplitOptions.RemoveEmptyEntries);
         if (tmp.Length == 2) {
             switch (tmp[0]) {
                 case "RunMode":
                     RunMode = (RunMode)(Int32.Parse(tmp[1]));
                     break;
                 case "AckReply":
                     AckReply = Boolean.Parse(tmp[1]);
                     break;
                 case "AdapterIndex":
                     AdapterIndex = Int32.Parse(tmp[1]);
                     break;
                 case "ArpReplyList":
                     var t = tmp[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                     ArpReplyList = new List<string>();
                     foreach (var ip in t) {
                         ArpReplyList.Add(ip);
                     }
                     break;
             }
         }
     }
 }
예제 #12
0
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var points = new List<Point3d>
      {
        new Point3d(0, 0, 0),
        new Point3d(0, 0, 1),
        new Point3d(0, 1, 0),
        new Point3d(0, 1, 1),
        new Point3d(1, 0, 0),
        new Point3d(1, 0, 1),
        new Point3d(1, 1, 0),
        new Point3d(1, 1, 1)
      };

      RhinoApp.WriteLine("Before sort ...");
      foreach (var point in points)
        RhinoApp.WriteLine("point: {0}", point);

      var sorted_points = Point3d.SortAndCullPointList(points, doc.ModelAbsoluteTolerance);

      RhinoApp.WriteLine("After sort ...");
      foreach (var point in sorted_points)
        RhinoApp.WriteLine("point: {0}", point);

      doc.Objects.AddPoints(sorted_points);
      doc.Views.Redraw();
      return Result.Success;
    }
예제 #13
0
파일: Application.cs 프로젝트: danryd/Tarro
        public Application(string name, string pathToApp, string executable, RunMode runMode = RunMode.AppDomain)
        {
            this.name = name;
            this.runMode = runMode;

            appCopy = new AppCopy(cachePath, pathToApp, executable);
            watcher = new AppWatcher(pathToApp);
            switch (runMode)
            {
                case RunMode.AppDomain:
                    runtime = new AppDomainRuntime(name, pathToApp, executable, appCopy.ShadowPath);
                    break;
                case RunMode.Process:
                    runtime = new ProcessRuntime(name, pathToApp, executable, appCopy.ShadowPath);
                    break;
                default:
                    throw new InvalidOperationException($"Unknown runmode, {runMode}");
            }

            watcher.AppChanged += (o, e) =>
            {
                Stop();
            };
            watcher.AfterQuietPeriod += (o, e) =>
            {
                Start();
            };
        }
예제 #14
0
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var go = new Rhino.Input.Custom.GetObject();
      go.SetCommandPrompt("Select objects to copy in place");
      go.GroupSelect = true;
      go.SubObjectSelect = false;
      go.GetMultiple(1, 0);
      if (go.CommandResult() != Result.Success)
        return go.CommandResult();

      var xform = Transform.Identity;
      var group_map = new Dictionary<int, int>();

      foreach (var obj_ref in go.Objects())
      {
        if (obj_ref != null)
        {
          var obj = obj_ref.Object();
          var duplicate = doc.Objects.Transform(obj_ref.ObjectId, xform, false);
          RhinoUpdateObjectGroups(ref obj, ref group_map);
        } 
      }
      doc.Views.Redraw();
      return Result.Success;
    }
예제 #15
0
        public override MetricCollector Create(RunMode runMode, WarmupData warmup, IBenchmarkSetting setting)
        {
            var timingSetting = setting as TimingBenchmarkSetting;
            Contract.Assert(timingSetting != null);

            return new TimingCollector(timingSetting.TimingMetricName);
        }
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      ObjRef obj_ref;
      var rc = RhinoGet.GetOneObject("Select surface or polysurface to mesh", true, ObjectType.Surface | ObjectType.PolysrfFilter, out obj_ref);
      if (rc != Result.Success)
        return rc;
      var brep = obj_ref.Brep();
      if (null == brep)
        return Result.Failure;

      // you could choose anyone of these for example
      var jagged_and_faster = MeshingParameters.Coarse;
      var smooth_and_slower = MeshingParameters.Smooth;
      var default_mesh_params = MeshingParameters.Default;
      var minimal = MeshingParameters.Minimal;

      var meshes = Mesh.CreateFromBrep(brep, smooth_and_slower);
      if (meshes == null || meshes.Length == 0)
        return Result.Failure;

      var brep_mesh = new Mesh();
      foreach (var mesh in meshes)
        brep_mesh.Append(mesh);
      doc.Objects.AddMesh(brep_mesh);
      doc.Views.Redraw();

      return Result.Success;
    }
        /// <summary>
        /// Call by Rhino when the user wants to run this command
        /// </summary>
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            if (null == m_grip_enabler)
              {
            // Register once and only once...
            m_grip_enabler = new SampleCsRectangleGripsEnabler();
            CustomObjectGrips.RegisterGripsEnabler(m_grip_enabler.TurnOnGrips, typeof(SampleCsRectangleGrips));
              }

              var go = new SampleCsGetRectangleCurve();
              go.SetCommandPrompt("Select rectangles for point display");
              go.GetMultiple(1, 0);
              if (go.CommandResult() != Result.Success)
            return go.CommandResult();

              for (var i = 0; i < go.ObjectCount; i++)
              {
            var rh_object = go.Object(i).Object();
            if (null != rh_object)
            {
              if (rh_object.GripsOn)
            rh_object.GripsOn = false;

              m_grip_enabler.TurnOnGrips(rh_object);
            }
              }

              doc.Views.Redraw();

              return Result.Success;
        }
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      ObjRef obj_ref;
      var rs = RhinoGet.GetOneObject(
        "Select object", false, ObjectType.AnyObject, out obj_ref);
      if (rs != Result.Success)
        return rs;
      var rhino_object = obj_ref.Object();
      if (rhino_object == null)
        return Result.Failure;

      var rhino_object_groups = rhino_object.Attributes.GetGroupList().DefaultIfEmpty(-1);

      var selectable_objects= from obj in doc.Objects.GetObjectList(ObjectType.AnyObject)
                              where obj.IsSelectable(true, false, false, false)
                              select obj;

      foreach (var selectable_object in selectable_objects)
      {
        foreach (var group in selectable_object.Attributes.GetGroupList())
        {
          if (rhino_object_groups.Contains(group))
          {
              selectable_object.Select(true);
              continue;
          }
        }
      }
      doc.Views.Redraw();
      return Result.Success;
    }
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var file_name = "";

      var bitmap = doc.Views.ActiveView.CaptureToBitmap(true, true, true);
      bitmap.MakeTransparent();

      // copy bitmap to clipboard
      Clipboard.SetImage(bitmap);

      // save bitmap to file
      var save_file_dialog = new Rhino.UI.SaveFileDialog
      {
        Filter = "*.bmp",
        InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
      };
      if (save_file_dialog.ShowDialog() == DialogResult.OK)
      {
        file_name = save_file_dialog.FileName;
      }

      if (file_name != "")
        bitmap.Save(file_name);

      return Rhino.Commands.Result.Success;
    }
예제 #20
0
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var go = new Rhino.Input.Custom.GetObject();
      go.SetCommandPrompt("Select objects");
      go.EnablePreSelect(true, true);
      go.EnablePostSelect(true);
      go.GetMultiple(0, 0);
      if (go.CommandResult() != Result.Success)
        return go.CommandResult();

      var selected_objects = go.Objects().ToList();

      if (go.ObjectsWerePreselected)
      {
        go.EnablePreSelect(false, true);
        go.DeselectAllBeforePostSelect = false;
        go.EnableUnselectObjectsOnExit(false);
        go.GetMultiple(0, 0);
        if (go.CommandResult() == Result.Success)
        {
          foreach (var obj in go.Objects())
          {
            selected_objects.Add(obj);
            // The normal behavior of commands is that when they finish,
            // objects that were pre-selected remain selected and objects
            // that were post-selected will not be selected. Because we
            // potentially could have both, we'll try to do something
            // consistent and make sure post-selected objects also stay selected
            obj.Object().Select(true);
          }
        }
      }
      return selected_objects.Count > 0 ? Result.Success : Result.Nothing;
    }
예제 #21
0
        /********************************************************
        * CLASS CONSTRUCTOR
        *********************************************************/
        /// <summary>
        /// Initialise the Algorithm
        /// </summary>
        public QCAlgorithm()
        {
            //Initialise the Algorithm Helper Classes:
            //- Note - ideally these wouldn't be here, but because of the DLL we need to make the classes shared across
            //  the Worker & Algorithm, limiting ability to do anything else.
            Securities = new SecurityManager();
            Transacions = new SecurityTransactionManager(Securities);
            Portfolio = new SecurityPortfolioManager(Securities, Transacions);

            //Initialise Data Manager
            DataManager = new DataManager();

            //Initialise Error and Order Holders:
            Errors = new List<string>();

            //Initialise Algorithm RunMode to Automatic:
            _runMode = RunMode.Automatic;

            //Initialise to unlocked:
            _locked = false;

            //Initialise Start and End Dates:
            _startDate = new DateTime();
            _endDate = new DateTime();
        }
예제 #22
0
        public override IEnumerable<MetricCollector> Create(RunMode runMode, WarmupData warmup, IBenchmarkSetting setting)
        {

            //if (warmup.ElapsedTicks <= BenchmarkConstants.SamplingPrecisionTicks)
                return new[] {new GcTotalMemoryCollector(MemoryMetricName)};
            //return new[] {new PerformanceCounterTotalMemoryCollector(MemoryMetricName)};
        }
예제 #23
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Plugin.InitialiseCSycles();
            if (doc.Views.ActiveView.ActiveViewport.DisplayMode.Id == Guid.Parse("69E0C7A5-1C6A-46C8-B98B-8779686CD181"))
            {
                var rvp = doc.Views.ActiveView.RealtimeDisplayMode as RenderedViewport;

                if (rvp != null)
                {
                    var getNumber = new GetInteger();
                    getNumber.SetLowerLimit(1, true);
                    getNumber.SetDefaultInteger(rvp.HudMaximumPasses()+100);
                    getNumber.SetCommandPrompt("Set new sample count");
                    var getRc = getNumber.Get();
                    if (getNumber.CommandResult() != Result.Success) return getNumber.CommandResult();
                    if (getRc == GetResult.Number)
                    {
                        var nr = getNumber.Number();
                        RhinoApp.WriteLine($"User changes samples to {nr}");
                        rvp.ChangeSamples(nr);
                        return Result.Success;
                    }
                }
            }

            RhinoApp.WriteLine("Active view isn't rendering with Cycles");

            return Result.Nothing;
        }
 protected override Result RunCommand(RhinoDoc doc, RunMode mode)
 {
     RcCore.It.EngineSettings.SaveDebugImages = !RcCore.It.EngineSettings.SaveDebugImages;
     var saving = RcCore.It.EngineSettings.SaveDebugImages ? "Saving" : "Not saving";
     RhinoApp.WriteLine($"{saving} debug images");
     return Result.Success;
 }
예제 #25
0
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var gs = new GetObject();
      gs.SetCommandPrompt("select sphere");
      gs.GeometryFilter = ObjectType.Surface;
      gs.DisablePreSelect();
      gs.SubObjectSelect = false;
      gs.Get();
      if (gs.CommandResult() != Result.Success)
        return gs.CommandResult();

      Sphere sphere;
      gs.Object(0).Surface().TryGetSphere(out sphere);
      if (sphere.IsValid)
      {
        var mesh = Mesh.CreateFromSphere(sphere, 10, 10);
        if (mesh == null)
          return Result.Failure;

        var conduit = new DrawBlueMeshConduit(mesh) {Enabled = true};
        doc.Views.Redraw();

        var in_str = "";
        Rhino.Input.RhinoGet.GetString("press <Enter> to continue", true, ref in_str);

        conduit.Enabled = false;
        doc.Views.Redraw();
        return Result.Success;
      }
      else
        return Result.Failure;
    }
예제 #26
0
파일: Drive.cs 프로젝트: maesi/prgsy
        /// <summary>
        /// Initialisiert den Antrieb des Roboters
        /// </summary>
        /// 
        /// <param name="runMode">der gewünschte Run-Mode (Real/Virtual)</param>
        public Drive(RunMode runMode)
        {
            if (!Constants.IsWinCE) runMode = RunMode.Virtual;
            this.runMode = runMode;

            this.disposed = false;

            // Antrieb initialisieren
            if (this.runMode == RunMode.Real)
            {
                this.driveCtrl = new DriveCtrlHW(Constants.IODriveCtrl);
                this.motorCtrlLeft = new MotorCtrlHW(Constants.IOMotorCtrlLeft);
                this.motorCtrlRight = new MotorCtrlHW(Constants.IOMotorCtrlRight);
            }
            else
            {
                this.driveCtrl = new DriveCtrlSim();
                this.motorCtrlLeft = new MotorCtrlSim();
                this.motorCtrlRight = new MotorCtrlSim();
            }

            // Beschleunigung festlegen
            this.motorCtrlLeft.Acceleration = 10f;
            this.motorCtrlRight.Acceleration = 10f;

            // Prozess-Thread erzeugen und starten
            this.thread = new Thread(RunTracks);
            this.thread.IsBackground = true;
            this.thread.Priority = ThreadPriority.Highest;
            this.thread.Start();
        }
예제 #27
0
        /// <summary>
        /// Initialisiert die Roboter-Konsole mit den dazugehörigen LED's und Schalter.
        /// </summary>
        public RobotConsole(RunMode runMode)
        {
            if (!Constants.IsWinCE) runMode = RunMode.Virtual;

            if (runMode == RunMode.Virtual)
            {
                digitalIn = new DigitalInSim();
                digitalOut = new DigitalOutSim();

            }
            else
            {
              //  digitalIn = new DigitalInHW(Constants.IOConsoleSWITCH);
                digitalIn = new DigitalInHW(Constants.IOConsoleSWITCH);
                digitalOut = new DigitalOutHW(Constants.IOConsoleLED);
            }

            this.leds = new Led[4];
            for (int i = 0; i < this.leds.Length; i++)
            {
                leds[i] = new Led(digitalOut,(Leds)i);
            }

            this.blinkingLeds = new BlinkingLed[4];
            for (int i = 0; i < this.blinkingLeds.Length; i++)
            {
                blinkingLeds[i] = new BlinkingLed(digitalOut, (BlinkingLeds)i);
            }

            this.switches = new Switch[4];
            for (int i = 0; i < this.switches.Length; i++)
            {
                switches[i] = new Switch(digitalIn, (Switches)i);
            }
        }
예제 #28
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var gp = new GetPoint();
            gp.SetCommandPrompt("Start:");
            
            if (gp.Get() != GetResult.Point)
            {
                RhinoApp.WriteLine("No point selected.");
                return gp.CommandResult();
            }

            var location = gp.Point();

            var dialog = new BBTextDialog();

            if (dialog.ShowDialog()!= true)
                return Result.Cancel;

            var typeWriter = dialog.Bold ? Typewriter.Bold : Typewriter.Regular;

            var x = doc.Views.ActiveView.ActiveViewport.CameraX;
            var y = doc.Views.ActiveView.ActiveViewport.CameraY;

            var unitX = x * dialog.Size;
            var unitY = y * dialog.Size;

            var curves = typeWriter.Write(dialog.Text, location, unitX, unitY, dialog.HAlign, dialog.VAlign);
            
            doc.Groups.Add(curves.Select(curve => doc.Objects.AddCurve(curve)));

            doc.Views.Redraw();

            return Result.Success;
        }
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      Rhino.DocObjects.ObjRef objref;
      var rc = RhinoGet.GetOneObject("Select curve", true, ObjectType.Curve,out objref);
      if(rc!= Result.Success)
        return rc;
      var curve = objref.Curve();
      if( curve==null )
        return Result.Failure;

      var gp = new GetPoint();
      gp.SetCommandPrompt("Pick a location on the curve");
      gp.Constrain(curve, false);
      gp.Get();
      if (gp.CommandResult() != Result.Success)
        return gp.CommandResult();

      var point = gp.Point();
      double closest_point_param;
      if (curve.ClosestPoint(point, out closest_point_param))
      {
        RhinoApp.WriteLine("point: ({0}), parameter: {1}", point, closest_point_param);
        doc.Objects.AddPoint(point);
        doc.Views.Redraw();
      }
      return Result.Success;
    }
예제 #30
0
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var gm = new GetObject();
      gm.SetCommandPrompt("Select solid meshes for volume calculation");
      gm.GeometryFilter = ObjectType.Mesh;
      gm.GeometryAttributeFilter = GeometryAttributeFilter.ClosedMesh;
      gm.SubObjectSelect = false;
      gm.GroupSelect = true;
      gm.GetMultiple(1, 0);
      if (gm.CommandResult() != Result.Success)
        return gm.CommandResult();

      double volume = 0.0;
      double volume_error = 0.0;
      foreach (var obj_ref in gm.Objects())
      {
        if (obj_ref.Mesh() != null)
        {
          var mass_properties = VolumeMassProperties.Compute(obj_ref.Mesh());
          if (mass_properties != null)
          {
            volume += mass_properties.Volume;
            volume_error += mass_properties.VolumeError;
          }
        }
      }

      RhinoApp.WriteLine("Total volume = {0:f} (+/- {1:f})", volume, volume_error);
      return Result.Success;
    }
예제 #31
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.DocObjects.ObjRef objref;
            Result rc = Rhino.Input.RhinoGet.GetOneObject("Select mesh", false, ObjectType.Mesh, out objref);

            if (rc != Result.Success)
            {
                return(rc);
            }
            if (null == objref)
            {
                return(Result.Failure);
            }

            Rhino.Geometry.Mesh mesh = objref.Mesh();
            if (null == mesh)
            {
                return(Result.Failure);
            }

            Rhino.Geometry.Collections.MeshTopologyEdgeList mesh_tope = mesh.TopologyEdges;
            for (int i = 0; i < mesh_tope.Count; i++)
            {
                // Find naked edges - edges with a single connecting face
                int[] mesh_topf = mesh_tope.GetConnectedFaces(i);
                if (null != mesh_topf && mesh_topf.Length == 1)
                {
                    Guid id = doc.Objects.AddLine(mesh_tope.EdgeLine(i));
                    doc.Objects.Select(id);
                }
            }

            doc.Views.Redraw();

            return(Result.Success);
        }
예제 #32
0
        protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode)
        {
            var apartmentHousesPercetage = new double();
            var population = new double();

            ObjRef[] srcCurves;

            RhinoGet.GetMultipleObjects("ClosedPolygones", false, ObjectType.Curve, out srcCurves);
            RhinoGet.GetNumber("Insert population", false, ref population, 0, 1000000);
            RhinoGet.GetNumber("Percent of population living in apartment houses", false, ref apartmentHousesPercetage, 0, 100000);

            var dicts = new Dictionary <Guid, DataDto>();

            for (var i = 0; i < srcCurves.Count(); i++)
            {
                var o = GetDto(srcCurves[i]);
                dicts.Add(srcCurves[i].ObjectId, o);
            }

            var optimalLivingArea   = GetOptimalLivingArea((int)Math.Round(population), (int)Math.Round(apartmentHousesPercetage));
            var excistingLivingArea = GetExcistingLivingArea(dicts);

            if (optimalLivingArea > 0 && excistingLivingArea > 0)
            {
                var overStockPercent = (excistingLivingArea - optimalLivingArea) * 100 / excistingLivingArea;

                RhinoApp.WriteLine($"Overstock {overStockPercent} percent");
            }

            else
            {
                RhinoApp.WriteLine($"No info to calculate overstock percent");
            }

            return(Result.Success);
        }
예제 #33
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            ObjRef[] obj_refs;
            var      rc = RhinoGet.GetMultipleObjects("Select points to move", false, ObjectType.Point, out obj_refs);

            if (rc != Result.Success || obj_refs == null)
            {
                return(rc);
            }

            foreach (var obj_ref in obj_refs)
            {
                var point3d = obj_ref.Point().Location;
                // modify the point coordinates in some way ...
                point3d.X++;
                point3d.Y++;
                point3d.Z++;

                doc.Objects.Replace(obj_ref, point3d);
            }

            doc.Views.Redraw();
            return(Result.Success);
        }
예제 #34
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh();

            mesh.Vertices.Add(new Rhino.Geometry.Point3d(0.5, 0.5, 0.5));
            mesh.Vertices.Add(new Rhino.Geometry.Point3d(0.5, 0.5, -0.5));
            mesh.Vertices.Add(new Rhino.Geometry.Point3d(0.5, -0.5, 0.5));
            mesh.Vertices.Add(new Rhino.Geometry.Point3d(0.5, -0.5, -0.5));
            mesh.Vertices.Add(new Rhino.Geometry.Point3d(-0.5, 0.5, 0.5));
            mesh.Vertices.Add(new Rhino.Geometry.Point3d(-0.5, 0.5, -0.5));
            mesh.Vertices.Add(new Rhino.Geometry.Point3d(-0.5, -0.5, 0.5));
            mesh.Vertices.Add(new Rhino.Geometry.Point3d(-0.5, -0.5, -0.5));

            mesh.Faces.AddFace(0, 1, 5, 4);
            mesh.Faces.AddFace(0, 4, 6, 2);
            mesh.Faces.AddFace(0, 2, 3, 1);
            mesh.Faces.AddFace(7, 3, 2, 6);
            mesh.Faces.AddFace(7, 6, 4, 5);
            mesh.Faces.AddFace(7, 5, 1, 3);

            // For vertex colors to "work", you must supply a color
            // for every vertex.
            for (int i = 0; i < mesh.Vertices.Count; i++)
            {
                mesh.VertexColors.Add(GetRandomColor());
            }

            mesh.FaceNormals.ComputeFaceNormals();
            mesh.Normals.ComputeNormals();
            mesh.Compact();

            doc.Objects.AddMesh(mesh);
            doc.Views.Redraw();

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var zebra_id      = VisualAnalysisMode.RhinoZebraStripeAnalysisModeId;
            var analysis_mode = VisualAnalysisMode.Find(zebra_id);

            if (null == analysis_mode)
            {
                return(Result.Failure);
            }

            var go = new GetObject();

            go.SetCommandPrompt("Select surfaces or polysurfaces for Zebra analysis");
            go.GeometryFilter  = ObjectType.Surface | ObjectType.PolysrfFilter;
            go.SubObjectSelect = false;
            go.GetMultiple(1, 0);
            if (go.CommandResult() != Result.Success)
            {
                return(go.CommandResult());
            }

            foreach (var obj_ref in go.Objects())
            {
                var obj = obj_ref.Object();
                if (null == obj)
                {
                    return(Result.Failure);
                }

                obj.EnableVisualAnalysisMode(analysis_mode, true);
            }

            doc.Views.Redraw();

            return(Result.Success);
        }
예제 #36
0
        /// <summary>
        /// Called by Rhino when the user wants to run the command.
        /// </summary>
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var rc = RockfishClientPlugIn.VerifyServerHostName();

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

            var message = "Hello Rhino!";

            rc = RhinoGet.GetString("String to echo", false, ref message);
            if (rc != Result.Success)
            {
                return(rc);
            }

            try
            {
                RockfishClientPlugIn.ServerHostName();
                using (var channel = new RockfishClientChannel())
                {
                    channel.Create();
                    message = channel.Echo(message);
                }
            }
            catch (Exception ex)
            {
                RhinoApp.WriteLine(ex.Message);
                return(Result.Failure);
            }

            RhinoApp.WriteLine(message);

            return(Result.Success);
        }
예제 #37
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Host.EnsureInitialisation();

            LinearElementCollection elements = Core.Instance.ActiveDocument.Model.Elements.LinearElements;

            foreach (LinearElement lEl in elements)
            {
                if (!lEl.IsDeleted)
                {
                    RhinoMeshAvatar mAv = new RhinoMeshAvatar();
                    ((IMeshAvatar)mAv).Builder.AddSectionPreview(lEl);
                    ((IMeshAvatar)mAv).FinalizeMesh();
                    Guid guid = RhinoOutput.BakeMesh(mAv.RenderMesh);

                    if (guid != Guid.Empty)
                    {
                        RhinoOutput.SetObjectName(guid, lEl.Name);
                        if (lEl.Family != null)
                        {
                            RhinoOutput.SetObjectUserString(guid, "Family", lEl.Family.Name);
                            if (lEl.Family.GetPrimaryMaterial() != null)
                            {
                                RhinoOutput.SetObjectUserString(guid, "Material", lEl.Family.GetPrimaryMaterial().Name);
                            }
                            if (lEl.Family.Profile != null)
                            {
                                RhinoOutput.SetObjectUserString(guid, "Profile", lEl.Family.Profile.ToString());
                            }
                        }
                    }
                }
            }
            Host.Instance.Refresh();
            return(Result.Success);
        }
예제 #38
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // all non-light objects that are selected
            var object_enumerator_settings = new ObjectEnumeratorSettings();

            object_enumerator_settings.IncludeLights         = false;
            object_enumerator_settings.IncludeGrips          = true;
            object_enumerator_settings.NormalObjects         = true;
            object_enumerator_settings.LockedObjects         = true;
            object_enumerator_settings.HiddenObjects         = true;
            object_enumerator_settings.ReferenceObjects      = true;
            object_enumerator_settings.SelectedObjectsFilter = true;
            var selected_objects = doc.Objects.GetObjectList(object_enumerator_settings);

            var current_layer_index = doc.Layers.CurrentLayerIndex;

            foreach (var selected_object in selected_objects)
            {
                selected_object.Attributes.LayerIndex = current_layer_index;
                selected_object.CommitChanges();
            }
            doc.Views.Redraw();
            return(Result.Success);
        }
예제 #39
0
        public Nightly(RunMode runMode, string decorateSrcDirName = null)
        {
            _runMode  = runMode;
            _nightly  = new Xml("nightly");
            _failures = _nightly.Append("failures");
            _leaks    = _nightly.Append("leaks");

            // Locate relevant directories.
            var nightlyDir = GetNightlyDir();

            _logDir = Path.Combine(nightlyDir, "Logs");
            // Clean up after any old screengrab directories
            var logDirScreengrabs = Path.Combine(_logDir, "NightlyScreengrabs");

            if (Directory.Exists(logDirScreengrabs))
            {
                Directory.Delete(logDirScreengrabs, true);
            }
            // First guess at working directory - distinguish between run types for machines that do double duty
            _skylineTesterDir = Path.Combine(nightlyDir, "SkylineTesterForNightly_" + runMode + (decorateSrcDirName ?? string.Empty));

            // Default duration.
            _duration = TimeSpan.FromHours(DEFAULT_DURATION_HOURS);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            const int order    = 3; // order = degree + 1
            const int cv_count = 9;

            var curve = new NurbsCurve(3, true, order, cv_count);

            curve.Points.SetPoint(0, 1.0, 0.0, 0.0, 1.0);
            curve.Points.SetPoint(1, 0.707107, 0.707107, 0.0, 0.707107);
            curve.Points.SetPoint(2, 0.0, 1.0, 0.0, 1.0);
            curve.Points.SetPoint(3, -0.707107, 0.707107, 0.0, 0.707107);
            curve.Points.SetPoint(4, -1.0, 0.0, 0.0, 1.0);
            curve.Points.SetPoint(5, -0.707107, -0.707107, 0.0, 0.707107);
            curve.Points.SetPoint(6, 0.0, -1.0, 0.0, 1.0);
            curve.Points.SetPoint(7, 0.707107, -0.707107, 0.0, 0.707107);
            curve.Points.SetPoint(8, 1.0, 0.0, 0.0, 1.0);

            curve.Knots[0] = 0.0;
            curve.Knots[1] = 0.0;
            curve.Knots[2] = 0.5 * Math.PI;
            curve.Knots[3] = 0.5 * Math.PI;
            curve.Knots[4] = Math.PI;
            curve.Knots[5] = Math.PI;
            curve.Knots[6] = 1.5 * Math.PI;
            curve.Knots[7] = 1.5 * Math.PI;
            curve.Knots[8] = 2.0 * Math.PI;
            curve.Knots[9] = 2.0 * Math.PI;

            if (curve.IsValid)
            {
                doc.Objects.AddCurve(curve);
                doc.Views.Redraw();
            }

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var context     = UmiContext.Current;
            var fileContent = string.Empty;
            var filePath    = string.Empty;

            ObjRef obj_ref;
            var    rc = RhinoGet.GetOneObject("Select a brep", true, ObjectType.Brep, out obj_ref);

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

            var refId = obj_ref.ObjectId;

            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = doc.Path;
                openFileDialog.Filter           = "Comma Separated Value | *.csv";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = openFileDialog.FileName;
                }
            }

            //Read the contents of the file into the umi db
            AdditionalLoads.AddAdditionalLoad(filePath, context, refId);

            RhinoApp.WriteLine($"Added additional load from '{filePath}'");
            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Select points
            if (!SelectPoints(out List <Point3d> inputPoints))
            {
                RhinoApp.WriteLine("Error in point selection");
                return(Result.Failure);
            }

            // Check for errors
            if (!CheckErrors(inputPoints))
            {
                RhinoApp.WriteLine("Error in point cloud");
                return(Result.Failure);
            }

            // Calculate the convex hull
            Polyline convexHull = ConvexHull.CalculateCH(inputPoints);

            // Draw convex hull line
            doc.Objects.AddPolyline(convexHull);
            doc.Views.Redraw();
            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var gp = new GetPoint();

            gp.SetCommandPrompt("Center point");
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }
            var center_point = gp.Point();

            if (center_point == Point3d.Unset)
            {
                return(Result.Failure);
            }

            var gcp = new GetCircleRadiusPoint(center_point);

            gcp.SetCommandPrompt("Radius");
            gcp.ConstrainToConstructionPlane(false);
            gcp.SetBasePoint(center_point, true);
            gcp.DrawLineFromPoint(center_point, true);
            gcp.Get();
            if (gcp.CommandResult() != Result.Success)
            {
                return(gcp.CommandResult());
            }

            var radius = center_point.DistanceTo(gcp.Point());
            var cplane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane();

            doc.Objects.AddCircle(new Circle(cplane, center_point, radius));
            doc.Views.Redraw();
            return(Result.Success);
        }
예제 #44
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            RhinoApp.WriteLine("The Urban Simulator has begun.");

            urbanModel theUrbanModel = new urbanModel();

            if (!getPrecinct(theUrbanModel))               //ask user to select surface
            {
                return(Result.Failure);
            }

            RhinoDoc.ActiveDoc.Views.RedrawEnabled.Equals(false);

            generateRoadNetwork(theUrbanModel);                  //generate road
            createBlocks(theUrbanModel);                         //create blocks using road
            subdivideBlocks(theUrbanModel, 30, 30, 50, 30);      //subdivide blocks into
            //instantiateBuildings(theUrbanModel);                 //place buildings on each block

            RhinoDoc.ActiveDoc.Views.RedrawEnabled.Equals(true);

            RhinoApp.WriteLine("The Urban Simulator is complete.");

            return(Result.Success);
        }
예제 #45
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Create a circle curve
            var circle = new Circle(Plane.WorldXY, 5.0);
            var curve0 = new ArcCurve(circle);

            // Add an instance defintion that uses the circle curve
            var attrib      = doc.CreateDefaultAttributes();
            var idef0_index = doc.InstanceDefinitions.Add("Circle", "Circle", Point3d.Origin, curve0, attrib);

            // Create a reference to the instance definition
            var idef0_id = doc.InstanceDefinitions[idef0_index].Id;
            var iref0    = new InstanceReferenceGeometry(idef0_id, Transform.Identity);

            // Create a polyline curve
            var rect = new Point3d[5];

            rect[0] = new Point3d(-5.0, -5.0, 0.0);
            rect[1] = new Point3d(5.0, -5.0, 0.0);
            rect[2] = new Point3d(5.0, 5.0, 0.0);
            rect[3] = new Point3d(-5.0, 5.0, 0.0);
            rect[4] = rect[0];
            var curve1 = new PolylineCurve(rect);

            // Add another instance definition that uses the polyline curve
            // and the instance reference
            var geometry    = new GeometryBase[] { curve1, iref0 };
            var attributes  = new[] { attrib, attrib };
            var idef1_index = doc.InstanceDefinitions.Add("Rectangle and Circle", "Rectangle and Circle", Point3d.Origin, geometry, attributes);

            // Add an instace of the new defintion to the document and redraw
            doc.Objects.AddInstanceObject(idef1_index, Transform.Identity);
            doc.Views.Redraw();

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // TODO: complete command.

            Brep my_brep = My_object_functions.Initialize("D:/Desktop/MyObject_2pins.3dm");

            My_object_functions.SetName(my_brep, "my_object_2_pins");
            My_object_functions.SetColor(my_brep, Color.Purple);
            My_object_functions.SetPosition(my_brep, new Point3d(0, -5.0, 5.0));
            My_object_functions.SetZ(my_brep, new Vector3d(0, 1.0, 0));
            My_object_functions.SetY(my_brep, new Vector3d(1.0, 0, 0));
            My_object_functions.SetX(my_brep, new Vector3d(0, 0, 1.0));

            My_object_functions.SetPinQuantity(my_brep, 2);
            My_object_functions.SetPinCoordination(my_brep, 0, new Point3d(0, 7.5, 0.0));
            My_object_functions.SetPinCoordination(my_brep, 1, new Point3d(0, -7.5, 0.0));

            for (int i = 0; i < 2; i++)
            {
                My_object_functions.SetPinGuid(my_brep, i, Guid.NewGuid());
            }

            ObjectAttributes my_attributes = new ObjectAttributes();

            my_attributes.ColorSource = ObjectColorSource.ColorFromObject;
            my_attributes.ObjectColor = My_object_functions.GetColor(my_brep);

            MyRhino5rs11project8PlugIn p = MyRhino5rs11project8PlugIn.Instance;

            p.my_objects_list.Add(my_brep);

            doc.Objects.AddBrep(my_brep, my_attributes);
            doc.Views.Redraw();

            return(Result.Success);
        }
예제 #47
0
        public CommandService(CommandServiceConfig config)
        {
            _caseSensitive  = config.CaseSensitiveCommands;
            _throwOnError   = config.ThrowOnError;
            _separatorChar  = config.SeparatorChar;
            _defaultRunMode = config.DefaultRunMode;
            if (_defaultRunMode == RunMode.Default)
            {
                throw new InvalidOperationException("The default run mode cannot be set to Default.");
            }

            _logManager          = new LogManager(config.LogLevel);
            _logManager.Message += async msg => await _logEvent.InvokeAsync(msg).ConfigureAwait(false);

            _cmdLogger = _logManager.CreateLogger("Command");

            _moduleLock      = new SemaphoreSlim(1, 1);
            _typedModuleDefs = new ConcurrentDictionary <Type, ModuleInfo>();
            _moduleDefs      = new HashSet <ModuleInfo>();
            _map             = new CommandMap(this);
            _typeReaders     = new ConcurrentDictionary <Type, ConcurrentDictionary <Type, TypeReader> >();

            _defaultTypeReaders = new ConcurrentDictionary <Type, TypeReader>();
            foreach (var type in PrimitiveParsers.SupportedTypes)
            {
                _defaultTypeReaders[type] = PrimitiveTypeReader.Create(type);
            }

            var entityTypeReaders = ImmutableList.CreateBuilder <Tuple <Type, Type> >();

            entityTypeReaders.Add(new Tuple <Type, Type>(typeof(IMessage), typeof(MessageTypeReader <>)));
            entityTypeReaders.Add(new Tuple <Type, Type>(typeof(IChannel), typeof(ChannelTypeReader <>)));
            entityTypeReaders.Add(new Tuple <Type, Type>(typeof(IRole), typeof(RoleTypeReader <>)));
            entityTypeReaders.Add(new Tuple <Type, Type>(typeof(IUser), typeof(UserTypeReader <>)));
            _entityTypeReaders = entityTypeReaders.ToImmutable();
        }
예제 #48
0
        /********************************************************
         * CLASS CONSTRUCTOR
         *********************************************************/
        /// <summary>
        /// QCAlgorithm Base Class Constructor - Initialize the underlying QCAlgorithm components.
        /// QCAlgorithm manages the transactions, portfolio, charting and security subscriptions for the users algorithms.
        /// </summary>
        public QCAlgorithm()
        {
            //Initialise the Algorithm Helper Classes:
            //- Note - ideally these wouldn't be here, but because of the DLL we need to make the classes shared across
            //  the Worker & Algorithm, limiting ability to do anything else.

            //Initialise Data Manager
            SubscriptionManager = new SubscriptionManager();

            Securities   = new SecurityManager();
            Transactions = new SecurityTransactionManager(Securities);
            Portfolio    = new SecurityPortfolioManager(Securities, Transactions);
            Notify       = new NotificationManager(false); // Notification manager defaults to disabled.

            //Initialise Algorithm RunMode to Series - Parallel Mode deprecated:
            _runMode = RunMode.Series;

            //Initialise to unlocked:
            _locked = false;

            //Initialise Start and End Dates:
            _startDate = new DateTime(1998, 01, 01);
            _endDate   = DateTime.Now.AddDays(-1);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            if (Rhino.Runtime.HostUtils.RunningOnOSX)
            {
                RhinoApp.WriteLine("This sample works on Rhino for Windows.");
                return(Result.Cancel);
            }

            // Toggle enabled state
            m_enabled = !m_enabled;

            if (m_enabled)
            {
                RhinoApp.KeyboardEvent += OnRhinoKeyboardEvent;
                RhinoApp.WriteLine("Keyboard hook enabled.");
            }
            else
            {
                RhinoApp.KeyboardEvent -= OnRhinoKeyboardEvent;
                RhinoApp.WriteLine("Keyboard hook disabled.");
            }

            return(Result.Success);
        }
예제 #50
0
        /// <summary>
        /// Call by Rhino when the user wants to run this command
        /// </summary>
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            if (null == m_grip_enabler)
            {
                // Register once and only once...
                m_grip_enabler = new SampleCsRectangleGripsEnabler();
                CustomObjectGrips.RegisterGripsEnabler(m_grip_enabler.TurnOnGrips, typeof(SampleCsRectangleGrips));
            }

            var go = new SampleCsGetRectangleCurve();

            go.SetCommandPrompt("Select rectangles for point display");
            go.GetMultiple(1, 0);
            if (go.CommandResult() != Result.Success)
            {
                return(go.CommandResult());
            }

            for (var i = 0; i < go.ObjectCount; i++)
            {
                var rh_object = go.Object(i).Object();
                if (null != rh_object)
                {
                    if (rh_object.GripsOn)
                    {
                        rh_object.GripsOn = false;
                    }

                    m_grip_enabler.TurnOnGrips(rh_object);
                }
            }

            doc.Views.Redraw();

            return(Result.Success);
        }
예제 #51
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var view = doc.Views.ActiveView;

            if (null == view)
            {
                return(Result.Failure);
            }

            var gz = new GetOption();

            gz.SetCommandPrompt("Zoom option");
            var b_opt = gz.AddOption("BoundingBox");
            var e_opt = gz.AddOption("Extents");
            var s_opt = gz.AddOption("Selected");

            gz.Get();
            if (gz.CommandResult() != Result.Success)
            {
                return(gz.CommandResult());
            }

            var option = gz.Option();

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

            if (option.Index == b_opt)
            {
                var go = new GetObject();
                go.SetCommandPrompt("Select objects");
                go.SubObjectSelect = false;
                go.GetMultiple(1, 0);
                if (go.CommandResult() != Result.Success)
                {
                    return(go.CommandResult());
                }

                var bbox = new BoundingBox();
                for (var i = 0; i < go.ObjectCount; i++)
                {
                    var geom = go.Object(i).Geometry();
                    if (null != geom)
                    {
                        var b = geom.GetBoundingBox(true);
                        if (b.IsValid)
                        {
                            if (0 == i)
                            {
                                bbox = b;
                            }
                            else
                            {
                                bbox.Union(b);
                            }
                        }
                    }
                }

                if (bbox.IsValid)
                {
                    view.ActiveViewport.ZoomBoundingBox(bbox);
                    view.Redraw();
                }
            }
            else if (option.Index == e_opt)
            {
                view.ActiveViewport.ZoomExtents();
                view.Redraw();
            }
            else if (option.Index == s_opt)
            {
                view.ActiveViewport.ZoomExtentsSelected();
                view.Redraw();
            }

            return(Result.Success);
        }
예제 #52
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Select objects to define block
            var go = new GetObject();

            go.SetCommandPrompt("Select objects to define block");
            go.ReferenceObjectSelect = false;
            go.SubObjectSelect       = false;
            go.GroupSelect           = true;

            // Phantoms, grips, lights, etc., cannot be in blocks.
            var forbidden_geometry_filter = ObjectType.Light | ObjectType.Grip | ObjectType.Phantom;
            var geometry_filter           = forbidden_geometry_filter ^ ObjectType.AnyObject;

            go.GeometryFilter = geometry_filter;
            go.GetMultiple(1, 0);
            if (go.CommandResult() != Result.Success)
            {
                return(go.CommandResult());
            }

            // Block base point
            Point3d base_point;
            var     rc = RhinoGet.GetPoint("Block base point", false, out base_point);

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

            // Block definition name
            string idef_name = "";

            rc = RhinoGet.GetString("Block definition name", false, ref idef_name);
            if (rc != Result.Success)
            {
                return(rc);
            }

            // Validate block name
            idef_name = idef_name.Trim();
            if (string.IsNullOrEmpty(idef_name))
            {
                return(Result.Nothing);
            }

            // See if block name already exists
            InstanceDefinition existing_idef = doc.InstanceDefinitions.Find(idef_name);

            if (existing_idef != null)
            {
                RhinoApp.WriteLine("Block definition {0} already exists", idef_name);
                return(Result.Nothing);
            }

            // Gather all of the selected objects
            var geometry   = new List <GeometryBase>();
            var attributes = new List <ObjectAttributes>();

            for (int i = 0; i < go.ObjectCount; i++)
            {
                var rh_object = go.Object(i).Object();
                if (rh_object != null)
                {
                    geometry.Add(rh_object.Geometry);
                    attributes.Add(rh_object.Attributes);
                }
            }

            // Gather all of the selected objects
            var idef_index = doc.InstanceDefinitions.Add(idef_name, string.Empty, base_point, geometry, attributes);

            if (idef_index < 0)
            {
                RhinoApp.WriteLine("Unable to create block definition", idef_name);
                return(Result.Failure);
            }

            return(Result.Success);
        }
 /// <summary>
 ///     Register a method as a Slash Command.
 /// </summary>
 /// <param name="name">Name of the command.</param>
 /// <param name="description">Description of the command.</param>
 /// <param name="ignoreGroupNames"> If <see langword="true"/>, <see cref="GroupAttribute"/>s will be ignored while creating this command and this method will be treated as a top level command.</param>
 /// <param name="runMode">Set the run mode of the command.</param>
 public SlashCommandAttribute(string name, string description, bool ignoreGroupNames = false, RunMode runMode = RunMode.Default)
 {
     Name             = name;
     Description      = description;
     IgnoreGroupNames = ignoreGroupNames;
     RunMode          = runMode;
 }
 public NonStandardCommandService(RunMode runMode)
 {
     _runMode = runMode;
 }
예제 #55
0
 protected override Result RunCommand(RhinoDoc doc, RunMode mode)
 {
     RhinoApp.RunScript(@"-_Open C:\model.3dm");
 }
예제 #56
0
 /// <summary>
 ///     Create a command for Autocomplete interaction handling.
 /// </summary>
 /// <param name="parameterName">Name of the target parameter.</param>
 /// <param name="commandName">Name of the target command.</param>
 /// <param name="runMode">Set the run mode of the command.</param>
 public AutocompleteCommandAttribute(string parameterName, string commandName, RunMode runMode = RunMode.Default)
 {
     ParameterName = parameterName;
     CommandName   = commandName;
     RunMode       = runMode;
 }
예제 #57
0
 protected override Result RunCommand(RhinoDoc doc, RunMode mode)
 {
     WolframScriptingPlugIn.Instance.StartReaderThread();
     return(Result.Success);
 }
예제 #58
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            {
                // Creating the folder into with the load profiles files will be saved
                string workspacepath    = FileSettings.WorkingFolder.ToString();
                string extractionfolder = FileSettings.WorkingFolder.ToString() + "\\Trnsys";
                string BundlePath       = FileSettings.WorkingFolder.ToString();

                bool exists1 = System.IO.Directory.Exists(workspacepath);
                if (!exists1)
                {
                    System.IO.Directory.CreateDirectory(workspacepath);
                }

                bool exists2 = System.IO.Directory.Exists(extractionfolder);
                if (!exists2)
                {
                    System.IO.Directory.CreateDirectory(extractionfolder);
                }


                // For each objects in the global context, create one csv file containing two columns
                // The first column is the simulation timestep and the second column is the the values
                // of the selected output

                foreach (var o in UmiContext.Current.GetObjects())
                {
                    // Create and Save File
                    string csvFileName = o.Id.ToString();
                    string filePath    = extractionfolder + "\\" + csvFileName + ".csv";
                    try
                    {
                        File.Create(filePath).Close();
                    }
                    catch (IOException)
                    {
                        string mess = "Creation of file " + csvFileName + ".csv" + "did not work";
                        RhinoApp.WriteLine(mess);
                    }

                    // Creating new string array for printing lines
                    StringBuilder newsb = new StringBuilder();

                    newsb.AppendLine($"{o.Name ?? o.Id}:");
                    File.AppendAllText(filePath, newsb.ToString());

                    var           series = o.Data.Select(kvp => kvp.Value);
                    List <string> lines  = new List <string>();

                    var m = series.ToArray()[6];

                    StringBuilder sbline = new StringBuilder();
                    string        line1  = "Time" + delimiter + $"\t{m.Name}";
                    lines.Add(line1);
                    string line2 = $"\t" + $"\t{m.Units}";
                    for (int i = 0; i < m.Data.Count; i++)
                    {
                        string line = i + delimiter + m.Data[i].ToString();
                        lines.Add(line);
                    }
                    File.AppendAllLines(filePath, lines);
                }
            }
            return(Result.Success);
        }
예제 #59
0
 public RgnIterator(Drawable drawable, RunMode runmode)
 {
     _drawable  = drawable;
     _runmode   = runmode;
     _rectangle = drawable.MaskBounds;
 }
예제 #60
0
        /// <summary>
        /// RunCommand
        /// </summary>
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Tolerance = doc.ModelAbsoluteTolerance;

            // Get persistent settings
            var settings = Settings;
            var radius   = settings.GetDouble("Radius", RADIUS);
            var cut_type = settings.GetEnumValue("CutType", CUTTYPE);

            // Select closed,planar curve
            var go = new GetClosedPlanarPolyline(Tolerance);

            go.SetCommandPrompt("Select closed, planar polyline");
            go.Get();
            if (go.CommandResult() != Result.Success)
            {
                return(go.CommandResult());
            }

            // Get curve
            var obj_ref = go.Object(0);
            var curve   = obj_ref.Curve();

            if (null == curve || !curve.IsClosed || !curve.IsPlanar())
            {
                return(Result.Failure);
            }

            // Get polyline
            Polyline polyline;

            if (!curve.TryGetPolyline(out polyline))
            {
                return(Result.Failure);
            }

            // Since first and last point are the same, remove the last point.
            polyline.RemoveAt(polyline.Count - 1);

            // Get curve plane
            Plane plane;

            if (!curve.TryGetPlane(out plane, Tolerance))
            {
                return(Result.Failure);
            }

            // Get corner point indices
            var indices = FindInnerCornerPoints(curve, polyline, plane);

            if (0 == indices.Length)
            {
                RhinoApp.WriteLine("No inner corners found.");
                return(Result.Nothing);
            }

            // Show preview conduit
            var conduit = new SampleCsOverCutConduit
            {
                Circles = CalculateCuttingCircles(curve, polyline, indices, plane, radius, cut_type),
                Enabled = true
            };

            doc.Views.Redraw();

            Result rc;

            // Choose overcut options
            var gp = new GetOption();

            gp.SetCommandPrompt("Choose overcut option");
            gp.AcceptNothing(true);
            for (;;)
            {
                gp.ClearCommandOptions();
                var cut_type_index = gp.AddOptionEnumList("CutType", cut_type);
                var radius_option  = new OptionDouble(radius, true, Tolerance);
                var radius_index   = gp.AddOptionDouble("Radius", ref radius_option);
                var res            = gp.Get();

                if (res == GetResult.Option)
                {
                    var option = gp.Option();
                    if (null != option)
                    {
                        if (option.Index == cut_type_index)
                        {
                            var list = Enum.GetValues(typeof(CutType)).Cast <CutType>().ToList();
                            cut_type = list[option.CurrentListOptionIndex];
                        }
                        else if (option.Index == radius_index)
                        {
                            radius = radius_option.CurrentValue;
                        }

                        conduit.Circles = CalculateCuttingCircles(curve, polyline, indices, plane, radius, cut_type);
                        doc.Views.Redraw();
                    }
                    continue;
                }

                if (res == GetResult.Nothing)
                {
                    rc = Result.Success;
                    break;
                }

                rc = Result.Cancel;
                break;
            }

            conduit.Enabled = false;

            if (rc == Result.Success)
            {
                // Try differencing circles from curve
                var success   = true;
                var new_curve = curve;
                for (var i = 0; i < conduit.Circles.Count && success; i++)
                {
                    var new_curves = Curve.CreateBooleanDifference(new_curve, new ArcCurve(conduit.Circles[i]), doc.ModelAbsoluteTolerance);
                    if (1 == new_curves.Length && null != new_curves[0])
                    {
                        new_curve = new_curves[0];
                    }
                    else
                    {
                        success = false;
                    }
                }

                // Add geometry to document
                if (success && null != new_curve)
                {
                    doc.Objects.Replace(obj_ref, new_curve);
                }
                else
                {
                    for (var i = 0; i < conduit.Circles.Count; i++)
                    {
                        doc.Objects.AddCircle(conduit.Circles[i]);
                    }
                }

                // Set persistent settings
                settings.SetDouble("Radius", radius);
                settings.SetEnumValue("CutType", cut_type);
            }

            doc.Views.Redraw();

            return(rc);
        }