Example #1
0
        public override void CleanUp()
        {
            CleanAndReady = false;

            if (shapeFileIndex != null)
            {
                shapeFileIndex.Dispose();
                GC.SuppressFinalize(shapeFileIndex);
                shapeFileIndex = null;
            }
            if (shapeFileVertex != null)
            {
                shapeFileVertex.Dispose();
                GC.SuppressFinalize(shapeFileVertex);

                shapeFileVertex = null;
            }


            if (lineList != null)
            {
                lineList.Clear();
            }
            if (lineList2d != null)
            {
                lineList2d.Clear();
            }

            if (triangleList2d != null)
            {
                triangleList2d.Clear();
            }

            if (triangleList != null)
            {
                triangleList.Clear();
            }
            if (textBatch != null)
            {
                textBatch.CleanUp();
            }
        }
        protected override bool PrepVertexBuffer(float opacity)
        {
            var col = table.GetColumnByUcd("meta.id");
            if (col == null)
            {
                col = table.Column[0];
            }

            if (shapeFileVertex == null)
            {
                var siapSet = IsSiapResultSet();

                if (lineList2d == null)
                {
                    lineList2d = new LineList();
                }
                lineList2d.Clear();

                var stcsCol = table.GetColumnByUcd("phys.area;obs.field");

                if (stcsCol == null && table.Columns.ContainsKey("regionSTCS"))
                {
                    stcsCol = table.Columns["regionSTCS"];
                }

                if (PlotType == PlotTypes.Gaussian)
                {
                    MarkerScale = MarkerScales.World;
                }
                else
                {
                    MarkerScale = MarkerScales.Screen;
                }

                var vertList = new List<TimeSeriesPointVertex>();
                var indexList = new List<UInt32>();
                var lastItem = new TimeSeriesPointVertex();
                positions.Clear();
                UInt32 currentIndex = 0;
                var color = Color.FromArgb((int)(opacity * Color.A), Color);

                pointScaleType = PointScaleTypes.StellarMagnitude;

                foreach (var row in table.Rows)
                {
                    try
                    {
                        if (lngColumn > -1 && latColumn > -1)
                        {
                            var Xcoord = Coordinates.ParseRA(row[LngColumn].ToString(), true) * 15 + 180;
                            var Ycoord = Coordinates.ParseDec(row[LatColumn].ToString());
                            lastItem.Position = Coordinates.GeoTo3dDouble(Ycoord, Xcoord).Vector311;
                            positions.Add(lastItem.Position);
                            lastItem.Color = color;
                            if (sizeColumn > -1)
                            {

                                try
                                {
                                    if (MarkerScale == MarkerScales.Screen)
                                    {
                                        lastItem.PointSize = 20f;
                                    }
                                    else
                                    {
                                        switch (pointScaleType)
                                        {
                                            case PointScaleTypes.Linear:
                                                lastItem.PointSize = Convert.ToSingle(row[sizeColumn]);
                                                break;
                                            case PointScaleTypes.Log:
                                                lastItem.PointSize = (float)Math.Log(Convert.ToSingle(row[sizeColumn]));
                                                break;
                                            case PointScaleTypes.Power:
                                                lastItem.PointSize = (float)Math.Pow(2, Convert.ToSingle(row[sizeColumn]));
                                                break;
                                            case PointScaleTypes.StellarMagnitude:
                                                {
                                                    double size = Convert.ToSingle(row[sizeColumn]);
                                                    lastItem.PointSize = (float)(40 / Math.Pow(1.6, size)) * 10;
                                                }
                                                break;
                                            case PointScaleTypes.Constant:
                                                lastItem.PointSize = 1;
                                                break;
                                            default:
                                                break;
                                        }
                                    }
                                }
                                catch
                                {
                                    lastItem.PointSize = .01f;
                                }
                            }
                            else
                            {
                                if (MarkerScale == MarkerScales.Screen)
                                {
                                    lastItem.PointSize = 20;
                                }
                                else
                                {
                                    lastItem.PointSize = (float)Math.Pow(2, 1) * 100;
                                }
                            }

                            if (startDateColumn > -1)
                            {
                                var dateTime = DateTime.Parse(row[startDateColumn].ToString());
                                lastItem.Tu = (float)SpaceTimeController.UtcToJulian(dateTime);
                                lastItem.Tv = 0;
                            }

                            vertList.Add(lastItem);
                            currentIndex++;
                        }

                        if (siapSet && stcsCol!= null)
                        {
                            AddSiapStcRow(stcsCol.Name, row, row == table.SelectedRow);
                        }
                    }

                    catch
                    {
                    }
                    lines = false;
                }

                if (siapSet && stcsCol != null)
                {
                    AddSiapStcRow(stcsCol.Name, table.SelectedRow, true);
                }

                shapeVertexCount = vertList.Count;
                if (shapeVertexCount == 0)
                {
                    shapeVertexCount = 1;
                }
                shapeFileVertex = new TimeSeriesPointSpriteSet(RenderContext11.PrepDevice, vertList.ToArray());
            }
            return true;
        }
        public override void CleanUp()
        {
            CleanAndReady = false;

            if (shapeFileIndex != null)
            {
                shapeFileIndex.Dispose();
                GC.SuppressFinalize(shapeFileIndex);
                shapeFileIndex = null;
            }
            if (shapeFileVertex != null)
            {
                shapeFileVertex.Dispose();
                GC.SuppressFinalize(shapeFileVertex);

                shapeFileVertex = null;
            }

            if (lineList != null)
            {
                lineList.Clear();
            }
            if (lineList2d != null)
            {
                lineList2d.Clear();
            }

            if (triangleList2d != null)
            {
                triangleList2d.Clear();
            }

            if (triangleList != null)
            {
                triangleList.Clear();
            }
            if (textBatch != null)
            {
                textBatch.CleanUp();
            }
        }
        protected override bool PrepVertexBuffer(float opacity)
        {
            table.Lock();

            CleanAndReady = true;

            if (lineList != null)
            {
                lineList.Clear();
            }

            if (lineList2d != null)
            {
                lineList2d.Clear();
            }
            if (triangleList != null)
            {
                triangleList.Clear();
            }

            if (triangleList2d != null)
            {
                triangleList2d.Clear();
            }

            if (textBatch != null)
            {
                textBatch.CleanUp();
            }

            if (lineList == null)
            {
                lineList = new LineList();
            }

            lineList.TimeSeries = timeSeries;

            if (lineList2d == null)
            {
                lineList2d = new LineList();
                lineList2d.DepthBuffered = false;

            }

            lineList.TimeSeries = timeSeries;

            if (triangleList == null)
            {
                triangleList = new TriangleList();
            }

            if (triangleList2d == null)
            {
                triangleList2d = new TriangleList();
                triangleList2d.DepthBuffered = false;
            }

            var vertList = new List<TimeSeriesPointVertex>();
            var indexList = new List<UInt32>();
            var lastItem = new TimeSeriesPointVertex();
            positions.Clear();
            UInt32 currentIndex = 0;

            var color = Color.FromArgb((int)Color.A, Color);

            // for space 3d
            ecliptic = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI;

            var baseDate = new DateTime(2010,1,1,12,00,00);

            foreach (var fgt in Filters)
            {
                var filter = fgt.Stats;
                filter.SelectDomain.Clear();
                if (filter.Computed)
                {
                    if (filter.DomainColumn > -1)
                    {
                        var i = 0;
                        foreach (var domainValue in filter.DomainValues)
                        {
                            if (filter.Selected[i])
                            {
                                filter.SelectDomain.Add(domainValue, filter.Selected[i]);
                            }
                            i++;
                        }
                    }
                }
            }

            var mr = LayerManager.AllMaps[ReferenceFrame].Frame.MeanRadius;
            if (mr != 0)
            {
                meanRadius = mr;
            }

            foreach (var row in table.Rows)
            {
                try
                {
                    var selected = false;
                    var firstFilter = true;
                    foreach (var fgt in Filters)
                    {
                        var filter = fgt.Stats;
                        if (filter.Computed && (selected || firstFilter))
                        {
                            if (filter.IsSelected(row))
                            {
                                selected = true;
                            }
                            else
                            {
                                selected = false;
                            }
                            firstFilter = false;

                        }
                    }

                    if (geometryColumn > -1 || (CoordinatesType == CoordinatesTypes.Spherical && (lngColumn > -1 && latColumn > -1)) || ((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;
                        var 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;
                            }

                            if (!double.TryParse(row[altColumn], out alt))
                            {
                                alt = 0;
                            }

                            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);
                            }
                        }

                        if (CoordinatesType == CoordinatesTypes.Spherical && lngColumn > -1 && latColumn > -1)
                        {
                            Xcoord = Coordinates.Parse(row[lngColumn]);
                            Ycoord = Coordinates.Parse(row[latColumn]);

                            if (astronomical)
                            {
                                if (RaUnits == RAUnits.Hours)
                                {
                                    Xcoord *= 015;
                                }
                                if (bufferIsFlat)
                                {
                                    Xcoord += 180;
                                }
                            }
                            if (!astronomical)
                            {
                                var offset = EGM96Geoid.Height(Ycoord, Xcoord);

                                altitude += offset;
                                alt += offset / meanRadius;
                            }
                            var pos = Coordinates.GeoTo3dDouble(Ycoord, Xcoord, alt);

                            lastItem.Position = pos.Vector311;

                            positions.Add(lastItem.Position);

                        }
                        else if (CoordinatesType == CoordinatesTypes.Rectangular)
                        {
                            var xyzScale = GetScaleFactor(CartesianScale, CartesianCustomScale) / meanRadius;

                            if (ZAxisColumn > -1)
                            {
                                Zcoord = Convert.ToDouble(row[ZAxisColumn]);
                            }

                            Xcoord = Convert.ToDouble(row[XAxisColumn]);
                            Ycoord = Convert.ToDouble(row[YAxisColumn]);

                            if (XAxisReverse)
                            {
                                Xcoord = -Xcoord;
                            }
                            if (YAxisReverse)
                            {
                                Ycoord = -Ycoord;
                            }
                            if (ZAxisReverse)
                            {
                                Zcoord = -Zcoord;
                            }

                            lastItem.Position = new Vector3((float)(Xcoord * xyzScale), (float)(Zcoord * xyzScale), (float)(Ycoord * xyzScale));
                            positions.Add(lastItem.Position);
                        }

                        switch (ColorMap)
                        {
                            case ColorMaps.Same_For_All:
                                lastItem.Color = color;
                                break;
                            case ColorMaps.Per_Column_Literal:
                                if (ColorMapColumn > -1)
                                {
                                    lastItem.Color = ParseColor(row[ColorMapColumn], color);
                                }
                                else
                                {
                                    lastItem.Color = color;
                                }
                                break;
                            //case ColorMaps.Group_by_Range:
                            //    break;
                            //case ColorMaps.Gradients_by_Range:
                            //    break;
                            case ColorMaps.Group_by_Values:
                                if (!ColorDomainValues.ContainsKey(row[ColorMapColumn]))
                                {
                                    MakeColorDomainValues();
                                }
                                lastItem.Color = Color.FromArgb(ColorDomainValues[row[ColorMapColumn]].MarkerIndex);
                                break;

                            default:
                                break;
                        }

                        if (selected)
                        {
                            lastItem.Color = Color.Yellow;
                        }

                        if (sizeColumn > -1)
                        {
                            switch (pointScaleType)
                            {
                                case PointScaleTypes.Linear:
                                    lastItem.PointSize = Convert.ToSingle(row[sizeColumn]);
                                    break;
                                case PointScaleTypes.Log:
                                    lastItem.PointSize = (float)Math.Log(Convert.ToSingle(row[sizeColumn]));
                                    break;
                                case PointScaleTypes.Power:
                                    {
                                        double size = 0;
                                        if (double.TryParse(row[sizeColumn], out size))
                                        {
                                            lastItem.PointSize = (float)Math.Pow(2, size);
                                        }
                                        else
                                        {
                                            lastItem.PointSize = 0;
                                        }
                                    }
                                    break;
                                case PointScaleTypes.StellarMagnitude:
                                    {
                                        double size = 0;
                                        if (double.TryParse(row[sizeColumn], out size))
                                        {

                                            if (!bufferIsFlat)
                                            {
                                                size = size - 5 * ((Math.Log10(distParces) - 1));
                                                lastItem.PointSize = (float)(120000000 / Math.Pow(1.6, size));
                                            }
                                            else
                                            {
                                                lastItem.PointSize = (float)(40 / Math.Pow(1.6, size));
                                            }

                                        }
                                        else
                                        {
                                            lastItem.PointSize = 0;
                                        }

                                    }
                                    break;

                                case PointScaleTypes.Constant:
                                    lastItem.PointSize = 1;
                                    break;
                                default:
                                    break;
                            }
                        }
                        else
                        {
                            lastItem.PointSize = 1;
                        }
                        if (PlotType == PlotTypes.Point)
                        {
                            lastItem.PointSize = 1;
                        }

                        if (startDateColumn > -1)
                        {
                            var dateTime = ParseDate(row[startDateColumn]);
                            lastItem.Tu = (float)(SpaceTimeController.UtcToJulian(dateTime) - SpaceTimeController.UtcToJulian(baseDate));

                            if (endDateColumn > -1)
                            {
                                dateTime = ParseDate(row[endDateColumn]);

                                lastItem.Tv = (float)(SpaceTimeController.UtcToJulian(dateTime) - SpaceTimeController.UtcToJulian(baseDate));
                            }
                            else
                            {
                                lastItem.Tv = lastItem.Tu;
                            }
                        }

                        if ((CoordinatesType == CoordinatesTypes.Spherical && (lngColumn > -1 && latColumn > -1)) || ((CoordinatesType == CoordinatesTypes.Rectangular) && (XAxisColumn > -1 && YAxisColumn > -1)))
                        {
                            vertList.Add(lastItem);
                            if (barChartBitmask != 0)
                            {
                                MakeBarChart(row, Ycoord, Xcoord, lastItem.PointSize, factor, lastItem.Color, selected, new Dates(lastItem.Tu, lastItem.Tv));
                            }
                        }

                        if (geometryColumn > -1)
                        {

                            ParseGeometry(row[geometryColumn], lastItem.Color, lastItem.Color, altitude, new Dates(lastItem.Tu, lastItem.Tv));

                        }

                        currentIndex++;
                    }
                }
                catch
                {
                }
                lines = false;
            }

            shapeVertexCount = vertList.Count;
            if (vertList.Count != 0)
            {
                shapeFileVertex = new TimeSeriesPointSpriteSet(RenderContext11.PrepDevice, vertList.ToArray());
                table.Unlock();
                return true;
            }

            table.Unlock();
            return false;
        }
        protected override bool PrepVertexBuffer(float opacity)
        {
            VoColumn col = table.GetColumnByUcd("meta.id");

            if (col == null)
            {
                col = table.Column[0];
            }

            if (shapeFileVertex == null)
            {
                bool siapSet = IsSiapResultSet();

                if (lineList2d == null)
                {
                    lineList2d = new LineList();
                }
                lineList2d.Clear();

                VoColumn stcsCol = table.GetColumnByUcd("phys.area;obs.field");

                if (stcsCol == null && table.Columns.ContainsKey("regionSTCS"))
                {
                    stcsCol = table.Columns["regionSTCS"];
                }

                if (PlotType == PlotTypes.Gaussian)
                {
                    MarkerScale = MarkerScales.World;
                }
                else
                {
                    MarkerScale = MarkerScales.Screen;
                }

                List <TimeSeriesPointVertex> vertList = new List <TimeSeriesPointVertex>();
                List <UInt32>         indexList       = new List <UInt32>();
                TimeSeriesPointVertex lastItem        = new TimeSeriesPointVertex();
                positions.Clear();
                UInt32 currentIndex = 0;
                Color  color        = Color.FromArgb((int)(opacity * (float)Color.A), Color);

                pointScaleType = PointScaleTypes.StellarMagnitude;

                foreach (VoRow row in table.Rows)
                {
                    try
                    {
                        if (lngColumn > -1 && latColumn > -1)
                        {
                            double Xcoord = Coordinates.ParseRA(row[this.LngColumn].ToString(), true) * 15 + 180;
                            double Ycoord = Coordinates.ParseDec(row[this.LatColumn].ToString());
                            lastItem.Position = Coordinates.GeoTo3dDouble(Ycoord, Xcoord).Vector311;
                            positions.Add(lastItem.Position);
                            lastItem.Color = color;
                            if (sizeColumn > -1)
                            {
                                try
                                {
                                    if (MarkerScale == MarkerScales.Screen)
                                    {
                                        lastItem.PointSize = 20f;
                                    }
                                    else
                                    {
                                        switch (pointScaleType)
                                        {
                                        case PointScaleTypes.Linear:
                                            lastItem.PointSize = Convert.ToSingle(row[sizeColumn]);
                                            break;

                                        case PointScaleTypes.Log:
                                            lastItem.PointSize = (float)Math.Log(Convert.ToSingle(row[sizeColumn]));
                                            break;

                                        case PointScaleTypes.Power:
                                            lastItem.PointSize = (float)Math.Pow(2, Convert.ToSingle(row[sizeColumn]));
                                            break;

                                        case PointScaleTypes.StellarMagnitude:
                                        {
                                            double size = Convert.ToSingle(row[sizeColumn]);
                                            lastItem.PointSize = (float)(40 / Math.Pow(1.6, size)) * 10;
                                        }
                                        break;

                                        case PointScaleTypes.Constant:
                                            lastItem.PointSize = 1;
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                }
                                catch
                                {
                                    lastItem.PointSize = .01f;
                                }
                            }
                            else
                            {
                                if (MarkerScale == MarkerScales.Screen)
                                {
                                    lastItem.PointSize = 20;
                                }
                                else
                                {
                                    lastItem.PointSize = (float)Math.Pow(2, 1) * 100;
                                }
                            }


                            if (startDateColumn > -1)
                            {
                                DateTime dateTime = DateTime.Parse(row[startDateColumn].ToString());
                                lastItem.Tu = (float)SpaceTimeController.UtcToJulian(dateTime);
                                lastItem.Tv = 0;
                            }


                            vertList.Add(lastItem);
                            currentIndex++;
                        }


                        if (siapSet && stcsCol != null)
                        {
                            AddSiapStcRow(stcsCol.Name, row, row == table.SelectedRow);
                        }
                    }

                    catch
                    {
                    }
                    lines = false;
                }

                if (siapSet && stcsCol != null)
                {
                    AddSiapStcRow(stcsCol.Name, table.SelectedRow, true);
                }


                shapeVertexCount = vertList.Count;
                if (shapeVertexCount == 0)
                {
                    shapeVertexCount = 1;
                }
                shapeFileVertex = new TimeSeriesPointSpriteSet(RenderContext11.PrepDevice, vertList.ToArray());
            }
            return(true);
        }