示例#1
0
 public void ClickPlot(int pixelX, int pixelY)
 {
     if (LocatorMode)
     {
         var result = LocatorResult.CreateClicked(pixelX, pixelY);
         _plotManager.EndLocatorMode(result);
     }
 }
示例#2
0
 public LocatorResult Next()
 {
     if (_index < _points.Length)
     {
         var res = LocatorResult.CreateClicked(_points[_index].X, _points[_index].Y);
         _index++;
         return(res);
     }
     return(LocatorResult.CreateNotClicked());
 }
示例#3
0
        public void ClickPlot(int pixelX, int pixelY)
        {
            _mainThread.Assert();

            if (LocatorMode)
            {
                var result = LocatorResult.CreateClicked(pixelX, pixelY);
                _plotManager.EndLocatorMode(_device, result);
            }
        }
        public void ClickPlot(int pixelX, int pixelY)
        {
            _shell.AssertIsOnMainThread();

            if (LocatorMode)
            {
                var result = LocatorResult.CreateClicked(pixelX, pixelY);
                EndLocatorMode(result);
            }
        }
示例#5
0
        private void RootContainer_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (_locatorTcs != null)
            {
                var rootContainer = (FrameworkElement)sender;
                var pos           = e.GetPosition(rootContainer);
                var pixelSize     = WpfUnitsConversion.ToPixels(rootContainer as Visual, pos);

                var result = LocatorResult.CreateClicked((int)pixelSize.X, (int)pixelSize.Y);
                EndLocatorMode(result);
            }
        }
示例#6
0
        public async Task LocatorCommand()
        {
            _plotDeviceVisualComponentContainerFactory.DeviceProperties = new PlotDeviceProperties(360, 360, 96);

            await InitializeGraphicsDevice();

            await ExecuteAndWaitForPlotsAsync(new[] {
                "plot(0:10)",
            });

            var device = _plotManager.ActiveDevice;

            device.Should().NotBeNull();

            var deviceVC       = _plotManager.GetPlotVisualComponent(device);
            var deviceCommands = new RPlotDeviceCommands(_workflow, deviceVC);

            device.LocatorMode.Should().BeFalse();

            deviceCommands.EndLocator.Should().BeInvisibleAndDisabled();

            var firstLocatorModeTask = EventTaskSources.IRPlotDevice.LocatorModeChanged.Create(device);
            var locatorTask          = ExecuteAndDoNotWaitForPlotsAsync(new[] {
                "res <- locator()",
            });
            await firstLocatorModeTask;

            var points = new Point[] {
                new Point(10, 10),
                new Point(100, 50),
                new Point(290, 90),
            };

            // R's high-level locator() function enters a loop that calls into
            // the graphics device low-level locator() API, which calls back into VS
            // to set locator mode and waits for either:
            // - a result with a click point
            // - a not clicked result
            // The high-level locator() function stops its loop when it gets
            // the not clicked result.
            foreach (var point in points)
            {
                device.LocatorMode.Should().BeTrue();
                deviceCommands.EndLocator.Should().BeEnabled();

                // Send a result with a click point, which will causes
                // locator mode to end and immediately start again
                var locatorModeTask = EventTaskSources.IRPlotDevice.LocatorModeChanged.Create(device);
                _plotManager.EndLocatorMode(device, LocatorResult.CreateClicked((int)point.X, (int)point.Y));
                await locatorModeTask;

                device.LocatorMode.Should().BeFalse();
                deviceCommands.EndLocator.Should().BeInvisibleAndDisabled();

                locatorModeTask = EventTaskSources.IRPlotDevice.LocatorModeChanged.Create(device);
                await locatorModeTask;
            }

            // Send a result with a not clicked result, which causes
            // locator mode to end, and the high-level locator() function
            // call will return.
            var lastLocatorModeTask = EventTaskSources.IRPlotDevice.LocatorModeChanged.Create(device);
            await deviceCommands.EndLocator.InvokeAsync();

            await lastLocatorModeTask;

            device.LocatorMode.Should().BeFalse();
            deviceCommands.EndLocator.Should().BeInvisibleAndDisabled();

            string outputFilePath = _testFiles.GetDestinationPath("LocatorResult.csv");

            await ExecuteAndDoNotWaitForPlotsAsync(new[] {
                $"write.csv(res, {outputFilePath.ToRPath().ToRStringLiteral()})"
            });

            var x = new double[] { -2.48008095952895, 1.55378525638498, 10.0697250455366 };
            var y = new double[] { 14.4476461865435, 12.091623959219, 9.73560173189449 };

            CheckLocatorResult(outputFilePath, x, y);

            await locatorTask;
        }