Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SLAM.MapView"/> class.
        /// </summary>
        /// <param name="mapModel">Map model.</param>
        public MapView(SlamMap mapModel)
        {
            this.mapModel = mapModel;
            robotView = new RobotView (mapModel.Robot);
            landmarkView = new LandmarkView (mapModel.Landmarks);
            pathView = new PathView (mapModel.Robot);

            // Subscribe to events.
            mapModel.MapUpdated += new EventHandler<MapUpdateEventArgs> (Map_Update);
            robotView.Robot.RobotUpdated += new EventHandler<RobotUpdateEventArgs> (Robot_Update);
            ExposeEvent += OnExpose;

            // Map width and height is specified in meters, and we are using
            // 1 pixel to every centimeter, so scale up by 100.
            viewWidth = (int)(mapModel.Width * 100);
            viewHeight = (int)(mapModel.Height * 100);
            cellWidth = (int)(mapModel.CellSize * 100);
            cellHeight = (int)(mapModel.CellSize * 100);
            centerX = (int)(viewWidth / 2);
            centerY = (int)(viewHeight / 2);

            SetSizeRequest (viewWidth, viewHeight);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SLAM.MapView"/> class.
        /// </summary>
        /// <param name="mapModel">Map model.</param>
        public MapView(SlamMap mapModel)
        {
            this.mapModel = mapModel;
            robotView     = new RobotView(mapModel.Robot);
            landmarkView  = new LandmarkView(mapModel.Landmarks);
            pathView      = new PathView(mapModel.Robot);

            // Subscribe to events.
            mapModel.MapUpdated          += new EventHandler <MapUpdateEventArgs> (Map_Update);
            robotView.Robot.RobotUpdated += new EventHandler <RobotUpdateEventArgs> (Robot_Update);
            ExposeEvent += OnExpose;

            // Map width and height is specified in meters, and we are using
            // 1 pixel to every centimeter, so scale up by 100.
            viewWidth  = (int)(mapModel.Width * 100);
            viewHeight = (int)(mapModel.Height * 100);
            cellWidth  = (int)(mapModel.CellSize * 100);
            cellHeight = (int)(mapModel.CellSize * 100);
            centerX    = (int)(viewWidth / 2);
            centerY    = (int)(viewHeight / 2);

            SetSizeRequest(viewWidth, viewHeight);
        }