protected override bool PrepVertexBuffer(RenderContext renderContext, float opacity) { table.Lock(); if (lineList != null) { lineList.Clear(); } if (lineList2d != null) { lineList2d.Clear(); } if (triangleList != null) { triangleList.Clear(); } if (pointList != null) { pointList.Clear(); } if (triangleList2d != null) { triangleList2d.Clear(); } if (lineList == null) { lineList = new LineList(); } if (pointList == null) { pointList = new PointList(renderContext); } lineList.TimeSeries = this.timeSeries; if (lineList2d == null) { lineList2d = new LineList(); lineList2d.DepthBuffered = false; } lineList.TimeSeries = this.timeSeries; if (triangleList == null) { triangleList = new TriangleList(); } if (triangleList2d == null) { triangleList2d = new TriangleList(); triangleList2d.DepthBuffered = false; } positions.Clear(); UInt32 currentIndex = 0; // device.RenderState.FillMode = FillMode.WireFrame; Color colorLocal = Color; // colorLocal.A = (byte)(Color.A * Opacity); // for space 3d double ecliptic = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI; Dictionary <string, bool> selectDomain = new Dictionary <string, bool>(); double mr = 0; // double mr = LayerManager.AllMaps[ReferenceFrame].Frame.MeanRadius; if (mr != 0) { meanRadius = mr; } Vector3d position = new Vector3d(); float pointSize = .0002f; Color pointColor = Colors.White; float pointStartTime = 0; float pointEndTime = 0; foreach (string[] row in table.Rows) { try { bool selected = false; if (geometryColumn > -1 || (this.CoordinatesType == CoordinatesTypes.Spherical && (lngColumn > -1 && latColumn > -1)) || ((this.CoordinatesType == CoordinatesTypes.Rectangular) && (XAxisColumn > -1 && YAxisColumn > -1))) { double Xcoord = 0; double Ycoord = 0; double Zcoord = 0; double alt = 1; double altitude = 0; double distParces = 0; double factor = GetScaleFactor(AltUnit, 1); if (altColumn == -1 || AltType == AltTypes.SeaLevel || bufferIsFlat) { alt = 1; if (astronomical & !bufferIsFlat) { alt = UiTools.AuPerLightYear * 100; } } else { if (AltType == AltTypes.Depth) { factor = -factor; } alt = 0; try { alt = double.Parse(row[altColumn]); } catch { } if (astronomical) { factor = factor / (1000 * UiTools.KilometersPerAu); distParces = (alt * factor) / UiTools.AuPerParsec; altitude = (factor * alt); alt = (factor * alt); } else if (AltType == AltTypes.Distance) { altitude = (factor * alt); alt = (factor * alt / meanRadius); } else { altitude = (factor * alt); alt = 1 + (factor * alt / meanRadius); } } //todo remove hack when alt is fixed //alt = 1; if (CoordinatesType == CoordinatesTypes.Spherical && lngColumn > -1 && latColumn > -1) { //Xcoord = Coordinates.Parse(row[lngColumn]); //Ycoord = Coordinates.Parse(row[latColumn]); Xcoord = double.Parse(row[lngColumn]); Ycoord = double.Parse(row[latColumn]); if (astronomical) { if (RaUnits == RAUnits.Hours) { Xcoord *= 015; } if (bufferIsFlat) { // Xcoord += 180; } } double offset = 0; //todo EGM96Geoid.Height(Ycoord, Xcoord); // if (altitude != 0) { //altitude += offset; //alt += offset / meanRadius; } Vector3d pos = Coordinates.GeoTo3dDoubleRad(Ycoord, Xcoord, alt); if (astronomical && !bufferIsFlat) { pos.RotateX(ecliptic); } position = pos; positions.Add(position); } else if (this.CoordinatesType == CoordinatesTypes.Rectangular) { double xyzScale = GetScaleFactor(CartesianScale, CartesianCustomScale) / meanRadius; if (ZAxisColumn > -1) { Zcoord = double.Parse(row[ZAxisColumn]); } Xcoord = double.Parse(row[XAxisColumn]); Ycoord = double.Parse(row[YAxisColumn]); if (XAxisReverse) { Xcoord = -Xcoord; } if (YAxisReverse) { Ycoord = -Ycoord; } if (ZAxisReverse) { Zcoord = -Zcoord; } position = Vector3d.Create((Xcoord * xyzScale), (Zcoord * xyzScale), (Ycoord * xyzScale)); positions.Add(position); } // SqlGeometry pntGeo = SqlGeometry.Point(Xcoord,Ycoord, 4326); //// SqlGeometry pntGeo = SqlGeometry.Point(new SqlChars(String.Format("Point ({0} {1})", Xcoord,Ycoord).ToCharArray()), 4326); // if (!geo.STContains(pntGeo)) // { // continue; // } switch (ColorMap) { case ColorMaps.Same_For_All: pointColor = colorLocal; break; case ColorMaps.Per_Column_Literal: if (ColorMapColumn > -1) { pointColor = ParseColor(row[ColorMapColumn], colorLocal); } else { pointColor = colorLocal; } break; //case ColorMaps.Group_by_Range: // break; //case ColorMaps.Gradients_by_Range: // break; //case ColorMaps.Group_by_Values: // pointColor = ColorDomainValues[row[ColorMapColumn]].MarkerIndex; // break; default: break; } if (sizeColumn > -1) { switch (pointScaleType) { case PointScaleTypes.Linear: pointSize = Single.Parse(row[sizeColumn]); break; case PointScaleTypes.Log: pointSize = (float)Math.Log(Single.Parse(row[sizeColumn])); break; case PointScaleTypes.Power: { double size = 0; try { pointSize = (float)double.Parse(row[altColumn]); } catch { pointSize = 0; } } break; case PointScaleTypes.StellarMagnitude: { double size = 0; try { size = double.Parse(row[sizeColumn]); if (!bufferIsFlat) { size = size - 5 * ((Util.LogN(distParces, 10) - 1)); pointSize = (float)(120000000 / Math.Pow(1.6, size)); } else { pointSize = (float)(40 / Math.Pow(1.6, size)); } } catch { pointSize = 0; } } break; case PointScaleTypes.Constant: pointSize = 1; break; default: break; } } else { pointSize = (float)1; } if (PlotType == PlotTypes.Point) { pointSize = (float)1; } if (astronomical & !bufferIsFlat) { // lastItem.PointSize *= 1000000000000000000000000000f; } if (startDateColumn > -1) { Date dateTime = new Date(row[startDateColumn]); pointStartTime = (float)(SpaceTimeController.UtcToJulian(dateTime) - SpaceTimeController.UtcToJulian(baseDate)); if (endDateColumn > -1) { dateTime = new Date(row[endDateColumn]); //dateTime = DateTime.Parse(row[endDateColumn]); pointEndTime = (float)(SpaceTimeController.UtcToJulian(dateTime) - SpaceTimeController.UtcToJulian(baseDate)); } else { pointEndTime = pointStartTime; } } pointList.AddPoint(position, pointColor, new Dates(pointStartTime, pointEndTime), pointSize); if (geometryColumn > -1) { ParseGeometry(row[geometryColumn], pointColor, pointColor, altitude, new Dates(pointStartTime, pointEndTime)); } //if (barChartBitmask != 0) //{ // MakeBarChart(device, row, Ycoord, Xcoord, pointSize, factor, Color.FromArgb(lastItem.Color), selected, new Dates(pointStartTime, pointEndTime)); //} currentIndex++; } } catch { } lines = false; } table.Unlock(); dataDirty = false; dirty = false; return(false); }