首页 / 浏览问题 / 桌面GIS / 问题详情
鼠标点击场景模型实现与模型属性信息的交互
23EXP 2017年07月17日
后续代码如下,之后还有很多代码,但调试的时候走到第一次发的那个点击函数就停止了,后续代码不再执行

//鼠标在场景控件中双击
        void sceneControl_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            isDoubleClick = true;
        }

        //场景中的模型被选中时发生
        void sceneControl_ObjectSelected(object sender, SuperMap.UI.ObjectSelectedEventArgs e)
        {
            try
            {
                //是否双击模型
                if (!isDoubleClick)
                {
                    return;
                }

                Selection3D selection3D = sceneControl.Scene.FindSelection(true)[0]; //创建一个三维选择集对象,返回场景中选择对象的选择集
                //如果3D场景中的选择集不为空
                if (selection3D != null)
                {
                    //模型类型:粮仓模型或传感器
                    string strModelType = selection3D.Layer.Name.Substring(0, selection3D.Layer.Name.IndexOf("_"));
                    if (strModelType == "粮仓模型")//选择的模型是粮仓
                    {
                        #region
                        string strLayerNo = selection3D.Layer.Name.Substring(5, selection3D.Layer.Name.IndexOf("@") - 5);//获取三维图层
                        DatasetVector dtv = DesktopPlugin.workspace.Datasources[0].Datasets["粮仓模型"] as DatasetVector;
                        Recordset recordset = dtv.GetRecordset(false, CursorType.Static);//游标通常来讲就是指向记录集中某条记录的指针。用户可以通过游标的前后移动定位到具体的某条记录
                        recordset.MoveFirst();
                        for (int i = 0; i < recordset.RecordCount; i++)
                        {
                            string strNO = string.Format("{0}", recordset.GetFieldValue("粮仓编号"));//根据字段名指定字段,获得数据集的属性数据表中当前记录该字段的值。
                            if (strNO == strLayerNo)
                            {
                                if (liangCangAttribution == null)
                                {
                                    liangCangAttribution = new LiangCangAttribution();
                                }
                                else if (liangCangAttribution.IsDisposed)
                                {
                                    liangCangAttribution = new LiangCangAttribution();
                                }
                                liangCangAttribution.labelName.Text = string.Format("{0}号粮仓", recordset.GetFieldValue("粮仓编号"));
                                liangCangAttribution.labelChang.Text = string.Format("{0}", recordset.GetFieldValue("粮仓长度"));
                                liangCangAttribution.labelKuan.Text = string.Format("{0}", recordset.GetFieldValue("粮仓宽度"));
                                liangCangAttribution.labelGao.Text = string.Format("{0}", recordset.GetFieldValue("粮仓高度"));
                                liangCangAttribution.labelWenDu.Text = string.Format("{0}", recordset.GetFieldValue("温度传感器数量"));
                                liangCangAttribution.labeShiDu.Text = string.Format("{0}", recordset.GetFieldValue("湿度传感器数量"));
                                liangCangAttribution.labelLeiXing.Text = string.Format("{0}", recordset.GetFieldValue("储粮类型"));
                                liangCangAttribution.labelLiangGaoDu.Text = string.Format("{0}", recordset.GetFieldValue("储粮高度"));
                                break;
                            }
                            recordset.MoveNext();
                        }
                        liangCangAttribution.Show();
                        recordset.Dispose();
                        recordset = null;
                        isDoubleClick = false;
                        #endregion
                    }

1个回答

把前面的断点去掉,然后在这里的return; 加断点

                if (!isDoubleClick)
                {
                    return;
                }

看看能不能调试到。
5,560EXP 2017年07月17日
...