JamesBremner / DXF_Viewer

A simple DXF File viewer
MIT License
22 stars 4 forks source link

Add support for drawing spline line with control points #2

Closed asmwarrior closed 5 years ago

asmwarrior commented 5 years ago

Hi, from your source code, I see you just skip the spline with control points. You only support the spline with fitpoints. So, my question is: can you support the spline with control points.

Under wxWidgets, I see there is a function named: DrawSpline, which you only need to supply all the points of the spline, you can have a look at this sample code from: Device contexts in wxWidgets, the last image of this page shows a spline.

Any suggestions? Thanks.

JamesBremner commented 5 years ago

The documentation for the wxWidgets DrawSpline method ( https://docs.wxwidgets.org/3.0/classwx_d_c.html#ad72d38c75ac6b3f80c1f957dd94089fa ) says:

Draws a spline between all given points using the current pen.

This suggests to me that it uses fit points. What makes you think it uses control points? Have you tried it?

asmwarrior commented 5 years ago

Hi, I already tested it by using the code snippet(the last code snippet in that web page) I mentioned in my first post: Device contexts in wxWidgets

    dc.DrawSpline(4, splines);
    dc.SetPen(wxPen(*wxBLUE, 5, wxSOLID));
    for (int i = 0; i<4; i++)
    {
        dc.DrawLine(splines[i].x, splines[i].y,splines[i].x, splines[i].y);
    }

You can see the spline is not go through the second and third points. So, my conclution is that the wxWidgets' DrawSpline method is using the control point.

asmwarrior commented 5 years ago

Oh, I just notice that you have pushed new code Display control point splines as simplified "linear" Beziers to implement this feature.

asmwarrior commented 5 years ago

Tested, and it works fine! Great! I think this issue(feature request) is implemented. Thanks.