This project is read-only.

Segment and Ray

Jun 4, 2012 at 1:37 AM


I've been looking at the source code for a while now.  I'm interested in creating new types of figures.  I'm looking at how the figures are created to get a better understanding what to do to create a new figure, but I must be missing something.

Take, for example, the ray and the segment.  I think I understand the part about dependencies, and both these figures have the same point, point dependency.  But where is it defined that the segment line ends at the second point and where the ray line continues on?  I would think the segment and ray classes would have that kind of logic, but it doesn't look like it.  

Can someone point me in the right direction? thanks.

Jun 22, 2012 at 8:10 AM

Generally, all you need to define your own figure is the actual figure class, and a corresponding Creator class (that defines which dependencies are required to be entered by the user to fully specify your figure).

Segment, Ray and Line all inherit from LineBase.

LineBase defines a property called OnScreenCoordinates, which returns a PointPair of actual endpoints drawn in the viewport.

The default LineBase implementation is just to return Coordinates (the two dependency points joined together).

However Ray overrides this virtual property with an implementation which uses the first dependency point as is, and extends the second point of OnScreenCoordinates till the edge of the viewport.

Line overrides this virtual property to extend both ends of the line to the edges of the viewport.

The math to extend a line to end at the viewport edge is in Math.GetLineFromSegment().

Hope this helps,