From 315766f6501751233fddda8a0e876efc74cdcebe Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 03 一月 2024 12:54:37 +0800
Subject: [PATCH] 添加坡度分析功能

---
 TEWin/FrmWin.cs                                        |   18 +
 TEWin/Resources/SlopeCursor/SlopeCursor.ico            |    0 
 TEWin/FrmTool.cs                                       |    1 
 TEWin/Resources/SlopeCursor/Query.png                  |    0 
 TEWin/Resources/SlopeCursor/cursor_m.cur               |    0 
 TEWin/Resources/SlopeCursor/Images/StartCursor.gif     |    0 
 TEWin/Resources/SlopeCursor/Lang.js                    |   31 ++
 TEWin/TEWin.csproj                                     |   33 ++
 TEWin/Resources/SlopeCursor/Images/SlopeCursorIcon.gif |    0 
 TEWin/Resources/SlopeCursor/arrow.png                  |    0 
 TEWin/Resources/SlopeCursor/help.html                  |  105 +++++++
 TEWin/Resources/SlopeCursor/ToolIcon.png               |    0 
 TEWin/Resources/SlopeCursor/cursor_wait.cur            |    0 
 TEWin/Resources/SlopeCursor/SlopeCursor.html           |  604 +++++++++++++++++++++++++++++++++++++++++++
 14 files changed, 788 insertions(+), 4 deletions(-)

diff --git a/TEWin/FrmTool.cs b/TEWin/FrmTool.cs
index bb937e6..44da8ac 100644
--- a/TEWin/FrmTool.cs
+++ b/TEWin/FrmTool.cs
@@ -26,7 +26,6 @@
 
 
             int code = Convert.ToInt32(str, 16);
-
             win.InvokeProc(code);
         }
     }
diff --git a/TEWin/FrmWin.cs b/TEWin/FrmWin.cs
index 4b04207..ff12251 100644
--- a/TEWin/FrmWin.cs
+++ b/TEWin/FrmWin.cs
@@ -88,6 +88,19 @@
         {
             switch (m.Msg)
             {
+                case 0x64:
+                    InvokeByCode(m.WParam.ToInt32()); break;
+                case 0x4A:
+                    MessageBox.Show("Test."); break;
+                default:
+                    base.DefWndProc(ref m); break;
+            }
+        }
+
+        public void InvokeByCode(int code)
+        {
+            switch (code)
+            {
                 case 0xc0: // 閲嶇疆榧犳爣妯″紡
                     SG.Window.SetInputMode(0); break;
                 case 0xc1: // 鎵撳紑鏁版嵁鏂规/鎵撳紑鏄剧ず鍦烘櫙
@@ -149,15 +162,14 @@
                     SG.Command.Execute(1028, null); break;
                 case 0xd6: // 浼犵粺4D浜у搧娲剧敓(闆嗘垚osgblab)
                     InvokeOsgbLab(); break;
-                default:
-                    base.DefWndProc(ref m); break;
             }
         }
 
         public void InvokeProc(int code)
         {
             Message m = new Message();
-            m.Msg = code;
+            m.Msg = 0x4A;
+            m.WParam = new IntPtr(code);
 
             this.DefWndProc(ref m);
         }
diff --git a/TEWin/Resources/SlopeCursor/Images/SlopeCursorIcon.gif b/TEWin/Resources/SlopeCursor/Images/SlopeCursorIcon.gif
new file mode 100644
index 0000000..e4002fc
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/Images/SlopeCursorIcon.gif
Binary files differ
diff --git a/TEWin/Resources/SlopeCursor/Images/StartCursor.gif b/TEWin/Resources/SlopeCursor/Images/StartCursor.gif
new file mode 100644
index 0000000..dee9164
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/Images/StartCursor.gif
Binary files differ
diff --git a/TEWin/Resources/SlopeCursor/Lang.js b/TEWin/Resources/SlopeCursor/Lang.js
new file mode 100644
index 0000000..38f1794
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/Lang.js
@@ -0,0 +1,31 @@
+锘縎GLang.lang = $.extend(SGLang.lang,{
+    ToolTitle: "SmartEarth, Inc.",
+    ToolName: "鍧″悜绠ご ",
+    ToolName1: "鍧″悜绠ご",
+    help: "甯姪",
+    Text3: "鍒涘缓",
+    Text4: "鍙栨秷",
+    Text5: "鍧″悜绠ご淇℃伅",
+    Text6: "鍧愭爣:",
+    Text7: "鏈�澶ф鏂滅巼",
+    Text8: "鏈�澶ф鏂滅巼鏈濆悜",
+    Text9: "鏈�澶ц礋鏂滅巼",
+    Text10: "鏈�澶ц礋鏂滅巼鏈濆悜",
+    Text11: "閲忔祴璺濈",
+    Text12: "璀︽垝鍧″害",
+    Text13: "鍗遍櫓鍧″害",
+    Text14: "鏄剧ず绠ご鏈濆悜",
+    Text15: "鍧″害鏌ヨ宸ュ叿涓嚭鐜版剰澶栭敊璇�",
+    Text16: "m",
+    Text17: "deg",
+    Text18: "鏄剧ず鏈�澶у潯搴﹀��",
+    Text19: "浠庝笉",
+    Text20: "鐐瑰嚮鏃�",
+    Text21: "鎬绘槸",
+    Text22: "鏄剧ず鍧″悜",
+    Text23: "鏄剧ず鍧愭爣淇℃伅",
+    Text24: "",
+    Text25: "",
+
+    Text99: "瀹屾垚"
+});
\ No newline at end of file
diff --git a/TEWin/Resources/SlopeCursor/Query.png b/TEWin/Resources/SlopeCursor/Query.png
new file mode 100644
index 0000000..caf6bc7
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/Query.png
Binary files differ
diff --git a/TEWin/Resources/SlopeCursor/SlopeCursor.html b/TEWin/Resources/SlopeCursor/SlopeCursor.html
new file mode 100644
index 0000000..41634fd
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/SlopeCursor.html
@@ -0,0 +1,604 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <title>ToolTitle</title>
+    <meta http-equiv="X-UA-Compatible" content="IE=9" />
+    <!-- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -->
+
+    <link rel="StyleSheet" href="../Style.css" type="text/css">
+    <style>
+    </style>
+</head>
+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="border: 0px" id="Body"  class="hideUntillTranslated" onload="Init()">
+    <!--oncontextmenu="return false;">  onclick="bHide=true;HideOptionsNow()" > -->
+    <table border="0" width="100%" cellspacing="0" cellpadding="2">
+        <tr>
+            <td class="ToolTopArea" id="TopAreaTD" width="100%" valign="middle" >
+                <table border="0" width="100%" cellspacing="0" cellpadding="0">
+                    <tr>
+                        <td width="55px"><img style="margin-left:5px;" src="ToolIcon.png" alt="" /></td>
+                        <td id="TitleTD" align="center" class="s12w i18n">ToolName</td>
+                        <td align="right" id="CloseHelpTd"><img style="margin-right:5px;" alt="" src="../CommonImg/help.png" border="0" class="i18n" alt="help" title="help" onclick="DisplayHelpPopup6(SGLang.i18nFile('help.html'),SGLang.i18n('help'))" style="cursor: pointer;"></td>
+                    </tr>
+                </table>
+            </td>
+        </tr>
+        <tr>
+            <td  class="ToolTopSeperator"></td>
+        </tr>        <tr class="s8">
+            <td >
+                <table class="PropertiesSheet" cellspacing="0" cellpadding="2" >
+
+                  <tr class='TableOtherLine'>
+                        <td align="top" class="s8b i18n">
+                            <label for="createAs" class="i18n">Text18</label>
+                        </td>
+                        <td align="left">
+                            <select id="DisplayMinMaxSlope"  style="width:100px;" >
+                                <option class="i18n" value=0>Text19</option>
+                                <option class="i18n" value=1 >Text20</option>
+                                <option class="i18n" value=2 selected>Text21</option>
+                            </select>
+                        </td>
+                    </tr>
+                           
+                  <tr >
+                        <td align="top" class="s8b i18n">
+                            <label for="createAs" class="i18n">Text22</label>
+                        </td>
+                        <td align="left">
+                            <select id="DisplayHeadingSlope"  style="width:100px;" >
+                                <option class="i18n" value=0 selected>Text19</option>
+                                <option class="i18n" value=1 >Text20</option>
+                                <option class="i18n" value=2 >Text21</option>
+                            </select>
+                        </td>
+                    </tr>
+                           
+                  <tr class='TableOtherLine'>
+                        <td align="top" class="s8b i18n">
+                            <label for="createAs" class="i18n">Text23</label>
+                        </td>
+                        <td align="left">
+                            <select id="DisplayCoordinateInfo"  style="width:100px;" >
+                                <option class="i18n" value=0 >Text19</option>
+                                <option class="i18n" value=1 selected>Text20</option>
+                                <option class="i18n" value=2 >Text21</option>
+                            </select>
+                        </td>
+                    </tr>
+                           
+
+                    <tr>
+                        <td class="s8b">
+                            <label for="createAs" class="i18n">Text11</label>
+                        </td>
+                        <td align="left">
+                        <input id="distanceID"  type="text"  value="10" style="width:100px" /> <label for="createAs" class="i18n">Text16</label>
+                        </td>            
+                    </tr>  
+                   <tr class='TableOtherLine'>
+                        <td align="top" class="s8b i18n">
+                            <label for="createAs" class="i18n">Text12</label>
+                        </td>
+                        <td align="left">
+                        <input id="warningSlopeID"  type="text"  value="10"  style="width:100px; background-color:#FFD7C1"/> <label for="createAs" class="i18n">Text17</label>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td class="s8b">
+                            <label for="createAs" class="i18n">Text13</label>
+                        </td>
+                        <td align="left">
+                        <input id="alertSlopeID"  type="text" value="15"  style="width:100px; background-color:#FFD7D7;"/> <label for="createAs" class="i18n">Text17</label>
+                        </td>            
+                    </tr>  
+ 
+                    <tr>
+                    <td colspan="2" align="center" class="ToolButtonsArea">
+                          
+                    <button id="groupButton" class="MenuButton MenuButtonLast" onclick="StartStop()"><img src="./query.png" /><br />         <span id="startstopSpan" class="i18n">Text3</span></button>
+
+                        </td>
+                        </tr>
+    </table>
+
+ <object id="SGWorld" classid="CLSID:3a4f9197-65a8-11d5-85c1-0001023952c1">    </object>
+<script language="javascript" src="../ToolsCommon65.js"></script>
+<script language="JavaScript">
+function DetectTEMode()
+{
+var vMode = document.documentMode;
+var rMode = 'IE5 Quirks Mode';
+if(vMode == 8){
+  rMode = 'IE8 Standards Mode';
+} else if(vMode == 7){
+  rMode = 'IE7 Strict Mode';
+} else if(vMode == 9){
+  rMode = 'IE9 Strict Mode';
+}
+//alert('Rendering in: ' + rMode);
+}
+DetectTEMode();
+
+var isStart = false;
+var gDisplayHeadingSlope ;
+var gDisplayMinMaxSlope ;
+var gDisplayCoordinateInfo;
+var gLastClickMouseX;
+var gLastClickMouseY;
+///var popupMsg;
+var timeoutID;
+var measureDistance;
+var warningSlope;
+var alertSlope;
+var arrowMaxPositive;
+var arrowMaxNegative;
+var arrowHeading;
+var labelMaxPositive;
+var labelMaxNegative;
+var labelHeading;
+var labelCoordinateInfo;
+var groupID;
+var colorNormalPositive ;
+var colorNormalNegative;
+var colorHeading;
+var colorLinewarning ;
+var colorLineAlert;
+var colorLabel;
+var colorTextNormal;
+var colorTextWarning;
+var colorTextAlert;
+var gNameIndex = 1;
+
+var cameraClickPos;
+var rootId;
+//--------------
+// Init
+function Init() {
+
+    SGWorld.AttachEvent("onFrame", onFrame);
+    SGWorld.AttachEvent("onLButtonDown", onLButtonDown);
+    SGWorld.AttachEvent("onLButtonUp", onLButtonUp);
+    SGWorld.AttachEvent("onRButtonUp", onRButtonUp);
+    SGWorld.AttachEvent("OnInputModeChanged", OnInputModeChanged);
+    rootId = GetParamValue("rootId", SGWorld.ProjectTree.RootID);
+    groupID = -1;
+
+    colorNormalPositive = SGWorld.Creator.CreateColor(255, 255, 255, 255);
+    colorNormalNegative = SGWorld.Creator.CreateColor(197, 197, 197, 255);
+    colorHeading = SGWorld.Creator.CreateColor(198, 255, 198, 255);
+
+    colorLinewarning = SGWorld.Creator.CreateColor(238, 173, 23, 255);
+    colorLineAlert = SGWorld.Creator.CreateColor(255, 117, 117, 255);
+    colorLabel = SGWorld.Creator.CreateColor(255, 255, 255, 255);
+    colorTextNormal = SGWorld.Creator.CreateColor(230, 230, 230,  0);
+    colorTextWarning = SGWorld.Creator.CreateColor(238, 173, 23 , 0 );
+    colorTextAlert = SGWorld.Creator.CreateColor(255,117,117, 0);
+    Reset(true, false);
+
+    
+
+}
+
+//------------------
+// Reset
+//------------------
+function Reset(FirstTime, FromMouseInputMode) {
+
+    try {
+        startstopSpan.innerHTML = SGLang.i18n("Text3");
+        if (isStart && SGWorld.Project.Name != "") {
+            ///ClosePopup();
+          //  alert(SGWorld.Project.Name);
+            isStart = false;
+            deleteObjs();
+        }
+
+        arrowMaxPositive = null;
+        arrowMaxNegative = null;
+        labelMaxPositive = null;
+        labelMaxNegative = null;
+        arrowHeading = null;
+        labelHeading = null;
+        labelCoordinateInfo = null;
+        gLastClickMouseX = -1;
+        gLastClickMouseY = -1;
+        isStart = false;
+
+        document.getElementById("distanceID").disabled = false;
+        document.getElementById("alertSlopeID").disabled = false;
+        document.getElementById("warningSlopeID").disabled = false;
+        document.getElementById("DisplayHeadingSlope").disabled = false;
+        document.getElementById("DisplayMinMaxSlope").disabled = false;
+        document.getElementById("DisplayCoordinateInfo").disabled = false;
+
+
+        if (FirstTime != 1 && FromMouseInputMode == 0) {
+            //        alert("input");
+            SGWorld.Window.SetInputMode(0);
+        }
+    }
+    catch (err) { isStart = false; }
+}
+
+//--------------
+// StartStop
+function StartStop() {
+
+    if (!isStart) {
+        isStart = true;
+        document.getElementById("distanceID").disabled = true;
+        document.getElementById("alertSlopeID").disabled = true;
+        document.getElementById("warningSlopeID").disabled = true;
+        document.getElementById("DisplayHeadingSlope").disabled = true;
+        document.getElementById("DisplayMinMaxSlope").disabled = true;
+        document.getElementById("DisplayCoordinateInfo").disabled = true;
+
+        startstopSpan.innerHTML = SGLang.i18n("Text4");
+        measureDistance = document.getElementById("distanceID").value;
+        alertSlope = document.getElementById("alertSlopeID").value;
+        warningSlope = document.getElementById("warningSlopeID").value;
+
+        gDisplayHeadingSlope = document.getElementById("DisplayHeadingSlope").value ;
+        gDisplayMinMaxSlope = document.getElementById("DisplayMinMaxSlope").value ;
+        gDisplayCoordinateInfo = document.getElementById("DisplayCoordinateInfo").value ;
+
+        createObjs(false);
+        
+        SGWorld.Window.SetInputMode(1, abspath() + "/cursor_m.cur", true);
+
+    }
+    else {
+        //        clearInterval (timeoutID);
+        Reset(false,false);
+    }
+
+}
+
+//------------
+//onFrame
+function onFrame() {
+    if (isStart == false)
+        return;
+
+    displaySlopeInfo(false);
+
+    }
+
+//------------
+//onLButtonDown
+function onLButtonDown(Flag, X, Y) {
+    if (isStart == false)
+        return;
+    SGWorld.Window.SetInputMode(1, abspath()+"/cursor_wait.cur", true);
+
+    // Save camera location to identify dragging 
+    cameraClickPos = SGWorld.Navigate.GetPosition();    
+}
+ //------------
+//onLButtonUp
+function onLButtonUp(Flag, X, Y) {
+    if (isStart == false)
+        return;
+
+    // Creating objects only if not dragging the terrain
+    if (cameraClickPos.IsEqual (SGWorld.Navigate.GetPosition()))
+        createObjs(true);
+    SGWorld.Window.SetInputMode(1, abspath() + "/cursor_m.cur", true);
+
+}
+
+//------------
+//onRButtonUp
+function onRButtonUp(Flag, X, Y) {
+    if (isStart == false)
+        return;
+        Reset (0,0);
+    return true;
+
+}
+//------------
+//OnInputModeChanged
+function OnInputModeChanged (newMode) {
+
+    Reset(0, 1);
+}
+
+//------------
+//createObjs
+function createObjs(fromClick) {
+
+    var subGroupID;
+
+   // try {
+
+        var tmpGroup = SGWorld.ProjectTree.CreateGroup(SGLang.i18n("ToolName"), SGWorld.ProjectTree.HiddenGroupID);
+
+        if (fromClick) {
+
+            displaySlopeInfo(true);  // Add tooltips to the objects
+
+            if (groupID == -1)
+                groupID = SGWorld.ProjectTree.CreateGroup(SGLang.i18n("ToolName"), rootId);
+
+            try {
+                subGroupID = SGWorld.ProjectTree.CreateGroup(SGLang.i18n("ToolName") + gNameIndex, groupID);
+            }
+            catch (err) {
+                groupID = SGWorld.ProjectTree.CreateGroup(SGLang.i18n("ToolName"), rootId);
+                subGroupID = SGWorld.ProjectTree.CreateGroup(SGLang.i18n("ToolName")+gNameIndex, groupID);
+            }
+
+            if (gDisplayMinMaxSlope > 0) {
+                SGWorld.ProjectTree.SetParent(arrowMaxPositive.ID, subGroupID);
+                SGWorld.ProjectTree.SetParent(arrowMaxNegative.ID, subGroupID);
+                SGWorld.ProjectTree.SetParent(labelMaxPositive.ID, subGroupID);
+                SGWorld.ProjectTree.SetParent(labelMaxNegative.ID, subGroupID);
+            }
+            if (gDisplayHeadingSlope > 0) {
+                SGWorld.ProjectTree.SetParent(arrowHeading.ID, subGroupID);
+                SGWorld.ProjectTree.SetParent(labelHeading.ID, subGroupID);
+            }
+            if (gDisplayCoordinateInfo > 0) {
+                SGWorld.ProjectTree.SetParent(labelCoordinateInfo.ID, subGroupID);
+            }
+
+            gNameIndex += 1;
+        }
+
+        var pos = SGWorld.Creator.CreatePosition(1.0, 1.0, 2.0, 3, 0, 0, 0);
+        var labelStyle = SGWorld.Creator.CreateLabelStyle(0);
+        labelStyle.Bold = true;
+        labelStyle.LineToGround = false;
+        labelStyle.Scale = measureDistance / 20;
+        labelStyle.FontSize = 10;
+        labelStyle.BackgroundColor = SGWorld.Creator.CreateColor(15, 15, 15, 0);
+
+        var arrowStyle = SGWorld.Creator.CreateLabelStyle(0);
+        arrowStyle.LimitScreenSize = false;
+        arrowStyle.Scale =  measureDistance / 100;
+        arrowStyle.LockMode = 1;
+
+        // Min/Max slopes arrows and labels
+        if (gDisplayMinMaxSlope > 0) {
+            arrowMaxPositive = SGWorld.Creator.CreateImageLabel(pos, abspath() + "./arrow.png", arrowStyle, tmpGroup, "max positive");
+            
+            // Max negative Arrow
+            arrowMaxNegative = SGWorld.Creator.CreateImageLabel(pos, abspath() + "./arrow.png", arrowStyle, tmpGroup, "max negative");
+
+            // Labels
+            labelMaxPositive = SGWorld.Creator.CreateLabel(pos, "positive", "", labelStyle, tmpGroup, "max positive label");
+            labelMaxNegative = SGWorld.Creator.CreateLabel(pos, "negative", "", labelStyle, tmpGroup, "max negative label");
+        }
+        // Heading arrow and label
+        if (gDisplayHeadingSlope > 0) {
+            arrowStyle.Scale = measureDistance / 50;
+            arrowHeading = SGWorld.Creator.CreateImageLabel(pos, abspath() + "./arrow.png", arrowStyle, tmpGroup, "Heading");
+            labelHeading = SGWorld.Creator.CreateLabel(pos, "Heading", "", labelStyle, tmpGroup, "Heading label");
+        }
+
+        if (gDisplayCoordinateInfo > 0) {
+            labelStyle.LineToGround = true;
+            labelStyle.MultilineJustification = "Left";
+            labelCoordinateInfo = SGWorld.Creator.CreateLabel(pos, "Info", "", labelStyle, tmpGroup, "Coordinate Info label");
+        }
+//    }
+//    catch (err) { alert(SGLang.i18n("Text15") + err); Reset(0, 0); }
+}
+//------------
+//deleteObjs
+function deleteObjs() {
+    try {
+        if (arrowMaxPositive != null)
+            SGWorld.Creator.DeleteObject(arrowMaxPositive.ID);
+        if (arrowMaxNegative != null)
+            SGWorld.Creator.DeleteObject(arrowMaxNegative.ID);
+        if (labelMaxPositive != null)
+            SGWorld.Creator.DeleteObject(labelMaxPositive.ID);
+        if (labelMaxNegative != null)
+            SGWorld.Creator.DeleteObject(labelMaxNegative.ID);
+        if (arrowHeading != null)
+            SGWorld.Creator.DeleteObject(arrowHeading.ID);
+        if (labelHeading != null)
+            SGWorld.Creator.DeleteObject(labelHeading.ID);
+        if (labelCoordinateInfo != null)
+            SGWorld.Creator.DeleteObject(labelCoordinateInfo.ID);
+    }
+    catch (err) { alert(SGLang.i18n("Text15") + err); Reset(0, 0); }
+}
+//------------
+//displaySlopeInfo
+function displaySlopeInfo(fromClick) {
+    if (!isStart) {
+        return false;
+    }
+
+    try {
+
+        var slopeSampling = 10;
+        var getGroundHeighType = 0;
+        if (fromClick) {
+            slopeSampling = 1;
+            getGroundHeighType = 2;
+        }
+
+        var mouseInfo = SGWorld.Window.GetMouseInfo();
+        var CursorInfo = SGWorld.Window.PixelToWorld(mouseInfo.X, mouseInfo.Y, 0 + 1 + 8192);
+
+        // After clicking the left mouse and recalculate the slopes with better accuracy do not recalculate until the mouse is moved
+        if (fromClick == false && gLastClickMouseX != -1 && gLastClickMouseX == mouseInfo.X && gLastClickMouseY == mouseInfo.Y)
+            return false;
+
+        if (fromClick) {
+            gLastClickMouseX = mouseInfo.X;
+            gLastClickMouseY = mouseInfo.Y;
+        }
+        /*Arik  
+         if (CursorInfo.Type != 0)
+            return false;    */
+
+        //Groud height in mouse location
+        var groundInfo = SGWorld.Terrain.GetGroundHeightInfo(CursorInfo.Position.X, CursorInfo.Position.Y, getGroundHeighType, true);
+        //Ground Height around mouse location
+        var i;
+        var maxPositiveAlt = -9999999;
+        var maxPositivePos;
+        var maxNegativeAlt = 9999999;
+        var maxNegativePos;
+        var destGroundInfo;
+        var headingPos;
+        var newPos = CursorInfo.Position.Copy();
+        // find min/max slopes
+        if (gDisplayMinMaxSlope == 2 || (gDisplayMinMaxSlope == 1 && fromClick)) {
+            for (i = 0; i < 360; i = i + slopeSampling) {
+                newPos = CursorInfo.Position.Copy();
+                newPos.Yaw = i;
+                SGWorld.CoordServices.MoveCoordEx(newPos, measureDistance, 0, 0);
+                destGroundInfo = SGWorld.Terrain.GetGroundHeightInfo(newPos.X, newPos.Y, getGroundHeighType, true);
+                if (destGroundInfo.Position.Altitude > maxPositiveAlt) {
+                    maxPositiveAlt = destGroundInfo.Position.Altitude;
+                    maxPositivePos = destGroundInfo.Position.Copy();
+                }
+
+                if (destGroundInfo.Position.Altitude < maxNegativeAlt) {
+                    maxNegativeAlt = destGroundInfo.Position.Altitude;
+                    maxNegativePos = destGroundInfo.Position.Copy();
+                }
+                //   measureDistance
+            }
+
+            if (maxPositiveAlt == maxNegativeAlt) {  // flat area - make sure not to position both arrows on the same position
+                newPos = CursorInfo.Position.Copy();
+                newPos.Yaw = 180;
+                SGWorld.CoordServices.MoveCoordEx(newPos, measureDistance, 0, 0);
+                destGroundInfo = SGWorld.Terrain.GetGroundHeightInfo(newPos.X, newPos.Y, getGroundHeighType, true);
+                maxPositiveAlt = destGroundInfo.Position.Altitude;
+                maxPositivePos = destGroundInfo.Position.Copy();
+            }
+        }
+        // heading arrow
+        if (gDisplayHeadingSlope == 2 || (gDisplayHeadingSlope == 1 && fromClick)) {
+            newPos = CursorInfo.Position.Copy();
+            newPos.Yaw = SGWorld.Navigate.GetPosition().Yaw;
+            SGWorld.CoordServices.MoveCoordEx(newPos, measureDistance * 2, 0, 0);
+            destGroundInfo = SGWorld.Terrain.GetGroundHeightInfo(newPos.X, newPos.Y, 2, true);
+            headingPos = destGroundInfo.Position.Copy();
+        }
+        // Set the object properties according to the new values
+        setObjsPosition(CursorInfo.Position, maxPositivePos, maxNegativePos, headingPos, fromClick);
+
+        // Send information to the Information Dialog
+        ///  SGWorld.Window.ShowMessageBarText("##SlopeCursor## X:" + CursorInfo.Position.X.toFixed(6) + "<br/>Y: " + CursorInfo.Position.Y.toFixed(6) + "<br/> Ground elevation: " + groundInfo.Position.Altitude.toFixed(2) + " m AMSL" + "<br/>Max elevation in range: = " + maxPositiveAlt.toFixed(2) + "<br/>Min elevation in range = " + maxNegativeAlt.toFixed(2), 0, 1);
+    }
+    catch (err) {        alert(SGLang.i18n("Text15") + err);   Reset(0, 0); } 
+}
+
+//-----------------
+// setObjsPosition
+function setObjsPosition(CursorPosition, maxPositivePos, maxNegativePos, headingPos, fromClick) {
+
+ try {
+    // Set Min/Max slope arrows and labels
+     if (gDisplayMinMaxSlope == 2 || (gDisplayMinMaxSlope == 1 && fromClick)) {
+
+         // Max positive angle
+         CursorPosition = CursorPosition.AimTo(maxPositivePos);
+
+         //arrowMaxPositive.Position = CursorPosition.Copy().MoveToward(maxPositivePos, measureDistance );
+         arrowMaxPositive.Position = CursorPosition.Copy().AimTo(maxPositivePos);
+         labelMaxPositive.Position = maxPositivePos.Copy();
+         labelMaxPositive.Position.Altitude = labelMaxPositive.Position.Altitude + measureDistance / 2;
+         if (CursorPosition.Pitch > alertSlope) {
+             labelMaxPositive.Style.TextColor = colorTextAlert;
+             arrowMaxPositive.Style.IconColor = colorLineAlert;
+         }
+         else if (CursorPosition.Pitch > warningSlope) {
+             labelMaxPositive.Style.TextColor = colorTextWarning;
+             arrowMaxPositive.Style.IconColor = colorLinewarning;
+         }
+         else {
+             labelMaxPositive.Style.TextColor = colorTextNormal;
+             arrowMaxPositive.Style.IconColor = colorNormalPositive;
+         }
+         var positiveAltDiff = maxPositivePos.Altitude - CursorPosition.Altitude;
+         if (fromClick)
+             labelMaxPositive.Tooltip.Text = "Max positive slope altitude = " + maxPositivePos.Altitude.toFixed(2) + " m AMSL (+" + positiveAltDiff.toFixed(2) + "m)";
+         labelMaxPositive.Text = "+" + CursorPosition.Pitch.toFixed(2) + String.fromCharCode(186);//  degree sign;
+
+         // Max negative angle
+         CursorPosition = CursorPosition.AimTo(maxNegativePos);
+         //arrowMaxNegative.Position = CursorPosition.Copy().MoveToward(maxNegativePos, measureDistance );
+         arrowMaxNegative.Position = CursorPosition.Copy().AimTo(maxNegativePos);
+         labelMaxNegative.Position = maxNegativePos.Copy();
+         labelMaxNegative.Position.Altitude = labelMaxNegative.Position.Altitude + measureDistance / 2;
+
+         if (CursorPosition.Pitch < -alertSlope) {
+             labelMaxNegative.Style.TextColor = colorTextAlert;
+             arrowMaxNegative.Style.IconColor = colorLineAlert;
+         }
+         else if (CursorPosition.Pitch < -warningSlope) {
+             labelMaxNegative.Style.TextColor = colorTextWarning;
+             arrowMaxNegative.Style.IconColor = colorLinewarning;
+         } else {
+             labelMaxNegative.Style.TextColor = colorTextNormal;
+             arrowMaxNegative.Style.IconColor = colorNormalNegative;
+         }
+         var negativeAltDiff = maxNegativePos.Altitude - CursorPosition.Altitude;
+         if (fromClick)
+             labelMaxNegative.Tooltip.Text = "Max negative slope altitude: " + maxNegativePos.Altitude.toFixed(2) + " m AMSL (" + negativeAltDiff.toFixed(2) + "m)";
+         labelMaxNegative.Text = CursorPosition.Pitch.toFixed(2) + String.fromCharCode(186); // degree sign;
+     }
+
+    // heading
+    if (gDisplayHeadingSlope == 2 || (gDisplayHeadingSlope == 1 && fromClick)) {
+        CursorPosition = CursorPosition.AimTo(headingPos);
+        //arrowHeading.Position = CursorPosition.Copy().MoveToward(headingPos, measureDistance*2 );
+        arrowHeading.Position = CursorPosition.Copy().AimTo(headingPos);
+        labelHeading.Position = headingPos.Copy();
+        labelHeading.Position.Altitude = labelHeading.Position.Altitude + measureDistance / 2;
+        arrowHeading.Style.IconColor = colorNormalPositive;
+        if (Math.abs(CursorPosition.Pitch) > alertSlope) {
+            labelHeading.Style.TextColor = colorTextAlert;
+        }
+        else if (Math.abs(CursorPosition.Pitch) > warningSlope) {
+            labelHeading.Style.TextColor= colorTextWarning;
+        } else {
+            labelHeading.Style.TextColor = colorTextNormal;
+        }
+        var headingAltDiff = headingPos.Altitude - CursorPosition.Altitude;
+        if (fromClick)
+            labelHeading.Tooltip.Text = "Heading slope altitude: " + headingPos.Altitude.toFixed(2) + " m AMSL (" + headingAltDiff.toFixed(2) + "m)";
+        if (CursorPosition.Pitch.toFixed(2) > 0 )
+            labelHeading.Text = "+" + CursorPosition.Pitch.toFixed(2) + String.fromCharCode(186); //degree sign;
+        else
+            labelHeading.Text = CursorPosition.Pitch.toFixed(2) + String.fromCharCode(186); //degree sign;
+    }
+
+    // Coordinate information
+    if (gDisplayCoordinateInfo == 2 || (gDisplayCoordinateInfo == 1 && fromClick)) {
+
+        labelCoordinateInfo.Position = CursorPosition.Copy();
+        labelCoordinateInfo.Position.Altitude = labelCoordinateInfo.Position.Altitude + measureDistance*1;
+        //labelCoordinateInfo.Position.AltitudeType = 0;
+        ///labelHeading.Style.BackgroundColor = colorTextNormal;
+        labelCoordinateInfo.Text = "X: " + CursorPosition.X.toFixed(6) + "\r\nY: " + CursorPosition.Y.toFixed(6) + "\r\nAlt: " + CursorPosition.Altitude.toFixed(2) + " m AMSL ";
+    }
+}
+catch (err) { alert(SGLang.i18n("Text15") + err); Reset(0, 0); } 
+}
+//--------------
+// ClosePopup
+function ClosePopup() {
+    try {
+    SGWorld.Window.RemovePopup(popupMsg);
+    }
+    catch (err) { }
+}
+</script>
+
+</body>
+</html>
+
+
+<!--Sig:00000040nuHMf1X22o3RTIYLzstK4pR9lnp3fIXFjHzi6jZqBuGn#IpBNFBrjWjF1UjdIGs2c6x8a40lKqIavlWVIElrXDJJ-->
diff --git a/TEWin/Resources/SlopeCursor/SlopeCursor.ico b/TEWin/Resources/SlopeCursor/SlopeCursor.ico
new file mode 100644
index 0000000..a657790
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/SlopeCursor.ico
Binary files differ
diff --git a/TEWin/Resources/SlopeCursor/ToolIcon.png b/TEWin/Resources/SlopeCursor/ToolIcon.png
new file mode 100644
index 0000000..4bdc0d0
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/ToolIcon.png
Binary files differ
diff --git a/TEWin/Resources/SlopeCursor/arrow.png b/TEWin/Resources/SlopeCursor/arrow.png
new file mode 100644
index 0000000..326ada4
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/arrow.png
Binary files differ
diff --git a/TEWin/Resources/SlopeCursor/cursor_m.cur b/TEWin/Resources/SlopeCursor/cursor_m.cur
new file mode 100644
index 0000000..4e0076c
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/cursor_m.cur
Binary files differ
diff --git a/TEWin/Resources/SlopeCursor/cursor_wait.cur b/TEWin/Resources/SlopeCursor/cursor_wait.cur
new file mode 100644
index 0000000..7aa16ff
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/cursor_wait.cur
Binary files differ
diff --git a/TEWin/Resources/SlopeCursor/help.html b/TEWin/Resources/SlopeCursor/help.html
new file mode 100644
index 0000000..b49d0da
--- /dev/null
+++ b/TEWin/Resources/SlopeCursor/help.html
@@ -0,0 +1,105 @@
+<html>
+<HEAD>
+<TITLE>TerraExplorer Pro - Skyline Software Systems, Inc.</TITLE>
+<LINK REL=StyleSheet HREF="../Style.css" TYPE="text/css">
+</head>
+<body>
+		<table border=0 cellPadding=0 CELLSPACING=0 class="s9" width=100%>
+		<tr><td class="s12b" align=center>
+			Slope Cursor tool
+		</tD></tr>
+		<tr><td>
+		<br>
+
+<div class=WordSection1>
+
+<p class=MsoNormal>The Slope Cursor tool displays information about a selected location including: its coordinates, altitude, and maximum positive/maximum negative slope values in a specified radius around the selected point.  </p>
+
+<h3>To use the Slope Cursor tool:</h3>
+
+<p class=MsoNormal>&nbsp;1. Set the Slope Cursor properties</p>
+
+<table class=SkyTable border=1 cellspacing=0 cellpadding=0 width=535
+ style='width:401.0pt;margin-left:.35in;border-collapse:collapse;border:none'>
+ <tr>
+  <td width=115 valign=top style='width:86.05pt;border:solid #4BACC6 1.0pt;
+  background:#D2EAF1;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Display Max Slope Values</p>
+  </td>
+  <td width=420 valign=top style='width:314.95pt;border:solid #4BACC6 1.0pt;
+  border-left:none;background:#D2EAF1;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Defines whether the maximum positive and maximum negative slope values are displayed. Choose between <b>Never, On Click</b> and <b>Always</b>.</p>
+  </td>
+ </tr>
+
+ <tr>
+  <td width=115 valign=top style='width:86.05pt;border:solid #4BACC6 1.0pt;
+  background:white;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Display Heading Slope</p>
+  </td>
+  <td width=420 valign=top style='width:314.95pt;border:solid #4BACC6 1.0pt;
+  border-left:none;background:white;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Defines whether the heading slope value is displayed. Choose between <b>Never, On Click</b> and <b>Always</b>. The heading is the current direction of the camera.
+</p>
+  </td>
+ </tr>
+
+ <tr>
+  <td width=115 valign=top style='width:86.05pt;border:solid #4BACC6 1.0pt;
+  background:#D2EAF1;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Display Coordinate Info</p>
+  </td>
+  <td width=420 valign=top style='width:314.95pt;border:solid #4BACC6 1.0pt;
+  border-left:none;background:#D2EAF1;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Defines whether the selected coordinate information is displayed. Choose between <b>Never, On Click</b> and <b>Always</b>.</p>
+  </td>
+ </tr>
+
+ <tr>
+  <td width=115 valign=top style='width:86.05pt;border:solid #4BACC6 1.0pt;
+  background:white;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Measure Distance</p>
+  </td>
+  <td width=420 valign=top style='width:314.95pt;border:solid #4BACC6 1.0pt;
+  border-left:none;background:white;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Defines the measurement radius around the center point.</p>
+  </td>
+ </tr>
+ <tr>
+  <td width=115 valign=top style='width:86.05pt;border:solid #4BACC6 1.0pt;
+  border-top:none;background:#D2EAF1;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Alert Slope</p>
+  </td>
+  <td width=420 valign=top style='width:314.95pt;border-top:none;border-left:
+  none;border-bottom:solid #4BACC6 1.0pt;border-right:solid #4BACC6 1.0pt;
+  background:#D2EAF1;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Apply colors to slope based on Alert rating levels.</p>
+  </td>
+ </tr>
+ <tr>
+  <td width=115 valign=top style='width:86.05pt;border:solid #4BACC6 1.0pt;
+  border-top:none;background:white;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Danger Slope</p>
+  </td>
+  <td width=420 valign=top style='width:314.95pt;border-top:none;border-left:
+  none;border-bottom:solid #4BACC6 1.0pt;border-right:solid #4BACC6 1.0pt;
+  background:white;padding:1.45pt 5.75pt 4.3pt 5.75pt'>
+  <p class=MsoNormal style='margin-left:.25in;text-indent:-.25in'>Apply colors to slope based on Danger rating levels.</p>
+  </td>
+ </tr>
+</table>
+<p >&nbsp;2. Click <b>Start</b> to initiate the Slope Cursor tool.</p>
+<p >&nbsp;3. Hover over the terrain to view slope arrows showing the maximum positive and maximum negative slope angles for the selected point.</p>
+<p >&nbsp;4. Left-click to recalculate slope values using a more precise method. The calculation may take a few seconds.</p>
+<p >&nbsp;5. Right-click or click Stop to exit Slope Cursor mode.</p>
+
+
+
+</div>
+			</td></tr>
+		</table>
+</body>
+</html>
+
+
+<!--Sig:00000040xWUdKq6k50ffNTVUrP6taKuX5.VPFLazlZMdtqhtD9VNuDEVRZjYltUyWgLn68Rb5pC1G1zIkRJzDRL3IlCZXQJJ-->
diff --git a/TEWin/TEWin.csproj b/TEWin/TEWin.csproj
index cf52400..e2d980d 100644
--- a/TEWin/TEWin.csproj
+++ b/TEWin/TEWin.csproj
@@ -170,6 +170,39 @@
     </COMReference>
   </ItemGroup>
   <ItemGroup>
+    <EmbeddedResource Include="Resources\SlopeCursor\arrow.png">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\cursor_m.cur">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\cursor_wait.cur">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\help.html">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\Images\SlopeCursorIcon.gif">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\Images\StartCursor.gif">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\Lang.js">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\Query.png">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\SlopeCursor.html">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\SlopeCursor.ico">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\SlopeCursor\ToolIcon.png">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
     <EmbeddedResource Include="Resources\AreaMeasurement\area.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </EmbeddedResource>

--
Gitblit v1.9.3