예제 #1
1
        public Grid GetNewGrid()
        {
            Grid grid = new Grid(_queryConfig);
            grid.ZoneId = ZoneId;
            grid.ZoneName = Zone;

            int max = 1;
            if (Grids.Count > 0)
            {
                max = Grids.Max(x => x.Id) + 1;
            }

            grid.Created();
            return grid;
        }
예제 #2
0
 public void ShowGrid(Grid grid)
 {
     if (grid == null)
     {
         //UpdateAll();
         return;
     }
     else
     {
         Model3DGroup group = Model as Model3DGroup;
         group.Children.Clear();
         CreateGrid(grid);
         _activeGrid = grid;
     }
 }
예제 #3
0
        private void Lookup()
        {
            var sql = String.Format(SelectString, SelectArgValues);
            var results = Database.QueryHelper.RunQuery(_connection, sql);
            var v = _queries.SelectQueryFields.FirstOrDefault(x => x.Property == "ZoneId");
            string zoneIdField = null;
            if (v != null)
            {
                zoneIdField = v.Column;
            }

            if (results != null)
            {
                foreach (var row in results)
                {
                    Grid g = new Grid(_queryConfig);
                    if (row.ContainsKey(zoneIdField) && results.First() == row)
                    {
                        ZoneId = Int32.Parse(row[zoneIdField].ToString());
                    }

                    g.SetProperties(Queries, row);
                    Grids.Add(g);
                    g.Created();
                }

                foreach (var grid in Grids)
                {
                    sql = String.Format(grid.SelectString, grid.SelectArgValues);
                    results = Database.QueryHelper.RunQuery(_connection, sql);
                    foreach (var row in results)
                    {
                        var wp = new Waypoint(_queryConfig);

                        wp.SetProperties(grid.Queries, row);

                        wp.GridReference = grid;
                        grid.Waypoints.Add(wp);
                        wp.Created();
                    }
                }
            }
        }
예제 #4
0
 public void RemoveGrid(Grid grid)
 {
     if (!Grids.Contains(grid)) return;
     RemoveObject(grid);
     grid.RemoveAllWaypoints();
     Grids.Remove(grid);
 }
예제 #5
0
        public string GetSQL(Grid grid)
        {
            List<Grid> g = new List<Grid>();
            g.Add(grid);

            return GetQuery(g);
        }
예제 #6
0
        public void AddGrid(Grid grid)
        {
            if (Grids.Contains(grid)) return;

            if (Grids.Count > 0)
            {
                int max = Grids.Max(x => x.Id);
                grid.Id = max + 1;
            }
            else
            {
                grid.Id = 1;
            }

            AddObject(grid);
            Grids.Add(grid);
        }
예제 #7
0
        private void CreateGrid(Grid grid)
        {
            Model3DGroup group = Model as Model3DGroup;

            Model3DCollection collection = new Model3DCollection();

            if (_mapping.ContainsKey(grid))
            {
                foreach (Model3D model in _mapping[grid])
                {
                    group.Children.Remove(model);
                }
            }

            foreach (Waypoint wp in grid.Waypoints)
            {
                MeshBuilder builder = new MeshBuilder();
                Point3D p = new Point3D(wp.X,wp.Y,wp.Z);

                if (Clipping != null && !Clipping.DrawPoint(p)) continue;
                builder.AddBox(p, 2, 2, 2);

                Transform3D headingRotate = new RotateTransform3D()
                {
                    CenterX = wp.X,
                    CenterY = wp.Y,
                    CenterZ = wp.Z,
                    Rotation = new AxisAngleRotation3D(
                        new Vector3D(0, 0, -1), wp.HeadingDegrees)
                };

                GeometryModel3D box;
                Material mat;

                if (wp.PauseTime > 0)
                {
                    mat = Materials.Red;
                }
                else
                {
                    mat = Materials.DarkGray;
                }

                box = new GeometryModel3D(builder.ToMesh(),mat);
                box.Transform = headingRotate;
                collection.Add(box);

                builder = new MeshBuilder();
                float radius = 3.0f;
                double hx = wp.X + Math.Cos( (wp.HeadingDegrees-90) / 180 * Math.PI ) * radius;
                double hy = wp.Y + Math.Sin( (wp.HeadingDegrees + 90) / 180 * Math.PI ) * radius;

                builder.AddArrow(new Point3D(wp.X, wp.Y, wp.Z),new Point3D(hx, hy, wp.Z), 0.5,1);
                collection.Add(new GeometryModel3D(builder.ToMesh(), mat));

                //box = new GeometryModel3D(builder.ToMesh(), mat);
                //collection.Add(box);

                if(wp.Name != null && !String.IsNullOrWhiteSpace(wp.Name) )
                {
                    GeometryModel3D text = TextCreator.CreateTextLabelModel3D(wp.Name, BrushHelper.CreateGrayBrush(50), true, 2, new Point3D(p.X, p.Y, p.Z + 5), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
                    text.Transform = new ScaleTransform3D(new Vector3D(-1, 1, 1), new Point3D(p.X, p.Y, p.Z));
                    collection.Add(text);
                }

                //GeometryModel3D text = TextCreator.CreateTextLabelModel3D(wp.GridId.ToString() + "G:" + wp.Number.ToString() + "N:" + wp.PauseTime.ToString() + "P", BrushHelper.CreateGrayBrush(5), true, 2,
                  //                                                          new Point3D(p.X, p.Y, p.Z + 5), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
                //text.Transform = new ScaleTransform3D(new Vector3D(-1, 1, 1), new Point3D(p.X, p.Y, p.Z));
                //collection.Add(text);

                builder = new MeshBuilder();

                if (grid.WanderType == Grid.WanderTypes.Patrol || grid.WanderType == Grid.WanderTypes.Circular)
                {
                    IEnumerable<Waypoint> nextWaypointQuery = grid.Waypoints.Where(
                        x => x.Number > wp.Number).OrderBy(y => y.Number);
                    if (nextWaypointQuery.Count() > 0)
                    {
                        Waypoint nextWaypoint = nextWaypointQuery.ElementAt(0);
                        builder.AddArrow(p, new Point3D(nextWaypoint.X, nextWaypoint.Y, nextWaypoint.Z), 0.5);

                        collection.Add(
                            new GeometryModel3D(builder.ToMesh(), Materials.White));
                    }
                }

                //collection.Add( new GeometryModel3D(builder.ToMesh(), Materials.
            }

            //collection.Add(new GeometryModel3D(builder.ToMesh(), Materials.White));

            _mapping[grid] = collection;
            foreach (Model3D model in collection)
            {
                group.Children.Add(model);
            }
        }