/// <summary> /// 构造函数 /// </summary> /// <param name="_graphcisLayer">图层</param> /// <param name="modelKml">模型kml</param> public Model3d_ArcGlobe(IGlobeGraphicsLayer _graphicLayer, KmlModel3d modelKml, IImport3DFile import3Dfile) { graphicLayer = _graphicLayer; this.ElementType = ElementTypeEnum.Model3D; // 图元类型 this.Description = modelKml.Description; // 图元描述 #region 符号 IGeometry geometry = import3Dfile.Geometry; //将模型转为3D符号 marker3DSymbol = new Marker3DSymbolClass(); marker3DSymbol.Shape = geometry; markerSymbol = marker3DSymbol as IMarkerSymbol; markerSymbol.Size = modelKml.Scale; markerSymbol.Angle = modelKml.Azimuth; IRgbColor c = new RgbColorClass(); c.Transparency = modelKml.Color.A; c.Red = modelKml.Color.R; c.Green = modelKml.Color.G; c.Blue = modelKml.Color.B; markerSymbol.Color = c; this.scale = modelKml.Scale; this.color = modelKml.Color; #endregion #region 位置 IPoint p = new PointClass(); p.PutCoords(modelKml.Position.Lng, modelKml.Position.Lat); p.Z = modelKml.Position.Alt; (p as IZAware).ZAware = true; #endregion lngLat = modelKml.Position; base.Geometry = p; //指定位置 base.Symbol = markerSymbol; //指定符号 flashTimer = new Timer(); flashTimer.Elapsed += new ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 500; }
//添加GLISTBOX项 private void addListBoxItem(ISymbol symbol) { IStyleGallery styleGallery; IStyleGalleryItem styleGalleryItem; IStyleGalleryStorage styleGalleryStorge; styleGalleryItem = new ServerStyleGalleryItemClass(); styleGalleryItem.Name = this.txtSymbolName.Text; styleGalleryItem.Category = "default"; object objSymbol = symbol; styleGalleryItem.Item = objSymbol; styleGallery = new ServerStyleGalleryClass(); styleGalleryStorge = styleGallery as IStyleGalleryStorage; styleGalleryStorge.TargetFile = fileName; ISymbologyStyleClass pSymbolClass = psymbologyStyleClass; pSymbolClass.AddItem(styleGalleryItem, 0); pSymbolClass.SelectItem(0); Image image = null; if (symbol is IMarker3DSymbol) { IMarker3DSymbol mar3dsym = symbol as IMarker3DSymbol; stdole.IPicture pic = mar3dsym.Thumbnail; image = Image.FromHbitmap(new System.IntPtr(pic.Handle)); } else { stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(styleGalleryItem, 140, 15); image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle)); } GridPanel panel = supergrid.PrimaryGrid; GridRow row = new GridRow(image); panel.Rows.Add(row); psymbologyStyleClass.RemoveItem(0); imagelist.Add(image); Symbollist.Add(symbol); }
private void RotateGeometry(IMarker3DSymbol pSymbol, IVector3D pAxis, double dDegree) { if ((pAxis != null) && (dDegree != 0.0)) { IMarker3DPlacement placement = pSymbol as IMarker3DPlacement; IGeometry shape = placement.Shape; IEnvelope envelope = shape.Envelope; IPoint point = new PointClass { X = envelope.XMin + (envelope.XMax - envelope.XMin), Y = envelope.YMin + (envelope.YMax - envelope.YMin), Z = envelope.ZMin + (envelope.ZMax - envelope.ZMin) }; double rotationAngle = this.DegreesToRadians(dDegree); ITransform3D transformd = shape as ITransform3D; transformd.Move3D(-point.X, -point.Y, -point.Z); transformd.RotateVector3D(pAxis, rotationAngle); transformd.Move3D(point.X, point.Y, point.Z); } }
/// <summary> /// 释放 /// </summary> public void Dispose() { if (flashTimer != null) { flashTimer.Stop(); flashTimer.Dispose(); flashTimer = null; } layer = null; mapControl = null; marker3DSymbol = null; markerSymbol = null; index = -1; isTimer = false; isFlash = false; isVisible = true; isHightLight = false; graphicLayer = null; }
private void ReAngleElements(IElement element2D, IElement element3D, double newAngle) { if (element2D != null) { IMarkerElement markerElement; markerElement = element2D as IMarkerElement; IPictureMarkerSymbol pictureMarkerSymbol = (IPictureMarkerSymbol)markerElement.Symbol; pictureMarkerSymbol.Angle = newAngle; markerElement.Symbol = pictureMarkerSymbol; } if (element3D != null) { IMarkerElement markerElement; markerElement = element3D as IMarkerElement; IMarker3DSymbol pMarker3DSymbol = (IMarker3DSymbol)markerElement.Symbol; IMarker3DPlacement pM3DP = (IMarker3DPlacement)pMarker3DSymbol; pM3DP.Angle = newAngle; markerElement.Symbol = (ESRI.ArcGIS.Display.IMarkerSymbol)pMarker3DSymbol; } }
private void btnadd_Click(object sender, EventArgs e) { if (superTabControl1.SelectedTabIndex == 0) { esriSimpleMarkerStyle style = new esriSimpleMarkerStyle(); if (cbSimpleStyle.SelectedIndex == 0) { style = esriSimpleMarkerStyle.esriSMSCircle; } else if (cbSimpleStyle.SelectedIndex == 1) { style = esriSimpleMarkerStyle.esriSMSSquare; } else if (cbSimpleStyle.SelectedIndex == 2) { style = esriSimpleMarkerStyle.esriSMSCross; } else if (cbSimpleStyle.SelectedIndex == 3) { style = esriSimpleMarkerStyle.esriSMSX; } else { style = esriSimpleMarkerStyle.esriSMSDiamond; } if (superTabControl1.SelectedTabIndex == 0) { if (checkBoxX1.Checked == true) { ISimpleMarkerSymbol pSimMarSymbol = creatsimpoint(colorsimple.SelectedColor, style, sizesimple.Value, anglesimple.Value, xsimoffset.Value, ysimoffset.Value, outcolor.SelectedColor, outsize.Value); addListBoxItem(pSimMarSymbol as ISymbol); } else { ISimpleMarkerSymbol pSimMarSymbol = creatsimpoint(colorsimple.SelectedColor, style, sizesimple.Value, anglesimple.Value, xsimoffset.Value, ysimoffset.Value, Color.Empty, 0); addListBoxItem(pSimMarSymbol as ISymbol); } } } else if (superTabControl1.SelectedTabIndex == 1) { if (picfilename == "") { MessageBox.Show("请先选择图片", "提示", MessageBoxButtons.OK); } else { IPictureMarkerSymbol pPicMarSymbol = creatpicpoint(sizepicture.Value, xpicoffset.Value, ypicoffset.Value, anglepicture.Value, backcolorpic.SelectedColor, picfilename); addListBoxItem(pPicMarSymbol as ISymbol); } } else if (superTabControl1.SelectedTabIndex == 2) { IArrowMarkerSymbol pArrMarPoint = creatarrowpoint(colorarrow.SelectedColor, lengtharrow.Value, widtharrow.Value, anglearrow.Value, xarroffset.Value, yarroffset.Value); addListBoxItem(pArrMarPoint as ISymbol); } else if (superTabControl1.SelectedTabIndex == 3) { if (filename3D == "") { MessageBox.Show("请先选择模型", "提示", MessageBoxButtons.OK); } else { IMarker3DSymbol p3DMarSymbol = creat3dmarkerpoint(isuse3d, filename3D); addListBoxItem(p3DMarSymbol as ISymbol); } } RePainPictureBox(Radio); }