コード例 #1
0
        private static void TestDatasetBuilder()
        {
            DatasetBuilder d = new DatasetBuilder();

            d.RequireField("all", new QueryBuilder().SelectAs("Data1", "setting1")
                           .SelectAs("Data2", "setting2")
                           .SelectAs("Data3", "setting3")
                           .Composite().Array()
                           .From("D:/Projects/temp/test.csv")
                           .Build());
            d.RequireField("firstColumn", new QueryBuilder().Select("Data1")
                           .Atomic().Array()
                           .From("D:/Projects/temp/test.csv")
                           .Build());
            d.RequireField("firstRow", new QueryBuilder().SelectAs("Data1", "setting1")
                           .SelectAs("Data2", "setting2")
                           .SelectAs("Data3", "setting3")
                           .Composite().Single()
                           .From("D:/Projects/temp/test.csv")
                           .Build());

            Packet p = d.Execute();

            JoinedSettings s = Decoder.DecodeAs <JoinedSettings>(p);
        }
コード例 #2
0
ファイル: FormMap.cs プロジェクト: RedfoxCh/EDDiscovery
        private void GenerateDataSetStandard()
        {
            InitStarLists();

            var builder = new DatasetBuilder()
            {
                // TODO: I'm working on deprecating "Origin" so that everything is build with an origin of (0,0,0) and the camera moves instead.
                // This will allow us a little more flexibility with moving the cursor around and improving translation/rotations.
                CenterSystem = CenterSystem,

                VisitedSystems = VisitedSystems,

                GridLines  = toolStripButtonGrid.Checked,
                DrawLines  = toolStripButtonDrawLines.Checked,
                AllSystems = toolStripButtonShowAllStars.Checked,
                Stations   = toolStripButtonStations.Checked
            };

            if (_starList != null)
            {
                builder.StarList = _starList.ConvertAll(system => (ISystem)system);
            }
            if (ReferenceSystems != null)
            {
                builder.ReferenceSystems = ReferenceSystems.ConvertAll(system => (ISystem)system);
            }

            _datasets = builder.Build();
        }
コード例 #3
0
 public void Initialize()
 {
     _subject = new DatasetBuilder
     {
         CenterSystem = new DB.InMemory.SystemClass(),
         StarList = SpawnStars().Select(s => new SystemClassStarNames(s)).ToList()
     };
 }
コード例 #4
0
 public void Initialize()
 {
     _subject = new DatasetBuilder
     {
         CenterSystem = new DB.InMemory.SystemClass(),
         StarList     = SpawnStars().Select(s => new SystemClassStarNames(s)).ToList()
     };
 }
コード例 #5
0
 public void Initialize()
 {
     _subject = new DatasetBuilder
     {
         CenterSystem = new DB.InMemory.SystemClass(),
         StarList     = SpawnStars()
     };
 }
コード例 #6
0
        private void GenerateDataSetStandard()
        {
            if (_datasets != null)
            {
                foreach (var ds in _datasets)
                {
                    if (ds is IDisposable)
                    {
                        ((IDisposable)ds).Dispose();
                    }
                }
            }

            InitStarLists();

            selectedmaps = GetSelectedMaps();

            builder = new DatasetBuilder()
            {
                // TODO: I'm working on deprecating "Origin" so that everything is build with an origin of (0,0,0) and the camera moves instead.
                // This will allow us a little more flexibility with moving the cursor around and improving translation/rotations.
                CenterSystem   = CenterSystem,
                SelectedSystem = _clickedSystem,

                VisitedSystems = VisitedSystems.Where(s => s.time >= startTime && s.time <= endTime).OrderBy(s => s.time).ToList(),

                Images = selectedmaps.ToArray(),

                GridLines  = toolStripButtonGrid.Checked,
                DrawLines  = toolStripButtonDrawLines.Checked,
                AllSystems = toolStripButtonShowAllStars.Checked,
                Stations   = toolStripButtonStations.Checked,
                UseImage   = selectedmaps.Count != 0
            };
            if (_starList != null)
            {
                builder.StarList = _starList.ConvertAll(system => (ISystem)system);
            }
            if (ReferenceSystems != null)
            {
                builder.ReferenceSystems = ReferenceSystems.ConvertAll(system => (ISystem)system);
            }
            if (PlannedRoute != null)
            {
                builder.PlannedRoute = PlannedRoute.ConvertAll(system => (ISystem)system);
            }

            _datasets = builder.Build();
        }
コード例 #7
0
        private void NamedStars() // background thread.. run after Update.  Thread never deletes, only adds to its own structures
        {
            try                   // just in case someone tears us down..
            {
                int lylimit = (int)(_starlimitly / _lastcamera.LastZoom);
                lylimit = Math.Max(lylimit, 1);
                int sqlylimit = lylimit * lylimit;                 // in squared distance limit from viewpoint

                StarGrid.TransFormInfo ti = new StarGrid.TransFormInfo(_resmat, _znear, _glControl.Width, _glControl.Height, sqlylimit, _lastcamera.LastCameraPos);

                SortedDictionary <float, StarGrid.InViewInfo> inviewlist = new SortedDictionary <float, StarGrid.InViewInfo>(new DuplicateKeyComparer <float>());       // who's in view, sorted by distance

                //Stopwatch sw1 = new Stopwatch();sw1.Start(); Tools.LogToFile(String.Format("starnamesest Estimate at {0} len {1}", ti.campos, sqlylimit));

                _stargrids.GetSystemsInView(ref inviewlist, 2000.0F, ti);            // consider all grids under 2k from current pos.

                //Tools.LogToFile(String.Format("starnamesest Took {0} in view {1}", sw1.ElapsedMilliseconds, inviewlist.Count));

                float textscalingw = Math.Min(_starnamemaxly, Math.Max(_starnamesizely / _lastcamera.LastZoom, _starnameminly)); // per char
                float starsize     = Math.Min(Math.Max(_lastcamera.LastZoom / 10F, 1.0F), 20F);                                  // Normal stars are at 1F.
                //Console.WriteLine("Per char {0} h {1} sc {2} ", textscalingw, textscalingh, starsize);

                foreach (StarNames s in _starnamesbackground.Values) // all items not processed
                {
                    s.updatedinview = false;                         // only items remaining will clear this
                }
                _needrepaint = false;                                // assume nothing changes

                int painted = 0;

                //string res = "";  // used to view whats added/removed/draw..

                foreach (StarGrid.InViewInfo inview in inviewlist.Values)            // for all in viewport, sorted by distance from camera position
                {
                    using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
                    {
                        StarNames sys  = null;
                        bool      draw = false;

                        if (_starnamesbackground.ContainsKey(inview.position))                   // if already there..
                        {
                            sys = _starnamesbackground[inview.position];
                            sys.updatedinview = true;

                            draw = (_discson && sys.paintstar == null && sys.newstar == null) ||
                                   (_nameson && ((sys.nametexture == null && sys.newnametexture == null)));

                            painted++;
                        }
                        else if (painted < maxstars)
                        {
                            ISystem sc = _formmap.FindSystem(inview.position, cn); // with the open connection, find this star..

                            if (sc != null)                                        // if can't be resolved, ignore
                            {
                                sys = new StarNames(sc, inview.position);          // we keep position in here using same floats as inview so it will match
                                _starnamesbackground.Add(inview.position, sys);    // add to our database
                                _starnamestoforeground.Add(sys);                   // send to foreground for adding
                                draw = true;
                                painted++;

                                //Tools.LogToFile(String.Format("starnamesest: push {0}", sys.Pos));
                                //res += "N";
                            }
                        }
                        else
                        {
                            break;      // no point doing any more..  got our fill of items
                        }

                        if (draw)
                        {
                            _needrepaint = true;                                            // changed a item.. needs a repaint

                            if (_nameson)
                            {
                                float width = textscalingw * sys.name.Length;

                                Bitmap map = DatasetBuilder.DrawString(sys.name, _namecolour, _starfont);

                                sys.newnametexture = TexturedQuadData.FromBitmap(map,
                                                                                 new PointData(sys.pos.X, sys.pos.Y, sys.pos.Z),
                                                                                 _lastcamera.Rotation,
                                                                                 width, textscalingw * 4.0F, _startextoffset + width / 2, 0);

                                sys.rotation = _lastcamera.Rotation;            // remember when we were when we draw it
                                sys.zoom     = _lastcamera.LastZoom;
                            }

                            if (_discson)
                            {
                                sys.newstar = new PointData(sys.pos.X, sys.pos.Y, sys.pos.Z, starsize, inview.AsColor);
                            }
                        }
                    }
                }

                foreach (StarNames s in _starnamesbackground.Values)              // only items above will remain.
                {
                    //if (s.inview != s.updatedinview) res += (s.updatedinview) ? "+" : "-";

                    _needrepaint = _needrepaint || (s.inview != s.updatedinview); // set if we change our mind on any of the items
                    s.inview     = s.updatedinview;                               // copy flag over, causes foreground to start removing them
                }

                //if ( _needrepaint) Console.WriteLine(String.Format("starnamesest in view  {0} limit {1} repaint {2} {3}", inviewlist.Count, lylimit, _needrepaint, res));

                //Tools.LogToFile(String.Format("starnamesest added all delta {0} topaint {1}", sw1.ElapsedMilliseconds, painted));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception watcher: " + ex.Message);
                System.Diagnostics.Trace.WriteLine("Trace: " + ex.StackTrace);
            }

            _formmap.BeginInvoke((System.Windows.Forms.MethodInvoker) delegate              // kick the UI thread to process.
            {
                _formmap.ChangeNamedStars();
            });
        }
コード例 #8
0
 public GeoFileDownloader(GeoFileDownloaderOptions options)
 {
     this.options = options;
     this.builder = new DatasetBuilder(options.RExecute, options.RootDirectory);
 }
コード例 #9
0
ファイル: StarNamesList.cs プロジェクト: brisu/EDDiscovery
        private void NamedStars() // background thread.. run after timer tick
        {
            try                   // just in case someone tears us down..
            {
                int lylimit = (int)(_starlimitly / _lastcamera.LastZoom);
                lylimit = Math.Max(lylimit, 20);
                //Console.Write("Look down " + _camera_paint_lookdown + " look forward " + _camera_paint_lookforward);
                //Console.Write("Repaint " + _repaintall + " Stars " + _starlimitly + " within " + lylimit + "  ");
                int sqlylimit = lylimit * lylimit;                 // in squared distance limit from viewpoint

                Vector3 modcampos = _lastcamera.CameraPos;
                modcampos.Y = -modcampos.Y;

                StarGrid.TransFormInfo ti = new StarGrid.TransFormInfo(_resmat, _znear, _glControl.Width, _glControl.Height, sqlylimit, modcampos);

                SortedDictionary <float, StarGrid.InViewInfo> inviewlist = new SortedDictionary <float, StarGrid.InViewInfo>(new DuplicateKeyComparer <float>()); // who's in view, sorted by distance

                _stargrids.GetSystemsInView(ref inviewlist, 2000.0, ti);                                                                                          // consider all grids under 2k from current pos.

                float textscalingw = Math.Min(_starnamemaxly, Math.Max(_starnamesizely / _lastcamera.LastZoom, _starnameminly));                                  // per char
                float textscalingh = textscalingw * 4;
                float textoffset   = .20F;
                float starsize     = Math.Min(Math.Max(_lastcamera.LastZoom / 10F, 1.0F), 20F); // Normal stars are at 1F.
                //Console.WriteLine("Per char {0} h {1} sc {2} ", textscalingw, textscalingh, starsize);

                lock (deletelock)                              // can't delete during update, can paint..
                {
                    foreach (StarNames s in _starnames.Values) // all items not processed
                    {
                        s.todispose = true;                    // only items remaining will clear this
                    }
                    int limit   = 1000;                        // max number of stars to show..
                    int painted = 0;

                    using (SQLiteConnectionED cn = new SQLiteConnectionED())
                    {
                        foreach (StarGrid.InViewInfo inview in inviewlist.Values)            // for all in viewport, sorted by distance from camera position
                        {
                            StarNames sys  = null;
                            bool      draw = false;

                            if (_starnames.ContainsKey(inview.position))                   // if already there..
                            {
                                sys           = _starnames[inview.position];
                                sys.todispose = false;                         // forced redraw due to change in orientation, or due to disposal
                                draw          = _flippedorzoomed || (_nameson && sys.newstar == null) || (_discson && sys.nametexture == null);
                                painted++;
                            }
                            else if (painted < limit)
                            {
                                ISystem sc = _formmap.FindSystem(inview.position, cn); // with the open connection, find this star..

                                if (sc != null)                                        // if can't be resolved, ignore
                                {
                                    sys = new StarNames(sc);
                                    lock (_starnames)
                                    {
                                        _starnames.Add(inview.position, sys);               // need to lock over add.. in case display is working
                                    }
                                    draw = true;
                                    painted++;
                                }
                                else
                                {
                                    // Console.WriteLine("Failed to find " + pos.X + "," + pos.Y + "," + pos.Z);
                                }
                            }
                            else
                            {
                                break;      // no point doing any more..  Either the closest ones have been found, or a new one was painted
                            }

                            if (draw)
                            {
                                if (_nameson)
                                {
                                    float width = textscalingw * sys.name.Length;

                                    Bitmap map;                     // now, delete is the only one who removed newtexture
                                                                    // and we are protected against delete..
                                    if (sys.nametexture == null)    // so see if newtexture is there
                                    {
                                        map = DatasetBuilder.DrawString(sys.name, Color.Orange, _starfont);
                                        sys.newnametexture = TexturedQuadData.FromBitmap(map,
                                                                                         new PointData(sys.x, sys.y, sys.z),
                                                                                         _lastcamera.Rotation,
                                                                                         width, textscalingh, textoffset + width / 2, 0);
                                    }
                                    else
                                    {
                                        sys.newnamevertices = TexturedQuadData.CalcVertices(new PointData(sys.x, sys.y, sys.z),
                                                                                            _lastcamera.Rotation,
                                                                                            width, textscalingh, textoffset + width / 2, 0);
                                    }
                                }

                                if (_discson)
                                {
                                    sys.newstar = new PointData(sys.x, sys.y, sys.z, starsize, Color.FromArgb(255, inview.colour & 255, (inview.colour >> 8) & 255, (inview.colour >> 16) & 255));
                                }
                            }
                        }
                    }

                    foreach (StarNames s in _starnames.Values)            // only items above will remain.
                    {
                        s.inview = !s.todispose;                          // copy flag over, causes foreground to start removing them
                    }
                }

                //Console.WriteLine("  " + (Environment.TickCount % 10000) + "Paint " + painted);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception watcher: " + ex.Message);
                System.Diagnostics.Trace.WriteLine("Trace: " + ex.StackTrace);
            }

            _formmap.Invoke((System.Windows.Forms.MethodInvoker) delegate              // kick the UI thread to process.
            {
                _formmap.ChangeNamedStars();
            });
        }
コード例 #10
0
        public void PrepareData()
        {
            var tfds = new DatasetBuilder();

            tfds.download_and_prepare();
        }