-
Notifications
You must be signed in to change notification settings - Fork 55
Add ICCAD-2013 sample #666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
0dfbf91 to
72a9233
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start. Points to address:
- Avoid and remove Python type annotation.
- Remove
_fp64p(). -
Use real number format (e.g., 70.0) for the coordinates. - Data and logic should be separated. Make data a string and logic in a helper class.
modmesh/pilot/_mesh.py
Outdated
|
|
||
| return spad | ||
|
|
||
| def poly_spad(coords: list[tuple[int, int]]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use type annotation in modmesh. Keep Python dynamic. When types are needed, do it in C++.
modmesh/pilot/_mesh.py
Outdated
| def mesh_iccad_2013(self): | ||
| world = core.WorldFp64() | ||
|
|
||
| def _fp64p(x, y): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove _fp64p(). It is redundant. Just use Point3dFp64 constructor. If the class name is too long to you, use a local alias.
modmesh/pilot/_mesh.py
Outdated
|
|
||
| return spad | ||
|
|
||
| world.add_segments(pad=rect_spad(70, 800, 180, 40)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use real number format (e.g., 70.0) for the coordinates.
modmesh/pilot/_mesh.py
Outdated
| self._pycon.writeToHistory(f"tri nedge: {mh.nedge}\n") | ||
|
|
||
| def mesh_iccad_2013(self): | ||
| world = core.WorldFp64() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data and logic should be separated. Make data a string and logic in a helper class.
cf3a3ef to
7dd7fc4
Compare
|
Hi, @yungyuc. I already fix all comment: I create a helper class named def mesh_iccad_2013(self):
mesh = iccad_2013.ICCAD2013Mesh()
mesh.add_item("RECT N M1 70 800 180 40")
mesh.add_item(
"PGON N M1 70 720 410 720 410 920 70 920 70 880 370 880 370 760 70 760"
)
mesh.add_item("RECT N M1 70 1060 180 40")
mesh.add_item(
"PGON N M1 70 980 410 980 410 1180 70 1180 70 1140 370 1140 370 1020 70 1020"
)
wid = self._mgr.add3DWidget()
wid.updateWorld(mesh.get_world())
wid.showMark()
|
7dd7fc4 to
fcf722b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Points to address:
- Rename
iccad_2013toplain_layer, and the class namePlaneLayer. - Move
plane_layerto be undermodmesh.plot. - Move the GUI code to a new sub-module
modmesh._canvas. - Use a separate PR to maintain dot files.
- Rename
_rect_spad()toadd_rectangle()(drop leading underscore). - Rename
_polygon_spad()toadd_polygon()(drop leading underscore). - Rename
add_item()toadd_figure().
| @@ -0,0 +1,33 @@ | |||
| # Copyright (c) 2026, Han-Xuan Huang <c1ydehhx@gmail.com> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (iccad_2013) is a horrible name for a graphical data processor. Name it more generic. I propose to name the module as plain_layer, and use PlaneLayer as the class name. "Plane" implies the two dimension.
The module should be moved under modmesh.plot, which has nothing to do with GUI.
Also read the code under cpp/modmesh/universe, which is the graphical C++ code that @tigercosmos is working on.
.gitignore
Outdated
| *.pdb | ||
| *.env | ||
| profiling/results/ | ||
| .cache No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not change dot files when adding feature. Use a separate PR to maintain dot files.
modmesh/pilot/_mesh.py
Outdated
|
|
||
| from .. import core | ||
| from ._gui_common import PilotFeature | ||
| from . import iccad_2013 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a new module for drawing exclusively 2D graphics. I propose to name it modmesh._canvas (we may change it in the future).
| def __init__(self): | ||
| self.world = core.WorldFp64() | ||
|
|
||
| def _rect_spad(self, x, y, w, h): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename _rect_spad() to add_rectangle().
|
|
||
| return spad | ||
|
|
||
| def _poly_spad(self, coords): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename _polygon_spad() to add_polygon().
|
|
||
| return spad | ||
|
|
||
| def add_item(self, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename add_item() to add_figure().
82f11b5 to
46d7b44
Compare
|
Hi @yungyuc. I already fix the issue in comment. I create I still need to add some tests for these class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some points were not addressed. New points to address:
- Do not add
Layer. It is not a necessary abstraction. - The code for GUI should also be moved in
_canvas.py.
modmesh/plot/plane_layer.py
Outdated
| from abc import ABC | ||
|
|
||
|
|
||
| class Layer(ABC): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not add Layer. It is not a necessary abstraction.
And I do not want to have a class of such a short name.
modmesh/pilot/_mesh.py
Outdated
| func=self.mesh_3dmix, | ||
| ) | ||
|
|
||
| self._add_menu_item( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code to great GUI should also be moved in _canvas.py. You may also need a new menu.
|
I fixed all issues. @yungyuc I create canva menu that can render ICCAD example.
and I remove abstract class. Please review it, thanks. |
yungyuc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point to address:
-
_canvasshould be before_profiling.
| from . import _svg_gui | ||
| from . import _linear_wave | ||
| from . import _profiling | ||
| from . import _canvas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_canvas should be before _profiling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks for the notice.
8c3b971 to
7d93610
Compare
7d93610 to
4236eb7
Compare
|
@c1ydehhx leave a global comment to notify when it's ready for the next review. |
|
@c1ydehhx update? |
|
Hi @yungyuc. I already fix the issue in comment. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yungyuc. I already fix the issue in comment. Thanks.
No, you didn't. Please review the code carefully and update.
And please rebase to the latest, squash the commits, and write a concise summary in the commit log.
| } | ||
| m_oneMenu = m_mainWindow->menuBar()->addMenu(QString("One")); | ||
| m_meshMenu = m_mainWindow->menuBar()->addMenu(QString("Mesh")); | ||
| m_canvaMenu = m_mainWindow->menuBar()->addMenu(QString("Canva")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a typo. The name should be canvas, not canva.
| QMenu * oneMenu() { return m_oneMenu; } | ||
| QMenu * meshMenu() { return m_meshMenu; } | ||
| QMenu * profilingMenu() { return m_profilingMenu; } | ||
| QMenu * canvaMenu() { return m_canvaMenu; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This canvasMenu should use the same order to be placed before profilingMenu.


In this PR, I added the mesh sample that draw the example in ICCAD-2013 CAD Contest paper. The result looks like this: