Beispiel #1
0
 /// <summary>
 /// 鼠标悬停事件
 /// </summary>
 /// <param name="PickResult"></param>
 /// <param name="IntersectPoint"></param>
 /// <param name="Mask"></param>
 /// <param name="EventSender"></param>
 void g_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
 {
     if (PickResult != null)
     {
         IFeatureLayerPickResult pr = PickResult as IFeatureLayerPickResult;
         string        featureId    = pr.FeatureId.ToString();
         IFeatureClass featureClass = null;
         IFeatureLayer fl           = pr.FeatureLayer;
         foreach (IFeatureClass fc in fcMap.Keys)
         {
             if (fc.Guid.ToString() == fl.FeatureClassId.ToString())
             {
                 featureClass = fc;
                 break;
             }
         }
         if (featureClass != null)
         {
             DataTable    dt           = CreateDataTable(featureClass);
             string       filterString = string.Format("oid={0}", featureId);
             IQueryFilter filter       = new QueryFilter();
             filter.WhereClause = filterString;
             GetResultSet(featureClass, filter, dt);
             showInfo(dt, IntersectPoint);
         }
     }
 }
Beispiel #2
0
        void axRenderControl1_RcMouseDragSelect(IPickResultCollection PickResults, gviModKeyMask Mask)
        {
            IPickResultCollection prc = PickResults;

            if (prc == null && CTRL && Mask == gviModKeyMask.gviModKeyCtrl)
            {
                return;
            }

            if (!CTRL || (CTRL && Mask != gviModKeyMask.gviModKeyCtrl))  //ctrl键
            {
                this.axRenderControl1.FeatureManager.UnhighlightAll();
            }

            if (prc != null)
            {
                for (int i = 0; i < prc.Count; i++)
                {
                    IPickResult pr = prc.Get(i);
                    if (pr != null && pr.Type == gviObjectType.gviObjectFeatureLayer)
                    {
                        IFeatureLayerPickResult flpr = pr as IFeatureLayerPickResult;
                        int           fid            = flpr.FeatureId;
                        IFeatureLayer fl             = flpr.FeatureLayer;
                        foreach (IFeatureClass fc in fcMap.Keys)
                        {
                            if (fc.Guid.Equals(fl.FeatureClassId))
                            {
                                this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Yellow);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 拾取线
        /// </summary>
        /// <param name="PickResult"></param>
        /// <param name="IntersectPoint"></param>
        /// <param name="Mask"></param>
        /// <param name="EventSender"></param>
        void g_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IntersectPoint == null)
            {
                return;
            }

            if (renderPolyline == null)
            {
                renderPolyline        = axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, null, rootId);
                renderPolyline.Symbol = new CurveSymbol()
                {
                    Color = System.Drawing.Color.Red, Width = 4
                };
            }

            if (polyline.PointCount < 2)
            {
                polyline.AppendPoint(IntersectPoint);
            }
            if (polyline.PointCount == 2)
            {
                axRenderControl1.InteractMode          = gviInteractMode.gviInteractNormal;
                axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectNone;
                axRenderControl1.MouseSelectMode       = gviMouseSelectMode.gviMouseSelectClick;
                axRenderControl1.RcMouseClickSelect   -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(g_RcMouseClickSelect);

                flagx = false;
            }
            renderPolyline.SetFdeGeometry(polyline);
        }
Beispiel #4
0
 void g_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
 {
     if (PickResult == null)
     {
         return;
     }
     else
     {
         if (PickResult.Type == gviObjectType.gviObjectTableLabel)
         {
             ITableLabelPickResult tlpr = PickResult as ITableLabelPickResult;
             gviObjectType         type = tlpr.Type;
             ITableLabel           fl   = tlpr.TableLabel;
             MessageBox.Show("拾取到" + type + "类型,名称为" + fl.TitleText);
         }
     }
 }
Beispiel #5
0
        /// <summary>
        /// 鼠标点击 拾取线段点
        /// </summary>
        /// <param name="PickResult"></param>
        /// <param name="IntersectPoint"></param>
        /// <param name="Mask"></param>
        /// <param name="EventSender"></param>
        void g_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IntersectPoint == null)
            {
                return;
            }

            if (renderPolyline == null)
            {
                renderPolyline = axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, null, rootId);
            }

            if (polyline.PointCount < 2)
            {
                polyline.AppendPoint(IntersectPoint);
            }
            if (polyline.PointCount == 2)
            {
                axRenderControl1.InteractMode          = gviInteractMode.gviInteractNormal;
                axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectNone;
                axRenderControl1.MouseSelectMode       = gviMouseSelectMode.gviMouseSelectClick;
                axRenderControl1.RcMouseClickSelect   -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(g_RcMouseClickSelect);

                IPoint p = polyline.StartPoint;
                this.startX.Text = p.X.ToString();
                this.startY.Text = p.Y.ToString();
                this.startZ.Text = p.Z.ToString();
                p = polyline.EndPoint;
                this.endX.Text   = p.X.ToString();
                this.endY.Text   = p.Y.ToString();
                this.endZ.Text   = p.Z.ToString();
                flagx            = false;
                this.label7.Text = "线构造成功!请点击“通视分析”按钮";
                this.btnFlyToSourcePoint.Enabled = true;
                this.btnFlyToTargetPoint.Enabled = true;
            }
            renderPolyline.SetFdeGeometry(polyline);
        }
Beispiel #6
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (PickResult != null)
            {
                if (PickResult.Type == gviObjectType.gviObjectFeatureLayer)
                {
                    IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult;
                    int           fid            = flpr.FeatureId;
                    IFeatureLayer fl             = flpr.FeatureLayer;
                    foreach (IFeatureClass fc in fcMap.Keys)
                    {
                        if (fc.Guid.Equals(fl.FeatureClassId))
                        {
                            IRowBuffer fdeRow = fc.GetRow(fid);
                            int        nPos   = fdeRow.FieldIndex("Geometry");
                            switch (source)
                            {
                            case SOURCE.SELECT1:
                                this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Yellow);
                                geo1.AddGeometry(fdeRow.GetValue(nPos) as IPolygon);
                                drawLabel(IntersectPoint, "要素一", System.Drawing.Color.Yellow);
                                break;

                            case SOURCE.SELECT2:
                                this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Red);
                                geo2.AddGeometry(fdeRow.GetValue(nPos) as IPolygon);
                                drawLabel(IntersectPoint, "要素二", System.Drawing.Color.Yellow);
                                break;
                            }
                            SelectObject obj = new SelectObject();
                            obj.FC = fc;
                            obj.ID = fid;
                            objToHide.Add(obj);
                        }
                    } // end foreach
                }
            }
            if (source == SOURCE.SELECT1 || source == SOURCE.SELECT2)
            {
                this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);

                this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal;
            }
        }
Beispiel #7
0
        private void AxRenderControl_RcMouseDragSelect(IPickResultCollection PickResults, gviModKeyMask Mask)
        {
            if (PickResults != null)
            {
                int         i = 0;
                IPickResult t = null;
                while ((t = PickResults.Get(i)) != null)
                {
                    if (t.Type == gviObjectType.gviObjectRenderPoint)
                    {
                        IRenderPoint temp = ((IRenderPointPickResult)t).Point;
                    }

                    if (t.Type == gviObjectType.gviObject3DTileLayer)
                    {
                        I3DTileLayer temp = ((I3DTileLayerPickResult)t).TileLayer;
                    }

                    if (t.Type == gviObjectType.gviObjectRenderModelPoint)
                    {
                        IRenderModelPoint temp = ((IRenderModelPointPickResult)t).ModelPoint;
                    }
                }
            }
        }
Beispiel #8
0
        void g_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IntersectPoint == null)
            {
                return;
            }
            if (isDrawing == true)
            {
                if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectClick))
                {
                    mouseClicks++;
                    if (mouseClicks % 2 == 1)
                    {
                        switch (type)
                        {
                        case HelperType.SectorRegion:
                        {
                            this.label7.Text = "请鼠标点击选择目标点";
                            fde_point1       = IntersectPoint;
                            axRenderControl1.MouseSelectMode = gviMouseSelectMode.gviMouseSelectClick | gviMouseSelectMode.gviMouseSelectMove;
                        }
                        break;

                        case HelperType.CircleRegion:
                        {
                            this.label7.Text = "请鼠标点击选择最外环点";
                            fde_point1       = IntersectPoint;
                            axRenderControl1.MouseSelectMode = gviMouseSelectMode.gviMouseSelectClick | gviMouseSelectMode.gviMouseSelectMove;
                        }
                        break;
                        }
                    }
                    else
                    {
                        isDrawing        = false;
                        this.label7.Text = "画结束";
                        this.btnSetSectorRegion.Enabled = true;
                        this.btnSetCircleRegion.Enabled = true;
                        this.btnSetRegion.Enabled       = true;

                        axRenderControl1.InteractMode          = gviInteractMode.gviInteractNormal;
                        axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectNone;
                        axRenderControl1.MouseSelectMode       = gviMouseSelectMode.gviMouseSelectClick;
                        axRenderControl1.RcMouseClickSelect   -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(g_RcMouseClickSelect);
                    }
                }
                else if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectMove))
                {
                    switch (type)
                    {
                    case HelperType.SectorRegion:
                    {
                        fde_point2 = IntersectPoint;
                        axRenderControl1.HighlightHelper.SetSectorRegion(fde_point1, fde_point2, double.Parse(this.numHorizontalAngle.Value.ToString()));
                    }
                    break;

                    case HelperType.CircleRegion:
                    {
                        fde_point2 = IntersectPoint;
                        ILine fde_line = geoFactory.CreateGeometry(gviGeometryType.gviGeometryLine,
                                                                   gviVertexAttribute.gviVertexAttributeZ) as ILine;
                        fde_line.StartPoint    = fde_point1;
                        fde_line.EndPoint      = fde_point2;
                        this.centerRadius.Text = fde_line.Length.ToString();
                        axRenderControl1.HighlightHelper.SetCircleRegion(fde_point1, fde_line.Length);
                    }
                    break;
                    }
                }
            }
        }
Beispiel #9
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (PickResult == null)
            {
                return;
            }

            if (EventSender == gviMouseSelectMode.gviMouseSelectMove)
            {
                if (currentLabel != null)
                {
                    currentLabel.Position = IntersectPoint;
                }
            }
            else if (EventSender == gviMouseSelectMode.gviMouseSelectClick)
            {
                switch (mode)
                {
                case 1:
                {
                    this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal;
                }
                break;

                case 2:
                {
                    if (clickCount == 0)
                    {
                        ILabelPickResult pr = PickResult as ILabelPickResult;
                        if (pr != null)
                        {
                            currentLabel = pr.Label;
                            clickCount++;
                        }
                    }
                    else if (clickCount == 1)
                    {
                        this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal;
                    }
                }
                break;
                }
            }
        }
Beispiel #10
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            try
            {
                if (PickResult != null)
                {
                    if (PickResult.Type == gviObjectType.gviObjectFeatureLayer)
                    {
                        IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult;
                        int fid = flpr.FeatureId;
                        this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow);

                        //////////////////////////////////////////////////////////////////////////
                        //
                        //  GeometryConvert的代码添加在这里
                        //
                        //////////////////////////////////////////////////////////////////////////
                        fidList.Clear();
                        fidList.Add(fid);
                        IRowBuffer rowGC = _featureClass.GetRow(fidList[0]);

                        int nPose = rowGC.FieldIndex("Geometry");
                        if (nPose == -1)
                        {
                            MessageBox.Show("不存在Geometry列");
                            return;
                        }

                        // 获取polygon
                        IPolyline polylineGC = null;
                        if (rowGC != null)
                        {
                            nPose = rowGC.FieldIndex("Geometry");
                            IGeometry geo = rowGC.GetValue(nPose) as IGeometry;
                            if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                            {
                                polylineGC = geo as IPolyline;
                            }
                        }

                        if (polylineGC != null)
                        {
                            this.Text = "拾取成功";
                        }
                        else
                        {
                            this.Text = "拾取失败";
                        }

                        param = new PropertySet();

                        if (this.tabControl1.SelectedIndex == 0)
                        {
                            // 1.调接口构造模型
                            double innerRadius = double.Parse(this.numInnerRadius.Value.ToString());
                            param.SetProperty("InnerRadius", innerRadius);
                            double outerRadius = double.Parse(this.numOuterRadius.Value.ToString());
                            param.SetProperty("OuterRadius", outerRadius);
                            double deflection = double.Parse(this.numDeflection.Value.ToString());
                            param.SetProperty("Deflection", deflection);

                            Color difColor = Color.FromArgb(Convert.ToInt32(DifColorBox.Text, 16));
                            param.SetProperty("DiffuseColor", difColor);
                            Color speColor = Color.FromArgb(Convert.ToInt32(SpeColorBox.Text, 16));
                            param.SetProperty("SpecularColor", speColor);


                            IModelPoint mp    = null;
                            IModel      model = null;
                            if (!paraModel.PolylineToPipeLine(polylineGC, param, out mp, out model))
                            {
                                MessageBox.Show("拉管线出错!");
                                return;
                            }

                            //2、将模型及贴图写入osg文件
                            string modelName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".osg");//输出osg文件路径
                            model.WriteFile(modelName, null);

                            //3、测试显示模型
                            mp.ModelName = modelName;
                            IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, null, rootId);
                            rmp.MouseSelectMask    = gviViewportMask.gviViewNone;
                            rmp.MaxVisibleDistance = 100000;
                            this.axRenderControl1.Camera.LookAtEnvelope(mp.Envelope);//飞入
                            mpList.Add(rmp);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                if (ex.GetType().Name.Equals("UnauthorizedAccessException"))
                {
                    MessageBox.Show("需要标准runtime授权");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #11
0
        void axRenderControl1_RcMouseClickSelect_CreateFeature(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            _geoEditor.FinishEdit();   //用于当拾取到基准面时,或者没有正常右键结束连续调用Start时
            this.axRenderControl1.FeatureManager.UnhighlightAll();

            if (PickResult != null)
            {
                switch (PickResult.Type)
                {
                case gviObjectType.gviObjectFeatureLayer:
                {
                    IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult;
                    int fid = flpr.FeatureId;
                    //加载多FeatureClass时要每次重新获取
                    _featureClass = (IFeatureClass)fcGUIDMap[flpr.FeatureLayer.FeatureClassId];
                    _featureLayer = flpr.FeatureLayer;

                    IFdeCursor cursor = null;
                    try
                    {
                        _buffer = _featureClass.CreateRowBuffer();
                        IQueryFilter filter = new QueryFilter();
                        //filter.AddSubField("oid");  //注意:StartEditFeatureGeometry里必须传入一个完整的rowbuffer,所以这里不能限定字段
                        filter.WhereClause = "oid =" + fid;
                        cursor             = _featureClass.Search(filter, false);
                        IRowBuffer row = null;

                        if ((row = cursor.NextRow()) != null)
                        {
                            _buffer = row as IRowBuffer;
                            int pos = _buffer.FieldIndex("Geometry");
                            oldfdeGeometry = _buffer.GetValue(pos) as IGeometry;
                            _buffer.SetValue(0, _featureClass.GetCount(null));          //修改fid为不同值,否则不是创建而是编辑
                        }
                    }
                    catch (COMException ex)
                    {
                        System.Diagnostics.Trace.WriteLine(ex.Message);
                    }
                    finally
                    {
                    }

                    this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow);

                    resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEditCreator);
                    if (!resultCode)
                    {
                        MessageBox.Show(this.axRenderControl1.GetLastError().ToString());
                    }
                }
                break;
                }
            }
        }
Beispiel #12
0
        void axRenderControl1_RcMouseClickSelect3(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IntersectPoint == null)
            {
                return;
            }

            if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectClick))
            {
                this.axRenderControl1.InteractMode        = gviInteractMode.gviInteractNormal;
                this.axRenderControl1.RcMouseClickSelect -= new Gvitech.CityMaker.Controls._IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect3);


                IViewshedPickResult pr = PickResult as IViewshedPickResult;
                if (pr == null)
                {
                    return;
                }

                IViewshed v = pr.Viewshed;
                if (v == null)
                {
                    return;
                }
                v.Highlight(System.Drawing.Color.Red);
            }
        }
Beispiel #13
0
        void axRenderControl1_RcMouseDragSelect(IPickResultCollection PickResults, gviModKeyMask Mask)
        {
            IPickResultCollection prc = PickResults;

            if (prc == null)
            {
                return;
            }

            Hashtable fcEnvMap = new Hashtable();

            this.axRenderControl1.FeatureManager.UnhighlightAll();
            for (int i = 0; i < prc.Count; i++)
            {
                IPickResult pr = prc.Get(i);
                if (pr.Type == gviObjectType.gviObjectFeatureLayer)
                {
                    IFeatureLayerPickResult flpr = pr as IFeatureLayerPickResult;
                    int           fid            = flpr.FeatureId;
                    IFeatureLayer fl             = flpr.FeatureLayer;
                    foreach (IFeatureClass fc in fcMap.Keys)
                    {
                        if (fc.Guid.Equals(fl.FeatureClassId))
                        {
                            this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Yellow);

                            if (fcEnvMap.ContainsKey(fc))
                            {
                                List <int> fids = fcEnvMap[fc] as List <int>;
                                fids.Add(fid);
                                fcEnvMap.Remove(fc);
                                fcEnvMap.Add(fc, fids);
                            }
                            else
                            {
                                List <int> fids = new List <int>();
                                fids.Add(fid);
                                fcEnvMap.Add(fc, fids);

                                fcGUIDs.Add(fc.Guid);
                            }
                        }
                    }
                }
            }

            // 计算Envelope
            env = null;
            foreach (IFeatureClass fc in fcEnvMap.Keys)
            {
                List <int> fids = fcEnvMap[fc] as List <int>;
                if (env == null)
                {
                    env = fc.GetFeaturesEnvelope(fids.ToArray(), "Geometry");
                }
                else
                {
                    env.ExpandByEnvelope(fc.GetFeaturesEnvelope(fids.ToArray(), "Geometry"));
                }
            }

            // 设定出图参数
            switch (type)
            {
            case ExportType.Export25D:
            {
                Export25D();
            }
            break;

            case ExportType.ExportDEM:
            {
                ExportDEM();
            }
            break;

            case ExportType.ExportDOM:
            {
                ExportDOM();
            }
            break;

            case ExportType.ExportOrthoImage:
            {
                ExportOrthoImage();
            }
            break;
            }

            // 恢复漫游模式
            this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal;
        }
Beispiel #14
0
        private void AxRenderControl_MouseClick(IPickResult IPickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IPickResult != null)
            {
                if (IPickResult.Type == gviObjectType.gviObjectRenderPoint)
                {
                    IRenderPoint temp = ((IRenderPointPickResult)IPickResult).Point;
                }

                if (IPickResult.Type == gviObjectType.gviObject3DTileLayer)
                {
                    I3DTileLayer temp = ((I3DTileLayerPickResult)IPickResult).TileLayer;
                }

                if (IPickResult.Type == gviObjectType.gviObjectRenderModelPoint)
                {
                    IRenderModelPoint temp = ((IRenderModelPointPickResult)IPickResult).ModelPoint;
                }
            }
        }
Beispiel #15
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IntersectPoint == null)
            {
                return;
            }

            if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectClick))
            {
                this.axRenderControl1.InteractMode        = gviInteractMode.gviInteractNormal;
                this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);


                //把视频加入list,同时更新界面
                locationName   = tmpTV.ViewshedObject.Guid.ToString();
                cp             = new CameraProperty();
                cp.name        = locationName;
                cp.X           = tmpTV.ViewshedObject.Position.X;
                cp.Y           = tmpTV.ViewshedObject.Position.Y;
                cp.Z           = tmpTV.ViewshedObject.Position.Z;
                cp.Heading     = tmpTV.ViewshedObject.Angle.Heading;
                cp.Roll        = tmpTV.ViewshedObject.Angle.Roll;
                cp.Tilt        = tmpTV.ViewshedObject.Angle.Tilt;
                cp.AspectRatio = tmpTV.ViewshedObject.AspectRatio;
                cp.FieldOfView = tmpTV.ViewshedObject.FieldOfView;

                videoList.Add(tmpTV.ViewshedObject);
                cp.index = videoList.Count - 1;

                DataRow dr = dt.NewRow();
                dr["Name"]     = locationName;
                dr["Location"] = cp;
                dr["Object"]   = tmpTV;
                dt.Rows.Add(dr);

                this.dataGridView1.Rows[dt.Rows.Count - 1].Selected = true;

                pf.SetSource(tmpTV);
            }
            else if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectMove))
            {
                this.axRenderControl1.Camera.GetCamera(out vector, out angle);
                tmpTV.SetAngle(angle);

                positionPoint    = IntersectPoint;
                positionPoint.Z += 10;
                tmpTV.SetPosition(positionPoint);
            }
        }
Beispiel #16
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            try
            {
                this.axRenderControl1.FeatureManager.UnhighlightAll();
                if (PickResult != null)
                {
                    if (PickResult.Type == gviObjectType.gviObjectFeatureLayer)
                    {
                        IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult;
                        int fid = flpr.FeatureId;
                        this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow);

                        //////////////////////////////////////////////////////////////////////////
                        //
                        //  GeometryConvert的代码添加在这里
                        //
                        //////////////////////////////////////////////////////////////////////////
                        fidList.Clear();
                        fidList.Add(fid);
                        IRowBuffer rowGC = _featureClass.GetRow(fidList[0]);

                        int nPose = rowGC.FieldIndex("Geometry");
                        if (nPose == -1)
                        {
                            MessageBox.Show("不存在Geometry列");
                            return;
                        }

                        // 获取ModelPoint
                        IModelPoint modelPointGC = null;
                        if (rowGC != null)
                        {
                            nPose = rowGC.FieldIndex("Geometry");
                            IGeometry geo = rowGC.GetValue(nPose) as IGeometry;
                            if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint)
                            {
                                modelPointGC = geo as IModelPoint;
                            }
                        }

                        this.Text = "拾取成功";

                        // 获取Model
                        string modelName = modelPointGC.ModelName;
                        IModel modelGC   = (_featureClass.FeatureDataSet as IResourceManager).GetModel(modelName);

                        // 1、获取MultiTriMesh
                        IGeometryConvertor gc      = new GeometryConvertor();
                        IMultiTriMesh      multiTM = gc.ModelPointToTriMesh(modelGC, modelPointGC, false);
                        this.Text = "ModelToTriMesh完成";

                        if (this.cbCreateRenderTriMesh.Checked)
                        {
                            // 创建RenderTriMesh在三维上显示
                            for (int i = 0; i < multiTM.GeometryCount; i++)
                            {
                                ITriMesh       tm  = multiTM.GetGeometry(i) as ITriMesh;
                                IRenderTriMesh rtm = this.axRenderControl1.ObjectManager.CreateRenderTriMesh(tm, null, rootId);

                                //随机颜色填充TriMesh
                                Random         randObj = new Random(i);
                                int            aColor  = randObj.Next(0, 255);
                                int            gColor  = randObj.Next(0, 255);
                                int            rColor  = randObj.Next(0, 255);
                                ISurfaceSymbol ss      = new SurfaceSymbol();
                                ss.Color   = System.Drawing.Color.FromArgb(rColor, gColor, aColor);
                                rtm.Symbol = ss;
                                rTMeshList.Add(rtm);
                            }
                        }

                        if (this.cbCreateRenderPolygon.Checked)
                        {
                            // 2、获取投影MultiPolygon
                            IMultiPolygon multiPolygon = gc.ProjectTriMeshToPolygon(multiTM, 1.0);
                            this.Text = "MultiTriMeshToFootprint完成。面积:" + multiPolygon.GetArea();

                            // 创建RenderPolygon在三维上显示
                            for (int i = 0; i < multiPolygon.GeometryCount; i++)
                            {
                                IPolygon       polygon  = multiPolygon.GetGeometry(i) as IPolygon;
                                IRenderPolygon rpolygon = this.axRenderControl1.ObjectManager.CreateRenderPolygon(polygon, null, rootId);
                                rPolygonList.Add(rpolygon);
                            }
                        }

                        if (this.cbCreateRenderPolygon2.Checked)
                        {
                            // 3、获取切割MultiPolygon
                            double heightSpec = 0.0, heightIntersect = 0.0;
                            Double.TryParse(IntersectPoint.Z.ToString(), out heightIntersect);
                            fidList.Clear();
                            fidList.Add(fid);
                            IEnvelope box = _featureClass.GetFeaturesEnvelope(fidList.ToArray(), "Geometry");
                            heightSpec = System.Math.Abs(heightIntersect - box.MinZ);
                            // 注意:CutTriMeshToPolygon方法的第三个参数为空间分辨率,应该选择合适值。
                            // 值过大会导致结果不精确,值过小会导致转换时间过长。使用时应设置大小合适的值来平衡精度和效率问题。
                            IMultiPolygon multiPolygon2 = gc.CutTriMeshToPolygon(multiTM, heightSpec, 0.5);
                            this.Text = "MultiTriMeshToFootprint2完成。面积:" + multiPolygon2.GetArea();

                            // 创建RenderPolygon在三维上显示
                            for (int i = 0; i < multiPolygon2.GeometryCount; i++)
                            {
                                IPolygon       polygon2  = multiPolygon2.GetGeometry(i) as IPolygon;
                                IRenderPolygon rpolygon2 = this.axRenderControl1.ObjectManager.CreateRenderPolygon(polygon2, null, rootId);
                                rPolygonList2.Add(rpolygon2);
                            }
                        }

                        if (this.cbCreateRenderMulPoint.Checked)
                        {
                            // 4、获取MultiPoint
                            IMultiPoint multiPoint = gc.MultiTriMeshToMultiPoint(multiTM, 3.0);
                            this.Text = "MultiTriMeshToMultiPoint完成。MultiPoint个数为:" + multiPoint.GeometryCount;

                            //创建RenderPoint在三维上显示
                            IRenderMultiPoint rpoint = this.axRenderControl1.ObjectManager.CreateRenderMultiPoint(multiPoint, null, rootId);
                            rPointList.Add(rpoint);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                if (ex.GetType().Name.Equals("UnauthorizedAccessException"))
                {
                    MessageBox.Show("需要标准runtime授权");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #17
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            IPickResult pr = PickResult;

            if (pr == null && CTRL && Mask == gviModKeyMask.gviModKeyCtrl)
            {
                return;
            }

            if (!CTRL || (CTRL && Mask != gviModKeyMask.gviModKeyCtrl))   //ctrl键
            {
                this.axRenderControl1.FeatureManager.UnhighlightAll();
            }

            if (EventSender == gviMouseSelectMode.gviMouseSelectClick)
            {
                if (PickResult != null)
                {
                    if (pr.Type == gviObjectType.gviObjectFeatureLayer)
                    {
                        IFeatureLayerPickResult flpr = pr as IFeatureLayerPickResult;
                        int           fid            = flpr.FeatureId;
                        IFeatureLayer fl             = flpr.FeatureLayer;
                        foreach (IFeatureClass fc in fcMap.Keys)
                        {
                            if (fc.Guid.Equals(fl.FeatureClassId))
                            {
                                this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Yellow);
                            }
                        }

                        WindowParam wp = new WindowParam();
                        wp.FilePath          = @"D:\05_CityMaker_DeveloperKit\trunk\SDK\Samples\JS\beginner\HTMLWindow\PropertyWindow.html";
                        wp.Position          = gviHTMLWindowPosition.gviWinPosCenterParent;
                        wp.SizeX             = 200;
                        wp.SizeY             = 150;
                        wp.Hastitle          = false;
                        wp.IsPopupWindow     = false;
                        wp.UseMoveHoverEvent = true;
                        wp.HideOnClick       = false;
                        wp.WinId             = fid;
                        IHTMLWindow hw = this.axRenderControl1 as IHTMLWindow;
                        hw.ShowPopupWindowEx(IntersectPoint, wp, true);
                    }
                }
            }
        }
Beispiel #18
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (PickResult == null)
            {
                return;
            }

            IRenderPolygonPickResult rpPickResult = PickResult as IRenderPolygonPickResult;

            if (rpPickResult != null)
            {
                IRenderPolygon rp        = rpPickResult.Polygon;
                string         strToShow = rp.GetClientData("Name");

                if (label == null)
                {
                    label = this.axRenderControl1.ObjectManager.CreateLabel(rootId);
                }
                label.Text     = strToShow;
                label.Position = IntersectPoint;
            }
        }
Beispiel #19
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            //获取水源点
            waterPoint = IntersectPoint;
            //设置参数
            this.numWaterHStart.Value = (decimal)IntersectPoint.Z;
            this.numWaterHEnd.Value   = (decimal)(IntersectPoint.Z + 30);
            //获取缓冲区bufPolygon\renderBufPolygon
            radius = (double)numBufferRadius.Value;
            ITopologicalOperator2D to = waterPoint as ITopologicalOperator2D;

            bufPolygon = to.Buffer2D(radius, gviBufferStyle.gviBufferCapround) as IPolygon;
            ISurfaceSymbol sf = new SurfaceSymbol();

            sf.Color = System.Drawing.Color.Yellow;
            ICurveSymbol cs = new CurveSymbol();

            cs.Color                     = System.Drawing.Color.Yellow;
            sf.BoundarySymbol            = cs;
            renderBufPolygon             = this.axRenderControl1.ObjectManager.CreateRenderPolygon(bufPolygon, sf, rootId);
            renderBufPolygon.HeightStyle = gviHeightStyle.gviHeightOnTerrain;

            this.axRenderControl1.InteractMode        = gviInteractMode.gviInteractNormal;
            this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);

            this.btnOnProcess.Enabled = true;
            this.btnSimulate.Enabled  = true;
        }
Beispiel #20
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (PickResult == null)
            {
                return;
            }
            IOverlayLabelPickResult pr    = PickResult as IOverlayLabelPickResult;
            IOverlayLabel           label = pr.OverlayLabel;

            this.Text = label.Text;
        }
Beispiel #21
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            this.axRenderControl1.FeatureManager.UnhighlightAll();

            // 置空
            _buffer       = null;
            _featureLayer = null;

            if (PickResult != null)
            {
                switch (PickResult.Type)
                {
                case gviObjectType.gviObjectFeatureLayer:
                {
                    IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult;
                    int fid = flpr.FeatureId;
                    //加载多FeatureClass时要每次重新获取
                    _featureClass = (IFeatureClass)fcGUIDMap[flpr.FeatureLayer.FeatureClassId];
                    _featureLayer = flpr.FeatureLayer;

                    IFdeCursor cursor = null;
                    try
                    {
                        _buffer = _featureClass.CreateRowBuffer();
                        QueryFilter filter = new QueryFilter();
                        //filter.AddSubField("oid");  //注意:StartEditFeatureGeometry里必须传入一个完整的rowbuffer,所以这里不能限定字段
                        filter.WhereClause = "oid =" + fid;
                        cursor             = _featureClass.Search(filter, false);
                        IRowBuffer row = null;
                        if ((row = cursor.NextRow()) != null)
                        {
                            _buffer = row as IRowBuffer;
                            int pos = _buffer.FieldIndex("Geometry");
                            oldfdeGeometry = _buffer.GetValue(pos) as IGeometry;
                        }
                    }
                    catch (COMException ex)
                    {
                        System.Diagnostics.Trace.WriteLine(ex.Message);
                    }
                    finally
                    {
                    }

                    this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow);
                    EditGeometry();
                }
                break;
                }
            }
        }
Beispiel #22
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (EventSender == gviMouseSelectMode.gviMouseSelectClick)
            {
                this.axRenderControl1.FeatureManager.UnhighlightAll();
                IPickResult pr = PickResult;
                if (pr == null)
                {
                    this.btn_AttachmentManager.Enabled = false;
                    return;
                }
                else if (pr.Type == gviObjectType.gviObjectFeatureLayer)
                {
                    IFeatureLayerPickResult flpr = pr as IFeatureLayerPickResult;
                    curSelectFid = flpr.FeatureId;
                    IFeatureLayer fl = flpr.FeatureLayer;

                    curSelectFc = fcuidMap[fl.FeatureClassId] as IFeatureClass;
                    this.btn_AttachmentManager.Enabled = true;
                    this.axRenderControl1.FeatureManager.HighlightFeature(curSelectFc, curSelectFid, System.Drawing.Color.Red);
                }
                else
                {
                    this.btn_AttachmentManager.Enabled = false;
                    return;
                }
            }
        }
Beispiel #23
0
        void axRenderControl1_RcMouseClickSelect2(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IntersectPoint == null)
            {
                return;
            }

            if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectClick))
            {
                this.axRenderControl1.InteractMode        = gviInteractMode.gviInteractNormal;
                this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect2);


                ISimplePointSymbol ps = new SimplePointSymbol();
                ps.Size      = 20;
                ps.FillColor = System.Drawing.Color.Red;
                this.axRenderControl1.ObjectManager.CreateRenderPoint(IntersectPoint, ps, rootId);

                for (int i = 0; i < videoList.Count; i++)
                {
                    IViewshed v = videoList[i];
                    v.Unhighlight();
                    double wx, wy;
                    bool   isIn = v.WorldToScreen(IntersectPoint, 1, out wx, out wy);
                    if (isIn)
                    {
                        v.Highlight(System.Drawing.Color.Red);

                        IPoint poiInWorld = v.ScreenToWorld(wx, wy);
                        if (poiInWorld != null)
                        {
                            this.axRenderControl1.InteractMode = gviInteractMode.gviInteractFocus;
                            bool bFocus = this.axRenderControl1.Camera.SetFocus(poiInWorld);
                            if (bFocus)
                            {
                                MessageBox.Show("set focus success!");
                            }
                        }
                    }
                }
            }
        }
Beispiel #24
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (PickResult.Type == gviObjectType.gviObjectLabel)
            {
                ILabelPickResult tlpr = PickResult as ILabelPickResult;
                gviObjectType    type = tlpr.Type;
                ILabel           fl   = tlpr.Label;
                MessageBox.Show("拾取到" + type + "类型,内容为" + fl.Text);
            }
            else if (PickResult.Type == gviObjectType.gviObjectRenderModelPoint)
            {
                IRenderModelPointPickResult tlpr = PickResult as IRenderModelPointPickResult;
                gviObjectType     type           = tlpr.Type;
                IRenderModelPoint fl             = tlpr.ModelPoint;
                MessageBox.Show("拾取到" + type + "类型,模型名称为" + fl.ModelName);
            }
            else if (PickResult.Type == gviObjectType.gviObjectRenderPoint)
            {
                IRenderPointPickResult tlpr = PickResult as IRenderPointPickResult;
                gviObjectType          type = tlpr.Type;
                IRenderPoint           fl   = tlpr.Point;
                MessageBox.Show("拾取到" + type + "类型,大小为" + fl.Symbol.Size);
            }
            else if (PickResult.Type == gviObjectType.gviObjectRenderPolyline)
            {
                IRenderPolylinePickResult tlpr = PickResult as IRenderPolylinePickResult;
                gviObjectType             type = tlpr.Type;
                IRenderPolyline           fl   = tlpr.Polyline;
                MessageBox.Show("拾取到" + type + "类型,GUID为" + fl.Guid);
            }
            else if (PickResult.Type == gviObjectType.gviObjectRenderPolygon)
            {
                IRenderPolygonPickResult tlpr = PickResult as IRenderPolygonPickResult;
                gviObjectType            type = tlpr.Type;
                IRenderPolygon           fl   = tlpr.Polygon;
                MessageBox.Show("拾取到" + type + "类型,GUID为" + fl.Guid);
            }
            else if (PickResult.Type == gviObjectType.gviObjectRenderPOI)
            {
                IRenderPOIPickResult tlpr = PickResult as IRenderPOIPickResult;
                gviObjectType        type = tlpr.Type;
                IRenderPOI           fl   = tlpr.POI;
                MessageBox.Show("拾取到" + type + "类型,名称为" + ((IPOI)fl.GetFdeGeometry()).Name);
            }
            else if (PickResult.Type == gviObjectType.gviObjectTerrainRegularPolygon)
            {
                ITerrainRegularPolygonPickResult regPolygonPick = PickResult as ITerrainRegularPolygonPickResult;
                gviObjectType          type       = regPolygonPick.Type;
                ITerrainRegularPolygon regPolygon = regPolygonPick.TerrainRegularPolygon;
                MessageBox.Show("拾取到" + type + "类型,geometryCount为" + regPolygon.GetFdeGeometry().GeometryType);
            }
            else if (PickResult.Type == gviObjectType.gviObjectTerrainArrow)
            {
                ITerrainArrowPickResult arrowPickResult = PickResult as ITerrainArrowPickResult;
                gviObjectType           type            = arrowPickResult.Type;
                ITerrainArrow           arrow           = arrowPickResult.TerrainArrow;
                MessageBox.Show("拾取到" + type + "类型,geometryType" + arrow.GetFdeGeometry().GeometryType);
            }
            else if (PickResult.Type == gviObjectType.gviObjectReferencePlane)
            {
                switch (this.toolStripComboBoxObjectManager.Text)
                {
                case "CreateLabel":
                {
                    label                     = this.axRenderControl1.ObjectManager.CreateLabel(rootId);
                    label.Text                = "我是testlabel";
                    label.Position            = IntersectPoint;
                    textSymbol                = new TextSymbol();
                    textAttribute             = new TextAttribute();
                    textAttribute.TextColor   = System.Drawing.Color.Yellow;
                    textAttribute.TextSize    = 20;
                    textAttribute.Underline   = true;
                    textAttribute.Font        = "楷体";
                    textSymbol.TextAttribute  = textAttribute;
                    textSymbol.VerticalOffset = 10;
                    textSymbol.DrawLine       = true;
                    textSymbol.MarginColor    = System.Drawing.Color.Yellow;
                    label.TextSymbol          = textSymbol;
                    this.axRenderControl1.Camera.FlyToObject(label.Guid, gviActionCode.gviActionFlyTo);
                }
                break;

                case "CreateRenderModelPoint":
                {
                    if (gfactory == null)
                    {
                        gfactory = new GeometryFactory();
                    }

                    string tmpOSGPath = (strMediaPath + @"\osg\Buildings\Apartment\Apartment.osg");
                    fde_modelpoint = gfactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint,
                                                             gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
                    fde_modelpoint.SetCoords(IntersectPoint.X, IntersectPoint.Y, IntersectPoint.Z, 0, 0);
                    fde_modelpoint.ModelName = tmpOSGPath;
                    rmodelpoint = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(fde_modelpoint, null, rootId);
                    rmodelpoint.MaxVisibleDistance = double.MaxValue;
                    rmodelpoint.MinVisiblePixels   = 0;
                    rmodelpoint.ShowOutline        = checkShowOutline.Checked;
                    IEulerAngle angle = new EulerAngle();
                    angle.Set(0, -20, 0);
                    this.axRenderControl1.Camera.LookAt(IntersectPoint.Position, 100, angle);
                }
                break;

                case "CreateRenderPoint":
                {
                    if (gfactory == null)
                    {
                        gfactory = new GeometryFactory();
                    }

                    fde_point = (IPoint)gfactory.CreateGeometry(gviGeometryType.gviGeometryPoint,
                                                                gviVertexAttribute.gviVertexAttributeZ);
                    fde_point.SetCoords(IntersectPoint.X, IntersectPoint.Y, IntersectPoint.Z, 0, 0);

                    pointSymbol           = new SimplePointSymbol();
                    pointSymbol.FillColor = System.Drawing.Color.Red;
                    pointSymbol.Size      = 10;
                    rpoint             = this.axRenderControl1.ObjectManager.CreateRenderPoint(fde_point, pointSymbol, rootId);
                    rpoint.ShowOutline = checkShowOutline.Checked;
                    this.axRenderControl1.Camera.FlyToObject(rpoint.Guid, gviActionCode.gviActionFlyTo);
                }
                break;

                case "CreateRenderPolyline":
                {
                    if (gfactory == null)
                    {
                        gfactory = new GeometryFactory();
                    }

                    fde_polyline = (IPolyline)gfactory.CreateGeometry(gviGeometryType.gviGeometryPolyline,
                                                                      gviVertexAttribute.gviVertexAttributeZ);
                    fde_point = (IPoint)gfactory.CreateGeometry(gviGeometryType.gviGeometryPoint,
                                                                gviVertexAttribute.gviVertexAttributeZ);
                    fde_point.SetCoords(IntersectPoint.X, IntersectPoint.Y, IntersectPoint.Z, 0, 0);
                    fde_polyline.AppendPoint(fde_point);
                    fde_point.SetCoords(IntersectPoint.X + 20, IntersectPoint.Y, IntersectPoint.Z, 0, 0);
                    fde_polyline.AppendPoint(fde_point);
                    fde_point.SetCoords(IntersectPoint.X + 20, IntersectPoint.Y + 20, IntersectPoint.Z, 0, 0);
                    fde_polyline.AppendPoint(fde_point);
                    fde_point.SetCoords(IntersectPoint.X + 20, IntersectPoint.Y + 20, IntersectPoint.Z + 20, 0, 0);
                    fde_polyline.AppendPoint(fde_point);

                    lineSymbol            = new CurveSymbol();
                    lineSymbol.Color      = System.Drawing.Color.Red;     // 紫红色
                    rpolyline             = this.axRenderControl1.ObjectManager.CreateRenderPolyline(fde_polyline, lineSymbol, rootId);
                    rpolyline.ShowOutline = checkShowOutline.Checked;
                    this.axRenderControl1.Camera.FlyToObject(rpolyline.Guid, gviActionCode.gviActionFlyTo);
                }
                break;

                case "CreateRenderPolygon":
                {
                    if (gfactory == null)
                    {
                        gfactory = new GeometryFactory();
                    }

                    fde_polygon = (IPolygon)gfactory.CreateGeometry(gviGeometryType.gviGeometryPolygon,
                                                                    gviVertexAttribute.gviVertexAttributeZ);

                    fde_point = (IPoint)gfactory.CreateGeometry(gviGeometryType.gviGeometryPoint,
                                                                gviVertexAttribute.gviVertexAttributeZ);
                    fde_point.SetCoords(IntersectPoint.X, IntersectPoint.Y, IntersectPoint.Z, 0, 0);
                    fde_polygon.ExteriorRing.AppendPoint(fde_point);
                    fde_point.SetCoords(IntersectPoint.X + 10, IntersectPoint.Y, IntersectPoint.Z, 0, 0);
                    fde_polygon.ExteriorRing.AppendPoint(fde_point);
                    fde_point.SetCoords(IntersectPoint.X + 10, IntersectPoint.Y + 10, IntersectPoint.Z, 0, 0);
                    fde_polygon.ExteriorRing.AppendPoint(fde_point);
                    fde_point.SetCoords(IntersectPoint.X, IntersectPoint.Y + 10, IntersectPoint.Z, 0, 0);
                    fde_polygon.ExteriorRing.AppendPoint(fde_point);

                    surfaceSymbol        = new SurfaceSymbol();
                    surfaceSymbol.Color  = System.Drawing.Color.Blue;         // 蓝色
                    rpolygon             = this.axRenderControl1.ObjectManager.CreateRenderPolygon(fde_polygon, surfaceSymbol, rootId);
                    rpolygon.ShowOutline = checkShowOutline.Checked;
                    this.axRenderControl1.Camera.FlyToObject(rpolygon.Guid, gviActionCode.gviActionFlyTo);
                }
                break;

                case "CreateRenderPOI":
                {
                    if (gfactory == null)
                    {
                        gfactory = new GeometryFactory();
                    }

                    fde_poi = (IPOI)gfactory.CreateGeometry(gviGeometryType.gviGeometryPOI, gviVertexAttribute.gviVertexAttributeZ);
                    fde_poi.SetCoords(IntersectPoint.X, IntersectPoint.Y, IntersectPoint.Z, 0, 0);
                    fde_poi.ImageName = "#(1)";
                    fde_poi.Name      = (++poiCount).ToString();
                    fde_poi.Size      = 50;
                    rpoi             = this.axRenderControl1.ObjectManager.CreateRenderPOI(fde_poi);
                    rpoi.ShowOutline = checkShowOutline.Checked;
                    this.axRenderControl1.Camera.FlyToObject(rpoi.Guid, gviActionCode.gviActionFlyTo);
                }
                break;

                case "CreateFixedBillboard":
                {
                    TextAttribute ta = new TextAttribute();
                    ta.TextSize  = 10;
                    ta.TextColor = System.Drawing.Color.Yellow;
                    IImage image     = null;
                    IModel model     = null;
                    string imageName = "";
                    this.axRenderControl1.Utility.CreateFixedBillboard("I'm fixed billboard!", ta, 50, 100, true, out model, out image, out imageName);
                    this.axRenderControl1.ObjectManager.AddModel("fixedModel", model);
                    this.axRenderControl1.ObjectManager.AddImage(imageName, image);

                    if (gfactory == null)
                    {
                        gfactory = new GeometryFactory();
                    }
                    fde_modelpoint = gfactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint,
                                                             gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
                    fde_modelpoint.SetCoords(IntersectPoint.X, IntersectPoint.Y, IntersectPoint.Z, 0, 0);
                    fde_modelpoint.ModelName = "fixedModel";
                    rmodelpoint = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(fde_modelpoint, null, rootId);
                    rmodelpoint.MaxVisibleDistance = double.MaxValue;
                    rmodelpoint.MinVisiblePixels   = 0;
                    rmodelpoint.ShowOutline        = checkShowOutline.Checked;
                    IEulerAngle angle = new EulerAngle();
                    angle.Set(0, -20, 0);
                    this.axRenderControl1.Camera.LookAt(IntersectPoint.Position, 100, angle);
                }
                break;

                case "CreateRegularPolygon":
                {
                    IPosition pos = new Position();
                    pos.X        = IntersectPoint.X;
                    pos.Y        = IntersectPoint.Y;
                    pos.Altitude = IntersectPoint.Z;
                    ITerrainRegularPolygon regPolygon = this.axRenderControl1.ObjectManager.CreateRegularPolygon(pos, 10, 10, System.Drawing.Color.Red, System.Drawing.Color.White, rootId);
                    this.axRenderControl1.Camera.FlyToObject(regPolygon.Guid, gviActionCode.gviActionFlyTo);
                }
                break;

                case "CreateArrow":
                {
                    IPosition pos = new Position();
                    pos.X        = IntersectPoint.X;
                    pos.Y        = IntersectPoint.Y;
                    pos.Altitude = IntersectPoint.Z;
                    ITerrainArrow regArrow = this.axRenderControl1.ObjectManager.CreateArrow(pos, 30, 4, System.Drawing.Color.Red, System.Drawing.Color.White, rootId);
                    this.axRenderControl1.Camera.FlyToObject(regArrow.Guid, gviActionCode.gviActionFlyTo);
                }
                break;
                }
            }
        }
Beispiel #25
0
        /// <summary>
        /// 鼠标点击 拾取分析点
        /// </summary>
        /// <param name="PickResult"></param>
        /// <param name="IntersectPoint"></param>
        /// <param name="Mask"></param>
        /// <param name="EventSender"></param>
        void g_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IntersectPoint == null)
            {
                return;
            }

            if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectClick))
            {
                mouseClicks++;
                if (mouseClicks % 2 == 1)
                {
                    this.label7.Text = "请鼠标点击选择目标点";
                    this.startX.Text = IntersectPoint.X.ToString();
                    this.startY.Text = IntersectPoint.Y.ToString();
                    this.startZ.Text = (IntersectPoint.Z + double.Parse(numZOffset.Value.ToString())).ToString();

                    axRenderControl1.MouseSelectMode = gviMouseSelectMode.gviMouseSelectClick | gviMouseSelectMode.gviMouseSelectMove;
                }
                else
                {
                    this.label7.Text             = "选择结束";
                    this.btnStartAnalyse.Enabled = true;

                    axRenderControl1.InteractMode          = gviInteractMode.gviInteractNormal;
                    axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectNone;
                    axRenderControl1.MouseSelectMode       = gviMouseSelectMode.gviMouseSelectClick;
                    axRenderControl1.RcMouseClickSelect   -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(g_RcMouseClickSelect);


                    geoRegion = axRenderControl1.HighlightHelper.GetRegion();
                    //开始空间查询
                    try
                    {
                        this.label7.Text = "开始空间查询";
                        ISpatialFilter sfilter = new SpatialFilter();
                        sfilter.Geometry      = geoRegion;
                        sfilter.SpatialRel    = gviSpatialRel.gviSpatialRelIntersects;
                        sfilter.GeometryField = "footprint";
                        cursor = buildingFC.Search(sfilter, false);
                        row    = null;
                        while ((row = cursor.NextRow()) != null)
                        {
                            int nfidpos = row.FieldIndex("Geometry");
                            if (nfidpos > -1)
                            {
                                geoInFC = row.GetValue(nfidpos) as IGeometry;
                            }
                            if (geoInFC != null)
                            {
                                //AddOcluder
                                axRenderControl1.VisualAnalysis.AddOccluder(buildingFL, geoInFC);

                                //highlight occluder
                                int fidpos = row.FieldIndex("oid");
                                if (fidpos > -1)
                                {
                                    axRenderControl1.FeatureManager.HighlightFeature(buildingFC, int.Parse(row.GetValue(fidpos).ToString()), System.Drawing.Color.Red);
                                }
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                    }
                    finally
                    {
                        if (cursor != null)
                        {
                            //Marshal.ReleaseComObject(cursor);
                            cursor = null;
                        }
                    }

                    this.label7.Text = "正在视域分析中...";
                    //StartAnalyse
                    axRenderControl1.VisualAnalysis.StartViewshedAnalyse(fde_point1, fde_point2, double.Parse(this.numHorizontalAngle.Value.ToString()));
                    axRenderControl1.HighlightHelper.VisibleMask = 0;
                    this.label7.Text = "分析结束";
                }
            }
            else if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectMove))
            {
                this.endX.Text = IntersectPoint.X.ToString();
                this.endY.Text = IntersectPoint.Y.ToString();
                this.endZ.Text = IntersectPoint.Z.ToString();

                fde_point1 = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPoint,
                                                       gviVertexAttribute.gviVertexAttributeZ) as IPoint;
                fde_point1.SetCoords(double.Parse(this.startX.Text), double.Parse(this.startY.Text), double.Parse(this.startZ.Text), 0, 0);
                fde_point2 = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPoint,
                                                       gviVertexAttribute.gviVertexAttributeZ) as IPoint;
                fde_point2.SetCoords(double.Parse(this.endX.Text), double.Parse(this.endY.Text), double.Parse(this.endZ.Text), 0, 0);
                axRenderControl1.HighlightHelper.SetSectorRegion(fde_point1, fde_point2, double.Parse(this.numHorizontalAngle.Value.ToString()));
            }
        }
Beispiel #26
0
        private void AxRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (PickResult == null)
            {
                return;
            }

            IRenderPipeLinePickResult pr = PickResult as IRenderPipeLinePickResult;

            if (pr == null)
            {
                return;
            }

            GetParam();
            IRenderPipeLine rpl = pr.RenderPipeLine;

            rpl.Color = System.Drawing.Color.Yellow;
            rpl.Play(playMode, duration, needLoop);
            currentPLs.Add(rpl);
        }
Beispiel #27
0
 void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
 {
     if (PickResult == null)
     {
         return;
     }
     this.axRenderControl1.FeatureManager.UnhighlightAll();
     if (PickResult.Type == gviObjectType.gviObjectTerrainImageLabel)
     {
         ITerrainImageLabelPickResult pr = PickResult as ITerrainImageLabelPickResult;
         pr.TerrainImageLabel.Highlight(Color.Red);
     }
 }
Beispiel #28
0
        private void AxRenderControl1_RcMouseDragSelect(IPickResultCollection PickResults, gviModKeyMask Mask)
        {
            if (PickResults == null)
            {
                return;
            }

            for (int i = 0; i < PickResults.Count; i++)
            {
                IRenderPipeLinePickResult pr = PickResults.Get(i) as IRenderPipeLinePickResult;
                if (pr == null)
                {
                    continue;
                }

                GetParam();
                IRenderPipeLine rpl = pr.RenderPipeLine;
                rpl.Color = System.Drawing.Color.Yellow;
                rpl.Play(playMode, duration, needLoop);
                currentPLs.Add(rpl);
            }
        }
Beispiel #29
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            IPickResult pr = PickResult;

            if (pr == null && CTRL && Mask == gviModKeyMask.gviModKeyCtrl)
            {
                return;
            }

            if (!CTRL || (CTRL && Mask != gviModKeyMask.gviModKeyCtrl))   //ctrl键
            {
                this.axRenderControl1.FeatureManager.UnhighlightAll();
                featureList.Clear();
            }

            if (EventSender == gviMouseSelectMode.gviMouseSelectClick)
            {
                if (PickResult != null)
                {
                    if (pr.Type == gviObjectType.gviObjectFeatureLayer)
                    {
                        IFeatureLayerPickResult flpr = pr as IFeatureLayerPickResult;
                        int           fid            = flpr.FeatureId;
                        IFeatureLayer fl             = flpr.FeatureLayer;
                        foreach (IFeatureClass fc in fcMap.Keys)
                        {
                            if (fc.Guid.Equals(fl.FeatureClassId))
                            {
                                this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Yellow);
                                FCAndFeature item = new FCAndFeature();
                                item.fc  = fc;
                                item.fid = fid;
                                featureList.Add(item);
                            }
                        }
                    }
                }
            }
        }
Beispiel #30
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            IPickResult pr = PickResult;

            if (pr == null)
            {
                return;
            }

            if (EventSender == gviMouseSelectMode.gviMouseSelectClick)
            {
                if (pr.Type == gviObjectType.gviObjectFeatureLayer)
                {
                    // 高亮Polygon
                    this.axRenderControl1.FeatureManager.UnhighlightAll();
                    IFeatureLayerPickResult flpr = pr as IFeatureLayerPickResult;
                    fid = flpr.FeatureId;
                    IFeatureLayer fl = flpr.FeatureLayer;
                    foreach (IFeatureClass fc in fcMap.Keys)
                    {
                        if (fc.Guid.Equals(fl.FeatureClassId))
                        {
                            IRowBuffer           fdeRow = fc.GetRow(fid);
                            IFieldInfoCollection col    = fdeRow.Fields;
                            for (int i = 0; i < col.Count; ++i)
                            {
                                IFieldInfo info = col.Get(i);
                                if (info.GeometryDef != null &&
                                    info.GeometryDef.GeometryColumnType == gviGeometryColumnType.gviGeometryColumnPolyline)
                                {
                                    int nPos = fdeRow.FieldIndex(info.Name);
                                    polyline = fdeRow.GetValue(nPos) as IPolyline;
                                    this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Yellow);
                                    //获取路宽
                                    nPos = fdeRow.FieldIndex("WIDTH");
                                    //width = (double)fdeRow.GetValue(nPos);
                                    width = 10;
                                }
                            }
                        } // end " if (fc.Guid.Equals(fl.FeatureClassId))"
                    }     // end "foreach (IFeatureClass fc in fcMap.Keys)"
                }
            }
        }