Add pilot canvas support for conic and cubic Bezier sample drawing#683
Add pilot canvas support for conic and cubic Bezier sample drawing#683tigercosmos wants to merge 1 commit intosolvcon:masterfrom
Conversation
|
It makes more sense to reuse
It may be tempting to refactor the existing |
|
And I am interested in a new work flow: use a PR to discuss complex design like this without any git history rewriting. Once the review is done, create a new PR to clean up the git history (using a new branch), add summarizing commit logs and review annotations, and close the discussion PR. This is more logistics but will keep the development course clearer. It's hard to gauge the pros and cons before trying. We may or may not need to do it right now. Let me know what do you think. |
|
@yungyuc I think it’s more efficient to refactor the code while adding new features, since the refactoring is then driven by real needs and we avoid leaving additional technical debt for the future. Regarding your proposed workflow, it sounds similar to keeping the full git history within the PR and then squashing the commits into a single, meaningful summary commit when merging. When using the “Squash and merge” option, we can provide a well-structured commit message (typically prepared by the PR author) to summarize the changes clearly. |
Refactoring and logical/data-structural changes should be separate. Mixing refactoring with other activities makes maintenance more difficult.
We can keep discussing the github workflow while moving forward the development. I agree the two-PR idea is similar to the single-PR-with-final-squash. I dislike "Squash and merge" which does not allow multiple commits with distinct, tailored commit logs. |
2d91fee to
27b5ae9
Compare
8350b07 to
5857897
Compare
5857897 to
8b2756a
Compare
| func=self.mesh_iccad_2013, | ||
| ) | ||
|
|
||
| tip = "Draw a sample S-shaped cubic Bezier curve with control points" |
There was a problem hiding this comment.
New samples are under "Canvas" menu.
|
|
||
| def __init__(self): | ||
| self.world = core.WorldFp64() | ||
| def _populate_sampler_points(curve, npoint=100, fac=1.0, off_x=0.0, |
There was a problem hiding this comment.
Shared by new samples.
|
|
||
|
|
||
| class CanvasMenu(PilotFeature): | ||
| class Canvas(PilotFeature): |
There was a problem hiding this comment.
I thnk it make more senses to keep just Canvas.
| func=self.mesh_iccad_2013, | ||
| ) | ||
|
|
||
| tip = "Draw a sample S-shaped cubic Bezier curve with control points" |
There was a problem hiding this comment.
New items for the followings.
| ) | ||
|
|
||
| @staticmethod | ||
| def _draw_layer(world, layer): |
There was a problem hiding this comment.
only for mesh_iccad_2013.
| widget.updateWorld(world) | ||
| widget.showMark() | ||
|
|
||
| def _bezier_s_curve(self): |
There was a problem hiding this comment.
The drawer of the new sample.
| class Ellipse(object): | ||
| def __init__(self, a=2.0, b=1.0): | ||
| self.a = a | ||
| self.b = b | ||
|
|
||
| def calc_points(self, npoint): | ||
| t_array = np.linspace(0.0, 2.0 * np.pi, npoint + 1, dtype='float64') | ||
| point_pad = core.PointPadFp64(ndim=2, nelem=npoint + 1) | ||
| for index, t_value in enumerate(t_array): | ||
| x_value = self.a * np.cos(t_value) | ||
| y_value = self.b * np.sin(t_value) | ||
| point_pad.set_at(index, x_value, y_value) | ||
| return point_pad | ||
|
|
||
|
|
||
| class EllipseSampler(object): | ||
| def __init__(self, world, ellipse): | ||
| self.world = world | ||
| self.ellipse = ellipse | ||
| self.points = None | ||
|
|
||
| def populate_points(self, npoint=100, fac=1.0, off_x=0.0, off_y=0.0): | ||
| self.points = _populate_sampler_points( | ||
| self.ellipse, npoint=npoint, fac=fac, off_x=off_x, off_y=off_y) | ||
|
|
||
| def draw_cbc(self, spacing=0.01): | ||
| _draw_piecewise_bezier(self.world, self.points, spacing=spacing) |
There was a problem hiding this comment.
Same pattern from Naca4Sampler.
Add pilot canvas drawing utilities for conic curves and cubic Bezier examples, and expose them through the GUI sample menu. - add `modmesh.pilot._canvas` with `Canvas`/`CanvasMenu` - implement `Ellipse`, `Parabola`, and `Hyperbola` samplers - add shared piecewise cubic Bezier rendering with input validation - add `BezierSample` presets and `BezierSampler` with control overlays - wire `_canvas` imports in pilot initialization - add `tests/test_pilot_canvas.py` for geometry generation, draw paths, and expected error cases
| @@ -0,0 +1,212 @@ | |||
| # Copyright (c) 2026, Anchi Liu <phy.tiger@gmail.com> | |||
There was a problem hiding this comment.
All cases are AI genereated with manual checks and fine-tuning.
8b2756a to
2eb3365
Compare
|
@yungyuc Could you please help review the PR? Thank you. |
Summary
Add pilot canvas support for conic and cubic Bezier sample drawing, and cover the new functionality with unit tests.
What changed
modmesh.pilot._canvas:Canvas+CanvasMenuintegration for pilot sample windowsEllipse/EllipseSamplerParabola/ParabolaSamplerHyperbola/HyperbolaSamplerBezierSamplepresets (s_curve,arch,loop)BezierSamplerwith control polygon and control-point rendering_canvasimports in pilot package/gui initialization so canvas menuitems are available in the GUI.
tests/test_pilot_canvas.pycovering:npoint, closure, extrema/vertex, branch checks)Validation
python3 -m pytest tests/test_pilot_canvas.pyDemo
AI Usage
Related to #682