예제 #1
0
        public SimulationVisualWaypoint3D(IWaypointInfo waypoint, DetailLevel detailLevel)
            : base(waypoint)
        {
            _waypoint = waypoint;
            var visual = new SphereVisual3D
            {
                Fill   = VisualizationConstants.BrushWaypointVisual,
                Center = new Point3D(waypoint.GetInfoCenterX(), waypoint.GetInfoCenterY(), waypoint.GetInfoCurrentTier().GetInfoZ() + WAYPOINT_LIFT),
                Radius = waypoint.GetInfoLength() / 2.0
            };

            Children.Add(visual);
            // Add connections to other ones (if detailed drawing mode)
            //foreach (var otherWP in waypoint.GetInfoConnectedWaypoints())
            //{
            //    // TODO draw connection to other wp
            //}
        }
예제 #2
0
        public SimulationVisualElevatorEntrance3D(IWaypointInfo elevator, DetailLevel detailLevel)
            : base(elevator)
        {
            _elevator = elevator;
            var visual = new BoxVisual3D
            {
                Fill   = VisualizationConstants.BrushElevatorEntranceVisual,
                Center = new Point3D(
                    _elevator.GetInfoCurrentTier().GetInfoTLX() + _elevator.GetInfoCenterX(),
                    _elevator.GetInfoCurrentTier().GetInfoTLY() + _elevator.GetInfoCenterY(),
                    _elevator.GetInfoCurrentTier().GetInfoZ() + ELEVATOR_HEIGHT / 2.0
                    ),
                Length = _elevator.GetInfoLength() * SIZE_FACTOR,
                Width  = _elevator.GetInfoWidth() * SIZE_FACTOR,
                Height = ELEVATOR_HEIGHT
            };

            Children.Add(visual);
        }
예제 #3
0
        public void Update()
        {
            // Update color
            Brush currentColor = _animationController.GetBotColor(_bot, _bot.GetInfoState());

            if (currentColor != Stroke)
            {
                Stroke = currentColor;
            }
            // Draw current goal of the bot
            _geometry.StartPoint = new Point(_transformer.ProjectX(_bot.GetInfoCenterX()), _transformer.ProjectY(_bot.GetInfoCenterY()));
            IWaypointInfo destination = _bot.GetInfoDestinationWaypoint();

            if (destination != null)
            {
                _geometry.EndPoint = new Point(_transformer.ProjectX(destination.GetInfoCenterX()), _transformer.ProjectY(destination.GetInfoCenterY()));
            }
            else
            {
                _geometry.EndPoint = new Point(_transformer.ProjectX(_bot.GetInfoCenterX()), _transformer.ProjectY(_bot.GetInfoCenterY()));
            }
        }
예제 #4
0
        public void Update()
        {
            // Get path
            List <IWaypointInfo> _botPath            = _bot.GetInfoPath();
            IWaypointInfo        _botCurrentWaypoint = _bot.GetInfoCurrentWaypoint();
            string state = _bot.GetInfoState();
            // Update color
            Brush currentColor = _animationController.GetBotColor(_bot, state);

            if (currentColor != Stroke)
            {
                Stroke = currentColor;
            }
            // If we do not have a path, cleanup and quit
            if (_botPath == null || !_botPath.Any() || state != "Move")
            {
                if (_geometry.Children.Count > 0)
                {
                    _geometry.Children.Clear();
                }
                return;
            }
            // If the path changed, update it
            if (_currentPath != _botPath)
            {
                // Store it
                _currentPath = _remainingPath = _botPath;
                // Remove old path
                _geometry.Children.Clear();
                // Add all connections
                IWaypointInfo previousNode = null;
                foreach (var currentNode in _currentPath)
                {
                    // Check whether it's the first node of the path
                    if (previousNode == null)
                    {
                        // Only store first node
                        previousNode = currentNode;
                    }
                    else
                    {
                        // Draw path
                        _geometry.Children.Add(
                            new LineGeometry(
                                // From start
                                new Point(_transformer.ProjectX(previousNode.GetInfoCenterX()), _transformer.ProjectY(previousNode.GetInfoCenterY())),
                                // To destination
                                new Point(_transformer.ProjectX(currentNode.GetInfoCenterX()), _transformer.ProjectY(currentNode.GetInfoCenterY()))));
                        // Update previous node
                        previousNode = currentNode;
                    }
                }
            }
        }
예제 #5
0
        public SimulationVisualElevatorEntrance2D(
            IWaypointInfo waypoint,
            DetailLevel detailLevel,
            Transformation2D transformer,
            double strokeThickness,
            MouseButtonEventHandler elementClickAction,
            SimulationAnimation2D controller)
            : base(waypoint, detailLevel, transformer, strokeThickness, elementClickAction, controller)
        {
            _waypoint = waypoint;
            // Create waypoint dot
            EllipseGeometry ellipse =
                new EllipseGeometry(
                    new Point(_transformer.ProjectX(waypoint.GetInfoCenterX()), _transformer.ProjectY(waypoint.GetInfoCenterY())),
                    _transformer.ProjectXLength(waypoint.GetInfoLength() / 2.0 * SIZE_FACTOR), _transformer.ProjectYLength(waypoint.GetInfoLength() / 2.0 * SIZE_FACTOR));

            _geometry.Children.Add(ellipse);
            // Paint it
            Fill            = VisualizationConstants.BrushElevatorEntranceVisual;
            Cursor          = System.Windows.Input.Cursors.Hand;
            MouseDown      += _elementClickAction;
            Stroke          = VisualizationConstants.BrushOutline;
            StrokeThickness = StrokeThicknessReference;
        }
예제 #6
0
        public SimulationVisualWaypoint2D(
            IWaypointInfo waypoint,
            DetailLevel detailLevel,
            Transformation2D transformer,
            double strokeThickness,
            MouseButtonEventHandler elementClickAction,
            SimulationAnimation2D controller)
            : base(waypoint, detailLevel, transformer, strokeThickness, elementClickAction, controller)
        {
            _waypoint = waypoint;
            // Create waypoint dot
            EllipseGeometry ellipse =
                new EllipseGeometry(
                    new Point(_transformer.ProjectX(waypoint.GetInfoCenterX()), _transformer.ProjectY(waypoint.GetInfoCenterY())),
                    _transformer.ProjectXLength(waypoint.GetInfoLength() / 2.0), _transformer.ProjectYLength(waypoint.GetInfoLength() / 2.0));

            _geometry.Children.Add(ellipse);
            // Add connections
            foreach (var otherWP in waypoint.GetInfoConnectedWaypoints())
            {
                Point  start  = new Point(_transformer.ProjectX(waypoint.GetInfoCenterX()), _transformer.ProjectY(waypoint.GetInfoCenterY()));
                Point  end    = new Point(_transformer.ProjectX(otherWP.GetInfoCenterX()), _transformer.ProjectY(otherWP.GetInfoCenterY()));
                double length = ArrowLineGeometryGenerator.GetDistanceBetweenPoints(start, end);
                var    geom   = ArrowLineGeometryGenerator.GenerateArrowGeometry(ArrowEnds.End, start, end, 45, 0.2 * length);
                _geometry.Children.Add(geom);
            }
            // Paint it
            Fill            = VisualizationConstants.BrushWaypointVisual;
            Cursor          = System.Windows.Input.Cursors.Hand;
            MouseDown      += _elementClickAction;
            Stroke          = VisualizationConstants.BrushOutline;
            StrokeThickness = StrokeThicknessReference;
        }