/// <summary> /// Loads the next field into view. Centers it and waits for click. /// Also readjusts text at top. /// </summary> /// <param name="f">Field to display</param> /// <param name="n">Current subfields number</param> /// <param name="total">Total number of subFields</param> private void LoadNext() { reset(); Number_Label.Text = "Define central free point in " + f.name + ": " + count + "/" + fields.Count; List<Polygon> shape = new List<Polygon>(); shape.Add(f.shape); fieldsRend.Polygons = shape; List<Polygon> comp = new List<Polygon>(); foreach (List<Polygon> p in f.walls.Values) { comp.AddRange(p); } wallsRend.Polygons = comp; comp = new List<Polygon>(); foreach (List<Polygon> p in f.objects.Values) { comp.AddRange(p); } objectsRend.Polygons = comp; comp = new List<Polygon>(); foreach (List<Polygon> p in f.regions.Values) { comp.AddRange(p); } regionsRend.Polygons = comp; PoseYPR point = new PoseYPR(f.shape.Center.X, f.shape.Center.Y, rend.CamOrtho.CameraPosition.z, rend.CamOrtho.CameraPosition.yaw, rend.CamOrtho.CameraPosition.pitch, rend.CamOrtho.CameraPosition.roll); rend.CamOrtho.CameraPosition = point; }
/// <summary> /// Opens metric map, fills mainField, and renders all Polygons /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void metricMapToolStripMenuItem_Click(object sender, EventArgs e) { this.openFileDialog1.Multiselect = true; this.openFileDialog1.Filter = "Xml File | *.xml"; DialogResult result = this.openFileDialog1.ShowDialog(); int sameTracker = subFields.Count; if (result == DialogResult.OK) { foreach (String path in openFileDialog1.FileNames) { try { Field f = Field.FromFile(path); if (subFields.Keys.Contains<string>(f.name)) { Error err = new Error(errorTypes.MultiName); err.ShowDialog(); err.Dispose(); return; } shift = false; //Shift shifter = new Shift(path, rend); //shifter.ShowDialog(); //if (shifter.shift) //{ // shift = true; //} ////shifter.Dispose(); if (!shift) { subFields.Add(f.name, f.shape); Fields_Box.Items.Add(f.name); foreach (KeyValuePair<string, List<Polygon>> w in f.walls) { mainField.walls.Add(w.Key, w.Value); Walls_Box.Items.Add(w.Key); } foreach (KeyValuePair<string, List<Polygon>> o in f.objects) { mainField.objects.Add(o.Key, o.Value); Objects_Box.Items.Add(o.Key); } foreach (KeyValuePair<string, List<Polygon>> r in f.regions) { mainField.regions.Add(r.Key, r.Value); Regions_Box.Items.Add(r.Key); } fieldsRend.Polygons = subFields.Values.ToList<Polygon>(); List<Polygon> comp = new List<Polygon>(); foreach (List<Polygon> p in mainField.walls.Values) { comp.AddRange(p); } wallsRend.Polygons = comp; comp = new List<Polygon>(); foreach (List<Polygon> p in mainField.objects.Values) { comp.AddRange(p); } objectsRend.Polygons = comp; comp = new List<Polygon>(); foreach (List<Polygon> p in mainField.regions.Values) { comp.AddRange(p); } regionsRend.Polygons = comp; } } catch (InvalidOperationException) { Error open = new Error(errorTypes.OpenFail, path); open.ShowDialog(); open.Dispose(); } } } if (subFields.Count != sameTracker) { Vector2 centerP = new Vector2(0, 0); foreach (Polygon shape in subFields.Values) { centerP += shape.Center; } centerP /= subFields.Count; PoseYPR point = new PoseYPR(centerP.X, centerP.Y, rend.CamOrtho.CameraPosition.z, rend.CamOrtho.CameraPosition.yaw, rend.CamOrtho.CameraPosition.pitch, rend.CamOrtho.CameraPosition.roll); rend.CamOrtho.CameraPosition = point; } }