Commit 93688872e96c6843b65f2fdaae7e3273ecb47ece

Authored by toan
1 parent b169b88b18
Exists in master

2036 : Update draw Restriction

Showing 2 changed files with 77 additions and 40 deletions Side-by-side Diff

sources/RoboforkApp/DesignerCanvas.cs
... ... @@ -255,6 +255,9 @@
255 255 LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[currentLine];
256 256 lineGeometry.EndPoint = LastPoint;
257 257  
  258 + // Add node to curver postion
  259 + AddNode(lineGeometry.StartPoint, gGrpRedNode);
  260 +
258 261 // Check end route
259 262 if (IsEndRoute(_goalPoint, lineGeometry))
260 263 {
261 264  
262 265  
... ... @@ -263,27 +266,24 @@
263 266 return;
264 267 }
265 268  
266   - // Add node to curver postion
267   - AddNode(lineGeometry.StartPoint, gGrpRedNode);
268   -
269 269 // Draw curver line
270   - DrawCurver((LineGeometry)gGrpLine.Children[currentLine - 1], (LineGeometry)gGrpLine.Children[currentLine]);
  270 + //DrawCurver((LineGeometry)gGrpLine.Children[currentLine - 1], (LineGeometry)gGrpLine.Children[currentLine]);
271 271 }
272 272 else
273 273 {
274 274 // Remove current line
275 275 gGrpLine.Children.RemoveAt(currentLine);
276 276 // Remove yellow node
277   - if (gGrpYellowNode.Children.Count > 0)
278   - {
279   - gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1);
280   - gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1);
281   - }
282   - // Remove curver line
283   - if (gGrpCurverLine.Children.Count > 0)
284   - {
285   - gGrpCurverLine.Children.RemoveAt(gGrpCurverLine.Children.Count - 1);
286   - }
  277 + //if (gGrpYellowNode.Children.Count > 0)
  278 + //{
  279 + // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1);
  280 + // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1);
  281 + //}
  282 + //// Remove curver line
  283 + //if (gGrpCurverLine.Children.Count > 0)
  284 + //{
  285 + // gGrpCurverLine.Children.RemoveAt(gGrpCurverLine.Children.Count - 1);
  286 + //}
287 287  
288 288 // Set end point to finish draw line
289 289 LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[currentLine - 1];
... ... @@ -297,13 +297,13 @@
297 297 return;
298 298 }
299 299  
300   - // Re-draw cuver line
301   - if (currentLine > 1)
302   - {
303   - if (IsCurverNode((LineGeometry)gGrpLine.Children[currentLine - 2]
304   - , (LineGeometry)gGrpLine.Children[currentLine - 1]))
305   - DrawCurver((LineGeometry)gGrpLine.Children[currentLine - 2], (LineGeometry)gGrpLine.Children[currentLine - 1]);
306   - }
  300 + //// Re-draw cuver line
  301 + //if (currentLine > 1)
  302 + //{
  303 + // if (IsCurverNode((LineGeometry)gGrpLine.Children[currentLine - 2]
  304 + // , (LineGeometry)gGrpLine.Children[currentLine - 1]))
  305 + // DrawCurver((LineGeometry)gGrpLine.Children[currentLine - 2], (LineGeometry)gGrpLine.Children[currentLine - 1]);
  306 + //}
307 307 }
308 308  
309 309 // Draw new line
310 310  
... ... @@ -774,22 +774,27 @@
774 774 {
775 775 beforeLastLine.EndPoint = lastLine.EndPoint;
776 776 gGrpLine.Children.RemoveAt(index);
777   - // Remove yellow node
778   - if (gGrpYellowNode.Children.Count > 0)
779   - {
780   - gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1);
781   - gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1);
782   - }
783   - // Remove curver line
784   - if (gGrpCurverLine.Children.Count > 0)
785   - {
786   - gGrpCurverLine.Children.RemoveAt(gGrpCurverLine.Children.Count - 1);
787   - }
  777 + //// Remove yellow node
  778 + //if (gGrpYellowNode.Children.Count > 0)
  779 + //{
  780 + // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1);
  781 + // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1);
  782 + //}
  783 + //// Remove curver line
  784 + //if (gGrpCurverLine.Children.Count > 0)
  785 + //{
  786 + // gGrpCurverLine.Children.RemoveAt(gGrpCurverLine.Children.Count - 1);
  787 + //}
788 788 index = index - 1;
789 789 lastLine = (LineGeometry)gGrpLine.Children[index];
790 790 }
791 791 }
792 792  
  793 + if (index == gGrpRedNode.Children.Count + 1)
  794 + {
  795 + AddNode(lastLine.StartPoint, gGrpRedNode);
  796 + }
  797 +
793 798 if (lastLine.EndPoint.X == centerX && lastLine.EndPoint.Y == centerY)
794 799 return;
795 800  
... ... @@ -820,11 +825,13 @@
820 825 // Draw curver line
821 826 if (IsCurverNode(beforeLastLine, lastLine))
822 827 {
823   - AddNode(beforeLastLine.EndPoint, gGrpRedNode);
824   - if (GetDistance(lastLine.StartPoint, lastLine.EndPoint) > RADIUS_CURVER_LINE + 25)
825   - {
826   - DrawCurver(beforeLastLine, lastLine);
827   - }
  828 + EllipseGeometry ellipseGeometry = (EllipseGeometry)gGrpRedNode.Children[gGrpRedNode.Children.Count - 1];
  829 + ellipseGeometry.Center = lastLine.StartPoint;
  830 + //
  831 + //if (GetDistance(lastLine.StartPoint, lastLine.EndPoint) > RADIUS_CURVER_LINE + 25)
  832 + //{
  833 + //DrawCurver(beforeLastLine, lastLine);
  834 + //}
828 835 }
829 836 }
830 837  
... ... @@ -923,8 +930,15 @@
923 930 //DrawCurverLine(startPoint, endPoint, sweepDirection, gGrpCurverLine);
924 931  
925 932 // Add node to postion distance 1300mm
926   - AddNode(startPoint, gGrpYellowNode);
927   - AddNode(endPoint, gGrpYellowNode);
  933 + if (GetDistance(oldLine.StartPoint, oldLine.EndPoint) > RADIUS_CURVER_LINE)
  934 + {
  935 + AddNode(startPoint, gGrpYellowNode);
  936 + }
  937 +
  938 + if (GetDistance(newLine.StartPoint, newLine.EndPoint) > RADIUS_CURVER_LINE)
  939 + {
  940 + AddNode(endPoint, gGrpYellowNode);
  941 + }
928 942 }
929 943  
930 944 /// <summary>
... ... @@ -1783,6 +1797,11 @@
1783 1797  
1784 1798 public void CreateGoalPoint()
1785 1799 {
  1800 + if (isGoalDrawRoute)
  1801 + {
  1802 + return;
  1803 + }
  1804 +
1786 1805 isStartDrawRoute = false;
1787 1806 if (_goalPoint == null)
1788 1807 {
... ... @@ -1798,6 +1817,11 @@
1798 1817  
1799 1818 public void CreateStartPoint()
1800 1819 {
  1820 + if (isGoalDrawRoute)
  1821 + {
  1822 + return;
  1823 + }
  1824 +
1801 1825 isStartDrawRoute = false;
1802 1826 if (_startPoint == null)
1803 1827 {
sources/RoboforkApp/RoboforkMenu.xaml.cs
... ... @@ -42,6 +42,10 @@
42 42 string tag = ((TreeViewItem)sender).Tag.ToString();
43 43 switch (tag)
44 44 {
  45 + case "SetupRestriction":
  46 + DoBeginSetupRestriction();
  47 + break;
  48 +
45 49 case "SetStart":
46 50 DoBeginSetStart();
47 51 break;
... ... @@ -84,6 +88,10 @@
84 88 string tag = ((TreeViewItem)sender).Tag.ToString();
85 89 switch (tag)
86 90 {
  91 + case "SetupRestriction":
  92 + //DoBeginSetStart();
  93 + break;
  94 +
87 95 case "SetStart":
88 96 //DoBeginSetStart();
89 97 break;
... ... @@ -121,7 +129,12 @@
121 129 MyDesignerCanvas.Operation = DesignerCanvas.OperationState.DrawSetFreeNode;
122 130 }
123 131  
124   -
  132 + private void DoBeginSetupRestriction()
  133 + {
  134 + MyDesignerCanvas.Init();
  135 + MyDesignerCanvas.Operation = DesignerCanvas.OperationState.DrawObstract;
  136 + MyDesignerCanvas.mouseState = DesignerCanvas.MouseState.None;
  137 + }
125 138  
126 139 private void DoBeginSetStart()
127 140 {