public void AddModel_Click(Point3D Point3D, int ModelIndex, string strID, string strNOID) { AddPointToDatasets(Point3D, ModelIndex, strID, strNOID); Datasource datasource = m_workspace.Datasources[0]; DatasetVector pointDataset = datasource.Datasets["Point3D"] as DatasetVector; Recordset recordset = pointDataset.GetRecordset(false, CursorType.Dynamic); GeoPoint3D geopoint3D = new GeoPoint3D(Point3D); GeoStyle3D geoStyle = new GeoStyle3D(); geoStyle.MarkerSymbolID = UserHelper.Marker3DSymbolID[ModelIndex]; geoStyle.IsMarkerSizeFixed = false; geoStyle.MarkerSize = 1; geoStyle.Marker3DScaleX = 0.03; geoStyle.Marker3DScaleY = 0.03; geoStyle.Marker3DScaleZ = 0.08; geoStyle.IsMarker3D = true; geoStyle.AltitudeMode = AltitudeMode.RelativeToGround; geopoint3D.Style3D = geoStyle; recordset.MoveLast(); recordset.AddNew(geopoint3D); recordset.SetFieldValue(m_filedName, strID); recordset.Update(); recordset.Dispose(); m_layer3DPoint.IsSelectable = false; m_layer3DPoint.UpdateData(); m_SceneControl.Scene.Refresh(); //AddKmlLayer(); //GeoPlacemark geoPlacemark = new GeoPlacemark(); //m_geoModel = new GeoModel(); //m_geoModel.FromFile(UserHelper.sModelName[ModelIndex]); ////人物模型朝向前进方向,如果原始方向一致则不需要旋转。 //m_geoModel.Style3D = m_style3D; //m_geoModel.RotationZ = 180; //m_geoModel.ScaleX = 0.3; //m_geoModel.ScaleY = 0.3; //m_geoModel.ScaleZ = 0.3; //m_geoModel.Position = new Point3D(Point3D.X, Point3D.Y, Point3D.Z); //geoPlacemark.Geometry = m_geoModel; //Feature3Ds feture3Ds = m_LayerKML.Features; //Feature3D feature = new Feature3D(); //feature.Geometry = geoPlacemark; //feature.Description = strID; //feature.Name = feature.Description; //feture3Ds.Add(feature); //feture3Ds.ToKMLFile(m_LayerKML.DataName); //m_LayerKML.UpdateData(); }
public void SetRegionPoint() { try { if (m_workspace.Datasources[0].Datasets.Contains("New_Point3D")) { DatasetVector datasetPoint3D = m_workspace.Datasources[0].Datasets["New_Point3D"] as DatasetVector; if (m_sceneControl.Scene.Layers.Contains("New_Point3D@gongyuan")) { m_sceneControl.Scene.Layers.Remove("New_Point3D@gongyuan"); } { Layer3DSettingVector pointSetting = new Layer3DSettingVector(); pointSetting.Style.AltitudeMode = AltitudeMode.RelativeToGround; pointSetting.Style.MarkerSize = 1; pointSetting.Style.IsMarkerSizeFixed = true; pointSetting.Style.MarkerScale = 1; pointSetting.Style.MarkerSymbolID = m_marker3DIndex; pointSetting.Style.IsMarker3D = true; m_layer3DRegionPoint = m_sceneControl.Scene.Layers.Add(datasetPoint3D, pointSetting, true, "New_Point3D@gongyuan"); } m_layer3DRegionPoint.UpdateData(); m_sceneControl.Scene.Refresh(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//刷新风格 private void RefreshStyle() { if (m_layer3D == null) { return; } if (m_bSelection) { m_layer3D.Selection.Style = m_style3D; m_layer3D.Selection.UpdateData(); } else { if (m_layer3D.Type == Layer3DType.Dataset) { Layer3DDataset layer3DDataset = m_layer3D as Layer3DDataset; //layer3DDataset.IsEditable = true; Layer3DSettingVector layerSetting = layer3DDataset.AdditionalSetting as Layer3DSettingVector; layerSetting.Style = m_style3D; layer3DDataset.AdditionalSetting = layerSetting; layer3DDataset.UpdateData(); } else if (m_layer3D.Type == Layer3DType.VectorFile) { Layer3DVectorFile layer3DFile = m_layer3D as Layer3DVectorFile; Layer3DSettingVector layerSetting = layer3DFile.AdditionalSetting as Layer3DSettingVector; layerSetting.Style = m_style3D; layer3DFile.AdditionalSetting = layerSetting; layer3DFile.UpdateData(); } this.m_sceneControl.Scene.Refresh(); } }
//将查询结果显示到场景中 private Layer3D AddResultToScene(DatasetVector dataset, Color color) { Layer3Ds layer3Ds = m_sceneControl.Scene.Layers; //设置图层风格为依模型 Layer3DSettingVector settingVector = new Layer3DSettingVector(); GeoStyle3D style3D = new GeoStyle3D(); style3D.AltitudeMode = AltitudeMode.ClampToObject; style3D.FillForeColor = color; settingVector.Style = style3D; //将数据添加到场景中 Layer3DDataset layerDataset = layer3Ds.Add(dataset, settingVector, true); layerDataset.UpdateData(); m_sceneControl.Scene.EnsureVisible(layerDataset); return(layerDataset); }
//将原始面数据集加载到场景中 private Layer3DDataset AddSrcRegionToScene(DatasetVector dataset) { Layer3Ds layer3Ds = m_sceneControl.Scene.Layers; //设置图层风格为依模型 Layer3DSettingVector settingVector = new Layer3DSettingVector(); GeoStyle3D style3D = new GeoStyle3D(); style3D.AltitudeMode = AltitudeMode.RelativeToGround; style3D.BottomAltitude = 1; style3D.FillForeColor = Color.Blue; settingVector.Style = style3D; //将数据添加到场景中 Layer3DDataset layerDataset = layer3Ds.Add(dataset, settingVector, true, dataset.Name); layerDataset.UpdateData(); m_sceneControl.Scene.EnsureVisible(layerDataset); m_sceneControl.Scene.Refresh(); return(layerDataset); }
//绘制线触发的事件 private void m_sceneControl_Tracked(object sender, Tracked3DEventArgs e) { Recordset recordset; Double lineWidth = 0.0; Double bottomheight = 0; try { if (flag) { if (!isRegion) { GeoLine3D geoLine3D = e.Geometry as GeoLine3D; GeoStyle3D geoStyle = new GeoStyle3D(); geoStyle.LineSymbolID = m_line3DIndex; geoStyle.LineWidth = lineWidth; geoStyle.AltitudeMode = AltitudeMode.RelativeToGround; geoStyle.BottomAltitude = bottomheight; geoLine3D.Style3D = geoStyle; recordset = m_datasetLine3D.GetRecordset(false, CursorType.Dynamic); recordset.AddNew(geoLine3D); recordset.Update(); recordset.Dispose(); m_layer3DLine.UpdateData(); m_sceneControl.Scene.Refresh(); } else { if (ispointRegion) { GeoRegion3D geoRegion3D = e.Geometry as GeoRegion3D; if (geoRegion3D.PartCount > 0) { Rectangle2D rect = geoRegion3D.Bounds; Datasource datasource = m_workspace.Datasources[0]; DatasetVector pointDataset = datasource.Datasets["Point3D"] as DatasetVector; for (double y = geoRegion3D.Bounds.Bottom; y < geoRegion3D.Bounds.Top;) { for (double x = geoRegion3D.Bounds.Left; x < geoRegion3D.Bounds.Right;) { recordset = pointDataset.GetRecordset(false, CursorType.Dynamic); Point3D pt3d = new Point3D(); pt3d.X = x; pt3d.Y = y; pt3d.Z = 0; GeoPoint3D geopoint3D = new GeoPoint3D(pt3d); GeoStyle3D geoStyle = new GeoStyle3D(); geoStyle.MarkerSymbolID = m_marker3DIndex; geoStyle.IsMarkerSizeFixed = false; geoStyle.MarkerSize = 1; geoStyle.Marker3DScaleX = 1; geoStyle.Marker3DScaleY = 1; geoStyle.Marker3DScaleZ = 1; geoStyle.IsMarker3D = true; geoStyle.AltitudeMode = AltitudeMode.RelativeToGround; geopoint3D.Style3D = geoStyle; recordset.MoveLast(); recordset.AddNew(geopoint3D); recordset.Update(); recordset.Dispose(); m_layer3DPoint.IsSelectable = false; m_layer3DPoint.UpdateData(); m_sceneControl.Scene.Refresh(); x += 0.0002; } y += 0.0002; } } } else { Datasource datasource = m_workspace.Datasources[0]; DatasetVector Region3DDataset = datasource.Datasets["Region3D"] as DatasetVector; recordset = Region3DDataset.GetRecordset(false, CursorType.Dynamic); GeoRegion3D geoRegion = e.Geometry as GeoRegion3D; GeoStyle3D geoStyle = new GeoStyle3D(); geoStyle.FillSymbolID = m_region3DIndex; geoStyle.AltitudeMode = AltitudeMode.RelativeToGround; geoStyle.BottomAltitude = 0.5; geoRegion.Style3D = geoStyle; recordset.AddNew(geoRegion); recordset.Update(); recordset.Dispose(); (m_layer3DRegion.AdditionalSetting as Layer3DSettingVector).Style = geoStyle; m_layer3DRegion.UpdateData(); m_sceneControl.Scene.Refresh(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 由地下飞到地上 /// </summary> public void FlyUndergroud() { try { // 地下飞行时,开启地下 m_sceneControl.Scene.Underground.IsVisible = true; m_sceneControl.Scene.CameraFOV = 60; // 加载飞行路线所需的数据和风格 //为“北京地铁”设置风格 DatasetVector dataSet_ditie = m_workspace.Datasources[0].Datasets["BeijingSubway"] as DatasetVector; Layer3DSettingVector settingvetor = new Layer3DSettingVector(); settingvetor.Style.AltitudeMode = AltitudeMode.RelativeToGround; settingvetor.Style.LineWidth = 3; settingvetor.Style.LineSymbolID = 962046; settingvetor.Style.BottomAltitude = -24; Layer3DDataset layer_ditie1 = m_sceneControl.Scene.Layers.Add(dataSet_ditie, settingvetor, true, "ditie"); layer_ditie1.IsSelectable = false; // 加载 "Subway_Line8"数据集作为地铁八号线的站点 DatasetVector DataSet_ditieLine8 = m_workspace.Datasources[0].Datasets["Subway_Line8"] as DatasetVector; Layer3DSettingVector setvetor_ditieLine8 = new Layer3DSettingVector(); setvetor_ditieLine8.Style = new GeoStyle3D(); setvetor_ditieLine8.Style.AltitudeMode = AltitudeMode.RelativeToGround; setvetor_ditieLine8.Style.BottomAltitude = 10; Layer3DDataset layer_ditieLine8 = m_sceneControl.Scene.Layers.Add(DataSet_ditieLine8, setvetor_ditieLine8, true, "地铁八号线"); layer_ditieLine8.UpdateData(); // 加载"BeijingSubway_Tunnel"数据集作为地铁巷道 DatasetVector DataSet_ditieL_2 = m_workspace.Datasources[0].Datasets["BeijingSubway_Tunnel"] as DatasetVector; Layer3DSettingVector setvetor_ditieL_2 = new Layer3DSettingVector(); setvetor_ditieL_2.Style = new GeoStyle3D(); setvetor_ditieL_2.Style.AltitudeMode = AltitudeMode.RelativeToGround; setvetor_ditieL_2.Style.BottomAltitude = -26.5; setvetor_ditieL_2.Style.LineSymbolID = 962047; setvetor_ditieL_2.Style.LineWidth = 10; Layer3DDataset layer_ditieL_2 = m_sceneControl.Scene.Layers.Add(DataSet_ditieL_2, setvetor_ditieL_2, true, "地铁巷道"); layer_ditieL_2.UpdateData(); // 加载北京地铁动画模型KML文件到场景 String KMLPath = @"..\..\SampleData\Symbol3DDisplay\Model\Subway.kml"; Layer3DKML layer_kml = m_sceneControl.Scene.Layers.Add(KMLPath, Layer3DType.KML, true, "模型动画") as Layer3DKML; Feature3D geofeature = layer_kml.Features.FindFeature(1, Feature3DSearchOption.AllFeatures); GeoPlacemark geoplacemark = geofeature.Geometry as GeoPlacemark; GeoModel geomodel = geoplacemark.Geometry as GeoModel; geomodel.Animation.PlayMode = PlayMode.Once; layer_kml.UpdateData(); //导入飞行路线文件 Boolean i = flyManager.Routes.FromFile(@"..\..\SampleData\Symbol3DDisplay\flyground.fpf"); flyManager.Routes.CurrentRouteIndex = 0; flyManager.Play(); //当飞行结束后触发事件 m_sceneControl.Focus(); m_sceneControl.Scene.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }