Example #1
0
        //鼠标在场景中停留两秒中显示坡度坡向信息
        private void timer_tick(Object sender, EventArgs e)
        {
            if (m_slope != null)
            {
                if (m_lastPoint3D != m_point3D)
                {
                    this.m_sceneControl.Scene.TrackingLayer.Clear();
                    double slopeValue     = m_slope.GetSlopeValue(m_point3D);
                    double slopeDirection = m_slope.GetSlopeDirectionValue(m_point3D);

                    TextStyle textstyle = new TextStyle();
                    textstyle.IsSizeFixed = true;
                    textstyle.FontName    = "微软雅黑";
                    textstyle.ForeColor   = Color.Black;
                    textstyle.FontScale   = 2;
                    textstyle.FontHeight  = 3;

                    TextPart3D textPart3D = new TextPart3D();
                    textPart3D.Text        = String.Format("Longitude: {0}\nLatitude:{1}\nAltitude: {2}\nSlopeValue: {3}\nSlopeDirection: {4}", m_point3D.X, m_point3D.Y, m_point3D.Z, slopeValue, slopeDirection);
                    textPart3D.AnchorPoint = m_point3D;
                    GeoText3D geoText3D = new GeoText3D(textPart3D);
                    geoText3D.TextStyle = textstyle;
                    GeoStyle3D style3D = new GeoStyle3D();
                    style3D.AltitudeMode   = AltitudeMode.Absolute;
                    style3D.BottomAltitude = 10;
                    geoText3D.Style3D      = style3D;
                    this.m_sceneControl.Scene.TrackingLayer.Add(geoText3D, "Text");


                    m_lastPoint3D = m_point3D;
                }
            }
        }
        public void coordLabel()
        {
            try
            {
                double x_label = mPoint3D.X;
                double y_label = mPoint3D.Y;
                double z_label = mPoint3D.Z;
                String coord   = "X: " + x_label + "\n\n" + "Y: " + y_label + "\n\n" + "Z: " + z_label;

                TextPart3D mText1 = new TextPart3D();
                mText1.Text        = coord;
                mText1.AnchorPoint = mPoint3D;
                TextStyle mTextStyle1 = new TextStyle();
                mTextStyle1.FontName    = "微软雅黑";
                mTextStyle1.ForeColor   = Color.Red;
                mTextStyle1.FontHeight  = 7;
                mTextStyle1.IsSizeFixed = false;
                mTextStyle1.Alignment   = TextAlignment.MiddleCenter;
                GeoText3D  geoText_1  = new GeoText3D(mText1, mTextStyle1);
                GeoStyle3D geostyle_1 = new GeoStyle3D();
                geostyle_1.AltitudeMode = AltitudeMode.RelativeToGround;
                geoText_1.Style3D       = geostyle_1;
                TrackingLayer3D trackinglayer = mSceneControl.Scene.TrackingLayer;
                trackinglayer.IsEditable = true;
                trackinglayer.IsVisible  = true;
                trackinglayer.Add(geoText_1, "Coord");
                mSceneControl.Scene.Refresh();
            }
            catch (Exception)
            {
            }
        }
Example #3
0
		private GeoText3D CreateText3DMessage()
		{
			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 = 4;
			GeoText3D text3D = new GeoText3D(textPart3D, style);
			text3D.Style3D = new GeoStyle3D();
			text3D.Style3D.AltitudeMode = AltitudeMode.RelativeToGround;
			return text3D;
		}
        private GeoText3D CreateText3DMessage()
        {
            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 = 4;
            GeoText3D text3D = new GeoText3D(textPart3D, style);
            text3D.Style3D = new GeoStyle3D();
            text3D.Style3D.AltitudeMode = AltitudeMode.RelativeToGround;
            return text3D;
        }
Example #5
0
        //鼠标选择对象事件
        void m_sceneControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_bAnalyisSucess == true)
            {
                this.m_sceneControl.Scene.TrackingLayer.Clear();

                if (m_shadowQuery != null && e.Button == MouseButtons.Left)
                {
                    Point point = new Point(e.X, e.Y);

                    double shadowRatio = m_shadowQuery.GetShadowRatio(point);

                    if (shadowRatio != -1)
                    {
                        this.label_shadowRatio.Text = String.Format("当前点的阴影率为:{0}%", shadowRatio * 100);


                        TextStyle textstyle = new TextStyle();
                        textstyle.IsSizeFixed = true;
                        textstyle.FontName    = "微软雅黑";
                        textstyle.ForeColor   = Color.Red;
                        textstyle.FontScale   = 2;
                        textstyle.FontHeight  = 2;

                        Point3D    point3D    = m_sceneControl.Scene.PixelToGlobe(e.Location);
                        TextPart3D textPart3D = new TextPart3D();
                        textPart3D.Text        = String.Format("阴影率:{0}%", shadowRatio * 100);
                        textPart3D.AnchorPoint = point3D;
                        GeoText3D geoText3D = new GeoText3D(textPart3D);
                        geoText3D.TextStyle = textstyle;
                        this.m_sceneControl.Scene.TrackingLayer.Add(geoText3D, "Text");
                    }
                    else
                    {
                        this.label_shadowRatio.Text = "当前点的阴影率为:***";
                    }
                }
            }
        }
        /// <summary>
        /// 标注名称
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void NameLabel()
        {
            try
            {
                Selection3D[] selection = mSceneControl.Scene.FindSelection(true);
                //判断选择集是否为空
                if (selection == null || selection.Length == 0)
                {
                    MessageBox.Show("请选择要标注名称的空间对象");
                    return;
                }
                //将选择集转换为记录
                Recordset recordset = selection[0].ToRecordset();
                //获取名称字段的值
                string str  = "";
                string str1 = "";
                object obj;
                bool   bol = false;
                for (int i = 0; i < recordset.FieldCount; i++)
                {
                    str = recordset.GetFieldInfos()[i].Name;
                    if (str == "Name")
                    {
                        bol  = true;
                        obj  = recordset.GetFieldValue(i);
                        str1 = "名称: " + obj.ToString() + "\n";
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                if (bol == false)
                {
                    MessageBox.Show("该对象没有名称属性!");
                }
                recordset.Dispose();

                TextPart3D mText1 = new TextPart3D();
                mText1.Text        = str1;
                mText1.AnchorPoint = mPoint3D;
                TextStyle mTextStyle1 = new TextStyle();
                mTextStyle1.FontName    = "微软雅黑";
                mTextStyle1.ForeColor   = Color.Red;
                mTextStyle1.FontHeight  = 7;
                mTextStyle1.IsSizeFixed = false;
                mTextStyle1.Alignment   = TextAlignment.MiddleCenter;
                GeoText3D  geoText_1  = new GeoText3D(mText1, mTextStyle1);
                GeoStyle3D geostyle_1 = new GeoStyle3D();
                geostyle_1.AltitudeMode = AltitudeMode.RelativeToGround;
                geoText_1.Style3D       = geostyle_1;
                TrackingLayer3D trackinglayer = mSceneControl.Scene.TrackingLayer;
                trackinglayer.IsEditable = true;
                trackinglayer.IsVisible  = true;
                trackinglayer.Add(geoText_1, "NameLabel");
                mSceneControl.Scene.Refresh();
            }
            catch (Exception)
            {
            }
        }
        public void LineInsertQuery()
        {
            Layer3Ds m_layer = mSceneControl.Scene.Layers;

            foreach (Layer3D mlayer in m_layer)
            {
                if (mlayer.Selection != null)
                {
                    mlayer.Selection.Clear();
                }
            }

            QueryParameter para = new QueryParameter();

            para.HasGeometry        = true;
            para.SpatialQueryMode   = SpatialQueryMode.Intersect;
            para.SpatialQueryObject = mRec2D;

            Recordset      recordset        = null;
            Layer3DDataset layer            = null;
            String         m_textID         = String.Empty;
            String         m_textName       = String.Empty;
            String         m_textDepth      = String.Empty;
            String         m_textDiameter   = String.Empty;
            String         m_InfomationText = String.Empty;

            for (int i = 0; i < 3; i++)
            {
                if (i == 0)
                {
                    recordset = mUseData.OutWaterNetWork.Query(para);
                    layer     = mUseData.OutWaterLines;
                }
                else if (i == 1)
                {
                    recordset = mUseData.SupplyWaterNetWork.Query(para);
                    layer     = mUseData.SupplyWaterLines;
                }
                else if (i == 2)
                {
                    recordset = mUseData.ElectricNetWork.Query(para);
                    layer     = mUseData.ElectricLayer;
                }


                List <Int32> ids = new List <int>(recordset.RecordCount);
                while (!recordset.IsEOF)
                {
                    m_textID          = System.Convert.ToString(recordset.GetFieldValue("SmID"));
                    m_textName        = System.Convert.ToString(recordset.GetFieldValue("Name"));
                    m_textDepth       = System.Convert.ToString(recordset.GetFieldValue("BottomAltitude"));
                    m_textDiameter    = System.Convert.ToString(recordset.GetFieldValue("PipeDiameter"));
                    m_InfomationText += m_textID + "      " + m_textName + "    " + m_textDepth + "            " + m_textDiameter + "\n";
                    ids.Add(recordset.GetID());
                    recordset.MoveNext();
                }
                layer.Selection.AddRange(ids.ToArray());
                layer.Selection.UpdateData();
                layer.Selection.Style.LineColor = Color.GreenYellow;
                mSceneControl.Scene.Refresh();
            }

            //进行文本标注
            String m_text = "编号" + "  " + "管线类别" + "  " + "埋设深度" + "  " + "管径" + "\n";

            m_text += m_InfomationText;
            TextPart3D mText1 = new TextPart3D();

            mText1.Text        = m_text;
            mText1.AnchorPoint = mAnchorPoint3D;
            TextStyle mTextStyle1 = new TextStyle();

            mTextStyle1.FontName    = "微软雅黑";
            mTextStyle1.ForeColor   = Color.Red;
            mTextStyle1.FontHeight  = 7;
            mTextStyle1.IsSizeFixed = false;
            mTextStyle1.Alignment   = TextAlignment.MiddleCenter;
            GeoText3D  geoText_1  = new GeoText3D(mText1, mTextStyle1);
            GeoStyle3D geostyle_1 = new GeoStyle3D();

            geostyle_1.AltitudeMode = AltitudeMode.RelativeToGround;
            geoText_1.Style3D       = geostyle_1;
            TrackingLayer3D trackinglayer = mSceneControl.Scene.TrackingLayer;

            trackinglayer.IsEditable = true;
            trackinglayer.IsVisible  = true;
            trackinglayer.Add(geoText_1, "PullFlatLabel");
        }
        /// <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);
            }
        }
        /// <summary>
        /// 鼠标动作Up
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void SceneControlMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                EndOneMeasure();
            }

            if (e.Button == MouseButtons.Left)
            {
                if (mPoint3Ds.Count == 0)
                {
                    //ClearMeasureResult();
                }

                if (mTempPoint != Point3D.Empty && mPoint3Ds.Count > 1)
                {
                    mPoint3Ds.Remove(mPoint3Ds.Count - 1);
                    mTempPoint = Point3D.Empty;
                }

                Point   location = mSceneControl.PointToClient(Cursor.Position);
                Point3D point3D  = new Point3D();

                if (mSceneControl.Action == Action3D.MeasureDistance && mIndex == 8 ||
                    mSceneControl.Action == Action3D.MeasureAltitude && mIndex == 9 ||
                    mSceneControl.Action == Action3D.MeasureHorizontalDistance)
                {
                    point3D = mSceneControl.Scene.PixelToGlobe(new Point(e.X, e.Y), SuperMap.Realspace.PixelToGlobeMode.TerrainAndModel);
                }
                else
                {
                    point3D = mSceneControl.Scene.PixelToGlobe(new Point(e.X, e.Y));
                }

                if (!Double.IsNaN(point3D.X) && !Double.IsNaN(point3D.Y) && !Double.IsNaN(point3D.Z))
                {
                    mPoint3Ds.Add(point3D);


                    if (mSceneControl.Action == Action3D.MeasureHorizontalDistance ||
                        mSceneControl.Action == Action3D.MeasureDistance && mIndex == 8)
                    {
                        //添加部分段长度
                        if (!Toolkit.IsZero(mCurLength))
                        {
                            if (mPoint3Ds.Count >= 2)
                            {
                                mPoint3Ds.RemoveRange(0, mPoint3Ds.Count - 2);
                                String     distanceUnit = "米";
                                GeoLine3D  geoLine3D    = new GeoLine3D(mPoint3Ds);
                                TextPart3D textPart3D   = new TextPart3D();
                                textPart3D.AnchorPoint = new Point3D(0, 0, 0);
                                Double tempCurLength = mCurLength;
                                textPart3D.Text = String.Format("{0:F2}{1}", tempCurLength, " " + distanceUnit);
                                if (mPoint3Ds[0].X > 0 && mPoint3Ds[1].X > 0 ||
                                    mPoint3Ds[0].X < 0 && mPoint3Ds[1].X < 0)
                                {
                                    textPart3D.X = geoLine3D.InnerPoint3D.X;
                                }
                                else
                                {
                                    textPart3D.X = 180;
                                }

                                textPart3D.Y = geoLine3D.InnerPoint3D.Y;
                                textPart3D.Z = geoLine3D.InnerPoint3D.Z;

                                GeoText3D text3d = mCurrentGeoText3DMessage == null?GetGeoText3DMessage() : mCurrentGeoText3DMessage;

                                text3d.AddPart(textPart3D);

                                //设置文字样式
                                text3d.TextStyle.FontHeight = 6;
                                text3d.TextStyle.Alignment  = TextAlignment.BottomLeft;
                                text3d.TextStyle.BackColor  = Color.Black;
                                text3d.TextStyle.Outline    = true;
                                text3d.Style3D.AltitudeMode = AltitudeMode.Absolute;

                                int index = mSceneControl.Scene.TrackingLayer.IndexOf(MessageTag);
                                if (index >= 0)
                                {
                                    mSceneControl.Scene.TrackingLayer.Remove(index);
                                }
                                //ClearTextMessageTag();
                                mSceneControl.Scene.TrackingLayer.Add(text3d, MessageTag);
                            }
                        }

                        //测地形距离
                        else if (mSceneControl.Action == Action3D.MeasureTerrainDistance)
                        {
                            //添加部分段长度
                            if (!Toolkit.IsZero(mCurLength))
                            {
                                if (mPoint3Ds.Count >= 2)
                                {
                                    mPoint3Ds.RemoveRange(0, mPoint3Ds.Count - 2);

                                    GeoLine3D  geoLine3D    = new GeoLine3D(mPoint3Ds);
                                    String     distanceUnit = "米";
                                    TextPart3D textPart3D   = new TextPart3D();
                                    textPart3D.AnchorPoint = new Point3D(0, 0, 0);
                                    Double tempCurLength = mCurLength;
                                    textPart3D.Text = String.Format("{0:F2}{1}", tempCurLength, " " + distanceUnit);
                                    if (mPoint3Ds[0].X > 0 && mPoint3Ds[1].X > 0 ||
                                        mPoint3Ds[0].X < 0 && mPoint3Ds[1].X < 0)
                                    {
                                        textPart3D.X = geoLine3D.InnerPoint.X;
                                        textPart3D.Y = geoLine3D.InnerPoint.Y;
                                    }
                                    else
                                    {
                                        textPart3D.X = 180;
                                        textPart3D.Y = geoLine3D.InnerPoint.Y;
                                    }
                                    textPart3D.Z = 0;
                                    GeoText3D text3d = GetGeoText3DMessage();
                                    text3d.AddPart(textPart3D);
                                    text3d.TextStyle.FontHeight = 6;
                                    text3d.TextStyle.Alignment  = TextAlignment.BottomLeft;
                                    text3d.TextStyle.BackColor  = Color.Black;
                                    text3d.TextStyle.Outline    = true;
                                    text3d.Style3D.AltitudeMode = AltitudeMode.ClampToGround;//贴地高程模式
                                    ClearTextMessageTag();
                                    mSceneControl.Scene.TrackingLayer.Add(text3d, MessageTag);
                                }
                            }
                        }
                        else if (mSceneControl.Action == Action3D.MeasureArea && mIndex == 10)
                        {
                        }
                        else if (mSceneControl.Action == Action3D.MeasureAltitude && mIndex == 9)
                        {
                            //清除量算高度信息
                            if (!(Toolkit.IsZero(mCurAltitude)))
                            {
                                EndOneMeasure();
                            }
                        }
                    }
                }
            }
        }
Example #11
0
		private void OutputMeasureDistance(SuperMap.UI.Tracking3DEventArgs e)
		{
			try
			{
				Point location = SmObjectLocator.getInstance().GlobeObject.PointToClient(Cursor.Position);

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

				location.Offset(30, 30);
				if (location.X > SmObjectLocator.getInstance().GlobeObject.Bounds.Width / 3 * 2)
				{
					location.X = SmObjectLocator.getInstance().GlobeObject.Bounds.Width / 3 * 2;
				}
				if (location.Y > SmObjectLocator.getInstance().GlobeObject.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.Style3D.BottomAltitude = 100;

				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 = m_point3Ds[0];
				}
				text3d[0].X = (lastPoint.X + e.X) / 2;
				text3d[0].Y = (lastPoint.Y + e.Y) / 2;

				int index = SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.IndexOf(m_messageTrackingTag);
				if (index >= 0)
				{
					SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.Remove(index);
				}
				SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.Add(text3d, m_messageTrackingTag);
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.StackTrace);
			}
		}
Example #12
0
		private void OutputMeasureArea(SuperMap.UI.Tracking3DEventArgs e)
		{
			try
			{
				Point location = SmObjectLocator.getInstance().GlobeObject.PointToClient(Cursor.Position);

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

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

					location.Offset(30, 30);
					if (location.X > SmObjectLocator.getInstance().GlobeObject.Bounds.Width / 4 * 3)
					{
						location.X = SmObjectLocator.getInstance().GlobeObject.Bounds.Width / 4 * 3;
					}
					if (location.Y > SmObjectLocator.getInstance().GlobeObject.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.Style3D.BottomAltitude = 100;

					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 = SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.IndexOf(m_messageTrackingTag);
					if (index >= 0)
					{
						SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.Remove(index);
					}
					SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.Add(text3d, m_messageTrackingTag);
					m_curArea = e.TotalArea;
				}
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.StackTrace);
			}
		}
Example #13
0
		// 鼠标右键,负责 显示分段量算结果
		void m_SceneControl_MouseUp(object sender, MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Right)
			{
				EndOneMeasure();
			}

			if (e.Button == MouseButtons.Left)
			{
				if (m_point3Ds.Count == 0)
				{
					//ClearMeasureResult();
				}

				if (m_tempPoint != Point3D.Empty && m_point3Ds.Count > 1)
				{
					m_point3Ds.Remove(m_point3Ds.Count - 1);
					m_tempPoint = Point3D.Empty;
				}

				Point location = SmObjectLocator.getInstance().GlobeObject.PointToClient(Cursor.Position);
				Point3D point3D = new Point3D();
				if (SmObjectLocator.getInstance().GlobeObject.Action == Action3D.MeasureDistance
					|| SmObjectLocator.getInstance().GlobeObject.Action == Action3D.MeasureAltitude || SmObjectLocator.getInstance().GlobeObject.Action == Action3D.MeasureHorizontalDistance)
				{
					point3D = SmObjectLocator.getInstance().GlobeObject.Scene.PixelToGlobe(new Point(e.X, e.Y), SuperMap.Realspace.PixelToGlobeMode.TerrainAndModel);
				}
				else
				{
					point3D = SmObjectLocator.getInstance().GlobeObject.Scene.PixelToGlobe(new Point(e.X, e.Y));
				}

				if (!Double.IsNaN(point3D.X) && !Double.IsNaN(point3D.Y) && !Double.IsNaN(point3D.Z))
				{
					m_point3Ds.Add(point3D);
					if (SmObjectLocator.getInstance().GlobeObject.Action == Action3D.MeasureHorizontalDistance || SmObjectLocator.getInstance().GlobeObject.Action == Action3D.MeasureDistance)
					{
						//添加部分段长度
						if (!Toolkit.IsZero(m_curLength))
						{
							if (m_point3Ds.Count >= 2)
							{
								m_point3Ds.RemoveRange(0, m_point3Ds.Count - 2);
								String distanceUnit = "米";
								GeoLine3D geoLine3D = new GeoLine3D(m_point3Ds);
								TextPart3D textPart3D = new TextPart3D();
								textPart3D.AnchorPoint = new Point3D(0, 0, 0);
								Double tempCurLength = m_curLength;
								textPart3D.Text = String.Format("{0:F2}{1}", tempCurLength, " " + distanceUnit);
								if (m_point3Ds[0].X > 0 && m_point3Ds[1].X > 0 ||
									m_point3Ds[0].X < 0 && m_point3Ds[1].X < 0)
								{
									textPart3D.X = geoLine3D.InnerPoint3D.X;
								}
								else
								{
									textPart3D.X = 180;
								}

								textPart3D.Y = geoLine3D.InnerPoint3D.Y;
								textPart3D.Z = geoLine3D.InnerPoint3D.Z;

								GeoText3D text3d = m_currentGeoText3DMessage == null ? GetGeoText3DMessage() : m_currentGeoText3DMessage;
								text3d.AddPart(textPart3D);

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

								int index = SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.IndexOf(m_messageTag);
								if (index >= 0)
								{
									SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.Remove(index);
								}
								//ClearTextMessageTag();
								SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.Add(text3d, m_messageTag);
							}
						}

						else if (SmObjectLocator.getInstance().GlobeObject.Action == Action3D.MeasureTerrainDistance)
						{
							//添加部分段长度
							if (!Toolkit.IsZero(m_curLength))
							{
								if (m_point3Ds.Count >= 2)
								{
									m_point3Ds.RemoveRange(0, m_point3Ds.Count - 2);

									GeoLine3D geoLine3D = new GeoLine3D(m_point3Ds);
									String distanceUnit = "米";
									TextPart3D textPart3D = new TextPart3D();
									textPart3D.AnchorPoint = new Point3D(0, 0, 0);
									Double tempCurLength = m_curLength;
									textPart3D.Text = String.Format("{0:F2}{1}", tempCurLength, " " + distanceUnit);
									if (m_point3Ds[0].X > 0 && m_point3Ds[1].X > 0 ||
										m_point3Ds[0].X < 0 && m_point3Ds[1].X < 0)
									{
										textPart3D.X = geoLine3D.InnerPoint.X;
										textPart3D.Y = geoLine3D.InnerPoint.Y;
									}
									else
									{
										textPart3D.X = 180;
										textPart3D.Y = geoLine3D.InnerPoint.Y;
									}
									textPart3D.Z = 0;
									GeoText3D text3d = GetGeoText3DMessage();
									text3d.AddPart(textPart3D);
									text3d.TextStyle.FontHeight = 6;
									text3d.TextStyle.Alignment = TextAlignment.BottomLeft;
									text3d.TextStyle.BackColor = Color.Black;
									text3d.TextStyle.Outline = true;
									text3d.Style3D.AltitudeMode = AltitudeMode.ClampToGround;
									ClearTextMessageTag();
									SmObjectLocator.getInstance().GlobeObject.Scene.TrackingLayer.Add(text3d, m_messageTag);
								}
							}
						}
						else if (SmObjectLocator.getInstance().GlobeObject.Action == Action3D.MeasureArea)
						{

						}
						else if (SmObjectLocator.getInstance().GlobeObject.Action == Action3D.MeasureAltitude)
						{
							//清除量算高度信息
							if (!(Toolkit.IsZero(m_curAltitude)))
							{
								EndOneMeasure();
							}
						}

					}
				}
			}
		}