//初始化控件当新建工程或者打开工程时 void generateSVGfilemapByConfigxml() { //注意偏移量,偏移主要是为了好看 如果不偏移的话 就会绘到角落上,这时的偏移是整个偏移 后面的不用偏移了,相对偏移0,0 int idx = 50; int idy = 50; cSVGDocLayerMap svgLayerMap = new cSVGDocLayerMap(PageWidth, PageHeight, idx, idy, sUnit); //add title string sTitle = Path.GetFileNameWithoutExtension(filePathLayerCss); svgLayerMap.addMapTitle(sTitle, 50, 20); XmlElement returnElemment; //svg文件和XML对应的问题还要思考一下 string filePathSVGLayerMap = Path.Combine(cProjectManager.dirPathTemp, Path.GetFileNameWithoutExtension(filePathLayerCss) + ".svg"); //这块需要处理覆盖问题。 if (File.Exists(filePathSVGLayerMap)) { File.Delete(filePathSVGLayerMap); } //如果顶层面断层数据不为空的话 应该加上断层 //读取当前顶层的断层数据 //List<ItemFaultLine> listFaultLine = cIOinputLayerSerier.readInputFaultFile(this.sSelectLayer); //foreach (ItemFaultLine line in listFaultLine) //{ // returnElemment = svgLayerMap.gFaultline(line.ltPoints, "red", 2); // svgLayerMap.addgElement2BaseLayer(returnElemment); //} //解析当前的XML配置文件,根据每个Layer标签的LayerType生成id为层名的图层,添加到svgLayer中去 XmlDocument xmlLayerMap = new XmlDocument(); xmlLayerMap.Load(filePathLayerCss); //XmlNode xnBaseLayer = xmlLayerMap.SelectSingleNode("/LayerMapConfig/BaseLayer"); //returnElemment = svgLayerMap.gWellsPositionFromXML(xnBaseLayer,"井"); //svgLayerMap.addgElement2BaseLayer(returnElemment); XmlNodeList xnList = xmlLayerMap.SelectNodes("/LayerMapConfig/Layer"); //或许Layer标签的节点 foreach (XmlNode xn in xnList) { string sID = xn.Attributes["id"].Value; //建立新层 XmlElement gXMLLayer = svgLayerMap.gLayerElement(sID); svgLayerMap.addgLayer(gXMLLayer, 0, 0); ////井位图层 //if (xn.Attributes["LayerType"].Value ==TypeLayer.LayerPosition.ToString()) // returnElemment = svgLayerMap.gWellsPositionFromXML(xn,sID); //地质熟悉数据图层 if (xn.Attributes["LayerType"].Value == TypeLayer.LayerGeoProperty.ToString()) { returnElemment = svgLayerMap.gLayerWellsGeologyPropertyFromXML(xn, sID); } //水平井图层 if (xn.Attributes["LayerType"].Value == TypeLayer.LayerHorizonalInterval.ToString()) { returnElemment = svgLayerMap.gHorizonalWellIntervelFromXML(xn, sID); } ////日产 //if (xn.Attributes["LayerType"].Value == TypeLayer.LayerDailyProduct.ToString()) // returnElemment = svgLayerMap.gDailyProductFromXML(xn, sID, listWellsStatic, listLayersDataCurrentLayerDynamic); ////累产饼图图层 //if (xn.Attributes["LayerType"].Value == TypeLayer.LayerSumProduct.ToString()) // returnElemment = svgLayerMap.gSumProductFromXML(xn, sID, listWellsStatic, listLayersDataCurrentLayerDynamic); //井位柱状图图层 if (xn.Attributes["LayerType"].Value == TypeLayer.LayerBarGraph.ToString()) { returnElemment = svgLayerMap.gWellBarGraphFromXML(xn, sID, listWellsStatic); } ////井位饼图图层 //if (xn.Attributes["LayerType"].Value == TypeLayer.LayerPieGraph.ToString()) // returnElemment = cXMLLayerMapWellPieGraph.gWellPieGraphFromXML(xn, sID, listWellsStatic); //新层加内容 //svgLayerMap.addgElement2Layer(gXMLLayer, returnElemment); } //add voi //if (this.cbxVoi.Checked == true) //{ // XmlElement gVoronoiLayer = svgLayerMap.gLayerElement("voronoi"); // svgLayerMap.addgLayer(gVoronoiLayer, svgLayerMap.offsetX_gSVG,svgLayerMap.offsetY_gSVG); // List<itemWellLayerVoi> listVoi = cIOVoronoi.read2Struct(); // foreach (itemWellLayerVoi well in listVoi.FindAll(p => p.sXCM == sSelectLayer)) // { // returnElemment = svgLayerMap.gVoronoiPolygon(well.sJH, well.ltdpVertex, "red", 2); // svgLayerMap.addgElement2Layer(gVoronoiLayer, returnElemment); // } //} //add connect //if (this.cbxConnect.Checked == true) //{ // XmlElement gConnectLayer = svgLayerMap.gLayerElement("Connect"); // svgLayerMap.addgLayer(gConnectLayer,0,0); // List<ItemConnectInjPro> listConnect = cIODicInjProCon.read2Struct(sSelectYM , sSelectLayer); // foreach (ItemConnectInjPro connect in listConnect) // { // //需要定到层位 // ItemWellMapPosition wellInj = listWellsStatic.Find(p => p.sJH == connect.sJHinj); // ItemWellMapPosition wellPro = listWellsStatic.Find(p => p.sJH == connect.sJHpro); // PointD p1 = new PointD(wellInj.dbX, wellInj.dbY); // PointD p2 = new PointD(wellPro.dbX, wellPro.dbY); // returnElemment = svgLayerMap.gConnectLine(p1, p2, "blue", 2); // svgLayerMap.addgElement2Layer(gConnectLayer, returnElemment); // } //} XmlElement gLayerCompass = svgLayerMap.gLayerElement("指南针"); svgLayerMap.addgLayer(gLayerCompass, svgLayerMap.offsetX_gSVG, svgLayerMap.offsetY_gSVG); svgLayerMap.addgElement2Layer(gLayerCompass, svgLayerMap.gCompass(300, 100)); svgLayerMap.makeSVGfile(filePathSVGLayerMap); this.webBrowserSVG.Navigate(new Uri(filePathSVGLayerMap)); }
public static string generateLayerMap(string filePathLayerOperate, string sCurrentLayer) { //注意偏移量,偏移主要是为了好看 如果不偏移的话 就会绘到角落上,这时的偏移是整个偏移 后面的不用偏移了,相对偏移0,0 //svg文件和XML对应的问题还要思考一下 string dirPathLayer = Path.Combine(cProjectManager.dirPathLayerDir, sCurrentLayer); string filePathSVGLayerMap = Path.Combine(dirPathLayer, Path.GetFileNameWithoutExtension(filePathLayerOperate) + ".svg"); //这块需要处理覆盖问题。 if (File.Exists(filePathSVGLayerMap)) { File.Delete(filePathSVGLayerMap); } //解析当前的XML配置文件,根据每个Layer标签的LayerType生成id为层名的图层,添加到svgLayer中去 XmlDocument xmlLayerMap = new XmlDocument(); xmlLayerMap.Load(filePathLayerOperate); //获取基本的页面信息及基础配置文件信息 //获取井位List XmlNodeList xnWellDataList = xmlLayerMap.SelectNodes("/LayerMapConfig/DataDicStatic/data/item"); List <ItemWellMapPosition> listWellLayerMap = new List <ItemWellMapPosition>(); foreach (XmlNode xn in xnWellDataList) { ItemWellMapPosition item = ItemWellMapPosition.parseLine(xn.Attributes["LayerDataDicText"].Value); listWellLayerMap.Add(item); } //根据配置文件,读取页面基本配置信息 cXELayerPage curPage = new cXELayerPage(xmlLayerMap); int idx = 200; int idy = 200; int PageWidth = curPage.iPageWidth; int PageHeight = curPage.iPageHeight; string sUnit = "mm"; cSVGDocLayerMap svgLayerMap = new cSVGDocLayerMap(PageWidth, PageHeight, idx, idy, sUnit); //add title string sTitle = Path.GetFileNameWithoutExtension(filePathLayerOperate); svgLayerMap.addMapTitle(sTitle, PageWidth / 2, 20); XmlElement returnElemment; cXEWellCss wellCss = new cXEWellCss(xmlLayerMap); //从配置文件中 读取图层列表,根据配置绘制图层 XmlNode xnLayerList = xmlLayerMap.SelectSingleNode("/LayerMapConfig/LayerList"); //或许Layer标签的节点 foreach (XmlNode xn in xnLayerList.ChildNodes) { string sIDLayer = xn.Attributes["id"].Value; string sLayerType = xn.Attributes["layerType"].Value; string sLayerVisible = xn["visible"].InnerText; //建立新层 XmlElement gNewLayer = svgLayerMap.gLayerElement(sIDLayer); svgLayerMap.addgLayer(gNewLayer, idx, idy); #region 测井曲线图层 if (sLayerVisible == "1" && sLayerType == TypeLayer.LayerLog.ToString()) { LayerDataLog layerDataLog = new LayerDataLog(xn); foreach (ItemWellMapPosition itemWell in listWellLayerMap) { Point PViewWell = cCordinationTransform.transRealPointF2ViewPoint(itemWell.dbX, itemWell.dbY, curPage.xRef, curPage.yRef, curPage.dfscale); returnElemment = cXMLLayerMapWellLog.gLayerWellLog(svgLayerMap, itemWell, layerDataLog); //新层加内容 int xViewStart = PViewWell.X; int yViewStart = PViewWell.Y; //如果左值小于右值,就把曲线坐班绘制 if (layerDataLog.iLeftDraw == 1) { xViewStart = xViewStart - layerDataLog.iTrackWidth; } svgLayerMap.addgElement2Layer(gNewLayer, returnElemment, xViewStart, yViewStart); } } #endregion #region 小层SectionLayer图层。 if (sLayerVisible == "1" && sLayerType == TypeLayer.LayerSection.ToString()) { //建立新层 XmlElement gWellLayer = svgLayerMap.gLayerElement("LayerSection"); svgLayerMap.addgLayer(gWellLayer, 0, 0); for (int i = 0; i < listWellLayerMap.Count; i++) { string sCurJH = listWellLayerMap[i].sJH; string sCurXCM = listWellLayerMap[i].sXCM; string dirLayerJH = Path.Combine(cProjectManager.dirPathLayerDir, sCurXCM, sCurJH); string filePathSecitonTemplatOper = Path.Combine(dirLayerJH, sCurJH + "_" + sCurXCM + ".xml"); string filePathSecitonLayerSectionSVG = Path.Combine(dirLayerJH, sCurJH + "_" + sCurXCM + ".svg"); //斜井模式 double fVscaleLayerSection = 50; makeWellLayerSectionGraph(filePathSecitonTemplatOper, listWellLayerMap[i].dbTop, listWellLayerMap[i].dbBot, fVscaleLayerSection); Point PViewWell = cCordinationTransform.transRealPointF2ViewPoint(listWellLayerMap[i].dbX, listWellLayerMap[i].dbY, curPage.xRef, curPage.yRef, curPage.dfscale); //新层加内容 int xViewStart = PViewWell.X; int yViewStart = PViewWell.Y; //这块应该改成相对路径 string pathLayerSectionRelative = Path.Combine(sCurJH, sCurJH + "_" + sCurXCM + ".svg"); if (File.Exists(filePathSecitonLayerSectionSVG)) { svgLayerMap.addgSVG2Layer(gNewLayer, filePathSecitonLayerSectionSVG, xViewStart, yViewStart); } } } #endregion #region 断层图层。 if (sLayerVisible == "1" && sLayerType == TypeLayer.LayerFaultLine.ToString()) { XmlNode dataLine = xn.SelectSingleNode("dataList"); if (dataLine != null) { XmlNodeList dataItem = dataLine.SelectNodes("dataItem"); foreach (XmlNode faultItem in dataItem) { ItemFaultLine curItemdata = new ItemFaultLine(faultItem); List <Point> listPointView = new List <Point>(); foreach (PointD pd in curItemdata.ltPoints) { Point PViewWell = cCordinationTransform.transRealPointF2ViewPoint(pd.X, pd.Y, curPage.xRef, curPage.yRef, curPage.dfscale); listPointView.Add(PViewWell); } returnElemment = cXMLLayerMapStatic.gFault(svgLayerMap, curItemdata, listPointView); //新层加内容 svgLayerMap.addgElement2Layer(gNewLayer, returnElemment); } } } #endregion #region 井位图层。 if (sLayerVisible == "1" && sLayerType == TypeLayer.LayerWellPosition.ToString()) { XmlNode dataList = xn.SelectSingleNode("dataList"); if (dataList != null) { XmlNodeList dataItem = dataList.SelectNodes("dataItem"); foreach (XmlNode xnWell in dataItem) { ItemLayerWellPattern itemWell = new ItemLayerWellPattern(xnWell); Point PViewWell = cCordinationTransform.transRealPointF2ViewPoint(itemWell.X, itemWell.Y, curPage.xRef, curPage.yRef, curPage.dfscale); returnElemment = cXMLLayerMapStatic.gWellPattern(svgLayerMap, itemWell, 10, 5, 5, 5, 5); //新层加内容 svgLayerMap.addgElement2Layer(gNewLayer, returnElemment, PViewWell.X, PViewWell.Y); } } } #endregion #region 井位饼图图层 if (sLayerType == TypeLayer.LayerPieGraph.ToString()) { returnElemment = cXMLLayerMapWellPieGraph.gWellPieGraphFromXML(svgLayerMap.svgDoc, xn, sIDLayer, listWellLayerMap, curPage); //新层加内容 svgLayerMap.addgElement2Layer(gNewLayer, returnElemment); } #endregion //由于井位图是底图,造成被压在最下面一层。这个问题要解决一下。 returnElemment = cSVGLayerWellPosition.gWellsPosition(xmlLayerMap, listWellLayerMap, "井位", wellCss, curPage); svgLayerMap.addgElement2BaseLayer(returnElemment); #region 比例尺 if (curPage.iShowScaleRuler == 1) { XmlElement gLayerScaleRuler = svgLayerMap.gLayerElement("比例尺"); svgLayerMap.addgLayer(gLayerScaleRuler, svgLayerMap.offsetX_gSVG, svgLayerMap.offsetY_gSVG); returnElemment = svgLayerMap.gScaleRuler(0, 0, curPage.dfscale); svgLayerMap.addgElement2Layer(gLayerScaleRuler, returnElemment, 100, 100); } #endregion #region 页面网格及标志 if (curPage.iShowMapFrame == 1) { returnElemment = svgLayerMap.gMapFrame(curPage); svgLayerMap.addgElement2BaseLayer(returnElemment); } #endregion #region 指南针 if (curPage.iShowCompass == 1) { XmlElement gLayerCompass = svgLayerMap.gLayerElement("指南针"); svgLayerMap.addgLayer(gLayerCompass, svgLayerMap.offsetX_gSVG, svgLayerMap.offsetY_gSVG); svgLayerMap.addgElement2Layer(gLayerCompass, svgLayerMap.gCompass(300, 100)); } #endregion } //end of 所有图层的绘制 svgLayerMap.makeSVGfile(filePathSVGLayerMap); return(filePathSVGLayerMap); }