Skip to content

autoinvert feature improvements#245

Merged
gr5 merged 11 commits intomasterfrom
gr5
Oct 16, 2025
Merged

autoinvert feature improvements#245
gr5 merged 11 commits intomasterfrom
gr5

Conversation

@gr5
Copy link
Collaborator

@gr5 gr5 commented Sep 27, 2025

This adds a feature requested by Yordan and fixes issue #167

Dale and I discussed and settled on the GUI implementation in this PR.

I apologize for 2 things:

  1. Mixed ways of doing braces. Some were autogenerated by QT (like the "on_" functions). Some were copy paste. Some I wrote and I'm very comfortable with either method so I usually just scroll up a bit and copy whatever already exists. A result of all that is a messy mixture of both styles.

  2. "on_" functions: QT automatically generated these slots and signals. This was done 3 months ago -- before Julien fixed all the slots and signals. I'm not sure how to do it the right way or if QT did it the right way or not. I can say there were no compiler warnings but I think the slot/signals warnings are not from the compiler but from clang and I don't know how to run that other than through the "actions" when I do a PR.

gr5 added 5 commits June 23, 2025 08:23
know when to invert the wavefront.

This is version in my video explaining my ideas.  I need to fix
a few things still.  work in progress.
Removed the code where I had "invert" button change the autoinvert status
Changed wording a little in the auto invert dialog
Spaced things out in the auto invert dialog for people with >100% scaling
Tested at 225% scaling
Fixed project files to include the new autoinvert dialog
Disable the "conic" button if cc=0.  If user changes cc to zero within
the mirror config and clicks "ok" and if it's in conic mode it switches
to "not set" mode.
I realized "Your wavefront may be inverted" is inappropriate when running
the dialog from the mirror config screen so that text changes depending how
you got there.
fixed a compiler warning, fixed other minor stuff.
@gr5 gr5 requested review from atsju and githubdoe September 27, 2025 15:54
@gr5
Copy link
Collaborator Author

gr5 commented Sep 27, 2025

Does not compile on linux and qt5 so I'll look into that.

@gr5 gr5 changed the title Gr5 autoinvert feature improvements Sep 28, 2025
@gr5
Copy link
Collaborator Author

gr5 commented Sep 28, 2025

Compiles just fine now. Ready for review. Again - I had edited 2 of the project files (".pro"), but missed the 3rd one (newest one).

Copy link
Collaborator

@atsju atsju left a comment

Choose a reason for hiding this comment

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

Code looks good. I have not tested to see how it looks (and do not plan to do it).

I have noticed some minor things to improve and personally I would remove the singleton design pattern.

Comment on lines 15 to 19
explicit autoInvertDlg(QWidget *parent = nullptr);
~autoInvertDlg();
static autoInvertDlg *get_Instance();
void setMainLabel(const QString & str);
void enableConic(bool b);
Copy link
Collaborator

Choose a reason for hiding this comment

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

if implementing singleton: need to delete copy constructor and operator

    autoInvertDlg(autoInvertDlg const&) = delete;
    autoInvertDlg& operator=(autoInvertDlg const&) = delete;

Comment on lines 17 to 20
autoInvertDlg *autoInvertDlg::get_Instance(){
static autoInvertDlg m_Instance{};
return &m_Instance;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would have preferred not to use singleton design pattern but this implementation is good.

EDIT: After reviewing all caode and trying to understand the architecture, I see 2 singletons getting each other while autoinvertdlg is only here to manage SurfaceManager->m_inverseMode. Who own who and make what is unclear.
My recommendation:

  • do not use singleton (autoInvertDlg does not need to live or be kept when the dialog is closed. Only reason i see is updateAutoInvertStatus but if you call it at construction and when needed, then I think you are all set).
  • You might pass a reference to sm->m_inverseMode to the constructor of the dialog and it won't need to get surfaceManager instance.

I thing this is a good illustration of why to avoid singleton. It makes the architecture more of a spaghetti code. Easy to write but more difficult to maintain and to keep different things separate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did your first recommendation (next commit; soon) as you are right: there is absolutely no need to make a singleton. The dialog is now created when needed and destroyed immediately after. Code is cleaner, simpler, smaller.

I didn't do the second suggestion. surface manager is already a singleton - might as well just use it the same way it is used everywhere else. No need to pass in a pointer to the surface manager class.

gr5 and others added 4 commits October 11, 2025 19:36
Co-authored-by: Julien Staub <atsju2@yahoo.fr>
Co-authored-by: Julien Staub <atsju2@yahoo.fr>
Co-authored-by: Julien Staub <atsju2@yahoo.fr>
Code is a little simpler, smaller.
@atsju atsju self-requested a review October 16, 2025 12:44
Copy link
Collaborator

@atsju atsju left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you for the modifications

mirrordlg.h Outdated
QTimer spacingChangeTimer;
void saveJson(const QString &fileName);
void enableAnnular(bool enable);
autoInvertDlg *m_autoInvertDlg;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
autoInvertDlg *m_autoInvertDlg;

Copy link
Collaborator

Choose a reason for hiding this comment

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

@gr5
Copy link
Collaborator Author

gr5 commented Oct 16, 2025

@atsju Please approve if... you approve. 😄

Dale has already approved the gist. We had some back and forth emails a few weeks ago. I don't feel he needs to do a review. I think this can be merged if you are okay with it.

@atsju
Copy link
Collaborator

atsju commented Oct 16, 2025

I didn't "approve" because of the last unused variable but was fine with general code.
I pushed the change. Please wait for automated build before merging.

@gr5
Copy link
Collaborator Author

gr5 commented Oct 16, 2025

There's an unused variable? I missed that but it doesn't sound critical since you've already approved.

@atsju
Copy link
Collaborator

atsju commented Oct 16, 2025

You probably missed my comment (just under the review, it's masked now, I unmasked it)
I committed in 7d10a47

@gr5 gr5 merged commit 38e95ad into master Oct 16, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments