Example #1
0
        public Server(DomainManager domains, ServerBase cloneBase)
            : base(domains, cloneBase)
        {
            if (cloneBase is Server)
            {
                Server clone = (Server)cloneBase;

                Cache              = clone.Cache;
                DirectRemotes      = clone.DirectRemotes;
                RemoteInfo         = clone.RemoteInfo;
                Remotes            = clone.Remotes;
                Lines              = clone.Lines;
                NetworkEstablished = clone.NetworkEstablished;
                Listeners          = clone.Listeners;

                if (clone.SaveTimer.Change(Timeout.Infinite, Timeout.Infinite))
                {
                    clone.SaveTimer.Dispose();
                }
            }

            SaveTimer = new Timer(SaveProc);

            Initialize();
        }
        public static PackedGeometry Pack(LineSet lineSet)
        {
            PackedGeometry packed;
            Coordinate     coordinate;

            packed = new PackedGeometry();

            coordinate = (Coordinate)lineSet.ChildrenWithAppliedReferences.FirstOrDefault(n => n.GetType() == typeof(Coordinate));

            packed.RGBA             = false;
            packed.RGB              = false;
            packed.Coloring         = false;
            packed.generateColorMap = false;

            if (coordinate != null)
            {
                packed._coords = X3DTypeConverters.MFVec3f(coordinate.point);

                packed.restartIndex = null;
                packed.vertexStride = 2;
                packed.vertexCount  = lineSet.vertexCount;

                packed.Interleave();
            }

            return(packed);
        }
Example #3
0
        public Server(DomainManager domains)
            : base(domains, Environment.MachineName)
        {
            SaveTimer = new Timer(SaveProc);
            Lines = new LineSet();
            DirectRemotes = new Dictionary<string, RemoteServer>();
            Remotes = new Dictionary<string, RemoteServer>();
            Settings = InitializeSettings();
            LocalRehash();

            Cache = Cache.Load();
            if (Cache == null)
            {
                Cache = Cache.Create();
                if (!Cache.Save())
                {
                    Console.WriteLine("Unable to save cache.  Will not start until cache is writable for security.");
                    Environment.Exit(1);
                    return;
                }
            }

            Certificates = new CertificateManager();
            string password = Settings.CertificatePassword;
            if (!Certificates.Load(Id, password) && !Certificates.Generate(Id, password))
            {
                Console.WriteLine("Unable to generate certificate on non-Windows OS.  There must be a single, valid X.509 certificate file named 'Certificate.{0}.*' in the current directory.", Id);
                Environment.Exit(1);
                return;
            }

            Initialize();
        }
Example #4
0
        public Server(DomainManager domains, ServerBase cloneBase)
            : base(domains, cloneBase)
        {
            if (cloneBase is Server)
            {
                Server clone = (Server)cloneBase;

                Cache = clone.Cache;
                DirectRemotes = clone.DirectRemotes;
                RemoteInfo = clone.RemoteInfo;
                Remotes = clone.Remotes;
                Lines = clone.Lines;
                NetworkEstablished = clone.NetworkEstablished;
                Listeners = clone.Listeners;

                if (clone.SaveTimer.Change(Timeout.Infinite, Timeout.Infinite))
                {
                    clone.SaveTimer.Dispose();
                }
            }

            SaveTimer = new Timer(SaveProc);

            Initialize();
        }
Example #5
0
        public Server(DomainManager domains)
            : base(domains, Environment.MachineName)
        {
            SaveTimer     = new Timer(SaveProc);
            Lines         = new LineSet();
            DirectRemotes = new Dictionary <string, RemoteServer>();
            Remotes       = new Dictionary <string, RemoteServer>();
            Settings      = InitializeSettings();
            LocalRehash();

            Cache = Cache.Load();
            if (Cache == null)
            {
                Cache = Cache.Create();
                if (!Cache.Save())
                {
                    Console.WriteLine("Unable to save cache.  Will not start until cache is writable for security.");
                    Environment.Exit(1);
                    return;
                }
            }

            Certificates = new CertificateManager();
            string password = Settings.CertificatePassword;

            if (!Certificates.Load(Id, password) && !Certificates.Generate(Id, password))
            {
                Console.WriteLine("Unable to generate certificate on non-Windows OS.  There must be a single, valid X.509 certificate file named 'Certificate.{0}.*' in the current directory.", Id);
                Environment.Exit(1);
                return;
            }

            Initialize();
        }
Example #6
0
 // Start is called before the first frame update
 void Start()
 {
     timer           = 0;
     priorityTimer   = 0;
     currentSet      = startSet;
     currentPriority = currentSet.priority;
     currentLine     = 0;
     priorityLine    = 0;
     currentSet.SetIsActive(true);
 }
Example #7
0
    void makeLine(GameObject attacker, Color color)
    {
        LineRenderer lRend = new GameObject().AddComponent <LineRenderer>();
        LineSet      line  = lRend.gameObject.AddComponent <LineSet>();

        line.init(m.frames);
        lRend.SetPositions(new Vector3[] { attacker.transform.position, transform.position });
        lRend.startColor = new Color(color.r / 2, color.g / 2, color.b / 2);
        lRend.endColor   = color;
        lRend.startWidth = 0.1f;
        lRend.endWidth   = 0.1f;
    }
Example #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            LineChartView lineChartView = (LineChartView)FindViewById(Resource.Id.linechart);
            LineSet       dataset       = new LineSet(labels, values)
                                          .SetFill(Color.ParseColor("#2d374c"))
                                          .SetDotsColor(Color.ParseColor("#ffc755"))
                                          .SetThickness(4);

            lineChartView.AddData(dataset);
            lineChartView.Show();
        }
Example #9
0
 public void ChangeLineSet(LineSet newSet)
 {
     if ((newSet != null && currentSet == null) || newSet.priority >= currentSet.priority)
     {
         priorityTimer = 0;
         priorityLine  = 0;
         if (currentSet != null)
         {
             currentSet.SetIsActive(false);
         }
         currentSet = newSet;
         currentSet.SetIsActive(true);
         currentPriority = currentSet.priority;
     }
 }
Example #10
0
 public static void RefreshLineSetGroup()
 {
     BuilderData.Data.lineSetMap.Clear();
     for (int i = 0; i < BuilderData.Data.linkGraph.Count; i++)
     {
         for (int j = 0; j < BuilderData.Data.linkGraph [i].Count - 1; j++)
         {
             if (BuilderData.Data.linkGraph [i] [j] != 999)
             {
                 BuilderCore.LineSet newSet = new LineSet(BuilderData.Data.builderNodes [i].gameObject,
                                                          BuilderData.Data.builderNodes [j].gameObject);
                 BuilderData.Data.lineSetMap.Add(newSet);
             }
         }
     }
 }
Example #11
0
 void Start()
 {
     //Look to root and in children find LineSet
     set = transform.root.GetComponentInChildren<LineSet>();
     renderLine = gameObject.AddComponent("LineRenderer") as LineRenderer;
     if(set != null)
     {
         //set data from LineSet
         renderLine.SetWidth(set.widthStart, set.widthEnd);
         renderLine.SetColors(set.colorStart,set.colorEnd);
         renderLine.material = set.material;
         prefabCheck = set.prefabCheck;
     }
     else
     {
         Debug.LogWarning(gameObject.name + "this object not found seting script");
     }
     //count of vertes joints + this object;
     renderLine.SetVertexCount(joint.Length+1);
 }
Example #12
0
        public void Serialize(Dictionary <string, object> json, BinaryWriter bw)
        {
            elements = new List <string>();

            if (PointSetElements != null)
            {
                foreach (var PointSet in PointSetElements)
                {
                    PointSet.Serialize(json, bw);
                    elements.Add(PointSet.uid.ToString());
                }
            }


            if (LineSetElements != null)
            {
                foreach (var LineSet in LineSetElements)
                {
                    LineSet.Serialize(json, bw);
                    elements.Add(LineSet.uid.ToString());
                }
            }

            if (SurfaceElements != null)
            {
                foreach (var Surface in SurfaceElements)
                {
                    Surface.Serialize(json, bw);
                    elements.Add(Surface.uid.ToString());
                }
            }

            if (VolumeElements != null)
            {
                foreach (var VolumeElement in VolumeElements)
                {
                    VolumeElement.Serialize(json, bw);
                    elements.Add(VolumeElement.uid.ToString());
                }
            }
        }
        static MetroDataBuilderOperation()
        {
            BuildStation(line1str, ref line1);
            BuildStation(line2str, ref line2);
            BuildStation(line3str, ref line3);


            TotalLine.AddRange(Line1);
            TotalLine.AddRange(Line2);
            TotalLine.AddRange(Line3);
            StationSet = new HashSet <Station>(TotalLine);

            SetLineNumber(Line1, 1, ref stationSet);
            SetLineNumber(Line2, 2, ref stationSet);
            SetLineNumber(Line3, 3, ref stationSet);

            LineSet.Add(Line1);
            LineSet.Add(Line2);
            LineSet.Add(Line3);

            TotalStation = StationSet.Count;
        }
Example #14
0
        public bool CanBeSeen(MapPoint from, MapPoint to, bool throughEntities = false, WorldObject except = null)
        {
            if (from == null || to == null)
            {
                return(false);
            }
            if (from == to)
            {
                return(true);
            }

            var occupiedCells = new short[0];

            if (!throughEntities)
            {
                occupiedCells = Objects.Where(x => x.BlockSight && x != except).Select(x => x.Cell.Id).ToArray();
            }

            var line = new LineSet(from, to);

            return(!(from point in line.EnumerateValidPoints().Skip(1) where to.CellId != point.CellId let cell = Cells[point.CellId]
                                                                                                                  where !cell.LineOfSight || !throughEntities && Array.IndexOf(occupiedCells, point.CellId) != -1 select point).Any());
        }
Example #15
0
        public bool CanBeSeen(short from, short to, bool throughEntities = false)
        {
            if (from == to)
            {
                return(true);
            }

            var occupiedCells = new short[0];

            if (!throughEntities)
            {
                occupiedCells = GetAllFighters(true).FindAll(x => x.BlockSight).Select(x => x.CellId).ToArray();
            }

            var line = new LineSet(new MapPoint(from), new MapPoint(to));

            var list = line.EnumerateValidPoints().Skip(1);

            return(!(from point in list
                     where to != point.CellId
                     let cell = point.CellId
                                where !Map.LineOfSight(cell) || !throughEntities && Array.IndexOf(occupiedCells, point.CellId) != -1
                                select point).Any());
        }
Example #16
0
        protected override void FindBoundary()
        {
            bool output = false;

            //float acceptanceRatio = 0.9f;
            //float maxTimeDistance = 0.5f;

            // ~~~~~~~~~~~ Variable Initializations ~~~~~~~~~~~~~ \\

            // Find out: Where do we want the boundary to be?
            // "One day": Take Okubo etc as predictor.
            int preferredBoundaryTime = SliceTimeMain + (24 * RedSea.Singleton.NumSubsteps) / _everyNthTimestep;
            float maxTimeDistance = 1.0f;
            float maxRadius = 12;
            float minRadius = 1;
            float radiusGrowth = StepSize * 3;
            float stepSizeStreamlines = StepSize;

            PointSet<Point> boundaryOW = OkuboBoundary(preferredBoundaryTime);

            // At which point did we find the Boundary?
            int[] boundaryIndices, boundaryIndicesLast;
            // At which point did we find the Boundary last time? Initalize 0.
            boundaryIndicesLast = new int[LineX];
            for (int i = 0; i < boundaryIndicesLast.Length; i++)
                boundaryIndicesLast[i] = int.MaxValue;

            // Keep the chosen lines in here.
            LineSet chosenPathlines = new LineSet(new Line[LineX]);
            // These are lines that do not fullfill the criteria, but are the best ones we got so far.
            Line[] bestPathlines = new Line[LineX];
            float[] bestTimeDistance = new float[LineX];
            for (int i = 0; i < bestTimeDistance.Length; i++)
                bestTimeDistance[i] = float.MaxValue;

            // ~~~~~~~~~~~~ Inner Circle ~~~~~~~~~~~~~~~~~~~~~~~~ \\

            //for (float offsetInnerCircle = 7; offsetInnerCircle < 10; offsetInnerCircle += 0.1f)
            float offsetInnerCircle = AlphaStable;
            {
                chosenPathlines = new LineSet(new Line[LineX]);

                Console.WriteLine("Current offset: {0}", offsetInnerCircle);
                //      float offsetInnerCircle = AlphaStable;

                // Save where to transit steady -> unsteady integration.
                float[] offsetSeeds = new float[LineX];
                for (int i = 0; i < offsetSeeds.Length; i++)
                    offsetSeeds[i] = offsetInnerCircle;
                // Create small circle around selection.
                Point[] circle = new Point[LineX];

                // Seeds for pathlines.
                PointSet<Point> seeds = boundaryOW; //new PointSet<Point>(circle);

                // ~~~~~~~~~~~~ Integrate Pathlines and Adapt ~~~~~~~~~~~~~~~~~~~~~~~~ \\
                // Setup integrator.
                Integrator pathlineIntegrator = Integrator.CreateIntegrator(null, IntegrationType, _cores[_selectedCore], _repulsion);
                pathlineIntegrator.StepSize = StepSize;

                // Count out the runs for debugging.
                int run = 0;

                //while (seeds.Length > 0)
                //{
                //   if (output)
                Console.WriteLine("Starting run {0}, {1} seeds left.", run++, seeds.Length);

                // ~~~~~~~~~~~~ Integrate Pathlines  ~~~~~~~~~~~~~~~~~~~~~~~~ \\
                #region IntegratePathlines
                // Do we need to load a field first?
                if (_velocity.TimeOrigin > preferredBoundaryTime - 1 || _velocity.TimeOrigin + _velocity.Size.T < preferredBoundaryTime + 1)
                    LoadField(Math.Max(preferredBoundaryTime - STEPS_IN_MEMORY / 2, 0), MemberMain, STEPS_IN_MEMORY);
                int startStep = (int)_velocity.TimeOrigin;

                // Integrate first few steps.
                pathlineIntegrator.Field = _velocity;
                pathlineIntegrator.Direction = Sign.POSITIVE;
                LineSet[] pathlines = pathlineIntegrator.Integrate(seeds, true);

                // Append integrated lines of next loaded vectorfield time slices.
                float timeLength = RedSea.Singleton.NumSubstepsTotal / _everyNthTimestep; //preferredBoundaryTime * 2;
                while (_currentEndStep + 1 < timeLength)
                {
                    // Don't load more steps than we need to!
                    int numSteps = (int)Math.Min(timeLength - _currentEndStep, STEPS_IN_MEMORY);
                    pathlineIntegrator.Field = null;
                    LoadField(_currentEndStep, MemberMain, numSteps);

                    // Integrate further.
                    pathlineIntegrator.Field = _velocity;
                    pathlineIntegrator.IntegrateFurther(pathlines[0]);
                }

                // Now, integrate backwards.
                pathlineIntegrator.Direction = Sign.NEGATIVE;
                while (startStep > 0)
                {
                    // Don't load more steps than we need to!
                    int numSteps = (int)Math.Min(startStep + 1, STEPS_IN_MEMORY);
                    pathlineIntegrator.Field = null;
                    LoadField(startStep - numSteps + 1, MemberMain, numSteps);
                    startStep = (int)_velocity.TimeOrigin;

                    // Integrate further.
                    pathlineIntegrator.Field = _velocity;
                    pathlineIntegrator.IntegrateFurther(pathlines[1]);
                }

                pathlines[1].Reverse();
                pathlines[1].Append(pathlines[0]);

                chosenPathlines = pathlines[1];
                #endregion IntegratePathlines

                //        // ~~~~~~~~~~~~ Get Boundary ~~~~~~~~~~~~~~~~~~~~~~~~ \\
                //        #region GetBoundary
                //        // The two needes functions.
                //        Line[] distances = FieldAnalysis.GetGraph(_cores[_selectedCore], _selection, pathlines[0], StepSize, _everyNthTimestep, true);
                //        Line[] angles = FieldAnalysis.GetGraph(_cores[_selectedCore], _selection, pathlines[0], StepSize, _everyNthTimestep, false);

                //        // Find the boundary based on angle and distance.
                //        FieldAnalysis.FindBoundaryFromDistanceAngleDonut(distances, angles, out boundaryIndices);
                //        #endregion GetBoundary

                //        // ~~~~~~~~~~~~ Chose or Offset Pathlines ~~~~~~~~~~~~ \\
                //        int numNewSeeds = 0;
                //        int numPathlines = 0;
                //        float avgTimeDistance = 0;
                //        // Recompute start points.
                //        for (int idx = 0; idx < LineX; ++idx)
                //        {
                //            // We already have an optimal line here. Continue.
                //            if (chosenPathlines[idx] != null)
                //                continue;

                //            // Should we save this line?

                //            Vector3 pos;
                //            // Save this point
                //            if (boundaryIndices[numPathlines] >= 0)
                //            {
                //                pos = pathlines[numPathlines][boundaryIndices[numPathlines]];
                //                _allBoundaryPoints.Add(new Point(pos) { Color = new Vector3(0.1f, pos.Z * _everyNthTimestep / RedSea.Singleton.NumSubstepsTotal, 0.1f) });
                //            }
                //            // Finally found it?
                //            // TODOD: DEBUG!!!!!!!!!!!!!!!!111!!!!!!!!!!!!!!!!!!elf!!!!!!!!!!!!!!!!
                //            float timeDistance = Math.Abs((boundaryIndices[numPathlines] * StepSize) - preferredBoundaryTime);
                //            avgTimeDistance += timeDistance;
                //            if (timeDistance < maxTimeDistance || run >= 100) // We reached the spot! Take this line!
                //            {
                //                chosenPathlines[idx] = pathlines[numPathlines];
                //                if (output)
                //                    Console.WriteLine("Line {0} was chosen because it is perfect!", idx);
                //            }
                //            else
                //            {
                //                // Add new seed to seed list.
                //                float scale = boundaryIndices[numPathlines] / preferredBoundaryTime;
                //                float newOffset = offsetSeeds[numPathlines] + ((scale > 1) ? radiusGrowth : -radiusGrowth);
                //                newOffset = Math.Max(minRadius, newOffset);
                //                newOffset = Math.Min(maxRadius, newOffset);

                //                // We are stuck. Take best value we reached so far and go on.
                //                if (newOffset == offsetSeeds[numPathlines] && bestPathlines[idx] != null)
                //                {
                //                    chosenPathlines[idx] = bestPathlines[idx];
                //                    continue;
                //                }
                //                if (timeDistance < bestTimeDistance[idx])
                //                {
                //                    bestPathlines[idx] = pathlines[numPathlines];
                //                    bestTimeDistance[idx] = timeDistance;
                //                }

                //                offsetSeeds[numPathlines] = newOffset;

                //                // Recompute position on circle.
                //                float x = (float)(Math.Sin(angleDiff * idx + Math.PI / 2));
                //                float y = (float)(Math.Cos(angleDiff * idx + Math.PI / 2));

                //                // Take the selection as center.
                //                seeds.Points[numNewSeeds] = new Point() { Position = new Vector3(_selection.X + x * offsetSeeds[numNewSeeds], _selection.Y + y * offsetSeeds[numNewSeeds], SliceTimeMain) };

                //                // Count up number of new seeds.
                //                numNewSeeds++;
                //            }

                //            // We do not count up this value if there is a chosen pathline at this index already.
                //            numPathlines++;
                //        }

                //        // We maybe need less seeds now?
                //        if (numNewSeeds < seeds.Length)
                //            Array.Resize(ref seeds.Points, numNewSeeds);

                //        Console.WriteLine("Average time distance: {0}", avgTimeDistance / numPathlines);
                //    }
            }
            // ~~~~~~~~~~~~ Get Boundary for Rendering~~~~~~~~~~~~~~~~~~~~~~~~ \\

            // The two needes functions.
            _coreDistanceGraph = FieldAnalysis.GetGraph(_cores[_selectedCore], _selection, chosenPathlines, StepSize, _everyNthTimestep, true);
            _coreAngleGraph = FieldAnalysis.GetGraph(_cores[_selectedCore], _selection, chosenPathlines, StepSize, _everyNthTimestep, false);

            // Find the boundary based on angle and distance.
            _boundaryBallFunction = new LineBall(_linePlane, new LineSet(new Line[] { FieldAnalysis.FindBoundaryFromDistanceAngleDonut(_coreDistanceGraph, _coreAngleGraph, out boundaryIndices) }));

            // Find the boundary in space-time.
            int time = SliceTimeMain;
            _boundariesSpacetime[time] = new Line() { Positions = new Vector3[LineX + 1] };
            for (int l = 0; l < LineX; ++l)
            {
                Vector3 pos = chosenPathlines[l][boundaryIndices[l]];
                _allBoundaryPoints.Add(new Point(pos) { Color = Vector3.UnitY * pos.Z / RedSea.Singleton.NumSubstepsTotal * _everyNthTimestep });
                _allBoundaryPoints.Add(boundaryOW.Points[l]);
                _boundariesSpacetime[time][l] = pos;
            }
            _boundariesSpacetime[time][LineX] = _boundariesSpacetime[time][0];
            _boundaryBallSpacetime = new LineBall(_linePlane, _boundariesSpacetime, LineBall.RenderEffect.HEIGHT, Colormap);

            // Pathlines for rendering.
            _pathlinesTime = chosenPathlines;
            _pathlines = new LineBall(_linePlane, chosenPathlines, LineBall.RenderEffect.HEIGHT, ColorMapping.GetComplementary(Colormap), Flat);

            Console.WriteLine("Khalas. Boundary indices:");
            float sumTime = 0;
            for (int i = 0; i < chosenPathlines.Length; i++)
            {
                float atTime = chosenPathlines[i][boundaryIndices[i]].Z;
                sumTime += atTime;
                Console.WriteLine("\tTime at {0}: {1}", i, atTime);
            }
            Console.WriteLine("Average time: {0}", sumTime / chosenPathlines.Length);

            _boundaryCloud = new PointCloud(_linePlane, new PointSet<Point>(_allBoundaryPoints.ToArray()));

            LineSet set = new LineSet(_coreAngleGraph);
            GeometryWriter.WriteHeightCSV(RedSea.Singleton.DonutFileName + "Angle.csv", set);
            GeometryWriter.WriteToFile(RedSea.Singleton.DonutFileName + ".angle", set);

            set = new LineSet(_coreDistanceGraph);
            GeometryWriter.WriteHeightCSV(RedSea.Singleton.DonutFileName + "Distance.csv", set);
            GeometryWriter.WriteToFile(RedSea.Singleton.DonutFileName + ".distance", set);
        }
Example #17
0
        protected List<Renderable> Map()
        {
            List<Renderable> output = new List<Renderable>(2);

            bool update = false;
            if (_lastSetting == null ||
                SliceTimeMainChanged)
            {

                GeometryWriter.ReadFromFile(RedSea.Singleton.DonutFileName + ".angle", out _loadedAngle);
                GeometryWriter.ReadFromFile(RedSea.Singleton.DonutFileName + ".distance", out _loadedDistance);
                _loadedBall = new LineBall(Plane, _loadedAngle, LineBall.RenderEffect.HEIGHT);

                int[] indices;
                _boundaryLoaded = FieldAnalysis.FindBoundaryFromDistanceAngleDonut(_loadedDistance.Lines, _loadedAngle.Lines, out indices);

                _blockData = FieldAnalysis.PlotLines2D(_loadedAngle);
                _boundaryBlock = FieldAnalysis.FindBoundaryFromDistanceDonut(_blockData.Lines);

                update = true;
            }

            if (update ||
                FlatChanged)
            {
                _loadedBall = new LineBall(Plane, _loadedAngle, LineBall.RenderEffect.HEIGHT, Colormap, Flat);
                _boundaryLoadedBall = new LineBall(_fightPlane, new LineSet(new Line[] { _boundaryLoaded }) { Thickness = 0.2f }, LineBall.RenderEffect.HEIGHT, Colormap, Flat);

                _blockBall = new LineBall(Plane, _blockData, LineBall.RenderEffect.HEIGHT, Colormap, Flat);
                _boundaryBlockBall = new LineBall(_fightPlane, new LineSet(new Line[] { _boundaryBlock }) { Thickness = 0.2f }, LineBall.RenderEffect.HEIGHT, Colormap, Flat);

                update = true;
            }
            if (_lastSetting == null ||
                WindowStartChanged ||
                WindowWidthChanged ||
                ColormapChanged ||
                update)
            {
                _loadedBall.LowerBound = WindowStart;
                _loadedBall.UpperBound = WindowWidth + WindowStart;
                _loadedBall.UsedMap = Colormap;

                _blockBall.LowerBound = WindowStart;
                _blockBall.UpperBound = WindowWidth + WindowStart;
                _blockBall.UsedMap = Colormap;

                _boundaryBlockBall.LowerBound = WindowStart;
                _boundaryBlockBall.UpperBound = WindowWidth + WindowStart;
                _boundaryBlockBall.UsedMap = ColorMapping.GetComplementary(Colormap);

                _boundaryLoadedBall.LowerBound = WindowStart;
                _boundaryLoadedBall.UpperBound = WindowWidth + WindowStart;
                _boundaryLoadedBall.UsedMap = ColorMapping.GetComplementary(Colormap);
            }

            output.Add(Graph ? _blockBall : _loadedBall);
            output.Add(Graph ? _boundaryBlockBall : _boundaryLoadedBall);

            return output;
        }
Example #18
0
        private void Panel1_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = e.Location;

            //p = new Point(p.X - (int)mapVisualizer.OffsetX, p.Y - (int)mapVisualizer.OffsetY);
            p = new Point(p.X - (int)(mapVisualizer.OffsetX * mapVisualizer.ZoomScale),
                          p.Y - (int)(mapVisualizer.OffsetY * mapVisualizer.ZoomScale));
            PointF pf = mapVisualizer.TranslatePoint(p);
            //label1.Text = pf.ToString();
            Dot dot = null;

            if (selectedDot != null && dotMode == DotMode.Move)
            {
                if (pf.X < 0)
                {
                    pf.X = 0;
                }
                if (pf.Y < 0)
                {
                    pf.Y = 0;
                }
                //var s = panel1.ContentSize;
                //if (point.X > s.Width - 1) point.X = s.Width - 1;
                //if (point.Y > s.Height - 1) point.Y = s.Height - 1;

                selectedDot.Point = pf;
                dot = selectedDot;
                try
                {
                    lock (__lock)
                    {
                        cts.Cancel();
                        cts.Dispose();
                    }
                    cts = new CancellationTokenSource();
                    StepSync.Instance.Step();
                    work?.Join();
                    work = new Thread(arg =>
                    {
                        CancellationToken cancellation = (CancellationToken)arg;
                        try
                        {
                            Map.AutoFind(cancellation);
                        }
                        catch (Exception ex)
                        {
                            Invoke((Action)(() => MessageBox.Show(ex.ToString())));
                        }
                        lock (__lock)
                        {
                            if (!cancellation.IsCancellationRequested)
                            {
                                new Thread(() => Invoke((Action)(() => matrixImageView.Invalidate())))
                                {
                                    Name = "MatrixInvalidate"
                                }.Start();
                            }
                        }
                    })
                    {
                        Name = "MapAutoFind"
                    };
                    work.Start(cts.Token);
                    matrixImageView.Invalidate();

                    //if (Map.AutoRebuildLineSets)
                    //    Map.FindLines();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                dot = mapVisualizer.FindDotFromTranslatedPoint(pf);
            }
            if (dot != null)
            {
                string nl = Environment.NewLine;
                //label5.Text = $"Dot{nl}ID {dot.ID}{nl}{dot.Point}";
            }
            //else label5.Text = String.Empty;
            if (Map.LineSets.TryGetValue(1, out LineSet lineSet))
            {
                var pp = mapVisualizer.TranslatePoint(e.Location);
                LineSet.CheckContains(lineSet.dots.Select(a => a.Point).ToArray(), pp);
            }
        }
Example #19
0
        protected static void StructParse(StructParseContext ctx, Dictionary <string, TagProc> tagSet)
        {
            LineUtil.LineData ld = new LineUtil.LineData();
            //GEDSplitter gs = new GEDSplitter();

            int i   = ctx.Begline + 1;
            int max = ctx.Lines.Max;

            for (; i < max; i++)
            {
                try
                {
                    ctx.gs.LevelTagAndRemain(ctx.Lines.GetLine(i), ld);
                    //LineUtil.LevelTagAndRemain(ld, ctx.Lines.GetLine(i));
                }
                catch (Exception)
                {
                    UnkRec exc = new UnkRec();
                    exc.Beg   = exc.End = i;
                    exc.Error = UnkRec.ErrorCode.Exception;
                    // TODO exc.Error = "Exception during parse, skipping line";
                    ctx.Record.Errors.Add(exc); // TODO is Record only for errors?
                    continue;
                }

                if (ld.Level <= ctx.Level)
                {
                    break; // end of sub-record
                }
                ctx.Remain1 = ld.Remain1;

                if (ld.Tag == null)
                {
                    UnkRec exc = new UnkRec();
                    exc.Beg   = exc.End = i;
                    exc.Error = UnkRec.ErrorCode.MissTag;
                    // TODO exc.Error = "Exception during parse, skipping line";
                    // TODO not exception - missing tag / invalid linebreak
                    ctx.Record.Errors.Add(exc); // TODO is Record only for errors?
                    continue;
                }

                TagProc tagproc;
                if (tagSet.TryGetValue(ld.Tag, out tagproc))
                {
                    ctx.Begline = i;
                    ctx.Tag     = ld.Tag;
                    tagproc(ctx, i, ld.Level);
                }
                else
                {
                    LineSet extra    = new LineSet();
                    char    oldLevel = ctx.Level;
                    ctx.Begline = i;
                    ctx.Level   = ld.Level;
                    GedRecParse.LookAhead(ctx);
                    extra.Beg = ctx.Begline + ctx.Lines.Beg; // Make line #s relative to file
                    extra.End = ctx.Endline + ctx.Lines.Beg;
                    ctx.Parent.OtherLines.Add(extra);
                    ctx.Level = oldLevel;
                }
                i = Math.Max(ctx.Endline, i); // HACK: extendedText() may have advanced ctx.Endline further
            }
            ctx.Endline = i - 1;
            ld          = null;
            //gs = null;
        }
Example #20
0
        private void InitDockLayout()
        {
            _mapForm      = new ControlMapForm();
            _mapForm.Text = "GIS地图";
            _mapForm.Show(dockPanel1, DockState.Document);
            _mapForm.CloseButton = false;
            _mapForm.UiInitAndInvoke();
            _mapForm.Activate();



            MouseMoveOperator mouseMoveOperate;
            MouseDownOperator mouseDownOperate;

            sfHandle = new ShapeFileHandle(_mapForm.Map);

            #region 加载gis地图
            string[] str = { @"D:\光纤传感监测系统\Monitor\Monitor\data\底图.shp", @"D:\光纤传感监测系统\Monitor\Monitor\data\省界WGS 84.shp", @"D:\光纤传感监测系统\Monitor\Monitor\data\海缆WGS 84.tif" };
            mapLayer        = new MapLayer();
            MainLayerHandle = mapLayer.AddLayer(_mapForm.Map, str, "底图");

            _mapForm.MainLayerHandle = MainLayerHandle;
            _mapForm.SetMainLayerHandle();
            #endregion


            //	_mapForm.Map.ZoomToMaxExtents();
            _mapForm.Map.ZoomToLayer(MainLayerHandle);



            #region  在地图上划线
            ClassLine line      = new ClassLine();
            ClassLine line_1    = new ClassLine();
            GisPoint  gisPoint  = new GisPoint();
            LineSet   lineSet   = new LineSet(tkMapColor.Yellow, 6.0f, tkDashStyle.dsSolid);
            LineSet   lineSet_1 = new LineSet(tkMapColor.Red, 5.0f, tkDashStyle.dsCustom);
            gisPoint.connectToDB("Data Source=" + new DirectoryInfo("../../../../").FullName + "Monitor\\Monitor\\data\\data.db");
            gisPoint.readData();
            gisPoint.InitLineData(line);
            line_1.startX = gisPoint.m_PointList[15].X;
            line_1.startY = gisPoint.m_PointList[15].Y;
            line_1.endX   = gisPoint.m_PointList[20].X;
            line_1.endY   = gisPoint.m_PointList[20].Y;

            drawLine = new classDrawLine(_mapForm.Map);
            drawLine.WriteLine(line, lineSet);
            drawLine.WriteLine(line_1, lineSet_1);
            #endregion

            #region   在gis地图中添加ais数据
            //1、获取数据库中数据
            SqliteData sqlite = new SqliteData("Data Source=" + new DirectoryInfo("../../../../").FullName +
                                               "Monitor\\Monitor\\data\\data.db");
            DataTable gisData = sqlite.readData("Point");

            //2、实例化AISData类
            ais           = new AISData(_mapForm.Map, gisData);
            drawPoint_Ais = new classDrawPoint(MapForm.Map);

            //3、在地图上加载ais数据
            pointSet = new PointSet("AisReal", tkDefaultPointSymbol.dpsTriangleUp, tkMapColor.Red, 16);
            drawPoint_Ais.CreatPoint(ais.point, pointSet);
            drawPoint_Ais.EditAttribute();
            sfHandle.AddMouseMoveShapeFile("Ais", drawPoint_Ais.LayerHandle);
            #endregion


            #region
            drawPoint = new classDrawPoint(_mapForm.Map);
            var pnt = new ClassPoint();
            pnt.x   = 121.907567728461;
            pnt.y   = 30.8729913928844;
            pnt.str = "图片详情";
            string path = new DirectoryInfo("../../../../").FullName + "Monitor\\Monitor\\data\\ship3.png";
            drawPoint.AddPicture(pnt, path);
            drawPoint.EditAttribute();
            sfHandle.AddMouseDownShapeFile("pic", drawPoint.LayerHandle);
            #endregion


            _mapForm.Sf_MouseMove = sfHandle.Sf_MouseMove;
            _mapForm.Sf_MouseDown = sfHandle.Sf_MouseDown;


            mouseMoveOperate = new MouseMoveOperator(Operation.AddLabel);
            mouseDownOperate = new MouseDownOperator(Operation.AddLabel);

            //传入委托
            MapForm.MouseMoveOperate = mouseMoveOperate;
            MapForm.mouseDownOperate = mouseDownOperate;

            //var point = new ClassPoint();
            //point.x = 121.907567728461;
            //point.y = 30.8739913928844;
            //addText = new classAddText(_mapForm.Map, MainLayerHandle);
            //addText.AddText(point.x, point.y);
        }