コード例 #1
0
        /// <summary>
        /// Navigate center of viewport to center of extent and change resolution
        /// </summary>
        /// <param name="extent">New extent for viewport to show</param>
        /// <param name="scaleMethod">Scale method to use to determine resolution</param>
        /// <param name="duration">Duration of animation in millisecondsScale method to use to determine resolution</param>
        public void NavigateTo(BoundingBox extent, ScaleMethod scaleMethod = ScaleMethod.Fit, long duration = 300)
        {
            if (extent == null)
            {
                return;
            }

            var resolution = ZoomHelper.DetermineResolution(
                extent.Width, extent.Height, _viewport.Width, _viewport.Height, scaleMethod);

            NavigateTo(extent.Centroid, resolution, duration);
        }
コード例 #2
0
    public override void OnStateEnter()
    {
        mull.treeDistance = 2f;


        ZoomHelper.setUIVisibility(infoBox, false);
        ZoomHelper.setUIVisibility(backButton, false);

        camera.transform.rotation = camera.getLastRotation();

        hiker.transform.rotation = hiker.GetComponent <OnHoverHiker> ().initialRotation;
    }
コード例 #3
0
        public void CalculateMatrix_StretchMode_UniformToFill()
        {
            var panelBounds   = new Rect(0, 0, 300, 200);
            var elementBounds = new Rect(0, 0, 100, 100);
            var target        = ZoomHelper.CalculateMatrix(panelBounds.Width, panelBounds.Height, elementBounds.Width, elementBounds.Height, StretchMode.UniformToFill);

            Assert.Equal(3.0, target.M11);
            Assert.Equal(0.0, target.M12);
            Assert.Equal(0.0, target.M21);
            Assert.Equal(3.0, target.M22);
            Assert.Equal(-100.0, target.M31);
            Assert.Equal(-100.0, target.M32);
        }
コード例 #4
0
    public override void OnStateEnter()
    {
        AudioSource correctGuessSound   = guessSounds[0];
        AudioSource incorrectGuessSound = guessSounds[1];


        guessColour.guessedColour();
        answerColour.correctColour();

        if (isGaelic)
        {
            infoContainer.answerText.text = "An Fhreagairt Cheart: " + answer.headname;
            infoContainer.guessText.text  = "Do Fhreagairt: " + guess.GetComponent <SettlementInformation> ().headname;
            moveOn.text = "Air aghaidh";
        }
        else
        {
            infoContainer.answerText.text = "The correct answer: " + answer.headname;
            infoContainer.guessText.text  = "Your answer: " + guess.GetComponent <SettlementInformation> ().headname;
            moveOn.text = "Continue";
        }

        if (qc.isCorrect())
        {
            if (isGaelic)
            {
                infoContainer.answerStatus.text = "Ceart!";
            }
            else
            {
                infoContainer.answerStatus.text = "Correct!";
            }
            infoContainer.answerStatus.color = Color.green;
            correctGuessSound.Play();
        }
        else
        {
            if (isGaelic)
            {
                infoContainer.answerStatus.text = "Ceàrr!";
            }
            else
            {
                infoContainer.answerStatus.text = "Wrong!";
            }
            infoContainer.answerStatus.color = new Color32(255, 53, 53, 255);
            incorrectGuessSound.Play();
        }

        ZoomHelper.setUIVisibility(answerGroup, true);
    }
コード例 #5
0
        public void ZoomToBbox(Point min, Point max)
        {
            double x, y, resolution;

            ZoomHelper.ZoomToBoudingbox(min.X, min.Y, max.X, max.Y, this.ActualWidth, out x, out y, out resolution);
            resolution = ZoomHelper.ClipToExtremes(rootLayer.Schema.Resolutions, resolution);

            this.Transform.Center     = new Point(x, y);
            this.Transform.Resolution = resolution;
            this.toResolution         = resolution;

            this.Refresh();
            ClearBBoxDrawing();
        }
コード例 #6
0
    private void OnChangeZoom()
    {
        //Example of scaling object
        //int zoom = OnlineMaps.instance.zoom;

        //float s = 10f / (2 << (zoom - 5));

        float originalScale = 1 << defaultZoom;
        float currentScale  = 1 << OnlineMaps.instance.zoom;

        ZoomHelper helper = dynamicMarker.instance.GetComponent <ZoomHelper>();

        helper.SetGizmoRange(currentScale / originalScale);
    }
コード例 #7
0
        public void ZoomIn()
        {
            if (ZoomLocked)
            {
                return;
            }

            if (double.IsNaN(toResolution))
            {
                toResolution = viewport.Resolution;
            }

            toResolution = ZoomHelper.ZoomIn(map.Resolutions, toResolution);
            ZoomMiddle();
        }
コード例 #8
0
        public void ZoomOut()
        {
            if (ZoomLocked)
            {
                return;
            }
            if (!viewInitialized)
            {
                return;
            }

            viewport.Resolution = ZoomHelper.ZoomOut(map.Resolutions, viewport.Resolution);

            OnViewChanged(false);
        }
コード例 #9
0
        public void ZoomIn()
        {
            if (ZoomLocked)
            {
                return;
            }

            if (double.IsNaN(_toResolution))
            {
                _toResolution = Map.Viewport.Resolution;
            }

            _toResolution = ZoomHelper.ZoomIn(_map.Resolutions, _toResolution);
            ZoomMiddle();
        }
コード例 #10
0
ファイル: MapControl.cs プロジェクト: zwzhlj100000/BruTile
        void MapControlMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (e.Delta > 0)
            {
                _viewport.UnitsPerPixel = ZoomHelper.ZoomIn(_tileSource.Schema.Resolutions.Select(r => r.Value.UnitsPerPixel).ToList(), _viewport.UnitsPerPixel);
            }
            else if (e.Delta < 0)
            {
                _viewport.UnitsPerPixel = ZoomHelper.ZoomOut(_tileSource.Schema.Resolutions.Select(r => r.Value.UnitsPerPixel).ToList(), _viewport.UnitsPerPixel);
            }

            _fetcher.ViewChanged(_viewport.Extent, _viewport.UnitsPerPixel);
            e.Handled = true; //so that the scroll event is not sent to the html page.
            _invalid  = true;
        }
コード例 #11
0
        /// <summary>
        /// Navigate center of viewport to center of extent and change resolution
        /// </summary>
        /// <param name="extent">New extent for viewport to show</param>
        /// <param name="scaleMethod">Scale method to use to determine resolution</param>
        public void NavigateTo(BoundingBox extent, ScaleMethod scaleMethod = ScaleMethod.Fit)
        {
            if (extent == null)
            {
                return;
            }

            var resolution = ZoomHelper.DetermineResolution(
                extent.Width, extent.Height, _viewport.Width, _viewport.Height, scaleMethod);

            _viewport.SetResolution(resolution);

            _viewport.SetCenter(extent.Centroid);

            Navigated?.Invoke(this, EventArgs.Empty);
        }
コード例 #12
0
ファイル: Navigator.cs プロジェクト: mattmiley/Mapsui
        /// <summary>
        /// Navigate center of viewport to center of extent and change resolution
        /// </summary>
        /// <param name="extent">New extent for viewport to show</param>
        /// <param name="scaleMethod">Scale method to use to determin resolution</param>
        public void NavigateTo(BoundingBox extent, ScaleMethod scaleMethod = ScaleMethod.Fit)
        {
            if (extent == null)
            {
                return;
            }

            var resolution = ZoomHelper.DetermineResolution(
                extent.Width, extent.Height, _viewport.Width, _viewport.Height, scaleMethod);

            _viewport.SetResolution(resolution);

            _viewport.SetCenter(extent.Centroid);

            _map.RefreshData(_viewport.Extent, _viewport.Resolution, true);
        }
コード例 #13
0
        private IObservable <T> Search(IEnvelop envelope, int zoomLevel)
        {
            var minMargin = ZoomHelper.GetMinMargin(zoomLevel);

            return(Observable.Create <T>(observer =>
            {
                var node = Root;
                if (!envelope.Intersects(node.Envelope))
                {
                    observer.OnCompleted();
                    return Disposable.Empty;
                }

                var nodesToSearch = new Stack <RTreeNode>();

                while (node != null && node.Envelope != null)
                {
                    if (node.Children != null)
                    {
                        foreach (var child in node.Children)
                        {
                            var childEnvelope = child.Envelope;
                            if (envelope.Intersects(childEnvelope))
                            {
                                if (node.IsLeaf && childEnvelope.Margin >= minMargin)
                                {
                                    observer.OnNext(child.Data);
                                }
                                else if (envelope.Contains(childEnvelope))
                                {
                                    Collect(child, minMargin, observer);
                                }
                                else
                                {
                                    nodesToSearch.Push(child);
                                }
                            }
                        }
                    }
                    node = nodesToSearch.TryPop();
                }
                observer.OnCompleted();
                return Disposable.Empty;
            }));
        }
コード例 #14
0
    public override void OnStateEnter()
    {
        questionController.setCurrentQuestion();
        if (isGaelic)
        {
            questionText.text = questionController.getCurrentQuestion().text_gaelic;
            answersLeft.text  = "" + questionController.questionsLeftToAnswer() + " freagairtean ceart air fhàgail";
        }
        else
        {
            questionText.text = questionController.getCurrentQuestion().text_english;
            answersLeft.text  = "" + questionController.questionsLeftToAnswer() + " correct answers remaining!";
        }

        camera.transform.position = camera.getBasePosition();
        ZoomHelper.setUIVisibility(questionGroup, true);
        ZoomHelper.setUIVisibility(answersLeftGroup, true);
        ZoomHelper.setUIVisibility(player, false);
    }
コード例 #15
0
        public void ZoomIn(PointF mapPosition)
        {
            // When zooming in we want the mouse position to stay above the same world coordinate.
            // We do that in 3 steps.

            // 1) Temporarily center on where the mouse is
            Map.Viewport.Center = Map.Viewport.ScreenToWorld(mapPosition.X, mapPosition.Y);

            // 2) Then zoom
            Map.Viewport.Resolution = ZoomHelper.ZoomIn(_map.Resolutions, Map.Viewport.Resolution);

            // 3) Then move the temporary center back to the mouse position
            Map.Viewport.Center = Map.Viewport.ScreenToWorld(
                Map.Viewport.Width - mapPosition.X,
                Map.Viewport.Height - mapPosition.Y);

            ViewChanged(true);
            Invalidate();
        }
コード例 #16
0
        private void LoadModel(Tile tile, Model model, Func <Rule, IModelBuilder, IGameObject> func)
        {
            var zoomLevel = ZoomHelper.GetZoomLevel(tile.RenderMode);
            var rule      = _stylesheet.GetModelRule(model, zoomLevel);

            if (rule.IsApplicable && ShouldUseBuilder(tile, rule, model))
            {
                try
                {
                    foreach (var modelBuilder in rule.GetModelBuilders(_customizationService))
                    {
                        var gameObject = func(rule, modelBuilder);
                        AttachBehaviours(gameObject, rule, model);
                    }
                }
                catch (Exception ex)
                {
                    Trace.Error(LogCategory, ex, Strings.UnableToLoadModel, model.ToString());
                }
            }
        }
コード例 #17
0
        /// <inheritdoc />
        public IObservable <Unit> Load(Tile tile)
        {
            var boundingBox = tile.BoundingBox;
            var zoomLevel   = ZoomHelper.GetZoomLevel(tile.RenderMode);

            var filterElementVisitor = new CompositeElementVisitor(
                new NodeVisitor(tile, _modelLoader, _objectPool),
                new WayVisitor(tile, _modelLoader, _objectPool),
                new RelationVisitor(tile, _modelLoader, _objectPool));

            _elevationProvider.SetNullPoint(tile.RelativeNullPoint);

            // download elevation data if necessary
            if (!_elevationProvider.HasElevation(tile.BoundingBox))
            {
                _elevationProvider.Download(tile.BoundingBox).Wait();
            }

            // prepare tile
            tile.Accept(tile, _modelLoader);

            var subject = new Subject <Unit>();

            _elementSourceProvider
            .Get(tile.BoundingBox)
            .SelectMany(e => e.Get(boundingBox, zoomLevel))
            .ObserveOn(Scheduler.ThreadPool)
            .SubscribeOn(Scheduler.ThreadPool)
            .Subscribe(element => element.Accept(filterElementVisitor),
                       () =>
            {
                tile.Canvas.Accept(tile, _modelLoader);
                subject.OnCompleted();
            });

            return(subject);
        }
コード例 #18
0
        private void MapControlMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (!_viewportInitialized)
            {
                return;
            }
            if (ZoomLocked)
            {
                return;
            }

            _currentMousePosition = e.GetPosition(this);
            //Needed for both MouseMove and MouseWheel event for mousewheel event

            if (double.IsNaN(_toResolution))
            {
                _toResolution = Map.Viewport.Resolution;
            }

            if (e.Delta > Constants.Epsilon)
            {
                _toResolution = ZoomHelper.ZoomIn(_map.Resolutions, _toResolution);
            }
            else if (e.Delta < Constants.Epsilon)
            {
                _toResolution = ZoomHelper.ZoomOut(_map.Resolutions, _toResolution);
            }

            e.Handled = true; //so that the scroll event is not sent to the html page.

            // Some cheating for personal gain. This workaround could be ommitted if the zoom animations was on CenterX, CenterY and Resolution, not Resolution alone.
            Map.Viewport.Center.X += 0.000000001;
            Map.Viewport.Center.Y += 0.000000001;

            StartZoomAnimation(Map.Viewport.Resolution, _toResolution);
        }
コード例 #19
0
 /* Code happening on each frame -  handling case when player moves to quiz */
 public override void Tick()
 {
     if (qc.isQuizActive() && timer <= totalTime)
     {
         if (timer == 0f)
         {
             statusController.setCanDiscover(false);
             ZoomHelper.setUIVisibility(goingToQuizCanvas, true);
         }
         timer += Time.deltaTime;
         if (isGaelic)
         {
             goingToQuizText.text = "Ceistean ann an " + Math.Ceiling(totalTime - timer);
         }
         else
         {
             goingToQuizText.text = "Going to quiz in " + Math.Ceiling(totalTime - timer);
         }
     }
     else if (qc.isQuizActive() && timer > totalTime)
     {
         camera.SetState(new UnfocusingState(camera));
     }
 }
コード例 #20
0
        public double GetResolution(int delta, IViewport viewport, IMap map)
        {
            // If the animation has ended then start from the current resolution.
            // The alternative is that use the previous resolution target and add an extra
            // level to that.
            if (!IsAnimating())
            {
                _toResolution = viewport.Resolution;
            }

            if (delta > Constants.Epsilon)
            {
                _toResolution = ZoomHelper.ZoomIn(map.Resolutions, _toResolution);
            }
            else if (delta < Constants.Epsilon)
            {
                _toResolution = ZoomHelper.ZoomOut(map.Resolutions, _toResolution);
            }

            // TickCount is fast https://stackoverflow.com/a/4075602/85325
            _tickCount = Environment.TickCount;

            return(_toResolution);
        }
コード例 #21
0
        /// <summary>
        /// Zoom in to the next resolution
        /// </summary>
        /// <param name="duration">Duration for animation in milliseconds.</param>
        /// <param name="easing">The type of easing function used to transform from begin tot end state</param>
        public void ZoomIn(long duration = -1, Easing?easing = default)
        {
            var resolution = ZoomHelper.ZoomIn(_map.Resolutions, _viewport.Resolution);

            ZoomTo(resolution, duration, easing);
        }
コード例 #22
0
 public void ZoomIn()
 {
     Map.Viewport.Resolution = ZoomHelper.ZoomIn(_map.Resolutions, Map.Viewport.Resolution);
     ViewChanged(true);
     Invalidate();
 }
コード例 #23
0
ファイル: Navigator.cs プロジェクト: pranker/Mapsui
 public void ZoomOut()
 {
     _viewport.SetResolution(ZoomHelper.ZoomOut(_map.Resolutions, _viewport.Resolution));
     _map.RefreshData(_viewport.Extent, _viewport.Resolution, true);
 }
コード例 #24
0
ファイル: AnimatedNavigator.cs プロジェクト: zoomvr/Mapsui
        /// <summary>
        /// Zoom out to a given point
        /// </summary>
        /// <param name="centerOfZoom">Center to use for zoom out</param>
        public void ZoomOut(Point centerOfZoom)
        {
            var resolution = ZoomHelper.ZoomOut(_map.Resolutions, _viewport.Resolution);

            ZoomTo(resolution, centerOfZoom);
        }
コード例 #25
0
ファイル: AnimatedNavigator.cs プロジェクト: zoomvr/Mapsui
        /// <summary>
        /// Zoom out to the next resolution
        /// </summary>
        public void ZoomOut()
        {
            var resolution = ZoomHelper.ZoomOut(_map.Resolutions, _viewport.Resolution);

            ZoomTo(resolution);
        }
コード例 #26
0
ファイル: ZoomableImage.cs プロジェクト: ania1234/FencingEars
 void Awake()
 {
     dragThreshold = 0.0000004f * Screen.width;
     zoomHelper    = new ZoomHelper(image.rectTransform, new Vector2(imageCutRectTransform.rect.width, imageCutRectTransform.rect.height), new Vector2(2048, 2048), mainCamera, 0.00004f * Screen.width);
 }
コード例 #27
0
 public override void OnStateEnter()
 {
     ZoomHelper.setUIVisibility(infoBox, true);
     ZoomHelper.setUIVisibility(backButton, true);
 }
コード例 #28
0
 public override void OnStateExit()
 {
     ZoomHelper.setMarkerVisibility(true);
 }
コード例 #29
0
        /// <summary>
        /// Zoom out to a given point
        /// </summary>
        /// <param name="centerOfZoom">Center of zoom. This is the one point in the map that stays on the same location while zooming in.
        /// For instance, in mouse wheel zoom animation the position of the mouse pointer can be the center of zoom.</param>
        /// <param name="duration">Duration for animation in milliseconds.</param>
        /// <param name="easing">The type of easing function used to transform from begin tot end state</param>
        public void ZoomOut(MPoint centerOfZoom, long duration = -1, Easing?easing = default)
        {
            var resolution = ZoomHelper.ZoomOut(_map.Resolutions, _viewport.Resolution);

            ZoomTo(resolution, centerOfZoom, duration, easing);
        }
コード例 #30
0
 public void ZoomOut()
 {
     viewport.Resolution = ZoomHelper.ZoomOut(map.Resolutions, viewport.Resolution);
     ViewChanged(true);
     InvalidateMap(true);
 }