public static IGraphicCollection GraphicsFromXml(XElement root) { if (root.Name != "IS3Graphics") { return(null); } IGraphicCollection gc = IS3Runtime.GraphicEngine.NewGraphicCollection(); foreach (XElement node in root.Descendants()) { IGraphic g = GraphicFromXml(node); if (g != null) { gc.Add(g); } } if (gc.Count == 0) { return(null); } else { return(gc); } }
// Draw horizontal distributed load // Note: x1<x2, (x1,y1)-(x2,y1) is a horizontal line, (x1,y2)-(x2,y3) is a oblique line // public static IGraphicCollection DistributedLoad_Horizontal(double x1, double x2, double y1, double y2, double y3, ISymbol backgroundFillSymbol, ISymbol arrowFillSymbol, ISymbol lineSymbol) { IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); IMapPoint p1 = Runtime.geometryEngine.newMapPoint(x1, y1); IMapPoint p2 = Runtime.geometryEngine.newMapPoint(x1, y2); IMapPoint p3 = Runtime.geometryEngine.newMapPoint(x2, y3); IMapPoint p4 = Runtime.geometryEngine.newMapPoint(x2, y1); IGraphic g = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4); g.Symbol = backgroundFillSymbol; gc.Add(g); IPointCollection pc = Runtime.geometryEngine.newPointCollection(); pc.Add(p1); pc.Add(p2); pc.Add(p3); pc.Add(p4); pc.Add(p1); g = Runtime.graphicEngine.newPolyline(pc); g.Symbol = lineSymbol; gc.Add(g); double x00, y00, y01; for (int i = 0; i <= 10; ++i) { x00 = x1 + i * (x2 - x1) / 10.0; y00 = y1; y01 = y2 + i * (y3 - y2) / 10.0; IMapPoint p00 = Runtime.geometryEngine.newMapPoint(x00, y00); IMapPoint p01 = Runtime.geometryEngine.newMapPoint(x00, y01); g = Runtime.graphicEngine.newLine(p00, p01); g.Symbol = lineSymbol; gc.Add(g); pc = GeomUtil.VectorArrowPoints(x00, y2, p00); g = Runtime.graphicEngine.newPolygon(pc); g.Symbol = arrowFillSymbol; gc.Add(g); } return(gc); }
void test() { IPointCollection pc = Runtime.geometryEngine.newPointCollection(); IMapPoint p1 = Runtime.geometryEngine.newMapPoint(0, 0); IMapPoint p2 = Runtime.geometryEngine.newMapPoint(0, 100); IMapPoint p3 = Runtime.geometryEngine.newMapPoint(100, 0); pc.Add(p1); pc.Add(p2); pc.Add(p3); IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); IGraphic g1 = Runtime.graphicEngine.newLine(p1, p2); IGraphic g2 = Runtime.graphicEngine.newLine(p1, p3); gc.Add(g1); gc.Add(g2); IEnvelope env = GraphicsUtil.GetGraphicsEnvelope(gc); }
protected virtual void DefaultDrawingELayerToXml(XElement root) { IGraphicsLayer gLayer = DefaultDrawingELayer.GraphicsLayer; IGraphicCollection gc = IS3Runtime.GraphicEngine.NewGraphicCollection(); foreach (IGraphic g in gLayer.Graphics) { gc.Add(g); } XElement parent = new XElement("DefaultDrawingELayer"); XElement node = GraphicsSerializer.GraphicsToXml(gc); parent.Add(node); root.Add(parent); }
void StartAnalysis() { double max = double.Parse(TB_Max.Text); //获取输入的view和复制坐标系 IView view = InputCB.SelectedItem as IView; _spatialRef = view.spatialReference; //开始分析 foreach (string MonLayerID in _selectedMonsDict.Keys) { //获取衬砌选中列表 IEnumerable <DGObject> mons = _selectedMonsDict[MonLayerID]; List <DGObject> monList = mons.ToList(); IGraphicsLayer gLayer = _inputView.getLayer(MonLayerID); foreach (DGObject dg in monList) { //获取单个监测点对象,计算监测状况 MonPoint mp = dg as MonPoint; int grade = 0; foreach (string key in mp.readingsDict.Keys) { List <MonReading> mrList = mp.readingsDict[key]; foreach (MonReading mr in mrList) { if (Math.Abs(mr.value) > max) { grade = 1; break; } } if (grade == 1) { break; } } //根据评估等级获取图形样式 ISymbol symbol = GetSymbol(grade); //为了演示,采用了较复杂的方法 //<简便方法 可替换下面代码> //IGraphicCollection gcollection = gLayer.getGraphics(sl); //IGraphic g = gcollection[0]; //g.Symbol = symbol; //IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); //gc.Add(g); //_slsGraphics[sl.id] = gc; //</简便方法> //获取衬砌图形 IGraphicCollection gcollection = gLayer.getGraphics(dg); IGraphic g = gcollection[0]; IPolygon ip = g.Geometry as IPolygon; //获取端点 IPointCollection ipc = ip.GetPoints(); //导入的监测点不是点类型,是个圆所以要转换,如果是点,自己可以转换为IMapPoint double centerX = 0; double centerY = 0; foreach (IMapPoint point in ipc) { centerX += point.X; centerY += point.Y; } if (ipc.Count > 0) { centerX = centerX / ipc.Count; centerY = centerY / ipc.Count; } double offset = 2; //新建新的点,注意复制坐标系 IMapPoint p1 = Runtime.geometryEngine.newMapPoint(centerX - offset, centerY - offset, _spatialRef); IMapPoint p2 = Runtime.geometryEngine.newMapPoint(centerX - offset, centerY + offset, _spatialRef); IMapPoint p3 = Runtime.geometryEngine.newMapPoint(centerX + offset, centerY + offset, _spatialRef); IMapPoint p4 = Runtime.geometryEngine.newMapPoint(centerX + offset, centerY - offset, _spatialRef); ////生成新的图形 g = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4); g.Symbol = symbol; IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); gc.Add(g); _MonGraphics[dg.id] = gc; //保存结果 } } }
void StartAnalyzing() { //Get input view IView view = InputCB.SelectedItem as IView; _spatialRef = view.spatialReference; //create new layer view.removeLayer("Rectanglelayer"); //clear the previous layer string layerID = "Rectanglelayer"; IGraphicsLayer mlayer = Runtime.graphicEngine.newGraphicsLayer(layerID, layerID); var sym_fill = GraphicsUtil.GetDefaultFillSymbol(); var renderer = Runtime.graphicEngine.newSimpleRenderer(sym_fill); mlayer.setRenderer(renderer); mlayer.Opacity = 1.0; view.addLayer(mlayer); //Define local variables IGraphic m; int count = 0; int result = 5; double monpointX; double monpointY; _monpoints = _prj.getSelectedObjs(_monitoringDomain, "MonPoint"); foreach (DGObject mp in _mps) { MonPoint _mp = mp as MonPoint; foreach (string key in _mp.readingsDict.Keys) { List <MonReading> a = _mp.readingsDict[key]; foreach (MonReading b in a) { if (System.Math.Abs(b.value) > mptb) { count++; } } if (count <= 50) { result = 5; } else if (count <= 150) { result = 4; } else if (count <= 250) { result = 3; } else if (count <= 350) { result = 2; } else { result = 1; } ISymbol symbol = GetSymbol(result); //Obtain borehole coordinates IGraphicsLayer mplayer = view.getLayer("MonPoint"); IGraphicCollection mpcollection = mplayer.getGraphics(_mp); m = mpcollection[0]; IGeometry mpgeometry = m.Geometry; IMapPoint mpmappoint = mpgeometry as IMapPoint; monpointX = mpmappoint.X; monpointY = mpmappoint.Y; //Draw rectangle IMapPoint p1 = Runtime.geometryEngine.newMapPoint(monpointX + 2200, monpointY + 2200, _spatialRef); IMapPoint p2 = Runtime.geometryEngine.newMapPoint(monpointX + 2200, monpointY - 2200, _spatialRef); IMapPoint p3 = Runtime.geometryEngine.newMapPoint(monpointX - 2200, monpointY - 2200, _spatialRef); IMapPoint p4 = Runtime.geometryEngine.newMapPoint(monpointX - 2200, monpointY + 2200, _spatialRef); m = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4); m.Symbol = symbol; IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); gc.Add(m); mlayer.addGraphics(gc); } } }
void StartAnalysis() { //获取输入的view和复制坐标系 IView view = InputCB.SelectedItem as IView; _spatialRef = view.spatialReference; //开始分析 foreach (string SLLayerID in _selectedSLsDict.Keys) { //获取衬砌选中列表 IEnumerable <DGObject> sls = _selectedSLsDict[SLLayerID]; List <DGObject> slList = sls.ToList(); IGraphicsLayer gLayer = _inputView.getLayer(SLLayerID); foreach (DGObject dg in slList) { //获取单个衬砌对象,计算评估等级 SegmentLining sl = dg as SegmentLining; SLConvergenceRecordType slConvergenceRecordType = sl.ConstructionRecord.SLConvergenceRecords; if (slConvergenceRecordType.SLConvergenceItems.Count == 0) { continue; } SLConvergenceItem slConvergenceItem = slConvergenceRecordType.SLConvergenceItems[0]; if (slConvergenceItem.HorizontalDev == double.NaN) { continue; } double raduis = (double)slConvergenceItem.HorizontalRad; double deviation = (double)slConvergenceItem.HorizontalDev; double ratio = deviation / (raduis - deviation) * 1000; int grade; if (ratio <= 3) { grade = 5; } else if (ratio <= 5) { grade = 4; } else if (ratio <= 8) { grade = 3; } else if (ratio <= 10) { grade = 2; } else { grade = 1; } //根据评估等级获取图形样式 ISymbol symbol = GetSymbol(grade); //为了演示,采用了较复杂的方法 //<简便方法 可替换下面代码> //IGraphicCollection gcollection = gLayer.getGraphics(sl); //IGraphic g = gcollection[0]; //g.Symbol = symbol; //IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); //gc.Add(g); //_slsGraphics[sl.id] = gc; //</简便方法> //获取衬砌图形 IGraphicCollection gcollection = gLayer.getGraphics(sl); IGraphic g = gcollection[0]; IPolygon polygon = g.Geometry as IPolygon; IPointCollection pointCollection = polygon.GetPoints(); //获取端点 //衬砌为长方形,故有四个点 IMapPoint p1_temp = pointCollection[0]; IMapPoint p2_temp = pointCollection[1]; IMapPoint p3_temp = pointCollection[2]; IMapPoint p4_temp = pointCollection[3]; //新建新的点,注意复制坐标系 IMapPoint p1 = Runtime.geometryEngine.newMapPoint(p1_temp.X, p1_temp.Y, _spatialRef); IMapPoint p2 = Runtime.geometryEngine.newMapPoint(p2_temp.X, p2_temp.Y, _spatialRef); IMapPoint p3 = Runtime.geometryEngine.newMapPoint(p3_temp.X, p3_temp.Y, _spatialRef); IMapPoint p4 = Runtime.geometryEngine.newMapPoint(p4_temp.X, p4_temp.Y, _spatialRef); //生成新的图形 g = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4); g.Symbol = symbol; IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); gc.Add(g); _slsGraphics[sl.id] = gc; //保存结果 } } }
private void DrawValueTable(double x, double z, double r, double max, double min, IGraphicCollection resultGraphic) { double n = (max - min) / 9.0; double dis = 3 * r / 9.0; double x_start = x - 1.5 * r; double y_start = z - 1.3 * r; IGraphic c = Runtime.graphicEngine.newGraphic(); c = ShapeMappingUtility.NewCircle(x, z, r, _spatialRef); c.Symbol = _whitefillSymbol; resultGraphic.Add(c); for (int i = 1; i < 10; i++) { double value = min + n * i; double left = x_start + dis * (i - 1); double bottom = y_start; double right = x_start + dis * i; double top = y_start + 0.07 * r; IGraphic g; ISimpleLineSymbol outline = Runtime.graphicEngine.newSimpleLineSymbol( Colors.White, Core.Graphics.SimpleLineStyle.Solid, 1.0); ISimpleFillSymbol fillSymbol = Runtime.graphicEngine.newSimpleFillSymbol( GradeColor.GetFEMColor(max, min, value), SimpleFillStyle.Solid, outline); g = ShapeMappingUtility.NewRectangle(left, top, right, bottom, _spatialRef); g.Symbol = fillSymbol; resultGraphic.Add(g); } double middle = (max + min) / 2.0; IGraphic text; text = Runtime.graphicEngine.newText(string.Format("{0:0.00}", min), Runtime.geometryEngine.newMapPoint(x - 1.5 * r, z - 1.24 * r, _spatialRef), Colors.White, "Arial", 12); resultGraphic.Add(text); text = Runtime.graphicEngine.newText(string.Format("{0:0.00}", middle), Runtime.geometryEngine.newMapPoint(x - 0.1 * r, z - 1.24 * r, _spatialRef), Colors.White, "Arial", 12); resultGraphic.Add(text); text = Runtime.graphicEngine.newText(string.Format("{0:0.00}", max), Runtime.geometryEngine.newMapPoint(x + 1.2 * r, z - 1.24 * r, _spatialRef), Colors.White, "Arial", 12); resultGraphic.Add(text); }
private void DrawForce(double x, double z, double r, int num, int n, double value, double max, double min, IGraphicCollection resultGraphic) { double m; double pi = 3.14159; if (Math.Abs(max) > Math.Abs(min)) m = Math.Abs(max); else m = Math.Abs(min); IGraphic g; double x1 = x - Math.Sin(2 * pi * (n - 1) / num) * r; double y1 = z + Math.Cos(2 * pi * (n - 1) / num) * r; double x2 = x - Math.Sin(2 * pi * n / num) * r; double y2 = z + Math.Cos(2 * pi * n / num) * r; double x3 = x - Math.Sin(2 * pi * n / num) * (r + 0.25 * r * value / m); double y3 = z + Math.Cos(2 * pi * n / num) * (r + 0.25 * r * value / m); double x4 = x - Math.Sin(2 * pi * (n - 1) / num) * (r + 0.25 * r * value / m); double y4 = z + Math.Cos(2 * pi * (n - 1) / num) * (r + 0.25 * r * value / m); IMapPoint p1 = Runtime.geometryEngine.newMapPoint(x1, y1, _spatialRef); IMapPoint p2 = Runtime.geometryEngine.newMapPoint(x2, y2, _spatialRef); IMapPoint p3 = Runtime.geometryEngine.newMapPoint(x3, y3, _spatialRef); IMapPoint p4 = Runtime.geometryEngine.newMapPoint(x4, y4, _spatialRef); g = ShapeMappingUtility.NewLine(p1, p2); g.Symbol = _lineSymbol; resultGraphic.Add(g); ISimpleLineSymbol outline = Runtime.graphicEngine.newSimpleLineSymbol( Color.FromArgb(255, 255, 255, 255), Core.Graphics.SimpleLineStyle.Solid, 1.0); ISimpleFillSymbol fillSymbol = Runtime.graphicEngine.newSimpleFillSymbol( GradeColor.GetFEMColor(max, min, value), SimpleFillStyle.Solid, outline); g = ShapeMappingUtility.NewQuadrilateral(p1, p2, p3, p4); g.Symbol = fillSymbol; resultGraphic.Add(g); }
private void DrawDisplacement(double x, double z, double r, LoadStructure loadStructure, IGraphicCollection resultGraphic) { double max_x = 0; double max_z = 0; double pi = 3.13159; double m = 0; double num = loadStructure.Result.Count(); foreach (LoadStructure.NodeResult nr in loadStructure.Result) { if (Math.Abs(nr.x) > max_x) max_x = Math.Abs(nr.x); if (Math.Abs(nr.y) > max_z) max_z = Math.Abs(nr.y); } if (max_x > max_z) m = max_x; else m = max_z; IGraphic g; ISymbol lineSymbol = Runtime.graphicEngine.newSimpleLineSymbol(Colors.Transparent, SimpleLineStyle.Solid, 1.0); g = ShapeMappingUtility.NewCircle(x, z, r, _spatialRef); g.Symbol = lineSymbol; resultGraphic.Add(g); IPointCollection pc = Runtime.geometryEngine.newPointCollection(); foreach (LoadStructure.NodeResult nr in loadStructure.Result) { double x1 = x - Math.Sin(2 * pi * (nr.n - 1) / num) * r + nr.x * 0.1 * r / m; double y1 = z + Math.Cos(2 * pi * (nr.n - 1) / num) * r + nr.y * 0.1 * r / m; IMapPoint p1 = Runtime.geometryEngine.newMapPoint(x1, y1, _spatialRef); pc.Add(p1); } double xf = x - Math.Sin(2 * pi * (loadStructure.Result[0].n - 1) / num) * r + loadStructure.Result[0].x * 0.1 * r / m; double yf = z + Math.Cos(2 * pi * (loadStructure.Result[0].n - 1) / num) * r + loadStructure.Result[0].y * 0.1 * r / m; IMapPoint first = Runtime.geometryEngine.newMapPoint(xf, yf, _spatialRef); pc.Add(first); ISymbol lineSymbol2 = Runtime.graphicEngine.newSimpleLineSymbol(Colors.Blue, SimpleLineStyle.Solid, 1.0); g = ShapeMappingUtility.NewPolyline(pc); g.Symbol = lineSymbol2; resultGraphic.Add(g); IGraphic text; for (int i = 1; i < 5; i++) { int n = i * 90; LoadStructure.NodeResult nr = loadStructure.Result[n - 1]; double x1 = x - Math.Sin(2 * pi * (nr.n - 1) / num) * r; double y1 = z + Math.Cos(2 * pi * (nr.n - 1) / num) * r; IMapPoint p = Runtime.geometryEngine.newMapPoint(x1, y1, _spatialRef); text = Runtime.graphicEngine.newText(string.Format("x:{0:0.00000000},y:{1:0.00000000}", nr.x, nr.y), p, Colors.Red, "Arial", 12); resultGraphic.Add(text); } }
void DrawAxisMileage(TunnelAxis axis, IGraphicCollection gc, int interval) { int count = axis.AxisPoints.Count; double start = axis.AxisPoints[0].Mileage; double end = axis.AxisPoints[count - 1].Mileage; double len = end - start; int num = (int)len / interval; num += 3; // add begin, end points, and a truncated interval for (int i = 0; i < num; ++i) { double m = start + i * interval; m = ((int)m / interval) * interval; if (m < start) m = start; if (m > end) m = end; int m1 = (int)m / 1000; int m2 = (int)m % 1000; string strK = "K" + m1.ToString() + "+" + m2.ToString(); TunnelAxisPoint axisPt = TunnelMappingUtility.MileageToAxisPoint(m, axis); IMapPoint p = Runtime.geometryEngine.newMapPoint(axisPt.X + 3, axisPt.Y + 3, _spatialRef); IGraphic g = Runtime.graphicEngine.newText(strK, p, Colors.Red, "Arial", 10.0); gc.Add(g); IPointCollection pc = TunnelMappingUtility.ComputeTunnelCrossLine(m, _settings.tickLen, _settings.tickLen, axis, _spatialRef); g = Runtime.graphicEngine.newPolyline(pc); g.Symbol = _symbol; gc.Add(g); } }