Skip to content
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

Core datums : Card2 : Core implementation #18126

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

PaddleStroke
Copy link
Contributor

@PaddleStroke PaddleStroke commented Nov 25, 2024

Part 2 of #16675

These are the changes to Core :

  • Change the Origin object and origin features into LocalCoordinateSytem and Datum features: rename and separate LCS and Origin. Origin becomes LCS with identity placement enforced. But this PR does not offer any UI to create the new LCS.
  • Changes the visuals of origin objects: Apply the changes asked by the DWG to fix several issues.

Note : no UI to create the new LCS objects. Only visible change is the origin appearance.
Note 2 : NO fix of the X axis orientation. So no migration script here.

Fix #16966
fix #17199
fix #9391
fix #15746

Thanks @3x380V for rebasing and fixing the commits!

@PaddleStroke
Copy link
Contributor Author

@chennes this one is the big part for Core. After this merges I can prepare second part for Part module.

@github-actions github-actions bot added Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD Mod: FEM Related to the FEM Workbench Mod: Part Design Related to the Part Design Workbench Mod: Part Related to the Part Workbench Mod: Sketcher Related to the Sketcher Workbench Mod: Test Related to the Test Workbench labels Nov 25, 2024
@3x380V
Copy link
Contributor

3x380V commented Nov 25, 2024

Comments from #16675 apply here as well. Also that svg change from Card1 should be probably dropped from here. I can fix that, if there is a will to take changes back.

@3x380V
Copy link
Contributor

3x380V commented Nov 25, 2024

@PaddleStroke, here is this PR cleaned up: https://github.com/3x380V/FreeCAD/tree/core_LCS2_

@PaddleStroke
Copy link
Contributor Author

@3x380V you mean this card2 or the initial PR? In your link it is 36 commits so it looks like the initial commit

@3x380V
Copy link
Contributor

3x380V commented Nov 25, 2024

@3x380V you mean this card2 or the initial PR? In your link it is 36 commits so it looks like the initial commit

This card2. You need to pull your main as I rebased it against latest and greatest. Alternatively you can see here individual commits: https://github.com/3x380V/FreeCAD/commits/core_LCS2_/ and I guess you can fetch them from there.

@3x380V
Copy link
Contributor

3x380V commented Nov 25, 2024

Test failing. I must have missed some necessary things.

Changing rotation in LocalCoordinateSystem::getSetupData() (commit "Core: Datums: Fix axis placement and add migration script.") makes that test fail. Test passes without that change. Not saying this is the culprit, but perhaps it rings the bell.

@3x380V
Copy link
Contributor

3x380V commented Nov 26, 2024

I'm not sure about the advantage of splitting this PR in several parts. They still look big and hard to review and I fail to see the point.

There is no advantage. Review is per commit (doing single well defined thing), so there is no limit on commit count. However each commit have to build and pass tests. Failing to comply with this rule causes trouble when bisecting. No need to worry about that only in case everyone does perfect job, so there is no need to hunt bugs by bisecting.

It feels to me more like a cosmetic/feel-better-because-we-did-something solution.

Indeed. However in this particular case it revealed breaking above rule. Being random contributor without any influence on the process I opted to repeat this argument over and over until someone responsible either get that into his head or provide counterargument ;-)

@PaddleStroke
Copy link
Contributor Author

You are right. I'm working on the commits then to untangle all of it.

@PaddleStroke PaddleStroke force-pushed the core_LCS2 branch 2 times, most recently from 8eeaf5a to f82c9b8 Compare November 26, 2024 09:23
@PaddleStroke
Copy link
Contributor Author

Commits cleaned. This is now ready @chennes

@3x380V
Copy link
Contributor

3x380V commented Nov 26, 2024

@PaddleStroke, I beg to differ.You ignored my cleanups :) I started fixing that after your force-push, but... Are you willing to use them?

@PaddleStroke
Copy link
Contributor Author

Can you please tell me specifically what you did? I wasn't sure how to compare. And there were some things to fix in the commits to make all commits build.

@3x380V
Copy link
Contributor

3x380V commented Nov 26, 2024

I made sure clang-format will left your work untouched after enabled on App, fixed some else after returns, optimized few functions.
git difftool -y core_LCS2_..core_LCS2 --no-merges could be used to see changes. I'm convinced it is worth merging that cleanup, so please give me some time to go over your latest changes.

@PaddleStroke
Copy link
Contributor Author

@3x380V ok thanks. Then please let me know the fixes you do and how I can apply them (Consider that I'm a bit of a noob in git, I mostly know rebasing and cherry-picking).

@3x380V
Copy link
Contributor

3x380V commented Nov 26, 2024

@PaddleStroke, I cannot attach patch (this is known issue), so you need a little work (or you can donwload it as text file core_LCS2.txt)
Pull my branch core_LCS2_ from https://github.com/3x380V/FreeCAD/tree/core_LCS2_ Now assuming both your and mine branch is rebased against the same base commit, you are ready to run git diff -w core_LCS2..core_LCS2_. White space changes are ignored to make patch more readable. If you are happy with changes made, just rename it to core_LCS2 (first rename your core_LCS2 to something else in case you'll need it later) and force push.

Most changes are to make clang-format happy for src/App, a bit of commit messages polishing, moving Datums.h guard changes to the first commit (where it belongs), no else after return, few optimizations.

@PaddleStroke
Copy link
Contributor Author

no else after return

That certainly sounds like a problem. Can you point it to me so I can check there's nothing amiss?

Datums.h guard

I moved those.

Then there's clang-format which I have not done. And which is not perfect as a result of the rebase.

@3x380V
Copy link
Contributor

3x380V commented Nov 26, 2024

Then there's clang-format which I have not done. And which is not perfect as a result of the rebase.

That's why I'm proposing you just replace commits with those ready to go and save yourself great amount of time. I had to resolve many conflicts before getting there, so there is no point to repeat it yourself.

@PaddleStroke PaddleStroke reopened this Nov 26, 2024
@PaddleStroke
Copy link
Contributor Author

@3x380V I have removed my commits, then merged your pull request to core_LCS2. So the 5 commits here are now yours. Can you please double check? Btw did you compile your version and checked if it was correct?
Thanks

@3x380V
Copy link
Contributor

3x380V commented Nov 26, 2024

git diff core_LCS2..core_LCS2_ is now empty, so it is single checked, but I consider it bullet proof enough.
This version was compiled and tested using FreeCADCmd -t 0 with all test passed.

@PaddleStroke
Copy link
Contributor Author

Ok. I'm compiling to check if everything still works as it should. Then it's ready to go in right @3x380V ?

@3x380V
Copy link
Contributor

3x380V commented Nov 26, 2024

Yes. Otherwise I cannot read diffs carefully enough and need holidays :)

Copy link
Member

@chennes chennes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a review of 3deec98 -- I think I restricted my comments only to changes lines, but I probably marked a few things that are really from the original, copied, code.


DatumElement::DatumElement()
DatumElement::DatumElement(bool hideRole)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean blindness

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to change this? It's a single argument it's not like it's problematic. I don't really understand this boolean blindness anyway. Unless someone is editing source code with notepad, the IDE let you see the signature of the function easily enough.

I think rejecting any use of boolean is a bit drastic. Searching for "(bool " in the source code gives 1510 results. If for each of those function we implemented a enum class, imagine the mess that would be.

If you still want me to take action please advise your prefered replacement solution. Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PaddleStroke, when editing your commits, please run clang-format -i src/App/whatever.cpp for files in App directory to be sure they still conform.
(as someone who is editing code with Vim, I'm not big fan of declaring enum for sole purpose of boolean blindness idiom)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these review suggestions are that: suggestions. @wwmayer first introduced me to the modern notion of "boolean blindness", and at the call site I do find it is easier to read calls that don't have booleans in them. With just a single argument the benefit of switching to an enumeration is marginal (at best), but I am happy to defer to @wwmayer here about whether in these cases we should indeed require a new enumeration.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that making an enum just to replace a boolean parameter is not ideal. Better to look at the root cause of the problem: the boolean parameter is causing the functions to do two different things (two responsibilities) -- maybe there actually should be two functions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these review suggestions are that: suggestions

How does one tell the difference between a "suggestion" and something that will prevent merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking about it, I think this boolean can be removed and replaced by a function 'hideRole'. Then this function can be called after the initialization.
However as this boolean is not used in this PR (it will be in next PR implementing the Part subclasses of those datums) I ask that we leave this as it is now as to not create more conflicts. And I'll replace this bool in this next PR.

src/App/Datums.cpp Show resolved Hide resolved
src/App/Datums.cpp Show resolved Hide resolved
src/App/Datums.cpp Outdated Show resolved Hide resolved
src/App/Datums.cpp Outdated Show resolved Hide resolved
src/Gui/ViewProviderDatum.cpp Show resolved Hide resolved
src/Gui/ViewProviderDatum.cpp Show resolved Hide resolved
src/Gui/ViewProviderOrigin.cpp Show resolved Hide resolved
src/Gui/ViewProviderPoint.cpp Outdated Show resolved Hide resolved
src/Gui/ViewProviderPoint.h Outdated Show resolved Hide resolved
Most of App::Origin is moved into this sub class of App::Origin.
Add App::Point. Change graphics of the planes/axis.
Remove scale-by-content behavior and make it fixed size on screen.
@PaddleStroke
Copy link
Contributor Author

Build and confirm it works as it should. The style of the origin objects is changed and the point is added. That's all.

@3x380V
Copy link
Contributor

3x380V commented Nov 26, 2024

@PaddleStroke, glad it worked. Do you want any help with the rest of changes once this PR is sorted out?

@PaddleStroke
Copy link
Contributor Author

I think the rest should be fine. The commit history is better and I think there won't be any conflicts. So I think it will be ok. I'll let you know if I struggle ;)
Thanks for the help here

@chennes chennes requested a review from wwmayer November 26, 2024 17:39
@3x380V
Copy link
Contributor

3x380V commented Nov 27, 2024

How does just added Assembly: Simulation implementation relate to this PR? Was it in intentional?

@PaddleStroke
Copy link
Contributor Author

PaddleStroke commented Nov 27, 2024

It was a mistake. I dropped it and force pushed but the commit is still here in this PR. I do not know why.
Looking at the ondsel branch, the commit is indeed gone. But here in the PR the commit is still here.

Edit: rewording last commit and pushing again solved the issue.

@PaddleStroke
Copy link
Contributor Author

PaddleStroke commented Nov 28, 2024

@wwmayer could you please tell if you intend to check this at some point? A 'no' or 'yes later' are perfectly acceptable and would be better than silence so that we know and don't wait for nothing. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD Mod: FEM Related to the FEM Workbench Mod: Part Design Related to the Part Design Workbench Mod: Part Related to the Part Workbench Mod: Sketcher Related to the Sketcher Workbench Mod: Test Related to the Test Workbench
Projects
None yet
4 participants