public FormMain() { InitializeComponent(); m_pMapC2 = axMapControl_main.Object as IMapControl2; m_pMapDoc = new MapDocumentClass(); m_pSceneCtl = axSceneControl_main.Object as ISceneControl; }
/// <summary> /// 打开ArcScene场景文档 张琪 /// </summary> public override void OnClick() { SysCommon.CProgress vProgress = new SysCommon.CProgress("进度条"); try { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = "打开一个场景文档"; openFileDialog1.Filter = "ArcScene场景(*.sxd)|*.sxd"; openFileDialog1.Multiselect = false; DialogResult pDialogResult = openFileDialog1.ShowDialog(); if (pDialogResult != DialogResult.OK) { return; } string pFileName = openFileDialog1.FileName; Plugin.LogTable.Writelog(Caption + pFileName); //xisheng 日志记录07.08 ISceneControl pSceneControl = m_sceneHookHelper.Hook as ISceneControl; vProgress.EnableCancel = false; //设置进度条 vProgress.ShowDescription = true; vProgress.FakeProgress = true; vProgress.TopMost = true; vProgress.ShowProgress(); vProgress.SetProgress("正在加载三维场景数据"); pSceneControl.LoadSxFile(pFileName);//加载三维文档 pSceneControl.SceneGraph.RefreshViewers(); vProgress.Close(); } catch { vProgress.Close(); } }
public FrmVertor(IPageLayoutControl3 pagelayoutcontrol, ISceneControl scenecontrol) { InitializeComponent(); this.EnableGlass = false; pPageLayoutControl = pagelayoutcontrol; pSceneControl = scenecontrol; }
public CmdPrintSceneView(ISceneControl scenecontrol) { // // TODO: Define values for the public properties // base.m_category = "CustomCE"; //localizable text base.m_caption = "导出图片"; //localizable text base.m_message = "导出三维场景图片"; //localizable text base.m_toolTip = "导出图片"; //localizable text base.m_name = "CustomCE.CmdPrintSceneView"; //unique id, non-localizable (e.g. "MyCategory_MyCommand") try { // // TODO: change bitmap name if necessary // string bitmapResourceName = GetType().Name + ".bmp"; base.m_bitmap = new Bitmap(GetType(), bitmapResourceName); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap"); } pSceneControl = scenecontrol; }
/// <summary> /// 加载默认的地图空间 /// </summary> /// <param name="sceneControl"></param> public void LoadDefaultWorkSpace(ISceneControl sceneControl) { if (sceneControl != null) { string defaultWorkSpacePath = GetDefaultWorkSpacePath(); sceneControl.LoadSxFile(defaultWorkSpacePath); } }
/// <summary> /// class constructor /// </summary> /// <param name="mapControl"></param> /// <param name="pageLayoutControl"></param> public ControlsSynchronizer(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl, ISceneControl sceneControl) : this() { //assign the class members m_mapControl = mapControl; m_pageLayoutControl = pageLayoutControl; m_sceneControl = sceneControl; }
/// <summary> /// 根据输入的要素在SceneControl中绘制元素 张琪 20110621 /// </summary> /// <param name="pSceneControl"></param> /// <param name="pGeom">几何要素</param> /// <param name="pSym"></param> public void AddGraphic(ISceneControl pSceneControl, IGeometry pGeom, ISymbol pSym) { if (pGeom == null) { return; } IElement pElement = null; switch (pGeom.GeometryType.ToString()) { case "esriGeometryPoint": //点要素 pElement = new MarkerElementClass(); IMarkerElement pPointElement = pElement as IMarkerElement; if (pSym != null) { IMarkerSymbol pMarker3DSymbol = pSym as IMarkerSymbol; pPointElement.Symbol = pMarker3DSymbol as IMarkerSymbol; } break; case "esriGeometryPolyline": //线要素 pElement = new LineElementClass(); ILineElement pLineElement = pElement as ILineElement; if (pSym != null) { ILineSymbol pLineSymbol = pSym as ILineSymbol; pLineElement.Symbol = pLineSymbol; } break; case "esriGeometryPolygon": //面要素 pElement = new PolygonElementClass(); IFillShapeElement pFillElement = pElement as IFillShapeElement; if (pSym != null) { IFillSymbol pFillSymbol = pSym as IFillSymbol; pFillElement.Symbol = pFillSymbol; } break; case "esriGeometryMultiPatch": //多面体要素 pElement = new MultiPatchElementClass(); IFillShapeElement pMultiPatchElement = pElement as IFillShapeElement; if (pSym != null) { IFillSymbol pFillSymbol = pSym as IFillSymbol; pMultiPatchElement.Symbol = pFillSymbol as IFillSymbol; } break; } pElement.Geometry = pGeom; IGraphicsContainer3D pGCon3D = pSceneControl.Scene.BasicGraphicsLayer as IGraphicsContainer3D; pGCon3D.AddElement(pElement);//在SceneControl中绘制要素 IGraphicsSelection pGS = pGCon3D as IGraphicsSelection; pSceneControl.Scene.SceneGraph.RefreshViewers(); }
private void FrmEdit3DFeatures_Load(object sender, EventArgs e) { // ISelection pSelection = m_MapCtrl.Map.FeatureSelection; // m_MapCtrl = ((AxMapControl)pmapcontrol).Object as IMapControl2; if (m_SceneCtrl == null) { m_SceneCtrl = ((AxSceneControl)psecontrol).Object as ISceneControl; } }
public Select(ISceneControl CurrentSceneControl) { InitializeComponent(); this.pSceneControl = CurrentSceneControl; //设置comboBoxMethod的选择项,并设置默认值为第一项 comBoxMethod.Items.Add("新建选择集"); comBoxMethod.Items.Add("添加进已有的选择集"); comBoxMethod.Items.Add("从当前选择集中清除"); comBoxMethod.Items.Add("从当前选择集中再次筛选"); comBoxMethod.SelectedIndex = 0; //最初时获取唯一值框不可使用 }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { if (m_sceneHookHelper == null) { return; } ISceneControl pSceneControl = m_sceneHookHelper.Hook as ISceneControl; frmCuttfillAnalyse pfrmCuttofillAnalyse = new frmCuttfillAnalyse(); pfrmCuttofillAnalyse.WriteLog = this.WriteLog; pfrmCuttofillAnalyse.CurrentSceneControl = m_sceneHookHelper.Hook as ISceneControl; pfrmCuttofillAnalyse.initialization(); pfrmCuttofillAnalyse.ShowDialog(); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { if (m_sceneHookHelper == null) { return; } ISceneControl pSceneControl = m_sceneHookHelper.Hook as ISceneControl; frm3DVolumeAreaSta pfrm3DVolumeAreaSta = new frm3DVolumeAreaSta(); pfrm3DVolumeAreaSta.WriteLog = this.WriteLog; pfrm3DVolumeAreaSta.CurrentSceneControl = m_sceneHookHelper.Hook as ISceneControl; pfrm3DVolumeAreaSta.initialization(); pfrm3DVolumeAreaSta.Show(); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add CmdExportScene.OnClick implementation ISceneControl pSceneCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as ISceneControl; SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "VRML files (*.wrl)|*.wrl"; if (dlg.ShowDialog() == DialogResult.OK) { ISceneExporter3d pSE = new VRMLExporter(); pSE.ExportFileName = dlg.FileName; pSE.ExportScene(pSceneCtr.Scene); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { if (m_sceneHookHelper == null) { return; } ISceneControl pSceneControl = m_sceneHookHelper.Hook as ISceneControl; frm3DSection pfrm3DSection = new frm3DSection(); pfrm3DSection.WriteLog = this.WriteLog; pfrm3DSection.CurrentSceneControl = m_sceneHookHelper.Hook as ISceneControl; pfrm3DSection.initialization(); pfrm3DSection.Show(); }
/// <summary> /// 加载用户的地图空间 /// </summary> /// <param name="sceneControl"></param> public void LoadUserWorkSpace(ISceneControl sceneControl) { if (sceneControl != null) { string userWorkSpacePath = GetUserWorkSpacePath(); if (!File.Exists(userWorkSpacePath)) { LoadDefaultWorkSpace(sceneControl); //创建一个新的地图文档实例 } else { sceneControl.LoadSxFile(userWorkSpacePath); } } }
/// <summary> /// 初始化的一些方法 /// </summary> public void Init(AxSceneControl axSceneControl) { if (axSceneControl != null) { try { this.m_axSceneControl = axSceneControl; m_sceneControl = axSceneControl.Object as ISceneControl; m_SceneGraph = m_sceneControl.SceneGraph; m_Scene = m_sceneControl.Scene; m_SceneViewer = m_SceneGraph.ActiveViewer; m_Camera = m_sceneControl.Camera; } catch (Exception e) { } } }
/// <summary> /// Occurs when this tool is clicked /// </summary> public override void OnClick() { // TODO: Add ToolEditFeatures.OnClick implementation ISceneControl pSceneCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as ISceneControl; IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; // FrmEdit3DFeatures FrmEditFeatures = new FrmEdit3DFeatures(); if (FrmEditFeatures == null) { FrmEditFeatures = new FrmEdit3DFeatures(); } if (FrmEditFeatures.IsDisposed == true) { FrmEditFeatures = new FrmEdit3DFeatures(); } FrmEditFeatures.psecontrol = ((ArrayList)m_controls)[1]; FrmEditFeatures.pmapcontrol = ((ArrayList)m_controls)[0]; FrmEditFeatures.pTinLayer = pTinLayer; FrmEditFeatures.m_SceneCtrl = pSceneCtr; FrmEditFeatures.m_MapCtrl = pMapCtr; FrmEditFeatures.Show(); FrmEditFeatures.Owner = System.Windows.Forms.Form.FromHandle(User32API.GetCurrentWindowHandle()) as System.Windows.Forms.Form; }
public FrmExportActiveViewFig(ISceneControl scenecontrol) { InitializeComponent(); pSceneControl = scenecontrol; FrmIndex = 2; }
/// <summary> /// 通过鼠标点击获取观察点与被观察点同时进行两点间通视分析 /// </summary> /// <param name="Button"></param> /// <param name="Shift"></param> /// <param name="X"></param> /// <param name="Y"></param> public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (m_frm3DLineOfSight.m_Layer == null || m_frm3DLineOfSight.m_Surface == null) { MessageBox.Show("请设置有效的表面数据", "提示!"); return; } if (m_frm3DLineOfSight.txtObsOffset.Text == "" || m_frm3DLineOfSight.txtTarOffset.Text == "") { MessageBox.Show("观察点高度和被观察点高度不能为空", "提示!"); return; } m_frm3DLineOfSight.TopMost = true; ISceneGraph pSceneGraph = m_sceneHookHelper.SceneGraph; m_pNewLineFeedback = new NewLineFeedbackClass(); IPolyline pPolyline = m_pNewLineFeedback.Stop(); //用于判断是否已经获取两点 ISceneControl pSceneControl = m_sceneHookHelper.Hook as ISceneControl; Cls3DModulsefun pCls3DModulsefun = new Cls3DModulsefun(); //用于绘制通视分析结果的方法 object pOwner; object pObject; ESRI.ArcGIS.Geometry.IPoint pPoint = new ESRI.ArcGIS.Geometry.PointClass(); pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out pPoint, out pOwner, out pObject);//获取鼠标点击的位置并转化为地理坐标 if (pPoint == null) { return; } ESRI.ArcGIS.Geometry.IPoint pFlashPoint = new ESRI.ArcGIS.Geometry.PointClass(); IClone pClone = pPoint as IClone; pFlashPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; pFlashPoint.Z = pFlashPoint.Z / pSceneGraph.VerticalExaggeration; pFlashPoint.SpatialReference = pSceneGraph.Scene.SpatialReference; IDisplay3D pDisplay = pSceneGraph as IDisplay3D; pDisplay.FlashLocation(pFlashPoint);//闪烁显示被点击的位置 IGeometry pGeometry = null; if (m_pScenePoints == null) { m_pScenePoints = new PolylineClass(); pGeometry = m_pScenePoints as IGeometry; pGeometry.SpatialReference = pSceneGraph.Scene.SpatialReference; } object before = Type.Missing; object after = Type.Missing; m_pScenePoints.AddPoint(pPoint, ref before, ref after);//添加获取的点到点集合中 if (m_pScenePoints.PointCount == 2) { pClone = m_pScenePoints as IClone; pPolyline = pClone.Clone() as ESRI.ArcGIS.Geometry.IPolyline;//当点集合中点数达到两个时生成一条线用于判断观察点与被观察点是否确定 m_pScenePoints = null; } if (pPolyline != null) { m_pScenePoints = null; ISurface pSurface = m_SurFace; ESRI.ArcGIS.Geometry.IPoint fPoint = pPolyline.FromPoint; //获取观察点 fPoint.Z = pSurface.GetElevation(fPoint); //获取观察点的高程 ESRI.ArcGIS.Geometry.IPoint tPoint = pPolyline.ToPoint; tPoint.Z = pSurface.GetElevation(tPoint); if (pSurface.IsVoidZ(fPoint.Z) || pSurface.IsVoidZ(tPoint.Z)) { return; } fPoint.Z = fPoint.Z + Convert.ToDouble(m_frm3DLineOfSight.txtObsOffset.Text);//观察者的高度加上观察者所在的高程才是观察点实际的高程 tPoint.Z = tPoint.Z + Convert.ToDouble(m_frm3DLineOfSight.txtTarOffset.Text); ESRI.ArcGIS.Geometry.IPoint pObstruct; IPolyline pVisPolyline; IPolyline pInVisPolyline; bool bIsVis; object pRefractionFactor = Type.Missing; //进行两点间的通视分析 pSurface.GetLineOfSight(fPoint, tPoint, out pObstruct, out pVisPolyline, out pInVisPolyline, out bIsVis, m_frm3DLineOfSight.checkBoxCurv.Checked, m_frm3DLineOfSight.checkBoxCurv.Checked, ref pRefractionFactor); ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Width = 2; pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; //绘制可视与不可视的沿地表线要素 if (pVisPolyline != null) { pSimpleLineSymbol.Color = Cls3DMarkDraw.getRGB(0, 255, 0); pCls3DModulsefun.AddGraphic(pSceneControl, pVisPolyline as IGeometry, pSimpleLineSymbol as ISymbol); } if (pInVisPolyline != null) { pSimpleLineSymbol.Color = Cls3DMarkDraw.getRGB(255, 0, 0); pCls3DModulsefun.AddGraphic(pSceneControl, pInVisPolyline as IGeometry, pSimpleLineSymbol as ISymbol); } IGeometryCollection pVisPatch = new MultiPatchClass();//用于存储可视域的要素 pGeometry = pVisPatch as IGeometry; pGeometry.SpatialReference = pSceneGraph.Scene.SpatialReference; double dTargetHeightForVis = 0; ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); IGeometryCollection pInVisPatch = new MultiPatchClass();//存储不可视域的要素 pGeometry = pInVisPatch as IGeometry; pGeometry.SpatialReference = pSceneGraph.Scene.SpatialReference; IGeometryCollection pPathGeo = pInVisPolyline as IGeometryCollection; if (pPathGeo != null) { //下面的作用是将不可视域线每段path生成线要素进行绘制 张琪 20110623 for (int i = 0; i < pPathGeo.GeometryCount; i++) { IGeometryCollection pInPolyline = new PolylineClass(); IPath path = pPathGeo.get_Geometry(i) as IPath; pInPolyline.AddGeometry(path as IGeometry, ref before, ref after); pCls3DModulsefun.CreateVerticalLOSPatches(bIsVis, fPoint, tPoint, pVisPolyline, pInPolyline as IPolyline, pVisPatch, pInVisPatch, dTargetHeightForVis); } } else//当不可视域为空时,直接分析生成可视域与不可视域 { pCls3DModulsefun.CreateVerticalLOSPatches(bIsVis, fPoint, tPoint, pVisPolyline, pInVisPolyline, pVisPatch, pInVisPatch, dTargetHeightForVis); } // // 对可视域与不可视域要素在场景中绘制出来 if (pInVisPatch != null) { pSimpleFillSymbol.Color = Cls3DMarkDraw.getRGB(255, 0, 0); pCls3DModulsefun.AddGraphic(pSceneControl, pInVisPatch as IGeometry, pSimpleFillSymbol as ISymbol); } if (pVisPatch != null) { pSimpleFillSymbol.Color = Cls3DMarkDraw.getRGB(0, 255, 0); pCls3DModulsefun.AddGraphic(pSceneControl, pVisPatch as IGeometry, pSimpleFillSymbol as ISymbol); } } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add ToolEditFeatures.OnMouseDown implementation try { ISceneControl pSceneCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as ISceneControl; if (pSceneCtr != null) { IPoint po; object owner, obj; pSceneCtr.SceneGraph.Locate(pSceneCtr.SceneViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out po, out owner, out obj);//po就是得到的点 //方法2 IHit3DSet pHit3dSet = null; pSceneCtr.SceneGraph.LocateMultiple(pSceneCtr.SceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out pHit3dSet); //po = pHit3D.Point;//po就是得到的点 //如果想得到某图层元素,可以看看下面代码 // int index = 2; if (pHit3dSet == null) { return; } pHit3dSet.OnePerLayer(); IHit3D pHit3D = (IHit3D)pHit3dSet.Hits.get_Element(0); IFeature pFeature = (IFeature)pHit3D.Object; if (pFeature == null) { return; } ILayer pLayer = owner as ILayer; if (pLayer == null) { return; } if (pLayer.Name != "Crater" && pLayer.Name != "NonCrater") { return; } IFeatureClass pFeatureClass = ((IFeatureLayer)pLayer).FeatureClass; pSceneCtr.Scene.ClearSelection(); pSceneCtr.Scene.SelectFeature(pLayer, pFeature); IActiveView pActiveView = pSceneCtr.Scene as IActiveView; pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null); IMultiPatch pMP = pFeature.Shape as IMultiPatch; FrmEditFeatures.setXLabel((pMP.Envelope.XMax + pMP.Envelope.XMin) / 2); FrmEditFeatures.setYLabel((pMP.Envelope.YMax + pMP.Envelope.YMin) / 2); } IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; if (pMapCtr != null) { IMap pMap = pMapCtr.Map; IPoint po = pMapCtr.ToMapPoint(X, Y); ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass(); pMap.SelectByShape(po, pSelectionEnv, true); //for (int i = 0; i < pMap.LayerCount; i++ ) //{ // ILayer pLayer = pMap.get_Layer(i); // if (pLayer.Name == "Crater") // { // pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null); // } // if (pLayer.Name =="NonCrater") // { // pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null); // } //} pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); IEnumFeatureSetup pSelectionsetup = pMap.FeatureSelection as IEnumFeatureSetup; pSelectionsetup.AllFields = true;//这里是关键 IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature; IFeature pF = pFeatureCollection.Next(); if (pF != null && pF.Shape is IMultiPatch) { IMultiPatch pMP = pF.Shape as IMultiPatch; FrmEditFeatures.setXLabel((pMP.Envelope.XMax + pMP.Envelope.XMin) / 2); FrmEditFeatures.setYLabel((pMP.Envelope.YMax + pMP.Envelope.YMin) / 2); } //ISelection pSelection =pMap.FeatureSelection; ////从Map.FeatureSelection获得ISelection不能读到Feature的其他属性, ////这是因为从axMapControl1.Map.FeatureSelection QI到IEnumFeature 时, ////ArcGIS中FeatureSelection默认的时候只存入Feature 的Shape,而不是整个Feature的字段数据。 ////如果要查看其他数据,必须要进行以下转换才可以: //IEnumFeatureSetup pSelectionsetup = pSelection as IEnumFeatureSetup; //pSelectionsetup.AllFields = true;//这里是关键 //IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature; //IFeature pF = pFeatureCollection.Next(); //if (pF != null) //{ // pF.Class //} } } catch (System.Exception ex) { } }