//private void displayProject(CRailwayProject item) //{ // double lat, lon, z, dir; // double cx, cy; // double[] cVerticesArray = null; // int count; // ITerrainPolyline66 polyline1; // //var cPos = sgworld.Creator.CreatePosition(item.CenterLongitude, item.CenterLatitude, 10, AltitudeTypeCode.ATC_TERRAIN_RELATIVE); // //sgworld.Creator.CreateLabel(cPos, item.ProjectName, CGisDataSettings.gDataPath + @"\Data\Textures\桥梁.png", cLabelStyle, mGroupIDStatic, item.ProjectName); // if (!CRailwayLineList.getGPSbyDKCode(item.mMidDKCode, item.CenterMileage, out lon, out lat, out z, out dir)) // { // Console.WriteLine(item.ProjectName + " 工点 坐标错误"); // return; // } // //item.getFXProgressByDate(mTEScene.toDate); // count = item.getDoneSubLine(out cVerticesArray); // polyline1 = sgworld.Creator.CreatePolylineFromArray(cVerticesArray, sgworld.Creator.CreateColor(0, 255, 0, 255), // AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mGroupIDDynamic, item.ProjectName + "Done"); // polyline1.Spline = true; // polyline1.Visibility.MaxVisibilityDistance = 10000000; // polyline1.Visibility.MinVisibilityDistance = 150; // polyline1.LineStyle.Width = -5; // count = item.getToDoSubLine(out cVerticesArray); // polyline1 = sgworld.Creator.CreatePolylineFromArray(cVerticesArray, sgworld.Creator.CreateColor(255, 255, 0, 255), // AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mGroupIDDynamic, item.ProjectName + "ToDo"); // polyline1.Spline = true; // polyline1.Visibility.MaxVisibilityDistance = 10000000; // polyline1.Visibility.MinVisibilityDistance = 150; // polyline1.LineStyle.Width = -5; // CoordinateConverter.LatLonOffest(lat, lon, dir, 90, 20, out cy, out cx); // var cPos2 = sgworld.Creator.CreatePosition(cx, cy, 15, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, -75, 0, 2000); // //sgworld.Creator.CreateCircle(cPos2, 140, sgworld.Creator.CreateColor(127, 127, 127, 127), sgworld.Creator.CreateColor(127, 127, 127, 127), mGroupIDStatic); // var ilabel = sgworld.Creator.CreateTextLabel(cPos2, item.ProjectName, CRWTEStandard.mLabelStyleL3, mGroupIDDynamic, "进度" + item.ProjectName); // //ilabel.Message = sgworld.Creator.CreateMessage(); // ilabel.ImageFileName = CGisDataSettings.gDataPath + @"Common\progress\Pie" + item.AvgProgress + ".png"; //} /// <summary> /// 添加桥梁、路基、隧道模型与标签,FIXME目前模型与工点表ProjectInof不一致(有些工点没有模型,有些工点应该对应多个模型),模型生成程序有一个单独的Excel表TEProj,不通过程序添加 /// </summary> /// <param name="groupID"></param> //private void createProjectLabel() //{ // if (string.IsNullOrEmpty(mGroupIDDynamic)) // mGroupIDDynamic = sgworld.ProjectTree.CreateGroup("Project"); // //List<CRailwayProject> ls = mSceneData.GetProjectOrderbyMileage(); // //foreach (CRailwayProject rp in ls) // //{ // // Console.WriteLine(rp.ToString()); // //} // foreach (CRailwayProject item in mSceneData.mBridgeList) // { // displayProject(item); // } // foreach (CRailwayProject item in mSceneData.mRoadList) // { // displayProject(item); // } // //foreach (CRailwayProject item in mSceneData.mTunnelList) // //{ // // displayProject(item); // //} // foreach (CRailwayProject item in mSceneData.mContBeamList) // { // displayProject(item); // } //} ///// <summary> ///// 用条带的方式,展示分项工程进度 ///// </summary> ///// <param name="rw"></param> ///// <param name="sgworld"></param> ///// <param name="branch"></param> ///// <param name="m"></param> //private void polylineMiddleLine(CRailwayProject rw, SGWorld66 sgworld, string branch, Dictionary<string, double> m) //{ // ITerrainPolyline66 polyline1; // ITerrainPolyline66 polyline2; // ITerrainPolyline66 polyline3; // ITerrainPolyline66 polyline4; // IColor66 lineColor1 = sgworld.Creator.CreateColor(242, 174, 17, 255); // IColor66 lineColor2 = sgworld.Creator.CreateColor(32, 183, 81, 255); // IColor66 lineColor3 = sgworld.Creator.CreateColor(183, 9, 9, 255); // IColor66 lineColor4 = sgworld.Creator.CreateColor(50, 50, 50, 255); // double[] x, y, z, dir; // int count = mSceneData.mMiddleLines.getSubLineByDKCode(rw.Mileage_Start_Discription, rw.Mileage_End_Discription, 10, out x, out y, out z, out dir); // double[] mArray1 = new double[count * 3]; // double[] mArray2 = new double[count * 3]; // double[] mArray3 = new double[count * 3]; // double[] mArray4 = new double[count * 3]; // for (int i = 0; i < count; i++) // { // mArray1[3 * i] = x[i]; // mArray1[3 * i + 1] = y[i]; // mArray1[3 * i + 2] = z[i] + 10; // mArray2[3 * i] = x[i]; // mArray2[3 * i + 1] = y[i]; // mArray2[3 * i + 2] = z[i] + 20; // mArray3[3 * i] = x[i]; // mArray3[3 * i + 1] = y[i]; // mArray3[3 * i + 2] = z[i] + 30; // mArray4[3 * i] = x[i]; // mArray4[3 * i + 1] = y[i]; // mArray4[3 * i + 2] = z[i] + 40; // } // if (m.Count >= 4) // { // KeyValuePair<string, double> kvp = m.ElementAt(0); // polyline1 = sgworld.Creator.CreatePolylineFromArray(mArray1, lineColor1, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, branch, rw.ProjectName + "-" + kvp.Key); // polyline1.Spline = true; // polyline1.Visibility.MaxVisibilityDistance = 10000000; // polyline1.Visibility.MinVisibilityDistance = 150; // polyline1.LineStyle.Width = 50.0; // polyline1.Visibility.Show = true; // polyline1.LineStyle.Color.SetAlpha(kvp.Value); // kvp = m.ElementAt(1); // polyline2 = sgworld.Creator.CreatePolylineFromArray(mArray2, lineColor2, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, branch, rw.ProjectName + "-" + kvp.Key); // polyline2.Spline = true; // polyline2.Visibility.MaxVisibilityDistance = 10000000; // polyline2.Visibility.MinVisibilityDistance = 150; // polyline2.LineStyle.Width = 30.0; // polyline2.Visibility.Show = true; // polyline2.LineStyle.Color.SetAlpha(kvp.Value); // kvp = m.ElementAt(2); // polyline3 = sgworld.Creator.CreatePolylineFromArray(mArray3, lineColor3, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, branch, rw.ProjectName + "-" + kvp.Key); // polyline3.Spline = true; // polyline3.Visibility.MaxVisibilityDistance = 10000000; // polyline3.Visibility.MinVisibilityDistance = 150; // polyline3.LineStyle.Width = 15.0; // polyline3.Visibility.Show = true; // polyline3.LineStyle.Color.SetAlpha(kvp.Value); // kvp = m.ElementAt(3); // polyline4 = sgworld.Creator.CreatePolylineFromArray(mArray4, lineColor4, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, branch, rw.ProjectName + "-" + kvp.Key); // polyline4.Spline = true; // polyline4.Visibility.MaxVisibilityDistance = 10000000; // polyline4.Visibility.MinVisibilityDistance = 150; // polyline4.LineStyle.Width = 5; // polyline4.Visibility.Show = true; // polyline4.LineStyle.Color.SetAlpha(kvp.Value); // } //} //private void createRibbon() //{ // var sgworld = new SGWorld66(); // if (string.IsNullOrEmpty(mGroupIDDynamic)) // mGroupIDDynamic = sgworld.ProjectTree.CreateGroup("ProjectProgress"); // foreach (CRailwayProject item in mSceneData.mBridgeList) // FIXME xyn // { // double[] p = new double[20]; // 工点分项进度,色带透明度 // String[] FXName = new String[20]; // 工点分项名字 // Dictionary<string, double> mFXProj = item.getFXProgressByDate(mTEScene.toDate); // polylineMiddleLine(item, sgworld, mGroupIDDynamic, mFXProj); // } //} /// <summary> /// 测试进度circle /// </summary> private void createCircle() { var sgworld = new SGWorld66(); if (string.IsNullOrEmpty(mGroupIDDynamic)) { mGroupIDDynamic = sgworld.ProjectTree.CreateGroup("ProjectProgress"); } ITerrainPolyline66 polyline; //ILabelStyle66 cLabelStyle = sgworld.Creator.CreateLabelStyle(SGLabelStyle.LS_DEFAULT); //{ // cLabelStyle.FontName = "Arial"; // Set font name to Arial // cLabelStyle.Italic = true; // Set label style font to italic // cLabelStyle.Scale = 3; // Set label style scale // cLabelStyle.TextOnImage = false; //} //CRailwayProject item = mSceneData.mProjectList[0]; foreach (CRailwayProject item in mSceneData.mBridgeList) // FIXME xyn { //if (item.mMileage_End - item.mMileage_Start > 15) //{ //item.getFXProgressByDate(mTEScene.toDate); //double[] cVerticesArray=null; //double latcen; //double loncen; double lat; double lon; double z; double dir; //int zone; //double x, y, xd, yd; double cx, cy; //double globalmeter; //bool isValue = mSceneData.mMiddleLines.getPosbyMeter(item.Mileage_Start_Ds, out lat, out lon, out z, out dir); //CoordinateConverter.LatLonOffest(lat, lon, z, 270, 300, out latcen, out loncen); //CoordinateConverter.LatLonToUTMXY(latcen, loncen, out x, out y, out zone); //int ccount = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(item.AvgProgress * 180.0))); if (!CRailwayLineList.getGPSbyDKCode(item.mMidDKCode, item.CenterMileage, out lon, out lat, out z, out dir)) { Console.WriteLine(item.ProjectName + " 工点 坐标错误"); continue; } CoordinateConverter.LatLonOffest(lat, lon, dir, 90, 20, out cy, out cx); //int angle = (int)(item.AvgProgress * 360); //int count = 0; //cVerticesArray = CTERWItem.TEDrawProgressCircle(cx, cy, z, 15, angle, out count); //try //{ // //sgworld.Creator.createpol // //polyline = sgworld.Creator.CreatePolygonFromArray(cVerticesArray, sgworld.Creator.CreateColor(255, 215, 0, 255), sgworld.Creator.CreateColor(255, 215, 0, 255), // //AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mTEID, item.ProjectName + "工点"); // //polyline.Visibility.MinVisibilityDistance = 1250; // //polyline.Spline = true; // //polyline.LineStyle.Width = -5; // polyline = sgworld.Creator.CreatePolylineFromArray(cVerticesArray, sgworld.Creator.CreateColor(255, 215, 0, 255), AltitudeTypeCode.ATC_TERRAIN_RELATIVE, mGroupIDDynamic, "工点" + item.ProjectName); // polyline.Visibility.MaxVisibilityDistance = 10000000; // polyline.FillStyle.Color = sgworld.Creator.CreateColor(255, 215, 0, 255); // polyline.LineStyle.Width = 130.0; // polyline.Visibility.Show = true; //} //catch (Exception ex) //{ // Console.WriteLine("Creation Failed" + item.ProjectName); //} var cPos = sgworld.Creator.CreatePosition(cx, cy, 10, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, -75, 0, 2000); var ilabel = sgworld.Creator.CreateTextLabel(cPos, item.AvgProgress + "%", CRWTEStandard.mLabelStyleL3, mGroupIDDynamic, "进度" + item.ProjectName); ilabel.ImageFileName = CGisDataSettings.gDataPath + @"Common\progress\Pie" + item.AvgProgress + ".png"; } }
/// <summary> /// /// </summary> /// <param name="g"></param> /// <param name="canvasWidth">画布宽度</param> /// <param name="centerMileage">中心里程</param> /// <param name="radiusMileage">里程半径</param> private void draw2DProjects(Graphics g, float canvasWidth, double centerMileage, double radiusMileage) { // 如果视点距离过近,视野半径只有20米,不再绘制 if (radiusMileage < 10) { return; } g.DrawString("济青高铁", defaultFont, Brushes.Red, new PointF(canvasWidth - 100, Cap1StartY)); //float titleHeight = 30; float scaleX; //float width = panel1.Size.Width; Matrix m = getTransM((float)centerMileage, (float)radiusMileage, canvasWidth, out scaleX, 50); //Matrix im = getInvTransM((float)centerMileage, (float)radiusMileage, canvasWidth, 50); // 左右50个像素空白 PointF[] sd = { new PointF(50, MileageAxisStartY), new PointF(canvasWidth / 2, MileageAxisStartY), new PointF(canvasWidth - 50, MileageAxisStartY) }; // 窗口 double[] sdMileage = { centerMileage - radiusMileage, centerMileage, centerMileage + radiusMileage }; //im.TransformPoints(sdMileage); string dkcode; double dkm; RectangleF areaf; //绘制里程坐标 g.DrawLine(roundPen, sd[0], sd[1]); g.DrawLine(roundPen, sd[1], sd[2]); string str; // 写里程坐标 for (int i = 0; i < 3; i++) { mRWScene.mMainPath.getDKCodebyPathMileage(sdMileage[i], out dkcode, out dkm); str = CRailwayLineList.CombiDKCode(dkcode, dkm); if (i == 1) { str = "当前里程" + str; if (string.IsNullOrEmpty(mDesc)) { areaf = new RectangleF(sd[i].X - 60, MileageAxisStartY + 5, 250, 20); } else { str += "。 下一目标:" + mDesc; areaf = new RectangleF(sd[i].X - 60, MileageAxisStartY + 5, 520, 20); } g.DrawString(str, defaultFont, Brushes.Black, areaf); } else { areaf = new RectangleF(sd[i].X - 40, MileageAxisStartY + 5, 80, 20); g.DrawString(str, defaultFont, Brushes.Black, areaf, centerFormat); } } //myGraphics.Transform = m; foreach (CRailwayTunnel t in mRWScene.mTunnelList) { draw_TunnelFX(g, t, 60, canvasWidth, m, scaleX); } foreach (CRailwayRoad r in mRWScene.mRoadList) { draw_RoadFX(g, r, 60, canvasWidth, m, scaleX); } foreach (CRailwayBridge b in mRWScene.mBridgeList) { draw_BridgeFX(g, b, 60, canvasWidth, m, scaleX); } foreach (CContBeam cb in mRWScene.mContBeamList) { draw_ContBeam(g, cb, 60, canvasWidth, m, scaleX); } foreach (CHotSpot hs in mRWScene.mConsSpotList) { draw_ConsSpot(g, hs, 60, canvasWidth, m, scaleX); } //draw_TunnelFX(myGraphics, ls, ld, width, m, 5000, -1000, 100, scaleX); //draw_TunnelFX(myGraphics, ls, ld, width, m, 5000, 1500, 10, scaleX); //draw_TunnelFX(myGraphics, ls, ld, width, m, 7500, -1000, 100, scaleX); //PointF[] sd = { new PointF(4000, 100), new PointF(6000, 100) }; // 窗口 //m.TransformPoints(sd); //Console.WriteLine(sd[0]); //Console.WriteLine(sd[1]); //im.TransformPoints(sd); //Console.WriteLine(sd[0]); //Console.WriteLine(sd[1]); //float scale = wh / 2 / vw; //Matrix rm = new Matrix(); //rm.Scale(2, 1); //rm.Translate(-50, -150); //rm.TransformPoints(sd); }
private void Sgworld_OnObjectAction(string ObjectID, IAction66 Action) { double d; if (Action.Code == ActionCode.AC_WAYPOINT_REACHED) { string strObjID = sgworld.ProjectTree.GetItemName(ObjectID); if (strObjID.Equals("TrainObj0")) { #if DEBUG Console.WriteLine("计数:" + mTrainWayPointCount + " of " + mTrainWayPointTotal); #endif mTrainWayPointCount = Math.Min(mTrainWayPointCount, mTrainWayPointTotal - 1); if (mTrainWayPointCount % 15 == 14) { RandomFollow(); } //double dis = CoordinateConverter.getUTMDistance(mDynamicTrain[0].Position.X, mDynamicTrain[0].Position.Y, mNavigationList[mNavNextIndex].Longitude, mNavigationList[mNavNextIndex].Latitude); //根据GPS确定里程, mSceneData.mMainPath.getPathMileagebyGPS(rx[mTrainWayPointCount], ry[mTrainWayPointCount], out mMainMileage, out d); //mDynamicTrain[0].Waypoints[mTrainWayPointTotal- mTrainWayPointCount] //mCurrentMileage = rm[mTrainWayPointCount]; mDistoNext = rm[mTrainWayPointTotal - 1] - rm[mTrainWayPointCount]; //#if DEBUG // if (Math.Abs(mDistoNext - dis) > 100) // Console.WriteLine("Something wrong in " + mTrainWayPointCount + " dis " + mDistoNext + " vs " + dis); //#endif string dkcode; double dkm; mSceneData.mMainPath.getDKCodebyPathMileage(mMainMileage, out dkcode, out dkm); string str = mNavigationList[mNavNextIndex].ObjectRef.ToString(); // 更新显示面板 panelInfo.mtotalProj = mNavigationList.Count; panelInfo.mcurrentProj = mNavNextIndex; panelInfo.mdkCode = CRailwayLineList.CombiDKCode(dkcode, dkm); panelInfo.mdistance = Math.Round(mDistoNext, 2); panelInfo.mnextProj = str; panelInfo.mconsLog = mSceneData.GetStrConsByGPS(rx[mTrainWayPointCount], ry[mTrainWayPointCount], 5000); panelInfo.updatePanel(); // 更新2D进度 panel2D.update2DPanel(mMainMileage, 500); if (mDistoNext < 500) // 可能 { ReachOnePlace(); //double dis = CoordinateConverter.getUTMDistance(mDynamicTrain[0].Position.X, mDynamicTrain[0].Position.Y, mNavigationList[mNavIndex + 1].Longitude, mNavigationList[mNavIndex + 1].Latitude); //#if DEBUG // Console.WriteLine("计数:" + mTrainWayPointCount + " of " + mTrainWayPointTotal + "count dis "+ mDistoNext + "\t gis dis" + dis); //#endif // if (mTrainWayPointTotal - mTrainWayPointCount <= 1) // { //#if DEBUG // ModelInfo.Helper.LogHelper.WriteLog(mNavIndex + ":train到达 " + mNavigationList[mNavIndex].ObjectRef.ToString() ); //#endif // //for (int j = 0; j < mDynamicTrain.Length; j++) // //{ // // mDynamicTrain[j].Pause = true; // //} // //mDistoNext = 0; // } } mTrainWayPointCount++; } else if (strObjID.Equals("VirtualObj")) { mVirtualWayPointCount--; if (isOnOneWay && mVirtualOnly) { double dis = CoordinateConverter.getUTMDistance(mVirtualObj.Position.X, mVirtualObj.Position.Y, mNavigationList[mNavNextIndex].Longitude, mNavigationList[mNavNextIndex].Latitude); if (dis < 100 || mVirtualWayPointCount == 0) { #if DEBUG ModelInfo.Helper.LogHelper.WriteLog(mNavIndex + "virtual到达 " + mNavigationList[mNavNextIndex].ObjectRef.ToString() + " 距离为 " + dis); #endif //sgworld.OnObjectAction -= Sgworld_OnObjectAction; ReachOnePlace(); } } } } }