|
|
cfceb0 |
using System;
|
|
|
cfceb0 |
using System.Drawing;
|
|
|
cfceb0 |
using System.Drawing.Imaging;
|
|
|
cfceb0 |
using System.Collections.Generic;
|
|
|
cfceb0 |
using System.Linq;
|
|
|
cfceb0 |
|
|
|
cfceb0 |
namespace Assistance {
|
|
|
cfceb0 |
public class Workarea {
|
|
|
cfceb0 |
public readonly List<assistant> assistants = new List<assistant>();</assistant></assistant>
|
|
|
cfceb0 |
public readonly List<activepoint> points = new List<activepoint>();</activepoint></activepoint>
|
|
|
cfceb0 |
public readonly Canvas canvas = new Canvas();
|
|
|
cfceb0 |
|
|
|
cfceb0 |
public ActivePoint ActivePoint = null;
|
|
|
cfceb0 |
|
|
|
cfceb0 |
public ActivePoint findPoint(Point position) {
|
|
|
cfceb0 |
foreach(ActivePoint point in points.Reverse<activepoint>())</activepoint>
|
|
|
cfceb0 |
if (point.isInside(position))
|
|
|
cfceb0 |
return point;
|
|
|
cfceb0 |
return null;
|
|
|
cfceb0 |
}
|
|
|
cfceb0 |
|
|
|
cfceb0 |
public void getGuidelines(List<guideline> outGuidelines, Point target) {</guideline>
|
|
|
cfceb0 |
foreach(Assistant assistant in assistants)
|
|
|
cfceb0 |
assistant.getGuidelines(outGuidelines, target);
|
|
|
cfceb0 |
}
|
|
|
cfceb0 |
|
|
|
cfceb0 |
public void draw(Graphics g, ActivePoint activePoint, Point target, Track track) {
|
|
|
cfceb0 |
// canvas
|
|
|
cfceb0 |
canvas.draw(g);
|
|
|
cfceb0 |
|
|
|
cfceb0 |
// guidelines and track
|
|
|
cfceb0 |
List<guideline> guidelines = new List<guideline>();</guideline></guideline>
|
|
|
cfceb0 |
if (track != null && track.points.Count > 0) {
|
|
|
cfceb0 |
getGuidelines(guidelines, track.points[0]);
|
|
|
e6a405 |
Guideline guideline = Guideline.findBest(guidelines, track);
|
|
|
e6a405 |
Track modifiedTrack = guideline == null
|
|
|
e6a405 |
? track.createChildAndBuild(Geometry.noTransform)
|
|
|
e6a405 |
: track.createChildAndBuild(guideline.transformPoint);
|
|
|
e6a405 |
|
|
|
e6a405 |
if (modifiedTrack.points.Count > 0) {
|
|
|
e6a405 |
guidelines.Clear();
|
|
|
e6a405 |
getGuidelines(guidelines, modifiedTrack.points.Last());
|
|
|
e6a405 |
}
|
|
|
cfceb0 |
foreach(Guideline gl in guidelines)
|
|
|
cfceb0 |
gl.draw(g);
|
|
|
e6a405 |
|
|
|
cfceb0 |
if (guideline != null) {
|
|
|
cfceb0 |
track.draw(g, true);
|
|
|
cfceb0 |
guideline.draw(g, true);
|
|
|
cfceb0 |
}
|
|
|
e6a405 |
modifiedTrack.draw(g);
|
|
|
cfceb0 |
} else {
|
|
|
cfceb0 |
getGuidelines(guidelines, target);
|
|
|
cfceb0 |
foreach(Guideline guideline in guidelines)
|
|
|
cfceb0 |
guideline.draw(g);
|
|
|
cfceb0 |
}
|
|
|
cfceb0 |
|
|
|
cfceb0 |
// assistants
|
|
|
cfceb0 |
foreach(Assistant assistant in assistants)
|
|
|
cfceb0 |
assistant.draw(g);
|
|
|
cfceb0 |
|
|
|
cfceb0 |
// assistant active points
|
|
|
cfceb0 |
foreach(ActivePoint point in points)
|
|
|
cfceb0 |
point.draw(g, activePoint == point);
|
|
|
cfceb0 |
}
|
|
|
cfceb0 |
|
|
|
cfceb0 |
public Track modifyTrack(Track track) {
|
|
|
cfceb0 |
if (track.points.Count < 1)
|
|
|
cfceb0 |
return track;
|
|
|
cfceb0 |
|
|
|
cfceb0 |
List<guideline> guidelines = new List<guideline>();</guideline></guideline>
|
|
|
cfceb0 |
getGuidelines(guidelines, track.points[0]);
|
|
|
cfceb0 |
Guideline guideline = Guideline.findBest(guidelines, track);
|
|
|
cfceb0 |
if (guideline == null)
|
|
|
77c1c7 |
return track.createChildAndBuild(Geometry.noTransform);
|
|
|
cfceb0 |
|
|
|
77c1c7 |
return track.createChildAndBuild(guideline.transformPoint);
|
|
|
cfceb0 |
}
|
|
|
cfceb0 |
|
|
|
cfceb0 |
public void paintTrack(Track track) {
|
|
|
cfceb0 |
canvas.paintTrack( modifyTrack(track) );
|
|
|
cfceb0 |
}
|
|
|
cfceb0 |
}
|
|
|
cfceb0 |
}
|
|
|
cfceb0 |
|