public void SetAllPlaceEx(string place, string city) { txtsociety.Visibility = Visibility.Hidden; txteconomic.Visibility = Visibility.Hidden; txtecology.Visibility = Visibility.Hidden; Introduce.Text = "本市各年份综合指标走势"; myState = WpfApplication3.Enum.MapState.Egg2; ecologyHigh = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "生态子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueHigh.Value; //double ecologyLow = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "生态子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueLow.Value; economicHigh = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "经济子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueHigh.Value; //double economicLow = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "经济子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueLow.Value; socialHigh = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "社会子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueHigh.Value; //double socialLow = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "社会子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueLow.Value; //List<Point3D> list = new List<Point3D>(); list.Clear(); for (int i = 2000; i < 2010; i++) { double indexEcology = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "生态子系统综合指标" && c.FromDate.Year == i).First().Value; double indexEconomic = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "经济子系统综合指标" && c.FromDate.Year == i).First().Value; double indexSocial = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "社会子系统综合指标" && c.FromDate.Year == i).First().Value; /////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// //画点/////////////////////////////////////////////////////////////// drawPoint2Ex(new Point3D(indexEcology - ecologyHigh / 2, indexEconomic - economicHigh / 2, indexSocial - socialHigh / 2), i); list.Add(new Point3D(indexEcology, indexEconomic, indexSocial)); if (indexEcology > ecologyHigh) isEcology.Add("NO|" + indexEcology); else { isEcology.Add("YES|" + indexEcology); } if (indexEconomic > economicHigh) isEconomic.Add("NO|" + indexEconomic); else { isEconomic.Add("YES|" + indexEconomic); } if (indexSocial > socialHigh) isSocial.Add("NO|" + indexSocial); else { isSocial.Add("YES|" + indexSocial); } } //画九条线 for (int i = 0; i < list.Count - 1; i++) { ScreenSpaceLines3D screenSpaceLines3D = new ScreenSpaceLines3D(); Point3DCollection point3DCollection = new Point3DCollection(); Point3D point3D = new Point3D(list[i].X - ecologyHigh / 2, list[i].Y - economicHigh / 2, list[i].Z - socialHigh / 2); Point3D point3D1 = new Point3D(list[i + 1].X - ecologyHigh / 2, list[i + 1].Y - economicHigh / 2, list[i + 1].Z - socialHigh / 2); point3DCollection.Add(point3D); point3DCollection.Add(point3D1); screenSpaceLines3D.Points = point3DCollection; screenSpaceLines3D.Thickness = 3; screenSpaceLines3D.Color = Color.FromRgb(0, 0, 0); //if (screenSpaceLines3Ds.Length != 0) //MyViewport.Children.Remove(screenSpaceLines3Ds[i]); screenSpaceLines3Ds[i] = screenSpaceLines3D; MyViewport.Children.Insert(0, screenSpaceLines3Ds[i]); } //_perspectiveCamera1 = MakeCamera(); //_perspectiveCamera2 = MakeCamera(); if (model3DGroup1 != null) model3DGroup1.Children.Clear(); if (model3DGroup2 != null) model3DGroup2.Children.Clear(); InitiateGroup(); GenerateViewPort(ecologyHigh, 0, economicHigh, 0, socialHigh, 0); GenerateViewPort2((ecologyHigh - 0) / 2, (economicHigh - 0) / 2, (socialHigh - 0) / 2, (ecologyHigh + 0) / 2, (economicHigh + 0) / 2, (socialHigh + 0) / 2); Show(); }
/// <summary> /// Set One Place /// </summary> /// <param name="place"></param> /// <param name="city"></param> /// <author>ZhangMiao</author> /// <date>20100324</date> public void SetOnePlace(string place, string city, int year) { myState = WpfApplication3.Enum.MapState.Egg; double indexEcology = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "生态子系统综合指标" && c.FromDate.Year == year).First().Value; double indexEconomic = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "经济子系统综合指标" && c.FromDate.Year == year).First().Value; double indexSocial = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "社会子系统综合指标" && c.FromDate.Year == year).First().Value; list.Clear(); list.Add(new Point3D(indexEcology, indexEconomic, indexSocial)); ecologyHigh = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "生态子系统综合指标" && c.FromDate.Year == year).First().WarnValueHigh.Value; economicHigh = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "经济子系统综合指标" && c.FromDate.Year == year).First().WarnValueHigh.Value; socialHigh = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "社会子系统综合指标" && c.FromDate.Year == year).First().WarnValueHigh.Value; setEgg(indexEcology, indexEconomic, indexSocial, ecologyHigh, economicHigh, socialHigh, year); #region 注释 //Point3D p = new Point3D(indexEcology - ecologyHigh/2, indexEconomic-economicHigh/2, indexSocial -socialHigh/2); //潘伟龙 新加 //Introduce.Text = "生态子系统综合指标" + (p.X + ecologyHigh / 2).ToString("f2") + ";经济子系统综合指标" + (p.Y + economicHigh / 2).ToString("f2") + ";社会子系统综合指标" + (p.Z + socialHigh / 2).ToString("f2"); //BitmapImage bi1 = new BitmapImage(); //bi1.BeginInit(); ////bi.UriSource = new Uri("/Images/light"+indexSummary.IsInWarn.ToString()+".png",UriKind.Relative); //bi1.UriSource = new Uri("/Images/light1.png", UriKind.Relative); //if (indexEcology > ecologyHigh) //{ // bi1.UriSource = new Uri("/Images/light0.gif", UriKind.Relative); // isEcologyFlow = true; //} //bi1.EndInit(); //lightEcology.Stretch = Stretch.Fill; //lightEcology.Source = bi1; //BitmapImage bi2 = new BitmapImage(); //bi2.BeginInit(); ////bi.UriSource = new Uri("/Images/light"+indexSummary.IsInWarn.ToString()+".png",UriKind.Relative); //bi2.UriSource = new Uri("/Images/light1.png", UriKind.Relative); //if (indexSocial > socialHigh) //{ // bi2.UriSource = new Uri("/Images/light0.gif", UriKind.Relative); // isSocialFlow = true; //} //bi2.EndInit(); //lightSociety.Stretch = Stretch.Fill; //lightSociety.Source = bi2; //BitmapImage bi3 = new BitmapImage(); //bi3.BeginInit(); ////bi.UriSource = new Uri("/Images/light"+indexSummary.IsInWarn.ToString()+".png",UriKind.Relative); //bi3.UriSource = new Uri("/Images/light1.png", UriKind.Relative); //if(indexEconomic>economicHigh) //{ // bi3.UriSource = new Uri("/Images/light0.gif", UriKind.Relative); // isEconomicFlow = true; //} //bi3.EndInit(); //lightEconomic.Stretch = Stretch.Fill; //lightEconomic.Source = bi3; //if(indexEcology>ecologyHigh||indexSocial>socialHigh||indexEconomic>economicHigh) //{ // drawPoint1Ex(p, year, true); //} //else //{ // drawPoint1Ex(p, year, false); //} //_perspectiveCamera1 = MakeCamera(); //_perspectiveCamera2 = MakeCamera(); //GenerateViewPort(ecologyHigh,0,economicHigh,0,socialHigh,0); //GenerateViewPort2((ecologyHigh - 0) / 2, (economicHigh - 0) / 2, (socialHigh - 0) / 2, (ecologyHigh + 0) / 2, (economicHigh + 0) / 2, (socialHigh + 0) / 2); ////GenertateView(ecologyHigh, 0, economicHigh, 0, socialHigh, 0, (ecologyHigh - 0) / 2, (economicHigh - 0) / 2, (socialHigh - 0) / 2, (ecologyHigh + 0) / 2, (economicHigh + 0) / 2, (socialHigh + 0) / 2); //Show(); #endregion }
/// <summary> /// Set All Place /// </summary> /// <param name="place"></param> /// <param name="city"></param> /// <author>ZhangMiao</author> /// <date>20100324</date> public void SetAllPlace(string place, string city) { Introduce.Text = "本市各年份综合指标走势"; myState = WpfApplication3.Enum.MapState.Egg2; //List<Point3D> list = new List<Point3D>(); for (int i = 2000; i < 2008; i++) { SetPlace(place, city, i, list, allValue, false); } List<Point3D> newList = new List<Point3D>(); for (int i = 0; i < list.Count - 1; i++) { double x = list[i + 1].X - list[i].X / list[i].X; double y = list[i + 1].Y - list[i].Y / list[i].Y; double z = list[i + 1].Z - list[i].Z / list[i].Z; newList.Add(new Point3D(x, y, z)); } double sumx = 0; double sumy = 0; double sumz = 0; for (int i = 0; i < newList.Count; i++) { sumx = sumx + newList[i].X; sumy = sumy + newList[i].Y; sumz = sumz + newList[i].Z; } double avex = sumx / newList.Count; double avey = sumy / newList.Count; double avez = sumz / newList.Count; //List<Point3D> endList = new List<Point3D>(); for (int i = 0; i < newList.Count; i++) { endList.Add(new Point3D((newList[i].X - avex), (newList[i].Y - avey), (newList[i].Z - avez))); } double average = allValue.Sum() / allValue.Count; double variance = 0.0; foreach (double v in allValue) { variance += Math.Pow((v - average), 2); } warnValue = average - 2.33 * Math.Pow((variance / allValue.Count), 0.5); foreach (Point3D p in endList) { drawPoint2(p, endList.IndexOf(p) + 2000); } Point3D pback = new Point3D(); Point3D pfront = new Point3D(); pback = endList[0]; for (int i = 0; i < endList.Count - 1; i++) { pfront = pback; pback = endList[i + 1]; ScreenSpaceLines3D pt = new ScreenSpaceLines3D(); pt.Points.Add(pfront); pt.Points.Add(pback); pt.Thickness = 2; pt.Color = Colors.Blue; MyViewport.Children.Insert(0, pt); double DArrow = Math.PI / 6; double MArrow = 0.3; #region 代码 double ZXYLong = Math.Sqrt((pback.Z - pfront.Z) * (pback.Z - pfront.Z) + (pback.X - pfront.X) * (pback.X - pfront.X) + (pback.Y - pfront.Y) * (pback.Y - pfront.Y)); if (ZXYLong == 0) continue; Point3D arrow1 = new Point3D(); Point3D arrow2 = new Point3D(); if (pback.Y == pfront.Y && pback.X == pfront.Y) { double MArrowY = MArrow * Math.Sin(DArrow); double MArrowZ = MArrow * Math.Cos(DArrow); int SignedZ; if (pback.Z > pfront.Z) SignedZ = -1; else SignedZ = 1; arrow1.X = pback.X; arrow1.Y = pback.Y - MArrow * Math.Sin(DArrow); arrow1.Z = pback.Z + SignedZ * MArrow * Math.Cos(DArrow); arrow2.X = pback.X; arrow2.Y = pback.Y + MArrow * Math.Sin(DArrow); arrow2.Z = pback.Z + SignedZ * MArrow * Math.Cos(DArrow); } else { double DegreeZ = Math.Asin((pback.Z - pfront.Z) / ZXYLong); double De2 = Math.PI / 2 - DegreeZ; double De1 = Math.PI - DArrow - De2; double De3 = Math.PI - De2; double De4 = Math.PI - De3 - DArrow; double LArrow = MArrow * Math.Sin(De1) / Math.Sin(De2); double MiddelZ = LArrow * (pback.Z - pfront.Z) / ZXYLong;// Math.Sin(DegreeZ); double MiddelY = LArrow * (pback.Y - pfront.Y) / ZXYLong;//Math.Sin(DegreeY); double MiddelX = LArrow * (pback.X - pfront.X) / ZXYLong;//Math.Sin(DegreeX); double MiddleZ = pback.Z - MiddelZ; double MiddleY = pback.Y - MiddelY; double MiddleX = pback.X - MiddelX; double ArOP = MArrow * Math.Sin(De1) / Math.Sin(De4); double Middle2 = MArrow * LArrow / ArOP; //double Middle2 = MArrow * Math.Sin(De4); double Z1 = LArrow * Math.Sin(DArrow) / Math.Sin(De1); double Z2 = MArrow * Math.Sin(DArrow) / Math.Sin(De3); arrow1.X = MiddleX; arrow1.Y = MiddleY; arrow1.Z = MiddleZ + Z1; arrow2.X = pback.X - Middle2 * ((pback.X - pfront.X) / ZXYLong); arrow2.Y = pback.Y - Middle2 * ((pback.Y - pfront.Y) / ZXYLong); arrow2.Z = pback.Z - Middle2 * ((pback.Z - pfront.Z) / ZXYLong) - Z2; } ScreenSpaceLines3D temp1 = new ScreenSpaceLines3D(); ScreenSpaceLines3D temp2 = new ScreenSpaceLines3D(); temp1.Points.Add(pback); temp2.Points.Add(pback); temp1.Points.Add(arrow1); temp2.Points.Add(arrow2); temp1.Thickness = 1; temp2.Thickness = 1; temp1.Color = Colors.Red; temp2.Color = Colors.Red; MyViewport.Children.Insert(0, temp1); MyViewport.Children.Insert(0, temp2); #endregion } double ecologyHigh = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "生态子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueHigh.Value; //double ecologyLow = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "生态子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueLow.Value; double economicHigh = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "经济子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueHigh.Value; //double economicLow = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "经济子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueLow.Value; double socialHigh = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "社会子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueHigh.Value; //double socialLow = DataLib.DA_Index.QueryIndexByZone(place).Where(c => c.Name == "社会子系统综合指标" && c.FromDate.Year == _currentYear).First().WarnValueLow.Value; _perspectiveCamera1 = MakeCamera(); _perspectiveCamera2 = MakeCamera(); GenerateViewPort(ecologyHigh, 0, economicHigh, 0, socialHigh, 0); GenerateViewPort2((ecologyHigh - 0) / 2, (economicHigh - 0) / 2, (socialHigh - 0) / 2, (ecologyHigh + 0) / 2, (economicHigh + 0) / 2, (socialHigh + 0) / 2); Show(); }