public Segment(RecordData p1, RecordData p2) { P1 = p1; P2 = p2; AltitudeMin = Math.Min(P1.Z, P2.Z); AltitudeMax = Math.Max(P1.Z, P2.Z); AltitudeMoyenne = (P1.Z + P2.Z) / 2; AllSegments.Add(this); }
private Color GetColor(RecordData record) { if (record.Z < -0.3) { return(Color.FromArgb(alpha, 50, 233, 0)); } if (record.Z > 0.1) { return(Color.FromArgb(alpha, 0, 6, 255)); } float delta = (record.Z + (float)0.30) / (float)0.40; float r = (((float)50 / 255) * (1 - delta) + ((float)0 / 255) * delta) * 255; float g = (((float)233 / 255) * (1 - delta) + ((float)6 / 255) * delta) * 255; float b = (((float)0 / 255) * (1 - delta) + ((float)255 / 255) * delta) * 255; if (r > 255) { r = 255; } if (g > 255) { g = 255; } if (b > 255) { b = 255; } if (r < 0) { r = 0; } if (g < 0) { g = 0; } if (b < 0) { b = 0; } return(Color.FromArgb(alpha, (int)r, (int)g, (int)b)); }
private void Form1_Load(object sender, EventArgs e) { RangeSliger.RangeChangedEvent += ValueChanged; //Trackbars AlphaTrackBar.Minimum = 0; AlphaTrackBar.Maximum = 255; AlphaTrackBar.Value = 125; alpha = AlphaTrackBar.Value; RotateTrackBar.Minimum = 0; RotateTrackBar.Maximum = 90; RotateTrackBar.Value = 0; //lecture des trajectoires //#ID;time;x;y;z;name;ID char[] sep = new char[] { ';' }; using (StreamReader sc = new StreamReader(filename)) { string line = ""; line = sc.ReadLine(); while ((line = sc.ReadLine()) != null) { var items = line.Split(sep[0]); if (items.Length == 7) { int index = 0; var rec = new RecordData( int.Parse(items[index++]), DateTime.ParseExact(items[index++].Substring(0, 8), "HH:mm:ssssss", CultureInfo.InvariantCulture), float.Parse(items[index++], CultureInfo.InvariantCulture), float.Parse(items[index++], CultureInfo.InvariantCulture), float.Parse(items[index++], CultureInfo.InvariantCulture) ); if (!dic.ContainsKey(rec.ID)) { dic.Add(rec.ID, new List <RecordData>()); } dic[rec.ID].Add(rec); } } bool first; RecordData previousPoint; RecordData newPoint = new RecordData(); foreach (var item in dic) { first = true; foreach (var record in item.Value) { record.X = (float)GenericScaleDouble(record.X, RecordData.MaxRecord.X, 1, RecordData.MinRecord.X, -1); record.Y = (float)GenericScaleDouble(record.Y, RecordData.MaxRecord.Y, 1, RecordData.MinRecord.Y, -1); record.Z = (float)GenericScaleDouble(record.Z, RecordData.MaxRecord.Z, 1, RecordData.MinRecord.Z, -1); record.NormalizedID = (float)GenericScaleDouble(record.ID, RecordData.MaxRecord.ID, 1, RecordData.MinRecord.ID, -1); record.NormalizedDate = (float)GenericScaleDouble(record.Date.Ticks, RecordData.MaxRecord.Date.Ticks, 1, RecordData.MinRecord.Date.Ticks, -1); if (first) { newPoint = record; first = false; } else { previousPoint = newPoint; newPoint = record; new Segment(previousPoint, newPoint); } } } Segment.AllSegments.Sort(); } InitOpenTK(); }