Example #1
0
        bool sgworld_OnRButtonDown(int Flags, int X, int Y)
        {
            if (LClickCount <= 2)
            {
                MessageBox.Show("绘制三个以上点构造面!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.SgWorld.Creator.DeleteObject(pITerrainPolygon.ID);
                pITerrainPolygon = null;
                return(true);
            }
            if (pbhander == "modify" && pITerrainPolygon != null && this.earth != 0)
            {
                string    Volum      = "填挖方分析" + System.Guid.NewGuid().ToString().Substring(0, 6);
                IGeometry pIGeometry = pITerrainPolygon.Geometry;
                // ABhigh = pITerrainPolygon.Position.Altitude;
                pITerrainModifier = this.SgWorld.Creator.CreateTerrainModifier(pIGeometry, ElevationBehaviorMode.EB_REPLACE, true, 0, 0, Volum);
                pITerrainModifier.Position.AltitudeType = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                pITerrainModifier.Position.Altitude     = this.earth;

                this.SgWorld.Creator.DeleteObject(pITerrainPolygon.ID);
                pITerrainPolygon = null;
                String[] cVerticesArray = null;
                int      pobjitemid     = this.SgWorld.ProjectTree.FindItem(Volum);
                String   pObjid         = this.SgWorld.ProjectTree.GetTerraObjectID(pobjitemid);

                cVerticesArray = new String[] { pObjid };
                IVolumeAnalysisInfo61 pIVolumeAnalysisInfo = this.SgWorld.Analysis.CalculateVolume(cVerticesArray, 0.5);
                this.label1.Text = "【土方】增加:" + Math.Round(pIVolumeAnalysisInfo.AddedCubicMeters, 3).ToString() + "立方米" + "||减少:" + Math.Round(pIVolumeAnalysisInfo.RemovedCubicMeters, 3).ToString() + "立方米";
            }
            pbhander = "";

            return(true);
        }
Example #2
0
        /// <summary>
        /// TE 右键单击事件
        /// </summary>
        /// <param name="Flags"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="pbHandled"></param>
        void TE_OnRButtonDown(int Flags, int X, int Y, ref object pbHandled)
        {
            if (En == "DrawGeo" && !this.LockRButton)
            {
                try
                {
                    ITerraExplorerObject61 pp = this.SgWorld.Creator.GetObject(this.CurrObjectID);
                    this.mTerrainPolygon61 = pp as ITerrainPolygon61;
                    IGeometry        geo              = this.mTerrainPolygon61.Geometry;
                    IPolygon         pPolygon         = geo as IPolygon;
                    ISpatialOperator _SpatialOperator = pPolygon.SpatialOperator;

                    uint nLineColor = 0xFF00FF00; // Abgr value -> solid green
                    uint nFillColor = 0x7FFF0000; // Abgr value -> 50% transparent blue

                    this.geo = _SpatialOperator.buffer((double)this.spinEdit1.Value);
                    this.SgWorld.Creator.CreatePolygon(this.geo, nLineColor, nFillColor, AltitudeTypeCode.ATC_ON_TERRAIN, GroupID, "Buffer" + System.Guid.NewGuid().ToString().Substring(0, 6));
                    this.LockRButton = true;
                    //Program.TE.Save();

                    this.En = null;
                    this.simpleButton2.Checked = false;
                }
                catch (Exception)
                {
                }
            }
        }
Example #3
0
 //左键单击
 bool sgworld_OnLButtonDown(int Flags, int X, int Y)
 {
     try
     {
         if (pbhander == "modify")
         {
             LClickCount++;
             //点击三个点以前画线,三个点以后画面
             double longitude, latitude, height;
             (this.TerraExplorer as IRender5).ScreenToTerrain(X, Y, out longitude, out latitude, out height);
             IPosition61 pIPosition = this.SgWorld.Navigate.GetPosition(AltitudeTypeCode.ATC_TERRAIN_RELATIVE);
             if (LClickCount < 3)
             {
                 this.pITerrainPolyline.AddVertex(longitude, height, latitude, 0);
                 ListVerticsArray.Add(longitude);
                 ListVerticsArray.Add(latitude);
                 ListVerticsArray.Add(pIPosition.Distance);
             }
             else
             {
                 if (LClickCount == 3)
                 {
                     ListVerticsArray.Add(longitude);
                     ListVerticsArray.Add(latitude);
                     ListVerticsArray.Add(pIPosition.Distance);
                     double[] tripletArray = new double[ListVerticsArray.Count];
                     ListVerticsArray.CopyTo(tripletArray, 0);
                     IColor61         LineColor         = this.SgWorld.Creator.CreateColor(Color.Red.R, Color.Red.G, Color.Red.B, Color.Red.A);
                     IColor61         FillColor         = this.SgWorld.Creator.CreateColor(Color.Red.R, Color.Red.G, Color.Red.B, 0);
                     AltitudeTypeCode eAltitudeTypeCode = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                     pITerrainPolygon = this.SgWorld.Creator.CreatePolygonFromArray(tripletArray, LineColor, FillColor, eAltitudeTypeCode, GroupID, "TempPolygon");
                     this.SgWorld.ProjectTree.DeleteItem(this.pITerrainPolyline.InfoTreeItemID);
                 }
                 else
                 {
                     if (pITerrainPolygon != null)
                     {
                         IPolygon pPolygon = pITerrainPolygon.Geometry as IPolygon;
                         pPolygon.StartEdit();
                         foreach (ILinearRing r in pPolygon.Rings)
                         {
                             r.Points.AddPoint(longitude, latitude, pIPosition.Distance);
                         }
                         pITerrainPolygon.Geometry = pPolygon.EndEdit();
                     }
                 }
             }
         }
     }
     catch
     {
         MessageBox.Show("地形调整范围绘制失败!");
     }
     return(true);
 }
Example #4
0
        //右键结束画面,同时根据设置生成限高面
        void TE_OnRButtonDown(int Flags, int X, int Y, ref object pbHandled)
        {
            if (StartDraw)
            {
                try
                {
                    StartDraw = false;
                    pbHandled = true;
                    Program.pRender.SetMouseInputMode(MouseInputMode.MI_FREE_FLIGHT);
                    Program.sgworld.ProjectTree.DeleteItem(this.polyLine.InfoTreeItemID);

                    IColor61 LineColor = Program.pCreator6.CreateColor(this.colorEditLmtHeight.Color.R, this.colorEditLmtHeight.Color.G,
                                                                       this.colorEditLmtHeight.Color.B, this.colorEditLmtHeight.Color.A);
                    int      Alpha     = (int)(255 * (this.zoomOpacity.Value / 100.0));
                    IColor61 FillColor = Program.pCreator6.CreateColor(this.colorEditLmtHeight.Color.R, this.colorEditLmtHeight.Color.G,
                                                                       this.colorEditLmtHeight.Color.B, Alpha);
                    if (list != null)
                    {
                        if (list.Count > 2)
                        {
                            double[] tripletArray = new double[list.Count];
                            list.CopyTo(tripletArray, 0);
                            CurrentControlHeight = Program.pCreator6.CreatePolygonFromArray(tripletArray, LineColor, FillColor, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, GroupID, "Controlheight");
                            list.Clear();
                            this.simpleBtnClear.Enabled = true;
                        }
                        else
                        {
                            MessageBox.Show("至少绘制三个点!");
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("绘制失败!");
                    list.Clear();
                    if (this.polyLine.NumOfVertices > 0)
                    {
                        for (int i = this.polyLine.NumOfVertices; i > 0; i--)
                        {
                            this.polyLine.DeleteVertex(i);
                        }
                    }
                }
            }
        }
Example #5
0
 /// <summary>
 /// TE 右键单击事件
 /// </summary>
 /// <param name="Flags"></param>
 /// <param name="X"></param>
 /// <param name="Y"></param>
 /// <param name="pbHandled"></param>
 void TE_OnRButtonDown(int Flags, int X, int Y, ref object pbHandled)
 {
     if (!this.lock_OnRButton)
     {
         try
         {
             ITerraExplorerObject61 pp = this.SgWorld.Creator.GetObject(this.CurrObjectID);
             this.pTerrainPolygon61 = pp as ITerrainPolygon61;
             geo = this.pTerrainPolygon61.Geometry;
             this.timer1.Enabled = true;
             // double SurfaceArea = Math.Round(this.SgWorld.Analysis.MeasureTerrainSurface(geo, 10), 2);
             // this.labelControl1.Text = "区域内表面积:" + SurfaceArea.ToString() + "平方米";
             this.lock_OnRButton = true;
         }
         catch (Exception)
         {
         }
     }
 }
Example #6
0
        /// <summary>
        /// TE 右键单击事件
        /// </summary>
        /// <param name="Flags"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="pbHandled"></param>
        void TE_OnRButtonDown(int Flags, int X, int Y, ref object pbHandled)
        {
            if (!this.lock_OnRButton)
            {
                try
                {
                    ITerraExplorerObject61 pp = this.SgWorld.Creator.GetObject(this.CurrObjectID);
                    this.pTerrainPolygon61 = pp as ITerrainPolygon61;
                    geo = this.pTerrainPolygon61.Geometry;
                    this.timer1.Enabled = true;
                    // double SurfaceArea = Math.Round(this.SgWorld.Analysis.MeasureTerrainSurface(geo, 10), 2);
                    // this.labelControl1.Text = "区域内表面积:" + SurfaceArea.ToString() + "平方米";
                    this.lock_OnRButton = true;
                }
                catch (Exception)
                {

                }

            }
        }
Example #7
0
        bool m_EventHook_OnLButtonUp(int Flags, int X, int Y)
        {
            double longitude, latitude, height;

            this.m_TerraExplorer.ScreenToTerrain(X, Y, out longitude, out latitude, out height);

            double viewerHeight = (double)speViewer.Value;

            if (m_Root == null)
            {
                m_RootX = longitude;
                m_RootY = latitude;

                double[] points =
                {
                    longitude, latitude, 0,
                    longitude, latitude, viewerHeight
                };

                ILineString geoLine = m_Hook.Creator.GeometryCreator.CreateLineStringGeometry(points);

                // 创建Root
                m_Root = m_Hook.Creator.CreatePolyline(geoLine as IGeometry, 0xFF00ffff, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, m_GroupID, m_RootName);
                m_Root.ExtendToGround = true;
                m_Root.SaveInFlyFile  = false;
            }
            else
            {
                try
                {
                    // 创建视域分析
                    double dis = this.m_TerraExplorer.ICoordSys3_GetDistance(m_RootX, m_RootY, longitude, latitude);
                    //Math.Sqrt((latitude - m_RootY) * (latitude - m_RootY) + (longitude - m_RootX) * (longitude - m_RootX));
                    //if (dis < 0.1) // 防止除以0
                    //    dis = 0.1;


                    if (dis <= viewerHeight)// 操他妈的必须大于视点高
                    {
                        dis = viewerHeight + 0.01;
                    }

                    double rawArc = Math.Atan2(latitude - m_RootY, longitude - m_RootX);
                    rawArc = 180 * rawArc / Math.PI;
                    //double rawArc = Math.Asin((latitude - m_RootY) / dis);//(longitude - m_RootX));
                    //rawArc = 180 * rawArc / Math.PI;
                    //if (longitude < m_RootX)
                    //    rawArc = 180 - rawArc;

                    // skyline中视域分析角度与数学角度转换
                    rawArc = rawArc - 90;

                    double disViewshed = dis;
                    disViewshed = Math.Sqrt(disViewshed * disViewshed - viewerHeight * viewerHeight);
                    IPosition61 pMouse = m_Hook.Creator.CreatePosition(m_RootX, m_RootY, viewerHeight, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, rawArc, 0, 0, disViewshed);

                    int index = 1;
                    while (true)
                    {
                        if (m_Hook.ProjectTree.FindItem(string.Format("视域分析\\视域分析{0}", index)) > 0)
                        {
                            index++;
                        }
                        else
                        {
                            break;
                        }
                    }
                    string strViewshed = string.Format("视域分析{0}", index);
                    int    viewshedID  = m_Hook.Analysis.CreateViewshed(pMouse, (double)speField.Value, (double)speSample.Value, (double)speRay.Value, (double)speTarget.Value, null, null, m_GroupID, strViewshed);

                    if (viewshedID <= 0)
                    {
                        MessageBox.Show("分析出现了错误");
                        return(false);
                    }

                    // 修改视域分析结果
                    string viewshedFull = string.Format("视域分析\\视域分析{0}", index);
                    // 删掉Root
                    m_Hook.ProjectTree.DeleteItem(m_Root.TreeItem.ItemID);
                    m_Root = null;
                    // 换掉Left,Right,Arc
                    int leftRay = m_Hook.ProjectTree.FindItem(string.Format("{0}\\{1}", viewshedFull, m_LeftRayName));
                    if (leftRay > 0)
                    {
                        m_Hook.ProjectTree.DeleteItem(leftRay);
                    }
                    int rightRay = m_Hook.ProjectTree.FindItem(string.Format("{0}\\{1}", viewshedFull, m_RightRayName));
                    if (rightRay > 0)
                    {
                        m_Hook.ProjectTree.DeleteItem(rightRay);
                    }
                    int arc = m_Hook.ProjectTree.FindItem(string.Format("{0}\\{1}", viewshedFull, m_ArcName));
                    if (arc > 0)
                    {
                        m_Hook.ProjectTree.DeleteItem(arc);
                    }

                    m_Hook.ProjectTree.SetParent(m_LeftRay.TreeItem.ItemID, viewshedID);
                    m_Hook.ProjectTree.SetParent(m_RightRay.TreeItem.ItemID, viewshedID);
                    m_Hook.ProjectTree.SetParent(m_Arc.TreeItem.ItemID, viewshedID);

                    // Visible和InVisible修改高度方式和高度
                    int vID   = m_Hook.ProjectTree.FindItem(string.Format("{0}\\{1}", viewshedFull, m_VisibleArea));
                    int invID = m_Hook.ProjectTree.FindItem(string.Format("{0}\\{1}", viewshedFull, m_InvisibleArea));
                    if (vID > 0 && invID > 0)
                    {
                        object[] objAreas =
                        {
                            m_Hook.ProjectTree.GetObject(vID),
                            m_Hook.ProjectTree.GetObject(invID)
                        };

                        foreach (object objArea in objAreas)
                        {
                            ITerrainPolygon61 polygon = objArea as ITerrainPolygon61;
                            polygon.Position.AltitudeType = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                            polygon.Position.Altitude     = (double)speTarget.Value;
                        }
                    }

                    m_LeftRay  = null;
                    m_RightRay = null;
                    m_Arc      = null;

                    this.Close();
                }
                catch
                {
                    MessageBox.Show("很抱歉,分析过程出现错误");
                }
            }

            return(false);
        }
Example #8
0
        bool sgworld_OnLButtonDown(int Flags, int X, int Y)
        {
            if (pbhander == "modify")
            {
                LClickCount++;
                IWorldPointInfo61 pIWPInfo = this.SgWorld.Window.PixelToWorld(X, Y, WorldPointType.WPT_TERRAIN);
                IPosition61 pIPosition = this.SgWorld.Navigate.GetPosition(AltitudeTypeCode.ATC_TERRAIN_RELATIVE);

                if (pITerrainPolygon == null)
                {
                    try
                    {
                        ILinearRing cRing = null;
                        double[] cVerticesArray = null;
                        cVerticesArray = new double[] {
                    pIPosition.X,  pIPosition.Y,  0,
                    pIWPInfo.Position.X,  pIWPInfo.Position.Y,  0,
                    pIWPInfo.Position.X,  pIWPInfo.Position.Y,  0,
                    };
                        cRing = this.SgWorld.Creator.GeometryCreator.CreateLinearRingGeometry(cVerticesArray);

                        uint nLineColor = 0xFF00FF00;
                        uint nFillColor = 0x7FFF0000;
                        AltitudeTypeCode eAltitudeTypeCode = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                        pITerrainPolygon = this.SgWorld.Creator.CreatePolygon(cRing, nLineColor, nFillColor, eAltitudeTypeCode, 0, "Polygon");

                        IPolygon polygonGeometry = pITerrainPolygon.Geometry as IPolygon;
                        polygonGeometry.StartEdit();
                        foreach (ILinearRing ring in polygonGeometry.Rings)
                        {
                            double dx = pIWPInfo.Position.X;
                            double dy = pIWPInfo.Position.Y;
                            double dh = pIWPInfo.Position.Distance;
                            ring.Points.AddPoint(dx, dy, dh);
                            ring.Points.DeletePoint(0);
                        }
                        IGeometry editedGeometry = polygonGeometry.EndEdit();
                        pITerrainPolygon.Geometry = editedGeometry;
                    }
                    catch (Exception)
                    {

                    }

                }
                else
                {
                    try
                    {
                        IPolygon polygonGeometry = pITerrainPolygon.Geometry as IPolygon;
                        polygonGeometry.StartEdit();
                        foreach (ILinearRing ring in polygonGeometry.Rings)
                        {
                            double dx = pIWPInfo.Position.X;
                            double dy = pIWPInfo.Position.Y;
                            double dh = pIWPInfo.Position.Distance;
                            ring.Points.AddPoint(dx, dy, dh);
                        }
                        IGeometry editedGeometry = polygonGeometry.EndEdit();
                        pITerrainPolygon.Geometry = editedGeometry;
                    }
                    catch (Exception)
                    {

                    }

                }
            }
            return false;
        }
Example #9
0
        bool sgworld_OnRButtonDown(int Flags, int X, int Y)
        {
            if (LClickCount<=2)
            {
                MessageBox.Show("绘制三个以上点构造面!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                this.SgWorld.Creator.DeleteObject(pITerrainPolygon.ID);
                pITerrainPolygon = null;
                return true;
            }
            if (pbhander == "modify" && pITerrainPolygon != null && this.earth != 0 )
            {
                string Volum = "填挖方分析" + System.Guid.NewGuid().ToString().Substring(0, 6);
                IGeometry pIGeometry = pITerrainPolygon.Geometry;
               // ABhigh = pITerrainPolygon.Position.Altitude;
                pITerrainModifier = this.SgWorld.Creator.CreateTerrainModifier(pIGeometry, ElevationBehaviorMode.EB_REPLACE, true, 0, 0, Volum);
                pITerrainModifier.Position.AltitudeType = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                pITerrainModifier.Position.Altitude = this.earth;

                this.SgWorld.Creator.DeleteObject(pITerrainPolygon.ID);
                pITerrainPolygon = null;
                String[] cVerticesArray = null;
                int pobjitemid = this.SgWorld.ProjectTree.FindItem(Volum);
                String pObjid = this.SgWorld.ProjectTree.GetTerraObjectID(pobjitemid);

                cVerticesArray = new String[] { pObjid };
                IVolumeAnalysisInfo61 pIVolumeAnalysisInfo = this.SgWorld.Analysis.CalculateVolume(cVerticesArray, 0.5);
                this.label1.Text = "【土方】增加:" + Math.Round(pIVolumeAnalysisInfo.AddedCubicMeters,3).ToString() + "立方米" + "||减少:" + Math.Round(pIVolumeAnalysisInfo.RemovedCubicMeters,3).ToString() + "立方米";
            }
            pbhander = "";

            return true;
        }
Example #10
0
        /// <summary>
        /// TE 右键单击事件
        /// </summary>
        /// <param name="Flags"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="pbHandled"></param>
        void TE_OnRButtonDown(int Flags, int X, int Y, ref object pbHandled)
        {
            if ( En =="DrawGeo"&&!this.LockRButton)
            {
                try
                {
                    ITerraExplorerObject61 pp = this.SgWorld.Creator.GetObject(this.CurrObjectID);
                    this.mTerrainPolygon61 = pp as ITerrainPolygon61;
                    IGeometry geo = this.mTerrainPolygon61.Geometry;
                    IPolygon pPolygon = geo as IPolygon;
                    ISpatialOperator _SpatialOperator = pPolygon.SpatialOperator;

                    uint nLineColor = 0xFF00FF00; // Abgr value -> solid green
                    uint nFillColor = 0x7FFF0000; // Abgr value -> 50% transparent blue

                    this.geo = _SpatialOperator.buffer((double)this.spinEdit1.Value);
                    this.SgWorld.Creator.CreatePolygon(this.geo, nLineColor, nFillColor, AltitudeTypeCode.ATC_ON_TERRAIN, GroupID, "Buffer" + System.Guid.NewGuid().ToString().Substring(0, 6));
                    this.LockRButton = true;
                    //Program.TE.Save();

                    this.En = null;
                    this.simpleButton2.Checked = false;
                }
                catch (Exception)
                {

                }

            }
        }
Example #11
0
        /// <summary>
        /// 鼠标左键按下时发生的事件(建立缓冲区的主要方法)
        /// </summary>
        /// <param name="Flags"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="pbHandled"></param>
        void TE_OnLButtonDown(int Flags, int X, int Y, ref object pbHandled)
        {
            if (En == "DrawGeo")
            {
            }
            else if (En == "SelectModle")
            {
                // 2012-9-20 张航宇
                // 若成功的完成了一次缓冲分析,则将状态释放,要求重新点击
                IWorldPointInfo61 pIWorldPointInfo = this.SgWorld.Window.PixelToWorld(X, Y, WorldPointType.WPT_MODEL);
                if (pIWorldPointInfo.ObjectID != "" && pIWorldPointInfo.ObjectID != null)
                {
                    try
                    {
                        ITerraExplorerObject61 pp = this.SgWorld.Creator.GetObject(pIWorldPointInfo.ObjectID);
                        if (pp.ObjectType == ObjectTypeCode.OT_FEATURE)
                        {
                            IFeature61 pIF = pp as IFeature61;
                            this.geo = pIF.GeometryZ.SpatialOperator.buffer((double)this.spinEdit1.Value);
                            ITerrainPolygon61 polygon = this.SgWorld.Creator.CreatePolygon(this.geo, -16711936, -10197916, cbRelative.Checked?AltitudeTypeCode.ATC_TERRAIN_RELATIVE: AltitudeTypeCode.ATC_ON_TERRAIN, GroupID, "Buffer" + System.Guid.NewGuid().ToString().Substring(0, 6));

                            if (cbRelative.Checked)
                            {
                                polygon.Position.Altitude = (double)speHeight.Value;
                            }

                            this.En             = null;
                            this.Select.Checked = false;
                        }
                        else
                        {
                            ITerrainModel61 pITerrainModel = this.SgWorld.Creator.GetObject(pIWorldPointInfo.ObjectID) as ITerrainModel61;
                            IBBox3D61       pBBox          = pITerrainModel.Terrain.BBox;
                            cVerticesArray = new double[] {
                                pBBox.MaxX, pBBox.MinY, 0,
                                pBBox.MaxX, pBBox.MaxY, 0,
                                pBBox.MinX, pBBox.MaxY, 0,
                                pBBox.MinX, pBBox.MinY, 0,
                            };
                            ILinearRing cRing            = this.SgWorld.Creator.GeometryCreator.CreateLinearRingGeometry(cVerticesArray);
                            IPolygon    cPolygonGeometry = this.SgWorld.Creator.GeometryCreator.CreatePolygonGeometry(cRing, null);
                            //this.geo = cPolygonGeometry as IGeometry;
                            ISpatialOperator _SpatialOperator = cPolygonGeometry.SpatialOperator;

                            this.geo = _SpatialOperator.buffer((double)this.spinEdit1.Value);
                            ITerrainPolygon61 polygon = this.SgWorld.Creator.CreatePolygon(this.geo, -16711936, -10197916, cbRelative.Checked ? AltitudeTypeCode.ATC_TERRAIN_RELATIVE : AltitudeTypeCode.ATC_ON_TERRAIN, GroupID, "Buffer" + System.Guid.NewGuid().ToString().Substring(0, 6));

                            if (cbRelative.Checked)
                            {
                                polygon.Position.Altitude = (double)speHeight.Value;
                            }

                            this.En             = null;
                            this.Select.Checked = false;
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
Example #12
0
        //左键单击
        bool sgworld_OnLButtonDown(int Flags, int X, int Y)
        {
            try
            {
                if (pbhander == "modify")
                {
                    LClickCount++;
                    //点击三个点以前画线,三个点以后画面
                    double longitude, latitude, height;
                    (this.TerraExplorer as IRender5).ScreenToTerrain(X, Y, out longitude, out latitude, out height);
                    IPosition61 pIPosition = this.SgWorld.Navigate.GetPosition(AltitudeTypeCode.ATC_TERRAIN_RELATIVE);
                    if (LClickCount < 3)
                    {
                        this.pITerrainPolyline.AddVertex(longitude, height, latitude, 0);
                        ListVerticsArray.Add(longitude);
                        ListVerticsArray.Add(latitude);
                        ListVerticsArray.Add(pIPosition.Distance);
                    }
                    else
                    {
                        if (LClickCount == 3)
                        {
                            ListVerticsArray.Add(longitude);
                            ListVerticsArray.Add(latitude);
                            ListVerticsArray.Add(pIPosition.Distance);
                            double[] tripletArray = new double[ListVerticsArray.Count];
                            ListVerticsArray.CopyTo(tripletArray, 0);
                            IColor61 LineColor = this.SgWorld.Creator.CreateColor(Color.Red.R, Color.Red.G, Color.Red.B, Color.Red.A);
                            IColor61 FillColor = this.SgWorld.Creator.CreateColor(Color.Red.R, Color.Red.G, Color.Red.B, 0);
                            AltitudeTypeCode eAltitudeTypeCode = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                            pITerrainPolygon = this.SgWorld.Creator.CreatePolygonFromArray(tripletArray, LineColor, FillColor, eAltitudeTypeCode, GroupID, "TempPolygon");
                            this.SgWorld.ProjectTree.DeleteItem(this.pITerrainPolyline.InfoTreeItemID);
                        }
                        else
                        {
                            if (pITerrainPolygon != null)
                            {
                                IPolygon pPolygon = pITerrainPolygon.Geometry as IPolygon;
                                pPolygon.StartEdit();
                                foreach (ILinearRing r in pPolygon.Rings)
                                {
                                    r.Points.AddPoint(longitude, latitude, pIPosition.Distance);
                                }
                                pITerrainPolygon.Geometry = pPolygon.EndEdit();
                            }
                        }
                    }
                }

            }
            catch
            {
                MessageBox.Show("地形调整范围绘制失败!");
            }
            return true;
        }
Example #13
0
        bool sgworld_OnLButtonDown(int Flags, int X, int Y)
        {
            if (pbhander == "modify")
            {
                LClickCount++;
                IWorldPointInfo61 pIWPInfo   = this.SgWorld.Window.PixelToWorld(X, Y, WorldPointType.WPT_TERRAIN);
                IPosition61       pIPosition = this.SgWorld.Navigate.GetPosition(AltitudeTypeCode.ATC_TERRAIN_RELATIVE);

                if (pITerrainPolygon == null)
                {
                    try
                    {
                        ILinearRing cRing          = null;
                        double[]    cVerticesArray = null;
                        cVerticesArray = new double[] {
                            pIPosition.X, pIPosition.Y, 0,
                            pIWPInfo.Position.X, pIWPInfo.Position.Y, 0,
                            pIWPInfo.Position.X, pIWPInfo.Position.Y, 0,
                        };
                        cRing = this.SgWorld.Creator.GeometryCreator.CreateLinearRingGeometry(cVerticesArray);

                        uint             nLineColor        = 0xFF00FF00;
                        uint             nFillColor        = 0x7FFF0000;
                        AltitudeTypeCode eAltitudeTypeCode = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                        pITerrainPolygon = this.SgWorld.Creator.CreatePolygon(cRing, nLineColor, nFillColor, eAltitudeTypeCode, 0, "Polygon");

                        IPolygon polygonGeometry = pITerrainPolygon.Geometry as IPolygon;
                        polygonGeometry.StartEdit();
                        foreach (ILinearRing ring in polygonGeometry.Rings)
                        {
                            double dx = pIWPInfo.Position.X;
                            double dy = pIWPInfo.Position.Y;
                            double dh = pIWPInfo.Position.Distance;
                            ring.Points.AddPoint(dx, dy, dh);
                            ring.Points.DeletePoint(0);
                        }
                        IGeometry editedGeometry = polygonGeometry.EndEdit();
                        pITerrainPolygon.Geometry = editedGeometry;
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    try
                    {
                        IPolygon polygonGeometry = pITerrainPolygon.Geometry as IPolygon;
                        polygonGeometry.StartEdit();
                        foreach (ILinearRing ring in polygonGeometry.Rings)
                        {
                            double dx = pIWPInfo.Position.X;
                            double dy = pIWPInfo.Position.Y;
                            double dh = pIWPInfo.Position.Distance;
                            ring.Points.AddPoint(dx, dy, dh);
                        }
                        IGeometry editedGeometry = polygonGeometry.EndEdit();
                        pITerrainPolygon.Geometry = editedGeometry;
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            return(false);
        }
Example #14
0
        //右键结束画面,同时根据设置生成限高面
        void TE_OnRButtonDown(int Flags, int X, int Y, ref object pbHandled)
        {
            if (StartDraw)
            {
                try
                {
                    StartDraw = false;
                    pbHandled = true;
                    Program.pRender.SetMouseInputMode(MouseInputMode.MI_FREE_FLIGHT);
                    Program.sgworld.ProjectTree.DeleteItem(this.polyLine.InfoTreeItemID);

                    IColor61 LineColor = Program.pCreator6.CreateColor(this.colorEditLmtHeight.Color.R, this.colorEditLmtHeight.Color.G,
                                                                       this.colorEditLmtHeight.Color.B, this.colorEditLmtHeight.Color.A);
                    int Alpha = (int)(255 * (this.zoomOpacity.Value / 100.0));
                    IColor61 FillColor = Program.pCreator6.CreateColor(this.colorEditLmtHeight.Color.R, this.colorEditLmtHeight.Color.G,
                                                     this.colorEditLmtHeight.Color.B, Alpha);
                    if (list != null)
                    {
                        if (list.Count > 2)
                        {
                            double[] tripletArray = new double[list.Count];
                            list.CopyTo(tripletArray, 0);
                            CurrentControlHeight = Program.pCreator6.CreatePolygonFromArray(tripletArray, LineColor, FillColor, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, GroupID, "Controlheight");
                            list.Clear();
                            this.simpleBtnClear.Enabled = true;
                        }
                        else
                            MessageBox.Show("至少绘制三个点!");
                    }
                }
                catch
                {
                    MessageBox.Show("绘制失败!");
                    list.Clear();
                    if(this.polyLine.NumOfVertices > 0)
                    {
                        for (int i = this.polyLine.NumOfVertices; i > 0; i--)
                             this.polyLine.DeleteVertex(i);
                    }
                }
            }
        }