Пример #1
0
        private void timer1_Tick(object sender, System.EventArgs e)
        {
            // 删除原有指针
            if (render_ZhiZhen != null)
            {
                this.axRenderControl1.ObjectManager.DeleteObject(render_ZhiZhen.Guid);
                render_ZhiZhen = null;
            }
            // 加载指针
            string modelNameZhiZhen = (strMediaPath + @"\osg\Dashboard\zhizhen.osg");

            fdepoint_ZhiZhen           = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);
            fdepoint_ZhiZhen.ModelName = modelNameZhiZhen;
            fdepoint_ZhiZhen.SetCoords(biaoPanX, biaoPanY, biaoPanZ + 0.01, 0, 0);
            fdepoint_ZhiZhen.SpatialCRS = dataset.SpatialReference;
            zhiZhenValue = random1.Next(0, 16);
            fdepoint_ZhiZhen.SelfRotate(0, 0, 1, -((zhiZhenValue % 16) * 3 * 3.14 / 32));
            render_ZhiZhen = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(fdepoint_ZhiZhen, null, rootId);
            label.Text     = "当前的压力值是:" + zhiZhenValue.ToString();

            // 刷新弹出窗口
            if (clickFlag == 1)
            {
                if (dxform.IsDisposed)
                {
                    return;
                }
                else
                {
                    dxform.arcScaleComponent1.Value = zhiZhenValue;
                    dxform.Refresh();
                }
            }
        }
Пример #2
0
        private void btnCreateModelPoint_Click(object sender, EventArgs e)
        {
            _geoEditor.FinishEdit();   //用于当拾取到基准面时,或者没有正常右键结束连续调用Start时

            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(0, 0, 0, 0, 0);
            fde_modelpoint.ModelName = tmpOsgPath;
            //****获取包围盒
            IResourceFactory resfac = new ResourceFactory();
            IPropertySet     images = new PropertySet();
            IModel           model  = null;
            IMatrix          matrix = null;

            resfac.CreateModelAndImageFromFile(tmpOsgPath, out images, out model, out matrix);
            fde_modelpoint.ModelEnvelope = model.Envelope;
            //*************
            rmodelpoint = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(fde_modelpoint, null, rootId);

            resultCode = _geoEditor.StartEditRenderGeometry(rmodelpoint, gviGeoEditType.gviGeoEditCreator);
            if (!resultCode)
            {
                MessageBox.Show(this.axRenderControl1.GetLastError().ToString());
            }

            oldfdeGeometry = fde_modelpoint;
        }
Пример #3
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;
                    }
                }
            }
        }
Пример #4
0
 private void LoadCar(IDynamicObject dynamicObject)
 {
     if (renderModelPoint == null)
     {
         // 构造ModelPoint
         mp = geoFac.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
         string modelName = (strMediaPath + @"\osg\Vehicles\Car\TCJ006.osg");
         mp.ModelName  = modelName;
         mp.SpatialCRS = dataset_Road.SpatialReference;
         // 设置位置
         IMatrix matrix = new Matrix();
         matrix.MakeIdentity();
         IPoint startPoint = null;
         double speed      = 0.0;
         dynamicObject.GetWaypoint2(0, out startPoint, out speed);
         matrix.SetTranslate(startPoint.Position);
         mp.FromMatrix(matrix);
         mp.SelfScale(0.05, 0.05, 0.05);
         // 创建骨骼动画
         renderModelPoint = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, null, rootId);
         renderModelPoint.MaxVisibleDistance = 10000;
         renderModelPoint.ViewingDistance    = 200;
         // 绑定到运动路径
         IMotionable m = renderModelPoint as IMotionable;
         pos.Set(0, 0, 0);
         m.Bind2(dynamicObject, pos, 90, 0, 0);
     }
 }
Пример #5
0
        private void btnSplitModelPoint_Click(object sender, EventArgs e)
        {
            cbShowSrcModelPoint.Checked = false;

            if (_multiPolygon.GeometryCount == 0)
            {
                _multiPolygon.AddGeometry(fde_polygon);
            }

            _gc.SplitModelPointByPolygon2D(_multiPolygon, ModelSrc, ModelPointSrc, out modelInterior, out mpInterior, out modelExterior, out mpExterior);

            if (modelInterior != null && mpInterior != null)
            {
                this.axRenderControl1.ObjectManager.AddModel(mpInterior.ModelName, modelInterior);
                rmpInterior = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mpInterior, null, rootId);
                guidToDelList.Add(rmpInterior.Guid);
                cbHideInteriorModelPoint.Enabled = true;
                btnDelInteriorModelPoint.Enabled = true;
            }

            if (modelExterior != null && mpExterior != null)
            {
                this.axRenderControl1.ObjectManager.AddModel(mpExterior.ModelName, modelExterior);
                rmpExterior = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mpExterior, null, rootId);
                guidToDelList.Add(rmpExterior.Guid);
                cbHideExteriorModelPoint.Enabled = true;
                btnDelExteriorModelPoint.Enabled = true;
            }
        }
        private void CreateRenderModelPoint(IPoint point)
        {
            // 创建模型
            if (gfactory == null)
            {
                gfactory = new GeometryFactory();
            }

            string tmpOSGPath = Environment.CurrentDirectory + @"\TrashCar\GLJCHE01.osg";

            //string tmpOSGPath = Environment.CurrentDirectory + @"\Apartment\Apartment.osg";
            fde_modelpoint            = gfactory.CreateGeometry(i3dGeometryType.i3dGeometryModelPoint, i3dVertexAttribute.i3dVertexAttributeZ) as IModelPoint;
            fde_modelpoint.SpatialCRS = crs;
            fde_modelpoint.SetCoords(point.X, point.Y, point.Z, 0, 0);
            fde_modelpoint.ModelName = tmpOSGPath;

            rmodelpoint = _axRenderControl.ObjectManager.CreateRenderModelPoint(fde_modelpoint, null);
            rmodelpoint.MaxVisibleDistance = double.MaxValue;
            rmodelpoint.MinVisiblePixels   = 0;
            IEulerAngle angle = new EulerAngle();

            angle.Set(0, -20, 0);

            _axRenderControl.Camera.LookAt2(point, 100, angle);
        }
Пример #7
0
 public override void Close()
 {
     if (this._rmp != null)
     {
         this._3DControl.ObjectManager.DeleteObject(this._rmp.Guid);
         this._rmp = null;
     }
 }
Пример #8
0
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            DevExpress.XtraEditors.Controls.EditorButton btn = e.Button;
            switch (btn.Caption)
            {
            case "定位":
                DF3DApplication app = DF3DApplication.Application;
                if (app == null || app.Current3DMapControl == null)
                {
                    return;
                }
                int focusedRowHandle = this.gridView1.FocusedRowHandle;
                if (focusedRowHandle == -1)
                {
                    return;
                }
                DataRow dr = this.gridView1.GetDataRow(focusedRowHandle);
                if (dr["geo"] != null && dr["Name"] != null && dr["fcName"] != null && dr["fc"] != null)
                {
                    ISurfaceSymbol ss = new SurfaceSymbolClass();
                    ss.Color = 0xcc00ff00;
                    ICurveSymbol cs = new CurveSymbolClass();
                    cs.Color          = 0xff00ff00;
                    cs.Width          = -5;
                    ss.BoundarySymbol = cs;
                    ISimplePointSymbol ps = new SimplePointSymbol();
                    ps.Size      = SystemInfo.Instance.SymbolSize;
                    ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16);
                    IGeometry objGeo = dr["geo"] as IGeometry;
                    if (objGeo.GeometryType == gviGeometryType.gviGeometryModelPoint)
                    {
                        IModelPoint       mp  = objGeo as IModelPoint;
                        IModelPointSymbol mps = new ModelPointSymbol();
                        mps.SetResourceDataSet((dr["fc"] as IFeatureClass).FeatureDataSet);
                        mps.Color = 0xffffff00;
                        IRenderModelPoint rMP = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(mp, mps, app.Current3DMapControl.ProjectTree.RootID);
                        rMP.Glow(8000);
                        app.Current3DMapControl.ObjectManager.DelayDelete(rMP.Guid, 8000);

                        IGeometryFactory geoFact = new GeometryFactory();
                        IPoint           pt      = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                        pt.X = mp.X; pt.Y = mp.Y; pt.Z = mp.Z;

                        ITableLabel tl = DrawTool.CreateTableLabel1(1);
                        tl.TitleText = dr["fcName"].ToString();
                        tl.SetRecord(0, 0, dr["Name"].ToString());
                        tl.Position = pt;

                        this._listRender.Add(tl.Guid);

                        app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo);
                    }
                }
                break;
            }
        }
Пример #9
0
        /// <summary>
        /// 加载模型
        /// </summary>
        private void LoadModel()
        {
            string           modelName  = (strMediaPath + @"\osg\Vehicles\XiaoFangChe\xiaoFangChe3.OSG");
            IGeometryFactory geoFactory = new GeometryFactory();
            IModelPoint      modelPoint = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);

            modelPoint.ModelName = modelName;
            modelPoint.SetCoords(firstX, firstY, firstZ, 0, 0);
            modelPoint.SpatialCRS        = datasetCRS;
            renderModelPoint             = CommonUnity.RenderHelper.ObjectManager.CreateRenderModelPoint(modelPoint, null, rootId);
            renderModelPoint.VisibleMask = gviViewportMask.gviViewAllNormalView;
        }
Пример #10
0
        private void LoadData()
        {
            if (geoFactory == null)
            {
                geoFactory = new GeometryFactory();
            }

            string      modelName  = (strMediaPath + @"\osg\Schemes\scheme-01.osg");
            IModelPoint modelPoint = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);

            modelPoint.ModelName = modelName;
            modelPoint.SetCoords(dx, dy, dz + 15, 0, 0);
            modelPoint.SpatialCRS         = _datasetCRS;
            renderModelPoint1             = axRenderControl1.ObjectManager.CreateRenderModelPoint(modelPoint, null, rootId);
            renderModelPoint1.VisibleMask = gviViewportMask.gviView0;
            IVector3 position = new Vector3();

            position.Set(dx, dy, dz);
            IPoint point = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ);

            point.SpatialCRS = _datasetCRS;
            point.SetCoords(position.X, position.Y, position.Z, 0, 0);
            IEulerAngle angle = new EulerAngle();

            angle.Set(0, -20, 0);
            axRenderControl1.Camera.LookAt2(point, 300, angle);

            modelName            = (strMediaPath + @"\osg\Schemes\scheme-02.osg");
            modelPoint           = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);
            modelPoint.ModelName = modelName;
            modelPoint.SetCoords(dx, dy, dz - 15, 0, 0);
            modelPoint.SpatialCRS         = _datasetCRS;
            renderModelPoint2             = axRenderControl1.ObjectManager.CreateRenderModelPoint(modelPoint, null, rootId);
            renderModelPoint2.VisibleMask = gviViewportMask.gviView1;


            modelName            = (strMediaPath + @"\osg\Schemes\scheme-03.osg");
            modelPoint           = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);
            modelPoint.ModelName = modelName;
            modelPoint.SetCoords(dx, dy, dz - 10, 0, 0);
            modelPoint.SpatialCRS         = _datasetCRS;
            renderModelPoint3             = axRenderControl1.ObjectManager.CreateRenderModelPoint(modelPoint, null, rootId);
            renderModelPoint3.VisibleMask = gviViewportMask.gviView2;


            modelName            = (strMediaPath + @"\osg\Schemes\scheme-04.osg");
            modelPoint           = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);
            modelPoint.ModelName = modelName;
            modelPoint.SetCoords(dx, dy, dz - 13, 0, 0);
            modelPoint.SpatialCRS         = _datasetCRS;
            renderModelPoint4             = axRenderControl1.ObjectManager.CreateRenderModelPoint(modelPoint, null, rootId);
            renderModelPoint4.VisibleMask = gviViewportMask.gviView3;
        }
Пример #11
0
        private void clear()
        {
            if (renderLine != null)
            {
                this.axRenderControl1.ObjectManager.DeleteObject(renderLine.Guid);
                renderLine = null;
            }
            if (multiRenderLine != null)
            {
                this.axRenderControl1.ObjectManager.DeleteObject(multiRenderLine.Guid);
                multiRenderLine = null;
            }
            if (tour != null)
            {
                this.axRenderControl1.ObjectManager.DeleteObject(tour.Guid);
                tour = null;
            }
            if (renderModelPoint != null)
            {
                this.axRenderControl1.ObjectManager.DeleteObject(renderModelPoint.Guid);
                renderModelPoint = null;
            }
            if (skinMesh != null)
            {
                this.axRenderControl1.ObjectManager.DeleteObject(skinMesh.Guid);
                skinMesh = null;
            }

            if (renderLineArray.Count != 0)
            {
                foreach (IRenderPolyline line in renderLineArray)
                {
                    this.axRenderControl1.ObjectManager.DeleteObject(line.Guid);
                }
                renderLineArray.Clear();
            }
            if (multiRenderLineArray.Count != 0)
            {
                foreach (IRenderMultiPolyline line in multiRenderLineArray)
                {
                    this.axRenderControl1.ObjectManager.DeleteObject(line.Guid);
                }
                multiRenderLineArray.Clear();
            }
            if (tmpRenderLineArray.Count != 0)
            {
                foreach (IRenderPolyline line in tmpRenderLineArray)
                {
                    this.axRenderControl1.ObjectManager.DeleteObject(line.Guid);
                }
                tmpRenderLineArray.Clear();
            }
        }
Пример #12
0
 public void Set3DModelFilePath(string filePath)
 {
     this._filePath = filePath;
     if (System.IO.File.Exists(this._filePath))
     {
         IModelPoint mp = this._geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, Gvitech.CityMaker.FdeGeometry.gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
         mp.SetCoords(0, 0, 0, 0, 0);
         mp.ModelName          = this._filePath;
         this._rmp             = this._3DControl.ObjectManager.CreateRenderModelPoint(mp, null, this._rootID);
         this._rmp.VisibleMask = gviViewportMask.gviViewAllNormalView;
         this._3DControl.ObjectEditor.StartEditRenderGeometry(this._rmp, gviGeoEditType.gviGeoEditCreator);
     }
 }
Пример #13
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            IPickResult pr = PickResult;
            IRenderModelPointPickResult renderpr = pr as IRenderModelPointPickResult;

            if (renderpr != null)
            {
                IRenderModelPoint mp = renderpr.ModelPoint;
                if (mp.ModelName.Contains("yibiaopan.osg") || mp.ModelName.Contains("zhizhen.osg"))
                {
                    dxform = new DXForm();
                    dxform.Show();
                    clickFlag = 1;
                }
            }
        }
Пример #14
0
 public static void TestDrawModel(IModelPoint mp, IModel model, List <string> filesPath)
 {
     if ((mp != null) && (model != null))
     {
         string str      = Application.StartupPath + @"\..\temp";
         string str2     = Path.Combine(str, "osg");
         string filePath = string.Format(@"{0}\{1}.osg", str2, mp.ModelName);
         if (!Directory.Exists(str))
         {
             Directory.CreateDirectory(str);
         }
         if (!Directory.Exists(str2))
         {
             Directory.CreateDirectory(str2);
         }
         IPropertySet images = null;
         IImage       image  = null;
         string       key    = string.Empty;
         images = new PropertySetClass();
         if (filesPath != null)
         {
             foreach (string str5 in filesPath)
             {
                 if (File.Exists(str5) || Directory.Exists(str5))
                 {
                     key   = Path.GetFileNameWithoutExtension(str5);
                     image = resFactory.CreateImageFromFile(str5);
                     images.SetProperty(key, image);
                 }
             }
         }
         model.WriteFile(filePath, images);
         IModelPointSymbol symbol = (ModelPointSymbol)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("6BCF8C9B-E506-43AE-AD6E-44A41D748431")));
         symbol.Color     = 0xaaaaaaaa;
         mp.ModelName     = filePath;
         mp.ModelEnvelope = model.Envelope;
         IRenderModelPoint item = Ocx.ObjectManager.CreateRenderModelPoint(mp, symbol, Ocx.ProjectTree.RootID);
         item.MaxVisibleDistance = 500000.0;
         tmpList.Add(item);
         Ocx.Camera.LookAtEnvelope(item.Envelope);
     }
 }
Пример #15
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;
                }
            }
        }
Пример #16
0
        /// <summary>
        /// 单击表格记录进行定位
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];

            if (row != null)
            {
                string            fid    = row.Cells["FID"].Value.ToString();
                IFeatureClass     fc     = row.Cells["FID"].Tag as IFeatureClass;
                IModelPoint       mp     = rowMap[fid].Modelpoint;
                IModelPointSymbol symbol = new ModelPointSymbol();
                symbol.SetResourceDataSet(fc.FeatureDataSet);
                IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, symbol, rootId);
                if (rmp != null)
                {
                    //定位
                    this.axRenderControl1.Camera.FlyToObject(rmp.Guid, gviActionCode.gviActionJump);
                    //闪烁
                    rmp.Glow(2000);
                    this.axRenderControl1.ObjectManager.DelayDelete(rmp.Guid, 2000);
                }
            }
        }
Пример #17
0
        private void toolStripButton_CreateRenderModelPoint_Click(object sender, EventArgs e)
        {
            IModel model = CreateModel(1, 1, 1, 0xffffffff);

            RenderControl.ObjectManager.AddModel("model", model);
            t.Stop();
            foreach (IRenderModelPoint m in list)
            {
                RenderControl.ObjectManager.DeleteObject(m.Guid);
            }
            list.Clear();
            MatrixList.Clear();
            int              x = Convert.ToInt32(toolStripTextBox_x.Text.Trim());
            int              y = Convert.ToInt32(toolStripTextBox_y.Text.Trim());
            int              n = Convert.ToInt32(toolStripTextBox_n.Text.Trim());
            double           x1, y1;
            IGeometryFactory gf = new GeometryFactory();

            for (int j = 0; j < x; j++)
            {
                for (int k = 0; k < y; k++)
                {
                    IModelPoint mp = gf.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;

                    x1               = n * j;
                    y1               = n * k;
                    mp.X             = x1;
                    mp.Y             = y1;
                    mp.Z             = 0;
                    mp.ModelName     = "model";
                    mp.ModelEnvelope = model.Envelope;
                    IRenderModelPoint rmp = RenderControl.ObjectManager.CreateRenderModelPoint(mp, null, RenderControl.ProjectTree.RootID);
                    rmp.MaxVisibleDistance = 99999999999999;
                    rmp.MinVisiblePixels   = 0;
                    list.Add(rmp);
                    MatrixList.Add(mp.AsMatrix());
                }
            }
        }
Пример #18
0
        private void btnCutModelPoint_Click(object sender, EventArgs e)
        {
            if (_multiPolygon.GeometryCount == 0)
            {
                _multiPolygon.AddGeometry(fde_polygon);
            }

            if (cbCutWithZ.Checked)
            {
                _gc.CutModelPointByPolygon2DWithZ(_multiPolygon, ModelSrc, ModelPointSrc, double.Parse(numMinZ.Value.ToString()), double.Parse(numMaxZ.Value.ToString()), out model, out mp);
            }
            else
            {
                _gc.CutModelPointByPolygon2D(_multiPolygon, ModelSrc, ModelPointSrc, out model, out mp);
            }
            cbShowSrcModelPoint.Checked = false;

            this.axRenderControl1.ObjectManager.AddModel(mp.ModelName, model);
            rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, null, rootId);
            guidToDelList.Add(rmp.Guid);

            cbHideModelPoint.Enabled = true;
            btnDelModelPoint.Enabled = true;
        }
Пример #19
0
        void axRenderControl1_RcMouseClickSelect_Edit(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            this.axRenderControl1.FeatureManager.UnhighlightAll();

            // 置空
            currentGeometry = null;
            _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;

                case gviObjectType.gviObjectRenderModelPoint:
                {
                    IRenderModelPointPickResult flpr = PickResult as IRenderModelPointPickResult;
                    rmodelpoint     = flpr.ModelPoint;
                    currentGeometry = rmodelpoint;
                    oldfdeGeometry  = rmodelpoint.GetFdeGeometry();
                    EditGeometry();
                }
                break;

                case gviObjectType.gviObjectRenderPoint:
                {
                    IRenderPointPickResult flpr = PickResult as IRenderPointPickResult;
                    rpoint          = flpr.Point;
                    currentGeometry = rpoint;
                    EditGeometry();
                }
                break;

                case gviObjectType.gviObjectRenderPolyline:
                {
                    IRenderPolylinePickResult flpr = PickResult as IRenderPolylinePickResult;
                    rpolyline       = flpr.Polyline;
                    currentGeometry = rpolyline;
                    EditGeometry();
                }
                break;

                case gviObjectType.gviObjectRenderPolygon:
                {
                    IRenderPolygonPickResult flpr = PickResult as IRenderPolygonPickResult;
                    rpolygon        = flpr.Polygon;
                    currentGeometry = rpolygon;
                    EditGeometry();
                }
                break;
                }
            }
        }
Пример #20
0
        /// <summary>
        /// 定位和闪烁
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int           featureId       = int.Parse((sender as DataGridView).CurrentRow.Cells[0].Value.ToString());
            IFeatureClass curFeatureClass = null;

            switch (tabControl1.SelectedTab.Name)
            {
            case "tabPage0Road":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Road")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;

            case "tabPage1Building":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Building")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;

            case "tabPage2Trees":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Trees")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;

            case "tabPage3Facility":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Facility")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;

            case "tabPage4LandScape":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Landscape")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;
            }

            string       filterString = string.Format("oid={0}", featureId);
            IQueryFilter filter       = new QueryFilter();

            filter.WhereClause = filterString;
            IFdeCursor cursor = null;

            try
            {
                cursor = curFeatureClass.Search(filter, true);
                if (cursor != null)
                {
                    IRowBuffer fdeRow = null;
                    if ((fdeRow = cursor.NextRow()) != null)
                    {
                        int nPos = fdeRow.FieldIndex("Geometry");
                        if (nPos != -1 && !fdeRow.IsNull(nPos))
                        {
                            IModelPoint       mp     = fdeRow.GetValue(nPos) as IModelPoint; // 从库中读取值
                            IModelPointSymbol symbol = new ModelPointSymbol();
                            symbol.SetResourceDataSet(curFeatureClass.FeatureDataSet);
                            IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, symbol, rootId);
                            if (rmp != null)
                            {
                                // 定位
                                this.axRenderControl1.Camera.FlyToObject(rmp.Guid, gviActionCode.gviActionJump);
                                // 闪烁
                                rmp.Glow(2000);
                                this.axRenderControl1.ObjectManager.DelayDelete(rmp.Guid, 2000);
                            }
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
            }
        }
Пример #21
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);
                }
            }
        }
Пример #22
0
        public bool ShowFlowDirection(int flowDir, out IRenderModelPoint rpt)
        {
            rpt = null;
            if (base._rowInfo == null)
            {
                return(false);
            }

            string str = Application.StartupPath + @"\..\Resource\Images\FlowDirection";

            if (!Directory.Exists(str))
            {
                return(false);
            }
            IImage _imgFlowImg = DrawGeometry.resFactory.CreateImageFromFile(str);

            _imgFlowImg.FrameInterval = 50;

            IPolyline        path        = null;
            IPipeSection     pipeSection = null;
            string           name        = "FlowDirection";
            IDrawDynamicFlow flow        = null;
            IModelPoint      mp          = null;

            try
            {
                IModel    model;
                IModel    model2;
                IPoint    pointValue = null;
                IPolyline polyline2  = null;
                polyline2 = base._geoGroup[1] as IPolyline;
                if ((polyline2 == null) || (polyline2.PointCount < 2))
                {
                    return(false);
                }
                path = polyline2.Clone() as IPolyline;
                for (int i = 0; i < path.PointCount; i++)
                {
                    pointValue = path.GetPoint(i);
                    if (pointValue != null)
                    {
                        pointValue.Z += this.OffsetZ;
                        path.UpdatePoint(i, pointValue);
                    }
                }

                pipeSection = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, VerticalPos.Center, 0.02, 0);

                flow = ParamModelFactory.Instance.CreateGeometryDraw(ModelType.DynamicFlow, Guid.NewGuid().ToString()) as IDrawDynamicFlow;
                flow.SetParameter(pipeSection, path, flowDir);
                flow.SetTextureRender(new string[] { name });
                if (!flow.Draw(out mp, out model, out model2))
                {
                    return(false);
                }

                #region 需要runtime授权
                IFeatureDataSet  iFeatureDataSet = DF3DPipeCreateApp.App.TempLib.OpenFeatureDataset("FeatureDataSet");
                IResourceManager manager         = iFeatureDataSet as IResourceManager;
                if (!manager.ModelExist(mp.ModelName))
                {
                    manager.AddModel(mp.ModelName, model, null);
                }
                if (!manager.ImageExist(name))
                {
                    manager.AddImage(name, _imgFlowImg);
                }
                #endregion

                IModelPointSymbol symbol = new ModelPointSymbolClass();
                symbol.SetResourceDataSet(iFeatureDataSet);
                symbol.Color       = uint.MaxValue;
                symbol.EnableColor = true;
                mp.ModelEnvelope   = model.Envelope;
                rpt = DrawGeometry.Ocx.ObjectManager.CreateRenderModelPoint(mp, symbol, DrawGeometry.Ocx.ProjectTree.RootID);

                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Пример #23
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;

            this.axRenderControl1.Camera.NearClipPlane = 0.1f;
            this.axRenderControl1.Camera.AutoClipPlane = false;

            // 设置天空盒

            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;
            }

            // 加载FDB场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                dataset = ds.OpenFeatureDataset(setnames[0]);
                string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = 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.Add(fc, geoNames);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

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

                    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.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;
                }
            }

            geoFactory               = new GeometryFactory();
            positionPoint            = geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
            positionPoint.SpatialCRS = dataset.SpatialReference;

            // 加载仪表盘
            string modelNameBiaoPan = (strMediaPath + @"\osg\Dashboard\yibiaopan.osg");

            fdepoint_biaopan           = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);
            fdepoint_biaopan.ModelName = modelNameBiaoPan;
            fdepoint_biaopan.SetCoords(biaoPanX, biaoPanY, biaoPanZ, 0, 0);
            fdepoint_biaopan.SpatialCRS = dataset.SpatialReference;
            render_biaopan = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(fdepoint_biaopan, null, rootId);
            // 加载指针
            string modelNameZhiZhen = (strMediaPath + @"\osg\Dashboard\zhizhen.osg");

            fdepoint_ZhiZhen           = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);
            fdepoint_ZhiZhen.ModelName = modelNameZhiZhen;
            fdepoint_ZhiZhen.SetCoords(biaoPanX, biaoPanY, biaoPanZ + 0.01, 0, 0);
            fdepoint_ZhiZhen.SpatialCRS = dataset.SpatialReference;
            render_ZhiZhen = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(fdepoint_ZhiZhen, null, rootId);
            // 加载文字标签
            IVector3 positionLabel = new Vector3();

            positionLabel.Set(biaoPanX, biaoPanY, biaoPanZ + 0.1);
            positionPoint.Position = positionLabel;
            label          = this.axRenderControl1.ObjectManager.CreateLabel(rootId);
            label.Text     = "当前的压力值是:" + zhiZhenValue.ToString();
            label.Position = positionPoint;
            ITextSymbol   textSymbol    = new TextSymbol();
            TextAttribute textAttribute = new TextAttribute();

            textAttribute.TextColor      = System.Drawing.Color.Black;
            textAttribute.TextSize       = 30;
            textAttribute.Font           = "宋体";
            textSymbol.TextAttribute     = textAttribute;
            textSymbol.MaxVisualDistance = 3;
            label.TextSymbol             = textSymbol;
            // 飞入表盘
            IEulerAngle angle_camera = new EulerAngle();

            angle_camera.Set(0, -45, 0);
            this.axRenderControl1.Camera.LookAt2(positionPoint, 2, angle_camera);

            // 注册鼠标单击事件
            this.axRenderControl1.RcMouseClickSelect += new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);


            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "DynamicBoard.html";
            }
        }
Пример #24
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.Red);

                        //////////////////////////////////////////////////////////////////////////
                        //
                        //  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
                        IPolygon polygonGC = null;
                        if (rowGC != null)
                        {
                            nPose = rowGC.FieldIndex("Geometry");
                            IGeometry geo = rowGC.GetValue(nPose) as IGeometry;
                            if (geo.GeometryType == gviGeometryType.gviGeometryPolygon)
                            {
                                polygonGC = geo as IPolygon;
                            }
                        }

                        this.Text = "拾取成功";

                        param = new PropertySet();

                        //第一个Tab页:PolygonToBuilding
                        if (this.tabControl1.SelectedIndex == 0)
                        {
                            // 1.调接口构造模型
                            double floorNum = double.Parse(this.numFloorNumber.Value.ToString());
                            param.SetProperty("FloorNumber", floorNum);
                            double floorHgt = double.Parse(this.numFloorHeight.Value.ToString());
                            param.SetProperty("FloorHeight", floorHgt);
                            double interiorOffset = double.Parse(this.numInteriorOffset.Value.ToString());
                            param.SetProperty("InteriorOffset", interiorOffset);
                            double exteriorOffset = double.Parse(this.numExteriorOffset.Value.ToString());
                            param.SetProperty("ExteriorOffset", exteriorOffset);
                            double heightOffset = double.Parse(this.numHeightOffset.Value.ToString());
                            param.SetProperty("HeightOffset", heightOffset);

                            string imgPath = (strMediaPath + @"\dds");
                            string roof    = this.comboBoxRoofTexture.Text;
                            string facade  = this.comboBoxFacadeTexture.Text;
                            param.SetProperty("FacadeTexture", roof);
                            param.SetProperty("RoofTexture", facade);

                            IModelPoint mp    = null;
                            IModel      model = null;
                            if (!paraModel.PolygonToBuilding(polygonGC, param, out mp, out model))
                            {
                                MessageBox.Show("拉体块出错!");
                                return;
                            }

                            //2、将模型及贴图写入osg文件
                            string           modelName  = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".osg");//输出osg文件路径
                            IResourceFactory resFactory = new ResourceFactory();
                            string[]         imageNames = model.GetImageNames();
                            IPropertySet     ps         = new PropertySet();
                            for (int i = 0; i < imageNames.Length; i++)
                            {
                                string imgName = imageNames[i];
                                IImage img     = resFactory.CreateImageFromFile(string.Format(@"{0}\{1}", imgPath + @"\facade", imgName));
                                if (img == null)
                                {
                                    img = resFactory.CreateImageFromFile(string.Format(@"{0}\{1}", imgPath + @"\roof", imgName));
                                }
                                ps.SetProperty(imgName, img);
                            }
                            model.WriteFile(modelName, ps);

                            //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);
                        }
                        //第二个tab页:ExtrudePolygonToTriMesh
                        else
                        {
                            // 1.调接口构造模型
                            double floorNum = double.Parse(this.numFloorNumber.Value.ToString());
                            param.SetProperty("FloorNumber", floorNum);
                            double floorHgt = double.Parse(this.numFloorHeight.Value.ToString());
                            param.SetProperty("FloorHeight", floorHgt);
                            double interiorOffset = double.Parse(this.numInteriorOffset.Value.ToString());
                            param.SetProperty("InteriorOffset", interiorOffset);
                            double exteriorOffset = double.Parse(this.numExteriorOffset.Value.ToString());
                            param.SetProperty("ExteriorOffset", exteriorOffset);
                            double heightOffset = double.Parse(this.numHeightOffset.Value.ToString());
                            param.SetProperty("HeightOffset", heightOffset);

                            double buildingHeight = double.Parse(this.numBuildingHeight.Value.ToString());
                            param.SetProperty("BuildingHeight", buildingHeight);
                            double buildingXScale = double.Parse(this.numBuildingXScale.Value.ToString());
                            param.SetProperty("BuildingXScale", buildingXScale);
                            double buildingYScale = double.Parse(this.numBuildingYScale.Value.ToString());
                            param.SetProperty("BuildingYScale", buildingYScale);

                            string imgPath = (strMediaPath + @"\dds");
                            string roof    = this.comboBoxRoofTexture.Text;
                            string facade  = this.comboBoxFacadeTexture.Text;
                            param.SetProperty("FacadeTexture", roof);
                            param.SetProperty("RoofTexture", facade);

                            IModelPoint mp    = null;
                            IModel      model = null;
                            if (!paraModel.PolygonToBuilding(polygonGC, param, out mp, out model))
                            {
                                MessageBox.Show("拉体块出错!");
                                return;
                            }

                            //2、将模型及贴图写入osg文件
                            string           modelName  = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".osg");//输出osg文件路径
                            IResourceFactory resFactory = new ResourceFactory();
                            string[]         imageNames = model.GetImageNames();
                            IPropertySet     ps         = new PropertySet();
                            for (int i = 0; i < imageNames.Length; i++)
                            {
                                string imgName = imageNames[i];
                                IImage img     = resFactory.CreateImageFromFile(string.Format(@"{0}\{1}", imgPath + @"\facade", imgName));
                                if (img == null)
                                {
                                    img = resFactory.CreateImageFromFile(string.Format(@"{0}\{1}", imgPath + @"\roof", imgName));
                                }
                                ps.SetProperty(imgName, img);
                            }
                            model.WriteFile(modelName, ps);

                            //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);
                }
            }
        }
Пример #25
0
        private void ShowFlowDirect(IFeatureLayerPickResult pr)
        {
            if (pr == null)
            {
                return;
            }
            IRowBuffer row    = null;
            IFdeCursor cursor = null;

            try
            {
                int fid = pr.FeatureId;
                DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(pr.FeatureLayer.FeatureClassId.ToString());
                if (dffc == null)
                {
                    return;
                }
                IFeatureClass fc  = dffc.GetFeatureClass();
                FacilityClass fac = dffc.GetFacilityClass();
                if (fc == null || fac == null || fac.Name != "PipeLine")
                {
                    return;
                }
                DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("FlowDirect");
                if (fi == null)
                {
                    return;
                }
                IFieldInfoCollection fiCol = fc.GetFields();
                int index = fiCol.IndexOf(fi.Name);
                if (index == -1)
                {
                    return;
                }
                int indexShape = fiCol.IndexOf("Shape");

                IQueryFilter filter = new QueryFilter();
                filter.WhereClause = "oid=" + fid;
                cursor             = fc.Search(filter, false);
                row = cursor.NextRow();
                if (row == null)
                {
                    return;
                }

                IPolyline line = null;
                if (indexShape != -1 && !row.IsNull(indexShape))
                {
                    object obj = row.GetValue(indexShape);
                    if (obj != null && obj is IPolyline)
                    {
                        line = obj as IPolyline;
                    }
                }
                string flowDirectValue = "0";
                int    type            = 1;// 1表示具有流向字段;2表示从高到低
                if (!row.IsNull(index))
                {
                    flowDirectValue = row.GetValue(index).ToString();
                    if (flowDirectValue != "0" && flowDirectValue != "1")
                    {
                        flowDirectValue = "0";
                    }
                    type = 1;
                }
                else if (line != null)
                {
                    if (line.StartPoint.Z > line.EndPoint.Z)
                    {
                        flowDirectValue = "0";
                    }
                    else
                    {
                        flowDirectValue = "1";
                    }
                    type = 2;
                }
                if (line == null)
                {
                    return;
                }

                if (this._isAuth)
                {
                    #region 流向渲染1
                    FacClassReg reg = FacilityInfoService.GetFacClassRegByFeatureClassID(fc.Guid.ToString());
                    if (reg == null)
                    {
                        return;
                    }
                    TopoClass tc = FacilityInfoService.GetTopoClassByFacClassCode(reg.FacClassCode);
                    if (tc == null)
                    {
                        return;
                    }
                    FacStyleClass        style          = null;
                    List <FacStyleClass> facilityStyles = FacilityInfoService.GetFacStyleByFacClassCode(reg.FacClassCode);
                    if ((facilityStyles != null) && (facilityStyles.Count > 0))
                    {
                        style = facilityStyles[0];
                    }
                    PipeLineFac       plfac = new PipeLineFac(reg, style, row, tc);
                    IRenderModelPoint rmp   = null;
                    DrawGeometry.Ocx = DF3DApplication.Application.Current3DMapControl;
                    plfac.ShowFlowDirection(int.Parse(flowDirectValue), out rmp);
                    if (rmp != null)
                    {
                        this._listRender.Add(rmp.Guid);
                    }
                    #endregion
                }
                else
                {
                    #region 流向渲染2
                    IEulerAngle angle    = DF3DApplication.Application.Current3DMapControl.Camera.GetAimingAngles2(line.StartPoint, line.EndPoint);
                    double      dia      = 0.0;
                    string      diaField = fac.GetFieldInfoNameBySystemName("Diameter");
                    int         indexDia = fiCol.IndexOf(diaField);
                    if (indexDia != -1 && !row.IsNull(indexDia))
                    {
                        string diaStr    = row.GetValue(indexDia).ToString();
                        int    indexDia1 = diaStr.ToString().IndexOf('*');
                        if (indexDia1 != -1)
                        {
                            var dia1 = int.Parse(diaStr.ToString().Substring(0, indexDia1));
                            var dia2 = int.Parse(diaStr.ToString().Substring(indexDia1 + 1, diaStr.ToString().Length));
                            dia = ((dia1 > dia2) ? dia1 : dia2) * 0.001;
                        }
                        else
                        {
                            dia = int.Parse(diaStr) * 0.001;
                        }
                    }
                    List <IPoint> points = new List <IPoint>();
                    if (flowDirectValue == "0")
                    {
                        for (int i = 0; i < line.PointCount; i++)
                        {
                            IPoint pt = line.GetPoint(i);
                            pt.Z += dia / 2;
                            points.Add(pt);
                        }
                    }
                    else if (flowDirectValue == "1")
                    {
                        for (int i = line.PointCount - 1; i >= 0; i--)
                        {
                            IPoint pt = line.GetPoint(i);
                            pt.Z += dia / 2;
                            points.Add(pt);
                        }
                    }
                    for (int i = 0; i < points.Count - 1; i++)
                    {
                        IPoint pt1 = points[i];
                        var    pt2 = points[i + 1];

                        double delt = 0;
                        double _rate, _distance;
                        if (!(Math.Abs(dia) < 0.0000001))
                        {
                            delt = 2.0 * dia;
                            if (dia <= 0.5 && dia >= 0.3)
                            {
                                _rate     = 7 * dia;
                                _distance = 3 * dia / 0.4;
                            }
                            else if (dia < 0.3 && dia > 0.1)
                            {
                                _rate     = 12 * dia;
                                _distance = 6 * dia / 0.4;
                            }
                            else if (dia <= 0.1)
                            {
                                _rate     = 22 * dia;
                                _distance = 9 * dia / 0.4;
                            }
                            else
                            {
                                _rate     = 3.5 * dia;
                                _distance = 1.5 * dia / 0.4;
                            }
                        }
                        else
                        {
                            _rate     = 2.0;
                            _distance = 3.0;
                            //z = maxZ + 0.2;
                            delt = 0.2;
                        }
                        List <IPoint> list = DisPerseLine(pt1, pt2, _distance);
                        if (list.Count < 2)
                        {
                            return;
                        }
                        List <IPoint>    list1   = new List <IPoint>();
                        IGeometryFactory geoFact = new GeometryFactoryClass();
                        for (int j = 0; j < list.Count - 1; j++)
                        {
                            IPoint p = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            p.X = (list[j].X + list[j + 1].X) / 2;
                            p.Y = (list[j].Y + list[j + 1].Y) / 2;
                            p.Z = (list[j].Z + list[j + 1].Z) / 2;
                            list1.Add(p);
                        }

                        for (var m = 0; m < list1.Count; m++)
                        {
                            IPosition pos = new PositionClass();
                            pos.X            = list1[m].X;
                            pos.Y            = list1[m].Y;
                            pos.Altitude     = list1[m].Z + delt;
                            pos.AltitudeType = gviAltitudeType.gviAltitudeTerrainAbsolute;
                            pos.Heading      = angle.Heading;
                            pos.Tilt         = angle.Tilt;
                            pos.Roll         = angle.Roll;
                            UInt32 color;
                            if (type == 1)
                            {
                                color = 0xFFFFFF00;
                            }
                            else
                            {
                                color = 0xFF00FFFF;
                            }
                            ITerrainArrow rArrow = DF3DApplication.Application.Current3DMapControl.ObjectManager.CreateArrow(pos, 0.8 * _rate, 3, color, color, DF3DApplication.Application.Current3DMapControl.ProjectTree.RootID);
                            this._listRender.Add(rArrow.Guid);
                        }
                    }
                    #endregion
                }
            }
            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;
                }
            }
        }
Пример #26
0
        void axRenderControl1_RcMouseClickSelect(object sender, Gvitech.CityMaker.Controls._IRenderControlEvents_RcMouseClickSelectEvent e)
        {
            if (e.pickResult.Type == gviObjectType.gviObjectLabel)
            {
                ILabelPickResult tlpr = e.pickResult as ILabelPickResult;
                gviObjectType    type = tlpr.Type;
                ILabel           fl   = tlpr.Label;
                MessageBox.Show("拾取到" + type + "类型,内容为" + fl.Text);
            }
            else if (e.pickResult.Type == gviObjectType.gviObjectRenderModelPoint)
            {
                IRenderModelPointPickResult tlpr = e.pickResult as IRenderModelPointPickResult;
                gviObjectType     type           = tlpr.Type;
                IRenderModelPoint fl             = tlpr.ModelPoint;
                MessageBox.Show("拾取到" + type + "类型,模型名称为" + fl.ModelName);
            }
            else if (e.pickResult.Type == gviObjectType.gviObjectRenderPoint)
            {
                IRenderPointPickResult tlpr = e.pickResult as IRenderPointPickResult;
                gviObjectType          type = tlpr.Type;
                IRenderPoint           fl   = tlpr.Point;
                MessageBox.Show("拾取到" + type + "类型,大小为" + fl.Symbol.Size);
            }
            else if (e.pickResult.Type == gviObjectType.gviObjectRenderPolyline)
            {
                IRenderPolylinePickResult tlpr = e.pickResult as IRenderPolylinePickResult;
                gviObjectType             type = tlpr.Type;
                IRenderPolyline           fl   = tlpr.Polyline;
                MessageBox.Show("拾取到" + type + "类型,GUID为" + fl.Guid);
            }
            else if (e.pickResult.Type == gviObjectType.gviObjectRenderPolygon)
            {
                IRenderPolygonPickResult tlpr = e.pickResult as IRenderPolygonPickResult;
                gviObjectType            type = tlpr.Type;
                IRenderPolygon           fl   = tlpr.Polygon;
                MessageBox.Show("拾取到" + type + "类型,GUID为" + fl.Guid);
            }
            else if (e.pickResult.Type == gviObjectType.gviObjectRenderPOI)
            {
                IRenderPOIPickResult tlpr = e.pickResult as IRenderPOIPickResult;
                gviObjectType        type = tlpr.Type;
                IRenderPOI           fl   = tlpr.POI;
                MessageBox.Show("拾取到" + type + "类型,名称为" + ((IPOI)fl.GetFdeGeometry()).Name);
            }
            else if (e.pickResult.Type == gviObjectType.gviObjectReferencePlane)
            {
                //ta = new TextAttribute();
                ta.TextSize = Convert.ToInt32(this.toolstripFontSize.Text.ToString());
                //  ta.TextColor = olec;
                IImage image     = null;
                IModel model     = null;
                string imageName = "";
                this.axRenderControl1.Utility.CreateFixedBillboard(label.Text, 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 GeometryFactoryClass();
                }
                fde_modelpoint = gfactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint,
                                                         gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
                fde_modelpoint.SetCoords(e.intersectPoint.X, e.intersectPoint.Y, e.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(e.intersectPoint.Position, 100, angle);
            }
        }
Пример #27
0
        /// <summary>
        /// 参数化建模
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDriveModel_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (polyline != null)
                {
                    center = polyline.Envelope.Center;
                    IModelPoint mp = new GeometryFactory().CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
                    mp.SpatialCRS = datasetCRS;
                    mp.Position   = center;

                    IModel         model     = new ResourceFactory().CreateModel();
                    IDrawGroup     group     = new DrawGroup();
                    IDrawPrimitive primitive = new DrawPrimitive();
                    IDrawMaterial  material  = new DrawMaterial();
                    material.TextureName = (strMediaPath + @"\shp\road\textrure.jpg");
                    material.CullMode    = gviCullFaceMode.gviCullNone;
                    material.WrapModeS   = gviTextureWrapMode.gviTextureWrapRepeat;
                    material.WrapModeT   = gviTextureWrapMode.gviTextureWrapRepeat;
                    IFloatArray va = new FloatArray();
                    IFloatArray ta = new FloatArray();
                    // 逐点外扩
                    for (int i = 0; i < polyline.PointCount; i++)
                    {
                        #region 单独处理最后一个点
                        if (i == polyline.PointCount - 1)
                        {
                            curPoint  = polyline.GetPoint(i);
                            vecCurPos = curPoint.Position;
                            // 最后一个点重用最后的方向向量
                            vecTarget = vecDirect.CrossProduct(vecZ);
                            vecTarget.Normalize();
                            vecTarget.MultiplyByScalar(width / 2);
                            vecP = vecCurPos.Add(vecTarget);
                            vecTarget.MultiplyByScalar(-1);
                            vecQ = vecCurPos.Add(vecTarget);
                            // 设置外扩点
                            P          = curPoint.Clone() as IPoint;
                            P.Position = vecP;
                            Q          = curPoint.Clone() as IPoint;
                            Q.Position = vecQ;
                            // 把点坐标加进顶点数组
                            va.Append((float)(vecP.X - center.X));
                            va.Append((float)(vecP.Y - center.Y));
                            va.Append((float)(vecP.Z - center.Z));
                            va.Append((float)(vecQ.X - center.X));
                            va.Append((float)(vecQ.Y - center.Y));
                            va.Append((float)(vecQ.Z - center.Z));
                            // 加纹理坐标
                            ta.Append(0);  //P点纹理
                            if (i == 0)
                            {
                                lastV = 0.0;
                            }
                            else
                            {
                                lastV = lastV + length / 10;  //v方向上每隔10米重复一次
                            }
                            ta.Append((float)lastV);
                            ta.Append(1);  //Q点纹理
                            ta.Append((float)lastV);

                            {
                                ISimplePointSymbol ps = new SimplePointSymbol();
                                ps.FillColor = System.Drawing.Color.Yellow;
                                ps.Size      = 5;
                                rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(P, ps, rootId));
                                rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(Q, ps, rootId));
                            }

                            break;
                        }
                        #endregion

                        // 当不是最后一个点时:
                        curPoint   = polyline.GetPoint(i);
                        nextPoint  = polyline.GetPoint(i + 1);
                        vecCurPos  = curPoint.Position;
                        vecNextPos = nextPoint.Position;
                        // 运算
                        vecNextPos.MultiplyByScalar(-1);
                        vecDirect = vecCurPos.Add(vecNextPos);  //方向向量
                        vecZ.Set(0, 0, 1);
                        vecTarget = vecDirect.CrossProduct(vecZ);
                        vecTarget.Normalize();
                        vecTarget.MultiplyByScalar(width / 2);
                        vecP = vecCurPos.Add(vecTarget);
                        vecTarget.MultiplyByScalar(-1);
                        vecQ = vecCurPos.Add(vecTarget);
                        // 设置外扩点
                        P          = curPoint.Clone() as IPoint;
                        P.Position = vecP;
                        Q          = curPoint.Clone() as IPoint;
                        Q.Position = vecQ;
                        // 把点坐标加进顶点数组
                        va.Append((float)(vecP.X - center.X));
                        va.Append((float)(vecP.Y - center.Y));
                        va.Append((float)(vecP.Z - center.Z));
                        va.Append((float)(vecQ.X - center.X));
                        va.Append((float)(vecQ.Y - center.Y));
                        va.Append((float)(vecQ.Z - center.Z));
                        // 加纹理坐标
                        ta.Append(0);  //P点纹理
                        if (i == 0)
                        {
                            lastV = 0.0;
                        }
                        else
                        {
                            lastV = lastV + length / 5; //v方向上每隔10米重复一次
                        }
                        length = vecDirect.Length;      //计算长度给奇数点用
                        ta.Append((float)lastV);
                        ta.Append(1);                   //Q点纹理
                        ta.Append((float)lastV);

                        {
                            ISimplePointSymbol ps = new SimplePointSymbol();
                            ps.FillColor = System.Drawing.Color.Yellow;
                            ps.Size      = 5;
                            rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(P, ps, rootId));
                            rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(Q, ps, rootId));
                        }
                    }
                    // 计算索引坐标
                    IUInt16Array ia = new UInt16Array();
                    for (int i = 0; i < va.Length / 6 - 1; i++)
                    {
                        ia.Append((ushort)(2 * i));
                        ia.Append((ushort)(2 * i + 1));
                        ia.Append((ushort)(2 * i + 2));
                        ia.Append((ushort)(2 * i + 1));
                        ia.Append((ushort)(2 * i + 3));
                        ia.Append((ushort)(2 * i + 2));
                    }
                    primitive.VertexArray   = va;
                    primitive.TexcoordArray = ta;
                    primitive.IndexArray    = ia;
                    primitive.Material      = material;
                    group.AddPrimitive(primitive);
                    model.AddGroup(group);

                    // 在内存中临时存储模型
                    string modelName = fid.ToString();
                    this.axRenderControl1.ObjectManager.AddModel(modelName, model);
                    mp.ModelName     = modelName;
                    mp.ModelEnvelope = model.Envelope;
                    // 可视化临时模型
                    IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, null, rootId);
                    rmp.MaxVisibleDistance = 100000;
                    rmp.MouseSelectMask    = gviViewportMask.gviViewNone;
                    rModelpointToDelList.Add(rmp);
                }
            }
            catch (System.Exception ex)
            {
                if (ex.GetType().Name.Equals("UnauthorizedAccessException"))
                {
                    MessageBox.Show("需要标准runtime授权");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #28
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;
                }
            }
        }
Пример #29
0
        void axRenderControl1_RcObjectEditFinish()
        {
            this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal;
            polygonDraw = currentGeometry as IPolygon;
            //抬高一点
            for (int i = 0; i < polygonDraw.ExteriorRing.PointCount; i++)
            {
                IPoint pointOnExr = polygonDraw.ExteriorRing.GetPoint(i).Clone() as IPoint;
                pointOnExr.Z += 1;
                polygonDraw.ExteriorRing.UpdatePoint(i, pointOnExr);
            }

            renderpolygonDraw.SetFdeGeometry(polygonDraw);
            renderpolygonDraw.VisibleMask = gviViewportMask.gviViewNone;

            double height = 0.0;

            try
            {
                height = double.Parse(this.numHeight.Value.ToString());
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("请检查挖洞高度");
                return;
            }

            //构造底面polygon
            IPolygon polygonBottom = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;

            for (int i = 0; i < polygonDraw.ExteriorRing.PointCount; i++)
            {
                IPoint pointOnExr = polygonDraw.ExteriorRing.GetPoint(i).Clone() as IPoint;
                maxZ          = pointOnExr.Z;
                pointOnExr.Z -= height;
                minZ          = pointOnExr.Z;
                polygonBottom.ExteriorRing.AppendPoint(pointOnExr);
            }
            polygonBottom.Close();
            PolygonList.Add(polygonBottom);
            //CreateRenderPolygon(polygonBottom);


            //构造侧面polygon
            for (int i = 0; i < polygonDraw.ExteriorRing.PointCount; i++)
            {
                IPoint pointOnExr = polygonDraw.ExteriorRing.GetPoint(i).Clone() as IPoint;
                pointOnExr.Z -= height;

                IPoint pointOnExr2 = null;
                if (i == polygonDraw.ExteriorRing.PointCount - 1)
                {
                    pointOnExr2 = polygonDraw.ExteriorRing.GetPoint(0).Clone() as IPoint;
                }
                else
                {
                    pointOnExr2 = polygonDraw.ExteriorRing.GetPoint(i + 1).Clone() as IPoint;
                }
                pointOnExr2.Z -= height;

                IPolygon polygonTemp = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
                polygonTemp.ExteriorRing.AppendPoint(polygonDraw.ExteriorRing.GetPoint(i));
                polygonTemp.ExteriorRing.AppendPoint(pointOnExr);
                polygonTemp.ExteriorRing.AppendPoint(pointOnExr2);
                if (i == polygonDraw.ExteriorRing.PointCount - 1)
                {
                    polygonTemp.ExteriorRing.AppendPoint(polygonDraw.ExteriorRing.GetPoint(0));
                }
                else
                {
                    polygonTemp.ExteriorRing.AppendPoint(polygonDraw.ExteriorRing.GetPoint(i + 1));
                }
                polygonTemp.Close();
                PolygonList.Add(polygonTemp);
                //CreateRenderPolygon(polygonTemp);
            }


            List <IRowBuffer> list   = new List <IRowBuffer>();
            ISpatialFilter    filter = new SpatialFilter();

            filter.Geometry      = polygonDraw;
            filter.SpatialRel    = gviSpatialRel.gviSpatialRelEnvelope;
            filter.GeometryField = "Geometry";
            IRowBuffer row    = null;
            IFdeCursor cursor = __fc.Search(filter, false);

            while ((row = cursor.NextRow()) != null)
            {
                list.Add(row);
            }

            foreach (IRowBuffer r in list)
            {
                __fid = (Int32)r.GetValue(0);
                int geometryIndex = -1;
                geometryIndex = r.FieldIndex("Geometry");
                int nameIndex = -1;
                nameIndex = r.FieldIndex("Name");
                if (geometryIndex != -1)
                {
                    // 获取ModelPoint
                    IModelPoint mp = r.GetValue(geometryIndex) as IModelPoint;

                    // 获取Model
                    string modelName = mp.ModelName;
                    IModel m         = (__fc.FeatureDataSet as IResourceManager).GetModel(modelName);

                    Logger.WriteMsg(LogLevel.Message, "---------开始ModelPointToTriMesh----------", DateTime.Now);
                    // 获取MultiTriMesh
                    IMultiTriMesh multiTM = gc.ModelPointToTriMesh(m, mp, false);
                    Logger.WriteMsg(LogLevel.Message, string.Format("---------完成ModelPointToTriMesh:{0}----------", multiTM.GeometryCount), DateTime.Now);

                    // 获取Name
                    string strName = r.GetValue(nameIndex).ToString();
                    for (int i = 0; i < multiTM.GeometryCount; i++)
                    {
                        ITriMesh tm = multiTM.GetGeometry(i) as ITriMesh;
                        //if (!tm.IsClosed)
                        //    continue;

                        // 生成剖面
                        for (int p = 0; p < PolygonList.Count; p++)
                        {
                            IPolygon curPolygon = PolygonList[p];
                            Logger.WriteMsg(LogLevel.Message, string.Format("TM:{0} PG:{1}", i, p), DateTime.Now);
                            if (gc.GetSolidProfile(tm, curPolygon, out multiPolygon))
                            {
                                Logger.WriteMsg(LogLevel.Message, string.Format("TM:{0} PG:{1} TRUE", i, p), DateTime.Now);
                                if (multiPolygon != null && multiPolygon.GeometryCount > 0)
                                {
                                    for (int j = 0; j < multiPolygon.GeometryCount; j++)
                                    {
                                        IPolygon tm2 = multiPolygon.GetGeometry(j) as IPolygon;
                                        //RenderPolygonList.Add(CreateRenderPolygon(tm2));

                                        ICurveSymbol cs = new CurveSymbol();
                                        cs.Color = Color.FromArgb(0, Color.White);
                                        ISurfaceSymbol ss = new SurfaceSymbol();
                                        ss.BoundarySymbol = cs;
                                        ss.Color          = m.GetGroup(0).GetPrimitive(0).Material.DiffuseColor;
                                        IRenderPolygon tmPolygon = this.axRenderControl1.ObjectManager.CreateRenderPolygon(tm2, ss, rootId);
                                        tmPolygon.SetClientData("Name", strName);
                                        RenderPolygonList.Add(tmPolygon);

                                        #region 用当前选中的模型材质,生成截面模型

                                        /*
                                         * IModel outModel = null;
                                         * IModelPoint outMP = null;
                                         * gc.PolygonToModelPoint(tm2, out outModel, out outMP);
                                         *
                                         * if (outModel != null && outMP != null)
                                         * {
                                         *
                                         *  IDrawGroup dgroup = outModel.GetGroup(0);
                                         *  IDrawPrimitive dpri = dgroup.GetPrimitive(0);
                                         *  IDrawMaterial dmar = dpri.Material;
                                         *  dmar.CullMode = gviCullFaceMode.gviCullNone;
                                         *
                                         *  //处理贴图
                                         *  //IPropertySet psOut = new PropertySet();
                                         *  string imgName = m.GetGroup(0).GetPrimitive(0).Material.TextureName;
                                         *  if (imgName != "")
                                         *  {
                                         *      dmar.WrapModeS = gviTextureWrapMode.gviTextureWrapRepeat;
                                         *      dmar.WrapModeT = gviTextureWrapMode.gviTextureWrapRepeat;
                                         *
                                         *      //string tmpImgPath = (strMediaPath + @"\1\") + imgName + ".dds";
                                         *      //IImage imageOut = (__fc.FeatureDataSet as IResourceManager).GetImage(imgName);
                                         *      //imageOut.WriteFile(tmpImgPath);
                                         *      //psOut.SetProperty(imgName, imageOut);
                                         *      //dmar.TextureName = imgName;
                                         *
                                         *      IImage image = (__fc.FeatureDataSet as IResourceManager).GetImage(imgName);
                                         *      this.axRenderControl1.ObjectManager.AddImage(imgName, image);
                                         *      dmar.TextureName = imgName;
                                         *
                                         *      if (dpri.VertexArray.Length == 12)
                                         *      {
                                         *          IFloatArray texcoords = new FloatArray();
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(1.0f);
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(1.0f);
                                         *          texcoords.Append(1.0f);
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(1.0f);
                                         *          dpri.TexcoordArray = texcoords;
                                         *      }
                                         *      else
                                         *      {
                                         *          IFloatArray texcoords = new FloatArray();
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(0);
                                         *          for (int v = 3; v < dpri.VertexArray.Length - 2; )
                                         *          {
                                         *              texcoords.Append(Math.Abs(dpri.VertexArray.Get(v) - dpri.VertexArray.Get(0)));
                                         *              texcoords.Append(Math.Abs(dpri.VertexArray.Get(v+2) - dpri.VertexArray.Get(2)));
                                         *              v += 3;
                                         *          }
                                         *          dpri.TexcoordArray = texcoords;
                                         *      }
                                         *  }
                                         *  else
                                         *  {
                                         *      dmar.DepthBias = m.GetGroup(0).GetPrimitive(0).Material.DepthBias;
                                         *      dmar.DiffuseColor = m.GetGroup(0).GetPrimitive(0).Material.DiffuseColor;
                                         *      dmar.EnableBlend = m.GetGroup(0).GetPrimitive(0).Material.EnableBlend;
                                         *      dmar.EnableLight = m.GetGroup(0).GetPrimitive(0).Material.EnableLight;
                                         *      dmar.SpecularColor = m.GetGroup(0).GetPrimitive(0).Material.SpecularColor;
                                         *      dmar.WrapModeS = m.GetGroup(0).GetPrimitive(0).Material.WrapModeS;
                                         *      dmar.WrapModeT = m.GetGroup(0).GetPrimitive(0).Material.WrapModeT;
                                         *  }
                                         *
                                         *  dpri.Material = dmar;
                                         *  dgroup.SetPrimitive(0, dpri);
                                         *  outModel.SetGroup(0, dgroup);
                                         *
                                         *  //处理模型
                                         *  //string osgNameOut = __fid + "_" + p + "_" + j;
                                         *  //string tmpOSGPath = (strMediaPath + @"\1\" + osgNameOut + ".osg");
                                         *  //outModel.WriteFile(tmpOSGPath, psOut);
                                         *  //outMP.ModelName = tmpOSGPath;
                                         *
                                         *
                                         *  string osgName = __fid + "_" + p + "_" + j;
                                         *  this.axRenderControl1.ObjectManager.AddModel(osgName, outModel);
                                         *  outMP.ModelName = osgName;
                                         *
                                         *  //可视化
                                         *  outMP.ModelEnvelope = outModel.Envelope;
                                         *  IRenderModelPoint outRenderMP = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(outMP, null, rootId);
                                         *  //this.axRenderControl1.RefreshModel(null, tmpOSGPath);
                                         *  outRenderMP.ShowOutline = true;
                                         *  //outRenderMP.VisibleMask = gviViewportMask.gviViewNone;
                                         *  RenderMPProfileList.Add(outRenderMP);
                                         * }
                                         */
                                        #endregion
                                    }
                                }
                            }
                        } //遍历PolygonList结束
                    }     //遍历multiTM结束



                    //去掉内环模型
                    __fl.VisibleMask = gviViewportMask.gviViewNone;
                    IModel            modelInterior = null;
                    IModelPoint       mpInterior    = null;
                    IRenderModelPoint rmpInterior   = null;
                    IModel            modelExterior = null;
                    IModelPoint       mpExterior    = null;
                    IRenderModelPoint rmpExterior   = null;
                    IMultiPolygon     mltiPolygon   = geoFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon;
                    mltiPolygon.AddGeometry(polygonDraw);
                    Logger.WriteMsg(LogLevel.Message, "---------开始SplitModelPointByPolygon2DWithZ----------", DateTime.Now);
                    if (gc.SplitModelPointByPolygon2DWithZ(mltiPolygon, m, mp, minZ, maxZ, out modelInterior, out mpInterior, out modelExterior, out mpExterior))
                    {
                        Logger.WriteMsg(LogLevel.Message, "SplitModelPointByPolygon2DWithZ返回值为TRUE", DateTime.Now);
                        if (modelExterior != null && mpExterior != null)
                        {
                            this.axRenderControl1.ObjectManager.AddModel(mpExterior.ModelName, modelExterior);
                            string[] imagenames = modelExterior.GetImageNames();
                            for (int q = 0; q < imagenames.Length; q++)
                            {
                                IImage image = (__fc.FeatureDataSet as IResourceManager).GetImage(imagenames[q]);
                                this.axRenderControl1.ObjectManager.AddImage(imagenames[q], image);
                            }
                            rmpExterior = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mpExterior, null, rootId);
                            RenderMPExteriorList.Add(rmpExterior);
                        }
                        if (modelInterior != null && mpInterior != null)
                        {
                            this.axRenderControl1.ObjectManager.AddModel(mpInterior.ModelName, modelInterior);
                            string[] imagenames = modelInterior.GetImageNames();
                            for (int q = 0; q < imagenames.Length; q++)
                            {
                                IImage image = (__fc.FeatureDataSet as IResourceManager).GetImage(imagenames[q]);
                                this.axRenderControl1.ObjectManager.AddImage(imagenames[q], image);
                            }
                            rmpInterior             = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mpInterior, null, rootId);
                            rmpInterior.VisibleMask = gviViewportMask.gviViewNone;
                            RenderMPInteriorList.Add(rmpInterior);
                        }
                    }
                }
            }//遍历RowBufferList结束
             //MessageBox.Show("执行成功");
        }
Пример #30
0
        private void LoadDynamicTableLabel()
        {
            #region 加载一个标签
            dynamicTableLabel = axRenderControl1.ObjectManager.CreateTableLabel(2, 2, rootId);

            dynamicTableLabel.TitleText = "消防车当前位置";
            dynamicTableLabel.SetRecord(0, 0, "X:");
            dynamicTableLabel.SetRecord(0, 1, firstX.ToString());
            dynamicTableLabel.SetRecord(1, 0, "Y:");
            dynamicTableLabel.SetRecord(1, 1, firstY.ToString());

            position.Set(firstX, firstY, firstZ + 2.4);
            if (fde_point == null)
            {
                fde_point = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
            }
            fde_point.Position         = position;
            dynamicTableLabel.Position = fde_point;

            dynamicTableLabel.BorderColor          = System.Drawing.Color.White;
            dynamicTableLabel.BorderWidth          = 2;
            dynamicTableLabel.TableBackgroundColor = System.Drawing.Color.Gray;
            dynamicTableLabel.TitleBackgroundColor = System.Drawing.Color.Red;

            // 表头样式
            TextAttribute headerTextAttribute = new TextAttribute();
            headerTextAttribute.TextColor              = System.Drawing.Color.Black;
            headerTextAttribute.OutlineColor           = System.Drawing.Color.Red;
            headerTextAttribute.Font                   = "黑体";
            headerTextAttribute.Bold                   = true;
            headerTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
            dynamicTableLabel.SetColumnTextAttribute(0, headerTextAttribute);

            // 内容样式
            TextAttribute contentTextAttribute = new TextAttribute();
            contentTextAttribute.TextColor              = System.Drawing.Color.Black;
            contentTextAttribute.OutlineColor           = System.Drawing.Color.Red;
            contentTextAttribute.Font                   = "黑体";
            contentTextAttribute.Bold                   = false;
            contentTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
            dynamicTableLabel.SetColumnTextAttribute(1, contentTextAttribute);

            // 标题样式
            TextAttribute capitalTextAttribute = new TextAttribute();
            capitalTextAttribute.TextColor              = System.Drawing.Color.White;
            capitalTextAttribute.OutlineColor           = System.Drawing.Color.Gray;
            capitalTextAttribute.Font                   = "华文新魏";
            capitalTextAttribute.TextSize               = 14;
            capitalTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineCenter;
            capitalTextAttribute.Bold                   = true;
            dynamicTableLabel.TitleTextAttribute        = capitalTextAttribute;

            angle.Set(0, -20, 0);
            axRenderControl1.Camera.LookAt(position, 30, angle);
            #endregion

            #region 加载一个模型
            if (renderModelPoint == null)
            {
                string           modelName  = (strMediaPath + @"\osg\Vehicles\XiaoFangChe\xiaoFangChe3.OSG");
                IGeometryFactory geoFactory = new GeometryFactory();
                IModelPoint      modePoint  = (IModelPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ);
                modePoint.ModelName = modelName;
                modePoint.SetCoords(firstX, firstY, firstZ, 0, 0);
                renderModelPoint = axRenderControl1.ObjectManager.CreateRenderModelPoint(modePoint, null, rootId);
            }
            #endregion

            #region 加载一个运动路径
            if (motionPath == null)
            {
                motionPath = axRenderControl1.ObjectManager.CreateMotionPath(rootId);
                // 为MotionPath添加第一个点
                position.Set(firstX, firstY, firstZ);
                angle.Set(firstH, firstP, firstR);
                scale.Set(firstSX, firstSY, firstSZ);
                motionPath.AddWaypoint(position, angle, scale, firtWhen);
                //为MotionPath添加第二个点
                position.Set(secondX, secondY, secondZ);
                angle.Set(secondH, secondP, secondR);
                scale.Set(secondSX, secondSY, secondSZ);
                motionPath.AddWaypoint(position, angle, scale, secondWhen);
                //为MotionPath添加第三个点
                position.Set(thirdX, thirdY, thirdZ);
                angle.Set(thirdH, thirdP, thirdR);
                scale.Set(thirdSX, thirdSY, thirdSZ);
                motionPath.AddWaypoint(position, angle, scale, thirdWhen);
                //为MotionPath添加第四个点
                position.Set(fourthX, fourthY, fourthZ);
                angle.Set(fourthH, fourthP, fourthR);
                scale.Set(fourthSX, fourthSY, fourthSZ);
                motionPath.AddWaypoint(position, angle, scale, fourthWhen);
            }
            #endregion

            #region 将模型和标牌同时绑定在路径上
            m = renderModelPoint as IMotionable;
            //将模型绑定到路径上

            v3.Set(0, 0, 0);
            m.Bind(motionPath, v3, 0, 0, 0);

            // 将标牌绑定到路径上
            if (dynamicTableLabel != null && motionPath != null)
            {
                m = dynamicTableLabel as IMotionable;
                v3.Set(0, 0, 6);
                m.Bind(motionPath, v3, 0, 0, 0);
            }
            #endregion
        }