private void OutputMeasureResult(SuperMap.UI.Tracking3DEventArgs e)
        {
            if (mSceneControl.Action == Action3D.MeasureDistance && mIndex == 8 ||
                mSceneControl.Action == Action3D.MeasureTerrainDistance ||
                mSceneControl.Action == Action3D.MeasureHorizontalDistance)
            {
                if (e.CurrentLength > 0)
                {
                    mCurLength = e.CurrentLength;
                    Double tempCurLength   = mCurLength;
                    Double tempTotalLength = e.TotalLength;
                    mStrResult = String.Format("    ", tempCurLength, " " + "米", tempTotalLength, " " + "米");
                    OutputMeasureDistance(e);
                }
            }
            if (mSceneControl.Action == Action3D.MeasureArea && mIndex == 10 ||
                mSceneControl.Action == Action3D.MeasureTerrainArea)
            {
                Double area = e.TotalArea;
                mStrResult = String.Format("", area, " " + "米");

                if (!Toolkit.IsZero(e.TotalArea))
                {
                    OutputMeasureArea(e);
                }
            }
            if (mSceneControl.Action == Action3D.MeasureAltitude && mIndex == 9)
            {
                Double currentHeight = e.CurrentHeight;
                mStrResult = String.Format("    ", currentHeight, " " + "米");
                OutputMeasureAltitude(e);
            }
        }
Exemplo n.º 2
0
        public void OutputMeasureArea(SuperMap.UI.Tracking3DEventArgs e1)
        {
            try
            {
                Point location = mSceneControl.PointToClient(Cursor.Position);
                mTempPoint = new Point3D(e1.X, e1.Y, e1.Z);
                mPoint3Ds.Add(mTempPoint);
                GeoRegion3D geoRegion3D = null;

                if (mPoint3Ds.Count >= 3)
                {
                    geoRegion3D                   = new GeoRegion3D(mPoint3Ds);
                    mGeoStyle3DTemp               = new GeoStyle3D();
                    mGeoStyle3DTemp.MarkerColor   = Color.FromArgb(255, 0, 0);
                    mGeoStyle3DTemp.LineColor     = Color.FromArgb(0, 255, 0);
                    mGeoStyle3DTemp.LineWidth     = 1;
                    mGeoStyle3DTemp.FillForeColor = Color.FromArgb(180, Color.Violet);
                    mGeoStyle3DTemp.AltitudeMode  = AltitudeMode.RelativeToGround;
                    geoRegion3D.Style3D           = mGeoStyle3DTemp.Clone();

                    location.Offset(30, 30);
                    if (location.X > mSceneControl.Bounds.Width / 4 * 3)
                    {
                        location.X = mSceneControl.Bounds.Width / 4 * 3;
                    }
                    if (location.Y > mSceneControl.Bounds.Height)
                    {
                        location.Y = location.Y - 60;
                    }

                    int index = mSceneControl.Scene.TrackingLayer.IndexOf(mMessageTrackingTag);
                    if (index >= 0)
                    {
                        mSceneControl.Scene.TrackingLayer.Remove(index);
                    }
                }
            }
            catch (System.Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
        private void OutputMeasureAltitude(SuperMap.UI.Tracking3DEventArgs e)
        {
            try
            {
                Point location = mSceneControl.PointToClient(Cursor.Position);
                location.Offset(30, 30);

                if (location.X > mSceneControl.Bounds.Width / 5 * 4)
                {
                    location.X = mSceneControl.Bounds.Width / 5 * 4;
                }
                if (location.Y > mSceneControl.Bounds.Height)
                {
                    location.Y = location.Y - 60;
                }

                GeoText3D text3d = GetGeoText3DMessage();

                text3d.TextStyle.FontHeight = 6;
                text3d.TextStyle.Alignment  = TextAlignment.BottomLeft;
                text3d.TextStyle.BackColor  = Color.Black;
                text3d.TextStyle.Outline    = true;
                text3d.Style3D.AltitudeMode = AltitudeMode.RelativeToGround;

                text3d[0].Text = e.CurrentHeight.ToString("##.00") + "米";
                text3d[0].X    = e.X;
                text3d[0].Y    = e.Y;
                text3d[0].Z    = e.Z + e.CurrentHeight;

                Console.WriteLine(text3d[0].Z);

                text3d.Style3D.AltitudeMode = AltitudeMode.Absolute;

                ClearTextMessageTag();
                mSceneControl.Scene.TrackingLayer.Add(text3d, MessageTag);
                mCurAltitude = e.CurrentHeight;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
        /// <summary>
        /// 测量面积
        /// </summary>
        /// <param name="e"></param>
        private void OutputMeasureArea(SuperMap.UI.Tracking3DEventArgs e)
        {
            try
            {
                Point location = mSceneControl.PointToClient(Cursor.Position);

                if (mTempPoint != Point3D.Empty)
                {
                    mPoint3Ds.Remove(mPoint3Ds.Count - 1);
                }
                mTempPoint = new Point3D(e.X, e.Y, e.Z);
                mPoint3Ds.Add(mTempPoint);

                GeoRegion3D geoRegion3D = null;
                if (mPoint3Ds.Count >= 3)
                {
                    geoRegion3D         = new GeoRegion3D(mPoint3Ds);
                    geoRegion3D.Style3D = mGeoStyle3DTemp.Clone();

                    location.Offset(30, 30);

                    if (location.X > mSceneControl.Bounds.Width / 4 * 3)
                    {
                        location.X = mSceneControl.Bounds.Width / 4 * 3;
                    }
                    if (location.Y > mSceneControl.Bounds.Height)
                    {
                        location.Y = location.Y - 60;
                    }

                    TextPart3D textPart3D = new TextPart3D();
                    textPart3D.AnchorPoint = new Point3D(0, 0, 0);
                    textPart3D.Text        = String.Empty;

                    TextStyle style = new TextStyle();
                    style.ForeColor   = Color.White;
                    style.IsSizeFixed = true;
                    style.FontHeight  = 6;
                    style.Alignment   = TextAlignment.BottomLeft;
                    style.BackColor   = Color.Black;
                    style.Outline     = true;
                    GeoText3D text3d = new GeoText3D(textPart3D, style);
                    text3d.Style3D = new GeoStyle3D();
                    text3d.Style3D.AltitudeMode = AltitudeMode.Absolute;

                    text3d[0].Text = e.TotalArea.ToString("##.00") + "平方米";

                    if (e.Geometry != null)
                    {
                        text3d[0].X = e.Geometry.InnerPoint.X;
                        text3d[0].Y = e.Geometry.InnerPoint.Y;
                    }
                    else
                    {
                        text3d[0].X = geoRegion3D.InnerPoint.X;
                        text3d[0].Y = geoRegion3D.InnerPoint.Y;
                    }

                    int index = mSceneControl.Scene.TrackingLayer.IndexOf(MessageTrackingTag);
                    if (index >= 0)
                    {
                        mSceneControl.Scene.TrackingLayer.Remove(index);
                    }
                    mSceneControl.Scene.TrackingLayer.Add(text3d, MessageTrackingTag);
                    mCurArea = e.TotalArea;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
        private void OutputMeasureDistance(SuperMap.UI.Tracking3DEventArgs e)
        {
            try
            {
                Point location = mSceneControl.PointToClient(Cursor.Position);

                if (mTempPoint != Point3D.Empty && mPoint3Ds.Count > 1)
                {
                    mPoint3Ds.Remove(mPoint3Ds.Count - 1);
                }
                mTempPoint = new Point3D(e.X, e.Y, e.Z);
                mPoint3Ds.Add(mTempPoint);

                location.Offset(30, 30);
                if (location.X > mSceneControl.Bounds.Width / 3 * 2)
                {
                    location.X = mSceneControl.Bounds.Width / 3 * 2;
                }
                if (location.Y > mSceneControl.Bounds.Height)
                {
                    location.Y = location.Y - 60;
                }

                TextPart3D textPart3D = new TextPart3D();
                textPart3D.AnchorPoint = new Point3D(0, 0, 0);
                textPart3D.Text        = String.Empty;

                TextStyle style = new TextStyle();
                style.ForeColor   = Color.White;
                style.IsSizeFixed = true;
                style.FontHeight  = 6;
                style.Alignment   = TextAlignment.BottomLeft;
                style.BackColor   = Color.Black;
                style.Outline     = true;
                GeoText3D text3d = new GeoText3D(textPart3D, style);
                text3d.Style3D = new GeoStyle3D();
                text3d.Style3D.AltitudeMode = AltitudeMode.Absolute;

                text3d[0].Text = e.CurrentLength.ToString("##.00") + "米";
                Point3D lastPoint = Point3D.Empty;
                if (e.Geometry != null)
                {
                    Point3Ds points = (e.Geometry as GeoLine3D)[0];
                    lastPoint = points[points.Count - 1];
                }
                else
                {
                    lastPoint = mPoint3Ds[0];
                }
                text3d[0].X = (lastPoint.X + e.X) / 2;
                text3d[0].Y = (lastPoint.Y + e.Y) / 2;

                int index = mSceneControl.Scene.TrackingLayer.IndexOf(MessageTrackingTag);
                if (index >= 0)
                {
                    mSceneControl.Scene.TrackingLayer.Remove(index);
                }
                mSceneControl.Scene.TrackingLayer.Add(text3d, MessageTrackingTag);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }