Example #1
0
        public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
        {
            ISceneGraph sceneGraph = this._plugin.SceneGraph;
            IPoint      point;
            object      obj;
            object      obj2;

            sceneGraph.Locate(sceneGraph.ActiveViewer, int_2, int_3, esriScenePickMode.esriScenePickAll, true, out point, out obj, out obj2);
            if (point != null)
            {
                ICamera camera = this._plugin.Camera;
                if (camera.ProjectionType == esri3DProjectionType.esriOrthoProjection)
                {
                    camera.Target = point;
                    sceneGraph.ActiveViewer.Redraw(true);
                }
                else
                {
                    IPoint target   = camera.Target;
                    IPoint observer = camera.Observer;
                    camera.Target = point;
                    camera.PolarUpdate(1.0, 0.0, 0.0, true);
                    IPoint observer2 = camera.Observer;
                    double num;
                    double num2;
                    sceneGraph.GetDrawingTimeInfo(out num, out num2);
                    if (num < 0.01)
                    {
                        num = 0.01;
                    }
                    int num3 = (int)(2.0 / num);
                    if (num3 < 1)
                    {
                        num3 = 1;
                    }
                    if (num3 > 60)
                    {
                        num3 = 60;
                    }
                    double num4 = (observer2.X - observer.X) / (double)num3;
                    double num5 = (observer2.Y - observer.Y) / (double)num3;
                    double num6 = (observer2.Z - observer.Z) / (double)num3;
                    double num7 = (point.X - target.X) / (double)num3;
                    double num8 = (point.Y - target.Y) / (double)num3;
                    double num9 = (point.Z - target.Z) / (double)num3;
                    for (int i = 0; i < num3; i++)
                    {
                        observer2.X     = observer.X + (double)i * num4;
                        observer2.Y     = observer.Y + (double)i * num5;
                        observer2.Z     = observer.Z + (double)i * num6;
                        point.X         = target.X + (double)i * num7;
                        point.Y         = target.Y + (double)i * num8;
                        point.Z         = target.Z + (double)i * num9;
                        camera.Observer = observer2;
                        camera.Target   = point;
                        sceneGraph.ActiveViewer.Redraw(true);
                    }
                }
            }
        }
Example #2
0
        public void EndFlight()
        {
            this.bool_0 = false;
            ISceneGraph sceneGraph = this._plugin.SceneGraph;
            IPoint      point      = new Point();

            System.Drawing.Rectangle rectangle = default(System.Drawing.Rectangle);
            if (ToolSceneFly.GetClientRect(this._plugin.ActiveViewer.hWnd, ref rectangle) != 0)
            {
                object obj;
                object obj2;
                sceneGraph.Locate(sceneGraph.ActiveViewer, rectangle.Right / 2, rectangle.Bottom / 2, esriScenePickMode.esriScenePickAll, true, out point, out obj, out obj2);
            }
            ICamera camera = this._plugin.Camera;

            if (point != null)
            {
                camera.Target   = point;
                camera.Observer = this.ipoint_0;
            }
            camera.RollAngle = 0.0;
            camera.PropertiesChanged();
            ToolSceneFly.SetCursor(this.cursor_1.Handle.ToInt32());
            this.int_0 = 0;
        }
Example #3
0
        public static IPoint XYToPoint(ISceneGraph isceneGraph_0, int int_0, int int_1)
        {
            IPoint       result       = null;
            ISceneViewer activeViewer = isceneGraph_0.ActiveViewer;
            object       obj;
            object       obj2;

            isceneGraph_0.Locate(activeViewer, int_0, int_1, esriScenePickMode.esriScenePickGeography, true, out result, out obj, out obj2);
            obj  = null;
            obj2 = null;
            return(result);
        }
Example #4
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            //Get the scene graph
            ISceneGraph pSceneGraph = m_pSceneHookHelper.SceneGraph;

            //Get the scene
            IScene pScene = (IScene)m_pSceneHookHelper.Scene;

            IPoint pPoint;
            object pOwner, pObject;

            //Translate screen coordinates into a 3D point
            pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out pPoint, out pOwner, out pObject);

            //Get a selection environment
            ISelectionEnvironment pSelectionEnv;

            pSelectionEnv = new SelectionEnvironmentClass();

            if (Shift == 0)
            {
                pSelectionEnv.CombinationMethod = ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew;

                //Clear previous selection
                if (pOwner == null)
                {
                    pScene.ClearSelection();
                    return;
                }
            }
            else
            {
                pSelectionEnv.CombinationMethod = ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultAdd;
            }

            //If the layer is a selectable feature layer
            if (pOwner is IFeatureLayer)
            {
                IFeatureLayer pFeatureLayer = (IFeatureLayer)pOwner;

                if (pFeatureLayer.Selectable == true)
                {
                    //Select by Shape
                    pScene.SelectByShape(pPoint, pSelectionEnv, false);
                }
            }

            //Refresh the scene viewer
            pSceneGraph.RefreshViewers();
        }
Example #5
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            //Get the scene graph
            ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph;

            IPoint pPoint;
            object pOwner, pObject;

            //Translate screen coordinates into a 3D point
            pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGraphics, false,
                               out pPoint, out pOwner, out pObject);

            IGraphicsSelection pGraphicsSelection;

            if (pObject == null)
            {
                if (Shift == 0)
                {
                    //Unselect selected graphics from the
                    //basic graphics layer and each layer
                    pGraphicsSelection = pSceneGraph.Scene.BasicGraphicsLayer as IGraphicsSelection;
                    pGraphicsSelection.UnselectAllElements();

                    for (int i = 0; i < pSceneGraph.Scene.LayerCount - 1; i++)
                    {
                        ILayer pLayer = (ILayer)pSceneGraph.Scene.get_Layer(i);
                        pGraphicsSelection = pLayer as IGraphicsSelection;
                        pGraphicsSelection.UnselectAllElements();
                    }
                }
            }
            else
            {
                pGraphicsSelection = pOwner as IGraphicsSelection;

                //Unselect any selected graphics
                if (Shift == 0)
                {
                    pGraphicsSelection.UnselectAllElements();
                }

                //Select element
                IElement pElement = (IElement)pObject;
                pGraphicsSelection.SelectElement(pElement);
            }

            //Refresh the scene viewer
            pSceneGraph.ActiveViewer.Redraw(false);
        }
Example #6
0
        public static IPoint XYToFeature(ISceneGraph isceneGraph_0, int int_0, int int_1, out IFeature ifeature_0, out IFeatureLayer ifeatureLayer_0)
        {
            ifeature_0      = null;
            ifeatureLayer_0 = null;
            ISceneViewer activeViewer = isceneGraph_0.ActiveViewer;
            IPoint       result;
            object       obj;
            object       obj2;

            isceneGraph_0.Locate(activeViewer, int_0, int_1, esriScenePickMode.esriScenePickGeography, true, out result, out obj, out obj2);
            if (obj2 != null && obj2 is IFeature)
            {
                ifeature_0      = (obj2 as IFeature);
                ifeatureLayer_0 = (obj as IFeatureLayer);
            }
            obj  = null;
            obj2 = null;
            return(result);
        }
Example #7
0
        public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
        {
            ISceneGraph sceneGraph = this._plugin.SceneGraph;
            IPoint      point;
            object      obj;
            object      obj2;

            sceneGraph.Locate(sceneGraph.ActiveViewer, int_2, int_3, esriScenePickMode.esriScenePickAll, true, out point, out obj, out obj2);
            if (point != null)
            {
                ICamera camera   = this._plugin.Camera;
                IPoint  observer = camera.Observer;
                double  num;
                double  num2;
                sceneGraph.GetDrawingTimeInfo(out num, out num2);
                if (num < 0.01)
                {
                    num = 0.01;
                }
                int num3 = (int)(2.0 / num);
                if (num3 < 1)
                {
                    num3 = 1;
                }
                if (num3 > 60)
                {
                    num3 = 60;
                }
                double num4 = (point.X - observer.X) / (double)num3;
                double num5 = (point.Y - observer.Y) / (double)num3;
                double num6 = (point.Z - observer.Z) / (double)num3;
                for (int i = 0; i <= num3; i++)
                {
                    point.X         = observer.X + (double)i * num4;
                    point.Y         = observer.Y + (double)i * num5;
                    point.Z         = observer.Z + (double)i * num6;
                    camera.Observer = point;
                    sceneGraph.ActiveViewer.Redraw(true);
                }
            }
        }
Example #8
0
        public void EndFlight()
        {
            m_bInUse = false;

            //Get the scene graph
            ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph;

            IPoint pPointTgt;

            pPointTgt = new PointClass();
            object    pOwner, pObject;
            Rectangle rect = new Rectangle();

            //Windows API call to get windows client coordinates
            if (GetClientRect(m_pSceneHookHelper.ActiveViewer.hWnd, ref rect) != 0)
            {
                //Translate coordinates into a 3D point
                pSceneGraph.Locate(pSceneGraph.ActiveViewer, rect.Right / 2, rect.Bottom / 2, esriScenePickMode.esriScenePickAll, true, out pPointTgt, out pOwner, out pObject);
            }

            //Get the camera
            ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera;

            if (pPointTgt != null)
            {
                //Reposition target and observer
                pCamera.Target   = pPointTgt;
                pCamera.Observer = m_pPointObs;
            }

            //Set the angle of the camera about the line
            //of sight between the observer and target
            pCamera.RollAngle = 0;
            pCamera.PropertiesChanged();

            //Windows API call to set cursor
            SetCursor(m_moveFlyCur.Handle.ToInt32());
            m_iSpeed = 0;
        }
Example #9
0
        /// <summary>
        /// 获取点击地图上的点
        /// </summary>
        /// <param name="Button"></param>
        /// <param name="Shift"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            try
            {
                ESRI.ArcGIS.Geometry.IPoint pMapPoint = new ESRI.ArcGIS.Geometry.PointClass();;
                ISceneGraph pSceneGraph = m_sceneHookHelper.SceneGraph;
                object      pOwner;
                object      pObject;
                object      before   = Type.Missing;
                object      after    = Type.Missing;
                object      StepSize = Type.Missing;
                IDisplay3D  pDisplay;
                pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out pMapPoint, out pOwner, out pObject); //获取鼠标点击的位置并转化为地理坐标
                if (pMapPoint == null)
                {
                    return;
                }
                pMapPoint.Z = pMapPoint.Z / m_sceneHookHelper.Scene.ExaggerationFactor;
                pMapPoint.Z = m_psurface.GetElevation(pMapPoint);
                pMapPoint.SpatialReference = pSceneGraph.Scene.SpatialReference;
                pDisplay = m_sceneHookHelper.SceneGraph as IDisplay3D;
                pDisplay.FlashLocation(pMapPoint);//闪烁显示被点击的位置
                IGeometry pGeom = null;
                Cls3DMarkDraw.DeleteAllElementsWithName(m_sceneHookHelper.Scene, sPolyOutlineName);
                //根据绘制对象类型的不同定义不同的类型
                switch (m_DrawType.ToString())
                {
                case "esriGeometryPoint":
                    m_Geometry = pMapPoint;
                    break;

                case "esriGeometryLine":
                    if (m_pPointColl == null)
                    {
                        m_pPointColl = new PolylineClass();
                        pGeom        = new PolylineClass();
                    }
                    m_pPointColl.AddPoint(pMapPoint, ref before, ref after);
                    break;

                case "esriGeometryPolygon":
                    if (m_pPointColl == null)
                    {
                        m_pPointColl = new PolygonClass();
                        pGeom        = new PolygonClass();
                    }
                    m_pPointColl.AddPoint(pMapPoint, ref before, ref after);
                    break;
                }

                //BeginDrawed(true);

                IGroupElement pGroup = null;
                if (m_pPointColl.PointCount == 1)
                {
                    //当为一个点时绘制点
                    Cls3DMarkDraw.AddSimpleGraphic(pMapPoint, Cls3DMarkDraw.getRGB(71, 61, 255), 4, sPolyOutlineName, m_sceneHookHelper.Scene, pGroup);
                }
                else if (m_DrawType.ToString() == "esriGeometryLine")
                {
                    pGeom = m_pPointColl as IGeometry;
                    pGeom.SpatialReference = pMapPoint.SpatialReference;
                    m_psurface.InterpolateShape(pGeom, out pGeom, ref StepSize);
                    Cls3DMarkDraw.AddSimpleGraphic(pGeom, Cls3DMarkDraw.getRGB(71, 61, 255), 4, sPolyOutlineName, m_sceneHookHelper.Scene, pGroup);
                    m_pPointColl = pGeom as IPointCollection;
                }
                else
                {
                    ITopologicalOperator pTopo = m_pPointColl as ITopologicalOperator;
                    pGeom = pTopo.Boundary;
                    pGeom.SpatialReference = pMapPoint.SpatialReference;
                    m_psurface.InterpolateShape(pGeom, out pGeom, ref StepSize);
                    Cls3DMarkDraw.AddSimpleGraphic(pGeom, Cls3DMarkDraw.getRGB(71, 61, 255), 4, sPolyOutlineName, m_sceneHookHelper.Scene, pGroup);
                }

                m_sceneHookHelper.SceneGraph.RefreshViewers();
            }
            catch
            {
                return;
            }
        }
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (!m_bInUse)
            {
                return;
            }

            try
            {
                if (GetCapture(m_pSceneHookHelper.ActiveViewer.hWnd) != 0)
                {
                    ReleaseCapture(m_pSceneHookHelper.ActiveViewer.hWnd);
                }

                //Get the scene viewer's camera
                ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera;

                //Get the scene graph
                ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph;

                //Create envelope
                IEnvelope pEnvelope;
                CreateEnvelope(X, Y, out pEnvelope);

                IPoint pPoint;
                object pOwner, pObject;

                if (pEnvelope.Width == 0 || pEnvelope.Height == 0)
                {
                    //Translate screen coordinates into a 3D point
                    pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickAll, true,
                                       out pPoint, out pOwner, out pObject);

                    //Set camera target and zoom in
                    pCamera.Target = pPoint;
                    pCamera.Zoom(1.3333333333333);
                }
                else
                {
                    //Get dimension of the scene viewer window
                    Rectangle rect;
                    rect = new Rectangle();

                    if (GetWindowRect(m_pSceneHookHelper.ActiveViewer.hWnd, ref rect) == 0)
                    {
                        return;
                    }

                    //If perspective (3D) view
                    if (pCamera.ProjectionType == esri3DProjectionType.esriPerspectiveProjection)
                    {
                        double dWidth, dHeight;

                        dWidth  = Math.Abs(rect.Right - rect.Left) * (Math.Abs(rect.Right - rect.Left) / pEnvelope.Width);
                        dHeight = Math.Abs(rect.Top - rect.Bottom) * (Math.Abs(rect.Top - rect.Bottom) / pEnvelope.Height);

                        pPoint = new PointClass();
                        pPoint.PutCoords(pEnvelope.XMin + (pEnvelope.Width / 2), pEnvelope.YMin + (pEnvelope.Height / 2));

                        //Redimension envelope based on scene viewer dimensions
                        pEnvelope.XMin   = pPoint.X - (dWidth / 2);
                        pEnvelope.YMin   = pPoint.Y - (dHeight / 2);
                        pEnvelope.Width  = dWidth;
                        pEnvelope.Height = dHeight;

                        //Zoom camera to the envelope
                        pCamera.ZoomToRect(pEnvelope);
                    }
                    else
                    {
                        //Translate screen coordinates into a 3D point
                        pSceneGraph.Locate(pSceneGraph.ActiveViewer, (int)(pEnvelope.XMin + (pEnvelope.Width / 2)),
                                           (int)(pEnvelope.YMin + (pEnvelope.Height / 2)), esriScenePickMode.esriScenePickAll, true,
                                           out pPoint, out pOwner, out pObject);

                        //Set camera target
                        pCamera.Target = pPoint;

                        double dx, dy;
                        dx = pEnvelope.Width;
                        dy = pEnvelope.Height;

                        //Determine zoom factor
                        if (dx > 0 && dy > 0)
                        {
                            dx = Math.Abs(rect.Right - rect.Left) / dx;
                            dy = Math.Abs(rect.Top - rect.Bottom) / dy;

                            if (dx < dy)
                            {
                                pCamera.Zoom(dx);
                            }
                            else
                            {
                                pCamera.Zoom(dy);
                            }
                        }
                        else
                        {
                            pCamera.Zoom(1.3333333333333);
                        }
                    }
                }
            }
            finally
            {
                //Redraw the scene viewer
                ISceneViewer pSceneViewer = (ISceneViewer)m_pSceneHookHelper.ActiveViewer;
                pSceneViewer.Redraw(true);


                m_bInUse = false;
            }
        }
Example #11
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            //Get the scene graph
            ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph;

            IPoint pNewObs;
            object pOwner, pObject;

            //Translate screen coordinates into a 3D point
            pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickAll, true,
                               out pNewObs, out pOwner, out pObject);

            if (pNewObs == null)
            {
                return;
            }

            //Get the scene viewer's camera
            ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera;

            //Get the camera's old observer
            IPoint pOldObs = (IPoint)pCamera.Observer;

            //Get the duration in seconds of last redraw
            //and the average number of frames per second
            double dlastFrameDuration, dMeanFrameRate;

            pSceneGraph.GetDrawingTimeInfo(out dlastFrameDuration, out dMeanFrameRate);

            if (dlastFrameDuration < 0.01)
            {
                dlastFrameDuration = 0.01;
            }

            int iSteps;

            iSteps = (int)(2 / dlastFrameDuration);
            if (iSteps < 1)
            {
                iSteps = 1;
            }

            if (iSteps > 60)
            {
                iSteps = 60;
            }

            double dxObs, dyObs, dzObs;

            dxObs = (pNewObs.X - pOldObs.X) / iSteps;
            dyObs = (pNewObs.Y - pOldObs.Y) / iSteps;
            dzObs = (pNewObs.Z - pOldObs.Z) / iSteps;

            //Loop through each step moving the camera's observer from the old
            //position to the new position, refreshing the scene viewer each time
            for (int i = 0; i <= iSteps; i++)
            {
                pNewObs.X        = pOldObs.X + (i * dxObs);
                pNewObs.Y        = pOldObs.Y + (i * dyObs);
                pNewObs.Z        = pOldObs.Z + (i * dzObs);
                pCamera.Observer = pNewObs;
                pSceneGraph.ActiveViewer.Redraw(true);
            }
        }
Example #12
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            //Get the scene graph
            ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph;

            IPoint pNewTgt;
            object pOwner, pObject;

            //Translate screen coordinates into a 3D point
            pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickAll, true,
                               out pNewTgt, out pOwner, out pObject);

            if (pNewTgt == null)
            {
                return;
            }

            //Get the scene viewer's camera
            ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera;

            //If orthographic (2D) view
            if (pCamera.ProjectionType == esri3DProjectionType.esriOrthoProjection)
            {
                //Set the camera's new target
                pCamera.Target = pNewTgt;

                //Redraw the scene viewer
                pSceneGraph.ActiveViewer.Redraw(true);
            }
            else
            {
                //Get the camera's old target and observer
                IPoint pOldTgt, pOldObs;
                pOldTgt = pCamera.Target;
                pOldObs = pCamera.Observer;

                //Set the camera's new target and get the new observer
                pCamera.Target = pNewTgt;
                pCamera.PolarUpdate(1, 0, 0, true);

                IPoint pNewObs = (IPoint)pCamera.Observer;

                //Get the duration in seconds of last redraw
                //and the average number of frames per second
                double dlastFrameDuration, dMeanFrameRate;
                pSceneGraph.GetDrawingTimeInfo(out dlastFrameDuration, out dMeanFrameRate);

                if (dlastFrameDuration < 0.01)
                {
                    dlastFrameDuration = 0.01;
                }

                int iSteps;
                iSteps = (int)(2 / dlastFrameDuration);
                if (iSteps < 1)
                {
                    iSteps = 1;
                }

                if (iSteps > 60)
                {
                    iSteps = 60;
                }

                double dxObs, dyObs, dzObs;
                double dxTgt, dyTgt, dzTgt;

                dxObs = (pNewObs.X - pOldObs.X) / iSteps;
                dyObs = (pNewObs.Y - pOldObs.Y) / iSteps;
                dzObs = (pNewObs.Z - pOldObs.Z) / iSteps;

                dxTgt = (pNewTgt.X - pOldTgt.X) / iSteps;
                dyTgt = (pNewTgt.Y - pOldTgt.Y) / iSteps;
                dzTgt = (pNewTgt.Z - pOldTgt.Z) / iSteps;

                //Loop through each step moving the camera's observer and target from the
                //old positions to the new positions, refreshing the scene viewer each time
                for (int i = 0; i < iSteps; i++)
                {
                    pNewObs.X = pOldObs.X + (i * dxObs);
                    pNewObs.Y = pOldObs.Y + (i * dyObs);
                    pNewObs.Z = pOldObs.Z + (i * dzObs);

                    pNewTgt.X = pOldTgt.X + (i * dxTgt);
                    pNewTgt.Y = pOldTgt.Y + (i * dyTgt);
                    pNewTgt.Z = pOldTgt.Z + (i * dzTgt);

                    pCamera.Observer = pNewObs;
                    pCamera.Target   = pNewTgt;
                    pSceneGraph.ActiveViewer.Redraw(true);
                }
            }
        }
Example #13
0
        /// <summary>
        /// 通过鼠标点击获取观察点与被观察点同时进行两点间通视分析
        /// </summary>
        /// <param name="Button"></param>
        /// <param name="Shift"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (m_frm3DLineOfSight.m_Layer == null || m_frm3DLineOfSight.m_Surface == null)
            {
                MessageBox.Show("请设置有效的表面数据", "提示!");
                return;
            }
            if (m_frm3DLineOfSight.txtObsOffset.Text == "" || m_frm3DLineOfSight.txtTarOffset.Text == "")
            {
                MessageBox.Show("观察点高度和被观察点高度不能为空", "提示!");
                return;
            }
            m_frm3DLineOfSight.TopMost = true;
            ISceneGraph pSceneGraph = m_sceneHookHelper.SceneGraph;

            m_pNewLineFeedback = new NewLineFeedbackClass();
            IPolyline       pPolyline        = m_pNewLineFeedback.Stop(); //用于判断是否已经获取两点
            ISceneControl   pSceneControl    = m_sceneHookHelper.Hook as ISceneControl;
            Cls3DModulsefun pCls3DModulsefun = new Cls3DModulsefun();     //用于绘制通视分析结果的方法
            object          pOwner;
            object          pObject;

            ESRI.ArcGIS.Geometry.IPoint pPoint = new ESRI.ArcGIS.Geometry.PointClass();
            pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out pPoint, out pOwner, out pObject);//获取鼠标点击的位置并转化为地理坐标
            if (pPoint == null)
            {
                return;
            }
            ESRI.ArcGIS.Geometry.IPoint pFlashPoint = new ESRI.ArcGIS.Geometry.PointClass();
            IClone pClone = pPoint as IClone;

            pFlashPoint   = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
            pFlashPoint.Z = pFlashPoint.Z / pSceneGraph.VerticalExaggeration;
            pFlashPoint.SpatialReference = pSceneGraph.Scene.SpatialReference;
            IDisplay3D pDisplay = pSceneGraph as IDisplay3D;

            pDisplay.FlashLocation(pFlashPoint);//闪烁显示被点击的位置
            IGeometry pGeometry = null;

            if (m_pScenePoints == null)
            {
                m_pScenePoints             = new PolylineClass();
                pGeometry                  = m_pScenePoints as IGeometry;
                pGeometry.SpatialReference = pSceneGraph.Scene.SpatialReference;
            }
            object before = Type.Missing;
            object after  = Type.Missing;

            m_pScenePoints.AddPoint(pPoint, ref before, ref after);//添加获取的点到点集合中
            if (m_pScenePoints.PointCount == 2)
            {
                pClone         = m_pScenePoints as IClone;
                pPolyline      = pClone.Clone() as  ESRI.ArcGIS.Geometry.IPolyline;//当点集合中点数达到两个时生成一条线用于判断观察点与被观察点是否确定
                m_pScenePoints = null;
            }
            if (pPolyline != null)
            {
                m_pScenePoints = null;
                ISurface pSurface = m_SurFace;
                ESRI.ArcGIS.Geometry.IPoint fPoint = pPolyline.FromPoint; //获取观察点
                fPoint.Z = pSurface.GetElevation(fPoint);                 //获取观察点的高程
                ESRI.ArcGIS.Geometry.IPoint tPoint = pPolyline.ToPoint;
                tPoint.Z = pSurface.GetElevation(tPoint);
                if (pSurface.IsVoidZ(fPoint.Z) || pSurface.IsVoidZ(tPoint.Z))
                {
                    return;
                }
                fPoint.Z = fPoint.Z + Convert.ToDouble(m_frm3DLineOfSight.txtObsOffset.Text);//观察者的高度加上观察者所在的高程才是观察点实际的高程
                tPoint.Z = tPoint.Z + Convert.ToDouble(m_frm3DLineOfSight.txtTarOffset.Text);
                ESRI.ArcGIS.Geometry.IPoint pObstruct;
                IPolyline pVisPolyline;
                IPolyline pInVisPolyline;
                bool      bIsVis;
                object    pRefractionFactor = Type.Missing;
                //进行两点间的通视分析
                pSurface.GetLineOfSight(fPoint, tPoint, out pObstruct, out pVisPolyline, out pInVisPolyline, out bIsVis, m_frm3DLineOfSight.checkBoxCurv.Checked, m_frm3DLineOfSight.checkBoxCurv.Checked, ref pRefractionFactor);

                ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
                pSimpleLineSymbol.Width = 2;
                pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                //绘制可视与不可视的沿地表线要素
                if (pVisPolyline != null)
                {
                    pSimpleLineSymbol.Color = Cls3DMarkDraw.getRGB(0, 255, 0);
                    pCls3DModulsefun.AddGraphic(pSceneControl, pVisPolyline as IGeometry, pSimpleLineSymbol as ISymbol);
                }
                if (pInVisPolyline != null)
                {
                    pSimpleLineSymbol.Color = Cls3DMarkDraw.getRGB(255, 0, 0);
                    pCls3DModulsefun.AddGraphic(pSceneControl, pInVisPolyline as IGeometry, pSimpleLineSymbol as ISymbol);
                }
                IGeometryCollection pVisPatch = new MultiPatchClass();//用于存储可视域的要素
                pGeometry = pVisPatch as IGeometry;
                pGeometry.SpatialReference = pSceneGraph.Scene.SpatialReference;
                double              dTargetHeightForVis = 0;
                ISimpleFillSymbol   pSimpleFillSymbol   = new SimpleFillSymbolClass();
                IGeometryCollection pInVisPatch         = new MultiPatchClass();//存储不可视域的要素
                pGeometry = pInVisPatch as IGeometry;
                pGeometry.SpatialReference = pSceneGraph.Scene.SpatialReference;
                IGeometryCollection pPathGeo = pInVisPolyline as IGeometryCollection;
                if (pPathGeo != null)
                {
                    //下面的作用是将不可视域线每段path生成线要素进行绘制       张琪  20110623
                    for (int i = 0; i < pPathGeo.GeometryCount; i++)
                    {
                        IGeometryCollection pInPolyline = new PolylineClass();
                        IPath path = pPathGeo.get_Geometry(i) as IPath;
                        pInPolyline.AddGeometry(path as IGeometry, ref before, ref after);
                        pCls3DModulsefun.CreateVerticalLOSPatches(bIsVis, fPoint, tPoint, pVisPolyline, pInPolyline as IPolyline, pVisPatch, pInVisPatch, dTargetHeightForVis);
                    }
                }
                else//当不可视域为空时,直接分析生成可视域与不可视域
                {
                    pCls3DModulsefun.CreateVerticalLOSPatches(bIsVis, fPoint, tPoint, pVisPolyline, pInVisPolyline, pVisPatch, pInVisPatch, dTargetHeightForVis);
                }
                //
                // 对可视域与不可视域要素在场景中绘制出来
                if (pInVisPatch != null)
                {
                    pSimpleFillSymbol.Color = Cls3DMarkDraw.getRGB(255, 0, 0);
                    pCls3DModulsefun.AddGraphic(pSceneControl, pInVisPatch as IGeometry, pSimpleFillSymbol as ISymbol);
                }
                if (pVisPatch != null)
                {
                    pSimpleFillSymbol.Color = Cls3DMarkDraw.getRGB(0, 255, 0);
                    pCls3DModulsefun.AddGraphic(pSceneControl, pVisPatch as IGeometry, pSimpleFillSymbol as ISymbol);
                }
            }
        }
Example #14
0
 public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
 {
     if (this.bool_0)
     {
         try
         {
             ICamera     camera     = this._plugin.Camera;
             ISceneGraph sceneGraph = this._plugin.SceneGraph;
             IEnvelope   envelope;
             this.CreateEnvelope(int_2, int_3, out envelope);
             if (envelope.Width == 0.0 || envelope.Height == 0.0)
             {
                 IPoint point;
                 object obj;
                 object obj2;
                 sceneGraph.Locate(sceneGraph.ActiveViewer, int_2, int_3, esriScenePickMode.esriScenePickAll, true, out point, out obj, out obj2);
                 if (point != null)
                 {
                     camera.Target = point;
                 }
                 camera.Zoom(0.75);
             }
             else if (camera.ProjectionType == esri3DProjectionType.esriPerspectiveProjection)
             {
                 camera.ZoomToRect(envelope);
             }
             else
             {
                 IPoint point;
                 object obj;
                 object obj2;
                 sceneGraph.Locate(sceneGraph.ActiveViewer, (int)(envelope.XMin + envelope.Width / 2.0), (int)(envelope.YMin + envelope.Height / 2.0), esriScenePickMode.esriScenePickAll, true, out point, out obj, out obj2);
                 if (point != null)
                 {
                     camera.Target = point;
                 }
                 System.Drawing.Rectangle rectangle = default(System.Drawing.Rectangle);
                 if (ToolSceneZoomIn.GetWindowRect(this._plugin.ActiveViewer.hWnd, ref rectangle) == 0)
                 {
                     return;
                 }
                 double num  = envelope.Width;
                 double num2 = envelope.Height;
                 if (num > 0.0 && num2 > 0.0)
                 {
                     num  /= (double)Math.Abs(rectangle.Right - rectangle.Left);
                     num2 /= (double)Math.Abs(rectangle.Top - rectangle.Bottom);
                     if (num > num2)
                     {
                         camera.Zoom(num);
                     }
                     else
                     {
                         camera.Zoom(num2);
                     }
                 }
                 else
                 {
                     camera.Zoom(0.75);
                 }
             }
         }
         catch
         {
         }
         ISceneViewer activeViewer = this._plugin.ActiveViewer;
         activeViewer.Redraw(true);
         if (this.graphics_0 != null)
         {
             this.graphics_0.Dispose();
             this.graphics_0 = null;
         }
         this.bool_0 = false;
     }
 }