コード例 #1
0
        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;
        }
コード例 #2
0
 private void ExportSTL_Load(object sender, EventArgs e)
 {
     Earth3d.MainWindow.UiController = this;
     lines = new LineList();
     lines.DepthBuffered = false;
     UpdateTextBoxes();
     initialized = true;
     UpdateLines();
 }
コード例 #3
0
        //public static SimpleLineList11 sketch = null;
        static void InitTranslateUI()
        {
            TranslateUILines = new LineList();
            TranslateUILines.TimeSeries = false;
            TranslateUILines.DepthBuffered = false;
            TranslateUILines.ShowFarSide = true;

            TranslateUI = new TriangleList();
            TranslateUI.DepthBuffered = false;
            TranslateUI.TimeSeries = false;
            TranslateUI.WriteZbuffer = false;

            double twoPi = Math.PI * 2;
            double step = twoPi / 45;
            double rad = .05;

            // X

            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(1 - rad * 4, 0, 0);
                Vector3d pnt2 = new Vector3d(1 - rad * 4, Math.Cos(a) * rad, Math.Sin(a) * rad);
                Vector3d pnt3 = new Vector3d(1 - rad * 4, Math.Cos(a + step) * rad, Math.Sin(a + step) * rad);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.Red, new Dates());
            }
            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(1, 0, 0);
                Vector3d pnt3 = new Vector3d(1 - rad * 4, Math.Cos(a) * rad, Math.Sin(a) * rad);
                Vector3d pnt2 = new Vector3d(1 - rad * 4, Math.Cos(a + step) * rad, Math.Sin(a + step) * rad);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.FromArgb(255, Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
            }

            TranslateUILines.AddLine(new Vector3d(0, 0, 0), new Vector3d(1, 0, 0), System.Drawing.Color.Red);

            // Y
            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(0, 1 - rad * 4, 0);
                Vector3d pnt3 = new Vector3d(Math.Cos(a) * rad, 1 - rad * 4, Math.Sin(a) * rad);
                Vector3d pnt2 = new Vector3d(Math.Cos(a + step) * rad, 1 - rad * 4, Math.Sin(a + step) * rad);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.Green, new Dates());
            }

            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(0, 1, 0);
                Vector3d pnt2 = new Vector3d(Math.Cos(a) * rad, 1 - rad * 4, Math.Sin(a) * rad);
                Vector3d pnt3 = new Vector3d(Math.Cos(a + step) * rad, 1 - rad * 4, Math.Sin(a + step) * rad);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.FromArgb(Math.Max(0, (int)(Math.Sin(a) * 128)), 255, Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
            }

            TranslateUILines.AddLine(new Vector3d(0, 0, 0), new Vector3d(0, 1, 0), System.Drawing.Color.Green);

            // Z
            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(0, 0, 1 - rad * 4);
                Vector3d pnt2 = new Vector3d(Math.Cos(a) * rad, Math.Sin(a) * rad, 1 - rad * 4);
                Vector3d pnt3 = new Vector3d(Math.Cos(a + step) * rad, Math.Sin(a + step) * rad, 1 - rad * 4);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.Blue, new Dates());
            }

            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(0, 0, 1);
                Vector3d pnt3 = new Vector3d(Math.Cos(a) * rad, Math.Sin(a) * rad, 1 - rad * 4);
                Vector3d pnt2 = new Vector3d(Math.Cos(a + step) * rad, Math.Sin(a + step) * rad, 1 - rad * 4);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.FromArgb(Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128)), 255), new Dates());
            }

            TranslateUILines.AddLine(new Vector3d(0, 0, 0), new Vector3d(0, 0, 1), System.Drawing.Color.Blue);
            InitRotateUI();
            InitScaleUI();
        }
コード例 #4
0
        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;
        }
コード例 #5
0
 public override bool Draw(RenderContext11 renderContext, float opacity, bool flat)
 {
     if (ShowEditUi && UiLines != null)
     {
         UiLines.DrawLines(renderContext, 1);
     }
     else
     {
         UiLines = null;
     }
     ShowEditUi = false;
     return true;
 }