ホームページ  >  記事  >  バックエンド開発  >  Styline二次開発をC#で動作させて線描画機能を実現

Styline二次開発をC#で動作させて線描画機能を実現

黄舟
黄舟オリジナル
2017-10-05 15:30:211843ブラウズ

c# スタイラインモデルを操作するには、モデルを左クリックして座標を取得し、線描画操作を完了します。

1: マウスクリックモデルイベント


 List<IPosition66> pos = new List<IPosition66>();
        private bool Sgworld_OnLButtonClicked(int Flags, int X, int Y)
        {
           
            var sgworld = new SGWorld66();
            var postioninfo = sgworld.Window.PixelToWorld(X, Y);
            IPosition66 ss = postioninfo.Position;
            ss.X = postioninfo.Position.X;
            ss.Y = postioninfo.Position.Y;
            pos.Add(ss); 
            return false;
        } 

2: 操作線描画


  string tMsg = String.Empty;
            ILinearRing cRing = null;
            IGeometry cPolygonGeometry = null;
            ITerrainPolyline66 cpolyo = null;
            //创建实例
            //MessageBox.Show(String.Format("X:{0}\r\nY:{1}", posl[i].PosX, posl[i].PosX));
            var sgworld = new SGWorld66();
            List<IPosition66> posl = pos;
            int sin = 0;
            sin = posl.Count*3;
            double[] cVerticesArray = new double[sin];
            //获取坐标值
            for (int i = 0; i < posl.Count; i++)
            { 
                cVerticesArray[i*3] = posl[i].X;
                cVerticesArray[i*3+1] = posl[i].Y;
                cVerticesArray[i * 3 + 2] = posl[i].Altitude;
            } 
            {
                cRing = sgworld.Creator.GeometryCreator.CreateLinearRingGeometry(cVerticesArray);
                cPolygonGeometry = sgworld.Creator.GeometryCreator.CreateLinearRingGeometry(cRing);
            } 
            {
                uint nLineColor = 0xFF00FF00; //颜色样式
                AltitudeTypeCode AltitudeType = AltitudeTypeCode.ATC_ON_TERRAIN;
                // D2. Create polygon
                cpolyo = sgworld.Creator.CreatePolyline(cPolygonGeometry, nLineColor, AltitudeType, string.Empty, "Polygon");
                ///注意坐标
                sgworld.Window.PixelToWorld(sgworld.Window.Rect.Left, sgworld.Window.Rect.Top, WorldPointType.WPT_TERRAIN);
            }

以上がStyline二次開発をC#で動作させて線描画機能を実現の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。