//清除所有可视域分析
        private void btn_Clear_Click(object sender, EventArgs e)
        {
            this.RegisterEvents(false);

            int nCount = m_viewshed3DList.Count();
            int i      = 0;

            for (i = 0; i < nCount; i++)
            {
                Viewshed3D viewShed = m_viewshed3DList[i];
                viewShed.Clear();
            }
            m_viewshed3DList.Clear();

            if (m_viewshed3D != null)
            {
                m_viewshed3D = null;
            }

            m_sceneControl.Action = Action3D.Pan;

            this.btn_Analyst.Enabled      = true;
            this.btn_StopAnalysis.Enabled = false;
            this.btn_Clear.Enabled        = false;
        }
        void m_sceneControl_Tracking(object sender, Tracking3DEventArgs e)
        {
            if (m_sceneControl.Action == Action3D.CreateLine)
            {
                if (m_bHasDone)
                {
                    m_viewshed3D = CreateViewShed3D();
                    m_bHasDone   = false;
                }
                if (m_viewshed3D != null)
                {
                    GeoLine3D geoline3d = e.Geometry as GeoLine3D;
                    if (geoline3d.PartCount > 0)
                    {
                        Point3Ds pts = geoline3d[0];

                        m_viewshed3D.ViewerPosition = pts[0];
                        updateObserverPosition(m_viewshed3D);

                        m_viewshed3D.SetDistDirByPoint(pts[1]);
                        updateParam(m_viewshed3D, false);
                    }
                }
            }
        }
        private Viewshed3D CreateViewShed3D()
        {
            //新建ViewShed对象
            Viewshed3D viewShed = new Viewshed3D(m_sceneControl.Scene);

            this.updateParam(viewShed, true);

            if (m_colorScheme == ColorScheme.Standand)
            {
                viewShed.VisibleAreaColor = Color.Green;
                viewShed.HiddenAreaColor  = Color.Red;
            }
            else if (m_colorScheme == ColorScheme.Custom)
            {
                viewShed.VisibleAreaColor = Color.Yellow;
                viewShed.HiddenAreaColor  = Color.Blue;
            }
            else if (m_colorScheme == ColorScheme.Random)
            {
                Random rand = new Random();
                viewShed.VisibleAreaColor = Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255));
                viewShed.HiddenAreaColor  = Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255));
            }

            viewShed.HintLineColor = m_hintLineColor;
            m_viewshed3DList.Add(viewShed);
            viewShed.Build();

            return(viewShed);
        }
 /// <summary>
 /// 数据更新, bFlag = false时,用ViewShed对象的属性值更新界面参数
 /// bFlag = true时,用界面参数值更新ViewShed对象的属性值
 /// </summary>
 /// <param name="viewshed3D"></param>
 /// <param name="bFlag"></param>
 void updateParam(Viewshed3D viewshed3D, bool bFlag)
 {
     if (bFlag == false)
     {
         this.numeric_Distance.Value      = Convert.ToDecimal(viewshed3D.Distance);
         this.numeric_Direction.Value     = Convert.ToDecimal(viewshed3D.Direction);
         this.numeric_HorizontalFOV.Value = Convert.ToDecimal(viewshed3D.HorizontalFov);
         this.numeric_VerticalFOV.Value   = Convert.ToDecimal(viewshed3D.VerticalFov);
         this.numeric_Pitch.Value         = Convert.ToDecimal(viewshed3D.Pitch);
     }
     else
     {
         viewshed3D.Distance      = Convert.ToDouble(this.numeric_Distance.Value);
         viewshed3D.Direction     = Convert.ToDouble(this.numeric_Direction.Value);
         viewshed3D.HorizontalFov = Convert.ToDouble(this.numeric_HorizontalFOV.Value);
         viewshed3D.VerticalFov   = Convert.ToDouble(this.numeric_VerticalFOV.Value);
         viewshed3D.Pitch         = Convert.ToDouble(this.numeric_Pitch.Value);
     }
 }
        //窗体关闭事件
        private void DlgViewShedAnalysis_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.RegisterEvents(false);

            int nCount = m_viewshed3DList.Count();
            int i      = 0;

            for (i = 0; i < nCount; i++)
            {
                Viewshed3D viewShed = m_viewshed3DList[i];
                viewShed.Clear();
            }
            m_viewshed3DList.Clear();

            if (m_viewshed3D != null)
            {
                m_viewshed3D = null;
            }
            m_sceneControl.Action = Action3D.Pan;
        }
 //更新观察点坐标
 void updateObserverPosition(Viewshed3D viewshed)
 {
     this.tb_ObserverX.Text      = Convert.ToString(viewshed.ViewerPosition.X);
     this.tb_ObserverY.Text      = Convert.ToString(viewshed.ViewerPosition.Y);
     this.tb_ObserverHeight.Text = Convert.ToString(viewshed.ViewerPosition.Z);
 }