private bool NodeFilterFunction(PowerNode node)
        {
            if (node.X < SW_LON || node.X > NE_LON || node.Y < SW_LAT || node.Y > NE_LAT)
            {
                return(false);
            }

            return(true);
        }
        private HitTestResultBehavior HitTestCallback(HitTestResult result)
        {
            RayHitTestResult htResult = result as RayHitTestResult;

            if (htResult != null)
            {
                if (nodeModels.ContainsKey(htResult.ModelHit))
                {
                    tooltip           = new ToolTip();
                    tooltip.Content   = nodeModels[htResult.ModelHit].ToolTip;
                    tooltip.IsOpen    = true;
                    tooltip.Placement = System.Windows.Controls.Primitives.PlacementMode.Mouse;

                    return(HitTestResultBehavior.Stop);
                }

                if (selectedModel1 != null)
                {
                    Material mat = new DiffuseMaterial(Brushes.Red);
                    selectedModel1.Material = oldMaterial1;
                    selectedModel2.Material = oldMaterial2;
                }

                if (lineModels.ContainsKey(htResult.ModelHit))
                {
                    PowerLine line = lineModels[htResult.ModelHit];
                    PowerNode pn1  = nodeMap.IdToNodeDictionary[line.FirstEnd];
                    PowerNode pn2  = nodeMap.IdToNodeDictionary[line.SecondEnd];

                    GeometryModel3D pn1Model = nodeModels.FirstOrDefault(n => n.Value == pn1).Key as GeometryModel3D;
                    GeometryModel3D pn2Model = nodeModels.FirstOrDefault(n => n.Value == pn2).Key as GeometryModel3D;

                    // Save old materials to restore on deselect
                    selectedModel1 = pn1Model;
                    selectedModel2 = pn2Model;
                    oldMaterial1   = pn1Model.Material;
                    oldMaterial2   = pn2Model.Material;

                    Material mat = new DiffuseMaterial(Brushes.GreenYellow);
                    pn1Model.Material = mat;
                    pn2Model.Material = mat;

                    // Show tooltip
                    tooltip           = new ToolTip();
                    tooltip.Content   = lineModels[htResult.ModelHit].ToolTip;
                    tooltip.IsOpen    = true;
                    tooltip.Placement = System.Windows.Controls.Primitives.PlacementMode.Mouse;
                }
            }

            return(HitTestResultBehavior.Stop);
        }