Beispiel #1
0
            protected override void OnMouseDown(GetPointMouseEventArgs e)
            {
                base.OnMouseDown(e);
                var picker = new PickContext();

                picker.View = e.Viewport.ParentView;

                picker.PickStyle = PickStyle.PointPick;

                var xform = e.Viewport.GetPickTransform(e.WindowPoint);

                picker.SetPickTransform(xform);

                foreach (var cp in m_conduit_points)
                {
                    double depth;
                    double distance;
                    if (picker.PickFrustumTest(cp.Point, out depth, out distance))
                    {
                        cp.Color = System.Drawing.Color.Red;
                    }
                    else
                    {
                        cp.Color = System.Drawing.Color.White;
                    }
                }
            }
Beispiel #2
0
        private List <ObjRef> ssget_point(RhinoDoc doc, RhinoView view, Point3d point)
        {
            var world_to_screen = view.ActiveViewport.GetTransform(CoordinateSystem.World, CoordinateSystem.Screen);

            point.Transform(world_to_screen);

            var pick_context = new PickContext();

            pick_context.View              = view;
            pick_context.PickStyle         = PickStyle.PointPick;
            pick_context.PickGroupsEnabled = true;

            var xform = view.ActiveViewport.GetPickTransform(Convert.ToInt32(point.X), Convert.ToInt32(point.Y));

            pick_context.SetPickTransform(xform);
            double depth, distance;

            foreach (var rhino_object in doc.Objects)
            {
                //rhino_object.OnPicked(pick_context, )
            }
            if (pick_context.PickFrustumTest(point, out depth, out distance))
            {
                pick_context.UpdateClippingPlanes();
            }
            return(null);
        }
Beispiel #3
0
        public override PickResult Pick(PickContext context)
        {
            Subchannel?   leastUsedSubchannel = null;
            int?          leastUsedCount      = null;
            AtomicCounter?leastUsedCounter    = null;

            foreach (var subchannel in _subchannels)
            {
                if (!subchannel.Attributes.TryGetValue(CounterKey, out var counter))
                {
                    throw new InvalidOperationException("All subchannels should have a counter.");
                }

                var currentCount = counter.Value;
                if (leastUsedSubchannel == null || leastUsedCount > currentCount)
                {
                    leastUsedSubchannel = subchannel;
                    leastUsedCount      = currentCount;
                    leastUsedCounter    = counter;
                }
            }

            Debug.Assert(leastUsedSubchannel != null);
            Debug.Assert(leastUsedCounter != null);

            leastUsedCounter.Increment();

            return(PickResult.ForSubchannel(leastUsedSubchannel, c =>
            {
                leastUsedCounter.Decrement();
            }));
        }
Beispiel #4
0
        protected override void OnMouseDown(GetPointMouseEventArgs e)
        {
            //control 키 누른채로 입력시 감소
            int direction = 1;

            if (e.ControlKeyDown)
            {
                direction = -1;
            }

            var picker = new PickContext();

            picker.View = e.Viewport.ParentView;

            picker.PickStyle = PickStyle.PointPick;

            var xform = e.Viewport.GetPickTransform(e.WindowPoint);

            picker.SetPickTransform(xform);

            for (int i = 0; i < tempLines.Count; i++)
            {
                double depth;
                double distance;
                double t;


                //shift 키 누른채로 입력 시 모든 선에 적용
                if (e.ShiftKeyDown)
                {
                    int index      = this.roadWidth.ToList().IndexOf(tempLines[i].RoadWidth);
                    int index_Next = (index + direction + roadWidth.Count()) % roadWidth.Count();

                    tempLines[i].RoadWidth = this.roadWidth[index_Next];
                    tempLines[i].Color     = CommonFunc.colorSetting.GetColorFromValue(this.roadWidth[index_Next]);
                    TuringAndCorbusierPlugIn.InstanceClass.plot.Surroundings[tempLines.IndexOf(tempLines[i])] = roadWidth[index_Next];
                }
                else
                {
                    //가까운 선에만 적용
                    if (picker.PickFrustumTest(tempLines[i].line, out t, out depth, out distance))
                    {
                        int index      = this.roadWidth.ToList().IndexOf(tempLines[i].RoadWidth);
                        int index_Next = (index + direction + roadWidth.Count()) % roadWidth.Count();

                        tempLines[i].RoadWidth = this.roadWidth[index_Next];
                        tempLines[i].Color     = CommonFunc.colorSetting.GetColorFromValue(this.roadWidth[index_Next]);
                        TuringAndCorbusierPlugIn.InstanceClass.plot.Surroundings[tempLines.IndexOf(tempLines[i])] = roadWidth[index_Next];
                    }
                }
            }
        }
Beispiel #5
0
        protected override void OnMouseDown(GetPointMouseEventArgs e)
        {
            base.OnMouseDown(e);
            var picker = new PickContext();

            picker.View = e.Viewport.ParentView;

            picker.PickStyle = PickStyle.PointPick;

            var xform = e.Viewport.GetPickTransform(e.WindowPoint);

            picker.SetPickTransform(xform);
        }
Beispiel #6
0
        protected override void OnMouseDown(GetPointMouseEventArgs e)
        {
            if (m_radius_dc.PickResult.Mode != GumballMode.None || m_height_dc.PickResult.Mode != GumballMode.None)
            {
                return;
            }

            m_base_origin = Point3d.Unset;
            m_base_point  = Point3d.Unset;

            m_radius_dc.PickResult.SetToDefault();
            m_height_dc.PickResult.SetToDefault();

            var pick_context = new PickContext
            {
                View      = e.Viewport.ParentView,
                PickStyle = PickStyle.PointPick
            };

            var xform = e.Viewport.GetPickTransform(e.WindowPoint);

            pick_context.SetPickTransform(xform);

            Line pick_line;

            e.Viewport.GetFrustumLine(e.WindowPoint.X, e.WindowPoint.Y, out pick_line);

            pick_context.PickLine = pick_line;
            pick_context.UpdateClippingPlanes();

            // try picking one of the gumballs
            if (m_radius_dc.PickGumball(pick_context, this))
            {
                m_base_origin = m_cylinder.RadiusPlane.Origin;
                m_base_point  = e.Point;
            }
            else if (m_height_dc.PickGumball(pick_context, this))
            {
                m_base_origin = m_cylinder.HeightPlane.Origin;
                m_base_point  = e.Point;
            }
        }
Beispiel #7
0
        protected override void OnMouseDown(GetPointMouseEventArgs e)
        {
            base.OnMouseDown(e);
            var picker = new PickContext
            {
                View = e.Viewport.ParentView,

                PickStyle = PickStyle.PointPick
            };


            var xform = e.Viewport.GetPickTransform(e.WindowPoint);

            picker.SetPickTransform(xform);

            foreach (var edgeLine in m_conduit_edges.Zip(m_conduit_lines, (edge, line) => new { edge, line }))
            {
                if (picker.PickFrustumTest(edgeLine.line, out double t, out double depth, out double distance))
                {
                    edgeLine.edge.Picked = !edgeLine.edge.Picked;
                }
            }
        }
Beispiel #8
0
        protected override void OnMouseDown(GetPointMouseEventArgs e)
        {
            base.OnMouseDown(e);
            var picker = new PickContext
            {
                View = e.Viewport.ParentView,

                PickStyle = PickStyle.PointPick
            };


            var xform = e.Viewport.GetPickTransform(e.WindowPoint);

            picker.SetPickTransform(xform);

            foreach (var vrt in m_conduit_vertices)
            {
                if (picker.PickFrustumTest(vrt.Point, out double depth, out double distance))
                {
                    vrt.Picked = !vrt.Picked;
                }
            }
        }
 public override PickResult Pick(PickContext context)
 {
     _loadBalancer.PickCount++;
     return(PickResult.ForDrop(new Status(StatusCode.DataLoss, string.Empty)));
 }
        public async ValueTask <(Subchannel Subchannel, BalancerAddress Address, Action <CompletionContext> OnComplete)> PickAsync(PickContext context, bool waitForReady, CancellationToken cancellationToken)
        {
            SubchannelPicker?previousPicker = null;

            // Wait for a valid picker. When the client state changes a new picker will be returned.
            // Cancellation will break out of the loop. Typically cancellation will come from a
            // deadline specified for a call being exceeded.
            while (true)
            {
                var currentPicker = await GetPickerAsync(previousPicker, cancellationToken).ConfigureAwait(false);

                ConnectionManagerLog.PickStarted(Logger);
                var result = currentPicker.Pick(context);

                switch (result.Type)
                {
                case PickResultType.Complete:
                    var subchannel = result.Subchannel !;
                    var address    = subchannel.CurrentAddress;

                    if (address != null)
                    {
                        ConnectionManagerLog.PickResultSuccessful(Logger, subchannel.Id, address);
                        return(subchannel, address, result.Complete);
                    }
                    else
                    {
                        ConnectionManagerLog.PickResultSubchannelNoCurrentAddress(Logger, subchannel.Id);
                        previousPicker = currentPicker;
                    }
                    break;

                case PickResultType.Queue:
                    ConnectionManagerLog.PickResultQueued(Logger);
                    previousPicker = currentPicker;
                    break;

                case PickResultType.Fail:
                    if (waitForReady)
                    {
                        ConnectionManagerLog.PickResultFailureWithWaitForReady(Logger, result.Status);
                        previousPicker = currentPicker;
                    }
                    else
                    {
                        ConnectionManagerLog.PickResultFailure(Logger, result.Status);
                        throw new RpcException(result.Status);
                    }
                    break;

                case PickResultType.Drop:
                    // Use metadata on the exception to signal the request was dropped.
                    // Metadata is checked by retry. If request was dropped then it isn't retried.
                    var metadata = new Metadata {
                        new Metadata.Entry(GrpcProtocolConstants.DropRequestTrailer, bool.TrueString)
                    };
                    throw new RpcException(result.Status, metadata);

                default:
                    throw new InvalidOperationException($"Unexpected pick result type: {result.Type}");
                }
            }
        }
        protected override async Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request, CancellationToken cancellationToken)
        {
            if (request.RequestUri == null)
            {
                throw new InvalidOperationException("Request message URI not set.");
            }

            var waitForReady = false;

            if (request.TryGetOption <bool>(WaitForReadyKey, out var value))
            {
                waitForReady = value;
            }

            await _manager.ConnectAsync(waitForReady : false, cancellationToken).ConfigureAwait(false);

            var pickContext = new PickContext {
                Request = request
            };
            var result = await _manager.PickAsync(pickContext, waitForReady, cancellationToken).ConfigureAwait(false);

            var address         = result.Address;
            var addressEndpoint = address.EndPoint;

            // Update request host if required.
            if (!request.RequestUri.IsAbsoluteUri ||
                request.RequestUri.Host != addressEndpoint.Host ||
                request.RequestUri.Port != addressEndpoint.Port)
            {
                var uriBuilder = new UriBuilder(request.RequestUri);
                uriBuilder.Host    = addressEndpoint.Host;
                uriBuilder.Port    = addressEndpoint.Port;
                request.RequestUri = uriBuilder.Uri;
            }

#if NET5_0_OR_GREATER
            // Set sub-connection onto request.
            // Will be used to get a stream in SocketsHttpHandler.ConnectCallback.
            request.SetOption(SubchannelKey, result.Subchannel);
            request.SetOption(CurrentAddressKey, address);
#endif

            var responseMessageTask = base.SendAsync(request, cancellationToken);
            result.SubchannelCallTracker?.Start();

            try
            {
                var responseMessage = await responseMessageTask.ConfigureAwait(false);

                // TODO(JamesNK): This doesn't take into account long running streams.
                // If there is response content then we need to wait until it is read to the end
                // or the request is disposed.
                result.SubchannelCallTracker?.Complete(new CompletionContext
                {
                    Address = address
                });

                return(responseMessage);
            }
            catch (Exception ex)
            {
                result.SubchannelCallTracker?.Complete(new CompletionContext
                {
                    Address = address,
                    Error   = ex
                });

                throw;
            }
        }
 /// <summary>
 /// Picks a ready <see cref="Subchannel"/> for the specified context.
 /// </summary>
 /// <param name="context">The pick content.</param>
 /// <returns>A ready <see cref="Subchannel"/>.</returns>
 public abstract PickResult Pick(PickContext context);
Beispiel #13
0
        protected override void OnMouseDown(GetPointMouseEventArgs e)
        {
            if (x_height_plus_dc.PickResult.Mode != GumballMode.None || x_height_minus_dc.PickResult.Mode != GumballMode.None ||
                y_height_plus_dc.PickResult.Mode != GumballMode.None || y_height_minus_dc.PickResult.Mode != GumballMode.None ||
                z_height_plus_dc.PickResult.Mode != GumballMode.None || z_height_minus_dc.PickResult.Mode != GumballMode.None)
            {
                return;
            }

            m_base_origin = Point3d.Unset;
            m_base_point  = Point3d.Unset;

            x_height_plus_dc.PickResult.SetToDefault();
            x_height_minus_dc.PickResult.SetToDefault();
            y_height_plus_dc.PickResult.SetToDefault();
            y_height_minus_dc.PickResult.SetToDefault();
            z_height_plus_dc.PickResult.SetToDefault();
            z_height_minus_dc.PickResult.SetToDefault();

            var pick_context = new PickContext
            {
                View      = e.Viewport.ParentView,
                PickStyle = PickStyle.PointPick
            };

            var xform = e.Viewport.GetPickTransform(e.WindowPoint);

            pick_context.SetPickTransform(xform);

            Line pick_line;

            e.Viewport.GetFrustumLine(e.WindowPoint.X, e.WindowPoint.Y, out pick_line);

            pick_context.PickLine = pick_line;

            // try picking one of the gumballs
            if (x_height_plus_dc.PickGumball(pick_context, this))
            {
                m_base_origin = m_Box.X_plus_plane.ClosestPoint(m_Box.Center);
                m_base_point  = e.Point;
            }

            else if (x_height_minus_dc.PickGumball(pick_context, this))
            {
                m_base_origin = m_Box.X_minus_plane.ClosestPoint(m_Box.Center);
                m_base_point  = e.Point;
            }

            else if (y_height_plus_dc.PickGumball(pick_context, this))
            {
                m_base_origin = m_Box.Y_plus_plane.ClosestPoint(m_Box.Center);
                m_base_point  = e.Point;
            }

            else if (y_height_minus_dc.PickGumball(pick_context, this))
            {
                m_base_origin = m_Box.Y_minus_plane.ClosestPoint(m_Box.Center);
                m_base_point  = e.Point;
            }
            else if (z_height_plus_dc.PickGumball(pick_context, this))
            {
                m_base_origin = m_Box.Z_plus_plane.ClosestPoint(m_Box.Center);
                m_base_point  = e.Point;
            }

            else if (z_height_minus_dc.PickGumball(pick_context, this))
            {
                m_base_origin = m_Box.Z_minus_plane.ClosestPoint(m_Box.Center);
                m_base_point  = e.Point;
            }
        }
Beispiel #14
0
        public virtual ActionResult AcceptBuilding(BuildingViewModel model)
        {
            string currentBuildingId;
            string currentSaurceArea;
            string currentSaurceAreaShortName;

            //TC1 : Press enter in textbox on building view.
            if (string.IsNullOrEmpty(model.ScannedBuildingOrArea))
            {
                //TC2 : Press enter in textbox on building area view or pallet view..
                if (!string.IsNullOrEmpty(model.CurrentBuildingId))
                {
                    model.CurrentBuildingId = model.CurrentBuildingId.ToUpper();
                    // If building is set, just proceed because area is optional
                    currentBuildingId          = model.CurrentBuildingId;
                    currentSaurceArea          = model.CurrentSourceArea;
                    currentSaurceAreaShortName = model.CurrentSourceAreaShortName;
                    MasterModel.ClearSessionValues(this.Session);
                    model.CurrentBuildingId          = currentBuildingId;
                    model.CurrentSourceArea          = currentSaurceArea;
                    model.CurrentSourceAreaShortName = currentSaurceAreaShortName;
                    return(View(Views.Pallet, new PalletViewModel(this.Session)));
                }
                // Building is not set. Start over.
                MasterModel.ClearSessionValues(this.Session);
                return(View(Views.Building, model));
            }

            var fieldName = model.NameFor(m => m.ScannedBuildingOrArea);

            try
            {
                PickContext pickContext = _repos.Value.GetPickContext(model.ScannedBuildingOrArea);
                //TC3 : Scan invlaid building or area.
                if (pickContext == null)
                {
                    // Bad scan. Preserve current building and area
                    ModelState.AddModelError(fieldName, string.Format("{0} is not a valid Building or Area", model.ScannedBuildingOrArea));
                    currentBuildingId          = model.CurrentBuildingId;
                    currentSaurceArea          = model.CurrentSourceArea;
                    currentSaurceAreaShortName = model.CurrentSourceAreaShortName;
                }
                else
                {
                    //TC4 : On first scan of building we reach here
                    if (IsInitialScan(model))
                    {
                        // Both values are
                        currentBuildingId          = pickContext.BuildingId;
                        currentSaurceArea          = pickContext.SourceArea;
                        currentSaurceAreaShortName = pickContext.SourceAreaShortName;
                    }
                    else if (pickContext.IsBuilding)
                    {
                        // Accept the building only
                        currentBuildingId          = pickContext.BuildingId;
                        currentSaurceAreaShortName = model.CurrentSourceAreaShortName;
                        currentSaurceArea          = model.CurrentSourceArea;
                    }
                    else if (pickContext.IsMultiBuildingArea)
                    {
                        currentBuildingId          = model.CurrentBuildingId;
                        currentSaurceArea          = pickContext.SourceArea;
                        currentSaurceAreaShortName = pickContext.SourceAreaShortName;
                    }
                    else if (pickContext.IsSingleBuildingArea)
                    {
                        // Ignore the area if it belongs to a different building
                        if (string.IsNullOrEmpty(model.CurrentBuildingId) || model.CurrentBuildingId == pickContext.BuildingId)
                        {
                            currentBuildingId          = pickContext.BuildingId;
                            currentSaurceArea          = pickContext.SourceArea;
                            currentSaurceAreaShortName = pickContext.SourceAreaShortName;
                        }
                        else
                        {
                            ModelState.AddModelError("", string.Format("Area {0} doesn't belong to building {1}", pickContext.SourceArea, model.CurrentBuildingId));
                            currentBuildingId          = model.CurrentBuildingId;
                            currentSaurceAreaShortName = string.Empty;
                            currentSaurceArea          = string.Empty;
                        }
                    }
                    else
                    {
                        throw new Exception("We never expect to get here");
                    }
                }
            }
            catch (DbException ex)
            {
                ModelState.AddModelError(fieldName, ex.Message);
                currentBuildingId          = model.CurrentBuildingId;
                currentSaurceArea          = model.CurrentSourceArea;
                currentSaurceAreaShortName = model.CurrentSourceAreaShortName;
            }
            MasterModel.ClearSessionValues(this.Session);
            model.CurrentBuildingId          = currentBuildingId;
            model.CurrentSourceArea          = currentSaurceArea;
            model.CurrentSourceAreaShortName = currentSaurceAreaShortName;
            if (!ModelState.IsValid || string.IsNullOrEmpty(model.CurrentBuildingId) || string.IsNullOrEmpty(model.CurrentSourceArea))
            {
                return(View(Views.Building, model));
            }

            return(View(Views.Pallet, new PalletViewModel(this.Session)));
        }
 public override PickResult Pick(PickContext context)
 {
     return(PickResult.ForFailure(_status));
 }
Beispiel #16
0
 public override PickResult Pick(PickContext context)
 {
     return(_pickResult);
 }