示例#1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            newRender = new SimpleGeometryRender();
            newRender.RenderGroupField = this.comboBox1.Text;

            if (IsSimplePoint)
            {
                ISimplePointSymbol newSymbol = new SimplePointSymbol();
                if (this.dataGridView2.Rows[0].Cells[1].Value.ToString() != "")
                {
                    newSymbol.Alignment = StringToGviPivotAlignment(this.dataGridView2.Rows[0].Cells[1].Value.ToString());
                }
                if (this.dataGridView2.Rows[1].Cells[1].Value.ToString() != "")
                {
                    newSymbol.Size = int.Parse(this.dataGridView2.Rows[1].Cells[1].Value.ToString());
                }

                if (this.dataGridView1.Rows[0].Cells[1].Value.ToString() != "")
                {
                    string colstr = this.dataGridView1.Rows[0].Cells[1].Value.ToString();
                    Color  col    = Utils.HexNumberToColor(colstr);
                    newSymbol.FillColor = col;
                }
                if (this.dataGridView1.Rows[1].Cells[1].Value.ToString() != "")
                {
                    newSymbol.Style = StringToSimplePointStyle(this.dataGridView1.Rows[1].Cells[1].Value.ToString());
                }

                newRender.Symbol = newSymbol;
            }
            else
            {
                IImagePointSymbol newSymbol = new ImagePointSymbol();
                if (this.dataGridView2.Rows[0].Cells[1].Value.ToString() != "")
                {
                    newSymbol.Alignment = StringToGviPivotAlignment(this.dataGridView2.Rows[0].Cells[1].Value.ToString());
                }
                if (this.dataGridView2.Rows[1].Cells[1].Value.ToString() != "")
                {
                    newSymbol.Size = int.Parse(this.dataGridView2.Rows[1].Cells[1].Value.ToString());
                }

                if (this.checkBox1.Checked)
                {
                    newSymbol.ImageName = this.textBoxPicturePath.Text;
                }
                else
                {
                    newSymbol.ImageName = this.textBoxPictureName.Text;
                }

                newRender.Symbol = newSymbol;
            }
        }
示例#2
0
文件: MainForm.cs 项目: batuZ/Samples
        //private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        //{
        //    dsManager.DeleteNetworkDataset("newNetworkDataset");
        //}

        private void btnSelectLocation_Click(object sender, System.EventArgs e)
        {
            clear();
            clearDeep();

            #region 我在这(两点间最优路径)
            if (((Button)sender).Name == "btnImHere")
            {
                this.axRenderControl1.Camera.GetCamera2(out fdepoint, out ang);
                try
                {
                    INetworkLocation location = new NetworkLocation();
                    location.Position = fdepoint;
                    routeSolver.AddLocation(location);
                }
                catch (COMException ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }

                if (txtLocationNames.Text == "")
                {
                    txtLocationNames.Text = "I'm Here!";
                }
                else
                {
                    txtLocationNames.Text = txtLocationNames.Text + Environment.NewLine + "I'm Here!";
                }
                IImagePointSymbol ips = new ImagePointSymbol();
                ips.ImageName = "#(i)";
                ips.Size      = 50;
                renderPoint   = this.axRenderControl1.ObjectManager.CreateRenderPoint(fdepoint, ips, rootId);
                renderPoint.MaxVisibleDistance = 10000;
                MessageBox.Show("请选择您想去的终点");
            }
            #endregion

            // 注册控件拾取事件
            this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);

            this.axRenderControl1.RcMouseClickSelect += new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);

            this.axRenderControl1.InteractMode          = gviInteractMode.gviInteractSelect;
            this.axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectFeatureLayer;
            this.axRenderControl1.MouseSelectMode       = gviMouseSelectMode.gviMouseSelectClick;
        }
示例#3
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);
            this.axRenderControl1.Camera.FlyTime = 1;

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "FeatureLayerSimpleRender.html";
            }

            layerEnvelopeMap = new Hashtable();
            layerFcMap       = new Hashtable();

            // 可视化Point类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\point.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                ISimpleTextRender textRender = new SimpleTextRender();
                textRender.Expression = "''..$(oid)";
                ITextSymbol   textSymbol    = new TextSymbol();
                TextAttribute textAttribute = new TextAttribute();
                textAttribute.TextColor   = System.Drawing.Color.Red;
                textSymbol.TextAttribute  = textAttribute;
                textSymbol.PivotAlignment = gviPivotAlignment.gviPivotAlignBottomCenter;
                textSymbol.VerticalOffset = 10;
                // 注意:必须设置symbol,默认文字不显示
                textRender.Symbol = textSymbol;

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                // 特别注意:此处设置了逻辑组字段,则需要在CreateFeatureLayer后设置组的可见性。否则,默认FeatureLayer将不可见。
                // 注意:必须用已注册RenderIndex的字段,否则CreateFeatureLayer创建不成功返回null
                geoRender.RenderGroupField = "Groupid";
                IImagePointSymbol geoSymbol = new ImagePointSymbol(); //将点以图片的形式显示出来
                geoSymbol.ImageName = "huang.png";                    //使用素材库里存在的图片
                geoSymbol.Size      = 25;
                geoRender.Symbol    = geoSymbol;

                FeatureLayerVisualize(ci, true, "Point", textRender, geoRender);
            }
            // 可视化Polyline类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polyline.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                ISimpleTextRender textRender = new SimpleTextRender();
                textRender.Expression = "''..$(oid)";

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                // 特别注意:此处设置了逻辑组字段,则需要在CreateFeatureLayer后设置组的可见性。否则,默认FeatureLayer将不可见。
                geoRender.RenderGroupField = "Groupid";
                ICurveSymbol geoSymbol = new CurveSymbol();
                geoSymbol.Color  = System.Drawing.Color.Red; //线颜色为Purple
                geoRender.Symbol = geoSymbol;

                FeatureLayerVisualize(ci, false, "Polyline", textRender, geoRender);
            }

            // 可视化Polygon类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polygon.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                ISimpleTextRender textRender = new SimpleTextRender();
                textRender.Expression = "''..$(oid)";

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                // 特别注意:此处设置了逻辑组字段,则需要在CreateFeatureLayer后设置组的可见性。否则,默认FeatureLayer将不可见。
                geoRender.RenderGroupField = "Groupid";
                ISurfaceSymbol geoSymbol = new SurfaceSymbol();
                geoSymbol.Color  = System.Drawing.Color.Yellow; //面填充色为Yellow
                geoRender.Symbol = geoSymbol;

                FeatureLayerVisualize(ci, false, "Polygon", textRender, geoRender);
            }

            // 可视化ModelPoint类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\community.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                ISimpleTextRender textRender = new SimpleTextRender();
                textRender.Expression = "''..$(oid)";

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                //特别注意:此处设置了逻辑组字段,则需要在CreateFeatureLayer后设置组的可见性。否则,默认FeatureLayer将不可见。
                geoRender.RenderGroupField = "Groupid";
                IModelPointSymbol geoSymbol = new ModelPointSymbol();
                geoSymbol.Color       = System.Drawing.Color.Yellow; //模型颜色为Red
                geoSymbol.EnableColor = true;                        //需开启,否则颜色设置无效
                geoRender.Symbol      = geoSymbol;

                FeatureLayerVisualize(ci, false, "ModelPoint", textRender, geoRender);
            }
        }
示例#4
0
        public PointRenderForm(IGeometryRender geoRender, object[] fieldNamesItems, bool isSimplePoint)
        {
            InitializeComponent();
            IsSimplePoint = isSimplePoint;

            {
                this.comboBox1.Items.AddRange(fieldNamesItems);
                this.comboBox1.Text = "";

                if (geoRender != null)
                {
                    int index = Utils.getIndexFromItems(fieldNamesItems, geoRender.RenderGroupField);
                    this.comboBox1.SelectedIndex = index;
                }
            }

            ISimpleGeometryRender render = geoRender as ISimpleGeometryRender;

            if (render == null)
            {
                if (isSimplePoint)
                {
                    this.dataGridView1.Enabled      = true;
                    this.checkBox1.Enabled          = false;
                    this.textBoxPictureName.Enabled = false;
                    this.textBoxPicturePath.Enabled = false;

                    ISimplePointSymbol tmpSymbol = new SimplePointSymbol();
                    string[]           row1      = new string[] { "Alignment", tmpSymbol.Alignment.ToString() };
                    string[]           row2      = new string[] { "Size", tmpSymbol.Size.ToString() };
                    object[]           rows      = new object[] { row1, row2 };
                    foreach (string[] rowArray in rows)
                    {
                        this.dataGridView2.Rows.Add(rowArray);
                    }

                    string[] row11 = new string[] { "FillColor", tmpSymbol.FillColor.ToString() };
                    string[] row12 = new string[] { "Style", tmpSymbol.Style.ToString() };
                    object[] rows2 = new object[] { row11, row12 };
                    foreach (string[] rowArray in rows2)
                    {
                        this.dataGridView1.Rows.Add(rowArray);
                    }
                    return;
                }
                else
                {
                    this.dataGridView1.Enabled      = false;
                    this.checkBox1.Enabled          = true;
                    this.textBoxPictureName.Enabled = true;

                    IImagePointSymbol tmpSymbol = new ImagePointSymbol();
                    string[]          row1      = new string[] { "Alignment", tmpSymbol.Alignment.ToString() };
                    string[]          row2      = new string[] { "Size", tmpSymbol.Size.ToString() };
                    object[]          rows      = new object[] { row1, row2 };
                    foreach (string[] rowArray in rows)
                    {
                        this.dataGridView2.Rows.Add(rowArray);
                    }

                    this.textBoxPictureName.Text = "";
                    return;
                }
            }

            if (render.Symbol == null)
            {
                return;
            }

            if (isSimplePoint)
            {
                this.dataGridView1.Enabled      = true;
                this.checkBox1.Enabled          = false;
                this.textBoxPictureName.Enabled = false;
                this.textBoxPicturePath.Enabled = false;

                ISimplePointSymbol symbol = render.Symbol as ISimplePointSymbol;
                if (symbol != null)
                {
                    string[] row1 = new string[] { "Alignment", symbol.Alignment.ToString() };
                    string[] row2 = new string[] { "Size", symbol.Size.ToString() };
                    object[] rows = new object[] { row1, row2 };
                    foreach (string[] rowArray in rows)
                    {
                        this.dataGridView2.Rows.Add(rowArray);
                    }

                    string[] row11 = new string[] { "FillColor", symbol.FillColor.ToString() };
                    string[] row12 = new string[] { "Style", symbol.Style.ToString() };
                    object[] rows2 = new object[] { row11, row12 };
                    foreach (string[] rowArray in rows2)
                    {
                        this.dataGridView1.Rows.Add(rowArray);
                    }
                }
                else
                {
                    ISimplePointSymbol tmpSymbol = new SimplePointSymbol();
                    string[]           row1      = new string[] { "Alignment", tmpSymbol.Alignment.ToString() };
                    string[]           row2      = new string[] { "Size", tmpSymbol.Size.ToString() };
                    object[]           rows      = new object[] { row1, row2 };
                    foreach (string[] rowArray in rows)
                    {
                        this.dataGridView2.Rows.Add(rowArray);
                    }

                    string[] row11 = new string[] { "FillColor", tmpSymbol.FillColor.ToString() };
                    string[] row12 = new string[] { "Style", tmpSymbol.Style.ToString() };
                    object[] rows2 = new object[] { row11, row12 };
                    foreach (string[] rowArray in rows2)
                    {
                        this.dataGridView1.Rows.Add(rowArray);
                    }
                }
            }
            else
            {
                this.dataGridView1.Enabled      = false;
                this.checkBox1.Enabled          = true;
                this.textBoxPictureName.Enabled = true;

                IImagePointSymbol symbol = render.Symbol as IImagePointSymbol;
                if (symbol != null)
                {
                    string[] row1 = new string[] { "Alignment", symbol.Alignment.ToString() };
                    string[] row2 = new string[] { "Size", symbol.Size.ToString() };
                    object[] rows = new object[] { row1, row2 };
                    foreach (string[] rowArray in rows)
                    {
                        this.dataGridView2.Rows.Add(rowArray);
                    }

                    this.textBoxPicturePath.Text = symbol.ImageName;
                    this.textBoxPictureName.Text = symbol.ImageName;
                }
                else
                {
                    IImagePointSymbol tmpSymbol = new ImagePointSymbol();
                    string[]          row1      = new string[] { "Alignment", tmpSymbol.Alignment.ToString() };
                    string[]          row2      = new string[] { "Size", tmpSymbol.Size.ToString() };
                    object[]          rows      = new object[] { row1, row2 };
                    foreach (string[] rowArray in rows)
                    {
                        this.dataGridView2.Rows.Add(rowArray);
                    }

                    this.textBoxPictureName.Text = "";
                }
            }
        }
示例#5
0
        private void OnFinishedDraw()
        {
            if (this._drawTool != null && this._drawTool.GeoType == DrawType.SelectOne &&
                this._drawTool.GetSelectFeatureLayerPickResult() != null && this._drawTool.GetSelectPoint() != null)
            {
                try
                {
                    IFeatureLayer fl = this._drawTool.GetSelectFeatureLayerPickResult().FeatureLayer;
                    if (fl == null)
                    {
                        return;
                    }
                    FacilityClass facc = Dictionary3DTable.Instance.GetFacilityClassByDFFeatureClassID(fl.FeatureClassId.ToString());
                    if (facc == null || facc.Name != "PipeLine")
                    {
                        XtraMessageBox.Show("您选中的不是管线设施,请选择管线设施。", "提示");
                        return;
                    }
                    DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fl.FeatureClassId.ToString());
                    if (dffc == null || dffc.GetFeatureClass() == null)
                    {
                        return;
                    }
                    IImagePointSymbol ips = new ImagePointSymbol();
                    ips.Size      = SystemInfo.Instance.SymbolSize;
                    ips.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\POI\\accidentPoint.png");

                    IPoint intersectPoint = this._drawTool.GetSelectPoint();

                    _rPoint = d3.ObjectManager.CreateRenderPoint(intersectPoint, ips, d3.ProjectTree.RootID);
                    _rPoint.MinVisibleDistance = 499;
                    _rPoint.MaxVisibleDistance = 99999;

                    _particleEffect = d3.ObjectManager.CreateParticleEffect(d3.ProjectTree.RootID);
                    MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(fl.FeatureClassId.ToString());
                    if (mc != null)
                    {
                        this.teCarrierType.Text = mc.ToString();
                    }
                    if (mc != null && (mc.Name == "PS" || mc.Name == "GS"))
                    {
                        _particleEffect.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\ParticleEffect\\water.png");

                        _particleEffect.ParticleBillboardType = gviParticleBillboardType.gviParticleBillboardOrientedMoveDirection;
                        //_particleEffect.setTextureTileRange(8, 8, 63, 63);
                        _particleEffect.EmissionMinRate          = 1600;
                        _particleEffect.EmissionMaxRate          = 1300;
                        _particleEffect.EmissionMinAngle         = 0;
                        _particleEffect.EmissionMaxAngle         = 0.025 * Math.PI; // 改成一个圆
                        _particleEffect.EmissionMinMoveSpeed     = 25;
                        _particleEffect.EmissionMaxMoveSpeed     = 30;
                        _particleEffect.EmissionMinRotationSpeed = 0;
                        _particleEffect.EmissionMaxRotationSpeed = 0;

                        _particleEffect.ParticleMinLifeTime     = 4.5;
                        _particleEffect.ParticleMaxLifeTime     = 5.5;
                        _particleEffect.EmissionMinParticleSize = 0.2;
                        _particleEffect.EmissionMaxParticleSize = 0.25;

                        _particleEffect.EmissionMinScaleSpeed = 0;
                        _particleEffect.EmissionMaxScaleSpeed = 0;
                        _particleEffect.ParticleBirthColor    = 0xffffffff;
                        _particleEffect.ParticleDeathColor    = 0x00ffffff;
                        _particleEffect.VerticalAcceleration  = 5;
                        _particleEffect.Damping          = 0.5;
                        _particleEffect.WindAcceleration = 0;
                        _particleEffect.WindDirection    = 0;
                        IEulerAngle v3t = new EulerAngle();
                        v3t.Set(90, 45, 0);
                        _particleEffect.EmissionDirectionEulerAngle = v3t;
                    }
                    else
                    {
                        _particleEffect.ImageName             = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\ParticleEffect\\smoke1.png");
                        _particleEffect.ParticleBillboardType = gviParticleBillboardType.gviParticleBillboardOrientedCamera;
                        _particleEffect.SetTextureTileRange(8, 8, 63, 63);  // 58,58位置的图有问题
                        _particleEffect.EmissionMinRate          = 20;
                        _particleEffect.EmissionMaxRate          = 30;
                        _particleEffect.EmissionMinAngle         = 0;
                        _particleEffect.EmissionMaxAngle         = 3.14 * 2.0; // 改成一个圆
                        _particleEffect.EmissionMinMoveSpeed     = 0;
                        _particleEffect.EmissionMaxMoveSpeed     = 1;
                        _particleEffect.EmissionMinRotationSpeed = -1;
                        _particleEffect.EmissionMaxRotationSpeed = 1;

                        _particleEffect.ParticleMinLifeTime     = 10;
                        _particleEffect.ParticleMaxLifeTime     = 12;
                        _particleEffect.EmissionMinParticleSize = 0.75;
                        _particleEffect.EmissionMaxParticleSize = 0.9;

                        _particleEffect.EmissionMinScaleSpeed = 1.5;
                        _particleEffect.EmissionMaxScaleSpeed = 1.85;
                        _particleEffect.ParticleBirthColor    = 0xffffffff;
                        _particleEffect.ParticleDeathColor    = 0x00ffffff;
                        _particleEffect.VerticalAcceleration  = -2;
                        _particleEffect.Damping          = 0;
                        _particleEffect.WindAcceleration = 0;
                        _particleEffect.WindDirection    = 0;
                    }
                    _particleEffect.MinVisibleDistance = 0;
                    _particleEffect.MaxVisibleDistance = 500;

                    _particleEffect.Start(-1);
                    IPoint   pttemp = (new GeometryFactoryClass()).CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint;
                    IVector3 v3     = new Vector3();
                    v3.Set(intersectPoint.X, intersectPoint.Y, intersectPoint.Z);
                    pttemp.Position = v3;
                    _particleEffect.SetCircleEmitter(pttemp, 0);

                    this._drawTool.End();
                }
                catch (Exception ex)
                {
                }
                finally
                {
                }
            }
        }
示例#6
0
        private void btnApply_Click(object sender, System.EventArgs e)
        {
            string script = this.txtScript.Text.Trim();

            if (script != "")
            {
                IGeometryRender render = selectedLayer.GetGeometryRender();
                if (render != null)
                {
                    if (render.RenderType == gviRenderType.gviRenderSimple)
                    {
                        ISimpleGeometryRender simpleRender = render as ISimpleGeometryRender;
                        IGeometrySymbol       geoSymbol    = simpleRender.Symbol;
                        geoSymbol.Script    = script;
                        simpleRender.Symbol = geoSymbol;
                        if (!selectedLayer.SetGeometryRender(simpleRender))
                        {
                            MessageBox.Show("错误码为:" + this.axRenderControl1.GetLastError());
                        }
                    }
                }
                else
                {
                    ISimpleGeometryRender simpleRender = new SimpleGeometryRender();
                    switch (type)
                    {
                    case LayerType.ModelPoint:
                    {
                        IModelPointSymbol mps = new ModelPointSymbol();
                        mps.Script          = script;
                        simpleRender.Symbol = mps;
                    }
                    break;

                    case LayerType.Polyline:
                    {
                        ICurveSymbol cs = new CurveSymbol();
                        cs.Script           = script;
                        simpleRender.Symbol = cs;
                    }
                    break;

                    case LayerType.Point:
                    {
                        if (script.Contains("<ImageName>"))
                        {
                            IImagePointSymbol ips = new ImagePointSymbol();
                            ips.Script          = script;
                            simpleRender.Symbol = ips;
                        }
                        else
                        {
                            ISimplePointSymbol sps = new SimplePointSymbol();
                            sps.Script          = script;
                            simpleRender.Symbol = sps;
                        }
                    }
                    break;

                    case LayerType.Polygon:
                    {
                        if (script.Contains("<Height>"))
                        {
                            IPolygon3DSymbol p3s = new Polygon3DSymbol();
                            p3s.Script          = script;
                            simpleRender.Symbol = p3s;
                        }
                        else
                        {
                            ISurfaceSymbol ss = new SurfaceSymbol();
                            ss.Script           = script;
                            simpleRender.Symbol = ss;
                        }
                    }
                    break;
                    }
                    if (!selectedLayer.SetGeometryRender(simpleRender))
                    {
                        MessageBox.Show("错误码为:" + this.axRenderControl1.GetLastError());
                    }
                }
            }
            else
            {
                selectedLayer.SetGeometryRender(null);
            }
        }
示例#7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(false, ps);

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;
            this.axRenderControl1.Camera.FlyTime = 0;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "ToolTipShow.html";
            }

            layerEnvelopeMap = new Hashtable();
            layerFcMap       = new Hashtable();

            // 可视化Point类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\point.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                IToolTipTextRender textRender = new ToolTipTextRender();
                textRender.Expression = "''..$(oid)";

                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                IImagePointSymbol     geoSymbol = new ImagePointSymbol(); //将点以图片的形式显示出来
                geoSymbol.ImageName = "huang.png";                        //使用素材库里存在的图片
                geoSymbol.Size      = 25;
                geoRender.Symbol    = geoSymbol;

                FeatureLayerVisualize(ci, true, "Point", textRender, geoRender);
            }
            // 可视化Polyline类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polyline.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                IToolTipTextRender textRender = new ToolTipTextRender();
                textRender.Expression = "''..$(oid)";

                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                ICurveSymbol          geoSymbol = new CurveSymbol();
                geoSymbol.Color  = System.Drawing.Color.Purple; //线颜色为Purple
                geoSymbol.Width  = 5;
                geoRender.Symbol = geoSymbol;

                FeatureLayerVisualize(ci, false, "Polyline", textRender, geoRender);
            }

            // 可视化Polygon类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polygon.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                IToolTipTextRender textRender = new ToolTipTextRender();
                textRender.Expression = "''..$(oid)";

                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                ISurfaceSymbol        geoSymbol = new SurfaceSymbol();
                geoSymbol.Color  = System.Drawing.Color.Yellow; //面填充色为Yellow
                geoRender.Symbol = geoSymbol;

                FeatureLayerVisualize(ci, false, "Polygon", textRender, geoRender);
            }

            // 可视化ModelPoint类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\community.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                IToolTipTextRender textRender = new ToolTipTextRender();
                textRender.Expression = "''..$(oid)";

                FeatureLayerVisualize(ci, false, "ModelPoint", textRender, null);
            }
        }
示例#8
0
文件: MainForm.cs 项目: batuZ/Samples
        private void btnFindWC_Click(object sender, EventArgs e)
        {
            clear();
            clearDeep();

            IFdeCursor cursor = null;

            try
            {
                if (closestFacilitySolver == null)
                {
                    closestFacilitySolver = network.CreateClosestFacilitySolver();
                    closestFacilitySolver.ImpedanceAttributeName = "Length";
                }
                closestFacilitySolver.LocationSearchTolerance = double.Parse(txtSearchTolerance.Text);
                closestFacilitySolver.ClearFacilityLocations();
                closestFacilitySolver.ClearEventLocations();

                // 添加WC设施点
                foreach (IFeatureClass fc in fcMap_POI.Keys)
                {
                    if (fc.Name.Contains("WC"))
                    {
                        cursor = fc.Search(null, true);
                        IRowBuffer row = null;
                        while ((row = cursor.NextRow()) != null)
                        {
                            try
                            {
                                INetworkLocation facility = new NetworkLocation();
                                int    pos   = row.FieldIndex("Geometry");
                                IPoint point = row.GetValue(pos) as IPoint;
                                facility.Position = point;
                                facility.Name     = fc.Guid.ToString() + "_" + row.GetValue(0).ToString(); //设定名字"fcGUID_oid"
                                closestFacilitySolver.AddFacilityLocation(facility);
                            }
                            catch (COMException ex)
                            {
                            }
                        }
                        break;
                    }
                }
                if (closestFacilitySolver.FacilityLocationCount == 0)
                {
                    MessageBox.Show("添加的厕所数为0,请调整LocationSearchTolerance大小");
                    return;
                }

                // 添加人所在的位置
                INetworkEventLocation location = new NetworkEventLocation();
                this.axRenderControl1.Camera.GetCamera2(out fdepoint, out ang);
                location.Position            = fdepoint;
                location.Name                = "I'mHere";
                location.TargetFacilityCount = int.Parse(txtMaxNum.Text);
                location.SetCutoff("Length", double.Parse(txtCutoff.Text));
                closestFacilitySolver.AddEventLocation(location);
                // 可视化人的位置
                IImagePointSymbol ips = new ImagePointSymbol();
                ips.ImageName = "#(i)";
                ips.Size      = 50;
                renderPoint   = this.axRenderControl1.ObjectManager.CreateRenderPoint(fdepoint, ips, rootId);

                if (closestFacilitySolver.Solve())
                {
                    int routeCount = closestFacilitySolver.RouteCount;
                    if (routeCount == 0)
                    {
                        MessageBox.Show("没有厕所在指定范围内");
                        return;
                    }
                    for (int i = 0; i < routeCount; i++)
                    {
                        INetworkRoute route = closestFacilitySolver.GetRoute(i);
                        if (route != null)
                        {
                            // 可视化线路
                            ICurveSymbol lineSym = new CurveSymbol();
                            lineSym.Color = System.Drawing.Color.Yellow;
                            lineSym.Width = -2;
                            IGeometry geo = route.GetRouteGeometry();
                            if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                            {
                                IPolyline line = geo as IPolyline;
                                renderLine = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, lineSym, rootId);
                                renderLine.MaxVisibleDistance = 10000;
                                renderLineArray.Add(renderLine);
                            }
                            else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                            {
                                IMultiPolyline line = geo as IMultiPolyline;
                                multiRenderLine = this.axRenderControl1.ObjectManager.CreateRenderMultiPolyline(line, lineSym, rootId);
                                multiRenderLine.MaxVisibleDistance = 10000;
                                multiRenderLineArray.Add(multiRenderLine);
                            }

                            drawTempLine(route);

                            // 高亮厕所
                            int segmentCount = route.SegmentCount;
                            for (int j = 0; j < segmentCount; j++)
                            {
                                INetworkLocation endLocation = route.GetSegment(j).EndLocation;
                                string[]         strs        = endLocation.Name.Split('_');
                                foreach (IFeatureClass fc in fcMap_POI.Keys)
                                {
                                    if (fc.Guid.ToString() == strs[0])
                                    {
                                        this.axRenderControl1.FeatureManager.HighlightFeature(fc, int.Parse(strs[1]), System.Drawing.Color.Yellow);
                                        break;
                                    }
                                }

                                //////////////////////测试NetworkElement相关//////////////////////////////////
                                INetworkElementCollection elementCols = route.GetSegment(j).GetNetworkElements();
                                for (int c = 0; c < elementCols.Count; c++)
                                {
                                    INetworkElement element = elementCols.Get(c);
                                    if (element.Type == gviNetworkElementType.gviEdge)
                                    {
                                        INetworkEdge edge  = element as INetworkEdge;
                                        int          subId = edge.SubID;
                                    }
                                    else
                                    {
                                        INetworkJunction       junction = element as INetworkJunction;
                                        INetworkEdgeCollection edgeCol  = junction.IncomingEdges;
                                        for (int ee = 0; ee < edgeCol.Count; ee++)
                                        {
                                            INetworkEdge edge  = edgeCol.Get(ee);
                                            int          subId = edge.SubID;
                                        }
                                    }
                                }
                                //////////////////////////////////////////////////////////////////////////
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("查找失败");
                }
            }
            catch (COMException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
            }
        }
示例#9
0
文件: MainForm.cs 项目: batuZ/Samples
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            this.axRenderControl1.Camera.FlyTime = 0;
            this.cbOrderPolicy.SelectedIndex     = 0;

            if (geoFac == null)
            {
                geoFac = new GeometryFactory();
            }

            #region 加载road FDB
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\Network.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                dataset_Road = ds.OpenFeatureDataset(setnames[0]);
                string[] fcnames = (string[])dataset_Road.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap_Road = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset_Road.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap_Road.Add(fc, geoNames);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // CreateFeautureLayer
            bool hasfly = false;
            foreach (IFeatureClass fc in fcMap_Road.Keys)
            {
                List <string> geoNames = (List <string>)fcMap_Road[fc];
                foreach (string geoName in geoNames)
                {
                    if (!geoName.Equals("Geometry"))
                    {
                        continue;
                    }

                    IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(
                        fc, geoName, null, null, rootId);

                    if (!hasfly)
                    {
                        IFieldInfoCollection fieldinfos  = fc.GetFields();
                        IFieldInfo           fieldinfo   = fieldinfos.Get(fieldinfos.IndexOf(geoName));
                        IGeometryDef         geometryDef = fieldinfo.GeometryDef;
                        IEnvelope            env         = geometryDef.Envelope;
                        if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 &&
                                            env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0))
                        {
                            continue;
                        }
                        IEulerAngle angle = new EulerAngle();
                        angle.Set(0, -20, 0);
                        this.axRenderControl1.Camera.LookAt(env.Center, 1000, angle);
                    }
                    hasfly = true;
                }
            }

            Thread.Sleep(2000);

            // 加载网络
            try
            {
                dsManager = dataset_Road.GetNetworkManager();
                string[] networkDatasetNames = dsManager.GetNetworkNames();
                bool     hasNetworkDataset   = false;
                for (int i = 0; i < networkDatasetNames.Length; i++)
                {
                    if (networkDatasetNames[i] == "newNetworkDataset")
                    {
                        hasNetworkDataset = true;
                    }
                }

                if (!hasNetworkDataset)
                {
                    dsLoader             = dsManager.CreateNetworkLoader();
                    dsLoader.Name        = "newNetworkDataset";
                    dsLoader.XYTolerance = double.Parse(txtLoaderTolerance.Text);
                    edgeNS                        = new EdgeNetworkSource();
                    edgeNS.SourceName             = "road";
                    edgeNS.ConnectivityPolicy     = gviNetworkEdgeConnectivityPolicy.gviEndVertex;
                    edgeNS.GeoColumnName          = "Geometry";
                    edgeNS.ClassConnectivityGroup = 1;
                    dsLoader.AddSource(edgeNS);
                    INetworkAttribute attr = new NetworkAttribute();
                    attr.FieldType = gviFieldType.gviFieldDouble;
                    attr.Name      = "Length";
                    attr.UsageType = gviNetworkAttributeUsageType.gviUseAsCost;
                    INetworkFieldEvaluator fieldEvaluator = new NetworkFieldEvaluator();
                    fieldEvaluator.FieldName = "Geometry";
                    attr.SetEvaluator(edgeNS, gviEdgeDirection.gviAlongDigitized, fieldEvaluator);
                    attr.SetEvaluator(edgeNS, gviEdgeDirection.gviAgainstDigitized, fieldEvaluator);
                    dsLoader.AddNetworkAttribute(attr);
                    dsLoader.LoadNetwork();
                }
                network = dsManager.GetNetwork("newNetworkDataset");

                routeSolver = network.CreateRouteSolver();
                routeSolver.ImpedanceAttributeName  = "Length";
                routeSolver.LocationSearchTolerance = double.Parse(txtSearchTolerance.Text);
                ////Marshal.ReleaseComObject(dsManager);
                ////Marshal.ReleaseComObject(dsLoader);
                ////Marshal.ReleaseComObject(attr);
                ////Marshal.ReleaseComObject(edgeNS);
                ////Marshal.ReleaseComObject(fieldEvaluator);
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            #endregion

            #region 加载POI FDB
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\POI-1.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                string[]        fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap_POI = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap_POI.Add(fc, geoNames);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            //解析配置文件
            string featurelayerName = "";
            IValueMapGeometryRender render_JingDian = new ValueMapGeometryRender();
            IValueMapGeometryRender render_MeiShi   = new ValueMapGeometryRender();
            IValueMapGeometryRender render_ZhuSu    = new ValueMapGeometryRender();
            IValueMapGeometryRender render_HuoDong  = new ValueMapGeometryRender();
            IValueMapGeometryRender render_GouWu    = new ValueMapGeometryRender();
            IValueMapGeometryRender render_ATM      = new ValueMapGeometryRender();
            IValueMapGeometryRender render_WC       = new ValueMapGeometryRender();

            string[] fn = Directory.GetFiles((strMediaPath + @"\xml\xml"));
            foreach (string str in fn)
            {
                IValueMapGeometryRender render = new ValueMapGeometryRender();
                try
                {
                    XmlDocument docReader = new XmlDocument();
                    docReader.Load(str);
                    if (docReader.SelectSingleNode("FeatureLayer") != null)
                    {
                        featurelayerName = docReader.SelectSingleNode("FeatureLayer").Attributes["Name"].Value;

                        XmlNode GeometryRenderNode = docReader.SelectSingleNode("FeatureLayer").ChildNodes[0];
                        switch (GeometryRenderNode.Attributes["HeightStyle"].Value)
                        {
                        case "gviHeightAbsolute":
                            render.HeightStyle = gviHeightStyle.gviHeightAbsolute;
                            break;

                        case "gviHeightOnTerrain":
                            render.HeightStyle = gviHeightStyle.gviHeightOnTerrain;
                            break;

                        case "gviHeightRelative":
                            render.HeightStyle = gviHeightStyle.gviHeightRelative;
                            break;
                        }
                        render.RenderGroupField = GeometryRenderNode.Attributes["GroupField"].Value;

                        XmlNodeList xnl = docReader.SelectSingleNode("FeatureLayer").ChildNodes[0].ChildNodes[0].ChildNodes;
                        if (xnl.Count > 0)
                        {
                            foreach (XmlNode RenderSchemeNode in xnl)
                            {
                                IGeometryRenderScheme renderScheme = new GeometryRenderScheme();

                                IUniqueValuesRenderRule uniqueRenderRule   = new UniqueValuesRenderRule();
                                IImagePointSymbol       imagePointSym      = new ImagePointSymbol();
                                XmlNodeList             renderSchemeChilds = RenderSchemeNode.ChildNodes;
                                if (renderSchemeChilds.Count > 0)
                                {
                                    XmlNode renderRuleNode = renderSchemeChilds.Item(0);
                                    uniqueRenderRule.LookUpField = renderRuleNode.Attributes["LookUpField"].Value;
                                    uniqueRenderRule.AddValue(renderRuleNode.Attributes["UniqueValue"].Value);

                                    XmlNode geometrySymbolNode = renderSchemeChilds.Item(1);
                                    imagePointSym.ImageName = geometrySymbolNode.Attributes["ImageName"].Value;
                                    //imagePointSym.Size = int.Parse(geometrySymbolNode.Attributes["Size"].Value);
                                    imagePointSym.Size      = 60;
                                    imagePointSym.Alignment = gviPivotAlignment.gviPivotAlignBottomCenter;
                                }
                                renderScheme.AddRule(uniqueRenderRule);
                                renderScheme.Symbol = imagePointSym;
                                render.AddScheme(renderScheme);
                            }
                        }

                        switch (featurelayerName)
                        {
                        case "景点347":
                            render_JingDian = render;
                            break;

                        case "ATM611":
                            render_ATM = render;
                            break;

                        case "购物67":
                            render_GouWu = render;
                            break;

                        case "活动927":
                            render_HuoDong = render;
                            break;

                        case "WC968":
                            render_WC = render;
                            break;

                        case "美食563":
                            render_MeiShi = render;
                            break;

                        case "住宿513":
                            render_ZhuSu = render;
                            break;
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(str + " 解析失败");
                    return;
                }
            }

            ISimpleTextRender textRender = new SimpleTextRender();
            textRender.Expression       = "$(Name)";
            textRender.DynamicPlacement = true;
            textRender.MinimizeOverlap  = true;
            ITextSymbol   textSymbol    = new TextSymbol();
            TextAttribute textAttribute = new TextAttribute();
            textAttribute.TextColor   = System.Drawing.Color.Blue;
            textAttribute.Font        = "微软雅黑";
            textSymbol.TextAttribute  = textAttribute;
            textSymbol.PivotAlignment = gviPivotAlignment.gviPivotAlignBottomCenter;
            textSymbol.VerticalOffset = 10;
            textRender.Symbol         = textSymbol;

            // CreateFeautureLayer
            foreach (IFeatureClass fc in fcMap_POI.Keys)
            {
                List <string> geoNames = (List <string>)fcMap_POI[fc];
                foreach (string geoName in geoNames)
                {
                    if (!geoName.Equals("Geometry"))
                    {
                        continue;
                    }

                    switch (fc.Name)
                    {
                    case "景点347":
                        this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, geoName, textRender, render_JingDian, rootId);
                        break;

                    case "ATM611":
                        this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, geoName, textRender, render_ATM, rootId);
                        break;

                    case "购物67":
                        this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, geoName, textRender, render_GouWu, rootId);
                        break;

                    case "活动927":
                        this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, geoName, textRender, render_HuoDong, rootId);
                        break;

                    case "WC968":
                        this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, geoName, textRender, render_WC, rootId);
                        break;

                    case "美食563":
                        this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, geoName, textRender, render_MeiShi, rootId);
                        break;

                    case "住宿513":
                        this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, geoName, textRender, render_ZhuSu, rootId);
                        break;
                    }
                }
            }
            #endregion

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "Network.html";
            }
        }
示例#10
0
        private void ClickQuery()
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            try
            {
                IFeatureLayer fl = this._drawTool.GetSelectFeatureLayerPickResult().FeatureLayer;
                if (fl == null)
                {
                    return;
                }
                int           featureId = this._drawTool.GetSelectFeatureLayerPickResult().FeatureId;
                FacilityClass facc      = Dictionary3DTable.Instance.GetFacilityClassByDFFeatureClassID(fl.FeatureClassId.ToString());
                if (facc == null || facc.Name != "PipeLine")
                {
                    XtraMessageBox.Show("您选中的不是管线设施,请选择管线设施。", "提示");
                    return;
                }
                DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fl.FeatureClassId.ToString());
                if (dffc == null || dffc.GetFeatureClass() == null)
                {
                    return;
                }
                IFeatureClass     fc  = dffc.GetFeatureClass();
                IImagePointSymbol ips = new ImagePointSymbol();
                ips.Size      = SystemInfo.Instance.SymbolSize;
                ips.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\POI\\accidentPoint.png");

                IPoint intersectPoint = this._drawTool.GetSelectPoint();

                _rPoint = app.Current3DMapControl.ObjectManager.CreateRenderPoint(intersectPoint, ips, app.Current3DMapControl.ProjectTree.RootID);
                _rPoint.MinVisibleDistance = 499;
                _rPoint.MaxVisibleDistance = 99999;

                _particleEffect = app.Current3DMapControl.ObjectManager.CreateParticleEffect(app.Current3DMapControl.ProjectTree.RootID);
                MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(fl.FeatureClassId.ToString());
                if (mc != null && (mc.Name == "PS" || mc.Name == "GS"))
                {
                    _particleEffect.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\ParticleEffect\\water.png");

                    _particleEffect.ParticleBillboardType = gviParticleBillboardType.gviParticleBillboardOrientedMoveDirection;
                    //_particleEffect.setTextureTileRange(8, 8, 63, 63);
                    _particleEffect.EmissionMinRate          = 1600;
                    _particleEffect.EmissionMaxRate          = 1300;
                    _particleEffect.EmissionMinAngle         = 0;
                    _particleEffect.EmissionMaxAngle         = 0.025 * Math.PI; // 改成一个圆
                    _particleEffect.EmissionMinMoveSpeed     = 25;
                    _particleEffect.EmissionMaxMoveSpeed     = 30;
                    _particleEffect.EmissionMinRotationSpeed = 0;
                    _particleEffect.EmissionMaxRotationSpeed = 0;

                    _particleEffect.ParticleMinLifeTime     = 4.5;
                    _particleEffect.ParticleMaxLifeTime     = 5.5;
                    _particleEffect.EmissionMinParticleSize = 0.2;
                    _particleEffect.EmissionMaxParticleSize = 0.25;

                    _particleEffect.EmissionMinScaleSpeed = 0;
                    _particleEffect.EmissionMaxScaleSpeed = 0;
                    _particleEffect.ParticleBirthColor    = 0xffffffff;
                    _particleEffect.ParticleDeathColor    = 0x00ffffff;
                    _particleEffect.VerticalAcceleration  = 5;
                    _particleEffect.Damping          = 0.5;
                    _particleEffect.WindAcceleration = 0;
                    _particleEffect.WindDirection    = 0;
                    IEulerAngle v3t = new EulerAngle();
                    v3t.Set(90, 45, 0);
                    _particleEffect.EmissionDirectionEulerAngle = v3t;
                }
                else
                {
                    _particleEffect.ImageName             = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\ParticleEffect\\smoke1.png");
                    _particleEffect.ParticleBillboardType = gviParticleBillboardType.gviParticleBillboardOrientedCamera;
                    _particleEffect.SetTextureTileRange(8, 8, 63, 63);  // 58,58位置的图有问题
                    _particleEffect.EmissionMinRate          = 20;
                    _particleEffect.EmissionMaxRate          = 30;
                    _particleEffect.EmissionMinAngle         = 0;
                    _particleEffect.EmissionMaxAngle         = 3.14 * 2.0; // 改成一个圆
                    _particleEffect.EmissionMinMoveSpeed     = 0;
                    _particleEffect.EmissionMaxMoveSpeed     = 1;
                    _particleEffect.EmissionMinRotationSpeed = -1;
                    _particleEffect.EmissionMaxRotationSpeed = 1;

                    _particleEffect.ParticleMinLifeTime     = 10;
                    _particleEffect.ParticleMaxLifeTime     = 12;
                    _particleEffect.EmissionMinParticleSize = 0.75;
                    _particleEffect.EmissionMaxParticleSize = 0.9;

                    _particleEffect.EmissionMinScaleSpeed = 1.5;
                    _particleEffect.EmissionMaxScaleSpeed = 1.85;
                    _particleEffect.ParticleBirthColor    = 0xffffffff;
                    _particleEffect.ParticleDeathColor    = 0x00ffffff;
                    _particleEffect.VerticalAcceleration  = -2;
                    _particleEffect.Damping          = 0;
                    _particleEffect.WindAcceleration = 0;
                    _particleEffect.WindDirection    = 0;
                }
                _particleEffect.MinVisibleDistance = 0;
                _particleEffect.MaxVisibleDistance = 500;

                _particleEffect.Start(-1);
                IPoint   pttemp = (new GeometryFactoryClass()).CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint;
                IVector3 v3     = new Vector3();
                v3.Set(intersectPoint.X, intersectPoint.Y, intersectPoint.Z);
                pttemp.Position = v3;
                _particleEffect.SetCircleEmitter(pttemp, 0);

                this._drawTool.End();

                WaitForm.Start("正在分析...", "请稍后");
                string  res  = GetValveClosed(fl.FeatureClassId.ToString(), featureId.ToString());
                JObject json = JObject.Parse(res);
                if (json["res"] != null)
                {
                    string resstr = json["res"].ToString();
                    if (resstr == "false")
                    {
                        XtraMessageBox.Show("分析出错", "提示");
                        return;
                    }
                    else
                    {
                        string msgstr = json["msg"].ToString();
                        if (json["count"] == null)
                        {
                            XtraMessageBox.Show(msgstr, "提示");
                            return;
                        }
                        int count = int.Parse(json["count"].ToString());

                        double totalx = 0.0;
                        double totaly = 0.0;
                        double totalz = 0.0;

                        #region 渲染搜索到的阀门
                        if (json["preValveIds"] != null)
                        {
                            string   preValveIds = json["preValveIds"].ToString();
                            string[] arr         = preValveIds.Split(';');
                            foreach (string item in arr)
                            {
                                int              index  = item.LastIndexOf("_");
                                string           fcguid = item.Substring(0, index);
                                string           oid    = item.Substring(index + 1, item.Length - index - 1);
                                DF3DFeatureClass dffc1  = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fcguid);
                                if (dffc != null)
                                {
                                    IFeatureClass fc1 = dffc1.GetFeatureClass();
                                    if (fc1 != null)
                                    {
                                        IFdeCursor cursor = null;
                                        IRowBuffer row    = null;
                                        try
                                        {
                                            IQueryFilter filter = new QueryFilter();
                                            filter.WhereClause = "oid=" + oid;
                                            filter.SubFields   = "oid,Shape";
                                            cursor             = fc1.Search(filter, false);
                                            row = cursor.NextRow();
                                            if (row != null && !row.IsNull(1))
                                            {
                                                object obj = row.GetValue(1);
                                                if (obj is IGeometry)
                                                {
                                                    IGeometry geo = obj as IGeometry;
                                                    switch (geo.GeometryType)
                                                    {
                                                    case gviGeometryType.gviGeometryPoint:
                                                        IPoint pt  = geo as IPoint;
                                                        IPOI   poi = (new GeometryFactoryClass()).CreateGeometry(gviGeometryType.gviGeometryPOI, gviVertexAttribute.gviVertexAttributeZ) as IPOI;
                                                        poi.X         = pt.X;
                                                        poi.Y         = pt.Y;
                                                        poi.Z         = pt.Z + 2;
                                                        totalx       += poi.X;
                                                        totaly       += poi.Y;
                                                        totalz       += poi.Z;
                                                        poi.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\POI\\valvePre.png");
                                                        poi.Size      = SystemInfo.Instance.SymbolSize;
                                                        poi.ShowName  = false;
                                                        IRenderPOI rpoi = app.Current3DMapControl.ObjectManager.CreateRenderPOI(poi);
                                                        this._listRGuid.Add(rpoi.Guid);
                                                        continue;
                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                        finally
                                        {
                                            if (cursor != null)
                                            {
                                                System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                                cursor = null;
                                            }
                                            if (row != null)
                                            {
                                                System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                                                row = null;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (json["nextValveIds"] != null)
                        {
                            string   nextValveIds = json["nextValveIds"].ToString();
                            string[] arr          = nextValveIds.Split(';');
                            foreach (string item in arr)
                            {
                                int              index  = item.LastIndexOf("_");
                                string           fcguid = item.Substring(0, index);
                                string           oid    = item.Substring(index + 1, item.Length - index - 1);
                                DF3DFeatureClass dffc1  = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fcguid);
                                if (dffc != null)
                                {
                                    IFeatureClass fc1 = dffc1.GetFeatureClass();
                                    if (fc1 != null)
                                    {
                                        IFdeCursor cursor = null;
                                        IRowBuffer row    = null;
                                        try
                                        {
                                            IQueryFilter filter = new QueryFilter();
                                            filter.WhereClause = "oid=" + oid;
                                            filter.SubFields   = "oid,Shape";
                                            cursor             = fc1.Search(filter, false);
                                            row = cursor.NextRow();
                                            if (row != null && !row.IsNull(1))
                                            {
                                                object obj = row.GetValue(1);
                                                if (obj is IGeometry)
                                                {
                                                    IGeometry geo = obj as IGeometry;
                                                    switch (geo.GeometryType)
                                                    {
                                                    case gviGeometryType.gviGeometryPoint:
                                                        IPoint pt  = geo as IPoint;
                                                        IPOI   poi = (new GeometryFactoryClass()).CreateGeometry(gviGeometryType.gviGeometryPOI, gviVertexAttribute.gviVertexAttributeZ) as IPOI;
                                                        poi.X         = pt.X;
                                                        poi.Y         = pt.Y;
                                                        poi.Z         = pt.Z + 2;
                                                        totalx       += poi.X;
                                                        totaly       += poi.Y;
                                                        totalz       += poi.Z;
                                                        poi.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\POI\\valveNext.png");
                                                        poi.Size      = SystemInfo.Instance.SymbolSize;
                                                        poi.ShowName  = false;
                                                        IRenderPOI rpoi = app.Current3DMapControl.ObjectManager.CreateRenderPOI(poi);
                                                        this._listRGuid.Add(rpoi.Guid);
                                                        continue;
                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                        finally
                                        {
                                            if (cursor != null)
                                            {
                                                System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                                cursor = null;
                                            }
                                            if (row != null)
                                            {
                                                System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                                                row = null;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion

                        // 定位
                        IVector3    vect;
                        IEulerAngle ang;
                        app.Current3DMapControl.Camera.GetCamera(out vect, out ang);
                        vect.Set(totalx / count, totaly / count, totalz / count + 600.0);
                        ang.Set(ang.Heading, -90, ang.Roll);
                        app.Current3DMapControl.Camera.SetCamera(vect, ang, gviSetCameraFlags.gviSetCameraNoFlags);
                    }
                }
                else
                {
                    XtraMessageBox.Show("分析出错", "提示");
                    return;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                WaitForm.Stop();
            }
        }