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

Images can be saved, undo & redo is working #1160

Merged
merged 14 commits into from
Aug 19, 2024
Merged

Images can be saved, undo & redo is working #1160

merged 14 commits into from
Aug 19, 2024

Conversation

Onetchou
Copy link
Contributor

Fixes #1100
Fixes #1098

@Onetchou Onetchou marked this pull request as ready for review July 31, 2024 12:11
@Onetchou Onetchou requested a review from DSCaskey July 31, 2024 12:11
@Onetchou
Copy link
Contributor Author

Since this PR is quite big and adds a lot of things it would be great if someone else than me could also test it to check if there's no unexpected crashes of the software in random situations 😉.

Copy link
Contributor

@DSCaskey DSCaskey left a comment

Choose a reason for hiding this comment

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

, m_isHovered(false)
, m_coloredHandles(false)

I get the desire to change the flag variable name, but it makes no sense. For one it doesn't match the condition that you're testing for... that is are you in a hover event? Secondly the handles are always colored... they're either darkgrey or red. Thirdly isHovered is used in all the other tools, so now we're breaking continutity by renaming this flag. 

I think what I would do, since that's the condition we're really checking, is name this flag something like m_handleIsHighlighted so that

if (m_handleIsHighlighted){} ... reads better than if (isHovered){}

Then to be consistent I would then also address the other isHovered's at some point like:

m_imageIsHighlighted, m_lineIsHighlighted, m_scenePointIsHighlighted, etc...

@DSCaskey
Copy link
Contributor

DSCaskey commented Aug 6, 2024

There's several issues I found if loading a pattern or redo'ng and an image file is deleted while working - not likely to happen, but possible. First is the dialog that pops up tells the user the file can not be read and it may be corrupt. This is not the case, but rather the file is missing Big difference.

Screenshot 2024-07-31 222704

The big issue is that the after you click OK, the app crashes. When reading, or redo'ing, need to check if the file exists before continuing... if NOT we need a new Error message box stating the file is not found... along the lines like not finding a measurement file when loading a pattern. A bonus would be the option to "find" a / the file. Again, along the lines of finding a missing measurement file.

@DSCaskey
Copy link
Contributor

DSCaskey commented Aug 9, 2024

const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.0");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.0.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.0");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.0.xsd");

Is there a reason we went from 0.7.0 to 0.8.0 and skipped all the schemas in between?

For consistency, the next locical bump in schema should be v0.7.1.xsd.

@Onetchou
Copy link
Contributor Author

Onetchou commented Aug 9, 2024

I get the desire to change the flag variable name, but it makes no sense. For one it doesn't match the condition that you're testing for... that is are you in a hover event? [...] Thirdly isHovered is used in all the other tools, so now we're breaking continutity by renaming this flag.

I changed the name of the flag because I added a condition that is not related to a hover event:

image

You can be over the handle but if you unclick it will unset the flag, even if it's still hovered...

Secondly the handles are always colored... they're either darkgrey or red.
I think what I would do, since that's the condition we're really checking, is name this flag something like m_handleIsHighlighted

😆 ok I'll change it if you want, no problem. But I don't think this is really a problem since it's quite understandable I think. Because if we want to use proper scientific definitions everywhere, one could argue that black is not a color and we'll have a lot of things to change in the software to correct this 😉

Then to be consistent I would then also address the other isHovered's at some point like:

m_imageIsHighlighted, m_lineIsHighlighted, m_scenePointIsHighlighted, etc...

I think that isHovered is perfectly fine everywhere else. I changed it here only because I changed the behavior of the flag: it doesn't reflect anymore the fact that the handle is hovered or not.

@Onetchou
Copy link
Contributor Author

Onetchou commented Aug 9, 2024

There's several issues I found if loading a pattern or redo'ng and an image file is deleted while working - not likely to happen, but possible. First is the dialog that pops up tells the user the file can not be read and it may be corrupt. This is not the case, but rather the file is missing Big difference.

Screenshot 2024-07-31 222704

The big issue is that the after you click OK, the app crashes. When reading, or redo'ing, need to check if the file exists before continuing... if NOT we need a new Error message box stating the file is not found... along the lines like not finding a measurement file when loading a pattern.

I was so focused to make the undo and redo work that I completely forgot to address the cases where the file is missing: I'll take a look at it, thanks for noticing it!

A bonus would be the option to "find" a / the file. Again, along the lines of finding a missing measurement file.

Yes, great idea, I'll implement it.

@Onetchou
Copy link
Contributor Author

Onetchou commented Aug 9, 2024

Is there a reason we went from 0.7.0 to 0.8.0 and skipped all the schemas in between?

Because I thought it was a major change since new items are added, this is not only new attributes of existing items:

image

@DSCaskey
Copy link
Contributor

DSCaskey commented Aug 10, 2024

You can be over the handle but if you unclick it will unset the flag, even if it's still hovered...

But the handles are always colored like I said. m_coloredHandles = false implies the handles are no longer colored. BTW... using "m_coloredHandles" implies you're coloring the handles NOT just this handle.

I think that isHovered is perfectly fine everywhere else. I changed it here only because I changed the behavior of the flag: it doesn't reflect anymore the fact that the handle is hovered or not.

Again, the condition that you're checking is whether to highlight the handle Red or not... which was my point of m_handleIsHighlighted. If it makes more sense... you could use m_highlightedHandle. Either one in English indicates the handle is highlighted... semantically different than coloredHandles or handlesAreColored. Yes, a highlighted handle is colored, but not every colored handle is highlighted. If you wanted to use m_redColoredHandle... then you'd be more correct, but still miss the WHY it's red.

painter->setBrush(m_highlightedHandle ? QColor(Qt::red) : QColor(Qt::darkGray));

Because I thought it was a major change since new items are added, this is not only new attributes of existing items:

Fair enough. I don't know why that's even there. Seems like it applies more to a build version, not a schema. The schema has nothing directly to do with a release. We could build a 1000 releases and patches without ever changing the schema. I suspect that RT just cut and pasted code from somewhere else not understanding the comments are not applicable in the case of the schemas. In fact the schema could have just as well been coded as a single digit, and it would have been easier. Like v001.xsd, v002.xsd... v100.xsd. If there is harder way to do things, that's what RT does.

That being said if it's not that big a hassle I'd like to see this schema as v0.7.1.xsd just so down the line someone else does wonder what happened to v0.7.1.xsd to v0.7.9.xsd... or worse try to use one of them.

@Onetchou
Copy link
Contributor Author

Onetchou commented Aug 17, 2024

Another error to solve (memo for myself):
New pattern > Add image > Undo > Redo > Add a point (endline tool) >
image

@Onetchou
Copy link
Contributor Author

When reading, or redo'ing, need to check if the file exists before continuing... if NOT we need a new Error message box stating the file is not found... along the lines like not finding a measurement file when loading a pattern. A bonus would be the option to "find" a / the file. Again, along the lines of finding a missing measurement file.

Done 👌

image

I think what I would do, since that's the condition we're really checking, is name this flag something like m_handleIsHighlighted

Done 👌

That being said if it's not that big a hassle I'd like to see this schema as v0.7.1.xsd just so down the line someone else does wonder what happened to v0.7.1.xsd to v0.7.9.xsd... or worse try to use one of them.

Done 👌

😊

@DSCaskey DSCaskey marked this pull request as ready for review August 19, 2024 21:22
Copy link
Contributor

@DSCaskey DSCaskey 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 to me.

Signed-off-by: DSCaskey <31944718+DSCaskey@users.noreply.github.com>
@DSCaskey DSCaskey merged commit 79ef650 into develop Aug 19, 2024
10 checks passed
@DSCaskey DSCaskey deleted the save-images branch August 19, 2024 21:42
@Onetchou
Copy link
Contributor Author

Onetchou commented Aug 20, 2024

@DSCaskey I've set this PR as a "draft PR", because it was not ready to be merged, there's still this important issue to be solved :

Another error to solve (memo for myself):
New pattern > Add image > Undo > Redo > Add a point (endline tool) >
image

Onetchou added a commit that referenced this pull request Sep 1, 2024
It has been inadvertantly squashed instead of rebase.

This reverts commit 79ef650.
Onetchou added a commit that referenced this pull request Sep 1, 2024
Revert the inadvertant squash.
This reverts commit 79ef650.
Onetchou added a commit that referenced this pull request Sep 3, 2024
Revert the inadvertant squash.
This reverts commit 79ef650.
Onetchou added a commit that referenced this pull request Sep 3, 2024
Revert the inadvertant squash.
This reverts commit 79ef650.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Saving background images Feature: Enable Undo and Redo for images
2 participants